@moonpay/platform-sdk-react-native 1.25.0 → 1.26.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -2,6 +2,7 @@ import { ListPaymentMethodsResponse, GetQuoteParams, Quote, ListAssetsResponse,
2
2
  export { AssetStatus, GetQuoteParams, ListAssetsResponse, ListPaymentMethodsResponse, PaginationInfo, PaymentMethodConfig, PaymentMethodType, PlatformAsset, Quote, SimulateBankTransferOutcome, SimulateBankTransferParams, SimulateSenderBankAccount, StoredCardPaymentMethod, StoredPaymentMethod, Transaction, TransactionWithStages } from '@moonpay/platform-protocol/api';
3
3
  import { Customer } from '@moonpay/platform-protocol/api/customer';
4
4
  export { Customer } from '@moonpay/platform-protocol/api/customer';
5
+ export { EnterpriseQuote } from '@moonpay/platform-protocol/api/enterprise';
5
6
  export { CardResponse } from '@moonpay/platform-protocol/frames/add-card';
6
7
  import * as ApplePayFrame$1 from '@moonpay/platform-protocol/frames/apple-pay';
7
8
  export { ApplePayButtonSettings } from '@moonpay/platform-protocol/frames/apple-pay';
@@ -112,6 +113,7 @@ interface AuthFrame {
112
113
  dispose(): void;
113
114
  }
114
115
 
116
+ /** @deprecated Use `SetupBuyButtonOptions` with `headless: true`. */
115
117
  interface SetupBuyOptions {
116
118
  /** Quote signature from getQuote(). */
117
119
  quote: string;
@@ -120,6 +122,7 @@ interface SetupBuyOptions {
120
122
  /** Callback for buy frame lifecycle events. */
121
123
  onEvent?: (event: BuySdk.Event) => void;
122
124
  }
125
+ /** @deprecated Use `BuyButtonFrame` from `setupBuyButton({ headless: true })`. */
123
126
  interface BuyFrame {
124
127
  /** Update the quote (e.g., after expiry). */
125
128
  setQuote(signature: string): void;
@@ -135,6 +138,11 @@ interface SetupBuyButtonOptions {
135
138
  applePayButtonSettings?: ApplePayFrame$1.ApplePayButtonSettings;
136
139
  /** Frame chrome. Defaults to the frame's own default (bare) when omitted. */
137
140
  presentation?: PresentationMode;
141
+ /**
142
+ * Run the frame hidden, with no button: it processes the quote on load, the
143
+ * way the deprecated `setupBuy` did.
144
+ */
145
+ headless?: boolean;
138
146
  /** Callback for buy-button frame lifecycle events. */
139
147
  onEvent?: (event: BuyButtonSdk.Event) => void;
140
148
  }
@@ -277,6 +285,7 @@ interface RNClient {
277
285
  setupWidget(options: SetupWidgetOptions): Promise<Result<WidgetFrame, WidgetSdk.SetupError>>;
278
286
  /** @deprecated Render <MoonPayApplePayButton> instead — it mounts inline where you place it. */
279
287
  setupApplePay(options: SetupApplePayOptions): Promise<Result<ApplePayFrame, ApplePaySdk.SetupError>>;
288
+ /** @deprecated Use `setupBuyButton({ ...options, headless: true })` or `<MoonPayBuyButton headless>`. The buy frame is being removed. */
280
289
  setupBuy(options: SetupBuyOptions): Promise<Result<BuyFrame, BuySdk.SetupError>>;
281
290
  /** @deprecated Render <MoonPayBuyButton> instead — it mounts inline where you place it. */
282
291
  setupBuyButton(options: SetupBuyButtonOptions): Promise<Result<BuyButtonFrame, BuyButtonSdk.SetupError>>;
@@ -330,6 +339,12 @@ interface RNClient {
330
339
  data: Identity;
331
340
  }, SubmitIdentityFilesError>>;
332
341
  }
342
+ /**
343
+ * The enterprise client exposes only the payment frames. Quotes, customers
344
+ * and transactions are API-driven for enterprise — call them from your server.
345
+ * For a buy without a visible button, use `setupBuyButton({ headless: true })`.
346
+ */
347
+ type RNEnterpriseClient = Pick<RNClient, 'setupBuyButton' | 'setupChallenge' | 'setupAddCard'>;
333
348
 
334
349
  interface MoonPayAddCardProps {
335
350
  /** Callback for add-card lifecycle events. */
@@ -388,6 +403,11 @@ interface MoonPayBuyButtonProps {
388
403
  externalTransactionId?: string;
389
404
  /** Styling for the Apple Pay button variant. Passed through to the frame, which is authoritative. Mount-time only. */
390
405
  applePayButtonSettings?: ApplePayFrame$1.ApplePayButtonSettings;
406
+ /**
407
+ * Render nothing visible and process the quote on load, the way the
408
+ * deprecated `<MoonPayBuyFrame>` did. Mount-time only.
409
+ */
410
+ headless?: boolean;
391
411
  /** Callback for buy button lifecycle events. */
392
412
  onEvent?: (event: BuyButtonSdk.Event) => void;
393
413
  /** Container style. Defaults to height 48. */
@@ -396,7 +416,7 @@ interface MoonPayBuyButtonProps {
396
416
  webViewProps?: Partial<WebViewProps>;
397
417
  }
398
418
  /** Inline card/buy button. Render it wherever it should appear in your layout. */
399
- declare function MoonPayBuyButton({ quote, externalTransactionId, applePayButtonSettings, onEvent, style, webViewProps, }: MoonPayBuyButtonProps): JSX.Element;
419
+ declare function MoonPayBuyButton({ quote, externalTransactionId, applePayButtonSettings, headless, onEvent, style, webViewProps, }: MoonPayBuyButtonProps): JSX.Element;
400
420
 
401
421
  interface MoonPayBuyFrameProps {
402
422
  /** Quote signature from getQuote(). Reactive — updates are pushed via setQuote without remounting. */
@@ -408,7 +428,10 @@ interface MoonPayBuyFrameProps {
408
428
  /** Advanced props forwarded to the underlying react-native-webview. `ref`, `source`, and `onMessage` are SDK-managed. */
409
429
  webViewProps?: Partial<WebViewProps>;
410
430
  }
411
- /** Headless buy frame (renders nothing visible). The declarative alternative to client.setupBuy(). */
431
+ /**
432
+ * Headless buy frame (renders nothing visible). The declarative alternative to client.setupBuy().
433
+ * @deprecated Render `<MoonPayBuyButton headless>` instead. The buy frame is being removed.
434
+ */
412
435
  declare function MoonPayBuyFrame({ quote, externalTransactionId, onEvent, webViewProps, }: MoonPayBuyFrameProps): JSX.Element;
413
436
 
414
437
  interface MoonPayChallengeProps {
@@ -559,6 +582,21 @@ interface MoonPayProviderProps {
559
582
  children: ReactNode;
560
583
  }
561
584
  declare function MoonPayProvider({ sessionToken: sessionTokenProp, apiBaseUrl, frameBaseUrl, theme, children, }: MoonPayProviderProps): JSX.Element;
585
+ interface MoonPayEnterpriseProviderProps {
586
+ /** Client token from your server. Authorizes every enterprise frame. */
587
+ clientToken: string;
588
+ frameBaseUrl?: string;
589
+ /** Theme applied to every visible MoonPay frame. */
590
+ theme?: ThemeOptions;
591
+ children: ReactNode;
592
+ }
593
+ /**
594
+ * Provider for enterprise integrations. Exposes only the payment frames —
595
+ * `<MoonPayBuyButton>` (including `headless`), `<MoonPayAddCard>`,
596
+ * `<MoonPayChallenge>` and their `setupX` methods via `useMoonPayEnterprise()`.
597
+ * Other frame components emit an error event saying they're unavailable.
598
+ */
599
+ declare function MoonPayEnterpriseProvider({ clientToken, frameBaseUrl, theme, children, }: MoonPayEnterpriseProviderProps): JSX.Element;
562
600
  declare function useMoonPay(): {
563
601
  client: RNClient;
564
602
  /** Set or replace the session token after mount. */
@@ -566,5 +604,8 @@ declare function useMoonPay(): {
566
604
  /** True once a session token (via prop or `initialize()`) is available. */
567
605
  isInitialized: boolean;
568
606
  };
607
+ declare function useMoonPayEnterprise(): {
608
+ client: RNEnterpriseClient;
609
+ };
569
610
 
570
- export { type AddCardFrame, type ApplePayFrame, type AuthFrame, type BuyButtonFrame, type BuyFrame, type ChallengeFrame, type ConnectFrame, type ConnectOptions, type ConnectionCheckEvent, type ConnectionResetEvent, type CustomerExportFrame, type GetConnectionOptions, type GooglePayFrame, MoonPayAddCard, type MoonPayAddCardProps, MoonPayApplePayButton, type MoonPayApplePayButtonProps, MoonPayAuth, type MoonPayAuthProps, MoonPayBuyButton, type MoonPayBuyButtonProps, MoonPayBuyFrame, type MoonPayBuyFrameProps, MoonPayChallenge, type MoonPayChallengeProps, MoonPayConnect, type MoonPayConnectProps, MoonPayConnectionCheck, type MoonPayConnectionCheckProps, MoonPayConnectionReset, type MoonPayConnectionResetProps, MoonPayCustomerExport, type MoonPayCustomerExportProps, MoonPayFrame, type MoonPayFrameProps, MoonPayGooglePayButton, type MoonPayGooglePayButtonProps, MoonPayProvider, type MoonPayProviderProps, MoonPayWidget, type MoonPayWidgetProps, type RNClient, type SetupAddCardOptions, type SetupApplePayOptions, type SetupAuthOptions, type SetupBuyButtonOptions, type SetupBuyOptions, type SetupChallengeOptions, type SetupCustomerExportOptions, type SetupGooglePayOptions, type SetupWidgetOptions, WebViewTransport, type WidgetFrame, useMoonPay };
611
+ export { type AddCardFrame, type ApplePayFrame, type AuthFrame, type BuyButtonFrame, type BuyFrame, type ChallengeFrame, type ConnectFrame, type ConnectOptions, type ConnectionCheckEvent, type ConnectionResetEvent, type CustomerExportFrame, type GetConnectionOptions, type GooglePayFrame, MoonPayAddCard, type MoonPayAddCardProps, MoonPayApplePayButton, type MoonPayApplePayButtonProps, MoonPayAuth, type MoonPayAuthProps, MoonPayBuyButton, type MoonPayBuyButtonProps, MoonPayBuyFrame, type MoonPayBuyFrameProps, MoonPayChallenge, type MoonPayChallengeProps, MoonPayConnect, type MoonPayConnectProps, MoonPayConnectionCheck, type MoonPayConnectionCheckProps, MoonPayConnectionReset, type MoonPayConnectionResetProps, MoonPayCustomerExport, type MoonPayCustomerExportProps, MoonPayEnterpriseProvider, type MoonPayEnterpriseProviderProps, MoonPayFrame, type MoonPayFrameProps, MoonPayGooglePayButton, type MoonPayGooglePayButtonProps, MoonPayProvider, type MoonPayProviderProps, MoonPayWidget, type MoonPayWidgetProps, type RNClient, type RNEnterpriseClient, type SetupAddCardOptions, type SetupApplePayOptions, type SetupAuthOptions, type SetupBuyButtonOptions, type SetupBuyOptions, type SetupChallengeOptions, type SetupCustomerExportOptions, type SetupGooglePayOptions, type SetupWidgetOptions, WebViewTransport, type WidgetFrame, useMoonPay, useMoonPayEnterprise };
package/dist/index.d.ts CHANGED
@@ -2,6 +2,7 @@ import { ListPaymentMethodsResponse, GetQuoteParams, Quote, ListAssetsResponse,
2
2
  export { AssetStatus, GetQuoteParams, ListAssetsResponse, ListPaymentMethodsResponse, PaginationInfo, PaymentMethodConfig, PaymentMethodType, PlatformAsset, Quote, SimulateBankTransferOutcome, SimulateBankTransferParams, SimulateSenderBankAccount, StoredCardPaymentMethod, StoredPaymentMethod, Transaction, TransactionWithStages } from '@moonpay/platform-protocol/api';
3
3
  import { Customer } from '@moonpay/platform-protocol/api/customer';
4
4
  export { Customer } from '@moonpay/platform-protocol/api/customer';
5
+ export { EnterpriseQuote } from '@moonpay/platform-protocol/api/enterprise';
5
6
  export { CardResponse } from '@moonpay/platform-protocol/frames/add-card';
6
7
  import * as ApplePayFrame$1 from '@moonpay/platform-protocol/frames/apple-pay';
7
8
  export { ApplePayButtonSettings } from '@moonpay/platform-protocol/frames/apple-pay';
@@ -112,6 +113,7 @@ interface AuthFrame {
112
113
  dispose(): void;
113
114
  }
114
115
 
116
+ /** @deprecated Use `SetupBuyButtonOptions` with `headless: true`. */
115
117
  interface SetupBuyOptions {
116
118
  /** Quote signature from getQuote(). */
117
119
  quote: string;
@@ -120,6 +122,7 @@ interface SetupBuyOptions {
120
122
  /** Callback for buy frame lifecycle events. */
121
123
  onEvent?: (event: BuySdk.Event) => void;
122
124
  }
125
+ /** @deprecated Use `BuyButtonFrame` from `setupBuyButton({ headless: true })`. */
123
126
  interface BuyFrame {
124
127
  /** Update the quote (e.g., after expiry). */
125
128
  setQuote(signature: string): void;
@@ -135,6 +138,11 @@ interface SetupBuyButtonOptions {
135
138
  applePayButtonSettings?: ApplePayFrame$1.ApplePayButtonSettings;
136
139
  /** Frame chrome. Defaults to the frame's own default (bare) when omitted. */
137
140
  presentation?: PresentationMode;
141
+ /**
142
+ * Run the frame hidden, with no button: it processes the quote on load, the
143
+ * way the deprecated `setupBuy` did.
144
+ */
145
+ headless?: boolean;
138
146
  /** Callback for buy-button frame lifecycle events. */
139
147
  onEvent?: (event: BuyButtonSdk.Event) => void;
140
148
  }
@@ -277,6 +285,7 @@ interface RNClient {
277
285
  setupWidget(options: SetupWidgetOptions): Promise<Result<WidgetFrame, WidgetSdk.SetupError>>;
278
286
  /** @deprecated Render <MoonPayApplePayButton> instead — it mounts inline where you place it. */
279
287
  setupApplePay(options: SetupApplePayOptions): Promise<Result<ApplePayFrame, ApplePaySdk.SetupError>>;
288
+ /** @deprecated Use `setupBuyButton({ ...options, headless: true })` or `<MoonPayBuyButton headless>`. The buy frame is being removed. */
280
289
  setupBuy(options: SetupBuyOptions): Promise<Result<BuyFrame, BuySdk.SetupError>>;
281
290
  /** @deprecated Render <MoonPayBuyButton> instead — it mounts inline where you place it. */
282
291
  setupBuyButton(options: SetupBuyButtonOptions): Promise<Result<BuyButtonFrame, BuyButtonSdk.SetupError>>;
@@ -330,6 +339,12 @@ interface RNClient {
330
339
  data: Identity;
331
340
  }, SubmitIdentityFilesError>>;
332
341
  }
342
+ /**
343
+ * The enterprise client exposes only the payment frames. Quotes, customers
344
+ * and transactions are API-driven for enterprise — call them from your server.
345
+ * For a buy without a visible button, use `setupBuyButton({ headless: true })`.
346
+ */
347
+ type RNEnterpriseClient = Pick<RNClient, 'setupBuyButton' | 'setupChallenge' | 'setupAddCard'>;
333
348
 
334
349
  interface MoonPayAddCardProps {
335
350
  /** Callback for add-card lifecycle events. */
@@ -388,6 +403,11 @@ interface MoonPayBuyButtonProps {
388
403
  externalTransactionId?: string;
389
404
  /** Styling for the Apple Pay button variant. Passed through to the frame, which is authoritative. Mount-time only. */
390
405
  applePayButtonSettings?: ApplePayFrame$1.ApplePayButtonSettings;
406
+ /**
407
+ * Render nothing visible and process the quote on load, the way the
408
+ * deprecated `<MoonPayBuyFrame>` did. Mount-time only.
409
+ */
410
+ headless?: boolean;
391
411
  /** Callback for buy button lifecycle events. */
392
412
  onEvent?: (event: BuyButtonSdk.Event) => void;
393
413
  /** Container style. Defaults to height 48. */
@@ -396,7 +416,7 @@ interface MoonPayBuyButtonProps {
396
416
  webViewProps?: Partial<WebViewProps>;
397
417
  }
398
418
  /** Inline card/buy button. Render it wherever it should appear in your layout. */
399
- declare function MoonPayBuyButton({ quote, externalTransactionId, applePayButtonSettings, onEvent, style, webViewProps, }: MoonPayBuyButtonProps): JSX.Element;
419
+ declare function MoonPayBuyButton({ quote, externalTransactionId, applePayButtonSettings, headless, onEvent, style, webViewProps, }: MoonPayBuyButtonProps): JSX.Element;
400
420
 
401
421
  interface MoonPayBuyFrameProps {
402
422
  /** Quote signature from getQuote(). Reactive — updates are pushed via setQuote without remounting. */
@@ -408,7 +428,10 @@ interface MoonPayBuyFrameProps {
408
428
  /** Advanced props forwarded to the underlying react-native-webview. `ref`, `source`, and `onMessage` are SDK-managed. */
409
429
  webViewProps?: Partial<WebViewProps>;
410
430
  }
411
- /** Headless buy frame (renders nothing visible). The declarative alternative to client.setupBuy(). */
431
+ /**
432
+ * Headless buy frame (renders nothing visible). The declarative alternative to client.setupBuy().
433
+ * @deprecated Render `<MoonPayBuyButton headless>` instead. The buy frame is being removed.
434
+ */
412
435
  declare function MoonPayBuyFrame({ quote, externalTransactionId, onEvent, webViewProps, }: MoonPayBuyFrameProps): JSX.Element;
413
436
 
414
437
  interface MoonPayChallengeProps {
@@ -559,6 +582,21 @@ interface MoonPayProviderProps {
559
582
  children: ReactNode;
560
583
  }
561
584
  declare function MoonPayProvider({ sessionToken: sessionTokenProp, apiBaseUrl, frameBaseUrl, theme, children, }: MoonPayProviderProps): JSX.Element;
585
+ interface MoonPayEnterpriseProviderProps {
586
+ /** Client token from your server. Authorizes every enterprise frame. */
587
+ clientToken: string;
588
+ frameBaseUrl?: string;
589
+ /** Theme applied to every visible MoonPay frame. */
590
+ theme?: ThemeOptions;
591
+ children: ReactNode;
592
+ }
593
+ /**
594
+ * Provider for enterprise integrations. Exposes only the payment frames —
595
+ * `<MoonPayBuyButton>` (including `headless`), `<MoonPayAddCard>`,
596
+ * `<MoonPayChallenge>` and their `setupX` methods via `useMoonPayEnterprise()`.
597
+ * Other frame components emit an error event saying they're unavailable.
598
+ */
599
+ declare function MoonPayEnterpriseProvider({ clientToken, frameBaseUrl, theme, children, }: MoonPayEnterpriseProviderProps): JSX.Element;
562
600
  declare function useMoonPay(): {
563
601
  client: RNClient;
564
602
  /** Set or replace the session token after mount. */
@@ -566,5 +604,8 @@ declare function useMoonPay(): {
566
604
  /** True once a session token (via prop or `initialize()`) is available. */
567
605
  isInitialized: boolean;
568
606
  };
607
+ declare function useMoonPayEnterprise(): {
608
+ client: RNEnterpriseClient;
609
+ };
569
610
 
570
- export { type AddCardFrame, type ApplePayFrame, type AuthFrame, type BuyButtonFrame, type BuyFrame, type ChallengeFrame, type ConnectFrame, type ConnectOptions, type ConnectionCheckEvent, type ConnectionResetEvent, type CustomerExportFrame, type GetConnectionOptions, type GooglePayFrame, MoonPayAddCard, type MoonPayAddCardProps, MoonPayApplePayButton, type MoonPayApplePayButtonProps, MoonPayAuth, type MoonPayAuthProps, MoonPayBuyButton, type MoonPayBuyButtonProps, MoonPayBuyFrame, type MoonPayBuyFrameProps, MoonPayChallenge, type MoonPayChallengeProps, MoonPayConnect, type MoonPayConnectProps, MoonPayConnectionCheck, type MoonPayConnectionCheckProps, MoonPayConnectionReset, type MoonPayConnectionResetProps, MoonPayCustomerExport, type MoonPayCustomerExportProps, MoonPayFrame, type MoonPayFrameProps, MoonPayGooglePayButton, type MoonPayGooglePayButtonProps, MoonPayProvider, type MoonPayProviderProps, MoonPayWidget, type MoonPayWidgetProps, type RNClient, type SetupAddCardOptions, type SetupApplePayOptions, type SetupAuthOptions, type SetupBuyButtonOptions, type SetupBuyOptions, type SetupChallengeOptions, type SetupCustomerExportOptions, type SetupGooglePayOptions, type SetupWidgetOptions, WebViewTransport, type WidgetFrame, useMoonPay };
611
+ export { type AddCardFrame, type ApplePayFrame, type AuthFrame, type BuyButtonFrame, type BuyFrame, type ChallengeFrame, type ConnectFrame, type ConnectOptions, type ConnectionCheckEvent, type ConnectionResetEvent, type CustomerExportFrame, type GetConnectionOptions, type GooglePayFrame, MoonPayAddCard, type MoonPayAddCardProps, MoonPayApplePayButton, type MoonPayApplePayButtonProps, MoonPayAuth, type MoonPayAuthProps, MoonPayBuyButton, type MoonPayBuyButtonProps, MoonPayBuyFrame, type MoonPayBuyFrameProps, MoonPayChallenge, type MoonPayChallengeProps, MoonPayConnect, type MoonPayConnectProps, MoonPayConnectionCheck, type MoonPayConnectionCheckProps, MoonPayConnectionReset, type MoonPayConnectionResetProps, MoonPayCustomerExport, type MoonPayCustomerExportProps, MoonPayEnterpriseProvider, type MoonPayEnterpriseProviderProps, MoonPayFrame, type MoonPayFrameProps, MoonPayGooglePayButton, type MoonPayGooglePayButtonProps, MoonPayProvider, type MoonPayProviderProps, MoonPayWidget, type MoonPayWidgetProps, type RNClient, type RNEnterpriseClient, type SetupAddCardOptions, type SetupApplePayOptions, type SetupAuthOptions, type SetupBuyButtonOptions, type SetupBuyOptions, type SetupChallengeOptions, type SetupCustomerExportOptions, type SetupGooglePayOptions, type SetupWidgetOptions, WebViewTransport, type WidgetFrame, useMoonPay, useMoonPayEnterprise };
package/dist/index.js CHANGED
@@ -126,6 +126,7 @@ var googlePaySpec = {
126
126
  var buyButtonSpec = {
127
127
  channelPrefix: "buy-button",
128
128
  path: FRAME_PATHS.buyButton,
129
+ enterprise: true,
129
130
  hidden: false,
130
131
  buildParams: (ctx, props) => ({
131
132
  clientToken: ctx.core.context.clientToken,
@@ -167,6 +168,14 @@ var buyButtonSpec = {
167
168
  payload: { code: "generic", message }
168
169
  })
169
170
  };
171
+ var headlessBuyButtonSpec = {
172
+ ...buyButtonSpec,
173
+ hidden: true,
174
+ buildParams: (ctx, props) => ({
175
+ ...buyButtonSpec.buildParams?.(ctx, props),
176
+ headless: true
177
+ })
178
+ };
170
179
  function applyCredentialsOnComplete(msg, ctx) {
171
180
  if (msg.kind !== "complete" || !ctx.privateKey) return;
172
181
  const connection = msg.payload;
@@ -355,6 +364,7 @@ var buySpec = {
355
364
  var addCardSpec = {
356
365
  channelPrefix: "add-card",
357
366
  path: FRAME_PATHS.addCard,
367
+ enterprise: true,
358
368
  hidden: false,
359
369
  buildParams: (ctx, props) => ({
360
370
  clientToken: ctx.core.context.clientToken,
@@ -414,6 +424,7 @@ var challengeSpec = {
414
424
  channelPrefix: "challenge",
415
425
  path: FRAME_PATHS.challenge,
416
426
  // documentation only — buildUrl below wins
427
+ enterprise: true,
417
428
  hidden: false,
418
429
  resolveChannelId: (props, generated) => new URL(props.url).searchParams.get("channelId") || generated,
419
430
  buildUrl: (ctx, props, channelId) => {
@@ -593,6 +604,9 @@ var FrameSessionDisposedError = class extends Error {
593
604
  }
594
605
  };
595
606
  function createFrameSession(spec, ctx, props, overrides = {}) {
607
+ if (ctx.enterpriseClientToken && !spec.enterprise) {
608
+ throw new Error(`The ${spec.channelPrefix} frame is not available for enterprise clients`);
609
+ }
596
610
  const generated = `${spec.channelPrefix}-${Date.now()}`;
597
611
  const channelId = spec.resolveChannelId ? spec.resolveChannelId(props, generated) : generated;
598
612
  let keyPair;
@@ -803,12 +817,15 @@ async function setupBuy(deps, opts) {
803
817
  import { err as err5, ok as ok5 } from "@moonpay/platform-protocol/result";
804
818
  async function setupBuyButton(deps, opts) {
805
819
  try {
806
- const { handle, dispose } = await deps.mountSession(buyButtonSpec, {
807
- quote: opts.quote,
808
- externalTransactionId: opts.externalTransactionId,
809
- applePayButtonSettings: opts.applePayButtonSettings,
810
- presentation: opts.presentation
811
- });
820
+ const { handle, dispose } = await deps.mountSession(
821
+ opts.headless ? headlessBuyButtonSpec : buyButtonSpec,
822
+ {
823
+ quote: opts.quote,
824
+ externalTransactionId: opts.externalTransactionId,
825
+ applePayButtonSettings: opts.applePayButtonSettings,
826
+ presentation: opts.presentation
827
+ }
828
+ );
812
829
  handle.onEvent((event) => opts.onEvent?.(event));
813
830
  return ok5({ setQuote: handle.commands.setQuote, dispose });
814
831
  } catch (e) {
@@ -1015,6 +1032,13 @@ function createRNClient(deps) {
1015
1032
  submitIdentityFiles: (id, body) => core.submitIdentityFiles(id, body)
1016
1033
  };
1017
1034
  }
1035
+ function createRNEnterpriseClient(deps) {
1036
+ return {
1037
+ setupBuyButton: (opts) => setupBuyButton(deps, opts),
1038
+ setupChallenge: (opts) => setupChallenge(deps, opts),
1039
+ setupAddCard: (opts) => setupAddCard(deps, opts)
1040
+ };
1041
+ }
1018
1042
 
1019
1043
  // src/methods/mount-session.ts
1020
1044
  var slotCounter = 0;
@@ -1259,24 +1283,21 @@ var styles = StyleSheet.create({
1259
1283
  });
1260
1284
 
1261
1285
  // src/provider.tsx
1262
- import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
1286
+ import { Fragment, jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
1287
+ var FrameHostContext = createContext(null);
1263
1288
  var MoonPayContext = createContext(null);
1264
- function MoonPayProvider({
1265
- sessionToken: sessionTokenProp,
1266
- apiBaseUrl,
1267
- frameBaseUrl,
1268
- theme,
1269
- children
1270
- }) {
1289
+ var MoonPayEnterpriseContext = createContext(null);
1290
+ function useFrameSlots() {
1271
1291
  const [frameSlots, setFrameSlots] = useState2([]);
1272
- const [internalToken, setInternalToken] = useState2(void 0);
1273
- const sessionToken = sessionTokenProp ?? internalToken;
1274
1292
  const addSlot = useCallback2((slot) => {
1275
1293
  setFrameSlots((prev) => [...prev, slot]);
1276
1294
  }, []);
1277
1295
  const removeSlot = useCallback2((id) => {
1278
1296
  setFrameSlots((prev) => prev.filter((s) => s.id !== id));
1279
1297
  }, []);
1298
+ return { frameSlots, addSlot, removeSlot };
1299
+ }
1300
+ function useCore(apiBaseUrl, frameBaseUrl) {
1280
1301
  const coreRef = useRef3(null);
1281
1302
  if (!coreRef.current) {
1282
1303
  coreRef.current = createClientCore({
@@ -1285,7 +1306,38 @@ function MoonPayProvider({
1285
1306
  createTransport: () => new WebViewTransport()
1286
1307
  });
1287
1308
  }
1288
- const core = coreRef.current;
1309
+ return coreRef.current;
1310
+ }
1311
+ function FrameSlots({
1312
+ frameSlots,
1313
+ removeSlot
1314
+ }) {
1315
+ return /* @__PURE__ */ jsxs2(Fragment, { children: [
1316
+ frameSlots.filter((slot) => slot.hidden).map((slot) => /* @__PURE__ */ jsx3(MoonPayFrame, { transport: slot.transport, hidden: true }, slot.id)),
1317
+ frameSlots.filter((slot) => !slot.hidden).map((slot) => /* @__PURE__ */ jsx3(
1318
+ VisibleFrameSlotSheet,
1319
+ {
1320
+ slot,
1321
+ onClose: () => {
1322
+ slot.dispose();
1323
+ removeSlot(slot.id);
1324
+ }
1325
+ },
1326
+ slot.id
1327
+ ))
1328
+ ] });
1329
+ }
1330
+ function MoonPayProvider({
1331
+ sessionToken: sessionTokenProp,
1332
+ apiBaseUrl,
1333
+ frameBaseUrl,
1334
+ theme,
1335
+ children
1336
+ }) {
1337
+ const { frameSlots, addSlot, removeSlot } = useFrameSlots();
1338
+ const [internalToken, setInternalToken] = useState2(void 0);
1339
+ const sessionToken = sessionTokenProp ?? internalToken;
1340
+ const core = useCore(apiBaseUrl, frameBaseUrl);
1289
1341
  const initialize = useCallback2(
1290
1342
  (token) => {
1291
1343
  core.context.setAccessToken("");
@@ -1294,46 +1346,72 @@ function MoonPayProvider({
1294
1346
  },
1295
1347
  [core]
1296
1348
  );
1297
- const client = useMemo2(() => {
1298
- const specCtx = { sessionToken, core, frameBaseUrl, theme };
1299
- return createRNClient({
1349
+ const specCtx = useMemo2(
1350
+ () => ({ sessionToken, core, frameBaseUrl, theme }),
1351
+ [sessionToken, core, frameBaseUrl, theme?.appearance]
1352
+ );
1353
+ const client = useMemo2(
1354
+ () => createRNClient({
1300
1355
  mountSession: createMountSession(specCtx, { addSlot, removeSlot }),
1301
1356
  core
1302
- });
1303
- }, [sessionToken, frameBaseUrl, core, addSlot, removeSlot, theme?.appearance]);
1357
+ }),
1358
+ [specCtx, core, addSlot, removeSlot]
1359
+ );
1304
1360
  const isInitialized = sessionToken !== void 0;
1305
- return /* @__PURE__ */ jsxs2(
1306
- MoonPayContext.Provider,
1307
- {
1308
- value: { client, sessionToken, core, frameBaseUrl, theme, initialize, isInitialized },
1309
- children: [
1310
- children,
1311
- frameSlots.filter((slot) => slot.hidden).map((slot) => /* @__PURE__ */ jsx3(MoonPayFrame, { transport: slot.transport, hidden: true }, slot.id)),
1312
- frameSlots.filter((slot) => !slot.hidden).map((slot) => /* @__PURE__ */ jsx3(
1313
- VisibleFrameSlotSheet,
1314
- {
1315
- slot,
1316
- onClose: () => {
1317
- slot.dispose();
1318
- removeSlot(slot.id);
1319
- }
1320
- },
1321
- slot.id
1322
- ))
1323
- ]
1324
- }
1361
+ return /* @__PURE__ */ jsx3(FrameHostContext.Provider, { value: specCtx, children: /* @__PURE__ */ jsxs2(MoonPayContext.Provider, { value: { client, initialize, isInitialized }, children: [
1362
+ children,
1363
+ /* @__PURE__ */ jsx3(FrameSlots, { frameSlots, removeSlot })
1364
+ ] }) });
1365
+ }
1366
+ function MoonPayEnterpriseProvider({
1367
+ clientToken,
1368
+ frameBaseUrl,
1369
+ theme,
1370
+ children
1371
+ }) {
1372
+ const { frameSlots, addSlot, removeSlot } = useFrameSlots();
1373
+ const core = useCore(void 0, frameBaseUrl);
1374
+ core.context.setClientToken(clientToken);
1375
+ const specCtx = useMemo2(
1376
+ () => ({ core, frameBaseUrl, theme, enterpriseClientToken: clientToken }),
1377
+ [clientToken, core, frameBaseUrl, theme?.appearance]
1325
1378
  );
1379
+ const value = useMemo2(
1380
+ () => ({
1381
+ client: createRNEnterpriseClient({
1382
+ mountSession: createMountSession(specCtx, { addSlot, removeSlot }),
1383
+ core
1384
+ })
1385
+ }),
1386
+ [specCtx, core, addSlot, removeSlot]
1387
+ );
1388
+ return /* @__PURE__ */ jsx3(FrameHostContext.Provider, { value: specCtx, children: /* @__PURE__ */ jsxs2(MoonPayEnterpriseContext.Provider, { value, children: [
1389
+ children,
1390
+ /* @__PURE__ */ jsx3(FrameSlots, { frameSlots, removeSlot })
1391
+ ] }) });
1326
1392
  }
1327
- function useMoonPayContext() {
1393
+ function useFrameHostContext() {
1394
+ const ctx = useContext(FrameHostContext);
1395
+ if (!ctx) {
1396
+ throw new Error(
1397
+ "MoonPay frame components must be used within a <MoonPayProvider> or <MoonPayEnterpriseProvider>"
1398
+ );
1399
+ }
1400
+ return ctx;
1401
+ }
1402
+ function useMoonPay() {
1328
1403
  const ctx = useContext(MoonPayContext);
1329
1404
  if (!ctx) {
1330
1405
  throw new Error("useMoonPay must be used within a <MoonPayProvider>");
1331
1406
  }
1332
1407
  return ctx;
1333
1408
  }
1334
- function useMoonPay() {
1335
- const { client, initialize, isInitialized } = useMoonPayContext();
1336
- return { client, initialize, isInitialized };
1409
+ function useMoonPayEnterprise() {
1410
+ const ctx = useContext(MoonPayEnterpriseContext);
1411
+ if (!ctx) {
1412
+ throw new Error("useMoonPayEnterprise must be used within a <MoonPayEnterpriseProvider>");
1413
+ }
1414
+ return ctx;
1337
1415
  }
1338
1416
 
1339
1417
  // src/frame-view.tsx
@@ -1356,7 +1434,8 @@ function MoonPayFrameView({
1356
1434
  webViewProps,
1357
1435
  onRef
1358
1436
  }) {
1359
- const { sessionToken, core, frameBaseUrl, theme } = useMoonPayContext();
1437
+ const frameHost = useFrameHostContext();
1438
+ const { sessionToken, enterpriseClientToken, core, frameBaseUrl } = frameHost;
1360
1439
  const [transport, setTransport] = useState3(null);
1361
1440
  const handleRef = useRef4(null);
1362
1441
  const onEventRef = useRef4(onEvent);
@@ -1382,11 +1461,7 @@ function MoonPayFrameView({
1382
1461
  }
1383
1462
  appliedRef.current = applied;
1384
1463
  try {
1385
- session = createFrameSession(
1386
- spec,
1387
- { sessionToken, core, frameBaseUrl, theme },
1388
- propsRef.current
1389
- );
1464
+ session = createFrameSession(spec, frameHost, propsRef.current);
1390
1465
  } catch (e) {
1391
1466
  onEventRef.current?.(
1392
1467
  spec.errorEvent(e instanceof Error ? e.message : "Failed to create frame")
@@ -1415,7 +1490,7 @@ function MoonPayFrameView({
1415
1490
  session.dispose();
1416
1491
  setTransport(null);
1417
1492
  };
1418
- }, [mountKey, spec, sessionToken, core, frameBaseUrl]);
1493
+ }, [mountKey, spec, sessionToken, enterpriseClientToken, core, frameBaseUrl]);
1419
1494
  useEffect3(() => {
1420
1495
  const handle = handleRef.current;
1421
1496
  if (!handle) return;
@@ -1491,6 +1566,7 @@ function MoonPayBuyButton({
1491
1566
  quote,
1492
1567
  externalTransactionId,
1493
1568
  applePayButtonSettings,
1569
+ headless,
1494
1570
  onEvent,
1495
1571
  style,
1496
1572
  webViewProps
@@ -1498,7 +1574,7 @@ function MoonPayBuyButton({
1498
1574
  return /* @__PURE__ */ jsx8(
1499
1575
  MoonPayFrameView,
1500
1576
  {
1501
- spec: buyButtonSpec,
1577
+ spec: headless ? headlessBuyButtonSpec : buyButtonSpec,
1502
1578
  props: { quote, externalTransactionId, applePayButtonSettings },
1503
1579
  style,
1504
1580
  defaultStyle: { height: 48 },
@@ -1682,11 +1758,13 @@ export {
1682
1758
  MoonPayConnectionCheck,
1683
1759
  MoonPayConnectionReset,
1684
1760
  MoonPayCustomerExport,
1761
+ MoonPayEnterpriseProvider,
1685
1762
  MoonPayFrame,
1686
1763
  MoonPayGooglePayButton,
1687
1764
  MoonPayProvider,
1688
1765
  MoonPayWidget,
1689
1766
  WebViewTransport,
1690
- useMoonPay
1767
+ useMoonPay,
1768
+ useMoonPayEnterprise
1691
1769
  };
1692
1770
  //# sourceMappingURL=index.js.map