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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@cardid/webcard

v0.4.1

Published

Smart card browser extension library - enables web applications to communicate with local smart card readers via APDU commands

Readme

Smart Card Browser Extension

This smart card browser extension is an attempt to provide a bridge between the JavaScript world that a Web developer is familiar with, and the native smart card subsystems available in desktop platforms. It works in Windows 10 and 11, macOS and Linux.

The idea is that a Web developer who wants to have low level access to smart cards in the machine where the browser is running would add a webcard.js file to the page. That script would in turn check if the extension is installed and if not prompt the user to install it.

The extension adds a webcard object to navigator and through it navigator.webcard.readers provides a list of the smart card reader objects available in the machine. Each reader has a name and an atr if there is a card inserted on it.

reader has three methods:

  • connect to establish a connection with the inserted card. It receives an optional argument to indicate if the connection should be exclusive or not (shared) the default is true
  • transcieve that sends the APDU passed as a hexidecimal string and returs the response also as a hexadecimal string
  • disconnect closes the connection

Quick Start

Step 1: Install the Extension

Download and run the installer for your platform:

Step 2: Add WebCard to Your Page

Option A: CDN (recommended)

<script src="https://cdn.jsdelivr.net/npm/@cardid/webcard/dist/webcard.iife.js"></script>

Option B: ES Module

<script type="module">
  import 'https://cdn.jsdelivr.net/npm/@cardid/webcard/dist/webcard.min.js';
  // navigator.webcard is now available
</script>

Option C: npm

npm install @cardid/webcard
import '@cardid/webcard';

Step 3: List Readers

const readers = await navigator.webcard.readers();
console.log(readers); // [{name: "Reader Name", atr: "", ...}, ...]

Step 4: Detect Card Events

navigator.webcard.cardInserted = (reader) => {
  console.log(`Card in ${reader.name}, ATR: ${reader.atr}`);
};

navigator.webcard.cardRemoved = (reader) => {
  console.log(`Card removed from ${reader.name}`);
};

Step 5: Communicate with Card

// Connect (true = shared mode, false = exclusive)
await reader.connect(true);

// Send APDU command (hex string)
const response = await reader.transceive('FFCA000000');
console.log(response); // "9000" or data + status

// Disconnect
await reader.disconnect();

Reader Events

navigator.webcard.readersConnected = (count) => { /* USB reader plugged in */ };
navigator.webcard.readersDisconnected = (count) => { /* USB reader unplugged */ };

Installing (Development)

Currently this development version requires manual installation of the unpacked extension:

  1. Build the native client for your platfrom, running either make (macOS) or MSBuild webcard.vcxproj (Windows) in the native folder
  2. Install the native client running install.sh (macOS) or install.bat (Windows) in the native folder
  3. Open Chrome -> Extensions, enable developer mode and add the unpacked extension from the extension folder.
  4. Open the example page, for example running python3 -m http.server from the example folder and then navigate to http://localhost:8000

Native Messages

Messages to native:

{i: 'string', c: integer, r: integer, a: 'string', p: integer}

i: unique message identifier c: command 1-list readers, 2-connect, 3-disconnect, 4-transcieve r: index of reader in reader list a: hex cAPDU to send to the card, sent only for c: 4 p: parameter, share mode for connect, sent only for c: 2

Messages from native:

{i: 'string', e: integer, r: integer, d: [array]|'string'}

i: unique message identifier, to link the response. Empty string on reader events e: reader event 1-card insert, 2-card remove. Sent only for reader events r: reader index for reader events d: data 1-string array with list of readers, 2-card atr, 4-hex rAPDU

Alternatives

There are apparently many options for smart card extensions in the Chrome store. But I could not figure out how to use them for raw APDU exchange. Maybe one of those is more suitable for your project.