@agent-score/commerce 2.1.0 → 2.1.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.js.map +1 -1
- package/dist/challenge/index.mjs.map +1 -1
- package/dist/{checkout-Bd_4aQ6c.d.mts → checkout-BRw_caGr.d.mts} +1 -22
- package/dist/{checkout-BH-I_Ns8.d.ts → checkout-CuSNUJFX.d.ts} +1 -22
- package/dist/core.js +1 -1
- package/dist/core.js.map +1 -1
- package/dist/core.mjs +1 -1
- 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 +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/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 +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 +72 -5
- package/dist/index.d.ts +72 -5
- package/dist/index.js +256 -136
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +253 -134
- 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/stripe-multichain/index.js +53 -4
- package/dist/stripe-multichain/index.js.map +1 -1
- package/dist/stripe-multichain/index.mjs +53 -4
- package/dist/stripe-multichain/index.mjs.map +1 -1
- package/package.json +4 -4
|
@@ -19660,6 +19660,22 @@ __export(stripe_multichain_exports, {
|
|
|
19660
19660
|
});
|
|
19661
19661
|
module.exports = __toCommonJS(stripe_multichain_exports);
|
|
19662
19662
|
|
|
19663
|
+
// src/errors.ts
|
|
19664
|
+
var CheckoutValidationError = class extends Error {
|
|
19665
|
+
code;
|
|
19666
|
+
action;
|
|
19667
|
+
status;
|
|
19668
|
+
extra;
|
|
19669
|
+
constructor(opts) {
|
|
19670
|
+
super(opts.message);
|
|
19671
|
+
this.name = "CheckoutValidationError";
|
|
19672
|
+
this.code = opts.code;
|
|
19673
|
+
this.action = opts.action ?? "fix_request";
|
|
19674
|
+
this.status = opts.status ?? 400;
|
|
19675
|
+
this.extra = opts.extra;
|
|
19676
|
+
}
|
|
19677
|
+
};
|
|
19678
|
+
|
|
19663
19679
|
// src/stripe-multichain/payment_intent.ts
|
|
19664
19680
|
async function createMultichainPaymentIntent({
|
|
19665
19681
|
stripe,
|
|
@@ -19692,7 +19708,12 @@ async function createMultichainPaymentIntent({
|
|
|
19692
19708
|
if (info?.address) depositAddresses[network] = info.address;
|
|
19693
19709
|
}
|
|
19694
19710
|
if (Object.keys(depositAddresses).length === 0) {
|
|
19695
|
-
throw new
|
|
19711
|
+
throw new CheckoutValidationError({
|
|
19712
|
+
code: "payment_provider_unavailable",
|
|
19713
|
+
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.",
|
|
19714
|
+
action: "retry_later",
|
|
19715
|
+
status: 503
|
|
19716
|
+
});
|
|
19696
19717
|
}
|
|
19697
19718
|
return { paymentIntentId: pi.id, depositAddresses };
|
|
19698
19719
|
}
|
|
@@ -19703,12 +19724,35 @@ async function createPayToAddressFromStripePI(opts) {
|
|
|
19703
19724
|
if (authHeader) {
|
|
19704
19725
|
const { Credential } = await Promise.resolve().then(() => (init_dist2(), dist_exports));
|
|
19705
19726
|
if (Credential.extractPaymentScheme(authHeader)) {
|
|
19706
|
-
|
|
19727
|
+
let credential;
|
|
19728
|
+
try {
|
|
19729
|
+
credential = Credential.fromRequest(opts.request);
|
|
19730
|
+
} catch {
|
|
19731
|
+
throw new CheckoutValidationError({
|
|
19732
|
+
code: "invalid_credential",
|
|
19733
|
+
message: "The Authorization: Payment header is not a valid MPP credential.",
|
|
19734
|
+
action: "retry_without_credential",
|
|
19735
|
+
status: 401
|
|
19736
|
+
});
|
|
19737
|
+
}
|
|
19707
19738
|
const method = credential.challenge.method;
|
|
19708
19739
|
if (method === "tempo" || method === "solana") {
|
|
19709
19740
|
const toAddress = credential.challenge.request.recipient;
|
|
19741
|
+
if (typeof toAddress !== "string" || !toAddress) {
|
|
19742
|
+
throw new CheckoutValidationError({
|
|
19743
|
+
code: "invalid_credential",
|
|
19744
|
+
message: "The MPP credential is missing its recipient field.",
|
|
19745
|
+
action: "retry_without_credential",
|
|
19746
|
+
status: 401
|
|
19747
|
+
});
|
|
19748
|
+
}
|
|
19710
19749
|
if (!await opts.piCache.hasAddress(toAddress)) {
|
|
19711
|
-
throw new
|
|
19750
|
+
throw new CheckoutValidationError({
|
|
19751
|
+
code: "invalid_credential",
|
|
19752
|
+
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.",
|
|
19753
|
+
action: "retry_without_credential",
|
|
19754
|
+
status: 401
|
|
19755
|
+
});
|
|
19712
19756
|
}
|
|
19713
19757
|
return toAddress;
|
|
19714
19758
|
}
|
|
@@ -19730,7 +19774,12 @@ async function createPayToAddressFromStripePI(opts) {
|
|
|
19730
19774
|
const preferred = opts.preferredNetwork ?? "tempo";
|
|
19731
19775
|
const payTo = depositAddresses[preferred] ?? depositAddresses.base ?? depositAddresses.tempo;
|
|
19732
19776
|
if (!payTo) {
|
|
19733
|
-
throw new
|
|
19777
|
+
throw new CheckoutValidationError({
|
|
19778
|
+
code: "payment_provider_unavailable",
|
|
19779
|
+
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.",
|
|
19780
|
+
action: "retry_later",
|
|
19781
|
+
status: 503
|
|
19782
|
+
});
|
|
19734
19783
|
}
|
|
19735
19784
|
return payTo;
|
|
19736
19785
|
}
|