npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

covid-certificate

v1.3.2

Published

Parse and verify a european digital covid certificate (dcc)

Downloads

41

Readme

Digital Covid Certificate

typescript licence version node

This package will parse and verify a European Digital Covid Certificates (DCC). Certificates in the form of QR-codes are being handed down to all vaccinated, recovered or tested citizens of the European Union.

Installation

You can install this package by using your favourite package manager

npm install covid-certificate --save

Webpack >= 5.0

Webpack < 5 used to include polyfills for node.js core modules by default. This is no longer the case. You will need to install and configure the polyfills yourself if you are using this package in the browser. For example by using the node-polyfill-webpack-plugin

npm install node-polyfill-webpack-plugin

configure webpack.config.js

const NodePolyfillPlugin = require("node-polyfill-webpack-plugin")

module.exports = {
	// Other rules...
	plugins: [
          new NodePolyfillPlugin()
	]
}

Getting started

This package can parse and verify the signature of digital covid certificate

Signature verification

To verify a certificate:

import { readCertificate } from "covid-certificate";

const cert = readCertificate("HC1:your_certificate_from_QR_code_scanner");
const verfificationResult = verifySignature(cert);

if (!verfificationResult.isValid()) {
  console.log(verfificationResult.getMessage());
}

Parsing certificate

Parsing the certificate will give you access to all the data inside the certificate. Before parsing it is recommended to verify the signature!

import { parse } from "covid-certificate";

const healthCertificate = parse("HC1:certificate_data_from_QR_code");
console.log(healthCertificate);

HealthCertificate

The HealthCertificate contains the following data

| Property | Type | Description | |----------------|--------|--------------------------------------------| | kid | string | The unique id of the issuer | | alg | string | The algorithm used to sign the certificate | | expirationDate | Date | Expiration date of certificate | | issuedAt | Date | Certificate issued at date | | dateOfBirth | string | Date of birth | | name | object | Name of the person | | vaccinations | array | The vaccinations | | recovered | array | Recovery data | | tests | array | Test data | | version | string | Version |

Full example

Following full example will give you a guide on how to use this library.

import { readCertificate, parseCoseCertificate, verifySignature } from "covid-certificate";

const cert = readCertificate(
  "HC1:6BF+70790T9WJWG.FKY*4GO0.O1CV2 O5 N2FBBRW1*70HS8WY04AC*WIFN0AHCD8KD97TK0F90KECTHGWJC0FDC:5AIA%G7X+AQB9746HS80:54IBQF60R6$A80X6S1BTYACG6M+9XG8KIAWNA91AY%67092L4WJCT3EHS8XJC +DXJCCWENF6OF63W5NW6WF6%JC QE/IAYJC5LEW34U3ET7DXC9 QE-ED8%E.JCBECB1A-:8$96646AL60A60S6Q$D.UDRYA 96NF6L/5QW6307KQEPD09WEQDD+Q6TW6FA7C466KCN9E%961A6DL6FA7D46JPCT3E5JDLA7$Q6E464W5TG6..DX%DZJC6/DTZ9 QE5$CB$DA/D JC1/D3Z8WED1ECW.CCWE.Y92OAGY8MY9L+9MPCG/D5 C5IA5N9$PC5$CUZCY$5Y$527BHB6*L8ARHDJL.Q7*2T7:SCNFZN70H6*AS6+T$D9UCAD97R8NIBO+/RJVE$9PAGPTBIZEP MO-Q0:R13IURRQ5MV93M9V3X2U:NDZSF"
);
const verfificationResult = verifySignature(cert);

if (!verfificationResult.isValid()) {
  console.log(verfificationResult.getMessage())
}

const healthCertificate = parseCoseCertificate(cert)

// Display vaccination information
if (healthCertificate.vaccinations.length > 0) {
  console.log(healthCertificate.vaccinations[0]);
}

will display

{
  "target": "COVID-19",
  "vaccineType": "MRNA",
  "medicinalProduct": "EU/1/20/1507",
  "manufacturer": "ORG-100031184",
  "doseNumber": 1,
  "totalDoses": 2,
  "date": "2021-05-29",
  "country": "DE",
  "issuer": "Robert Koch-Institut",
  "id": "URN:UVCI:01DE/IZ12345A/5CWLU12RNOB9RXSEOP6FG8#W"
}

Documentation

Full documentation of the library can be found here

Author

This library is written by Benno Tielen. Contributions are welcome!