Smile ID requires you to send a unique signature and timestamp with every job you run. Although running jobs using any of our libraries will automatically calculate the signature, there might be instances you want to run a job using our REST API or generate signatures. In such instances you can use the sample code below to calculate a signature:
constsmileIdentityCore=require("smile-identity-core");constSignature=smileIdentityCore.Signature;// Initializepartner_id ="<Put your partner ID here>"; // login to the Smile ID portal to view your partner idapi_key ="<Put your base64 encoded API key here>"; // copy your API key from the Smile ID portalconnection =newSignature(partner_id, api_key);// Generate the Signaturegenerated_signature =connection.generate_signature("<put your custom timestamp>",); // where timestamp is optional
To ensure the response you receive from your callback is actually from Smile ID, you can confirm the returned signature and timestamp. You can use the sample code below to confirm the signature:
constsmileIdentityCore=require("smile-identity-core");constSignature=smileIdentityCore.Signature;// Initializepartner_id ="<Put your partner ID here>"; // login to the Smile ID portal to view your partner idapi_key ="<Put your API key here>"; // copy your API key from the Smile ID portalconnection =newSignature(partner_id, api_key);// Confirm a signaturesignature =connection.confirm_signature("<put the received timestamp>","<put the received signature>",);