This is a TypeScript/JavaScript library which verifies the QR codes of certificates issued by the South African COVID-19 Vaccine Certificate System.

Overview

verify-za-vaccine-cert

npm

This is a TypeScript/JavaScript library which verifies the QR codes of certificates issued by the South African COVID-19 Vaccine Certificate System. It is an implementation of the algorithm described in the VCS Verification API Specification, Version 1.0.

The current vaccine certificates do not incorporate a digital signature. They can only be verified by calling the Public VCS Verification API provided by the Department of Health. It is therefore not possible to validate certificates when offline. For offline use this library does provide a function that checks the format of a certificate without validating it through the API, but this will not detect sophisticated forgeries.

This library works in both Node.js and in the browser. However, the VCS API currently does not set the necessary CORS headers, so you can't call it directly from browser code. You will have to proxy the requests through your own server, for which see the endpointUrl option described below.

Note that the verification API specification indicates that it has is a limit of 30 requests per IP address per second.

Install

npm install --save verify-za-vaccine-cert

Example

import { verifyCert, VerificationError } from 'verify-za-vaccine-cert'

const qrcode = '{"alg":"sha256","kid":"9e9e5863-b900-4f2f-b572-c48ee4ddee75cwtG6ZL54We1MmE","iss":"ZAF","iat":"2021-12-03T18:55:37.790","exp":"3M","hcert":"eyJ2ZXJzaW9uIjoiMi4wIiwiaWRUeXBlIjoiUlNBSUQiLCJpZE1hc2siOiI4ODAyMTAqKioqKio2IiwiZmlyc3ROYW1lIjoiQWRyaWFuIEpvaG4iLCJzdXJuYW1lIjoiRnJpdGgiLCJkYXRlT2ZCaXJ0aCI6IjEwLUZlYi0xOTg4IiwiaW1tdW5pemF0aW9uRXZlbnRzIjpbeyJ2YWNjaW5lUmVjZWl2ZWQiOiJDb21pcm5hdHkiLCJ2YWNjaW5lRGF0ZSI6IjIwLUF1Zy0yMDIxIn0seyJ2YWNjaW5lUmVjZWl2ZWQiOiJDb21pcm5hdHkiLCJ2YWNjaW5lRGF0ZSI6IjA0LU9jdC0yMDIxIn1dLCJleHBpcnlEYXRlIjoiMDMtTWFyLTIwMjIifQ==","hashalg":"sha256","hash":"caed4092ce4cd4af205aa90653126b836ea94e2d2619fe7fb53ea71af24c11fa"}'

const result = await verifyCert(qrcode)

if (result.valid) {
  console.log('Valid cert:', JSON.stringify(result.cert))
} else {
  console.log('Invalid cert:', VerificationError[result.reason])
}

The value of result.cert in this case is:

{
  "version": "2.0",
  "idType": "RSAID",
  "idMask": "880210******6",
  "firstName": "Adrian John",
  "surname": "Frith",
  "dateOfBirth": "10-Feb-1988",
  "immunizationEvents": [
    {
      "vaccineReceived": "Comirnaty",
      "vaccineDate": "20-Aug-2021"
    },
    {
      "vaccineReceived": "Comirnaty",
      "vaccineDate": "04-Oct-2021"
    }
  ],
  "expiryDate": "03-Mar-2022"
}

Usage

Verify a certificate (online)

const result = await verifyCert(qrcode, { endpointUrl: '...' })

The parameter qrcode must be a string containing the data as scanned from the QR code on the certificate. If endpointUrl is set then the verification request will be sent to that URL instead of the public VCS endpoint.

If the certificate is valid the result will have the form:

{
  valid: true,
  cert: { ... }
}

and cert will contain the data stored in the certificate (see the example above).

If the certificate is invalid the result will have the form:

{
  valid: false,
  reason: ...
}

The reason field will be one of the values from VerificationError (which is a TypeScript enum):

  • InvalidJson: the value supplied does not parse as a JSON object.
  • MissingField: one of the required fields is missing from the certificate.
  • InvalidHash: the certificate's hash is not valid.
  • CertFormat: the inner certificate data is not a Base64-encoded JSON object as required.
  • ApiBadResponse: the request to the VCS API failed.
  • ApiBadJson: the response from the VCS API was not valid JSON.
  • ApiNotValid: the VCS API responded that the certificate is not valid.

Check certificate format without verification (offline)

const result = checkCertFormat(qrcode)

The result of this function takes the same format as that of verifyCert, except that it is returned synchronously and not through a Promise.

License

This library is released under the MIT License. See LICENSE for more details. Copyright © 2022 Adrian Frith.

You might also like...

GitHub action to get notification whenever vaccine slot is availble in cowin portal :tada:

GitHub action to get notification whenever vaccine slot is availble in cowin portal :tada:

Covid Vaccine availability notifier Setup Fork this repo Update the config at src/config.js Delete the db file src/db.json module.exports = { // opt

Jul 27, 2022

AUTOVSB - AUTO Vaccine Slot Booker

AUTOVSB - AUTO Vaccine Slot Booker

AUTOVSB AUTOVSB - AUTO Vaccine Slot Booker A script based on browser automation which continuously scraps COVID-19 vaccine slot data, alerts you and b

Nov 3, 2022

World Covid Tracker With Javascript

World Covid Tracker With Javascript

World Covid Tracker Track the covid stats in every continent and each of their respective countries. Built with : React Redux-toolkit Tailwind Jest Gi

Dec 19, 2022

Get updates in Telegram when a vaccination center available in your pin code. We can win Covid 🤝

Cowin Bot Get updates in Telegram when an vaccination center available in your pin code. We can win Covid 🤝 Commands: /start - Start the Bot /help -

Oct 3, 2022

An application to help in the automatic booking of COVID vaccination slots in India whenever they become available.

An application to help in the automatic booking of COVID vaccination slots in India whenever they become available.

Co-WIN automated slot booking Automatically book vaccine slots as and when they become available This application aims to automatically book vaccine s

Nov 23, 2022

Built a covid-19 trcaker app using React.js implementing hooks and materail UI

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

Dec 21, 2021

USA Covid-19 Tracker is a mobile-first application built with React and Redux to give precise information about the virus behavior in the United States. Great transitions and user feedback made with plain CSS.

USA Covid-19 Tracker is a mobile-first application built with React and Redux to give precise information about the virus behavior in the United States. Great transitions and user feedback made with plain CSS.

React.js USA Covid-19 Tracker This application allows the public to keep track of the stadistics of the Covid-19 Pandemic in the United Stated. You wi

Oct 25, 2022

Real-time covid data in Brazil states.

Real-time covid data in Brazil states.

Brazil Covid Data Brazil Covid Data is a web application that allows you to see information about the pandemics on your state just by hovering it on t

Feb 15, 2022

Covidapp - Stop COVID-19 Hrvatska

Covidapp - Stop COVID-19 Hrvatska

Stop COVID-19 Hrvatska Description Kako bi usporili širenje bolesti COVID-19 međ

Feb 12, 2022
Owner
Adrian Frith
Adrian Frith
⚡️ Look for Covid-19 Resources, Get Vaccine Availability Notification, Complete source code for covidrescue.co.in website.

covidrescue.co.in ⚡️ Get real-time, verified leads on Oxygen, Remdesivir, ICU, Beds, Food and more based on your location. Get notifications on Vaccin

Placeholder Tech 15 Jul 10, 2022
Fill the boring catsalud covid vaccine form with a console command

vacunacovid-catsalud-autofullfill form Fill the boring catsalud covid vaccine form with a console command Manual use, pasting in the script in the con

null 18 Jul 27, 2021
Check EU Digitial Covid Certificates with ease and validate them against country and local rules.

Check EU Digitial Covid Certificates with ease and validate them against local or country rules. What is the purpose of CovidValidator? CovidValidator

Timo Koenig 10 Mar 14, 2022
A simple PWA to scan your EU digital COVID Certificate and generate a passbook from it

COVID-19 passbook Generator The aim of this project is to let a user scan a EU Digital COVID Certificate with their smartphone, and generate a passboo

Thibault Milan 129 Nov 11, 2022
⚡️The Fullstack React Framework — built on Next.js

The Fullstack React Framework "Zero-API" Data Layer — Built on Next.js — Inspired by Ruby on Rails Read the Documentation “Zero-API” data layer lets y

⚡️Blitz 12.5k Jan 4, 2023
Website yang memberikan informasi terkait ketersediaan rumah sakit dan tempat tidur rumah sakit untuk pasien covid-19 ataupun non-covid di Indonesia.

Bed Covid RS Indonesia Website yang memberikan informasi terkait ketersediaan rumah sakit dan tempat tidur rumah sakit untuk pasien covid-19 ataupun n

Hendra Agil Syaputra 22 Oct 23, 2022
Worldwide-covid-statistics - covid-19 tracker developed using Reactjs, Axios , chartjs, material icons

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

Akinmegha Temitope Samuel 1 Jan 3, 2022
Covid-19 Tracker is a mobile web application showcasing the covid-19 statistics in Africa.

Covid-19 Tracker is a mobile web application showcasing the covid-19 statistics in Africa. when the user clicks on the countries' cards, they will be rendered to the details page that contains more information about the covid-19 in the selected country. Also, the user can search for a specific country using the search bar.

Nedjwa Bouraiou 7 Sep 6, 2022
A web app built with Covid-19-API that displays Covid 19 cases, deaths and recovery per country in the entire World

Covid19 Tracker A web app built with Covid-19-API that displays Covid 19 cases, deaths and recovery per country in the entire World Built With HTML, C

Promise Okechukwu 4 Nov 1, 2022
A Tracker to Check the availability of vaccine through pincode and buzzer in case of availability

Welcome to covid-vaccine-tracker ?? A Tracker to Check the availability of vaccine through pincode and buzzer in case of availability ?? Homepage Prer

Ayush Bansal 21 Jun 7, 2021