Giter Site home page Giter Site logo

olalonde / shc-protocol Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 1.0 526 KB

Library for decoding and verifying Smart Health Cards data (e.g. the Quebec Covid Vaccine QR code).

License: MIT License

JavaScript 1.53% TypeScript 98.47%
smart-health-card shc quebec vaccination-passport

shc-protocol's Introduction

Smart Health Cards library

Library for decoding and verifying Smart Health Cards data (e.g. the Quebec Covid Vaccine QR code).

Example

import decode from "shc-protocol";

(async () => {
  const rawQrText =
    "shc:/567629095243206034602924374044603122295953265460346029254077280433602870286471674522280928613331456437653141590640220306450459085643550341424541364037063665417137241236380304375622046737407532323925433443326057360106452931531270742428395038692212766566046938775507593966070420405229673107363333693803425720586229543633123300103877712022113608123739554159750065216576244136280332243607756009665859260023605803272728675721123035212164252561302458076644543210260735435742003171574339537172115043532966334536735428113958605523117307120954595940355931687040114532417303424039651066632209425741412212703267325456534137225708120573042126716936576331122727086139744341560859437500341264706904260465583253732838100829123422126208775858655545243477645920507637325929080373682704763707057100412927585265582550667760036577704021621136444536642771754403736036776160662638060600324033352612760522074054305466502054376441420410096741425206682467446356124533125330537750124227303028400359750054286111584333366267631155530460382155690074592636502724332654657410557730225306356323745403423657422565211128283333346832702663720538744360722833654566035731067308726224373476706465293608106711742940525720295456606873533426066835102443280923746156754126314130556412726961056137220606047644413737522667302267377250590432617356226443096866703304680076745369120674030573312336127454012437565572373107004250255426335362717057650427082543112329402404675520202939260458387410313866226959567029050800693059723470237666045873346268737738504572586731601071064358";
  const result = await decode(rawQrText);
  console.log(result);
})();

Result:

{
  header: {
    zip: 'DEF',
    alg: 'ES256',
    kid: '3Kfdg-XwP-7gXyywtUfUADwBumDOPKMQx-iELL11W9s'
  },
  payload: {
    iss: 'https://smarthealth.cards/examples/issuer',
    nbf: 1620847989.837,
    vc: {
      type: [
        'https://smarthealth.cards#health-card',
        'https://smarthealth.cards#immunization',
        'https://smarthealth.cards#covid19'
      ],
      credentialSubject: {
        fhirVersion: '4.0.1',
        fhirBundle: {
          resourceType: 'Bundle',
          type: 'collection',
          entry: [
            {
              fullUrl: 'resource:0',
              resource: {
                resourceType: 'Patient',
                name: [ { family: 'Anyperson', given: [ 'John', 'B.' ] } ],
                birthDate: '1951-01-20'
              }
            },
            {
              fullUrl: 'resource:1',
              resource: {
                resourceType: 'Immunization',
                status: 'completed',
                vaccineCode: {
                  coding: [
                    {
                      system: 'http://hl7.org/fhir/sid/cvx',
                      code: '207'
                    }
                  ]
                },
                patient: { reference: 'resource:0' },
                occurrenceDateTime: '2021-01-01',
                performer: [ { actor: { display: 'ABC General Hospital' } } ],
                lotNumber: '0000001'
              }
            },
            {
              fullUrl: 'resource:2',
              resource: {
                resourceType: 'Immunization',
                status: 'completed',
                vaccineCode: {
                  coding: [
                    {
                      system: 'http://hl7.org/fhir/sid/cvx',
                      code: '207'
                    }
                  ]
                },
                patient: { reference: 'resource:0' },
                occurrenceDateTime: '2021-01-29',
                performer: [ { actor: { display: 'ABC General Hospital' } } ],
                lotNumber: '0000007'
              }
            }
          ]
        }
      }
    }
  },
  verifications: {
    trustable: true,
    verifiedBy: '3Kfdg-XwP-7gXyywtUfUADwBumDOPKMQx-iELL11W9s',
    origin: 'https://smarthealth.cards/examples/issuer'
  }
}

Credits and inspiration :

References

  • FHIR: FHIR is a standard for health care data exchange.

shc-protocol's People

Contributors

olalonde avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

moukaila

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.