@agent-score/commerce 2.6.8 → 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/README.md +1 -1
- package/dist/challenge/index.d.mts +3 -3
- package/dist/challenge/index.d.ts +3 -3
- package/dist/challenge/index.js.map +1 -1
- package/dist/challenge/index.mjs.map +1 -1
- package/dist/{checkout-PjmMESkc.d.mts → checkout-DKq9gV3G.d.mts} +15 -14
- package/dist/{checkout-U3tGU1Au.d.ts → checkout-DW7GgRrl.d.ts} +15 -14
- package/dist/core.js +1 -1
- package/dist/core.mjs +1 -1
- package/dist/discovery/index.d.mts +4 -4
- package/dist/discovery/index.d.ts +4 -4
- 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 +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +17 -23
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -23
- package/dist/index.mjs.map +1 -1
- package/dist/{network_kind-D2xpo2Fj.d.mts → network_kind-CLdLbqU5.d.mts} +1 -1
- package/dist/{network_kind-BmbWKNud.d.ts → network_kind-toxNABqw.d.ts} +1 -1
- package/dist/payment/index.d.mts +3 -3
- package/dist/payment/index.d.ts +3 -3
- package/dist/payment/index.js +0 -2
- package/dist/payment/index.js.map +1 -1
- package/dist/payment/index.mjs +0 -2
- package/dist/payment/index.mjs.map +1 -1
- package/dist/{pricing-CytRwhC2.d.ts → pricing-Dx3F1VAv.d.ts} +1 -1
- package/dist/{pricing-KHDqMLd7.d.mts → pricing-sfv3CPiY.d.mts} +1 -1
- package/dist/{rail_spec-BFZmW9RN.d.mts → rail_spec-DGdb4Gnd.d.mts} +0 -25
- package/dist/{rail_spec-BFZmW9RN.d.ts → rail_spec-DGdb4Gnd.d.ts} +0 -25
- package/package.json +5 -5
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.
|
|
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();
|
|
@@ -24727,13 +24727,11 @@ async function registerSolana(spec) {
|
|
|
24727
24727
|
"createMppxServer: SolanaMppRailSpec requires a string recipient (per-order factories not supported here)."
|
|
24728
24728
|
);
|
|
24729
24729
|
}
|
|
24730
|
-
const ataCreationRequired = spec.ataCreationRequired !== false;
|
|
24731
24730
|
const baseMethod = solanaMpp.charge({
|
|
24732
24731
|
recipient: spec.recipient,
|
|
24733
24732
|
currency: spec.token ?? defaultMint,
|
|
24734
24733
|
decimals: spec.decimals ?? defaultDecimals,
|
|
24735
24734
|
network,
|
|
24736
|
-
...ataCreationRequired ? { splits: [{ recipient: spec.recipient, amount: "0", ataCreationRequired: true }] } : {},
|
|
24737
24735
|
...spec.rpcUrl ? { rpcUrl: spec.rpcUrl } : {},
|
|
24738
24736
|
...spec.signer ? { signer: spec.signer } : {},
|
|
24739
24737
|
...spec.tokenProgram ? { tokenProgram: spec.tokenProgram } : {}
|
|
@@ -25713,7 +25711,7 @@ var Checkout = class {
|
|
|
25713
25711
|
const malformed = malformedPaymentCredential(request.headers);
|
|
25714
25712
|
const enforced = malformed !== null && (malformed.channel === "x402" ? this.x402ServerAvailable() && this.x402BaseNetwork !== null : this.composeMppx !== void 0);
|
|
25715
25713
|
if (enforced) {
|
|
25716
|
-
const result = await this.
|
|
25714
|
+
const result = await this.handle(this.stripPaymentHeaders(request));
|
|
25717
25715
|
return { ...result, settlePhase: "credential_malformed" };
|
|
25718
25716
|
}
|
|
25719
25717
|
}
|
|
@@ -26232,12 +26230,10 @@ var Checkout = class {
|
|
|
26232
26230
|
settlePhase: "verify_failed"
|
|
26233
26231
|
};
|
|
26234
26232
|
}
|
|
26235
|
-
/** Emit
|
|
26236
|
-
* ask the
|
|
26237
|
-
* build the rich 402 body.
|
|
26238
|
-
*
|
|
26239
|
-
* computed pricing / resolved recipients, so the normal discovery leg (which
|
|
26240
|
-
* 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. */
|
|
26241
26237
|
async emitFreshChallenge(ctx) {
|
|
26242
26238
|
if (ctx.pricing === null) ctx.pricing = await this.computePricing(ctx);
|
|
26243
26239
|
await this.resolveRecipientsForCtx(ctx);
|
|
@@ -26251,25 +26247,23 @@ var Checkout = class {
|
|
|
26251
26247
|
}
|
|
26252
26248
|
return await this.emit402(ctx, mppxHeaders);
|
|
26253
26249
|
}
|
|
26254
|
-
/** Return a copy of
|
|
26255
|
-
*
|
|
26256
|
-
*
|
|
26257
|
-
*
|
|
26258
|
-
* re-challenge.
|
|
26259
|
-
|
|
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) {
|
|
26260
26259
|
const headers = {};
|
|
26261
|
-
for (const [k, v] of Object.entries(
|
|
26260
|
+
for (const [k, v] of Object.entries(request.headers)) {
|
|
26262
26261
|
const lk = k.toLowerCase();
|
|
26263
26262
|
if (lk === "payment-signature" || lk === "x-payment") continue;
|
|
26264
26263
|
if (lk === "authorization" && v.startsWith("Payment ")) continue;
|
|
26265
26264
|
headers[k] = v;
|
|
26266
26265
|
}
|
|
26267
|
-
return {
|
|
26268
|
-
...ctx,
|
|
26269
|
-
request: { ...ctx.request, headers },
|
|
26270
|
-
pricing: null,
|
|
26271
|
-
recipients: {}
|
|
26272
|
-
};
|
|
26266
|
+
return { ...request, headers };
|
|
26273
26267
|
}
|
|
26274
26268
|
async emit402(ctx, mppxHeaders = {}) {
|
|
26275
26269
|
if (ctx.pricing === null) {
|