@agent-score/commerce 2.6.3 → 2.6.5
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 +2 -2
- package/dist/{checkout-CzB9f_jf.d.mts → checkout-DOd9GDmt.d.mts} +15 -3
- package/dist/{checkout-C4RD7M0Z.d.ts → checkout-GcDNDzSK.d.ts} +15 -3
- 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 +99 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +97 -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 +42 -21
- package/dist/payment/index.d.ts +42 -21
- package/dist/payment/index.js +53 -0
- package/dist/payment/index.js.map +1 -1
- package/dist/payment/index.mjs +51 -0
- package/dist/payment/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/payment/index.mjs
CHANGED
|
@@ -1142,6 +1142,22 @@ function x402SignerFromPayload(payload) {
|
|
|
1142
1142
|
txHash: null
|
|
1143
1143
|
};
|
|
1144
1144
|
}
|
|
1145
|
+
function mppCredentialPayloadType(authorizationHeader) {
|
|
1146
|
+
if (typeof authorizationHeader !== "string") return null;
|
|
1147
|
+
if (!authorizationHeader.toLowerCase().startsWith("payment ")) return null;
|
|
1148
|
+
const token = authorizationHeader.slice("payment ".length).trim();
|
|
1149
|
+
if (!token) return null;
|
|
1150
|
+
try {
|
|
1151
|
+
const credential = JSON.parse(atob(token));
|
|
1152
|
+
if (!credential || typeof credential !== "object") return null;
|
|
1153
|
+
const payload = credential.payload;
|
|
1154
|
+
if (!payload || typeof payload !== "object") return null;
|
|
1155
|
+
const type = payload.type;
|
|
1156
|
+
return typeof type === "string" ? type : null;
|
|
1157
|
+
} catch {
|
|
1158
|
+
return null;
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1145
1161
|
function mppSignerFromAuth(authorizationHeader) {
|
|
1146
1162
|
if (typeof authorizationHeader !== "string") return NULL_RESULT;
|
|
1147
1163
|
if (!authorizationHeader.toLowerCase().startsWith("payment ")) return NULL_RESULT;
|
|
@@ -1350,6 +1366,39 @@ function hasMppxHeader(input) {
|
|
|
1350
1366
|
const headers = asHeaders(input);
|
|
1351
1367
|
return Boolean(readHeader(headers, "authorization")?.startsWith("Payment "));
|
|
1352
1368
|
}
|
|
1369
|
+
var JWT_SHAPE_RE = /^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/;
|
|
1370
|
+
function decodesToJsonObject(token) {
|
|
1371
|
+
try {
|
|
1372
|
+
const parsed = JSON.parse(Buffer.from(token, "base64").toString("utf8"));
|
|
1373
|
+
return typeof parsed === "object" && parsed !== null;
|
|
1374
|
+
} catch {
|
|
1375
|
+
return false;
|
|
1376
|
+
}
|
|
1377
|
+
}
|
|
1378
|
+
function malformedPaymentCredential(input) {
|
|
1379
|
+
const headers = asHeaders(input);
|
|
1380
|
+
const x402Token = readHeader(headers, "payment-signature") ?? readHeader(headers, "x-payment");
|
|
1381
|
+
if (x402Token !== null && x402Token.length > 0) {
|
|
1382
|
+
if (!decodesToJsonObject(x402Token)) {
|
|
1383
|
+
return {
|
|
1384
|
+
channel: "x402",
|
|
1385
|
+
message: "X-Payment header is not decodable base64 JSON."
|
|
1386
|
+
};
|
|
1387
|
+
}
|
|
1388
|
+
return null;
|
|
1389
|
+
}
|
|
1390
|
+
const auth = readHeader(headers, "authorization");
|
|
1391
|
+
if (auth !== null && auth.startsWith("Payment ")) {
|
|
1392
|
+
const token = auth.slice("Payment ".length).trim();
|
|
1393
|
+
if (token.length === 0 || !decodesToJsonObject(token) && !JWT_SHAPE_RE.test(token)) {
|
|
1394
|
+
return {
|
|
1395
|
+
channel: "mpp",
|
|
1396
|
+
message: "Authorization: Payment credential is neither base64-encoded JSON nor a token-shaped value."
|
|
1397
|
+
};
|
|
1398
|
+
}
|
|
1399
|
+
}
|
|
1400
|
+
return null;
|
|
1401
|
+
}
|
|
1353
1402
|
|
|
1354
1403
|
// src/payment/network_kind.ts
|
|
1355
1404
|
function readNetwork(input) {
|
|
@@ -1400,6 +1449,8 @@ export {
|
|
|
1400
1449
|
lazyX402Server,
|
|
1401
1450
|
loadSolanaFeePayer,
|
|
1402
1451
|
lookupRail,
|
|
1452
|
+
malformedPaymentCredential,
|
|
1453
|
+
mppCredentialPayloadType,
|
|
1403
1454
|
mppxChallengeHeaders,
|
|
1404
1455
|
networkFamily,
|
|
1405
1456
|
networks,
|