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

@phantom/api-key-stamper

v1.0.2

Published

API key stamper for Phantom Wallet SDK

Downloads

8,693

Readme

@phantom/api-key-stamper

API key stamper for authenticating requests to Phantom Wallet API.

Installation

npm install @phantom/api-key-stamper
# or
yarn add @phantom/api-key-stamper

Usage

The ApiKeyStamper is used to sign HTTP requests with Ed25519 signatures for authentication with Phantom's API.

Basic Usage

import { ApiKeyStamper } from "@phantom/api-key-stamper";
import { PhantomClient } from "@phantom/client";

// Create a stamper with your secret key
const stamper = new ApiKeyStamper({
  apiSecretKey: "your-base58-encoded-secret-key",
});

// Use it with PhantomClient
const client = new PhantomClient(
  {
    apiBaseUrl: "https://api.phantom.app/v1/wallets",
    organizationId: "your-org-id",
  },
  stamper,
);

// Now all requests will be automatically signed
const wallet = await client.createWallet("My Wallet");

With Server SDK

The @phantom/server-sdk package uses this stamper internally:

import { ServerSDK } from "@phantom/server-sdk";

const sdk = new ServerSDK({
  organizationId: "your-org-id",
  appId: "your-app-id",
  apiBaseUrl: "https://api.phantom.app/v1/wallets",
  apiPrivateKey: "your-base58-encoded-secret-key",
});

// The SDK automatically creates and uses an ApiKeyStamper
const wallet = await sdk.createWallet("My Wallet");

How it Works

  1. The stamper takes your base58-encoded Ed25519 secret key
  2. For each request, it signs the request body with the secret key
  3. The stamp is added to the request headers as X-Phantom-Stamp containing:
    • publicKey: Base64url-encoded public key
    • signature: Base64url-encoded signature
    • kind: Always "PKI" for this authentication method
  4. The entire stamp object is JSON-encoded and then base64url-encoded
  5. The server verifies the signature to authenticate the request

Example Stamp Structure

Before encoding, the stamp object looks like:

{
  "publicKey": "base64url-encoded-public-key",
  "signature": "base64url-encoded-signature",
  "kind": "PKI"
}

This JSON is then base64url-encoded and sent as the X-Phantom-Stamp header.

Security Notes

  • Keep your secret key secure and never expose it in client-side code
  • Only use this stamper in server-side applications
  • The secret key should be stored securely (e.g., in environment variables)

Development

Running Tests

npm test

The test suite includes:

  • Constructor validation with valid/invalid keys
  • Header addition and preservation
  • Different data types (string, object, undefined)
  • Stamp structure validation
  • Cryptographic signature verification
  • Base64url encoding/decoding utilities
  • Edge cases and error handling

API Reference

ApiKeyStamper

class ApiKeyStamper {
  constructor(config: ApiKeyStamperConfig);
  stamp(config: AxiosRequestConfig): Promise<AxiosRequestConfig>;
}

interface ApiKeyStamperConfig {
  apiSecretKey: string; // Base58-encoded Ed25519 secret key
}