@agent-score/commerce 2.1.0 → 2.2.0
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 +2 -2
- package/dist/challenge/index.d.ts +2 -2
- package/dist/challenge/index.js +7 -5
- package/dist/challenge/index.js.map +1 -1
- package/dist/challenge/index.mjs +7 -5
- package/dist/challenge/index.mjs.map +1 -1
- package/dist/{checkout-Bd_4aQ6c.d.mts → checkout-CKQE2QpJ.d.mts} +38 -23
- package/dist/{checkout-BH-I_Ns8.d.ts → checkout-CfgxgPZL.d.ts} +38 -23
- package/dist/core.js +4 -3
- package/dist/core.js.map +1 -1
- package/dist/core.mjs +4 -3
- package/dist/core.mjs.map +1 -1
- package/dist/{default_rails-BxBzcCA1.d.ts → default_rails-C5gKZJMI.d.ts} +11 -1
- package/dist/{default_rails-BWAquZeu.d.mts → default_rails-XFCuRddA.d.mts} +11 -1
- package/dist/discovery/index.d.mts +3 -3
- package/dist/discovery/index.d.ts +3 -3
- package/dist/identity/express.d.mts +4 -3
- package/dist/identity/express.d.ts +4 -3
- package/dist/identity/express.js +4 -3
- package/dist/identity/express.js.map +1 -1
- package/dist/identity/express.mjs +4 -3
- package/dist/identity/express.mjs.map +1 -1
- package/dist/identity/fastify.d.mts +4 -3
- package/dist/identity/fastify.d.ts +4 -3
- package/dist/identity/fastify.js +4 -3
- package/dist/identity/fastify.js.map +1 -1
- package/dist/identity/fastify.mjs +4 -3
- package/dist/identity/fastify.mjs.map +1 -1
- package/dist/identity/hono.d.mts +4 -3
- package/dist/identity/hono.d.ts +4 -3
- package/dist/identity/hono.js +4 -3
- package/dist/identity/hono.js.map +1 -1
- package/dist/identity/hono.mjs +4 -3
- package/dist/identity/hono.mjs.map +1 -1
- package/dist/identity/nextjs.js +4 -3
- package/dist/identity/nextjs.js.map +1 -1
- package/dist/identity/nextjs.mjs +4 -3
- package/dist/identity/nextjs.mjs.map +1 -1
- package/dist/identity/policy.js +22 -23363
- package/dist/identity/policy.js.map +1 -1
- package/dist/identity/policy.mjs +1 -23366
- package/dist/identity/policy.mjs.map +1 -1
- package/dist/identity/web.js +4 -3
- package/dist/identity/web.js.map +1 -1
- package/dist/identity/web.mjs +4 -3
- package/dist/identity/web.mjs.map +1 -1
- package/dist/index.d.mts +73 -6
- package/dist/index.d.ts +73 -6
- package/dist/index.js +392 -148
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +389 -146
- package/dist/index.mjs.map +1 -1
- package/dist/middleware/express.js.map +1 -1
- package/dist/middleware/express.mjs.map +1 -1
- package/dist/middleware/fastify.js.map +1 -1
- package/dist/middleware/fastify.mjs.map +1 -1
- package/dist/middleware/hono.js.map +1 -1
- package/dist/middleware/hono.mjs.map +1 -1
- package/dist/middleware/nextjs.js.map +1 -1
- package/dist/middleware/nextjs.mjs.map +1 -1
- package/dist/middleware/web.js.map +1 -1
- package/dist/middleware/web.mjs.map +1 -1
- package/dist/payment/index.d.mts +13 -17
- package/dist/payment/index.d.ts +13 -17
- package/dist/payment/index.js +80 -4
- package/dist/payment/index.js.map +1 -1
- package/dist/payment/index.mjs +79 -4
- package/dist/payment/index.mjs.map +1 -1
- package/dist/{pricing-4n5Ota0D.d.mts → pricing-dSI3ePmE.d.mts} +4 -2
- package/dist/{pricing-DHfH3ogG.d.ts → pricing-uFGRNoGl.d.ts} +4 -2
- package/dist/stripe-multichain/index.js +55 -5
- package/dist/stripe-multichain/index.js.map +1 -1
- package/dist/stripe-multichain/index.mjs +55 -5
- package/dist/stripe-multichain/index.mjs.map +1 -1
- package/package.json +8 -8
|
@@ -43,8 +43,10 @@ declare function buildHowToPay({ url, retryBodyJson, totalUsd, rails, opTokenPla
|
|
|
43
43
|
totalUsd: string | number;
|
|
44
44
|
/** Per-rail config — each is optional. Pass only the rails you support. */
|
|
45
45
|
rails: HowToPayRails;
|
|
46
|
-
/** Placeholder text for the operator token in commands. Defaults to '<your_opc_token>'.
|
|
47
|
-
|
|
46
|
+
/** Placeholder text for the operator token in commands. Defaults to '<your_opc_token>'.
|
|
47
|
+
* Pass `null` (gateless merchants) to strip the `-H 'X-Operator-Token: ...'` line entirely
|
|
48
|
+
* from each rail command — appropriate when the merchant doesn't run an identity gate. */
|
|
49
|
+
opTokenPlaceholder?: string | null;
|
|
48
50
|
/** Override max-spend value used in commands. Default: `ceil(totalUsd) + 1`
|
|
49
51
|
* (for prices ≥ $1) or `totalUsd.toFixed(decimals)` (for sub-dollar prices,
|
|
50
52
|
* so the command flags reflect the real amount instead of `1.00`). */
|
|
@@ -43,8 +43,10 @@ declare function buildHowToPay({ url, retryBodyJson, totalUsd, rails, opTokenPla
|
|
|
43
43
|
totalUsd: string | number;
|
|
44
44
|
/** Per-rail config — each is optional. Pass only the rails you support. */
|
|
45
45
|
rails: HowToPayRails;
|
|
46
|
-
/** Placeholder text for the operator token in commands. Defaults to '<your_opc_token>'.
|
|
47
|
-
|
|
46
|
+
/** Placeholder text for the operator token in commands. Defaults to '<your_opc_token>'.
|
|
47
|
+
* Pass `null` (gateless merchants) to strip the `-H 'X-Operator-Token: ...'` line entirely
|
|
48
|
+
* from each rail command — appropriate when the merchant doesn't run an identity gate. */
|
|
49
|
+
opTokenPlaceholder?: string | null;
|
|
48
50
|
/** Override max-spend value used in commands. Default: `ceil(totalUsd) + 1`
|
|
49
51
|
* (for prices ≥ $1) or `totalUsd.toFixed(decimals)` (for sub-dollar prices,
|
|
50
52
|
* so the command flags reflect the real amount instead of `1.00`). */
|
|
@@ -19434,11 +19434,12 @@ function toClient(method, options) {
|
|
|
19434
19434
|
};
|
|
19435
19435
|
}
|
|
19436
19436
|
function toServer(method, options) {
|
|
19437
|
-
const { authorize, defaults, html, request, respond, stableBinding, transport, verify: verify3 } = options;
|
|
19437
|
+
const { authorize, defaults, extensions, html, request, respond, stableBinding, transport, verify: verify3 } = options;
|
|
19438
19438
|
return {
|
|
19439
19439
|
...method,
|
|
19440
19440
|
authorize,
|
|
19441
19441
|
defaults,
|
|
19442
|
+
extensions,
|
|
19442
19443
|
html,
|
|
19443
19444
|
request,
|
|
19444
19445
|
respond,
|
|
@@ -19660,6 +19661,22 @@ __export(stripe_multichain_exports, {
|
|
|
19660
19661
|
});
|
|
19661
19662
|
module.exports = __toCommonJS(stripe_multichain_exports);
|
|
19662
19663
|
|
|
19664
|
+
// src/errors.ts
|
|
19665
|
+
var CheckoutValidationError = class extends Error {
|
|
19666
|
+
code;
|
|
19667
|
+
action;
|
|
19668
|
+
status;
|
|
19669
|
+
extra;
|
|
19670
|
+
constructor(opts) {
|
|
19671
|
+
super(opts.message);
|
|
19672
|
+
this.name = "CheckoutValidationError";
|
|
19673
|
+
this.code = opts.code;
|
|
19674
|
+
this.action = opts.action ?? "fix_request";
|
|
19675
|
+
this.status = opts.status ?? 400;
|
|
19676
|
+
this.extra = opts.extra;
|
|
19677
|
+
}
|
|
19678
|
+
};
|
|
19679
|
+
|
|
19663
19680
|
// src/stripe-multichain/payment_intent.ts
|
|
19664
19681
|
async function createMultichainPaymentIntent({
|
|
19665
19682
|
stripe,
|
|
@@ -19692,7 +19709,12 @@ async function createMultichainPaymentIntent({
|
|
|
19692
19709
|
if (info?.address) depositAddresses[network] = info.address;
|
|
19693
19710
|
}
|
|
19694
19711
|
if (Object.keys(depositAddresses).length === 0) {
|
|
19695
|
-
throw new
|
|
19712
|
+
throw new CheckoutValidationError({
|
|
19713
|
+
code: "payment_provider_unavailable",
|
|
19714
|
+
message: "Stripe returned no crypto deposit addresses for this PaymentIntent. The account may not be enrolled in the Stablecoins and Crypto preview, or the feature was revoked.",
|
|
19715
|
+
action: "retry_later",
|
|
19716
|
+
status: 503
|
|
19717
|
+
});
|
|
19696
19718
|
}
|
|
19697
19719
|
return { paymentIntentId: pi.id, depositAddresses };
|
|
19698
19720
|
}
|
|
@@ -19703,12 +19725,35 @@ async function createPayToAddressFromStripePI(opts) {
|
|
|
19703
19725
|
if (authHeader) {
|
|
19704
19726
|
const { Credential } = await Promise.resolve().then(() => (init_dist2(), dist_exports));
|
|
19705
19727
|
if (Credential.extractPaymentScheme(authHeader)) {
|
|
19706
|
-
|
|
19728
|
+
let credential;
|
|
19729
|
+
try {
|
|
19730
|
+
credential = Credential.fromRequest(opts.request);
|
|
19731
|
+
} catch {
|
|
19732
|
+
throw new CheckoutValidationError({
|
|
19733
|
+
code: "invalid_credential",
|
|
19734
|
+
message: "The Authorization: Payment header is not a valid MPP credential.",
|
|
19735
|
+
action: "retry_without_credential",
|
|
19736
|
+
status: 401
|
|
19737
|
+
});
|
|
19738
|
+
}
|
|
19707
19739
|
const method = credential.challenge.method;
|
|
19708
19740
|
if (method === "tempo" || method === "solana") {
|
|
19709
19741
|
const toAddress = credential.challenge.request.recipient;
|
|
19742
|
+
if (typeof toAddress !== "string" || !toAddress) {
|
|
19743
|
+
throw new CheckoutValidationError({
|
|
19744
|
+
code: "invalid_credential",
|
|
19745
|
+
message: "The MPP credential is missing its recipient field.",
|
|
19746
|
+
action: "retry_without_credential",
|
|
19747
|
+
status: 401
|
|
19748
|
+
});
|
|
19749
|
+
}
|
|
19710
19750
|
if (!await opts.piCache.hasAddress(toAddress)) {
|
|
19711
|
-
throw new
|
|
19751
|
+
throw new CheckoutValidationError({
|
|
19752
|
+
code: "invalid_credential",
|
|
19753
|
+
message: "The signed-against payTo recipient is not in this merchant's cache (unknown or expired). Retry without the Authorization: Payment header to receive a fresh 402 challenge.",
|
|
19754
|
+
action: "retry_without_credential",
|
|
19755
|
+
status: 401
|
|
19756
|
+
});
|
|
19712
19757
|
}
|
|
19713
19758
|
return toAddress;
|
|
19714
19759
|
}
|
|
@@ -19730,7 +19775,12 @@ async function createPayToAddressFromStripePI(opts) {
|
|
|
19730
19775
|
const preferred = opts.preferredNetwork ?? "tempo";
|
|
19731
19776
|
const payTo = depositAddresses[preferred] ?? depositAddresses.base ?? depositAddresses.tempo;
|
|
19732
19777
|
if (!payTo) {
|
|
19733
|
-
throw new
|
|
19778
|
+
throw new CheckoutValidationError({
|
|
19779
|
+
code: "payment_provider_unavailable",
|
|
19780
|
+
message: "Stripe returned deposit addresses but none matched the requested network (tempo / base / solana). The account may have only a subset of multichain networks enabled.",
|
|
19781
|
+
action: "retry_later",
|
|
19782
|
+
status: 503
|
|
19783
|
+
});
|
|
19734
19784
|
}
|
|
19735
19785
|
return payTo;
|
|
19736
19786
|
}
|