@agent-score/commerce 2.7.0 → 2.7.1
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-Wc7NUHxZ.d.mts → checkout-DKq9gV3G.d.mts} +13 -12
- package/dist/{checkout-CIH1UcKZ.d.ts → checkout-DW7GgRrl.d.ts} +13 -12
- 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/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 +17 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -21
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -22574,7 +22574,7 @@ function createAgentScoreCore(options) {
|
|
|
22574
22574
|
} = options;
|
|
22575
22575
|
const baseUrl = stripTrailingSlashes(rawBaseUrl);
|
|
22576
22576
|
const agentMemoryHint = buildAgentMemoryHint(aipTrustedIssuers);
|
|
22577
|
-
const defaultUa = `@agent-score/commerce@${"2.7.
|
|
22577
|
+
const defaultUa = `@agent-score/commerce@${"2.7.1"}`;
|
|
22578
22578
|
const userAgentHeader = userAgent ? `${userAgent} (${defaultUa})` : defaultUa;
|
|
22579
22579
|
const sdk = new AgentScore({ apiKey, baseUrl, userAgent: userAgentHeader });
|
|
22580
22580
|
const sessionSdkCache = /* @__PURE__ */ new Map();
|
|
@@ -25711,7 +25711,7 @@ var Checkout = class {
|
|
|
25711
25711
|
const malformed = malformedPaymentCredential(request.headers);
|
|
25712
25712
|
const enforced = malformed !== null && (malformed.channel === "x402" ? this.x402ServerAvailable() && this.x402BaseNetwork !== null : this.composeMppx !== void 0);
|
|
25713
25713
|
if (enforced) {
|
|
25714
|
-
const result = await this.
|
|
25714
|
+
const result = await this.handle(this.stripPaymentHeaders(request));
|
|
25715
25715
|
return { ...result, settlePhase: "credential_malformed" };
|
|
25716
25716
|
}
|
|
25717
25717
|
}
|
|
@@ -26230,12 +26230,10 @@ var Checkout = class {
|
|
|
26230
26230
|
settlePhase: "verify_failed"
|
|
26231
26231
|
};
|
|
26232
26232
|
}
|
|
26233
|
-
/** Emit
|
|
26234
|
-
* ask the
|
|
26235
|
-
* build the rich 402 body.
|
|
26236
|
-
*
|
|
26237
|
-
* computed pricing / resolved recipients, so the normal discovery leg (which
|
|
26238
|
-
* primes both) pays nothing extra. */
|
|
26233
|
+
/** Emit the discovery-leg 402: pricing (idempotent), mint per-order
|
|
26234
|
+
* recipients, ask the optional MPP compose hook for a fresh WWW-Authenticate,
|
|
26235
|
+
* and build the rich 402 body. preValidate + pricing already ran in the main
|
|
26236
|
+
* flow before this is reached, so it primes nothing twice. */
|
|
26239
26237
|
async emitFreshChallenge(ctx) {
|
|
26240
26238
|
if (ctx.pricing === null) ctx.pricing = await this.computePricing(ctx);
|
|
26241
26239
|
await this.resolveRecipientsForCtx(ctx);
|
|
@@ -26249,25 +26247,23 @@ var Checkout = class {
|
|
|
26249
26247
|
}
|
|
26250
26248
|
return await this.emit402(ctx, mppxHeaders);
|
|
26251
26249
|
}
|
|
26252
|
-
/** Return a copy of
|
|
26253
|
-
*
|
|
26254
|
-
*
|
|
26255
|
-
*
|
|
26256
|
-
* re-challenge.
|
|
26257
|
-
|
|
26250
|
+
/** Return a copy of the request with every payment-credential header removed,
|
|
26251
|
+
* so re-entering handle() treats it as a discovery (no-credential) request:
|
|
26252
|
+
* preValidate + pricing + minting + compose all run their fresh path, and the
|
|
26253
|
+
* gate/assess and settle are skipped. Turns a malformed-credential request
|
|
26254
|
+
* into a clean 402 re-challenge. The raw request is left intact (its body may
|
|
26255
|
+
* already be consumed); MPP compose reads it only best-effort under a
|
|
26256
|
+
* try/catch, while the stripped headers are what the credential-shape check,
|
|
26257
|
+
* gate dispatch, and recipient minting read. */
|
|
26258
|
+
stripPaymentHeaders(request) {
|
|
26258
26259
|
const headers = {};
|
|
26259
|
-
for (const [k, v] of Object.entries(
|
|
26260
|
+
for (const [k, v] of Object.entries(request.headers)) {
|
|
26260
26261
|
const lk = k.toLowerCase();
|
|
26261
26262
|
if (lk === "payment-signature" || lk === "x-payment") continue;
|
|
26262
26263
|
if (lk === "authorization" && v.startsWith("Payment ")) continue;
|
|
26263
26264
|
headers[k] = v;
|
|
26264
26265
|
}
|
|
26265
|
-
return {
|
|
26266
|
-
...ctx,
|
|
26267
|
-
request: { ...ctx.request, headers },
|
|
26268
|
-
pricing: null,
|
|
26269
|
-
recipients: {}
|
|
26270
|
-
};
|
|
26266
|
+
return { ...request, headers };
|
|
26271
26267
|
}
|
|
26272
26268
|
async emit402(ctx, mppxHeaders = {}) {
|
|
26273
26269
|
if (ctx.pricing === null) {
|