@seedhape/x402-merchant-sdk 0.5.2 → 0.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +371 -8
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +180 -0
- package/dist/cli.js.map +1 -0
- package/dist/commerce.d.ts +2 -0
- package/dist/commerce.d.ts.map +1 -1
- package/dist/commerce.js +1 -0
- package/dist/commerce.js.map +1 -1
- package/dist/fulfillment.d.ts +153 -0
- package/dist/fulfillment.d.ts.map +1 -0
- package/dist/fulfillment.js +369 -0
- package/dist/fulfillment.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/middleware.d.ts +3 -3
- package/dist/middleware.d.ts.map +1 -1
- package/dist/middleware.js +7 -3
- package/dist/middleware.js.map +1 -1
- package/dist/protocol-catalog.d.ts +67 -0
- package/dist/protocol-catalog.d.ts.map +1 -0
- package/dist/protocol-catalog.js +76 -0
- package/dist/protocol-catalog.js.map +1 -0
- package/dist/proxy.d.ts +19 -0
- package/dist/proxy.d.ts.map +1 -0
- package/dist/proxy.js +100 -0
- package/dist/proxy.js.map +1 -0
- package/dist/seller.d.ts +24 -0
- package/dist/seller.d.ts.map +1 -1
- package/dist/seller.js +195 -28
- package/dist/seller.js.map +1 -1
- package/dist/stripe-mpp.d.ts +2 -2
- package/dist/stripe-mpp.d.ts.map +1 -1
- package/dist/stripe-mpp.js +8 -2
- package/dist/stripe-mpp.js.map +1 -1
- package/dist/ucp-handler.d.ts +8 -0
- package/dist/ucp-handler.d.ts.map +1 -0
- package/dist/ucp-handler.js +132 -0
- package/dist/ucp-handler.js.map +1 -0
- package/package.json +6 -3
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { createUcpCatalog } from "./protocol-catalog.js";
|
|
2
|
+
function id(prefix) {
|
|
3
|
+
const uuid = globalThis.crypto?.randomUUID?.() ?? Math.random().toString(36).slice(2);
|
|
4
|
+
return `${prefix}_${uuid}`;
|
|
5
|
+
}
|
|
6
|
+
function json(body, status = 200) { return new Response(JSON.stringify(body), { status, headers: { "content-type": "application/json", "cache-control": "no-store" } }); }
|
|
7
|
+
const x402Schema = { "$schema": "https://json-schema.org/draft/2020-12/schema", type: "object", required: ["settlement"], properties: { settlement: { const: "x402" } }, additionalProperties: false };
|
|
8
|
+
const x402InstrumentSchema = { "$schema": "https://json-schema.org/draft/2020-12/schema", type: "object", required: ["type"], properties: { type: { const: "usdc" } }, additionalProperties: false };
|
|
9
|
+
const mppSchema = { "$schema": "https://json-schema.org/draft/2020-12/schema", type: "object", required: ["settlement"], properties: { settlement: { const: "stripe_mpp" } }, additionalProperties: false };
|
|
10
|
+
const mppInstrumentSchema = { "$schema": "https://json-schema.org/draft/2020-12/schema", type: "object", required: ["type"], properties: { type: { enum: ["card", "link"] } }, additionalProperties: false };
|
|
11
|
+
function checkHeaders(request, mutation = false) {
|
|
12
|
+
const agent = request.headers.get("UCP-Agent") ?? "";
|
|
13
|
+
const profile = agent.match(/^profile="([^\"]+)"$/)?.[1];
|
|
14
|
+
if (!profile || !/^https:\/\/.+\/.well-known\/ucp$/.test(profile))
|
|
15
|
+
throw new Error("UCP-Agent must identify an HTTPS /.well-known/ucp profile.");
|
|
16
|
+
if (!request.headers.get("Request-Id"))
|
|
17
|
+
throw new Error("Request-Id is required.");
|
|
18
|
+
if (mutation && !request.headers.get("Idempotency-Key"))
|
|
19
|
+
throw new Error("Idempotency-Key is required for checkout changes.");
|
|
20
|
+
}
|
|
21
|
+
function paymentHandlers(seller, origin) {
|
|
22
|
+
const methods = new Set(seller.catalog().flatMap((product) => product.paymentMethods));
|
|
23
|
+
const handlers = {};
|
|
24
|
+
if (methods.has("x402"))
|
|
25
|
+
handlers["dev.seedhape.x402"] = [{ id: "seedhape_x402", name: "Seedhape x402", version: "1", spec: `${origin}/ucp/handlers/x402`, config_schema: `${origin}/ucp/handlers/x402/schema.json`, instrument_schemas: [`${origin}/ucp/handlers/x402/instrument-schema.json`], available_instruments: [{ type: "usdc" }], config: { settlement: "x402" } }];
|
|
26
|
+
if (methods.has("mpp"))
|
|
27
|
+
handlers["dev.seedhape.stripe_mpp"] = [{ id: "seedhape_stripe_mpp", name: "Seedhape Stripe MPP", version: "1", spec: `${origin}/ucp/handlers/stripe-mpp`, config_schema: `${origin}/ucp/handlers/stripe-mpp/schema.json`, instrument_schemas: [`${origin}/ucp/handlers/stripe-mpp/instrument-schema.json`], available_instruments: [{ type: "card" }, { type: "link" }], config: { settlement: "stripe_mpp" } }];
|
|
28
|
+
return handlers;
|
|
29
|
+
}
|
|
30
|
+
function profile(seller, origin, currency, checkout) {
|
|
31
|
+
return { ucp: { version: "2026-08-25", services: { "dev.ucp.shopping": [{ version: "2026-08-25", transport: "rest", endpoint: `${origin}/api/ucp` }] }, capabilities: { "dev.ucp.shopping.catalog.search": [{ version: "2026-08-25" }], "dev.ucp.shopping.catalog.lookup": [{ version: "2026-08-25" }], ...(checkout ? { "dev.ucp.shopping.checkout": [{ version: "2026-08-25" }] } : {}) }, payment_handlers: paymentHandlers(seller, origin), currency }, keys: [] };
|
|
32
|
+
}
|
|
33
|
+
function paymentHeaders(payment) {
|
|
34
|
+
const method = String(payment?.method ?? "").toLowerCase();
|
|
35
|
+
const credential = payment?.credential;
|
|
36
|
+
if (typeof credential !== "string" || !credential)
|
|
37
|
+
throw new Error("A payment credential is required.");
|
|
38
|
+
if (["mpp", "stripe", "card", "link"].includes(method))
|
|
39
|
+
return { authorization: credential.startsWith("Payment ") ? credential : `Payment ${credential}`, "accept-payment": "stripe/charge, stripe/session" };
|
|
40
|
+
if (["x402", "crypto", "usdc", "eip3009"].includes(method))
|
|
41
|
+
return { "payment-signature": credential, "x-payment": credential };
|
|
42
|
+
throw new Error("payment.method must be mpp or x402.");
|
|
43
|
+
}
|
|
44
|
+
/** Fetch-compatible UCP adapter for Express, Next.js, Hono, and node:http. */
|
|
45
|
+
export function createUcpHandler(seller, options) {
|
|
46
|
+
const origin = new URL(options.origin).origin;
|
|
47
|
+
const currency = options.currency ?? "USD";
|
|
48
|
+
const sessions = new Map();
|
|
49
|
+
const catalog = () => seller.catalog();
|
|
50
|
+
const responseFor = (session) => session.response;
|
|
51
|
+
return async function handle(request) {
|
|
52
|
+
try {
|
|
53
|
+
const url = new URL(request.url);
|
|
54
|
+
if (url.pathname === "/.well-known/ucp" && request.method === "GET")
|
|
55
|
+
return json(profile(seller, origin, currency, true));
|
|
56
|
+
if (url.pathname === "/ucp/handlers/x402/schema.json")
|
|
57
|
+
return json(x402Schema);
|
|
58
|
+
if (url.pathname === "/ucp/handlers/x402/instrument-schema.json")
|
|
59
|
+
return json(x402InstrumentSchema);
|
|
60
|
+
if (url.pathname === "/ucp/handlers/stripe-mpp/schema.json")
|
|
61
|
+
return json(mppSchema);
|
|
62
|
+
if (url.pathname === "/ucp/handlers/stripe-mpp/instrument-schema.json")
|
|
63
|
+
return json(mppInstrumentSchema);
|
|
64
|
+
if (!url.pathname.startsWith("/api/ucp"))
|
|
65
|
+
return json({ error: "Not found" }, 404);
|
|
66
|
+
checkHeaders(request, request.method !== "GET");
|
|
67
|
+
if (url.pathname === "/api/ucp/catalog/search" && request.method === "POST") {
|
|
68
|
+
const body = await request.json();
|
|
69
|
+
const query = typeof body.query === "string" ? body.query.toLowerCase() : "";
|
|
70
|
+
const products = catalog().filter((item) => !query || `${item.name} ${item.description}`.toLowerCase().includes(query));
|
|
71
|
+
return json({ ucp: { version: "2026-08-25", capabilities: { "dev.ucp.shopping.catalog.search": [{ version: "2026-08-25" }] } }, products: createUcpCatalog(products.map((item) => ({ id: item.id, name: item.name, description: item.description, endpoint: item.endpoint, price: { amount: BigInt(item.price.amount), asset: item.price.asset ?? "", network: item.price.network ?? "", decimals: item.price.decimals ?? 2 } })), origin, currency) });
|
|
72
|
+
}
|
|
73
|
+
if (url.pathname === "/api/ucp/catalog/lookup" && request.method === "POST") {
|
|
74
|
+
const body = await request.json();
|
|
75
|
+
const ids = Array.isArray(body.ids) ? body.ids.map(String) : [];
|
|
76
|
+
const products = catalog().filter((item) => ids.includes(item.id));
|
|
77
|
+
return json({ ucp: { version: "2026-08-25" }, products: createUcpCatalog(products.map((item) => ({ id: item.id, name: item.name, description: item.description, endpoint: item.endpoint, price: { amount: BigInt(item.price.amount), asset: item.price.asset ?? "", network: item.price.network ?? "", decimals: item.price.decimals ?? 2 } })), origin, currency) });
|
|
78
|
+
}
|
|
79
|
+
const match = url.pathname.match(/^\/api\/ucp\/checkout-sessions(?:\/([^/]+))?(?:\/(complete|cancel))?$/);
|
|
80
|
+
if (!match)
|
|
81
|
+
return json({ error: "Not found" }, 404);
|
|
82
|
+
const sessionId = match[1];
|
|
83
|
+
if (!sessionId && request.method === "POST") {
|
|
84
|
+
const body = await request.json();
|
|
85
|
+
const line = body.line_items?.[0];
|
|
86
|
+
const productId = line?.item?.id ?? line?.id;
|
|
87
|
+
const quantity = Number(line?.quantity ?? 1);
|
|
88
|
+
const product = catalog().find((item) => item.id === productId);
|
|
89
|
+
if (!product || !Number.isSafeInteger(quantity) || quantity < 1)
|
|
90
|
+
return json({ error: "A valid product and quantity are required." }, 400);
|
|
91
|
+
if (typeof product.price.amount !== "string")
|
|
92
|
+
return json({ error: "UCP product price must be serialized as a string." }, 400);
|
|
93
|
+
const selectedProductId = product.id;
|
|
94
|
+
const session = { id: id("ucp"), productId: selectedProductId, quantity, status: "incomplete", response: { ucp: { version: "2026-08-25", status: "success", payment_handlers: paymentHandlers(seller, origin) }, id: "", status: "incomplete", currency, line_items: [{ item: { id: selectedProductId, title: product.name }, quantity }], totals: [{ type: "total", amount: Number(product.price.amount) * quantity, currency }], messages: [{ type: "info", code: "payment_pending", content: "Select a payment method to continue." }] }, createdAt: Date.now() };
|
|
95
|
+
session.response.id = session.id;
|
|
96
|
+
sessions.set(session.id, session);
|
|
97
|
+
return json(responseFor(session), 201);
|
|
98
|
+
}
|
|
99
|
+
if (!sessionId)
|
|
100
|
+
return json({ error: "Checkout session id is required." }, 400);
|
|
101
|
+
const session = sessions.get(sessionId);
|
|
102
|
+
if (!session)
|
|
103
|
+
return json({ error: "Checkout session not found." }, 404);
|
|
104
|
+
if (request.method === "GET" && !match[2])
|
|
105
|
+
return json(responseFor(session));
|
|
106
|
+
if (match[2] === "cancel" && request.method === "POST") {
|
|
107
|
+
session.status = "canceled";
|
|
108
|
+
session.response.status = "canceled";
|
|
109
|
+
return json(responseFor(session));
|
|
110
|
+
}
|
|
111
|
+
if (match[2] === "complete" && request.method === "POST") {
|
|
112
|
+
if (session.status !== "incomplete")
|
|
113
|
+
return json(responseFor(session), 409);
|
|
114
|
+
const body = await request.json();
|
|
115
|
+
const headers = paymentHeaders(body.payment);
|
|
116
|
+
const product = seller.product(session.productId);
|
|
117
|
+
const response = await seller.fetch(product.id)(new Request(new URL(product.endpoint, origin), { method: "GET", headers: new Headers(headers) }));
|
|
118
|
+
if (!response.ok)
|
|
119
|
+
return json({ error: `Payment failed with HTTP ${response.status}.` }, 402);
|
|
120
|
+
const reference = response.headers.get("payment-receipt") ?? response.headers.get("PAYMENT-RESPONSE") ?? `ucp_${session.id}`;
|
|
121
|
+
session.status = "completed";
|
|
122
|
+
session.response = { ...session.response, status: "completed", payment_reference: reference };
|
|
123
|
+
return json(responseFor(session));
|
|
124
|
+
}
|
|
125
|
+
return json({ error: "Unsupported checkout operation." }, 405);
|
|
126
|
+
}
|
|
127
|
+
catch (error) {
|
|
128
|
+
return json({ error: error instanceof Error ? error.message : String(error) }, 400);
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=ucp-handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ucp-handler.js","sourceRoot":"","sources":["../src/ucp-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAuB,MAAM,uBAAuB,CAAC;AAK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AG,WAAW,CAAC;gBAAC,OAAO,CAAC,QAAQ,GAAG,EAAE,GAAG,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,iBAAiB,EAAE,SAAS,EAAE,CAAC;gBAC5H,OAAO,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC;YACpC,CAAC;YACD,OAAO,IAAI,CAAC,EAAE,KAAK,EAAE,iCAAiC,EAAE,EAAE,GAAG,CAAC,CAAC;QACjE,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAAC,OAAO,IAAI,CAAC,EAAE,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;QAAC,CAAC;IAC1G,CAAC,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seedhape/x402-merchant-sdk",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.3",
|
|
4
4
|
"description": "Add x402 payment-gated routes, settlement receipts, and merchant accounting to Node.js services.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -15,6 +15,9 @@
|
|
|
15
15
|
"dist",
|
|
16
16
|
"README.md"
|
|
17
17
|
],
|
|
18
|
+
"bin": {
|
|
19
|
+
"x402-merchant-sdk": "./dist/cli.js"
|
|
20
|
+
},
|
|
18
21
|
"keywords": [
|
|
19
22
|
"x402",
|
|
20
23
|
"payments",
|
|
@@ -39,7 +42,7 @@
|
|
|
39
42
|
"access": "public"
|
|
40
43
|
},
|
|
41
44
|
"dependencies": {
|
|
42
|
-
"@seedhape/core": "^0.
|
|
45
|
+
"@seedhape/core": "^0.2.0",
|
|
43
46
|
"@modelcontextprotocol/sdk": "^1.30.0",
|
|
44
47
|
"@solana/kit": "^5.5.1",
|
|
45
48
|
"@x402/core": "2.23.0",
|
|
@@ -70,4 +73,4 @@
|
|
|
70
73
|
"scripts": {
|
|
71
74
|
"test": "node --test test/*.test.mjs"
|
|
72
75
|
}
|
|
73
|
-
}
|
|
76
|
+
}
|