A JavaScript library for parsing and verifying EVC (European Vaccination Card) tokens. Supports both JWT and CWT (CBOR Web Token) formats.
npm install @syadem/evc-jsA JavaScript library for parsing and verifying EVC (European Vaccination Card) tokens. Supports both JWT and CWT (CBOR Web Token) formats.
``sh`
npm install @syadem/evc-js
`js
import { parseJwtEvc } from '@syadem/evc-js';
import { importSPKI } from "jose";
const jwt = "eyJhbGciOiJFUzI1NiJ9.eyJkb2IiOiIxOTkwLTAx...";
const publicKey = await importSPKI(
-----BEGIN PUBLIC KEY-----
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEd26RtDbKuFnLvRshkJdY3t4kDCTQ
J3P4EXio3jcFFoAbus2k5bjc+0Q//Oyy8/4tDyGZ89U/me/pGUORg3+F+Q==
-----END PUBLIC KEY-----,
"ES256"
);
const { evc, validation } = await parseJwtEvc(jwt, publicKey);
console.log("Certificate:", evc);
console.log("Signature verified:", validation.signatureVerified);
`
`js
import { parseCwtEvc, getKey } from '@syadem/evc-js';
const cwt = "6BFOXN*TS0BI$ZDZRH..."; // Base45-encoded CWT
const { evc, validation } = await parseCwtEvc(cwt, getKey);
console.log("Certificate:", evc);
`
`js
import { serializeEvcTokenToJwt } from '@syadem/evc-js';
import { importPKCS8 } from "jose";
const evc = {
dateOfBirth: new Date("1990-01-01"),
name: { firstName: "John", lastName: "Doe" },
version: "1.0.0",
issuer: "SYADEM",
vaccinations: [
{ nuvaCode: 12345, countryCode: "FRA", performedOn: new Date("2023-06-15"), id: 67890 }
]
};
const privateKey = await importPKCS8(-----BEGIN EC PRIVATE KEY-----..., "ES256");``
const jwt = await serializeEvcTokenToJwt(evc, privateKey);
For details on CBOR encoding, COSE signatures, JWK key management, and the full token processing pipeline, see EVC_PARSING.md.
- EVC Schema Specification - Official payload structure
- EVC Documentation - Full documentation
- EUVABECO Project - Project homepage
- EUVABECO Trust Keys - Public keys for signature verification