@moonpay/platform-sdk-react-native 1.24.3 → 1.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +140 -55
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +45 -4
- package/dist/index.d.ts +45 -4
- package/dist/index.js +138 -55
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -2,10 +2,11 @@ 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';
|
|
8
|
-
export { Cancellation as ChallengeCancellation, CompleteResult as ChallengeCompleteResult } from '@moonpay/platform-protocol/frames/challenge';
|
|
9
|
+
export { Cancellation as ChallengeCancellation, CompleteResult as ChallengeCompleteResult, ErrorCode as ChallengeErrorCode } from '@moonpay/platform-protocol/frames/challenge';
|
|
9
10
|
import { Connection } from '@moonpay/platform-protocol/models/connection';
|
|
10
11
|
export { Connection, ConnectionStatus } from '@moonpay/platform-protocol/models/connection';
|
|
11
12
|
import { Result } from '@moonpay/platform-protocol/result';
|
|
@@ -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
|
-
/**
|
|
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,10 +2,11 @@ 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';
|
|
8
|
-
export { Cancellation as ChallengeCancellation, CompleteResult as ChallengeCompleteResult } from '@moonpay/platform-protocol/frames/challenge';
|
|
9
|
+
export { Cancellation as ChallengeCancellation, CompleteResult as ChallengeCompleteResult, ErrorCode as ChallengeErrorCode } from '@moonpay/platform-protocol/frames/challenge';
|
|
9
10
|
import { Connection } from '@moonpay/platform-protocol/models/connection';
|
|
10
11
|
export { Connection, ConnectionStatus } from '@moonpay/platform-protocol/models/connection';
|
|
11
12
|
import { Result } from '@moonpay/platform-protocol/result';
|
|
@@ -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
|
-
/**
|
|
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,
|
|
@@ -151,6 +152,11 @@ var buyButtonSpec = {
|
|
|
151
152
|
kind: "challenge",
|
|
152
153
|
payload: msg.payload
|
|
153
154
|
};
|
|
155
|
+
case "cancelled":
|
|
156
|
+
return {
|
|
157
|
+
kind: "cancelled",
|
|
158
|
+
payload: msg.payload
|
|
159
|
+
};
|
|
154
160
|
case "error":
|
|
155
161
|
return { kind: "error", payload: msg.payload };
|
|
156
162
|
default:
|
|
@@ -162,6 +168,14 @@ var buyButtonSpec = {
|
|
|
162
168
|
payload: { code: "generic", message }
|
|
163
169
|
})
|
|
164
170
|
};
|
|
171
|
+
var headlessBuyButtonSpec = {
|
|
172
|
+
...buyButtonSpec,
|
|
173
|
+
hidden: true,
|
|
174
|
+
buildParams: (ctx, props) => ({
|
|
175
|
+
...buyButtonSpec.buildParams?.(ctx, props),
|
|
176
|
+
headless: true
|
|
177
|
+
})
|
|
178
|
+
};
|
|
165
179
|
function applyCredentialsOnComplete(msg, ctx) {
|
|
166
180
|
if (msg.kind !== "complete" || !ctx.privateKey) return;
|
|
167
181
|
const connection = msg.payload;
|
|
@@ -350,6 +364,7 @@ var buySpec = {
|
|
|
350
364
|
var addCardSpec = {
|
|
351
365
|
channelPrefix: "add-card",
|
|
352
366
|
path: FRAME_PATHS.addCard,
|
|
367
|
+
enterprise: true,
|
|
353
368
|
hidden: false,
|
|
354
369
|
buildParams: (ctx, props) => ({
|
|
355
370
|
clientToken: ctx.core.context.clientToken,
|
|
@@ -409,6 +424,7 @@ var challengeSpec = {
|
|
|
409
424
|
channelPrefix: "challenge",
|
|
410
425
|
path: FRAME_PATHS.challenge,
|
|
411
426
|
// documentation only — buildUrl below wins
|
|
427
|
+
enterprise: true,
|
|
412
428
|
hidden: false,
|
|
413
429
|
resolveChannelId: (props, generated) => new URL(props.url).searchParams.get("channelId") || generated,
|
|
414
430
|
buildUrl: (ctx, props, channelId) => {
|
|
@@ -588,6 +604,9 @@ var FrameSessionDisposedError = class extends Error {
|
|
|
588
604
|
}
|
|
589
605
|
};
|
|
590
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
|
+
}
|
|
591
610
|
const generated = `${spec.channelPrefix}-${Date.now()}`;
|
|
592
611
|
const channelId = spec.resolveChannelId ? spec.resolveChannelId(props, generated) : generated;
|
|
593
612
|
let keyPair;
|
|
@@ -798,12 +817,15 @@ async function setupBuy(deps, opts) {
|
|
|
798
817
|
import { err as err5, ok as ok5 } from "@moonpay/platform-protocol/result";
|
|
799
818
|
async function setupBuyButton(deps, opts) {
|
|
800
819
|
try {
|
|
801
|
-
const { handle, dispose } = await deps.mountSession(
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
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
|
+
);
|
|
807
829
|
handle.onEvent((event) => opts.onEvent?.(event));
|
|
808
830
|
return ok5({ setQuote: handle.commands.setQuote, dispose });
|
|
809
831
|
} catch (e) {
|
|
@@ -1010,6 +1032,13 @@ function createRNClient(deps) {
|
|
|
1010
1032
|
submitIdentityFiles: (id, body) => core.submitIdentityFiles(id, body)
|
|
1011
1033
|
};
|
|
1012
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
|
+
}
|
|
1013
1042
|
|
|
1014
1043
|
// src/methods/mount-session.ts
|
|
1015
1044
|
var slotCounter = 0;
|
|
@@ -1254,24 +1283,21 @@ var styles = StyleSheet.create({
|
|
|
1254
1283
|
});
|
|
1255
1284
|
|
|
1256
1285
|
// src/provider.tsx
|
|
1257
|
-
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);
|
|
1258
1288
|
var MoonPayContext = createContext(null);
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
apiBaseUrl,
|
|
1262
|
-
frameBaseUrl,
|
|
1263
|
-
theme,
|
|
1264
|
-
children
|
|
1265
|
-
}) {
|
|
1289
|
+
var MoonPayEnterpriseContext = createContext(null);
|
|
1290
|
+
function useFrameSlots() {
|
|
1266
1291
|
const [frameSlots, setFrameSlots] = useState2([]);
|
|
1267
|
-
const [internalToken, setInternalToken] = useState2(void 0);
|
|
1268
|
-
const sessionToken = sessionTokenProp ?? internalToken;
|
|
1269
1292
|
const addSlot = useCallback2((slot) => {
|
|
1270
1293
|
setFrameSlots((prev) => [...prev, slot]);
|
|
1271
1294
|
}, []);
|
|
1272
1295
|
const removeSlot = useCallback2((id) => {
|
|
1273
1296
|
setFrameSlots((prev) => prev.filter((s) => s.id !== id));
|
|
1274
1297
|
}, []);
|
|
1298
|
+
return { frameSlots, addSlot, removeSlot };
|
|
1299
|
+
}
|
|
1300
|
+
function useCore(apiBaseUrl, frameBaseUrl) {
|
|
1275
1301
|
const coreRef = useRef3(null);
|
|
1276
1302
|
if (!coreRef.current) {
|
|
1277
1303
|
coreRef.current = createClientCore({
|
|
@@ -1280,7 +1306,38 @@ function MoonPayProvider({
|
|
|
1280
1306
|
createTransport: () => new WebViewTransport()
|
|
1281
1307
|
});
|
|
1282
1308
|
}
|
|
1283
|
-
|
|
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);
|
|
1284
1341
|
const initialize = useCallback2(
|
|
1285
1342
|
(token) => {
|
|
1286
1343
|
core.context.setAccessToken("");
|
|
@@ -1289,46 +1346,72 @@ function MoonPayProvider({
|
|
|
1289
1346
|
},
|
|
1290
1347
|
[core]
|
|
1291
1348
|
);
|
|
1292
|
-
const
|
|
1293
|
-
|
|
1294
|
-
|
|
1349
|
+
const specCtx = useMemo2(
|
|
1350
|
+
() => ({ sessionToken, core, frameBaseUrl, theme }),
|
|
1351
|
+
[sessionToken, core, frameBaseUrl, theme?.appearance]
|
|
1352
|
+
);
|
|
1353
|
+
const client = useMemo2(
|
|
1354
|
+
() => createRNClient({
|
|
1295
1355
|
mountSession: createMountSession(specCtx, { addSlot, removeSlot }),
|
|
1296
1356
|
core
|
|
1297
|
-
})
|
|
1298
|
-
|
|
1357
|
+
}),
|
|
1358
|
+
[specCtx, core, addSlot, removeSlot]
|
|
1359
|
+
);
|
|
1299
1360
|
const isInitialized = sessionToken !== void 0;
|
|
1300
|
-
return /* @__PURE__ */ jsxs2(
|
|
1301
|
-
|
|
1302
|
-
{
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
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]
|
|
1378
|
+
);
|
|
1379
|
+
const value = useMemo2(
|
|
1380
|
+
() => ({
|
|
1381
|
+
client: createRNEnterpriseClient({
|
|
1382
|
+
mountSession: createMountSession(specCtx, { addSlot, removeSlot }),
|
|
1383
|
+
core
|
|
1384
|
+
})
|
|
1385
|
+
}),
|
|
1386
|
+
[specCtx, core, addSlot, removeSlot]
|
|
1320
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
|
+
] }) });
|
|
1392
|
+
}
|
|
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;
|
|
1321
1401
|
}
|
|
1322
|
-
function
|
|
1402
|
+
function useMoonPay() {
|
|
1323
1403
|
const ctx = useContext(MoonPayContext);
|
|
1324
1404
|
if (!ctx) {
|
|
1325
1405
|
throw new Error("useMoonPay must be used within a <MoonPayProvider>");
|
|
1326
1406
|
}
|
|
1327
1407
|
return ctx;
|
|
1328
1408
|
}
|
|
1329
|
-
function
|
|
1330
|
-
const
|
|
1331
|
-
|
|
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;
|
|
1332
1415
|
}
|
|
1333
1416
|
|
|
1334
1417
|
// src/frame-view.tsx
|
|
@@ -1351,7 +1434,8 @@ function MoonPayFrameView({
|
|
|
1351
1434
|
webViewProps,
|
|
1352
1435
|
onRef
|
|
1353
1436
|
}) {
|
|
1354
|
-
const
|
|
1437
|
+
const frameHost = useFrameHostContext();
|
|
1438
|
+
const { sessionToken, enterpriseClientToken, core, frameBaseUrl } = frameHost;
|
|
1355
1439
|
const [transport, setTransport] = useState3(null);
|
|
1356
1440
|
const handleRef = useRef4(null);
|
|
1357
1441
|
const onEventRef = useRef4(onEvent);
|
|
@@ -1377,11 +1461,7 @@ function MoonPayFrameView({
|
|
|
1377
1461
|
}
|
|
1378
1462
|
appliedRef.current = applied;
|
|
1379
1463
|
try {
|
|
1380
|
-
session = createFrameSession(
|
|
1381
|
-
spec,
|
|
1382
|
-
{ sessionToken, core, frameBaseUrl, theme },
|
|
1383
|
-
propsRef.current
|
|
1384
|
-
);
|
|
1464
|
+
session = createFrameSession(spec, frameHost, propsRef.current);
|
|
1385
1465
|
} catch (e) {
|
|
1386
1466
|
onEventRef.current?.(
|
|
1387
1467
|
spec.errorEvent(e instanceof Error ? e.message : "Failed to create frame")
|
|
@@ -1410,7 +1490,7 @@ function MoonPayFrameView({
|
|
|
1410
1490
|
session.dispose();
|
|
1411
1491
|
setTransport(null);
|
|
1412
1492
|
};
|
|
1413
|
-
}, [mountKey, spec, sessionToken, core, frameBaseUrl]);
|
|
1493
|
+
}, [mountKey, spec, sessionToken, enterpriseClientToken, core, frameBaseUrl]);
|
|
1414
1494
|
useEffect3(() => {
|
|
1415
1495
|
const handle = handleRef.current;
|
|
1416
1496
|
if (!handle) return;
|
|
@@ -1486,6 +1566,7 @@ function MoonPayBuyButton({
|
|
|
1486
1566
|
quote,
|
|
1487
1567
|
externalTransactionId,
|
|
1488
1568
|
applePayButtonSettings,
|
|
1569
|
+
headless,
|
|
1489
1570
|
onEvent,
|
|
1490
1571
|
style,
|
|
1491
1572
|
webViewProps
|
|
@@ -1493,7 +1574,7 @@ function MoonPayBuyButton({
|
|
|
1493
1574
|
return /* @__PURE__ */ jsx8(
|
|
1494
1575
|
MoonPayFrameView,
|
|
1495
1576
|
{
|
|
1496
|
-
spec: buyButtonSpec,
|
|
1577
|
+
spec: headless ? headlessBuyButtonSpec : buyButtonSpec,
|
|
1497
1578
|
props: { quote, externalTransactionId, applePayButtonSettings },
|
|
1498
1579
|
style,
|
|
1499
1580
|
defaultStyle: { height: 48 },
|
|
@@ -1677,11 +1758,13 @@ export {
|
|
|
1677
1758
|
MoonPayConnectionCheck,
|
|
1678
1759
|
MoonPayConnectionReset,
|
|
1679
1760
|
MoonPayCustomerExport,
|
|
1761
|
+
MoonPayEnterpriseProvider,
|
|
1680
1762
|
MoonPayFrame,
|
|
1681
1763
|
MoonPayGooglePayButton,
|
|
1682
1764
|
MoonPayProvider,
|
|
1683
1765
|
MoonPayWidget,
|
|
1684
1766
|
WebViewTransport,
|
|
1685
|
-
useMoonPay
|
|
1767
|
+
useMoonPay,
|
|
1768
|
+
useMoonPayEnterprise
|
|
1686
1769
|
};
|
|
1687
1770
|
//# sourceMappingURL=index.js.map
|