@notarise-gov-sg/eu-dcc-generator
TypeScript icon, indicating that this package has built-in type declarations

2.2.0 • Public • Published

Known Vulnerabilities GitHub issues License

Generate EU Digital Covid Certificates

A helper library for for generate EU Digital Covid Certificates.

Getting Started

npm i @notarise-gov-sg/eu-dcc-generator

1. Import

import EuDccGenerator from "@notarise-gov-sg/eu-dcc-generator";
const euDccGenerator = EuDccGenerator(privateKey, publicKey, issuerName);

2. Prepare records

// Patient Details
const patientDetails: PatientDetails = {
  name: "Tan Chen Chen",
  familyName: "Tan",
  firstName: "Chen Chen",
  dateOfBirth: "1990-01-15",
  meta: {
    reference: "abc-cde-cde",
    notarisedOn: "2022-02-26T00:00:00.000Z",
    passportNumber: "E7831177G",
    url: "storedUrl",
  }
};

// Basic Details
const basicDetails: BasicDetails = {
  patientDetails,
  reference: "abc-cde-cde",
  issuerName: "MOH",
  expiryDaysOrDate: 365
};

// Notarise PDT (PCR Testing Record)
const singlePCRTestingRecord: TestingRecord[] = [
  {
    testTypeCode: "94309-2",
    naatTestName: "SARS-CoV-2 (COVID-19) RNA [Presence] in Specimen by NAA with probe detection",
    collectionDateTime: "2020-09-27T06:15:00Z",
    testResultCode: "260385009",
    testCenter: "MacRitchie Medical Clinic",
    testCountry: "SG"
  }
];

// Notarise PDT (ART Testing Record)
const singleARTTestingRecord: TestingRecord[] = [
  {
    testTypeCode: "97097-0",
    ratTestDeviceCode: "1833",
    collectionDateTime: "2020-09-27T06:15:00Z",
    testResultCode: "260385009",
    testCenter: "MacRitchie Medical Clinic",
    testCountry: "SG"
  }
];

// Notarise Vaccination (Vaccination Record)
const vaccinationRecord: VaccinationRecord = {
  vaccinations: [
    {
      vaccineCode: "3339641000133109",
      vaccineName: "PFIZER-BIONTECH COVID-19 Vaccine [Tozinameran] Injection",
      vaccineLot: "Lot12345",
      vaccinationDateTime: "2021-02-14",
      vaccinationLocationCode: "HIC001",
      vaccinationCountry: "SG"
    },
    {
      vaccineCode: "3339641000133109",
      vaccineName: "PFIZER-BIONTECH COVID-19 Vaccine [Tozinameran] Injection",
      vaccineLot: "Lot97531",
      vaccinationDateTime: "2021-03-03",
      vaccinationLocationCode: "HIC002",
      vaccinationCountry: "SG"
    }
  ],
  effectiveDate: "2021-03-17"
};

// Notarise Recovery (Recovery Record)
const validRecoveryRecord: RecoveryRecord[] = [
  {
    firstPositiveTestDate: "2022-01-01T00:00:00.000Z",
    testValidFrom: "2022-01-08T00:00:00.000Z",
    testValidUntil: "2022-06-30T00:00:00.000Z",
    testCountry: "SG"
  }
];

3. Generate Json and sign the payload

  • Generate for Vaccination Record
const payloadJson = euDccGenerator.genEuDcc(basicDetails, vaccinationRecord);
const signedPayload = euDccGenerator.signPayload(payloadJsonpayload);

// signedPayload response data
[
  {
    certificate: {...}
    vaccineCode: '3339641000133109',
    doseNumber: 1,
    expiryDateTime: '2023-02-23T01:00:01.098Z',
    qr: 'HC1:.....',
    appleCovidCardUrl: 'https://redirect.health.apple.com/EU-DCC/#...'
  },
  {
    certificate: {...}
    vaccineCode: '3339641000133109',
    doseNumber: 2,
    expiryDateTime: '2023-02-23T01:00:01.098Z',
    qr: 'HC1:.....',
    appleCovidCardUrl: 'https://redirect.health.apple.com/EU-DCC/#...'
  }
]
  • Generate for Test Record
const payloadJson = euDccGenerator.genEuDcc(basicDetails, [testingRecord]);
const signedPayload = euDccGenerator.signPayload(payloadJsonpayload);

// signedPayload response data
[
  {
    certificate: {...}
    type: 'PCR',
    expiryDateTime: '2023-02-23T01:00:01.098Z',
    qr: 'HC1:.....',
    appleCovidCardUrl: 'https://redirect.health.apple.com/EU-DCC/#...'
  }
]

Readme

Keywords

none

Package Sidebar

Install

npm i @notarise-gov-sg/eu-dcc-generator

Weekly Downloads

2

Version

2.2.0

License

MIT

Unpacked Size

52.4 kB

Total Files

25

Last publish

Collaborators

  • notarise-david
  • notarise-bot
  • hjunyuan
  • causztic