@cedros/pay-react 1.0.5 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +190 -38
- package/dist/{CedrosContext-CFEXGwQg.mjs → CedrosContext-DUT3cLZg.mjs} +683 -372
- package/dist/CedrosContext-efFL4kQz.js +11 -0
- package/dist/admin/index.d.ts +9 -0
- package/dist/admin/index.d.ts.map +1 -0
- package/dist/admin/plugin.d.ts +9 -0
- package/dist/admin/plugin.d.ts.map +1 -0
- package/dist/admin/types.d.ts +115 -0
- package/dist/admin/types.d.ts.map +1 -0
- package/dist/components/CedrosPay.d.ts.map +1 -1
- package/dist/components/CreditsButton.d.ts +42 -0
- package/dist/components/CreditsButton.d.ts.map +1 -0
- package/dist/components/CreditsSubscribeButton.d.ts +55 -0
- package/dist/components/CreditsSubscribeButton.d.ts.map +1 -0
- package/dist/components/CryptoButton.d.ts.map +1 -1
- package/dist/components/CryptoSubscribeButton.d.ts.map +1 -1
- package/dist/components/PaymentModal.d.ts +8 -2
- package/dist/components/PaymentModal.d.ts.map +1 -1
- package/dist/components/PurchaseButton.d.ts +14 -3
- package/dist/components/PurchaseButton.d.ts.map +1 -1
- package/dist/components/SubscriptionManagementPanel.d.ts.map +1 -1
- package/dist/components/admin/AISettingsSection.d.ts +3 -0
- package/dist/components/admin/AISettingsSection.d.ts.map +1 -0
- package/dist/components/admin/AdminAuthManager.d.ts +95 -0
- package/dist/components/admin/AdminAuthManager.d.ts.map +1 -0
- package/dist/components/admin/CedrosPayAdminDashboard.d.ts +40 -0
- package/dist/components/admin/CedrosPayAdminDashboard.d.ts.map +1 -0
- package/dist/components/admin/ConfigEditor.d.ts +13 -0
- package/dist/components/admin/ConfigEditor.d.ts.map +1 -0
- package/dist/components/admin/CouponsSection.d.ts +3 -0
- package/dist/components/admin/CouponsSection.d.ts.map +1 -0
- package/dist/components/admin/Dropdown.d.ts +29 -0
- package/dist/components/admin/Dropdown.d.ts.map +1 -0
- package/dist/components/admin/FAQSection.d.ts +3 -0
- package/dist/components/admin/FAQSection.d.ts.map +1 -0
- package/dist/components/admin/MessagingSection.d.ts +10 -0
- package/dist/components/admin/MessagingSection.d.ts.map +1 -0
- package/dist/components/admin/OverviewSection.d.ts +3 -0
- package/dist/components/admin/OverviewSection.d.ts.map +1 -0
- package/dist/components/admin/PaymentSettingsSection.d.ts +3 -0
- package/dist/components/admin/PaymentSettingsSection.d.ts.map +1 -0
- package/dist/components/admin/ProductVariationsEditor.d.ts +14 -0
- package/dist/components/admin/ProductVariationsEditor.d.ts.map +1 -0
- package/dist/components/admin/ProductsSection.d.ts +3 -0
- package/dist/components/admin/ProductsSection.d.ts.map +1 -0
- package/dist/components/admin/RefundsSection.d.ts +3 -0
- package/dist/components/admin/RefundsSection.d.ts.map +1 -0
- package/dist/components/admin/SettingsSection.d.ts +10 -0
- package/dist/components/admin/SettingsSection.d.ts.map +1 -0
- package/dist/components/admin/SingleCategorySettings.d.ts +21 -0
- package/dist/components/admin/SingleCategorySettings.d.ts.map +1 -0
- package/dist/components/admin/StatsBar.d.ts +19 -0
- package/dist/components/admin/StatsBar.d.ts.map +1 -0
- package/dist/components/admin/StorefrontSection.d.ts +3 -0
- package/dist/components/admin/StorefrontSection.d.ts.map +1 -0
- package/dist/components/admin/SubscriptionsSection.d.ts +3 -0
- package/dist/components/admin/SubscriptionsSection.d.ts.map +1 -0
- package/dist/components/admin/TransactionsSection.d.ts +3 -0
- package/dist/components/admin/TransactionsSection.d.ts.map +1 -0
- package/dist/components/admin/VariantInventoryGrid.d.ts +19 -0
- package/dist/components/admin/VariantInventoryGrid.d.ts.map +1 -0
- package/dist/components/admin/VariationTypeEditor.d.ts +15 -0
- package/dist/components/admin/VariationTypeEditor.d.ts.map +1 -0
- package/dist/components/admin/configApi.d.ts +104 -0
- package/dist/components/admin/configApi.d.ts.map +1 -0
- package/dist/components/admin/icons.d.ts +50 -0
- package/dist/components/admin/icons.d.ts.map +1 -0
- package/dist/components/admin/index.d.ts +16 -0
- package/dist/components/admin/index.d.ts.map +1 -0
- package/dist/components/admin/sections-more.d.ts +12 -0
- package/dist/components/admin/sections-more.d.ts.map +1 -0
- package/dist/components/admin/sections.d.ts +12 -0
- package/dist/components/admin/sections.d.ts.map +1 -0
- package/dist/components/admin/types.d.ts +324 -0
- package/dist/components/admin/types.d.ts.map +1 -0
- package/dist/components/admin/useAdminAuth.d.ts +50 -0
- package/dist/components/admin/useAdminAuth.d.ts.map +1 -0
- package/dist/components/admin/useAutosave.d.ts +56 -0
- package/dist/components/admin/useAutosave.d.ts.map +1 -0
- package/dist/components/admin/useProductVariations.d.ts +56 -0
- package/dist/components/admin/useProductVariations.d.ts.map +1 -0
- package/dist/components/subscriptionPanelStyles.d.ts +2 -3
- package/dist/components/subscriptionPanelStyles.d.ts.map +1 -1
- package/dist/context/CedrosContext.d.ts +2 -0
- package/dist/context/CedrosContext.d.ts.map +1 -1
- package/dist/context/ThemeContext.d.ts +6 -0
- package/dist/context/ThemeContext.d.ts.map +1 -1
- package/dist/crypto-only.d.ts +1 -1
- package/dist/crypto-only.d.ts.map +1 -1
- package/dist/crypto-only.js +1 -1
- package/dist/crypto-only.mjs +16 -17
- package/dist/ecommerce/__tests__/cartCheckoutRequirements.test.d.ts +2 -0
- package/dist/ecommerce/__tests__/cartCheckoutRequirements.test.d.ts.map +1 -0
- package/dist/ecommerce/__tests__/cartProviderPersistence.test.d.ts +2 -0
- package/dist/ecommerce/__tests__/cartProviderPersistence.test.d.ts.map +1 -0
- package/dist/ecommerce/__tests__/cartReducer.test.d.ts +2 -0
- package/dist/ecommerce/__tests__/cartReducer.test.d.ts.map +1 -0
- package/dist/ecommerce/__tests__/cartServerMerge.test.d.ts +2 -0
- package/dist/ecommerce/__tests__/cartServerMerge.test.d.ts.map +1 -0
- package/dist/ecommerce/__tests__/checkoutPaymentMethods.test.d.ts +2 -0
- package/dist/ecommerce/__tests__/checkoutPaymentMethods.test.d.ts.map +1 -0
- package/dist/ecommerce/__tests__/checkoutReturn.test.d.ts +2 -0
- package/dist/ecommerce/__tests__/checkoutReturn.test.d.ts.map +1 -0
- package/dist/ecommerce/__tests__/checkoutSchema.test.d.ts +2 -0
- package/dist/ecommerce/__tests__/checkoutSchema.test.d.ts.map +1 -0
- package/dist/ecommerce/__tests__/mockAdapter.test.d.ts +2 -0
- package/dist/ecommerce/__tests__/mockAdapter.test.d.ts.map +1 -0
- package/dist/ecommerce/adapters/CommerceAdapter.d.ts +235 -0
- package/dist/ecommerce/adapters/CommerceAdapter.d.ts.map +1 -0
- package/dist/ecommerce/adapters/mock/mockAdapter.d.ts +3 -0
- package/dist/ecommerce/adapters/mock/mockAdapter.d.ts.map +1 -0
- package/dist/ecommerce/adapters/paywall/paywallAdapter.d.ts +6 -0
- package/dist/ecommerce/adapters/paywall/paywallAdapter.d.ts.map +1 -0
- package/dist/ecommerce/components/cart/CartLineItem.d.ts +12 -0
- package/dist/ecommerce/components/cart/CartLineItem.d.ts.map +1 -0
- package/dist/ecommerce/components/cart/CartPageContent.d.ts +6 -0
- package/dist/ecommerce/components/cart/CartPageContent.d.ts.map +1 -0
- package/dist/ecommerce/components/cart/CartPanel.d.ts +5 -0
- package/dist/ecommerce/components/cart/CartPanel.d.ts.map +1 -0
- package/dist/ecommerce/components/cart/CartSidebar.d.ts +11 -0
- package/dist/ecommerce/components/cart/CartSidebar.d.ts.map +1 -0
- package/dist/ecommerce/components/cart/CartSummary.d.ts +13 -0
- package/dist/ecommerce/components/cart/CartSummary.d.ts.map +1 -0
- package/dist/ecommerce/components/cart/PromoCodeInput.d.ts +6 -0
- package/dist/ecommerce/components/cart/PromoCodeInput.d.ts.map +1 -0
- package/dist/ecommerce/components/catalog/Breadcrumbs.d.ts +9 -0
- package/dist/ecommerce/components/catalog/Breadcrumbs.d.ts.map +1 -0
- package/dist/ecommerce/components/catalog/CategoryNav.d.ts +8 -0
- package/dist/ecommerce/components/catalog/CategoryNav.d.ts.map +1 -0
- package/dist/ecommerce/components/catalog/FilterPanel.d.ts +29 -0
- package/dist/ecommerce/components/catalog/FilterPanel.d.ts.map +1 -0
- package/dist/ecommerce/components/catalog/Price.d.ts +9 -0
- package/dist/ecommerce/components/catalog/Price.d.ts.map +1 -0
- package/dist/ecommerce/components/catalog/ProductCard.d.ts +14 -0
- package/dist/ecommerce/components/catalog/ProductCard.d.ts.map +1 -0
- package/dist/ecommerce/components/catalog/ProductGallery.d.ts +6 -0
- package/dist/ecommerce/components/catalog/ProductGallery.d.ts.map +1 -0
- package/dist/ecommerce/components/catalog/ProductGrid.d.ts +20 -0
- package/dist/ecommerce/components/catalog/ProductGrid.d.ts.map +1 -0
- package/dist/ecommerce/components/catalog/QuantitySelector.d.ts +8 -0
- package/dist/ecommerce/components/catalog/QuantitySelector.d.ts.map +1 -0
- package/dist/ecommerce/components/catalog/QuickViewDialog.d.ts +10 -0
- package/dist/ecommerce/components/catalog/QuickViewDialog.d.ts.map +1 -0
- package/dist/ecommerce/components/catalog/SearchInput.d.ts +7 -0
- package/dist/ecommerce/components/catalog/SearchInput.d.ts.map +1 -0
- package/dist/ecommerce/components/catalog/VariantSelector.d.ts +19 -0
- package/dist/ecommerce/components/catalog/VariantSelector.d.ts.map +1 -0
- package/dist/ecommerce/components/chat/ShopChatPanel.d.ts +4 -0
- package/dist/ecommerce/components/chat/ShopChatPanel.d.ts.map +1 -0
- package/dist/ecommerce/components/checkout/AddressForm.d.ts +9 -0
- package/dist/ecommerce/components/checkout/AddressForm.d.ts.map +1 -0
- package/dist/ecommerce/components/checkout/CheckoutCancelPage.d.ts +24 -0
- package/dist/ecommerce/components/checkout/CheckoutCancelPage.d.ts.map +1 -0
- package/dist/ecommerce/components/checkout/CheckoutForm.d.ts +4 -0
- package/dist/ecommerce/components/checkout/CheckoutForm.d.ts.map +1 -0
- package/dist/ecommerce/components/checkout/CheckoutLayout.d.ts +6 -0
- package/dist/ecommerce/components/checkout/CheckoutLayout.d.ts.map +1 -0
- package/dist/ecommerce/components/checkout/CheckoutReceipt.d.ts +8 -0
- package/dist/ecommerce/components/checkout/CheckoutReceipt.d.ts.map +1 -0
- package/dist/ecommerce/components/checkout/CheckoutSuccessPage.d.ts +29 -0
- package/dist/ecommerce/components/checkout/CheckoutSuccessPage.d.ts.map +1 -0
- package/dist/ecommerce/components/checkout/InventoryVerificationDialog.d.ts +19 -0
- package/dist/ecommerce/components/checkout/InventoryVerificationDialog.d.ts.map +1 -0
- package/dist/ecommerce/components/checkout/OrderReview.d.ts +4 -0
- package/dist/ecommerce/components/checkout/OrderReview.d.ts.map +1 -0
- package/dist/ecommerce/components/checkout/PaymentStep.d.ts +15 -0
- package/dist/ecommerce/components/checkout/PaymentStep.d.ts.map +1 -0
- package/dist/ecommerce/components/checkout/ShippingMethodSelector.d.ts +9 -0
- package/dist/ecommerce/components/checkout/ShippingMethodSelector.d.ts.map +1 -0
- package/dist/ecommerce/components/faq/FAQItem.d.ts +29 -0
- package/dist/ecommerce/components/faq/FAQItem.d.ts.map +1 -0
- package/dist/ecommerce/components/faq/FAQItem.test.d.ts +7 -0
- package/dist/ecommerce/components/faq/FAQItem.test.d.ts.map +1 -0
- package/dist/ecommerce/components/faq/FAQList.d.ts +15 -0
- package/dist/ecommerce/components/faq/FAQList.d.ts.map +1 -0
- package/dist/ecommerce/components/faq/index.d.ts +3 -0
- package/dist/ecommerce/components/faq/index.d.ts.map +1 -0
- package/dist/ecommerce/components/general/EmptyState.d.ts +8 -0
- package/dist/ecommerce/components/general/EmptyState.d.ts.map +1 -0
- package/dist/ecommerce/components/general/ErrorBoundary.d.ts +16 -0
- package/dist/ecommerce/components/general/ErrorBoundary.d.ts.map +1 -0
- package/dist/ecommerce/components/general/ErrorState.d.ts +7 -0
- package/dist/ecommerce/components/general/ErrorState.d.ts.map +1 -0
- package/dist/ecommerce/components/general/toast.d.ts +19 -0
- package/dist/ecommerce/components/general/toast.d.ts.map +1 -0
- package/dist/ecommerce/components/orders/OrderCard.d.ts +7 -0
- package/dist/ecommerce/components/orders/OrderCard.d.ts.map +1 -0
- package/dist/ecommerce/components/orders/OrderDetails.d.ts +7 -0
- package/dist/ecommerce/components/orders/OrderDetails.d.ts.map +1 -0
- package/dist/ecommerce/components/orders/OrderList.d.ts +7 -0
- package/dist/ecommerce/components/orders/OrderList.d.ts.map +1 -0
- package/dist/ecommerce/components/ui/accordion.d.ts +7 -0
- package/dist/ecommerce/components/ui/accordion.d.ts.map +1 -0
- package/dist/ecommerce/components/ui/badge.d.ts +10 -0
- package/dist/ecommerce/components/ui/badge.d.ts.map +1 -0
- package/dist/ecommerce/components/ui/button.d.ts +12 -0
- package/dist/ecommerce/components/ui/button.d.ts.map +1 -0
- package/dist/ecommerce/components/ui/card.d.ts +8 -0
- package/dist/ecommerce/components/ui/card.d.ts.map +1 -0
- package/dist/ecommerce/components/ui/dialog.d.ts +13 -0
- package/dist/ecommerce/components/ui/dialog.d.ts.map +1 -0
- package/dist/ecommerce/components/ui/input.d.ts +5 -0
- package/dist/ecommerce/components/ui/input.d.ts.map +1 -0
- package/dist/ecommerce/components/ui/label.d.ts +3 -0
- package/dist/ecommerce/components/ui/label.d.ts.map +1 -0
- package/dist/ecommerce/components/ui/select.d.ts +9 -0
- package/dist/ecommerce/components/ui/select.d.ts.map +1 -0
- package/dist/ecommerce/components/ui/separator.d.ts +4 -0
- package/dist/ecommerce/components/ui/separator.d.ts.map +1 -0
- package/dist/ecommerce/components/ui/sheet.d.ts +21 -0
- package/dist/ecommerce/components/ui/sheet.d.ts.map +1 -0
- package/dist/ecommerce/components/ui/skeleton.d.ts +3 -0
- package/dist/ecommerce/components/ui/skeleton.d.ts.map +1 -0
- package/dist/ecommerce/components/ui/tabs.d.ts +7 -0
- package/dist/ecommerce/components/ui/tabs.d.ts.map +1 -0
- package/dist/ecommerce/components/ui/textarea.d.ts +5 -0
- package/dist/ecommerce/components/ui/textarea.d.ts.map +1 -0
- package/dist/ecommerce/config/context.d.ts +13 -0
- package/dist/ecommerce/config/context.d.ts.map +1 -0
- package/dist/ecommerce/config/types.d.ts +48 -0
- package/dist/ecommerce/config/types.d.ts.map +1 -0
- package/dist/ecommerce/hooks/checkoutReturn.d.ts +3 -0
- package/dist/ecommerce/hooks/checkoutReturn.d.ts.map +1 -0
- package/dist/ecommerce/hooks/useAIRelatedProducts.d.ts +33 -0
- package/dist/ecommerce/hooks/useAIRelatedProducts.d.ts.map +1 -0
- package/dist/ecommerce/hooks/useCartInventory.d.ts +42 -0
- package/dist/ecommerce/hooks/useCartInventory.d.ts.map +1 -0
- package/dist/ecommerce/hooks/useCatalogUrlState.d.ts +15 -0
- package/dist/ecommerce/hooks/useCatalogUrlState.d.ts.map +1 -0
- package/dist/ecommerce/hooks/useCategories.d.ts +7 -0
- package/dist/ecommerce/hooks/useCategories.d.ts.map +1 -0
- package/dist/ecommerce/hooks/useCheckoutResultFromUrl.d.ts +4 -0
- package/dist/ecommerce/hooks/useCheckoutResultFromUrl.d.ts.map +1 -0
- package/dist/ecommerce/hooks/useHoldExpiry.d.ts +34 -0
- package/dist/ecommerce/hooks/useHoldExpiry.d.ts.map +1 -0
- package/dist/ecommerce/hooks/useInventoryVerification.d.ts +41 -0
- package/dist/ecommerce/hooks/useInventoryVerification.d.ts.map +1 -0
- package/dist/ecommerce/hooks/useOrders.d.ts +7 -0
- package/dist/ecommerce/hooks/useOrders.d.ts.map +1 -0
- package/dist/ecommerce/hooks/usePaymentMethodsConfig.d.ts +6 -0
- package/dist/ecommerce/hooks/usePaymentMethodsConfig.d.ts.map +1 -0
- package/dist/ecommerce/hooks/useProduct.d.ts +7 -0
- package/dist/ecommerce/hooks/useProduct.d.ts.map +1 -0
- package/dist/ecommerce/hooks/useProducts.d.ts +8 -0
- package/dist/ecommerce/hooks/useProducts.d.ts.map +1 -0
- package/dist/ecommerce/hooks/useShippingMethods.d.ts +10 -0
- package/dist/ecommerce/hooks/useShippingMethods.d.ts.map +1 -0
- package/dist/ecommerce/hooks/useStorefrontSettings.d.ts +32 -0
- package/dist/ecommerce/hooks/useStorefrontSettings.d.ts.map +1 -0
- package/dist/ecommerce/hooks/useSubscriptionData.d.ts +8 -0
- package/dist/ecommerce/hooks/useSubscriptionData.d.ts.map +1 -0
- package/dist/ecommerce/index.d.ts +98 -0
- package/dist/ecommerce/index.d.ts.map +1 -0
- package/dist/ecommerce/integrations/cedros-pay/useCedrosPayCheckoutAdapter.d.ts +10 -0
- package/dist/ecommerce/integrations/cedros-pay/useCedrosPayCheckoutAdapter.d.ts.map +1 -0
- package/dist/ecommerce/state/cart/CartProvider.d.ts +27 -0
- package/dist/ecommerce/state/cart/CartProvider.d.ts.map +1 -0
- package/dist/ecommerce/state/cart/cartReducer.d.ts +35 -0
- package/dist/ecommerce/state/cart/cartReducer.d.ts.map +1 -0
- package/dist/ecommerce/state/checkout/checkoutSchema.d.ts +21 -0
- package/dist/ecommerce/state/checkout/checkoutSchema.d.ts.map +1 -0
- package/dist/ecommerce/state/checkout/useCheckout.d.ts +34 -0
- package/dist/ecommerce/state/checkout/useCheckout.d.ts.map +1 -0
- package/dist/ecommerce/templates/CartTemplate.d.ts +5 -0
- package/dist/ecommerce/templates/CartTemplate.d.ts.map +1 -0
- package/dist/ecommerce/templates/CategoryTemplate.d.ts +11 -0
- package/dist/ecommerce/templates/CategoryTemplate.d.ts.map +1 -0
- package/dist/ecommerce/templates/CheckoutTemplate.d.ts +9 -0
- package/dist/ecommerce/templates/CheckoutTemplate.d.ts.map +1 -0
- package/dist/ecommerce/templates/ProductTemplate.d.ts +11 -0
- package/dist/ecommerce/templates/ProductTemplate.d.ts.map +1 -0
- package/dist/ecommerce/templates/PurchaseHistoryTemplate.d.ts +6 -0
- package/dist/ecommerce/templates/PurchaseHistoryTemplate.d.ts.map +1 -0
- package/dist/ecommerce/templates/ReceiptTemplate.d.ts +19 -0
- package/dist/ecommerce/templates/ReceiptTemplate.d.ts.map +1 -0
- package/dist/ecommerce/templates/ShopTemplate.d.ts +15 -0
- package/dist/ecommerce/templates/ShopTemplate.d.ts.map +1 -0
- package/dist/ecommerce/templates/SubscriptionTemplate.d.ts +15 -0
- package/dist/ecommerce/templates/SubscriptionTemplate.d.ts.map +1 -0
- package/dist/ecommerce/testing/adapterContract.d.ts +11 -0
- package/dist/ecommerce/testing/adapterContract.d.ts.map +1 -0
- package/dist/ecommerce/types.d.ts +164 -0
- package/dist/ecommerce/types.d.ts.map +1 -0
- package/dist/ecommerce/utils/cartCheckoutRequirements.d.ts +18 -0
- package/dist/ecommerce/utils/cartCheckoutRequirements.d.ts.map +1 -0
- package/dist/ecommerce/utils/cartItemMetadata.d.ts +3 -0
- package/dist/ecommerce/utils/cartItemMetadata.d.ts.map +1 -0
- package/dist/ecommerce/utils/cn.d.ts +3 -0
- package/dist/ecommerce/utils/cn.d.ts.map +1 -0
- package/dist/ecommerce/utils/money.d.ts +6 -0
- package/dist/ecommerce/utils/money.d.ts.map +1 -0
- package/dist/ecommerce/utils/storage.d.ts +5 -0
- package/dist/ecommerce/utils/storage.d.ts.map +1 -0
- package/dist/en-BXheDBal.mjs +19 -0
- package/dist/en-Yikrt96u.js +1 -0
- package/dist/hooks/useCreditsPayment.d.ts +64 -0
- package/dist/hooks/useCreditsPayment.d.ts.map +1 -0
- package/dist/hooks/useCreditsSubscription.d.ts +42 -0
- package/dist/hooks/useCreditsSubscription.d.ts.map +1 -0
- package/dist/hooks/usePaymentMode.d.ts.map +1 -1
- package/dist/hooks/useStripeCheckout.d.ts +1 -0
- package/dist/hooks/useStripeCheckout.d.ts.map +1 -1
- package/dist/hooks/useSubscriptionManagement.d.ts +4 -0
- package/dist/hooks/useSubscriptionManagement.d.ts.map +1 -1
- package/dist/hooks/useX402Payment.d.ts +1 -0
- package/dist/hooks/useX402Payment.d.ts.map +1 -1
- package/dist/index-DPl2S6i0.js +136 -0
- package/dist/index-SV9PXby1.mjs +26838 -0
- package/dist/index.d.ts +10 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +79 -1922
- package/dist/magic-string.es-B81Zo59j.js +10 -0
- package/dist/magic-string.es-uPKorP4O.mjs +663 -0
- package/dist/managers/CreditsManager.d.ts +151 -0
- package/dist/managers/CreditsManager.d.ts.map +1 -0
- package/dist/managers/ManagerCache.d.ts +2 -0
- package/dist/managers/ManagerCache.d.ts.map +1 -1
- package/dist/managers/RouteDiscoveryManager.d.ts.map +1 -1
- package/dist/managers/StripeManager.d.ts.map +1 -1
- package/dist/managers/X402Manager.d.ts.map +1 -1
- package/dist/pay-react.css +1 -1
- package/dist/sections-BsFQxfHN.mjs +10 -0
- package/dist/sections-CTqBNAKW.js +1 -0
- package/dist/stripe-only.d.ts +1 -1
- package/dist/stripe-only.d.ts.map +1 -1
- package/dist/stripe-only.js +1 -1
- package/dist/stripe-only.mjs +12 -13
- package/dist/styles-C4-_hbgr.js +1 -0
- package/dist/styles-QcAsIVWl.mjs +1909 -0
- package/dist/telemetry.js +1 -1
- package/dist/telemetry.mjs +1 -1
- package/dist/testing/index.js +147 -1
- package/dist/testing/index.mjs +10555 -103
- package/dist/types/componentOptions.d.ts +14 -4
- package/dist/types/componentOptions.d.ts.map +1 -1
- package/dist/types/errors.d.ts +26 -4
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/index.d.ts +115 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/cartHelpers.d.ts +3 -0
- package/dist/utils/cartHelpers.d.ts.map +1 -1
- package/dist/utils/cspHelper.d.ts +7 -1
- package/dist/utils/cspHelper.d.ts.map +1 -1
- package/dist/utils/csvHelpers.d.ts +62 -0
- package/dist/utils/csvHelpers.d.ts.map +1 -0
- package/dist/utils/csvHelpers.test.d.ts +2 -0
- package/dist/utils/csvHelpers.test.d.ts.map +1 -0
- package/dist/utils/dateHelpers.d.ts +24 -0
- package/dist/utils/dateHelpers.d.ts.map +1 -0
- package/dist/utils/eventEmitter.d.ts +1 -1
- package/dist/utils/eventEmitter.d.ts.map +1 -1
- package/dist/utils/fetchWithTimeout.d.ts +3 -3
- package/dist/utils/index.d.ts +2 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/tokenMintValidator.d.ts +10 -6
- package/dist/utils/tokenMintValidator.d.ts.map +1 -1
- package/dist/utils/uuid.d.ts.map +1 -1
- package/dist/uuid-C5B8o31X.js +1 -0
- package/dist/uuid-_z3jSatJ.mjs +17 -0
- package/package.json +25 -9
- package/dist/CedrosContext-DbndTsTA.js +0 -11
- package/dist/en-C739WV_-.mjs +0 -19
- package/dist/en-Cz4OpvN-.js +0 -1
- package/dist/styles-DFcRS8Uu.mjs +0 -1626
- package/dist/styles-Dup9uK6S.js +0 -1
- package/dist/utils/uuid-shim.d.ts +0 -9
- package/dist/utils/uuid-shim.d.ts.map +0 -1
- package/dist/uuid-C0iMjdcc.js +0 -1
- package/dist/uuid-UlzrVY8Y.mjs +0 -17
- package/dist/walletDetection-JZR3UCOa.mjs +0 -27
- package/dist/walletDetection-bNmV5ItZ.js +0 -1
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
import { jsx as X } from "react/jsx-runtime";
|
|
2
|
-
import { createContext as
|
|
3
|
-
import { g as
|
|
4
|
-
import { clusterApiUrl as je, Connection as
|
|
5
|
-
import { getAssociatedTokenAddress as
|
|
6
|
-
import { PhantomWalletAdapter as
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
for (var e = document.querySelectorAll('script[src^="'.concat(
|
|
2
|
+
import { createContext as ye, useContext as re, useState as Z, useRef as we, useEffect as L, useMemo as $ } from "react";
|
|
3
|
+
import { g as T } from "./uuid-_z3jSatJ.mjs";
|
|
4
|
+
import { clusterApiUrl as je, Connection as ze, Transaction as oe, PublicKey as N, LAMPORTS_PER_SOL as qe } from "@solana/web3.js";
|
|
5
|
+
import { getAssociatedTokenAddress as Qe, createTransferInstruction as We } from "@solana/spl-token";
|
|
6
|
+
import { PhantomWalletAdapter as He, SolflareWalletAdapter as Ve } from "@solana/wallet-adapter-wallets";
|
|
7
|
+
var me = "https://js.stripe.com/v3", Ge = /^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;
|
|
8
|
+
var Ke = function() {
|
|
9
|
+
for (var e = document.querySelectorAll('script[src^="'.concat(me, '"]')), t = 0; t < e.length; t++) {
|
|
10
10
|
var n = e[t];
|
|
11
|
-
if (
|
|
11
|
+
if (Ge.test(n.src))
|
|
12
12
|
return n;
|
|
13
13
|
}
|
|
14
14
|
return null;
|
|
15
|
-
},
|
|
15
|
+
}, se = function(e) {
|
|
16
16
|
var t = "", n = document.createElement("script");
|
|
17
|
-
n.src = "".concat(
|
|
17
|
+
n.src = "".concat(me).concat(t);
|
|
18
18
|
var a = document.head || document.body;
|
|
19
19
|
if (!a)
|
|
20
20
|
throw new Error("Expected document.body not to be null. Stripe.js requires a <body> element.");
|
|
21
21
|
return a.appendChild(n), n;
|
|
22
|
-
},
|
|
22
|
+
}, Je = function(e, t) {
|
|
23
23
|
!e || !e._registerWrapper || e._registerWrapper({
|
|
24
24
|
name: "stripe-js",
|
|
25
25
|
version: "4.6.0",
|
|
26
26
|
startTime: t
|
|
27
27
|
});
|
|
28
|
-
},
|
|
28
|
+
}, I = null, Q = null, W = null, Ye = function(e) {
|
|
29
29
|
return function() {
|
|
30
30
|
e(new Error("Failed to load Stripe.js"));
|
|
31
31
|
};
|
|
@@ -33,8 +33,8 @@ var Ge = function() {
|
|
|
33
33
|
return function() {
|
|
34
34
|
window.Stripe ? e(window.Stripe) : t(new Error("Stripe.js not available"));
|
|
35
35
|
};
|
|
36
|
-
},
|
|
37
|
-
return
|
|
36
|
+
}, Ze = function(e) {
|
|
37
|
+
return I !== null ? I : (I = new Promise(function(t, n) {
|
|
38
38
|
if (typeof window > "u" || typeof document > "u") {
|
|
39
39
|
t(null);
|
|
40
40
|
return;
|
|
@@ -44,32 +44,32 @@ var Ge = function() {
|
|
|
44
44
|
return;
|
|
45
45
|
}
|
|
46
46
|
try {
|
|
47
|
-
var a =
|
|
47
|
+
var a = Ke();
|
|
48
48
|
if (!(a && e)) {
|
|
49
49
|
if (!a)
|
|
50
|
-
a =
|
|
51
|
-
else if (a &&
|
|
50
|
+
a = se(e);
|
|
51
|
+
else if (a && W !== null && Q !== null) {
|
|
52
52
|
var i;
|
|
53
|
-
a.removeEventListener("load",
|
|
53
|
+
a.removeEventListener("load", W), a.removeEventListener("error", Q), (i = a.parentNode) === null || i === void 0 || i.removeChild(a), a = se(e);
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
|
-
|
|
56
|
+
W = Xe(t, n), Q = Ye(n), a.addEventListener("load", W), a.addEventListener("error", Q);
|
|
57
57
|
} catch (o) {
|
|
58
58
|
n(o);
|
|
59
59
|
return;
|
|
60
60
|
}
|
|
61
|
-
}),
|
|
62
|
-
return
|
|
61
|
+
}), I.catch(function(t) {
|
|
62
|
+
return I = null, Promise.reject(t);
|
|
63
63
|
}));
|
|
64
|
-
},
|
|
64
|
+
}, $e = function(e, t, n) {
|
|
65
65
|
if (e === null)
|
|
66
66
|
return null;
|
|
67
67
|
var a = e.apply(void 0, t);
|
|
68
|
-
return
|
|
69
|
-
},
|
|
70
|
-
return
|
|
71
|
-
return
|
|
72
|
-
}),
|
|
68
|
+
return Je(a, n), a;
|
|
69
|
+
}, F, ge = !1, be = function() {
|
|
70
|
+
return F || (F = Ze(null).catch(function(e) {
|
|
71
|
+
return F = null, Promise.reject(e);
|
|
72
|
+
}), F);
|
|
73
73
|
};
|
|
74
74
|
Promise.resolve().then(function() {
|
|
75
75
|
return be();
|
|
@@ -82,9 +82,9 @@ var ve = function() {
|
|
|
82
82
|
ge = !0;
|
|
83
83
|
var a = Date.now();
|
|
84
84
|
return be().then(function(i) {
|
|
85
|
-
return
|
|
85
|
+
return $e(i, t, a);
|
|
86
86
|
});
|
|
87
|
-
},
|
|
87
|
+
}, _e = /* @__PURE__ */ ((r) => (r[r.DEBUG = 0] = "DEBUG", r[r.INFO = 1] = "INFO", r[r.WARN = 2] = "WARN", r[r.ERROR = 3] = "ERROR", r[r.SILENT = 4] = "SILENT", r))(_e || {});
|
|
88
88
|
class Ee {
|
|
89
89
|
config;
|
|
90
90
|
constructor(e) {
|
|
@@ -139,20 +139,20 @@ class Ee {
|
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
const et = () => typeof process < "u" && process.env.NODE_ENV === "development" ? 0 : 2;
|
|
142
|
-
let
|
|
142
|
+
let V = null;
|
|
143
143
|
function c() {
|
|
144
|
-
return
|
|
144
|
+
return V || (V = new Ee({
|
|
145
145
|
level: et(),
|
|
146
146
|
prefix: "[CedrosPay]"
|
|
147
|
-
})),
|
|
147
|
+
})), V;
|
|
148
148
|
}
|
|
149
149
|
function tt(r) {
|
|
150
|
-
|
|
150
|
+
V = r;
|
|
151
151
|
}
|
|
152
152
|
function rt(r) {
|
|
153
153
|
return new Ee(r);
|
|
154
154
|
}
|
|
155
|
-
function
|
|
155
|
+
function k(r, e) {
|
|
156
156
|
return r instanceof Error ? r.message : typeof r == "string" ? r : e;
|
|
157
157
|
}
|
|
158
158
|
const nt = {
|
|
@@ -178,8 +178,8 @@ async function v(r, e, t = !1) {
|
|
|
178
178
|
return await r.text() || e;
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
|
-
const at =
|
|
182
|
-
async function
|
|
181
|
+
const at = 15e3;
|
|
182
|
+
async function y(r, e = {}, t = at) {
|
|
183
183
|
const n = new AbortController(), a = e.signal;
|
|
184
184
|
if (a?.aborted)
|
|
185
185
|
throw n.abort(), new DOMException("The operation was aborted", "AbortError");
|
|
@@ -204,8 +204,8 @@ function R(r) {
|
|
|
204
204
|
function o() {
|
|
205
205
|
const f = Date.now(), h = f - a;
|
|
206
206
|
if (h > 0) {
|
|
207
|
-
const
|
|
208
|
-
n = Math.min(e, n +
|
|
207
|
+
const A = h * i;
|
|
208
|
+
n = Math.min(e, n + A), a = f;
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
211
|
function s() {
|
|
@@ -230,7 +230,7 @@ function R(r) {
|
|
|
230
230
|
reset: d
|
|
231
231
|
};
|
|
232
232
|
}
|
|
233
|
-
const
|
|
233
|
+
const M = {
|
|
234
234
|
/** 10 requests per minute - recommended for payment requests */
|
|
235
235
|
PAYMENT: { maxRequests: 10, windowMs: 6e4 },
|
|
236
236
|
/** 30 requests per minute - for quote fetching */
|
|
@@ -241,12 +241,12 @@ const A = {
|
|
|
241
241
|
PERMISSIVE: { maxRequests: 100, windowMs: 6e4 }
|
|
242
242
|
};
|
|
243
243
|
var it = /* @__PURE__ */ ((r) => (r.CLOSED = "CLOSED", r.OPEN = "OPEN", r.HALF_OPEN = "HALF_OPEN", r))(it || {});
|
|
244
|
-
class
|
|
244
|
+
class m extends Error {
|
|
245
245
|
constructor(e) {
|
|
246
246
|
super(e), this.name = "CircuitBreakerOpenError";
|
|
247
247
|
}
|
|
248
248
|
}
|
|
249
|
-
function
|
|
249
|
+
function U(r) {
|
|
250
250
|
const { failureThreshold: e, timeout: t, name: n = "circuit-breaker" } = r;
|
|
251
251
|
let a = "CLOSED", i = 0, o = 0, s = 0, u = null, l = null, d = null;
|
|
252
252
|
function f() {
|
|
@@ -255,25 +255,25 @@ function $(r) {
|
|
|
255
255
|
function h() {
|
|
256
256
|
l = Date.now(), o++, a === "HALF_OPEN" ? (c().debug(`[CircuitBreaker:${n}] Success in HALF_OPEN → CLOSED`), a = "CLOSED", i = 0) : a === "CLOSED" && (i = 0);
|
|
257
257
|
}
|
|
258
|
-
function
|
|
258
|
+
function A(S) {
|
|
259
259
|
u = Date.now(), i++, c().warn(`[CircuitBreaker:${n}] Failure recorded (${i}/${e}):`, S.message), a === "HALF_OPEN" ? (c().warn(`[CircuitBreaker:${n}] Failed in HALF_OPEN → OPEN`), a = "OPEN", d = Date.now() + t) : a === "CLOSED" && i >= e && (c().error(`[CircuitBreaker:${n}] Failure threshold reached (${i}) → OPEN`), a = "OPEN", d = Date.now() + t);
|
|
260
260
|
}
|
|
261
261
|
async function p(S) {
|
|
262
262
|
if (f(), a === "OPEN") {
|
|
263
263
|
s++;
|
|
264
|
-
const
|
|
265
|
-
throw new
|
|
266
|
-
`Circuit breaker is OPEN. Service is unavailable. Retry in ${
|
|
264
|
+
const E = d ? Math.ceil((d - Date.now()) / 1e3) : 0;
|
|
265
|
+
throw new m(
|
|
266
|
+
`Circuit breaker is OPEN. Service is unavailable. Retry in ${E}s.`
|
|
267
267
|
);
|
|
268
268
|
}
|
|
269
269
|
try {
|
|
270
|
-
const
|
|
271
|
-
return h(),
|
|
272
|
-
} catch (
|
|
273
|
-
throw
|
|
270
|
+
const E = await S();
|
|
271
|
+
return h(), E;
|
|
272
|
+
} catch (E) {
|
|
273
|
+
throw A(E instanceof Error ? E : new Error(String(E))), E;
|
|
274
274
|
}
|
|
275
275
|
}
|
|
276
|
-
function
|
|
276
|
+
function w() {
|
|
277
277
|
return f(), a;
|
|
278
278
|
}
|
|
279
279
|
function P() {
|
|
@@ -286,21 +286,21 @@ function $(r) {
|
|
|
286
286
|
lastSuccessTime: l
|
|
287
287
|
};
|
|
288
288
|
}
|
|
289
|
-
function
|
|
289
|
+
function D() {
|
|
290
290
|
c().debug(`[CircuitBreaker:${n}] Manual reset → CLOSED`), a = "CLOSED", i = 0, o = 0, s = 0, u = null, l = null, d = null;
|
|
291
291
|
}
|
|
292
|
-
function
|
|
292
|
+
function x() {
|
|
293
293
|
c().warn(`[CircuitBreaker:${n}] Manual trip → OPEN`), a = "OPEN", d = Date.now() + t;
|
|
294
294
|
}
|
|
295
295
|
return {
|
|
296
296
|
execute: p,
|
|
297
|
-
getState:
|
|
297
|
+
getState: w,
|
|
298
298
|
getStats: P,
|
|
299
|
-
reset:
|
|
300
|
-
trip:
|
|
299
|
+
reset: D,
|
|
300
|
+
trip: x
|
|
301
301
|
};
|
|
302
302
|
}
|
|
303
|
-
const
|
|
303
|
+
const rr = {
|
|
304
304
|
/** Strict: Opens quickly (3 failures), long timeout (60s) */
|
|
305
305
|
STRICT: { failureThreshold: 3, timeout: 6e4 },
|
|
306
306
|
/** Standard: Balanced settings (5 failures, 30s timeout) */
|
|
@@ -325,7 +325,7 @@ function st(r, e, t, n, a) {
|
|
|
325
325
|
function ct(r) {
|
|
326
326
|
return new Promise((e) => setTimeout(e, r));
|
|
327
327
|
}
|
|
328
|
-
async function
|
|
328
|
+
async function g(r, e = {}) {
|
|
329
329
|
const {
|
|
330
330
|
maxRetries: t = 3,
|
|
331
331
|
initialDelayMs: n = 1e3,
|
|
@@ -344,19 +344,19 @@ async function C(r, e = {}) {
|
|
|
344
344
|
), h;
|
|
345
345
|
} catch (h) {
|
|
346
346
|
l = h instanceof Error ? h : new Error(String(h));
|
|
347
|
-
const
|
|
348
|
-
if (
|
|
347
|
+
const A = f === t, p = s(l, f);
|
|
348
|
+
if (A || !p)
|
|
349
349
|
throw c().warn(
|
|
350
|
-
`[Retry:${u}] Failed on attempt ${f + 1}/${t + 1}. ${
|
|
350
|
+
`[Retry:${u}] Failed on attempt ${f + 1}/${t + 1}. ${A ? "No more retries." : "Error not retryable."}`
|
|
351
351
|
), l;
|
|
352
|
-
const
|
|
353
|
-
d +=
|
|
354
|
-
`[Retry:${u}] Attempt ${f + 1}/${t + 1} failed: ${l.message}. Retrying in ${
|
|
355
|
-
), await ct(
|
|
352
|
+
const w = st(f, n, a, i, o);
|
|
353
|
+
d += w, c().warn(
|
|
354
|
+
`[Retry:${u}] Attempt ${f + 1}/${t + 1} failed: ${l.message}. Retrying in ${w}ms...`
|
|
355
|
+
), await ct(w);
|
|
356
356
|
}
|
|
357
357
|
throw l || new Error("Retry failed with no error");
|
|
358
358
|
}
|
|
359
|
-
const
|
|
359
|
+
const b = {
|
|
360
360
|
/** Quick retries for transient errors (3 retries, 1s initial, 2x backoff) */
|
|
361
361
|
QUICK: {
|
|
362
362
|
maxRetries: 3,
|
|
@@ -390,8 +390,8 @@ class lt {
|
|
|
390
390
|
stripe = null;
|
|
391
391
|
publicKey;
|
|
392
392
|
routeDiscovery;
|
|
393
|
-
rateLimiter = R(
|
|
394
|
-
circuitBreaker =
|
|
393
|
+
rateLimiter = R(M.PAYMENT);
|
|
394
|
+
circuitBreaker = U({
|
|
395
395
|
failureThreshold: 5,
|
|
396
396
|
timeout: 1e4,
|
|
397
397
|
// 10 seconds for faster recovery in payment flows
|
|
@@ -414,15 +414,15 @@ class lt {
|
|
|
414
414
|
if (!this.rateLimiter.tryConsume())
|
|
415
415
|
throw new Error("Rate limit exceeded for Stripe session creation. Please try again later.");
|
|
416
416
|
try {
|
|
417
|
-
return await this.circuitBreaker.execute(async () => await
|
|
417
|
+
return await this.circuitBreaker.execute(async () => await g(
|
|
418
418
|
async () => {
|
|
419
419
|
const t = await this.routeDiscovery.buildUrl("/paywall/v1/stripe-session");
|
|
420
420
|
c().debug("[StripeManager] Creating session with request:", e), e.couponCode ? c().debug("[StripeManager] Coupon code included:", e.couponCode) : c().debug("[StripeManager] No coupon code in request");
|
|
421
|
-
const n = await
|
|
421
|
+
const n = await y(t, {
|
|
422
422
|
method: "POST",
|
|
423
423
|
headers: {
|
|
424
424
|
"Content-Type": "application/json",
|
|
425
|
-
"Idempotency-Key":
|
|
425
|
+
"Idempotency-Key": T()
|
|
426
426
|
},
|
|
427
427
|
body: JSON.stringify(e)
|
|
428
428
|
});
|
|
@@ -430,12 +430,12 @@ class lt {
|
|
|
430
430
|
const a = await v(n, "Failed to create Stripe session");
|
|
431
431
|
throw new Error(a);
|
|
432
432
|
}
|
|
433
|
-
return n.json();
|
|
433
|
+
return await n.json();
|
|
434
434
|
},
|
|
435
|
-
{ ...
|
|
435
|
+
{ ...b.STANDARD, name: "stripe-create-session" }
|
|
436
436
|
));
|
|
437
437
|
} catch (t) {
|
|
438
|
-
throw t instanceof
|
|
438
|
+
throw t instanceof m ? (c().error("[StripeManager] Circuit breaker is OPEN - Stripe service unavailable"), new Error("Stripe payment service is temporarily unavailable. Please try again in a few moments.")) : t;
|
|
439
439
|
}
|
|
440
440
|
}
|
|
441
441
|
/**
|
|
@@ -463,7 +463,7 @@ class lt {
|
|
|
463
463
|
} catch (t) {
|
|
464
464
|
return {
|
|
465
465
|
success: !1,
|
|
466
|
-
error:
|
|
466
|
+
error: k(t, "Unknown error")
|
|
467
467
|
};
|
|
468
468
|
}
|
|
469
469
|
}
|
|
@@ -478,7 +478,7 @@ class lt {
|
|
|
478
478
|
error: "Rate limit exceeded for cart checkout. Please try again later."
|
|
479
479
|
};
|
|
480
480
|
try {
|
|
481
|
-
const u = await this.circuitBreaker.execute(async () => await
|
|
481
|
+
const u = await this.circuitBreaker.execute(async () => await g(
|
|
482
482
|
async () => {
|
|
483
483
|
const l = await this.routeDiscovery.buildUrl("/paywall/v1/cart/checkout"), d = {
|
|
484
484
|
items: t,
|
|
@@ -486,12 +486,15 @@ class lt {
|
|
|
486
486
|
cancelUrl: a,
|
|
487
487
|
metadata: i,
|
|
488
488
|
customerEmail: o,
|
|
489
|
+
coupon: s,
|
|
490
|
+
// New Rust server field
|
|
489
491
|
couponCode: s
|
|
490
|
-
|
|
492
|
+
// Legacy Go server field (backwards compat)
|
|
493
|
+
}, f = await y(l, {
|
|
491
494
|
method: "POST",
|
|
492
495
|
headers: {
|
|
493
496
|
"Content-Type": "application/json",
|
|
494
|
-
"Idempotency-Key":
|
|
497
|
+
"Idempotency-Key": T()
|
|
495
498
|
},
|
|
496
499
|
body: JSON.stringify(d)
|
|
497
500
|
});
|
|
@@ -501,124 +504,124 @@ class lt {
|
|
|
501
504
|
}
|
|
502
505
|
return await f.json();
|
|
503
506
|
},
|
|
504
|
-
{ ...
|
|
507
|
+
{ ...b.STANDARD, name: "stripe-cart-checkout" }
|
|
505
508
|
));
|
|
506
509
|
return await this.redirectToCheckout(u.sessionId);
|
|
507
510
|
} catch (u) {
|
|
508
|
-
return u instanceof
|
|
511
|
+
return u instanceof m ? {
|
|
509
512
|
success: !1,
|
|
510
513
|
error: "Stripe payment service is temporarily unavailable. Please try again in a few moments."
|
|
511
514
|
} : {
|
|
512
515
|
success: !1,
|
|
513
|
-
error:
|
|
516
|
+
error: k(u, "Cart checkout failed")
|
|
514
517
|
};
|
|
515
518
|
}
|
|
516
519
|
}
|
|
517
520
|
}
|
|
518
|
-
const
|
|
521
|
+
const Ce = "3.7.8", ut = Ce, O = typeof Buffer == "function", ce = typeof TextDecoder == "function" ? new TextDecoder() : void 0, le = typeof TextEncoder == "function" ? new TextEncoder() : void 0, dt = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", j = Array.prototype.slice.call(dt), H = ((r) => {
|
|
519
522
|
let e = {};
|
|
520
523
|
return r.forEach((t, n) => e[t] = n), e;
|
|
521
|
-
})(
|
|
524
|
+
})(j), ft = /^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/, C = String.fromCharCode.bind(String), ue = typeof Uint8Array.from == "function" ? Uint8Array.from.bind(Uint8Array) : (r) => new Uint8Array(Array.prototype.slice.call(r, 0)), Se = (r) => r.replace(/=/g, "").replace(/[+\/]/g, (e) => e == "+" ? "-" : "_"), Pe = (r) => r.replace(/[^A-Za-z0-9\+\/]/g, ""), xe = (r) => {
|
|
522
525
|
let e, t, n, a, i = "";
|
|
523
526
|
const o = r.length % 3;
|
|
524
527
|
for (let s = 0; s < r.length; ) {
|
|
525
528
|
if ((t = r.charCodeAt(s++)) > 255 || (n = r.charCodeAt(s++)) > 255 || (a = r.charCodeAt(s++)) > 255)
|
|
526
529
|
throw new TypeError("invalid character found");
|
|
527
|
-
e = t << 16 | n << 8 | a, i +=
|
|
530
|
+
e = t << 16 | n << 8 | a, i += j[e >> 18 & 63] + j[e >> 12 & 63] + j[e >> 6 & 63] + j[e & 63];
|
|
528
531
|
}
|
|
529
532
|
return o ? i.slice(0, o - 3) + "===".substring(o) : i;
|
|
530
|
-
},
|
|
533
|
+
}, ne = typeof btoa == "function" ? (r) => btoa(r) : O ? (r) => Buffer.from(r, "binary").toString("base64") : xe, _ = O ? (r) => Buffer.from(r).toString("base64") : (r) => {
|
|
531
534
|
let t = [];
|
|
532
535
|
for (let n = 0, a = r.length; n < a; n += 4096)
|
|
533
|
-
t.push(
|
|
534
|
-
return
|
|
535
|
-
},
|
|
536
|
+
t.push(C.apply(null, r.subarray(n, n + 4096)));
|
|
537
|
+
return ne(t.join(""));
|
|
538
|
+
}, G = (r, e = !1) => e ? Se(_(r)) : _(r), ht = (r) => {
|
|
536
539
|
if (r.length < 2) {
|
|
537
540
|
var e = r.charCodeAt(0);
|
|
538
|
-
return e < 128 ? r : e < 2048 ?
|
|
541
|
+
return e < 128 ? r : e < 2048 ? C(192 | e >>> 6) + C(128 | e & 63) : C(224 | e >>> 12 & 15) + C(128 | e >>> 6 & 63) + C(128 | e & 63);
|
|
539
542
|
} else {
|
|
540
543
|
var e = 65536 + (r.charCodeAt(0) - 55296) * 1024 + (r.charCodeAt(1) - 56320);
|
|
541
|
-
return
|
|
544
|
+
return C(240 | e >>> 18 & 7) + C(128 | e >>> 12 & 63) + C(128 | e >>> 6 & 63) + C(128 | e & 63);
|
|
542
545
|
}
|
|
543
|
-
},
|
|
546
|
+
}, At = /[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g, Te = (r) => r.replace(At, ht), de = O ? (r) => Buffer.from(r, "utf8").toString("base64") : le ? (r) => _(le.encode(r)) : (r) => ne(Te(r)), B = (r, e = !1) => e ? Se(de(r)) : de(r), fe = (r) => B(r, !0), pt = /[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g, yt = (r) => {
|
|
544
547
|
switch (r.length) {
|
|
545
548
|
case 4:
|
|
546
549
|
var e = (7 & r.charCodeAt(0)) << 18 | (63 & r.charCodeAt(1)) << 12 | (63 & r.charCodeAt(2)) << 6 | 63 & r.charCodeAt(3), t = e - 65536;
|
|
547
|
-
return
|
|
550
|
+
return C((t >>> 10) + 55296) + C((t & 1023) + 56320);
|
|
548
551
|
case 3:
|
|
549
|
-
return
|
|
552
|
+
return C((15 & r.charCodeAt(0)) << 12 | (63 & r.charCodeAt(1)) << 6 | 63 & r.charCodeAt(2));
|
|
550
553
|
default:
|
|
551
|
-
return
|
|
554
|
+
return C((31 & r.charCodeAt(0)) << 6 | 63 & r.charCodeAt(1));
|
|
552
555
|
}
|
|
553
|
-
},
|
|
556
|
+
}, ke = (r) => r.replace(pt, yt), Re = (r) => {
|
|
554
557
|
if (r = r.replace(/\s+/g, ""), !ft.test(r))
|
|
555
558
|
throw new TypeError("malformed base64.");
|
|
556
559
|
r += "==".slice(2 - (r.length & 3));
|
|
557
560
|
let e, t, n, a = [];
|
|
558
561
|
for (let i = 0; i < r.length; )
|
|
559
|
-
e =
|
|
562
|
+
e = H[r.charAt(i++)] << 18 | H[r.charAt(i++)] << 12 | (t = H[r.charAt(i++)]) << 6 | (n = H[r.charAt(i++)]), t === 64 ? a.push(C(e >> 16 & 255)) : n === 64 ? a.push(C(e >> 16 & 255, e >> 8 & 255)) : a.push(C(e >> 16 & 255, e >> 8 & 255, e & 255));
|
|
560
563
|
return a.join("");
|
|
561
|
-
},
|
|
564
|
+
}, ae = typeof atob == "function" ? (r) => atob(Pe(r)) : O ? (r) => Buffer.from(r, "base64").toString("binary") : Re, Me = O ? (r) => ue(Buffer.from(r, "base64")) : (r) => ue(ae(r).split("").map((e) => e.charCodeAt(0))), De = (r) => Me(Be(r)), wt = O ? (r) => Buffer.from(r, "base64").toString("utf8") : ce ? (r) => ce.decode(Me(r)) : (r) => ke(ae(r)), Be = (r) => Pe(r.replace(/[-_]/g, (e) => e == "-" ? "+" : "/")), ee = (r) => wt(Be(r)), mt = (r) => {
|
|
562
565
|
if (typeof r != "string")
|
|
563
566
|
return !1;
|
|
564
567
|
const e = r.replace(/\s+/g, "").replace(/={0,2}$/, "");
|
|
565
568
|
return !/[^\s0-9a-zA-Z\+/]/.test(e) || !/[^\s0-9a-zA-Z\-_]/.test(e);
|
|
566
|
-
},
|
|
569
|
+
}, Ue = (r) => ({
|
|
567
570
|
value: r,
|
|
568
571
|
enumerable: !1,
|
|
569
572
|
writable: !0,
|
|
570
573
|
configurable: !0
|
|
571
574
|
}), Oe = function() {
|
|
572
|
-
const r = (e, t) => Object.defineProperty(String.prototype, e,
|
|
575
|
+
const r = (e, t) => Object.defineProperty(String.prototype, e, Ue(t));
|
|
573
576
|
r("fromBase64", function() {
|
|
574
577
|
return ee(this);
|
|
575
578
|
}), r("toBase64", function(e) {
|
|
576
|
-
return
|
|
579
|
+
return B(this, e);
|
|
577
580
|
}), r("toBase64URI", function() {
|
|
578
|
-
return
|
|
581
|
+
return B(this, !0);
|
|
579
582
|
}), r("toBase64URL", function() {
|
|
580
|
-
return
|
|
583
|
+
return B(this, !0);
|
|
581
584
|
}), r("toUint8Array", function() {
|
|
582
|
-
return
|
|
585
|
+
return De(this);
|
|
583
586
|
});
|
|
584
587
|
}, Ne = function() {
|
|
585
|
-
const r = (e, t) => Object.defineProperty(Uint8Array.prototype, e,
|
|
588
|
+
const r = (e, t) => Object.defineProperty(Uint8Array.prototype, e, Ue(t));
|
|
586
589
|
r("toBase64", function(e) {
|
|
587
|
-
return
|
|
590
|
+
return G(this, e);
|
|
588
591
|
}), r("toBase64URI", function() {
|
|
589
|
-
return
|
|
592
|
+
return G(this, !0);
|
|
590
593
|
}), r("toBase64URL", function() {
|
|
591
|
-
return
|
|
594
|
+
return G(this, !0);
|
|
592
595
|
});
|
|
593
|
-
},
|
|
596
|
+
}, gt = () => {
|
|
594
597
|
Oe(), Ne();
|
|
595
|
-
},
|
|
596
|
-
version:
|
|
598
|
+
}, z = {
|
|
599
|
+
version: Ce,
|
|
597
600
|
VERSION: ut,
|
|
598
|
-
atob:
|
|
599
|
-
atobPolyfill:
|
|
600
|
-
btoa:
|
|
601
|
-
btoaPolyfill:
|
|
601
|
+
atob: ae,
|
|
602
|
+
atobPolyfill: Re,
|
|
603
|
+
btoa: ne,
|
|
604
|
+
btoaPolyfill: xe,
|
|
602
605
|
fromBase64: ee,
|
|
603
|
-
toBase64:
|
|
604
|
-
encode:
|
|
605
|
-
encodeURI:
|
|
606
|
-
encodeURL:
|
|
606
|
+
toBase64: B,
|
|
607
|
+
encode: B,
|
|
608
|
+
encodeURI: fe,
|
|
609
|
+
encodeURL: fe,
|
|
607
610
|
utob: Te,
|
|
608
|
-
btou:
|
|
611
|
+
btou: ke,
|
|
609
612
|
decode: ee,
|
|
610
|
-
isValid:
|
|
611
|
-
fromUint8Array:
|
|
612
|
-
toUint8Array:
|
|
613
|
+
isValid: mt,
|
|
614
|
+
fromUint8Array: G,
|
|
615
|
+
toUint8Array: De,
|
|
613
616
|
extendString: Oe,
|
|
614
617
|
extendUint8Array: Ne,
|
|
615
|
-
extendBuiltins:
|
|
618
|
+
extendBuiltins: gt
|
|
616
619
|
};
|
|
617
|
-
class
|
|
620
|
+
class bt {
|
|
618
621
|
routeDiscovery;
|
|
619
|
-
quoteRateLimiter = R(
|
|
620
|
-
verifyRateLimiter = R(
|
|
621
|
-
circuitBreaker =
|
|
622
|
+
quoteRateLimiter = R(M.QUOTE);
|
|
623
|
+
verifyRateLimiter = R(M.PAYMENT);
|
|
624
|
+
circuitBreaker = U({
|
|
622
625
|
failureThreshold: 5,
|
|
623
626
|
timeout: 1e4,
|
|
624
627
|
// 10 seconds for faster recovery in payment flows
|
|
@@ -637,14 +640,14 @@ class vt {
|
|
|
637
640
|
if (!this.quoteRateLimiter.tryConsume())
|
|
638
641
|
throw new Error("Rate limit exceeded for quote requests. Please try again later.");
|
|
639
642
|
try {
|
|
640
|
-
return await this.circuitBreaker.execute(async () => await
|
|
643
|
+
return await this.circuitBreaker.execute(async () => await g(
|
|
641
644
|
async () => {
|
|
642
645
|
const a = "/paywall/v1/quote";
|
|
643
646
|
c().debug(
|
|
644
647
|
"[X402Manager] Requesting quote",
|
|
645
648
|
n ? "with coupon" : "without coupon"
|
|
646
649
|
);
|
|
647
|
-
const i = await this.routeDiscovery.buildUrl(a), o = await
|
|
650
|
+
const i = await this.routeDiscovery.buildUrl(a), o = await y(i, {
|
|
648
651
|
method: "POST",
|
|
649
652
|
headers: {
|
|
650
653
|
"Content-Type": "application/json"
|
|
@@ -657,14 +660,16 @@ class vt {
|
|
|
657
660
|
if (o.status !== 402)
|
|
658
661
|
throw new Error(`Expected 402 status, got ${o.status}`);
|
|
659
662
|
const s = await o.json();
|
|
660
|
-
if (
|
|
661
|
-
|
|
662
|
-
|
|
663
|
+
if (s.crypto)
|
|
664
|
+
return s.crypto;
|
|
665
|
+
if (s.accepts && s.accepts.length > 0)
|
|
666
|
+
return s.accepts[0];
|
|
667
|
+
throw new Error("Invalid x402 response: missing crypto or accepts field");
|
|
663
668
|
},
|
|
664
|
-
{ ...
|
|
669
|
+
{ ...b.QUICK, name: "x402-quote" }
|
|
665
670
|
));
|
|
666
671
|
} catch (a) {
|
|
667
|
-
throw a instanceof
|
|
672
|
+
throw a instanceof m ? (c().error("[X402Manager] Circuit breaker is OPEN - x402 service unavailable"), new Error("Payment service is temporarily unavailable. Please try again in a few moments.")) : a;
|
|
668
673
|
}
|
|
669
674
|
}
|
|
670
675
|
/**
|
|
@@ -675,17 +680,20 @@ class vt {
|
|
|
675
680
|
if (!this.quoteRateLimiter.tryConsume())
|
|
676
681
|
throw new Error("Rate limit exceeded for cart quote requests. Please try again later.");
|
|
677
682
|
try {
|
|
678
|
-
return await this.circuitBreaker.execute(async () => await
|
|
683
|
+
return await this.circuitBreaker.execute(async () => await g(
|
|
679
684
|
async () => {
|
|
680
685
|
const i = await this.routeDiscovery.buildUrl("/paywall/v1/cart/quote"), o = {
|
|
681
686
|
items: t,
|
|
682
687
|
metadata: n,
|
|
688
|
+
coupon: a,
|
|
689
|
+
// New Rust server field
|
|
683
690
|
couponCode: a
|
|
684
|
-
|
|
691
|
+
// Legacy Go server field (backwards compat)
|
|
692
|
+
}, s = await y(i, {
|
|
685
693
|
method: "POST",
|
|
686
694
|
headers: {
|
|
687
695
|
"Content-Type": "application/json",
|
|
688
|
-
"Idempotency-Key":
|
|
696
|
+
"Idempotency-Key": T()
|
|
689
697
|
},
|
|
690
698
|
body: JSON.stringify(o)
|
|
691
699
|
});
|
|
@@ -693,12 +701,12 @@ class vt {
|
|
|
693
701
|
const u = await v(s, "Failed to get cart quote");
|
|
694
702
|
throw new Error(u);
|
|
695
703
|
}
|
|
696
|
-
return s.json();
|
|
704
|
+
return await s.json();
|
|
697
705
|
},
|
|
698
|
-
{ ...
|
|
706
|
+
{ ...b.QUICK, name: "x402-cart-quote" }
|
|
699
707
|
));
|
|
700
708
|
} catch (i) {
|
|
701
|
-
throw i instanceof
|
|
709
|
+
throw i instanceof m ? (c().error("[X402Manager] Circuit breaker is OPEN - cart quote service unavailable"), new Error("Payment service is temporarily unavailable. Please try again in a few moments.")) : i;
|
|
702
710
|
}
|
|
703
711
|
}
|
|
704
712
|
/**
|
|
@@ -706,7 +714,7 @@ class vt {
|
|
|
706
714
|
*/
|
|
707
715
|
buildPaymentHeader(e) {
|
|
708
716
|
const t = JSON.stringify(e);
|
|
709
|
-
return
|
|
717
|
+
return z.encode(t);
|
|
710
718
|
}
|
|
711
719
|
/**
|
|
712
720
|
* Parse X-PAYMENT-RESPONSE header (base64 encoded settlement response)
|
|
@@ -716,7 +724,7 @@ class vt {
|
|
|
716
724
|
if (!t)
|
|
717
725
|
return null;
|
|
718
726
|
try {
|
|
719
|
-
const n =
|
|
727
|
+
const n = z.decode(t), a = JSON.parse(n);
|
|
720
728
|
return typeof a.success != "boolean" ? (c().error("Invalid settlement response: missing success field"), null) : a;
|
|
721
729
|
} catch (n) {
|
|
722
730
|
return c().error("Failed to parse settlement response:", n), null;
|
|
@@ -740,7 +748,7 @@ class vt {
|
|
|
740
748
|
error: "Rate limit exceeded for payment verification. Please try again later."
|
|
741
749
|
};
|
|
742
750
|
try {
|
|
743
|
-
return await this.circuitBreaker.execute(async () => await
|
|
751
|
+
return await this.circuitBreaker.execute(async () => await g(
|
|
744
752
|
async () => {
|
|
745
753
|
const u = {
|
|
746
754
|
...n,
|
|
@@ -763,22 +771,22 @@ class vt {
|
|
|
763
771
|
hasCoupon: !!a,
|
|
764
772
|
hasMetadata: !!i
|
|
765
773
|
});
|
|
766
|
-
const f = await this.routeDiscovery.buildUrl(d), h = await
|
|
774
|
+
const f = await this.routeDiscovery.buildUrl(d), h = await y(f, {
|
|
767
775
|
method: "POST",
|
|
768
776
|
headers: {
|
|
769
777
|
"Content-Type": "application/json",
|
|
770
778
|
"X-PAYMENT": l,
|
|
771
|
-
"Idempotency-Key":
|
|
779
|
+
"Idempotency-Key": T()
|
|
772
780
|
}
|
|
773
781
|
});
|
|
774
782
|
if (h.ok) {
|
|
775
|
-
const { settlement: p, transactionId:
|
|
783
|
+
const { settlement: p, transactionId: w } = await this.handlePaymentVerification(
|
|
776
784
|
h,
|
|
777
785
|
n.payload.signature
|
|
778
786
|
);
|
|
779
787
|
return {
|
|
780
788
|
success: !0,
|
|
781
|
-
transactionId:
|
|
789
|
+
transactionId: w,
|
|
782
790
|
settlement: p || void 0
|
|
783
791
|
};
|
|
784
792
|
}
|
|
@@ -787,15 +795,15 @@ class vt {
|
|
|
787
795
|
error: await v(h, "Payment verification failed", !0)
|
|
788
796
|
};
|
|
789
797
|
},
|
|
790
|
-
{ ...
|
|
798
|
+
{ ...b.STANDARD, name: "x402-verify" }
|
|
791
799
|
));
|
|
792
800
|
} catch (s) {
|
|
793
|
-
return s instanceof
|
|
801
|
+
return s instanceof m ? {
|
|
794
802
|
success: !1,
|
|
795
803
|
error: "Payment verification service is temporarily unavailable. Please try again in a few moments."
|
|
796
804
|
} : {
|
|
797
805
|
success: !1,
|
|
798
|
-
error:
|
|
806
|
+
error: k(s, "Unknown error")
|
|
799
807
|
};
|
|
800
808
|
}
|
|
801
809
|
}
|
|
@@ -808,11 +816,11 @@ class vt {
|
|
|
808
816
|
if (!this.quoteRateLimiter.tryConsume())
|
|
809
817
|
throw new Error("Rate limit exceeded for gasless transaction requests. Please try again later.");
|
|
810
818
|
try {
|
|
811
|
-
return await this.circuitBreaker.execute(async () => await
|
|
819
|
+
return await this.circuitBreaker.execute(async () => await g(
|
|
812
820
|
async () => {
|
|
813
821
|
const o = await this.routeDiscovery.buildUrl(
|
|
814
822
|
"/paywall/v1/gasless-transaction"
|
|
815
|
-
), s = await
|
|
823
|
+
), s = await y(o, {
|
|
816
824
|
method: "POST",
|
|
817
825
|
headers: {
|
|
818
826
|
"Content-Type": "application/json"
|
|
@@ -828,12 +836,12 @@ class vt {
|
|
|
828
836
|
const u = await v(s, "Failed to build gasless transaction");
|
|
829
837
|
throw new Error(u);
|
|
830
838
|
}
|
|
831
|
-
return s.json();
|
|
839
|
+
return await s.json();
|
|
832
840
|
},
|
|
833
|
-
{ ...
|
|
841
|
+
{ ...b.QUICK, name: "x402-gasless-build" }
|
|
834
842
|
));
|
|
835
843
|
} catch (o) {
|
|
836
|
-
throw o instanceof
|
|
844
|
+
throw o instanceof m ? (c().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;
|
|
837
845
|
}
|
|
838
846
|
}
|
|
839
847
|
/**
|
|
@@ -856,7 +864,7 @@ class vt {
|
|
|
856
864
|
error: "Rate limit exceeded for gasless transaction verification. Please try again later."
|
|
857
865
|
};
|
|
858
866
|
try {
|
|
859
|
-
return await this.circuitBreaker.execute(async () => await
|
|
867
|
+
return await this.circuitBreaker.execute(async () => await g(
|
|
860
868
|
async () => {
|
|
861
869
|
const l = {
|
|
862
870
|
x402Version: 0,
|
|
@@ -874,39 +882,39 @@ class vt {
|
|
|
874
882
|
...a ? { couponCode: a } : {}
|
|
875
883
|
}
|
|
876
884
|
}
|
|
877
|
-
}, d = this.buildPaymentHeader(l), h = await this.routeDiscovery.buildUrl("/paywall/v1/verify"),
|
|
885
|
+
}, d = this.buildPaymentHeader(l), h = await this.routeDiscovery.buildUrl("/paywall/v1/verify"), A = await y(h, {
|
|
878
886
|
method: "POST",
|
|
879
887
|
headers: {
|
|
880
888
|
"Content-Type": "application/json",
|
|
881
889
|
"X-PAYMENT": d,
|
|
882
|
-
"Idempotency-Key":
|
|
890
|
+
"Idempotency-Key": T()
|
|
883
891
|
}
|
|
884
892
|
});
|
|
885
|
-
if (
|
|
886
|
-
const { settlement:
|
|
887
|
-
|
|
893
|
+
if (A.ok) {
|
|
894
|
+
const { settlement: w, transactionId: P } = await this.handlePaymentVerification(
|
|
895
|
+
A,
|
|
888
896
|
"gasless-tx"
|
|
889
897
|
);
|
|
890
898
|
return {
|
|
891
899
|
success: !0,
|
|
892
900
|
transactionId: P,
|
|
893
|
-
settlement:
|
|
901
|
+
settlement: w || void 0
|
|
894
902
|
};
|
|
895
903
|
}
|
|
896
904
|
return {
|
|
897
905
|
success: !1,
|
|
898
|
-
error: await v(
|
|
906
|
+
error: await v(A, "Gasless transaction failed", !0)
|
|
899
907
|
};
|
|
900
908
|
},
|
|
901
|
-
{ ...
|
|
909
|
+
{ ...b.STANDARD, name: "x402-gasless-verify" }
|
|
902
910
|
));
|
|
903
911
|
} catch (u) {
|
|
904
|
-
return u instanceof
|
|
912
|
+
return u instanceof m ? {
|
|
905
913
|
success: !1,
|
|
906
914
|
error: "Gasless transaction verification service is temporarily unavailable. Please try again in a few moments."
|
|
907
915
|
} : {
|
|
908
916
|
success: !1,
|
|
909
|
-
error:
|
|
917
|
+
error: k(u, "Unknown error")
|
|
910
918
|
};
|
|
911
919
|
}
|
|
912
920
|
}
|
|
@@ -935,7 +943,7 @@ class vt {
|
|
|
935
943
|
return !!(e.scheme && e.network && e.maxAmountRequired && e.resource && e.payTo && e.asset && e.maxTimeoutSeconds > 0);
|
|
936
944
|
}
|
|
937
945
|
}
|
|
938
|
-
function
|
|
946
|
+
function vt(r) {
|
|
939
947
|
if (r.length >= 255)
|
|
940
948
|
throw new TypeError("Alphabet too long");
|
|
941
949
|
const e = new Uint8Array(256);
|
|
@@ -954,25 +962,25 @@ function Et(r) {
|
|
|
954
962
|
if (l.length === 0)
|
|
955
963
|
return "";
|
|
956
964
|
let d = 0, f = 0, h = 0;
|
|
957
|
-
const
|
|
958
|
-
for (; h !==
|
|
965
|
+
const A = l.length;
|
|
966
|
+
for (; h !== A && l[h] === 0; )
|
|
959
967
|
h++, d++;
|
|
960
|
-
const p = (
|
|
961
|
-
for (; h !==
|
|
962
|
-
let
|
|
963
|
-
for (let
|
|
964
|
-
|
|
965
|
-
if (
|
|
968
|
+
const p = (A - h) * i + 1 >>> 0, w = new Uint8Array(p);
|
|
969
|
+
for (; h !== A; ) {
|
|
970
|
+
let x = l[h], S = 0;
|
|
971
|
+
for (let E = p - 1; (x !== 0 || S < f) && E !== -1; E--, S++)
|
|
972
|
+
x += 256 * w[E] >>> 0, w[E] = x % t >>> 0, x = x / t >>> 0;
|
|
973
|
+
if (x !== 0)
|
|
966
974
|
throw new Error("Non-zero carry");
|
|
967
975
|
f = S, h++;
|
|
968
976
|
}
|
|
969
977
|
let P = p - f;
|
|
970
|
-
for (; P !== p &&
|
|
978
|
+
for (; P !== p && w[P] === 0; )
|
|
971
979
|
P++;
|
|
972
|
-
let
|
|
980
|
+
let D = n.repeat(d);
|
|
973
981
|
for (; P < p; ++P)
|
|
974
|
-
|
|
975
|
-
return
|
|
982
|
+
D += r.charAt(w[P]);
|
|
983
|
+
return D;
|
|
976
984
|
}
|
|
977
985
|
function s(l) {
|
|
978
986
|
if (typeof l != "string")
|
|
@@ -982,28 +990,28 @@ function Et(r) {
|
|
|
982
990
|
let d = 0, f = 0, h = 0;
|
|
983
991
|
for (; l[d] === n; )
|
|
984
992
|
f++, d++;
|
|
985
|
-
const
|
|
993
|
+
const A = (l.length - d) * a + 1 >>> 0, p = new Uint8Array(A);
|
|
986
994
|
for (; d < l.length; ) {
|
|
987
|
-
const
|
|
988
|
-
if (
|
|
995
|
+
const x = l.charCodeAt(d);
|
|
996
|
+
if (x > 255)
|
|
989
997
|
return;
|
|
990
|
-
let S = e[
|
|
998
|
+
let S = e[x];
|
|
991
999
|
if (S === 255)
|
|
992
1000
|
return;
|
|
993
|
-
let
|
|
994
|
-
for (let
|
|
995
|
-
S += t * p[
|
|
1001
|
+
let E = 0;
|
|
1002
|
+
for (let q = A - 1; (S !== 0 || E < h) && q !== -1; q--, E++)
|
|
1003
|
+
S += t * p[q] >>> 0, p[q] = S % 256 >>> 0, S = S / 256 >>> 0;
|
|
996
1004
|
if (S !== 0)
|
|
997
1005
|
throw new Error("Non-zero carry");
|
|
998
|
-
h =
|
|
1006
|
+
h = E, d++;
|
|
999
1007
|
}
|
|
1000
|
-
let
|
|
1001
|
-
for (;
|
|
1002
|
-
|
|
1003
|
-
const P = new Uint8Array(f + (
|
|
1004
|
-
let
|
|
1005
|
-
for (;
|
|
1006
|
-
P[
|
|
1008
|
+
let w = A - h;
|
|
1009
|
+
for (; w !== A && p[w] === 0; )
|
|
1010
|
+
w++;
|
|
1011
|
+
const P = new Uint8Array(f + (A - w));
|
|
1012
|
+
let D = f;
|
|
1013
|
+
for (; w !== A; )
|
|
1014
|
+
P[D++] = p[w++];
|
|
1007
1015
|
return P;
|
|
1008
1016
|
}
|
|
1009
1017
|
function u(l) {
|
|
@@ -1018,24 +1026,42 @@ function Et(r) {
|
|
|
1018
1026
|
decode: u
|
|
1019
1027
|
};
|
|
1020
1028
|
}
|
|
1021
|
-
var
|
|
1022
|
-
const
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
}
|
|
1028
|
-
|
|
1029
|
+
var Et = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
1030
|
+
const he = vt(Et), Ct = "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==", St = "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", Pt = "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==", xt = "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==", Tt = {
|
|
1031
|
+
EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v: {
|
|
1032
|
+
symbol: "USDC",
|
|
1033
|
+
decimals: 6,
|
|
1034
|
+
icon: Ct
|
|
1035
|
+
},
|
|
1036
|
+
Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB: {
|
|
1037
|
+
symbol: "USDT",
|
|
1038
|
+
decimals: 6,
|
|
1039
|
+
icon: St
|
|
1040
|
+
},
|
|
1041
|
+
"2b1kV6DkPAnxd5ixfnxCpjxmKwqjjaYmCZfHsFu24GXo": {
|
|
1042
|
+
symbol: "PYUSD",
|
|
1043
|
+
decimals: 6,
|
|
1044
|
+
icon: Pt
|
|
1045
|
+
},
|
|
1046
|
+
CASHx9KJUStyftLFWGvEVf59SGeG9sh5FfcnZMVPCASH: {
|
|
1047
|
+
symbol: "CASH",
|
|
1048
|
+
decimals: 6,
|
|
1049
|
+
icon: xt
|
|
1050
|
+
}
|
|
1051
|
+
}, te = Object.fromEntries(
|
|
1052
|
+
Object.entries(Tt).map(([r, e]) => [r, e.symbol])
|
|
1053
|
+
);
|
|
1054
|
+
function kt(r) {
|
|
1029
1055
|
return r in te;
|
|
1030
1056
|
}
|
|
1031
|
-
function
|
|
1057
|
+
function Ie(r, e = "token mint", t = !1) {
|
|
1032
1058
|
if (!r || r.trim().length === 0)
|
|
1033
1059
|
return {
|
|
1034
1060
|
isValid: !0,
|
|
1035
1061
|
isKnownStablecoin: !1
|
|
1036
1062
|
};
|
|
1037
1063
|
const n = r.trim();
|
|
1038
|
-
if (
|
|
1064
|
+
if (kt(n))
|
|
1039
1065
|
return {
|
|
1040
1066
|
isValid: !0,
|
|
1041
1067
|
isKnownStablecoin: !0,
|
|
@@ -1090,10 +1116,10 @@ function Be(r, e = "token mint", t = !1) {
|
|
|
1090
1116
|
`)
|
|
1091
1117
|
};
|
|
1092
1118
|
}
|
|
1093
|
-
function
|
|
1094
|
-
return
|
|
1119
|
+
function Rt(r, e = "unknown", t = !1) {
|
|
1120
|
+
return Ie(r, `X402Requirement (resource: ${e})`, t);
|
|
1095
1121
|
}
|
|
1096
|
-
class
|
|
1122
|
+
class Mt {
|
|
1097
1123
|
connection;
|
|
1098
1124
|
cluster;
|
|
1099
1125
|
endpoint;
|
|
@@ -1103,7 +1129,7 @@ class Pt {
|
|
|
1103
1129
|
windowMs: 6e4
|
|
1104
1130
|
// 50 requests per minute for RPC calls
|
|
1105
1131
|
});
|
|
1106
|
-
rpcCircuitBreaker =
|
|
1132
|
+
rpcCircuitBreaker = U({
|
|
1107
1133
|
failureThreshold: 5,
|
|
1108
1134
|
timeout: 1e4,
|
|
1109
1135
|
// 10 seconds for faster recovery in payment flows
|
|
@@ -1117,7 +1143,7 @@ class Pt {
|
|
|
1117
1143
|
*/
|
|
1118
1144
|
createConnection() {
|
|
1119
1145
|
const e = this.endpoint ?? je(this.cluster);
|
|
1120
|
-
return new
|
|
1146
|
+
return new ze(e, "confirmed");
|
|
1121
1147
|
}
|
|
1122
1148
|
/**
|
|
1123
1149
|
* Transform RPC errors into user-friendly messages
|
|
@@ -1137,15 +1163,15 @@ class Pt {
|
|
|
1137
1163
|
const { requirement: t, payerPublicKey: n, blockhash: a } = e;
|
|
1138
1164
|
if (!t || !t.payTo)
|
|
1139
1165
|
throw new Error("Invalid requirement: missing payTo");
|
|
1140
|
-
|
|
1141
|
-
const i = new
|
|
1166
|
+
c().debug("[WalletManager] Building transaction for resource:", t.resource);
|
|
1167
|
+
const i = new oe(), o = this.resolveAmountInMinorUnits(t), s = t.asset;
|
|
1142
1168
|
if (!s)
|
|
1143
1169
|
throw new Error("asset is required in x402 requirement");
|
|
1144
|
-
const u =
|
|
1170
|
+
const u = Rt(s, t.resource, this.allowUnknownMint);
|
|
1145
1171
|
if (!u.isValid && u.error)
|
|
1146
1172
|
throw new Error(u.error);
|
|
1147
1173
|
u.warning && c().warn(u.warning);
|
|
1148
|
-
const l = new N(s), d = await
|
|
1174
|
+
const l = new N(s), d = await Qe(
|
|
1149
1175
|
l,
|
|
1150
1176
|
n
|
|
1151
1177
|
);
|
|
@@ -1153,12 +1179,12 @@ class Pt {
|
|
|
1153
1179
|
throw new Error("RPC rate limit exceeded. Please try again in a moment.");
|
|
1154
1180
|
let f;
|
|
1155
1181
|
try {
|
|
1156
|
-
f = await this.rpcCircuitBreaker.execute(async () => await
|
|
1182
|
+
f = await this.rpcCircuitBreaker.execute(async () => await g(
|
|
1157
1183
|
async () => await this.connection.getAccountInfo(d),
|
|
1158
|
-
{ ...
|
|
1184
|
+
{ ...b.QUICK, name: "rpc-get-account-info" }
|
|
1159
1185
|
));
|
|
1160
1186
|
} catch (p) {
|
|
1161
|
-
throw p instanceof
|
|
1187
|
+
throw p instanceof m ? new Error("Solana RPC service is temporarily unavailable. Please try again in a few moments.") : this.transformRpcError(p);
|
|
1162
1188
|
}
|
|
1163
1189
|
if (!f)
|
|
1164
1190
|
throw new Error("Payer is missing an associated token account for this mint");
|
|
@@ -1169,36 +1195,36 @@ class Pt {
|
|
|
1169
1195
|
throw new Error("We are currently unable to process payment, please try again later");
|
|
1170
1196
|
}
|
|
1171
1197
|
if (i.add(
|
|
1172
|
-
|
|
1198
|
+
We(
|
|
1173
1199
|
d,
|
|
1174
1200
|
h,
|
|
1175
1201
|
n,
|
|
1176
1202
|
o
|
|
1177
1203
|
)
|
|
1178
1204
|
), t.extra?.memo) {
|
|
1179
|
-
const { TransactionInstruction: p } = await import("@solana/web3.js"),
|
|
1205
|
+
const { TransactionInstruction: p } = await import("@solana/web3.js"), w = new p({
|
|
1180
1206
|
keys: [],
|
|
1181
1207
|
programId: new N("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),
|
|
1182
1208
|
data: Buffer.from(t.extra.memo, "utf8")
|
|
1183
1209
|
});
|
|
1184
|
-
i.add(
|
|
1210
|
+
i.add(w);
|
|
1185
1211
|
}
|
|
1186
|
-
let
|
|
1212
|
+
let A;
|
|
1187
1213
|
if (a)
|
|
1188
|
-
|
|
1214
|
+
A = a;
|
|
1189
1215
|
else {
|
|
1190
1216
|
if (!this.rpcRateLimiter.tryConsume())
|
|
1191
1217
|
throw new Error("RPC rate limit exceeded. Please try again in a moment.");
|
|
1192
1218
|
try {
|
|
1193
|
-
|
|
1219
|
+
A = (await this.rpcCircuitBreaker.execute(async () => await g(
|
|
1194
1220
|
async () => await this.connection.getLatestBlockhash(),
|
|
1195
|
-
{ ...
|
|
1221
|
+
{ ...b.QUICK, name: "rpc-get-blockhash" }
|
|
1196
1222
|
))).blockhash;
|
|
1197
1223
|
} catch (p) {
|
|
1198
|
-
throw p instanceof
|
|
1224
|
+
throw p instanceof m ? new Error("Solana RPC service is temporarily unavailable. Please try again in a few moments.") : this.transformRpcError(p);
|
|
1199
1225
|
}
|
|
1200
1226
|
}
|
|
1201
|
-
return i.recentBlockhash =
|
|
1227
|
+
return i.recentBlockhash = A, t.extra?.feePayer ? i.feePayer = new N(t.extra.feePayer) : i.feePayer = n, i;
|
|
1202
1228
|
}
|
|
1203
1229
|
/**
|
|
1204
1230
|
* Parse amount from x402 requirement (already in atomic units as string)
|
|
@@ -1232,13 +1258,13 @@ class Pt {
|
|
|
1232
1258
|
*/
|
|
1233
1259
|
async signTransaction(e) {
|
|
1234
1260
|
const { transaction: t, signTransaction: n } = e;
|
|
1235
|
-
|
|
1261
|
+
c().debug("[WalletManager] Requesting wallet to sign transaction");
|
|
1236
1262
|
const a = await n(t), i = a.serialize(), o = a.signatures[0]?.signature;
|
|
1237
1263
|
if (!o)
|
|
1238
1264
|
throw new Error("Signed transaction missing signature");
|
|
1239
|
-
const s =
|
|
1240
|
-
return
|
|
1241
|
-
serialized:
|
|
1265
|
+
const s = he.encode(o);
|
|
1266
|
+
return c().debug("[WalletManager] Transaction signed with signature:", s.substring(0, 20) + "..."), {
|
|
1267
|
+
serialized: z.fromUint8Array(i),
|
|
1242
1268
|
signature: s
|
|
1243
1269
|
};
|
|
1244
1270
|
}
|
|
@@ -1248,11 +1274,11 @@ class Pt {
|
|
|
1248
1274
|
*/
|
|
1249
1275
|
deserializeTransaction(e) {
|
|
1250
1276
|
try {
|
|
1251
|
-
const t =
|
|
1252
|
-
return
|
|
1277
|
+
const t = z.toUint8Array(e);
|
|
1278
|
+
return oe.from(t);
|
|
1253
1279
|
} catch (t) {
|
|
1254
1280
|
throw new Error(
|
|
1255
|
-
`Failed to deserialize transaction: ${
|
|
1281
|
+
`Failed to deserialize transaction: ${k(t, "Unknown error")}`
|
|
1256
1282
|
);
|
|
1257
1283
|
}
|
|
1258
1284
|
}
|
|
@@ -1265,14 +1291,14 @@ class Pt {
|
|
|
1265
1291
|
a && t.recentBlockhash !== a && (t.recentBlockhash = a);
|
|
1266
1292
|
const i = await n(t), o = i.signatures[0]?.signature;
|
|
1267
1293
|
if (o) {
|
|
1268
|
-
const u =
|
|
1269
|
-
|
|
1294
|
+
const u = he.encode(o);
|
|
1295
|
+
c().debug("[WalletManager] Partially signed with signature:", u.substring(0, 20) + "...");
|
|
1270
1296
|
}
|
|
1271
1297
|
const s = i.serialize({
|
|
1272
1298
|
requireAllSignatures: !1,
|
|
1273
1299
|
verifySignatures: !1
|
|
1274
1300
|
});
|
|
1275
|
-
return
|
|
1301
|
+
return z.fromUint8Array(s);
|
|
1276
1302
|
}
|
|
1277
1303
|
/**
|
|
1278
1304
|
* Get wallet balance
|
|
@@ -1281,12 +1307,12 @@ class Pt {
|
|
|
1281
1307
|
if (!this.rpcRateLimiter.tryConsume())
|
|
1282
1308
|
throw new Error("RPC rate limit exceeded. Please try again in a moment.");
|
|
1283
1309
|
try {
|
|
1284
|
-
return await this.rpcCircuitBreaker.execute(async () => await
|
|
1310
|
+
return await this.rpcCircuitBreaker.execute(async () => await g(
|
|
1285
1311
|
async () => await this.connection.getBalance(e),
|
|
1286
|
-
{ ...
|
|
1287
|
-
)) /
|
|
1312
|
+
{ ...b.QUICK, name: "rpc-get-balance" }
|
|
1313
|
+
)) / qe;
|
|
1288
1314
|
} catch (t) {
|
|
1289
|
-
throw t instanceof
|
|
1315
|
+
throw t instanceof m ? new Error("Solana RPC service is temporarily unavailable. Please try again in a few moments.") : this.transformRpcError(t);
|
|
1290
1316
|
}
|
|
1291
1317
|
}
|
|
1292
1318
|
/**
|
|
@@ -1296,23 +1322,23 @@ class Pt {
|
|
|
1296
1322
|
if (!this.rpcRateLimiter.tryConsume())
|
|
1297
1323
|
return c().warn("[WalletManager] RPC rate limit exceeded for transaction verification"), !1;
|
|
1298
1324
|
try {
|
|
1299
|
-
return !!(await this.rpcCircuitBreaker.execute(async () => await
|
|
1325
|
+
return !!(await this.rpcCircuitBreaker.execute(async () => await g(
|
|
1300
1326
|
async () => await this.connection.getSignatureStatus(e),
|
|
1301
|
-
{ ...
|
|
1327
|
+
{ ...b.QUICK, name: "rpc-verify-tx" }
|
|
1302
1328
|
))).value?.confirmationStatus;
|
|
1303
1329
|
} catch (t) {
|
|
1304
|
-
return t instanceof
|
|
1330
|
+
return t instanceof m && c().warn("[WalletManager] Circuit breaker OPEN - cannot verify transaction"), !1;
|
|
1305
1331
|
}
|
|
1306
1332
|
}
|
|
1307
1333
|
}
|
|
1308
|
-
class
|
|
1334
|
+
class Dt {
|
|
1309
1335
|
stripe = null;
|
|
1310
1336
|
publicKey;
|
|
1311
1337
|
routeDiscovery;
|
|
1312
1338
|
// Separate rate limiters for different operation types
|
|
1313
|
-
sessionRateLimiter = R(
|
|
1314
|
-
statusRateLimiter = R(
|
|
1315
|
-
circuitBreaker =
|
|
1339
|
+
sessionRateLimiter = R(M.PAYMENT);
|
|
1340
|
+
statusRateLimiter = R(M.QUOTE);
|
|
1341
|
+
circuitBreaker = U({
|
|
1316
1342
|
failureThreshold: 5,
|
|
1317
1343
|
timeout: 1e4,
|
|
1318
1344
|
// 10 seconds for faster recovery
|
|
@@ -1332,10 +1358,10 @@ class Tt {
|
|
|
1332
1358
|
throw new Error("Rate limit exceeded. Please try again later.");
|
|
1333
1359
|
try {
|
|
1334
1360
|
return await this.circuitBreaker.execute(
|
|
1335
|
-
() =>
|
|
1361
|
+
() => g(t, { ...b.STANDARD, name: n })
|
|
1336
1362
|
);
|
|
1337
1363
|
} catch (i) {
|
|
1338
|
-
throw i instanceof
|
|
1364
|
+
throw i instanceof m ? (c().error(`[SubscriptionManager] Circuit breaker OPEN for ${a}`), new Error("Service temporarily unavailable. Please try again in a few moments.")) : i;
|
|
1339
1365
|
}
|
|
1340
1366
|
}
|
|
1341
1367
|
/**
|
|
@@ -1345,7 +1371,7 @@ class Tt {
|
|
|
1345
1371
|
if (!this.sessionRateLimiter.tryConsume())
|
|
1346
1372
|
throw new Error("Rate limit exceeded for subscription session creation. Please try again later.");
|
|
1347
1373
|
try {
|
|
1348
|
-
return await this.circuitBreaker.execute(async () => await
|
|
1374
|
+
return await this.circuitBreaker.execute(async () => await g(
|
|
1349
1375
|
async () => {
|
|
1350
1376
|
const t = await this.routeDiscovery.buildUrl("/paywall/v1/subscription/stripe-session");
|
|
1351
1377
|
c().debug("[SubscriptionManager] Creating subscription session:", {
|
|
@@ -1353,11 +1379,11 @@ class Tt {
|
|
|
1353
1379
|
interval: e.interval,
|
|
1354
1380
|
trialDays: e.trialDays
|
|
1355
1381
|
});
|
|
1356
|
-
const n = await
|
|
1382
|
+
const n = await y(t, {
|
|
1357
1383
|
method: "POST",
|
|
1358
1384
|
headers: {
|
|
1359
1385
|
"Content-Type": "application/json",
|
|
1360
|
-
"Idempotency-Key":
|
|
1386
|
+
"Idempotency-Key": T()
|
|
1361
1387
|
},
|
|
1362
1388
|
body: JSON.stringify(e)
|
|
1363
1389
|
});
|
|
@@ -1368,12 +1394,12 @@ class Tt {
|
|
|
1368
1394
|
);
|
|
1369
1395
|
throw new Error(a);
|
|
1370
1396
|
}
|
|
1371
|
-
return n.json();
|
|
1397
|
+
return await n.json();
|
|
1372
1398
|
},
|
|
1373
|
-
{ ...
|
|
1399
|
+
{ ...b.STANDARD, name: "subscription-create-session" }
|
|
1374
1400
|
));
|
|
1375
1401
|
} catch (t) {
|
|
1376
|
-
throw t instanceof
|
|
1402
|
+
throw t instanceof m ? (c().error("[SubscriptionManager] Circuit breaker is OPEN - service unavailable"), new Error(
|
|
1377
1403
|
"Subscription service is temporarily unavailable. Please try again in a few moments."
|
|
1378
1404
|
)) : t;
|
|
1379
1405
|
}
|
|
@@ -1403,7 +1429,7 @@ class Tt {
|
|
|
1403
1429
|
} catch (t) {
|
|
1404
1430
|
return {
|
|
1405
1431
|
success: !1,
|
|
1406
|
-
error:
|
|
1432
|
+
error: k(t, "Subscription failed")
|
|
1407
1433
|
};
|
|
1408
1434
|
}
|
|
1409
1435
|
}
|
|
@@ -1414,7 +1440,7 @@ class Tt {
|
|
|
1414
1440
|
if (!this.statusRateLimiter.tryConsume())
|
|
1415
1441
|
throw new Error("Rate limit exceeded for subscription status check. Please try again later.");
|
|
1416
1442
|
try {
|
|
1417
|
-
return await this.circuitBreaker.execute(async () => await
|
|
1443
|
+
return await this.circuitBreaker.execute(async () => await g(
|
|
1418
1444
|
async () => {
|
|
1419
1445
|
const t = new URLSearchParams({
|
|
1420
1446
|
resource: e.resource,
|
|
@@ -1423,7 +1449,7 @@ class Tt {
|
|
|
1423
1449
|
`/paywall/v1/subscription/status?${t.toString()}`
|
|
1424
1450
|
);
|
|
1425
1451
|
c().debug("[SubscriptionManager] Checking subscription status:", e);
|
|
1426
|
-
const a = await
|
|
1452
|
+
const a = await y(n, {
|
|
1427
1453
|
method: "GET",
|
|
1428
1454
|
headers: {
|
|
1429
1455
|
"Content-Type": "application/json"
|
|
@@ -1436,12 +1462,12 @@ class Tt {
|
|
|
1436
1462
|
);
|
|
1437
1463
|
throw new Error(i);
|
|
1438
1464
|
}
|
|
1439
|
-
return a.json();
|
|
1465
|
+
return await a.json();
|
|
1440
1466
|
},
|
|
1441
|
-
{ ...
|
|
1467
|
+
{ ...b.STANDARD, name: "subscription-status-check" }
|
|
1442
1468
|
));
|
|
1443
1469
|
} catch (t) {
|
|
1444
|
-
throw t instanceof
|
|
1470
|
+
throw t instanceof m ? (c().error("[SubscriptionManager] Circuit breaker is OPEN for status check"), new Error(
|
|
1445
1471
|
"Subscription status service is temporarily unavailable. Please try again in a few moments."
|
|
1446
1472
|
)) : t;
|
|
1447
1473
|
}
|
|
@@ -1453,7 +1479,7 @@ class Tt {
|
|
|
1453
1479
|
if (!this.statusRateLimiter.tryConsume())
|
|
1454
1480
|
throw new Error("Rate limit exceeded for subscription quote. Please try again later.");
|
|
1455
1481
|
try {
|
|
1456
|
-
return await this.circuitBreaker.execute(async () => await
|
|
1482
|
+
return await this.circuitBreaker.execute(async () => await g(
|
|
1457
1483
|
async () => {
|
|
1458
1484
|
const a = await this.routeDiscovery.buildUrl("/paywall/v1/subscription/quote"), i = {
|
|
1459
1485
|
resource: e,
|
|
@@ -1462,7 +1488,7 @@ class Tt {
|
|
|
1462
1488
|
intervalDays: n?.intervalDays
|
|
1463
1489
|
};
|
|
1464
1490
|
c().debug("[SubscriptionManager] Requesting subscription quote:", i);
|
|
1465
|
-
const o = await
|
|
1491
|
+
const o = await y(a, {
|
|
1466
1492
|
method: "POST",
|
|
1467
1493
|
headers: {
|
|
1468
1494
|
"Content-Type": "application/json"
|
|
@@ -1476,12 +1502,12 @@ class Tt {
|
|
|
1476
1502
|
);
|
|
1477
1503
|
throw new Error(s);
|
|
1478
1504
|
}
|
|
1479
|
-
return o.json();
|
|
1505
|
+
return await o.json();
|
|
1480
1506
|
},
|
|
1481
|
-
{ ...
|
|
1507
|
+
{ ...b.STANDARD, name: "subscription-quote" }
|
|
1482
1508
|
));
|
|
1483
1509
|
} catch (a) {
|
|
1484
|
-
throw a instanceof
|
|
1510
|
+
throw a instanceof m ? (c().error("[SubscriptionManager] Circuit breaker is OPEN for quote"), new Error(
|
|
1485
1511
|
"Subscription quote service is temporarily unavailable. Please try again in a few moments."
|
|
1486
1512
|
)) : a;
|
|
1487
1513
|
}
|
|
@@ -1493,13 +1519,13 @@ class Tt {
|
|
|
1493
1519
|
async () => {
|
|
1494
1520
|
const t = await this.routeDiscovery.buildUrl("/paywall/v1/subscription/cancel");
|
|
1495
1521
|
c().debug("[SubscriptionManager] Canceling subscription:", e);
|
|
1496
|
-
const n = await
|
|
1522
|
+
const n = await y(t, {
|
|
1497
1523
|
method: "POST",
|
|
1498
1524
|
headers: { "Content-Type": "application/json" },
|
|
1499
1525
|
body: JSON.stringify(e)
|
|
1500
1526
|
});
|
|
1501
1527
|
if (!n.ok) throw new Error(await v(n, "Failed to cancel"));
|
|
1502
|
-
return n.json();
|
|
1528
|
+
return await n.json();
|
|
1503
1529
|
},
|
|
1504
1530
|
"subscription-cancel",
|
|
1505
1531
|
"cancellation"
|
|
@@ -1512,13 +1538,13 @@ class Tt {
|
|
|
1512
1538
|
async () => {
|
|
1513
1539
|
const t = await this.routeDiscovery.buildUrl("/paywall/v1/subscription/portal");
|
|
1514
1540
|
c().debug("[SubscriptionManager] Getting billing portal URL:", e);
|
|
1515
|
-
const n = await
|
|
1541
|
+
const n = await y(t, {
|
|
1516
1542
|
method: "POST",
|
|
1517
1543
|
headers: { "Content-Type": "application/json" },
|
|
1518
1544
|
body: JSON.stringify(e)
|
|
1519
1545
|
});
|
|
1520
1546
|
if (!n.ok) throw new Error(await v(n, "Failed to get portal"));
|
|
1521
|
-
return n.json();
|
|
1547
|
+
return await n.json();
|
|
1522
1548
|
},
|
|
1523
1549
|
"subscription-portal",
|
|
1524
1550
|
"portal"
|
|
@@ -1531,24 +1557,24 @@ class Tt {
|
|
|
1531
1557
|
async () => {
|
|
1532
1558
|
const t = await this.routeDiscovery.buildUrl("/paywall/v1/subscription/x402/activate");
|
|
1533
1559
|
c().debug("[SubscriptionManager] Activating x402 subscription:", e);
|
|
1534
|
-
const n = await
|
|
1560
|
+
const n = await y(t, {
|
|
1535
1561
|
method: "POST",
|
|
1536
1562
|
headers: { "Content-Type": "application/json" },
|
|
1537
1563
|
body: JSON.stringify(e)
|
|
1538
1564
|
});
|
|
1539
1565
|
if (!n.ok) throw new Error(await v(n, "Failed to activate"));
|
|
1540
|
-
return n.json();
|
|
1566
|
+
return await n.json();
|
|
1541
1567
|
},
|
|
1542
1568
|
"subscription-activate",
|
|
1543
1569
|
"activation"
|
|
1544
1570
|
);
|
|
1545
1571
|
}
|
|
1546
1572
|
}
|
|
1547
|
-
class
|
|
1573
|
+
class Bt {
|
|
1548
1574
|
routeDiscovery;
|
|
1549
|
-
rateLimiter = R(
|
|
1550
|
-
queryRateLimiter = R(
|
|
1551
|
-
circuitBreaker =
|
|
1575
|
+
rateLimiter = R(M.PAYMENT);
|
|
1576
|
+
queryRateLimiter = R(M.QUOTE);
|
|
1577
|
+
circuitBreaker = U({
|
|
1552
1578
|
failureThreshold: 5,
|
|
1553
1579
|
timeout: 1e4,
|
|
1554
1580
|
name: "subscription-change-manager"
|
|
@@ -1562,10 +1588,10 @@ class Rt {
|
|
|
1562
1588
|
throw new Error("Rate limit exceeded. Please try again later.");
|
|
1563
1589
|
try {
|
|
1564
1590
|
return await this.circuitBreaker.execute(
|
|
1565
|
-
() =>
|
|
1591
|
+
() => g(t, { ...b.STANDARD, name: n })
|
|
1566
1592
|
);
|
|
1567
1593
|
} catch (i) {
|
|
1568
|
-
throw i instanceof
|
|
1594
|
+
throw i instanceof m ? (c().error(`[SubscriptionChangeManager] Circuit breaker OPEN for ${a}`), new Error("Service temporarily unavailable. Please try again in a few moments.")) : i;
|
|
1569
1595
|
}
|
|
1570
1596
|
}
|
|
1571
1597
|
/** Change subscription plan (upgrade or downgrade) */
|
|
@@ -1575,14 +1601,14 @@ class Rt {
|
|
|
1575
1601
|
async () => {
|
|
1576
1602
|
const t = await this.routeDiscovery.buildUrl("/paywall/v1/subscription/change");
|
|
1577
1603
|
c().debug("[SubscriptionChangeManager] Changing subscription:", e);
|
|
1578
|
-
const n = await
|
|
1604
|
+
const n = await y(t, {
|
|
1579
1605
|
method: "POST",
|
|
1580
|
-
headers: { "Content-Type": "application/json", "Idempotency-Key":
|
|
1606
|
+
headers: { "Content-Type": "application/json", "Idempotency-Key": T() },
|
|
1581
1607
|
body: JSON.stringify(e)
|
|
1582
1608
|
});
|
|
1583
1609
|
if (!n.ok)
|
|
1584
1610
|
throw new Error(await v(n, "Failed to change subscription"));
|
|
1585
|
-
return n.json();
|
|
1611
|
+
return await n.json();
|
|
1586
1612
|
},
|
|
1587
1613
|
"subscription-change",
|
|
1588
1614
|
"plan change"
|
|
@@ -1595,14 +1621,14 @@ class Rt {
|
|
|
1595
1621
|
async () => {
|
|
1596
1622
|
const t = await this.routeDiscovery.buildUrl("/paywall/v1/subscription/change/preview");
|
|
1597
1623
|
c().debug("[SubscriptionChangeManager] Previewing subscription change:", e);
|
|
1598
|
-
const n = await
|
|
1624
|
+
const n = await y(t, {
|
|
1599
1625
|
method: "POST",
|
|
1600
1626
|
headers: { "Content-Type": "application/json" },
|
|
1601
1627
|
body: JSON.stringify(e)
|
|
1602
1628
|
});
|
|
1603
1629
|
if (!n.ok)
|
|
1604
1630
|
throw new Error(await v(n, "Failed to preview change"));
|
|
1605
|
-
return n.json();
|
|
1631
|
+
return await n.json();
|
|
1606
1632
|
},
|
|
1607
1633
|
"subscription-preview",
|
|
1608
1634
|
"change preview"
|
|
@@ -1615,13 +1641,13 @@ class Rt {
|
|
|
1615
1641
|
async () => {
|
|
1616
1642
|
const n = new URLSearchParams({ resource: e, userId: t }), a = await this.routeDiscovery.buildUrl(`/paywall/v1/subscription/details?${n}`);
|
|
1617
1643
|
c().debug("[SubscriptionChangeManager] Getting subscription details:", { resource: e, userId: t });
|
|
1618
|
-
const i = await
|
|
1644
|
+
const i = await y(a, {
|
|
1619
1645
|
method: "GET",
|
|
1620
1646
|
headers: { "Content-Type": "application/json" }
|
|
1621
1647
|
});
|
|
1622
1648
|
if (!i.ok)
|
|
1623
1649
|
throw new Error(await v(i, "Failed to get subscription details"));
|
|
1624
|
-
return i.json();
|
|
1650
|
+
return await i.json();
|
|
1625
1651
|
},
|
|
1626
1652
|
"subscription-details",
|
|
1627
1653
|
"details"
|
|
@@ -1634,14 +1660,14 @@ class Rt {
|
|
|
1634
1660
|
async () => {
|
|
1635
1661
|
const t = await this.routeDiscovery.buildUrl("/paywall/v1/subscription/cancel");
|
|
1636
1662
|
c().debug("[SubscriptionChangeManager] Canceling subscription:", e);
|
|
1637
|
-
const n = await
|
|
1663
|
+
const n = await y(t, {
|
|
1638
1664
|
method: "POST",
|
|
1639
1665
|
headers: { "Content-Type": "application/json" },
|
|
1640
1666
|
body: JSON.stringify(e)
|
|
1641
1667
|
});
|
|
1642
1668
|
if (!n.ok)
|
|
1643
1669
|
throw new Error(await v(n, "Failed to cancel subscription"));
|
|
1644
|
-
return n.json();
|
|
1670
|
+
return await n.json();
|
|
1645
1671
|
},
|
|
1646
1672
|
"subscription-cancel",
|
|
1647
1673
|
"cancellation"
|
|
@@ -1654,21 +1680,297 @@ class Rt {
|
|
|
1654
1680
|
async () => {
|
|
1655
1681
|
const t = await this.routeDiscovery.buildUrl("/paywall/v1/subscription/portal");
|
|
1656
1682
|
c().debug("[SubscriptionChangeManager] Getting billing portal URL:", e);
|
|
1657
|
-
const n = await
|
|
1683
|
+
const n = await y(t, {
|
|
1658
1684
|
method: "POST",
|
|
1659
1685
|
headers: { "Content-Type": "application/json" },
|
|
1660
1686
|
body: JSON.stringify(e)
|
|
1661
1687
|
});
|
|
1662
1688
|
if (!n.ok)
|
|
1663
1689
|
throw new Error(await v(n, "Failed to get billing portal URL"));
|
|
1664
|
-
return n.json();
|
|
1690
|
+
return await n.json();
|
|
1665
1691
|
},
|
|
1666
1692
|
"subscription-portal",
|
|
1667
1693
|
"portal"
|
|
1668
1694
|
);
|
|
1669
1695
|
}
|
|
1670
1696
|
}
|
|
1671
|
-
class
|
|
1697
|
+
class Ut {
|
|
1698
|
+
routeDiscovery;
|
|
1699
|
+
rateLimiter = R(M.PAYMENT);
|
|
1700
|
+
circuitBreaker = U({
|
|
1701
|
+
failureThreshold: 5,
|
|
1702
|
+
timeout: 1e4,
|
|
1703
|
+
name: "credits-manager"
|
|
1704
|
+
});
|
|
1705
|
+
constructor(e) {
|
|
1706
|
+
this.routeDiscovery = e;
|
|
1707
|
+
}
|
|
1708
|
+
async requestQuote(e, t) {
|
|
1709
|
+
if (!this.rateLimiter.tryConsume())
|
|
1710
|
+
throw new Error("Rate limit exceeded for credits quote. Please try again later.");
|
|
1711
|
+
try {
|
|
1712
|
+
return await this.circuitBreaker.execute(async () => await g(
|
|
1713
|
+
async () => {
|
|
1714
|
+
const n = await this.routeDiscovery.buildUrl("/paywall/v1/quote");
|
|
1715
|
+
c().debug("[CreditsManager] Requesting quote for resource:", e);
|
|
1716
|
+
const a = await y(n, {
|
|
1717
|
+
method: "POST",
|
|
1718
|
+
headers: { "Content-Type": "application/json" },
|
|
1719
|
+
body: JSON.stringify({ resource: e, couponCode: t })
|
|
1720
|
+
});
|
|
1721
|
+
if (a.status === 402)
|
|
1722
|
+
return (await a.json()).credits || null;
|
|
1723
|
+
if (!a.ok) {
|
|
1724
|
+
const i = await v(a, "Failed to get credits quote");
|
|
1725
|
+
throw new Error(i);
|
|
1726
|
+
}
|
|
1727
|
+
return null;
|
|
1728
|
+
},
|
|
1729
|
+
{ ...b.STANDARD, name: "credits-quote" }
|
|
1730
|
+
));
|
|
1731
|
+
} catch (n) {
|
|
1732
|
+
throw n instanceof m ? (c().error("[CreditsManager] Circuit breaker is OPEN - credits service unavailable"), new Error("Credits service is temporarily unavailable. Please try again in a few moments.")) : n;
|
|
1733
|
+
}
|
|
1734
|
+
}
|
|
1735
|
+
async requestCartQuote(e, t) {
|
|
1736
|
+
if (!this.rateLimiter.tryConsume())
|
|
1737
|
+
throw new Error("Rate limit exceeded for cart credits quote. Please try again later.");
|
|
1738
|
+
try {
|
|
1739
|
+
return await this.circuitBreaker.execute(async () => await g(
|
|
1740
|
+
async () => {
|
|
1741
|
+
const n = await this.routeDiscovery.buildUrl("/paywall/v1/cart/quote");
|
|
1742
|
+
c().debug("[CreditsManager] Requesting cart quote for items:", e.length);
|
|
1743
|
+
const a = await y(n, {
|
|
1744
|
+
method: "POST",
|
|
1745
|
+
headers: { "Content-Type": "application/json" },
|
|
1746
|
+
body: JSON.stringify({ items: e, couponCode: t })
|
|
1747
|
+
});
|
|
1748
|
+
if (!a.ok) {
|
|
1749
|
+
const o = await v(a, "Failed to get cart credits quote");
|
|
1750
|
+
throw new Error(o);
|
|
1751
|
+
}
|
|
1752
|
+
const i = await a.json();
|
|
1753
|
+
return i.credits ? {
|
|
1754
|
+
cartId: i.cartId,
|
|
1755
|
+
credits: i.credits
|
|
1756
|
+
} : null;
|
|
1757
|
+
},
|
|
1758
|
+
{ ...b.STANDARD, name: "credits-cart-quote" }
|
|
1759
|
+
));
|
|
1760
|
+
} catch (n) {
|
|
1761
|
+
throw n instanceof m ? new Error("Credits service is temporarily unavailable. Please try again in a few moments.") : n;
|
|
1762
|
+
}
|
|
1763
|
+
}
|
|
1764
|
+
/**
|
|
1765
|
+
* Create a hold on user's credits
|
|
1766
|
+
* Requires Authorization header with cedros-login JWT token
|
|
1767
|
+
*/
|
|
1768
|
+
async createHold(e) {
|
|
1769
|
+
const { resource: t, couponCode: n, authToken: a } = e;
|
|
1770
|
+
if (!this.rateLimiter.tryConsume())
|
|
1771
|
+
throw new Error("Rate limit exceeded for credits hold. Please try again later.");
|
|
1772
|
+
try {
|
|
1773
|
+
return await this.circuitBreaker.execute(async () => await g(
|
|
1774
|
+
async () => {
|
|
1775
|
+
const i = await this.routeDiscovery.buildUrl("/paywall/v1/credits/hold");
|
|
1776
|
+
c().debug("[CreditsManager] Creating hold for resource:", t);
|
|
1777
|
+
const o = await y(i, {
|
|
1778
|
+
method: "POST",
|
|
1779
|
+
headers: {
|
|
1780
|
+
"Content-Type": "application/json",
|
|
1781
|
+
Authorization: `Bearer ${a}`,
|
|
1782
|
+
"Idempotency-Key": T()
|
|
1783
|
+
},
|
|
1784
|
+
body: JSON.stringify({ resource: t, couponCode: n })
|
|
1785
|
+
});
|
|
1786
|
+
if (!o.ok) {
|
|
1787
|
+
const s = await v(o, "Failed to create credits hold");
|
|
1788
|
+
throw new Error(s);
|
|
1789
|
+
}
|
|
1790
|
+
return await o.json();
|
|
1791
|
+
},
|
|
1792
|
+
{ ...b.STANDARD, name: "credits-create-hold" }
|
|
1793
|
+
));
|
|
1794
|
+
} catch (i) {
|
|
1795
|
+
throw i instanceof m ? new Error("Credits service is temporarily unavailable. Please try again in a few moments.") : i;
|
|
1796
|
+
}
|
|
1797
|
+
}
|
|
1798
|
+
/**
|
|
1799
|
+
* Create a hold on user's credits for a cart
|
|
1800
|
+
* Requires Authorization header with cedros-login JWT token
|
|
1801
|
+
*/
|
|
1802
|
+
async createCartHold(e) {
|
|
1803
|
+
const { cartId: t, authToken: n } = e;
|
|
1804
|
+
if (!this.rateLimiter.tryConsume())
|
|
1805
|
+
throw new Error("Rate limit exceeded for cart credits hold. Please try again later.");
|
|
1806
|
+
try {
|
|
1807
|
+
return await this.circuitBreaker.execute(async () => await g(
|
|
1808
|
+
async () => {
|
|
1809
|
+
const a = await this.routeDiscovery.buildUrl(`/paywall/v1/cart/${t}/credits/hold`);
|
|
1810
|
+
c().debug("[CreditsManager] Creating cart hold for cart:", t);
|
|
1811
|
+
const i = await y(a, {
|
|
1812
|
+
method: "POST",
|
|
1813
|
+
headers: {
|
|
1814
|
+
"Content-Type": "application/json",
|
|
1815
|
+
Authorization: `Bearer ${n}`,
|
|
1816
|
+
"Idempotency-Key": T()
|
|
1817
|
+
},
|
|
1818
|
+
body: JSON.stringify({})
|
|
1819
|
+
});
|
|
1820
|
+
if (!i.ok) {
|
|
1821
|
+
const o = await v(i, "Failed to create cart credits hold");
|
|
1822
|
+
throw new Error(o);
|
|
1823
|
+
}
|
|
1824
|
+
return await i.json();
|
|
1825
|
+
},
|
|
1826
|
+
{ ...b.STANDARD, name: "credits-create-cart-hold" }
|
|
1827
|
+
));
|
|
1828
|
+
} catch (a) {
|
|
1829
|
+
throw a instanceof m ? new Error("Credits service is temporarily unavailable. Please try again in a few moments.") : a;
|
|
1830
|
+
}
|
|
1831
|
+
}
|
|
1832
|
+
async authorizePayment(e) {
|
|
1833
|
+
const { resource: t, holdId: n, couponCode: a, authToken: i, metadata: o } = e;
|
|
1834
|
+
if (!this.rateLimiter.tryConsume())
|
|
1835
|
+
return {
|
|
1836
|
+
success: !1,
|
|
1837
|
+
error: "Rate limit exceeded for credits authorization. Please try again later.",
|
|
1838
|
+
errorCode: "rate_limit_exceeded"
|
|
1839
|
+
};
|
|
1840
|
+
try {
|
|
1841
|
+
return await this.circuitBreaker.execute(async () => await g(
|
|
1842
|
+
async () => {
|
|
1843
|
+
const s = await this.routeDiscovery.buildUrl("/paywall/v1/credits/authorize");
|
|
1844
|
+
c().debug("[CreditsManager] Authorizing payment for resource:", t);
|
|
1845
|
+
const u = await y(s, {
|
|
1846
|
+
method: "POST",
|
|
1847
|
+
headers: {
|
|
1848
|
+
"Content-Type": "application/json",
|
|
1849
|
+
Authorization: `Bearer ${i}`,
|
|
1850
|
+
"Idempotency-Key": T()
|
|
1851
|
+
},
|
|
1852
|
+
body: JSON.stringify({
|
|
1853
|
+
resource: t,
|
|
1854
|
+
holdId: n,
|
|
1855
|
+
couponCode: a,
|
|
1856
|
+
...o && { metadata: o }
|
|
1857
|
+
})
|
|
1858
|
+
});
|
|
1859
|
+
if (!u.ok) {
|
|
1860
|
+
const d = await u.json().catch(() => ({}));
|
|
1861
|
+
return {
|
|
1862
|
+
success: !1,
|
|
1863
|
+
error: d.error?.message || "Credits authorization failed",
|
|
1864
|
+
errorCode: d.error?.code || "authorization_failed"
|
|
1865
|
+
};
|
|
1866
|
+
}
|
|
1867
|
+
return {
|
|
1868
|
+
success: !0,
|
|
1869
|
+
transactionId: (await u.json()).transactionId
|
|
1870
|
+
};
|
|
1871
|
+
},
|
|
1872
|
+
{ ...b.STANDARD, name: "credits-authorize" }
|
|
1873
|
+
));
|
|
1874
|
+
} catch (s) {
|
|
1875
|
+
return s instanceof m ? {
|
|
1876
|
+
success: !1,
|
|
1877
|
+
error: "Credits service is temporarily unavailable. Please try again in a few moments.",
|
|
1878
|
+
errorCode: "service_unavailable"
|
|
1879
|
+
} : {
|
|
1880
|
+
success: !1,
|
|
1881
|
+
error: k(s, "Credits authorization failed"),
|
|
1882
|
+
errorCode: "authorization_failed"
|
|
1883
|
+
};
|
|
1884
|
+
}
|
|
1885
|
+
}
|
|
1886
|
+
async authorizeCartPayment(e) {
|
|
1887
|
+
const { cartId: t, holdId: n, authToken: a, metadata: i } = e;
|
|
1888
|
+
if (!this.rateLimiter.tryConsume())
|
|
1889
|
+
return {
|
|
1890
|
+
success: !1,
|
|
1891
|
+
error: "Rate limit exceeded for cart credits authorization. Please try again later.",
|
|
1892
|
+
errorCode: "rate_limit_exceeded"
|
|
1893
|
+
};
|
|
1894
|
+
try {
|
|
1895
|
+
return await this.circuitBreaker.execute(async () => await g(
|
|
1896
|
+
async () => {
|
|
1897
|
+
const o = await this.routeDiscovery.buildUrl(`/paywall/v1/cart/${t}/credits/authorize`);
|
|
1898
|
+
c().debug("[CreditsManager] Authorizing cart payment for cart:", t);
|
|
1899
|
+
const s = await y(o, {
|
|
1900
|
+
method: "POST",
|
|
1901
|
+
headers: {
|
|
1902
|
+
"Content-Type": "application/json",
|
|
1903
|
+
Authorization: `Bearer ${a}`,
|
|
1904
|
+
"Idempotency-Key": T()
|
|
1905
|
+
},
|
|
1906
|
+
body: JSON.stringify({
|
|
1907
|
+
holdId: n,
|
|
1908
|
+
...i && { metadata: i }
|
|
1909
|
+
})
|
|
1910
|
+
});
|
|
1911
|
+
if (!s.ok) {
|
|
1912
|
+
const l = await s.json().catch((d) => (c().error("[CreditsManager] Failed to parse error response JSON:", d, {
|
|
1913
|
+
cartId: t,
|
|
1914
|
+
status: s.status,
|
|
1915
|
+
statusText: s.statusText
|
|
1916
|
+
}), {}));
|
|
1917
|
+
return {
|
|
1918
|
+
success: !1,
|
|
1919
|
+
error: l.error?.message || "Cart credits authorization failed",
|
|
1920
|
+
errorCode: l.error?.code || "authorization_failed"
|
|
1921
|
+
};
|
|
1922
|
+
}
|
|
1923
|
+
return {
|
|
1924
|
+
success: !0,
|
|
1925
|
+
transactionId: (await s.json()).transactionId
|
|
1926
|
+
};
|
|
1927
|
+
},
|
|
1928
|
+
{ ...b.STANDARD, name: "credits-cart-authorize" }
|
|
1929
|
+
));
|
|
1930
|
+
} catch (o) {
|
|
1931
|
+
return o instanceof m ? {
|
|
1932
|
+
success: !1,
|
|
1933
|
+
error: "Credits service is temporarily unavailable. Please try again in a few moments.",
|
|
1934
|
+
errorCode: "service_unavailable"
|
|
1935
|
+
} : {
|
|
1936
|
+
success: !1,
|
|
1937
|
+
error: k(o, "Cart credits authorization failed"),
|
|
1938
|
+
errorCode: "authorization_failed"
|
|
1939
|
+
};
|
|
1940
|
+
}
|
|
1941
|
+
}
|
|
1942
|
+
/**
|
|
1943
|
+
* Process a complete credits payment (convenience method)
|
|
1944
|
+
* Combines createHold + authorizePayment in one call
|
|
1945
|
+
*
|
|
1946
|
+
* @param resource - Resource being purchased
|
|
1947
|
+
* @param authToken - JWT token from cedros-login
|
|
1948
|
+
* @param couponCode - Optional coupon code
|
|
1949
|
+
* @param metadata - Optional metadata
|
|
1950
|
+
*/
|
|
1951
|
+
async processPayment(e, t, n, a) {
|
|
1952
|
+
try {
|
|
1953
|
+
const i = await this.createHold({ resource: e, couponCode: n, authToken: t }), o = await this.authorizePayment({
|
|
1954
|
+
resource: e,
|
|
1955
|
+
holdId: i.holdId,
|
|
1956
|
+
couponCode: n,
|
|
1957
|
+
authToken: t,
|
|
1958
|
+
metadata: a
|
|
1959
|
+
});
|
|
1960
|
+
return {
|
|
1961
|
+
success: o.success,
|
|
1962
|
+
transactionId: o.transactionId,
|
|
1963
|
+
error: o.error
|
|
1964
|
+
};
|
|
1965
|
+
} catch (i) {
|
|
1966
|
+
return {
|
|
1967
|
+
success: !1,
|
|
1968
|
+
error: k(i, "Credits payment failed")
|
|
1969
|
+
};
|
|
1970
|
+
}
|
|
1971
|
+
}
|
|
1972
|
+
}
|
|
1973
|
+
class Ot {
|
|
1672
1974
|
serverUrl;
|
|
1673
1975
|
routePrefix = null;
|
|
1674
1976
|
discoveryPromise = null;
|
|
@@ -1693,7 +1995,7 @@ class kt {
|
|
|
1693
1995
|
let t = 0;
|
|
1694
1996
|
for (; t < this.maxRetries; )
|
|
1695
1997
|
try {
|
|
1696
|
-
const n = await
|
|
1998
|
+
const n = await y(`${this.serverUrl}/cedros-health`);
|
|
1697
1999
|
if (!n.ok) {
|
|
1698
2000
|
if (n.status >= 400 && n.status < 500)
|
|
1699
2001
|
return c().warn(`Route discovery received ${n.status} - not retrying client error`), this.routePrefix = "", "";
|
|
@@ -1719,7 +2021,7 @@ class kt {
|
|
|
1719
2021
|
try {
|
|
1720
2022
|
return await this.discoveryPromise;
|
|
1721
2023
|
} finally {
|
|
1722
|
-
this.discoveryPromise = null;
|
|
2024
|
+
this.discoveryPromise === e && (this.discoveryPromise = null);
|
|
1723
2025
|
}
|
|
1724
2026
|
}
|
|
1725
2027
|
/**
|
|
@@ -1736,8 +2038,8 @@ class kt {
|
|
|
1736
2038
|
this.routePrefix = null, this.discoveryPromise = null;
|
|
1737
2039
|
}
|
|
1738
2040
|
}
|
|
1739
|
-
const
|
|
1740
|
-
function
|
|
2041
|
+
const K = /* @__PURE__ */ new Map();
|
|
2042
|
+
function Fe(r, e, t, n, a) {
|
|
1741
2043
|
return JSON.stringify({
|
|
1742
2044
|
stripePublicKey: r,
|
|
1743
2045
|
serverUrl: e,
|
|
@@ -1746,15 +2048,15 @@ function Ie(r, e, t, n, a) {
|
|
|
1746
2048
|
dangerouslyAllowUnknownMint: a || !1
|
|
1747
2049
|
});
|
|
1748
2050
|
}
|
|
1749
|
-
function
|
|
1750
|
-
const i =
|
|
2051
|
+
function Nt(r, e, t, n, a) {
|
|
2052
|
+
const i = Fe(
|
|
1751
2053
|
r,
|
|
1752
2054
|
e,
|
|
1753
2055
|
t,
|
|
1754
2056
|
n,
|
|
1755
2057
|
a
|
|
1756
2058
|
);
|
|
1757
|
-
let o =
|
|
2059
|
+
let o = K.get(i);
|
|
1758
2060
|
if (o)
|
|
1759
2061
|
return o.refCount++, c().debug(
|
|
1760
2062
|
`[ManagerCache] Reusing cached managers (refCount: ${o.refCount}):`,
|
|
@@ -1764,29 +2066,30 @@ function At(r, e, t, n, a) {
|
|
|
1764
2066
|
"[ManagerCache] Creating new manager instances:",
|
|
1765
2067
|
{ stripePublicKey: r.slice(0, 10) + "...", serverUrl: e }
|
|
1766
2068
|
);
|
|
1767
|
-
const s = new
|
|
2069
|
+
const s = new Ot(e), u = new lt(r, s), l = new bt(s), d = new Mt(
|
|
1768
2070
|
t,
|
|
1769
2071
|
n,
|
|
1770
2072
|
a ?? !1
|
|
1771
|
-
), f = new
|
|
2073
|
+
), f = new Dt(r, s), h = new Bt(s), A = new Ut(s);
|
|
1772
2074
|
return o = {
|
|
1773
2075
|
stripeManager: u,
|
|
1774
2076
|
x402Manager: l,
|
|
1775
2077
|
walletManager: d,
|
|
1776
2078
|
subscriptionManager: f,
|
|
1777
2079
|
subscriptionChangeManager: h,
|
|
2080
|
+
creditsManager: A,
|
|
1778
2081
|
routeDiscovery: s,
|
|
1779
2082
|
refCount: 1
|
|
1780
|
-
},
|
|
2083
|
+
}, K.set(i, o), o;
|
|
1781
2084
|
}
|
|
1782
|
-
function
|
|
1783
|
-
const i =
|
|
2085
|
+
function It(r, e, t, n, a) {
|
|
2086
|
+
const i = Fe(
|
|
1784
2087
|
r,
|
|
1785
2088
|
e,
|
|
1786
2089
|
t,
|
|
1787
2090
|
n,
|
|
1788
2091
|
a
|
|
1789
|
-
), o =
|
|
2092
|
+
), o = K.get(i);
|
|
1790
2093
|
if (!o) {
|
|
1791
2094
|
c().warn("[ManagerCache] Attempted to release non-existent managers:", { cacheKey: i });
|
|
1792
2095
|
return;
|
|
@@ -1794,21 +2097,21 @@ function Mt(r, e, t, n, a) {
|
|
|
1794
2097
|
o.refCount--, c().debug(
|
|
1795
2098
|
`[ManagerCache] Released manager reference (refCount: ${o.refCount}):`,
|
|
1796
2099
|
{ stripePublicKey: r.slice(0, 10) + "...", serverUrl: e }
|
|
1797
|
-
), o.refCount <= 0 && (
|
|
2100
|
+
), o.refCount <= 0 && (K.delete(i), c().debug("[ManagerCache] Removed managers from cache (refCount reached 0)"));
|
|
1798
2101
|
}
|
|
1799
|
-
const
|
|
2102
|
+
const Ft = [
|
|
1800
2103
|
"stripePublicKey"
|
|
1801
|
-
],
|
|
1802
|
-
function
|
|
2104
|
+
], Ae = /* @__PURE__ */ new Set(["mainnet-beta", "devnet", "testnet"]);
|
|
2105
|
+
function Lt() {
|
|
1803
2106
|
if (typeof window < "u" && window.location)
|
|
1804
2107
|
return window.location.origin;
|
|
1805
2108
|
throw new Error(
|
|
1806
2109
|
"serverUrl is required in SSR/Node environments. In browser environments, it defaults to window.location.origin"
|
|
1807
2110
|
);
|
|
1808
2111
|
}
|
|
1809
|
-
function
|
|
2112
|
+
function jt(r) {
|
|
1810
2113
|
const e = [];
|
|
1811
|
-
|
|
2114
|
+
Ft.forEach((n) => {
|
|
1812
2115
|
const a = r[n];
|
|
1813
2116
|
(typeof a != "string" || a.trim().length === 0) && e.push({
|
|
1814
2117
|
field: n,
|
|
@@ -1823,16 +2126,16 @@ function Ot(r) {
|
|
|
1823
2126
|
}), t = "") : t = r.serverUrl;
|
|
1824
2127
|
else
|
|
1825
2128
|
try {
|
|
1826
|
-
t =
|
|
2129
|
+
t = Lt();
|
|
1827
2130
|
} catch (n) {
|
|
1828
2131
|
e.push({
|
|
1829
2132
|
field: "serverUrl",
|
|
1830
2133
|
message: n instanceof Error ? n.message : "failed to determine default"
|
|
1831
2134
|
}), t = "";
|
|
1832
2135
|
}
|
|
1833
|
-
if (
|
|
2136
|
+
if (Ae.has(r.solanaCluster) || e.push({
|
|
1834
2137
|
field: "solanaCluster",
|
|
1835
|
-
message: `must be one of ${Array.from(
|
|
2138
|
+
message: `must be one of ${Array.from(Ae).join(", ")}`
|
|
1836
2139
|
}), r.solanaEndpoint !== void 0 && (typeof r.solanaEndpoint != "string" ? e.push({
|
|
1837
2140
|
field: "solanaEndpoint",
|
|
1838
2141
|
message: "must be a string when provided"
|
|
@@ -1852,7 +2155,7 @@ function Ot(r) {
|
|
|
1852
2155
|
${n}`);
|
|
1853
2156
|
}
|
|
1854
2157
|
if (r.tokenMint) {
|
|
1855
|
-
const n = r.dangerouslyAllowUnknownMint === !0, a =
|
|
2158
|
+
const n = r.dangerouslyAllowUnknownMint === !0, a = Ie(r.tokenMint, "CedrosConfig.tokenMint", n);
|
|
1856
2159
|
if (!a.isValid && a.error)
|
|
1857
2160
|
throw new Error(a.error);
|
|
1858
2161
|
a.warning && c().warn(a.warning);
|
|
@@ -1862,7 +2165,7 @@ ${n}`);
|
|
|
1862
2165
|
serverUrl: t
|
|
1863
2166
|
};
|
|
1864
2167
|
}
|
|
1865
|
-
class
|
|
2168
|
+
class zt {
|
|
1866
2169
|
adapters = null;
|
|
1867
2170
|
poolId;
|
|
1868
2171
|
isCleanedUp = !1;
|
|
@@ -1877,8 +2180,8 @@ class Nt {
|
|
|
1877
2180
|
*/
|
|
1878
2181
|
getAdapters() {
|
|
1879
2182
|
return typeof window > "u" ? [] : this.isCleanedUp ? (c().warn(`[WalletPool] Attempted to use pool after cleanup: ${this.poolId}`), []) : this.adapters !== null ? this.adapters : (c().debug(`[WalletPool] Initializing adapters for pool: ${this.poolId}`), this.adapters = [
|
|
1880
|
-
new
|
|
1881
|
-
new
|
|
2183
|
+
new He(),
|
|
2184
|
+
new Ve()
|
|
1882
2185
|
], this.adapters);
|
|
1883
2186
|
}
|
|
1884
2187
|
/**
|
|
@@ -1920,10 +2223,10 @@ class Nt {
|
|
|
1920
2223
|
return this.poolId;
|
|
1921
2224
|
}
|
|
1922
2225
|
}
|
|
1923
|
-
function
|
|
1924
|
-
return new
|
|
2226
|
+
function qt(r) {
|
|
2227
|
+
return new zt(r);
|
|
1925
2228
|
}
|
|
1926
|
-
const
|
|
2229
|
+
const Qt = Object.freeze({
|
|
1927
2230
|
surfaceBackground: "rgba(255, 255, 255, 0)",
|
|
1928
2231
|
surfaceText: "#111827",
|
|
1929
2232
|
surfaceBorder: "rgba(15, 23, 42, 0.08)",
|
|
@@ -1946,7 +2249,7 @@ const It = Object.freeze({
|
|
|
1946
2249
|
buttonPadding: "0.75rem 1.5rem",
|
|
1947
2250
|
buttonFontSize: "1rem",
|
|
1948
2251
|
buttonFontWeight: "600"
|
|
1949
|
-
}),
|
|
2252
|
+
}), Wt = Object.freeze({
|
|
1950
2253
|
surfaceBackground: "rgba(17, 24, 39, 0.6)",
|
|
1951
2254
|
surfaceText: "#f9fafb",
|
|
1952
2255
|
surfaceBorder: "rgba(148, 163, 184, 0.25)",
|
|
@@ -1969,7 +2272,7 @@ const It = Object.freeze({
|
|
|
1969
2272
|
buttonPadding: "0.75rem 1.5rem",
|
|
1970
2273
|
buttonFontSize: "1rem",
|
|
1971
2274
|
buttonFontWeight: "600"
|
|
1972
|
-
}),
|
|
2275
|
+
}), Ht = {
|
|
1973
2276
|
surfaceBackground: "--cedros-surface-bg",
|
|
1974
2277
|
surfaceText: "--cedros-surface-text",
|
|
1975
2278
|
surfaceBorder: "--cedros-surface-border",
|
|
@@ -1992,27 +2295,27 @@ const It = Object.freeze({
|
|
|
1992
2295
|
buttonPadding: "--cedros-button-padding",
|
|
1993
2296
|
buttonFontSize: "--cedros-button-font-size",
|
|
1994
2297
|
buttonFontWeight: "--cedros-button-font-weight"
|
|
1995
|
-
},
|
|
1996
|
-
function
|
|
2298
|
+
}, ie = ye(null);
|
|
2299
|
+
function Vt(r, e) {
|
|
1997
2300
|
return {
|
|
1998
|
-
...r === "dark" ?
|
|
2301
|
+
...r === "dark" ? Wt : Qt,
|
|
1999
2302
|
...e
|
|
2000
2303
|
};
|
|
2001
2304
|
}
|
|
2002
|
-
function
|
|
2305
|
+
function Gt(r) {
|
|
2003
2306
|
const e = Object.entries(r).map(([t, n]) => [
|
|
2004
|
-
|
|
2307
|
+
Ht[t],
|
|
2005
2308
|
n
|
|
2006
2309
|
]);
|
|
2007
2310
|
return Object.fromEntries(e);
|
|
2008
2311
|
}
|
|
2009
|
-
function
|
|
2312
|
+
function Kt({
|
|
2010
2313
|
initialMode: r = "light",
|
|
2011
2314
|
overrides: e,
|
|
2012
2315
|
unstyled: t = !1,
|
|
2013
2316
|
children: n
|
|
2014
2317
|
}) {
|
|
2015
|
-
const [a, i] =
|
|
2318
|
+
const [a, i] = Z(r), [o, s] = Z(e), u = we(e);
|
|
2016
2319
|
L(() => {
|
|
2017
2320
|
if (e === u.current)
|
|
2018
2321
|
return;
|
|
@@ -2020,8 +2323,8 @@ function _t({
|
|
|
2020
2323
|
(f) => e[f] !== u.current?.[f]
|
|
2021
2324
|
)) && (u.current = e, s(e));
|
|
2022
2325
|
}, [e]);
|
|
2023
|
-
const l =
|
|
2024
|
-
const d =
|
|
2326
|
+
const l = $(() => {
|
|
2327
|
+
const d = Vt(a, o), f = t ? {} : Gt(d), h = t ? "" : `cedros-theme-root cedros-theme cedros-theme--${a}`;
|
|
2025
2328
|
return {
|
|
2026
2329
|
mode: a,
|
|
2027
2330
|
setMode: i,
|
|
@@ -2031,31 +2334,34 @@ function _t({
|
|
|
2031
2334
|
unstyled: t
|
|
2032
2335
|
};
|
|
2033
2336
|
}, [a, o, t]);
|
|
2034
|
-
return /* @__PURE__ */ X(
|
|
2337
|
+
return /* @__PURE__ */ X(ie.Provider, { value: l, children: n });
|
|
2035
2338
|
}
|
|
2036
|
-
function
|
|
2037
|
-
const r =
|
|
2339
|
+
function nr() {
|
|
2340
|
+
const r = re(ie);
|
|
2038
2341
|
if (!r)
|
|
2039
2342
|
throw new Error("useCedrosTheme must be used within CedrosProvider");
|
|
2040
2343
|
return r;
|
|
2041
2344
|
}
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2345
|
+
function ar() {
|
|
2346
|
+
return re(ie);
|
|
2347
|
+
}
|
|
2348
|
+
let J = !1, Y = !1;
|
|
2349
|
+
async function Jt() {
|
|
2350
|
+
if (J)
|
|
2351
|
+
return Y ? { available: !0 } : {
|
|
2046
2352
|
available: !1,
|
|
2047
|
-
error:
|
|
2353
|
+
error: pe()
|
|
2048
2354
|
};
|
|
2049
2355
|
try {
|
|
2050
|
-
return await import("@solana/web3.js"),
|
|
2356
|
+
return await import("@solana/web3.js"), J = !0, Y = !0, { available: !0 };
|
|
2051
2357
|
} catch {
|
|
2052
|
-
return
|
|
2358
|
+
return J = !0, Y = !1, {
|
|
2053
2359
|
available: !1,
|
|
2054
|
-
error:
|
|
2360
|
+
error: pe()
|
|
2055
2361
|
};
|
|
2056
2362
|
}
|
|
2057
2363
|
}
|
|
2058
|
-
function
|
|
2364
|
+
function pe() {
|
|
2059
2365
|
return `Solana dependencies not installed. To use crypto payments, install them with:
|
|
2060
2366
|
|
|
2061
2367
|
npm install @solana/web3.js @solana/spl-token @solana/wallet-adapter-react @solana/wallet-adapter-react-ui @solana/wallet-adapter-wallets @solana/wallet-adapter-base
|
|
@@ -2063,23 +2369,23 @@ npm install @solana/web3.js @solana/spl-token @solana/wallet-adapter-react @sola
|
|
|
2063
2369
|
Or if you only need Stripe payments, hide the crypto button with:
|
|
2064
2370
|
<CedrosPay showCrypto={false} />`;
|
|
2065
2371
|
}
|
|
2066
|
-
function
|
|
2372
|
+
function Yt() {
|
|
2067
2373
|
return typeof process < "u" && process.env.NODE_ENV === "development" ? 0 : 2;
|
|
2068
2374
|
}
|
|
2069
|
-
const
|
|
2070
|
-
function
|
|
2071
|
-
const t =
|
|
2072
|
-
n.current === null && (n.current =
|
|
2073
|
-
const [a, i] =
|
|
2375
|
+
const Le = ye(null);
|
|
2376
|
+
function ir({ config: r, children: e }) {
|
|
2377
|
+
const t = $(() => jt(r), [r]), n = we(null);
|
|
2378
|
+
n.current === null && (n.current = qt());
|
|
2379
|
+
const [a, i] = Z(null);
|
|
2074
2380
|
L(() => {
|
|
2075
2381
|
let s = !1;
|
|
2076
|
-
return
|
|
2382
|
+
return Jt().then((u) => {
|
|
2077
2383
|
s || (u.available ? i(void 0) : i(u.error || "Solana dependencies not available"));
|
|
2078
2384
|
}), () => {
|
|
2079
2385
|
s = !0;
|
|
2080
2386
|
};
|
|
2081
2387
|
}, []), L(() => {
|
|
2082
|
-
const s = t.logLevel ??
|
|
2388
|
+
const s = t.logLevel ?? Yt(), u = rt({
|
|
2083
2389
|
level: s,
|
|
2084
2390
|
prefix: "[CedrosPay]"
|
|
2085
2391
|
});
|
|
@@ -2094,7 +2400,7 @@ function Yt({ config: r, children: e }) {
|
|
|
2094
2400
|
}, []), L(() => {
|
|
2095
2401
|
const s = t.stripePublicKey, u = t.serverUrl ?? "", l = t.solanaCluster, d = t.solanaEndpoint, f = t.dangerouslyAllowUnknownMint;
|
|
2096
2402
|
return () => {
|
|
2097
|
-
|
|
2403
|
+
It(s, u, l, d, f);
|
|
2098
2404
|
};
|
|
2099
2405
|
}, [
|
|
2100
2406
|
t.stripePublicKey,
|
|
@@ -2103,8 +2409,8 @@ function Yt({ config: r, children: e }) {
|
|
|
2103
2409
|
t.solanaEndpoint,
|
|
2104
2410
|
t.dangerouslyAllowUnknownMint
|
|
2105
2411
|
]);
|
|
2106
|
-
const o =
|
|
2107
|
-
const { stripeManager: s, x402Manager: u, walletManager: l, subscriptionManager: d, subscriptionChangeManager: f } =
|
|
2412
|
+
const o = $(() => {
|
|
2413
|
+
const { stripeManager: s, x402Manager: u, walletManager: l, subscriptionManager: d, subscriptionChangeManager: f, creditsManager: h } = Nt(
|
|
2108
2414
|
t.stripePublicKey,
|
|
2109
2415
|
t.serverUrl ?? "",
|
|
2110
2416
|
t.solanaCluster,
|
|
@@ -2118,12 +2424,13 @@ function Yt({ config: r, children: e }) {
|
|
|
2118
2424
|
walletManager: l,
|
|
2119
2425
|
subscriptionManager: d,
|
|
2120
2426
|
subscriptionChangeManager: f,
|
|
2427
|
+
creditsManager: h,
|
|
2121
2428
|
walletPool: n.current,
|
|
2122
2429
|
solanaError: a
|
|
2123
2430
|
};
|
|
2124
2431
|
}, [t, a]);
|
|
2125
|
-
return /* @__PURE__ */ X(
|
|
2126
|
-
|
|
2432
|
+
return /* @__PURE__ */ X(Le.Provider, { value: o, children: /* @__PURE__ */ X(
|
|
2433
|
+
Kt,
|
|
2127
2434
|
{
|
|
2128
2435
|
initialMode: t.theme ?? "light",
|
|
2129
2436
|
overrides: t.themeOverrides,
|
|
@@ -2132,32 +2439,36 @@ function Yt({ config: r, children: e }) {
|
|
|
2132
2439
|
}
|
|
2133
2440
|
) });
|
|
2134
2441
|
}
|
|
2135
|
-
function
|
|
2136
|
-
const r =
|
|
2442
|
+
function or() {
|
|
2443
|
+
const r = re(Le);
|
|
2137
2444
|
if (!r)
|
|
2138
2445
|
throw new Error("useCedrosContext must be used within CedrosProvider");
|
|
2139
2446
|
return r;
|
|
2140
2447
|
}
|
|
2141
2448
|
export {
|
|
2142
|
-
|
|
2449
|
+
ir as C,
|
|
2143
2450
|
te as K,
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2451
|
+
_e as L,
|
|
2452
|
+
M as R,
|
|
2453
|
+
Tt as S,
|
|
2454
|
+
zt as W,
|
|
2455
|
+
nr as a,
|
|
2148
2456
|
Ee as b,
|
|
2149
2457
|
R as c,
|
|
2150
2458
|
rt as d,
|
|
2151
|
-
|
|
2152
|
-
|
|
2459
|
+
Ie as e,
|
|
2460
|
+
k as f,
|
|
2153
2461
|
c as g,
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2462
|
+
he as h,
|
|
2463
|
+
y as i,
|
|
2464
|
+
ar as j,
|
|
2465
|
+
U as k,
|
|
2466
|
+
it as l,
|
|
2467
|
+
m,
|
|
2468
|
+
rr as n,
|
|
2469
|
+
b as o,
|
|
2470
|
+
qt as p,
|
|
2471
|
+
g as r,
|
|
2472
|
+
or as u,
|
|
2473
|
+
jt as v
|
|
2163
2474
|
};
|