Skip to content
sirosfoundationPublic

About

Wallet Messaging Protocol (WMP) TypeScript library

Resources

Security policy

Stars

0 stars

Watchers

1 watching

Forks

Repository files navigation

@sirosfoundation/wmp-js

CI OpenSSF Scorecard License

TypeScript implementation of the Wallet Messaging Protocol (WMP) — a JSON-RPC 2.0 protocol for bidirectional communication between wallet frontends and backend services.

Features

  • JSON-RPC 2.0 request/response and notification handling
  • Bidirectional peer with concurrent request tracking and timeout support
  • Pluggable transports — WebSocket and HTTP+SSE included
  • Flow profile for orchestrating multi-step wallet flows (issuance, presentation, etc.)
  • Zero runtime dependencies, ESM-only
  • Fully tested — 38 tests

Install

npm install @sirosfoundation/wmp-js

Quick Start

import { Peer, HttpSseTransport } from "@sirosfoundation/wmp-js";

const transport = new HttpSseTransport({
  rpcUrl: "https://wallet-backend.example.com/wmp/rpc",
  eventsUrl: "https://wallet-backend.example.com/wmp/events",
});

const peer = new Peer(transport, {
  // Handle incoming notifications
  onNotification: (method, params) => {
    console.log("notification:", method, params);
  },
});

await peer.connect();

// Create a session
const session = await peer.request("wmp.session.create", {
  wmp: { version: "0.1", session_id: "" },
  auth: { token: "bearer-token" },
});

// Start a flow
const flow = await peer.request("wmp.flow.start", {
  wmp: { version: "0.1", session_id: session.session_id },
  flow_type: "issuance",
  flow_id: "flow-1",
});

API

Transport

interface Transport {
  send(data: string): Promise<void>;
  onMessage(handler: (data: string) => void): void;
  connect(): Promise<void>;
  close(): void;
}

Built-in transports:

  • WebSocketTransport — full-duplex WebSocket
  • HttpSseTransport — HTTP POST for requests, SSE for server notifications

Peer

Bidirectional JSON-RPC 2.0 peer over any Transport.

const peer = new Peer(transport, options);

// Send request and wait for response
const result = await peer.request("method.name", params);

// Send notification (no response expected)
peer.notify("method.name", params);

Flow Profile

Higher-level abstraction for wallet flows.

import { Registry } from "@sirosfoundation/wmp-js";

const registry = new Registry();

registry.register("issuance", {
  onStart: async (ctx, params) => { /* ... */ },
  onProgress: async (ctx, params) => { /* ... */ },
  onComplete: async (ctx, params) => { /* ... */ },
});

Development

npm install
npm test          # run tests
npm run test:watch # watch mode
npm run build     # compile TypeScript
npm run lint      # type-check

License

BSD-2-Clause — Copyright (c) 2026, SIROS Foundation

About

Wallet Messaging Protocol (WMP) TypeScript library

Resources

Security policy

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages