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

@digital-passports/javascript-sdk

v1.5.0

Published

JavaScript SDK for interacting with the Digital Passport Hub REST API.

Readme

Digital Passport Hub JavaScript SDK

Easily interact with the Digital Passport Hub REST API from your Node.js or browser applications.

Installation

npm install @digital-passports/javascript-sdk

Usage

Node.js (Server)

Use this approach for server-side applications (Node.js, serverless, backend scripts):

const { DigitalPassport } = require('@digital-passports/javascript-sdk');

const dpp = new DigitalPassport({ apiKey: 'your_api_key' });

(async () => {
  const passports = await dpp.listPassports();
  console.log(passports);
})();

Browser (Frontend)

Use this approach for web applications running in the browser:

With a Bundler (Webpack, Vite, Parcel, etc.)

import { DigitalPassport } from '@digital-passports/javascript-sdk';

const dpp = new DigitalPassport({ apiKey: 'your_api_key' });

Directly in HTML (via CDN or UMD bundle)

<script src="https://unpkg.com/@digital-passports/javascript-sdk/dist/digital-passport-hub-javascript-sdk.umd.js"></script>
<script>
  const dpp = new window.DigitalPassport({ apiKey: 'your_api_key' });
  dpp.listPassports().then(console.log);
</script>

When to Use Each Module

  • Node.js/Server: Use the standard import (require or import) for any backend or serverless environment. The SDK will automatically use Node.js-compatible HTTP requests.
  • Browser:
    • If using a modern build tool (Webpack, Vite, etc.), use the ESM import (import { DigitalPassport } ...).
    • If you want to include the SDK directly in an HTML page (no build step), use the UMD bundle from the dist/ directory or a CDN. The SDK will attach itself to window.DigitalPassport.

API Reference

new DigitalPassport(options)

  • options.apiKey (required): Your API key
  • options.environment (optional): Defaults to 'production'

listPassports()

Returns a paginated list of all Digital Product Passports.

createPassport(data)

Creates a new Digital Product Passport.

  • data: Object with at least sku and name fields

Error Handling

All methods throw errors with detailed messages if the API request fails.

Enhanced Error Codes

The SDK provides enhanced error codes on all errors thrown as DigitalPassportError:

  • All error codes are available as the exported ErrorCode enum from the SDK.

| Code | Description | |------------------|------------------------------------------------------------------| | ErrorCode.NETWORK_ERROR | A network error occurred (DNS, offline, CORS, etc.) | | ErrorCode.VALIDATION_ERROR | Invalid or missing user-supplied data, or 4xx validation errors | | ErrorCode.AUTH_ERROR | Authentication or authorization error (401/403) | | ErrorCode.NOT_FOUND | Resource not found (404) | | ErrorCode.SERVER_ERROR | Server-side error (5xx) | | ErrorCode.HTTP_ERROR | Other HTTP errors (non-2xx, not covered above) | | ErrorCode.UNEXPECTED_ERROR | An unexpected error occurred (e.g., code bug, unknown exception) |

You can use these codes to handle errors more precisely:

import { ErrorCode } from '@digital-passports/javascript-sdk';

try {
  await dpp.listPassports();
} catch (err) {
  if (err.code === ErrorCode.NETWORK_ERROR) {
    // Show a network error message to the user
  } else if (err.code === ErrorCode.HTTP_ERROR) {
    // Handle API errors (e.g., invalid API key, 404, etc.)
  } else {
    // Handle unexpected errors
  }
}

TypeScript Support

Type definitions are included for autocompletion and type safety.

License

MIT