@agent-score/commerce 2.1.1 → 2.3.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 +2 -2
- package/dist/challenge/index.d.mts +3 -3
- package/dist/challenge/index.d.ts +3 -3
- 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-BRw_caGr.d.mts → checkout-Ceo1_rVJ.d.mts} +38 -2
- package/dist/{checkout-CuSNUJFX.d.ts → checkout-ChyOi7aU.d.ts} +38 -2
- 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-C5gKZJMI.d.ts → default_rails-DtR_E9N9.d.ts} +1 -1
- package/dist/{default_rails-XFCuRddA.d.mts → default_rails-K25PtWrL.d.mts} +1 -1
- package/dist/discovery/index.d.mts +4 -4
- package/dist/discovery/index.d.ts +4 -4
- 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/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 +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +139 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +139 -13
- package/dist/index.mjs.map +1 -1
- package/dist/payment/index.d.mts +3 -3
- package/dist/payment/index.d.ts +3 -3
- package/dist/payment/index.js +2 -0
- package/dist/payment/index.js.map +1 -1
- package/dist/payment/index.mjs +2 -0
- package/dist/payment/index.mjs.map +1 -1
- package/dist/{pricing-DHfH3ogG.d.ts → pricing-B3-aKxSz.d.ts} +5 -3
- package/dist/{pricing-4n5Ota0D.d.mts → pricing-BReyZiqN.d.mts} +5 -3
- package/dist/{rail_spec-D6qzh3J0.d.mts → rail_spec-B1239jPp.d.mts} +25 -0
- package/dist/{rail_spec-D6qzh3J0.d.ts → rail_spec-B1239jPp.d.ts} +25 -0
- package/dist/stripe-multichain/index.d.mts +61 -11
- package/dist/stripe-multichain/index.d.ts +61 -11
- package/dist/stripe-multichain/index.js +84 -43
- package/dist/stripe-multichain/index.js.map +1 -1
- package/dist/stripe-multichain/index.mjs +83 -43
- package/dist/stripe-multichain/index.mjs.map +1 -1
- package/package.json +9 -9
|
@@ -19432,11 +19432,12 @@ function toClient(method, options) {
|
|
|
19432
19432
|
};
|
|
19433
19433
|
}
|
|
19434
19434
|
function toServer(method, options) {
|
|
19435
|
-
const { authorize, defaults, html, request, respond, stableBinding, transport, verify: verify3 } = options;
|
|
19435
|
+
const { authorize, defaults, extensions, html, request, respond, stableBinding, transport, verify: verify3 } = options;
|
|
19436
19436
|
return {
|
|
19437
19437
|
...method,
|
|
19438
19438
|
authorize,
|
|
19439
19439
|
defaults,
|
|
19440
|
+
extensions,
|
|
19440
19441
|
html,
|
|
19441
19442
|
request,
|
|
19442
19443
|
respond,
|
|
@@ -19701,50 +19702,76 @@ async function createMultichainPaymentIntent({
|
|
|
19701
19702
|
}
|
|
19702
19703
|
|
|
19703
19704
|
// src/stripe-multichain/pay_to_address.ts
|
|
19705
|
+
var DEFAULT_NETWORKS = ["tempo", "base", "solana"];
|
|
19704
19706
|
async function createPayToAddressFromStripePI(opts) {
|
|
19707
|
+
const fromCredential = await tryResolveFromCredential(opts);
|
|
19708
|
+
if (fromCredential !== null) return fromCredential;
|
|
19709
|
+
const { preferred } = await mintAndCache(opts);
|
|
19710
|
+
return preferred;
|
|
19711
|
+
}
|
|
19712
|
+
async function mintMultichainRecipients(opts) {
|
|
19713
|
+
const fromCredential = await tryResolveFromCredential(opts);
|
|
19714
|
+
if (fromCredential !== null) {
|
|
19715
|
+
const piId = opts.piCache.getPaymentIntentId(fromCredential);
|
|
19716
|
+
const networkMap = piId ? readNetworkMapFromCache(opts.piCache, piId) : {};
|
|
19717
|
+
const merged2 = { ...networkMap, ...opts.staticRecipients ?? {} };
|
|
19718
|
+
return {
|
|
19719
|
+
recipients: merged2,
|
|
19720
|
+
...piId !== void 0 && { paymentIntentId: piId },
|
|
19721
|
+
reusedFromCredential: true
|
|
19722
|
+
};
|
|
19723
|
+
}
|
|
19724
|
+
const { merged, paymentIntentId } = await mintAndCache(opts);
|
|
19725
|
+
return { recipients: merged, paymentIntentId, reusedFromCredential: false };
|
|
19726
|
+
}
|
|
19727
|
+
async function tryResolveFromCredential(opts) {
|
|
19705
19728
|
const authHeader = opts.request.headers.get("authorization");
|
|
19706
|
-
if (authHeader)
|
|
19707
|
-
|
|
19708
|
-
|
|
19709
|
-
|
|
19710
|
-
|
|
19711
|
-
|
|
19712
|
-
|
|
19713
|
-
|
|
19714
|
-
|
|
19715
|
-
|
|
19716
|
-
|
|
19717
|
-
|
|
19718
|
-
|
|
19719
|
-
|
|
19720
|
-
|
|
19721
|
-
|
|
19722
|
-
|
|
19723
|
-
|
|
19724
|
-
|
|
19725
|
-
|
|
19726
|
-
|
|
19727
|
-
|
|
19728
|
-
|
|
19729
|
-
|
|
19730
|
-
|
|
19731
|
-
|
|
19732
|
-
|
|
19733
|
-
|
|
19734
|
-
|
|
19735
|
-
|
|
19736
|
-
|
|
19737
|
-
|
|
19738
|
-
|
|
19739
|
-
|
|
19740
|
-
}
|
|
19741
|
-
}
|
|
19729
|
+
if (!authHeader) return null;
|
|
19730
|
+
const { Credential } = await Promise.resolve().then(() => (init_dist2(), dist_exports));
|
|
19731
|
+
if (!Credential.extractPaymentScheme(authHeader)) return null;
|
|
19732
|
+
let credential;
|
|
19733
|
+
try {
|
|
19734
|
+
credential = Credential.fromRequest(opts.request);
|
|
19735
|
+
} catch {
|
|
19736
|
+
throw new CheckoutValidationError({
|
|
19737
|
+
code: "invalid_credential",
|
|
19738
|
+
message: "The Authorization: Payment header is not a valid MPP credential.",
|
|
19739
|
+
action: "retry_without_credential",
|
|
19740
|
+
status: 401
|
|
19741
|
+
});
|
|
19742
|
+
}
|
|
19743
|
+
const method = credential.challenge.method;
|
|
19744
|
+
if (method !== "tempo" && method !== "solana") return null;
|
|
19745
|
+
const toAddress = credential.challenge.request.recipient;
|
|
19746
|
+
if (typeof toAddress !== "string" || !toAddress) {
|
|
19747
|
+
throw new CheckoutValidationError({
|
|
19748
|
+
code: "invalid_credential",
|
|
19749
|
+
message: "The MPP credential is missing its recipient field.",
|
|
19750
|
+
action: "retry_without_credential",
|
|
19751
|
+
status: 401
|
|
19752
|
+
});
|
|
19753
|
+
}
|
|
19754
|
+
const staticForMethod = opts.staticRecipients?.[method];
|
|
19755
|
+
if (staticForMethod && staticForMethod === toAddress) return toAddress;
|
|
19756
|
+
if (!await opts.piCache.hasAddress(toAddress)) {
|
|
19757
|
+
throw new CheckoutValidationError({
|
|
19758
|
+
code: "invalid_credential",
|
|
19759
|
+
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.",
|
|
19760
|
+
action: "retry_without_credential",
|
|
19761
|
+
status: 401
|
|
19762
|
+
});
|
|
19742
19763
|
}
|
|
19764
|
+
return toAddress;
|
|
19765
|
+
}
|
|
19766
|
+
async function mintAndCache(opts) {
|
|
19767
|
+
const staticRecipients = opts.staticRecipients ?? {};
|
|
19768
|
+
const requestedNetworks = opts.networks ?? [...DEFAULT_NETWORKS];
|
|
19769
|
+
const stripeNetworks = requestedNetworks.filter((n) => !(n in staticRecipients));
|
|
19743
19770
|
const idempotencyKey = opts.orderId ? `pi-${opts.orderId}-${opts.amountCents}` : void 0;
|
|
19744
19771
|
const { paymentIntentId, depositAddresses } = await createMultichainPaymentIntent({
|
|
19745
19772
|
stripe: opts.stripe,
|
|
19746
19773
|
amount: opts.amountCents,
|
|
19747
|
-
networks:
|
|
19774
|
+
networks: stripeNetworks,
|
|
19748
19775
|
...opts.metadata ? { metadata: opts.metadata } : {},
|
|
19749
19776
|
...idempotencyKey ? { idempotencyKey } : {}
|
|
19750
19777
|
});
|
|
@@ -19752,10 +19779,14 @@ async function createPayToAddressFromStripePI(opts) {
|
|
|
19752
19779
|
await opts.piCache.cacheAddress(address2);
|
|
19753
19780
|
opts.piCache.cachePaymentIntent(address2, paymentIntentId);
|
|
19754
19781
|
}
|
|
19755
|
-
|
|
19756
|
-
|
|
19757
|
-
|
|
19758
|
-
|
|
19782
|
+
for (const address2 of Object.values(staticRecipients)) {
|
|
19783
|
+
await opts.piCache.cacheAddress(address2);
|
|
19784
|
+
}
|
|
19785
|
+
const merged = { ...depositAddresses, ...staticRecipients };
|
|
19786
|
+
opts.piCache.cacheNetworkAddresses(paymentIntentId, merged);
|
|
19787
|
+
const preferredKey = opts.preferredNetwork ?? "tempo";
|
|
19788
|
+
const preferred = merged[preferredKey] ?? merged.base ?? merged.tempo;
|
|
19789
|
+
if (!preferred) {
|
|
19759
19790
|
throw new CheckoutValidationError({
|
|
19760
19791
|
code: "payment_provider_unavailable",
|
|
19761
19792
|
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.",
|
|
@@ -19763,7 +19794,15 @@ async function createPayToAddressFromStripePI(opts) {
|
|
|
19763
19794
|
status: 503
|
|
19764
19795
|
});
|
|
19765
19796
|
}
|
|
19766
|
-
return
|
|
19797
|
+
return { preferred, merged, paymentIntentId };
|
|
19798
|
+
}
|
|
19799
|
+
function readNetworkMapFromCache(piCache, paymentIntentId) {
|
|
19800
|
+
const entries = [];
|
|
19801
|
+
for (const n of DEFAULT_NETWORKS) {
|
|
19802
|
+
const addr = piCache.getNetworkDepositAddress(paymentIntentId, n);
|
|
19803
|
+
if (addr) entries.push([n, addr]);
|
|
19804
|
+
}
|
|
19805
|
+
return Object.fromEntries(entries);
|
|
19767
19806
|
}
|
|
19768
19807
|
|
|
19769
19808
|
// src/stripe-multichain/simulate_deposit.ts
|
|
@@ -19987,6 +20026,7 @@ export {
|
|
|
19987
20026
|
createMultichainPaymentIntent,
|
|
19988
20027
|
createPayToAddressFromStripePI,
|
|
19989
20028
|
createPiCache,
|
|
20029
|
+
mintMultichainRecipients,
|
|
19990
20030
|
networkForOutcome,
|
|
19991
20031
|
simulateCryptoDeposit,
|
|
19992
20032
|
simulateDepositForOutcome,
|