@turnkey/indexed-db-stamper
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

@turnkey/indexed-db-stamper

npm

The @turnkey/indexed-db-stamper package enables secure request stamping using an unextractable P-256 keypair stored in the browser’s IndexedDB. It serves the same purpose as @turnkey/api-key-stamper, allowing you to sign and approve requests to Turnkey’s API, but without exposing the private key. This is ideal for long-lived browser sessions in progressive web apps (PWAs), wallet extensions, or any context where the key must remain secure and persistent across reloads.

The IndexedDbStamper generates the private key using SubtleCrypto and stores it in a non-exportable format, ensuring that it cannot be extracted or exfiltrated by application code. The keypair is stored in IndexedDB so that it can be reused in subsequent sessions.

Usage:

The IndexedDbStamper class implements the TStamper interface used by the TurnkeyClient in the @turnkey/http module. It encapsulates the logic necessary to sign activity requests and generates the appropriate HTTP headers for authentication.

import { IndexedDbStamper } from "@turnkey/indexed-db-stamper";

// Initialize the stamper and generate or load the keypair
const stamper = new IndexedDbStamper();
await stamper.init();

// Once initialized, the stamper is ready to be passed into the TurnkeyClient.
const httpClient = new TurnkeyClient(
  { baseUrl: "https://api.turnkey.com" },
  stamper,
);

Readme

Keywords

Package Sidebar

Install

npm i @turnkey/indexed-db-stamper

Weekly Downloads

3,895

Version

1.1.0

License

Apache-2.0

Unpacked Size

54.5 kB

Total Files

11

Last publish

Collaborators

  • omkar_turnkey
  • andrewtk
  • tdawson
  • moe-dev
  • zanetk
  • r-n-o
  • jack-kearney-tkhq
  • bcturnkey