@unifold/core 0.1.68-beta.0 → 0.1.68-beta.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/dist/index.d.mts CHANGED
@@ -108,9 +108,9 @@ declare enum ExecutionStatus {
108
108
  }
109
109
  interface IconUrl {
110
110
  url: string;
111
- format: "svg" | "png";
111
+ format: 'svg' | 'png';
112
112
  }
113
- type ProductType = "deposit" | "payment";
113
+ type ProductType = 'deposit' | 'payment';
114
114
  interface DirectExecutionResponse {
115
115
  id: string;
116
116
  project_id: string;
@@ -277,7 +277,7 @@ declare function getTokenMetadata(request: GetTokenMetadataRequest, publishableK
277
277
  * @param preferredFormat - Preferred format ("svg" or "png"), defaults to "svg"
278
278
  * @returns The URL string for the preferred format, or first available if preferred not found
279
279
  */
280
- declare function getPreferredIconUrl(iconUrls: IconUrl[] | undefined, preferredFormat?: "svg" | "png"): string | undefined;
280
+ declare function getPreferredIconUrl(iconUrls: IconUrl[] | undefined, preferredFormat?: 'svg' | 'png'): string | undefined;
281
281
  interface FiatCurrency {
282
282
  currency_code: string;
283
283
  name: string;
@@ -343,8 +343,11 @@ declare function getOnrampQuotes(request: OnrampQuotesRequest, publishableKey?:
343
343
  /**
344
344
  * Payment method for an onramp session. Defaults to `card` server-side.
345
345
  * `sepa` routes the session through SEPA bank transfer (Swapped-only today).
346
+ * `apple_pay` preselects Apple Pay on Coinbase's standard onramp surface
347
+ * (Coinbase only) — useful as a fallback when the headless Apple Pay flow
348
+ * is unavailable.
346
349
  */
347
- type OnrampSessionPaymentMethod = "card" | "sepa";
350
+ type OnrampSessionPaymentMethod = 'card' | 'sepa' | 'apple_pay';
348
351
  interface OnrampSessionRequest {
349
352
  service_provider: string;
350
353
  country_code: string;
@@ -414,6 +417,28 @@ interface GetBankTransferProvidersOptions {
414
417
  * availability + the caller-supplied country.
415
418
  */
416
419
  declare function getBankTransferProviders(publishableKey?: string, options?: GetBankTransferProvidersOptions): Promise<BankTransferProvidersResponse>;
420
+ interface ApplePayProvider {
421
+ service_provider: string;
422
+ service_provider_display_name: string;
423
+ description: string;
424
+ icon_url: string;
425
+ icon_urls: Array<{
426
+ url: string;
427
+ format: string;
428
+ }>;
429
+ enabled: boolean;
430
+ payment_methods: string[];
431
+ supported_countries: string[];
432
+ }
433
+ interface ApplePayProvidersResponse {
434
+ data: ApplePayProvider[];
435
+ }
436
+ /**
437
+ * Get supported Apple Pay onramp providers. The response is geo-restricted:
438
+ * only returns providers when the caller IP is in a supported region (US
439
+ * excluding NY for Coinbase) and the project has Apple Pay enabled.
440
+ */
441
+ declare function getApplePayProviders(publishableKey?: string): Promise<ApplePayProvidersResponse>;
417
442
  /**
418
443
  * Generate a URL for the sessions/start endpoint that redirects to the onramp provider.
419
444
  * This is useful for avoiding popup blockers by opening the URL directly via anchor tag.
@@ -505,6 +530,7 @@ interface FeaturedWallet {
505
530
  icon_urls: IconUrl[];
506
531
  }
507
532
  interface ProjectConfigResponse {
533
+ project_id?: string;
508
534
  project_name?: string;
509
535
  asset_cdn_url: string;
510
536
  transfer_crypto: {
@@ -526,11 +552,21 @@ interface ProjectConfigResponse {
526
552
  cash_app?: {
527
553
  enabled: boolean;
528
554
  };
555
+ apple_pay?: {
556
+ enabled: boolean;
557
+ };
529
558
  pay_with_exchange?: {
530
559
  enabled: boolean;
531
560
  };
532
561
  fiat_onramp?: {
562
+ /** Developer/merchant-controlled toggle (dashboard + SDK prop). */
533
563
  enabled: boolean;
564
+ /**
565
+ * Platform-controlled hard hide, independent of `enabled`. Defaults to
566
+ * false. When true, the fiat on-ramp must be hidden regardless of `enabled`
567
+ * or the SDK prop.
568
+ */
569
+ is_hidden?: boolean;
534
570
  };
535
571
  deposit_tracker?: {
536
572
  enabled: boolean;
@@ -553,7 +589,21 @@ interface BankTransferConfig {
553
589
  * Get project configuration
554
590
  * @param publishableKey - Optional publishable key, defaults to configured key
555
591
  */
556
- declare function getProjectConfig(publishableKey?: string): Promise<ProjectConfigResponse>;
592
+ /**
593
+ * Optional caller-location hints for {@link getProjectConfig}.
594
+ *
595
+ * When `countryCode` is provided it is sent to the API, which uses it for
596
+ * region-based settings (e.g. whether the fiat on-ramp is hidden) and skips
597
+ * server-side IP geolocation. Omit to let the backend resolve the region from
598
+ * the request IP.
599
+ */
600
+ interface GetProjectConfigOptions {
601
+ /** ISO 3166-1 alpha-2 country code (e.g. "US"). */
602
+ countryCode?: string;
603
+ /** ISO 3166-2 subdivision code (e.g. "CA"). */
604
+ subdivisionCode?: string;
605
+ }
606
+ declare function getProjectConfig(publishableKey?: string, options?: GetProjectConfigOptions): Promise<ProjectConfigResponse>;
557
607
  interface IpAddressResponse {
558
608
  alpha2: string;
559
609
  alpha3: string;
@@ -613,9 +663,9 @@ interface AddressBalancesResponse {
613
663
  */
614
664
  declare function getAddressBalances(address: string, chainType: ChainType, publishableKey?: string): Promise<AddressBalancesResponse>;
615
665
  /** Wallet ids supported by the connect-wallet flow. */
616
- type WalletMobileDeepLinkWallet = "phantom" | "metamask" | "coinbase" | "trust" | "rainbow" | "rabby" | "okx";
666
+ type WalletMobileDeepLinkWallet = 'phantom' | 'metamask' | 'coinbase' | 'trust' | 'rainbow' | 'rabby' | 'okx';
617
667
  /** Chain types an external wallet can connect on. */
618
- type ExternalWalletChainType = "ethereum" | "solana";
668
+ type ExternalWalletChainType = 'ethereum' | 'solana';
619
669
  /** A supported external (self-custody) wallet from the directory endpoint. */
620
670
  interface ExternalWalletInfo {
621
671
  id: WalletMobileDeepLinkWallet;
@@ -625,7 +675,7 @@ interface ExternalWalletInfo {
625
675
  icon_url: string;
626
676
  icon_urls: Array<{
627
677
  url: string;
628
- format: "svg" | "png";
678
+ format: 'svg' | 'png';
629
679
  }>;
630
680
  /** Whether the wallet can be opened into its in-app browser on mobile. */
631
681
  supports_mobile_browse: boolean;
@@ -634,7 +684,7 @@ interface ExternalWalletInfo {
634
684
  * `null` means all platforms; an explicit list (e.g. `["ios"]`) tells the
635
685
  * client to only offer mobile-browse on those platforms.
636
686
  */
637
- mobile_browse_platforms: ("ios" | "android")[] | null;
687
+ mobile_browse_platforms: ('ios' | 'android')[] | null;
638
688
  }
639
689
  interface ExternalWalletsResponse {
640
690
  data: ExternalWalletInfo[];
@@ -855,9 +905,9 @@ interface IntegrationAccount {
855
905
  icon_urls: IconUrl[];
856
906
  }
857
907
  type AuthenticateOAuthResult = {
858
- status: "pending";
908
+ status: 'pending';
859
909
  } | {
860
- status: "completed";
910
+ status: 'completed';
861
911
  accounts: IntegrationAccount[];
862
912
  access_token: string;
863
913
  expires_at: string;
@@ -992,13 +1042,13 @@ interface PaymentIntentDepositAddress {
992
1042
  * this vocabulary; the `awaiting_refund` / `refunding` / `refunded` /
993
1043
  * `refund_failed` states are only reachable for `type === 'locked_quote'` in v1.
994
1044
  */
995
- type PaymentIntentStatus = "requires_payment" | "processing" | "succeeded" | "canceled" | "expired" | "awaiting_refund" | "refunding" | "refunded" | "refund_failed";
1045
+ type PaymentIntentStatus = 'requires_payment' | 'processing' | 'succeeded' | 'canceled' | 'expired' | 'awaiting_refund' | 'refunding' | 'refunded' | 'refund_failed';
996
1046
  /**
997
1047
  * Product mode of a payment intent. `default` is the standard PI flow.
998
1048
  * `locked_quote` adds time-boxed rate locking, source-side amount tracking,
999
1049
  * an expiration timer, and a refund flow. Same row, different mode.
1000
1050
  */
1001
- type PaymentIntentType = "default" | "locked_quote";
1051
+ type PaymentIntentType = 'default' | 'locked_quote';
1002
1052
  interface PaymentIntent {
1003
1053
  id: string;
1004
1054
  /** Discriminator — `default` for the standard flow, `locked_quote` for rate-locked. */
@@ -1319,7 +1369,476 @@ interface CashAppLimits {
1319
1369
  declare function getCashAppLimits(currency?: string, publishableKey?: string): Promise<CashAppLimits>;
1320
1370
  declare function createCashAppSession(request: CashAppSessionRequest, publishableKey?: string): Promise<CashAppSessionResponse>;
1321
1371
  declare function getCashAppSessionStatus(externalId: string, publishableKey?: string): Promise<CashAppSessionStatusResponse>;
1372
+ interface StripeConfigResponse {
1373
+ publishable_key: string;
1374
+ merchant_identifier: string | null;
1375
+ }
1376
+ interface StripeAuthIntentResponse {
1377
+ auth_intent_id: string;
1378
+ expires_at: number;
1379
+ }
1380
+ interface StripeAccessTokenResponse {
1381
+ access_token: string;
1382
+ refresh_token?: string;
1383
+ token_type: string;
1384
+ expires_in: number;
1385
+ scope?: string;
1386
+ /** Stripe sometimes nests the refresh token here instead of top-level */
1387
+ refresh?: {
1388
+ refresh_token: string;
1389
+ expires_in: number;
1390
+ };
1391
+ }
1392
+ interface StripeCustomerVerification {
1393
+ name: string;
1394
+ status: 'not_started' | 'pending' | 'rejected' | 'verified';
1395
+ errors: string[];
1396
+ }
1397
+ interface StripeCryptoCustomer {
1398
+ id: string;
1399
+ object: string;
1400
+ provided_fields: string[];
1401
+ verifications: StripeCustomerVerification[];
1402
+ }
1403
+ interface StripeConsumerWallet {
1404
+ id: string;
1405
+ livemode: boolean;
1406
+ network: string;
1407
+ wallet_address: string;
1408
+ chain_type?: string;
1409
+ chain_id?: string;
1410
+ }
1411
+ interface StripePaymentToken {
1412
+ id: string;
1413
+ type: 'card' | 'us_bank_account';
1414
+ card?: {
1415
+ brand?: string;
1416
+ last4?: string;
1417
+ exp_month?: number;
1418
+ exp_year?: number;
1419
+ funding: string;
1420
+ wallet?: {
1421
+ type: string;
1422
+ };
1423
+ };
1424
+ us_bank_account?: {
1425
+ account_type?: string;
1426
+ last4?: string;
1427
+ bank_name?: string;
1428
+ };
1429
+ }
1430
+ interface StripeListResponse<T> {
1431
+ data: T[];
1432
+ has_more: boolean;
1433
+ }
1434
+ interface StripeCreateSessionRequest {
1435
+ cryptoCustomerId: string;
1436
+ paymentToken: string;
1437
+ sourceAmount: number;
1438
+ sourceCurrency: string;
1439
+ destinationCurrency: string;
1440
+ destinationNetwork: string;
1441
+ walletAddress: string;
1442
+ }
1443
+ interface StripeOnrampTransactionDetails {
1444
+ wallet_address?: string;
1445
+ wallet_addresses?: Record<string, string> | null;
1446
+ source_amount?: string;
1447
+ source_currency?: string;
1448
+ destination_amount?: string;
1449
+ destination_currency?: string;
1450
+ destination_network?: string;
1451
+ fees?: {
1452
+ network_fee_amount?: string;
1453
+ transaction_fee_amount?: string;
1454
+ };
1455
+ quote_expiration?: number;
1456
+ transaction_id?: string | null;
1457
+ last_error?: string | null;
1458
+ }
1459
+ interface StripeOnrampSession {
1460
+ id: string;
1461
+ object: string;
1462
+ status: string;
1463
+ client_secret?: string;
1464
+ crypto_customer_id?: string;
1465
+ livemode?: boolean;
1466
+ transaction_details?: StripeOnrampTransactionDetails;
1467
+ }
1468
+ interface StripeConfirmRequest {
1469
+ mandateData?: Record<string, unknown>;
1470
+ }
1471
+ interface StripeDefaultTokenResponse {
1472
+ destination_network: string;
1473
+ destination_currency: string;
1474
+ destination_token_metadata: {
1475
+ icon_url?: string;
1476
+ icon_urls?: Array<{
1477
+ url: string;
1478
+ format: string;
1479
+ }>;
1480
+ decimals?: number;
1481
+ symbol: string;
1482
+ name: string;
1483
+ token_address: string;
1484
+ chain_id: string;
1485
+ chain_type: string;
1486
+ chain_name: string;
1487
+ chain?: {
1488
+ icon_url?: string;
1489
+ icon_urls?: Array<{
1490
+ url: string;
1491
+ format: string;
1492
+ }>;
1493
+ chain_id: string;
1494
+ chain_name: string;
1495
+ chain_type: string;
1496
+ };
1497
+ };
1498
+ estimated_processing_time: number | null;
1499
+ }
1500
+ /**
1501
+ * Get the default token for the Stripe headless onramp flow.
1502
+ * Requires the user's destination token context (same params as the
1503
+ * non-headless default_token endpoint).
1504
+ */
1505
+ declare function stripeGetDefaultToken(params: {
1506
+ tokenAddress: string;
1507
+ chainId: string;
1508
+ chainType: string;
1509
+ countryCode?: string;
1510
+ }, publishableKey?: string): Promise<StripeDefaultTokenResponse>;
1511
+ interface StripeQuoteRequest {
1512
+ sourceAmount: string;
1513
+ sourceCurrency: string;
1514
+ destinationCurrency: string;
1515
+ destinationNetwork: string;
1516
+ }
1517
+ interface StripeQuotesResponse {
1518
+ source_amount: number;
1519
+ source_currency: string;
1520
+ total_fee: number;
1521
+ source_total_amount: number;
1522
+ destination_amount: number;
1523
+ destination_currency: string;
1524
+ destination_network: string;
1525
+ service_provider: string;
1526
+ service_provider_display_name: string;
1527
+ destination_network_quotes: Record<string, unknown[]>;
1528
+ }
1529
+ /**
1530
+ * Backend error_type values for headless Stripe onramp failures. The SDK can
1531
+ * branch on these instead of string-matching Stripe messages.
1532
+ */
1533
+ type StripeOnrampErrorType = 'stripe_onramp_missing_minimum_identity_verification' | 'stripe_onramp_missing_identity_verification' | 'stripe_onramp_missing_document_verification' | 'stripe_onramp_purchase_limit_reached' | 'stripe_onramp_bad_request' | 'stripe_onramp_forbidden' | 'stripe_onramp_not_found' | 'stripe_onramp_upstream_error' | (string & NonNullable<unknown>);
1534
+ declare class StripeApiResponseError extends Error {
1535
+ readonly statusCode: number;
1536
+ /** Underlying Stripe error code (e.g. `crypto_onramp_session_error`), when available */
1537
+ readonly stripeCode?: string | undefined;
1538
+ /** Unifold backend error_type (e.g. `stripe_onramp_missing_document_verification`) */
1539
+ readonly errorType?: StripeOnrampErrorType | undefined;
1540
+ constructor(message: string, statusCode: number,
1541
+ /** Underlying Stripe error code (e.g. `crypto_onramp_session_error`), when available */
1542
+ stripeCode?: string | undefined,
1543
+ /** Unifold backend error_type (e.g. `stripe_onramp_missing_document_verification`) */
1544
+ errorType?: StripeOnrampErrorType | undefined);
1545
+ }
1546
+ /**
1547
+ * Fetch Stripe config (publishable key + merchant ID) for SDK initialization.
1548
+ * The Stripe publishable key is stored server-side per project, so consumers
1549
+ * don't need to pass it manually — this endpoint returns it.
1550
+ */
1551
+ declare function stripeGetConfig(publishableKey?: string): Promise<StripeConfigResponse>;
1552
+ /**
1553
+ * Create a LinkAuthIntent to start the Stripe Link OAuth flow.
1554
+ * Only `email` is required — OAuth scopes are configured server-side.
1555
+ */
1556
+ declare function stripeCreateAuthIntent(email: string, publishableKey?: string): Promise<StripeAuthIntentResponse>;
1557
+ /**
1558
+ * Exchange a consented LinkAuthIntent for OAuth access tokens.
1559
+ */
1560
+ declare function stripeExchangeTokens(authIntentId: string, publishableKey?: string): Promise<StripeAccessTokenResponse>;
1561
+ /**
1562
+ * Refresh an expired OAuth access token.
1563
+ */
1564
+ declare function stripeRefreshToken(refreshToken: string, publishableKey?: string): Promise<StripeAccessTokenResponse>;
1565
+ declare function stripeGetCustomer(customerId: string, oauthToken: string, publishableKey?: string): Promise<StripeCryptoCustomer>;
1566
+ /**
1567
+ * List wallet addresses registered for a CryptoCustomer.
1568
+ * Endpoint: GET /customers/:id/wallet_addresses
1569
+ */
1570
+ declare function stripeListWallets(customerId: string, oauthToken: string, publishableKey?: string): Promise<StripeListResponse<StripeConsumerWallet>>;
1571
+ declare function stripeListPaymentTokens(customerId: string, oauthToken: string, publishableKey?: string): Promise<StripeListResponse<StripePaymentToken>>;
1572
+ /**
1573
+ * Create a headless CryptoOnrampSession.
1574
+ * Uses `walletAddress` (string) not `wallet_addresses` (object).
1575
+ */
1576
+ declare function stripeCreateSession(request: StripeCreateSessionRequest, oauthToken: string, publishableKey?: string): Promise<StripeOnrampSession>;
1577
+ /**
1578
+ * Confirm a CryptoOnrampSession to initiate payment.
1579
+ * Endpoint: POST /sessions/:id/confirm (not /checkout)
1580
+ */
1581
+ declare function stripeConfirmSession(sessionId: string, oauthToken: string, request?: StripeConfirmRequest, publishableKey?: string): Promise<StripeOnrampSession>;
1582
+ declare function stripeRefreshQuote(sessionId: string, oauthToken: string, publishableKey?: string): Promise<StripeOnrampSession>;
1583
+ /**
1584
+ * Retrieve a CryptoOnrampSession by ID.
1585
+ */
1586
+ declare function stripeGetSession(sessionId: string, oauthToken: string, publishableKey?: string): Promise<StripeOnrampSession>;
1587
+ /**
1588
+ * Get onramp quotes from Stripe — returns quotes grouped by network
1589
+ * with destination amounts, fees, and totals.
1590
+ */
1591
+ /**
1592
+ * Get onramp quotes from Stripe. Same shape as the unified onramp quotes
1593
+ * (sourceAmount, sourceCurrency, destinationCurrency, destinationNetwork).
1594
+ * OAuth token is optional — without it, returns indicative pricing.
1595
+ */
1596
+ declare function stripeGetQuotes(request: StripeQuoteRequest, oauthToken?: string, publishableKey?: string): Promise<StripeQuotesResponse>;
1597
+ interface StripeTransactionLimitEntry {
1598
+ limit: number;
1599
+ settlement_speed: 'instant' | 'standard';
1600
+ }
1601
+ /** limits keyed by source currency → payment method → entries */
1602
+ interface StripeTransactionLimitsResponse {
1603
+ object: string;
1604
+ crypto_customer_id: string;
1605
+ livemode: boolean;
1606
+ limits: Record<string, Record<string, StripeTransactionLimitEntry[]>>;
1607
+ }
1608
+ /**
1609
+ * Retrieve the customer's remaining onramp transaction limits.
1610
+ * Use this to proactively detect when a desired amount exceeds the limit
1611
+ * for the customer's current KYC tier before attempting to create a session.
1612
+ */
1613
+ declare function stripeGetTransactionLimits(params: {
1614
+ cryptoCustomerId: string;
1615
+ destinationNetwork: string;
1616
+ walletAddress: string;
1617
+ destinationTag?: string;
1618
+ refresh?: boolean;
1619
+ }, oauthToken: string, publishableKey?: string): Promise<StripeTransactionLimitsResponse>;
1322
1620
  declare function sendHypercoreTransaction(request: SendHypercoreTransactionRequest, publishableKey?: string): Promise<SendHypercoreTransactionResponse>;
1621
+ interface CoinbaseLegalAgreement {
1622
+ key: string;
1623
+ name: string;
1624
+ url: string;
1625
+ }
1626
+ interface CoinbaseLegalAgreementsResponse {
1627
+ agreements: CoinbaseLegalAgreement[];
1628
+ /** Disclosure copy; `{{links}}` is replaced with the joined agreement links. */
1629
+ disclosure: string;
1630
+ }
1631
+ /** Coinbase Guest Checkout ToS / User Agreement / Privacy URLs. Safe to cache. */
1632
+ declare function getCoinbaseLegalAgreements(publishableKey?: string): Promise<CoinbaseLegalAgreementsResponse>;
1633
+ type OnrampVerificationFactorStatus = 'unverified' | 'verified';
1634
+ interface OnrampVerificationFactor {
1635
+ status: OnrampVerificationFactorStatus;
1636
+ verified_at?: string;
1637
+ }
1638
+ type OnrampVerificationStatus = 'requires_input' | 'verified' | 'expired' | 'canceled';
1639
+ interface OnrampVerificationSession {
1640
+ id: string;
1641
+ object: 'onramp.verification_session';
1642
+ status: OnrampVerificationStatus;
1643
+ /** Returned ONLY on creation. Required on all subsequent actions. */
1644
+ client_secret?: string;
1645
+ email: OnrampVerificationFactor;
1646
+ phone: OnrampVerificationFactor;
1647
+ expires_at: string;
1648
+ }
1649
+ interface CreateOnrampVerificationSessionRequest {
1650
+ email: string;
1651
+ /** US phone in E.164 (e.g. +12345678901). */
1652
+ phone: string;
1653
+ terms_accepted: boolean;
1654
+ /** Skip email OTP when the caller has verified the address out-of-band. Phone OTP is never skippable. */
1655
+ email_already_verified?: boolean;
1656
+ /** Optional correlation id for a planned order. */
1657
+ external_id?: string;
1658
+ }
1659
+ interface OnrampVerificationTokenResponse {
1660
+ token: string;
1661
+ token_type: 'Bearer';
1662
+ /** Token lifetime in seconds. */
1663
+ expires_in: number;
1664
+ }
1665
+ declare function createOnrampVerificationSession(request: CreateOnrampVerificationSessionRequest, publishableKey?: string): Promise<OnrampVerificationSession>;
1666
+ declare function sendOnrampVerificationOtp(id: string, factor: 'email' | 'phone', clientSecret: string, publishableKey?: string): Promise<OnrampVerificationSession>;
1667
+ declare function verifyOnrampVerificationOtp(id: string, factor: 'email' | 'phone', clientSecret: string, code: string, publishableKey?: string): Promise<OnrampVerificationSession>;
1668
+ declare function exchangeOnrampVerificationToken(id: string, clientSecret: string, publishableKey?: string): Promise<OnrampVerificationTokenResponse>;
1669
+ declare function getOnrampVerificationSession(id: string, clientSecret: string, publishableKey?: string): Promise<OnrampVerificationSession>;
1670
+ interface CreateCoinbaseApplePaySessionRequest {
1671
+ source_currency: string;
1672
+ /** Mutually exclusive with destination_amount. */
1673
+ source_amount?: string;
1674
+ /** Mutually exclusive with source_amount. */
1675
+ destination_amount?: string;
1676
+ destination_currency: string;
1677
+ destination_network: string;
1678
+ wallet_address: string;
1679
+ /** Optional override; defaults to the verified email on the onramp token. */
1680
+ email?: string;
1681
+ /** Auto-generated when omitted. */
1682
+ external_id?: string;
1683
+ /**
1684
+ * Iframe-embedding origin (CDP-registered + Apple-verified by the merchant).
1685
+ * Reserved for a future iframe checkout — the SDK currently opens the payment
1686
+ * surface in a popup window and ignores this field on the server. Accepted
1687
+ * now so partners can pass it without an SDK upgrade later.
1688
+ */
1689
+ domain?: string;
1690
+ }
1691
+ interface CoinbaseApplePaySessionResponse {
1692
+ id: string;
1693
+ external_id: string;
1694
+ /** URL to load in a webview/iframe — renders the Apple Pay button. */
1695
+ url: string;
1696
+ service_provider: string;
1697
+ status: string;
1698
+ wallet_address: string;
1699
+ source_currency: string;
1700
+ source_amount: string;
1701
+ destination_currency: string;
1702
+ destination_network: string;
1703
+ destination_amount?: string;
1704
+ total_fee?: number;
1705
+ }
1706
+ /**
1707
+ * One Coinbase guest-checkout limit bucket. Field names are snake_case
1708
+ * to match the wire format (every API response is recursively
1709
+ * snake_cased by `TransformInterceptor` on the way out).
1710
+ */
1711
+ interface CoinbaseApplePayLimit {
1712
+ /** `weekly_spending` (rolling 7-day USD cap) or `lifetime_transactions` (all-time count). */
1713
+ limit_type: 'weekly_spending' | 'lifetime_transactions';
1714
+ /** USD for spending limits; absent for count limits. */
1715
+ currency?: string;
1716
+ /** Max limit value (stringified). */
1717
+ limit: string;
1718
+ /** Remaining capacity (`"0"` once the cap is exhausted). */
1719
+ remaining: string;
1720
+ }
1721
+ /**
1722
+ * State machine for a single limit-upgrade option, per Coinbase's
1723
+ * headless-onramp limits-upgrade guide:
1724
+ *
1725
+ * unrequested → user has never submitted; collect `fields` and POST
1726
+ * /limits/upgrade.
1727
+ * pending → submission under review by Coinbase; poll /limits
1728
+ * until a terminal state.
1729
+ * resubmit → previous submission was rejected but retryable;
1730
+ * collect corrected `fields` and POST /limits/upgrade
1731
+ * again.
1732
+ * active → terminal. Upgrade approved.
1733
+ * inactive → terminal. User permanently blocked; do not retry.
1734
+ */
1735
+ type ApplePayLimitUpgradeStatus = 'unrequested' | 'pending' | 'resubmit' | 'active' | 'inactive';
1736
+ /** One available limit-upgrade option (shape is loose; Coinbase may add fields). */
1737
+ interface CoinbaseApplePayLimitUpgradeOption {
1738
+ /** State machine value. May be absent on partial / pre-eligible responses. */
1739
+ status?: ApplePayLimitUpgradeStatus | string;
1740
+ /** Field keys to collect from the user (today: `ssnLast4`, `dateOfBirth`). */
1741
+ fields?: string[];
1742
+ [key: string]: unknown;
1743
+ }
1744
+ /**
1745
+ * Wire-format response from `POST /apple_pay/limits`. The two `limit_*`
1746
+ * fields come straight from Coinbase (via our snake_casing
1747
+ * passthrough); the two derived fields (`limit_reached`,
1748
+ * `upgrade_status`) are appended by the SDK function for caller
1749
+ * ergonomics — see `getCoinbaseApplePayLimits`.
1750
+ */
1751
+ interface CoinbaseApplePayLimitsResponse {
1752
+ limits: CoinbaseApplePayLimit[];
1753
+ limit_upgrade_options?: CoinbaseApplePayLimitUpgradeOption[];
1754
+ /**
1755
+ * Convenience flag baked in by the SDK function. True iff EITHER
1756
+ * `weekly_spending` OR `lifetime_transactions` is exhausted —
1757
+ * Coinbase rejects a new order if it would exceed *either* cap, so
1758
+ * either bucket at `"0"` blocks the user from transacting.
1759
+ * Equivalent to `isApplePayLimitReached(response)`.
1760
+ */
1761
+ limit_reached: boolean;
1762
+ /**
1763
+ * Convenience flag baked in by the SDK function — the status of
1764
+ * `limit_upgrade_options[0]` when present, `null` otherwise.
1765
+ * Equivalent to `getApplePayLimitUpgradeStatus(response)`.
1766
+ */
1767
+ upgrade_status: ApplePayLimitUpgradeStatus | null;
1768
+ }
1769
+ /**
1770
+ * True iff EITHER `weekly_spending` OR `lifetime_transactions` bucket
1771
+ * is exhausted (`remaining === "0"`). Coinbase rejects a new order if
1772
+ * it would exceed *either* cap — so a user with `weekly=985` but
1773
+ * `lifetime=0` still can't transact, and we should route to the
1774
+ * upgrade flow (or terminal screen if no upgrade is available).
1775
+ *
1776
+ * Defensive on missing buckets: an absent bucket is treated as "not at
1777
+ * cap" for that dimension. All buckets absent ⇒ false (safe default —
1778
+ * we have no evidence they're blocked).
1779
+ */
1780
+ declare function isApplePayLimitReached(response: Pick<CoinbaseApplePayLimitsResponse, 'limits'>): boolean;
1781
+ /**
1782
+ * Extract the upgrade option's `status` from a limits response. Returns
1783
+ * `null` when the user has no `limit_upgrade_options` at all
1784
+ * (ineligible) or when the upstream omits the field; the caller should
1785
+ * treat that case the same as an `inactive` terminal — there's no
1786
+ * upgrade path.
1787
+ *
1788
+ * Today Coinbase only ever returns a single entry in
1789
+ * `limit_upgrade_options`; if that changes we'll need to scope this by
1790
+ * payment-method type. For now indexing `[0]` is what the
1791
+ * limits-upgrade guide itself does.
1792
+ */
1793
+ declare function getApplePayLimitUpgradeStatus(response: Pick<CoinbaseApplePayLimitsResponse, 'limit_upgrade_options'>): ApplePayLimitUpgradeStatus | null;
1794
+ /**
1795
+ * Fetch the user's current Apple Pay (guest-checkout) limits + any
1796
+ * available upgrade options. Safe to call before the verification OTP —
1797
+ * callers usually pair this with `isApplePayBothLimitsReached` to decide
1798
+ * whether to surface the limit-upgrade flow instead of sending the SMS.
1799
+ *
1800
+ * @see https://docs.cdp.coinbase.com/api-reference/v2/rest-api/onramp/get-onramp-user-limits
1801
+ */
1802
+ declare function getCoinbaseApplePayLimits(
1803
+ /** US phone in E.164 (e.g. `+12345678901`). */
1804
+ phone: string, publishableKey?: string, signal?: AbortSignal): Promise<CoinbaseApplePayLimitsResponse>;
1805
+ interface RequestCoinbaseApplePayLimitUpgradeRequest {
1806
+ /** US phone in E.164. Must match a phone the user controls (Coinbase verifies via the prior OTP). */
1807
+ phone: string;
1808
+ fields: {
1809
+ /** Last 4 SSN digits, no dashes/spaces. */
1810
+ ssnLast4: string;
1811
+ /** Zero-padded day/month, 4-digit year. */
1812
+ dateOfBirth: {
1813
+ day: string;
1814
+ month: string;
1815
+ year: string;
1816
+ };
1817
+ };
1818
+ }
1819
+ interface RequestCoinbaseApplePayLimitUpgradeResponse {
1820
+ /** Always `"accepted"`. The upgrade decision is asynchronous — poll the limits endpoint. */
1821
+ status: 'accepted';
1822
+ }
1823
+ /**
1824
+ * Submit identity fields (DOB + SSN last 4) to request an Apple Pay limit
1825
+ * upgrade. The decision is asynchronous on Coinbase's side; poll
1826
+ * `getCoinbaseApplePayLimits` after this to observe whether the new caps
1827
+ * landed.
1828
+ *
1829
+ * @see https://docs.cdp.coinbase.com/api-reference/v2/rest-api/onramp/request-limit-upgrade
1830
+ */
1831
+ declare function requestCoinbaseApplePayLimitUpgrade(request: RequestCoinbaseApplePayLimitUpgradeRequest, publishableKey?: string, signal?: AbortSignal): Promise<RequestCoinbaseApplePayLimitUpgradeResponse>;
1832
+ /**
1833
+ * Create an Apple Pay onramp session. Requires a fresh `onrampToken` from
1834
+ * `exchangeOnrampVerificationToken`.
1835
+ *
1836
+ * Pass `signal` from an `AbortController` when calling from a debounced /
1837
+ * race-prone code path (e.g. the amount-screen create-on-input loop) so a
1838
+ * superseded in-flight request can be cancelled and its response can't
1839
+ * overwrite a newer one.
1840
+ */
1841
+ declare function createCoinbaseApplePaySession(request: CreateCoinbaseApplePaySessionRequest, onrampToken: string, publishableKey?: string, signal?: AbortSignal): Promise<CoinbaseApplePaySessionResponse>;
1323
1842
 
1324
1843
  /**
1325
1844
  * Format a stablecoin amount to 2 decimal places, ceiling any fractional
@@ -1362,9 +1881,9 @@ declare enum CheckoutEventType {
1362
1881
  PAYMENT_INTENT_SUCCEEDED = "payment_intent.succeeded"
1363
1882
  }
1364
1883
  /** Funding method used by a deposit flow. */
1365
- type DepositMethod = "transfer" | "card" | "cashapp" | "pay_with_exchange" | "exchange_connect" | "wallet_connect";
1884
+ type DepositMethod = 'transfer' | 'card' | 'cashapp' | 'apple_pay' | 'pay_with_exchange' | 'exchange_connect' | 'wallet_connect';
1366
1885
  /** Funding method used by a checkout flow. */
1367
- type CheckoutMethod = "transfer" | "wallet_connect";
1886
+ type CheckoutMethod = 'transfer' | 'wallet_connect';
1368
1887
  /** `data.object` payload for {@link DepositEventType.ONRAMP_SESSION_CREATED} */
1369
1888
  interface OnrampSessionCreatedData {
1370
1889
  externalId: string;
@@ -1377,7 +1896,7 @@ interface OnrampSessionCreatedData {
1377
1896
  */
1378
1897
  interface CheckoutPaymentIntent {
1379
1898
  id: string;
1380
- status: "succeeded";
1899
+ status: 'succeeded';
1381
1900
  recipientAddress: string;
1382
1901
  destinationChainType: string;
1383
1902
  destinationChainId: string;
@@ -1628,4 +2147,4 @@ declare const i18n: {
1628
2147
  };
1629
2148
  type I18nStrings = typeof i18n;
1630
2149
 
1631
- export { ActionType, type AddressBalanceResponse, type AddressBalancesResponse, type AddressValidationFailureCode, type AddressValidationMetadata, type AuthenticateOAuthResult, type AutoSwapRequest, type AutoSwapResponse, type BankTransferConfig, type BankTransferProvider, type BankTransferProvidersResponse, type BlockedCountrySubdivision, type BuildHypercoreTransactionRequest, type BuildHypercoreTransactionResponse, type BuildSolanaTransactionRequest, type BuildSolanaTransactionResponse, type CashAppLimits, type CashAppSessionRequest, type CashAppSessionResponse, type CashAppSessionStatusResponse, type ChainType, type CheckoutEvent, CheckoutEventType, type CheckoutMethod, type CheckoutPaymentIntent, type CheckoutPaymentIntentData, type CheckoutPaymentIntentSucceededEvent, type ConfirmIntegrationTransferResult, type CreateDepositAddressRequest, type CreateExchangeSessionRequest, type CreateExchangeSessionResponse, type CreateIntegrationTransferParams, type CreateIntegrationTransferResult, type DefaultTokenChain, type DefaultTokenMetadata, type DefaultTokenResponse, type DepositAddressResponse, type DepositEvent, DepositEventType, type DepositMethod, type DepositQuote, type DepositQuoteRequest, type DestinationToken, type DestinationTokenChain, type DirectExecution, type DirectExecutionResponse, type DirectExecutionSucceededEvent, type EvmContractCall, type ExchangeProviderInfo, type ExchangeProvidersResponse, type ExchangeSessionStartParams, type ExchangeWalletAddress, ExecutionStatus, type ExternalWalletChainType, type ExternalWalletInfo, type ExternalWalletsResponse, type FeaturedToken, type FeaturedWallet, type FiatCurrenciesResponse, type FiatCurrency, type GetBankTransferProvidersOptions, type GetExchangesQuery, type HypercoreActivationRequest, type HypercoreActivationResponse, type I18nStrings, type IconUrl, IneligibilityReason, type IntegrationAccount, type IntegrationExchangeInfo, type IntegrationExchangesResponse, type IntegrationFeeAmount, type IntegrationHoldingsResponse, IntegrationProvider, type IpAddressResponse, type LockedQuoteLimits, type LockedQuotePreview, type LockedQuotePreviewRequest, type OnrampQuote, type OnrampQuotesRequest, type OnrampQuotesResponse, type OnrampSessionCreatedData, type OnrampSessionCreatedEvent, type OnrampSessionPaymentMethod, type OnrampSessionRequest, type OnrampSessionResponse, type PaymentIntent, type PaymentIntentDepositAddress, type PaymentIntentExecutionsResponse, type PaymentIntentStatus, type PaymentIntentType, type PaymentNetwork, type PollExecutionsRequest, type PollExecutionsResponse, type ProductType, type ProjectConfigResponse, type QueryExecutionsRequest, type QueryExecutionsResponse, type RefreshIntegrationTokenResult, SOLANA_USDC_ADDRESS, type SendHypercoreTransactionRequest, type SendHypercoreTransactionResponse, type SendSolanaTransactionRequest, type SendSolanaTransactionResponse, type SourceToken, type SourceTokenNetwork, type StartIntegrationOAuthResult, type SupportedChain, type SupportedDepositTokensResponse, type SupportedDestinationTokensResponse, type SupportedSourceTokensQuery, type SupportedSourceTokensResponse, type SupportedToken, type TokenBalance, type TokenChain, type TokenChainIconUrl, type TokenChainsResponse, type TokenIconUrl, type TokenInfo, type TokenMetadata, type TransferDefaultTokenParams, type TransferDefaultTokenResult, type UserIpInfo, type VerifyAddressRequest, type VerifyAddressResponse, type Wallet, type WalletMobileDeepLinkDepositAddress, type WalletMobileDeepLinkResponse, type WalletMobileDeepLinkWallet, type WithdrawDirectExecutionSucceededEvent, type WithdrawEvent, WithdrawEventType, authenticateIntegrationOAuth, buildHypercoreTransaction, buildSolanaTransaction, checkHypercoreActivation, confirmIntegrationTransfer, createCashAppSession, createDepositAddress, createExchangeSession, createIntegrationTransfer, createOnrampSession, formatStablecoinAmount, generateKSUID, generatePrefixedKSUID, getAddressBalance, getAddressBalances, getApiBaseUrl, getBankTransferProviders, getCashAppLimits, getCashAppSessionStatus, getChainName, getDefaultOnrampToken, getDepositAddress, getDepositQuote, getExchangeSessionStartUrl, getExchanges, getExternalWallets, getFiatCurrencies, getIconUrl, getIconUrlWithCdn, getIntegrationExchanges, getIntegrationHoldings, getIntegrationTransferDefaultToken, getIpAddress, getOnrampQuotes, getOnrampSessionStartUrl, getPreferredIconUrl, getProjectConfig, getSupportedDepositTokens, getSupportedDestinationTokens, getTokenChains, getTokenMetadata, getWalletByChainType, getWalletMobileDeepLink, i18n, listPaymentIntentExecutions, pollDirectExecutions, queryExecutions, refreshIntegrationToken, retrievePaymentIntent, revokeIntegrationToken, sendHypercoreTransaction, sendSolanaTransaction, setApiConfig, startIntegrationOAuth, useUserIp, verifyRecipientAddress };
2150
+ export { ActionType, type AddressBalanceResponse, type AddressBalancesResponse, type AddressValidationFailureCode, type AddressValidationMetadata, type ApplePayLimitUpgradeStatus, type ApplePayProvider, type ApplePayProvidersResponse, type AuthenticateOAuthResult, type AutoSwapRequest, type AutoSwapResponse, type BankTransferConfig, type BankTransferProvider, type BankTransferProvidersResponse, type BlockedCountrySubdivision, type BuildHypercoreTransactionRequest, type BuildHypercoreTransactionResponse, type BuildSolanaTransactionRequest, type BuildSolanaTransactionResponse, type CashAppLimits, type CashAppSessionRequest, type CashAppSessionResponse, type CashAppSessionStatusResponse, type ChainType, type CheckoutEvent, CheckoutEventType, type CheckoutMethod, type CheckoutPaymentIntent, type CheckoutPaymentIntentData, type CheckoutPaymentIntentSucceededEvent, type CoinbaseApplePayLimit, type CoinbaseApplePayLimitUpgradeOption, type CoinbaseApplePayLimitsResponse, type CoinbaseApplePaySessionResponse, type CoinbaseLegalAgreement, type CoinbaseLegalAgreementsResponse, type ConfirmIntegrationTransferResult, type CreateCoinbaseApplePaySessionRequest, type CreateDepositAddressRequest, type CreateExchangeSessionRequest, type CreateExchangeSessionResponse, type CreateIntegrationTransferParams, type CreateIntegrationTransferResult, type CreateOnrampVerificationSessionRequest, type DefaultTokenChain, type DefaultTokenMetadata, type DefaultTokenResponse, type DepositAddressResponse, type DepositEvent, DepositEventType, type DepositMethod, type DepositQuote, type DepositQuoteRequest, type DestinationToken, type DestinationTokenChain, type DirectExecution, type DirectExecutionResponse, type DirectExecutionSucceededEvent, type EvmContractCall, type ExchangeProviderInfo, type ExchangeProvidersResponse, type ExchangeSessionStartParams, type ExchangeWalletAddress, ExecutionStatus, type ExternalWalletChainType, type ExternalWalletInfo, type ExternalWalletsResponse, type FeaturedToken, type FeaturedWallet, type FiatCurrenciesResponse, type FiatCurrency, type GetBankTransferProvidersOptions, type GetExchangesQuery, type HypercoreActivationRequest, type HypercoreActivationResponse, type I18nStrings, type IconUrl, IneligibilityReason, type IntegrationAccount, type IntegrationExchangeInfo, type IntegrationExchangesResponse, type IntegrationFeeAmount, type IntegrationHoldingsResponse, IntegrationProvider, type IpAddressResponse, type LockedQuoteLimits, type LockedQuotePreview, type LockedQuotePreviewRequest, type OnrampQuote, type OnrampQuotesRequest, type OnrampQuotesResponse, type OnrampSessionCreatedData, type OnrampSessionCreatedEvent, type OnrampSessionPaymentMethod, type OnrampSessionRequest, type OnrampSessionResponse, type OnrampVerificationFactor, type OnrampVerificationFactorStatus, type OnrampVerificationSession, type OnrampVerificationStatus, type OnrampVerificationTokenResponse, type PaymentIntent, type PaymentIntentDepositAddress, type PaymentIntentExecutionsResponse, type PaymentIntentStatus, type PaymentIntentType, type PaymentNetwork, type PollExecutionsRequest, type PollExecutionsResponse, type ProductType, type ProjectConfigResponse, type QueryExecutionsRequest, type QueryExecutionsResponse, type RefreshIntegrationTokenResult, type RequestCoinbaseApplePayLimitUpgradeRequest, type RequestCoinbaseApplePayLimitUpgradeResponse, SOLANA_USDC_ADDRESS, type SendHypercoreTransactionRequest, type SendHypercoreTransactionResponse, type SendSolanaTransactionRequest, type SendSolanaTransactionResponse, type SourceToken, type SourceTokenNetwork, type StartIntegrationOAuthResult, type StripeAccessTokenResponse, StripeApiResponseError, type StripeAuthIntentResponse, type StripeConfigResponse, type StripeConfirmRequest, type StripeConsumerWallet, type StripeCreateSessionRequest, type StripeCryptoCustomer, type StripeCustomerVerification, type StripeDefaultTokenResponse, type StripeListResponse, type StripeOnrampErrorType, type StripeOnrampSession, type StripeOnrampTransactionDetails, type StripePaymentToken, type StripeQuoteRequest, type StripeQuotesResponse, type StripeTransactionLimitEntry, type StripeTransactionLimitsResponse, type SupportedChain, type SupportedDepositTokensResponse, type SupportedDestinationTokensResponse, type SupportedSourceTokensQuery, type SupportedSourceTokensResponse, type SupportedToken, type TokenBalance, type TokenChain, type TokenChainIconUrl, type TokenChainsResponse, type TokenIconUrl, type TokenInfo, type TokenMetadata, type TransferDefaultTokenParams, type TransferDefaultTokenResult, type UserIpInfo, type VerifyAddressRequest, type VerifyAddressResponse, type Wallet, type WalletMobileDeepLinkDepositAddress, type WalletMobileDeepLinkResponse, type WalletMobileDeepLinkWallet, type WithdrawDirectExecutionSucceededEvent, type WithdrawEvent, WithdrawEventType, authenticateIntegrationOAuth, buildHypercoreTransaction, buildSolanaTransaction, checkHypercoreActivation, confirmIntegrationTransfer, createCashAppSession, createCoinbaseApplePaySession, createDepositAddress, createExchangeSession, createIntegrationTransfer, createOnrampSession, createOnrampVerificationSession, exchangeOnrampVerificationToken, formatStablecoinAmount, generateKSUID, generatePrefixedKSUID, getAddressBalance, getAddressBalances, getApiBaseUrl, getApplePayLimitUpgradeStatus, getApplePayProviders, getBankTransferProviders, getCashAppLimits, getCashAppSessionStatus, getChainName, getCoinbaseApplePayLimits, getCoinbaseLegalAgreements, getDefaultOnrampToken, getDepositAddress, getDepositQuote, getExchangeSessionStartUrl, getExchanges, getExternalWallets, getFiatCurrencies, getIconUrl, getIconUrlWithCdn, getIntegrationExchanges, getIntegrationHoldings, getIntegrationTransferDefaultToken, getIpAddress, getOnrampQuotes, getOnrampSessionStartUrl, getOnrampVerificationSession, getPreferredIconUrl, getProjectConfig, getSupportedDepositTokens, getSupportedDestinationTokens, getTokenChains, getTokenMetadata, getWalletByChainType, getWalletMobileDeepLink, i18n, isApplePayLimitReached, listPaymentIntentExecutions, pollDirectExecutions, queryExecutions, refreshIntegrationToken, requestCoinbaseApplePayLimitUpgrade, retrievePaymentIntent, revokeIntegrationToken, sendHypercoreTransaction, sendOnrampVerificationOtp, sendSolanaTransaction, setApiConfig, startIntegrationOAuth, stripeConfirmSession, stripeCreateAuthIntent, stripeCreateSession, stripeExchangeTokens, stripeGetConfig, stripeGetCustomer, stripeGetDefaultToken, stripeGetQuotes, stripeGetSession, stripeGetTransactionLimits, stripeListPaymentTokens, stripeListWallets, stripeRefreshQuote, stripeRefreshToken, useUserIp, verifyOnrampVerificationOtp, verifyRecipientAddress };