@agent-score/commerce 2.0.1 → 2.0.2
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-B1JuEcbx.d.ts → checkout-DhSj_h94.d.ts} +6 -0
- package/dist/{checkout-BN5i1Fi7.d.mts → checkout-jNUIql6D.d.mts} +6 -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.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/policy.js +49 -4
- package/dist/identity/policy.js.map +1 -1
- package/dist/identity/policy.mjs +49 -4
- package/dist/identity/policy.mjs.map +1 -1
- package/dist/identity/web.js +1 -1
- package/dist/identity/web.mjs +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +49 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +49 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
|
@@ -19692,7 +19692,7 @@ function deserialize3(value) {
|
|
|
19692
19692
|
try {
|
|
19693
19693
|
const json2 = Base64_exports.toString(prefixMatch[1]);
|
|
19694
19694
|
const parsed = JSON.parse(json2);
|
|
19695
|
-
const { opaque: challengeOpaque, request, ...challengeFields } = parsed.challenge;
|
|
19695
|
+
const { opaque: challengeOpaque, request, meta: _meta, ...challengeFields } = parsed.challenge;
|
|
19696
19696
|
const { meta: meta4, opaque } = normalizeCredentialOpaque(challengeOpaque);
|
|
19697
19697
|
const challenge = Schema.parse({
|
|
19698
19698
|
...challengeFields,
|
|
@@ -21125,7 +21125,7 @@ function createAgentScoreCore(options) {
|
|
|
21125
21125
|
} = options;
|
|
21126
21126
|
const baseUrl = stripTrailingSlashes(rawBaseUrl);
|
|
21127
21127
|
const agentMemoryHint = buildAgentMemoryHint();
|
|
21128
|
-
const defaultUa = `@agent-score/commerce@${"2.0.
|
|
21128
|
+
const defaultUa = `@agent-score/commerce@${"2.0.2"}`;
|
|
21129
21129
|
const userAgentHeader = userAgent ? `${userAgent} (${defaultUa})` : defaultUa;
|
|
21130
21130
|
const sdk = new AgentScore({ apiKey, baseUrl, userAgent: userAgentHeader });
|
|
21131
21131
|
const sessionSdkCache = /* @__PURE__ */ new Map();
|
|
@@ -22859,6 +22859,38 @@ var Checkout = class {
|
|
|
22859
22859
|
}
|
|
22860
22860
|
return "tempo";
|
|
22861
22861
|
}
|
|
22862
|
+
/** Map an mppx credential `method` (`tempo` | `solana` | `stripe`) to the
|
|
22863
|
+
* merchant's rails-dict key. Used in handleMppx so onSettled outcomes
|
|
22864
|
+
* distinguish Solana from Tempo (both settle under `rail: 'mpp'`) and from
|
|
22865
|
+
* Stripe SPT. Returns the first matching key or `undefined` when no rail in
|
|
22866
|
+
* the merchant's config corresponds to that method. */
|
|
22867
|
+
railsKeyForMppxMethod(method) {
|
|
22868
|
+
if (method === "stripe") {
|
|
22869
|
+
for (const [k, v] of Object.entries(this.rails)) {
|
|
22870
|
+
if (isStripeRailSpec2(v)) return k;
|
|
22871
|
+
}
|
|
22872
|
+
return void 0;
|
|
22873
|
+
}
|
|
22874
|
+
if (method === "solana") {
|
|
22875
|
+
for (const [k, v] of Object.entries(this.rails)) {
|
|
22876
|
+
if (isStripeRailSpec2(v) || isTempoSessionRailSpec3(v)) continue;
|
|
22877
|
+
const network = v.network ?? "";
|
|
22878
|
+
if (network.startsWith("solana:") || "rpcUrl" in v || "tokenProgram" in v) return k;
|
|
22879
|
+
}
|
|
22880
|
+
return void 0;
|
|
22881
|
+
}
|
|
22882
|
+
if (method === "tempo") {
|
|
22883
|
+
for (const [k, v] of Object.entries(this.rails)) {
|
|
22884
|
+
if (isStripeRailSpec2(v)) continue;
|
|
22885
|
+
const network = v.network ?? "";
|
|
22886
|
+
if (network.startsWith("solana:") || "rpcUrl" in v || "tokenProgram" in v) continue;
|
|
22887
|
+
if (network.startsWith("eip155:")) continue;
|
|
22888
|
+
return k;
|
|
22889
|
+
}
|
|
22890
|
+
return void 0;
|
|
22891
|
+
}
|
|
22892
|
+
return void 0;
|
|
22893
|
+
}
|
|
22862
22894
|
/** CAIP-2 read from `rails['x402_base'].network` (or its default).
|
|
22863
22895
|
* Defined only when an `X402BaseRailSpec` is present in rails AND a server
|
|
22864
22896
|
* is configured (explicit or auto-derived); otherwise `null`. */
|
|
@@ -23205,15 +23237,20 @@ var Checkout = class {
|
|
|
23205
23237
|
}
|
|
23206
23238
|
const composed = await this.composeMppx(ctx);
|
|
23207
23239
|
if (composed.status === 200) {
|
|
23240
|
+
const paymentReceiptHeader = composed.paymentReceiptHeader ?? extractMppxReceiptHeaderFromRaw(composed.raw);
|
|
23241
|
+
const directMethod = composed.raw?.receipt?.method;
|
|
23242
|
+
const headerMethod = paymentReceiptHeader ? await extractMppxReceiptMethod(paymentReceiptHeader) : void 0;
|
|
23243
|
+
const receiptMethod = directMethod ?? headerMethod;
|
|
23244
|
+
const derivedKey = typeof receiptMethod === "string" ? this.railsKeyForMppxMethod(receiptMethod) : void 0;
|
|
23208
23245
|
const outcome = {
|
|
23209
23246
|
rail: "mpp",
|
|
23210
23247
|
paymentResponseHeader: composed.paymentResponseHeader ?? null,
|
|
23211
|
-
paymentReceiptHeader
|
|
23248
|
+
paymentReceiptHeader,
|
|
23212
23249
|
raw: composed.raw,
|
|
23213
23250
|
txHash: composed.txHash ?? null,
|
|
23214
23251
|
signerAddress: composed.signerAddress ?? null,
|
|
23215
23252
|
signerNetwork: composed.signerNetwork ?? null,
|
|
23216
|
-
railKey: composed.railKey ?? this.mppRailKey()
|
|
23253
|
+
railKey: derivedKey ?? composed.railKey ?? this.mppRailKey()
|
|
23217
23254
|
};
|
|
23218
23255
|
return await this.buildSuccess(ctx, outcome);
|
|
23219
23256
|
}
|
|
@@ -23404,6 +23441,14 @@ function extractMppxReceiptHeaderFromRaw(raw) {
|
|
|
23404
23441
|
return null;
|
|
23405
23442
|
}
|
|
23406
23443
|
}
|
|
23444
|
+
async function extractMppxReceiptMethod(header) {
|
|
23445
|
+
try {
|
|
23446
|
+
const { Receipt } = await Promise.resolve().then(() => (init_dist2(), dist_exports));
|
|
23447
|
+
return Receipt.deserialize(header).method;
|
|
23448
|
+
} catch {
|
|
23449
|
+
return void 0;
|
|
23450
|
+
}
|
|
23451
|
+
}
|
|
23407
23452
|
function headersToRecord(h) {
|
|
23408
23453
|
if (h === void 0) return {};
|
|
23409
23454
|
if (h instanceof Headers) {
|