@moonpay/platform-sdk-web 1.0.2 → 1.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.
- package/README.md +9 -0
- package/dist/index.cjs +14 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -5
- package/dist/index.d.ts +6 -5
- package/dist/index.js +17 -10
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -35,6 +35,15 @@ if (connection.value.status === 'connectionRequired') {
|
|
|
35
35
|
|
|
36
36
|
All client methods return a `Result<T, E>` discriminated union instead of throwing — check `result.ok` before using `result.value`.
|
|
37
37
|
|
|
38
|
+
Pass an optional `theme` to render every MoonPay frame in light or dark mode (omit it to follow the customer's system preference). The connect flow can override it per call:
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
const client = createClient({ sessionToken, theme: { appearance: 'dark' } });
|
|
42
|
+
|
|
43
|
+
// Override for a single frame:
|
|
44
|
+
await client.connect({ container, theme: { appearance: 'light' } });
|
|
45
|
+
```
|
|
46
|
+
|
|
38
47
|
## What the client provides
|
|
39
48
|
|
|
40
49
|
- **Connection** — `getConnection()`, `connect()`, `setupAuth()`, `resetConnection()`
|
package/dist/index.cjs
CHANGED
|
@@ -126,7 +126,7 @@ var IframeTransport = class {
|
|
|
126
126
|
|
|
127
127
|
// src/client.ts
|
|
128
128
|
function createClient(options) {
|
|
129
|
-
const { sessionToken, apiBaseUrl, frameBaseUrl } = options;
|
|
129
|
+
const { sessionToken, apiBaseUrl, frameBaseUrl, theme } = options;
|
|
130
130
|
const core = (0, import_platform_sdk_core.createClientCore)({
|
|
131
131
|
apiBaseUrl,
|
|
132
132
|
frameBaseUrl,
|
|
@@ -200,7 +200,8 @@ function createClient(options) {
|
|
|
200
200
|
sessionToken,
|
|
201
201
|
channelId,
|
|
202
202
|
publicKey,
|
|
203
|
-
|
|
203
|
+
// Per-call theme wins; otherwise fall back to the client-level theme.
|
|
204
|
+
...(0, import_platform_sdk_core.themeParams)(opts.theme ?? theme)
|
|
204
205
|
},
|
|
205
206
|
{ frameBaseUrl }
|
|
206
207
|
);
|
|
@@ -255,7 +256,7 @@ function createClient(options) {
|
|
|
255
256
|
const channelId = `auth-${crypto.randomUUID()}`;
|
|
256
257
|
const url = (0, import_platform_sdk_core.buildFrameUrl)(
|
|
257
258
|
import_platform_sdk_core.FRAME_PATHS.auth,
|
|
258
|
-
{ clientToken, channelId, publicKey },
|
|
259
|
+
{ clientToken, channelId, publicKey, ...(0, import_platform_sdk_core.themeParams)(theme) },
|
|
259
260
|
{ frameBaseUrl }
|
|
260
261
|
);
|
|
261
262
|
const transport = core.createTransport();
|
|
@@ -308,7 +309,8 @@ function createClient(options) {
|
|
|
308
309
|
flow: "buy",
|
|
309
310
|
clientToken: core.context.clientToken,
|
|
310
311
|
quoteSignature: opts.quote,
|
|
311
|
-
channelId
|
|
312
|
+
channelId,
|
|
313
|
+
...(0, import_platform_sdk_core.themeParams)(theme)
|
|
312
314
|
},
|
|
313
315
|
{ frameBaseUrl }
|
|
314
316
|
);
|
|
@@ -368,7 +370,8 @@ function createClient(options) {
|
|
|
368
370
|
{
|
|
369
371
|
clientToken: core.context.clientToken,
|
|
370
372
|
signature: opts.quote,
|
|
371
|
-
channelId
|
|
373
|
+
channelId,
|
|
374
|
+
...(0, import_platform_sdk_core.themeParams)(theme)
|
|
372
375
|
},
|
|
373
376
|
{ frameBaseUrl }
|
|
374
377
|
);
|
|
@@ -441,7 +444,8 @@ function createClient(options) {
|
|
|
441
444
|
clientToken: core.context.clientToken,
|
|
442
445
|
signature: opts.quote,
|
|
443
446
|
channelId,
|
|
444
|
-
...opts.externalTransactionId && { externalTransactionId: opts.externalTransactionId }
|
|
447
|
+
...opts.externalTransactionId && { externalTransactionId: opts.externalTransactionId },
|
|
448
|
+
...(0, import_platform_sdk_core.themeParams)(theme)
|
|
445
449
|
},
|
|
446
450
|
{ frameBaseUrl }
|
|
447
451
|
);
|
|
@@ -605,7 +609,8 @@ function createClient(options) {
|
|
|
605
609
|
{
|
|
606
610
|
channelId,
|
|
607
611
|
clientToken: core.context.clientToken,
|
|
608
|
-
signature: opts.quote
|
|
612
|
+
signature: opts.quote,
|
|
613
|
+
...(0, import_platform_sdk_core.themeParams)(theme)
|
|
609
614
|
},
|
|
610
615
|
{ frameBaseUrl }
|
|
611
616
|
);
|
|
@@ -672,7 +677,7 @@ function createClient(options) {
|
|
|
672
677
|
const handle = await (0, import_platform_sdk_core.createFrameOrchestrator)({
|
|
673
678
|
transport,
|
|
674
679
|
channelId,
|
|
675
|
-
url: url.toString(),
|
|
680
|
+
url: (0, import_platform_sdk_core.applyThemeParam)(url.toString(), theme),
|
|
676
681
|
container: opts.container
|
|
677
682
|
});
|
|
678
683
|
handle.onMessage((msg) => {
|
|
@@ -712,7 +717,7 @@ function createClient(options) {
|
|
|
712
717
|
const channelId = `add-card-${crypto.randomUUID()}`;
|
|
713
718
|
const url = (0, import_platform_sdk_core.buildFrameUrl)(
|
|
714
719
|
import_platform_sdk_core.FRAME_PATHS.addCard,
|
|
715
|
-
{ channelId, clientToken: core.context.clientToken },
|
|
720
|
+
{ channelId, clientToken: core.context.clientToken, ...(0, import_platform_sdk_core.themeParams)(theme) },
|
|
716
721
|
{ frameBaseUrl }
|
|
717
722
|
);
|
|
718
723
|
const transport = core.createTransport();
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/client.ts","../src/iframe-transport.ts"],"sourcesContent":["// Re-export commonly used protocol types for convenience\n\nexport type {\n GetQuoteParams,\n ListPaymentMethodsResponse,\n PaginationInfo,\n PaymentMethodConfig,\n PaymentMethodType,\n Quote,\n StoredCardPaymentMethod,\n StoredPaymentMethod,\n Transaction,\n TransactionWithStages,\n} from '@moonpay/platform-protocol/api';\n// Frame-level types used in event payloads\nexport type { CardResponse } from '@moonpay/platform-protocol/frames/add-card';\nexport type {\n Cancellation as ChallengeCancellation,\n CompleteResult as ChallengeCompleteResult,\n} from '@moonpay/platform-protocol/frames/challenge';\nexport type { Connection } from '@moonpay/platform-protocol/models/connection';\nexport { ConnectionStatus } from '@moonpay/platform-protocol/models/connection';\nexport type { Result } from '@moonpay/platform-protocol/result';\n// SDK-facing event types — re-exported under their partner-facing names\nexport type {\n Event as AddCardEvent,\n SetupError as SetupAddCardError,\n} from '@moonpay/platform-protocol/sdks/add-card';\nexport type {\n Event as ApplePayEvent,\n SetupError as SetupApplePayError,\n} from '@moonpay/platform-protocol/sdks/apple-pay';\nexport type {\n Event as AuthEvent,\n SetupError as SetupAuthError,\n} from '@moonpay/platform-protocol/sdks/auth';\nexport type {\n Event as BuyEvent,\n SetupError as SetupBuyError,\n} from '@moonpay/platform-protocol/sdks/buy';\nexport type {\n Event as BuyButtonEvent,\n SetupError as SetupBuyButtonError,\n} from '@moonpay/platform-protocol/sdks/buy-button';\nexport type {\n Event as ChallengeEvent,\n SetupError as SetupChallengeError,\n} from '@moonpay/platform-protocol/sdks/challenge';\nexport type { Event as ConnectEvent } from '@moonpay/platform-protocol/sdks/connect';\nexport type {\n Event as GooglePayEvent,\n SetupError as SetupGooglePayError,\n} from '@moonpay/platform-protocol/sdks/google-pay';\nexport type {\n Event as WidgetEvent,\n SetupError as SetupWidgetError,\n} from '@moonpay/platform-protocol/sdks/widget';\nexport {\n type AddCardFrame,\n type ApplePayFrame,\n type AuthFrame,\n type BuyButtonFrame,\n type BuyFrame,\n type ChallengeFrame,\n type Client,\n type ConnectFrame,\n type ConnectOptions,\n type CreateClientOptions,\n createClient,\n type GetConnectionOptions,\n type GooglePayFrame,\n type SetupAddCardOptions,\n type SetupApplePayOptions,\n type SetupAuthOptions,\n type SetupBuyButtonOptions,\n type SetupBuyOptions,\n type SetupChallengeOptions,\n type SetupGooglePayOptions,\n type SetupWidgetOptions,\n type WidgetFrame,\n} from './client.js';\nexport { IframeTransport } from './iframe-transport.js';\n","import type {\n GetQuoteParams,\n ListPaymentMethodsResponse,\n PaginationInfo,\n Quote,\n Transaction,\n TransactionWithStages,\n} from '@moonpay/platform-protocol/api';\nimport type {\n CreateIdentityError,\n DevPlatformApiError,\n GetIdentityError,\n GetIdentityUploadUrlError,\n GetPaymentMethodsError,\n GetQuoteError,\n GetTransactionsError,\n SubmitIdentityFilesError,\n UpdateIdentityError,\n VerifyIdentityError,\n} from '@moonpay/platform-protocol/api/errors';\nimport type {\n CreateIdentityRequestBody,\n Identity,\n IdentityFileUploadUrl,\n IdentityFileUploadUrlRequestBody,\n IdentityVerificationResponse,\n SubmitIdentityFilesRequestBody,\n UpdateIdentityRequestBody,\n} from '@moonpay/platform-protocol/api/identity';\nimport type * as AddCardFrameTypes from '@moonpay/platform-protocol/frames/add-card';\nimport type * as ApplePayFrameTypes from '@moonpay/platform-protocol/frames/apple-pay';\nimport type * as BuyFrameTypes from '@moonpay/platform-protocol/frames/buy';\nimport type * as BuyButtonFrameTypes from '@moonpay/platform-protocol/frames/buy-button';\nimport type * as ChallengeFrameTypes from '@moonpay/platform-protocol/frames/challenge';\nimport type * as GooglePayFrameTypes from '@moonpay/platform-protocol/frames/google-pay';\nimport type * as WidgetFrameTypes from '@moonpay/platform-protocol/frames/widget';\nimport type { ChallengeRequired } from '@moonpay/platform-protocol/models/challenge';\nimport type { Connection, ConnectionError } from '@moonpay/platform-protocol/models/connection';\nimport { ConnectionStatus } from '@moonpay/platform-protocol/models/connection';\nimport type { ProtocolMessage } from '@moonpay/platform-protocol/protocol';\nimport type { Result } from '@moonpay/platform-protocol/result';\nimport { err, ok } from '@moonpay/platform-protocol/result';\nimport type * as AddCardSdk from '@moonpay/platform-protocol/sdks/add-card';\nimport type * as ApplePaySdk from '@moonpay/platform-protocol/sdks/apple-pay';\nimport type * as AuthSdk from '@moonpay/platform-protocol/sdks/auth';\nimport type * as BuySdk from '@moonpay/platform-protocol/sdks/buy';\nimport type * as BuyButtonSdk from '@moonpay/platform-protocol/sdks/buy-button';\nimport type * as ChallengeSdk from '@moonpay/platform-protocol/sdks/challenge';\nimport type * as ConnectSdk from '@moonpay/platform-protocol/sdks/connect';\nimport type * as GooglePaySdk from '@moonpay/platform-protocol/sdks/google-pay';\nimport type { ResetConnectionError } from '@moonpay/platform-protocol/sdks/reset';\nimport type * as WidgetSdk from '@moonpay/platform-protocol/sdks/widget';\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 GetConnectionOptions {\n /**\n * Pass `true` for headless / Identity-API integrations so the check\n * frame opts out of KYC-based statuses. Legal (`termsAcceptanceRequired`)\n * is always surfaced regardless. Defaults to `false`.\n */\n skipKyc?: boolean;\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: ConnectSdk.Event) => 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: WidgetSdk.Event) => 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: ApplePaySdk.Event) => 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: GooglePaySdk.Event) => 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: BuySdk.Event) => 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: BuyButtonSdk.Event) => 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 a frame's `challenge` event (buy, buy-button, Apple Pay, or Google Pay). */\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: ChallengeSdk.Event) => 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: AddCardSdk.Event) => void;\n}\n\nexport interface AddCardFrame {\n dispose(): void;\n}\n\nexport interface SetupAuthOptions {\n /** DOM element to render the auth frame into. */\n container: HTMLElement;\n /** Callback for auth frame lifecycle events. */\n onEvent?: (event: AuthSdk.Event) => void;\n}\n\nexport interface AuthFrame {\n dispose(): void;\n}\n\nexport interface Client {\n /**\n * Probe the customer's connection state via the hidden check-connection\n * frame. Returns the `Connection` discriminated union and populates the\n * internal context with bootstrap `accessToken` / `clientToken` for any\n * status that carries credentials (`active`, `connectionRequired`).\n *\n * Headless / Identity-API integrations should pass `skipKyc: true` so the\n * check frame opts out of KYC-related result codes — the frame still\n * surfaces `termsAcceptanceRequired` (legal can't be skipped) but won't\n * resolve to `pending` / `failed` due to KYC alone.\n */\n getConnection(\n options?: GetConnectionOptions,\n ): Promise<Result<Connection, ConnectSdk.GetConnectionError>>;\n connect(options: ConnectOptions): Promise<Result<ConnectFrame, ConnectSdk.ConnectError>>;\n /**\n * Launch the auth frame — the lighter-weight counterpart to `connect()`\n * for headless / Identity-API partners. Requires a `clientToken` to be\n * present in the client's context, which is populated automatically by a\n * prior `getConnection()` call that returned `connectionRequired`.\n * Call `getConnection()` first; if its status is `connectionRequired`,\n * call `setupAuth()` to drive the customer through email/OTP.\n */\n setupAuth(options: SetupAuthOptions): Promise<Result<AuthFrame, AuthSdk.SetupError>>;\n getPaymentMethods(): Promise<\n Result<{ data: ListPaymentMethodsResponse }, GetPaymentMethodsError>\n >;\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, WidgetSdk.SetupError>>;\n setupApplePay(\n options: SetupApplePayOptions,\n ): Promise<Result<ApplePayFrame, ApplePaySdk.SetupError>>;\n setupGooglePay(\n options: SetupGooglePayOptions,\n ): Promise<Result<GooglePayFrame, GooglePaySdk.SetupError>>;\n deletePaymentMethod(id: string): Promise<Result<void, 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, BuySdk.SetupError>>;\n setupBuyButton(\n options: SetupBuyButtonOptions,\n ): Promise<Result<BuyButtonFrame, BuyButtonSdk.SetupError>>;\n setupChallenge(\n options: SetupChallengeOptions,\n ): Promise<Result<ChallengeFrame, ChallengeSdk.SetupError>>;\n setupAddCard(options: SetupAddCardOptions): Promise<Result<AddCardFrame, AddCardSdk.SetupError>>;\n\n // Identity API\n /**\n * Create an identity for the customer bound to the credential. The API\n * returns `data: null` (HTTP 204) when the customer has no outstanding\n * requirements (already onboarded).\n */\n createIdentity(\n body: CreateIdentityRequestBody,\n ): Promise<Result<{ data: Identity | null }, CreateIdentityError>>;\n /** Fetch the identity bound to the credential's customer. */\n getIdentity(id: string): Promise<Result<{ data: Identity }, GetIdentityError>>;\n /** Submit one or more outstanding requirements on the identity. */\n updateIdentity(\n id: string,\n body: UpdateIdentityRequestBody,\n ): Promise<Result<{ data: Identity }, UpdateIdentityError>>;\n /** Submit the identity for verification. */\n verifyIdentity(\n id: string,\n ): Promise<Result<{ data: IdentityVerificationResponse }, VerifyIdentityError>>;\n /** Issue a presigned URL to upload an identity-related file. */\n getIdentityUploadUrl(\n id: string,\n body: IdentityFileUploadUrlRequestBody,\n ): Promise<Result<{ data: IdentityFileUploadUrl }, GetIdentityUploadUrlError>>;\n /** Confirm one or more previously-uploaded identity-related files. */\n submitIdentityFiles(\n id: string,\n body: SubmitIdentityFilesRequestBody,\n ): Promise<Result<{ data: Identity }, SubmitIdentityFilesError>>;\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(\n options: GetConnectionOptions = {},\n ): Promise<Result<Connection, ConnectSdk.GetConnectionError>> {\n const { privateKey, publicKey } = generateKeyPair();\n const channelId = `check-${crypto.randomUUID()}`;\n\n const url = buildFrameUrl(\n FRAME_PATHS.checkConnection,\n {\n sessionToken,\n channelId,\n publicKey,\n ...(options.skipKyc && { skipKyc: true }),\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: document.body,\n hidden: true,\n handshakeTimeout: 10_000,\n });\n\n return new Promise<Result<Connection, ConnectSdk.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(\n opts: ConnectOptions,\n ): Promise<Result<ConnectFrame, ConnectSdk.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, ConnectSdk.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 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 // ------- setupAuth (visible iframe) -------\n async function setupAuth(opts: SetupAuthOptions): Promise<Result<AuthFrame, AuthSdk.SetupError>> {\n const clientToken = core.context.clientToken;\n if (!clientToken) {\n return err({\n kind: 'configurationError',\n message:\n 'No clientToken in context — call getConnection() first and ensure it resolved with status \"connectionRequired\".',\n });\n }\n\n const { privateKey, publicKey } = generateKeyPair();\n const channelId = `auth-${crypto.randomUUID()}`;\n\n const url = buildFrameUrl(\n FRAME_PATHS.auth,\n { clientToken, 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: opts.container,\n });\n\n return new Promise<Result<AuthFrame, AuthSdk.SetupError>>((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 ConnectionError;\n opts.onEvent?.({ kind: 'error', payload });\n handle.dispose();\n resolve(err({ kind: 'genericError', message: 'Auth frame 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 if (\n connection.status === ConnectionStatus.active ||\n connection.status === ConnectionStatus.termsAcceptanceRequired\n ) {\n opts.onEvent?.({ kind: 'complete', payload: connection });\n }\n resolve(ok({ dispose: () => handle.dispose() }));\n }\n });\n });\n } catch (e) {\n return err({\n kind: 'genericError',\n message: e instanceof Error ? e.message : 'Auth setup failed',\n });\n }\n }\n\n // ------- setupWidget -------\n async function setupWidget(\n opts: SetupWidgetOptions,\n ): Promise<Result<WidgetFrame, WidgetSdk.SetupError>> {\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 WidgetFrameTypes.MessageMap['transactionCreated'],\n });\n break;\n case 'complete':\n opts.onEvent?.({\n kind: 'complete',\n payload: msg.payload as WidgetFrameTypes.MessageMap['complete'],\n });\n break;\n case 'error': {\n const payload = msg.payload as WidgetFrameTypes.MessageMap['error'];\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, ApplePaySdk.SetupError>> {\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 ApplePayFrameTypes.InboundMessageMap['complete'],\n });\n break;\n case 'challenge':\n opts.onEvent?.({\n kind: 'challenge',\n payload: msg.payload as ApplePayFrameTypes.InboundMessageMap['challenge'],\n });\n break;\n case 'error': {\n const payload = msg.payload as ApplePayFrameTypes.InboundMessageMap['error'];\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, GooglePaySdk.SetupError>> {\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 GooglePayFrameTypes.InboundMessageMap['complete'],\n });\n break;\n case 'challenge':\n opts.onEvent?.({\n kind: 'challenge',\n payload: msg.payload as GooglePayFrameTypes.InboundMessageMap['challenge'],\n });\n break;\n case 'error': {\n const payload = msg.payload as GooglePayFrameTypes.InboundMessageMap['error'];\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, BuySdk.SetupError>> {\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 BuyFrameTypes.MessageMap['complete'],\n });\n break;\n case 'challenge':\n opts.onEvent?.({\n kind: 'challenge',\n payload: msg.payload as ChallengeRequired,\n });\n break;\n case 'error':\n opts.onEvent?.({\n kind: 'error',\n payload: msg.payload as BuyFrameTypes.MessageMap['error'],\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, BuyButtonSdk.SetupError>> {\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 BuyButtonFrameTypes.MessageMap['complete'],\n });\n break;\n case 'challenge':\n opts.onEvent?.({\n kind: 'challenge',\n payload: msg.payload as ChallengeRequired,\n });\n break;\n case 'error':\n opts.onEvent?.({\n kind: 'error',\n payload: msg.payload as BuyButtonFrameTypes.MessageMap['error'],\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, ChallengeSdk.SetupError>> {\n let url: URL;\n try {\n url = new URL(opts.url);\n } catch {\n return err({ kind: 'configurationError', message: 'Invalid challenge URL' });\n }\n\n let channelId = url.searchParams.get('channelId') ?? '';\n if (!channelId) {\n channelId = `challenge-${crypto.randomUUID()}`;\n url.searchParams.set('channelId', channelId);\n }\n\n const transport = core.createTransport();\n\n try {\n const handle = await createFrameOrchestrator({\n transport,\n channelId,\n url: url.toString(),\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?.({\n kind: 'complete',\n payload: msg.payload as ChallengeFrameTypes.CompleteResult,\n });\n break;\n case 'cancelled':\n opts.onEvent?.({\n kind: 'cancelled',\n payload: msg.payload as ChallengeFrameTypes.Cancellation,\n });\n break;\n case 'error':\n opts.onEvent?.({\n kind: 'error',\n payload: msg.payload as ChallengeFrameTypes.MessageMap['error'],\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, AddCardSdk.SetupError>> {\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 'ready':\n opts.onEvent?.({ kind: 'ready' });\n break;\n case 'complete':\n opts.onEvent?.({\n kind: 'complete',\n payload: msg.payload as AddCardFrameTypes.MessageMap['complete'],\n });\n break;\n case 'error':\n opts.onEvent?.({\n kind: 'error',\n payload: msg.payload as AddCardFrameTypes.MessageMap['error'],\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 setupAuth,\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 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}\n","import type { ProtocolMessage } from '@moonpay/platform-protocol/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.handl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ts","../src/client.ts","../src/iframe-transport.ts"],"sourcesContent":["// Re-export commonly used protocol types for convenience\n\nexport type {\n GetQuoteParams,\n ListPaymentMethodsResponse,\n PaginationInfo,\n PaymentMethodConfig,\n PaymentMethodType,\n Quote,\n StoredCardPaymentMethod,\n StoredPaymentMethod,\n Transaction,\n TransactionWithStages,\n} from '@moonpay/platform-protocol/api';\n// Frame-level types used in event payloads\nexport type { CardResponse } from '@moonpay/platform-protocol/frames/add-card';\nexport type {\n Cancellation as ChallengeCancellation,\n CompleteResult as ChallengeCompleteResult,\n} from '@moonpay/platform-protocol/frames/challenge';\nexport type { Connection } from '@moonpay/platform-protocol/models/connection';\nexport { ConnectionStatus } from '@moonpay/platform-protocol/models/connection';\nexport type { Result } from '@moonpay/platform-protocol/result';\n// SDK-facing event types — re-exported under their partner-facing names\nexport type {\n Event as AddCardEvent,\n SetupError as SetupAddCardError,\n} from '@moonpay/platform-protocol/sdks/add-card';\nexport type {\n Event as ApplePayEvent,\n SetupError as SetupApplePayError,\n} from '@moonpay/platform-protocol/sdks/apple-pay';\nexport type {\n Event as AuthEvent,\n SetupError as SetupAuthError,\n} from '@moonpay/platform-protocol/sdks/auth';\nexport type {\n Event as BuyEvent,\n SetupError as SetupBuyError,\n} from '@moonpay/platform-protocol/sdks/buy';\nexport type {\n Event as BuyButtonEvent,\n SetupError as SetupBuyButtonError,\n} from '@moonpay/platform-protocol/sdks/buy-button';\nexport type {\n Event as ChallengeEvent,\n SetupError as SetupChallengeError,\n} from '@moonpay/platform-protocol/sdks/challenge';\nexport type { Event as ConnectEvent } from '@moonpay/platform-protocol/sdks/connect';\nexport type {\n Event as GooglePayEvent,\n SetupError as SetupGooglePayError,\n} from '@moonpay/platform-protocol/sdks/google-pay';\nexport type {\n Event as WidgetEvent,\n SetupError as SetupWidgetError,\n} from '@moonpay/platform-protocol/sdks/widget';\nexport type { ThemeOptions } from '@moonpay/platform-sdk-core';\nexport {\n type AddCardFrame,\n type ApplePayFrame,\n type AuthFrame,\n type BuyButtonFrame,\n type BuyFrame,\n type ChallengeFrame,\n type Client,\n type ConnectFrame,\n type ConnectOptions,\n type CreateClientOptions,\n createClient,\n type GetConnectionOptions,\n type GooglePayFrame,\n type SetupAddCardOptions,\n type SetupApplePayOptions,\n type SetupAuthOptions,\n type SetupBuyButtonOptions,\n type SetupBuyOptions,\n type SetupChallengeOptions,\n type SetupGooglePayOptions,\n type SetupWidgetOptions,\n type WidgetFrame,\n} from './client.js';\nexport { IframeTransport } from './iframe-transport.js';\n","import type {\n GetQuoteParams,\n ListPaymentMethodsResponse,\n PaginationInfo,\n Quote,\n Transaction,\n TransactionWithStages,\n} from '@moonpay/platform-protocol/api';\nimport type {\n CreateIdentityError,\n DevPlatformApiError,\n GetIdentityError,\n GetIdentityUploadUrlError,\n GetPaymentMethodsError,\n GetQuoteError,\n GetTransactionsError,\n SubmitIdentityFilesError,\n UpdateIdentityError,\n VerifyIdentityError,\n} from '@moonpay/platform-protocol/api/errors';\nimport type {\n CreateIdentityRequestBody,\n Identity,\n IdentityFileUploadUrl,\n IdentityFileUploadUrlRequestBody,\n IdentityVerificationResponse,\n SubmitIdentityFilesRequestBody,\n UpdateIdentityRequestBody,\n} from '@moonpay/platform-protocol/api/identity';\nimport type * as AddCardFrameTypes from '@moonpay/platform-protocol/frames/add-card';\nimport type * as ApplePayFrameTypes from '@moonpay/platform-protocol/frames/apple-pay';\nimport type * as BuyFrameTypes from '@moonpay/platform-protocol/frames/buy';\nimport type * as BuyButtonFrameTypes from '@moonpay/platform-protocol/frames/buy-button';\nimport type * as ChallengeFrameTypes from '@moonpay/platform-protocol/frames/challenge';\nimport type * as GooglePayFrameTypes from '@moonpay/platform-protocol/frames/google-pay';\nimport type * as WidgetFrameTypes from '@moonpay/platform-protocol/frames/widget';\nimport type { ChallengeRequired } from '@moonpay/platform-protocol/models/challenge';\nimport type { Connection, ConnectionError } from '@moonpay/platform-protocol/models/connection';\nimport { ConnectionStatus } from '@moonpay/platform-protocol/models/connection';\nimport type { ProtocolMessage } from '@moonpay/platform-protocol/protocol';\nimport type { Result } from '@moonpay/platform-protocol/result';\nimport { err, ok } from '@moonpay/platform-protocol/result';\nimport type * as AddCardSdk from '@moonpay/platform-protocol/sdks/add-card';\nimport type * as ApplePaySdk from '@moonpay/platform-protocol/sdks/apple-pay';\nimport type * as AuthSdk from '@moonpay/platform-protocol/sdks/auth';\nimport type * as BuySdk from '@moonpay/platform-protocol/sdks/buy';\nimport type * as BuyButtonSdk from '@moonpay/platform-protocol/sdks/buy-button';\nimport type * as ChallengeSdk from '@moonpay/platform-protocol/sdks/challenge';\nimport type * as ConnectSdk from '@moonpay/platform-protocol/sdks/connect';\nimport type * as GooglePaySdk from '@moonpay/platform-protocol/sdks/google-pay';\nimport type { ResetConnectionError } from '@moonpay/platform-protocol/sdks/reset';\nimport type * as WidgetSdk from '@moonpay/platform-protocol/sdks/widget';\nimport {\n applyThemeParam,\n buildFrameUrl,\n type CoreClient,\n createClientCore,\n createFrameOrchestrator,\n decryptCredentials,\n FRAME_PATHS,\n generateKeyPair,\n type ListTransactionsParams,\n type ThemeOptions,\n themeParams,\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 /** Theme applied to every visible MoonPay frame (connect, widget, Apple/Google Pay, …). */\n theme?: ThemeOptions;\n}\n\nexport interface GetConnectionOptions {\n /**\n * Pass `true` for headless / Identity-API integrations so the check\n * frame opts out of KYC-based statuses. Legal (`termsAcceptanceRequired`)\n * is always surfaced regardless. Defaults to `false`.\n */\n skipKyc?: boolean;\n}\n\nexport interface ConnectOptions {\n /** DOM element to render the connect frame into. */\n container: HTMLElement;\n /** Theme for this connect frame. Overrides the client-level `theme`. */\n theme?: ThemeOptions;\n /** Callback for connect lifecycle events. */\n onEvent?: (event: ConnectSdk.Event) => 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: WidgetSdk.Event) => 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: ApplePaySdk.Event) => 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: GooglePaySdk.Event) => 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: BuySdk.Event) => 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: BuyButtonSdk.Event) => 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 a frame's `challenge` event (buy, buy-button, Apple Pay, or Google Pay). */\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: ChallengeSdk.Event) => 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: AddCardSdk.Event) => void;\n}\n\nexport interface AddCardFrame {\n dispose(): void;\n}\n\nexport interface SetupAuthOptions {\n /** DOM element to render the auth frame into. */\n container: HTMLElement;\n /** Callback for auth frame lifecycle events. */\n onEvent?: (event: AuthSdk.Event) => void;\n}\n\nexport interface AuthFrame {\n dispose(): void;\n}\n\nexport interface Client {\n /**\n * Probe the customer's connection state via the hidden check-connection\n * frame. Returns the `Connection` discriminated union and populates the\n * internal context with bootstrap `accessToken` / `clientToken` for any\n * status that carries credentials (`active`, `connectionRequired`).\n *\n * Headless / Identity-API integrations should pass `skipKyc: true` so the\n * check frame opts out of KYC-related result codes — the frame still\n * surfaces `termsAcceptanceRequired` (legal can't be skipped) but won't\n * resolve to `pending` / `failed` due to KYC alone.\n */\n getConnection(\n options?: GetConnectionOptions,\n ): Promise<Result<Connection, ConnectSdk.GetConnectionError>>;\n connect(options: ConnectOptions): Promise<Result<ConnectFrame, ConnectSdk.ConnectError>>;\n /**\n * Launch the auth frame — the lighter-weight counterpart to `connect()`\n * for headless / Identity-API partners. Requires a `clientToken` to be\n * present in the client's context, which is populated automatically by a\n * prior `getConnection()` call that returned `connectionRequired`.\n * Call `getConnection()` first; if its status is `connectionRequired`,\n * call `setupAuth()` to drive the customer through email/OTP.\n */\n setupAuth(options: SetupAuthOptions): Promise<Result<AuthFrame, AuthSdk.SetupError>>;\n getPaymentMethods(): Promise<\n Result<{ data: ListPaymentMethodsResponse }, GetPaymentMethodsError>\n >;\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, WidgetSdk.SetupError>>;\n setupApplePay(\n options: SetupApplePayOptions,\n ): Promise<Result<ApplePayFrame, ApplePaySdk.SetupError>>;\n setupGooglePay(\n options: SetupGooglePayOptions,\n ): Promise<Result<GooglePayFrame, GooglePaySdk.SetupError>>;\n deletePaymentMethod(id: string): Promise<Result<void, 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, BuySdk.SetupError>>;\n setupBuyButton(\n options: SetupBuyButtonOptions,\n ): Promise<Result<BuyButtonFrame, BuyButtonSdk.SetupError>>;\n setupChallenge(\n options: SetupChallengeOptions,\n ): Promise<Result<ChallengeFrame, ChallengeSdk.SetupError>>;\n setupAddCard(options: SetupAddCardOptions): Promise<Result<AddCardFrame, AddCardSdk.SetupError>>;\n\n // Identity API\n /**\n * Create an identity for the customer bound to the credential. The API\n * returns `data: null` (HTTP 204) when the customer has no outstanding\n * requirements (already onboarded).\n */\n createIdentity(\n body: CreateIdentityRequestBody,\n ): Promise<Result<{ data: Identity | null }, CreateIdentityError>>;\n /** Fetch the identity bound to the credential's customer. */\n getIdentity(id: string): Promise<Result<{ data: Identity }, GetIdentityError>>;\n /** Submit one or more outstanding requirements on the identity. */\n updateIdentity(\n id: string,\n body: UpdateIdentityRequestBody,\n ): Promise<Result<{ data: Identity }, UpdateIdentityError>>;\n /** Submit the identity for verification. */\n verifyIdentity(\n id: string,\n ): Promise<Result<{ data: IdentityVerificationResponse }, VerifyIdentityError>>;\n /** Issue a presigned URL to upload an identity-related file. */\n getIdentityUploadUrl(\n id: string,\n body: IdentityFileUploadUrlRequestBody,\n ): Promise<Result<{ data: IdentityFileUploadUrl }, GetIdentityUploadUrlError>>;\n /** Confirm one or more previously-uploaded identity-related files. */\n submitIdentityFiles(\n id: string,\n body: SubmitIdentityFilesRequestBody,\n ): Promise<Result<{ data: Identity }, SubmitIdentityFilesError>>;\n}\n\n// ---------------------------------------------------------------------------\n// createClient\n// ---------------------------------------------------------------------------\n\nexport function createClient(options: CreateClientOptions): Client {\n const { sessionToken, apiBaseUrl, frameBaseUrl, theme } = 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(\n options: GetConnectionOptions = {},\n ): Promise<Result<Connection, ConnectSdk.GetConnectionError>> {\n const { privateKey, publicKey } = generateKeyPair();\n const channelId = `check-${crypto.randomUUID()}`;\n\n const url = buildFrameUrl(\n FRAME_PATHS.checkConnection,\n {\n sessionToken,\n channelId,\n publicKey,\n ...(options.skipKyc && { skipKyc: true }),\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: document.body,\n hidden: true,\n handshakeTimeout: 10_000,\n });\n\n return new Promise<Result<Connection, ConnectSdk.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(\n opts: ConnectOptions,\n ): Promise<Result<ConnectFrame, ConnectSdk.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 // Per-call theme wins; otherwise fall back to the client-level theme.\n ...themeParams(opts.theme ?? theme),\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, ConnectSdk.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 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 // ------- setupAuth (visible iframe) -------\n async function setupAuth(opts: SetupAuthOptions): Promise<Result<AuthFrame, AuthSdk.SetupError>> {\n const clientToken = core.context.clientToken;\n if (!clientToken) {\n return err({\n kind: 'configurationError',\n message:\n 'No clientToken in context — call getConnection() first and ensure it resolved with status \"connectionRequired\".',\n });\n }\n\n const { privateKey, publicKey } = generateKeyPair();\n const channelId = `auth-${crypto.randomUUID()}`;\n\n const url = buildFrameUrl(\n FRAME_PATHS.auth,\n { clientToken, channelId, publicKey, ...themeParams(theme) },\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<AuthFrame, AuthSdk.SetupError>>((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 ConnectionError;\n opts.onEvent?.({ kind: 'error', payload });\n handle.dispose();\n resolve(err({ kind: 'genericError', message: 'Auth frame 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 if (\n connection.status === ConnectionStatus.active ||\n connection.status === ConnectionStatus.termsAcceptanceRequired\n ) {\n opts.onEvent?.({ kind: 'complete', payload: connection });\n }\n resolve(ok({ dispose: () => handle.dispose() }));\n }\n });\n });\n } catch (e) {\n return err({\n kind: 'genericError',\n message: e instanceof Error ? e.message : 'Auth setup failed',\n });\n }\n }\n\n // ------- setupWidget -------\n async function setupWidget(\n opts: SetupWidgetOptions,\n ): Promise<Result<WidgetFrame, WidgetSdk.SetupError>> {\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 ...themeParams(theme),\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 WidgetFrameTypes.MessageMap['transactionCreated'],\n });\n break;\n case 'complete':\n opts.onEvent?.({\n kind: 'complete',\n payload: msg.payload as WidgetFrameTypes.MessageMap['complete'],\n });\n break;\n case 'error': {\n const payload = msg.payload as WidgetFrameTypes.MessageMap['error'];\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, ApplePaySdk.SetupError>> {\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 ...themeParams(theme),\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 ApplePayFrameTypes.InboundMessageMap['complete'],\n });\n break;\n case 'challenge':\n opts.onEvent?.({\n kind: 'challenge',\n payload: msg.payload as ApplePayFrameTypes.InboundMessageMap['challenge'],\n });\n break;\n case 'error': {\n const payload = msg.payload as ApplePayFrameTypes.InboundMessageMap['error'];\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, GooglePaySdk.SetupError>> {\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 ...themeParams(theme),\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 GooglePayFrameTypes.InboundMessageMap['complete'],\n });\n break;\n case 'challenge':\n opts.onEvent?.({\n kind: 'challenge',\n payload: msg.payload as GooglePayFrameTypes.InboundMessageMap['challenge'],\n });\n break;\n case 'error': {\n const payload = msg.payload as GooglePayFrameTypes.InboundMessageMap['error'];\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, BuySdk.SetupError>> {\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 BuyFrameTypes.MessageMap['complete'],\n });\n break;\n case 'challenge':\n opts.onEvent?.({\n kind: 'challenge',\n payload: msg.payload as ChallengeRequired,\n });\n break;\n case 'error':\n opts.onEvent?.({\n kind: 'error',\n payload: msg.payload as BuyFrameTypes.MessageMap['error'],\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, BuyButtonSdk.SetupError>> {\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 ...themeParams(theme),\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 BuyButtonFrameTypes.MessageMap['complete'],\n });\n break;\n case 'challenge':\n opts.onEvent?.({\n kind: 'challenge',\n payload: msg.payload as ChallengeRequired,\n });\n break;\n case 'error':\n opts.onEvent?.({\n kind: 'error',\n payload: msg.payload as BuyButtonFrameTypes.MessageMap['error'],\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, ChallengeSdk.SetupError>> {\n let url: URL;\n try {\n url = new URL(opts.url);\n } catch {\n return err({ kind: 'configurationError', message: 'Invalid challenge URL' });\n }\n\n let channelId = url.searchParams.get('channelId') ?? '';\n if (!channelId) {\n channelId = `challenge-${crypto.randomUUID()}`;\n url.searchParams.set('channelId', channelId);\n }\n\n const transport = core.createTransport();\n\n try {\n const handle = await createFrameOrchestrator({\n transport,\n channelId,\n url: applyThemeParam(url.toString(), theme),\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?.({\n kind: 'complete',\n payload: msg.payload as ChallengeFrameTypes.CompleteResult,\n });\n break;\n case 'cancelled':\n opts.onEvent?.({\n kind: 'cancelled',\n payload: msg.payload as ChallengeFrameTypes.Cancellation,\n });\n break;\n case 'error':\n opts.onEvent?.({\n kind: 'error',\n payload: msg.payload as ChallengeFrameTypes.MessageMap['error'],\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, AddCardSdk.SetupError>> {\n const channelId = `add-card-${crypto.randomUUID()}`;\n\n const url = buildFrameUrl(\n FRAME_PATHS.addCard,\n { channelId, clientToken: core.context.clientToken, ...themeParams(theme) },\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 'complete':\n opts.onEvent?.({\n kind: 'complete',\n payload: msg.payload as AddCardFrameTypes.MessageMap['complete'],\n });\n break;\n case 'error':\n opts.onEvent?.({\n kind: 'error',\n payload: msg.payload as AddCardFrameTypes.MessageMap['error'],\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 setupAuth,\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 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}\n","import type { ProtocolMessage } from '@moonpay/platform-protocol/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;AAAA;AAAA;AAAA;AAAA;AAAA;AAqBA,IAAAA,qBAAiC;;;ACiBjC,wBAAiC;AAGjC,oBAAwB;AAWxB,+BAYO;;;ACzDP,IAAM,0BAA0B;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,SAAS,gBAAgB,QAAyB;AAChD,SAAO,wBAAwB,KAAK,CAAC,YAAY,QAAQ,KAAK,MAAM,CAAC;AACvE;AAUO,IAAM,kBAAN,MAAgD;AAAA,EAC7C,SAAmC;AAAA,EACnC,YAAgC;AAAA,EAChC,gBAA+B;AAAA,EAC/B,WAAkD,CAAC;AAAA,EACnD,gBAAwD;AAAA,EAEhE,OAAO,KAAa,SAA6B;AAC/C,UAAM,YAAY,QAAQ;AAC1B,SAAK,YAAY;AAEjB,UAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,WAAO,MAAM;AACb,WAAO,MAAM,SAAS;AAEtB,QAAI,QAAQ,QAAQ;AA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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,IAEA,gBAAgB,CAAC,SAAS,KAAK,eAAe,IAAI;AAAA,IAClD,aAAa,CAAC,OAAO,KAAK,YAAY,EAAE;AAAA,IACxC,gBAAgB,CAAC,IAAI,SAAS,KAAK,eAAe,IAAI,IAAI;AAAA,IAC1D,gBAAgB,CAAC,OAAO,KAAK,eAAe,EAAE;AAAA,IAC9C,sBAAsB,CAAC,IAAI,SAAS,KAAK,qBAAqB,IAAI,IAAI;AAAA,IACtE,qBAAqB,CAAC,IAAI,SAAS,KAAK,oBAAoB,IAAI,IAAI;AAAA,EACtE;AACF;","names":["import_connection","options"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -24,10 +24,11 @@ import * as GooglePaySdk from '@moonpay/platform-protocol/sdks/google-pay';
|
|
|
24
24
|
export { Event as GooglePayEvent, SetupError as SetupGooglePayError } from '@moonpay/platform-protocol/sdks/google-pay';
|
|
25
25
|
import * as WidgetSdk from '@moonpay/platform-protocol/sdks/widget';
|
|
26
26
|
export { SetupError as SetupWidgetError, Event as WidgetEvent } from '@moonpay/platform-protocol/sdks/widget';
|
|
27
|
+
import { ThemeOptions, ListTransactionsParams, FrameTransport, FrameOptions } from '@moonpay/platform-sdk-core';
|
|
28
|
+
export { ThemeOptions } from '@moonpay/platform-sdk-core';
|
|
27
29
|
import { GetPaymentMethodsError, GetQuoteError, GetTransactionsError, DevPlatformApiError, CreateIdentityError, GetIdentityError, UpdateIdentityError, VerifyIdentityError, GetIdentityUploadUrlError, SubmitIdentityFilesError } from '@moonpay/platform-protocol/api/errors';
|
|
28
30
|
import { CreateIdentityRequestBody, Identity, UpdateIdentityRequestBody, IdentityVerificationResponse, IdentityFileUploadUrlRequestBody, IdentityFileUploadUrl, SubmitIdentityFilesRequestBody } from '@moonpay/platform-protocol/api/identity';
|
|
29
31
|
import { ResetConnectionError } from '@moonpay/platform-protocol/sdks/reset';
|
|
30
|
-
import { ListTransactionsParams, FrameTransport, FrameOptions } from '@moonpay/platform-sdk-core';
|
|
31
32
|
import { ProtocolMessage } from '@moonpay/platform-protocol/protocol';
|
|
32
33
|
|
|
33
34
|
interface CreateClientOptions {
|
|
@@ -37,6 +38,8 @@ interface CreateClientOptions {
|
|
|
37
38
|
apiBaseUrl?: string;
|
|
38
39
|
/** Override the frame base URL. Defaults to production. */
|
|
39
40
|
frameBaseUrl?: string;
|
|
41
|
+
/** Theme applied to every visible MoonPay frame (connect, widget, Apple/Google Pay, …). */
|
|
42
|
+
theme?: ThemeOptions;
|
|
40
43
|
}
|
|
41
44
|
interface GetConnectionOptions {
|
|
42
45
|
/**
|
|
@@ -49,10 +52,8 @@ interface GetConnectionOptions {
|
|
|
49
52
|
interface ConnectOptions {
|
|
50
53
|
/** DOM element to render the connect frame into. */
|
|
51
54
|
container: HTMLElement;
|
|
52
|
-
/** Theme
|
|
53
|
-
theme?:
|
|
54
|
-
appearance?: 'light' | 'dark';
|
|
55
|
-
};
|
|
55
|
+
/** Theme for this connect frame. Overrides the client-level `theme`. */
|
|
56
|
+
theme?: ThemeOptions;
|
|
56
57
|
/** Callback for connect lifecycle events. */
|
|
57
58
|
onEvent?: (event: ConnectSdk.Event) => void;
|
|
58
59
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -24,10 +24,11 @@ import * as GooglePaySdk from '@moonpay/platform-protocol/sdks/google-pay';
|
|
|
24
24
|
export { Event as GooglePayEvent, SetupError as SetupGooglePayError } from '@moonpay/platform-protocol/sdks/google-pay';
|
|
25
25
|
import * as WidgetSdk from '@moonpay/platform-protocol/sdks/widget';
|
|
26
26
|
export { SetupError as SetupWidgetError, Event as WidgetEvent } from '@moonpay/platform-protocol/sdks/widget';
|
|
27
|
+
import { ThemeOptions, ListTransactionsParams, FrameTransport, FrameOptions } from '@moonpay/platform-sdk-core';
|
|
28
|
+
export { ThemeOptions } from '@moonpay/platform-sdk-core';
|
|
27
29
|
import { GetPaymentMethodsError, GetQuoteError, GetTransactionsError, DevPlatformApiError, CreateIdentityError, GetIdentityError, UpdateIdentityError, VerifyIdentityError, GetIdentityUploadUrlError, SubmitIdentityFilesError } from '@moonpay/platform-protocol/api/errors';
|
|
28
30
|
import { CreateIdentityRequestBody, Identity, UpdateIdentityRequestBody, IdentityVerificationResponse, IdentityFileUploadUrlRequestBody, IdentityFileUploadUrl, SubmitIdentityFilesRequestBody } from '@moonpay/platform-protocol/api/identity';
|
|
29
31
|
import { ResetConnectionError } from '@moonpay/platform-protocol/sdks/reset';
|
|
30
|
-
import { ListTransactionsParams, FrameTransport, FrameOptions } from '@moonpay/platform-sdk-core';
|
|
31
32
|
import { ProtocolMessage } from '@moonpay/platform-protocol/protocol';
|
|
32
33
|
|
|
33
34
|
interface CreateClientOptions {
|
|
@@ -37,6 +38,8 @@ interface CreateClientOptions {
|
|
|
37
38
|
apiBaseUrl?: string;
|
|
38
39
|
/** Override the frame base URL. Defaults to production. */
|
|
39
40
|
frameBaseUrl?: string;
|
|
41
|
+
/** Theme applied to every visible MoonPay frame (connect, widget, Apple/Google Pay, …). */
|
|
42
|
+
theme?: ThemeOptions;
|
|
40
43
|
}
|
|
41
44
|
interface GetConnectionOptions {
|
|
42
45
|
/**
|
|
@@ -49,10 +52,8 @@ interface GetConnectionOptions {
|
|
|
49
52
|
interface ConnectOptions {
|
|
50
53
|
/** DOM element to render the connect frame into. */
|
|
51
54
|
container: HTMLElement;
|
|
52
|
-
/** Theme
|
|
53
|
-
theme?:
|
|
54
|
-
appearance?: 'light' | 'dark';
|
|
55
|
-
};
|
|
55
|
+
/** Theme for this connect frame. Overrides the client-level `theme`. */
|
|
56
|
+
theme?: ThemeOptions;
|
|
56
57
|
/** Callback for connect lifecycle events. */
|
|
57
58
|
onEvent?: (event: ConnectSdk.Event) => void;
|
|
58
59
|
}
|
package/dist/index.js
CHANGED
|
@@ -5,12 +5,14 @@ import { ConnectionStatus as ConnectionStatus2 } from "@moonpay/platform-protoco
|
|
|
5
5
|
import { ConnectionStatus } from "@moonpay/platform-protocol/models/connection";
|
|
6
6
|
import { err, ok } from "@moonpay/platform-protocol/result";
|
|
7
7
|
import {
|
|
8
|
+
applyThemeParam,
|
|
8
9
|
buildFrameUrl,
|
|
9
10
|
createClientCore,
|
|
10
11
|
createFrameOrchestrator,
|
|
11
12
|
decryptCredentials,
|
|
12
13
|
FRAME_PATHS,
|
|
13
|
-
generateKeyPair
|
|
14
|
+
generateKeyPair,
|
|
15
|
+
themeParams
|
|
14
16
|
} from "@moonpay/platform-sdk-core";
|
|
15
17
|
|
|
16
18
|
// src/iframe-transport.ts
|
|
@@ -107,7 +109,7 @@ var IframeTransport = class {
|
|
|
107
109
|
|
|
108
110
|
// src/client.ts
|
|
109
111
|
function createClient(options) {
|
|
110
|
-
const { sessionToken, apiBaseUrl, frameBaseUrl } = options;
|
|
112
|
+
const { sessionToken, apiBaseUrl, frameBaseUrl, theme } = options;
|
|
111
113
|
const core = createClientCore({
|
|
112
114
|
apiBaseUrl,
|
|
113
115
|
frameBaseUrl,
|
|
@@ -181,7 +183,8 @@ function createClient(options) {
|
|
|
181
183
|
sessionToken,
|
|
182
184
|
channelId,
|
|
183
185
|
publicKey,
|
|
184
|
-
|
|
186
|
+
// Per-call theme wins; otherwise fall back to the client-level theme.
|
|
187
|
+
...themeParams(opts.theme ?? theme)
|
|
185
188
|
},
|
|
186
189
|
{ frameBaseUrl }
|
|
187
190
|
);
|
|
@@ -236,7 +239,7 @@ function createClient(options) {
|
|
|
236
239
|
const channelId = `auth-${crypto.randomUUID()}`;
|
|
237
240
|
const url = buildFrameUrl(
|
|
238
241
|
FRAME_PATHS.auth,
|
|
239
|
-
{ clientToken, channelId, publicKey },
|
|
242
|
+
{ clientToken, channelId, publicKey, ...themeParams(theme) },
|
|
240
243
|
{ frameBaseUrl }
|
|
241
244
|
);
|
|
242
245
|
const transport = core.createTransport();
|
|
@@ -289,7 +292,8 @@ function createClient(options) {
|
|
|
289
292
|
flow: "buy",
|
|
290
293
|
clientToken: core.context.clientToken,
|
|
291
294
|
quoteSignature: opts.quote,
|
|
292
|
-
channelId
|
|
295
|
+
channelId,
|
|
296
|
+
...themeParams(theme)
|
|
293
297
|
},
|
|
294
298
|
{ frameBaseUrl }
|
|
295
299
|
);
|
|
@@ -349,7 +353,8 @@ function createClient(options) {
|
|
|
349
353
|
{
|
|
350
354
|
clientToken: core.context.clientToken,
|
|
351
355
|
signature: opts.quote,
|
|
352
|
-
channelId
|
|
356
|
+
channelId,
|
|
357
|
+
...themeParams(theme)
|
|
353
358
|
},
|
|
354
359
|
{ frameBaseUrl }
|
|
355
360
|
);
|
|
@@ -422,7 +427,8 @@ function createClient(options) {
|
|
|
422
427
|
clientToken: core.context.clientToken,
|
|
423
428
|
signature: opts.quote,
|
|
424
429
|
channelId,
|
|
425
|
-
...opts.externalTransactionId && { externalTransactionId: opts.externalTransactionId }
|
|
430
|
+
...opts.externalTransactionId && { externalTransactionId: opts.externalTransactionId },
|
|
431
|
+
...themeParams(theme)
|
|
426
432
|
},
|
|
427
433
|
{ frameBaseUrl }
|
|
428
434
|
);
|
|
@@ -586,7 +592,8 @@ function createClient(options) {
|
|
|
586
592
|
{
|
|
587
593
|
channelId,
|
|
588
594
|
clientToken: core.context.clientToken,
|
|
589
|
-
signature: opts.quote
|
|
595
|
+
signature: opts.quote,
|
|
596
|
+
...themeParams(theme)
|
|
590
597
|
},
|
|
591
598
|
{ frameBaseUrl }
|
|
592
599
|
);
|
|
@@ -653,7 +660,7 @@ function createClient(options) {
|
|
|
653
660
|
const handle = await createFrameOrchestrator({
|
|
654
661
|
transport,
|
|
655
662
|
channelId,
|
|
656
|
-
url: url.toString(),
|
|
663
|
+
url: applyThemeParam(url.toString(), theme),
|
|
657
664
|
container: opts.container
|
|
658
665
|
});
|
|
659
666
|
handle.onMessage((msg) => {
|
|
@@ -693,7 +700,7 @@ function createClient(options) {
|
|
|
693
700
|
const channelId = `add-card-${crypto.randomUUID()}`;
|
|
694
701
|
const url = buildFrameUrl(
|
|
695
702
|
FRAME_PATHS.addCard,
|
|
696
|
-
{ channelId, clientToken: core.context.clientToken },
|
|
703
|
+
{ channelId, clientToken: core.context.clientToken, ...themeParams(theme) },
|
|
697
704
|
{ frameBaseUrl }
|
|
698
705
|
);
|
|
699
706
|
const transport = core.createTransport();
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/client.ts","../src/iframe-transport.ts"],"sourcesContent":["// Re-export commonly used protocol types for convenience\n\nexport type {\n GetQuoteParams,\n ListPaymentMethodsResponse,\n PaginationInfo,\n PaymentMethodConfig,\n PaymentMethodType,\n Quote,\n StoredCardPaymentMethod,\n StoredPaymentMethod,\n Transaction,\n TransactionWithStages,\n} from '@moonpay/platform-protocol/api';\n// Frame-level types used in event payloads\nexport type { CardResponse } from '@moonpay/platform-protocol/frames/add-card';\nexport type {\n Cancellation as ChallengeCancellation,\n CompleteResult as ChallengeCompleteResult,\n} from '@moonpay/platform-protocol/frames/challenge';\nexport type { Connection } from '@moonpay/platform-protocol/models/connection';\nexport { ConnectionStatus } from '@moonpay/platform-protocol/models/connection';\nexport type { Result } from '@moonpay/platform-protocol/result';\n// SDK-facing event types — re-exported under their partner-facing names\nexport type {\n Event as AddCardEvent,\n SetupError as SetupAddCardError,\n} from '@moonpay/platform-protocol/sdks/add-card';\nexport type {\n Event as ApplePayEvent,\n SetupError as SetupApplePayError,\n} from '@moonpay/platform-protocol/sdks/apple-pay';\nexport type {\n Event as AuthEvent,\n SetupError as SetupAuthError,\n} from '@moonpay/platform-protocol/sdks/auth';\nexport type {\n Event as BuyEvent,\n SetupError as SetupBuyError,\n} from '@moonpay/platform-protocol/sdks/buy';\nexport type {\n Event as BuyButtonEvent,\n SetupError as SetupBuyButtonError,\n} from '@moonpay/platform-protocol/sdks/buy-button';\nexport type {\n Event as ChallengeEvent,\n SetupError as SetupChallengeError,\n} from '@moonpay/platform-protocol/sdks/challenge';\nexport type { Event as ConnectEvent } from '@moonpay/platform-protocol/sdks/connect';\nexport type {\n Event as GooglePayEvent,\n SetupError as SetupGooglePayError,\n} from '@moonpay/platform-protocol/sdks/google-pay';\nexport type {\n Event as WidgetEvent,\n SetupError as SetupWidgetError,\n} from '@moonpay/platform-protocol/sdks/widget';\nexport {\n type AddCardFrame,\n type ApplePayFrame,\n type AuthFrame,\n type BuyButtonFrame,\n type BuyFrame,\n type ChallengeFrame,\n type Client,\n type ConnectFrame,\n type ConnectOptions,\n type CreateClientOptions,\n createClient,\n type GetConnectionOptions,\n type GooglePayFrame,\n type SetupAddCardOptions,\n type SetupApplePayOptions,\n type SetupAuthOptions,\n type SetupBuyButtonOptions,\n type SetupBuyOptions,\n type SetupChallengeOptions,\n type SetupGooglePayOptions,\n type SetupWidgetOptions,\n type WidgetFrame,\n} from './client.js';\nexport { IframeTransport } from './iframe-transport.js';\n","import type {\n GetQuoteParams,\n ListPaymentMethodsResponse,\n PaginationInfo,\n Quote,\n Transaction,\n TransactionWithStages,\n} from '@moonpay/platform-protocol/api';\nimport type {\n CreateIdentityError,\n DevPlatformApiError,\n GetIdentityError,\n GetIdentityUploadUrlError,\n GetPaymentMethodsError,\n GetQuoteError,\n GetTransactionsError,\n SubmitIdentityFilesError,\n UpdateIdentityError,\n VerifyIdentityError,\n} from '@moonpay/platform-protocol/api/errors';\nimport type {\n CreateIdentityRequestBody,\n Identity,\n IdentityFileUploadUrl,\n IdentityFileUploadUrlRequestBody,\n IdentityVerificationResponse,\n SubmitIdentityFilesRequestBody,\n UpdateIdentityRequestBody,\n} from '@moonpay/platform-protocol/api/identity';\nimport type * as AddCardFrameTypes from '@moonpay/platform-protocol/frames/add-card';\nimport type * as ApplePayFrameTypes from '@moonpay/platform-protocol/frames/apple-pay';\nimport type * as BuyFrameTypes from '@moonpay/platform-protocol/frames/buy';\nimport type * as BuyButtonFrameTypes from '@moonpay/platform-protocol/frames/buy-button';\nimport type * as ChallengeFrameTypes from '@moonpay/platform-protocol/frames/challenge';\nimport type * as GooglePayFrameTypes from '@moonpay/platform-protocol/frames/google-pay';\nimport type * as WidgetFrameTypes from '@moonpay/platform-protocol/frames/widget';\nimport type { ChallengeRequired } from '@moonpay/platform-protocol/models/challenge';\nimport type { Connection, ConnectionError } from '@moonpay/platform-protocol/models/connection';\nimport { ConnectionStatus } from '@moonpay/platform-protocol/models/connection';\nimport type { ProtocolMessage } from '@moonpay/platform-protocol/protocol';\nimport type { Result } from '@moonpay/platform-protocol/result';\nimport { err, ok } from '@moonpay/platform-protocol/result';\nimport type * as AddCardSdk from '@moonpay/platform-protocol/sdks/add-card';\nimport type * as ApplePaySdk from '@moonpay/platform-protocol/sdks/apple-pay';\nimport type * as AuthSdk from '@moonpay/platform-protocol/sdks/auth';\nimport type * as BuySdk from '@moonpay/platform-protocol/sdks/buy';\nimport type * as BuyButtonSdk from '@moonpay/platform-protocol/sdks/buy-button';\nimport type * as ChallengeSdk from '@moonpay/platform-protocol/sdks/challenge';\nimport type * as ConnectSdk from '@moonpay/platform-protocol/sdks/connect';\nimport type * as GooglePaySdk from '@moonpay/platform-protocol/sdks/google-pay';\nimport type { ResetConnectionError } from '@moonpay/platform-protocol/sdks/reset';\nimport type * as WidgetSdk from '@moonpay/platform-protocol/sdks/widget';\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 GetConnectionOptions {\n /**\n * Pass `true` for headless / Identity-API integrations so the check\n * frame opts out of KYC-based statuses. Legal (`termsAcceptanceRequired`)\n * is always surfaced regardless. Defaults to `false`.\n */\n skipKyc?: boolean;\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: ConnectSdk.Event) => 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: WidgetSdk.Event) => 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: ApplePaySdk.Event) => 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: GooglePaySdk.Event) => 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: BuySdk.Event) => 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: BuyButtonSdk.Event) => 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 a frame's `challenge` event (buy, buy-button, Apple Pay, or Google Pay). */\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: ChallengeSdk.Event) => 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: AddCardSdk.Event) => void;\n}\n\nexport interface AddCardFrame {\n dispose(): void;\n}\n\nexport interface SetupAuthOptions {\n /** DOM element to render the auth frame into. */\n container: HTMLElement;\n /** Callback for auth frame lifecycle events. */\n onEvent?: (event: AuthSdk.Event) => void;\n}\n\nexport interface AuthFrame {\n dispose(): void;\n}\n\nexport interface Client {\n /**\n * Probe the customer's connection state via the hidden check-connection\n * frame. Returns the `Connection` discriminated union and populates the\n * internal context with bootstrap `accessToken` / `clientToken` for any\n * status that carries credentials (`active`, `connectionRequired`).\n *\n * Headless / Identity-API integrations should pass `skipKyc: true` so the\n * check frame opts out of KYC-related result codes — the frame still\n * surfaces `termsAcceptanceRequired` (legal can't be skipped) but won't\n * resolve to `pending` / `failed` due to KYC alone.\n */\n getConnection(\n options?: GetConnectionOptions,\n ): Promise<Result<Connection, ConnectSdk.GetConnectionError>>;\n connect(options: ConnectOptions): Promise<Result<ConnectFrame, ConnectSdk.ConnectError>>;\n /**\n * Launch the auth frame — the lighter-weight counterpart to `connect()`\n * for headless / Identity-API partners. Requires a `clientToken` to be\n * present in the client's context, which is populated automatically by a\n * prior `getConnection()` call that returned `connectionRequired`.\n * Call `getConnection()` first; if its status is `connectionRequired`,\n * call `setupAuth()` to drive the customer through email/OTP.\n */\n setupAuth(options: SetupAuthOptions): Promise<Result<AuthFrame, AuthSdk.SetupError>>;\n getPaymentMethods(): Promise<\n Result<{ data: ListPaymentMethodsResponse }, GetPaymentMethodsError>\n >;\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, WidgetSdk.SetupError>>;\n setupApplePay(\n options: SetupApplePayOptions,\n ): Promise<Result<ApplePayFrame, ApplePaySdk.SetupError>>;\n setupGooglePay(\n options: SetupGooglePayOptions,\n ): Promise<Result<GooglePayFrame, GooglePaySdk.SetupError>>;\n deletePaymentMethod(id: string): Promise<Result<void, 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, BuySdk.SetupError>>;\n setupBuyButton(\n options: SetupBuyButtonOptions,\n ): Promise<Result<BuyButtonFrame, BuyButtonSdk.SetupError>>;\n setupChallenge(\n options: SetupChallengeOptions,\n ): Promise<Result<ChallengeFrame, ChallengeSdk.SetupError>>;\n setupAddCard(options: SetupAddCardOptions): Promise<Result<AddCardFrame, AddCardSdk.SetupError>>;\n\n // Identity API\n /**\n * Create an identity for the customer bound to the credential. The API\n * returns `data: null` (HTTP 204) when the customer has no outstanding\n * requirements (already onboarded).\n */\n createIdentity(\n body: CreateIdentityRequestBody,\n ): Promise<Result<{ data: Identity | null }, CreateIdentityError>>;\n /** Fetch the identity bound to the credential's customer. */\n getIdentity(id: string): Promise<Result<{ data: Identity }, GetIdentityError>>;\n /** Submit one or more outstanding requirements on the identity. */\n updateIdentity(\n id: string,\n body: UpdateIdentityRequestBody,\n ): Promise<Result<{ data: Identity }, UpdateIdentityError>>;\n /** Submit the identity for verification. */\n verifyIdentity(\n id: string,\n ): Promise<Result<{ data: IdentityVerificationResponse }, VerifyIdentityError>>;\n /** Issue a presigned URL to upload an identity-related file. */\n getIdentityUploadUrl(\n id: string,\n body: IdentityFileUploadUrlRequestBody,\n ): Promise<Result<{ data: IdentityFileUploadUrl }, GetIdentityUploadUrlError>>;\n /** Confirm one or more previously-uploaded identity-related files. */\n submitIdentityFiles(\n id: string,\n body: SubmitIdentityFilesRequestBody,\n ): Promise<Result<{ data: Identity }, SubmitIdentityFilesError>>;\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(\n options: GetConnectionOptions = {},\n ): Promise<Result<Connection, ConnectSdk.GetConnectionError>> {\n const { privateKey, publicKey } = generateKeyPair();\n const channelId = `check-${crypto.randomUUID()}`;\n\n const url = buildFrameUrl(\n FRAME_PATHS.checkConnection,\n {\n sessionToken,\n channelId,\n publicKey,\n ...(options.skipKyc && { skipKyc: true }),\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: document.body,\n hidden: true,\n handshakeTimeout: 10_000,\n });\n\n return new Promise<Result<Connection, ConnectSdk.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(\n opts: ConnectOptions,\n ): Promise<Result<ConnectFrame, ConnectSdk.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, ConnectSdk.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 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 // ------- setupAuth (visible iframe) -------\n async function setupAuth(opts: SetupAuthOptions): Promise<Result<AuthFrame, AuthSdk.SetupError>> {\n const clientToken = core.context.clientToken;\n if (!clientToken) {\n return err({\n kind: 'configurationError',\n message:\n 'No clientToken in context — call getConnection() first and ensure it resolved with status \"connectionRequired\".',\n });\n }\n\n const { privateKey, publicKey } = generateKeyPair();\n const channelId = `auth-${crypto.randomUUID()}`;\n\n const url = buildFrameUrl(\n FRAME_PATHS.auth,\n { clientToken, 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: opts.container,\n });\n\n return new Promise<Result<AuthFrame, AuthSdk.SetupError>>((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 ConnectionError;\n opts.onEvent?.({ kind: 'error', payload });\n handle.dispose();\n resolve(err({ kind: 'genericError', message: 'Auth frame 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 if (\n connection.status === ConnectionStatus.active ||\n connection.status === ConnectionStatus.termsAcceptanceRequired\n ) {\n opts.onEvent?.({ kind: 'complete', payload: connection });\n }\n resolve(ok({ dispose: () => handle.dispose() }));\n }\n });\n });\n } catch (e) {\n return err({\n kind: 'genericError',\n message: e instanceof Error ? e.message : 'Auth setup failed',\n });\n }\n }\n\n // ------- setupWidget -------\n async function setupWidget(\n opts: SetupWidgetOptions,\n ): Promise<Result<WidgetFrame, WidgetSdk.SetupError>> {\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 WidgetFrameTypes.MessageMap['transactionCreated'],\n });\n break;\n case 'complete':\n opts.onEvent?.({\n kind: 'complete',\n payload: msg.payload as WidgetFrameTypes.MessageMap['complete'],\n });\n break;\n case 'error': {\n const payload = msg.payload as WidgetFrameTypes.MessageMap['error'];\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, ApplePaySdk.SetupError>> {\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 ApplePayFrameTypes.InboundMessageMap['complete'],\n });\n break;\n case 'challenge':\n opts.onEvent?.({\n kind: 'challenge',\n payload: msg.payload as ApplePayFrameTypes.InboundMessageMap['challenge'],\n });\n break;\n case 'error': {\n const payload = msg.payload as ApplePayFrameTypes.InboundMessageMap['error'];\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, GooglePaySdk.SetupError>> {\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 GooglePayFrameTypes.InboundMessageMap['complete'],\n });\n break;\n case 'challenge':\n opts.onEvent?.({\n kind: 'challenge',\n payload: msg.payload as GooglePayFrameTypes.InboundMessageMap['challenge'],\n });\n break;\n case 'error': {\n const payload = msg.payload as GooglePayFrameTypes.InboundMessageMap['error'];\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, BuySdk.SetupError>> {\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 BuyFrameTypes.MessageMap['complete'],\n });\n break;\n case 'challenge':\n opts.onEvent?.({\n kind: 'challenge',\n payload: msg.payload as ChallengeRequired,\n });\n break;\n case 'error':\n opts.onEvent?.({\n kind: 'error',\n payload: msg.payload as BuyFrameTypes.MessageMap['error'],\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, BuyButtonSdk.SetupError>> {\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 BuyButtonFrameTypes.MessageMap['complete'],\n });\n break;\n case 'challenge':\n opts.onEvent?.({\n kind: 'challenge',\n payload: msg.payload as ChallengeRequired,\n });\n break;\n case 'error':\n opts.onEvent?.({\n kind: 'error',\n payload: msg.payload as BuyButtonFrameTypes.MessageMap['error'],\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, ChallengeSdk.SetupError>> {\n let url: URL;\n try {\n url = new URL(opts.url);\n } catch {\n return err({ kind: 'configurationError', message: 'Invalid challenge URL' });\n }\n\n let channelId = url.searchParams.get('channelId') ?? '';\n if (!channelId) {\n channelId = `challenge-${crypto.randomUUID()}`;\n url.searchParams.set('channelId', channelId);\n }\n\n const transport = core.createTransport();\n\n try {\n const handle = await createFrameOrchestrator({\n transport,\n channelId,\n url: url.toString(),\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?.({\n kind: 'complete',\n payload: msg.payload as ChallengeFrameTypes.CompleteResult,\n });\n break;\n case 'cancelled':\n opts.onEvent?.({\n kind: 'cancelled',\n payload: msg.payload as ChallengeFrameTypes.Cancellation,\n });\n break;\n case 'error':\n opts.onEvent?.({\n kind: 'error',\n payload: msg.payload as ChallengeFrameTypes.MessageMap['error'],\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, AddCardSdk.SetupError>> {\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 'ready':\n opts.onEvent?.({ kind: 'ready' });\n break;\n case 'complete':\n opts.onEvent?.({\n kind: 'complete',\n payload: msg.payload as AddCardFrameTypes.MessageMap['complete'],\n });\n break;\n case 'error':\n opts.onEvent?.({\n kind: 'error',\n payload: msg.payload as AddCardFrameTypes.MessageMap['error'],\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 setupAuth,\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 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}\n","import type { ProtocolMessage } from '@moonpay/platform-protocol/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":";AAqBA,SAAS,oBAAAA,yBAAwB;;;ACiBjC,SAAS,wBAAwB;AAGjC,SAAS,KAAK,UAAU;AAWxB;AAAA,EACE;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;;;ACtDP,IAAM,0BAA0B;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,SAAS,gBAAgB,QAAyB;AAChD,SAAO,wBAAwB,KAAK,CAAC,YAAY,QAAQ,KAAK,MAAM,CAAC;AACvE;AAUO,IAA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,IACH;AAAA,EACF;AAGA,SAAO;AAAA,IACL;AAAA,IACA;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,IAEA,gBAAgB,CAAC,SAAS,KAAK,eAAe,IAAI;AAAA,IAClD,aAAa,CAAC,OAAO,KAAK,YAAY,EAAE;AAAA,IACxC,gBAAgB,CAAC,IAAI,SAAS,KAAK,eAAe,IAAI,IAAI;AAAA,IAC1D,gBAAgB,CAAC,OAAO,KAAK,eAAe,EAAE;AAAA,IAC9C,sBAAsB,CAAC,IAAI,SAAS,KAAK,qBAAqB,IAAI,IAAI;AAAA,IACtE,qBAAqB,CAAC,IAAI,SAAS,KAAK,oBAAoB,IAAI,IAAI;AAAA,EACtE;AACF;","names":["ConnectionStatus","options"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/client.ts","../src/iframe-transport.ts"],"sourcesContent":["// Re-export commonly used protocol types for convenience\n\nexport type {\n GetQuoteParams,\n ListPaymentMethodsResponse,\n PaginationInfo,\n PaymentMethodConfig,\n PaymentMethodType,\n Quote,\n StoredCardPaymentMethod,\n StoredPaymentMethod,\n Transaction,\n TransactionWithStages,\n} from '@moonpay/platform-protocol/api';\n// Frame-level types used in event payloads\nexport type { CardResponse } from '@moonpay/platform-protocol/frames/add-card';\nexport type {\n Cancellation as ChallengeCancellation,\n CompleteResult as ChallengeCompleteResult,\n} from '@moonpay/platform-protocol/frames/challenge';\nexport type { Connection } from '@moonpay/platform-protocol/models/connection';\nexport { ConnectionStatus } from '@moonpay/platform-protocol/models/connection';\nexport type { Result } from '@moonpay/platform-protocol/result';\n// SDK-facing event types — re-exported under their partner-facing names\nexport type {\n Event as AddCardEvent,\n SetupError as SetupAddCardError,\n} from '@moonpay/platform-protocol/sdks/add-card';\nexport type {\n Event as ApplePayEvent,\n SetupError as SetupApplePayError,\n} from '@moonpay/platform-protocol/sdks/apple-pay';\nexport type {\n Event as AuthEvent,\n SetupError as SetupAuthError,\n} from '@moonpay/platform-protocol/sdks/auth';\nexport type {\n Event as BuyEvent,\n SetupError as SetupBuyError,\n} from '@moonpay/platform-protocol/sdks/buy';\nexport type {\n Event as BuyButtonEvent,\n SetupError as SetupBuyButtonError,\n} from '@moonpay/platform-protocol/sdks/buy-button';\nexport type {\n Event as ChallengeEvent,\n SetupError as SetupChallengeError,\n} from '@moonpay/platform-protocol/sdks/challenge';\nexport type { Event as ConnectEvent } from '@moonpay/platform-protocol/sdks/connect';\nexport type {\n Event as GooglePayEvent,\n SetupError as SetupGooglePayError,\n} from '@moonpay/platform-protocol/sdks/google-pay';\nexport type {\n Event as WidgetEvent,\n SetupError as SetupWidgetError,\n} from '@moonpay/platform-protocol/sdks/widget';\nexport type { ThemeOptions } from '@moonpay/platform-sdk-core';\nexport {\n type AddCardFrame,\n type ApplePayFrame,\n type AuthFrame,\n type BuyButtonFrame,\n type BuyFrame,\n type ChallengeFrame,\n type Client,\n type ConnectFrame,\n type ConnectOptions,\n type CreateClientOptions,\n createClient,\n type GetConnectionOptions,\n type GooglePayFrame,\n type SetupAddCardOptions,\n type SetupApplePayOptions,\n type SetupAuthOptions,\n type SetupBuyButtonOptions,\n type SetupBuyOptions,\n type SetupChallengeOptions,\n type SetupGooglePayOptions,\n type SetupWidgetOptions,\n type WidgetFrame,\n} from './client.js';\nexport { IframeTransport } from './iframe-transport.js';\n","import type {\n GetQuoteParams,\n ListPaymentMethodsResponse,\n PaginationInfo,\n Quote,\n Transaction,\n TransactionWithStages,\n} from '@moonpay/platform-protocol/api';\nimport type {\n CreateIdentityError,\n DevPlatformApiError,\n GetIdentityError,\n GetIdentityUploadUrlError,\n GetPaymentMethodsError,\n GetQuoteError,\n GetTransactionsError,\n SubmitIdentityFilesError,\n UpdateIdentityError,\n VerifyIdentityError,\n} from '@moonpay/platform-protocol/api/errors';\nimport type {\n CreateIdentityRequestBody,\n Identity,\n IdentityFileUploadUrl,\n IdentityFileUploadUrlRequestBody,\n IdentityVerificationResponse,\n SubmitIdentityFilesRequestBody,\n UpdateIdentityRequestBody,\n} from '@moonpay/platform-protocol/api/identity';\nimport type * as AddCardFrameTypes from '@moonpay/platform-protocol/frames/add-card';\nimport type * as ApplePayFrameTypes from '@moonpay/platform-protocol/frames/apple-pay';\nimport type * as BuyFrameTypes from '@moonpay/platform-protocol/frames/buy';\nimport type * as BuyButtonFrameTypes from '@moonpay/platform-protocol/frames/buy-button';\nimport type * as ChallengeFrameTypes from '@moonpay/platform-protocol/frames/challenge';\nimport type * as GooglePayFrameTypes from '@moonpay/platform-protocol/frames/google-pay';\nimport type * as WidgetFrameTypes from '@moonpay/platform-protocol/frames/widget';\nimport type { ChallengeRequired } from '@moonpay/platform-protocol/models/challenge';\nimport type { Connection, ConnectionError } from '@moonpay/platform-protocol/models/connection';\nimport { ConnectionStatus } from '@moonpay/platform-protocol/models/connection';\nimport type { ProtocolMessage } from '@moonpay/platform-protocol/protocol';\nimport type { Result } from '@moonpay/platform-protocol/result';\nimport { err, ok } from '@moonpay/platform-protocol/result';\nimport type * as AddCardSdk from '@moonpay/platform-protocol/sdks/add-card';\nimport type * as ApplePaySdk from '@moonpay/platform-protocol/sdks/apple-pay';\nimport type * as AuthSdk from '@moonpay/platform-protocol/sdks/auth';\nimport type * as BuySdk from '@moonpay/platform-protocol/sdks/buy';\nimport type * as BuyButtonSdk from '@moonpay/platform-protocol/sdks/buy-button';\nimport type * as ChallengeSdk from '@moonpay/platform-protocol/sdks/challenge';\nimport type * as ConnectSdk from '@moonpay/platform-protocol/sdks/connect';\nimport type * as GooglePaySdk from '@moonpay/platform-protocol/sdks/google-pay';\nimport type { ResetConnectionError } from '@moonpay/platform-protocol/sdks/reset';\nimport type * as WidgetSdk from '@moonpay/platform-protocol/sdks/widget';\nimport {\n applyThemeParam,\n buildFrameUrl,\n type CoreClient,\n createClientCore,\n createFrameOrchestrator,\n decryptCredentials,\n FRAME_PATHS,\n generateKeyPair,\n type ListTransactionsParams,\n type ThemeOptions,\n themeParams,\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 /** Theme applied to every visible MoonPay frame (connect, widget, Apple/Google Pay, …). */\n theme?: ThemeOptions;\n}\n\nexport interface GetConnectionOptions {\n /**\n * Pass `true` for headless / Identity-API integrations so the check\n * frame opts out of KYC-based statuses. Legal (`termsAcceptanceRequired`)\n * is always surfaced regardless. Defaults to `false`.\n */\n skipKyc?: boolean;\n}\n\nexport interface ConnectOptions {\n /** DOM element to render the connect frame into. */\n container: HTMLElement;\n /** Theme for this connect frame. Overrides the client-level `theme`. */\n theme?: ThemeOptions;\n /** Callback for connect lifecycle events. */\n onEvent?: (event: ConnectSdk.Event) => 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: WidgetSdk.Event) => 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: ApplePaySdk.Event) => 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: GooglePaySdk.Event) => 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: BuySdk.Event) => 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: BuyButtonSdk.Event) => 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 a frame's `challenge` event (buy, buy-button, Apple Pay, or Google Pay). */\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: ChallengeSdk.Event) => 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: AddCardSdk.Event) => void;\n}\n\nexport interface AddCardFrame {\n dispose(): void;\n}\n\nexport interface SetupAuthOptions {\n /** DOM element to render the auth frame into. */\n container: HTMLElement;\n /** Callback for auth frame lifecycle events. */\n onEvent?: (event: AuthSdk.Event) => void;\n}\n\nexport interface AuthFrame {\n dispose(): void;\n}\n\nexport interface Client {\n /**\n * Probe the customer's connection state via the hidden check-connection\n * frame. Returns the `Connection` discriminated union and populates the\n * internal context with bootstrap `accessToken` / `clientToken` for any\n * status that carries credentials (`active`, `connectionRequired`).\n *\n * Headless / Identity-API integrations should pass `skipKyc: true` so the\n * check frame opts out of KYC-related result codes — the frame still\n * surfaces `termsAcceptanceRequired` (legal can't be skipped) but won't\n * resolve to `pending` / `failed` due to KYC alone.\n */\n getConnection(\n options?: GetConnectionOptions,\n ): Promise<Result<Connection, ConnectSdk.GetConnectionError>>;\n connect(options: ConnectOptions): Promise<Result<ConnectFrame, ConnectSdk.ConnectError>>;\n /**\n * Launch the auth frame — the lighter-weight counterpart to `connect()`\n * for headless / Identity-API partners. Requires a `clientToken` to be\n * present in the client's context, which is populated automatically by a\n * prior `getConnection()` call that returned `connectionRequired`.\n * Call `getConnection()` first; if its status is `connectionRequired`,\n * call `setupAuth()` to drive the customer through email/OTP.\n */\n setupAuth(options: SetupAuthOptions): Promise<Result<AuthFrame, AuthSdk.SetupError>>;\n getPaymentMethods(): Promise<\n Result<{ data: ListPaymentMethodsResponse }, GetPaymentMethodsError>\n >;\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, WidgetSdk.SetupError>>;\n setupApplePay(\n options: SetupApplePayOptions,\n ): Promise<Result<ApplePayFrame, ApplePaySdk.SetupError>>;\n setupGooglePay(\n options: SetupGooglePayOptions,\n ): Promise<Result<GooglePayFrame, GooglePaySdk.SetupError>>;\n deletePaymentMethod(id: string): Promise<Result<void, 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, BuySdk.SetupError>>;\n setupBuyButton(\n options: SetupBuyButtonOptions,\n ): Promise<Result<BuyButtonFrame, BuyButtonSdk.SetupError>>;\n setupChallenge(\n options: SetupChallengeOptions,\n ): Promise<Result<ChallengeFrame, ChallengeSdk.SetupError>>;\n setupAddCard(options: SetupAddCardOptions): Promise<Result<AddCardFrame, AddCardSdk.SetupError>>;\n\n // Identity API\n /**\n * Create an identity for the customer bound to the credential. The API\n * returns `data: null` (HTTP 204) when the customer has no outstanding\n * requirements (already onboarded).\n */\n createIdentity(\n body: CreateIdentityRequestBody,\n ): Promise<Result<{ data: Identity | null }, CreateIdentityError>>;\n /** Fetch the identity bound to the credential's customer. */\n getIdentity(id: string): Promise<Result<{ data: Identity }, GetIdentityError>>;\n /** Submit one or more outstanding requirements on the identity. */\n updateIdentity(\n id: string,\n body: UpdateIdentityRequestBody,\n ): Promise<Result<{ data: Identity }, UpdateIdentityError>>;\n /** Submit the identity for verification. */\n verifyIdentity(\n id: string,\n ): Promise<Result<{ data: IdentityVerificationResponse }, VerifyIdentityError>>;\n /** Issue a presigned URL to upload an identity-related file. */\n getIdentityUploadUrl(\n id: string,\n body: IdentityFileUploadUrlRequestBody,\n ): Promise<Result<{ data: IdentityFileUploadUrl }, GetIdentityUploadUrlError>>;\n /** Confirm one or more previously-uploaded identity-related files. */\n submitIdentityFiles(\n id: string,\n body: SubmitIdentityFilesRequestBody,\n ): Promise<Result<{ data: Identity }, SubmitIdentityFilesError>>;\n}\n\n// ---------------------------------------------------------------------------\n// createClient\n// ---------------------------------------------------------------------------\n\nexport function createClient(options: CreateClientOptions): Client {\n const { sessionToken, apiBaseUrl, frameBaseUrl, theme } = 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(\n options: GetConnectionOptions = {},\n ): Promise<Result<Connection, ConnectSdk.GetConnectionError>> {\n const { privateKey, publicKey } = generateKeyPair();\n const channelId = `check-${crypto.randomUUID()}`;\n\n const url = buildFrameUrl(\n FRAME_PATHS.checkConnection,\n {\n sessionToken,\n channelId,\n publicKey,\n ...(options.skipKyc && { skipKyc: true }),\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: document.body,\n hidden: true,\n handshakeTimeout: 10_000,\n });\n\n return new Promise<Result<Connection, ConnectSdk.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(\n opts: ConnectOptions,\n ): Promise<Result<ConnectFrame, ConnectSdk.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 // Per-call theme wins; otherwise fall back to the client-level theme.\n ...themeParams(opts.theme ?? theme),\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, ConnectSdk.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 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 // ------- setupAuth (visible iframe) -------\n async function setupAuth(opts: SetupAuthOptions): Promise<Result<AuthFrame, AuthSdk.SetupError>> {\n const clientToken = core.context.clientToken;\n if (!clientToken) {\n return err({\n kind: 'configurationError',\n message:\n 'No clientToken in context — call getConnection() first and ensure it resolved with status \"connectionRequired\".',\n });\n }\n\n const { privateKey, publicKey } = generateKeyPair();\n const channelId = `auth-${crypto.randomUUID()}`;\n\n const url = buildFrameUrl(\n FRAME_PATHS.auth,\n { clientToken, channelId, publicKey, ...themeParams(theme) },\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<AuthFrame, AuthSdk.SetupError>>((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 ConnectionError;\n opts.onEvent?.({ kind: 'error', payload });\n handle.dispose();\n resolve(err({ kind: 'genericError', message: 'Auth frame 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 if (\n connection.status === ConnectionStatus.active ||\n connection.status === ConnectionStatus.termsAcceptanceRequired\n ) {\n opts.onEvent?.({ kind: 'complete', payload: connection });\n }\n resolve(ok({ dispose: () => handle.dispose() }));\n }\n });\n });\n } catch (e) {\n return err({\n kind: 'genericError',\n message: e instanceof Error ? e.message : 'Auth setup failed',\n });\n }\n }\n\n // ------- setupWidget -------\n async function setupWidget(\n opts: SetupWidgetOptions,\n ): Promise<Result<WidgetFrame, WidgetSdk.SetupError>> {\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 ...themeParams(theme),\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 WidgetFrameTypes.MessageMap['transactionCreated'],\n });\n break;\n case 'complete':\n opts.onEvent?.({\n kind: 'complete',\n payload: msg.payload as WidgetFrameTypes.MessageMap['complete'],\n });\n break;\n case 'error': {\n const payload = msg.payload as WidgetFrameTypes.MessageMap['error'];\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, ApplePaySdk.SetupError>> {\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 ...themeParams(theme),\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 ApplePayFrameTypes.InboundMessageMap['complete'],\n });\n break;\n case 'challenge':\n opts.onEvent?.({\n kind: 'challenge',\n payload: msg.payload as ApplePayFrameTypes.InboundMessageMap['challenge'],\n });\n break;\n case 'error': {\n const payload = msg.payload as ApplePayFrameTypes.InboundMessageMap['error'];\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, GooglePaySdk.SetupError>> {\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 ...themeParams(theme),\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 GooglePayFrameTypes.InboundMessageMap['complete'],\n });\n break;\n case 'challenge':\n opts.onEvent?.({\n kind: 'challenge',\n payload: msg.payload as GooglePayFrameTypes.InboundMessageMap['challenge'],\n });\n break;\n case 'error': {\n const payload = msg.payload as GooglePayFrameTypes.InboundMessageMap['error'];\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, BuySdk.SetupError>> {\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 BuyFrameTypes.MessageMap['complete'],\n });\n break;\n case 'challenge':\n opts.onEvent?.({\n kind: 'challenge',\n payload: msg.payload as ChallengeRequired,\n });\n break;\n case 'error':\n opts.onEvent?.({\n kind: 'error',\n payload: msg.payload as BuyFrameTypes.MessageMap['error'],\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, BuyButtonSdk.SetupError>> {\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 ...themeParams(theme),\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 BuyButtonFrameTypes.MessageMap['complete'],\n });\n break;\n case 'challenge':\n opts.onEvent?.({\n kind: 'challenge',\n payload: msg.payload as ChallengeRequired,\n });\n break;\n case 'error':\n opts.onEvent?.({\n kind: 'error',\n payload: msg.payload as BuyButtonFrameTypes.MessageMap['error'],\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, ChallengeSdk.SetupError>> {\n let url: URL;\n try {\n url = new URL(opts.url);\n } catch {\n return err({ kind: 'configurationError', message: 'Invalid challenge URL' });\n }\n\n let channelId = url.searchParams.get('channelId') ?? '';\n if (!channelId) {\n channelId = `challenge-${crypto.randomUUID()}`;\n url.searchParams.set('channelId', channelId);\n }\n\n const transport = core.createTransport();\n\n try {\n const handle = await createFrameOrchestrator({\n transport,\n channelId,\n url: applyThemeParam(url.toString(), theme),\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?.({\n kind: 'complete',\n payload: msg.payload as ChallengeFrameTypes.CompleteResult,\n });\n break;\n case 'cancelled':\n opts.onEvent?.({\n kind: 'cancelled',\n payload: msg.payload as ChallengeFrameTypes.Cancellation,\n });\n break;\n case 'error':\n opts.onEvent?.({\n kind: 'error',\n payload: msg.payload as ChallengeFrameTypes.MessageMap['error'],\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, AddCardSdk.SetupError>> {\n const channelId = `add-card-${crypto.randomUUID()}`;\n\n const url = buildFrameUrl(\n FRAME_PATHS.addCard,\n { channelId, clientToken: core.context.clientToken, ...themeParams(theme) },\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 'complete':\n opts.onEvent?.({\n kind: 'complete',\n payload: msg.payload as AddCardFrameTypes.MessageMap['complete'],\n });\n break;\n case 'error':\n opts.onEvent?.({\n kind: 'error',\n payload: msg.payload as AddCardFrameTypes.MessageMap['error'],\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 setupAuth,\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 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}\n","import type { ProtocolMessage } from '@moonpay/platform-protocol/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":";AAqBA,SAAS,oBAAAA,yBAAwB;;;ACiBjC,SAAS,wBAAwB;AAGjC,SAAS,KAAK,UAAU;AAWxB;AAAA,EACE;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAGA;AAAA,OACK;;;ACzDP,IAAM,0BAA0B;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,SAAS,gBAAgB,QAAyB;AAChD,SAAO,wBAAwB,KAAK,CAAC,YAAY,QAAQ,KAAK,MAAM,CAAC;AACvE;AAUO,IAAM,kBAAN,MAAgD;AAAA,EAC7C,SAAmC;AAAA,EACnC,YAAgC;AAAA,EAChC,gBAA+B;AAAA,EAC/B,WAAkD,CAAC;AAAA,EACnD,gBAAwD;AAAA,EAEhE,OAAO,KAAa,SAA6B;AAC/C,UAAM,YAAY,QAAQ;AAC1B,SAAK,YAAY;AAEjB,UAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,WAAO,MAAM;AACb,WAAO,MAAM,SAAS;AAEtB,QAAI,QAAQ,QAAQ;AAClB,aAAO,MAAM,QAAQ;AACrB,aAAO,MAAM,SAAS;AACtB,aAAO,MAAM,WAAW;AACxB,aAAO,MAAM,WAAW;AAAA,IAC1B,OAAO;AACL,aAAO,MAAM,QAAQ;AACrB,aAAO,MAAM,SAAS;AAAA,IACxB;AAEA,WAAO,QAAQ;AAEf,SAAK,SAAS;AAGd,SAAK,gBAAgB,KAAK,cAAc,KAAK,IAAI;AACjD,WAAO,iBAAiB,WAAW,KAAK,aAAa;AAErD,cAAU,YAAY,MAAM;AAAA,EAC9B;AAAA,EAEA,YAAY,SAAgC;AAC1C,QAAI,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IACxC,gBAAgB,CAAC,IAAI,SAAS,KAAK,eAAe,IAAI,IAAI;AAAA,IAC1D,gBAAgB,CAAC,OAAO,KAAK,eAAe,EAAE;AAAA,IAC9C,sBAAsB,CAAC,IAAI,SAAS,KAAK,qBAAqB,IAAI,IAAI;AAAA,IACtE,qBAAqB,CAAC,IAAI,SAAS,KAAK,oBAAoB,IAAI,IAAI;AAAA,EACtE;AACF;","names":["ConnectionStatus","options"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moonpay/platform-sdk-web",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "MoonPay Developer Platform SDK for web browsers",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@moonpay/platform-protocol": "1.0.2",
|
|
32
|
-
"@moonpay/platform-sdk-core": "1.0
|
|
32
|
+
"@moonpay/platform-sdk-core": "1.2.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"tsup": "8.0.0",
|