npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

dcc-wasm

v0.2.0

Published

Parse Digital Covid Certificates with WebAssembly

Downloads

5

Readme

Parse a digital covid certificate

types version licence

This is a WebAssembly (wasm) package to parse a European Digital Covid Certificate (DCC). The source is written in Rust, compiled to webassembly. Signatures are also being verified.

Installation

Use your favourite package manager to use this package in your javascript projects.

npm install dcc-wasm --save

webpack >= 5

Add the following to webpack.config.js

{
  module: {
    rules: [
      {
        test: /\.wasm$/,
        type: 'webassembly/async',
      }
    ]
  },
  experiments: {
    asyncWebAssembly: true
  }
}

Getting started

Here is an example on how use this package

import { parse } from "dcc-wasm"

const parseResult = parse("HC1:6BFOXN*TS0BI$ZD-PHQ7I9AD66V5B22CH9M9ESI9XBHXK-%69LQOGI.*V76GCV4*XUA2P-FHT-HNTI4L6N$Q%UG/YL WO*Z7ON15 BM0VM.JQ$F4W17PG4.VAS5EG4V*BRL0K-RDY5RWOOH6PO9:TUQJAJG9-*NIRICVELZUZM9EN9-O9:PICIG805CZKHKB-43.E3KD3OAJ6*K6ZCY73JC3KD3ZQTWD3E.KLC8M3LP-89B9K+KB2KK3M*EDZI9$JAQJKKIJX2MM+GWHKSKE MCAOI8%MCU5VTQDPIMQK9*O7%NC.UTWA6QK.-T3-SY$NCU5CIQ 52744E09TBOC.UKMI$8R+1A7CPFRMLNKNM8JI0JPGN:0K7OOBRLY667SYHJL9B7VPO:SWLH1/S4KQQK0$5REQT5RN1FR%SHPLRKWJO8LQ84EBC$-P4A0V1BBR5XWB3OCGEK:$8HHOLQOZUJ*30Q8CD1");

if(!parseResult.successful || !parseResult.signature_valid) {
  console.log(parseResult.error)
}

console.log(parseResult.data)

Would result in:

{
  "1": "DE",
  "4": 1643356073,
  "6": 1622316073,
  "-260": {
    "1": {
      "r": [
        {
          "ci": "URN:UVCI:01DE/5CWLU12RNOB9RXSEOP6FG8#W",
          "is": "Robert Koch-Institut",
          "co": "DE",
          "tg": "840539006",
          "fr": "2021-01-10",
          "df": "2021-05-29",
          "du": "2021-06-15"
        }
      ],
      "dob": "1964-08-12",
      "nam": {
        "fn": "Mustermann",
        "gn": "Erika",
        "fnt": "MUSTERMANN",
        "gnt": "ERIKA"
      },
      "ver": "1.0.0"
    }
  }
}

The specifications of this data can be found here

ParsingResult

| Property | Type | Description | |-----------------|---------|-------------------------------------------------------| | successful | bool | Will be true if the data could be parsed successfully | | signature_valid | bool | Will be true if the signature could be verifyed | | kid | string | Issuer identifier | | algorithm | number | The algorithm to sign the data | | data | unknown | The data in the health certificate |

Building from source

  1. Clone repository
  2. Install wasm-pack by running curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh in your terminal
  3. Run wasm-pack build --target nodejs --outdir package/node to build the wasm package for a nodejs environment
  4. Run wasm-pack build --outdir package/webpack to build the wasm package a browser package

Running tests

Rust

  • wasm-pack test --node
  • wasm-pack test --firefox --headless

Javascript

Follow these steps from the root dir to run the javascript tests

  • wasm-pack build --target nodejs --outdir package/node to build
  • change directory to package cd package
  • npm install
  • npm run test to run the tests