Nutrient Web SDK
    Preparing search index...

    Type Alias TwoStepSignatureCallback

    TwoStepSignatureCallback: (
        result: {
            dataToBeSigned: ArrayBuffer;
            fileContents: ArrayBuffer | null;
            hash: string;
        },
    ) => Promise<
        | ArrayBuffer
        | SignatureCallbackResponsePkcs7
        | SignatureCallbackResponseRaw,
    >

    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 a Promise object that resolves to any of these types:

    • An ArrayBuffer that contains either the signed data or a PKCS7 container that includes it.
    • A SignatureCallbackResponsePkcs7 that is structured type for when the signature device or service creates signatures in the PKCS#7 format.
    • A SignatureCallbackResponseRaw that is structured type for when the signature device or service creates signatures in the raw (for instance, PKCS#1.5) format. If the returned Promise object 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.

    Type Declaration

      • (
            result: {
                dataToBeSigned: ArrayBuffer;
                fileContents: ArrayBuffer | null;
                hash: string;
            },
        ): Promise<
            | ArrayBuffer
            | SignatureCallbackResponsePkcs7
            | SignatureCallbackResponseRaw,
        >
      • Parameters

        • result: { dataToBeSigned: ArrayBuffer; fileContents: ArrayBuffer | null; hash: string }
          • 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 Promise<
            | ArrayBuffer
            | SignatureCallbackResponsePkcs7
            | SignatureCallbackResponseRaw,
        >

        A promise that resolves to any of these:

        • An ArrayBuffer that 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. The ArrayBuffer return type is deprecated. It's recommended to return either a SignatureCallbackResponsePkcs7 or SignatureCallbackResponseRaw, depending on the signature format.

    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!");
    })