@moonpay/platform-sdk-react-native 1.6.0 → 1.7.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/README.md +5 -3
- package/dist/index.cjs +115 -63
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +43 -3
- package/dist/index.d.ts +43 -3
- package/dist/index.js +106 -53
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { ListPaymentMethodsResponse, GetQuoteParams, Quote, ListAssetsResponse, Transaction, PaginationInfo, TransactionWithStages } from '@moonpay/platform-protocol/api';
|
|
2
2
|
export { AssetStatus, GetQuoteParams, ListAssetsResponse, ListPaymentMethodsResponse, PaginationInfo, PaymentMethodConfig, PaymentMethodType, PlatformAsset, Quote, StoredCardPaymentMethod, StoredPaymentMethod, Transaction, TransactionWithStages } from '@moonpay/platform-protocol/api';
|
|
3
|
+
import { Customer } from '@moonpay/platform-protocol/api/customer';
|
|
4
|
+
export { Customer } from '@moonpay/platform-protocol/api/customer';
|
|
3
5
|
export { CardResponse } from '@moonpay/platform-protocol/frames/add-card';
|
|
4
6
|
export { Cancellation as ChallengeCancellation, CompleteResult as ChallengeCompleteResult } from '@moonpay/platform-protocol/frames/challenge';
|
|
5
7
|
import { Connection } from '@moonpay/platform-protocol/models/connection';
|
|
@@ -20,14 +22,16 @@ import * as ChallengeSdk from '@moonpay/platform-protocol/sdks/challenge';
|
|
|
20
22
|
export { Event as ChallengeEvent, SetupError as SetupChallengeError } from '@moonpay/platform-protocol/sdks/challenge';
|
|
21
23
|
import * as ConnectSdk from '@moonpay/platform-protocol/sdks/connect';
|
|
22
24
|
export { Event as ConnectEvent } from '@moonpay/platform-protocol/sdks/connect';
|
|
25
|
+
import * as CustomerExportSdk from '@moonpay/platform-protocol/sdks/customer-export';
|
|
26
|
+
export { Event as CustomerExportEvent, SetupError as SetupCustomerExportError } from '@moonpay/platform-protocol/sdks/customer-export';
|
|
23
27
|
import * as GooglePaySdk from '@moonpay/platform-protocol/sdks/google-pay';
|
|
24
28
|
export { Event as GooglePayEvent, SetupError as SetupGooglePayError } from '@moonpay/platform-protocol/sdks/google-pay';
|
|
25
29
|
import * as WidgetSdk from '@moonpay/platform-protocol/sdks/widget';
|
|
26
30
|
export { SetupError as SetupWidgetError, Event as WidgetEvent } from '@moonpay/platform-protocol/sdks/widget';
|
|
27
31
|
import { FrameTransport, FrameOptions, ThemeOptions, ListAssetsParams, ListTransactionsParams } from '@moonpay/platform-sdk-core';
|
|
28
32
|
export { ListAssetsParams, ThemeOptions } from '@moonpay/platform-sdk-core';
|
|
29
|
-
import { GetPaymentMethodsError, GetQuoteError, GetAssetsError, GetTransactionsError, DevPlatformApiError, CreateIdentityError, GetIdentityError, UpdateIdentityError, VerifyIdentityError, GetIdentityUploadUrlError, SubmitIdentityFilesError } from '@moonpay/platform-protocol/api/errors';
|
|
30
|
-
import {
|
|
33
|
+
import { GetPaymentMethodsError, GetQuoteError, GetAssetsError, GetTransactionsError, DevPlatformApiError, GetCustomerError, SubmitCustomerKycError, GetCustomerUploadUrlError, SubmitCustomerFilesError, CreateIdentityError, GetIdentityError, UpdateIdentityError, VerifyIdentityError, GetIdentityUploadUrlError, SubmitIdentityFilesError } from '@moonpay/platform-protocol/api/errors';
|
|
34
|
+
import { UpdateIdentityRequestBody, IdentityFileUploadUrlRequestBody, IdentityFileUploadUrl, SubmitIdentityFilesRequestBody, CreateIdentityRequestBody, Identity, IdentityVerificationResponse } from '@moonpay/platform-protocol/api/identity';
|
|
31
35
|
import { ResetConnectionError } from '@moonpay/platform-protocol/sdks/reset';
|
|
32
36
|
import { ViewStyle } from 'react-native';
|
|
33
37
|
import { ProtocolMessage } from '@moonpay/platform-protocol/protocol';
|
|
@@ -151,6 +155,14 @@ interface GetConnectionOptions {
|
|
|
151
155
|
skipKyc?: boolean;
|
|
152
156
|
}
|
|
153
157
|
|
|
158
|
+
interface SetupCustomerExportOptions {
|
|
159
|
+
/** Callback for customer-export frame lifecycle events. */
|
|
160
|
+
onEvent?: (event: CustomerExportSdk.Event) => void;
|
|
161
|
+
}
|
|
162
|
+
interface CustomerExportFrame {
|
|
163
|
+
dispose(): void;
|
|
164
|
+
}
|
|
165
|
+
|
|
154
166
|
interface SetupGooglePayOptions {
|
|
155
167
|
/** Quote signature from getQuote(). */
|
|
156
168
|
quote: string;
|
|
@@ -234,21 +246,40 @@ interface RNClient {
|
|
|
234
246
|
resetConnection(): Promise<Result<void, ResetConnectionError>>;
|
|
235
247
|
setupChallenge(options: SetupChallengeOptions): Promise<Result<ChallengeFrame, ChallengeSdk.SetupError>>;
|
|
236
248
|
setupAddCard(options: SetupAddCardOptions): Promise<Result<AddCardFrame, AddCardSdk.SetupError>>;
|
|
249
|
+
setupCustomerExport(options: SetupCustomerExportOptions): Promise<Result<CustomerExportFrame, CustomerExportSdk.SetupError>>;
|
|
250
|
+
getCustomer(id: string): Promise<Result<{
|
|
251
|
+
data: Customer;
|
|
252
|
+
}, GetCustomerError>>;
|
|
253
|
+
submitCustomerKyc(id: string, body: UpdateIdentityRequestBody): Promise<Result<{
|
|
254
|
+
data: Customer;
|
|
255
|
+
}, SubmitCustomerKycError>>;
|
|
256
|
+
getCustomerUploadUrl(id: string, body: IdentityFileUploadUrlRequestBody): Promise<Result<{
|
|
257
|
+
data: IdentityFileUploadUrl;
|
|
258
|
+
}, GetCustomerUploadUrlError>>;
|
|
259
|
+
submitCustomerFiles(id: string, body: SubmitIdentityFilesRequestBody): Promise<Result<{
|
|
260
|
+
data: Customer;
|
|
261
|
+
}, SubmitCustomerFilesError>>;
|
|
262
|
+
/** @deprecated Customers are created automatically now — call `getCustomer` directly instead. */
|
|
237
263
|
createIdentity(body: CreateIdentityRequestBody): Promise<Result<{
|
|
238
264
|
data: Identity | null;
|
|
239
265
|
}, CreateIdentityError>>;
|
|
266
|
+
/** @deprecated Use `getCustomer` instead. */
|
|
240
267
|
getIdentity(id: string): Promise<Result<{
|
|
241
268
|
data: Identity;
|
|
242
269
|
}, GetIdentityError>>;
|
|
270
|
+
/** @deprecated Use `submitCustomerKyc` instead. */
|
|
243
271
|
updateIdentity(id: string, body: UpdateIdentityRequestBody): Promise<Result<{
|
|
244
272
|
data: Identity;
|
|
245
273
|
}, UpdateIdentityError>>;
|
|
274
|
+
/** @deprecated No longer needed — Customer API verification has no direct replacement call. */
|
|
246
275
|
verifyIdentity(id: string): Promise<Result<{
|
|
247
276
|
data: IdentityVerificationResponse;
|
|
248
277
|
}, VerifyIdentityError>>;
|
|
278
|
+
/** @deprecated Use `getCustomerUploadUrl` instead. */
|
|
249
279
|
getIdentityUploadUrl(id: string, body: IdentityFileUploadUrlRequestBody): Promise<Result<{
|
|
250
280
|
data: IdentityFileUploadUrl;
|
|
251
281
|
}, GetIdentityUploadUrlError>>;
|
|
282
|
+
/** @deprecated Use `submitCustomerFiles` instead. */
|
|
252
283
|
submitIdentityFiles(id: string, body: SubmitIdentityFilesRequestBody): Promise<Result<{
|
|
253
284
|
data: Identity;
|
|
254
285
|
}, SubmitIdentityFilesError>>;
|
|
@@ -369,6 +400,15 @@ interface MoonPayConnectionResetProps {
|
|
|
369
400
|
/** Headless reset frame (renders nothing visible). The declarative alternative to client.resetConnection(). */
|
|
370
401
|
declare function MoonPayConnectionReset({ onEvent }: MoonPayConnectionResetProps): JSX.Element;
|
|
371
402
|
|
|
403
|
+
interface MoonPayCustomerExportProps {
|
|
404
|
+
/** Callback for customer-export lifecycle events. */
|
|
405
|
+
onEvent?: (event: CustomerExportSdk.Event) => void;
|
|
406
|
+
/** Container style. Defaults to flex: 1. */
|
|
407
|
+
style?: ViewStyle;
|
|
408
|
+
}
|
|
409
|
+
/** Inline customer-export consent frame — embed export consent capture in your own layout. */
|
|
410
|
+
declare function MoonPayCustomerExport({ onEvent, style }: MoonPayCustomerExportProps): JSX.Element;
|
|
411
|
+
|
|
372
412
|
interface MoonPayGooglePayButtonProps {
|
|
373
413
|
/** Quote signature from getQuote(). Reactive — updates are pushed via setQuote without remounting. */
|
|
374
414
|
quote: string;
|
|
@@ -420,4 +460,4 @@ declare function useMoonPay(): {
|
|
|
420
460
|
client: RNClient;
|
|
421
461
|
};
|
|
422
462
|
|
|
423
|
-
export { type AddCardFrame, type ApplePayFrame, type AuthFrame, type BuyButtonFrame, type BuyFrame, type ChallengeFrame, type ConnectFrame, type ConnectOptions, type ConnectionCheckEvent, type ConnectionResetEvent, 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, 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 SetupGooglePayOptions, type SetupWidgetOptions, WebViewTransport, type WidgetFrame, useMoonPay };
|
|
463
|
+
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { ListPaymentMethodsResponse, GetQuoteParams, Quote, ListAssetsResponse, Transaction, PaginationInfo, TransactionWithStages } from '@moonpay/platform-protocol/api';
|
|
2
2
|
export { AssetStatus, GetQuoteParams, ListAssetsResponse, ListPaymentMethodsResponse, PaginationInfo, PaymentMethodConfig, PaymentMethodType, PlatformAsset, Quote, StoredCardPaymentMethod, StoredPaymentMethod, Transaction, TransactionWithStages } from '@moonpay/platform-protocol/api';
|
|
3
|
+
import { Customer } from '@moonpay/platform-protocol/api/customer';
|
|
4
|
+
export { Customer } from '@moonpay/platform-protocol/api/customer';
|
|
3
5
|
export { CardResponse } from '@moonpay/platform-protocol/frames/add-card';
|
|
4
6
|
export { Cancellation as ChallengeCancellation, CompleteResult as ChallengeCompleteResult } from '@moonpay/platform-protocol/frames/challenge';
|
|
5
7
|
import { Connection } from '@moonpay/platform-protocol/models/connection';
|
|
@@ -20,14 +22,16 @@ import * as ChallengeSdk from '@moonpay/platform-protocol/sdks/challenge';
|
|
|
20
22
|
export { Event as ChallengeEvent, SetupError as SetupChallengeError } from '@moonpay/platform-protocol/sdks/challenge';
|
|
21
23
|
import * as ConnectSdk from '@moonpay/platform-protocol/sdks/connect';
|
|
22
24
|
export { Event as ConnectEvent } from '@moonpay/platform-protocol/sdks/connect';
|
|
25
|
+
import * as CustomerExportSdk from '@moonpay/platform-protocol/sdks/customer-export';
|
|
26
|
+
export { Event as CustomerExportEvent, SetupError as SetupCustomerExportError } from '@moonpay/platform-protocol/sdks/customer-export';
|
|
23
27
|
import * as GooglePaySdk from '@moonpay/platform-protocol/sdks/google-pay';
|
|
24
28
|
export { Event as GooglePayEvent, SetupError as SetupGooglePayError } from '@moonpay/platform-protocol/sdks/google-pay';
|
|
25
29
|
import * as WidgetSdk from '@moonpay/platform-protocol/sdks/widget';
|
|
26
30
|
export { SetupError as SetupWidgetError, Event as WidgetEvent } from '@moonpay/platform-protocol/sdks/widget';
|
|
27
31
|
import { FrameTransport, FrameOptions, ThemeOptions, ListAssetsParams, ListTransactionsParams } from '@moonpay/platform-sdk-core';
|
|
28
32
|
export { ListAssetsParams, ThemeOptions } from '@moonpay/platform-sdk-core';
|
|
29
|
-
import { GetPaymentMethodsError, GetQuoteError, GetAssetsError, GetTransactionsError, DevPlatformApiError, CreateIdentityError, GetIdentityError, UpdateIdentityError, VerifyIdentityError, GetIdentityUploadUrlError, SubmitIdentityFilesError } from '@moonpay/platform-protocol/api/errors';
|
|
30
|
-
import {
|
|
33
|
+
import { GetPaymentMethodsError, GetQuoteError, GetAssetsError, GetTransactionsError, DevPlatformApiError, GetCustomerError, SubmitCustomerKycError, GetCustomerUploadUrlError, SubmitCustomerFilesError, CreateIdentityError, GetIdentityError, UpdateIdentityError, VerifyIdentityError, GetIdentityUploadUrlError, SubmitIdentityFilesError } from '@moonpay/platform-protocol/api/errors';
|
|
34
|
+
import { UpdateIdentityRequestBody, IdentityFileUploadUrlRequestBody, IdentityFileUploadUrl, SubmitIdentityFilesRequestBody, CreateIdentityRequestBody, Identity, IdentityVerificationResponse } from '@moonpay/platform-protocol/api/identity';
|
|
31
35
|
import { ResetConnectionError } from '@moonpay/platform-protocol/sdks/reset';
|
|
32
36
|
import { ViewStyle } from 'react-native';
|
|
33
37
|
import { ProtocolMessage } from '@moonpay/platform-protocol/protocol';
|
|
@@ -151,6 +155,14 @@ interface GetConnectionOptions {
|
|
|
151
155
|
skipKyc?: boolean;
|
|
152
156
|
}
|
|
153
157
|
|
|
158
|
+
interface SetupCustomerExportOptions {
|
|
159
|
+
/** Callback for customer-export frame lifecycle events. */
|
|
160
|
+
onEvent?: (event: CustomerExportSdk.Event) => void;
|
|
161
|
+
}
|
|
162
|
+
interface CustomerExportFrame {
|
|
163
|
+
dispose(): void;
|
|
164
|
+
}
|
|
165
|
+
|
|
154
166
|
interface SetupGooglePayOptions {
|
|
155
167
|
/** Quote signature from getQuote(). */
|
|
156
168
|
quote: string;
|
|
@@ -234,21 +246,40 @@ interface RNClient {
|
|
|
234
246
|
resetConnection(): Promise<Result<void, ResetConnectionError>>;
|
|
235
247
|
setupChallenge(options: SetupChallengeOptions): Promise<Result<ChallengeFrame, ChallengeSdk.SetupError>>;
|
|
236
248
|
setupAddCard(options: SetupAddCardOptions): Promise<Result<AddCardFrame, AddCardSdk.SetupError>>;
|
|
249
|
+
setupCustomerExport(options: SetupCustomerExportOptions): Promise<Result<CustomerExportFrame, CustomerExportSdk.SetupError>>;
|
|
250
|
+
getCustomer(id: string): Promise<Result<{
|
|
251
|
+
data: Customer;
|
|
252
|
+
}, GetCustomerError>>;
|
|
253
|
+
submitCustomerKyc(id: string, body: UpdateIdentityRequestBody): Promise<Result<{
|
|
254
|
+
data: Customer;
|
|
255
|
+
}, SubmitCustomerKycError>>;
|
|
256
|
+
getCustomerUploadUrl(id: string, body: IdentityFileUploadUrlRequestBody): Promise<Result<{
|
|
257
|
+
data: IdentityFileUploadUrl;
|
|
258
|
+
}, GetCustomerUploadUrlError>>;
|
|
259
|
+
submitCustomerFiles(id: string, body: SubmitIdentityFilesRequestBody): Promise<Result<{
|
|
260
|
+
data: Customer;
|
|
261
|
+
}, SubmitCustomerFilesError>>;
|
|
262
|
+
/** @deprecated Customers are created automatically now — call `getCustomer` directly instead. */
|
|
237
263
|
createIdentity(body: CreateIdentityRequestBody): Promise<Result<{
|
|
238
264
|
data: Identity | null;
|
|
239
265
|
}, CreateIdentityError>>;
|
|
266
|
+
/** @deprecated Use `getCustomer` instead. */
|
|
240
267
|
getIdentity(id: string): Promise<Result<{
|
|
241
268
|
data: Identity;
|
|
242
269
|
}, GetIdentityError>>;
|
|
270
|
+
/** @deprecated Use `submitCustomerKyc` instead. */
|
|
243
271
|
updateIdentity(id: string, body: UpdateIdentityRequestBody): Promise<Result<{
|
|
244
272
|
data: Identity;
|
|
245
273
|
}, UpdateIdentityError>>;
|
|
274
|
+
/** @deprecated No longer needed — Customer API verification has no direct replacement call. */
|
|
246
275
|
verifyIdentity(id: string): Promise<Result<{
|
|
247
276
|
data: IdentityVerificationResponse;
|
|
248
277
|
}, VerifyIdentityError>>;
|
|
278
|
+
/** @deprecated Use `getCustomerUploadUrl` instead. */
|
|
249
279
|
getIdentityUploadUrl(id: string, body: IdentityFileUploadUrlRequestBody): Promise<Result<{
|
|
250
280
|
data: IdentityFileUploadUrl;
|
|
251
281
|
}, GetIdentityUploadUrlError>>;
|
|
282
|
+
/** @deprecated Use `submitCustomerFiles` instead. */
|
|
252
283
|
submitIdentityFiles(id: string, body: SubmitIdentityFilesRequestBody): Promise<Result<{
|
|
253
284
|
data: Identity;
|
|
254
285
|
}, SubmitIdentityFilesError>>;
|
|
@@ -369,6 +400,15 @@ interface MoonPayConnectionResetProps {
|
|
|
369
400
|
/** Headless reset frame (renders nothing visible). The declarative alternative to client.resetConnection(). */
|
|
370
401
|
declare function MoonPayConnectionReset({ onEvent }: MoonPayConnectionResetProps): JSX.Element;
|
|
371
402
|
|
|
403
|
+
interface MoonPayCustomerExportProps {
|
|
404
|
+
/** Callback for customer-export lifecycle events. */
|
|
405
|
+
onEvent?: (event: CustomerExportSdk.Event) => void;
|
|
406
|
+
/** Container style. Defaults to flex: 1. */
|
|
407
|
+
style?: ViewStyle;
|
|
408
|
+
}
|
|
409
|
+
/** Inline customer-export consent frame — embed export consent capture in your own layout. */
|
|
410
|
+
declare function MoonPayCustomerExport({ onEvent, style }: MoonPayCustomerExportProps): JSX.Element;
|
|
411
|
+
|
|
372
412
|
interface MoonPayGooglePayButtonProps {
|
|
373
413
|
/** Quote signature from getQuote(). Reactive — updates are pushed via setQuote without remounting. */
|
|
374
414
|
quote: string;
|
|
@@ -420,4 +460,4 @@ declare function useMoonPay(): {
|
|
|
420
460
|
client: RNClient;
|
|
421
461
|
};
|
|
422
462
|
|
|
423
|
-
export { type AddCardFrame, type ApplePayFrame, type AuthFrame, type BuyButtonFrame, type BuyFrame, type ChallengeFrame, type ConnectFrame, type ConnectOptions, type ConnectionCheckEvent, type ConnectionResetEvent, 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, 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 SetupGooglePayOptions, type SetupWidgetOptions, WebViewTransport, type WidgetFrame, useMoonPay };
|
|
463
|
+
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 };
|
package/dist/index.js
CHANGED
|
@@ -137,14 +137,12 @@ var buyButtonSpec = {
|
|
|
137
137
|
})
|
|
138
138
|
};
|
|
139
139
|
function applyCredentialsOnComplete(msg, ctx) {
|
|
140
|
-
if (msg.kind !== "complete" || !ctx.privateKey)
|
|
141
|
-
return;
|
|
140
|
+
if (msg.kind !== "complete" || !ctx.privateKey) return;
|
|
142
141
|
const connection = msg.payload;
|
|
143
142
|
if (connection.status !== ConnectionStatus.active && connection.status !== ConnectionStatus.connectionRequired) {
|
|
144
143
|
return;
|
|
145
144
|
}
|
|
146
|
-
if (!connection.credentials)
|
|
147
|
-
return;
|
|
145
|
+
if (!connection.credentials) return;
|
|
148
146
|
const creds = decryptCredentials(connection.credentials, ctx.privateKey);
|
|
149
147
|
ctx.core.context.setAccessToken(creds.accessToken);
|
|
150
148
|
ctx.core.context.setClientToken(creds.clientToken);
|
|
@@ -329,6 +327,33 @@ var addCardSpec = {
|
|
|
329
327
|
payload: { code: "generic", message }
|
|
330
328
|
})
|
|
331
329
|
};
|
|
330
|
+
var customerExportSpec = {
|
|
331
|
+
channelPrefix: "customer-export",
|
|
332
|
+
path: FRAME_PATHS.customerExport,
|
|
333
|
+
hidden: false,
|
|
334
|
+
buildParams: (ctx) => ({ clientToken: ctx.core.context.clientToken }),
|
|
335
|
+
mapMessage: (msg) => {
|
|
336
|
+
switch (msg.kind) {
|
|
337
|
+
case "ready":
|
|
338
|
+
return { kind: "ready" };
|
|
339
|
+
case "complete":
|
|
340
|
+
return {
|
|
341
|
+
kind: "complete",
|
|
342
|
+
payload: msg.payload
|
|
343
|
+
};
|
|
344
|
+
case "error":
|
|
345
|
+
return { kind: "error", payload: msg.payload };
|
|
346
|
+
case "close":
|
|
347
|
+
return { kind: "close" };
|
|
348
|
+
default:
|
|
349
|
+
return null;
|
|
350
|
+
}
|
|
351
|
+
},
|
|
352
|
+
errorEvent: (message) => ({
|
|
353
|
+
kind: "error",
|
|
354
|
+
payload: { code: ConnectionErrorCode.connectionFailedGeneric, message }
|
|
355
|
+
})
|
|
356
|
+
};
|
|
332
357
|
var challengeSpec = {
|
|
333
358
|
channelPrefix: "challenge",
|
|
334
359
|
path: FRAME_PATHS.challenge,
|
|
@@ -366,8 +391,7 @@ var connectionResetSpec = {
|
|
|
366
391
|
handshakeTimeout: 5e3,
|
|
367
392
|
buildParams: (ctx) => ({ sessionToken: ctx.sessionToken }),
|
|
368
393
|
mapMessage: (msg) => {
|
|
369
|
-
if (msg.kind === "complete")
|
|
370
|
-
return { kind: "complete" };
|
|
394
|
+
if (msg.kind === "complete") return { kind: "complete" };
|
|
371
395
|
if (msg.kind === "error") {
|
|
372
396
|
const payload = msg.payload;
|
|
373
397
|
return { kind: "error", payload: { message: payload?.message ?? "Reset failed" } };
|
|
@@ -394,8 +418,7 @@ function MoonPayFrame({ transport, hidden, style }) {
|
|
|
394
418
|
};
|
|
395
419
|
}, [transport]);
|
|
396
420
|
const url = transport.url;
|
|
397
|
-
if (!url)
|
|
398
|
-
return null;
|
|
421
|
+
if (!url) return null;
|
|
399
422
|
const handleMessage = (event) => {
|
|
400
423
|
transport.handleWebViewMessage(event.nativeEvent.data);
|
|
401
424
|
};
|
|
@@ -423,6 +446,9 @@ import {
|
|
|
423
446
|
} from "@moonpay/platform-sdk-core";
|
|
424
447
|
|
|
425
448
|
// src/webview-transport.ts
|
|
449
|
+
import {
|
|
450
|
+
isTrustedFrameUrl
|
|
451
|
+
} from "@moonpay/platform-sdk-core";
|
|
426
452
|
var WebViewTransport = class {
|
|
427
453
|
webViewRef = null;
|
|
428
454
|
handlers = [];
|
|
@@ -436,8 +462,7 @@ var WebViewTransport = class {
|
|
|
436
462
|
handleWebViewMessage(data) {
|
|
437
463
|
try {
|
|
438
464
|
const msg = JSON.parse(data);
|
|
439
|
-
if (!msg.kind)
|
|
440
|
-
return;
|
|
465
|
+
if (!msg.kind) return;
|
|
441
466
|
for (const handler of this.handlers) {
|
|
442
467
|
handler(msg);
|
|
443
468
|
}
|
|
@@ -452,6 +477,9 @@ var WebViewTransport = class {
|
|
|
452
477
|
}
|
|
453
478
|
// FrameTransport interface
|
|
454
479
|
create(url, options) {
|
|
480
|
+
if (!isTrustedFrameUrl(url)) {
|
|
481
|
+
throw new Error("Refusing to load frame: URL is not a trusted MoonPay origin");
|
|
482
|
+
}
|
|
455
483
|
this._url = url;
|
|
456
484
|
this._options = options;
|
|
457
485
|
}
|
|
@@ -465,8 +493,7 @@ var WebViewTransport = class {
|
|
|
465
493
|
this.handlers.push(handler);
|
|
466
494
|
return () => {
|
|
467
495
|
const idx = this.handlers.indexOf(handler);
|
|
468
|
-
if (idx >= 0)
|
|
469
|
-
this.handlers.splice(idx, 1);
|
|
496
|
+
if (idx >= 0) this.handlers.splice(idx, 1);
|
|
470
497
|
};
|
|
471
498
|
}
|
|
472
499
|
dispose() {
|
|
@@ -514,8 +541,7 @@ function createFrameSession(spec, ctx, props, overrides = {}) {
|
|
|
514
541
|
const disposeHandlers = [];
|
|
515
542
|
let disposeNotified = false;
|
|
516
543
|
const notifyDisposed = () => {
|
|
517
|
-
if (disposeNotified)
|
|
518
|
-
return;
|
|
544
|
+
if (disposeNotified) return;
|
|
519
545
|
disposeNotified = true;
|
|
520
546
|
for (const handler of [...disposeHandlers]) {
|
|
521
547
|
handler();
|
|
@@ -540,8 +566,7 @@ function createFrameSession(spec, ctx, props, overrides = {}) {
|
|
|
540
566
|
eventHandlers.push(handler);
|
|
541
567
|
return () => {
|
|
542
568
|
const idx = eventHandlers.indexOf(handler);
|
|
543
|
-
if (idx >= 0)
|
|
544
|
-
eventHandlers.splice(idx, 1);
|
|
569
|
+
if (idx >= 0) eventHandlers.splice(idx, 1);
|
|
545
570
|
};
|
|
546
571
|
},
|
|
547
572
|
onMessage: (handler) => handle.onMessage(handler),
|
|
@@ -549,8 +574,7 @@ function createFrameSession(spec, ctx, props, overrides = {}) {
|
|
|
549
574
|
disposeHandlers.push(handler);
|
|
550
575
|
return () => {
|
|
551
576
|
const idx = disposeHandlers.indexOf(handler);
|
|
552
|
-
if (idx >= 0)
|
|
553
|
-
disposeHandlers.splice(idx, 1);
|
|
577
|
+
if (idx >= 0) disposeHandlers.splice(idx, 1);
|
|
554
578
|
};
|
|
555
579
|
},
|
|
556
580
|
sendMessage: send,
|
|
@@ -698,15 +722,19 @@ async function setupBuyButton(deps, opts) {
|
|
|
698
722
|
|
|
699
723
|
// src/methods/challenge.ts
|
|
700
724
|
import { err as err6, ok as ok6 } from "@moonpay/platform-protocol/result";
|
|
725
|
+
import { isTrustedFrameUrl as isTrustedFrameUrl2 } from "@moonpay/platform-sdk-core";
|
|
701
726
|
async function setupChallenge(deps, opts) {
|
|
727
|
+
if (!isTrustedFrameUrl2(opts.url)) {
|
|
728
|
+
return err6({
|
|
729
|
+
kind: "configurationError",
|
|
730
|
+
message: "Challenge URL must be served from a trusted MoonPay origin"
|
|
731
|
+
});
|
|
732
|
+
}
|
|
702
733
|
try {
|
|
703
734
|
const { handle, dispose } = await deps.mountSession(challengeSpec, { url: opts.url });
|
|
704
735
|
handle.onEvent((event) => opts.onEvent?.(event));
|
|
705
736
|
return ok6({ dispose });
|
|
706
737
|
} catch (e) {
|
|
707
|
-
if (e instanceof TypeError) {
|
|
708
|
-
return err6({ kind: "configurationError", message: "Invalid challenge URL" });
|
|
709
|
-
}
|
|
710
738
|
return err6({
|
|
711
739
|
kind: "genericError",
|
|
712
740
|
message: e instanceof Error ? e.message : "Challenge setup failed"
|
|
@@ -791,8 +819,23 @@ async function resetConnection(deps) {
|
|
|
791
819
|
}
|
|
792
820
|
}
|
|
793
821
|
|
|
794
|
-
// src/methods/
|
|
822
|
+
// src/methods/customer-export.ts
|
|
795
823
|
import { err as err9, ok as ok10 } from "@moonpay/platform-protocol/result";
|
|
824
|
+
async function setupCustomerExport(deps, opts) {
|
|
825
|
+
try {
|
|
826
|
+
const { handle, dispose } = await deps.mountSession(customerExportSpec, {});
|
|
827
|
+
handle.onEvent((event) => opts.onEvent?.(event));
|
|
828
|
+
return ok10({ dispose });
|
|
829
|
+
} catch (e) {
|
|
830
|
+
return err9({
|
|
831
|
+
kind: "genericError",
|
|
832
|
+
message: e instanceof Error ? e.message : "Customer export setup failed"
|
|
833
|
+
});
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
// src/methods/google-pay.ts
|
|
838
|
+
import { err as err10, ok as ok11 } from "@moonpay/platform-protocol/result";
|
|
796
839
|
async function setupGooglePay(deps, opts) {
|
|
797
840
|
try {
|
|
798
841
|
const { handle, dispose } = await deps.mountSession(googlePaySpec, {
|
|
@@ -800,9 +843,9 @@ async function setupGooglePay(deps, opts) {
|
|
|
800
843
|
externalTransactionId: opts.externalTransactionId
|
|
801
844
|
});
|
|
802
845
|
handle.onEvent((event) => opts.onEvent?.(event));
|
|
803
|
-
return
|
|
846
|
+
return ok11({ setQuote: handle.commands.setQuote, dispose });
|
|
804
847
|
} catch (e) {
|
|
805
|
-
return
|
|
848
|
+
return err10({
|
|
806
849
|
kind: "genericError",
|
|
807
850
|
message: e instanceof Error ? e.message : "Google Pay setup failed"
|
|
808
851
|
});
|
|
@@ -810,14 +853,14 @@ async function setupGooglePay(deps, opts) {
|
|
|
810
853
|
}
|
|
811
854
|
|
|
812
855
|
// src/methods/widget.ts
|
|
813
|
-
import { err as
|
|
856
|
+
import { err as err11, ok as ok12 } from "@moonpay/platform-protocol/result";
|
|
814
857
|
async function setupWidget(deps, opts) {
|
|
815
858
|
try {
|
|
816
859
|
const { handle, dispose } = await deps.mountSession(widgetSpec, { quote: opts.quote });
|
|
817
860
|
handle.onEvent((event) => opts.onEvent?.(event));
|
|
818
|
-
return
|
|
861
|
+
return ok12({ dispose });
|
|
819
862
|
} catch (e) {
|
|
820
|
-
return
|
|
863
|
+
return err11({
|
|
821
864
|
kind: "genericError",
|
|
822
865
|
message: e instanceof Error ? e.message : "Widget setup failed"
|
|
823
866
|
});
|
|
@@ -845,6 +888,11 @@ function createRNClient(deps) {
|
|
|
845
888
|
resetConnection: () => resetConnection(deps),
|
|
846
889
|
setupChallenge: (opts) => setupChallenge(deps, opts),
|
|
847
890
|
setupAddCard: (opts) => setupAddCard(deps, opts),
|
|
891
|
+
setupCustomerExport: (opts) => setupCustomerExport(deps, opts),
|
|
892
|
+
getCustomer: (id) => core.getCustomer(id),
|
|
893
|
+
submitCustomerKyc: (id, body) => core.submitCustomerKyc(id, body),
|
|
894
|
+
getCustomerUploadUrl: (id, body) => core.getCustomerUploadUrl(id, body),
|
|
895
|
+
submitCustomerFiles: (id, body) => core.submitCustomerFiles(id, body),
|
|
848
896
|
createIdentity: (body) => core.createIdentity(body),
|
|
849
897
|
getIdentity: (id) => core.getIdentity(id),
|
|
850
898
|
updateIdentity: (id, body) => core.updateIdentity(id, body),
|
|
@@ -905,18 +953,15 @@ var NOOP = {
|
|
|
905
953
|
close: false
|
|
906
954
|
};
|
|
907
955
|
function resolvePresentation(phase, signal) {
|
|
908
|
-
if (phase === "closed")
|
|
909
|
-
return { phase: "closed", ...NOOP };
|
|
956
|
+
if (phase === "closed") return { phase: "closed", ...NOOP };
|
|
910
957
|
switch (signal) {
|
|
911
958
|
case "ready":
|
|
912
959
|
return { ...NOOP, phase: "presented", present: phase === "hidden", liftSpinner: true };
|
|
913
960
|
case "grace":
|
|
914
|
-
if (phase === "presented")
|
|
915
|
-
return { phase: "presented", ...NOOP };
|
|
961
|
+
if (phase === "presented") return { phase: "presented", ...NOOP };
|
|
916
962
|
return { ...NOOP, phase: "presented", present: true };
|
|
917
963
|
case "terminal":
|
|
918
|
-
if (phase === "hidden")
|
|
919
|
-
return { ...NOOP, phase: "closed", dismissSilent: true };
|
|
964
|
+
if (phase === "hidden") return { ...NOOP, phase: "closed", dismissSilent: true };
|
|
920
965
|
return { ...NOOP, phase: "closed", close: true };
|
|
921
966
|
}
|
|
922
967
|
}
|
|
@@ -956,13 +1001,11 @@ function VisibleFrameSlotSheet({
|
|
|
956
1001
|
onCloseRef.current = onClose;
|
|
957
1002
|
const closingRef = useRef2(false);
|
|
958
1003
|
const close = useCallback(() => {
|
|
959
|
-
if (closingRef.current)
|
|
960
|
-
return;
|
|
1004
|
+
if (closingRef.current) return;
|
|
961
1005
|
closingRef.current = true;
|
|
962
1006
|
phaseRef.current = "closed";
|
|
963
1007
|
animateSheet(translateY, sheetHeight, ({ finished }) => {
|
|
964
|
-
if (finished)
|
|
965
|
-
onCloseRef.current();
|
|
1008
|
+
if (finished) onCloseRef.current();
|
|
966
1009
|
});
|
|
967
1010
|
}, [translateY, sheetHeight]);
|
|
968
1011
|
const panResponder = useMemo(
|
|
@@ -1005,12 +1048,9 @@ function VisibleFrameSlotSheet({
|
|
|
1005
1048
|
setPresented(true);
|
|
1006
1049
|
animateSheet(translateY, 0);
|
|
1007
1050
|
}
|
|
1008
|
-
if (result.liftSpinner)
|
|
1009
|
-
|
|
1010
|
-
if (result.
|
|
1011
|
-
onCloseRef.current();
|
|
1012
|
-
if (result.close)
|
|
1013
|
-
close();
|
|
1051
|
+
if (result.liftSpinner) setFrameReady(true);
|
|
1052
|
+
if (result.dismissSilent) onCloseRef.current();
|
|
1053
|
+
if (result.close) close();
|
|
1014
1054
|
},
|
|
1015
1055
|
[translateY, close]
|
|
1016
1056
|
);
|
|
@@ -1020,10 +1060,8 @@ function VisibleFrameSlotSheet({
|
|
|
1020
1060
|
}, [dispatch]);
|
|
1021
1061
|
useEffect2(() => {
|
|
1022
1062
|
const unsubscribe = slot.transport.onMessage((msg) => {
|
|
1023
|
-
if (msg.kind === "ready")
|
|
1024
|
-
|
|
1025
|
-
else if (msg.kind === "complete" || msg.kind === "error")
|
|
1026
|
-
dispatch("terminal");
|
|
1063
|
+
if (msg.kind === "ready") dispatch("ready");
|
|
1064
|
+
else if (msg.kind === "complete" || msg.kind === "error") dispatch("terminal");
|
|
1027
1065
|
});
|
|
1028
1066
|
return unsubscribe;
|
|
1029
1067
|
}, [slot.transport, dispatch]);
|
|
@@ -1246,8 +1284,7 @@ function MoonPayFrameView({
|
|
|
1246
1284
|
}, [mountKey, spec, sessionToken, core, frameBaseUrl]);
|
|
1247
1285
|
useEffect3(() => {
|
|
1248
1286
|
const handle = handleRef.current;
|
|
1249
|
-
if (!handle)
|
|
1250
|
-
return;
|
|
1287
|
+
if (!handle) return;
|
|
1251
1288
|
applyReactiveProps(spec, reactiveKeys, propsRef.current, appliedRef.current, handle);
|
|
1252
1289
|
}, [liveKey]);
|
|
1253
1290
|
if (spec.hidden) {
|
|
@@ -1392,15 +1429,30 @@ function MoonPayConnectionReset({ onEvent }) {
|
|
|
1392
1429
|
return /* @__PURE__ */ jsx13(MoonPayFrameView, { spec: connectionResetSpec, props: {}, defaultStyle: {}, onEvent });
|
|
1393
1430
|
}
|
|
1394
1431
|
|
|
1395
|
-
// src/components/
|
|
1432
|
+
// src/components/customer-export.tsx
|
|
1396
1433
|
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
1434
|
+
function MoonPayCustomerExport({ onEvent, style }) {
|
|
1435
|
+
return /* @__PURE__ */ jsx14(
|
|
1436
|
+
MoonPayFrameView,
|
|
1437
|
+
{
|
|
1438
|
+
spec: customerExportSpec,
|
|
1439
|
+
props: {},
|
|
1440
|
+
style,
|
|
1441
|
+
defaultStyle: { flex: 1 },
|
|
1442
|
+
onEvent
|
|
1443
|
+
}
|
|
1444
|
+
);
|
|
1445
|
+
}
|
|
1446
|
+
|
|
1447
|
+
// src/components/google-pay-button.tsx
|
|
1448
|
+
import { jsx as jsx15 } from "react/jsx-runtime";
|
|
1397
1449
|
function MoonPayGooglePayButton({
|
|
1398
1450
|
quote,
|
|
1399
1451
|
externalTransactionId,
|
|
1400
1452
|
onEvent,
|
|
1401
1453
|
style
|
|
1402
1454
|
}) {
|
|
1403
|
-
return /* @__PURE__ */
|
|
1455
|
+
return /* @__PURE__ */ jsx15(
|
|
1404
1456
|
MoonPayFrameView,
|
|
1405
1457
|
{
|
|
1406
1458
|
spec: googlePaySpec,
|
|
@@ -1413,9 +1465,9 @@ function MoonPayGooglePayButton({
|
|
|
1413
1465
|
}
|
|
1414
1466
|
|
|
1415
1467
|
// src/components/widget.tsx
|
|
1416
|
-
import { jsx as
|
|
1468
|
+
import { jsx as jsx16 } from "react/jsx-runtime";
|
|
1417
1469
|
function MoonPayWidget({ quote, onEvent, style }) {
|
|
1418
|
-
return /* @__PURE__ */
|
|
1470
|
+
return /* @__PURE__ */ jsx16(
|
|
1419
1471
|
MoonPayFrameView,
|
|
1420
1472
|
{
|
|
1421
1473
|
spec: widgetSpec,
|
|
@@ -1437,6 +1489,7 @@ export {
|
|
|
1437
1489
|
MoonPayConnect,
|
|
1438
1490
|
MoonPayConnectionCheck,
|
|
1439
1491
|
MoonPayConnectionReset,
|
|
1492
|
+
MoonPayCustomerExport,
|
|
1440
1493
|
MoonPayFrame,
|
|
1441
1494
|
MoonPayGooglePayButton,
|
|
1442
1495
|
MoonPayProvider,
|