@cedros/pay-react 1.1.24 → 1.1.26
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/{AISettingsSection-Dw0ZlxMf.mjs → AISettingsSection-BlIv3CzS.mjs} +2 -2
- package/dist/{AISettingsSection-IXS1Wt_1.js → AISettingsSection-DELur7D2.js} +1 -1
- package/dist/{AutosaveIndicator-BJsg_kFZ.mjs → AutosaveIndicator-Bed0-ekg.mjs} +1 -1
- package/dist/{AutosaveIndicator-CY_YHM1D.js → AutosaveIndicator-Dn_qA2hK.js} +1 -1
- package/dist/CedrosContext-C2RjHLaQ.js +6 -0
- package/dist/{CedrosContext-DQUbL8yP.mjs → CedrosContext-CY6zvjvJ.mjs} +768 -617
- package/dist/ChatLogsSection-BH5tLA4T.js +1 -0
- package/dist/ChatLogsSection-v4zwzCTC.mjs +201 -0
- package/dist/ComplianceSection-CemgfDrL.mjs +650 -0
- package/dist/ComplianceSection-DP2a9-S0.js +1 -0
- package/dist/{CryptoButton-D1BCZBk4.mjs → CryptoButton-BV9owVe2.mjs} +2 -2
- package/dist/{CryptoButton-C1AAOOfj.js → CryptoButton-DpiCnyXE.js} +1 -1
- package/dist/CustomersSection-CBwy_waO.js +1 -0
- package/dist/CustomersSection-D_j7OrfS.mjs +207 -0
- package/dist/DisputesSection-BLjIk60n.js +1 -0
- package/dist/DisputesSection-BcAbXp3K.mjs +230 -0
- package/dist/{FAQSection-C78MnK4k.mjs → FAQSection-Dn38OhB_.mjs} +1 -1
- package/dist/{FAQSection-BmgmzDN5.js → FAQSection-wNeH0i6Q.js} +1 -1
- package/dist/ImagesSection-0ZzKlzMJ.js +1 -0
- package/dist/ImagesSection-Ctw9Icym.mjs +216 -0
- package/dist/InventorySection-DmhjUlRZ.mjs +150 -0
- package/dist/InventorySection-zV6lTmue.js +1 -0
- package/dist/{MessagingSection-De3t8bSI.mjs → MessagingSection-B1FaGxkp.mjs} +2 -2
- package/dist/{MessagingSection-CWLZcg11.js → MessagingSection-B_wdFR0j.js} +1 -1
- package/dist/{OrdersSection-_xKVzjSZ.mjs → OrdersSection-Bj8bPdg8.mjs} +6 -6
- package/dist/{OrdersSection-BKOxsZw0.js → OrdersSection-Dw2FX-1d.js} +1 -1
- package/dist/{PaymentSettingsSection-BTEn9Dxb.js → PaymentSettingsSection-BYF4D-GR.js} +1 -1
- package/dist/{PaymentSettingsSection-KjU_dN_d.mjs → PaymentSettingsSection-EnMxeWjv.mjs} +1 -1
- package/dist/ReturnsSection-BC0L8r2e.mjs +267 -0
- package/dist/ReturnsSection-D_pJVxuG.js +1 -0
- package/dist/{SettingsSection-8QHZB59k.mjs → SettingsSection-KYdEizq_.mjs} +19 -13
- package/dist/SettingsSection-vdYFSNxB.js +1 -0
- package/dist/ShippingSection-1DRSTu49.js +1 -0
- package/dist/ShippingSection-BOgto6_9.mjs +434 -0
- package/dist/{SingleCategorySettings-CRXTMTo5.js → SingleCategorySettings-DwCnBdRf.js} +1 -1
- package/dist/{SingleCategorySettings--LK0TZW0.mjs → SingleCategorySettings-suJ8z9d8.mjs} +4 -4
- package/dist/{StorefrontSection-CeCpr8hn.mjs → StorefrontSection-BRvIGBEJ.mjs} +2 -2
- package/dist/{StorefrontSection-C9DzCmOf.js → StorefrontSection-RumGkb3C.js} +1 -1
- package/dist/{SubscriptionsSection-Dn5SY6S_.js → SubscriptionsSection-C2aLLn7L.js} +1 -1
- package/dist/{SubscriptionsSection-C2xk8ApF.mjs → SubscriptionsSection-D60qrX9a.mjs} +7 -7
- package/dist/TaxSection-C7-pv-Rl.mjs +294 -0
- package/dist/TaxSection-Dt1DnM51.js +1 -0
- package/dist/Token22Section-CrHLQ0EB.mjs +2260 -0
- package/dist/Token22Section-DY3mUwTY.js +1 -0
- package/dist/{WalletManager-Bwk3rgr1.js → WalletManager-B3UdQ5pQ.js} +1 -1
- package/dist/{WalletManager-CXvQ0Zu9.mjs → WalletManager-BIwH8Dw_.mjs} +1 -1
- package/dist/WebhooksSection-CKeiJ7Py.js +1 -0
- package/dist/WebhooksSection-COPW4Ec0.mjs +223 -0
- package/dist/{configApi-Ch0Rr7TD.mjs → configApi-6XhAJGKX.mjs} +31 -0
- package/dist/{configApi-CxEbCAgG.js → configApi-DkduMQg1.js} +1 -1
- package/dist/crypto-only.js +1 -1
- package/dist/crypto-only.mjs +85 -83
- package/dist/index-C0g-JxJk.js +84 -0
- package/dist/{index-BHF82XBB.mjs → index-DXnuQp5x.mjs} +8643 -7678
- package/dist/index.js +1 -1
- package/dist/index.mjs +42 -40
- package/dist/{sections-C1rb9YRh.mjs → sections-C1NpK7hk.mjs} +2 -2
- package/dist/{sections-8e5Y3ukY.js → sections-DVVSZBhW.js} +1 -1
- package/dist/src/admin/plugin.d.ts.map +1 -1
- package/dist/src/components/ComplianceGatePage.d.ts +40 -0
- package/dist/src/components/ComplianceGatePage.d.ts.map +1 -0
- package/dist/src/components/SubscribeButton.d.ts +1 -5
- package/dist/src/components/SubscribeButton.d.ts.map +1 -1
- package/dist/src/components/admin/AdminAuthManager.d.ts +7 -3
- package/dist/src/components/admin/AdminAuthManager.d.ts.map +1 -1
- package/dist/src/components/admin/AssetClassesTab.d.ts.map +1 -1
- package/dist/src/components/admin/CedrosPayAdminDashboard.d.ts +1 -1
- package/dist/src/components/admin/CedrosPayAdminDashboard.d.ts.map +1 -1
- package/dist/src/components/admin/ChatLogsSection.d.ts +3 -0
- package/dist/src/components/admin/ChatLogsSection.d.ts.map +1 -0
- package/dist/src/components/admin/ComplianceKycTab.d.ts +3 -0
- package/dist/src/components/admin/ComplianceKycTab.d.ts.map +1 -0
- package/dist/src/components/admin/ComplianceRequirementsEditor.d.ts +8 -0
- package/dist/src/components/admin/ComplianceRequirementsEditor.d.ts.map +1 -0
- package/dist/src/components/admin/ComplianceSanctionsApi.d.ts +3 -0
- package/dist/src/components/admin/ComplianceSanctionsApi.d.ts.map +1 -0
- package/dist/src/components/admin/ComplianceSection.d.ts +3 -0
- package/dist/src/components/admin/ComplianceSection.d.ts.map +1 -0
- package/dist/src/components/admin/CustomersSection.d.ts +3 -0
- package/dist/src/components/admin/CustomersSection.d.ts.map +1 -0
- package/dist/src/components/admin/DisputesSection.d.ts +3 -0
- package/dist/src/components/admin/DisputesSection.d.ts.map +1 -0
- package/dist/src/components/admin/GiftCardAnalytics.d.ts +3 -0
- package/dist/src/components/admin/GiftCardAnalytics.d.ts.map +1 -0
- package/dist/src/components/admin/GiftCardManager.d.ts +3 -0
- package/dist/src/components/admin/GiftCardManager.d.ts.map +1 -0
- package/dist/src/components/admin/ImagesSection.d.ts +3 -0
- package/dist/src/components/admin/ImagesSection.d.ts.map +1 -0
- package/dist/src/components/admin/InventorySection.d.ts +3 -0
- package/dist/src/components/admin/InventorySection.d.ts.map +1 -0
- package/dist/src/components/admin/LiquidityPoolTab.d.ts.map +1 -1
- package/dist/src/components/admin/NftMetadataPreview.d.ts +20 -0
- package/dist/src/components/admin/NftMetadataPreview.d.ts.map +1 -0
- package/dist/src/components/admin/PoolManagementView.d.ts +14 -0
- package/dist/src/components/admin/PoolManagementView.d.ts.map +1 -0
- package/dist/src/components/admin/ProductsSection.d.ts.map +1 -1
- package/dist/src/components/admin/RefundsSection.d.ts.map +1 -1
- package/dist/src/components/admin/ReturnsSection.d.ts +3 -0
- package/dist/src/components/admin/ReturnsSection.d.ts.map +1 -0
- package/dist/src/components/admin/SettingsSection.d.ts.map +1 -1
- package/dist/src/components/admin/ShippingSection.d.ts +3 -0
- package/dist/src/components/admin/ShippingSection.d.ts.map +1 -0
- package/dist/src/components/admin/TaxSection.d.ts +3 -0
- package/dist/src/components/admin/TaxSection.d.ts.map +1 -0
- package/dist/src/components/admin/Token22Section.d.ts.map +1 -1
- package/dist/src/components/admin/WebhooksSection.d.ts +3 -0
- package/dist/src/components/admin/WebhooksSection.d.ts.map +1 -0
- package/dist/src/components/admin/complianceTypes.d.ts +74 -0
- package/dist/src/components/admin/complianceTypes.d.ts.map +1 -0
- package/dist/src/components/admin/configApi.d.ts.map +1 -1
- package/dist/src/components/admin/icons.d.ts +1 -0
- package/dist/src/components/admin/icons.d.ts.map +1 -1
- package/dist/src/components/admin/useAdminAuth.d.ts +1 -1
- package/dist/src/components/admin/useAdminAuth.d.ts.map +1 -1
- package/dist/src/context/CedrosContext.d.ts.map +1 -1
- package/dist/src/ecommerce/adapters/CommerceAdapter.d.ts +36 -0
- package/dist/src/ecommerce/adapters/CommerceAdapter.d.ts.map +1 -1
- package/dist/src/ecommerce/adapters/paywall/paywallAdapter.d.ts.map +1 -1
- package/dist/src/ecommerce/components/catalog/TokenDisplay.d.ts +36 -0
- package/dist/src/ecommerce/components/catalog/TokenDisplay.d.ts.map +1 -0
- package/dist/src/ecommerce/components/chat/ShopChatPanel.d.ts +8 -5
- package/dist/src/ecommerce/components/chat/ShopChatPanel.d.ts.map +1 -1
- package/dist/src/ecommerce/components/checkout/CheckoutForm.d.ts.map +1 -1
- package/dist/src/ecommerce/components/checkout/SendAsGiftSection.d.ts +15 -0
- package/dist/src/ecommerce/components/checkout/SendAsGiftSection.d.ts.map +1 -0
- package/dist/src/ecommerce/components/gift-cards/GiftCardBalanceChecker.d.ts +19 -0
- package/dist/src/ecommerce/components/gift-cards/GiftCardBalanceChecker.d.ts.map +1 -0
- package/dist/src/ecommerce/components/orders/MyRedemptionsPage.d.ts +13 -0
- package/dist/src/ecommerce/components/orders/MyRedemptionsPage.d.ts.map +1 -0
- package/dist/src/ecommerce/components/orders/MyTokensPage.d.ts +15 -0
- package/dist/src/ecommerce/components/orders/MyTokensPage.d.ts.map +1 -0
- package/dist/src/ecommerce/components/orders/OrderDetails.d.ts.map +1 -1
- package/dist/src/ecommerce/hooks/useCartInventory.d.ts.map +1 -1
- package/dist/src/ecommerce/index.d.ts +12 -2
- package/dist/src/ecommerce/index.d.ts.map +1 -1
- package/dist/src/ecommerce/state/checkout/checkoutSchema.d.ts +3 -0
- package/dist/src/ecommerce/state/checkout/checkoutSchema.d.ts.map +1 -1
- package/dist/src/ecommerce/state/checkout/useCheckout.d.ts.map +1 -1
- package/dist/src/ecommerce/types.d.ts +6 -0
- package/dist/src/ecommerce/types.d.ts.map +1 -1
- package/dist/src/ecommerce/utils/cartItemMetadata.d.ts.map +1 -1
- package/dist/src/hooks/useComplianceCheck.d.ts +30 -0
- package/dist/src/hooks/useComplianceCheck.d.ts.map +1 -0
- package/dist/src/hooks/useSubscriptionManagement.d.ts.map +1 -1
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/managers/CreditsManager.d.ts.map +1 -1
- package/dist/src/managers/ManagerCache.d.ts +2 -2
- package/dist/src/managers/ManagerCache.d.ts.map +1 -1
- package/dist/src/managers/StripeManager.d.ts +7 -1
- package/dist/src/managers/StripeManager.d.ts.map +1 -1
- package/dist/src/managers/SubscriptionChangeManager.d.ts.map +1 -1
- package/dist/src/managers/SubscriptionManager.d.ts.map +1 -1
- package/dist/src/types/index.d.ts +14 -0
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/src/types/subscription.d.ts +21 -33
- package/dist/src/types/subscription.d.ts.map +1 -1
- package/dist/src/utils/exponentialBackoff.d.ts +22 -0
- package/dist/src/utils/exponentialBackoff.d.ts.map +1 -1
- package/dist/stripe-only.js +1 -1
- package/dist/stripe-only.mjs +2 -2
- package/dist/styles-BT4bhFey.js +1 -0
- package/dist/{styles-Ag-7ZvAB.mjs → styles-D4SQkuV3.mjs} +606 -609
- package/dist/testing/index.js +1 -1
- package/dist/testing/index.mjs +1 -1
- package/dist/{walletPool-C_0P4mTw.mjs → walletPool-DE-t1wSW.mjs} +1 -1
- package/dist/{walletPool-Ddv33tej.js → walletPool-IS7R3MR1.js} +1 -1
- package/package.json +1 -1
- package/dist/CedrosContext-7dwmEeUY.js +0 -6
- package/dist/SettingsSection-cKF0tLnS.js +0 -1
- package/dist/Token22Section-DUUl59dZ.js +0 -1
- package/dist/Token22Section-HygkDNtL.mjs +0 -1685
- package/dist/index-OaWkrl0G.js +0 -84
- package/dist/styles-21F1-oqx.js +0 -1
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useContext as
|
|
3
|
-
import { g as
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
for (var e = document.querySelectorAll('script[src^="'.concat(
|
|
1
|
+
import { jsx as J } from "react/jsx-runtime";
|
|
2
|
+
import { useContext as se, useState as U, useRef as ve, useEffect as F, useMemo as ae, createContext as Ee } from "react";
|
|
3
|
+
import { g as k } from "./uuid-_z3jSatJ.mjs";
|
|
4
|
+
var Ce = "https://js.stripe.com/v3", Qe = /^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;
|
|
5
|
+
var We = function() {
|
|
6
|
+
for (var e = document.querySelectorAll('script[src^="'.concat(Ce, '"]')), r = 0; r < e.length; r++) {
|
|
7
7
|
var a = e[r];
|
|
8
|
-
if (
|
|
8
|
+
if (Qe.test(a.src))
|
|
9
9
|
return a;
|
|
10
10
|
}
|
|
11
11
|
return null;
|
|
12
|
-
},
|
|
12
|
+
}, de = function(e) {
|
|
13
13
|
var r = "", a = document.createElement("script");
|
|
14
|
-
a.src = "".concat(
|
|
14
|
+
a.src = "".concat(Ce).concat(r);
|
|
15
15
|
var n = document.head || document.body;
|
|
16
16
|
if (!n)
|
|
17
17
|
throw new Error("Expected document.body not to be null. Stripe.js requires a <body> element.");
|
|
18
18
|
return n.appendChild(a), a;
|
|
19
|
-
},
|
|
19
|
+
}, Ke = function(e, r) {
|
|
20
20
|
!e || !e._registerWrapper || e._registerWrapper({
|
|
21
21
|
name: "stripe-js",
|
|
22
22
|
version: "4.6.0",
|
|
23
23
|
startTime: r
|
|
24
24
|
});
|
|
25
|
-
},
|
|
25
|
+
}, q = null, W = null, K = null, Ge = function(e) {
|
|
26
26
|
return function() {
|
|
27
27
|
e(new Error("Failed to load Stripe.js"));
|
|
28
28
|
};
|
|
29
|
-
},
|
|
29
|
+
}, Ve = function(e, r) {
|
|
30
30
|
return function() {
|
|
31
31
|
window.Stripe ? e(window.Stripe) : r(new Error("Stripe.js not available"));
|
|
32
32
|
};
|
|
33
|
-
},
|
|
34
|
-
return
|
|
33
|
+
}, Je = function(e) {
|
|
34
|
+
return q !== null ? q : (q = new Promise(function(r, a) {
|
|
35
35
|
if (typeof window > "u" || typeof document > "u") {
|
|
36
36
|
r(null);
|
|
37
37
|
return;
|
|
@@ -41,48 +41,48 @@ var je = function() {
|
|
|
41
41
|
return;
|
|
42
42
|
}
|
|
43
43
|
try {
|
|
44
|
-
var n =
|
|
44
|
+
var n = We();
|
|
45
45
|
if (!(n && e)) {
|
|
46
46
|
if (!n)
|
|
47
|
-
n =
|
|
48
|
-
else if (n &&
|
|
47
|
+
n = de(e);
|
|
48
|
+
else if (n && K !== null && W !== null) {
|
|
49
49
|
var i;
|
|
50
|
-
n.removeEventListener("load",
|
|
50
|
+
n.removeEventListener("load", K), n.removeEventListener("error", W), (i = n.parentNode) === null || i === void 0 || i.removeChild(n), n = de(e);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
-
|
|
53
|
+
K = Ve(r, a), W = Ge(a), n.addEventListener("load", K), n.addEventListener("error", W);
|
|
54
54
|
} catch (o) {
|
|
55
55
|
a(o);
|
|
56
56
|
return;
|
|
57
57
|
}
|
|
58
|
-
}),
|
|
59
|
-
return
|
|
58
|
+
}), q.catch(function(r) {
|
|
59
|
+
return q = null, Promise.reject(r);
|
|
60
60
|
}));
|
|
61
|
-
},
|
|
61
|
+
}, Ye = function(e, r, a) {
|
|
62
62
|
if (e === null)
|
|
63
63
|
return null;
|
|
64
64
|
var n = e.apply(void 0, r);
|
|
65
|
-
return
|
|
66
|
-
},
|
|
67
|
-
return
|
|
68
|
-
return
|
|
69
|
-
}),
|
|
65
|
+
return Ke(n, a), n;
|
|
66
|
+
}, j, Pe = !1, Se = function() {
|
|
67
|
+
return j || (j = Je(null).catch(function(e) {
|
|
68
|
+
return j = null, Promise.reject(e);
|
|
69
|
+
}), j);
|
|
70
70
|
};
|
|
71
71
|
Promise.resolve().then(function() {
|
|
72
|
-
return
|
|
72
|
+
return Se();
|
|
73
73
|
}).catch(function(t) {
|
|
74
|
-
|
|
74
|
+
Pe || console.warn(t);
|
|
75
75
|
});
|
|
76
|
-
var
|
|
76
|
+
var Te = function() {
|
|
77
77
|
for (var e = arguments.length, r = new Array(e), a = 0; a < e; a++)
|
|
78
78
|
r[a] = arguments[a];
|
|
79
|
-
|
|
79
|
+
Pe = !0;
|
|
80
80
|
var n = Date.now();
|
|
81
|
-
return
|
|
82
|
-
return
|
|
81
|
+
return Se().then(function(i) {
|
|
82
|
+
return Ye(i, r, n);
|
|
83
83
|
});
|
|
84
|
-
},
|
|
85
|
-
class
|
|
84
|
+
}, $e = /* @__PURE__ */ ((t) => (t[t.DEBUG = 0] = "DEBUG", t[t.INFO = 1] = "INFO", t[t.WARN = 2] = "WARN", t[t.ERROR = 3] = "ERROR", t[t.SILENT = 4] = "SILENT", t))($e || {});
|
|
85
|
+
class xe {
|
|
86
86
|
config;
|
|
87
87
|
constructor(e) {
|
|
88
88
|
this.config = e;
|
|
@@ -135,24 +135,24 @@ class Ee {
|
|
|
135
135
|
r(`[${i}] ${n}[${e}]`, ...a);
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
|
-
const
|
|
139
|
-
let
|
|
138
|
+
const Xe = () => typeof process < "u" && process.env.NODE_ENV === "development" ? 0 : 2;
|
|
139
|
+
let Y = null;
|
|
140
140
|
function l() {
|
|
141
|
-
return
|
|
142
|
-
level:
|
|
141
|
+
return Y || (Y = new xe({
|
|
142
|
+
level: Xe(),
|
|
143
143
|
prefix: "[CedrosPay]"
|
|
144
|
-
})),
|
|
144
|
+
})), Y;
|
|
145
145
|
}
|
|
146
|
-
function
|
|
147
|
-
|
|
146
|
+
function Ze(t) {
|
|
147
|
+
Y = t;
|
|
148
148
|
}
|
|
149
|
-
function
|
|
150
|
-
return new
|
|
149
|
+
function et(t) {
|
|
150
|
+
return new xe(t);
|
|
151
151
|
}
|
|
152
|
-
function
|
|
152
|
+
function O(t, e) {
|
|
153
153
|
return t instanceof Error ? t.message : typeof t == "string" ? t : e;
|
|
154
154
|
}
|
|
155
|
-
const
|
|
155
|
+
const tt = {
|
|
156
156
|
service_unavailable: "Service temporarily unavailable. Please try again later or contact support.",
|
|
157
157
|
server_insufficient_funds: "Service temporarily unavailable. Please try again later or contact support.",
|
|
158
158
|
insufficient_funds_token: "Insufficient token balance in your wallet. Please add more tokens and try again.",
|
|
@@ -162,14 +162,14 @@ const Ze = {
|
|
|
162
162
|
send_failed: "Failed to send transaction. Please try again or contact support.",
|
|
163
163
|
timeout: "Transaction timed out. Please check the blockchain explorer or try again."
|
|
164
164
|
};
|
|
165
|
-
async function
|
|
165
|
+
async function w(t, e, r = !1) {
|
|
166
166
|
const a = typeof t.clone == "function", n = a ? t.clone() : void 0;
|
|
167
167
|
try {
|
|
168
168
|
const i = await t.json();
|
|
169
169
|
if (r && i.verificationError) {
|
|
170
170
|
l().debug(`Payment verification failed: ${i.verificationError.code}`);
|
|
171
171
|
const o = i.verificationError.code;
|
|
172
|
-
return
|
|
172
|
+
return tt[o] || i.verificationError.message || e;
|
|
173
173
|
}
|
|
174
174
|
return typeof i.error == "string" ? i.error : i.error && typeof i.error == "object" && "message" in i.error ? i.error.message : e;
|
|
175
175
|
} catch {
|
|
@@ -188,8 +188,8 @@ async function g(t, e, r = !1) {
|
|
|
188
188
|
return e;
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
|
-
const
|
|
192
|
-
async function p(t, e = {}, r =
|
|
191
|
+
const rt = 15e3;
|
|
192
|
+
async function p(t, e = {}, r = rt) {
|
|
193
193
|
const a = new AbortController(), n = e.signal;
|
|
194
194
|
if (n?.aborted)
|
|
195
195
|
throw a.abort(), new DOMException("The operation was aborted", "AbortError");
|
|
@@ -207,15 +207,15 @@ async function p(t, e = {}, r = $e) {
|
|
|
207
207
|
clearTimeout(i), n && o && n.removeEventListener("abort", o);
|
|
208
208
|
}
|
|
209
209
|
}
|
|
210
|
-
function
|
|
210
|
+
function I(t) {
|
|
211
211
|
const { maxRequests: e, windowMs: r } = t;
|
|
212
212
|
let a = e, n = Date.now();
|
|
213
213
|
const i = e / r;
|
|
214
214
|
function o() {
|
|
215
|
-
const
|
|
215
|
+
const h = Date.now(), y = h - n;
|
|
216
216
|
if (y > 0) {
|
|
217
|
-
const
|
|
218
|
-
a = Math.min(e, a +
|
|
217
|
+
const d = y * i;
|
|
218
|
+
a = Math.min(e, a + d), n = h;
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
221
|
function s() {
|
|
@@ -224,23 +224,23 @@ function R(t) {
|
|
|
224
224
|
function c() {
|
|
225
225
|
return o(), Math.floor(a);
|
|
226
226
|
}
|
|
227
|
-
function
|
|
227
|
+
function u() {
|
|
228
228
|
if (o(), a >= 1)
|
|
229
229
|
return 0;
|
|
230
230
|
const y = (1 - a) / i;
|
|
231
231
|
return Math.ceil(y);
|
|
232
232
|
}
|
|
233
|
-
function
|
|
233
|
+
function f() {
|
|
234
234
|
a = e, n = Date.now();
|
|
235
235
|
}
|
|
236
236
|
return {
|
|
237
237
|
tryConsume: s,
|
|
238
238
|
getAvailableTokens: c,
|
|
239
|
-
getTimeUntilRefill:
|
|
240
|
-
reset:
|
|
239
|
+
getTimeUntilRefill: u,
|
|
240
|
+
reset: f
|
|
241
241
|
};
|
|
242
242
|
}
|
|
243
|
-
const
|
|
243
|
+
const B = {
|
|
244
244
|
/** 10 requests per minute - recommended for payment requests */
|
|
245
245
|
PAYMENT: { maxRequests: 10, windowMs: 6e4 },
|
|
246
246
|
/** 30 requests per minute - for quote fetching */
|
|
@@ -250,88 +250,88 @@ const M = {
|
|
|
250
250
|
/** 100 requests per minute - permissive for UI interactions */
|
|
251
251
|
PERMISSIVE: { maxRequests: 100, windowMs: 6e4 }
|
|
252
252
|
};
|
|
253
|
-
var
|
|
254
|
-
class
|
|
253
|
+
var at = /* @__PURE__ */ ((t) => (t.CLOSED = "CLOSED", t.OPEN = "OPEN", t.HALF_OPEN = "HALF_OPEN", t))(at || {});
|
|
254
|
+
class g extends Error {
|
|
255
255
|
constructor(e) {
|
|
256
256
|
super(e), this.name = "CircuitBreakerOpenError";
|
|
257
257
|
}
|
|
258
258
|
}
|
|
259
|
-
function
|
|
259
|
+
function Q(t) {
|
|
260
260
|
const { failureThreshold: e, timeout: r, failureWindow: a = r * 2, name: n = "circuit-breaker" } = t;
|
|
261
|
-
let i = "CLOSED", o = [], s = 0, c = 0,
|
|
262
|
-
function
|
|
263
|
-
const
|
|
264
|
-
o = o.filter((
|
|
261
|
+
let i = "CLOSED", o = [], s = 0, c = 0, u = null, f = null, h = null, y = !1;
|
|
262
|
+
function d() {
|
|
263
|
+
const R = Date.now() - a;
|
|
264
|
+
o = o.filter((C) => C > R);
|
|
265
265
|
}
|
|
266
|
-
function
|
|
267
|
-
i === "OPEN" &&
|
|
266
|
+
function m() {
|
|
267
|
+
i === "OPEN" && h !== null && Date.now() >= h && (l().debug(`[CircuitBreaker:${n}] Transitioning OPEN → HALF_OPEN (timeout expired)`), i = "HALF_OPEN", h = null);
|
|
268
268
|
}
|
|
269
|
-
function
|
|
270
|
-
|
|
269
|
+
function A() {
|
|
270
|
+
f = Date.now(), s++, i === "HALF_OPEN" ? (l().debug(`[CircuitBreaker:${n}] Success in HALF_OPEN → CLOSED`), i = "CLOSED", o = []) : i === "CLOSED" && (o = []);
|
|
271
271
|
}
|
|
272
|
-
function
|
|
273
|
-
const
|
|
274
|
-
|
|
275
|
-
const
|
|
276
|
-
l().warn(`[CircuitBreaker:${n}] Failure recorded (${
|
|
272
|
+
function b(R) {
|
|
273
|
+
const C = Date.now();
|
|
274
|
+
u = C, o.push(C), d();
|
|
275
|
+
const Z = o.length;
|
|
276
|
+
l().warn(`[CircuitBreaker:${n}] Failure recorded (${Z}/${e}):`, R.message), i === "HALF_OPEN" ? (l().warn(`[CircuitBreaker:${n}] Failed in HALF_OPEN → OPEN`), i = "OPEN", h = C + r) : i === "CLOSED" && Z >= e && (l().error(`[CircuitBreaker:${n}] Failure threshold reached (${Z}) → OPEN`), i = "OPEN", h = C + r);
|
|
277
277
|
}
|
|
278
|
-
async function x(
|
|
279
|
-
if (
|
|
278
|
+
async function x(R) {
|
|
279
|
+
if (m(), i === "OPEN") {
|
|
280
280
|
c++;
|
|
281
|
-
const
|
|
282
|
-
throw new
|
|
283
|
-
`Circuit breaker is OPEN. Service is unavailable. Retry in ${
|
|
281
|
+
const C = h ? Math.ceil((h - Date.now()) / 1e3) : 0;
|
|
282
|
+
throw new g(
|
|
283
|
+
`Circuit breaker is OPEN. Service is unavailable. Retry in ${C}s.`
|
|
284
284
|
);
|
|
285
285
|
}
|
|
286
286
|
if (i === "HALF_OPEN" && y)
|
|
287
|
-
throw c++, new
|
|
287
|
+
throw c++, new g(
|
|
288
288
|
"Circuit breaker is HALF_OPEN. A probe request is already in progress."
|
|
289
289
|
);
|
|
290
290
|
i === "HALF_OPEN" && (y = !0);
|
|
291
291
|
try {
|
|
292
|
-
const
|
|
293
|
-
return
|
|
294
|
-
} catch (
|
|
295
|
-
throw C
|
|
292
|
+
const C = await R();
|
|
293
|
+
return A(), C;
|
|
294
|
+
} catch (C) {
|
|
295
|
+
throw b(C instanceof Error ? C : new Error(String(C))), C;
|
|
296
296
|
} finally {
|
|
297
297
|
y && (y = !1);
|
|
298
298
|
}
|
|
299
299
|
}
|
|
300
|
-
function
|
|
301
|
-
return
|
|
300
|
+
function D() {
|
|
301
|
+
return m(), i;
|
|
302
302
|
}
|
|
303
|
-
function
|
|
304
|
-
return
|
|
303
|
+
function M() {
|
|
304
|
+
return m(), d(), {
|
|
305
305
|
state: i,
|
|
306
306
|
failures: o.length,
|
|
307
307
|
successes: s,
|
|
308
308
|
rejections: c,
|
|
309
|
-
lastFailureTime:
|
|
310
|
-
lastSuccessTime:
|
|
309
|
+
lastFailureTime: u,
|
|
310
|
+
lastSuccessTime: f
|
|
311
311
|
};
|
|
312
312
|
}
|
|
313
|
-
function
|
|
314
|
-
l().debug(`[CircuitBreaker:${n}] Manual reset → CLOSED`), i = "CLOSED", o = [], s = 0, c = 0,
|
|
313
|
+
function S() {
|
|
314
|
+
l().debug(`[CircuitBreaker:${n}] Manual reset → CLOSED`), i = "CLOSED", o = [], s = 0, c = 0, u = null, f = null, h = null;
|
|
315
315
|
}
|
|
316
|
-
function
|
|
317
|
-
l().warn(`[CircuitBreaker:${n}] Manual trip → OPEN`), i = "OPEN",
|
|
316
|
+
function _() {
|
|
317
|
+
l().warn(`[CircuitBreaker:${n}] Manual trip → OPEN`), i = "OPEN", h = Date.now() + r;
|
|
318
318
|
}
|
|
319
319
|
return {
|
|
320
320
|
execute: x,
|
|
321
|
-
getState:
|
|
322
|
-
getStats:
|
|
323
|
-
reset:
|
|
324
|
-
trip:
|
|
321
|
+
getState: D,
|
|
322
|
+
getStats: M,
|
|
323
|
+
reset: S,
|
|
324
|
+
trip: _
|
|
325
325
|
};
|
|
326
326
|
}
|
|
327
|
-
const
|
|
327
|
+
const Yt = {
|
|
328
328
|
/** Strict: Opens quickly (3 failures), long timeout (60s) */
|
|
329
329
|
STRICT: { failureThreshold: 3, timeout: 6e4 },
|
|
330
330
|
/** Standard: Balanced settings (5 failures, 30s timeout) */
|
|
331
331
|
STANDARD: { failureThreshold: 5, timeout: 3e4 },
|
|
332
332
|
/** Lenient: Tolerates more failures (10 failures, 15s timeout) */
|
|
333
333
|
LENIENT: { failureThreshold: 10, timeout: 15e3 }
|
|
334
|
-
},
|
|
334
|
+
}, nt = {
|
|
335
335
|
// ===== PAYMENT VERIFICATION ERRORS (402) =====
|
|
336
336
|
invalid_payment_proof: {
|
|
337
337
|
message: "Payment verification failed",
|
|
@@ -584,14 +584,14 @@ const Qt = {
|
|
|
584
584
|
technicalHint: "Server misconfiguration"
|
|
585
585
|
}
|
|
586
586
|
};
|
|
587
|
-
function
|
|
588
|
-
return
|
|
587
|
+
function it(t) {
|
|
588
|
+
return nt[t] || {
|
|
589
589
|
message: "An unexpected error occurred",
|
|
590
590
|
action: "Please try again or contact support if this continues.",
|
|
591
591
|
technicalHint: `Unknown error code: ${t}`
|
|
592
592
|
};
|
|
593
593
|
}
|
|
594
|
-
class
|
|
594
|
+
class N extends Error {
|
|
595
595
|
/** Machine-readable error code enum */
|
|
596
596
|
code;
|
|
597
597
|
/** Whether this error can be safely retried */
|
|
@@ -601,7 +601,7 @@ class O extends Error {
|
|
|
601
601
|
/** HTTP status code (if from API response) */
|
|
602
602
|
httpStatus;
|
|
603
603
|
constructor(e, r, a = !1, n, i) {
|
|
604
|
-
super(r), this.name = "PaymentError", this.code = e, this.retryable = a, this.details = n, this.httpStatus = i, Object.setPrototypeOf(this,
|
|
604
|
+
super(r), this.name = "PaymentError", this.code = e, this.retryable = a, this.details = n, this.httpStatus = i, Object.setPrototypeOf(this, N.prototype);
|
|
605
605
|
}
|
|
606
606
|
/**
|
|
607
607
|
* Check if this error is retryable
|
|
@@ -646,7 +646,7 @@ class O extends Error {
|
|
|
646
646
|
* @private
|
|
647
647
|
*/
|
|
648
648
|
getErrorInfo() {
|
|
649
|
-
return
|
|
649
|
+
return it(this.code);
|
|
650
650
|
}
|
|
651
651
|
/**
|
|
652
652
|
* Create PaymentError from API error response
|
|
@@ -655,8 +655,8 @@ class O extends Error {
|
|
|
655
655
|
* from error codes using ERROR_CATEGORIES.RETRYABLE.
|
|
656
656
|
*/
|
|
657
657
|
static fromErrorResponse(e, r) {
|
|
658
|
-
const a = e.error.retryable ??
|
|
659
|
-
return new
|
|
658
|
+
const a = e.error.retryable ?? ot.RETRYABLE.includes(e.error.code);
|
|
659
|
+
return new N(
|
|
660
660
|
e.error.code,
|
|
661
661
|
e.error.message,
|
|
662
662
|
a,
|
|
@@ -669,18 +669,18 @@ class O extends Error {
|
|
|
669
669
|
* Useful for catch blocks where error type is unknown
|
|
670
670
|
*/
|
|
671
671
|
static fromUnknown(e) {
|
|
672
|
-
return e instanceof
|
|
672
|
+
return e instanceof N ? e : e instanceof Error ? new N(
|
|
673
673
|
"internal_error",
|
|
674
674
|
e.message,
|
|
675
675
|
!1
|
|
676
|
-
) : new
|
|
676
|
+
) : new N(
|
|
677
677
|
"internal_error",
|
|
678
678
|
String(e),
|
|
679
679
|
!1
|
|
680
680
|
);
|
|
681
681
|
}
|
|
682
682
|
}
|
|
683
|
-
const
|
|
683
|
+
const ot = {
|
|
684
684
|
/** Insufficient funds errors requiring user to add funds */
|
|
685
685
|
INSUFFICIENT_FUNDS: [
|
|
686
686
|
"insufficient_funds_sol",
|
|
@@ -747,54 +747,105 @@ const at = {
|
|
|
747
747
|
"nonce_already_used"
|
|
748
748
|
/* NONCE_ALREADY_USED */
|
|
749
749
|
]
|
|
750
|
-
};
|
|
751
|
-
function
|
|
752
|
-
if (t
|
|
753
|
-
|
|
754
|
-
|
|
750
|
+
}, fe = 300 * 1e3, G = /* @__PURE__ */ new Map();
|
|
751
|
+
function st(t) {
|
|
752
|
+
if (!t)
|
|
753
|
+
return;
|
|
754
|
+
const e = Number(t);
|
|
755
|
+
if (Number.isFinite(e) && e >= 0)
|
|
756
|
+
return Math.min(e * 1e3, fe);
|
|
757
|
+
const r = Date.parse(t);
|
|
758
|
+
if (!Number.isNaN(r))
|
|
759
|
+
return Math.min(Math.max(r - Date.now(), 0), fe);
|
|
760
|
+
}
|
|
761
|
+
class T extends Error {
|
|
762
|
+
httpStatus;
|
|
763
|
+
retryAfterMs;
|
|
764
|
+
constructor(e, r, a) {
|
|
765
|
+
super(e), this.name = "RetryableHttpError", this.httpStatus = r, this.retryAfterMs = a, Object.setPrototypeOf(this, T.prototype);
|
|
766
|
+
}
|
|
767
|
+
static fromResponse(e, r) {
|
|
768
|
+
const a = e.headers && typeof e.headers.get == "function" ? e.headers.get("Retry-After") : null;
|
|
769
|
+
return new T(
|
|
770
|
+
r,
|
|
771
|
+
e.status,
|
|
772
|
+
st(a)
|
|
773
|
+
);
|
|
755
774
|
}
|
|
756
|
-
const r = t.message.toLowerCase();
|
|
757
|
-
return !!(r.includes("network") || r.includes("timeout") || r.includes("fetch failed") || r.includes("econnrefused"));
|
|
758
775
|
}
|
|
759
|
-
function
|
|
776
|
+
function ct(t) {
|
|
777
|
+
if (t instanceof N || t instanceof T)
|
|
778
|
+
return t.httpStatus;
|
|
779
|
+
}
|
|
780
|
+
function lt(t) {
|
|
781
|
+
if (t instanceof T)
|
|
782
|
+
return t.retryAfterMs;
|
|
783
|
+
}
|
|
784
|
+
function ut(t, e) {
|
|
785
|
+
const r = ct(t);
|
|
786
|
+
if (r != null) {
|
|
787
|
+
const n = r;
|
|
788
|
+
return n === 429 || n >= 500 && n < 600;
|
|
789
|
+
}
|
|
790
|
+
const a = t.message.toLowerCase();
|
|
791
|
+
return !!(a.includes("network") || a.includes("timeout") || a.includes("fetch failed") || a.includes("econnrefused"));
|
|
792
|
+
}
|
|
793
|
+
function dt(t, e, r, a, n) {
|
|
760
794
|
const i = e * Math.pow(r, t), o = Math.min(i, a);
|
|
761
795
|
return Math.floor(n ? o * 0.5 + Math.random() * o * 0.5 : o);
|
|
762
796
|
}
|
|
763
|
-
function
|
|
797
|
+
function ft(t) {
|
|
764
798
|
return new Promise((e) => setTimeout(e, t));
|
|
765
799
|
}
|
|
766
|
-
async function
|
|
800
|
+
async function E(t, e = {}) {
|
|
767
801
|
const {
|
|
768
802
|
maxRetries: r = 3,
|
|
769
803
|
initialDelayMs: a = 1e3,
|
|
770
804
|
backoffFactor: n = 2,
|
|
771
805
|
maxDelayMs: i = 3e4,
|
|
772
806
|
jitter: o = !0,
|
|
773
|
-
shouldRetry: s =
|
|
774
|
-
name: c = "retry"
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
807
|
+
shouldRetry: s = ut,
|
|
808
|
+
name: c = "retry",
|
|
809
|
+
inFlightKey: u
|
|
810
|
+
} = e, f = async () => {
|
|
811
|
+
let d = null, m = 0;
|
|
812
|
+
for (let A = 0; A <= r; A++)
|
|
813
|
+
try {
|
|
814
|
+
const b = await t();
|
|
815
|
+
return A > 0 && l().debug(
|
|
816
|
+
`[Retry:${c}] Succeeded on attempt ${A + 1}/${r + 1} after ${m}ms`
|
|
817
|
+
), b;
|
|
818
|
+
} catch (b) {
|
|
819
|
+
d = b instanceof Error ? b : new Error(String(b));
|
|
820
|
+
const x = A === r, D = s(d, A);
|
|
821
|
+
if (x || !D)
|
|
822
|
+
throw l().warn(
|
|
823
|
+
`[Retry:${c}] Failed on attempt ${A + 1}/${r + 1}. ${x ? "No more retries." : "Error not retryable."}`
|
|
824
|
+
), d;
|
|
825
|
+
const S = lt(d) ?? dt(
|
|
826
|
+
A,
|
|
827
|
+
a,
|
|
828
|
+
n,
|
|
829
|
+
i,
|
|
830
|
+
o
|
|
831
|
+
);
|
|
832
|
+
m += S, l().warn(
|
|
833
|
+
`[Retry:${c}] Attempt ${A + 1}/${r + 1} failed: ${d.message}. Retrying in ${S}ms...`
|
|
834
|
+
), await ft(S);
|
|
835
|
+
}
|
|
836
|
+
throw d || new Error("Retry failed with no error");
|
|
837
|
+
};
|
|
838
|
+
if (!u)
|
|
839
|
+
return f();
|
|
840
|
+
const h = G.get(u);
|
|
841
|
+
if (h)
|
|
842
|
+
return h;
|
|
843
|
+
const y = f().finally(() => {
|
|
844
|
+
G.get(u) === y && G.delete(u);
|
|
845
|
+
});
|
|
846
|
+
return G.set(u, y), y;
|
|
796
847
|
}
|
|
797
|
-
const
|
|
848
|
+
const v = {
|
|
798
849
|
/** Quick retries for transient errors (3 retries, 1s initial, 2x backoff) */
|
|
799
850
|
QUICK: {
|
|
800
851
|
maxRetries: 3,
|
|
@@ -822,22 +873,37 @@ const E = {
|
|
|
822
873
|
initialDelayMs: 5e3,
|
|
823
874
|
backoffFactor: 2,
|
|
824
875
|
maxDelayMs: 6e4
|
|
876
|
+
},
|
|
877
|
+
/** At most one retry for writes with a real idempotency guarantee */
|
|
878
|
+
IDEMPOTENT_WRITE: {
|
|
879
|
+
maxRetries: 1,
|
|
880
|
+
initialDelayMs: 1e3,
|
|
881
|
+
backoffFactor: 2,
|
|
882
|
+
maxDelayMs: 1e4
|
|
883
|
+
},
|
|
884
|
+
/** Never automatically retry non-idempotent writes */
|
|
885
|
+
WRITE_ONCE: {
|
|
886
|
+
maxRetries: 0,
|
|
887
|
+
initialDelayMs: 1e3,
|
|
888
|
+
backoffFactor: 2,
|
|
889
|
+
maxDelayMs: 1e4
|
|
825
890
|
}
|
|
826
891
|
};
|
|
827
|
-
class
|
|
892
|
+
class ht {
|
|
828
893
|
stripe = null;
|
|
829
894
|
initPromise = null;
|
|
830
895
|
publicKey;
|
|
831
896
|
routeDiscovery;
|
|
832
|
-
|
|
833
|
-
|
|
897
|
+
complianceCheckEnabled;
|
|
898
|
+
rateLimiter = I(B.PAYMENT);
|
|
899
|
+
circuitBreaker = Q({
|
|
834
900
|
failureThreshold: 5,
|
|
835
901
|
timeout: 1e4,
|
|
836
902
|
// 10 seconds for faster recovery in payment flows
|
|
837
903
|
name: "stripe-manager"
|
|
838
904
|
});
|
|
839
|
-
constructor(e, r) {
|
|
840
|
-
this.publicKey = e, this.routeDiscovery = r;
|
|
905
|
+
constructor(e, r, a = !1) {
|
|
906
|
+
this.publicKey = e, this.routeDiscovery = r, this.complianceCheckEnabled = a;
|
|
841
907
|
}
|
|
842
908
|
/**
|
|
843
909
|
* Initialize Stripe.js library
|
|
@@ -847,7 +913,7 @@ class st {
|
|
|
847
913
|
async initialize() {
|
|
848
914
|
this.stripe || (this.initPromise || (this.initPromise = (async () => {
|
|
849
915
|
try {
|
|
850
|
-
if (this.stripe = await
|
|
916
|
+
if (this.stripe = await Te(this.publicKey), !this.stripe) throw new Error("Failed to initialize Stripe");
|
|
851
917
|
} catch (e) {
|
|
852
918
|
throw this.initPromise = null, e;
|
|
853
919
|
}
|
|
@@ -859,35 +925,39 @@ class st {
|
|
|
859
925
|
async createSession(e) {
|
|
860
926
|
if (!this.rateLimiter.tryConsume())
|
|
861
927
|
throw new Error("Rate limit exceeded for Stripe session creation. Please try again later.");
|
|
862
|
-
const r =
|
|
928
|
+
const r = k(), a = JSON.stringify(e);
|
|
863
929
|
try {
|
|
864
|
-
return await this.circuitBreaker.execute(async () => await
|
|
930
|
+
return await this.circuitBreaker.execute(async () => await E(
|
|
865
931
|
async () => {
|
|
866
|
-
const
|
|
932
|
+
const n = await this.routeDiscovery.buildUrl("/paywall/v1/stripe-session");
|
|
867
933
|
l().debug("[StripeManager] Creating session", {
|
|
868
934
|
resource: e.resource,
|
|
869
935
|
hasCouponCode: !!e.couponCode,
|
|
870
936
|
hasMetadata: !!(e.metadata && Object.keys(e.metadata).length),
|
|
871
937
|
metadataKeyCount: e.metadata ? Object.keys(e.metadata).length : 0
|
|
872
938
|
});
|
|
873
|
-
const
|
|
939
|
+
const i = await p(n, {
|
|
874
940
|
method: "POST",
|
|
875
941
|
headers: {
|
|
876
942
|
"Content-Type": "application/json",
|
|
877
943
|
"Idempotency-Key": r
|
|
878
944
|
},
|
|
879
|
-
body:
|
|
945
|
+
body: a
|
|
880
946
|
});
|
|
881
|
-
if (!
|
|
882
|
-
const
|
|
883
|
-
throw
|
|
947
|
+
if (!i.ok) {
|
|
948
|
+
const o = await w(i, "Failed to create Stripe session");
|
|
949
|
+
throw T.fromResponse(i, o);
|
|
884
950
|
}
|
|
885
|
-
return await
|
|
951
|
+
return await i.json();
|
|
886
952
|
},
|
|
887
|
-
{
|
|
953
|
+
{
|
|
954
|
+
...v.IDEMPOTENT_WRITE,
|
|
955
|
+
name: "stripe-create-session",
|
|
956
|
+
inFlightKey: `stripe:create-session:${a}`
|
|
957
|
+
}
|
|
888
958
|
));
|
|
889
|
-
} catch (
|
|
890
|
-
throw
|
|
959
|
+
} catch (n) {
|
|
960
|
+
throw n instanceof g ? (l().error("[StripeManager] Circuit breaker is OPEN - Stripe service unavailable"), new Error("Stripe payment service is temporarily unavailable. Please try again in a few moments.")) : n;
|
|
891
961
|
}
|
|
892
962
|
}
|
|
893
963
|
/**
|
|
@@ -905,17 +975,40 @@ class st {
|
|
|
905
975
|
error: r.error.message
|
|
906
976
|
} : { success: !0 };
|
|
907
977
|
}
|
|
978
|
+
/**
|
|
979
|
+
* Run a pre-flight compliance check for the given resources.
|
|
980
|
+
* Returns null if cleared, or a PaymentResult with the block reasons.
|
|
981
|
+
*/
|
|
982
|
+
async runComplianceCheck(e) {
|
|
983
|
+
if (!this.complianceCheckEnabled) return null;
|
|
984
|
+
try {
|
|
985
|
+
const r = await this.routeDiscovery.buildUrl("/paywall/v1/compliance-check"), a = await p(r, {
|
|
986
|
+
method: "POST",
|
|
987
|
+
headers: { "Content-Type": "application/json" },
|
|
988
|
+
body: JSON.stringify({ resources: e })
|
|
989
|
+
});
|
|
990
|
+
if (!a.ok) return null;
|
|
991
|
+
const n = await a.json();
|
|
992
|
+
if (!n.cleared)
|
|
993
|
+
return { success: !1, error: `Purchase blocked: ${(n.reasons ?? ["Purchase blocked by compliance check"]).join("; ")}` };
|
|
994
|
+
} catch {
|
|
995
|
+
l().warn("[StripeManager] Compliance pre-check failed, proceeding");
|
|
996
|
+
}
|
|
997
|
+
return null;
|
|
998
|
+
}
|
|
908
999
|
/**
|
|
909
1000
|
* Handle complete payment flow: create session and redirect
|
|
910
1001
|
*/
|
|
911
1002
|
async processPayment(e) {
|
|
912
1003
|
try {
|
|
913
|
-
const r = await this.
|
|
914
|
-
|
|
1004
|
+
const r = await this.runComplianceCheck([e.resource]);
|
|
1005
|
+
if (r) return r;
|
|
1006
|
+
const a = await this.createSession(e);
|
|
1007
|
+
return await this.redirectToCheckout(a.sessionId);
|
|
915
1008
|
} catch (r) {
|
|
916
1009
|
return {
|
|
917
1010
|
success: !1,
|
|
918
|
-
error:
|
|
1011
|
+
error: O(r, "Unknown error")
|
|
919
1012
|
};
|
|
920
1013
|
}
|
|
921
1014
|
}
|
|
@@ -931,171 +1024,174 @@ class st {
|
|
|
931
1024
|
customerEmail: o,
|
|
932
1025
|
customerName: s,
|
|
933
1026
|
customerPhone: c,
|
|
934
|
-
shippingAddress:
|
|
935
|
-
billingAddress:
|
|
936
|
-
couponCode:
|
|
1027
|
+
shippingAddress: u,
|
|
1028
|
+
billingAddress: f,
|
|
1029
|
+
couponCode: h,
|
|
937
1030
|
tipAmount: y,
|
|
938
|
-
shippingMethodId:
|
|
939
|
-
paymentMethodId:
|
|
940
|
-
} = e;
|
|
1031
|
+
shippingMethodId: d,
|
|
1032
|
+
paymentMethodId: m
|
|
1033
|
+
} = e, A = r.map((S) => S.resource), b = await this.runComplianceCheck(A);
|
|
1034
|
+
if (b) return b;
|
|
941
1035
|
if (!this.rateLimiter.tryConsume())
|
|
942
1036
|
return {
|
|
943
1037
|
success: !1,
|
|
944
1038
|
error: "Rate limit exceeded for cart checkout. Please try again later."
|
|
945
1039
|
};
|
|
946
|
-
const
|
|
1040
|
+
const x = k(), M = JSON.stringify({
|
|
1041
|
+
items: r,
|
|
1042
|
+
successUrl: a,
|
|
1043
|
+
cancelUrl: n,
|
|
1044
|
+
metadata: i,
|
|
1045
|
+
customerEmail: o,
|
|
1046
|
+
customerName: s,
|
|
1047
|
+
customerPhone: c,
|
|
1048
|
+
shippingAddress: u,
|
|
1049
|
+
billingAddress: f,
|
|
1050
|
+
coupon: h,
|
|
1051
|
+
couponCode: h,
|
|
1052
|
+
tipAmount: y,
|
|
1053
|
+
shippingMethodId: d,
|
|
1054
|
+
paymentMethodId: m
|
|
1055
|
+
});
|
|
947
1056
|
try {
|
|
948
|
-
const
|
|
1057
|
+
const S = await this.circuitBreaker.execute(async () => await E(
|
|
949
1058
|
async () => {
|
|
950
|
-
const
|
|
1059
|
+
const _ = await this.routeDiscovery.buildUrl("/paywall/v1/cart/checkout"), R = await p(_, {
|
|
951
1060
|
method: "POST",
|
|
952
1061
|
headers: {
|
|
953
1062
|
"Content-Type": "application/json",
|
|
954
|
-
"Idempotency-Key":
|
|
1063
|
+
"Idempotency-Key": x
|
|
955
1064
|
},
|
|
956
|
-
body:
|
|
957
|
-
items: r,
|
|
958
|
-
successUrl: a,
|
|
959
|
-
cancelUrl: n,
|
|
960
|
-
metadata: i,
|
|
961
|
-
customerEmail: o,
|
|
962
|
-
customerName: s,
|
|
963
|
-
customerPhone: c,
|
|
964
|
-
shippingAddress: d,
|
|
965
|
-
billingAddress: m,
|
|
966
|
-
coupon: u,
|
|
967
|
-
// New Rust server field
|
|
968
|
-
couponCode: u,
|
|
969
|
-
// Legacy Go server field (backwards compat)
|
|
970
|
-
tipAmount: y,
|
|
971
|
-
shippingMethodId: f,
|
|
972
|
-
paymentMethodId: h
|
|
973
|
-
})
|
|
1065
|
+
body: M
|
|
974
1066
|
});
|
|
975
|
-
if (!
|
|
976
|
-
const
|
|
977
|
-
throw
|
|
1067
|
+
if (!R.ok) {
|
|
1068
|
+
const C = await w(R, "Failed to create cart checkout session");
|
|
1069
|
+
throw T.fromResponse(R, C);
|
|
978
1070
|
}
|
|
979
|
-
return await
|
|
1071
|
+
return await R.json();
|
|
980
1072
|
},
|
|
981
|
-
{
|
|
1073
|
+
{
|
|
1074
|
+
...v.IDEMPOTENT_WRITE,
|
|
1075
|
+
name: "stripe-cart-checkout",
|
|
1076
|
+
inFlightKey: `stripe:cart-checkout:${M}`
|
|
1077
|
+
}
|
|
982
1078
|
));
|
|
983
|
-
return await this.redirectToCheckout(
|
|
984
|
-
} catch (
|
|
985
|
-
return
|
|
1079
|
+
return await this.redirectToCheckout(S.sessionId);
|
|
1080
|
+
} catch (S) {
|
|
1081
|
+
return S instanceof g ? {
|
|
986
1082
|
success: !1,
|
|
987
1083
|
error: "Stripe payment service is temporarily unavailable. Please try again in a few moments."
|
|
988
1084
|
} : {
|
|
989
1085
|
success: !1,
|
|
990
|
-
error:
|
|
1086
|
+
error: O(S, "Cart checkout failed")
|
|
991
1087
|
};
|
|
992
1088
|
}
|
|
993
1089
|
}
|
|
994
1090
|
}
|
|
995
|
-
const
|
|
1091
|
+
const ke = "3.7.8", mt = ke, L = typeof Buffer == "function", he = typeof TextDecoder == "function" ? new TextDecoder() : void 0, me = typeof TextEncoder == "function" ? new TextEncoder() : void 0, yt = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", z = Array.prototype.slice.call(yt), V = ((t) => {
|
|
996
1092
|
let e = {};
|
|
997
1093
|
return t.forEach((r, a) => e[r] = a), e;
|
|
998
|
-
})(
|
|
1094
|
+
})(z), pt = /^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/, P = String.fromCharCode.bind(String), ye = typeof Uint8Array.from == "function" ? Uint8Array.from.bind(Uint8Array) : (t) => new Uint8Array(Array.prototype.slice.call(t, 0)), Re = (t) => t.replace(/=/g, "").replace(/[+\/]/g, (e) => e == "+" ? "-" : "_"), Me = (t) => t.replace(/[^A-Za-z0-9\+\/]/g, ""), De = (t) => {
|
|
999
1095
|
let e, r, a, n, i = "";
|
|
1000
1096
|
const o = t.length % 3;
|
|
1001
1097
|
for (let s = 0; s < t.length; ) {
|
|
1002
1098
|
if ((r = t.charCodeAt(s++)) > 255 || (a = t.charCodeAt(s++)) > 255 || (n = t.charCodeAt(s++)) > 255)
|
|
1003
1099
|
throw new TypeError("invalid character found");
|
|
1004
|
-
e = r << 16 | a << 8 | n, i +=
|
|
1100
|
+
e = r << 16 | a << 8 | n, i += z[e >> 18 & 63] + z[e >> 12 & 63] + z[e >> 6 & 63] + z[e & 63];
|
|
1005
1101
|
}
|
|
1006
1102
|
return o ? i.slice(0, o - 3) + "===".substring(o) : i;
|
|
1007
|
-
},
|
|
1103
|
+
}, ce = typeof btoa == "function" ? (t) => btoa(t) : L ? (t) => Buffer.from(t, "binary").toString("base64") : De, ne = L ? (t) => Buffer.from(t).toString("base64") : (t) => {
|
|
1008
1104
|
let r = [];
|
|
1009
1105
|
for (let a = 0, n = t.length; a < n; a += 4096)
|
|
1010
|
-
r.push(
|
|
1011
|
-
return
|
|
1012
|
-
},
|
|
1106
|
+
r.push(P.apply(null, t.subarray(a, a + 4096)));
|
|
1107
|
+
return ce(r.join(""));
|
|
1108
|
+
}, $ = (t, e = !1) => e ? Re(ne(t)) : ne(t), At = (t) => {
|
|
1013
1109
|
if (t.length < 2) {
|
|
1014
1110
|
var e = t.charCodeAt(0);
|
|
1015
|
-
return e < 128 ? t : e < 2048 ?
|
|
1111
|
+
return e < 128 ? t : e < 2048 ? P(192 | e >>> 6) + P(128 | e & 63) : P(224 | e >>> 12 & 15) + P(128 | e >>> 6 & 63) + P(128 | e & 63);
|
|
1016
1112
|
} else {
|
|
1017
1113
|
var e = 65536 + (t.charCodeAt(0) - 55296) * 1024 + (t.charCodeAt(1) - 56320);
|
|
1018
|
-
return
|
|
1114
|
+
return P(240 | e >>> 18 & 7) + P(128 | e >>> 12 & 63) + P(128 | e >>> 6 & 63) + P(128 | e & 63);
|
|
1019
1115
|
}
|
|
1020
|
-
},
|
|
1116
|
+
}, gt = /[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g, Oe = (t) => t.replace(gt, At), pe = L ? (t) => Buffer.from(t, "utf8").toString("base64") : me ? (t) => ne(me.encode(t)) : (t) => ce(Oe(t)), H = (t, e = !1) => e ? Re(pe(t)) : pe(t), Ae = (t) => H(t, !0), wt = /[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g, bt = (t) => {
|
|
1021
1117
|
switch (t.length) {
|
|
1022
1118
|
case 4:
|
|
1023
1119
|
var e = (7 & t.charCodeAt(0)) << 18 | (63 & t.charCodeAt(1)) << 12 | (63 & t.charCodeAt(2)) << 6 | 63 & t.charCodeAt(3), r = e - 65536;
|
|
1024
|
-
return
|
|
1120
|
+
return P((r >>> 10) + 55296) + P((r & 1023) + 56320);
|
|
1025
1121
|
case 3:
|
|
1026
|
-
return
|
|
1122
|
+
return P((15 & t.charCodeAt(0)) << 12 | (63 & t.charCodeAt(1)) << 6 | 63 & t.charCodeAt(2));
|
|
1027
1123
|
default:
|
|
1028
|
-
return
|
|
1124
|
+
return P((31 & t.charCodeAt(0)) << 6 | 63 & t.charCodeAt(1));
|
|
1029
1125
|
}
|
|
1030
|
-
},
|
|
1031
|
-
if (t = t.replace(/\s+/g, ""), !
|
|
1126
|
+
}, Ie = (t) => t.replace(wt, bt), Be = (t) => {
|
|
1127
|
+
if (t = t.replace(/\s+/g, ""), !pt.test(t))
|
|
1032
1128
|
throw new TypeError("malformed base64.");
|
|
1033
1129
|
t += "==".slice(2 - (t.length & 3));
|
|
1034
1130
|
let e, r, a, n = [];
|
|
1035
1131
|
for (let i = 0; i < t.length; )
|
|
1036
|
-
e =
|
|
1132
|
+
e = V[t.charAt(i++)] << 18 | V[t.charAt(i++)] << 12 | (r = V[t.charAt(i++)]) << 6 | (a = V[t.charAt(i++)]), r === 64 ? n.push(P(e >> 16 & 255)) : a === 64 ? n.push(P(e >> 16 & 255, e >> 8 & 255)) : n.push(P(e >> 16 & 255, e >> 8 & 255, e & 255));
|
|
1037
1133
|
return n.join("");
|
|
1038
|
-
},
|
|
1134
|
+
}, le = typeof atob == "function" ? (t) => atob(Me(t)) : L ? (t) => Buffer.from(t, "base64").toString("binary") : Be, _e = L ? (t) => ye(Buffer.from(t, "base64")) : (t) => ye(le(t).split("").map((e) => e.charCodeAt(0))), Ne = (t) => _e(Fe(t)), vt = L ? (t) => Buffer.from(t, "base64").toString("utf8") : he ? (t) => he.decode(_e(t)) : (t) => Ie(le(t)), Fe = (t) => Me(t.replace(/[-_]/g, (e) => e == "-" ? "+" : "/")), ie = (t) => vt(Fe(t)), Et = (t) => {
|
|
1039
1135
|
if (typeof t != "string")
|
|
1040
1136
|
return !1;
|
|
1041
1137
|
const e = t.replace(/\s+/g, "").replace(/={0,2}$/, "");
|
|
1042
1138
|
return !/[^\s0-9a-zA-Z\+/]/.test(e) || !/[^\s0-9a-zA-Z\-_]/.test(e);
|
|
1043
|
-
},
|
|
1139
|
+
}, Ue = (t) => ({
|
|
1044
1140
|
value: t,
|
|
1045
1141
|
enumerable: !1,
|
|
1046
1142
|
writable: !0,
|
|
1047
1143
|
configurable: !0
|
|
1048
|
-
}),
|
|
1049
|
-
const t = (e, r) => Object.defineProperty(String.prototype, e,
|
|
1144
|
+
}), He = function() {
|
|
1145
|
+
const t = (e, r) => Object.defineProperty(String.prototype, e, Ue(r));
|
|
1050
1146
|
t("fromBase64", function() {
|
|
1051
|
-
return
|
|
1147
|
+
return ie(this);
|
|
1052
1148
|
}), t("toBase64", function(e) {
|
|
1053
|
-
return
|
|
1149
|
+
return H(this, e);
|
|
1054
1150
|
}), t("toBase64URI", function() {
|
|
1055
|
-
return
|
|
1151
|
+
return H(this, !0);
|
|
1056
1152
|
}), t("toBase64URL", function() {
|
|
1057
|
-
return
|
|
1153
|
+
return H(this, !0);
|
|
1058
1154
|
}), t("toUint8Array", function() {
|
|
1059
|
-
return
|
|
1155
|
+
return Ne(this);
|
|
1060
1156
|
});
|
|
1061
|
-
},
|
|
1062
|
-
const t = (e, r) => Object.defineProperty(Uint8Array.prototype, e,
|
|
1157
|
+
}, Le = function() {
|
|
1158
|
+
const t = (e, r) => Object.defineProperty(Uint8Array.prototype, e, Ue(r));
|
|
1063
1159
|
t("toBase64", function(e) {
|
|
1064
|
-
return
|
|
1160
|
+
return $(this, e);
|
|
1065
1161
|
}), t("toBase64URI", function() {
|
|
1066
|
-
return
|
|
1162
|
+
return $(this, !0);
|
|
1067
1163
|
}), t("toBase64URL", function() {
|
|
1068
|
-
return
|
|
1164
|
+
return $(this, !0);
|
|
1069
1165
|
});
|
|
1070
|
-
},
|
|
1071
|
-
|
|
1072
|
-
},
|
|
1073
|
-
version:
|
|
1074
|
-
VERSION:
|
|
1075
|
-
atob:
|
|
1076
|
-
atobPolyfill:
|
|
1077
|
-
btoa:
|
|
1078
|
-
btoaPolyfill:
|
|
1079
|
-
fromBase64:
|
|
1080
|
-
toBase64:
|
|
1081
|
-
encode:
|
|
1082
|
-
encodeURI:
|
|
1083
|
-
encodeURL:
|
|
1084
|
-
utob:
|
|
1085
|
-
btou:
|
|
1086
|
-
decode:
|
|
1087
|
-
isValid:
|
|
1088
|
-
fromUint8Array:
|
|
1089
|
-
toUint8Array:
|
|
1090
|
-
extendString:
|
|
1091
|
-
extendUint8Array:
|
|
1092
|
-
extendBuiltins:
|
|
1166
|
+
}, Ct = () => {
|
|
1167
|
+
He(), Le();
|
|
1168
|
+
}, ge = {
|
|
1169
|
+
version: ke,
|
|
1170
|
+
VERSION: mt,
|
|
1171
|
+
atob: le,
|
|
1172
|
+
atobPolyfill: Be,
|
|
1173
|
+
btoa: ce,
|
|
1174
|
+
btoaPolyfill: De,
|
|
1175
|
+
fromBase64: ie,
|
|
1176
|
+
toBase64: H,
|
|
1177
|
+
encode: H,
|
|
1178
|
+
encodeURI: Ae,
|
|
1179
|
+
encodeURL: Ae,
|
|
1180
|
+
utob: Oe,
|
|
1181
|
+
btou: Ie,
|
|
1182
|
+
decode: ie,
|
|
1183
|
+
isValid: Et,
|
|
1184
|
+
fromUint8Array: $,
|
|
1185
|
+
toUint8Array: Ne,
|
|
1186
|
+
extendString: He,
|
|
1187
|
+
extendUint8Array: Le,
|
|
1188
|
+
extendBuiltins: Ct
|
|
1093
1189
|
};
|
|
1094
|
-
class
|
|
1190
|
+
class Pt {
|
|
1095
1191
|
routeDiscovery;
|
|
1096
|
-
quoteRateLimiter =
|
|
1097
|
-
verifyRateLimiter =
|
|
1098
|
-
circuitBreaker =
|
|
1192
|
+
quoteRateLimiter = I(B.QUOTE);
|
|
1193
|
+
verifyRateLimiter = I(B.PAYMENT);
|
|
1194
|
+
circuitBreaker = Q({
|
|
1099
1195
|
failureThreshold: 5,
|
|
1100
1196
|
timeout: 1e4,
|
|
1101
1197
|
// 10 seconds for faster recovery in payment flows
|
|
@@ -1114,7 +1210,7 @@ class gt {
|
|
|
1114
1210
|
if (!this.quoteRateLimiter.tryConsume())
|
|
1115
1211
|
throw new Error("Rate limit exceeded for quote requests. Please try again later.");
|
|
1116
1212
|
try {
|
|
1117
|
-
return await this.circuitBreaker.execute(async () => await
|
|
1213
|
+
return await this.circuitBreaker.execute(async () => await E(
|
|
1118
1214
|
async () => {
|
|
1119
1215
|
const n = "/paywall/v1/quote";
|
|
1120
1216
|
l().debug(
|
|
@@ -1147,10 +1243,10 @@ class gt {
|
|
|
1147
1243
|
} else
|
|
1148
1244
|
throw new Error("Invalid x402 response: missing crypto or accepts field");
|
|
1149
1245
|
},
|
|
1150
|
-
{ ...
|
|
1246
|
+
{ ...v.QUICK, name: "x402-quote" }
|
|
1151
1247
|
));
|
|
1152
1248
|
} catch (n) {
|
|
1153
|
-
throw n instanceof
|
|
1249
|
+
throw n instanceof g ? (l().error("[X402Manager] Circuit breaker is OPEN - x402 service unavailable"), new Error("Payment service is temporarily unavailable. Please try again in a few moments.")) : n;
|
|
1154
1250
|
}
|
|
1155
1251
|
}
|
|
1156
1252
|
/**
|
|
@@ -1160,9 +1256,9 @@ class gt {
|
|
|
1160
1256
|
const { items: r, metadata: a, couponCode: n } = e;
|
|
1161
1257
|
if (!this.quoteRateLimiter.tryConsume())
|
|
1162
1258
|
throw new Error("Rate limit exceeded for cart quote requests. Please try again later.");
|
|
1163
|
-
const i =
|
|
1259
|
+
const i = k();
|
|
1164
1260
|
try {
|
|
1165
|
-
return await this.circuitBreaker.execute(async () => await
|
|
1261
|
+
return await this.circuitBreaker.execute(async () => await E(
|
|
1166
1262
|
async () => {
|
|
1167
1263
|
const o = await this.routeDiscovery.buildUrl("/paywall/v1/cart/quote"), c = await p(o, {
|
|
1168
1264
|
method: "POST",
|
|
@@ -1180,20 +1276,20 @@ class gt {
|
|
|
1180
1276
|
})
|
|
1181
1277
|
});
|
|
1182
1278
|
if (c.status !== 402 && !c.ok) {
|
|
1183
|
-
const
|
|
1184
|
-
throw new Error(
|
|
1279
|
+
const f = await w(c, "Failed to get cart quote");
|
|
1280
|
+
throw new Error(f);
|
|
1185
1281
|
}
|
|
1186
|
-
const
|
|
1187
|
-
if (!
|
|
1282
|
+
const u = await c.json();
|
|
1283
|
+
if (!u.cartId || !u.quote)
|
|
1188
1284
|
throw new Error("Invalid cart quote response: missing cartId or quote");
|
|
1189
|
-
if (
|
|
1285
|
+
if (u.quote.crypto && !this.validateRequirement(u.quote.crypto))
|
|
1190
1286
|
throw new Error("Invalid x402 cart quote: missing required fields in crypto quote");
|
|
1191
|
-
return
|
|
1287
|
+
return u;
|
|
1192
1288
|
},
|
|
1193
|
-
{ ...
|
|
1289
|
+
{ ...v.QUICK, name: "x402-cart-quote" }
|
|
1194
1290
|
));
|
|
1195
1291
|
} catch (o) {
|
|
1196
|
-
throw o instanceof
|
|
1292
|
+
throw o instanceof g ? (l().error("[X402Manager] Circuit breaker is OPEN - cart quote service unavailable"), new Error("Payment service is temporarily unavailable. Please try again in a few moments.")) : o;
|
|
1197
1293
|
}
|
|
1198
1294
|
}
|
|
1199
1295
|
/**
|
|
@@ -1201,7 +1297,7 @@ class gt {
|
|
|
1201
1297
|
*/
|
|
1202
1298
|
buildPaymentHeader(e) {
|
|
1203
1299
|
const r = JSON.stringify(e);
|
|
1204
|
-
return
|
|
1300
|
+
return ge.encode(r);
|
|
1205
1301
|
}
|
|
1206
1302
|
/**
|
|
1207
1303
|
* Parse X-PAYMENT-RESPONSE header (base64 encoded settlement response)
|
|
@@ -1211,7 +1307,7 @@ class gt {
|
|
|
1211
1307
|
if (!r)
|
|
1212
1308
|
return null;
|
|
1213
1309
|
try {
|
|
1214
|
-
const a =
|
|
1310
|
+
const a = ge.decode(r), n = JSON.parse(a);
|
|
1215
1311
|
return typeof n.success != "boolean" ? (l().error("Invalid settlement response: missing success field"), null) : n;
|
|
1216
1312
|
} catch (a) {
|
|
1217
1313
|
return l().error("Failed to parse settlement response:", a), null;
|
|
@@ -1234,11 +1330,11 @@ class gt {
|
|
|
1234
1330
|
success: !1,
|
|
1235
1331
|
error: "Rate limit exceeded for payment verification. Please try again later."
|
|
1236
1332
|
};
|
|
1237
|
-
const s =
|
|
1333
|
+
const s = k();
|
|
1238
1334
|
try {
|
|
1239
|
-
return await this.circuitBreaker.execute(async () => await
|
|
1335
|
+
return await this.circuitBreaker.execute(async () => await E(
|
|
1240
1336
|
async () => {
|
|
1241
|
-
const
|
|
1337
|
+
const u = {
|
|
1242
1338
|
...a,
|
|
1243
1339
|
payload: {
|
|
1244
1340
|
...a.payload,
|
|
@@ -1253,45 +1349,45 @@ class gt {
|
|
|
1253
1349
|
// Add coupon if present
|
|
1254
1350
|
}
|
|
1255
1351
|
}
|
|
1256
|
-
},
|
|
1352
|
+
}, f = this.buildPaymentHeader(u), h = "/paywall/v1/verify";
|
|
1257
1353
|
l().debug("[X402Manager] Submitting payment", {
|
|
1258
1354
|
resourceType: o,
|
|
1259
1355
|
hasCoupon: !!n,
|
|
1260
1356
|
hasMetadata: !!i
|
|
1261
1357
|
});
|
|
1262
|
-
const y = await this.routeDiscovery.buildUrl(
|
|
1358
|
+
const y = await this.routeDiscovery.buildUrl(h), d = await p(y, {
|
|
1263
1359
|
method: "POST",
|
|
1264
1360
|
headers: {
|
|
1265
1361
|
"Content-Type": "application/json",
|
|
1266
|
-
"X-PAYMENT":
|
|
1362
|
+
"X-PAYMENT": f,
|
|
1267
1363
|
"Idempotency-Key": s
|
|
1268
1364
|
}
|
|
1269
1365
|
});
|
|
1270
|
-
if (
|
|
1271
|
-
const { settlement:
|
|
1272
|
-
|
|
1366
|
+
if (d.ok) {
|
|
1367
|
+
const { settlement: A, transactionId: b } = await this.handlePaymentVerification(
|
|
1368
|
+
d,
|
|
1273
1369
|
a.payload.signature
|
|
1274
1370
|
);
|
|
1275
1371
|
return {
|
|
1276
1372
|
success: !0,
|
|
1277
|
-
transactionId:
|
|
1278
|
-
settlement:
|
|
1373
|
+
transactionId: b,
|
|
1374
|
+
settlement: A || void 0
|
|
1279
1375
|
};
|
|
1280
1376
|
}
|
|
1281
1377
|
return {
|
|
1282
1378
|
success: !1,
|
|
1283
|
-
error: await
|
|
1379
|
+
error: await w(d, "Payment verification failed", !0)
|
|
1284
1380
|
};
|
|
1285
1381
|
},
|
|
1286
1382
|
{ maxRetries: 0, initialDelayMs: 0, backoffFactor: 1, maxDelayMs: 0, name: "x402-verify" }
|
|
1287
1383
|
));
|
|
1288
1384
|
} catch (c) {
|
|
1289
|
-
return c instanceof
|
|
1385
|
+
return c instanceof g ? {
|
|
1290
1386
|
success: !1,
|
|
1291
1387
|
error: "Payment verification service is temporarily unavailable. Please try again in a few moments."
|
|
1292
1388
|
} : {
|
|
1293
1389
|
success: !1,
|
|
1294
|
-
error:
|
|
1390
|
+
error: O(c, "Unknown error")
|
|
1295
1391
|
};
|
|
1296
1392
|
}
|
|
1297
1393
|
}
|
|
@@ -1304,7 +1400,7 @@ class gt {
|
|
|
1304
1400
|
if (!this.quoteRateLimiter.tryConsume())
|
|
1305
1401
|
throw new Error("Rate limit exceeded for gasless transaction requests. Please try again later.");
|
|
1306
1402
|
try {
|
|
1307
|
-
return await this.circuitBreaker.execute(async () => await
|
|
1403
|
+
return await this.circuitBreaker.execute(async () => await E(
|
|
1308
1404
|
async () => {
|
|
1309
1405
|
const o = await this.routeDiscovery.buildUrl(
|
|
1310
1406
|
"/paywall/v1/gasless-transaction"
|
|
@@ -1321,15 +1417,15 @@ class gt {
|
|
|
1321
1417
|
})
|
|
1322
1418
|
});
|
|
1323
1419
|
if (!s.ok) {
|
|
1324
|
-
const c = await
|
|
1420
|
+
const c = await w(s, "Failed to build gasless transaction");
|
|
1325
1421
|
throw new Error(c);
|
|
1326
1422
|
}
|
|
1327
1423
|
return await s.json();
|
|
1328
1424
|
},
|
|
1329
|
-
{ ...
|
|
1425
|
+
{ ...v.QUICK, name: "x402-gasless-build" }
|
|
1330
1426
|
));
|
|
1331
1427
|
} catch (o) {
|
|
1332
|
-
throw o instanceof
|
|
1428
|
+
throw o instanceof g ? (l().error("[X402Manager] Circuit breaker is OPEN - gasless transaction service unavailable"), new Error("Gasless transaction service is temporarily unavailable. Please try again in a few moments.")) : o;
|
|
1333
1429
|
}
|
|
1334
1430
|
}
|
|
1335
1431
|
/**
|
|
@@ -1351,11 +1447,11 @@ class gt {
|
|
|
1351
1447
|
success: !1,
|
|
1352
1448
|
error: "Rate limit exceeded for gasless transaction verification. Please try again later."
|
|
1353
1449
|
};
|
|
1354
|
-
const c =
|
|
1450
|
+
const c = k();
|
|
1355
1451
|
try {
|
|
1356
|
-
return await this.circuitBreaker.execute(async () => await
|
|
1452
|
+
return await this.circuitBreaker.execute(async () => await E(
|
|
1357
1453
|
async () => {
|
|
1358
|
-
const
|
|
1454
|
+
const f = {
|
|
1359
1455
|
x402Version: 0,
|
|
1360
1456
|
scheme: s?.scheme || "solana-spl-transfer",
|
|
1361
1457
|
network: s?.network || "mainnet-beta",
|
|
@@ -1371,39 +1467,39 @@ class gt {
|
|
|
1371
1467
|
...n ? { couponCode: n } : {}
|
|
1372
1468
|
}
|
|
1373
1469
|
}
|
|
1374
|
-
},
|
|
1470
|
+
}, h = this.buildPaymentHeader(f), d = await this.routeDiscovery.buildUrl("/paywall/v1/verify"), m = await p(d, {
|
|
1375
1471
|
method: "POST",
|
|
1376
1472
|
headers: {
|
|
1377
1473
|
"Content-Type": "application/json",
|
|
1378
|
-
"X-PAYMENT":
|
|
1474
|
+
"X-PAYMENT": h,
|
|
1379
1475
|
"Idempotency-Key": c
|
|
1380
1476
|
}
|
|
1381
1477
|
});
|
|
1382
|
-
if (
|
|
1383
|
-
const { settlement:
|
|
1384
|
-
|
|
1478
|
+
if (m.ok) {
|
|
1479
|
+
const { settlement: b, transactionId: x } = await this.handlePaymentVerification(
|
|
1480
|
+
m,
|
|
1385
1481
|
"gasless-tx"
|
|
1386
1482
|
);
|
|
1387
1483
|
return {
|
|
1388
1484
|
success: !0,
|
|
1389
1485
|
transactionId: x,
|
|
1390
|
-
settlement:
|
|
1486
|
+
settlement: b || void 0
|
|
1391
1487
|
};
|
|
1392
1488
|
}
|
|
1393
1489
|
return {
|
|
1394
1490
|
success: !1,
|
|
1395
|
-
error: await
|
|
1491
|
+
error: await w(m, "Gasless transaction failed", !0)
|
|
1396
1492
|
};
|
|
1397
1493
|
},
|
|
1398
1494
|
{ maxRetries: 0, initialDelayMs: 0, backoffFactor: 1, maxDelayMs: 0, name: "x402-gasless-verify" }
|
|
1399
1495
|
));
|
|
1400
|
-
} catch (
|
|
1401
|
-
return
|
|
1496
|
+
} catch (u) {
|
|
1497
|
+
return u instanceof g ? {
|
|
1402
1498
|
success: !1,
|
|
1403
1499
|
error: "Gasless transaction verification service is temporarily unavailable. Please try again in a few moments."
|
|
1404
1500
|
} : {
|
|
1405
1501
|
success: !1,
|
|
1406
|
-
error:
|
|
1502
|
+
error: O(u, "Unknown error")
|
|
1407
1503
|
};
|
|
1408
1504
|
}
|
|
1409
1505
|
}
|
|
@@ -1432,15 +1528,15 @@ class gt {
|
|
|
1432
1528
|
return !!(e.scheme && e.network && e.maxAmountRequired && e.resource && e.payTo && e.asset && e.maxTimeoutSeconds > 0);
|
|
1433
1529
|
}
|
|
1434
1530
|
}
|
|
1435
|
-
class
|
|
1531
|
+
class St {
|
|
1436
1532
|
stripe = null;
|
|
1437
1533
|
initPromise = null;
|
|
1438
1534
|
publicKey;
|
|
1439
1535
|
routeDiscovery;
|
|
1440
1536
|
// Separate rate limiters for different operation types
|
|
1441
|
-
sessionRateLimiter =
|
|
1442
|
-
statusRateLimiter =
|
|
1443
|
-
circuitBreaker =
|
|
1537
|
+
sessionRateLimiter = I(B.PAYMENT);
|
|
1538
|
+
statusRateLimiter = I(B.QUOTE);
|
|
1539
|
+
circuitBreaker = Q({
|
|
1444
1540
|
failureThreshold: 5,
|
|
1445
1541
|
timeout: 1e4,
|
|
1446
1542
|
// 10 seconds for faster recovery
|
|
@@ -1456,19 +1552,19 @@ class wt {
|
|
|
1456
1552
|
*/
|
|
1457
1553
|
async initialize() {
|
|
1458
1554
|
this.stripe || (this.initPromise || (this.initPromise = (async () => {
|
|
1459
|
-
if (this.stripe = await
|
|
1555
|
+
if (this.stripe = await Te(this.publicKey), !this.stripe) throw new Error("Failed to initialize Stripe");
|
|
1460
1556
|
})()), await this.initPromise);
|
|
1461
1557
|
}
|
|
1462
1558
|
/** Internal helper: execute with rate limiting, circuit breaker, and retry */
|
|
1463
|
-
async executeWithResilience(e, r, a, n) {
|
|
1559
|
+
async executeWithResilience(e, r, a, n, i = v.STANDARD) {
|
|
1464
1560
|
if (!e.tryConsume())
|
|
1465
1561
|
throw new Error("Rate limit exceeded. Please try again later.");
|
|
1466
1562
|
try {
|
|
1467
1563
|
return await this.circuitBreaker.execute(
|
|
1468
|
-
() =>
|
|
1564
|
+
() => E(r, { ...i, name: a })
|
|
1469
1565
|
);
|
|
1470
|
-
} catch (
|
|
1471
|
-
throw
|
|
1566
|
+
} catch (o) {
|
|
1567
|
+
throw o instanceof g ? (l().error(`[SubscriptionManager] Circuit breaker OPEN for ${n}`), new Error("Service temporarily unavailable. Please try again in a few moments.")) : o;
|
|
1472
1568
|
}
|
|
1473
1569
|
}
|
|
1474
1570
|
/**
|
|
@@ -1477,39 +1573,43 @@ class wt {
|
|
|
1477
1573
|
async createSubscriptionSession(e) {
|
|
1478
1574
|
if (!this.sessionRateLimiter.tryConsume())
|
|
1479
1575
|
throw new Error("Rate limit exceeded for subscription session creation. Please try again later.");
|
|
1480
|
-
const r =
|
|
1576
|
+
const r = k(), a = JSON.stringify(e);
|
|
1481
1577
|
try {
|
|
1482
|
-
return await this.circuitBreaker.execute(async () => await
|
|
1578
|
+
return await this.circuitBreaker.execute(async () => await E(
|
|
1483
1579
|
async () => {
|
|
1484
|
-
const
|
|
1580
|
+
const n = await this.routeDiscovery.buildUrl("/paywall/v1/subscription/stripe-session");
|
|
1485
1581
|
l().debug("[SubscriptionManager] Creating subscription session:", {
|
|
1486
1582
|
resource: e.resource,
|
|
1487
1583
|
interval: e.interval,
|
|
1488
1584
|
trialDays: e.trialDays
|
|
1489
1585
|
});
|
|
1490
|
-
const
|
|
1586
|
+
const i = await p(n, {
|
|
1491
1587
|
method: "POST",
|
|
1492
1588
|
headers: {
|
|
1493
1589
|
"Content-Type": "application/json",
|
|
1494
1590
|
"Idempotency-Key": r
|
|
1495
1591
|
},
|
|
1496
|
-
body:
|
|
1592
|
+
body: a
|
|
1497
1593
|
});
|
|
1498
|
-
if (!
|
|
1499
|
-
const
|
|
1500
|
-
|
|
1594
|
+
if (!i.ok) {
|
|
1595
|
+
const o = await w(
|
|
1596
|
+
i,
|
|
1501
1597
|
"Failed to create subscription session"
|
|
1502
1598
|
);
|
|
1503
|
-
throw
|
|
1599
|
+
throw T.fromResponse(i, o);
|
|
1504
1600
|
}
|
|
1505
|
-
return await
|
|
1601
|
+
return await i.json();
|
|
1506
1602
|
},
|
|
1507
|
-
{
|
|
1603
|
+
{
|
|
1604
|
+
...v.IDEMPOTENT_WRITE,
|
|
1605
|
+
name: "subscription-create-session",
|
|
1606
|
+
inFlightKey: `subscription:create-session:${a}`
|
|
1607
|
+
}
|
|
1508
1608
|
));
|
|
1509
|
-
} catch (
|
|
1510
|
-
throw
|
|
1609
|
+
} catch (n) {
|
|
1610
|
+
throw n instanceof g ? (l().error("[SubscriptionManager] Circuit breaker is OPEN - service unavailable"), new Error(
|
|
1511
1611
|
"Subscription service is temporarily unavailable. Please try again in a few moments."
|
|
1512
|
-
)) :
|
|
1612
|
+
)) : n;
|
|
1513
1613
|
}
|
|
1514
1614
|
}
|
|
1515
1615
|
/**
|
|
@@ -1537,7 +1637,7 @@ class wt {
|
|
|
1537
1637
|
} catch (r) {
|
|
1538
1638
|
return {
|
|
1539
1639
|
success: !1,
|
|
1540
|
-
error:
|
|
1640
|
+
error: O(r, "Subscription failed")
|
|
1541
1641
|
};
|
|
1542
1642
|
}
|
|
1543
1643
|
}
|
|
@@ -1548,7 +1648,7 @@ class wt {
|
|
|
1548
1648
|
if (!this.statusRateLimiter.tryConsume())
|
|
1549
1649
|
throw new Error("Rate limit exceeded for subscription status check. Please try again later.");
|
|
1550
1650
|
try {
|
|
1551
|
-
return await this.circuitBreaker.execute(async () => await
|
|
1651
|
+
return await this.circuitBreaker.execute(async () => await E(
|
|
1552
1652
|
async () => {
|
|
1553
1653
|
const r = new URLSearchParams({
|
|
1554
1654
|
resource: e.resource,
|
|
@@ -1564,7 +1664,7 @@ class wt {
|
|
|
1564
1664
|
}
|
|
1565
1665
|
});
|
|
1566
1666
|
if (!n.ok) {
|
|
1567
|
-
const i = await
|
|
1667
|
+
const i = await w(
|
|
1568
1668
|
n,
|
|
1569
1669
|
"Failed to check subscription status"
|
|
1570
1670
|
);
|
|
@@ -1572,10 +1672,10 @@ class wt {
|
|
|
1572
1672
|
}
|
|
1573
1673
|
return await n.json();
|
|
1574
1674
|
},
|
|
1575
|
-
{ ...
|
|
1675
|
+
{ ...v.STANDARD, name: "subscription-status-check" }
|
|
1576
1676
|
));
|
|
1577
1677
|
} catch (r) {
|
|
1578
|
-
throw r instanceof
|
|
1678
|
+
throw r instanceof g ? (l().error("[SubscriptionManager] Circuit breaker is OPEN for status check"), new Error(
|
|
1579
1679
|
"Subscription status service is temporarily unavailable. Please try again in a few moments."
|
|
1580
1680
|
)) : r;
|
|
1581
1681
|
}
|
|
@@ -1587,7 +1687,7 @@ class wt {
|
|
|
1587
1687
|
if (!this.statusRateLimiter.tryConsume())
|
|
1588
1688
|
throw new Error("Rate limit exceeded for subscription quote. Please try again later.");
|
|
1589
1689
|
try {
|
|
1590
|
-
return await this.circuitBreaker.execute(async () => await
|
|
1690
|
+
return await this.circuitBreaker.execute(async () => await E(
|
|
1591
1691
|
async () => {
|
|
1592
1692
|
const n = await this.routeDiscovery.buildUrl("/paywall/v1/subscription/quote"), i = {
|
|
1593
1693
|
resource: e,
|
|
@@ -1604,7 +1704,7 @@ class wt {
|
|
|
1604
1704
|
body: JSON.stringify(i)
|
|
1605
1705
|
});
|
|
1606
1706
|
if (o.status !== 402 && !o.ok) {
|
|
1607
|
-
const s = await
|
|
1707
|
+
const s = await w(
|
|
1608
1708
|
o,
|
|
1609
1709
|
"Failed to get subscription quote"
|
|
1610
1710
|
);
|
|
@@ -1612,39 +1712,48 @@ class wt {
|
|
|
1612
1712
|
}
|
|
1613
1713
|
return await o.json();
|
|
1614
1714
|
},
|
|
1615
|
-
{ ...
|
|
1715
|
+
{ ...v.STANDARD, name: "subscription-quote" }
|
|
1616
1716
|
));
|
|
1617
1717
|
} catch (n) {
|
|
1618
|
-
throw n instanceof
|
|
1718
|
+
throw n instanceof g ? (l().error("[SubscriptionManager] Circuit breaker is OPEN for quote"), new Error(
|
|
1619
1719
|
"Subscription quote service is temporarily unavailable. Please try again in a few moments."
|
|
1620
1720
|
)) : n;
|
|
1621
1721
|
}
|
|
1622
1722
|
}
|
|
1623
1723
|
/** Activate x402 subscription after payment verification */
|
|
1624
1724
|
async activateX402Subscription(e) {
|
|
1725
|
+
const r = JSON.stringify(e);
|
|
1625
1726
|
return this.executeWithResilience(
|
|
1626
1727
|
this.sessionRateLimiter,
|
|
1627
1728
|
async () => {
|
|
1628
|
-
const
|
|
1729
|
+
const a = await this.routeDiscovery.buildUrl("/paywall/v1/subscription/x402/activate");
|
|
1629
1730
|
l().debug("[SubscriptionManager] Activating x402 subscription:", e);
|
|
1630
|
-
const
|
|
1731
|
+
const n = await p(a, {
|
|
1631
1732
|
method: "POST",
|
|
1632
1733
|
headers: { "Content-Type": "application/json" },
|
|
1633
|
-
body:
|
|
1734
|
+
body: r
|
|
1634
1735
|
});
|
|
1635
|
-
if (!
|
|
1636
|
-
|
|
1736
|
+
if (!n.ok)
|
|
1737
|
+
throw T.fromResponse(
|
|
1738
|
+
n,
|
|
1739
|
+
await w(n, "Failed to activate")
|
|
1740
|
+
);
|
|
1741
|
+
return await n.json();
|
|
1637
1742
|
},
|
|
1638
1743
|
"subscription-activate",
|
|
1639
|
-
"activation"
|
|
1744
|
+
"activation",
|
|
1745
|
+
{
|
|
1746
|
+
...v.IDEMPOTENT_WRITE,
|
|
1747
|
+
inFlightKey: `subscription:activate:${r}`
|
|
1748
|
+
}
|
|
1640
1749
|
);
|
|
1641
1750
|
}
|
|
1642
1751
|
}
|
|
1643
|
-
class
|
|
1752
|
+
class Tt {
|
|
1644
1753
|
routeDiscovery;
|
|
1645
|
-
rateLimiter =
|
|
1646
|
-
queryRateLimiter =
|
|
1647
|
-
circuitBreaker =
|
|
1754
|
+
rateLimiter = I(B.PAYMENT);
|
|
1755
|
+
queryRateLimiter = I(B.QUOTE);
|
|
1756
|
+
circuitBreaker = Q({
|
|
1648
1757
|
failureThreshold: 5,
|
|
1649
1758
|
timeout: 1e4,
|
|
1650
1759
|
name: "subscription-change-manager"
|
|
@@ -1653,36 +1762,43 @@ class bt {
|
|
|
1653
1762
|
this.routeDiscovery = e;
|
|
1654
1763
|
}
|
|
1655
1764
|
/** Internal helper: execute with rate limiting, circuit breaker, and retry */
|
|
1656
|
-
async executeWithResilience(e, r, a, n) {
|
|
1765
|
+
async executeWithResilience(e, r, a, n, i = v.STANDARD) {
|
|
1657
1766
|
if (!e.tryConsume())
|
|
1658
1767
|
throw new Error("Rate limit exceeded. Please try again later.");
|
|
1659
1768
|
try {
|
|
1660
1769
|
return await this.circuitBreaker.execute(
|
|
1661
|
-
() =>
|
|
1770
|
+
() => E(r, { ...i, name: a })
|
|
1662
1771
|
);
|
|
1663
|
-
} catch (
|
|
1664
|
-
throw
|
|
1772
|
+
} catch (o) {
|
|
1773
|
+
throw o instanceof g ? (l().error(`[SubscriptionChangeManager] Circuit breaker OPEN for ${n}`), new Error("Service temporarily unavailable. Please try again in a few moments.")) : o;
|
|
1665
1774
|
}
|
|
1666
1775
|
}
|
|
1667
1776
|
/** Change subscription plan (upgrade or downgrade) */
|
|
1668
1777
|
async changeSubscription(e) {
|
|
1669
|
-
const r =
|
|
1778
|
+
const r = k(), a = JSON.stringify(e);
|
|
1670
1779
|
return this.executeWithResilience(
|
|
1671
1780
|
this.rateLimiter,
|
|
1672
1781
|
async () => {
|
|
1673
|
-
const
|
|
1782
|
+
const n = await this.routeDiscovery.buildUrl("/paywall/v1/subscription/change");
|
|
1674
1783
|
l().debug("[SubscriptionChangeManager] Changing subscription:", e);
|
|
1675
|
-
const
|
|
1784
|
+
const i = await p(n, {
|
|
1676
1785
|
method: "POST",
|
|
1677
1786
|
headers: { "Content-Type": "application/json", "Idempotency-Key": r },
|
|
1678
|
-
body:
|
|
1787
|
+
body: a
|
|
1679
1788
|
});
|
|
1680
|
-
if (!
|
|
1681
|
-
throw
|
|
1682
|
-
|
|
1789
|
+
if (!i.ok)
|
|
1790
|
+
throw T.fromResponse(
|
|
1791
|
+
i,
|
|
1792
|
+
await w(i, "Failed to change subscription")
|
|
1793
|
+
);
|
|
1794
|
+
return await i.json();
|
|
1683
1795
|
},
|
|
1684
1796
|
"subscription-change",
|
|
1685
|
-
"plan change"
|
|
1797
|
+
"plan change",
|
|
1798
|
+
{
|
|
1799
|
+
...v.IDEMPOTENT_WRITE,
|
|
1800
|
+
inFlightKey: `subscription:change:${a}`
|
|
1801
|
+
}
|
|
1686
1802
|
);
|
|
1687
1803
|
}
|
|
1688
1804
|
/** Preview subscription change (get proration details) */
|
|
@@ -1698,7 +1814,7 @@ class bt {
|
|
|
1698
1814
|
body: JSON.stringify(e)
|
|
1699
1815
|
});
|
|
1700
1816
|
if (!a.ok)
|
|
1701
|
-
throw new Error(await
|
|
1817
|
+
throw new Error(await w(a, "Failed to preview change"));
|
|
1702
1818
|
return await a.json();
|
|
1703
1819
|
},
|
|
1704
1820
|
"subscription-preview",
|
|
@@ -1717,7 +1833,7 @@ class bt {
|
|
|
1717
1833
|
headers: { "Content-Type": "application/json" }
|
|
1718
1834
|
});
|
|
1719
1835
|
if (!i.ok)
|
|
1720
|
-
throw new Error(await
|
|
1836
|
+
throw new Error(await w(i, "Failed to get subscription details"));
|
|
1721
1837
|
return await i.json();
|
|
1722
1838
|
},
|
|
1723
1839
|
"subscription-details",
|
|
@@ -1726,49 +1842,65 @@ class bt {
|
|
|
1726
1842
|
}
|
|
1727
1843
|
/** Cancel a subscription */
|
|
1728
1844
|
async cancel(e) {
|
|
1845
|
+
const r = JSON.stringify(e);
|
|
1729
1846
|
return this.executeWithResilience(
|
|
1730
1847
|
this.rateLimiter,
|
|
1731
1848
|
async () => {
|
|
1732
|
-
const
|
|
1849
|
+
const a = await this.routeDiscovery.buildUrl("/paywall/v1/subscription/cancel");
|
|
1733
1850
|
l().debug("[SubscriptionChangeManager] Canceling subscription:", e);
|
|
1734
|
-
const
|
|
1851
|
+
const n = await p(a, {
|
|
1735
1852
|
method: "POST",
|
|
1736
1853
|
headers: { "Content-Type": "application/json" },
|
|
1737
|
-
body:
|
|
1854
|
+
body: r
|
|
1738
1855
|
});
|
|
1739
|
-
if (!
|
|
1740
|
-
throw
|
|
1741
|
-
|
|
1856
|
+
if (!n.ok)
|
|
1857
|
+
throw T.fromResponse(
|
|
1858
|
+
n,
|
|
1859
|
+
await w(n, "Failed to cancel subscription")
|
|
1860
|
+
);
|
|
1861
|
+
return await n.json();
|
|
1742
1862
|
},
|
|
1743
1863
|
"subscription-cancel",
|
|
1744
|
-
"cancellation"
|
|
1864
|
+
"cancellation",
|
|
1865
|
+
{
|
|
1866
|
+
...v.WRITE_ONCE,
|
|
1867
|
+
inFlightKey: `subscription:cancel:${r}`
|
|
1868
|
+
}
|
|
1745
1869
|
);
|
|
1746
1870
|
}
|
|
1747
1871
|
/** Get Stripe billing portal URL */
|
|
1748
1872
|
async getBillingPortalUrl(e) {
|
|
1873
|
+
const r = JSON.stringify(e);
|
|
1749
1874
|
return this.executeWithResilience(
|
|
1750
1875
|
this.queryRateLimiter,
|
|
1751
1876
|
async () => {
|
|
1752
|
-
const
|
|
1877
|
+
const a = await this.routeDiscovery.buildUrl("/paywall/v1/subscription/portal");
|
|
1753
1878
|
l().debug("[SubscriptionChangeManager] Getting billing portal URL:", e);
|
|
1754
|
-
const
|
|
1879
|
+
const n = await p(a, {
|
|
1755
1880
|
method: "POST",
|
|
1756
1881
|
headers: { "Content-Type": "application/json" },
|
|
1757
|
-
body:
|
|
1882
|
+
body: r
|
|
1758
1883
|
});
|
|
1759
|
-
if (!
|
|
1760
|
-
throw
|
|
1761
|
-
|
|
1884
|
+
if (!n.ok)
|
|
1885
|
+
throw T.fromResponse(
|
|
1886
|
+
n,
|
|
1887
|
+
await w(n, "Failed to get billing portal URL")
|
|
1888
|
+
);
|
|
1889
|
+
return await n.json();
|
|
1762
1890
|
},
|
|
1763
1891
|
"subscription-portal",
|
|
1764
|
-
"portal"
|
|
1892
|
+
"portal",
|
|
1893
|
+
{
|
|
1894
|
+
...v.WRITE_ONCE,
|
|
1895
|
+
inFlightKey: `subscription:portal:${r}`
|
|
1896
|
+
}
|
|
1765
1897
|
);
|
|
1766
1898
|
}
|
|
1767
1899
|
}
|
|
1768
|
-
class
|
|
1900
|
+
class xt {
|
|
1769
1901
|
routeDiscovery;
|
|
1770
|
-
rateLimiter =
|
|
1771
|
-
circuitBreaker =
|
|
1902
|
+
rateLimiter = I(B.PAYMENT);
|
|
1903
|
+
circuitBreaker = Q({
|
|
1772
1904
|
failureThreshold: 5,
|
|
1773
1905
|
timeout: 1e4,
|
|
1774
1906
|
name: "credits-manager"
|
|
@@ -1780,7 +1912,7 @@ class vt {
|
|
|
1780
1912
|
if (!this.rateLimiter.tryConsume())
|
|
1781
1913
|
throw new Error("Rate limit exceeded for credits quote. Please try again later.");
|
|
1782
1914
|
try {
|
|
1783
|
-
return await this.circuitBreaker.execute(async () => await
|
|
1915
|
+
return await this.circuitBreaker.execute(async () => await E(
|
|
1784
1916
|
async () => {
|
|
1785
1917
|
const a = await this.routeDiscovery.buildUrl("/paywall/v1/quote");
|
|
1786
1918
|
l().debug("[CreditsManager] Requesting quote");
|
|
@@ -1792,22 +1924,22 @@ class vt {
|
|
|
1792
1924
|
if (n.status === 402)
|
|
1793
1925
|
return (await n.json()).credits || null;
|
|
1794
1926
|
if (!n.ok) {
|
|
1795
|
-
const i = await
|
|
1927
|
+
const i = await w(n, "Failed to get credits quote");
|
|
1796
1928
|
throw new Error(i);
|
|
1797
1929
|
}
|
|
1798
1930
|
return null;
|
|
1799
1931
|
},
|
|
1800
|
-
{ ...
|
|
1932
|
+
{ ...v.STANDARD, name: "credits-quote" }
|
|
1801
1933
|
));
|
|
1802
1934
|
} catch (a) {
|
|
1803
|
-
throw a instanceof
|
|
1935
|
+
throw a instanceof g ? (l().error("[CreditsManager] Circuit breaker is OPEN - credits service unavailable"), new Error("Credits service is temporarily unavailable. Please try again in a few moments.")) : a;
|
|
1804
1936
|
}
|
|
1805
1937
|
}
|
|
1806
1938
|
async requestCartQuote(e, r) {
|
|
1807
1939
|
if (!this.rateLimiter.tryConsume())
|
|
1808
1940
|
throw new Error("Rate limit exceeded for cart credits quote. Please try again later.");
|
|
1809
1941
|
try {
|
|
1810
|
-
return await this.circuitBreaker.execute(async () => await
|
|
1942
|
+
return await this.circuitBreaker.execute(async () => await E(
|
|
1811
1943
|
async () => {
|
|
1812
1944
|
const a = await this.routeDiscovery.buildUrl("/paywall/v1/cart/quote");
|
|
1813
1945
|
l().debug("[CreditsManager] Requesting cart quote for items:", e.length);
|
|
@@ -1823,13 +1955,13 @@ class vt {
|
|
|
1823
1955
|
credits: o.credits
|
|
1824
1956
|
} : null;
|
|
1825
1957
|
}
|
|
1826
|
-
const i = await
|
|
1958
|
+
const i = await w(n, "Failed to get cart credits quote");
|
|
1827
1959
|
throw new Error(i);
|
|
1828
1960
|
},
|
|
1829
|
-
{ ...
|
|
1961
|
+
{ ...v.STANDARD, name: "credits-cart-quote" }
|
|
1830
1962
|
));
|
|
1831
1963
|
} catch (a) {
|
|
1832
|
-
throw a instanceof
|
|
1964
|
+
throw a instanceof g ? new Error("Credits service is temporarily unavailable. Please try again in a few moments.") : a;
|
|
1833
1965
|
}
|
|
1834
1966
|
}
|
|
1835
1967
|
/**
|
|
@@ -1840,31 +1972,35 @@ class vt {
|
|
|
1840
1972
|
const { resource: r, couponCode: a, authToken: n } = e;
|
|
1841
1973
|
if (!this.rateLimiter.tryConsume())
|
|
1842
1974
|
throw new Error("Rate limit exceeded for credits hold. Please try again later.");
|
|
1843
|
-
const i =
|
|
1975
|
+
const i = k(), o = JSON.stringify({ resource: r, couponCode: a });
|
|
1844
1976
|
try {
|
|
1845
|
-
return await this.circuitBreaker.execute(async () => await
|
|
1977
|
+
return await this.circuitBreaker.execute(async () => await E(
|
|
1846
1978
|
async () => {
|
|
1847
|
-
const
|
|
1979
|
+
const s = await this.routeDiscovery.buildUrl("/paywall/v1/credits/hold");
|
|
1848
1980
|
l().debug("[CreditsManager] Creating hold");
|
|
1849
|
-
const
|
|
1981
|
+
const c = await p(s, {
|
|
1850
1982
|
method: "POST",
|
|
1851
1983
|
headers: {
|
|
1852
1984
|
"Content-Type": "application/json",
|
|
1853
1985
|
Authorization: `Bearer ${n}`,
|
|
1854
1986
|
"Idempotency-Key": i
|
|
1855
1987
|
},
|
|
1856
|
-
body:
|
|
1988
|
+
body: o
|
|
1857
1989
|
});
|
|
1858
|
-
if (!
|
|
1859
|
-
const
|
|
1860
|
-
throw
|
|
1990
|
+
if (!c.ok) {
|
|
1991
|
+
const u = await w(c, "Failed to create credits hold");
|
|
1992
|
+
throw T.fromResponse(c, u);
|
|
1861
1993
|
}
|
|
1862
|
-
return await
|
|
1994
|
+
return await c.json();
|
|
1863
1995
|
},
|
|
1864
|
-
{
|
|
1996
|
+
{
|
|
1997
|
+
...v.IDEMPOTENT_WRITE,
|
|
1998
|
+
name: "credits-create-hold",
|
|
1999
|
+
inFlightKey: `credits:create-hold:${n}:${o}`
|
|
2000
|
+
}
|
|
1865
2001
|
));
|
|
1866
|
-
} catch (
|
|
1867
|
-
throw
|
|
2002
|
+
} catch (s) {
|
|
2003
|
+
throw s instanceof g ? new Error("Credits service is temporarily unavailable. Please try again in a few moments.") : s;
|
|
1868
2004
|
}
|
|
1869
2005
|
}
|
|
1870
2006
|
/**
|
|
@@ -1875,9 +2011,9 @@ class vt {
|
|
|
1875
2011
|
const { cartId: r, authToken: a } = e;
|
|
1876
2012
|
if (!this.rateLimiter.tryConsume())
|
|
1877
2013
|
throw new Error("Rate limit exceeded for cart credits hold. Please try again later.");
|
|
1878
|
-
const n =
|
|
2014
|
+
const n = k();
|
|
1879
2015
|
try {
|
|
1880
|
-
return await this.circuitBreaker.execute(async () => await
|
|
2016
|
+
return await this.circuitBreaker.execute(async () => await E(
|
|
1881
2017
|
async () => {
|
|
1882
2018
|
const i = await this.routeDiscovery.buildUrl(`/paywall/v1/cart/${encodeURIComponent(r)}/credits/hold`);
|
|
1883
2019
|
l().debug("[CreditsManager] Creating cart hold for cart:", r);
|
|
@@ -1891,15 +2027,19 @@ class vt {
|
|
|
1891
2027
|
body: JSON.stringify({})
|
|
1892
2028
|
});
|
|
1893
2029
|
if (!o.ok) {
|
|
1894
|
-
const s = await
|
|
1895
|
-
throw
|
|
2030
|
+
const s = await w(o, "Failed to create cart credits hold");
|
|
2031
|
+
throw T.fromResponse(o, s);
|
|
1896
2032
|
}
|
|
1897
2033
|
return await o.json();
|
|
1898
2034
|
},
|
|
1899
|
-
{
|
|
2035
|
+
{
|
|
2036
|
+
...v.IDEMPOTENT_WRITE,
|
|
2037
|
+
name: "credits-create-cart-hold",
|
|
2038
|
+
inFlightKey: `credits:create-cart-hold:${a}:${r}`
|
|
2039
|
+
}
|
|
1900
2040
|
));
|
|
1901
2041
|
} catch (i) {
|
|
1902
|
-
throw i instanceof
|
|
2042
|
+
throw i instanceof g ? new Error("Credits service is temporarily unavailable. Please try again in a few moments.") : i;
|
|
1903
2043
|
}
|
|
1904
2044
|
}
|
|
1905
2045
|
async authorizePayment(e) {
|
|
@@ -1910,49 +2050,52 @@ class vt {
|
|
|
1910
2050
|
error: "Rate limit exceeded for credits authorization. Please try again later.",
|
|
1911
2051
|
errorCode: "rate_limit_exceeded"
|
|
1912
2052
|
};
|
|
1913
|
-
const s =
|
|
2053
|
+
const s = k(), c = JSON.stringify({
|
|
2054
|
+
resource: r,
|
|
2055
|
+
holdId: a,
|
|
2056
|
+
couponCode: n,
|
|
2057
|
+
...o && { metadata: o }
|
|
2058
|
+
});
|
|
1914
2059
|
try {
|
|
1915
|
-
return await this.circuitBreaker.execute(async () => await
|
|
2060
|
+
return await this.circuitBreaker.execute(async () => await E(
|
|
1916
2061
|
async () => {
|
|
1917
|
-
const
|
|
2062
|
+
const u = await this.routeDiscovery.buildUrl("/paywall/v1/credits/authorize");
|
|
1918
2063
|
l().debug("[CreditsManager] Authorizing payment");
|
|
1919
|
-
const
|
|
2064
|
+
const f = await p(u, {
|
|
1920
2065
|
method: "POST",
|
|
1921
2066
|
headers: {
|
|
1922
2067
|
"Content-Type": "application/json",
|
|
1923
2068
|
Authorization: `Bearer ${i}`,
|
|
1924
2069
|
"Idempotency-Key": s
|
|
1925
2070
|
},
|
|
1926
|
-
body:
|
|
1927
|
-
resource: r,
|
|
1928
|
-
holdId: a,
|
|
1929
|
-
couponCode: n,
|
|
1930
|
-
...o && { metadata: o }
|
|
1931
|
-
})
|
|
2071
|
+
body: c
|
|
1932
2072
|
});
|
|
1933
|
-
if (!
|
|
1934
|
-
const
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
};
|
|
2073
|
+
if (!f.ok) {
|
|
2074
|
+
const y = await f.json().catch(() => ({}));
|
|
2075
|
+
throw T.fromResponse(
|
|
2076
|
+
f,
|
|
2077
|
+
y.error?.message || "Credits authorization failed"
|
|
2078
|
+
);
|
|
1940
2079
|
}
|
|
1941
2080
|
return {
|
|
1942
2081
|
success: !0,
|
|
1943
|
-
transactionId: (await
|
|
2082
|
+
transactionId: (await f.json()).transactionId
|
|
1944
2083
|
};
|
|
1945
2084
|
},
|
|
1946
|
-
{
|
|
2085
|
+
{
|
|
2086
|
+
...v.IDEMPOTENT_WRITE,
|
|
2087
|
+
name: "credits-authorize",
|
|
2088
|
+
inFlightKey: `credits:authorize:${i}:${c}`
|
|
2089
|
+
}
|
|
1947
2090
|
));
|
|
1948
|
-
} catch (
|
|
1949
|
-
return
|
|
2091
|
+
} catch (u) {
|
|
2092
|
+
return u instanceof g ? {
|
|
1950
2093
|
success: !1,
|
|
1951
2094
|
error: "Credits service is temporarily unavailable. Please try again in a few moments.",
|
|
1952
2095
|
errorCode: "service_unavailable"
|
|
1953
2096
|
} : {
|
|
1954
2097
|
success: !1,
|
|
1955
|
-
error:
|
|
2098
|
+
error: O(u, "Credits authorization failed"),
|
|
1956
2099
|
errorCode: "authorization_failed"
|
|
1957
2100
|
};
|
|
1958
2101
|
}
|
|
@@ -1965,51 +2108,54 @@ class vt {
|
|
|
1965
2108
|
error: "Rate limit exceeded for cart credits authorization. Please try again later.",
|
|
1966
2109
|
errorCode: "rate_limit_exceeded"
|
|
1967
2110
|
};
|
|
1968
|
-
const o =
|
|
2111
|
+
const o = k(), s = JSON.stringify({
|
|
2112
|
+
holdId: a,
|
|
2113
|
+
...i && { metadata: i }
|
|
2114
|
+
});
|
|
1969
2115
|
try {
|
|
1970
|
-
return await this.circuitBreaker.execute(async () => await
|
|
2116
|
+
return await this.circuitBreaker.execute(async () => await E(
|
|
1971
2117
|
async () => {
|
|
1972
|
-
const
|
|
2118
|
+
const c = await this.routeDiscovery.buildUrl(`/paywall/v1/cart/${encodeURIComponent(r)}/credits/authorize`);
|
|
1973
2119
|
l().debug("[CreditsManager] Authorizing cart payment for cart:", r);
|
|
1974
|
-
const
|
|
2120
|
+
const u = await p(c, {
|
|
1975
2121
|
method: "POST",
|
|
1976
2122
|
headers: {
|
|
1977
2123
|
"Content-Type": "application/json",
|
|
1978
2124
|
Authorization: `Bearer ${n}`,
|
|
1979
2125
|
"Idempotency-Key": o
|
|
1980
2126
|
},
|
|
1981
|
-
body:
|
|
1982
|
-
holdId: a,
|
|
1983
|
-
...i && { metadata: i }
|
|
1984
|
-
})
|
|
2127
|
+
body: s
|
|
1985
2128
|
});
|
|
1986
|
-
if (!
|
|
1987
|
-
const
|
|
2129
|
+
if (!u.ok) {
|
|
2130
|
+
const h = await u.json().catch((y) => (l().error("[CreditsManager] Failed to parse error response JSON:", y, {
|
|
1988
2131
|
cartId: r,
|
|
1989
|
-
status:
|
|
1990
|
-
statusText:
|
|
2132
|
+
status: u.status,
|
|
2133
|
+
statusText: u.statusText
|
|
1991
2134
|
}), {}));
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
};
|
|
2135
|
+
throw T.fromResponse(
|
|
2136
|
+
u,
|
|
2137
|
+
h.error?.message || "Cart credits authorization failed"
|
|
2138
|
+
);
|
|
1997
2139
|
}
|
|
1998
2140
|
return {
|
|
1999
2141
|
success: !0,
|
|
2000
|
-
transactionId: (await
|
|
2142
|
+
transactionId: (await u.json()).transactionId
|
|
2001
2143
|
};
|
|
2002
2144
|
},
|
|
2003
|
-
{
|
|
2145
|
+
{
|
|
2146
|
+
...v.IDEMPOTENT_WRITE,
|
|
2147
|
+
name: "credits-cart-authorize",
|
|
2148
|
+
inFlightKey: `credits:cart-authorize:${n}:${r}:${s}`
|
|
2149
|
+
}
|
|
2004
2150
|
));
|
|
2005
|
-
} catch (
|
|
2006
|
-
return
|
|
2151
|
+
} catch (c) {
|
|
2152
|
+
return c instanceof g ? {
|
|
2007
2153
|
success: !1,
|
|
2008
2154
|
error: "Credits service is temporarily unavailable. Please try again in a few moments.",
|
|
2009
2155
|
errorCode: "service_unavailable"
|
|
2010
2156
|
} : {
|
|
2011
2157
|
success: !1,
|
|
2012
|
-
error:
|
|
2158
|
+
error: O(c, "Cart credits authorization failed"),
|
|
2013
2159
|
errorCode: "authorization_failed"
|
|
2014
2160
|
};
|
|
2015
2161
|
}
|
|
@@ -2022,16 +2168,16 @@ class vt {
|
|
|
2022
2168
|
method: "POST",
|
|
2023
2169
|
headers: {
|
|
2024
2170
|
Authorization: `Bearer ${r}`,
|
|
2025
|
-
"Idempotency-Key":
|
|
2171
|
+
"Idempotency-Key": k()
|
|
2026
2172
|
}
|
|
2027
2173
|
});
|
|
2028
2174
|
if (!n.ok) {
|
|
2029
|
-
const i = await
|
|
2175
|
+
const i = await w(n, "Failed to release credits hold");
|
|
2030
2176
|
throw new Error(i);
|
|
2031
2177
|
}
|
|
2032
2178
|
});
|
|
2033
2179
|
} catch (a) {
|
|
2034
|
-
throw a instanceof
|
|
2180
|
+
throw a instanceof g ? new Error("Credits service is temporarily unavailable. Please try again in a few moments.") : a;
|
|
2035
2181
|
}
|
|
2036
2182
|
}
|
|
2037
2183
|
/**
|
|
@@ -2074,7 +2220,7 @@ class vt {
|
|
|
2074
2220
|
}
|
|
2075
2221
|
return {
|
|
2076
2222
|
success: !1,
|
|
2077
|
-
error:
|
|
2223
|
+
error: O(o, "Credits payment failed")
|
|
2078
2224
|
};
|
|
2079
2225
|
}
|
|
2080
2226
|
}
|
|
@@ -2086,17 +2232,17 @@ class vt {
|
|
|
2086
2232
|
headers: { Authorization: `Bearer ${e}` }
|
|
2087
2233
|
});
|
|
2088
2234
|
if (!a.ok) {
|
|
2089
|
-
const n = await
|
|
2235
|
+
const n = await w(a, "Failed to fetch credits balance");
|
|
2090
2236
|
throw new Error(n);
|
|
2091
2237
|
}
|
|
2092
2238
|
return await a.json();
|
|
2093
2239
|
});
|
|
2094
2240
|
} catch (r) {
|
|
2095
|
-
throw r instanceof
|
|
2241
|
+
throw r instanceof g ? new Error("Credits service is temporarily unavailable. Please try again in a few moments.") : r;
|
|
2096
2242
|
}
|
|
2097
2243
|
}
|
|
2098
2244
|
}
|
|
2099
|
-
class
|
|
2245
|
+
class kt {
|
|
2100
2246
|
serverUrl;
|
|
2101
2247
|
getLogger;
|
|
2102
2248
|
fetchWithTimeout;
|
|
@@ -2164,131 +2310,134 @@ class Ct {
|
|
|
2164
2310
|
this.routePrefix = null, this.discoveryPromise = null, this.failedDiscoveryAt = null;
|
|
2165
2311
|
}
|
|
2166
2312
|
}
|
|
2167
|
-
class
|
|
2313
|
+
class Rt extends kt {
|
|
2168
2314
|
constructor(e) {
|
|
2169
2315
|
super(e, { getLogger: l, fetchWithTimeout: p });
|
|
2170
2316
|
}
|
|
2171
2317
|
}
|
|
2172
|
-
let
|
|
2173
|
-
async function
|
|
2174
|
-
return
|
|
2318
|
+
let ee = null;
|
|
2319
|
+
async function Mt() {
|
|
2320
|
+
return ee || (ee = (await import("./WalletManager-BIwH8Dw_.mjs")).WalletManager), ee;
|
|
2175
2321
|
}
|
|
2176
|
-
const
|
|
2177
|
-
function
|
|
2322
|
+
const X = /* @__PURE__ */ new Map(), te = /* @__PURE__ */ new Map();
|
|
2323
|
+
function qe(t, e, r, a, n, i) {
|
|
2178
2324
|
return JSON.stringify({
|
|
2179
2325
|
stripePublicKey: t,
|
|
2180
2326
|
serverUrl: e,
|
|
2181
2327
|
solanaCluster: r,
|
|
2182
2328
|
solanaEndpoint: a || "",
|
|
2183
|
-
dangerouslyAllowUnknownMint: n || !1
|
|
2329
|
+
dangerouslyAllowUnknownMint: n || !1,
|
|
2330
|
+
complianceCheck: i || !1
|
|
2184
2331
|
});
|
|
2185
2332
|
}
|
|
2186
|
-
async function
|
|
2187
|
-
const
|
|
2333
|
+
async function Dt(t, e, r, a, n, i) {
|
|
2334
|
+
const o = qe(
|
|
2188
2335
|
t,
|
|
2189
2336
|
e,
|
|
2190
2337
|
r,
|
|
2191
2338
|
a,
|
|
2192
|
-
n
|
|
2339
|
+
n,
|
|
2340
|
+
i
|
|
2193
2341
|
);
|
|
2194
|
-
let
|
|
2195
|
-
if (o)
|
|
2196
|
-
return o.refCount++, l().debug(
|
|
2197
|
-
`[ManagerCache] Reusing cached managers (refCount: ${o.refCount}):`,
|
|
2198
|
-
{ stripePublicKey: t.slice(0, 10) + "...", serverUrl: e }
|
|
2199
|
-
), o;
|
|
2200
|
-
const s = Z.get(i);
|
|
2342
|
+
let s = X.get(o);
|
|
2201
2343
|
if (s)
|
|
2202
|
-
return
|
|
2203
|
-
`[ManagerCache] Reusing
|
|
2344
|
+
return s.refCount++, l().debug(
|
|
2345
|
+
`[ManagerCache] Reusing cached managers (refCount: ${s.refCount}):`,
|
|
2346
|
+
{ stripePublicKey: t.slice(0, 10) + "...", serverUrl: e }
|
|
2347
|
+
), s;
|
|
2348
|
+
const c = te.get(o);
|
|
2349
|
+
if (c)
|
|
2350
|
+
return s = await c, s.refCount++, l().debug(
|
|
2351
|
+
`[ManagerCache] Reusing in-flight managers (refCount: ${s.refCount}):`,
|
|
2204
2352
|
{ stripePublicKey: t.slice(0, 10) + "...", serverUrl: e }
|
|
2205
|
-
),
|
|
2353
|
+
), s;
|
|
2206
2354
|
l().debug(
|
|
2207
2355
|
"[ManagerCache] Creating new manager instances:",
|
|
2208
2356
|
{ stripePublicKey: t.slice(0, 10) + "...", serverUrl: e }
|
|
2209
2357
|
);
|
|
2210
|
-
const
|
|
2211
|
-
const
|
|
2358
|
+
const u = (async () => {
|
|
2359
|
+
const f = new Rt(e), h = new ht(t, f, i ?? !1), y = new Pt(f), d = await Mt(), m = new d(
|
|
2212
2360
|
r,
|
|
2213
2361
|
a,
|
|
2214
2362
|
n ?? !1
|
|
2215
|
-
),
|
|
2363
|
+
), A = new St(t, f), b = new Tt(f), x = new xt(f);
|
|
2216
2364
|
return {
|
|
2217
|
-
stripeManager:
|
|
2218
|
-
x402Manager:
|
|
2219
|
-
walletManager:
|
|
2220
|
-
subscriptionManager:
|
|
2221
|
-
subscriptionChangeManager:
|
|
2222
|
-
creditsManager:
|
|
2223
|
-
routeDiscovery:
|
|
2365
|
+
stripeManager: h,
|
|
2366
|
+
x402Manager: y,
|
|
2367
|
+
walletManager: m,
|
|
2368
|
+
subscriptionManager: A,
|
|
2369
|
+
subscriptionChangeManager: b,
|
|
2370
|
+
creditsManager: x,
|
|
2371
|
+
routeDiscovery: f,
|
|
2224
2372
|
refCount: 1
|
|
2225
2373
|
};
|
|
2226
2374
|
})();
|
|
2227
|
-
|
|
2375
|
+
te.set(o, u);
|
|
2228
2376
|
try {
|
|
2229
|
-
return
|
|
2377
|
+
return s = await u, X.set(o, s), s;
|
|
2230
2378
|
} finally {
|
|
2231
|
-
|
|
2379
|
+
te.delete(o);
|
|
2232
2380
|
}
|
|
2233
2381
|
}
|
|
2234
|
-
function
|
|
2235
|
-
const
|
|
2382
|
+
function we(t, e, r, a, n, i) {
|
|
2383
|
+
const o = qe(
|
|
2236
2384
|
t,
|
|
2237
2385
|
e,
|
|
2238
2386
|
r,
|
|
2239
2387
|
a,
|
|
2240
|
-
n
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2388
|
+
n,
|
|
2389
|
+
i
|
|
2390
|
+
), s = X.get(o);
|
|
2391
|
+
if (!s) {
|
|
2392
|
+
l().warn("[ManagerCache] Attempted to release non-existent managers:", { cacheKey: o });
|
|
2244
2393
|
return;
|
|
2245
2394
|
}
|
|
2246
|
-
|
|
2247
|
-
`[ManagerCache] Released manager reference (refCount: ${
|
|
2395
|
+
s.refCount--, l().debug(
|
|
2396
|
+
`[ManagerCache] Released manager reference (refCount: ${s.refCount}):`,
|
|
2248
2397
|
{ stripePublicKey: t.slice(0, 10) + "...", serverUrl: e }
|
|
2249
|
-
),
|
|
2398
|
+
), s.refCount <= 0 && (X.delete(o), l().debug("[ManagerCache] Removed managers from cache (refCount reached 0)"));
|
|
2250
2399
|
}
|
|
2251
|
-
const
|
|
2400
|
+
const Ot = "data:image/webp;base64,UklGRnIIAABXRUJQVlA4WAoAAAAYAAAAOwAAOwAAQUxQSK4BAAABkHPbtrE9+z73/RTbqWw7Lf+BbbNKbTudbZe2qy+VbVv3PmeHj05G6ohg4LaRounNMtN1voB42ABA5R7TNlx5+O7du9e3Tiwb0b4EgFyAOCQM1Z16+DWFUZC7m3uVB2zKQGBhe+77RGHonJffCL1zQuHDxQ1hrEmTatDjHIXOC2MgzpNf1tVJkWgsGhyihI7JIE74aUYp2ITFAoz9QO+ZAs7zanvkEilKbIkMJS5ANwoJmrCodYVOmBqh5zIEJjZc9xods4A4rrPGxGitrJSU71yNyH4Myl7JTEl+5zzYSH9nlkrxHBzxWUzLVEnhh+YI/gq3+UphpvA8m/s7/wg9M4bjFNg/0vplrxQ+rQEDg/xihmT23jxYJZ8UPq8OA5z77Wt405FDR4poSMjiAJhPRxUIu8D+UVonOhfNPEVHPM9juFacwo+1V6kJQ3Y9Sa8ljhPuUvRk4UdNWU9ST3b9n0W3iG5DumdS9y7o3kHVu6/75ii/dbpvrO7brvtPUf2X6f5DVf/dmpxBmauociRVbqbKCXW5qCoHVuXempxf1dZQtXFUbat/yKZTtSUBVlA4INwFAABwGgCdASo8ADwAPm0qj0WkIqEZ+zYAQAbEtgBOmZoZF+E8zGoP3X8VbcdLvma8t+jH0E+YB+ofSA8wH7VdQv0AP75/iOsG9ADy3/Y5/b/91fgI/Y7MOesb0e/q+TUR1vt7VO6mwG0imO70GM5/0P7BX6qelv7EP209lz9oDRea09ZR+SjhX7sBu/ZS7tG917rPgI3Q7XsB7luy2hAg/95C2Z1L362OH1oFziDY/K5gWoSytSAtiKvA/jW1MehBzdLzJfszPPBvGa15IYwIVRTjO2Hz5ZS9HjLMehwAAP64SgjD3qeg6NRe/Ok+iFhrG3pgglCfbam3yBaDUH36sUiQx0PB1ZZyOHq0ky+f97h6tJMvo0p9LkfXecWOFJ8J5G7yRPuL4tzGLT09QulTJw42xp2hd+lMgIa51XoHx/iftn8B2D3k92H5jOQr+uIXFHHK5FpcTG+qGEF+np0LiQa+vdW7/+ZzOLVRf7jR5X3ANPt93Ng92DW7NflVr6kMr88O/v2ZNb0vtgao2Am/R3CDKiNq89f86CT6r2L2g1oTui7H3E1yhSPQpEOz01I3fhfiMMv4weqKuoedxn/xLg5uzHa6Gte4C/dQYkG3ZFSy4CXQtRjftBrjX/Oj+HpSUPDsv0wPW+ml5NbBKDCj2f3SD8TVMf2ZfHrOkR602RVk2UmKC+H0Y9iK6k98vsgPINtz0II8X7Mj2nJkTC6IMLuQ8dNTUq9VXOnhXrdhNZoaH94ePo6baBl3hTGFAnD3/b+gR/vtbqV7wktuX6fpnjeTBe/Drp6z3neeANj/aX4CsU9w67nwYOjZhueCjxaDKUnNjLPjI1e0BoTbcOzOQ0wHJHZJ+Pt608StBu4HiJ8NjH46fnvXL3yiMoSvkAuwCE1AakA+eU1u3unyjl1/MnZQmbp8fzfsfrFesehLPcIkYdCiZ+52QbmINNTjEsvjuBuZRubBE+Laihppsxoo4efGIo0xkw0etu1+yzvkqp88w3pBq0mRl13gnnc+2zl6SmhwgmNFbz+F8qAqmdfJL8iaNSGEWlPlpczDDe62GBZMlBhQmq/XCn/1b+VazHvJXkoIFDF+wktMg+rKfLyfTlXdK0cs+Kn8h+rjMakkf3WLo1TftMLn+O+x/Gat+BGstJrM1xvCSSnHQY+NV4B4gRqyZ55gRNnqN/0lWrATOcHUaGXpkTIM/yxFjxcePcSFo+t2aJ5lShtVukETzRxaIXgRkpROeWQHWpTHOaexmXOzF0b833qJSoXMk2zB/uMrgDzKd7d3ohUz8Ra08WYKlAuMQD08bF4+jUepEspqPLoYLQ73TfmL+1LwKxyTV3gEu6WnxBPWPLnYIGYN9U47ZNlB+NgHgYtKTyii6060RAG+wN32WUVFxCZw0HMHnHFgwxD34L/anlpS7mOrjKgyuGYhFC7iHqTQHuoAO1ekBHV+rndnbETKfa1F7LxNLYq+dmJyytmQrJUCGjelorI1m/TMQNiFVrY4FCI1Gl2W1JsZsw9zA+Bh3JmjkC0H5/0JV6JotNMatJIZ4v5PqwJe3r8xd+FNS3ynccdu+xtVdc27qwVdoomciZD5oXYey9KAFSAKO594sBKZNWUJTLXnt0BJbdF8FkQYvg3DQajYY2p+ixd5Ag7o92gw0pVVDDOP+WQxiEmKqgWJyTBsnsBk2Bxi2Unsv8S/4PmE8Hy/vy+Mij+aTAKZvg716IHfHX0/JMeFfmAnsZ39Q0qkfdPtq6+CxbGZ7wKDsK/8l/MVGuyd6faJFt5wyoOXuNrr3JC9EoBmjcOzkVw/6RNP49poZ1xzsX3q7B4HGfI/XSfRQq3HeZ2j12d0E3gCAube4oExaT1sx/v8F+f61QOsGdSaqM2im6qOGkSRkrRQ7L8hvS8vEYJeVkAbFvX5ov7e/egYYNToMHj651c5/rCVYtB9Ned6GvGN8R0x3t7+lsf8+ofhHRzpyvwxd6c5pREZVOKnXzplhJ61mki4JmAAAABFWElGugAAAEV4aWYAAElJKgAIAAAABgASAQMAAQAAAAEAAAAaAQUAAQAAAFYAAAAbAQUAAQAAAF4AAAAoAQMAAQAAAAIAAAATAgMAAQAAAAEAAABphwQAAQAAAGYAAAAAAAAASAAAAAEAAABIAAAAAQAAAAYAAJAHAAQAAAAwMjEwAZEHAAQAAAABAgMAAKAHAAQAAAAwMTAwAaADAAEAAAD//wAAAqAEAAEAAAA8AAAAA6AEAAEAAAA8AAAAAAAAAA==", It = "data:image/svg+xml,%3csvg%20width='868'%20height='868'%20viewBox='0%200%20868%20868'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3ccircle%20cx='434'%20cy='434'%20r='434'%20fill='%231B262D'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M234.563%20184H640.697C650.387%20184%20659.339%20189.164%20664.172%20197.542L782.495%20402.657C788.631%20413.294%20786.808%20426.72%20778.056%20435.346L452.368%20756.327C441.818%20766.724%20424.846%20766.724%20414.296%20756.327L89.0484%20435.78C80.0927%20426.954%2078.4157%20413.136%2085.0013%20402.433L211.48%20196.884C216.405%20188.879%20225.146%20184%20234.563%20184ZM588.257%20275.577V333.129H472.567V373.032C553.82%20377.296%20614.782%20394.81%20615.234%20415.802L615.231%20459.563C614.779%20480.556%20553.82%20498.069%20472.567%20502.333V600.259H395.746V502.333C314.492%20498.069%20253.531%20480.555%20253.078%20459.563L253.081%20415.802C253.533%20394.81%20314.492%20377.296%20395.746%20373.032V333.129H280.055V275.577H588.257ZM434.156%20472.268C520.868%20472.268%20593.345%20457.459%20611.082%20437.683C596.041%20420.912%20541.636%20407.713%20472.567%20404.089V445.867C460.187%20446.516%20447.336%20446.858%20434.156%20446.858C420.976%20446.858%20408.125%20446.516%20395.746%20445.867V404.089C326.676%20407.713%20272.271%20420.912%20257.23%20437.683C274.968%20457.459%20347.444%20472.268%20434.156%20472.268Z'%20fill='%23009393'/%3e%3c/svg%3e", Bt = "data:image/webp;base64,UklGRqwEAABXRUJQVlA4WAoAAAAYAAAAOwAAOwAAQUxQSL8BAAABkGvbtmlLc5997yvbmW19gBnbDm2kjF5UmW3bthXZVZFdZ+81r+87Z1XlEaHIbSNlMstwos4XUBSTLAFQo/u01Zdf/yLDDze3zB/YwADJEoOoJAKg7oTdH4SF+XxiZlMgSESzwAJdVn2iUJzzOUMiLhQKf+/va2FtBLMBuu1zpHcsincUXhtoTKLsCTVX/KF3wrLhPLm/OWzZtjQWfZ7RhYyAC/lxMowpSzJYJAyFkZDQc21FBMUT7BqGjpHxf3m+XlEPUHE/f3vGgPzmw4awRUaTexkyJhwfNShctVgZXyJDXq4CUyjNy6Y4fVOBIkAPR2GcOE7Jm2NQ/RE9YzXht3a5VYvlOX0xF0fy+tp/ozBuQg6DzZYb6Bi7ed4rB5Mp/1Co4cNhLUo1StLxDIDqrynUoRswiF6nFnIxsDpnZ5WBW0GFZ1qZ8HfLDk5txHHsGDpSa6B0cXZEa+DsTr1M+P4qPdXwjynU4+1/a7oN3Sm6G+meSd27oHsHde++7puj+tYpv7G6b7vun6L7l6n+oZp/t7JmUNUqqhpJV5upakJVLaqqgVW1t6rmV401NGMc1djqH4rpIseSfyPFkgAAVlA4IAQCAABQDACdASo8ADwAPm0yk0akIyGhJgzogA2JaQAThroHvLxu+aPf5G2BYxv+B6XHzx6GPon/o+qz/tOAA/TM82gR0vnExWoiQRM36jlg2UIvwCSqySErzuguz9EP2x/7hsNazr91aIworWI7AAD+/TZ+6Ipl444OdT+2wU0Ov+T8oJuVP/vUbT/w1Jsv6Awnl6rvF/xetfOPt3gTQZZi0Y/AOx563J7CJkqTR/fc/n34zyeKzR80fhfv4ef+Hjhz/CX5aQo+58zg/FdE+7bLoophGfG0szI513EH+q+Gc73H1PFdJYf7CF8v5dhr3tMwEVX5Ji2ZxejK8xrf/E6nVXqlA4DrYNRP09InHc+fEqO/fH8xr+rMf4y1F9TOnwVffZblLoTP6lot0m/sh7sTiDQr0mIA8TiHoOffGDG6KzV+B3239udfhzD740gkRi/m53abX0Ku3vAgadgFFqL0vk8M/4aI+cI+0fbLW17mWGeMu21wSRRQiv5iNgGKR3vEGXAItcLDft1uUzWAfbe1X3zK/ymT7bA/76PB6UUknm+Y5MM4osurUXU/k7P38pN/3slnGfpFzjl4c3USY4mH9ZCJYUuC/kGEnq/yRPalPdODNFvW6s8MiQeQejYNRY0LsJ0WXkK8vXiDmihCivYAOPoSovesL7on+WAArDNM/BcQSQvCYABFWElGugAAAEV4aWYAAElJKgAIAAAABgASAQMAAQAAAAEAAAAaAQUAAQAAAFYAAAAbAQUAAQAAAF4AAAAoAQMAAQAAAAIAAAATAgMAAQAAAAEAAABphwQAAQAAAGYAAAAAAAAASAAAAAEAAABIAAAAAQAAAAYAAJAHAAQAAAAwMjEwAZEHAAQAAAABAgMAAKAHAAQAAAAwMTAwAaADAAEAAAD//wAAAqAEAAEAAAA8AAAAA6AEAAEAAAA8AAAAAAAAAA==", _t = "data:image/webp;base64,UklGRtgCAABXRUJQVlA4WAoAAAAIAAAAOwAAOwAAVlA4IPgBAABQCwCdASo8ADwAPm0wk0ekIqGhKBQMqIANiWkADPF3uV2D8VcQGk1mg+P36i9SLnZvYAQxszEWYzEwX1RVkqG/4BGbJgMSHqhKDFsjWsGfPPrvfef11goNmCDDlBJHVVD+8gAA/vu4q03kl+E7FpjtZ2gc8pQ619Hjv9NywoRZ6az43C1wcrRr/lWzJlJhLWMHN0MkVl1ueAf6Hn8StVzeUfMBXOKkgfe2msx7QWR5PnHW/5c6/35yrtWnrURc2q6UYlGin+v8C2dQqexkW6rX2EEijTI9eEQ46PWH3/59fM2AlMvvR2abaRk5XX7V1triQncRxvMfz5YmYDN+PY/ikcZUNaiFucKoUq5riv0eKCezuFNHecE11ojwJqWRSTWpalkz5autXp6vFS+FT1tWUsB/fs1CCOZxaA1vR1grOEaiuKe1RYm7e05psWtqbXLVmm1bA8Ly9PFkVdCbc6hR3UuBBsFGnVeGOUeMn2onnfvYhBMcM9YPxGdQkwZLXOk1VuQSTk01Shf3fZrFyRlFauftFdPYhKXwqrr+meav1P+KLKBVosqmHnFFfgExsQ/rOf3TSd+mOqQfJA+cF+HojNU7nmM3uDkoCBi+//Gqp+gPNNW8M4LFrol8rxE+7WsjqMgfwv1f+Nr25RtG1Wa/KkniRCAAAABFWElGugAAAEV4aWYAAElJKgAIAAAABgASAQMAAQAAAAEAAAAaAQUAAQAAAFYAAAAbAQUAAQAAAF4AAAAoAQMAAQAAAAIAAAATAgMAAQAAAAEAAABphwQAAQAAAGYAAAAAAAAASAAAAAEAAABIAAAAAQAAAAYAAJAHAAQAAAAwMjEwAZEHAAQAAAABAgMAAKAHAAQAAAAwMTAwAaADAAEAAAD//wAAAqAEAAEAAAA8AAAAA6AEAAEAAAA8AAAAAAAAAA==", Nt = {
|
|
2252
2401
|
EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v: {
|
|
2253
2402
|
symbol: "USDC",
|
|
2254
2403
|
decimals: 6,
|
|
2255
|
-
icon:
|
|
2404
|
+
icon: Ot
|
|
2256
2405
|
},
|
|
2257
2406
|
Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB: {
|
|
2258
2407
|
symbol: "USDT",
|
|
2259
2408
|
decimals: 6,
|
|
2260
|
-
icon:
|
|
2409
|
+
icon: It
|
|
2261
2410
|
},
|
|
2262
2411
|
"2b1kV6DkPAnxd5ixfnxCpjxmKwqjjaYmCZfHsFu24GXo": {
|
|
2263
2412
|
symbol: "PYUSD",
|
|
2264
2413
|
decimals: 6,
|
|
2265
|
-
icon:
|
|
2414
|
+
icon: Bt
|
|
2266
2415
|
},
|
|
2267
2416
|
CASHx9KJUStyftLFWGvEVf59SGeG9sh5FfcnZMVPCASH: {
|
|
2268
2417
|
symbol: "CASH",
|
|
2269
2418
|
decimals: 6,
|
|
2270
|
-
icon:
|
|
2419
|
+
icon: _t
|
|
2271
2420
|
}
|
|
2272
|
-
},
|
|
2273
|
-
Object.entries(
|
|
2421
|
+
}, oe = Object.fromEntries(
|
|
2422
|
+
Object.entries(Nt).map(([t, e]) => [t, e.symbol])
|
|
2274
2423
|
);
|
|
2275
|
-
function
|
|
2276
|
-
return t in
|
|
2424
|
+
function Ft(t) {
|
|
2425
|
+
return t in oe;
|
|
2277
2426
|
}
|
|
2278
|
-
function
|
|
2427
|
+
function je(t, e = "token mint", r = !1) {
|
|
2279
2428
|
if (!t || t.trim().length === 0)
|
|
2280
2429
|
return {
|
|
2281
2430
|
isValid: !0,
|
|
2282
2431
|
isKnownStablecoin: !1
|
|
2283
2432
|
};
|
|
2284
2433
|
const a = t.trim();
|
|
2285
|
-
if (
|
|
2434
|
+
if (Ft(a))
|
|
2286
2435
|
return {
|
|
2287
2436
|
isValid: !0,
|
|
2288
2437
|
isKnownStablecoin: !0,
|
|
2289
|
-
symbol:
|
|
2438
|
+
symbol: oe[a]
|
|
2290
2439
|
};
|
|
2291
|
-
const n = Object.entries(
|
|
2440
|
+
const n = Object.entries(oe).map(([i, o]) => ` ${o}: ${i}`).join(`
|
|
2292
2441
|
`);
|
|
2293
2442
|
return r ? {
|
|
2294
2443
|
isValid: !0,
|
|
@@ -2337,18 +2486,18 @@ function Fe(t, e = "token mint", r = !1) {
|
|
|
2337
2486
|
`)
|
|
2338
2487
|
};
|
|
2339
2488
|
}
|
|
2340
|
-
function
|
|
2341
|
-
return
|
|
2489
|
+
function $t(t, e = "unknown", r = !1) {
|
|
2490
|
+
return je(t, `X402Requirement (resource: ${e})`, r);
|
|
2342
2491
|
}
|
|
2343
|
-
const
|
|
2344
|
-
function
|
|
2492
|
+
const be = /* @__PURE__ */ new Set(["mainnet-beta", "devnet", "testnet"]);
|
|
2493
|
+
function Ut() {
|
|
2345
2494
|
if (typeof window < "u" && window.location)
|
|
2346
2495
|
return window.location.origin;
|
|
2347
2496
|
throw new Error(
|
|
2348
2497
|
"serverUrl is required in SSR/Node environments. In browser environments, it defaults to window.location.origin"
|
|
2349
2498
|
);
|
|
2350
2499
|
}
|
|
2351
|
-
function
|
|
2500
|
+
function Ht(t) {
|
|
2352
2501
|
const e = [];
|
|
2353
2502
|
if (t.showCard !== !1) {
|
|
2354
2503
|
const n = t.stripePublicKey;
|
|
@@ -2368,16 +2517,16 @@ function Bt(t) {
|
|
|
2368
2517
|
}), a = t.serverUrl);
|
|
2369
2518
|
else
|
|
2370
2519
|
try {
|
|
2371
|
-
a =
|
|
2520
|
+
a = Ut();
|
|
2372
2521
|
} catch (n) {
|
|
2373
2522
|
e.push({
|
|
2374
2523
|
field: "serverUrl",
|
|
2375
2524
|
message: n instanceof Error ? n.message : "failed to determine default"
|
|
2376
2525
|
}), a = "";
|
|
2377
2526
|
}
|
|
2378
|
-
if (
|
|
2527
|
+
if (be.has(t.solanaCluster) || e.push({
|
|
2379
2528
|
field: "solanaCluster",
|
|
2380
|
-
message: `must be one of ${Array.from(
|
|
2529
|
+
message: `must be one of ${Array.from(be).join(", ")}`
|
|
2381
2530
|
}), t.solanaEndpoint !== void 0 && (typeof t.solanaEndpoint != "string" ? e.push({
|
|
2382
2531
|
field: "solanaEndpoint",
|
|
2383
2532
|
message: "must be a string when provided"
|
|
@@ -2397,7 +2546,7 @@ function Bt(t) {
|
|
|
2397
2546
|
${n}`);
|
|
2398
2547
|
}
|
|
2399
2548
|
if (t.tokenMint) {
|
|
2400
|
-
const n = t.dangerouslyAllowUnknownMint === !0, i =
|
|
2549
|
+
const n = t.dangerouslyAllowUnknownMint === !0, i = je(t.tokenMint, "CedrosConfig.tokenMint", n);
|
|
2401
2550
|
if (!i.isValid && i.error)
|
|
2402
2551
|
throw new Error(i.error);
|
|
2403
2552
|
i.warning && l().warn(i.warning);
|
|
@@ -2407,7 +2556,7 @@ ${n}`);
|
|
|
2407
2556
|
serverUrl: a
|
|
2408
2557
|
};
|
|
2409
2558
|
}
|
|
2410
|
-
const
|
|
2559
|
+
const Lt = Object.freeze({
|
|
2411
2560
|
surfaceBackground: "rgba(255, 255, 255, 0)",
|
|
2412
2561
|
surfaceText: "#111827",
|
|
2413
2562
|
surfaceBorder: "rgba(15, 23, 42, 0.08)",
|
|
@@ -2430,7 +2579,7 @@ const _t = Object.freeze({
|
|
|
2430
2579
|
buttonPadding: "0.75rem 1.5rem",
|
|
2431
2580
|
buttonFontSize: "1rem",
|
|
2432
2581
|
buttonFontWeight: "600"
|
|
2433
|
-
}),
|
|
2582
|
+
}), qt = Object.freeze({
|
|
2434
2583
|
surfaceBackground: "rgba(17, 24, 39, 0.6)",
|
|
2435
2584
|
surfaceText: "#f9fafb",
|
|
2436
2585
|
surfaceBorder: "rgba(148, 163, 184, 0.25)",
|
|
@@ -2453,7 +2602,7 @@ const _t = Object.freeze({
|
|
|
2453
2602
|
buttonPadding: "0.75rem 1.5rem",
|
|
2454
2603
|
buttonFontSize: "1rem",
|
|
2455
2604
|
buttonFontWeight: "600"
|
|
2456
|
-
}),
|
|
2605
|
+
}), jt = {
|
|
2457
2606
|
surfaceBackground: "--cedros-surface-bg",
|
|
2458
2607
|
surfaceText: "--cedros-surface-text",
|
|
2459
2608
|
surfaceBorder: "--cedros-surface-border",
|
|
@@ -2476,175 +2625,177 @@ const _t = Object.freeze({
|
|
|
2476
2625
|
buttonPadding: "--cedros-button-padding",
|
|
2477
2626
|
buttonFontSize: "--cedros-button-font-size",
|
|
2478
2627
|
buttonFontWeight: "--cedros-button-font-weight"
|
|
2479
|
-
},
|
|
2480
|
-
function
|
|
2628
|
+
}, ue = Ee(null);
|
|
2629
|
+
function zt(t, e) {
|
|
2481
2630
|
return {
|
|
2482
|
-
...t === "dark" ?
|
|
2631
|
+
...t === "dark" ? qt : Lt,
|
|
2483
2632
|
...e
|
|
2484
2633
|
};
|
|
2485
2634
|
}
|
|
2486
|
-
function
|
|
2635
|
+
function Qt(t) {
|
|
2487
2636
|
const e = Object.entries(t).map(([r, a]) => [
|
|
2488
|
-
|
|
2637
|
+
jt[r],
|
|
2489
2638
|
a
|
|
2490
2639
|
]);
|
|
2491
2640
|
return Object.fromEntries(e);
|
|
2492
2641
|
}
|
|
2493
|
-
function
|
|
2642
|
+
function Wt({
|
|
2494
2643
|
initialMode: t = "light",
|
|
2495
2644
|
overrides: e,
|
|
2496
2645
|
unstyled: r = !1,
|
|
2497
2646
|
children: a
|
|
2498
2647
|
}) {
|
|
2499
|
-
const [n, i] =
|
|
2500
|
-
|
|
2648
|
+
const [n, i] = U(t), [o, s] = U(e), c = ve(e);
|
|
2649
|
+
F(() => {
|
|
2501
2650
|
if (e === c.current)
|
|
2502
2651
|
return;
|
|
2503
2652
|
(!e || !c.current ? e !== c.current : Object.keys({ ...e, ...c.current }).some(
|
|
2504
|
-
(
|
|
2653
|
+
(h) => e[h] !== c.current?.[h]
|
|
2505
2654
|
)) && (c.current = e, s(e));
|
|
2506
2655
|
}, [e]);
|
|
2507
|
-
const
|
|
2508
|
-
const
|
|
2656
|
+
const u = ae(() => {
|
|
2657
|
+
const f = zt(n, o), h = r ? {} : Qt(f), y = r ? "" : `cedros-theme-root cedros-theme cedros-theme--${n}`;
|
|
2509
2658
|
return {
|
|
2510
2659
|
mode: n,
|
|
2511
2660
|
setMode: i,
|
|
2512
|
-
tokens:
|
|
2661
|
+
tokens: f,
|
|
2513
2662
|
className: y,
|
|
2514
|
-
style:
|
|
2663
|
+
style: h,
|
|
2515
2664
|
unstyled: r
|
|
2516
2665
|
};
|
|
2517
2666
|
}, [n, o, r]);
|
|
2518
|
-
return /* @__PURE__ */
|
|
2667
|
+
return /* @__PURE__ */ J(ue.Provider, { value: u, children: a });
|
|
2519
2668
|
}
|
|
2520
|
-
function
|
|
2521
|
-
const t =
|
|
2669
|
+
function Xt() {
|
|
2670
|
+
const t = se(ue);
|
|
2522
2671
|
if (!t)
|
|
2523
2672
|
throw new Error("useCedrosTheme must be used within CedrosProvider");
|
|
2524
2673
|
return t;
|
|
2525
2674
|
}
|
|
2526
|
-
function
|
|
2527
|
-
return
|
|
2675
|
+
function Zt() {
|
|
2676
|
+
return se(ue);
|
|
2528
2677
|
}
|
|
2529
|
-
const
|
|
2678
|
+
const re = {
|
|
2530
2679
|
getAdapters: () => [],
|
|
2531
2680
|
cleanup: async () => {
|
|
2532
2681
|
},
|
|
2533
2682
|
isInitialized: () => !1,
|
|
2534
2683
|
getId: () => "stub"
|
|
2535
2684
|
};
|
|
2536
|
-
function
|
|
2685
|
+
function Kt() {
|
|
2537
2686
|
return typeof process < "u" && process.env.NODE_ENV === "development" ? 0 : 2;
|
|
2538
2687
|
}
|
|
2539
|
-
const
|
|
2540
|
-
function
|
|
2541
|
-
const r =
|
|
2542
|
-
|
|
2543
|
-
let
|
|
2544
|
-
return import("./walletPool-
|
|
2545
|
-
if (
|
|
2546
|
-
const
|
|
2547
|
-
s.current =
|
|
2548
|
-
}).catch((
|
|
2549
|
-
|
|
2688
|
+
const ze = Ee(null);
|
|
2689
|
+
function er({ config: t, children: e }) {
|
|
2690
|
+
const r = ae(() => Ht(t), [t]), [a, n] = U(null), [i, o] = U(re), s = ve(re);
|
|
2691
|
+
F(() => {
|
|
2692
|
+
let d = !1;
|
|
2693
|
+
return import("./walletPool-DE-t1wSW.mjs").then(({ createWalletPool: m }) => {
|
|
2694
|
+
if (d) return;
|
|
2695
|
+
const A = m();
|
|
2696
|
+
s.current = A, o(A);
|
|
2697
|
+
}).catch((m) => {
|
|
2698
|
+
d || (l().error("[CedrosProvider] Wallet pool initialization failed:", m), n("Failed to initialize Cedros provider"));
|
|
2550
2699
|
}), () => {
|
|
2551
|
-
|
|
2700
|
+
d = !0;
|
|
2552
2701
|
};
|
|
2553
2702
|
}, []);
|
|
2554
|
-
const [c,
|
|
2555
|
-
|
|
2556
|
-
let
|
|
2703
|
+
const [c, u] = U(null);
|
|
2704
|
+
F(() => {
|
|
2705
|
+
let d = !1;
|
|
2557
2706
|
return import("./solanaCheck-IlYsbXDd.mjs").then(
|
|
2558
|
-
({ checkSolanaAvailability:
|
|
2559
|
-
).then((
|
|
2560
|
-
|
|
2561
|
-
}).catch((
|
|
2562
|
-
|
|
2707
|
+
({ checkSolanaAvailability: m }) => m()
|
|
2708
|
+
).then((m) => {
|
|
2709
|
+
d || (m.available ? u(void 0) : u(m.error || "Solana dependencies not available"));
|
|
2710
|
+
}).catch((m) => {
|
|
2711
|
+
d || (l().warn("[CedrosProvider] Solana availability check failed:", m), u("Unable to verify Solana availability"));
|
|
2563
2712
|
}), () => {
|
|
2564
|
-
|
|
2713
|
+
d = !0;
|
|
2565
2714
|
};
|
|
2566
|
-
}, []),
|
|
2567
|
-
const
|
|
2568
|
-
level:
|
|
2715
|
+
}, []), F(() => {
|
|
2716
|
+
const d = r.logLevel ?? Kt(), m = et({
|
|
2717
|
+
level: d,
|
|
2569
2718
|
prefix: "[CedrosPay]"
|
|
2570
2719
|
});
|
|
2571
|
-
|
|
2572
|
-
}, [r.logLevel]),
|
|
2573
|
-
const
|
|
2574
|
-
|
|
2575
|
-
l().warn("[CedrosProvider] Wallet pool cleanup failed:",
|
|
2720
|
+
Ze(m);
|
|
2721
|
+
}, [r.logLevel]), F(() => () => {
|
|
2722
|
+
const d = s.current;
|
|
2723
|
+
d && d !== re && d.cleanup().catch((m) => {
|
|
2724
|
+
l().warn("[CedrosProvider] Wallet pool cleanup failed:", m);
|
|
2576
2725
|
});
|
|
2577
2726
|
}, []);
|
|
2578
|
-
const [
|
|
2579
|
-
|
|
2580
|
-
let
|
|
2581
|
-
const
|
|
2582
|
-
return
|
|
2583
|
-
if (
|
|
2584
|
-
|
|
2727
|
+
const [f, h] = U(null);
|
|
2728
|
+
F(() => {
|
|
2729
|
+
let d = !1, m = !1;
|
|
2730
|
+
const A = r.stripePublicKey ?? "", b = r.serverUrl ?? "", x = r.solanaCluster, D = r.solanaEndpoint, M = r.dangerouslyAllowUnknownMint, S = r.complianceCheck;
|
|
2731
|
+
return Dt(A, b, x, D, M, S).then((_) => {
|
|
2732
|
+
if (d) {
|
|
2733
|
+
we(A, b, x, D, M, S);
|
|
2585
2734
|
return;
|
|
2586
2735
|
}
|
|
2587
|
-
|
|
2588
|
-
}).catch((
|
|
2589
|
-
|
|
2736
|
+
m = !0, h(_);
|
|
2737
|
+
}).catch((_) => {
|
|
2738
|
+
d || (l().error("[CedrosProvider] Manager initialization failed:", _), n("Failed to initialize Cedros provider"));
|
|
2590
2739
|
}), () => {
|
|
2591
|
-
|
|
2740
|
+
d = !0, m && we(A, b, x, D, M, S);
|
|
2592
2741
|
};
|
|
2593
2742
|
}, [
|
|
2594
2743
|
r.stripePublicKey,
|
|
2595
2744
|
r.serverUrl,
|
|
2596
2745
|
r.solanaCluster,
|
|
2597
2746
|
r.solanaEndpoint,
|
|
2598
|
-
r.dangerouslyAllowUnknownMint
|
|
2747
|
+
r.dangerouslyAllowUnknownMint,
|
|
2748
|
+
r.complianceCheck
|
|
2599
2749
|
]);
|
|
2600
|
-
const y =
|
|
2750
|
+
const y = ae(() => f ? {
|
|
2601
2751
|
config: r,
|
|
2602
|
-
...
|
|
2752
|
+
...f,
|
|
2603
2753
|
walletPool: i,
|
|
2604
2754
|
solanaError: c
|
|
2605
|
-
} : null, [r,
|
|
2606
|
-
return a ? /* @__PURE__ */
|
|
2607
|
-
|
|
2755
|
+
} : null, [r, f, i, c]);
|
|
2756
|
+
return a ? /* @__PURE__ */ J("div", { role: "alert", children: a }) : /* @__PURE__ */ J(
|
|
2757
|
+
Wt,
|
|
2608
2758
|
{
|
|
2609
2759
|
initialMode: r.theme ?? "light",
|
|
2610
2760
|
overrides: r.themeOverrides,
|
|
2611
2761
|
unstyled: r.unstyled ?? !1,
|
|
2612
|
-
children: y ? /* @__PURE__ */
|
|
2762
|
+
children: y ? /* @__PURE__ */ J(ze.Provider, { value: y, children: e }) : null
|
|
2613
2763
|
}
|
|
2614
2764
|
);
|
|
2615
2765
|
}
|
|
2616
|
-
function
|
|
2617
|
-
const t =
|
|
2766
|
+
function tr() {
|
|
2767
|
+
const t = se(ze);
|
|
2618
2768
|
if (!t)
|
|
2619
2769
|
throw new Error("useCedrosContext must be used within CedrosProvider");
|
|
2620
2770
|
return t;
|
|
2621
2771
|
}
|
|
2622
2772
|
export {
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2773
|
+
Yt as C,
|
|
2774
|
+
ot as E,
|
|
2775
|
+
oe as K,
|
|
2776
|
+
$e as L,
|
|
2777
|
+
N as P,
|
|
2778
|
+
B as R,
|
|
2779
|
+
Nt as S,
|
|
2780
|
+
er as a,
|
|
2781
|
+
g as b,
|
|
2782
|
+
at as c,
|
|
2783
|
+
xe as d,
|
|
2784
|
+
v as e,
|
|
2785
|
+
Q as f,
|
|
2786
|
+
et as g,
|
|
2787
|
+
I as h,
|
|
2638
2788
|
l as i,
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2789
|
+
Xt as j,
|
|
2790
|
+
$t as k,
|
|
2791
|
+
ge as l,
|
|
2792
|
+
O as m,
|
|
2793
|
+
je as n,
|
|
2794
|
+
it as o,
|
|
2645
2795
|
p,
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2796
|
+
Zt as q,
|
|
2797
|
+
E as r,
|
|
2798
|
+
w as s,
|
|
2799
|
+
tr as u,
|
|
2800
|
+
Ht as v
|
|
2650
2801
|
};
|