Javascript library for verifying Blockcerts

This package has been deprecated in favor of a scoped package. Please install @blockcerts/cert-verifier-js instead for all the Blockcerts goodness.
Last updated 2 years ago by jfraichot .
MIT · Original npm · Tarball · package.json
$ cnpm install cert-verifier-js 
SYNC missed versions from official npm registry.


Build Status codecov

A library to parse and verify Blockcerts certificates.



$ npm i cert-verifier-js



Exposed by default:

var Certificate = require('cert-verifier-js');
var certificate = new Certificate(certificateDefinition);

ES module

import Certificate from 'cert-verifier-js';
let certificate = new Certificate(certificateDefinition);

Script tag (iife)

Check an example here

<script src='node_modules/cert-verifier-js/dist/verifier-iife.js'></script>
  var certificate = new Verifier.Certificate(certificateDefinition);


You can find more examples in the test folder.

Parse a Blockcert certificate

var fs = require('fs');

fs.readFile('./certificate.json', 'utf8', function (err, data) {
  if (err) {

  let certificate = new Certificate(data);

Verify a Blockcert certificate

var fs = require('fs');

fs.readFile('./certificate.json', 'utf8', function (err, data) {
  if (err) {

  let certificate = new Certificate(data);
  const verificationResult = await certificate.verify(({code, label, status, errorMessage}) => {
    console.log('Code:', code, label, ' - Status:', status);
    if (errorMessage) {
      console.log(`The step ${code} fails with the error: ${errorMessage}`);
  if (verificationResult.status === 'failure') {
    console.log(`The certificate is not valid. Error: ${verificationResult.errorMessage}`);



new Certificate(certificateDefinition)

const certificate = new Certificate(certificateDefinition);

The constructor automatically parses a certificate.


  • certificateDefinition (String|Object): the certificate definition. Can either be a string or a JSON object.


The certificate instance has the following properties:

  • certificateImage: String. Raw data of the certificate image
  • certificateJson: Object. Certificate JSON object
  • chain: Object. Chain the certificate was issued on
  • description: String. Description of the certificate
  • expires: String. Expiration date
  • id: String. Certificate's ID
  • isFormatValid: Boolean. Indicates whether or not the certificate has a valid format
  • issuedOn: String. Datetime of issuance (ISO-8601)
  • issuer: Object. Certificate issuer
  • metadataJson: Object. Certificate metadata object
  • name: String. Name of the certificate
  • publicKey: String. Certificate's public key
  • receipt: String. Certificate's receipt
  • recipientFullName: String. Full name of recipient
  • recordLink: String. Link to the certificate record
  • revocationKey: String|null. Revocation key (if any)
  • sealImage: String. Raw data of the seal's image;
  • signature: String. Certificate's signature
  • signatureImage: String. Raw data of the certificate's signature image;
  • subtitle: String. Subtitle of the certificate
  • transactionId: String. Transaction ID
  • rawTransactionLink: String. Raw transaction ID
  • transactionLink: String. Transaction link
  • verificationSteps: VerificationStep[]. The array of steps the certificate will have to go through during verification
  • version: CertificateVersion. Version of the certificate

Note: verificationSteps is generated according to the nature of the certificate. The full steps array is provided ahead of verification in order to give more flexibility to the consumer. For example, you might want to pre-render the verification steps for animation, or render a count of steps and/or sub-steps.

VerificationStep has the following shape:

    code: 'formatValidation',
    label: 'Format validation',
    labelPending: 'Validating format',
    subSteps: [
        code: 'getTransactionId',
        label: 'Get transaction ID',
        labelPending: 'Getting transaction ID',
        parentStep: 'formatValidation'


This will run the verification of a certificate. The function is asynchronous.

const certificateVerification = await certificate.verify(({code, label, status, errorMessage}) => {
    console.log('Sub step update:', code, label, status);
console.log(`Verification was a ${certificateVerification.status}:`, certificateVerification.errorMessage);


  • ({code, label, status, errorMessage}) => {} (Function): callback function called whenever a substep status has changed. The callback parameter has 4 properties:
    • code: substep code
    • label: readable label of the substep
    • status: substep status (success, failure, starting)
    • errorMessage: error message (optional)


The final verification status:

{ code, status, errorMessage }
  • code: code of the final step (final)
  • status: final verification status (success, failure)
  • errorMessage: error message (optional)


Several constants are being exposed:



Run the tests

$ npm run test


$ npm run build

The build files are in the dist folder.

Verification process

If you want more details about the verification process, please check out the documentation.


Contact us at the Blockcerts community forum.

Current Tags

  • 2.0.2                                ...           latest (2 years ago)

5 Versions

  • 2.0.2 [deprecated]           ...           2 years ago
  • 2.0.1                                ...           2 years ago
  • 2.0.0                                ...           2 years ago
  • 1.0.1                                ...           2 years ago
  • 1.0.0                                ...           2 years ago
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (13)
Dev Dependencies (22)

Copyright 2014 - 2016 © taobao.org |