@moonpay/platform-sdk-web 0.0.0 → 0.2.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.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/client.ts","../src/iframe-transport.ts"],"sourcesContent":["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 ResetConnectionError,\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 generateKeyPair,\n type ListTransactionsParams,\n} from '@moonpay/platform-sdk-core';\nimport { IframeTransport } from './iframe-transport.js';\n\n// ---------------------------------------------------------------------------\n// Public types\n// ---------------------------------------------------------------------------\n\nexport interface CreateClientOptions {\n /** Session token from your server (via createSession). */\n sessionToken: string;\n /** Override the API base URL. Defaults to production. */\n apiBaseUrl?: string;\n /** Override the frame base URL. Defaults to production. */\n frameBaseUrl?: string;\n}\n\nexport interface ConnectOptions {\n /** DOM element to render the connect frame into. */\n container: HTMLElement;\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 /** DOM element to render the widget into. */\n container: HTMLElement;\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 /** DOM element to render the Apple Pay button into. */\n container: HTMLElement;\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 SetupGooglePayOptions {\n /** Quote signature from getQuote(). */\n quote: string;\n /** DOM element to render the Google Pay button into. */\n container: HTMLElement;\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 SetupBuyOptions {\n /** Quote signature from getQuote(). */\n quote: string;\n /** DOM element to attach the hidden buy frame to. */\n container: HTMLElement;\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 /** DOM element to render the buy button into. */\n container: HTMLElement;\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 SetupChallengeOptions {\n /** Full challenge URL received from the buy or buy-button frame's `challenge` event. */\n url: string;\n /** DOM element to render the challenge frame into. */\n container: HTMLElement;\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 /** DOM element to render the add-card frame into. */\n container: HTMLElement;\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 Client {\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 setupGooglePay(\n options: SetupGooglePayOptions,\n ): Promise<Result<GooglePayFrame, SetupGooglePayError>>;\n deletePaymentMethod(\n id: string,\n ): Promise<Result<void, import('@moonpay/platform-protocol').DevPlatformApiError>>;\n /**\n * Clears the customer's MoonPay connection for this partner by running the\n * reset frame. Resolves when the reset completes or times out (5s).\n * Call this after clearing your own local auth state (the client reference\n * can be captured before disposal since the session token is baked in).\n */\n resetConnection(): Promise<Result<void, ResetConnectionError>>;\n setupBuy(options: SetupBuyOptions): Promise<Result<BuyFrame, SetupBuyError>>;\n setupBuyButton(\n options: SetupBuyButtonOptions,\n ): Promise<Result<BuyButtonFrame, SetupBuyButtonError>>;\n setupChallenge(\n options: SetupChallengeOptions,\n ): Promise<Result<ChallengeFrame, SetupChallengeError>>;\n setupAddCard(options: SetupAddCardOptions): Promise<Result<AddCardFrame, SetupAddCardError>>;\n}\n\n// ---------------------------------------------------------------------------\n// createClient\n// ---------------------------------------------------------------------------\n\nexport function createClient(options: CreateClientOptions): Client {\n const { sessionToken, apiBaseUrl, frameBaseUrl } = options;\n\n const core: CoreClient = createClientCore({\n apiBaseUrl,\n frameBaseUrl,\n createTransport: () => new IframeTransport(),\n });\n\n // ------- getConnection (hidden iframe) -------\n async function getConnection(): Promise<Result<Connection, GetConnectionError>> {\n const { privateKey, publicKey } = generateKeyPair();\n const channelId = `check-${crypto.randomUUID()}`;\n\n const url = buildFrameUrl(\n FRAME_PATHS.checkConnection,\n { sessionToken, channelId, publicKey },\n { frameBaseUrl },\n );\n\n const transport = core.createTransport();\n\n try {\n const handle = await createFrameOrchestrator({\n transport,\n channelId,\n url,\n container: document.body,\n hidden: true,\n handshakeTimeout: 10_000,\n });\n\n return new Promise<Result<Connection, GetConnectionError>>((resolve) => {\n const timeout = setTimeout(() => {\n handle.dispose();\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 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 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 } else if (connection.status === ConnectionStatus.connectionRequired) {\n // Decrypt anonymous tokens so the client token is ready for\n // 1-tap Apple Pay (oneTapApplePay in capabilities) without\n // requiring a full connect flow first.\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 connect',\n });\n }\n }\n\n // ------- connect (visible iframe) -------\n async function connect(opts: ConnectOptions): Promise<Result<ConnectFrame, ConnectError>> {\n const { privateKey, publicKey } = generateKeyPair();\n const channelId = `connect-${crypto.randomUUID()}`;\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 const transport = core.createTransport();\n\n try {\n const handle = await createFrameOrchestrator({\n transport,\n channelId,\n url,\n container: opts.container,\n });\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 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(ok({ dispose: () => handle.dispose() }));\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-${crypto.randomUUID()}`;\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 const transport = core.createTransport();\n\n try {\n const handle = await createFrameOrchestrator({\n transport,\n channelId,\n url,\n container: opts.container,\n });\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: {\n code: payload.code,\n message: payload.message,\n },\n });\n break;\n }\n case 'close':\n opts.onEvent?.({ kind: 'close' });\n break;\n }\n });\n\n return ok({ dispose: () => handle.dispose() });\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-${crypto.randomUUID()}`;\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 const transport = core.createTransport();\n\n try {\n const handle = await createFrameOrchestrator({\n transport,\n channelId,\n url,\n container: opts.container,\n });\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 {\n code: string;\n message: string;\n };\n if (payload.code === 'quoteExpired') {\n opts.onEvent?.({\n kind: 'quoteExpired',\n payload: { setQuote },\n });\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({ setQuote, dispose: () => handle.dispose() });\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 // ------- setupGooglePay -------\n async function setupGooglePay(\n opts: SetupGooglePayOptions,\n ): Promise<Result<GooglePayFrame, SetupGooglePayError>> {\n const channelId = `googlepay-${crypto.randomUUID()}`;\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 const transport = core.createTransport();\n\n try {\n const handle = await createFrameOrchestrator({\n transport,\n channelId,\n url,\n container: opts.container,\n });\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 {\n code: string;\n message: string;\n };\n if (payload.code === 'quoteExpired') {\n opts.onEvent?.({\n kind: 'quoteExpired',\n payload: { setQuote },\n });\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({ setQuote, dispose: () => handle.dispose() });\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 // ------- resetConnection -------\n async function resetConnection(): Promise<Result<void, ResetConnectionError>> {\n const channelId = `reset-${crypto.randomUUID()}`;\n const url = buildFrameUrl(FRAME_PATHS.reset, { sessionToken, channelId }, { frameBaseUrl });\n const transport = core.createTransport();\n\n try {\n const handle = await createFrameOrchestrator({\n transport,\n channelId,\n url,\n container: document.body,\n hidden: true,\n handshakeTimeout: 5_000,\n });\n\n return new Promise<Result<void, ResetConnectionError>>((resolve) => {\n const timeout = setTimeout(() => {\n handle.dispose();\n resolve(ok(undefined));\n }, 5_000);\n\n handle.onMessage((msg: ProtocolMessage) => {\n if (msg.kind === 'complete' || msg.kind === 'error') {\n clearTimeout(timeout);\n handle.dispose();\n resolve(ok(undefined));\n }\n });\n });\n } catch {\n return ok(undefined);\n }\n }\n\n // ------- setupBuy -------\n async function setupBuy(opts: SetupBuyOptions): Promise<Result<BuyFrame, SetupBuyError>> {\n const channelId = `buy-${crypto.randomUUID()}`;\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 const transport = core.createTransport();\n\n try {\n const handle = await createFrameOrchestrator({\n transport,\n channelId,\n url,\n container: opts.container,\n hidden: true,\n });\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 BuyEvent & { kind: 'complete' } extends { payload: infer P }\n ? P\n : never,\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({ setQuote, dispose: () => handle.dispose() });\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-${crypto.randomUUID()}`;\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 const transport = core.createTransport();\n\n try {\n const handle = await createFrameOrchestrator({\n transport,\n channelId,\n url,\n container: opts.container,\n });\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({ setQuote, dispose: () => handle.dispose() });\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 // ------- 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 const transport = core.createTransport();\n\n try {\n const handle = await createFrameOrchestrator({\n transport,\n channelId,\n url: opts.url,\n container: opts.container,\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?.({ kind: 'complete', payload: msg.payload as ChallengeCompleteResult });\n break;\n case 'cancelled':\n opts.onEvent?.({ kind: 'cancelled', payload: msg.payload as ChallengeCancellation });\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({ dispose: () => handle.dispose() });\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-${crypto.randomUUID()}`;\n\n const url = buildFrameUrl(\n FRAME_PATHS.addCard,\n { channelId, clientToken: core.context.clientToken },\n { frameBaseUrl },\n );\n\n const transport = core.createTransport();\n\n try {\n const handle = await createFrameOrchestrator({\n transport,\n channelId,\n url,\n container: opts.container,\n });\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 { code: 'generic' | 'configurationError'; message: string },\n });\n break;\n }\n });\n\n return ok({ dispose: () => handle.dispose() });\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 // ------- Compose the client -------\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 deletePaymentMethod: (id) => core.deletePaymentMethod(id),\n resetConnection,\n setupWidget,\n setupApplePay,\n setupGooglePay,\n setupBuy,\n setupBuyButton,\n setupChallenge,\n setupAddCard,\n };\n}\n","import type { ProtocolMessage } from '@moonpay/platform-protocol';\nimport type { FrameOptions, FrameTransport } from '@moonpay/platform-sdk-core';\n\n// ---------------------------------------------------------------------------\n// Origin validation\n// ---------------------------------------------------------------------------\n\nconst ALLOWED_ORIGIN_PATTERNS = [\n /^https:\\/\\/([a-zA-Z0-9-]+\\.)*moonpay\\.com$/,\n /^https:\\/\\/([a-zA-Z0-9-]+\\.)*moonpaycloud\\.com$/,\n /^https:\\/\\/([a-zA-Z0-9-]+\\.)*preview\\.moonpay-dev\\.com$/,\n /^http:\\/\\/localhost(:\\d+)?$/,\n];\n\nfunction isAllowedOrigin(origin: string): boolean {\n return ALLOWED_ORIGIN_PATTERNS.some((pattern) => pattern.test(origin));\n}\n\n// ---------------------------------------------------------------------------\n// IframeTransport\n// ---------------------------------------------------------------------------\n\n/**\n * FrameTransport implementation for web browsers using HTMLIFrameElement\n * and window.postMessage.\n */\nexport class IframeTransport implements FrameTransport {\n private iframe: HTMLIFrameElement | null = null;\n private container: HTMLElement | null = null;\n private trustedOrigin: string | null = null;\n private handlers: Array<(msg: ProtocolMessage) => void> = [];\n private boundListener: ((event: MessageEvent) => void) | null = null;\n\n create(url: string, options: FrameOptions): void {\n const container = options.container as HTMLElement;\n this.container = container;\n\n const iframe = document.createElement('iframe');\n iframe.src = url;\n iframe.style.border = 'none';\n\n if (options.hidden) {\n iframe.style.width = '0';\n iframe.style.height = '0';\n iframe.style.position = 'absolute';\n iframe.style.overflow = 'hidden';\n } else {\n iframe.style.width = '100%';\n iframe.style.height = '100%';\n }\n\n iframe.allow = 'accelerometer; autoplay; camera; encrypted-media; gyroscope; payment';\n\n this.iframe = iframe;\n\n // Attach the postMessage listener before appending (frame may handshake fast)\n this.boundListener = this.handleMessage.bind(this);\n window.addEventListener('message', this.boundListener);\n\n container.appendChild(iframe);\n }\n\n sendMessage(message: ProtocolMessage): void {\n if (!this.iframe?.contentWindow) {\n throw new Error('Cannot send message: iframe not initialized');\n }\n if (!this.trustedOrigin) {\n throw new Error('Cannot send message: no trusted origin established');\n }\n this.iframe.contentWindow.postMessage(JSON.stringify(message), this.trustedOrigin);\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 if (this.boundListener) {\n window.removeEventListener('message', this.boundListener);\n this.boundListener = null;\n }\n this.handlers.length = 0;\n if (this.iframe && this.container?.contains(this.iframe)) {\n this.iframe.remove();\n }\n this.iframe = null;\n this.container = null;\n this.trustedOrigin = null;\n }\n\n // ---------------------------------------------------------------------------\n // Private\n // ---------------------------------------------------------------------------\n\n private handleMessage(event: MessageEvent): void {\n if (!isAllowedOrigin(event.origin)) return;\n\n let msg: ProtocolMessage;\n try {\n msg = typeof event.data === 'string' ? JSON.parse(event.data) : event.data;\n if (!msg.kind) return;\n } catch {\n return;\n }\n\n // On first valid message from an allowed origin, lock the trusted origin\n if (!this.trustedOrigin) {\n this.trustedOrigin = event.origin;\n } else if (event.origin !== this.trustedOrigin) {\n return;\n }\n\n for (const handler of this.handlers) {\n handler(msg);\n }\n }\n}\n"],"mappings":";AAAA;AAAA,EAYE;AAAA,EACA;AAAA,EASA;AAAA,OAgBK;AACP;AAAA,EACE;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;;;ACzCP,IAAM,0BAA0B;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,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YAAY;AAAA,MACZ,EAAE,WAAW,aAAa,KAAK,QAAQ,YAAY;AAAA,MACnD,EAAE,aAAa;AAAA,IACjB;AAEA,UAAM,YAAY,KAAK,gBAAgB;AAEvC,QAAI;AACF,YAAM,SAAS,MAAM,wBAAwB;AAAA,QAC3C;AAAA,QACA;AAAA,QACA;AAAA,QACA,WAAW,KAAK;AAAA,MAClB,CAAC;AAED,aAAO,UAAU,CAAC,QAAyB;AACzC,gBAAQ,IAAI,MAAM;AAAA,UAChB,KAAK;AACH,iBAAK,UAAU,EAAE,MAAM,YAAY,SAAS,IAAI,QAAkC,CAAC;AACnF;AAAA,UACF,KAAK;AACH,iBAAK,UAAU;AAAA,cACb,MAAM;AAAA,cACN,SAAS,IAAI;AAAA,YACf,CAAC;AACD;AAAA,QACJ;AAAA,MACF,CAAC;AAED,aAAO,GAAG,EAAE,SAAS,MAAM,OAAO,QAAQ,EAAE,CAAC;AAAA,IAC/C,SAAS,GAAG;AACV,aAAO,IAAI;AAAA,QACT,MAAM;AAAA,QACN,SAAS,aAAa,QAAQ,EAAE,UAAU;AAAA,MAC5C,CAAC;AAAA,IACH;AAAA,EACF;AAGA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,mBAAmB,MAAM,KAAK,kBAAkB;AAAA,IAChD,UAAU,CAAC,WAAW,KAAK,SAAS,MAAM;AAAA,IAC1C,kBAAkB,CAAC,WAAW,KAAK,iBAAiB,MAAM;AAAA,IAC1D,gBAAgB,CAAC,OAAO,KAAK,eAAe,EAAE;AAAA,IAC9C,qBAAqB,CAAC,OAAO,KAAK,oBAAoB,EAAE;AAAA,IACxD;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
package/package.json CHANGED
@@ -1,10 +1,42 @@
1
1
  {
2
2
  "name": "@moonpay/platform-sdk-web",
3
- "version": "0.0.0",
4
- "description": "MoonPay Platform SDK for Web (placeholder)",
5
- "main": "index.js",
6
- "license": "UNLICENSED",
3
+ "version": "0.2.0",
4
+ "description": "MoonPay Developer Platform SDK for web browsers",
5
+ "type": "module",
6
+ "main": "./dist/index.cjs",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": {
12
+ "types": "./dist/index.d.ts",
13
+ "default": "./dist/index.js"
14
+ },
15
+ "require": {
16
+ "types": "./dist/index.d.cts",
17
+ "default": "./dist/index.cjs"
18
+ }
19
+ }
20
+ },
21
+ "files": [
22
+ "dist"
23
+ ],
24
+ "scripts": {
25
+ "build": "tsup",
26
+ "typecheck": "tsc --noEmit",
27
+ "clean": "rm -rf dist"
28
+ },
29
+ "dependencies": {
30
+ "@moonpay/platform-protocol": "workspace:*",
31
+ "@moonpay/platform-sdk-core": "workspace:*"
32
+ },
33
+ "devDependencies": {
34
+ "tsup": "8.0.0",
35
+ "typescript": "5.7.3"
36
+ },
37
+ "sideEffects": false,
38
+ "license": "MIT",
7
39
  "publishConfig": {
8
- "access": "public"
40
+ "access": "restricted"
9
41
  }
10
42
  }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # @moonpay/platform-sdk-web
2
-
3
- Placeholder.
package/index.js DELETED
@@ -1 +0,0 @@
1
- module.exports = {};