NZCP.js  

A JavaScript implementation of NZ COVID Pass verification, New Zealand’s proof of COVID-19 vaccination solution, written in TypeScript. All contributions welcome ?

We also have a Rust implementation available.

This library can be used for both in browser and Node.js.

Install

# NPM
npm i @vaxxnz/nzcp

# Yarn
yarn add @vaxxnz/nzcp

Demo

Usage

import { verifyPassURI } from "@vaxxnz/nzcp";

// Verify a New Zealand COVID-19 Pass
const result = await verifyPassURI("NZCP:/1/2KCEVIQEIVVWK6...");

Successful Verification

On successful verification of the given pass, the verifyPassURI method returns the following result:

{
  "success": true,            // Verification Outcome
  "violates": null,           // Error object if code is invalid
  "credentialSubject": {      // Pass holder's details
    "givenName": "Emily",     // Pass holder's given name
    "familyName": "Example",  // Pass holder's family name
    "dob": "01/01/1970"       // Pass holder's date of birth
  }
}

Unsuccessful Verification

On unsuccessful verification of the given pass, the verifyPassURI method returns the following result:

{
  "success": false,           // Verification Outcome
  "violates": {               // Error information
    "message": "Error..",     // Friendly Error Message
    "section": "0.0",         // Section of official specs under violation
    "link": "https://..",     // Link to specifications breached
  },
  "credentialSubject": null   // No pass holder data due to error
}

Advanced Parameters

To allow for flexibility in this library, verifyPassURIWithTrustedIssuers method allows for additional parameters as documented below.

Custom Trusted Issuers

import { verifyPassURIWithTrustedIssuers } from "@vaxxnz/nzcp";

// An array of trusted issuers which work with the NZ COVID Pass - Technical Specification
// https://nzcp.covid19.health.nz/
const nzcpTrustedIssuers = ["did:web:nzcp.covid19.health.nz"];

const result = await verifyPassURIWithTrustedIssuers(
  "NZCP:/1/2KCEVIQEIVVWK6...",  // COVID-19 Pass to be verified
  nzcpTrustedIssuers            // Array of trusted issuers
);

NPM

@vaxxnz/nzcp

Contribute

# Install dependencies
yarn install

# Use developer scripts
yarn lint
yarn test
yarn test-watch
yarn build-all

GitHub

View Github