@agent-score/commerce 2.6.3 → 2.6.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/{checkout-C4RD7M0Z.d.ts → checkout-B-Z5_EQP.d.ts} +9 -0
- package/dist/{checkout-CzB9f_jf.d.mts → checkout-BtdHSF_w.d.mts} +9 -0
- package/dist/core.js +1 -1
- package/dist/core.mjs +1 -1
- package/dist/discovery/index.d.mts +1 -1
- package/dist/discovery/index.d.ts +1 -1
- package/dist/identity/express.js +1 -1
- package/dist/identity/express.js.map +1 -1
- package/dist/identity/express.mjs +1 -1
- package/dist/identity/express.mjs.map +1 -1
- package/dist/identity/fastify.js +1 -1
- package/dist/identity/fastify.js.map +1 -1
- package/dist/identity/fastify.mjs +1 -1
- package/dist/identity/fastify.mjs.map +1 -1
- package/dist/identity/hono.js +1 -1
- package/dist/identity/hono.js.map +1 -1
- package/dist/identity/hono.mjs +1 -1
- package/dist/identity/hono.mjs.map +1 -1
- package/dist/identity/nextjs.js +1 -1
- package/dist/identity/nextjs.js.map +1 -1
- package/dist/identity/nextjs.mjs +1 -1
- package/dist/identity/nextjs.mjs.map +1 -1
- package/dist/identity/web.js +1 -1
- package/dist/identity/web.js.map +1 -1
- package/dist/identity/web.mjs +1 -1
- package/dist/identity/web.mjs.map +1 -1
- package/dist/index.d.mts +35 -17
- package/dist/index.d.ts +35 -17
- package/dist/index.js +80 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +78 -9
- package/dist/index.mjs.map +1 -1
- package/dist/{network_kind-BIJM2peR.d.ts → network_kind-BmbWKNud.d.ts} +23 -1
- package/dist/{network_kind-C0EMkdzz.d.mts → network_kind-D2xpo2Fj.d.mts} +23 -1
- package/dist/payment/index.d.mts +27 -20
- package/dist/payment/index.d.ts +27 -20
- package/dist/payment/index.js +35 -0
- package/dist/payment/index.js.map +1 -1
- package/dist/payment/index.mjs +34 -0
- package/dist/payment/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/payment/index.mjs
CHANGED
|
@@ -1350,6 +1350,39 @@ function hasMppxHeader(input) {
|
|
|
1350
1350
|
const headers = asHeaders(input);
|
|
1351
1351
|
return Boolean(readHeader(headers, "authorization")?.startsWith("Payment "));
|
|
1352
1352
|
}
|
|
1353
|
+
var JWT_SHAPE_RE = /^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/;
|
|
1354
|
+
function decodesToJsonObject(token) {
|
|
1355
|
+
try {
|
|
1356
|
+
const parsed = JSON.parse(Buffer.from(token, "base64").toString("utf8"));
|
|
1357
|
+
return typeof parsed === "object" && parsed !== null;
|
|
1358
|
+
} catch {
|
|
1359
|
+
return false;
|
|
1360
|
+
}
|
|
1361
|
+
}
|
|
1362
|
+
function malformedPaymentCredential(input) {
|
|
1363
|
+
const headers = asHeaders(input);
|
|
1364
|
+
const x402Token = readHeader(headers, "payment-signature") ?? readHeader(headers, "x-payment");
|
|
1365
|
+
if (x402Token !== null && x402Token.length > 0) {
|
|
1366
|
+
if (!decodesToJsonObject(x402Token)) {
|
|
1367
|
+
return {
|
|
1368
|
+
channel: "x402",
|
|
1369
|
+
message: "X-Payment header is not decodable base64 JSON."
|
|
1370
|
+
};
|
|
1371
|
+
}
|
|
1372
|
+
return null;
|
|
1373
|
+
}
|
|
1374
|
+
const auth = readHeader(headers, "authorization");
|
|
1375
|
+
if (auth !== null && auth.startsWith("Payment ")) {
|
|
1376
|
+
const token = auth.slice("Payment ".length).trim();
|
|
1377
|
+
if (token.length === 0 || !decodesToJsonObject(token) && !JWT_SHAPE_RE.test(token)) {
|
|
1378
|
+
return {
|
|
1379
|
+
channel: "mpp",
|
|
1380
|
+
message: "Authorization: Payment credential is neither base64-encoded JSON nor a token-shaped value."
|
|
1381
|
+
};
|
|
1382
|
+
}
|
|
1383
|
+
}
|
|
1384
|
+
return null;
|
|
1385
|
+
}
|
|
1353
1386
|
|
|
1354
1387
|
// src/payment/network_kind.ts
|
|
1355
1388
|
function readNetwork(input) {
|
|
@@ -1400,6 +1433,7 @@ export {
|
|
|
1400
1433
|
lazyX402Server,
|
|
1401
1434
|
loadSolanaFeePayer,
|
|
1402
1435
|
lookupRail,
|
|
1436
|
+
malformedPaymentCredential,
|
|
1403
1437
|
mppxChallengeHeaders,
|
|
1404
1438
|
networkFamily,
|
|
1405
1439
|
networks,
|