@moonpay/platform-sdk-react-native 0.2.2 → 0.3.0-next.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 +7 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +19 -1
- package/dist/index.d.ts +19 -1
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -699,7 +699,13 @@ function MoonPayProvider({
|
|
|
699
699
|
setupBuyButton,
|
|
700
700
|
setupGooglePay,
|
|
701
701
|
setupChallenge,
|
|
702
|
-
setupAddCard
|
|
702
|
+
setupAddCard,
|
|
703
|
+
createIdentity: (body) => core.createIdentity(body),
|
|
704
|
+
getIdentity: (id) => core.getIdentity(id),
|
|
705
|
+
updateIdentity: (id, body) => core.updateIdentity(id, body),
|
|
706
|
+
verifyIdentity: (id) => core.verifyIdentity(id),
|
|
707
|
+
getIdentityUploadUrl: (id, body) => core.getIdentityUploadUrl(id, body),
|
|
708
|
+
submitIdentityFiles: (id, body) => core.submitIdentityFiles(id, body)
|
|
703
709
|
};
|
|
704
710
|
}, [sessionToken, frameBaseUrl, core, addSlot, removeSlot]);
|
|
705
711
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(MoonPayContext.Provider, { value: { client }, children: [
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/frame-component.tsx","../src/provider.tsx","../src/webview-transport.ts"],"sourcesContent":["// Re-export commonly used protocol types for convenience\nexport type {\n AddCardEvent,\n ApplePayEvent,\n BuyButtonEvent,\n BuyEvent,\n CardResponse,\n ChallengeCancellation,\n ChallengeCompleteResult,\n ChallengeEvent,\n ConnectEvent,\n Connection,\n ConnectionStatus,\n GetQuoteParams,\n GooglePayEvent,\n PaymentMethodConfig,\n Quote,\n Result,\n StoredPaymentMethod,\n Transaction,\n TransactionWithStages,\n WidgetEvent,\n} from '@moonpay/platform-protocol';\n\nexport {\n MoonPayFrame,\n type MoonPayFrameProps,\n} from './frame-component.js';\nexport {\n type AddCardFrame,\n type ApplePayFrame,\n type BuyButtonFrame,\n type BuyFrame,\n type ChallengeFrame,\n type ConnectFrame,\n type ConnectOptions,\n type GooglePayFrame,\n MoonPayProvider,\n type MoonPayProviderProps,\n type RNClient,\n type SetupAddCardOptions,\n type SetupApplePayOptions,\n type SetupBuyButtonOptions,\n type SetupBuyOptions,\n type SetupChallengeOptions,\n type SetupGooglePayOptions,\n type SetupWidgetOptions,\n useMoonPay,\n type WidgetFrame,\n} from './provider.js';\nexport { WebViewTransport } from './webview-transport.js';\n","import { useEffect, useRef } from 'react';\nimport { View, type ViewStyle } from 'react-native';\nimport WebView, { type WebViewMessageEvent } from 'react-native-webview';\nimport type { WebViewTransport } from './webview-transport.js';\n\nexport interface MoonPayFrameProps {\n /** The transport instance managing this frame's communication. */\n transport: WebViewTransport;\n /** Whether this is a hidden utility frame (zero height). */\n hidden?: boolean;\n /** Optional style overrides for the container view. */\n style?: ViewStyle;\n}\n\n/**\n * Reusable React Native component that renders a MoonPay frame as a WebView.\n * Bridges the WebViewTransport to the actual WebView instance.\n */\nexport function MoonPayFrame({ transport, hidden, style }: MoonPayFrameProps): JSX.Element | null {\n const webViewRef = useRef<WebView>(null);\n\n useEffect(() => {\n transport.attachWebView(webViewRef);\n return () => {\n // Don't dispose — the orchestrator manages lifecycle\n };\n }, [transport]);\n\n const url = transport.url;\n if (!url) return null;\n\n const handleMessage = (event: WebViewMessageEvent) => {\n transport.handleWebViewMessage(event.nativeEvent.data);\n };\n\n const containerStyle: ViewStyle = hidden\n ? { width: 0, height: 0, overflow: 'hidden' }\n : { flex: 1, ...style };\n\n return (\n <View style={containerStyle}>\n <WebView\n ref={webViewRef}\n source={{ uri: url }}\n onMessage={handleMessage}\n allowsInlineMediaPlayback\n javaScriptEnabled\n domStorageEnabled\n style={{ flex: 1 }}\n />\n </View>\n );\n}\n","import {\n type AddCardEvent,\n type ApplePayEvent,\n type BuyButtonEvent,\n type BuyEvent,\n type CardResponse,\n type ChallengeCancellation,\n type ChallengeCompleteResult,\n type ChallengeEvent,\n type ConnectError,\n type ConnectEvent,\n type Connection,\n ConnectionStatus,\n err,\n type GetConnectionError,\n type GetPaymentMethodsError,\n type GetQuoteError,\n type GetQuoteParams,\n type GetTransactionsError,\n type GooglePayEvent,\n type GooglePayInboundMessageMap,\n type ListPaymentMethodsResponse,\n ok,\n type PaginationInfo,\n type ProtocolMessage,\n type Quote,\n type Result,\n type SetupAddCardError,\n type SetupApplePayError,\n type SetupBuyButtonError,\n type SetupBuyError,\n type SetupChallengeError,\n type SetupGooglePayError,\n type SetupWidgetError,\n type Transaction,\n type TransactionWithStages,\n type WidgetEvent,\n} from '@moonpay/platform-protocol';\nimport {\n buildFrameUrl,\n type CoreClient,\n createClientCore,\n createFrameOrchestrator,\n decryptCredentials,\n FRAME_PATHS,\n type FrameHandle,\n generateKeyPair,\n type ListTransactionsParams,\n} from '@moonpay/platform-sdk-core';\nimport {\n createContext,\n type ReactNode,\n useCallback,\n useContext,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { MoonPayFrame } from './frame-component.js';\nimport { WebViewTransport } from './webview-transport.js';\n\n// ---------------------------------------------------------------------------\n// Frame slot — represents a frame the provider needs to render\n// ---------------------------------------------------------------------------\n\ninterface FrameSlot {\n id: string;\n transport: WebViewTransport;\n hidden: boolean;\n}\n\n// ---------------------------------------------------------------------------\n// Public types\n// ---------------------------------------------------------------------------\n\nexport interface ConnectOptions {\n /** Theme options for the connect frame. */\n theme?: { appearance?: 'light' | 'dark' };\n /** Callback for connect lifecycle events. */\n onEvent?: (event: ConnectEvent) => void;\n}\n\nexport interface ConnectFrame {\n dispose(): void;\n}\n\nexport interface SetupWidgetOptions {\n /** Quote signature from getQuote(). */\n quote: string;\n /** Callback for widget lifecycle events. */\n onEvent?: (event: WidgetEvent) => void;\n}\n\nexport interface WidgetFrame {\n dispose(): void;\n}\n\nexport interface SetupApplePayOptions {\n /** Quote signature from getQuote(). */\n quote: string;\n /** Callback for Apple Pay lifecycle events. */\n onEvent?: (event: ApplePayEvent) => void;\n}\n\nexport interface ApplePayFrame {\n /** Update the quote (e.g., after expiry). */\n setQuote(signature: string): void;\n dispose(): void;\n}\n\nexport interface SetupBuyOptions {\n /** Quote signature from getQuote(). */\n quote: string;\n /** Partner-assigned identifier for this transaction attempt. */\n externalTransactionId?: string;\n /** Callback for buy frame lifecycle events. */\n onEvent?: (event: BuyEvent) => void;\n}\n\nexport interface BuyFrame {\n /** Update the quote (e.g., after expiry). */\n setQuote(signature: string): void;\n dispose(): void;\n}\n\nexport interface SetupBuyButtonOptions {\n /** Quote signature from getQuote(). */\n quote: string;\n /** Callback for buy-button frame lifecycle events. */\n onEvent?: (event: BuyButtonEvent) => void;\n}\n\nexport interface BuyButtonFrame {\n /** Update the quote (e.g., after expiry). */\n setQuote(signature: string): void;\n dispose(): void;\n}\n\nexport interface SetupGooglePayOptions {\n /** Quote signature from getQuote(). */\n quote: string;\n /** Partner-assigned identifier for this transaction attempt. */\n externalTransactionId?: string;\n /** Callback for Google Pay lifecycle events. */\n onEvent?: (event: GooglePayEvent) => void;\n}\n\nexport interface GooglePayFrame {\n /** Update the quote (e.g., after expiry). */\n setQuote(signature: string): void;\n dispose(): void;\n}\n\nexport interface SetupChallengeOptions {\n /** Full challenge URL received from a frame's `challenge` event. */\n url: string;\n /** Callback for challenge frame lifecycle events. */\n onEvent?: (event: ChallengeEvent) => void;\n}\n\nexport interface ChallengeFrame {\n dispose(): void;\n}\n\nexport interface SetupAddCardOptions {\n /** Callback for add-card frame lifecycle events. */\n onEvent?: (event: AddCardEvent) => void;\n}\n\nexport interface AddCardFrame {\n dispose(): void;\n}\n\nexport interface RNClient {\n getConnection(): Promise<Result<Connection, GetConnectionError>>;\n connect(options: ConnectOptions): Promise<Result<ConnectFrame, ConnectError>>;\n getPaymentMethods(): Promise<Result<ListPaymentMethodsResponse, GetPaymentMethodsError>>;\n getQuote(params: GetQuoteParams): Promise<Result<{ data: Quote }, GetQuoteError>>;\n listTransactions(\n params?: ListTransactionsParams,\n ): Promise<Result<{ data: Transaction[]; pageInfo: PaginationInfo }, GetTransactionsError>>;\n getTransaction(\n id: string,\n ): Promise<Result<{ data: TransactionWithStages }, GetTransactionsError>>;\n setupWidget(options: SetupWidgetOptions): Promise<Result<WidgetFrame, SetupWidgetError>>;\n setupApplePay(options: SetupApplePayOptions): Promise<Result<ApplePayFrame, SetupApplePayError>>;\n setupBuy(options: SetupBuyOptions): Promise<Result<BuyFrame, SetupBuyError>>;\n setupBuyButton(\n options: SetupBuyButtonOptions,\n ): Promise<Result<BuyButtonFrame, SetupBuyButtonError>>;\n setupGooglePay(\n options: SetupGooglePayOptions,\n ): Promise<Result<GooglePayFrame, SetupGooglePayError>>;\n setupChallenge(\n options: SetupChallengeOptions,\n ): Promise<Result<ChallengeFrame, SetupChallengeError>>;\n setupAddCard(options: SetupAddCardOptions): Promise<Result<AddCardFrame, SetupAddCardError>>;\n}\n\n// ---------------------------------------------------------------------------\n// Context\n// ---------------------------------------------------------------------------\n\ninterface MoonPayContextValue {\n client: RNClient;\n}\n\nconst MoonPayContext = createContext<MoonPayContextValue | null>(null);\n\n// ---------------------------------------------------------------------------\n// Provider\n// ---------------------------------------------------------------------------\n\nexport interface MoonPayProviderProps {\n sessionToken: string;\n apiBaseUrl?: string;\n frameBaseUrl?: string;\n children: ReactNode;\n}\n\nlet slotCounter = 0;\n\nexport function MoonPayProvider({\n sessionToken,\n apiBaseUrl,\n frameBaseUrl,\n children,\n}: MoonPayProviderProps): JSX.Element {\n const [frameSlots, setFrameSlots] = useState<FrameSlot[]>([]);\n\n // Stable refs for addSlot/removeSlot so client methods don't re-create\n const addSlot = useCallback((slot: FrameSlot) => {\n setFrameSlots((prev) => [...prev, slot]);\n }, []);\n\n const removeSlot = useCallback((id: string) => {\n setFrameSlots((prev) => prev.filter((s) => s.id !== id));\n }, []);\n\n // Keep a ref to core so it's stable across renders\n const coreRef = useRef<CoreClient | null>(null);\n if (!coreRef.current) {\n coreRef.current = createClientCore({\n apiBaseUrl,\n frameBaseUrl,\n createTransport: () => new WebViewTransport(),\n });\n }\n const core = coreRef.current;\n\n const client = useMemo<RNClient>(() => {\n // Helper: create a transport + slot, wait for orchestrator handshake\n function createManagedFrame(opts: {\n url: string;\n channelId: string;\n hidden: boolean;\n handshakeTimeout?: number;\n }): { promise: Promise<{ handle: FrameHandle; slotId: string }>; transport: WebViewTransport } {\n const transport = new WebViewTransport();\n const slotId = `slot-${++slotCounter}`;\n\n const promise = new Promise<{ handle: FrameHandle; slotId: string }>((resolve, reject) => {\n // Defer adding the slot to allow the transport to be fully set up\n // before the WebView renders\n transport.create(opts.url, { container: null, hidden: opts.hidden });\n\n addSlot({ id: slotId, transport, hidden: opts.hidden });\n\n createFrameOrchestrator({\n transport,\n channelId: opts.channelId,\n url: opts.url,\n container: null,\n hidden: opts.hidden,\n handshakeTimeout: opts.handshakeTimeout ?? 15_000,\n })\n .then((handle) => resolve({ handle, slotId }))\n .catch((e) => {\n removeSlot(slotId);\n reject(e);\n });\n });\n\n return { promise, transport };\n }\n\n // ------- getConnection (hidden frame) -------\n async function getConnection(): Promise<Result<Connection, GetConnectionError>> {\n const { privateKey, publicKey } = generateKeyPair();\n const channelId = `check-${Date.now()}`;\n\n const url = buildFrameUrl(\n FRAME_PATHS.checkConnection,\n { sessionToken, channelId, publicKey },\n { frameBaseUrl },\n );\n\n try {\n const { promise } = createManagedFrame({\n url,\n channelId,\n hidden: true,\n handshakeTimeout: 10_000,\n });\n\n const { handle, slotId } = await promise;\n\n return new Promise<Result<Connection, GetConnectionError>>((resolve) => {\n const timeout = setTimeout(() => {\n handle.dispose();\n removeSlot(slotId);\n resolve(err({ message: 'Get connection timed out' }));\n }, 10_000);\n\n handle.onMessage((msg: ProtocolMessage) => {\n if (msg.kind === 'error') {\n clearTimeout(timeout);\n handle.dispose();\n removeSlot(slotId);\n const payload = msg.payload as { message: string };\n resolve(err({ message: payload.message }));\n return;\n }\n\n if (msg.kind === 'complete') {\n clearTimeout(timeout);\n handle.dispose();\n removeSlot(slotId);\n const connection = msg.payload as Connection;\n\n if (connection.status === ConnectionStatus.active) {\n const creds = decryptCredentials(connection.credentials, privateKey);\n core.context.setAccessToken(creds.accessToken);\n core.context.setClientToken(creds.clientToken);\n }\n\n resolve(ok(connection));\n }\n });\n });\n } catch (e) {\n return err({\n message: e instanceof Error ? e.message : 'Failed to check connection',\n });\n }\n }\n\n // ------- connect (visible frame) -------\n async function connect(opts: ConnectOptions): Promise<Result<ConnectFrame, ConnectError>> {\n const { privateKey, publicKey } = generateKeyPair();\n const channelId = `connect-${Date.now()}`;\n\n const url = buildFrameUrl(\n FRAME_PATHS.connect,\n {\n sessionToken,\n channelId,\n publicKey,\n ...(opts.theme?.appearance && { appearance: opts.theme.appearance }),\n },\n { frameBaseUrl },\n );\n\n try {\n const { promise } = createManagedFrame({ url, channelId, hidden: false });\n const { handle, slotId } = await promise;\n\n return new Promise<Result<ConnectFrame, ConnectError>>((resolve) => {\n handle.onMessage((msg: ProtocolMessage) => {\n if (msg.kind === 'ready') {\n opts.onEvent?.({ kind: 'ready' });\n return;\n }\n\n if (msg.kind === 'error') {\n const payload = msg.payload as import('@moonpay/platform-protocol').ConnectionError;\n opts.onEvent?.({ kind: 'error', payload });\n handle.dispose();\n removeSlot(slotId);\n resolve(err({ message: 'Connection error' }));\n return;\n }\n\n if (msg.kind === 'complete') {\n const connection = msg.payload as Connection;\n\n if (connection.status === ConnectionStatus.active) {\n const creds = decryptCredentials(connection.credentials, privateKey);\n core.context.setAccessToken(creds.accessToken);\n core.context.setClientToken(creds.clientToken);\n }\n\n opts.onEvent?.({ kind: 'complete', payload: connection });\n resolve(\n ok({\n dispose: () => {\n handle.dispose();\n removeSlot(slotId);\n },\n }),\n );\n }\n });\n });\n } catch (e) {\n return err({\n message: e instanceof Error ? e.message : 'Connect failed',\n });\n }\n }\n\n // ------- setupWidget -------\n async function setupWidget(\n opts: SetupWidgetOptions,\n ): Promise<Result<WidgetFrame, SetupWidgetError>> {\n const channelId = `widget-${Date.now()}`;\n\n const url = buildFrameUrl(\n FRAME_PATHS.widget,\n {\n flow: 'buy',\n clientToken: core.context.clientToken,\n quoteSignature: opts.quote,\n channelId,\n },\n { frameBaseUrl },\n );\n\n try {\n const { promise } = createManagedFrame({ url, channelId, hidden: false });\n const { handle, slotId } = await promise;\n\n handle.onMessage((msg: ProtocolMessage) => {\n switch (msg.kind) {\n case 'ready':\n opts.onEvent?.({ kind: 'ready' });\n break;\n case 'transactionCreated':\n opts.onEvent?.({\n kind: 'transactionCreated',\n payload: msg.payload as { transaction: { id: string; status: string } },\n });\n break;\n case 'complete':\n opts.onEvent?.({\n kind: 'complete',\n payload: msg.payload as {\n transaction: import('@moonpay/platform-protocol').FrameTransaction;\n },\n });\n break;\n case 'error': {\n const payload = msg.payload as {\n code: 'configurationError' | 'apiError' | 'generic';\n message: string;\n };\n opts.onEvent?.({\n kind: 'error',\n payload: { code: payload.code, message: payload.message },\n });\n break;\n }\n case 'close':\n opts.onEvent?.({ kind: 'close' });\n break;\n }\n });\n\n return ok({\n dispose: () => {\n handle.dispose();\n removeSlot(slotId);\n },\n });\n } catch (e) {\n return err({\n kind: 'genericError',\n message: e instanceof Error ? e.message : 'Widget setup failed',\n });\n }\n }\n\n // ------- setupApplePay -------\n async function setupApplePay(\n opts: SetupApplePayOptions,\n ): Promise<Result<ApplePayFrame, SetupApplePayError>> {\n const channelId = `applepay-${Date.now()}`;\n\n const url = buildFrameUrl(\n FRAME_PATHS.applePay,\n {\n clientToken: core.context.clientToken,\n signature: opts.quote,\n channelId,\n },\n { frameBaseUrl },\n );\n\n try {\n const { promise } = createManagedFrame({ url, channelId, hidden: false });\n const { handle, slotId } = await promise;\n\n const setQuote = (signature: string) => {\n handle.sendMessage({\n version: 2,\n meta: { channelId },\n kind: 'setQuote',\n payload: { quote: { signature } },\n });\n };\n\n handle.onMessage((msg: ProtocolMessage) => {\n switch (msg.kind) {\n case 'ready':\n opts.onEvent?.({ kind: 'ready' });\n break;\n case 'complete':\n opts.onEvent?.({\n kind: 'complete',\n payload: msg.payload as {\n transaction: import('@moonpay/platform-protocol').FrameTransaction;\n },\n });\n break;\n case 'error': {\n const payload = msg.payload as { code: string; message: string };\n if (payload.code === 'quoteExpired') {\n opts.onEvent?.({ kind: 'quoteExpired', payload: { setQuote } });\n } else if (payload.code === 'applePayUnavailable') {\n opts.onEvent?.({ kind: 'unsupported' });\n } else {\n const kind =\n payload.code === 'generic'\n ? 'genericError'\n : (payload.code as\n | 'configurationError'\n | 'invalidQuote'\n | 'oneTapApplePaySecondFactorRequired'\n | 'genericError');\n opts.onEvent?.({\n kind: 'error',\n payload: { kind, message: payload.message },\n });\n }\n break;\n }\n }\n });\n\n return ok({\n setQuote,\n dispose: () => {\n handle.dispose();\n removeSlot(slotId);\n },\n });\n } catch (e) {\n return err({\n kind: 'genericError',\n message: e instanceof Error ? e.message : 'Apple Pay setup failed',\n });\n }\n }\n\n // ------- setupBuy (hidden frame) -------\n async function setupBuy(opts: SetupBuyOptions): Promise<Result<BuyFrame, SetupBuyError>> {\n const channelId = `buy-${Date.now()}`;\n\n const url = buildFrameUrl(\n FRAME_PATHS.buy,\n {\n channelId,\n clientToken: core.context.clientToken,\n signature: opts.quote,\n ...(opts.externalTransactionId && { externalTransactionId: opts.externalTransactionId }),\n },\n { frameBaseUrl },\n );\n\n try {\n const { promise } = createManagedFrame({ url, channelId, hidden: true });\n const { handle, slotId } = await promise;\n\n const setQuote = (signature: string) => {\n handle.sendMessage({\n version: 2,\n meta: { channelId },\n kind: 'setQuote',\n payload: { quote: { signature } },\n });\n };\n\n handle.onMessage((msg: ProtocolMessage) => {\n switch (msg.kind) {\n case 'ready':\n opts.onEvent?.({ kind: 'ready' });\n break;\n case 'complete':\n opts.onEvent?.({\n kind: 'complete',\n payload: msg.payload as {\n transaction: import('@moonpay/platform-protocol').FrameTransaction;\n },\n });\n break;\n case 'challenge':\n opts.onEvent?.({\n kind: 'challenge',\n payload: msg.payload as { kind: string; url: string },\n });\n break;\n case 'error':\n opts.onEvent?.({\n kind: 'error',\n payload: msg.payload as { code: string; message: string },\n });\n break;\n }\n });\n\n return ok({\n setQuote,\n dispose: () => {\n handle.dispose();\n removeSlot(slotId);\n },\n });\n } catch (e) {\n return err({\n kind: 'genericError',\n message: e instanceof Error ? e.message : 'Buy setup failed',\n });\n }\n }\n\n // ------- setupBuyButton -------\n async function setupBuyButton(\n opts: SetupBuyButtonOptions,\n ): Promise<Result<BuyButtonFrame, SetupBuyButtonError>> {\n const channelId = `buy-button-${Date.now()}`;\n\n const url = buildFrameUrl(\n FRAME_PATHS.buyButton,\n {\n channelId,\n clientToken: core.context.clientToken,\n signature: opts.quote,\n },\n { frameBaseUrl },\n );\n\n try {\n const { promise } = createManagedFrame({ url, channelId, hidden: false });\n const { handle, slotId } = await promise;\n\n const setQuote = (signature: string) => {\n handle.sendMessage({\n version: 2,\n meta: { channelId },\n kind: 'setQuote',\n payload: { quote: { signature } },\n });\n };\n\n handle.onMessage((msg: ProtocolMessage) => {\n switch (msg.kind) {\n case 'complete':\n opts.onEvent?.({\n kind: 'complete',\n payload: msg.payload as {\n transaction: import('@moonpay/platform-protocol').FrameTransaction;\n },\n });\n break;\n case 'challenge':\n opts.onEvent?.({\n kind: 'challenge',\n payload: msg.payload as { kind: string; url: string },\n });\n break;\n case 'error':\n opts.onEvent?.({\n kind: 'error',\n payload: msg.payload as { code: string; message: string },\n });\n break;\n }\n });\n\n return ok({\n setQuote,\n dispose: () => {\n handle.dispose();\n removeSlot(slotId);\n },\n });\n } catch (e) {\n return err({\n kind: 'genericError',\n message: e instanceof Error ? e.message : 'Buy button setup failed',\n });\n }\n }\n\n // ------- setupGooglePay -------\n async function setupGooglePay(\n opts: SetupGooglePayOptions,\n ): Promise<Result<GooglePayFrame, SetupGooglePayError>> {\n const channelId = `googlepay-${Date.now()}`;\n\n const url = buildFrameUrl(\n FRAME_PATHS.googlePay,\n {\n clientToken: core.context.clientToken,\n signature: opts.quote,\n channelId,\n ...(opts.externalTransactionId && { externalTransactionId: opts.externalTransactionId }),\n },\n { frameBaseUrl },\n );\n\n try {\n const { promise } = createManagedFrame({ url, channelId, hidden: false });\n const { handle, slotId } = await promise;\n\n const setQuote = (signature: string) => {\n handle.sendMessage({\n version: 2,\n meta: { channelId },\n kind: 'setQuote',\n payload: { quote: { signature } },\n });\n };\n\n handle.onMessage((msg: ProtocolMessage) => {\n switch (msg.kind) {\n case 'ready':\n opts.onEvent?.({ kind: 'ready' });\n break;\n case 'complete':\n opts.onEvent?.({\n kind: 'complete',\n payload: msg.payload as {\n transaction: import('@moonpay/platform-protocol').FrameTransaction;\n },\n });\n break;\n case 'challenge':\n opts.onEvent?.({\n kind: 'challenge',\n payload: msg.payload as GooglePayInboundMessageMap['challenge'],\n });\n break;\n case 'error': {\n const payload = msg.payload as { code: string; message: string };\n if (payload.code === 'quoteExpired') {\n opts.onEvent?.({ kind: 'quoteExpired', payload: { setQuote } });\n } else if (payload.code === 'googlePayUnavailable') {\n opts.onEvent?.({ kind: 'unsupported' });\n } else {\n const kind =\n payload.code === 'generic'\n ? 'genericError'\n : (payload.code as 'configurationError' | 'invalidQuote' | 'genericError');\n opts.onEvent?.({\n kind: 'error',\n payload: { kind, message: payload.message },\n });\n }\n break;\n }\n }\n });\n\n return ok({\n setQuote,\n dispose: () => {\n handle.dispose();\n removeSlot(slotId);\n },\n });\n } catch (e) {\n return err({\n kind: 'genericError',\n message: e instanceof Error ? e.message : 'Google Pay setup failed',\n });\n }\n }\n\n // ------- setupChallenge -------\n async function setupChallenge(\n opts: SetupChallengeOptions,\n ): Promise<Result<ChallengeFrame, SetupChallengeError>> {\n let channelId: string;\n try {\n channelId = new URL(opts.url).searchParams.get('channelId') ?? '';\n if (!channelId) throw new Error('missing channelId');\n } catch {\n return err({ kind: 'configurationError', message: 'Challenge URL is missing channelId' });\n }\n\n try {\n const { promise } = createManagedFrame({ url: opts.url, channelId, hidden: false });\n const { handle, slotId } = await promise;\n\n handle.onMessage((msg: ProtocolMessage) => {\n switch (msg.kind) {\n case 'ready':\n opts.onEvent?.({ kind: 'ready' });\n break;\n case 'complete':\n opts.onEvent?.({\n kind: 'complete',\n payload: msg.payload as ChallengeCompleteResult,\n });\n break;\n case 'cancelled':\n opts.onEvent?.({\n kind: 'cancelled',\n payload: msg.payload as ChallengeCancellation,\n });\n break;\n case 'error':\n opts.onEvent?.({\n kind: 'error',\n payload: msg.payload as { code: string; message: string },\n });\n break;\n }\n });\n\n return ok({\n dispose: () => {\n handle.dispose();\n removeSlot(slotId);\n },\n });\n } catch (e) {\n return err({\n kind: 'genericError',\n message: e instanceof Error ? e.message : 'Challenge setup failed',\n });\n }\n }\n\n // ------- setupAddCard -------\n async function setupAddCard(\n opts: SetupAddCardOptions,\n ): Promise<Result<AddCardFrame, SetupAddCardError>> {\n const channelId = `add-card-${Date.now()}`;\n\n const url = buildFrameUrl(\n FRAME_PATHS.addCard,\n { channelId, clientToken: core.context.clientToken },\n { frameBaseUrl },\n );\n\n try {\n const { promise } = createManagedFrame({ url, channelId, hidden: false });\n const { handle, slotId } = await promise;\n\n handle.onMessage((msg: ProtocolMessage) => {\n switch (msg.kind) {\n case 'complete':\n opts.onEvent?.({ kind: 'complete', payload: msg.payload as { card: CardResponse } });\n break;\n case 'error':\n opts.onEvent?.({\n kind: 'error',\n payload: msg.payload as {\n code: 'generic' | 'configurationError';\n message: string;\n },\n });\n break;\n }\n });\n\n return ok({\n dispose: () => {\n handle.dispose();\n removeSlot(slotId);\n },\n });\n } catch (e) {\n return err({\n kind: 'genericError',\n message: e instanceof Error ? e.message : 'Add card setup failed',\n });\n }\n }\n\n return {\n getConnection,\n connect,\n getPaymentMethods: () => core.getPaymentMethods(),\n getQuote: (params) => core.getQuote(params),\n listTransactions: (params) => core.listTransactions(params),\n getTransaction: (id) => core.getTransaction(id),\n setupWidget,\n setupApplePay,\n setupBuy,\n setupBuyButton,\n setupGooglePay,\n setupChallenge,\n setupAddCard,\n };\n }, [sessionToken, frameBaseUrl, core, addSlot, removeSlot]);\n\n return (\n <MoonPayContext.Provider value={{ client }}>\n {children}\n {frameSlots.map((slot) => (\n <MoonPayFrame key={slot.id} transport={slot.transport} hidden={slot.hidden} />\n ))}\n </MoonPayContext.Provider>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Hook\n// ---------------------------------------------------------------------------\n\nexport function useMoonPay(): MoonPayContextValue {\n const ctx = useContext(MoonPayContext);\n if (!ctx) {\n throw new Error('useMoonPay must be used within a <MoonPayProvider>');\n }\n return ctx;\n}\n","import type { ProtocolMessage } from '@moonpay/platform-protocol';\nimport type { FrameOptions, FrameTransport } from '@moonpay/platform-sdk-core';\nimport type { RefObject } from 'react';\nimport type WebView from 'react-native-webview';\n\n/**\n * FrameTransport implementation for React Native using react-native-webview.\n *\n * Unlike the web IframeTransport, the WebView is rendered declaratively via\n * React components. This transport bridges the imperative FrameTransport\n * interface to a WebView ref.\n */\nexport class WebViewTransport implements FrameTransport {\n private webViewRef: RefObject<WebView | null> | null = null;\n private handlers: Array<(msg: ProtocolMessage) => void> = [];\n private _url: string = '';\n private _options: FrameOptions | null = null;\n\n /** Called by the frame component when it mounts the WebView. */\n attachWebView(ref: RefObject<WebView | null>): void {\n this.webViewRef = ref;\n }\n\n /** Called by the WebView's onMessage prop to route incoming messages. */\n handleWebViewMessage(data: string): void {\n try {\n const msg: ProtocolMessage = JSON.parse(data);\n if (!msg.kind) return;\n for (const handler of this.handlers) {\n handler(msg);\n }\n } catch {\n // Ignore non-protocol messages\n }\n }\n\n get url(): string {\n return this._url;\n }\n\n get options(): FrameOptions | null {\n return this._options;\n }\n\n // FrameTransport interface\n\n create(url: string, options: FrameOptions): void {\n this._url = url;\n this._options = options;\n // The actual WebView rendering is handled by React components.\n // This method stores the URL and options for the component to read.\n }\n\n sendMessage(message: ProtocolMessage): void {\n if (!this.webViewRef?.current) {\n throw new Error('Cannot send message: WebView not attached');\n }\n const js = `\n window.postMessage(${JSON.stringify(JSON.stringify(message))}, '*');\n true;\n `;\n this.webViewRef.current.injectJavaScript(js);\n }\n\n onMessage(handler: (msg: ProtocolMessage) => void): () => void {\n this.handlers.push(handler);\n return () => {\n const idx = this.handlers.indexOf(handler);\n if (idx >= 0) this.handlers.splice(idx, 1);\n };\n }\n\n dispose(): void {\n this.handlers.length = 0;\n this.webViewRef = null;\n this._url = '';\n this._options = null;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAAkC;AAClC,0BAAqC;AACrC,kCAAkD;AAuC5C;AAvBC,SAAS,aAAa,EAAE,WAAW,QAAQ,MAAM,GAA0C;AAChG,QAAM,iBAAa,qBAAgB,IAAI;AAEvC,8BAAU,MAAM;AACd,cAAU,cAAc,UAAU;AAClC,WAAO,MAAM;AAAA,IAEb;AAAA,EACF,GAAG,CAAC,SAAS,CAAC;AAEd,QAAM,MAAM,UAAU;AACtB,MAAI,CAAC;AAAK,WAAO;AAEjB,QAAM,gBAAgB,CAAC,UAA+B;AACpD,cAAU,qBAAqB,MAAM,YAAY,IAAI;AAAA,EACvD;AAEA,QAAM,iBAA4B,SAC9B,EAAE,OAAO,GAAG,QAAQ,GAAG,UAAU,SAAS,IAC1C,EAAE,MAAM,GAAG,GAAG,MAAM;AAExB,SACE,4CAAC,4BAAK,OAAO,gBACX;AAAA,IAAC,4BAAAA;AAAA,IAAA;AAAA,MACC,KAAK;AAAA,MACL,QAAQ,EAAE,KAAK,IAAI;AAAA,MACnB,WAAW;AAAA,MACX,2BAAyB;AAAA,MACzB,mBAAiB;AAAA,MACjB,mBAAiB;AAAA,MACjB,OAAO,EAAE,MAAM,EAAE;AAAA;AAAA,EACnB,GACF;AAEJ;;;ACpDA,+BAqCO;AACP,+BAUO;AACP,IAAAC,gBAQO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DAAoD;AAAA,EACtE;AACA,SAAO;AACT;","names":["WebView","import_react","import_jsx_runtime"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/frame-component.tsx","../src/provider.tsx","../src/webview-transport.ts"],"sourcesContent":["// Re-export commonly used protocol types for convenience\nexport type {\n AddCardEvent,\n ApplePayEvent,\n BuyButtonEvent,\n BuyEvent,\n CardResponse,\n ChallengeCancellation,\n ChallengeCompleteResult,\n ChallengeEvent,\n ConnectEvent,\n Connection,\n ConnectionStatus,\n GetQuoteParams,\n GooglePayEvent,\n PaymentMethodConfig,\n Quote,\n Result,\n StoredPaymentMethod,\n Transaction,\n TransactionWithStages,\n WidgetEvent,\n} from '@moonpay/platform-protocol';\n\nexport {\n MoonPayFrame,\n type MoonPayFrameProps,\n} from './frame-component.js';\nexport {\n type AddCardFrame,\n type ApplePayFrame,\n type BuyButtonFrame,\n type BuyFrame,\n type ChallengeFrame,\n type ConnectFrame,\n type ConnectOptions,\n type GooglePayFrame,\n MoonPayProvider,\n type MoonPayProviderProps,\n type RNClient,\n type SetupAddCardOptions,\n type SetupApplePayOptions,\n type SetupBuyButtonOptions,\n type SetupBuyOptions,\n type SetupChallengeOptions,\n type SetupGooglePayOptions,\n type SetupWidgetOptions,\n useMoonPay,\n type WidgetFrame,\n} from './provider.js';\nexport { WebViewTransport } from './webview-transport.js';\n","import { useEffect, useRef } from 'react';\nimport { View, type ViewStyle } from 'react-native';\nimport WebView, { type WebViewMessageEvent } from 'react-native-webview';\nimport type { WebViewTransport } from './webview-transport.js';\n\nexport interface MoonPayFrameProps {\n /** The transport instance managing this frame's communication. */\n transport: WebViewTransport;\n /** Whether this is a hidden utility frame (zero height). */\n hidden?: boolean;\n /** Optional style overrides for the container view. */\n style?: ViewStyle;\n}\n\n/**\n * Reusable React Native component that renders a MoonPay frame as a WebView.\n * Bridges the WebViewTransport to the actual WebView instance.\n */\nexport function MoonPayFrame({ transport, hidden, style }: MoonPayFrameProps): JSX.Element | null {\n const webViewRef = useRef<WebView>(null);\n\n useEffect(() => {\n transport.attachWebView(webViewRef);\n return () => {\n // Don't dispose — the orchestrator manages lifecycle\n };\n }, [transport]);\n\n const url = transport.url;\n if (!url) return null;\n\n const handleMessage = (event: WebViewMessageEvent) => {\n transport.handleWebViewMessage(event.nativeEvent.data);\n };\n\n const containerStyle: ViewStyle = hidden\n ? { width: 0, height: 0, overflow: 'hidden' }\n : { flex: 1, ...style };\n\n return (\n <View style={containerStyle}>\n <WebView\n ref={webViewRef}\n source={{ uri: url }}\n onMessage={handleMessage}\n allowsInlineMediaPlayback\n javaScriptEnabled\n domStorageEnabled\n style={{ flex: 1 }}\n />\n </View>\n );\n}\n","import {\n type AddCardEvent,\n type ApplePayEvent,\n type BuyButtonEvent,\n type BuyEvent,\n type CardResponse,\n type ChallengeCancellation,\n type ChallengeCompleteResult,\n type ChallengeEvent,\n type ConnectError,\n type ConnectEvent,\n type Connection,\n ConnectionStatus,\n type CreateIdentityError,\n type CreateIdentityRequestBody,\n err,\n type GetConnectionError,\n type GetIdentityError,\n type GetIdentityUploadUrlError,\n type GetPaymentMethodsError,\n type GetQuoteError,\n type GetQuoteParams,\n type GetTransactionsError,\n type GooglePayEvent,\n type GooglePayInboundMessageMap,\n type Identity,\n type IdentityFileUploadUrl,\n type IdentityFileUploadUrlRequestBody,\n type IdentityVerificationResponse,\n type ListPaymentMethodsResponse,\n ok,\n type PaginationInfo,\n type ProtocolMessage,\n type Quote,\n type Result,\n type SetupAddCardError,\n type SetupApplePayError,\n type SetupBuyButtonError,\n type SetupBuyError,\n type SetupChallengeError,\n type SetupGooglePayError,\n type SetupWidgetError,\n type SubmitIdentityFilesError,\n type SubmitIdentityFilesRequestBody,\n type Transaction,\n type TransactionWithStages,\n type UpdateIdentityError,\n type UpdateIdentityRequestBody,\n type VerifyIdentityError,\n type WidgetEvent,\n} from '@moonpay/platform-protocol';\nimport {\n buildFrameUrl,\n type CoreClient,\n createClientCore,\n createFrameOrchestrator,\n decryptCredentials,\n FRAME_PATHS,\n type FrameHandle,\n generateKeyPair,\n type ListTransactionsParams,\n} from '@moonpay/platform-sdk-core';\nimport {\n createContext,\n type ReactNode,\n useCallback,\n useContext,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { MoonPayFrame } from './frame-component.js';\nimport { WebViewTransport } from './webview-transport.js';\n\n// ---------------------------------------------------------------------------\n// Frame slot — represents a frame the provider needs to render\n// ---------------------------------------------------------------------------\n\ninterface FrameSlot {\n id: string;\n transport: WebViewTransport;\n hidden: boolean;\n}\n\n// ---------------------------------------------------------------------------\n// Public types\n// ---------------------------------------------------------------------------\n\nexport interface ConnectOptions {\n /** Theme options for the connect frame. */\n theme?: { appearance?: 'light' | 'dark' };\n /** Callback for connect lifecycle events. */\n onEvent?: (event: ConnectEvent) => void;\n}\n\nexport interface ConnectFrame {\n dispose(): void;\n}\n\nexport interface SetupWidgetOptions {\n /** Quote signature from getQuote(). */\n quote: string;\n /** Callback for widget lifecycle events. */\n onEvent?: (event: WidgetEvent) => void;\n}\n\nexport interface WidgetFrame {\n dispose(): void;\n}\n\nexport interface SetupApplePayOptions {\n /** Quote signature from getQuote(). */\n quote: string;\n /** Callback for Apple Pay lifecycle events. */\n onEvent?: (event: ApplePayEvent) => void;\n}\n\nexport interface ApplePayFrame {\n /** Update the quote (e.g., after expiry). */\n setQuote(signature: string): void;\n dispose(): void;\n}\n\nexport interface SetupBuyOptions {\n /** Quote signature from getQuote(). */\n quote: string;\n /** Partner-assigned identifier for this transaction attempt. */\n externalTransactionId?: string;\n /** Callback for buy frame lifecycle events. */\n onEvent?: (event: BuyEvent) => void;\n}\n\nexport interface BuyFrame {\n /** Update the quote (e.g., after expiry). */\n setQuote(signature: string): void;\n dispose(): void;\n}\n\nexport interface SetupBuyButtonOptions {\n /** Quote signature from getQuote(). */\n quote: string;\n /** Callback for buy-button frame lifecycle events. */\n onEvent?: (event: BuyButtonEvent) => void;\n}\n\nexport interface BuyButtonFrame {\n /** Update the quote (e.g., after expiry). */\n setQuote(signature: string): void;\n dispose(): void;\n}\n\nexport interface SetupGooglePayOptions {\n /** Quote signature from getQuote(). */\n quote: string;\n /** Partner-assigned identifier for this transaction attempt. */\n externalTransactionId?: string;\n /** Callback for Google Pay lifecycle events. */\n onEvent?: (event: GooglePayEvent) => void;\n}\n\nexport interface GooglePayFrame {\n /** Update the quote (e.g., after expiry). */\n setQuote(signature: string): void;\n dispose(): void;\n}\n\nexport interface SetupChallengeOptions {\n /** Full challenge URL received from a frame's `challenge` event. */\n url: string;\n /** Callback for challenge frame lifecycle events. */\n onEvent?: (event: ChallengeEvent) => void;\n}\n\nexport interface ChallengeFrame {\n dispose(): void;\n}\n\nexport interface SetupAddCardOptions {\n /** Callback for add-card frame lifecycle events. */\n onEvent?: (event: AddCardEvent) => void;\n}\n\nexport interface AddCardFrame {\n dispose(): void;\n}\n\nexport interface RNClient {\n getConnection(): Promise<Result<Connection, GetConnectionError>>;\n connect(options: ConnectOptions): Promise<Result<ConnectFrame, ConnectError>>;\n getPaymentMethods(): Promise<Result<ListPaymentMethodsResponse, GetPaymentMethodsError>>;\n getQuote(params: GetQuoteParams): Promise<Result<{ data: Quote }, GetQuoteError>>;\n listTransactions(\n params?: ListTransactionsParams,\n ): Promise<Result<{ data: Transaction[]; pageInfo: PaginationInfo }, GetTransactionsError>>;\n getTransaction(\n id: string,\n ): Promise<Result<{ data: TransactionWithStages }, GetTransactionsError>>;\n setupWidget(options: SetupWidgetOptions): Promise<Result<WidgetFrame, SetupWidgetError>>;\n setupApplePay(options: SetupApplePayOptions): Promise<Result<ApplePayFrame, SetupApplePayError>>;\n setupBuy(options: SetupBuyOptions): Promise<Result<BuyFrame, SetupBuyError>>;\n setupBuyButton(\n options: SetupBuyButtonOptions,\n ): Promise<Result<BuyButtonFrame, SetupBuyButtonError>>;\n setupGooglePay(\n options: SetupGooglePayOptions,\n ): Promise<Result<GooglePayFrame, SetupGooglePayError>>;\n setupChallenge(\n options: SetupChallengeOptions,\n ): Promise<Result<ChallengeFrame, SetupChallengeError>>;\n setupAddCard(options: SetupAddCardOptions): Promise<Result<AddCardFrame, SetupAddCardError>>;\n\n // Identity API\n createIdentity(\n body: CreateIdentityRequestBody,\n ): Promise<Result<{ data: Identity | null }, CreateIdentityError>>;\n getIdentity(id: string): Promise<Result<{ data: Identity }, GetIdentityError>>;\n updateIdentity(\n id: string,\n body: UpdateIdentityRequestBody,\n ): Promise<Result<{ data: Identity }, UpdateIdentityError>>;\n verifyIdentity(\n id: string,\n ): Promise<Result<{ data: IdentityVerificationResponse }, VerifyIdentityError>>;\n getIdentityUploadUrl(\n id: string,\n body: IdentityFileUploadUrlRequestBody,\n ): Promise<Result<{ data: IdentityFileUploadUrl }, GetIdentityUploadUrlError>>;\n submitIdentityFiles(\n id: string,\n body: SubmitIdentityFilesRequestBody,\n ): Promise<Result<{ data: Identity }, SubmitIdentityFilesError>>;\n}\n\n// ---------------------------------------------------------------------------\n// Context\n// ---------------------------------------------------------------------------\n\ninterface MoonPayContextValue {\n client: RNClient;\n}\n\nconst MoonPayContext = createContext<MoonPayContextValue | null>(null);\n\n// ---------------------------------------------------------------------------\n// Provider\n// ---------------------------------------------------------------------------\n\nexport interface MoonPayProviderProps {\n sessionToken: string;\n apiBaseUrl?: string;\n frameBaseUrl?: string;\n children: ReactNode;\n}\n\nlet slotCounter = 0;\n\nexport function MoonPayProvider({\n sessionToken,\n apiBaseUrl,\n frameBaseUrl,\n children,\n}: MoonPayProviderProps): JSX.Element {\n const [frameSlots, setFrameSlots] = useState<FrameSlot[]>([]);\n\n // Stable refs for addSlot/removeSlot so client methods don't re-create\n const addSlot = useCallback((slot: FrameSlot) => {\n setFrameSlots((prev) => [...prev, slot]);\n }, []);\n\n const removeSlot = useCallback((id: string) => {\n setFrameSlots((prev) => prev.filter((s) => s.id !== id));\n }, []);\n\n // Keep a ref to core so it's stable across renders\n const coreRef = useRef<CoreClient | null>(null);\n if (!coreRef.current) {\n coreRef.current = createClientCore({\n apiBaseUrl,\n frameBaseUrl,\n createTransport: () => new WebViewTransport(),\n });\n }\n const core = coreRef.current;\n\n const client = useMemo<RNClient>(() => {\n // Helper: create a transport + slot, wait for orchestrator handshake\n function createManagedFrame(opts: {\n url: string;\n channelId: string;\n hidden: boolean;\n handshakeTimeout?: number;\n }): { promise: Promise<{ handle: FrameHandle; slotId: string }>; transport: WebViewTransport } {\n const transport = new WebViewTransport();\n const slotId = `slot-${++slotCounter}`;\n\n const promise = new Promise<{ handle: FrameHandle; slotId: string }>((resolve, reject) => {\n // Defer adding the slot to allow the transport to be fully set up\n // before the WebView renders\n transport.create(opts.url, { container: null, hidden: opts.hidden });\n\n addSlot({ id: slotId, transport, hidden: opts.hidden });\n\n createFrameOrchestrator({\n transport,\n channelId: opts.channelId,\n url: opts.url,\n container: null,\n hidden: opts.hidden,\n handshakeTimeout: opts.handshakeTimeout ?? 15_000,\n })\n .then((handle) => resolve({ handle, slotId }))\n .catch((e) => {\n removeSlot(slotId);\n reject(e);\n });\n });\n\n return { promise, transport };\n }\n\n // ------- getConnection (hidden frame) -------\n async function getConnection(): Promise<Result<Connection, GetConnectionError>> {\n const { privateKey, publicKey } = generateKeyPair();\n const channelId = `check-${Date.now()}`;\n\n const url = buildFrameUrl(\n FRAME_PATHS.checkConnection,\n { sessionToken, channelId, publicKey },\n { frameBaseUrl },\n );\n\n try {\n const { promise } = createManagedFrame({\n url,\n channelId,\n hidden: true,\n handshakeTimeout: 10_000,\n });\n\n const { handle, slotId } = await promise;\n\n return new Promise<Result<Connection, GetConnectionError>>((resolve) => {\n const timeout = setTimeout(() => {\n handle.dispose();\n removeSlot(slotId);\n resolve(err({ message: 'Get connection timed out' }));\n }, 10_000);\n\n handle.onMessage((msg: ProtocolMessage) => {\n if (msg.kind === 'error') {\n clearTimeout(timeout);\n handle.dispose();\n removeSlot(slotId);\n const payload = msg.payload as { message: string };\n resolve(err({ message: payload.message }));\n return;\n }\n\n if (msg.kind === 'complete') {\n clearTimeout(timeout);\n handle.dispose();\n removeSlot(slotId);\n const connection = msg.payload as Connection;\n\n if (connection.status === ConnectionStatus.active) {\n const creds = decryptCredentials(connection.credentials, privateKey);\n core.context.setAccessToken(creds.accessToken);\n core.context.setClientToken(creds.clientToken);\n }\n\n resolve(ok(connection));\n }\n });\n });\n } catch (e) {\n return err({\n message: e instanceof Error ? e.message : 'Failed to check connection',\n });\n }\n }\n\n // ------- connect (visible frame) -------\n async function connect(opts: ConnectOptions): Promise<Result<ConnectFrame, ConnectError>> {\n const { privateKey, publicKey } = generateKeyPair();\n const channelId = `connect-${Date.now()}`;\n\n const url = buildFrameUrl(\n FRAME_PATHS.connect,\n {\n sessionToken,\n channelId,\n publicKey,\n ...(opts.theme?.appearance && { appearance: opts.theme.appearance }),\n },\n { frameBaseUrl },\n );\n\n try {\n const { promise } = createManagedFrame({ url, channelId, hidden: false });\n const { handle, slotId } = await promise;\n\n return new Promise<Result<ConnectFrame, ConnectError>>((resolve) => {\n handle.onMessage((msg: ProtocolMessage) => {\n if (msg.kind === 'ready') {\n opts.onEvent?.({ kind: 'ready' });\n return;\n }\n\n if (msg.kind === 'error') {\n const payload = msg.payload as import('@moonpay/platform-protocol').ConnectionError;\n opts.onEvent?.({ kind: 'error', payload });\n handle.dispose();\n removeSlot(slotId);\n resolve(err({ message: 'Connection error' }));\n return;\n }\n\n if (msg.kind === 'complete') {\n const connection = msg.payload as Connection;\n\n if (connection.status === ConnectionStatus.active) {\n const creds = decryptCredentials(connection.credentials, privateKey);\n core.context.setAccessToken(creds.accessToken);\n core.context.setClientToken(creds.clientToken);\n }\n\n opts.onEvent?.({ kind: 'complete', payload: connection });\n resolve(\n ok({\n dispose: () => {\n handle.dispose();\n removeSlot(slotId);\n },\n }),\n );\n }\n });\n });\n } catch (e) {\n return err({\n message: e instanceof Error ? e.message : 'Connect failed',\n });\n }\n }\n\n // ------- setupWidget -------\n async function setupWidget(\n opts: SetupWidgetOptions,\n ): Promise<Result<WidgetFrame, SetupWidgetError>> {\n const channelId = `widget-${Date.now()}`;\n\n const url = buildFrameUrl(\n FRAME_PATHS.widget,\n {\n flow: 'buy',\n clientToken: core.context.clientToken,\n quoteSignature: opts.quote,\n channelId,\n },\n { frameBaseUrl },\n );\n\n try {\n const { promise } = createManagedFrame({ url, channelId, hidden: false });\n const { handle, slotId } = await promise;\n\n handle.onMessage((msg: ProtocolMessage) => {\n switch (msg.kind) {\n case 'ready':\n opts.onEvent?.({ kind: 'ready' });\n break;\n case 'transactionCreated':\n opts.onEvent?.({\n kind: 'transactionCreated',\n payload: msg.payload as { transaction: { id: string; status: string } },\n });\n break;\n case 'complete':\n opts.onEvent?.({\n kind: 'complete',\n payload: msg.payload as {\n transaction: import('@moonpay/platform-protocol').FrameTransaction;\n },\n });\n break;\n case 'error': {\n const payload = msg.payload as {\n code: 'configurationError' | 'apiError' | 'generic';\n message: string;\n };\n opts.onEvent?.({\n kind: 'error',\n payload: { code: payload.code, message: payload.message },\n });\n break;\n }\n case 'close':\n opts.onEvent?.({ kind: 'close' });\n break;\n }\n });\n\n return ok({\n dispose: () => {\n handle.dispose();\n removeSlot(slotId);\n },\n });\n } catch (e) {\n return err({\n kind: 'genericError',\n message: e instanceof Error ? e.message : 'Widget setup failed',\n });\n }\n }\n\n // ------- setupApplePay -------\n async function setupApplePay(\n opts: SetupApplePayOptions,\n ): Promise<Result<ApplePayFrame, SetupApplePayError>> {\n const channelId = `applepay-${Date.now()}`;\n\n const url = buildFrameUrl(\n FRAME_PATHS.applePay,\n {\n clientToken: core.context.clientToken,\n signature: opts.quote,\n channelId,\n },\n { frameBaseUrl },\n );\n\n try {\n const { promise } = createManagedFrame({ url, channelId, hidden: false });\n const { handle, slotId } = await promise;\n\n const setQuote = (signature: string) => {\n handle.sendMessage({\n version: 2,\n meta: { channelId },\n kind: 'setQuote',\n payload: { quote: { signature } },\n });\n };\n\n handle.onMessage((msg: ProtocolMessage) => {\n switch (msg.kind) {\n case 'ready':\n opts.onEvent?.({ kind: 'ready' });\n break;\n case 'complete':\n opts.onEvent?.({\n kind: 'complete',\n payload: msg.payload as {\n transaction: import('@moonpay/platform-protocol').FrameTransaction;\n },\n });\n break;\n case 'error': {\n const payload = msg.payload as { code: string; message: string };\n if (payload.code === 'quoteExpired') {\n opts.onEvent?.({ kind: 'quoteExpired', payload: { setQuote } });\n } else if (payload.code === 'applePayUnavailable') {\n opts.onEvent?.({ kind: 'unsupported' });\n } else {\n const kind =\n payload.code === 'generic'\n ? 'genericError'\n : (payload.code as\n | 'configurationError'\n | 'invalidQuote'\n | 'oneTapApplePaySecondFactorRequired'\n | 'genericError');\n opts.onEvent?.({\n kind: 'error',\n payload: { kind, message: payload.message },\n });\n }\n break;\n }\n }\n });\n\n return ok({\n setQuote,\n dispose: () => {\n handle.dispose();\n removeSlot(slotId);\n },\n });\n } catch (e) {\n return err({\n kind: 'genericError',\n message: e instanceof Error ? e.message : 'Apple Pay setup failed',\n });\n }\n }\n\n // ------- setupBuy (hidden frame) -------\n async function setupBuy(opts: SetupBuyOptions): Promise<Result<BuyFrame, SetupBuyError>> {\n const channelId = `buy-${Date.now()}`;\n\n const url = buildFrameUrl(\n FRAME_PATHS.buy,\n {\n channelId,\n clientToken: core.context.clientToken,\n signature: opts.quote,\n ...(opts.externalTransactionId && { externalTransactionId: opts.externalTransactionId }),\n },\n { frameBaseUrl },\n );\n\n try {\n const { promise } = createManagedFrame({ url, channelId, hidden: true });\n const { handle, slotId } = await promise;\n\n const setQuote = (signature: string) => {\n handle.sendMessage({\n version: 2,\n meta: { channelId },\n kind: 'setQuote',\n payload: { quote: { signature } },\n });\n };\n\n handle.onMessage((msg: ProtocolMessage) => {\n switch (msg.kind) {\n case 'ready':\n opts.onEvent?.({ kind: 'ready' });\n break;\n case 'complete':\n opts.onEvent?.({\n kind: 'complete',\n payload: msg.payload as {\n transaction: import('@moonpay/platform-protocol').FrameTransaction;\n },\n });\n break;\n case 'challenge':\n opts.onEvent?.({\n kind: 'challenge',\n payload: msg.payload as { kind: string; url: string },\n });\n break;\n case 'error':\n opts.onEvent?.({\n kind: 'error',\n payload: msg.payload as { code: string; message: string },\n });\n break;\n }\n });\n\n return ok({\n setQuote,\n dispose: () => {\n handle.dispose();\n removeSlot(slotId);\n },\n });\n } catch (e) {\n return err({\n kind: 'genericError',\n message: e instanceof Error ? e.message : 'Buy setup failed',\n });\n }\n }\n\n // ------- setupBuyButton -------\n async function setupBuyButton(\n opts: SetupBuyButtonOptions,\n ): Promise<Result<BuyButtonFrame, SetupBuyButtonError>> {\n const channelId = `buy-button-${Date.now()}`;\n\n const url = buildFrameUrl(\n FRAME_PATHS.buyButton,\n {\n channelId,\n clientToken: core.context.clientToken,\n signature: opts.quote,\n },\n { frameBaseUrl },\n );\n\n try {\n const { promise } = createManagedFrame({ url, channelId, hidden: false });\n const { handle, slotId } = await promise;\n\n const setQuote = (signature: string) => {\n handle.sendMessage({\n version: 2,\n meta: { channelId },\n kind: 'setQuote',\n payload: { quote: { signature } },\n });\n };\n\n handle.onMessage((msg: ProtocolMessage) => {\n switch (msg.kind) {\n case 'complete':\n opts.onEvent?.({\n kind: 'complete',\n payload: msg.payload as {\n transaction: import('@moonpay/platform-protocol').FrameTransaction;\n },\n });\n break;\n case 'challenge':\n opts.onEvent?.({\n kind: 'challenge',\n payload: msg.payload as { kind: string; url: string },\n });\n break;\n case 'error':\n opts.onEvent?.({\n kind: 'error',\n payload: msg.payload as { code: string; message: string },\n });\n break;\n }\n });\n\n return ok({\n setQuote,\n dispose: () => {\n handle.dispose();\n removeSlot(slotId);\n },\n });\n } catch (e) {\n return err({\n kind: 'genericError',\n message: e instanceof Error ? e.message : 'Buy button setup failed',\n });\n }\n }\n\n // ------- setupGooglePay -------\n async function setupGooglePay(\n opts: SetupGooglePayOptions,\n ): Promise<Result<GooglePayFrame, SetupGooglePayError>> {\n const channelId = `googlepay-${Date.now()}`;\n\n const url = buildFrameUrl(\n FRAME_PATHS.googlePay,\n {\n clientToken: core.context.clientToken,\n signature: opts.quote,\n channelId,\n ...(opts.externalTransactionId && { externalTransactionId: opts.externalTransactionId }),\n },\n { frameBaseUrl },\n );\n\n try {\n const { promise } = createManagedFrame({ url, channelId, hidden: false });\n const { handle, slotId } = await promise;\n\n const setQuote = (signature: string) => {\n handle.sendMessage({\n version: 2,\n meta: { channelId },\n kind: 'setQuote',\n payload: { quote: { signature } },\n });\n };\n\n handle.onMessage((msg: ProtocolMessage) => {\n switch (msg.kind) {\n case 'ready':\n opts.onEvent?.({ kind: 'ready' });\n break;\n case 'complete':\n opts.onEvent?.({\n kind: 'complete',\n payload: msg.payload as {\n transaction: import('@moonpay/platform-protocol').FrameTransaction;\n },\n });\n break;\n case 'challenge':\n opts.onEvent?.({\n kind: 'challenge',\n payload: msg.payload as GooglePayInboundMessageMap['challenge'],\n });\n break;\n case 'error': {\n const payload = msg.payload as { code: string; message: string };\n if (payload.code === 'quoteExpired') {\n opts.onEvent?.({ kind: 'quoteExpired', payload: { setQuote } });\n } else if (payload.code === 'googlePayUnavailable') {\n opts.onEvent?.({ kind: 'unsupported' });\n } else {\n const kind =\n payload.code === 'generic'\n ? 'genericError'\n : (payload.code as 'configurationError' | 'invalidQuote' | 'genericError');\n opts.onEvent?.({\n kind: 'error',\n payload: { kind, message: payload.message },\n });\n }\n break;\n }\n }\n });\n\n return ok({\n setQuote,\n dispose: () => {\n handle.dispose();\n removeSlot(slotId);\n },\n });\n } catch (e) {\n return err({\n kind: 'genericError',\n message: e instanceof Error ? e.message : 'Google Pay setup failed',\n });\n }\n }\n\n // ------- setupChallenge -------\n async function setupChallenge(\n opts: SetupChallengeOptions,\n ): Promise<Result<ChallengeFrame, SetupChallengeError>> {\n let channelId: string;\n try {\n channelId = new URL(opts.url).searchParams.get('channelId') ?? '';\n if (!channelId) throw new Error('missing channelId');\n } catch {\n return err({ kind: 'configurationError', message: 'Challenge URL is missing channelId' });\n }\n\n try {\n const { promise } = createManagedFrame({ url: opts.url, channelId, hidden: false });\n const { handle, slotId } = await promise;\n\n handle.onMessage((msg: ProtocolMessage) => {\n switch (msg.kind) {\n case 'ready':\n opts.onEvent?.({ kind: 'ready' });\n break;\n case 'complete':\n opts.onEvent?.({\n kind: 'complete',\n payload: msg.payload as ChallengeCompleteResult,\n });\n break;\n case 'cancelled':\n opts.onEvent?.({\n kind: 'cancelled',\n payload: msg.payload as ChallengeCancellation,\n });\n break;\n case 'error':\n opts.onEvent?.({\n kind: 'error',\n payload: msg.payload as { code: string; message: string },\n });\n break;\n }\n });\n\n return ok({\n dispose: () => {\n handle.dispose();\n removeSlot(slotId);\n },\n });\n } catch (e) {\n return err({\n kind: 'genericError',\n message: e instanceof Error ? e.message : 'Challenge setup failed',\n });\n }\n }\n\n // ------- setupAddCard -------\n async function setupAddCard(\n opts: SetupAddCardOptions,\n ): Promise<Result<AddCardFrame, SetupAddCardError>> {\n const channelId = `add-card-${Date.now()}`;\n\n const url = buildFrameUrl(\n FRAME_PATHS.addCard,\n { channelId, clientToken: core.context.clientToken },\n { frameBaseUrl },\n );\n\n try {\n const { promise } = createManagedFrame({ url, channelId, hidden: false });\n const { handle, slotId } = await promise;\n\n handle.onMessage((msg: ProtocolMessage) => {\n switch (msg.kind) {\n case 'complete':\n opts.onEvent?.({ kind: 'complete', payload: msg.payload as { card: CardResponse } });\n break;\n case 'error':\n opts.onEvent?.({\n kind: 'error',\n payload: msg.payload as {\n code: 'generic' | 'configurationError';\n message: string;\n },\n });\n break;\n }\n });\n\n return ok({\n dispose: () => {\n handle.dispose();\n removeSlot(slotId);\n },\n });\n } catch (e) {\n return err({\n kind: 'genericError',\n message: e instanceof Error ? e.message : 'Add card setup failed',\n });\n }\n }\n\n return {\n getConnection,\n connect,\n getPaymentMethods: () => core.getPaymentMethods(),\n getQuote: (params) => core.getQuote(params),\n listTransactions: (params) => core.listTransactions(params),\n getTransaction: (id) => core.getTransaction(id),\n setupWidget,\n setupApplePay,\n setupBuy,\n setupBuyButton,\n setupGooglePay,\n setupChallenge,\n setupAddCard,\n\n createIdentity: (body) => core.createIdentity(body),\n getIdentity: (id) => core.getIdentity(id),\n updateIdentity: (id, body) => core.updateIdentity(id, body),\n verifyIdentity: (id) => core.verifyIdentity(id),\n getIdentityUploadUrl: (id, body) => core.getIdentityUploadUrl(id, body),\n submitIdentityFiles: (id, body) => core.submitIdentityFiles(id, body),\n };\n }, [sessionToken, frameBaseUrl, core, addSlot, removeSlot]);\n\n return (\n <MoonPayContext.Provider value={{ client }}>\n {children}\n {frameSlots.map((slot) => (\n <MoonPayFrame key={slot.id} transport={slot.transport} hidden={slot.hidden} />\n ))}\n </MoonPayContext.Provider>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Hook\n// ---------------------------------------------------------------------------\n\nexport function useMoonPay(): MoonPayContextValue {\n const ctx = useContext(MoonPayContext);\n if (!ctx) {\n throw new Error('useMoonPay must be used within a <MoonPayProvider>');\n }\n return ctx;\n}\n","import type { ProtocolMessage } from '@moonpay/platform-protocol';\nimport type { FrameOptions, FrameTransport } from '@moonpay/platform-sdk-core';\nimport type { RefObject } from 'react';\nimport type WebView from 'react-native-webview';\n\n/**\n * FrameTransport implementation for React Native using react-native-webview.\n *\n * Unlike the web IframeTransport, the WebView is rendered declaratively via\n * React components. This transport bridges the imperative FrameTransport\n * interface to a WebView ref.\n */\nexport class WebViewTransport implements FrameTransport {\n private webViewRef: RefObject<WebView | null> | null = null;\n private handlers: Array<(msg: ProtocolMessage) => void> = [];\n private _url: string = '';\n private _options: FrameOptions | null = null;\n\n /** Called by the frame component when it mounts the WebView. */\n attachWebView(ref: RefObject<WebView | null>): void {\n this.webViewRef = ref;\n }\n\n /** Called by the WebView's onMessage prop to route incoming messages. */\n handleWebViewMessage(data: string): void {\n try {\n const msg: ProtocolMessage = JSON.parse(data);\n if (!msg.kind) return;\n for (const handler of this.handlers) {\n handler(msg);\n }\n } catch {\n // Ignore non-protocol messages\n }\n }\n\n get url(): string {\n return this._url;\n }\n\n get options(): FrameOptions | null {\n return this._options;\n }\n\n // FrameTransport interface\n\n create(url: string, options: FrameOptions): void {\n this._url = url;\n this._options = options;\n // The actual WebView rendering is handled by React components.\n // This method stores the URL and options for the component to read.\n }\n\n sendMessage(message: ProtocolMessage): void {\n if (!this.webViewRef?.current) {\n throw new Error('Cannot send message: WebView not attached');\n }\n const js = `\n window.postMessage(${JSON.stringify(JSON.stringify(message))}, '*');\n true;\n `;\n this.webViewRef.current.injectJavaScript(js);\n }\n\n onMessage(handler: (msg: ProtocolMessage) => void): () => void {\n this.handlers.push(handler);\n return () => {\n const idx = this.handlers.indexOf(handler);\n if (idx >= 0) this.handlers.splice(idx, 1);\n };\n }\n\n dispose(): void {\n this.handlers.length = 0;\n this.webViewRef = null;\n this._url = '';\n this._options = null;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAAkC;AAClC,0BAAqC;AACrC,kCAAkD;AAuC5C;AAvBC,SAAS,aAAa,EAAE,WAAW,QAAQ,MAAM,GAA0C;AAChG,QAAM,iBAAa,qBAAgB,IAAI;AAEvC,8BAAU,MAAM;AACd,cAAU,cAAc,UAAU;AAClC,WAAO,MAAM;AAAA,IAEb;AAAA,EACF,GAAG,CAAC,SAAS,CAAC;AAEd,QAAM,MAAM,UAAU;AACtB,MAAI,CAAC;AAAK,WAAO;AAEjB,QAAM,gBAAgB,CAAC,UAA+B;AACpD,cAAU,qBAAqB,MAAM,YAAY,IAAI;AAAA,EACvD;AAEA,QAAM,iBAA4B,SAC9B,EAAE,OAAO,GAAG,QAAQ,GAAG,UAAU,SAAS,IAC1C,EAAE,MAAM,GAAG,GAAG,MAAM;AAExB,SACE,4CAAC,4BAAK,OAAO,gBACX;AAAA,IAAC,4BAAAA;AAAA,IAAA;AAAA,MACC,KAAK;AAAA,MACL,QAAQ,EAAE,KAAK,IAAI;AAAA,MACnB,WAAW;AAAA,MACX,2BAAyB;AAAA,MACzB,mBAAiB;AAAA,MACjB,mBAAiB;AAAA,MACjB,OAAO,EAAE,MAAM,EAA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A,MACtE,qBAAqB,CAAC,IAAI,SAAS,KAAK,oBAAoB,IAAI,IAAI;AAAA,IACtE;AAAA,EACF,GAAG,CAAC,cAAc,cAAc,MAAM,SAAS,UAAU,CAAC;AAE1D,SACE,8CAAC,eAAe,UAAf,EAAwB,OAAO,EAAE,OAAO,GACtC;AAAA;AAAA,IACA,WAAW,IAAI,CAAC,SACf,6CAAC,gBAA2B,WAAW,KAAK,WAAW,QAAQ,KAAK,UAAjD,KAAK,EAAoD,CAC7E;AAAA,KACH;AAEJ;AAMO,SAAS,aAAkC;AAChD,QAAM,UAAM,0BAAW,cAAc;AACrC,MAAI,CAAC,KAAK;AACR,UAAM,IAAI,MAAM,oDAAoD;AAAA,EACtE;AACA,SAAO;AACT;","names":["WebView","import_react","import_jsx_runtime"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ProtocolMessage, ConnectEvent, Result, Connection, GetConnectionError, ConnectError, ListPaymentMethodsResponse, GetPaymentMethodsError, GetQuoteParams, Quote, GetQuoteError, Transaction, PaginationInfo, GetTransactionsError, TransactionWithStages, WidgetEvent, SetupWidgetError, ApplePayEvent, SetupApplePayError, BuyEvent, SetupBuyError, BuyButtonEvent, SetupBuyButtonError, GooglePayEvent, SetupGooglePayError, ChallengeEvent, SetupChallengeError, AddCardEvent, SetupAddCardError } from '@moonpay/platform-protocol';
|
|
1
|
+
import { ProtocolMessage, ConnectEvent, Result, Connection, GetConnectionError, ConnectError, ListPaymentMethodsResponse, GetPaymentMethodsError, GetQuoteParams, Quote, GetQuoteError, Transaction, PaginationInfo, GetTransactionsError, TransactionWithStages, WidgetEvent, SetupWidgetError, ApplePayEvent, SetupApplePayError, BuyEvent, SetupBuyError, BuyButtonEvent, SetupBuyButtonError, GooglePayEvent, SetupGooglePayError, ChallengeEvent, SetupChallengeError, AddCardEvent, SetupAddCardError, CreateIdentityRequestBody, Identity, CreateIdentityError, GetIdentityError, UpdateIdentityRequestBody, UpdateIdentityError, IdentityVerificationResponse, VerifyIdentityError, IdentityFileUploadUrlRequestBody, IdentityFileUploadUrl, GetIdentityUploadUrlError, SubmitIdentityFilesRequestBody, SubmitIdentityFilesError } from '@moonpay/platform-protocol';
|
|
2
2
|
export { AddCardEvent, ApplePayEvent, BuyButtonEvent, BuyEvent, CardResponse, ChallengeCancellation, ChallengeCompleteResult, ChallengeEvent, ConnectEvent, Connection, ConnectionStatus, GetQuoteParams, GooglePayEvent, PaymentMethodConfig, Quote, Result, StoredPaymentMethod, Transaction, TransactionWithStages, WidgetEvent } from '@moonpay/platform-protocol';
|
|
3
3
|
import { ViewStyle } from 'react-native';
|
|
4
4
|
import { FrameTransport, FrameOptions, ListTransactionsParams } from '@moonpay/platform-sdk-core';
|
|
@@ -148,6 +148,24 @@ interface RNClient {
|
|
|
148
148
|
setupGooglePay(options: SetupGooglePayOptions): Promise<Result<GooglePayFrame, SetupGooglePayError>>;
|
|
149
149
|
setupChallenge(options: SetupChallengeOptions): Promise<Result<ChallengeFrame, SetupChallengeError>>;
|
|
150
150
|
setupAddCard(options: SetupAddCardOptions): Promise<Result<AddCardFrame, SetupAddCardError>>;
|
|
151
|
+
createIdentity(body: CreateIdentityRequestBody): Promise<Result<{
|
|
152
|
+
data: Identity | null;
|
|
153
|
+
}, CreateIdentityError>>;
|
|
154
|
+
getIdentity(id: string): Promise<Result<{
|
|
155
|
+
data: Identity;
|
|
156
|
+
}, GetIdentityError>>;
|
|
157
|
+
updateIdentity(id: string, body: UpdateIdentityRequestBody): Promise<Result<{
|
|
158
|
+
data: Identity;
|
|
159
|
+
}, UpdateIdentityError>>;
|
|
160
|
+
verifyIdentity(id: string): Promise<Result<{
|
|
161
|
+
data: IdentityVerificationResponse;
|
|
162
|
+
}, VerifyIdentityError>>;
|
|
163
|
+
getIdentityUploadUrl(id: string, body: IdentityFileUploadUrlRequestBody): Promise<Result<{
|
|
164
|
+
data: IdentityFileUploadUrl;
|
|
165
|
+
}, GetIdentityUploadUrlError>>;
|
|
166
|
+
submitIdentityFiles(id: string, body: SubmitIdentityFilesRequestBody): Promise<Result<{
|
|
167
|
+
data: Identity;
|
|
168
|
+
}, SubmitIdentityFilesError>>;
|
|
151
169
|
}
|
|
152
170
|
interface MoonPayContextValue {
|
|
153
171
|
client: RNClient;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ProtocolMessage, ConnectEvent, Result, Connection, GetConnectionError, ConnectError, ListPaymentMethodsResponse, GetPaymentMethodsError, GetQuoteParams, Quote, GetQuoteError, Transaction, PaginationInfo, GetTransactionsError, TransactionWithStages, WidgetEvent, SetupWidgetError, ApplePayEvent, SetupApplePayError, BuyEvent, SetupBuyError, BuyButtonEvent, SetupBuyButtonError, GooglePayEvent, SetupGooglePayError, ChallengeEvent, SetupChallengeError, AddCardEvent, SetupAddCardError } from '@moonpay/platform-protocol';
|
|
1
|
+
import { ProtocolMessage, ConnectEvent, Result, Connection, GetConnectionError, ConnectError, ListPaymentMethodsResponse, GetPaymentMethodsError, GetQuoteParams, Quote, GetQuoteError, Transaction, PaginationInfo, GetTransactionsError, TransactionWithStages, WidgetEvent, SetupWidgetError, ApplePayEvent, SetupApplePayError, BuyEvent, SetupBuyError, BuyButtonEvent, SetupBuyButtonError, GooglePayEvent, SetupGooglePayError, ChallengeEvent, SetupChallengeError, AddCardEvent, SetupAddCardError, CreateIdentityRequestBody, Identity, CreateIdentityError, GetIdentityError, UpdateIdentityRequestBody, UpdateIdentityError, IdentityVerificationResponse, VerifyIdentityError, IdentityFileUploadUrlRequestBody, IdentityFileUploadUrl, GetIdentityUploadUrlError, SubmitIdentityFilesRequestBody, SubmitIdentityFilesError } from '@moonpay/platform-protocol';
|
|
2
2
|
export { AddCardEvent, ApplePayEvent, BuyButtonEvent, BuyEvent, CardResponse, ChallengeCancellation, ChallengeCompleteResult, ChallengeEvent, ConnectEvent, Connection, ConnectionStatus, GetQuoteParams, GooglePayEvent, PaymentMethodConfig, Quote, Result, StoredPaymentMethod, Transaction, TransactionWithStages, WidgetEvent } from '@moonpay/platform-protocol';
|
|
3
3
|
import { ViewStyle } from 'react-native';
|
|
4
4
|
import { FrameTransport, FrameOptions, ListTransactionsParams } from '@moonpay/platform-sdk-core';
|
|
@@ -148,6 +148,24 @@ interface RNClient {
|
|
|
148
148
|
setupGooglePay(options: SetupGooglePayOptions): Promise<Result<GooglePayFrame, SetupGooglePayError>>;
|
|
149
149
|
setupChallenge(options: SetupChallengeOptions): Promise<Result<ChallengeFrame, SetupChallengeError>>;
|
|
150
150
|
setupAddCard(options: SetupAddCardOptions): Promise<Result<AddCardFrame, SetupAddCardError>>;
|
|
151
|
+
createIdentity(body: CreateIdentityRequestBody): Promise<Result<{
|
|
152
|
+
data: Identity | null;
|
|
153
|
+
}, CreateIdentityError>>;
|
|
154
|
+
getIdentity(id: string): Promise<Result<{
|
|
155
|
+
data: Identity;
|
|
156
|
+
}, GetIdentityError>>;
|
|
157
|
+
updateIdentity(id: string, body: UpdateIdentityRequestBody): Promise<Result<{
|
|
158
|
+
data: Identity;
|
|
159
|
+
}, UpdateIdentityError>>;
|
|
160
|
+
verifyIdentity(id: string): Promise<Result<{
|
|
161
|
+
data: IdentityVerificationResponse;
|
|
162
|
+
}, VerifyIdentityError>>;
|
|
163
|
+
getIdentityUploadUrl(id: string, body: IdentityFileUploadUrlRequestBody): Promise<Result<{
|
|
164
|
+
data: IdentityFileUploadUrl;
|
|
165
|
+
}, GetIdentityUploadUrlError>>;
|
|
166
|
+
submitIdentityFiles(id: string, body: SubmitIdentityFilesRequestBody): Promise<Result<{
|
|
167
|
+
data: Identity;
|
|
168
|
+
}, SubmitIdentityFilesError>>;
|
|
151
169
|
}
|
|
152
170
|
interface MoonPayContextValue {
|
|
153
171
|
client: RNClient;
|
package/dist/index.js
CHANGED
|
@@ -678,7 +678,13 @@ function MoonPayProvider({
|
|
|
678
678
|
setupBuyButton,
|
|
679
679
|
setupGooglePay,
|
|
680
680
|
setupChallenge,
|
|
681
|
-
setupAddCard
|
|
681
|
+
setupAddCard,
|
|
682
|
+
createIdentity: (body) => core.createIdentity(body),
|
|
683
|
+
getIdentity: (id) => core.getIdentity(id),
|
|
684
|
+
updateIdentity: (id, body) => core.updateIdentity(id, body),
|
|
685
|
+
verifyIdentity: (id) => core.verifyIdentity(id),
|
|
686
|
+
getIdentityUploadUrl: (id, body) => core.getIdentityUploadUrl(id, body),
|
|
687
|
+
submitIdentityFiles: (id, body) => core.submitIdentityFiles(id, body)
|
|
682
688
|
};
|
|
683
689
|
}, [sessionToken, frameBaseUrl, core, addSlot, removeSlot]);
|
|
684
690
|
return /* @__PURE__ */ jsxs(MoonPayContext.Provider, { value: { client }, children: [
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/frame-component.tsx","../src/provider.tsx","../src/webview-transport.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\nimport { View, type ViewStyle } from 'react-native';\nimport WebView, { type WebViewMessageEvent } from 'react-native-webview';\nimport type { WebViewTransport } from './webview-transport.js';\n\nexport interface MoonPayFrameProps {\n /** The transport instance managing this frame's communication. */\n transport: WebViewTransport;\n /** Whether this is a hidden utility frame (zero height). */\n hidden?: boolean;\n /** Optional style overrides for the container view. */\n style?: ViewStyle;\n}\n\n/**\n * Reusable React Native component that renders a MoonPay frame as a WebView.\n * Bridges the WebViewTransport to the actual WebView instance.\n */\nexport function MoonPayFrame({ transport, hidden, style }: MoonPayFrameProps): JSX.Element | null {\n const webViewRef = useRef<WebView>(null);\n\n useEffect(() => {\n transport.attachWebView(webViewRef);\n return () => {\n // Don't dispose — the orchestrator manages lifecycle\n };\n }, [transport]);\n\n const url = transport.url;\n if (!url) return null;\n\n const handleMessage = (event: WebViewMessageEvent) => {\n transport.handleWebViewMessage(event.nativeEvent.data);\n };\n\n const containerStyle: ViewStyle = hidden\n ? { width: 0, height: 0, overflow: 'hidden' }\n : { flex: 1, ...style };\n\n return (\n <View style={containerStyle}>\n <WebView\n ref={webViewRef}\n source={{ uri: url }}\n onMessage={handleMessage}\n allowsInlineMediaPlayback\n javaScriptEnabled\n domStorageEnabled\n style={{ flex: 1 }}\n />\n </View>\n );\n}\n","import {\n type AddCardEvent,\n type ApplePayEvent,\n type BuyButtonEvent,\n type BuyEvent,\n type CardResponse,\n type ChallengeCancellation,\n type ChallengeCompleteResult,\n type ChallengeEvent,\n type ConnectError,\n type ConnectEvent,\n type Connection,\n ConnectionStatus,\n err,\n type GetConnectionError,\n type GetPaymentMethodsError,\n type GetQuoteError,\n type GetQuoteParams,\n type GetTransactionsError,\n type GooglePayEvent,\n type GooglePayInboundMessageMap,\n type ListPaymentMethodsResponse,\n ok,\n type PaginationInfo,\n type ProtocolMessage,\n type Quote,\n type Result,\n type SetupAddCardError,\n type SetupApplePayError,\n type SetupBuyButtonError,\n type SetupBuyError,\n type SetupChallengeError,\n type SetupGooglePayError,\n type SetupWidgetError,\n type Transaction,\n type TransactionWithStages,\n type WidgetEvent,\n} from '@moonpay/platform-protocol';\nimport {\n buildFrameUrl,\n type CoreClient,\n createClientCore,\n createFrameOrchestrator,\n decryptCredentials,\n FRAME_PATHS,\n type FrameHandle,\n generateKeyPair,\n type ListTransactionsParams,\n} from '@moonpay/platform-sdk-core';\nimport {\n createContext,\n type ReactNode,\n useCallback,\n useContext,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { MoonPayFrame } from './frame-component.js';\nimport { WebViewTransport } from './webview-transport.js';\n\n// ---------------------------------------------------------------------------\n// Frame slot — represents a frame the provider needs to render\n// ---------------------------------------------------------------------------\n\ninterface FrameSlot {\n id: string;\n transport: WebViewTransport;\n hidden: boolean;\n}\n\n// ---------------------------------------------------------------------------\n// Public types\n// ---------------------------------------------------------------------------\n\nexport interface ConnectOptions {\n /** Theme options for the connect frame. */\n theme?: { appearance?: 'light' | 'dark' };\n /** Callback for connect lifecycle events. */\n onEvent?: (event: ConnectEvent) => void;\n}\n\nexport interface ConnectFrame {\n dispose(): void;\n}\n\nexport interface SetupWidgetOptions {\n /** Quote signature from getQuote(). */\n quote: string;\n /** Callback for widget lifecycle events. */\n onEvent?: (event: WidgetEvent) => void;\n}\n\nexport interface WidgetFrame {\n dispose(): void;\n}\n\nexport interface SetupApplePayOptions {\n /** Quote signature from getQuote(). */\n quote: string;\n /** Callback for Apple Pay lifecycle events. */\n onEvent?: (event: ApplePayEvent) => void;\n}\n\nexport interface ApplePayFrame {\n /** Update the quote (e.g., after expiry). */\n setQuote(signature: string): void;\n dispose(): void;\n}\n\nexport interface SetupBuyOptions {\n /** Quote signature from getQuote(). */\n quote: string;\n /** Partner-assigned identifier for this transaction attempt. */\n externalTransactionId?: string;\n /** Callback for buy frame lifecycle events. */\n onEvent?: (event: BuyEvent) => void;\n}\n\nexport interface BuyFrame {\n /** Update the quote (e.g., after expiry). */\n setQuote(signature: string): void;\n dispose(): void;\n}\n\nexport interface SetupBuyButtonOptions {\n /** Quote signature from getQuote(). */\n quote: string;\n /** Callback for buy-button frame lifecycle events. */\n onEvent?: (event: BuyButtonEvent) => void;\n}\n\nexport interface BuyButtonFrame {\n /** Update the quote (e.g., after expiry). */\n setQuote(signature: string): void;\n dispose(): void;\n}\n\nexport interface SetupGooglePayOptions {\n /** Quote signature from getQuote(). */\n quote: string;\n /** Partner-assigned identifier for this transaction attempt. */\n externalTransactionId?: string;\n /** Callback for Google Pay lifecycle events. */\n onEvent?: (event: GooglePayEvent) => void;\n}\n\nexport interface GooglePayFrame {\n /** Update the quote (e.g., after expiry). */\n setQuote(signature: string): void;\n dispose(): void;\n}\n\nexport interface SetupChallengeOptions {\n /** Full challenge URL received from a frame's `challenge` event. */\n url: string;\n /** Callback for challenge frame lifecycle events. */\n onEvent?: (event: ChallengeEvent) => void;\n}\n\nexport interface ChallengeFrame {\n dispose(): void;\n}\n\nexport interface SetupAddCardOptions {\n /** Callback for add-card frame lifecycle events. */\n onEvent?: (event: AddCardEvent) => void;\n}\n\nexport interface AddCardFrame {\n dispose(): void;\n}\n\nexport interface RNClient {\n getConnection(): Promise<Result<Connection, GetConnectionError>>;\n connect(options: ConnectOptions): Promise<Result<ConnectFrame, ConnectError>>;\n getPaymentMethods(): Promise<Result<ListPaymentMethodsResponse, GetPaymentMethodsError>>;\n getQuote(params: GetQuoteParams): Promise<Result<{ data: Quote }, GetQuoteError>>;\n listTransactions(\n params?: ListTransactionsParams,\n ): Promise<Result<{ data: Transaction[]; pageInfo: PaginationInfo }, GetTransactionsError>>;\n getTransaction(\n id: string,\n ): Promise<Result<{ data: TransactionWithStages }, GetTransactionsError>>;\n setupWidget(options: SetupWidgetOptions): Promise<Result<WidgetFrame, SetupWidgetError>>;\n setupApplePay(options: SetupApplePayOptions): Promise<Result<ApplePayFrame, SetupApplePayError>>;\n setupBuy(options: SetupBuyOptions): Promise<Result<BuyFrame, SetupBuyError>>;\n setupBuyButton(\n options: SetupBuyButtonOptions,\n ): Promise<Result<BuyButtonFrame, SetupBuyButtonError>>;\n setupGooglePay(\n options: SetupGooglePayOptions,\n ): Promise<Result<GooglePayFrame, SetupGooglePayError>>;\n setupChallenge(\n options: SetupChallengeOptions,\n ): Promise<Result<ChallengeFrame, SetupChallengeError>>;\n setupAddCard(options: SetupAddCardOptions): Promise<Result<AddCardFrame, SetupAddCardError>>;\n}\n\n// ---------------------------------------------------------------------------\n// Context\n// ---------------------------------------------------------------------------\n\ninterface MoonPayContextValue {\n client: RNClient;\n}\n\nconst MoonPayContext = createContext<MoonPayContextValue | null>(null);\n\n// ---------------------------------------------------------------------------\n// Provider\n// ---------------------------------------------------------------------------\n\nexport interface MoonPayProviderProps {\n sessionToken: string;\n apiBaseUrl?: string;\n frameBaseUrl?: string;\n children: ReactNode;\n}\n\nlet slotCounter = 0;\n\nexport function MoonPayProvider({\n sessionToken,\n apiBaseUrl,\n frameBaseUrl,\n children,\n}: MoonPayProviderProps): JSX.Element {\n const [frameSlots, setFrameSlots] = useState<FrameSlot[]>([]);\n\n // Stable refs for addSlot/removeSlot so client methods don't re-create\n const addSlot = useCallback((slot: FrameSlot) => {\n setFrameSlots((prev) => [...prev, slot]);\n }, []);\n\n const removeSlot = useCallback((id: string) => {\n setFrameSlots((prev) => prev.filter((s) => s.id !== id));\n }, []);\n\n // Keep a ref to core so it's stable across renders\n const coreRef = useRef<CoreClient | null>(null);\n if (!coreRef.current) {\n coreRef.current = createClientCore({\n apiBaseUrl,\n frameBaseUrl,\n createTransport: () => new WebViewTransport(),\n });\n }\n const core = coreRef.current;\n\n const client = useMemo<RNClient>(() => {\n // Helper: create a transport + slot, wait for orchestrator handshake\n function createManagedFrame(opts: {\n url: string;\n channelId: string;\n hidden: boolean;\n handshakeTimeout?: number;\n }): { promise: Promise<{ handle: FrameHandle; slotId: string }>; transport: WebViewTransport } {\n const transport = new WebViewTransport();\n const slotId = `slot-${++slotCounter}`;\n\n const promise = new Promise<{ handle: FrameHandle; slotId: string }>((resolve, reject) => {\n // Defer adding the slot to allow the transport to be fully set up\n // before the WebView renders\n transport.create(opts.url, { container: null, hidden: opts.hidden });\n\n addSlot({ id: slotId, transport, hidden: opts.hidden });\n\n createFrameOrchestrator({\n transport,\n channelId: opts.channelId,\n url: opts.url,\n container: null,\n hidden: opts.hidden,\n handshakeTimeout: opts.handshakeTimeout ?? 15_000,\n })\n .then((handle) => resolve({ handle, slotId }))\n .catch((e) => {\n removeSlot(slotId);\n reject(e);\n });\n });\n\n return { promise, transport };\n }\n\n // ------- getConnection (hidden frame) -------\n async function getConnection(): Promise<Result<Connection, GetConnectionError>> {\n const { privateKey, publicKey } = generateKeyPair();\n const channelId = `check-${Date.now()}`;\n\n const url = buildFrameUrl(\n FRAME_PATHS.checkConnection,\n { sessionToken, channelId, publicKey },\n { frameBaseUrl },\n );\n\n try {\n const { promise } = createManagedFrame({\n url,\n channelId,\n hidden: true,\n handshakeTimeout: 10_000,\n });\n\n const { handle, slotId } = await promise;\n\n return new Promise<Result<Connection, GetConnectionError>>((resolve) => {\n const timeout = setTimeout(() => {\n handle.dispose();\n removeSlot(slotId);\n resolve(err({ message: 'Get connection timed out' }));\n }, 10_000);\n\n handle.onMessage((msg: ProtocolMessage) => {\n if (msg.kind === 'error') {\n clearTimeout(timeout);\n handle.dispose();\n removeSlot(slotId);\n const payload = msg.payload as { message: string };\n resolve(err({ message: payload.message }));\n return;\n }\n\n if (msg.kind === 'complete') {\n clearTimeout(timeout);\n handle.dispose();\n removeSlot(slotId);\n const connection = msg.payload as Connection;\n\n if (connection.status === ConnectionStatus.active) {\n const creds = decryptCredentials(connection.credentials, privateKey);\n core.context.setAccessToken(creds.accessToken);\n core.context.setClientToken(creds.clientToken);\n }\n\n resolve(ok(connection));\n }\n });\n });\n } catch (e) {\n return err({\n message: e instanceof Error ? e.message : 'Failed to check connection',\n });\n }\n }\n\n // ------- connect (visible frame) -------\n async function connect(opts: ConnectOptions): Promise<Result<ConnectFrame, ConnectError>> {\n const { privateKey, publicKey } = generateKeyPair();\n const channelId = `connect-${Date.now()}`;\n\n const url = buildFrameUrl(\n FRAME_PATHS.connect,\n {\n sessionToken,\n channelId,\n publicKey,\n ...(opts.theme?.appearance && { appearance: opts.theme.appearance }),\n },\n { frameBaseUrl },\n );\n\n try {\n const { promise } = createManagedFrame({ url, channelId, hidden: false });\n const { handle, slotId } = await promise;\n\n return new Promise<Result<ConnectFrame, ConnectError>>((resolve) => {\n handle.onMessage((msg: ProtocolMessage) => {\n if (msg.kind === 'ready') {\n opts.onEvent?.({ kind: 'ready' });\n return;\n }\n\n if (msg.kind === 'error') {\n const payload = msg.payload as import('@moonpay/platform-protocol').ConnectionError;\n opts.onEvent?.({ kind: 'error', payload });\n handle.dispose();\n removeSlot(slotId);\n resolve(err({ message: 'Connection error' }));\n return;\n }\n\n if (msg.kind === 'complete') {\n const connection = msg.payload as Connection;\n\n if (connection.status === ConnectionStatus.active) {\n const creds = decryptCredentials(connection.credentials, privateKey);\n core.context.setAccessToken(creds.accessToken);\n core.context.setClientToken(creds.clientToken);\n }\n\n opts.onEvent?.({ kind: 'complete', payload: connection });\n resolve(\n ok({\n dispose: () => {\n handle.dispose();\n removeSlot(slotId);\n },\n }),\n );\n }\n });\n });\n } catch (e) {\n return err({\n message: e instanceof Error ? e.message : 'Connect failed',\n });\n }\n }\n\n // ------- setupWidget -------\n async function setupWidget(\n opts: SetupWidgetOptions,\n ): Promise<Result<WidgetFrame, SetupWidgetError>> {\n const channelId = `widget-${Date.now()}`;\n\n const url = buildFrameUrl(\n FRAME_PATHS.widget,\n {\n flow: 'buy',\n clientToken: core.context.clientToken,\n quoteSignature: opts.quote,\n channelId,\n },\n { frameBaseUrl },\n );\n\n try {\n const { promise } = createManagedFrame({ url, channelId, hidden: false });\n const { handle, slotId } = await promise;\n\n handle.onMessage((msg: ProtocolMessage) => {\n switch (msg.kind) {\n case 'ready':\n opts.onEvent?.({ kind: 'ready' });\n break;\n case 'transactionCreated':\n opts.onEvent?.({\n kind: 'transactionCreated',\n payload: msg.payload as { transaction: { id: string; status: string } },\n });\n break;\n case 'complete':\n opts.onEvent?.({\n kind: 'complete',\n payload: msg.payload as {\n transaction: import('@moonpay/platform-protocol').FrameTransaction;\n },\n });\n break;\n case 'error': {\n const payload = msg.payload as {\n code: 'configurationError' | 'apiError' | 'generic';\n message: string;\n };\n opts.onEvent?.({\n kind: 'error',\n payload: { code: payload.code, message: payload.message },\n });\n break;\n }\n case 'close':\n opts.onEvent?.({ kind: 'close' });\n break;\n }\n });\n\n return ok({\n dispose: () => {\n handle.dispose();\n removeSlot(slotId);\n },\n });\n } catch (e) {\n return err({\n kind: 'genericError',\n message: e instanceof Error ? e.message : 'Widget setup failed',\n });\n }\n }\n\n // ------- setupApplePay -------\n async function setupApplePay(\n opts: SetupApplePayOptions,\n ): Promise<Result<ApplePayFrame, SetupApplePayError>> {\n const channelId = `applepay-${Date.now()}`;\n\n const url = buildFrameUrl(\n FRAME_PATHS.applePay,\n {\n clientToken: core.context.clientToken,\n signature: opts.quote,\n channelId,\n },\n { frameBaseUrl },\n );\n\n try {\n const { promise } = createManagedFrame({ url, channelId, hidden: false });\n const { handle, slotId } = await promise;\n\n const setQuote = (signature: string) => {\n handle.sendMessage({\n version: 2,\n meta: { channelId },\n kind: 'setQuote',\n payload: { quote: { signature } },\n });\n };\n\n handle.onMessage((msg: ProtocolMessage) => {\n switch (msg.kind) {\n case 'ready':\n opts.onEvent?.({ kind: 'ready' });\n break;\n case 'complete':\n opts.onEvent?.({\n kind: 'complete',\n payload: msg.payload as {\n transaction: import('@moonpay/platform-protocol').FrameTransaction;\n },\n });\n break;\n case 'error': {\n const payload = msg.payload as { code: string; message: string };\n if (payload.code === 'quoteExpired') {\n opts.onEvent?.({ kind: 'quoteExpired', payload: { setQuote } });\n } else if (payload.code === 'applePayUnavailable') {\n opts.onEvent?.({ kind: 'unsupported' });\n } else {\n const kind =\n payload.code === 'generic'\n ? 'genericError'\n : (payload.code as\n | 'configurationError'\n | 'invalidQuote'\n | 'oneTapApplePaySecondFactorRequired'\n | 'genericError');\n opts.onEvent?.({\n kind: 'error',\n payload: { kind, message: payload.message },\n });\n }\n break;\n }\n }\n });\n\n return ok({\n setQuote,\n dispose: () => {\n handle.dispose();\n removeSlot(slotId);\n },\n });\n } catch (e) {\n return err({\n kind: 'genericError',\n message: e instanceof Error ? e.message : 'Apple Pay setup failed',\n });\n }\n }\n\n // ------- setupBuy (hidden frame) -------\n async function setupBuy(opts: SetupBuyOptions): Promise<Result<BuyFrame, SetupBuyError>> {\n const channelId = `buy-${Date.now()}`;\n\n const url = buildFrameUrl(\n FRAME_PATHS.buy,\n {\n channelId,\n clientToken: core.context.clientToken,\n signature: opts.quote,\n ...(opts.externalTransactionId && { externalTransactionId: opts.externalTransactionId }),\n },\n { frameBaseUrl },\n );\n\n try {\n const { promise } = createManagedFrame({ url, channelId, hidden: true });\n const { handle, slotId } = await promise;\n\n const setQuote = (signature: string) => {\n handle.sendMessage({\n version: 2,\n meta: { channelId },\n kind: 'setQuote',\n payload: { quote: { signature } },\n });\n };\n\n handle.onMessage((msg: ProtocolMessage) => {\n switch (msg.kind) {\n case 'ready':\n opts.onEvent?.({ kind: 'ready' });\n break;\n case 'complete':\n opts.onEvent?.({\n kind: 'complete',\n payload: msg.payload as {\n transaction: import('@moonpay/platform-protocol').FrameTransaction;\n },\n });\n break;\n case 'challenge':\n opts.onEvent?.({\n kind: 'challenge',\n payload: msg.payload as { kind: string; url: string },\n });\n break;\n case 'error':\n opts.onEvent?.({\n kind: 'error',\n payload: msg.payload as { code: string; message: string },\n });\n break;\n }\n });\n\n return ok({\n setQuote,\n dispose: () => {\n handle.dispose();\n removeSlot(slotId);\n },\n });\n } catch (e) {\n return err({\n kind: 'genericError',\n message: e instanceof Error ? e.message : 'Buy setup failed',\n });\n }\n }\n\n // ------- setupBuyButton -------\n async function setupBuyButton(\n opts: SetupBuyButtonOptions,\n ): Promise<Result<BuyButtonFrame, SetupBuyButtonError>> {\n const channelId = `buy-button-${Date.now()}`;\n\n const url = buildFrameUrl(\n FRAME_PATHS.buyButton,\n {\n channelId,\n clientToken: core.context.clientToken,\n signature: opts.quote,\n },\n { frameBaseUrl },\n );\n\n try {\n const { promise } = createManagedFrame({ url, channelId, hidden: false });\n const { handle, slotId } = await promise;\n\n const setQuote = (signature: string) => {\n handle.sendMessage({\n version: 2,\n meta: { channelId },\n kind: 'setQuote',\n payload: { quote: { signature } },\n });\n };\n\n handle.onMessage((msg: ProtocolMessage) => {\n switch (msg.kind) {\n case 'complete':\n opts.onEvent?.({\n kind: 'complete',\n payload: msg.payload as {\n transaction: import('@moonpay/platform-protocol').FrameTransaction;\n },\n });\n break;\n case 'challenge':\n opts.onEvent?.({\n kind: 'challenge',\n payload: msg.payload as { kind: string; url: string },\n });\n break;\n case 'error':\n opts.onEvent?.({\n kind: 'error',\n payload: msg.payload as { code: string; message: string },\n });\n break;\n }\n });\n\n return ok({\n setQuote,\n dispose: () => {\n handle.dispose();\n removeSlot(slotId);\n },\n });\n } catch (e) {\n return err({\n kind: 'genericError',\n message: e instanceof Error ? e.message : 'Buy button setup failed',\n });\n }\n }\n\n // ------- setupGooglePay -------\n async function setupGooglePay(\n opts: SetupGooglePayOptions,\n ): Promise<Result<GooglePayFrame, SetupGooglePayError>> {\n const channelId = `googlepay-${Date.now()}`;\n\n const url = buildFrameUrl(\n FRAME_PATHS.googlePay,\n {\n clientToken: core.context.clientToken,\n signature: opts.quote,\n channelId,\n ...(opts.externalTransactionId && { externalTransactionId: opts.externalTransactionId }),\n },\n { frameBaseUrl },\n );\n\n try {\n const { promise } = createManagedFrame({ url, channelId, hidden: false });\n const { handle, slotId } = await promise;\n\n const setQuote = (signature: string) => {\n handle.sendMessage({\n version: 2,\n meta: { channelId },\n kind: 'setQuote',\n payload: { quote: { signature } },\n });\n };\n\n handle.onMessage((msg: ProtocolMessage) => {\n switch (msg.kind) {\n case 'ready':\n opts.onEvent?.({ kind: 'ready' });\n break;\n case 'complete':\n opts.onEvent?.({\n kind: 'complete',\n payload: msg.payload as {\n transaction: import('@moonpay/platform-protocol').FrameTransaction;\n },\n });\n break;\n case 'challenge':\n opts.onEvent?.({\n kind: 'challenge',\n payload: msg.payload as GooglePayInboundMessageMap['challenge'],\n });\n break;\n case 'error': {\n const payload = msg.payload as { code: string; message: string };\n if (payload.code === 'quoteExpired') {\n opts.onEvent?.({ kind: 'quoteExpired', payload: { setQuote } });\n } else if (payload.code === 'googlePayUnavailable') {\n opts.onEvent?.({ kind: 'unsupported' });\n } else {\n const kind =\n payload.code === 'generic'\n ? 'genericError'\n : (payload.code as 'configurationError' | 'invalidQuote' | 'genericError');\n opts.onEvent?.({\n kind: 'error',\n payload: { kind, message: payload.message },\n });\n }\n break;\n }\n }\n });\n\n return ok({\n setQuote,\n dispose: () => {\n handle.dispose();\n removeSlot(slotId);\n },\n });\n } catch (e) {\n return err({\n kind: 'genericError',\n message: e instanceof Error ? e.message : 'Google Pay setup failed',\n });\n }\n }\n\n // ------- setupChallenge -------\n async function setupChallenge(\n opts: SetupChallengeOptions,\n ): Promise<Result<ChallengeFrame, SetupChallengeError>> {\n let channelId: string;\n try {\n channelId = new URL(opts.url).searchParams.get('channelId') ?? '';\n if (!channelId) throw new Error('missing channelId');\n } catch {\n return err({ kind: 'configurationError', message: 'Challenge URL is missing channelId' });\n }\n\n try {\n const { promise } = createManagedFrame({ url: opts.url, channelId, hidden: false });\n const { handle, slotId } = await promise;\n\n handle.onMessage((msg: ProtocolMessage) => {\n switch (msg.kind) {\n case 'ready':\n opts.onEvent?.({ kind: 'ready' });\n break;\n case 'complete':\n opts.onEvent?.({\n kind: 'complete',\n payload: msg.payload as ChallengeCompleteResult,\n });\n break;\n case 'cancelled':\n opts.onEvent?.({\n kind: 'cancelled',\n payload: msg.payload as ChallengeCancellation,\n });\n break;\n case 'error':\n opts.onEvent?.({\n kind: 'error',\n payload: msg.payload as { code: string; message: string },\n });\n break;\n }\n });\n\n return ok({\n dispose: () => {\n handle.dispose();\n removeSlot(slotId);\n },\n });\n } catch (e) {\n return err({\n kind: 'genericError',\n message: e instanceof Error ? e.message : 'Challenge setup failed',\n });\n }\n }\n\n // ------- setupAddCard -------\n async function setupAddCard(\n opts: SetupAddCardOptions,\n ): Promise<Result<AddCardFrame, SetupAddCardError>> {\n const channelId = `add-card-${Date.now()}`;\n\n const url = buildFrameUrl(\n FRAME_PATHS.addCard,\n { channelId, clientToken: core.context.clientToken },\n { frameBaseUrl },\n );\n\n try {\n const { promise } = createManagedFrame({ url, channelId, hidden: false });\n const { handle, slotId } = await promise;\n\n handle.onMessage((msg: ProtocolMessage) => {\n switch (msg.kind) {\n case 'complete':\n opts.onEvent?.({ kind: 'complete', payload: msg.payload as { card: CardResponse } });\n break;\n case 'error':\n opts.onEvent?.({\n kind: 'error',\n payload: msg.payload as {\n code: 'generic' | 'configurationError';\n message: string;\n },\n });\n break;\n }\n });\n\n return ok({\n dispose: () => {\n handle.dispose();\n removeSlot(slotId);\n },\n });\n } catch (e) {\n return err({\n kind: 'genericError',\n message: e instanceof Error ? e.message : 'Add card setup failed',\n });\n }\n }\n\n return {\n getConnection,\n connect,\n getPaymentMethods: () => core.getPaymentMethods(),\n getQuote: (params) => core.getQuote(params),\n listTransactions: (params) => core.listTransactions(params),\n getTransaction: (id) => core.getTransaction(id),\n setupWidget,\n setupApplePay,\n setupBuy,\n setupBuyButton,\n setupGooglePay,\n setupChallenge,\n setupAddCard,\n };\n }, [sessionToken, frameBaseUrl, core, addSlot, removeSlot]);\n\n return (\n <MoonPayContext.Provider value={{ client }}>\n {children}\n {frameSlots.map((slot) => (\n <MoonPayFrame key={slot.id} transport={slot.transport} hidden={slot.hidden} />\n ))}\n </MoonPayContext.Provider>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Hook\n// ---------------------------------------------------------------------------\n\nexport function useMoonPay(): MoonPayContextValue {\n const ctx = useContext(MoonPayContext);\n if (!ctx) {\n throw new Error('useMoonPay must be used within a <MoonPayProvider>');\n }\n return ctx;\n}\n","import type { ProtocolMessage } from '@moonpay/platform-protocol';\nimport type { FrameOptions, FrameTransport } from '@moonpay/platform-sdk-core';\nimport type { RefObject } from 'react';\nimport type WebView from 'react-native-webview';\n\n/**\n * FrameTransport implementation for React Native using react-native-webview.\n *\n * Unlike the web IframeTransport, the WebView is rendered declaratively via\n * React components. This transport bridges the imperative FrameTransport\n * interface to a WebView ref.\n */\nexport class WebViewTransport implements FrameTransport {\n private webViewRef: RefObject<WebView | null> | null = null;\n private handlers: Array<(msg: ProtocolMessage) => void> = [];\n private _url: string = '';\n private _options: FrameOptions | null = null;\n\n /** Called by the frame component when it mounts the WebView. */\n attachWebView(ref: RefObject<WebView | null>): void {\n this.webViewRef = ref;\n }\n\n /** Called by the WebView's onMessage prop to route incoming messages. */\n handleWebViewMessage(data: string): void {\n try {\n const msg: ProtocolMessage = JSON.parse(data);\n if (!msg.kind) return;\n for (const handler of this.handlers) {\n handler(msg);\n }\n } catch {\n // Ignore non-protocol messages\n }\n }\n\n get url(): string {\n return this._url;\n }\n\n get options(): FrameOptions | null {\n return this._options;\n }\n\n // FrameTransport interface\n\n create(url: string, options: FrameOptions): void {\n this._url = url;\n this._options = options;\n // The actual WebView rendering is handled by React components.\n // This method stores the URL and options for the component to read.\n }\n\n sendMessage(message: ProtocolMessage): void {\n if (!this.webViewRef?.current) {\n throw new Error('Cannot send message: WebView not attached');\n }\n const js = `\n window.postMessage(${JSON.stringify(JSON.stringify(message))}, '*');\n true;\n `;\n this.webViewRef.current.injectJavaScript(js);\n }\n\n onMessage(handler: (msg: ProtocolMessage) => void): () => void {\n this.handlers.push(handler);\n return () => {\n const idx = this.handlers.indexOf(handler);\n if (idx >= 0) this.handlers.splice(idx, 1);\n };\n }\n\n dispose(): void {\n this.handlers.length = 0;\n this.webViewRef = null;\n this._url = '';\n this._options = null;\n }\n}\n"],"mappings":";AAAA,SAAS,WAAW,cAAc;AAClC,SAAS,YAA4B;AACrC,OAAO,aAA2C;AAuC5C;AAvBC,SAAS,aAAa,EAAE,WAAW,QAAQ,MAAM,GAA0C;AAChG,QAAM,aAAa,OAAgB,IAAI;AAEvC,YAAU,MAAM;AACd,cAAU,cAAc,UAAU;AAClC,WAAO,MAAM;AAAA,IAEb;AAAA,EACF,GAAG,CAAC,SAAS,CAAC;AAEd,QAAM,MAAM,UAAU;AACtB,MAAI,CAAC;AAAK,WAAO;AAEjB,QAAM,gBAAgB,CAAC,UAA+B;AACpD,cAAU,qBAAqB,MAAM,YAAY,IAAI;AAAA,EACvD;AAEA,QAAM,iBAA4B,SAC9B,EAAE,OAAO,GAAG,QAAQ,GAAG,UAAU,SAAS,IAC1C,EAAE,MAAM,GAAG,GAAG,MAAM;AAExB,SACE,oBAAC,QAAK,OAAO,gBACX;AAAA,IAAC;AAAA;AAAA,MACC,KAAK;AAAA,MACL,QAAQ,EAAE,KAAK,IAAI;AAAA,MACnB,WAAW;AAAA,MACX,2BAAyB;AAAA,MACzB,mBAAiB;AAAA,MACjB,mBAAiB;AAAA,MACjB,OAAO,EAAE,MAAM,EAAE;AAAA;AAAA,EACnB,GACF;AAEJ;;;ACpDA;AAAA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AAW,QAAQ,KAAK,UAAjD,KAAK,EAAoD,CAC7E;AAAA,KACH;AAEJ;AAMO,SAAS,aAAkC;AAChD,QAAM,MAAM,WAAW,cAAc;AACrC,MAAI,CAAC,KAAK;AACR,UAAM,IAAI,MAAM,oDAAoD;AAAA,EACtE;AACA,SAAO;AACT;","names":["useRef","jsx","useRef"]}
|
|
1
|
+
{"version":3,"sources":["../src/frame-component.tsx","../src/provider.tsx","../src/webview-transport.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\nimport { View, type ViewStyle } from 'react-native';\nimport WebView, { type WebViewMessageEvent } from 'react-native-webview';\nimport type { WebViewTransport } from './webview-transport.js';\n\nexport interface MoonPayFrameProps {\n /** The transport instance managing this frame's communication. */\n transport: WebViewTransport;\n /** Whether this is a hidden utility frame (zero height). */\n hidden?: boolean;\n /** Optional style overrides for the container view. */\n style?: ViewStyle;\n}\n\n/**\n * Reusable React Native component that renders a MoonPay frame as a WebView.\n * Bridges the WebViewTransport to the actual WebView instance.\n */\nexport function MoonPayFrame({ transport, hidden, style }: MoonPayFrameProps): JSX.Element | null {\n const webViewRef = useRef<WebView>(null);\n\n useEffect(() => {\n transport.attachWebView(webViewRef);\n return () => {\n // Don't dispose — the orchestrator manages lifecycle\n };\n }, [transport]);\n\n const url = transport.url;\n if (!url) return null;\n\n const handleMessage = (event: WebViewMessageEvent) => {\n transport.handleWebViewMessage(event.nativeEvent.data);\n };\n\n const containerStyle: ViewStyle = hidden\n ? { width: 0, height: 0, overflow: 'hidden' }\n : { flex: 1, ...style };\n\n return (\n <View style={containerStyle}>\n <WebView\n ref={webViewRef}\n source={{ uri: url }}\n onMessage={handleMessage}\n allowsInlineMediaPlayback\n javaScriptEnabled\n domStorageEnabled\n style={{ flex: 1 }}\n />\n </View>\n );\n}\n","import {\n type AddCardEvent,\n type ApplePayEvent,\n type BuyButtonEvent,\n type BuyEvent,\n type CardResponse,\n type ChallengeCancellation,\n type ChallengeCompleteResult,\n type ChallengeEvent,\n type ConnectError,\n type ConnectEvent,\n type Connection,\n ConnectionStatus,\n type CreateIdentityError,\n type CreateIdentityRequestBody,\n err,\n type GetConnectionError,\n type GetIdentityError,\n type GetIdentityUploadUrlError,\n type GetPaymentMethodsError,\n type GetQuoteError,\n type GetQuoteParams,\n type GetTransactionsError,\n type GooglePayEvent,\n type GooglePayInboundMessageMap,\n type Identity,\n type IdentityFileUploadUrl,\n type IdentityFileUploadUrlRequestBody,\n type IdentityVerificationResponse,\n type ListPaymentMethodsResponse,\n ok,\n type PaginationInfo,\n type ProtocolMessage,\n type Quote,\n type Result,\n type SetupAddCardError,\n type SetupApplePayError,\n type SetupBuyButtonError,\n type SetupBuyError,\n type SetupChallengeError,\n type SetupGooglePayError,\n type SetupWidgetError,\n type SubmitIdentityFilesError,\n type SubmitIdentityFilesRequestBody,\n type Transaction,\n type TransactionWithStages,\n type UpdateIdentityError,\n type UpdateIdentityRequestBody,\n type VerifyIdentityError,\n type WidgetEvent,\n} from '@moonpay/platform-protocol';\nimport {\n buildFrameUrl,\n type CoreClient,\n createClientCore,\n createFrameOrchestrator,\n decryptCredentials,\n FRAME_PATHS,\n type FrameHandle,\n generateKeyPair,\n type ListTransactionsParams,\n} from '@moonpay/platform-sdk-core';\nimport {\n createContext,\n type ReactNode,\n useCallback,\n useContext,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { MoonPayFrame } from './frame-component.js';\nimport { WebViewTransport } from './webview-transport.js';\n\n// ---------------------------------------------------------------------------\n// Frame slot — represents a frame the provider needs to render\n// ---------------------------------------------------------------------------\n\ninterface FrameSlot {\n id: string;\n transport: WebViewTransport;\n hidden: boolean;\n}\n\n// ---------------------------------------------------------------------------\n// Public types\n// ---------------------------------------------------------------------------\n\nexport interface ConnectOptions {\n /** Theme options for the connect frame. */\n theme?: { appearance?: 'light' | 'dark' };\n /** Callback for connect lifecycle events. */\n onEvent?: (event: ConnectEvent) => void;\n}\n\nexport interface ConnectFrame {\n dispose(): void;\n}\n\nexport interface SetupWidgetOptions {\n /** Quote signature from getQuote(). */\n quote: string;\n /** Callback for widget lifecycle events. */\n onEvent?: (event: WidgetEvent) => void;\n}\n\nexport interface WidgetFrame {\n dispose(): void;\n}\n\nexport interface SetupApplePayOptions {\n /** Quote signature from getQuote(). */\n quote: string;\n /** Callback for Apple Pay lifecycle events. */\n onEvent?: (event: ApplePayEvent) => void;\n}\n\nexport interface ApplePayFrame {\n /** Update the quote (e.g., after expiry). */\n setQuote(signature: string): void;\n dispose(): void;\n}\n\nexport interface SetupBuyOptions {\n /** Quote signature from getQuote(). */\n quote: string;\n /** Partner-assigned identifier for this transaction attempt. */\n externalTransactionId?: string;\n /** Callback for buy frame lifecycle events. */\n onEvent?: (event: BuyEvent) => void;\n}\n\nexport interface BuyFrame {\n /** Update the quote (e.g., after expiry). */\n setQuote(signature: string): void;\n dispose(): void;\n}\n\nexport interface SetupBuyButtonOptions {\n /** Quote signature from getQuote(). */\n quote: string;\n /** Callback for buy-button frame lifecycle events. */\n onEvent?: (event: BuyButtonEvent) => void;\n}\n\nexport interface BuyButtonFrame {\n /** Update the quote (e.g., after expiry). */\n setQuote(signature: string): void;\n dispose(): void;\n}\n\nexport interface SetupGooglePayOptions {\n /** Quote signature from getQuote(). */\n quote: string;\n /** Partner-assigned identifier for this transaction attempt. */\n externalTransactionId?: string;\n /** Callback for Google Pay lifecycle events. */\n onEvent?: (event: GooglePayEvent) => void;\n}\n\nexport interface GooglePayFrame {\n /** Update the quote (e.g., after expiry). */\n setQuote(signature: string): void;\n dispose(): void;\n}\n\nexport interface SetupChallengeOptions {\n /** Full challenge URL received from a frame's `challenge` event. */\n url: string;\n /** Callback for challenge frame lifecycle events. */\n onEvent?: (event: ChallengeEvent) => void;\n}\n\nexport interface ChallengeFrame {\n dispose(): void;\n}\n\nexport interface SetupAddCardOptions {\n /** Callback for add-card frame lifecycle events. */\n onEvent?: (event: AddCardEvent) => void;\n}\n\nexport interface AddCardFrame {\n dispose(): void;\n}\n\nexport interface RNClient {\n getConnection(): Promise<Result<Connection, GetConnectionError>>;\n connect(options: ConnectOptions): Promise<Result<ConnectFrame, ConnectError>>;\n getPaymentMethods(): Promise<Result<ListPaymentMethodsResponse, GetPaymentMethodsError>>;\n getQuote(params: GetQuoteParams): Promise<Result<{ data: Quote }, GetQuoteError>>;\n listTransactions(\n params?: ListTransactionsParams,\n ): Promise<Result<{ data: Transaction[]; pageInfo: PaginationInfo }, GetTransactionsError>>;\n getTransaction(\n id: string,\n ): Promise<Result<{ data: TransactionWithStages }, GetTransactionsError>>;\n setupWidget(options: SetupWidgetOptions): Promise<Result<WidgetFrame, SetupWidgetError>>;\n setupApplePay(options: SetupApplePayOptions): Promise<Result<ApplePayFrame, SetupApplePayError>>;\n setupBuy(options: SetupBuyOptions): Promise<Result<BuyFrame, SetupBuyError>>;\n setupBuyButton(\n options: SetupBuyButtonOptions,\n ): Promise<Result<BuyButtonFrame, SetupBuyButtonError>>;\n setupGooglePay(\n options: SetupGooglePayOptions,\n ): Promise<Result<GooglePayFrame, SetupGooglePayError>>;\n setupChallenge(\n options: SetupChallengeOptions,\n ): Promise<Result<ChallengeFrame, SetupChallengeError>>;\n setupAddCard(options: SetupAddCardOptions): Promise<Result<AddCardFrame, SetupAddCardError>>;\n\n // Identity API\n createIdentity(\n body: CreateIdentityRequestBody,\n ): Promise<Result<{ data: Identity | null }, CreateIdentityError>>;\n getIdentity(id: string): Promise<Result<{ data: Identity }, GetIdentityError>>;\n updateIdentity(\n id: string,\n body: UpdateIdentityRequestBody,\n ): Promise<Result<{ data: Identity }, UpdateIdentityError>>;\n verifyIdentity(\n id: string,\n ): Promise<Result<{ data: IdentityVerificationResponse }, VerifyIdentityError>>;\n getIdentityUploadUrl(\n id: string,\n body: IdentityFileUploadUrlRequestBody,\n ): Promise<Result<{ data: IdentityFileUploadUrl }, GetIdentityUploadUrlError>>;\n submitIdentityFiles(\n id: string,\n body: SubmitIdentityFilesRequestBody,\n ): Promise<Result<{ data: Identity }, SubmitIdentityFilesError>>;\n}\n\n// ---------------------------------------------------------------------------\n// Context\n// ---------------------------------------------------------------------------\n\ninterface MoonPayContextValue {\n client: RNClient;\n}\n\nconst MoonPayContext = createContext<MoonPayContextValue | null>(null);\n\n// ---------------------------------------------------------------------------\n// Provider\n// ---------------------------------------------------------------------------\n\nexport interface MoonPayProviderProps {\n sessionToken: string;\n apiBaseUrl?: string;\n frameBaseUrl?: string;\n children: ReactNode;\n}\n\nlet slotCounter = 0;\n\nexport function MoonPayProvider({\n sessionToken,\n apiBaseUrl,\n frameBaseUrl,\n children,\n}: MoonPayProviderProps): JSX.Element {\n const [frameSlots, setFrameSlots] = useState<FrameSlot[]>([]);\n\n // Stable refs for addSlot/removeSlot so client methods don't re-create\n const addSlot = useCallback((slot: FrameSlot) => {\n setFrameSlots((prev) => [...prev, slot]);\n }, []);\n\n const removeSlot = useCallback((id: string) => {\n setFrameSlots((prev) => prev.filter((s) => s.id !== id));\n }, []);\n\n // Keep a ref to core so it's stable across renders\n const coreRef = useRef<CoreClient | null>(null);\n if (!coreRef.current) {\n coreRef.current = createClientCore({\n apiBaseUrl,\n frameBaseUrl,\n createTransport: () => new WebViewTransport(),\n });\n }\n const core = coreRef.current;\n\n const client = useMemo<RNClient>(() => {\n // Helper: create a transport + slot, wait for orchestrator handshake\n function createManagedFrame(opts: {\n url: string;\n channelId: string;\n hidden: boolean;\n handshakeTimeout?: number;\n }): { promise: Promise<{ handle: FrameHandle; slotId: string }>; transport: WebViewTransport } {\n const transport = new WebViewTransport();\n const slotId = `slot-${++slotCounter}`;\n\n const promise = new Promise<{ handle: FrameHandle; slotId: string }>((resolve, reject) => {\n // Defer adding the slot to allow the transport to be fully set up\n // before the WebView renders\n transport.create(opts.url, { container: null, hidden: opts.hidden });\n\n addSlot({ id: slotId, transport, hidden: opts.hidden });\n\n createFrameOrchestrator({\n transport,\n channelId: opts.channelId,\n url: opts.url,\n container: null,\n hidden: opts.hidden,\n handshakeTimeout: opts.handshakeTimeout ?? 15_000,\n })\n .then((handle) => resolve({ handle, slotId }))\n .catch((e) => {\n removeSlot(slotId);\n reject(e);\n });\n });\n\n return { promise, transport };\n }\n\n // ------- getConnection (hidden frame) -------\n async function getConnection(): Promise<Result<Connection, GetConnectionError>> {\n const { privateKey, publicKey } = generateKeyPair();\n const channelId = `check-${Date.now()}`;\n\n const url = buildFrameUrl(\n FRAME_PATHS.checkConnection,\n { sessionToken, channelId, publicKey },\n { frameBaseUrl },\n );\n\n try {\n const { promise } = createManagedFrame({\n url,\n channelId,\n hidden: true,\n handshakeTimeout: 10_000,\n });\n\n const { handle, slotId } = await promise;\n\n return new Promise<Result<Connection, GetConnectionError>>((resolve) => {\n const timeout = setTimeout(() => {\n handle.dispose();\n removeSlot(slotId);\n resolve(err({ message: 'Get connection timed out' }));\n }, 10_000);\n\n handle.onMessage((msg: ProtocolMessage) => {\n if (msg.kind === 'error') {\n clearTimeout(timeout);\n handle.dispose();\n removeSlot(slotId);\n const payload = msg.payload as { message: string };\n resolve(err({ message: payload.message }));\n return;\n }\n\n if (msg.kind === 'complete') {\n clearTimeout(timeout);\n handle.dispose();\n removeSlot(slotId);\n const connection = msg.payload as Connection;\n\n if (connection.status === ConnectionStatus.active) {\n const creds = decryptCredentials(connection.credentials, privateKey);\n core.context.setAccessToken(creds.accessToken);\n core.context.setClientToken(creds.clientToken);\n }\n\n resolve(ok(connection));\n }\n });\n });\n } catch (e) {\n return err({\n message: e instanceof Error ? e.message : 'Failed to check connection',\n });\n }\n }\n\n // ------- connect (visible frame) -------\n async function connect(opts: ConnectOptions): Promise<Result<ConnectFrame, ConnectError>> {\n const { privateKey, publicKey } = generateKeyPair();\n const channelId = `connect-${Date.now()}`;\n\n const url = buildFrameUrl(\n FRAME_PATHS.connect,\n {\n sessionToken,\n channelId,\n publicKey,\n ...(opts.theme?.appearance && { appearance: opts.theme.appearance }),\n },\n { frameBaseUrl },\n );\n\n try {\n const { promise } = createManagedFrame({ url, channelId, hidden: false });\n const { handle, slotId } = await promise;\n\n return new Promise<Result<ConnectFrame, ConnectError>>((resolve) => {\n handle.onMessage((msg: ProtocolMessage) => {\n if (msg.kind === 'ready') {\n opts.onEvent?.({ kind: 'ready' });\n return;\n }\n\n if (msg.kind === 'error') {\n const payload = msg.payload as import('@moonpay/platform-protocol').ConnectionError;\n opts.onEvent?.({ kind: 'error', payload });\n handle.dispose();\n removeSlot(slotId);\n resolve(err({ message: 'Connection error' }));\n return;\n }\n\n if (msg.kind === 'complete') {\n const connection = msg.payload as Connection;\n\n if (connection.status === ConnectionStatus.active) {\n const creds = decryptCredentials(connection.credentials, privateKey);\n core.context.setAccessToken(creds.accessToken);\n core.context.setClientToken(creds.clientToken);\n }\n\n opts.onEvent?.({ kind: 'complete', payload: connection });\n resolve(\n ok({\n dispose: () => {\n handle.dispose();\n removeSlot(slotId);\n },\n }),\n );\n }\n });\n });\n } catch (e) {\n return err({\n message: e instanceof Error ? e.message : 'Connect failed',\n });\n }\n }\n\n // ------- setupWidget -------\n async function setupWidget(\n opts: SetupWidgetOptions,\n ): Promise<Result<WidgetFrame, SetupWidgetError>> {\n const channelId = `widget-${Date.now()}`;\n\n const url = buildFrameUrl(\n FRAME_PATHS.widget,\n {\n flow: 'buy',\n clientToken: core.context.clientToken,\n quoteSignature: opts.quote,\n channelId,\n },\n { frameBaseUrl },\n );\n\n try {\n const { promise } = createManagedFrame({ url, channelId, hidden: false });\n const { handle, slotId } = await promise;\n\n handle.onMessage((msg: ProtocolMessage) => {\n switch (msg.kind) {\n case 'ready':\n opts.onEvent?.({ kind: 'ready' });\n break;\n case 'transactionCreated':\n opts.onEvent?.({\n kind: 'transactionCreated',\n payload: msg.payload as { transaction: { id: string; status: string } },\n });\n break;\n case 'complete':\n opts.onEvent?.({\n kind: 'complete',\n payload: msg.payload as {\n transaction: import('@moonpay/platform-protocol').FrameTransaction;\n },\n });\n break;\n case 'error': {\n const payload = msg.payload as {\n code: 'configurationError' | 'apiError' | 'generic';\n message: string;\n };\n opts.onEvent?.({\n kind: 'error',\n payload: { code: payload.code, message: payload.message },\n });\n break;\n }\n case 'close':\n opts.onEvent?.({ kind: 'close' });\n break;\n }\n });\n\n return ok({\n dispose: () => {\n handle.dispose();\n removeSlot(slotId);\n },\n });\n } catch (e) {\n return err({\n kind: 'genericError',\n message: e instanceof Error ? e.message : 'Widget setup failed',\n });\n }\n }\n\n // ------- setupApplePay -------\n async function setupApplePay(\n opts: SetupApplePayOptions,\n ): Promise<Result<ApplePayFrame, SetupApplePayError>> {\n const channelId = `applepay-${Date.now()}`;\n\n const url = buildFrameUrl(\n FRAME_PATHS.applePay,\n {\n clientToken: core.context.clientToken,\n signature: opts.quote,\n channelId,\n },\n { frameBaseUrl },\n );\n\n try {\n const { promise } = createManagedFrame({ url, channelId, hidden: false });\n const { handle, slotId } = await promise;\n\n const setQuote = (signature: string) => {\n handle.sendMessage({\n version: 2,\n meta: { channelId },\n kind: 'setQuote',\n payload: { quote: { signature } },\n });\n };\n\n handle.onMessage((msg: ProtocolMessage) => {\n switch (msg.kind) {\n case 'ready':\n opts.onEvent?.({ kind: 'ready' });\n break;\n case 'complete':\n opts.onEvent?.({\n kind: 'complete',\n payload: msg.payload as {\n transaction: import('@moonpay/platform-protocol').FrameTransaction;\n },\n });\n break;\n case 'error': {\n const payload = msg.payload as { code: string; message: string };\n if (payload.code === 'quoteExpired') {\n opts.onEvent?.({ kind: 'quoteExpired', payload: { setQuote } });\n } else if (payload.code === 'applePayUnavailable') {\n opts.onEvent?.({ kind: 'unsupported' });\n } else {\n const kind =\n payload.code === 'generic'\n ? 'genericError'\n : (payload.code as\n | 'configurationError'\n | 'invalidQuote'\n | 'oneTapApplePaySecondFactorRequired'\n | 'genericError');\n opts.onEvent?.({\n kind: 'error',\n payload: { kind, message: payload.message },\n });\n }\n break;\n }\n }\n });\n\n return ok({\n setQuote,\n dispose: () => {\n handle.dispose();\n removeSlot(slotId);\n },\n });\n } catch (e) {\n return err({\n kind: 'genericError',\n message: e instanceof Error ? e.message : 'Apple Pay setup failed',\n });\n }\n }\n\n // ------- setupBuy (hidden frame) -------\n async function setupBuy(opts: SetupBuyOptions): Promise<Result<BuyFrame, SetupBuyError>> {\n const channelId = `buy-${Date.now()}`;\n\n const url = buildFrameUrl(\n FRAME_PATHS.buy,\n {\n channelId,\n clientToken: core.context.clientToken,\n signature: opts.quote,\n ...(opts.externalTransactionId && { externalTransactionId: opts.externalTransactionId }),\n },\n { frameBaseUrl },\n );\n\n try {\n const { promise } = createManagedFrame({ url, channelId, hidden: true });\n const { handle, slotId } = await promise;\n\n const setQuote = (signature: string) => {\n handle.sendMessage({\n version: 2,\n meta: { channelId },\n kind: 'setQuote',\n payload: { quote: { signature } },\n });\n };\n\n handle.onMessage((msg: ProtocolMessage) => {\n switch (msg.kind) {\n case 'ready':\n opts.onEvent?.({ kind: 'ready' });\n break;\n case 'complete':\n opts.onEvent?.({\n kind: 'complete',\n payload: msg.payload as {\n transaction: import('@moonpay/platform-protocol').FrameTransaction;\n },\n });\n break;\n case 'challenge':\n opts.onEvent?.({\n kind: 'challenge',\n payload: msg.payload as { kind: string; url: string },\n });\n break;\n case 'error':\n opts.onEvent?.({\n kind: 'error',\n payload: msg.payload as { code: string; message: string },\n });\n break;\n }\n });\n\n return ok({\n setQuote,\n dispose: () => {\n handle.dispose();\n removeSlot(slotId);\n },\n });\n } catch (e) {\n return err({\n kind: 'genericError',\n message: e instanceof Error ? e.message : 'Buy setup failed',\n });\n }\n }\n\n // ------- setupBuyButton -------\n async function setupBuyButton(\n opts: SetupBuyButtonOptions,\n ): Promise<Result<BuyButtonFrame, SetupBuyButtonError>> {\n const channelId = `buy-button-${Date.now()}`;\n\n const url = buildFrameUrl(\n FRAME_PATHS.buyButton,\n {\n channelId,\n clientToken: core.context.clientToken,\n signature: opts.quote,\n },\n { frameBaseUrl },\n );\n\n try {\n const { promise } = createManagedFrame({ url, channelId, hidden: false });\n const { handle, slotId } = await promise;\n\n const setQuote = (signature: string) => {\n handle.sendMessage({\n version: 2,\n meta: { channelId },\n kind: 'setQuote',\n payload: { quote: { signature } },\n });\n };\n\n handle.onMessage((msg: ProtocolMessage) => {\n switch (msg.kind) {\n case 'complete':\n opts.onEvent?.({\n kind: 'complete',\n payload: msg.payload as {\n transaction: import('@moonpay/platform-protocol').FrameTransaction;\n },\n });\n break;\n case 'challenge':\n opts.onEvent?.({\n kind: 'challenge',\n payload: msg.payload as { kind: string; url: string },\n });\n break;\n case 'error':\n opts.onEvent?.({\n kind: 'error',\n payload: msg.payload as { code: string; message: string },\n });\n break;\n }\n });\n\n return ok({\n setQuote,\n dispose: () => {\n handle.dispose();\n removeSlot(slotId);\n },\n });\n } catch (e) {\n return err({\n kind: 'genericError',\n message: e instanceof Error ? e.message : 'Buy button setup failed',\n });\n }\n }\n\n // ------- setupGooglePay -------\n async function setupGooglePay(\n opts: SetupGooglePayOptions,\n ): Promise<Result<GooglePayFrame, SetupGooglePayError>> {\n const channelId = `googlepay-${Date.now()}`;\n\n const url = buildFrameUrl(\n FRAME_PATHS.googlePay,\n {\n clientToken: core.context.clientToken,\n signature: opts.quote,\n channelId,\n ...(opts.externalTransactionId && { externalTransactionId: opts.externalTransactionId }),\n },\n { frameBaseUrl },\n );\n\n try {\n const { promise } = createManagedFrame({ url, channelId, hidden: false });\n const { handle, slotId } = await promise;\n\n const setQuote = (signature: string) => {\n handle.sendMessage({\n version: 2,\n meta: { channelId },\n kind: 'setQuote',\n payload: { quote: { signature } },\n });\n };\n\n handle.onMessage((msg: ProtocolMessage) => {\n switch (msg.kind) {\n case 'ready':\n opts.onEvent?.({ kind: 'ready' });\n break;\n case 'complete':\n opts.onEvent?.({\n kind: 'complete',\n payload: msg.payload as {\n transaction: import('@moonpay/platform-protocol').FrameTransaction;\n },\n });\n break;\n case 'challenge':\n opts.onEvent?.({\n kind: 'challenge',\n payload: msg.payload as GooglePayInboundMessageMap['challenge'],\n });\n break;\n case 'error': {\n const payload = msg.payload as { code: string; message: string };\n if (payload.code === 'quoteExpired') {\n opts.onEvent?.({ kind: 'quoteExpired', payload: { setQuote } });\n } else if (payload.code === 'googlePayUnavailable') {\n opts.onEvent?.({ kind: 'unsupported' });\n } else {\n const kind =\n payload.code === 'generic'\n ? 'genericError'\n : (payload.code as 'configurationError' | 'invalidQuote' | 'genericError');\n opts.onEvent?.({\n kind: 'error',\n payload: { kind, message: payload.message },\n });\n }\n break;\n }\n }\n });\n\n return ok({\n setQuote,\n dispose: () => {\n handle.dispose();\n removeSlot(slotId);\n },\n });\n } catch (e) {\n return err({\n kind: 'genericError',\n message: e instanceof Error ? e.message : 'Google Pay setup failed',\n });\n }\n }\n\n // ------- setupChallenge -------\n async function setupChallenge(\n opts: SetupChallengeOptions,\n ): Promise<Result<ChallengeFrame, SetupChallengeError>> {\n let channelId: string;\n try {\n channelId = new URL(opts.url).searchParams.get('channelId') ?? '';\n if (!channelId) throw new Error('missing channelId');\n } catch {\n return err({ kind: 'configurationError', message: 'Challenge URL is missing channelId' });\n }\n\n try {\n const { promise } = createManagedFrame({ url: opts.url, channelId, hidden: false });\n const { handle, slotId } = await promise;\n\n handle.onMessage((msg: ProtocolMessage) => {\n switch (msg.kind) {\n case 'ready':\n opts.onEvent?.({ kind: 'ready' });\n break;\n case 'complete':\n opts.onEvent?.({\n kind: 'complete',\n payload: msg.payload as ChallengeCompleteResult,\n });\n break;\n case 'cancelled':\n opts.onEvent?.({\n kind: 'cancelled',\n payload: msg.payload as ChallengeCancellation,\n });\n break;\n case 'error':\n opts.onEvent?.({\n kind: 'error',\n payload: msg.payload as { code: string; message: string },\n });\n break;\n }\n });\n\n return ok({\n dispose: () => {\n handle.dispose();\n removeSlot(slotId);\n },\n });\n } catch (e) {\n return err({\n kind: 'genericError',\n message: e instanceof Error ? e.message : 'Challenge setup failed',\n });\n }\n }\n\n // ------- setupAddCard -------\n async function setupAddCard(\n opts: SetupAddCardOptions,\n ): Promise<Result<AddCardFrame, SetupAddCardError>> {\n const channelId = `add-card-${Date.now()}`;\n\n const url = buildFrameUrl(\n FRAME_PATHS.addCard,\n { channelId, clientToken: core.context.clientToken },\n { frameBaseUrl },\n );\n\n try {\n const { promise } = createManagedFrame({ url, channelId, hidden: false });\n const { handle, slotId } = await promise;\n\n handle.onMessage((msg: ProtocolMessage) => {\n switch (msg.kind) {\n case 'complete':\n opts.onEvent?.({ kind: 'complete', payload: msg.payload as { card: CardResponse } });\n break;\n case 'error':\n opts.onEvent?.({\n kind: 'error',\n payload: msg.payload as {\n code: 'generic' | 'configurationError';\n message: string;\n },\n });\n break;\n }\n });\n\n return ok({\n dispose: () => {\n handle.dispose();\n removeSlot(slotId);\n },\n });\n } catch (e) {\n return err({\n kind: 'genericError',\n message: e instanceof Error ? e.message : 'Add card setup failed',\n });\n }\n }\n\n return {\n getConnection,\n connect,\n getPaymentMethods: () => core.getPaymentMethods(),\n getQuote: (params) => core.getQuote(params),\n listTransactions: (params) => core.listTransactions(params),\n getTransaction: (id) => core.getTransaction(id),\n setupWidget,\n setupApplePay,\n setupBuy,\n setupBuyButton,\n setupGooglePay,\n setupChallenge,\n setupAddCard,\n\n createIdentity: (body) => core.createIdentity(body),\n getIdentity: (id) => core.getIdentity(id),\n updateIdentity: (id, body) => core.updateIdentity(id, body),\n verifyIdentity: (id) => core.verifyIdentity(id),\n getIdentityUploadUrl: (id, body) => core.getIdentityUploadUrl(id, body),\n submitIdentityFiles: (id, body) => core.submitIdentityFiles(id, body),\n };\n }, [sessionToken, frameBaseUrl, core, addSlot, removeSlot]);\n\n return (\n <MoonPayContext.Provider value={{ client }}>\n {children}\n {frameSlots.map((slot) => (\n <MoonPayFrame key={slot.id} transport={slot.transport} hidden={slot.hidden} />\n ))}\n </MoonPayContext.Provider>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Hook\n// ---------------------------------------------------------------------------\n\nexport function useMoonPay(): MoonPayContextValue {\n const ctx = useContext(MoonPayContext);\n if (!ctx) {\n throw new Error('useMoonPay must be used within a <MoonPayProvider>');\n }\n return ctx;\n}\n","import type { ProtocolMessage } from '@moonpay/platform-protocol';\nimport type { FrameOptions, FrameTransport } from '@moonpay/platform-sdk-core';\nimport type { RefObject } from 'react';\nimport type WebView from 'react-native-webview';\n\n/**\n * FrameTransport implementation for React Native using react-native-webview.\n *\n * Unlike the web IframeTransport, the WebView is rendered declaratively via\n * React components. This transport bridges the imperative FrameTransport\n * interface to a WebView ref.\n */\nexport class WebViewTransport implements FrameTransport {\n private webViewRef: RefObject<WebView | null> | null = null;\n private handlers: Array<(msg: ProtocolMessage) => void> = [];\n private _url: string = '';\n private _options: FrameOptions | null = null;\n\n /** Called by the frame component when it mounts the WebView. */\n attachWebView(ref: RefObject<WebView | null>): void {\n this.webViewRef = ref;\n }\n\n /** Called by the WebView's onMessage prop to route incoming messages. */\n handleWebViewMessage(data: string): void {\n try {\n const msg: ProtocolMessage = JSON.parse(data);\n if (!msg.kind) return;\n for (const handler of this.handlers) {\n handler(msg);\n }\n } catch {\n // Ignore non-protocol messages\n }\n }\n\n get url(): string {\n return this._url;\n }\n\n get options(): FrameOptions | null {\n return this._options;\n }\n\n // FrameTransport interface\n\n create(url: string, options: FrameOptions): void {\n this._url = url;\n this._options = options;\n // The actual WebView rendering is handled by React components.\n // This method stores the URL and options for the component to read.\n }\n\n sendMessage(message: ProtocolMessage): void {\n if (!this.webViewRef?.current) {\n throw new Error('Cannot send message: WebView not attached');\n }\n const js = `\n window.postMessage(${JSON.stringify(JSON.stringify(message))}, '*');\n true;\n `;\n this.webViewRef.current.injectJavaScript(js);\n }\n\n onMessage(handler: (msg: ProtocolMessage) => void): () => void {\n this.handlers.push(handler);\n return () => {\n const idx = this.handlers.indexOf(handler);\n if (idx >= 0) this.handlers.splice(idx, 1);\n };\n }\n\n dispose(): void {\n this.handlers.length = 0;\n this.webViewRef = null;\n this._url = '';\n this._options = null;\n }\n}\n"],"mappings":";AAAA,SAAS,WAAW,cAAc;AAClC,SAAS,YAA4B;AACrC,OAAO,aAA2C;AAuC5C;AAvBC,SAAS,aAAa,EAAE,WAAW,QAAQ,MAAM,GAA0C;AA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ED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moonpay/platform-sdk-react-native",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0-next.0",
|
|
4
4
|
"description": "MoonPay Developer Platform SDK for React Native",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"clean": "rm -rf dist"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@moonpay/platform-protocol": "0.
|
|
32
|
-
"@moonpay/platform-sdk-core": "0.
|
|
31
|
+
"@moonpay/platform-protocol": "0.3.0-next.0",
|
|
32
|
+
"@moonpay/platform-sdk-core": "0.3.0-next.0"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"react": "18.2.0",
|