Constructor
# new ZippieSign(props)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
props |
ZippieSignProps
|
Component properties |
|
acceptLabel |
string
|
<optional> |
Accept label text |
onAuthorized |
onAuthorizedCallback
|
<optional> |
Callback when the identity has signed the subject. |
onError |
onErrorCallback
|
<optional> |
Callback if there was an error during the signing process. |
onRejected |
onRejectedCallback
|
<optional> |
Callback if the user rejected the signing process. |
rejectLabel |
string
|
<optional> |
Reject label text |
subject |
SignSubject.<any>
|
Subject to use identity to sign |
Example
import { ZippieSign } from '@zippie/did-react-components'
export const SignComponent = () => {
// We store the signed object in this state variable
const [result, setResult] = useState<ECSignature>()
// This is the object that we will be signing.
const objectToSign = {
timestamp: (new Date().getTime() / 1000),
message: 'This is some custom JSON message to sign',
}
// Called when the user has authorized the DID to perform the signature operation.
const onAuthorized = (result: ECSignature) => {
console.info(result)
setResult(result)
}
// Called in the event the user rejects the request or an error has occured.
const onRejected = (error: any) => {
console.error(error)
}
return (
<>
!result ?
<ZippieSign subject={objectToSign} {...{ onAuthorized, onRejected }} />
:
<pre>{JSON.stringify(result, null, 2)}</pre>
</>
)
}