1.0.4 • Published 3 years ago

france-ehealth-certificaces v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

france-ehealth-certificates

This library provides a quick and easy interface to verify COVID-19 certificates generated in France.

Your bugfix and pull request contribution are always welcomed.

Installation and Usage

You can install france-ehealth-certificates using npm:

$ npm install france-ehealth-certificates

Vaccination certificates

Signature verification

const fhc = require('france-ehealth-certificaces');

let vaccination = new fhc.Vaccination("DC04FR0000011E6D1E6DL101FRL0THEOULE SUR MER\u001dL1JEAN PAUL\u001dL231051962L3COVID-19\u001dL4J07BX03\u001dL5COMIRNATY PFIZER/BIONTECH\u001dL6COMIRNATY PFIZER/BIONTECH\u001dL71L82L901032021LACO\u001f32T2SI2RUMPDLBHAFSBDF2CUE7GI4NR5WC3NSBEU6AZ7QZJZCPMCTXTVIDZAKEYO7237SQ2ZPOCMZKG7U3Q2LIMPPVJMA7TQAAKC5DY");
let isVerified = false;
// This method will throw an error if you use an invalid key.
isVerified = vaccination.verifySignature("-----BEGIN PUBLIC KEY-----MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEqY8NfM1igIiTvsTUNuedGDSh1uAB1w8cTNzNnZ4v4in3JAUU6N3AypjQx0QMnMSShJoPvac/w5L02grgf4TCPA==-----END PUBLIC KEY-----");
// This method will always return a boolean without throwing.
isVerified = vaccination.tryVerifySignature("-----BEGIN PUBLIC KEY-----MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEqY8NfM1igIiTvsTUNuedGDSh1uAB1w8cTNzNnZ4v4in3JAUU6N3AypjQx0QMnMSShJoPvac/w5L02grgf4TCPA==-----END PUBLIC KEY-----");

2D-DOC is signed using ECDSA keys.

Read certificate fields

Field idField contentObject propertyExample
L0Patient last namelastnameTHEOULE SUR MER
L1Patient first namefirstnameJEAN PAUL
L2Patient birth datebirthdate31/05/1962
L3Disease namediseaseCOVID-19
L4Preventive agentpreventiveAgentJ07BX03
L5Vaccine namevaccineCOMIRNATY PFIZER/BIONTECH
L6Vaccine maker namevaccineMakerCOMIRNATY PFIZER/BIONTECH
L7Current number of injectionsnbDoseTaken1
L8Required number of injectionsnbDoseExpected2
L9Last date of injectionlastDoseDate01/03/2021
LACurrent vaccination cycle statestateCO

LA field values :

  • CO : Incomplete vaccination cycle
  • TE : Full vaccination cycle

Data used in this example is a sample available on ANTS website.

Sanitary certificates

Signature verification

const fhc = require('france-ehealth-certificaces');

let sanitary = new fhc.Sanitary("DC04FR00000113371337B201FRF0CORRINE\u001dF1BERTHIER\u001dF206121965F3FF4000\u001dF5XF6200620131200\u001fWZR5Y3AIRAFBIMKWLHSYX4BXNMELEVA3AXVL5IKZDX444F3A44VWXY2FKEWS4JUEOWLTSZ2MSMVW3NZ3LWO5FZKNLKVOMQT37LHV4II");
let isVerified = false;
// This method will throw an error if you use an invalid key.
isVerified = sanitary.verifySignature("-----BEGIN PUBLIC KEY-----MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEqY8NfM1igIiTvsTUNuedGDSh1uAB1w8cTNzNnZ4v4in3JAUU6N3AypjQx0QMnMSShJoPvac/w5L02grgf4TCPA==-----END PUBLIC KEY-----");
// This method will always return a boolean without throwing.
isVerified = sanitary.tryVerifySignature("-----BEGIN PUBLIC KEY-----MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEqY8NfM1igIiTvsTUNuedGDSh1uAB1w8cTNzNnZ4v4in3JAUU6N3AypjQx0QMnMSShJoPvac/w5L02grgf4TCPA==-----END PUBLIC KEY-----");

2D-DOC is signed using ECDSA keys.

Read certificate fields

Field idField contentObject propertyExample
F0Patient first namefirstnameCORRINE
F1Patient last namelastnameBERTHIER
F2Patient birth datebirthdate31/05/1962
F3Patient gendergenderF
F4Analysis codeanalysisCode000
F5Analysis resultanalysisResultX
F6Analysis datetimeanalysisDatetime20/06/2013 12:00

F3 field values :

  • M : Male
  • F : Female
  • U : Unknown

F4 codes are available on LOINC website.

F5 field values :

  • P : Positive
  • N : Negative
  • I : Undetermined
  • X : Non-compliant sample

Data used in this example is a sample available on ANTS website.

2D-DOC Header fields

FieldObject propertyExample
2D-DOC implementation versiondcVersion04
Certification authority iddcAuthorityIdFR00
Certificate iddcCertificateId0001
Document issue datedcDocumentDate4/5/2013
Signature creation datedcDocumentSignatureDate4/5/2013
Document type iddcDocumentTypeIdB2
Document perimeter iddcDocumentPerimeterId01
Document country (ISO-3166-Alpha2)dcDocumentCountryFR

2D-DOC Message

FieldObject propertyValue
MessagemessageHeader + Body - Signature
HeaderheaderHeader
BodybodyBody
SignaturesignatureSignature

Signature is the raw value from the 2D-DOC. This value is still base32 (RFC 4648) encoded.

F.A.Q

Does this library validate the French regulations for events access ?

No. This library only provides features to read and verify a COVID-19 certificates (Vaccination & Sanitary (RT-PCR)).

You need to implement French regulations on your side.

Do it work with European certificates ?

No. European certificates use another format of certificates.

You can find more information here.

Where can I find the public keys for signature verification?

Almost a challenge, but you can find them inside "TousAntiCovid" app source code.

Links

Licence

MIT License

Copyright (c) 2021 Florian Pisani

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

0.0.1

3 years ago