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

@passkeybridge/vc-wallet-sdk

v0.6.1

Published

Official PasskeyBridge SDK for issuing and verifying W3C Verifiable Credentials (JWT-VC + SD-JWT-VC) against the PasskeyBridge identity attestation platform.

Readme

@passkeybridge/vc-wallet-sdk

npm version license

Official TypeScript SDK for the PasskeyBridge Verifiable Credentials platform. Issue and verify W3C JWT-VC and SD-JWT-VC credentials, hold them in a local encrypted wallet, prove holder possession with Key-Binding JWTs, run the OID4VCI issuance flow, and manage credential lifecycle from any Node.js, Deno, browser, or edge runtime with the fetch API.

This README describes 0.6.1. The 0.x line is still moving: see Versioning and stability before you pin.

Installation

npm install @passkeybridge/vc-wallet-sdk
# or
pnpm add @passkeybridge/vc-wallet-sdk
# or
bun add @passkeybridge/vc-wallet-sdk

Requires Node.js 20.19 or newer, which is what package.json declares in engines, or any other runtime with a global fetch. The package declares no runtime dependencies.

Quick start

import { PBWallet } from "@passkeybridge/vc-wallet-sdk";

const wallet = new PBWallet({
  apiKey: process.env.PB_API_KEY!,        // pb_live_... from the dashboard Keys tab
  tenantId: process.env.PB_TENANT_ID!,    // your tenant UUID
});

const issued = await wallet.issue({
  subjectDid: "did:web:example.com:users:alice",
  credentialType: "IdentityAttestation",
  claims: { verificationLevel: "enhanced" },
  expirationDays: 90,
});

console.log(issued.credential.credential_id);
console.log(issued.credential.jwt);

Constructor

new PBWallet(options)

| Option | Type | Default | Description | | ------------------ | ---------------- | --------------------------------- | ----------------------------------------------- | | apiKey | string | none | Tenant API key (pb_live_... / pb_test_...). Optional; see Required API key scopes. | | tenantId | string | required | Your PasskeyBridge tenant UUID. | | baseUrl | string | https://api.passkeybridge.io/v1 | Override only for staging or self-host. | | credentialIssuer | string | https://api.passkeybridge.io/v1 | The issuer identifier OID4VCI proofs are addressed to. Not the transport URL. | | fetch | typeof fetch | global fetch | Inject a custom fetch (Undici, polyfill). | | timeoutMs | number | 15000 | Per-request timeout, covering the response body. | | persist | boolean | true | Use IndexedDB when available. See below. | | storage | WalletStorage | auto | Replace the built-in storage backend entirely. |

PBWallet.version is a static string carrying the package version, useful in bug reports and client telemetry.

Storage selection is persist && hasIndexedDb(). In a browser you get IndexedDbStorage; in Node, Deno, an edge runtime, or SSR you get MemoryStorage, which lives for the life of the process. Setting persist: false forces memory even in a browser. To persist outside a browser (React Native, a Node CLI, a server-side wallet), implement the WalletStorage interface and pass it as storage.

The IndexedDB database is named pb-vc-wallet:<tenantId> since 0.6.0, so two wallets for two tenants on one origin do not share records. Releases before 0.6.0 used one database, pb-vc-wallet, for every wallet on the origin; to keep reading it, pass storage: new IndexedDbStorage(), whose default name is the exported LEGACY_IDB_NAME.

The SDK never follows an HTTP redirect. A 3xx from the API is answered as invalid_response, because the tenant identity headers are custom and a followed cross-origin redirect would carry them, and a 307 or 308 the request body, to the new origin.

Issuance

wallet.issue(params)

Issues a JWT-VC by default, or an SD-JWT-VC when disclosureFrame is present.

const cred = await wallet.issue({
  subjectDid: "did:web:example.com:users:alice",
  credentialType: "IdentityAttestation",
  claims: { verifiedAt: "2026-05-25T00:00:00Z", verificationLevel: "enhanced" },
  expirationDays: 90,
  disclosureFrame: { verifiedAt: true },        // switches format to SD-JWT-VC
  holderPublicJwk: { kty: "EC", crv: "P-256", x: "...", y: "..." },
});

When disclosureFrame is present (empty or not) or holderBinding: true is passed, and you do not supply holderPublicJwk, the SDK generates an ECDSA P-256 key pair, sends the public JWK with the request, and keeps the private key in the wallet's storage, memory included. That private key is what later lets presentWithBinding produce a KB-JWT, so it must survive for the credential to remain presentable.

Returns { credential, pqc, sd?, record_id, latency_ms }, plus, when the SDK generated a key, holderBound (the credential's cnf.jwk is that key) and holderKeyPersisted (the private half was stored). The key is stored only when the credential is bound to it. Treat holderKeyPersisted: false as a credential to re-issue: it can never produce a KB-JWT. pqc carries the signing algorithm and key fingerprint; sd is present only for SD-JWT-VC.

Presentation and verification

wallet.verifyPresentation(params) and wallet.verify(params)

verify is an alias. Verification runs server-side.

const result = await wallet.verifyPresentation({
  vpToken: "eyJ...",
  expectedNonce: "...",          // optional replay check
  presentationDefinition: pd,    // optional Presentation Exchange definition
});

if (result.verified) {
  console.log("cross-reference id", result.crossReferenceId);
}

wallet.verifyBatchPresentation(vpTokens, presentationDefinition?, options?)

Up to 20 VP tokens against one definition in a single round trip. Returns a VerifyResult extended with batch and tokenCount.

wallet.createPresentationRequest(definition, responseUri?)

Builds an OpenID4VP authorization request from a presentation definition. Returns { authorizationRequest, state, nonce, presentationDefinitionId }.

Local wallet

const stored = await wallet.store(issued.credential, { source: "onboarding" });
const fromJwt = await wallet.storeJwt("eyJ...");   // out-of-band credential

await wallet.list({ type: "IdentityAttestation", validOnly: true });
await wallet.get("urn:uuid:...");
await wallet.remove("urn:uuid:...");               // drops the holder key too
await wallet.clearAll();

| Method | Notes | | ------ | ----- | | store(credential, metadata?) | Persist an IssuedCredential. Returns the stored record. | | storeJwt(jwt, metadata?) | Persist a raw JWT-VC or SD-JWT-VC, extracting metadata from the payload. | | list(filter?) | Filter by type, issuer, and validOnly (drops past expiresAt). | | get(credentialId) | Returns null when absent, rather than throwing. | | remove(credentialId) | Removes the holder key, then the credential. Rejects if the key cannot be removed. | | clearAll() | Wipes every holder key, then every credential. Rejects if the key wipe fails. |

A credential id is chosen by its issuer. store and storeJwt refuse a DIFFERENT credential under an id that is already held (invalid_params), whatever issuer it names: the iss string in a JWT is not verified locally, so it cannot be the authority to overwrite. Re-storing the exact same JWT (new metadata, a refreshed record) needs nothing; replacing takes an explicit decision, storeJwt(jwt, metadata, { replace: true }). The insert is atomic in both built-in backends, so two concurrent stores of one id cannot both succeed. A credential without a jti receives a random urn:local: id; an SD-JWT-VC's vct is recorded as its type.

In the browser, records are encrypted at rest with a non-extractable AES-256-GCM key held in IndexedDB. What that protects against is a copy of the database FILES read outside the browser (a backup, a forensic dump of the origin's storage): the ciphertext is useless without the key object, and the browser serialises a non-extractable key in a form only the browser can turn back into a usable key. It is not device binding: a whole browser profile copied to another machine and opened in the same browser has the key objects back. Nor does it protect against script running in the wallet's own origin, which can use the key exactly as the wallet does. Holder private keys are held as non-extractable CryptoKeys too: same-origin script, and a copied profile, can sign with them there, but can never read the key bytes out. That holds whether the wallet built its backend or you passed new IndexedDbStorage() or new MemoryStorage() yourself; only a backend of your own receives an exportable JWK, since it may serialise to JSON. Rows written by a release before at-rest encryption existed, and holder keys held as exportable JWKs by 0.5.0, are rewritten in their protected form the first time they are read, without ever putting back a row a concurrent remove or clearAll deleted; a rewrite that could not happen is reported through new IndexedDbStorage(name, { onLegacyRowRetained }), which defaults to a console.warn. MemoryStorage is not encrypted, because it is already process-local and dies with the process.

Holder binding

wallet.hasHolderBinding(credentialId)

True when a locally held private key is bound to that credential: the record holds a private half and, when the credential is stored too, its cnf.jwk names that key. Worth checking before you promise a verifier a key-bound presentation.

wallet.presentWithBinding(credentialId, audience, nonce, disclosureNames?)

Returns an SD-JWT-VC with a Key-Binding JWT appended, proving possession of the bound key. Omit disclosureNames (or pass an empty array) to reveal every disclosure; otherwise only the named claims are included, together with the disclosures they hang from, so a nested claim such as city inside a selectively disclosable address travels with address. Throws invalid_params when the credential carries no cnf, or its cnf names a key other than the one held for it, because such a presentation could never verify.

const presentation = await wallet.presentWithBinding(
  "urn:uuid:...",
  "did:web:verifier.example",
  authRequest.nonce,
  ["verifiedAt"],              // reveal this claim only
);

wallet.selectCredentials(definition) and wallet.assembleBatchTokens(ids)

selectCredentials matches the local wallet against a presentation definition and returns the credentials that satisfy it, one per input descriptor, in descriptor order. It matches the holder's view of each credential, with SD-JWT disclosures folded into the issuer payload, so a constraint on a selectively disclosable claim can match; a token whose disclosures reference one digest from several places is malformed and is never matched. Distinct credentials are preferred and the search backtracks when an early choice would leave a later descriptor nothing, but Presentation Exchange does not require distinct credentials, so one may serve several descriptors when nothing else fits. When some descriptor has no fitting credential the list is partial; assignCredentials(definition, candidates) returns { complete, assignments } naming it. const and enum compare JSON values structurally. assembleBatchTokens resolves ids into their JWT strings for a batch verification call.

Status and lifecycle

wallet.checkStatus(credentialId)

Returns one of active | suspended | revoked | expired | unknown.

wallet.batchCheckStatus(credentialIds)

Up to 100 ids per call.

const { credentials, checkedAt } = await wallet.batchCheckStatus([
  "urn:uuid:...",
  "urn:uuid:...",
]);

wallet.revoke / suspend / reinstate(credentialId, reason?)

await wallet.revoke("urn:uuid:...", "key_compromise");

wallet.refreshStatusList(issuerDid?)

Forces a StatusList2021 rebuild. Returns { etag, totalCredentials, revokedCount, generatedAt, statusListCredential }.

OID4VCI

The issuer creates an offer; a wallet redeems it with the pre-authorized code.

wallet.createCredentialOffer(params) (issuer side)

const offer = await wallet.createCredentialOffer({
  credentialType: "IdentityAttestation",
  subjectDid: "did:web:example.com:users:alice",
  claims: { verificationLevel: "enhanced" },
  formats: ["vc+sd-jwt"],
});

// Render offer.credentialOfferUri as a QR code.
console.log(offer.preAuthorizedCode, offer.expiresAt);

wallet.redeemOffer(preAuthorizedCode, format?, autoStore?) (wallet side)

Runs the whole pre-authorized code flow: token exchange, then the credential request with an auto-generated holder proof for SD-JWT formats, then storage of the holder key and, when autoStore is true, of the credential. The proof is addressed to credentialIssuer, not to baseUrl.

const redeemed = await wallet.redeemOffer(offer.preAuthorizedCode, "vc+sd-jwt");

console.log(redeemed.credential, redeemed.format);
if (redeemed.stored) console.log("saved as", redeemed.stored.credentialId);

format defaults to "jwt_vc_json" and autoStore to true.

An SD-JWT must come back bound to the key the proof was signed with: a credential with no cnf.jwk, or one naming another key, is refused with invalid_response before anything is stored.

Check redeemed.holderKeyPersisted on an SD-JWT redemption. The key is filed under the credential's jti whether or not the credential was stored, so a later storeJwt of the same credential finds it. false means the credential arrived but its binding key did not survive, so it can never produce a KB-JWT and should be re-issued rather than kept; redeemed.storeError says why the credential or the key was not stored.

Requires 0.5.0 or later. In every earlier published version this method returned 401 unconditionally: the credential endpoint is OAuth-protected and the SDK discarded the access token it had just been issued.

wallet.getIssuerMetadata(tenantSlug?)

Fetches the OID4VCI issuer metadata document (credential configurations and supported formats). No API key scope required.

Exported helpers

import {
  decodeCredential,
  generateHolderKeyPair,
  createKbJwt,
  createOid4vciProof,
  splitSdJwt,
  selectDisclosures,
  selectDisclosuresWithAncestors,
  disclosureDigest,
  cnfJwk,
  samePublicJwk,
  matchCredentials,
  matchCredentialsWithDisclosures,
  assignCredentials,
  reconstructDisclosedClaims,
  decodeJwtPayload,
  resolveSimplePath,
  hasNestedQuantifier,
  patternShape,
  patternCost,
  MemoryStorage,
  IndexedDbStorage,
  createDefaultStorage,
  hasIndexedDb,
  LEGACY_IDB_NAME,
  PBWalletError,
} from "@passkeybridge/vc-wallet-sdk";

| Helper | Purpose | | ------ | ------- | | decodeCredential(jwt) | Header and payload of a JWT or SD-JWT. No signature verification. | | decodeJwtPayload(jwt) | Payload only; returns null on failure instead of throwing. | | generateHolderKeyPair(opts?) | ECDSA P-256 pair for holder binding. Extractable by default; { extractable: false } yields a privateKey that can sign but never be exported. | | cnfJwk(jwk) | Reduce a JWK to the canonical cnf subset (EC, RSA, OKP). Throws on any other type. | | samePublicJwk(a, b) | Whether two public JWKs name the same key. | | createKbJwt(sdJwt, audience, nonce, privateKey) | Sign a Key-Binding JWT with a private JWK or a CryptoKey. | | createOid4vciProof(pair, opts) | Build an OID4VCI §7.2.1 proof JWT. | | splitSdJwt(token) | Split into { issuerJwt, disclosures }, dropping any KB-JWT. | | selectDisclosures(disclosures, names?) | Filter disclosures by claim name alone. | | selectDisclosuresWithAncestors(disclosures, names?) | The same, plus every disclosure a selected one hangs from. | | disclosureDigest(encoded) | The SD-JWT digest of one encoded disclosure. | | matchCredentials(definition, candidates) | Presentation Exchange matcher over a candidate set, issuer payload only. | | matchCredentialsWithDisclosures(definition, candidates) | The same over the holder's view, disclosures folded in. | | assignCredentials(definition, candidates) | The assignment behind the matcher, with complete and one entry per descriptor. | | reconstructDisclosedClaims(jwt) | An SD-JWT payload with its disclosures folded back in. | | resolveSimplePath(obj, path) | Resolve $.a.b[0] against an object. | | hasNestedQuantifier(pattern), patternShape(pattern), patternCost(shape, length) | The bounds the matcher applies to a verifier's pattern. | | jsonEqual(a, b) | JSON value equality, as const and enum use it. | | hasIndexedDb() | Whether the runtime has usable IndexedDB. |

createOid4vciProof takes an options object:

const proof = await createOid4vciProof(pair, {
  credentialIssuer: "https://api.passkeybridge.io/v1",  // becomes `aud`
  cNonce: tokenResponse.c_nonce,
  // clientId: omit for the pre-authorized code flow
});

credentialIssuer is the value the issuer advertises as credential_issuer, which is not necessarily the URL you are calling. Leave clientId unset unless you are driving an authorization-code flow yourself: OpenID4VCI §7.2.1 requires iss to be omitted when the access token came from a pre-authorized code flow through anonymous access to the token endpoint, which is the flow this SDK implements.

matchCredentials is deliberately lightweight. It covers JSONPath field constraints with type, pattern, const, enum and contains filters, where contains requires one element that satisfies the whole subschema. Because a pattern is written by the verifier, it is treated as untrusted: patterns over 512 characters, patterns with a quantifier or an alternation anywhere inside a quantified group (? included, at any depth), values over 4096 characters, and any pattern-and-value pairing whose backtracking budget (the value length to the power of the unbounded quantifiers, times the bounded choices) exceeds 2^24 are all refused rather than matched. Two unbounded quantifiers pass at any accepted length, three up to 256 characters, four up to 64. Refusal is fail-closed, so a credential is withheld rather than offered on a pattern the matcher will not run. This removes the practical attack; it is not a proof of linear-time matching.

Deprecated: hashPhone

const phoneHash = await hashPhone("+15551234567"); // unkeyed SHA-256 hex (legacy)

This is a plain, unkeyed SHA-256. It does not match the platform's server-side keyed HMAC-SHA-256 under a server-held pepper, so it will not correlate against server-hashed identifiers, and because the phone keyspace is small an unkeyed digest is reversible by enumeration. It is not a privacy control on its own. Send the raw E.164 phone to ingest and let the platform key it. Since 2026-09-18 a digest you send as phone_hash is keyed again under the server pepper before it is stored, so it is no longer enumerable at rest, but it is still your digest on the wire and in the callback envelope, and it will not correlate with signals the platform keyed from the number. Retained only for the legacy client-supplied phone_hash path; it will be removed in a future major version.

Errors

Every failure throws PBWalletError:

try {
  await wallet.issue(params);
} catch (err) {
  if (err instanceof PBWalletError) {
    console.error(err.code, err.httpStatus, err.message, err.requestId);
  }
}

code is stable and safe to branch on: invalid_options, invalid_params, network_error, timeout, http_error, invalid_response, unauthorized, forbidden, not_found, rate_limited, server_error, decode_error.

Required API key scopes

| Scope | Used by | | ----------- | ---------------------------------------------------------------------------- | | vc_issue | issue, createCredentialOffer | | vc_verify | verifyPresentation, verify, verifyBatchPresentation, createPresentationRequest | | vc_revoke | revoke, suspend, reinstate, refreshStatusList |

No scope required for checkStatus, batchCheckStatus and getIssuerMetadata, so a verifier can resolve revocation and read issuer metadata without an API key. Since 0.6.0 apiKey is optional at construction for exactly these calls; a method that needs a key throws invalid_options before any request when the wallet has none.

redeemOffer needs no scope either. It authenticates with the pre-authorized code, exchanging it for a short-lived access token that it then presents to the credential endpoint.

Purely local methods (store, storeJwt, list, get, remove, clearAll, hasHolderBinding, presentWithBinding, selectCredentials, assembleBatchTokens) make no network call and need no scope.

Versioning and stability

The SDK follows semver. The 0.x line may introduce breaking changes between minor versions as the surface fills out, so pin to the current minor (^0.6.0) rather than to 0.x broadly, and read the CHANGELOG before moving between minors.

License

Apache-2.0 © PasskeyBridge LLC.