Criipto
  1. Integrations
  2. Node.js

This guide shows you how to use implement Criipto Signatures in Node.js to sign PAdeS-LTA documents using MitID, BankID or any other eID supported by Criipto.

Getting started

Requirements

This library supports Node 16 and later.

Installation

The SDK is available on NPM:

npm install --save @criipto/signatures
yarn add @criipto/signatures

Configure the SDK

import CriiptoSignatures from '@criipto/signatures';
const client = new CriiptoSignatures("{YOUR_CRIIPTO_CLIENT_ID}", "{YOUR_CRIIPTO_CLIENT_SECRET}");

Creating your first signature order

Create a signature order by

import CriiptoSignatures from '@criipto/signatures';
const client = new CriiptoSignatures("{YOUR_CRIIPTO_CLIENT_ID}", "{YOUR_CRIIPTO_CLIENT_SECRET}");

// Create signature order
const signatureOrder = await client.createSignatureOrder({
  title: "Node.js sample",
  documents: [
    {
      pdf: {
        title: "Node.js Sample",
        blob: pdf.toString('base64'),
        storageMode: 'Temporary'
      }
    }
  ]
});

// ... store the signatureOrder.id

Adding signatories

Signatories are the individuals you wish to sign your documents.

import CriiptoSignatures from '@criipto/signatures';
const signatureOrderId = "..." // The id from when you previosuly created the signature order

// Add signatory to signature order
var signatory = await client.addSignatory(signatureOrderId);

console.log(signatory.href); // The signatory.href is the signing link that you can show or send to your users

Closing the signature order

Once everyone has signed you must close the signature order to finalize the process and extract the signed documents.

const client = new CriiptoSignatures("{YOUR_CRIIPTO_CLIENT_ID}", "{YOUR_CRIIPTO_CLIENT_SECRET}");
var signatureOrderId = "..." // The id from when you previosuly created the signature order

// Close signature order
var closedSignatureOrder = await client.closeSignatureOrder(signatureOrderId);

closedSignatureOrder.documents.forEach(document => {
  // document.blob is a Buffer containing the signed PDF
});

More examples

More Node.js examples are provided for all the options supported by the Criipto Signatures API.