@moonpay/platform-protocol 0.3.0-next.1 → 1.0.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.
Files changed (175) hide show
  1. package/README.md +45 -0
  2. package/dist/{index.cjs → api/errors.cjs} +7 -51
  3. package/dist/api/errors.cjs.map +1 -0
  4. package/dist/api/errors.d.cts +46 -0
  5. package/dist/api/errors.d.ts +46 -0
  6. package/dist/api/errors.js +27 -0
  7. package/dist/api/errors.js.map +1 -0
  8. package/dist/api/identity.cjs +19 -0
  9. package/dist/api/identity.cjs.map +1 -0
  10. package/dist/api/identity.d.cts +156 -0
  11. package/dist/api/identity.d.ts +156 -0
  12. package/dist/api/identity.js +1 -0
  13. package/dist/api/identity.js.map +1 -0
  14. package/dist/api/index.cjs +19 -0
  15. package/dist/api/index.cjs.map +1 -0
  16. package/dist/api/index.d.cts +466 -0
  17. package/dist/api/index.d.ts +466 -0
  18. package/dist/api/index.js +1 -0
  19. package/dist/api/index.js.map +1 -0
  20. package/dist/frames/add-card.cjs +19 -0
  21. package/dist/frames/add-card.cjs.map +1 -0
  22. package/dist/frames/add-card.d.cts +24 -0
  23. package/dist/frames/add-card.d.ts +24 -0
  24. package/dist/frames/add-card.js +1 -0
  25. package/dist/frames/add-card.js.map +1 -0
  26. package/dist/frames/apple-pay.cjs +19 -0
  27. package/dist/frames/apple-pay.cjs.map +1 -0
  28. package/dist/frames/apple-pay.d.cts +22 -0
  29. package/dist/frames/apple-pay.d.ts +22 -0
  30. package/dist/frames/apple-pay.js +1 -0
  31. package/dist/frames/apple-pay.js.map +1 -0
  32. package/dist/frames/auth.cjs +19 -0
  33. package/dist/frames/auth.cjs.map +1 -0
  34. package/dist/frames/auth.d.cts +15 -0
  35. package/dist/frames/auth.d.ts +15 -0
  36. package/dist/frames/auth.js +1 -0
  37. package/dist/frames/auth.js.map +1 -0
  38. package/dist/frames/buy-button.cjs +19 -0
  39. package/dist/frames/buy-button.cjs.map +1 -0
  40. package/dist/frames/buy-button.d.cts +21 -0
  41. package/dist/frames/buy-button.d.ts +21 -0
  42. package/dist/frames/buy-button.js +1 -0
  43. package/dist/frames/buy-button.js.map +1 -0
  44. package/dist/frames/buy.cjs +19 -0
  45. package/dist/frames/buy.cjs.map +1 -0
  46. package/dist/frames/buy.d.cts +22 -0
  47. package/dist/frames/buy.d.ts +22 -0
  48. package/dist/frames/buy.js +1 -0
  49. package/dist/frames/buy.js.map +1 -0
  50. package/dist/frames/challenge.cjs +19 -0
  51. package/dist/frames/challenge.cjs.map +1 -0
  52. package/dist/frames/challenge.d.cts +30 -0
  53. package/dist/frames/challenge.d.ts +30 -0
  54. package/dist/frames/challenge.js +1 -0
  55. package/dist/frames/challenge.js.map +1 -0
  56. package/dist/frames/connect.cjs +19 -0
  57. package/dist/frames/connect.cjs.map +1 -0
  58. package/dist/frames/connect.d.cts +9 -0
  59. package/dist/frames/connect.d.ts +9 -0
  60. package/dist/frames/connect.js +1 -0
  61. package/dist/frames/connect.js.map +1 -0
  62. package/dist/frames/google-pay.cjs +19 -0
  63. package/dist/frames/google-pay.cjs.map +1 -0
  64. package/dist/frames/google-pay.d.cts +22 -0
  65. package/dist/frames/google-pay.d.ts +22 -0
  66. package/dist/frames/google-pay.js +1 -0
  67. package/dist/frames/google-pay.js.map +1 -0
  68. package/dist/frames/reset.cjs +19 -0
  69. package/dist/frames/reset.cjs.map +1 -0
  70. package/dist/frames/reset.d.cts +12 -0
  71. package/dist/frames/reset.d.ts +12 -0
  72. package/dist/frames/reset.js +1 -0
  73. package/dist/frames/reset.js.map +1 -0
  74. package/dist/frames/widget.cjs +19 -0
  75. package/dist/frames/widget.cjs.map +1 -0
  76. package/dist/frames/widget.d.cts +19 -0
  77. package/dist/frames/widget.d.ts +19 -0
  78. package/dist/frames/widget.js +1 -0
  79. package/dist/frames/widget.js.map +1 -0
  80. package/dist/models/challenge.cjs +19 -0
  81. package/dist/models/challenge.cjs.map +1 -0
  82. package/dist/models/challenge.d.cts +12 -0
  83. package/dist/models/challenge.d.ts +12 -0
  84. package/dist/models/challenge.js +1 -0
  85. package/dist/models/challenge.js.map +1 -0
  86. package/dist/models/connection.cjs +46 -0
  87. package/dist/models/connection.cjs.map +1 -0
  88. package/dist/models/connection.d.cts +142 -0
  89. package/dist/models/connection.d.ts +142 -0
  90. package/dist/models/connection.js +20 -0
  91. package/dist/models/connection.js.map +1 -0
  92. package/dist/models/transaction.cjs +19 -0
  93. package/dist/models/transaction.cjs.map +1 -0
  94. package/dist/models/transaction.d.cts +15 -0
  95. package/dist/models/transaction.d.ts +15 -0
  96. package/dist/models/transaction.js +1 -0
  97. package/dist/models/transaction.js.map +1 -0
  98. package/dist/protocol.cjs +34 -0
  99. package/dist/protocol.cjs.map +1 -0
  100. package/dist/protocol.d.cts +30 -0
  101. package/dist/protocol.d.ts +30 -0
  102. package/dist/protocol.js +8 -0
  103. package/dist/protocol.js.map +1 -0
  104. package/dist/result.cjs +40 -0
  105. package/dist/result.cjs.map +1 -0
  106. package/dist/result.d.cts +30 -0
  107. package/dist/result.d.ts +30 -0
  108. package/dist/result.js +14 -0
  109. package/dist/result.js.map +1 -0
  110. package/dist/sdks/add-card.cjs +19 -0
  111. package/dist/sdks/add-card.cjs.map +1 -0
  112. package/dist/sdks/add-card.d.cts +20 -0
  113. package/dist/sdks/add-card.d.ts +20 -0
  114. package/dist/sdks/add-card.js +1 -0
  115. package/dist/sdks/add-card.js.map +1 -0
  116. package/dist/sdks/apple-pay.cjs +19 -0
  117. package/dist/sdks/apple-pay.cjs.map +1 -0
  118. package/dist/sdks/apple-pay.d.cts +36 -0
  119. package/dist/sdks/apple-pay.d.ts +36 -0
  120. package/dist/sdks/apple-pay.js +1 -0
  121. package/dist/sdks/apple-pay.js.map +1 -0
  122. package/dist/sdks/auth.cjs +19 -0
  123. package/dist/sdks/auth.cjs.map +1 -0
  124. package/dist/sdks/auth.d.cts +18 -0
  125. package/dist/sdks/auth.d.ts +18 -0
  126. package/dist/sdks/auth.js +1 -0
  127. package/dist/sdks/auth.js.map +1 -0
  128. package/dist/sdks/buy-button.cjs +19 -0
  129. package/dist/sdks/buy-button.cjs.map +1 -0
  130. package/dist/sdks/buy-button.d.cts +21 -0
  131. package/dist/sdks/buy-button.d.ts +21 -0
  132. package/dist/sdks/buy-button.js +1 -0
  133. package/dist/sdks/buy-button.js.map +1 -0
  134. package/dist/sdks/buy.cjs +19 -0
  135. package/dist/sdks/buy.cjs.map +1 -0
  136. package/dist/sdks/buy.d.cts +23 -0
  137. package/dist/sdks/buy.d.ts +23 -0
  138. package/dist/sdks/buy.js +1 -0
  139. package/dist/sdks/buy.js.map +1 -0
  140. package/dist/sdks/challenge.cjs +19 -0
  141. package/dist/sdks/challenge.cjs.map +1 -0
  142. package/dist/sdks/challenge.d.cts +22 -0
  143. package/dist/sdks/challenge.d.ts +22 -0
  144. package/dist/sdks/challenge.js +1 -0
  145. package/dist/sdks/challenge.js.map +1 -0
  146. package/dist/sdks/connect.cjs +19 -0
  147. package/dist/sdks/connect.cjs.map +1 -0
  148. package/dist/sdks/connect.d.cts +20 -0
  149. package/dist/sdks/connect.d.ts +20 -0
  150. package/dist/sdks/connect.js +1 -0
  151. package/dist/sdks/connect.js.map +1 -0
  152. package/dist/sdks/google-pay.cjs +19 -0
  153. package/dist/sdks/google-pay.cjs.map +1 -0
  154. package/dist/sdks/google-pay.d.cts +36 -0
  155. package/dist/sdks/google-pay.d.ts +36 -0
  156. package/dist/sdks/google-pay.js +1 -0
  157. package/dist/sdks/google-pay.js.map +1 -0
  158. package/dist/sdks/reset.cjs +19 -0
  159. package/dist/sdks/reset.cjs.map +1 -0
  160. package/dist/sdks/reset.d.cts +5 -0
  161. package/dist/sdks/reset.d.ts +5 -0
  162. package/dist/sdks/reset.js +1 -0
  163. package/dist/sdks/reset.js.map +1 -0
  164. package/dist/sdks/widget.cjs +19 -0
  165. package/dist/sdks/widget.cjs.map +1 -0
  166. package/dist/sdks/widget.d.cts +26 -0
  167. package/dist/sdks/widget.d.ts +26 -0
  168. package/dist/sdks/widget.js +1 -0
  169. package/dist/sdks/widget.js.map +1 -0
  170. package/package.json +278 -11
  171. package/dist/index.cjs.map +0 -1
  172. package/dist/index.d.cts +0 -1289
  173. package/dist/index.d.ts +0 -1289
  174. package/dist/index.js +0 -63
  175. package/dist/index.js.map +0 -1
package/dist/index.js DELETED
@@ -1,63 +0,0 @@
1
- // src/connection.ts
2
- var ConnectionStatus = /* @__PURE__ */ ((ConnectionStatus2) => {
3
- ConnectionStatus2["connectionRequired"] = "connectionRequired";
4
- ConnectionStatus2["active"] = "active";
5
- ConnectionStatus2["unavailable"] = "unavailable";
6
- ConnectionStatus2["pending"] = "pending";
7
- ConnectionStatus2["failed"] = "failed";
8
- ConnectionStatus2["termsAcceptanceRequired"] = "termsAcceptanceRequired";
9
- return ConnectionStatus2;
10
- })(ConnectionStatus || {});
11
-
12
- // src/errors.ts
13
- var ConnectionErrorCode = /* @__PURE__ */ ((ConnectionErrorCode2) => {
14
- ConnectionErrorCode2["validationError"] = "validationError";
15
- ConnectionErrorCode2["connectionFailedGeneric"] = "generic";
16
- return ConnectionErrorCode2;
17
- })(ConnectionErrorCode || {});
18
- var DevPlatformApiErrorCodes = {
19
- unknownError: "unknown_error",
20
- unauthorized: "unauthorized",
21
- forbidden: "forbidden",
22
- notFound: "not_found",
23
- invalidRequest: "invalid_request",
24
- notImplemented: "not_implemented",
25
- tooManyRequests: "too_many_requests",
26
- notAllowed: "not_allowed",
27
- conflict: "conflict",
28
- unprocessableEntity: "unprocessable_entity",
29
- sseTimeout: "sse_timeout",
30
- sseError: "sse_error",
31
- connectionRequired: "connection_required",
32
- connectionPending: "connection_pending",
33
- connectionUnavailable: "connection_unavailable",
34
- serviceUnavailable: "service_unavailable",
35
- requirementsIncomplete: "requirements_incomplete",
36
- verificationRejected: "verification_rejected",
37
- countryMismatch: "country_mismatch",
38
- unsupportedCountry: "unsupported_country"
39
- };
40
-
41
- // src/message.ts
42
- var HANDSHAKE_REQUEST_KIND = "handshake";
43
- var HANDSHAKE_ACK_KIND = "ack";
44
-
45
- // src/result.ts
46
- var ok = (value) => ({
47
- ok: true,
48
- value
49
- });
50
- var err = (error) => ({
51
- ok: false,
52
- error
53
- });
54
- export {
55
- ConnectionErrorCode,
56
- ConnectionStatus,
57
- DevPlatformApiErrorCodes,
58
- HANDSHAKE_ACK_KIND,
59
- HANDSHAKE_REQUEST_KIND,
60
- err,
61
- ok
62
- };
63
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/connection.ts","../src/errors.ts","../src/message.ts","../src/result.ts"],"sourcesContent":["// ---------------------------------------------------------------------------\n// Connection statuses\n// ---------------------------------------------------------------------------\n\nexport enum ConnectionStatus {\n /**\n * New or expired user — needs the full connect flow.\n */\n connectionRequired = 'connectionRequired',\n\n /**\n * Valid connection — encrypted credentials are included.\n */\n active = 'active',\n\n /**\n * Restricted location — connection cannot be used.\n */\n unavailable = 'unavailable',\n\n /**\n * KYC decision delayed — may resolve on a subsequent visit.\n */\n pending = 'pending',\n\n /**\n * Terminal failure — KYC fail, rejection, etc.\n */\n failed = 'failed',\n\n /**\n * Customer has no valid Terms of Use attestation on file (headless/Identity API partners).\n * Display Terms of Use in your own UI, capture acceptance, call\n * `POST /platform/v1/terms/attestations`, then retry the connection.\n */\n termsAcceptanceRequired = 'termsAcceptanceRequired',\n}\n\nexport interface ConnectionRequired {\n status: ConnectionStatus.connectionRequired;\n /**\n * Base64-encoded, X25519+AES-GCM encrypted anonymous token payload.\n * These are frame-internal tokens used by the connect frame — they cannot be\n * used to call MoonPay APIs directly. Decrypt via `decryptCredentials()` only\n * if you need the `clientToken` to bootstrap the connect frame manually.\n */\n credentials: string;\n /**\n * Capabilities and regulatory requirements available before authentication, if any.\n * Present when Apple Pay 1TAP is enabled for the partner.\n */\n capabilities?: CustomerCapabilities;\n}\n\nexport interface ActiveConnection {\n status: ConnectionStatus.active;\n /** The authenticated MoonPay customer. */\n customer: { id: string };\n /**\n * Base64-encoded, X25519+AES-GCM encrypted JSON containing:\n * ```json\n * {\n * \"accessToken\": \"<token>\",\n * \"clientToken\": \"<token>\",\n * \"expiresAt\": \"<iso8601>\"\n * }\n * ```\n *\n * - `accessToken`: A token that can be used to make API requests from the client.\n * - `clientToken`: A token that can be used to initialize sensitive frames such as Apple Pay.\n * - `expiresAt`: An ISO 8601 formatted string indicating when the tokens expire.\n */\n credentials: string;\n /**\n * Capabilities and regulatory requirements for the authenticated customer.\n */\n capabilities: CustomerCapabilities;\n}\n\nexport interface UnavailableConnection {\n status: ConnectionStatus.unavailable;\n}\n\nexport interface PendingConnection {\n status: ConnectionStatus.pending;\n}\n\nexport interface FailedConnection {\n status: ConnectionStatus.failed;\n reason: string;\n}\n\nexport interface TermsAcceptanceRequiredConnection {\n status: ConnectionStatus.termsAcceptanceRequired;\n}\n\n/** Discriminated union of all connection result statuses. */\nexport type Connection =\n | ConnectionRequired\n | ActiveConnection\n | UnavailableConnection\n | PendingConnection\n | FailedConnection\n | TermsAcceptanceRequiredConnection;\n\n// ---------------------------------------------------------------------------\n// Decrypted credentials (what the SDK exposes after decryption)\n// ---------------------------------------------------------------------------\n\nexport interface DecryptedCredentials {\n accessToken: string;\n clientToken: string;\n expiresAt: string;\n}\n\n// ---------------------------------------------------------------------------\n// Customer capabilities\n// ---------------------------------------------------------------------------\n\n/**\n * Capabilities and regulatory requirements for the authenticated customer.\n */\nexport interface CustomerCapabilities {\n /** Capabilities for the ramps (buy and sell) product. */\n ramps?: RampsCapability;\n /** Capabilities for the Apple Pay 1TAP flow. Present when 1TAP is enabled for the partner and the customer matches. */\n oneTapApplePay?: RampsCapability;\n}\n\n/**\n * Capabilities and requirements for the ramps (buy and sell) product.\n */\nexport interface RampsCapability {\n /** Regulatory requirements for ramps operations in the customer's jurisdiction. */\n requirements: RampsRequirements;\n}\n\n/**\n * Regulatory requirements that apply to ramps operations for the customer.\n */\nexport interface RampsRequirements {\n /**\n * Present when the customer's jurisdiction requires payment disclosures\n * before a ramps transaction. Omitted when no disclosures are required.\n */\n paymentDisclosures?: PaymentDisclosuresRequirement;\n}\n\n/**\n * A jurisdiction that requires payment disclosures before a ramps transaction.\n */\nexport interface PaymentDisclosuresRequirement {\n /** The ISO 3166-1 alpha-3 country code for the jurisdiction. */\n country: string;\n /** The state or province code within the country. */\n administrativeArea: string;\n}\n","// ---------------------------------------------------------------------------\n// Connection errors (from connect/check-connection frames)\n// ---------------------------------------------------------------------------\n\nexport enum ConnectionErrorCode {\n validationError = 'validationError',\n /** Wire value is `'generic'`. */\n connectionFailedGeneric = 'generic',\n}\n\nexport interface ConfigValidationFieldError {\n code: 'invalidSessionToken' | 'invalidClientToken' | 'invalidPublicKey';\n message: string;\n}\n\nexport type ConnectionError =\n | {\n code: ConnectionErrorCode.validationError;\n errors: ConfigValidationFieldError[];\n }\n | {\n code: ConnectionErrorCode.connectionFailedGeneric;\n message?: string;\n };\n\n// ---------------------------------------------------------------------------\n// API errors\n// ---------------------------------------------------------------------------\n\nexport const DevPlatformApiErrorCodes = {\n unknownError: 'unknown_error',\n unauthorized: 'unauthorized',\n forbidden: 'forbidden',\n notFound: 'not_found',\n invalidRequest: 'invalid_request',\n notImplemented: 'not_implemented',\n tooManyRequests: 'too_many_requests',\n notAllowed: 'not_allowed',\n conflict: 'conflict',\n unprocessableEntity: 'unprocessable_entity',\n sseTimeout: 'sse_timeout',\n sseError: 'sse_error',\n connectionRequired: 'connection_required',\n connectionPending: 'connection_pending',\n connectionUnavailable: 'connection_unavailable',\n serviceUnavailable: 'service_unavailable',\n requirementsIncomplete: 'requirements_incomplete',\n verificationRejected: 'verification_rejected',\n countryMismatch: 'country_mismatch',\n unsupportedCountry: 'unsupported_country',\n} as const;\n\nexport type DevPlatformApiErrorCode =\n (typeof DevPlatformApiErrorCodes)[keyof typeof DevPlatformApiErrorCodes];\n\nexport interface DevPlatformApiErrorDetail {\n field?: string;\n message: string;\n}\n\n/** Shape returned by the MoonPay Platform API on error responses. */\nexport interface DevPlatformApiError {\n code: DevPlatformApiErrorCode;\n message: string;\n errors?: DevPlatformApiErrorDetail[];\n}\n\n// ---------------------------------------------------------------------------\n// SDK-level error types\n// ---------------------------------------------------------------------------\n\nexport interface GetConnectionError {\n message: string;\n}\n\nexport interface ConnectError {\n message: string;\n}\n\nexport interface SetupWidgetError {\n kind: 'configurationError' | 'apiError' | 'genericError';\n message: string;\n}\n\nexport interface SetupApplePayError {\n kind:\n | 'invalidQuote'\n | 'quoteExpired'\n | 'applePayUnavailable'\n | 'oneTapApplePaySecondFactorRequired'\n | 'genericError';\n message: string;\n}\n\nexport interface SetupGooglePayError {\n kind: 'invalidQuote' | 'quoteExpired' | 'googlePayUnavailable' | 'genericError';\n message: string;\n}\n\nexport type GetQuoteError = DevPlatformApiError;\nexport type GetPaymentMethodsError = DevPlatformApiError;\nexport type GetTransactionsError = DevPlatformApiError;\nexport type CreateSessionError = DevPlatformApiError;\nexport type RevokeSessionError = DevPlatformApiError;\nexport type CreateIdentityError = DevPlatformApiError;\nexport type GetIdentityError = DevPlatformApiError;\nexport type UpdateIdentityError = DevPlatformApiError;\nexport type VerifyIdentityError = DevPlatformApiError;\nexport type GetIdentityUploadUrlError = DevPlatformApiError;\nexport type SubmitIdentityFilesError = DevPlatformApiError;\n\nexport interface SetupBuyError {\n kind: 'configurationError' | 'genericError';\n message: string;\n}\n\nexport interface SetupBuyButtonError {\n kind: 'configurationError' | 'genericError';\n message: string;\n}\n\nexport interface SetupChallengeError {\n kind: 'configurationError' | 'genericError';\n message: string;\n}\n\nexport interface SetupAuthError {\n kind: 'configurationError' | 'genericError';\n message: string;\n}\n\nexport interface SetupAddCardError {\n kind: 'configurationError' | 'genericError';\n message: string;\n}\n\nexport interface ResetConnectionError {\n message: string;\n}\n","// ---------------------------------------------------------------------------\n// Wire format\n// ---------------------------------------------------------------------------\n\n/** The V2 protocol envelope sent over postMessage between frames and SDK. */\nexport interface ProtocolMessage<K extends string = string, P = unknown> {\n version: 2;\n meta: { channelId: string };\n kind: K;\n payload?: P;\n}\n\n// ---------------------------------------------------------------------------\n// Handshake\n// ---------------------------------------------------------------------------\n\nexport const HANDSHAKE_REQUEST_KIND = 'handshake' as const;\nexport const HANDSHAKE_ACK_KIND = 'ack' as const;\n\nexport type HandshakeRequest = ProtocolMessage<typeof HANDSHAKE_REQUEST_KIND>;\nexport type HandshakeAck = ProtocolMessage<typeof HANDSHAKE_ACK_KIND>;\n\n// ---------------------------------------------------------------------------\n// Frame → Parent message maps\n// ---------------------------------------------------------------------------\n\n/**\n * Maps message `kind` to its payload type for the widget frame.\n * Frames use this to type-check what they send; SDK uses it to type-check\n * what it receives.\n */\nexport interface WidgetMessageMap {\n ready: void;\n error: {\n code: 'configurationError' | 'apiError' | 'generic';\n message: string;\n };\n transactionCreated: {\n transaction: { id: string; status: string };\n };\n complete: {\n transaction: FrameTransaction;\n };\n close: void;\n}\n\n/**\n * Maps message `kind` to its payload type for the Apple Pay frame\n * (child → parent direction).\n */\nexport interface ApplePayInboundMessageMap {\n ready: void;\n error: {\n code:\n | 'configurationError'\n | 'quoteExpired'\n | 'invalidQuote'\n | 'applePayUnavailable'\n | 'generic'\n | 'oneTapApplePaySecondFactorRequired';\n message: string;\n };\n complete: {\n transaction: FrameTransaction;\n };\n}\n\n/**\n * Maps message `kind` to its payload type for the Apple Pay frame\n * (parent → child direction).\n */\nexport interface ApplePayOutboundMessageMap {\n setQuote: { quote: { signature: string } };\n}\n\n/**\n * Maps message `kind` to its payload type for the Google Pay frame\n * (child → parent direction).\n */\nexport interface GooglePayInboundMessageMap {\n ready: void;\n error: {\n code:\n | 'configurationError'\n | 'quoteExpired'\n | 'invalidQuote'\n | 'googlePayUnavailable'\n | 'generic';\n message: string;\n };\n /** Signals that the pipeline requires a challenge step. Load `url` in a challenge frame. */\n challenge: { kind: 'frame'; url: string };\n complete: {\n transaction: FrameTransaction;\n };\n}\n\n/**\n * Maps message `kind` to its payload type for the Google Pay frame\n * (parent → child direction).\n */\nexport interface GooglePayOutboundMessageMap {\n setQuote: { quote: { signature: string } };\n}\n\n/**\n * Maps message `kind` to its payload type for the connect/check-connection\n * frame (child → parent direction).\n */\nexport interface ConnectMessageMap {\n ready: void;\n error: ConnectionError;\n complete:\n | ConnectionRequired\n | ActiveConnection\n | UnavailableConnection\n | PendingConnection\n | FailedConnection\n | TermsAcceptanceRequiredConnection;\n}\n\n/**\n * Maps message `kind` to its payload type for the auth frame\n * (child → parent direction).\n *\n * The auth frame is the lighter-weight counterpart to the connect frame:\n * partners (typically headless / Identity-API integrations) drive the\n * customer through email/OTP authentication only, then receive the\n * encrypted credentials. The frame is gated on `clientToken` rather than\n * `sessionToken` — partners obtain the `clientToken` via the prior\n * `getConnection()` probe (it is decrypted into `core.context` on a\n * `connectionRequired` result).\n */\nexport interface AuthMessageMap {\n ready: void;\n error: ConnectionError;\n complete: ActiveConnection | TermsAcceptanceRequiredConnection;\n}\n\n// ---------------------------------------------------------------------------\n// Buy frame\n// ---------------------------------------------------------------------------\n\n/**\n * Maps message `kind` to its payload type for the buy frame\n * (child → parent direction).\n *\n * The buy frame executes the full buy pipeline (pre-check → create →\n * post-check) headlessly. It may escalate to a challenge frame mid-pipeline.\n */\nexport interface BuyMessageMap {\n ready: void;\n complete: { transaction: FrameTransaction };\n /** Signals that the pipeline requires a challenge step. Load `url` in a challenge frame. */\n challenge: { kind: string; url: string };\n error: { code: string; message: string };\n}\n\n/**\n * Maps message `kind` to its payload type for the buy frame\n * (parent → child direction).\n */\nexport interface BuyOutboundMessageMap {\n setQuote: { quote: { signature: string } };\n}\n\n// ---------------------------------------------------------------------------\n// Buy-button frame\n// ---------------------------------------------------------------------------\n\n/**\n * Maps message `kind` to its payload type for the buy-button frame\n * (child → parent direction).\n *\n * The buy-button frame renders a payment button (card, Apple Pay, Google Pay)\n * and runs the buy pipeline on tap. It may escalate to a challenge frame.\n */\nexport interface BuyButtonMessageMap {\n complete: { transaction: FrameTransaction };\n /** Signals that the pipeline requires a challenge step. Load `url` in a challenge frame. */\n challenge: { kind: string; url: string };\n error: { code: string; message: string };\n}\n\n/**\n * Maps message `kind` to its payload type for the buy-button frame\n * (parent → child direction).\n */\nexport interface BuyButtonOutboundMessageMap {\n setQuote: { quote: { signature: string } };\n}\n\n// ---------------------------------------------------------------------------\n// Challenge frame\n// ---------------------------------------------------------------------------\n\nexport type ChallengeCompleteResult =\n | { flow: 'buy'; transaction: FrameTransaction }\n | { flow: 'identity'; identityId: string };\n\nexport type ChallengeCancellation =\n | { flow: 'buy'; transactionId?: string; challengeToken?: string }\n | { flow: 'identity' };\n\n/**\n * Maps message `kind` to its payload type for the challenge frame\n * (child → parent direction).\n *\n * The challenge frame is fully self-contained — it is driven by the\n * `challengeToken` URL param. There is no parent → child message map.\n */\nexport interface ChallengeMessageMap {\n ready: void;\n complete: ChallengeCompleteResult;\n /** User dismissed the challenge. Carry `transactionId` / `challengeToken` to resume. */\n cancelled: ChallengeCancellation;\n error: { code: string; message: string };\n}\n\n// ---------------------------------------------------------------------------\n// Reset frame\n// ---------------------------------------------------------------------------\n\n/**\n * Maps message `kind` to its payload type for the reset frame\n * (child → parent direction).\n *\n * The reset frame clears the customer's MoonPay connection for the partner.\n * It is fully driven by the `sessionToken` URL param. There is no\n * parent → child message map.\n */\nexport interface ResetMessageMap {\n complete: void;\n error: { code: string; message: string };\n}\n\n// ---------------------------------------------------------------------------\n// Add-card frame\n// ---------------------------------------------------------------------------\n\n/** Card returned by the add-card frame on successful creation. */\nexport interface CardResponse {\n id: string;\n /** Payment method type, e.g. `'card'`. */\n type: string;\n /** Card sub-type, e.g. `'credit'` or `'debit'`. */\n cardType: string;\n /** Card network brand, e.g. `'visa'` or `'mastercard'`. */\n brand: string;\n last4: string;\n expirationMonth: string;\n expirationYear: string;\n availability: { active: true };\n}\n\n/**\n * Maps message `kind` to its payload type for the add-card frame\n * (child → parent direction).\n *\n * There is no parent → child message map for the add-card frame.\n */\nexport interface AddCardMessageMap {\n complete: { card: CardResponse };\n error: { code: 'generic' | 'configurationError'; message: string };\n}\n\n// ---------------------------------------------------------------------------\n// Transaction type used inside frame messages\n// ---------------------------------------------------------------------------\n\nimport type {\n ActiveConnection,\n ConnectionRequired,\n FailedConnection,\n PendingConnection,\n TermsAcceptanceRequiredConnection,\n UnavailableConnection,\n} from './connection.js';\nimport type { ConnectionError } from './errors.js';\n\n/** Transaction shape as sent within frame postMessage payloads. */\nexport type FrameTransaction =\n | { id: string; status: string }\n | { id?: string; status: 'failed'; failureReason: string };\n\n// ---------------------------------------------------------------------------\n// Typed message constructors (utility types)\n// ---------------------------------------------------------------------------\n\n/** A ProtocolMessage typed to a specific message map entry. */\nexport type TypedMessage<\n Map extends Record<string, unknown>,\n K extends keyof Map & string,\n> = Map[K] extends void ? ProtocolMessage<K, undefined> : ProtocolMessage<K, Map[K]>;\n\n/** Union of all typed messages for a given message map. */\nexport type MessageUnion<Map extends Record<string, unknown>> = {\n [K in keyof Map & string]: TypedMessage<Map, K>;\n}[keyof Map & string];\n","/**\n * A discriminated union representing either a successful value or an error.\n * SDK methods return this type instead of throwing exceptions.\n */\nexport type Result<T, E> = { ok: true; value: T } | { ok: false; error: E };\n\n/** A Result variant for operations that produce no value on success. */\nexport type EmptyResult<E> = { ok: true } | { ok: false; error: E };\n\n/** Construct a successful Result. */\nexport const ok = <T>(value: T): { ok: true; value: T } => ({\n ok: true,\n value,\n});\n\n/** Construct a failed Result. */\nexport const err = <E>(error: E): { ok: false; error: E } => ({\n ok: false,\n error,\n});\n"],"mappings":";AAIO,IAAK,mBAAL,kBAAKA,sBAAL;AAIL,EAAAA,kBAAA,wBAAqB;AAKrB,EAAAA,kBAAA,YAAS;AAKT,EAAAA,kBAAA,iBAAc;AAKd,EAAAA,kBAAA,aAAU;AAKV,EAAAA,kBAAA,YAAS;AAOT,EAAAA,kBAAA,6BAA0B;AA/BhB,SAAAA;AAAA,GAAA;;;ACAL,IAAK,sBAAL,kBAAKC,yBAAL;AACL,EAAAA,qBAAA,qBAAkB;AAElB,EAAAA,qBAAA,6BAA0B;AAHhB,SAAAA;AAAA,GAAA;AAyBL,IAAM,2BAA2B;AAAA,EACtC,cAAc;AAAA,EACd,cAAc;AAAA,EACd,WAAW;AAAA,EACX,UAAU;AAAA,EACV,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,iBAAiB;AAAA,EACjB,YAAY;AAAA,EACZ,UAAU;AAAA,EACV,qBAAqB;AAAA,EACrB,YAAY;AAAA,EACZ,UAAU;AAAA,EACV,oBAAoB;AAAA,EACpB,mBAAmB;AAAA,EACnB,uBAAuB;AAAA,EACvB,oBAAoB;AAAA,EACpB,wBAAwB;AAAA,EACxB,sBAAsB;AAAA,EACtB,iBAAiB;AAAA,EACjB,oBAAoB;AACtB;;;AClCO,IAAM,yBAAyB;AAC/B,IAAM,qBAAqB;;;ACP3B,IAAM,KAAK,CAAI,WAAsC;AAAA,EAC1D,IAAI;AAAA,EACJ;AACF;AAGO,IAAM,MAAM,CAAI,WAAuC;AAAA,EAC5D,IAAI;AAAA,EACJ;AACF;","names":["ConnectionStatus","ConnectionErrorCode"]}