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.
# NPM
npm i @vaxxnz/nzcp
# Yarn
yarn add @vaxxnz/nzcp
import { verifyPassURI } from "@vaxxnz/nzcp";
// Verify a New Zealand COVID-19 Pass
const result = await verifyPassURI("NZCP:/1/2KCEVIQEIVVWK6...");
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
}
}
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
}
To allow for flexibility in this library, verifyPassURIWithTrustedIssuers
method allows for additional parameters as documented below.
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
);
See something that can be improved? Report an Issue or contact us to report a security concern.
Want to help us build a better library? We welcome contributions via pull requests and welcome you to our wider Vaxx.nz community on Discord: Join our Discord community.
# Install dependencies
yarn install
# Use developer scripts
yarn lint
yarn test
yarn test-watch
yarn build-all