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

expo-secure-signing

v0.3.0

Published

Secure signing for Expo using device hardware capabilities

Readme

expo-secure-signing

⚠️ Please note that the module is currently in beta and is not suitable for production.

Secure, easy to audit, device-backed ECDSA P‑256 signing for Expo / React Native apps. Also integrates with system biometric authentication and device passcode.

This module stores private keys in the platform’s protected key storage:

  • Android: backed by the Android Keystore system (docs). When available, it prefers StrongBox.
  • iOS: backed by the Secure Enclave (docs).

The private key never leaves the keystore / secure hardware; the module only exposes public key export, sign, and verify operations.

Platform support

  • iOS: iOS 15.1+
  • Android: minSdk 24+
  • Expo Go: not supported (requires a native build / custom dev client)

Installation

Install the package in your app:

npx expo install expo-secure-signing

Usage without biometric/passcode authentication

import SecureSigning, {
  AuthCheckResult,
  GenerateKeyPairResult,
  SignMethod,
} from "expo-secure-signing";

const alias = "my-key";

// 1) Create (or reuse) a device-backed P‑256 key pair
const res = await SecureSigning.generateKeyPair(alias);
if (res === GenerateKeyPairResult.NOT_AVAILABLE) {
  throw new Error("Secure signing is not available on this device.");
}

// 2) Export the public key
// - Default: Base64 of DER SubjectPublicKeyInfo (SPKI)
// - Optional: PEM (-----BEGIN PUBLIC KEY----- ...), wrapped at 64 chars/line
const publicKey = SecureSigning.getPublicKey(alias, { format: "PEM" });
if (!publicKey) throw new Error("Missing key");

// 3) Sign and verify (signature is Base64-encoded DER ECDSA signature)
const message = "hello";
const signatureBase64 = await SecureSigning.sign(alias, message);
if (!signatureBase64) throw new Error("Signing failed");
const ok = SecureSigning.verify(alias, message, signatureBase64);

Usage with biometric/passcode authentication

import SecureSigning, {
  AuthCheckResult,
  GenerateKeyPairResult,
  SignMethod,
} from "expo-secure-signing";

const alias = "my-auth-key";

// 1) Optional but recommended: check auth capability first
const authStatus = SecureSigning.isAuthCheckAvailable();
if (authStatus !== AuthCheckResult.AVAILABLE) {
  throw new Error(`Authentication not available: ${authStatus}`);
}

// 2) Export the public key
const created = await SecureSigning.generateKeyPair(alias, {
  requireAuthentication: true,
  // iOS: choose auth method when generating the key.
  authMethod: SignMethod.PASSCODE_OR_BIOMETRIC,
});

if (
  created === GenerateKeyPairResult.NOT_AVAILABLE
) {
  throw new Error("Secure signing is not available on this device.");
}

// 3) Sign and verify with passcode/biometric prompt
const signature = await SecureSigning.sign(alias, "sensitive payload", {
  // Android: choose auth method and optional prompt text when signing.
  authMethod: SignMethod.PASSCODE_OR_BIOMETRIC,
  promptTitle: "Sign message",
  promptSubtitle: "Authenticate to continue",
});

If you want to allow Face ID on iOS, add NSFaceIDUsageDescription in your app config:

{
  "ios": {
    "infoPlist": {
      "NSFaceIDUsageDescription": "We use Face ID to secure your data."
    }
  }
}

API (all exposed functions)

The default export is the native module instance:

import SecureSigning from "expo-secure-signing";

isAuthCheckAvailable(): AuthCheckResult

Checks if biometric/passcode authentication is available on the current device.

  • Returns:
    • AuthCheckResult.AVAILABLE
    • AuthCheckResult.NO_HARDWARE
    • AuthCheckResult.UNAVAILABLE

generateKeyPair(alias: string, options?: GenerateKeyPairOptions): Promise<GenerateKeyPairResult>

Creates a new ECDSA P‑256 key pair for the given alias, if it doesn’t already exist.

  • Returns:

    • GenerateKeyPairResult.KEY_PAIR_GENERATED
    • GenerateKeyPairResult.KEY_PAIR_ALREADY_EXISTS
    • GenerateKeyPairResult.NOT_AVAILABLE (e.g. secure hardware / keystore APIs not available)
  • Options:

    • requireAuthentication?: boolean (default: false)
    • authMethod?: SignMethod (default: SignMethod.PASSCODE_OR_BIOMETRIC, iOS)

getPublicKey(alias: string, options?: { format?: "DER" | "PEM" }): string | null

Returns the public key for alias, or null if the key doesn’t exist.

removeKeyPair(alias: string): boolean

Deletes the key pair for alias.

  • Returns: true if the entry existed and was deleted, otherwise false.

aliases(): string[]

Lists aliases currently stored by the platform keystore/keychain for this key type.

sign(alias: string, data: string, options?: SignOptions): Promise<string | null>

Signs data with the private key stored under alias.

  • Algorithm: ECDSA P‑256 with SHA‑256 (SHA256withECDSA)

  • Input: data is treated as a UTF‑8 string message

  • Returns: Base64 of the DER/X9.62 encoded ECDSA signature, or null if key is missing

  • Options:

    • promptTitle?: string (default: "Unlock", Android)
    • promptSubtitle?: string (default: "Enter your PIN to continue", Android)
    • authMethod?: SignMethod (default: SignMethod.PASSCODE_OR_BIOMETRIC, Android)

If the key doesn’t exist, native code returns null (which may surface as a runtime error in JS). Ensure you call generateKeyPair() first and/or check getPublicKey() before signing.

verify(alias: string, data: string, signature: string): boolean | null

Verifies a Base64 signature for data using the key pair under alias.

  • Returns:
    • true / false if the key exists and verification ran
    • null if the key doesn’t exist

Data formats

  • Public key: Base64 of DER SPKI for P‑256 (portable to most crypto libraries).
  • Signature: Base64 of DER/X9.62 ECDSA signature (ASN.1 sequence of r and s).