Type Alias TwoStepSignatureCallback
Type Alias
Type Signature
type TwoStepSignatureCallback = (
result: {
dataToBeSigned: ArrayBuffer;
fileContents: ArrayBuffer | null;
hash: string;
},
) => Promise<
| ArrayBuffer
| SignatureCallbackResponsePkcs7
| SignatureCallbackResponseRaw,
>
result: {
dataToBeSigned: ArrayBuffer;
fileContents: ArrayBuffer | null;
hash: string;
},
) => Promise<
| ArrayBuffer
| SignatureCallbackResponsePkcs7
| SignatureCallbackResponseRaw,
>
Example
Sign document (Standalone)
instance.signDocument(null, function({ hash, fileContents }) {
return new Promise(function(resolve, reject) {
const PKCS7Container = getPKCS7Container(hash, fileContents);
if (PKCS7Container != null) {
return resolve(PKCS7Container)
}
reject(new Error("Could not retrieve the PKCS7 container."))
})
}).then(function() {
console.log("Document signed!");
})
Type Declaration
Parameters
result
{ … }
dataToBeSigned: ArrayBuffer
Data to be signed for CAdES signatures.
fileContents: ArrayBuffer | null
Content of the file to be signed. Provided only for CMS signatures.
hash: string
Hash of the current document
Returns
A promise that resolves to any of these:
- An
ArrayBufferthat contains the signed data in the PKCS#1.5 or PKCS#7 format. - A
SignatureCallbackResponsePkcs7, for when the signature device or service creates signatures in the PKCS#7 format. - A
SignatureCallbackResponseRaw, for when the signature device or service creates signatures in the raw (for instance, PKCS#1.5) format. TheArrayBufferreturn type is deprecated. It's recommended to return either aSignatureCallbackResponsePkcs7orSignatureCallbackResponseRaw, depending on the signature format.
This callback is called when a document has been prepared for digitally signing by calling
instance.signDocument(). It receives the current document hash, file contents and data to be signed as arguments, and must return aPromiseobject that resolves to any of these types:ArrayBufferthat contains either the signed data or a PKCS7 container that includes it.SignatureCallbackResponsePkcs7that is structured type for when the signature device or service creates signatures in the PKCS#7 format.SignatureCallbackResponseRawthat is structured type for when the signature device or service creates signatures in the raw (for instance, PKCS#1.5) format. If the returnedPromiseobject rejects, the document will not be signed.The provided file contents or the data to be signed can be used as input for the Web Crypto API, or for a signing service of your choice to be signed (hashed and encrypted). The file contents hash is also provided so it can be used it to verify the validity of the contents.
See this guide article for more information on how to digitally sign a document on Standalone.