@agent-score/commerce 2.7.2 → 2.7.4
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/dist/core.js +1 -1
- package/dist/core.mjs +1 -1
- package/dist/identity/express.js +1 -1
- package/dist/identity/express.mjs +1 -1
- package/dist/identity/fastify.js +1 -1
- package/dist/identity/fastify.mjs +1 -1
- package/dist/identity/hono.js +1 -1
- package/dist/identity/hono.mjs +1 -1
- package/dist/identity/nextjs.js +1 -1
- package/dist/identity/nextjs.mjs +1 -1
- package/dist/identity/web.js +1 -1
- package/dist/identity/web.mjs +1 -1
- package/dist/index.js +29 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +29 -4
- package/dist/index.mjs.map +1 -1
- package/dist/payment/index.d.mts +23 -1
- package/dist/payment/index.d.ts +23 -1
- package/dist/payment/index.js +20 -2
- package/dist/payment/index.js.map +1 -1
- package/dist/payment/index.mjs +19 -2
- package/dist/payment/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -22618,7 +22618,7 @@ function createAgentScoreCore(options) {
|
|
|
22618
22618
|
} = options;
|
|
22619
22619
|
const baseUrl = stripTrailingSlashes(rawBaseUrl);
|
|
22620
22620
|
const agentMemoryHint = buildAgentMemoryHint(aipTrustedIssuers);
|
|
22621
|
-
const defaultUa = `@agent-score/commerce@${"2.7.
|
|
22621
|
+
const defaultUa = `@agent-score/commerce@${"2.7.4"}`;
|
|
22622
22622
|
const userAgentHeader = userAgent ? `${userAgent} (${defaultUa})` : defaultUa;
|
|
22623
22623
|
const sdk = new AgentScore({ apiKey, baseUrl, userAgent: userAgentHeader });
|
|
22624
22624
|
const sessionSdkCache = /* @__PURE__ */ new Map();
|
|
@@ -25068,6 +25068,21 @@ function classifyX402SettleResult(result) {
|
|
|
25068
25068
|
};
|
|
25069
25069
|
}
|
|
25070
25070
|
}
|
|
25071
|
+
function toCanonicalX402PaymentPayload(payload) {
|
|
25072
|
+
if (typeof payload !== "object" || payload === null) return payload;
|
|
25073
|
+
const p = payload;
|
|
25074
|
+
const accepted = typeof p.accepted === "object" && p.accepted !== null ? p.accepted : void 0;
|
|
25075
|
+
const scheme = p.scheme ?? accepted?.scheme;
|
|
25076
|
+
const network = p.network ?? accepted?.network;
|
|
25077
|
+
const inner = p.payload;
|
|
25078
|
+
if (scheme === void 0 || network === void 0 || inner === void 0) return payload;
|
|
25079
|
+
return {
|
|
25080
|
+
x402Version: p.x402Version ?? 2,
|
|
25081
|
+
scheme,
|
|
25082
|
+
network,
|
|
25083
|
+
payload: inner
|
|
25084
|
+
};
|
|
25085
|
+
}
|
|
25071
25086
|
async function processX402Settle({
|
|
25072
25087
|
x402Server,
|
|
25073
25088
|
payload,
|
|
@@ -25088,6 +25103,7 @@ async function processX402Settle({
|
|
|
25088
25103
|
if (!matchedRequirement) {
|
|
25089
25104
|
return { success: false, phase: "no_requirements", reason: "x402Server.buildPaymentRequirements returned empty" };
|
|
25090
25105
|
}
|
|
25106
|
+
const canonicalPayload = toCanonicalX402PaymentPayload(payload);
|
|
25091
25107
|
const resolvedTransportContext = transportContext ?? (() => {
|
|
25092
25108
|
const path = new URL(resourceMeta.url).pathname;
|
|
25093
25109
|
return { method: "POST", adapter: { getPath: () => path }, routePattern: path };
|
|
@@ -25102,7 +25118,7 @@ async function processX402Settle({
|
|
|
25102
25118
|
let verifyResult;
|
|
25103
25119
|
try {
|
|
25104
25120
|
verifyResult = await server.verifyPayment(
|
|
25105
|
-
|
|
25121
|
+
canonicalPayload,
|
|
25106
25122
|
matchedRequirement,
|
|
25107
25123
|
enrichedExt,
|
|
25108
25124
|
resolvedTransportContext
|
|
@@ -25117,7 +25133,7 @@ async function processX402Settle({
|
|
|
25117
25133
|
}
|
|
25118
25134
|
try {
|
|
25119
25135
|
const settleResult = await server.settlePayment(
|
|
25120
|
-
|
|
25136
|
+
canonicalPayload,
|
|
25121
25137
|
matchedRequirement,
|
|
25122
25138
|
enrichedExt,
|
|
25123
25139
|
resolvedTransportContext
|
|
@@ -25358,6 +25374,15 @@ function getIdentityStatus(ctx) {
|
|
|
25358
25374
|
if (decision === "allow") return "verified";
|
|
25359
25375
|
return "unverified";
|
|
25360
25376
|
}
|
|
25377
|
+
function stripPaymentHeadersFromRaw(raw) {
|
|
25378
|
+
if (typeof Request === "undefined" || !(raw instanceof Request)) return raw;
|
|
25379
|
+
const headers = new Headers(raw.headers);
|
|
25380
|
+
headers.delete("payment-signature");
|
|
25381
|
+
headers.delete("x-payment");
|
|
25382
|
+
const auth = headers.get("authorization");
|
|
25383
|
+
if (auth !== null && auth.startsWith("Payment ")) headers.delete("authorization");
|
|
25384
|
+
return new Request(raw.url, { method: raw.method, headers });
|
|
25385
|
+
}
|
|
25361
25386
|
function resolveIdentityMetadata(ctx) {
|
|
25362
25387
|
const h = normalizeHeadersToLowercase(ctx.request.headers);
|
|
25363
25388
|
const wallet = h["x-wallet-address"];
|
|
@@ -26307,7 +26332,7 @@ var Checkout = class {
|
|
|
26307
26332
|
if (lk === "authorization" && v.startsWith("Payment ")) continue;
|
|
26308
26333
|
headers[k] = v;
|
|
26309
26334
|
}
|
|
26310
|
-
return { ...request, headers };
|
|
26335
|
+
return { ...request, headers, raw: stripPaymentHeadersFromRaw(request.raw) };
|
|
26311
26336
|
}
|
|
26312
26337
|
async emit402(ctx, mppxHeaders = {}) {
|
|
26313
26338
|
if (ctx.pricing === null) {
|