-
Notifications
You must be signed in to change notification settings - Fork 2
Add onFinishSigning prop & upgrade all minor version deps #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
||
// parse query params into an object | ||
const searchStr = data.split('?')[1] | ||
const searchObj = JSON.parse('{"' + decodeURI(searchStr).replace(/"/g, '\\"').replace(/&/g, '","').replace(/=/g, '":"') + '"}') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'd do 2 things here that feel a little safer
- Use
URLSearchParams
if it exists. You can do something likeif (typeof URLSearchParams !== 'undefined') {...}
then use it - Fallback to what you have. It also feels safer to decodeURI on each value component after you have the object, since often URLs will have their non-alpha characters encoded like
%20
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, IE doesnt support URLSearchParams, so IE users would fallback to the json parse
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implemented
const searchStr = data.split('?')[1] | ||
const searchObj = JSON.parse('{"' + decodeURI(searchStr).replace(/"/g, '\\"').replace(/&/g, '","').replace(/=/g, '":"') + '"}') | ||
const { signerStatus, signerEid, nextSignerEid, documentGroupStatus, documentGroupEid, etchPacketEid, weldDataEid } = searchObj | ||
this.props.onFinishSigning({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also make sure there is no error
or errorType
in the searchObj
before calling this? This callback should only be called on signer success. I'll add an error handler mirroring this in the next pass
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
"@babel/plugin-proposal-class-properties": "^7.12.1", | ||
"@babel/preset-env": "^7.12.1", | ||
"@babel/preset-react": "^7.12.5", | ||
"@babel/core": "^7.15.8", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yay for upgraded deps!
@@ -53,14 +53,27 @@ Example: | |||
onLoad={() => setLoading(false)} | |||
``` | |||
|
|||
#### onFinish |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should keep onFinish
in the docs, but say it is deprecated as people are still using it. I'd also remove the redirect bits from the example, and maybe just log it as an example
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left onFinish
in docs and noted as deprecated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think just need to address the error case on URLSearchParams, but other than that, good to go
} | ||
} | ||
|
||
if (!searchObj.error && !searchObj.errorType) this.props.onFinishSigning(payload) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this work in the URLSearchParams case? Or would it need to call .get()
? Would it make more sense to put those things into the payload?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, would need to call .get()
. Good catch. Fixed!
Tested the new components with |
https://www.npmjs.com/package/@anvilco/react-signature-frame |
Description of the change
Add
onFinishSigning
as a prop ofAnvilSignatureFrame
that calls after signing.Very similar to the
onFinish
func prop, except it takes apayload
as input instead of theredirectURL
.The
payload
is constructed fromredirectURL
query params.Updated docs with
onFinishSigning
and removedonFinish
.Example:
Also bumped minor versions for dependencies, seeing a lot of vulnerabilities: https://github.com/anvilco/react-ui/security/dependabot
Type of change
Related issues
Fixes anvilco/anvil#2733
Dev Checklist