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

mpp-buyer-sdk

v0.1.0

Published

Plural MPP Buyer SDK - x402 Machine Payments Protocol client for AI agents (TypeScript)

Downloads

155

Readme

@plural/mpp-buyer-sdk

 

TypeScript SDK for Plural MPP buyer agents. It handles x402-style HTTP 402

payment challenges, creates one-time MPP payment tokens, retries protected

requests with a Payment credential, and parses Payment-Receipt headers.

 

Install

 


npm install @plural/mpp-buyer-sdk

 

Requires Node.js >=18 or another runtime with fetch, AbortSignal.timeout,

and standard Web APIs.

 

Package Layout

 

The SDK is split into small modules and exposed through npm subpath exports:

 


import { PluralBuyer } from "@plural/mpp-buyer-sdk";

import { PluralBuyer as Client } from "@plural/mpp-buyer-sdk/client";

import { MppEnvironment } from "@plural/mpp-buyer-sdk/config";

import { GrantVerifier } from "@plural/mpp-buyer-sdk/grantex";

import type { PluralBuyerConfig, Receipt } from "@plural/mpp-buyer-sdk/types";

import { decodeReceipt } from "@plural/mpp-buyer-sdk/utils";

 

Use the root import for most applications. Use subpath imports when building

larger services that want clearer ownership boundaries.

 

Quick Start

 


import { MppEnvironment, PluralBuyer } from "@plural/mpp-buyer-sdk";

 

const buyer = PluralBuyer.create({

  clientId: "buyer-client-id",

  clientSecret: "buyer-client-secret",

  customerReference: "customer-ref",

  baseUrl: MppEnvironment.SANDBOX,

});

 

const response = await buyer.get("https://seller.example.com/api/premium");

console.log(await response.json());

 

Configuration

 


const buyer = PluralBuyer.create({

  clientId: process.env.PLURAL_CLIENT_ID!,

  clientSecret: process.env.PLURAL_CLIENT_SECRET!,

  customerReference: "customer-ref",

  baseUrl: MppEnvironment.SANDBOX,

  requestTimeoutMs: 30_000,

  maxRetries: 3,

  onPaymentComplete(receipt) {

    console.log("captured", receipt);

  },

});

 

baseUrl is the Plural MPP base URL. Authentication always uses

POST /api/auth/v1/token; the same base URL can route that call internally to

your central Keycloak-backed auth service.

 

For Grantex grant verification, pass a JWKS URL such as

https://grantex.dev/.well-known/jwks.json or the base URL

https://grantex.dev. The SDK verifies RS256 signatures offline, caches JWKS,

checks expiry and agent ID, and enforces MPP payment scopes before retrying a

paid request.

 

Flow

 

  1. Your app calls buyer.get(...), buyer.post(...), or buyer.request(...).

  2. If the seller returns 402 with WWW-Authenticate: Payment <challenge>,

   the SDK decodes and validates the challenge.

  1. The SDK authenticates with POST /api/auth/v1/token.

  2. The SDK creates a payment token with POST /mpp/v1/token.

  3. The SDK retries the original request with

   Authorization: Payment <credential>.

  1. The SDK returns the final response and optionally calls

   onPaymentComplete with the decoded Payment-Receipt.

 

Direct MPP APIs

 


await buyer.methods.createMandate({

  mobileNumber: "+919876543210",

  amount: { value: 50000, currency: "INR" },

  customerReference: "customer-ref",

});

 

await buyer.methods.getMandate("authorization-id");

await buyer.methods.createToken({ customerReference: "customer-ref" });

 

Development

 


npm install

npm run build

npm test

npm pack --dry-run

 

npm publish --access public will run prepublishOnly, compile dist/, and

publish only the files declared in package.json.

 

License

 

MIT