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

@tradeport/signatures

v0.1.1

Published

Normalize blockchain signatures to a standard format for creating JWT tokens across Sui, Aptos, Movement, Supra, and Iota

Readme

@tradeport/signatures

A TypeScript library for normalizing blockchain signatures to a standard format across multiple chains including Sui, Aptos, Movement, Supra, and Iota to be used for passing in the correct data to TradePort's auth service to create a JWT

Features

  • 🔐 Unified interface for normalizing wallet signatures across different blockchains
  • 🎯 Type-safe TypeScript implementation
  • 🏗️ Clean, extensible architecture using the Strategy Pattern
  • ✨ Support for Sui (with zkLogin), Aptos, Movement, and Supra
  • 🔌 Easy integration with any frontend application or SDK
  • 📦 Simple API: new SignatureNormalizer(blockchain).normalize(...)

Installation

npm install @tradeport/signatures
# or
yarn add @tradeport/signatures
# or
pnpm add @tradeport/signatures

Usage

Basic Usage

import { SignatureNormalizer } from "@tradeport/signatures";

// Create a normalizer for your blockchain
const normalizer = new SignatureNormalizer("sui");

// Normalize the signed message to a standard format
const signedMessageData = normalizer.normalize(
  signedMessage,
  walletData,
  originalMessage
);

console.log(signedMessageData);
// {
//   signature: "0x...",
//   message: "0x...",
//   publicKey: "0x...",
//   jwt?: "..." // Optional, for zkLogin or special cases
// }

Using Chain-Specific Normalizers (Advanced)

import { SuiSignatureNormalizer } from "@tradeport/signatures";

const suiNormalizer = new SuiSignatureNormalizer();
const result = suiNormalizer.normalize(signedMessage, walletData);

Type Definitions

import type {
  Blockchain,
  WalletData,
  SignedMessageData,
} from "@tradeport/signatures";

const walletData: WalletData = {
  walletAddress: "0x...",
  publicKey: "0x...",
  walletName: "Sui Wallet",
};

Supported Blockchains

| Blockchain | Identifier | Special Features | | ---------- | ------------ | ----------------------------------------- | | Sui | 'sui' | zkLogin support, wallet-specific handling | | Aptos | 'aptos' | Extensible for custom wallet formats | | Movement | 'movement' | Extensible for custom wallet formats | | Supra | 'supra' | Extensible for custom wallet formats |

Architecture

This library uses the Strategy Pattern for clean, maintainable code:

  • SignatureNormalizer - Main class that accepts blockchain type in constructor
  • BaseSignatureNormalizer - Abstract base class defining the interface
  • Chain-specific normalizers - Internal implementations for each blockchain

Standardized Output

All normalizers return a consistent SignedMessageData format:

interface SignedMessageData {
  signature: string; // The signature in appropriate format
  message: string; // The message (usually hex-encoded)
  publicKey: string; // The public key of the signer
  jwt?: string; // Optional JWT (for zkLogin or other special cases)
}

API Reference

SignatureNormalizer

constructor(blockchain: Blockchain)

Creates a new signature normalizer for the specified blockchain.

normalize(
  signedMessage: any,
  walletData: WalletData,
  originalMessage?: string
): SignedMessageData

Normalizes the signed message to a standardized format.

Extending for Custom Chains

To add support for a new blockchain:

  1. Create a new normalizer extending BaseSignatureNormalizer
  2. Implement the normalize method
  3. Add your blockchain to the Blockchain type
  4. Register it in the SignatureNormalizer constructor

Example:

import {
  BaseSignatureNormalizer,
  SignedMessageData,
  WalletData,
} from "@tradeport/signatures";

export class MyChainSignatureNormalizer extends BaseSignatureNormalizer {
  normalize(
    signedMessage: any,
    walletData: WalletData,
    originalMessage?: string
  ): SignedMessageData {
    // Your custom logic here
    return {
      signature: processedSignature,
      message: this.stringToHex(message),
      publicKey: walletData.publicKey,
    };
  }
}

Development

# Install dependencies
pnpm install

# Build the library
pnpm build

# Run linting
pnpm lint

# Fix linting issues
pnpm lint:fix

# Run tests
pnpm test

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.