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

@thru/passkey

v0.3.17

Published

WebAuthn passkey registration and signing for Thru apps across browser, popup, React Native, and server.

Downloads

2,302

Readme

@thru/passkey

WebAuthn passkey registration and signing for Thru apps across browser, popup, React Native, and server.

Installation

npm install @thru/passkey

Entry Points

  • @thru/passkey/web - browser/WebAuthn registration and signing
  • @thru/passkey/popup - popup bridge/protocol helpers for embedded browser flows
  • @thru/passkey/mobile - React Native/mobile passkey and secure-storage helpers
  • @thru/passkey/auth - higher-level app auth/store helpers
  • @thru/passkey/server - backend wallet/challenge/submit helpers

Deprecated Root Import

The root import path is deprecated:

import { registerPasskey } from '@thru/passkey';

Use explicit entry points instead:

import { registerPasskey } from '@thru/passkey/web';

The root path remains as a temporary compatibility shim and will be removed after downstream consumers migrate.

Browser Usage

This package requires a browser environment with WebAuthn support (navigator.credentials).

Register a Passkey

import { registerPasskey } from '@thru/passkey/web';

const result = await registerPasskey('alice', 'user-id-123', 'example.com');

Sign with a Known Credential

import { signWithPasskey } from '@thru/passkey/web';

const challenge = new Uint8Array(32);
const result = await signWithPasskey(credentialId, challenge, 'example.com');

Sign with a Stored Passkey

import { signWithStoredPasskey } from '@thru/passkey/web';
import type { PasskeyMetadata, PasskeyPopupContext } from '@thru/passkey/web';

const preferredPasskey: PasskeyMetadata | null = null;
const allPasskeys: PasskeyMetadata[] = [];
const context: PasskeyPopupContext = {
  appName: 'My App',
  origin: 'https://app.example.com',
};

const result = await signWithStoredPasskey(
  challenge,
  'example.com',
  preferredPasskey,
  allPasskeys,
  context
);

Capability Detection

import {
  isWebAuthnSupported,
  preloadPasskeyClientCapabilities,
  getPasskeyClientCapabilities,
  shouldUsePasskeyPopup,
} from '@thru/passkey/web';

Popup Bridge

Use the popup helpers when your browser app needs a separate approval window for embedded or iframe-based passkey flows.

Parent Side

import {
  openPasskeyPopupWindow,
  requestPasskeyPopup,
  closePopup,
  PASSKEY_POPUP_PATH,
  PASSKEY_POPUP_CHANNEL,
} from '@thru/passkey/popup';

Popup Window Side

import {
  buildSuccessResponse,
  decodeChallenge,
  getResponseError,
  toPopupSigningResult,
} from '@thru/passkey/popup';

Communication between parent and popup uses postMessage with BroadcastChannel as a fallback. The popup path defaults to /passkey/popup.

Browser Convenience Exports

@thru/passkey/web re-exports the browser-side encoding and crypto helpers used by the wallet today, including:

  • bytesToHex
  • hexToBytes
  • bytesToBase64
  • bytesToBase64Url
  • base64UrlToBytes
  • arrayBufferToBase64Url
  • base64UrlToArrayBuffer

Types

Key web types exported from @thru/passkey/web:

  • PasskeyRegistrationResult
  • PasskeySigningResult
  • PasskeyDiscoverableSigningResult
  • PasskeyStoredSigningResult
  • PasskeyMetadata
  • PasskeyClientCapabilities
  • PasskeyPopupContext

Key popup types exported from @thru/passkey/popup:

  • PasskeyPopupRequest
  • PasskeyPopupResponse
  • PasskeyPopupSigningResult
  • PasskeyPopupStoredSigningResult
  • PasskeyPopupAccount

Embedded browser recovery

Delegate publickey-credentials-get and publickey-credentials-create to the exact wallet origin in the host's Permissions-Policy header and iframe allow attribute. Unknown browser capability APIs do not prevent inline ceremonies. WebKit cross-origin creation and confirmed iframe restrictions require an explicit user action to continue in a popup; cancellation and generic security errors never trigger automatic popup fallback.

Hosted integrations can register setPasskeyRecoveryHandler(handler, reporter) from @thru/passkey/web. Render the request's retry and cancel actions in existing wallet UI. Call retry directly from a click handler: it opens the window synchronously and resumes only the pending ceremony. Keep the request's original approval mounted until completion. The returned cleanup function aborts pending work. cancelPasskeyCeremony() also cancels on host dismissal.

Without a recovery handler, restricted calls reject with PasskeyIframeRestrictionError (action and reason). All browser registration and signing functions accept promptMode: 'auto' | 'inline' | 'popup', allowPopupFallback, and signal. Explicit popup mode must be called from a user interaction. allowPopupFallback: false always prohibits popup routing, including when promptMode: 'popup' is supplied.

Only one ceremony can run per document. A failed assertion does not automatically retry after a focus error or ambiguous cancellation. Show an explicit retry in the existing approval UI. Missing stored credentials can use discoverable sign-in; popup recovery preserves the requested RP ID and selected credential.