All Projects → italia → verificac19-sdk

italia / verificac19-sdk

Licence: MIT license
✅ Official VerificaC19 Node.js SDK

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to verificac19-sdk

covid19-passbook-generator
A simple PWA to scan your EU digital COVID Certificate and generate a passbook from it
Stars: ✭ 130 (+154.9%)
Mutual labels:  covid-19, digital-covid-certificate
covid-pass-verifier
🦠 Scan, parse and verify HCERT compliant government-issued COVID-19 passes.
Stars: ✭ 25 (-50.98%)
Mutual labels:  covid-19, digital-covid-certificate
it-dgc-opendata
Open Data on the European Digital Covid Certificates (EU DCC) issued and acquired by the national platform
Stars: ✭ 25 (-50.98%)
Mutual labels:  digital-covid-certificate, greenpass
DCC-green-pass-decoder
A simple web app to decode EU Digital Covid Certificate/Green Pass QR codes.
Stars: ✭ 42 (-17.65%)
Mutual labels:  digital-covid-certificate, greenpass
covidtrackerapiwrapper
CovidSharp is a crossplatform C# API wrapper for the Coronavirus tracking API (https://github.com/ExpDev07/coronavirus-tracker-api)
Stars: ✭ 11 (-78.43%)
Mutual labels:  covid-19
Kaggle
Kaggle Kernels (Python, R, Jupyter Notebooks)
Stars: ✭ 26 (-49.02%)
Mutual labels:  covid-19
the-researcher-covid-tracker
ระบบติดตามและรายงานข้อมูลการระบาดและการฉีดวัคซีน COVID-19 ในประเทศไทย
Stars: ✭ 111 (+117.65%)
Mutual labels:  covid-19
camara-descontaminacao-ar
Câmara de descontaminação de ar
Stars: ✭ 15 (-70.59%)
Mutual labels:  covid-19
quanto-manca
Quando torneremo alla normalità?
Stars: ✭ 16 (-68.63%)
Mutual labels:  covid-19
covid19-resources
Curated list of Coronavirus data & apps
Stars: ✭ 35 (-31.37%)
Mutual labels:  covid-19
Raspberry-Pi-E-Ink-Dashboard
Tri color e-ink dashboard written in Python 3.7, running on Raspberry Pi
Stars: ✭ 80 (+56.86%)
Mutual labels:  covid-19
covid19
This API provides updated real-time data on coronavirus cases from the worldometers page, provided by the most reputable organizations and statistical offices in the world.
Stars: ✭ 77 (+50.98%)
Mutual labels:  covid-19
covid-rt-estimates
National and subnational estimates of the time-varying reproduction number for Covid-19
Stars: ✭ 31 (-39.22%)
Mutual labels:  covid-19
SupplyInfo
Help your neighbourhood get supplies in the most efficient and safe way possible. Alert your locality on available essentials in the neighbourhood by using Neighbourhood Supply.
Stars: ✭ 17 (-66.67%)
Mutual labels:  covid-19
covid-19-projects
List for tracking covid-19 related projects
Stars: ✭ 23 (-54.9%)
Mutual labels:  covid-19
coronavirus-dresden
Collects official SARS-CoV-2 infection statistics published by the city of Dresden.
Stars: ✭ 19 (-62.75%)
Mutual labels:  covid-19
red-cross
官方公示数据概览
Stars: ✭ 18 (-64.71%)
Mutual labels:  covid-19
care fe
Care is an integrated tele-triage+bed allocation+patient shifting tool for implementing a decentralised Covid19 management strategy.
Stars: ✭ 80 (+56.86%)
Mutual labels:  covid-19
Covid19arData
Data COVID-19 Argentina actualizada y en formatos abiertos.
Stars: ✭ 51 (+0%)
Mutual labels:  covid-19
awesome-covid-19-resources
A curated list of awesome resources for COVID-19
Stars: ✭ 36 (-29.41%)
Mutual labels:  covid-19

VerificaC19 SDK for Node.js

Official VerificaC19 SDK implementation for Node.js (official SDKs list).

Read this in other languages: Italian 🇮🇹.

Requirements

  • Node.js version >= 12.x
  • MongoDB version >= 5.x (used to store CRL)

Installation

npm i verificac19-sdk

Usage

Setup CRL environment

CRL data will be stored in a MongoDB database. This repository provides a simple docker-compose.yml file (dev instance) with a replica set. By default the connection string is mongodb://root:example@localhost:27017/VC19?authSource=admin.

If you want to change it as dotenv is used for environment variables managment, you must create a .env file in your root folder and set VC19_MONGODB_URL value.

👉🏻 See an example examples/.env.

⚠️ If you don't want to use MongoDB to store CRL, read how to write your own CRL management system.

Download and cache rules, CRL data and DSCs

You can download and cache rules, CRL data and DSCs using Service module.

const {Service} = require('verificac19-sdk');

const main = async () => {
  await Service.updateAll();
}

⚠️ By default rules and DSCs will be cached in a folder called .cache, to change it, set VC19_CACHE_FOLDER inside your .env file.

By default updateAll is allowed to fetch new data every 24 hours. To change this value, set VC19_UPDATE_HOURS inside your .env file.

👉🏻 See an example examples/syncdata.js.

Verify a DCC

You can load a DCC from an image or from a raw string using Certificate module.

const {Certificate} = require('verificac19-sdk');

const main = async () => {
  const myDCCfromImage = await Certificate.fromImage('./data/myDCC.png');
  const myDCCfromRaw = await Certificate.fromRaw('HC1:6BF+70790T9WJWG.FKY*4GO0.O1CV2...etc..');
}

Loaded DCC has the following structure:

{
  person: {
    standardisedFamilyName: 'MUSTERMANN',
    familyName: 'Mustermann',
    standardisedGivenName: 'ERIKA',
    givenName: 'Erika'
  },
  dateOfBirth: '1964-08-12',
  kid: 'TH15154F4k3K1D=',
  exemptions: [ ... ],         // Array of exemptions (if any)
  vaccinations: [ ... ],       // Array of vaccinations (if any)
  tests: [ ... ],              // Array of tests (if any)
  recoveryStatements: [ ... ], // Array of recovery statements (if any)
  dcc: DCCObject               // from dcc-utils https://github.com/ministero-salute/dcc-utils
}

👉🏻 fromImage and fromRaw methods may rise CertificateParsingError.

You can verify a DCC using Validator module.

const {Certificate, Validator} = require('verificac19-sdk');

const main = async () => {
  const myDCC = await Certificate.fromImage('./data/myDCC.png');
  const validationResult = await Validator.validate(myDCC);
}

Validator.validate returns an object containing person name, date_of_birth, code and a message alongside the result

{
  person: 'Erika Mustermann',
  date_of_birth: '1964-08-12',
  code: 'NOT_VALID',
  result: false,
  message: 'Test Result is expired at : 2021-05-22T12:34:56.000Z'
}

you can compare the resulting code with Validator.codes values

Code Description Result
VALID Certificate is valid true
⚠️ TEST_NEEDED Test needed if verification mode is BOOSTER_DGP false
NOT_VALID Certificate is not valid false
NOT_VALID_YET Certificate is not valid yet false
REVOKED Certificate is revoked false
NOT_EU_DCC Certificate is not an EU DCC false

for example

const validationResult = await Validator.validate(dccTest);
console.log(validationResult.code === Validator.codes.NOT_VALID);

👉🏻 validate method may rise CertificateVerificationError (e.g. when cache is not ready yet).

👉🏻 See an example examples/verifydccs.js.

Verification mode

If you want to change verification mode and verify whether a certificate is a Super Green Pass or not, you need to pass Validator.mode.SUPER_DGP to Validator.validate method.

const result = await Validator.validate(dcc, Validator.mode.SUPER_DGP);
Code Description
NORMAL_DGP Normal verification (default value)
SUPER_DGP Super Green Pass verification
VISITORS_RSA_DGP RSA Visitors (ex BOOSTER_DGP verification mode)

DECRETO-LEGGE 4 febbraio 2022, n. 5

Alternative methods

To update rules and DSCs you can also use updateRules, updateSignaturesList and updateSignatures methods

const {Service} = require('verificac19-sdk');

const main = async () => {
  await Service.setUp();
  await Service.updateRules();
  await Service.updateSignaturesList();
  await Service.updateSignatures();
  await Service.updateCRL();
  await Service.tearDown();
}

To verify a DCC you can also use Validator.checkRules and Validator.checkSignature methods.

const {Certificate, Validator} = require('verificac19-sdk');

const main = async () => {
  const myDCC = await Certificate.fromImage('./data/myDCC.png');
  const rulesOk = await Validator.checkRules(myDCC).result;
  const signatureOk = await Validator.checkSignature(myDCC);
}

Development

Install dependencies

npm i

Run tests

Run mongodb services using Docker

docker-compose up

Set VC19_CACHE_FOLDER and run tests

npm run test

Authors

Copyright (c) 2021 - Andrea Stagi

Parts of the core code have been written by Area servizi ICT, Politecnico di Milano.

Contributors

Here is a list of contributors. Thank you to everyone involved for improving this project, day by day.

License

VerificaC19-SDK for Node.js is available under the MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].