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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@zerodev/signer-core

v0.0.1-alpha.2

Published

Functional KMS SDK built on Turnkey

Readme

@zerodev/signer-core

TypeScript SDK for managing wallet signing keys with Turnkey's non-custodial infrastructure.

Features

  • Multiple authentication methods (Passkey, Email, OTP, OAuth)
  • Non-custodial key management via Turnkey
  • Automatic session refresh
  • Multi-session support
  • viem integration for Ethereum operations
  • TypeScript with full type safety

Installation

npm install @zerodev/signer-core
# or
yarn add @zerodev/signer-core
# or
pnpm add @zerodev/signer-core

Quick Start

import { createZeroDevSigner } from '@zerodev/signer-core';

// 1. Initialize the SDK
const signer = await createZeroDevSigner({
  projectId: 'your-project-id',
});

// 2. Authenticate with passkey
await signer.auth({
  type: 'passkey',
  email: '[email protected]',
  mode: 'register'  // or 'login' for existing users
});

// 3. Get wallet account (viem LocalAccount)
const account = await signer.toAccount();
console.log('Wallet address:', account.address);

// 4. Sign a message
const signature = await account.signMessage({
  message: 'Hello World'
});

// 5. Send a transaction
import { createWalletClient, http } from 'viem';
import { sepolia } from 'viem/chains';

const walletClient = createWalletClient({
  account,
  chain: sepolia,
  transport: http()
});

const hash = await walletClient.sendTransaction({
  to: '0x...',
  value: parseEther('0.001')
});

Authentication Methods

Passkey (WebAuthn)

// Register new passkey
await signer.auth({
  type: 'passkey',
  email: '[email protected]',
  mode: 'register'
});

// Login with existing passkey
await signer.auth({
  type: 'passkey',
  email: '[email protected]',
  mode: 'login'
});

Email Magic Link

// Send magic link
await signer.auth({
  type: "otp",
  mode: "sendOtp",
  email: "[email protected]",
  contact: { type: "email", contact: email },
  emailCustomization: {
    magicLinkTemplate: 'https://yourapp.com/verify?otp=%s'
  },
});

// After user clicks link, parse otp from url params
await signer.auth({
  type: "otp",
  mode: "verifyOtp",
  otpId,
  otpCode: otp, // OTP from magic link url
  subOrganizationId,
});

Email OTP

// Step 1: Send OTP code
const data = await signer.auth({
  type: 'otp',
  mode: 'sendOtp',
  email: '[email protected]',
  contact: { type: 'email', contact: '[email protected]' }
});

// Step 2: Verify OTP code
await signer.auth({
  type: 'otp',
  mode: 'verifyOtp',
  otpId: data.otpId,
  otpCode: '123456',
  subOrganizationId: data.subOrganizationId
});

OAuth (Google)

// After getting credential from Google OAuth
await signer.auth({
  type: 'oauth',
  provider: 'google',
  credential: googleCredential  // JWT from Google
});

Session Management

// Get active session
const session = await signer.getSession();
console.log('Session expires:', new Date(session.expiry));

// Refresh session (extends expiry)
const newSession = await signer.refreshSession();

// Get all sessions
const allSessions = await signer.getAllSessions();

// Switch to different session
await signer.switchSession(sessionId);

// Clear specific session
await signer.clearSession(sessionId);

// Logout (clear all sessions)
await signer.logout();

Configuration Options

interface ZeroDevSignerConfig {
  projectId: string;                  // Required: Your project ID
  organizationId?: string;            // Turnkey organization ID
  proxyBaseUrl?: string;              // KMS backend URL
  iframeUrl?: string;                 // Turnkey iframe URL (default: auth.turnkey.com)
  iframeContainer?: HTMLElement;      // Custom iframe container
  iframeElementId?: string;           // Custom iframe element ID
  sessionStorage?: StorageAdapter;    // Custom storage (default: localStorage)
  rpId?: string;                      // WebAuthn RP ID (default: window.location.hostname)
}

Custom Storage

import { createZeroDevSigner, type StorageAdapter } from '@zerodev/signer-core';

// Implement custom storage (e.g., IndexedDB, AsyncStorage)
const customStorage: StorageAdapter = {
  getItem: async (key: string) => {
    // Your implementation
    return value;
  },
  setItem: async (key: string, value: string) => {
    // Your implementation
  },
  removeItem: async (key: string) => {
    // Your implementation
  }
};

const signer = await createZeroDevSigner({
  projectId: 'your-project-id',
  sessionStorage: customStorage
});

Export Wallet

Export your wallet's seed phrase using Turnkey's secure iframe:

Setup: Add a container element to your HTML:

<div id="export-container"></div>

Usage:

import { createIframeStamper } from '@zerodev/signer-core';

// 1. Create export iframe stamper
// IMPORTANT: Container element must exist in DOM first!
const exportIframeStamper = await createIframeStamper({
  iframeUrl: 'https://export.turnkey.com',
  iframeContainer: document.getElementById('export-container'),
  iframeElementId: 'export-iframe'
});

// 2. Initialize iframe and get target public key
const targetPublicKey = await exportIframeStamper.init();

// 3. Get encrypted export bundle from SDK
const { exportBundle, organizationId } = await signer.exportWallet(targetPublicKey);

// 4. Inject into iframe to display seed phrase
await exportIframeStamper.injectWalletExportBundle(exportBundle, organizationId);

// The seed phrase is now visible in the 'export-container' div

Note: The SDK handles Turnkey API calls. The iframe handles secure decryption and display. The seed phrase never touches your JavaScript code.

TypeScript Types

import type {
  ZeroDevSignerSDK,
  ZeroDevSignerConfig,
  ZeroDevSignerSession,
  AuthParams,
  StamperType,
  ExportWalletParameters,
  ExportWalletReturnType
} from '@zerodev/signer-core';

React Integration

For React apps, see the demo implementation at zerodev-signer-demo.

Key patterns:

  • Use React Context for SDK instance
  • Handle session state with useState/useEffect
  • Auto-refresh sessions in background
  • Session expiry warnings

License

MIT

Links