UNPKG

digital-covid-certificate-lib

Version:

A library to parse and verify Digital Covid Certificates (DCC)

26 lines 1.56 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); // This converter can be exported as soon as CORS is enabled on the endpoint. // Otherwise the request will always fail when executing it the browser... class ConvertFromHC1ToLT1 { static convert(cert) { return __awaiter(this, void 0, void 0, function* () { const body = JSON.stringify({ hcert: cert.certificateWithPrefix }); const headers = [["Content-Type", "application/json"]]; const method = 'POST'; return fetch(this.certLightEndpoint, { body, headers, method }); }); } } ConvertFromHC1ToLT1.conversionEndpoint = "https://covidcertificate-app.bit.admin.ch/app/transform/v1/"; ConvertFromHC1ToLT1.certLightEndpoint = `${ConvertFromHC1ToLT1.conversionEndpoint}certificateLight`; //# sourceMappingURL=ConvertFromHC1ToLT1.js.map