@moonpay/platform-protocol 0.2.2 → 0.3.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +210 -2
- package/dist/index.d.ts +210 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/connection.ts","../src/errors.ts","../src/message.ts","../src/result.ts"],"sourcesContent":["// API types (clean aliases from generated OpenAPI types)\nexport type {\n Asset,\n AssetBase,\n CreateSessionTokenRequestBody,\n CreateSessionTokenReturnType,\n Fees,\n GetQuoteParams,\n LimitWithAsset,\n ListPaymentMethodsResponse,\n MonetaryFeeAmount,\n PaginationInfo,\n PaymentMethodAvailability,\n PaymentMethodCapabilities,\n PaymentMethodConfig,\n PaymentMethodType,\n Quote,\n QuoteLimitEntry,\n QuoteLimits,\n QuotePaymentMethod,\n Stage,\n StageKind,\n StageStatus,\n StoredCardPaymentMethod,\n StoredPaymentMethod,\n TermsAttestation,\n Transaction,\n TransactionCustomer,\n TransactionPaymentMethod,\n TransactionStatus,\n TransactionWithStages,\n Wallet,\n} from './api.js';\n// Commands (parent → child)\nexport type {\n SetBuyButtonQuoteCommand,\n SetBuyQuoteCommand,\n SetGooglePayQuoteCommand,\n SetQuoteCommand,\n} from './commands.js';\n// Connection statuses\nexport {\n type ActiveConnection,\n type Connection,\n type ConnectionRequired,\n ConnectionStatus,\n type CustomerCapabilities,\n type DecryptedCredentials,\n type FailedConnection,\n type PaymentDisclosuresRequirement,\n type PendingConnection,\n type RampsCapability,\n type RampsRequirements,\n type TermsAcceptanceRequiredConnection,\n type UnavailableConnection,\n} from './connection.js';\n// Errors\nexport {\n type ConfigValidationFieldError,\n type ConnectError,\n type ConnectionError,\n ConnectionErrorCode,\n type CreateSessionError,\n type DevPlatformApiError,\n type DevPlatformApiErrorCode,\n DevPlatformApiErrorCodes,\n type DevPlatformApiErrorDetail,\n type GetConnectionError,\n type GetPaymentMethodsError,\n type GetQuoteError,\n type GetTransactionsError,\n type ResetConnectionError,\n type RevokeSessionError,\n type SetupAddCardError,\n type SetupApplePayError,\n type SetupBuyButtonError,\n type SetupBuyError,\n type SetupChallengeError,\n type SetupGooglePayError,\n type SetupWidgetError,\n} from './errors.js';\n// SDK-facing events\nexport type {\n AddCardEvent,\n ApplePayEvent,\n ApplePayEventError,\n BuyButtonEvent,\n BuyEvent,\n CardResponse,\n ChallengeCancellation,\n ChallengeCompleteResult,\n ChallengeEvent,\n ConnectEvent,\n GooglePayEvent,\n GooglePayEventError,\n WidgetEvent,\n} from './events.js';\n// Protocol message envelope and message maps\nexport type {\n AddCardMessageMap,\n ApplePayInboundMessageMap,\n ApplePayOutboundMessageMap,\n BuyButtonMessageMap,\n BuyButtonOutboundMessageMap,\n BuyMessageMap,\n BuyOutboundMessageMap,\n ChallengeMessageMap,\n ConnectMessageMap,\n FrameTransaction,\n GooglePayInboundMessageMap,\n GooglePayOutboundMessageMap,\n HandshakeAck,\n HandshakeRequest,\n MessageUnion,\n ProtocolMessage,\n ResetMessageMap,\n TypedMessage,\n WidgetMessageMap,\n} from './message.js';\nexport { HANDSHAKE_ACK_KIND, HANDSHAKE_REQUEST_KIND } from './message.js';\nexport { type EmptyResult, err, ok, type Result } from './result.js';\n","// ---------------------------------------------------------------------------\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;\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 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// 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":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACIO,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"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/connection.ts","../src/errors.ts","../src/message.ts","../src/result.ts"],"sourcesContent":["// API types (clean aliases from generated OpenAPI types)\nexport type {\n Asset,\n AssetBase,\n CreateSessionTokenRequestBody,\n CreateSessionTokenReturnType,\n Fees,\n GetQuoteParams,\n LimitWithAsset,\n ListPaymentMethodsResponse,\n MonetaryFeeAmount,\n PaginationInfo,\n PaymentMethodAvailability,\n PaymentMethodCapabilities,\n PaymentMethodConfig,\n PaymentMethodType,\n Quote,\n QuoteLimitEntry,\n QuoteLimits,\n QuotePaymentMethod,\n Stage,\n StageKind,\n StageStatus,\n StoredCardPaymentMethod,\n StoredPaymentMethod,\n TermsAttestation,\n Transaction,\n TransactionCustomer,\n TransactionPaymentMethod,\n TransactionStatus,\n TransactionWithStages,\n Wallet,\n} from './api.js';\n// Commands (parent → child)\nexport type {\n SetBuyButtonQuoteCommand,\n SetBuyQuoteCommand,\n SetGooglePayQuoteCommand,\n SetQuoteCommand,\n} from './commands.js';\n// Connection statuses\nexport {\n type ActiveConnection,\n type Connection,\n type ConnectionRequired,\n ConnectionStatus,\n type CustomerCapabilities,\n type DecryptedCredentials,\n type FailedConnection,\n type PaymentDisclosuresRequirement,\n type PendingConnection,\n type RampsCapability,\n type RampsRequirements,\n type TermsAcceptanceRequiredConnection,\n type UnavailableConnection,\n} from './connection.js';\n// Errors\nexport {\n type ConfigValidationFieldError,\n type ConnectError,\n type ConnectionError,\n ConnectionErrorCode,\n type CreateIdentityError,\n type CreateSessionError,\n type DevPlatformApiError,\n type DevPlatformApiErrorCode,\n DevPlatformApiErrorCodes,\n type DevPlatformApiErrorDetail,\n type GetConnectionError,\n type GetIdentityError,\n type GetIdentityUploadUrlError,\n type GetPaymentMethodsError,\n type GetQuoteError,\n type GetTransactionsError,\n type ResetConnectionError,\n type RevokeSessionError,\n type SetupAddCardError,\n type SetupApplePayError,\n type SetupAuthError,\n type SetupBuyButtonError,\n type SetupBuyError,\n type SetupChallengeError,\n type SetupGooglePayError,\n type SetupWidgetError,\n type SubmitIdentityFilesError,\n type UpdateIdentityError,\n type VerifyIdentityError,\n} from './errors.js';\n// SDK-facing events\nexport type {\n AddCardEvent,\n ApplePayEvent,\n ApplePayEventError,\n AuthEvent,\n BuyButtonEvent,\n BuyEvent,\n CardResponse,\n ChallengeCancellation,\n ChallengeCompleteResult,\n ChallengeEvent,\n ConnectEvent,\n GooglePayEvent,\n GooglePayEventError,\n WidgetEvent,\n} from './events.js';\n// Identity API\nexport type {\n CapabilityProduct,\n CreateIdentityRequestBody,\n CreateIdentityResidentialAddress,\n Identity,\n IdentityBasicDetailsSubmission,\n IdentityCapability,\n IdentityFileMimeType,\n IdentityFileSide,\n IdentityFileSubmission,\n IdentityFileType,\n IdentityFileUploadUrl,\n IdentityFileUploadUrlHeaders,\n IdentityFileUploadUrlRequestBody,\n IdentityPhoneNumberSubmission,\n IdentityResidentialAddressSubmission,\n IdentityStatus,\n IdentityTaxIdentifierGenericSubmission,\n IdentityTaxIdentifierSchemeSubmission,\n IdentityTaxIdentifierSubmission,\n IdentityTaxIdentifierType,\n IdentityVerificationChallenge,\n IdentityVerificationResponse,\n IdentityVerificationStatus,\n RequirementEntry,\n RequirementFieldName,\n RequirementItemStatus,\n Requirements,\n SubmitIdentityFilesRequestBody,\n UpdateIdentityRequestBody,\n} from './identity.js';\n// Protocol message envelope and message maps\nexport type {\n AddCardMessageMap,\n ApplePayInboundMessageMap,\n ApplePayOutboundMessageMap,\n AuthMessageMap,\n BuyButtonMessageMap,\n BuyButtonOutboundMessageMap,\n BuyMessageMap,\n BuyOutboundMessageMap,\n ChallengeMessageMap,\n ConnectMessageMap,\n FrameTransaction,\n GooglePayInboundMessageMap,\n GooglePayOutboundMessageMap,\n HandshakeAck,\n HandshakeRequest,\n MessageUnion,\n ProtocolMessage,\n ResetMessageMap,\n TypedMessage,\n WidgetMessageMap,\n} from './message.js';\nexport { HANDSHAKE_ACK_KIND, HANDSHAKE_REQUEST_KIND } from './message.js';\nexport { type EmptyResult, err, ok, type Result } from './result.js';\n","// ---------------------------------------------------------------------------\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":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACIO,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"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -45,7 +45,7 @@ type CreateSessionTokenRequestBody = {
|
|
|
45
45
|
/**
|
|
46
46
|
* A unique identifier for the customer from your system.
|
|
47
47
|
*/
|
|
48
|
-
externalCustomerId
|
|
48
|
+
externalCustomerId?: string;
|
|
49
49
|
/**
|
|
50
50
|
* The IP address of the user's device to ensure the integrity of the session. Both IPv4 and IPv6 values are supported.
|
|
51
51
|
*/
|
|
@@ -171,6 +171,10 @@ type GetQuoteResponse = {
|
|
|
171
171
|
* The rate used to convert fiat <-> crypto, expressed as the crypto value of one unit of fiat.
|
|
172
172
|
*/
|
|
173
173
|
exchangeRate: string;
|
|
174
|
+
/**
|
|
175
|
+
* Disclosures the partner must render verbatim before the customer can complete the transaction. Empty when no disclosure is required for the customer's geography, payment method, and asset combination.
|
|
176
|
+
*/
|
|
177
|
+
paymentDisclosures: Array<PaymentDisclosure>;
|
|
174
178
|
/**
|
|
175
179
|
* An opaque token representing the quote to initiate payment frames.
|
|
176
180
|
*/
|
|
@@ -289,6 +293,19 @@ type MoonPayPaymentsStoredPaymentMethodBase = {
|
|
|
289
293
|
id: string;
|
|
290
294
|
type: PaymentMethodType;
|
|
291
295
|
};
|
|
296
|
+
/**
|
|
297
|
+
* A payment disclosure that the partner must render verbatim before the customer can complete the transaction.
|
|
298
|
+
*/
|
|
299
|
+
type PaymentDisclosure = {
|
|
300
|
+
/**
|
|
301
|
+
* Stable identifier of the disclosure. Each id maps to one specific piece of text. The full list of ids and their canonical text is published in the developer documentation.
|
|
302
|
+
*/
|
|
303
|
+
id: string;
|
|
304
|
+
/**
|
|
305
|
+
* Version of the disclosure text. Bumped whenever the canonical wording for this `id` changes. Partners that receive an unknown `(id, version)` pair should fall back to a conservative disclosure and alert their integration team.
|
|
306
|
+
*/
|
|
307
|
+
version: string;
|
|
308
|
+
};
|
|
292
309
|
type PaymentMethodType = 'apple_pay' | 'card' | 'ach' | 'fps' | 'fps_open_banking' | 'google_pay' | 'sepa' | 'sepa_open_banking' | 'pix' | 'paypal' | 'venmo' | 'revolut_pay' | 'moonpay_balance' | 'interac';
|
|
293
310
|
type QuoteLimitEntry = {
|
|
294
311
|
/**
|
|
@@ -643,6 +660,12 @@ type GetPaymentMethodsError = DevPlatformApiError;
|
|
|
643
660
|
type GetTransactionsError = DevPlatformApiError;
|
|
644
661
|
type CreateSessionError = DevPlatformApiError;
|
|
645
662
|
type RevokeSessionError = DevPlatformApiError;
|
|
663
|
+
type CreateIdentityError = DevPlatformApiError;
|
|
664
|
+
type GetIdentityError = DevPlatformApiError;
|
|
665
|
+
type UpdateIdentityError = DevPlatformApiError;
|
|
666
|
+
type VerifyIdentityError = DevPlatformApiError;
|
|
667
|
+
type GetIdentityUploadUrlError = DevPlatformApiError;
|
|
668
|
+
type SubmitIdentityFilesError = DevPlatformApiError;
|
|
646
669
|
interface SetupBuyError {
|
|
647
670
|
kind: 'configurationError' | 'genericError';
|
|
648
671
|
message: string;
|
|
@@ -655,6 +678,10 @@ interface SetupChallengeError {
|
|
|
655
678
|
kind: 'configurationError' | 'genericError';
|
|
656
679
|
message: string;
|
|
657
680
|
}
|
|
681
|
+
interface SetupAuthError {
|
|
682
|
+
kind: 'configurationError' | 'genericError';
|
|
683
|
+
message: string;
|
|
684
|
+
}
|
|
658
685
|
interface SetupAddCardError {
|
|
659
686
|
kind: 'configurationError' | 'genericError';
|
|
660
687
|
message: string;
|
|
@@ -762,6 +789,23 @@ interface ConnectMessageMap {
|
|
|
762
789
|
error: ConnectionError;
|
|
763
790
|
complete: ConnectionRequired | ActiveConnection | UnavailableConnection | PendingConnection | FailedConnection | TermsAcceptanceRequiredConnection;
|
|
764
791
|
}
|
|
792
|
+
/**
|
|
793
|
+
* Maps message `kind` to its payload type for the auth frame
|
|
794
|
+
* (child → parent direction).
|
|
795
|
+
*
|
|
796
|
+
* The auth frame is the lighter-weight counterpart to the connect frame:
|
|
797
|
+
* partners (typically headless / Identity-API integrations) drive the
|
|
798
|
+
* customer through email/OTP authentication only, then receive the
|
|
799
|
+
* encrypted credentials. The frame is gated on `clientToken` rather than
|
|
800
|
+
* `sessionToken` — partners obtain the `clientToken` via the prior
|
|
801
|
+
* `getConnection()` probe (it is decrypted into `core.context` on a
|
|
802
|
+
* `connectionRequired` result).
|
|
803
|
+
*/
|
|
804
|
+
interface AuthMessageMap {
|
|
805
|
+
ready: void;
|
|
806
|
+
error: ConnectionError;
|
|
807
|
+
complete: ActiveConnection | TermsAcceptanceRequiredConnection;
|
|
808
|
+
}
|
|
765
809
|
/**
|
|
766
810
|
* Maps message `kind` to its payload type for the buy frame
|
|
767
811
|
* (child → parent direction).
|
|
@@ -1002,6 +1046,15 @@ type ConnectEvent = {
|
|
|
1002
1046
|
kind: 'complete';
|
|
1003
1047
|
payload: ConnectMessageMap['complete'];
|
|
1004
1048
|
};
|
|
1049
|
+
type AuthEvent = {
|
|
1050
|
+
kind: 'ready';
|
|
1051
|
+
} | {
|
|
1052
|
+
kind: 'error';
|
|
1053
|
+
payload: AuthMessageMap['error'];
|
|
1054
|
+
} | {
|
|
1055
|
+
kind: 'complete';
|
|
1056
|
+
payload: AuthMessageMap['complete'];
|
|
1057
|
+
};
|
|
1005
1058
|
type BuyEvent = {
|
|
1006
1059
|
kind: 'ready';
|
|
1007
1060
|
} | {
|
|
@@ -1049,6 +1102,161 @@ type AddCardEvent = {
|
|
|
1049
1102
|
payload: AddCardMessageMap['error'];
|
|
1050
1103
|
};
|
|
1051
1104
|
|
|
1105
|
+
/**
|
|
1106
|
+
* Identity API types.
|
|
1107
|
+
*
|
|
1108
|
+
* Sourced from `moonpay-api/packages/dev-platform/modules/identity/main.tsp`.
|
|
1109
|
+
* The TypeSpec is marked `@vnext` and is not yet emitted into the public
|
|
1110
|
+
* OpenAPI spec, so these types are hand-rolled. Once the spec ships, replace
|
|
1111
|
+
* with aliases re-exported from `./gen/` (same pattern as `Quote`, `Identity`,
|
|
1112
|
+
* etc. in `api.ts`).
|
|
1113
|
+
*/
|
|
1114
|
+
/** A platform capability a partner wants the customer to unlock. */
|
|
1115
|
+
type CapabilityProduct = 'ramps';
|
|
1116
|
+
/** A requested capability scoped to an identity. */
|
|
1117
|
+
interface IdentityCapability {
|
|
1118
|
+
product: CapabilityProduct;
|
|
1119
|
+
}
|
|
1120
|
+
/** The state of an identity across the KYC lifecycle. */
|
|
1121
|
+
type IdentityStatus = 'created' | 'collecting' | 'verifying' | 'challengeRequired' | 'approved' | 'rejected' | 'manualReview' | 'blocked';
|
|
1122
|
+
/** The completion state of a requirement item. */
|
|
1123
|
+
type RequirementItemStatus = 'incomplete' | 'complete';
|
|
1124
|
+
/** A field a customer must provide to fulfil a requirement. */
|
|
1125
|
+
type RequirementFieldName = 'firstName' | 'lastName' | 'dateOfBirth' | 'nationality' | 'street' | 'locality' | 'postalCode' | 'country' | 'administrativeArea' | 'ssn' | 'cpf' | 'tin';
|
|
1126
|
+
/** Status of a single requirement group on an identity. */
|
|
1127
|
+
interface RequirementEntry {
|
|
1128
|
+
status: RequirementItemStatus;
|
|
1129
|
+
requiredFields?: RequirementFieldName[];
|
|
1130
|
+
}
|
|
1131
|
+
/** Outstanding and completed requirements for the identity, keyed by category. */
|
|
1132
|
+
interface Requirements {
|
|
1133
|
+
basicDetails?: RequirementEntry;
|
|
1134
|
+
residentialAddress?: RequirementEntry;
|
|
1135
|
+
identityDocuments?: RequirementEntry;
|
|
1136
|
+
selfie?: RequirementEntry;
|
|
1137
|
+
taxIdentifiers?: RequirementEntry;
|
|
1138
|
+
proofOfAddress?: RequirementEntry;
|
|
1139
|
+
phoneNumber?: RequirementEntry;
|
|
1140
|
+
}
|
|
1141
|
+
/** Residential-address fields accepted at identity creation. */
|
|
1142
|
+
interface CreateIdentityResidentialAddress {
|
|
1143
|
+
/** ISO 3166-1 alpha-3 country code declared by the partner. */
|
|
1144
|
+
country: string;
|
|
1145
|
+
}
|
|
1146
|
+
/** Request body for creating an identity. */
|
|
1147
|
+
interface CreateIdentityRequestBody {
|
|
1148
|
+
residentialAddress: CreateIdentityResidentialAddress;
|
|
1149
|
+
/** Capabilities the partner wants the customer to unlock. Must contain at least one value. */
|
|
1150
|
+
capabilities: IdentityCapability[];
|
|
1151
|
+
}
|
|
1152
|
+
/** Customer's basic personal details. */
|
|
1153
|
+
interface IdentityBasicDetailsSubmission {
|
|
1154
|
+
firstName?: string;
|
|
1155
|
+
lastName?: string;
|
|
1156
|
+
nationality?: string;
|
|
1157
|
+
/** YYYY-MM-DD. */
|
|
1158
|
+
dateOfBirth?: string;
|
|
1159
|
+
}
|
|
1160
|
+
/** Customer's residential address. */
|
|
1161
|
+
interface IdentityResidentialAddressSubmission {
|
|
1162
|
+
country?: string;
|
|
1163
|
+
administrativeArea?: string;
|
|
1164
|
+
locality?: string;
|
|
1165
|
+
street?: string;
|
|
1166
|
+
subStreet?: string;
|
|
1167
|
+
postalCode?: string;
|
|
1168
|
+
}
|
|
1169
|
+
/** Customer's phone number in E.164 format. */
|
|
1170
|
+
interface IdentityPhoneNumberSubmission {
|
|
1171
|
+
number: string;
|
|
1172
|
+
}
|
|
1173
|
+
/** Type of tax identifier the customer is submitting. */
|
|
1174
|
+
type IdentityTaxIdentifierType = 'tin' | 'ssn' | 'cpf';
|
|
1175
|
+
/** Tax Identification Number — country must be supplied. */
|
|
1176
|
+
interface IdentityTaxIdentifierGenericSubmission {
|
|
1177
|
+
type: 'tin';
|
|
1178
|
+
country: string;
|
|
1179
|
+
value: string;
|
|
1180
|
+
}
|
|
1181
|
+
/** Country-specific tax identifier (SSN/CPF). */
|
|
1182
|
+
interface IdentityTaxIdentifierSchemeSubmission {
|
|
1183
|
+
type: 'ssn' | 'cpf';
|
|
1184
|
+
value: string;
|
|
1185
|
+
}
|
|
1186
|
+
type IdentityTaxIdentifierSubmission = IdentityTaxIdentifierGenericSubmission | IdentityTaxIdentifierSchemeSubmission;
|
|
1187
|
+
/** Request body for updating an identity by submitting one or more requirements. */
|
|
1188
|
+
interface UpdateIdentityRequestBody {
|
|
1189
|
+
residentialAddress?: IdentityResidentialAddressSubmission;
|
|
1190
|
+
basicDetails?: IdentityBasicDetailsSubmission;
|
|
1191
|
+
phoneNumber?: IdentityPhoneNumberSubmission;
|
|
1192
|
+
taxIdentifiers?: IdentityTaxIdentifierSubmission[];
|
|
1193
|
+
}
|
|
1194
|
+
/** A MoonPay-hosted challenge a partner must surface to the customer. */
|
|
1195
|
+
interface IdentityVerificationChallenge {
|
|
1196
|
+
/** Fully-formed challenge URL. */
|
|
1197
|
+
url: string;
|
|
1198
|
+
/** ISO 8601 expiry. */
|
|
1199
|
+
expiresAt: string;
|
|
1200
|
+
}
|
|
1201
|
+
/** The state of an identity verification request. */
|
|
1202
|
+
type IdentityVerificationStatus = 'approved' | 'processing' | 'challengeRequired';
|
|
1203
|
+
/** Outcome of `POST /platform/v1/identities/{id}/verifications`. */
|
|
1204
|
+
type IdentityVerificationResponse = {
|
|
1205
|
+
status: 'approved';
|
|
1206
|
+
} | {
|
|
1207
|
+
status: 'processing';
|
|
1208
|
+
} | {
|
|
1209
|
+
status: 'challengeRequired';
|
|
1210
|
+
challenge: IdentityVerificationChallenge;
|
|
1211
|
+
};
|
|
1212
|
+
/** Type of identity-related file the customer is uploading. */
|
|
1213
|
+
type IdentityFileType = 'drivingLicence' | 'nationalIdentityCard' | 'passport' | 'residencePermit' | 'selfie' | 'proofOfAddress';
|
|
1214
|
+
/** Side of a two-sided identity document. */
|
|
1215
|
+
type IdentityFileSide = 'front' | 'back';
|
|
1216
|
+
/** MIME type of the file being uploaded. */
|
|
1217
|
+
type IdentityFileMimeType = 'image/jpeg' | 'image/png' | 'application/pdf';
|
|
1218
|
+
/** Request body for issuing a presigned upload URL. */
|
|
1219
|
+
interface IdentityFileUploadUrlRequestBody {
|
|
1220
|
+
fileType: IdentityFileType;
|
|
1221
|
+
/** Required for two-sided file types (`drivingLicence`, `nationalIdentityCard`, `residencePermit`); omit for single-sided. */
|
|
1222
|
+
side?: IdentityFileSide;
|
|
1223
|
+
/** Must match the `Content-Type` header used on the subsequent upload request. */
|
|
1224
|
+
mimeType: IdentityFileMimeType;
|
|
1225
|
+
}
|
|
1226
|
+
/** Headers the partner must send when uploading the file to the presigned URL. */
|
|
1227
|
+
interface IdentityFileUploadUrlHeaders {
|
|
1228
|
+
'Content-Type': string;
|
|
1229
|
+
}
|
|
1230
|
+
/** Presigned URL the partner uses to upload an identity-related file. */
|
|
1231
|
+
interface IdentityFileUploadUrl {
|
|
1232
|
+
uploadId: string;
|
|
1233
|
+
url: string;
|
|
1234
|
+
/** ISO 8601 expiry. */
|
|
1235
|
+
expiresAt: string;
|
|
1236
|
+
headers: IdentityFileUploadUrlHeaders;
|
|
1237
|
+
}
|
|
1238
|
+
/** A single uploaded file the partner is confirming for submission. */
|
|
1239
|
+
interface IdentityFileSubmission {
|
|
1240
|
+
uploadId: string;
|
|
1241
|
+
fileType: IdentityFileType;
|
|
1242
|
+
side?: IdentityFileSide;
|
|
1243
|
+
}
|
|
1244
|
+
/** Request body for confirming one or more uploaded identity-related files. */
|
|
1245
|
+
interface SubmitIdentityFilesRequestBody {
|
|
1246
|
+
files: IdentityFileSubmission[];
|
|
1247
|
+
}
|
|
1248
|
+
/** A KYC identity. */
|
|
1249
|
+
interface Identity {
|
|
1250
|
+
id: string;
|
|
1251
|
+
status: IdentityStatus;
|
|
1252
|
+
capabilities: IdentityCapability[];
|
|
1253
|
+
requirements: Requirements;
|
|
1254
|
+
/** Present only when `status` is `challengeRequired`. */
|
|
1255
|
+
challenge?: IdentityVerificationChallenge;
|
|
1256
|
+
createdAt: string;
|
|
1257
|
+
updatedAt: string;
|
|
1258
|
+
}
|
|
1259
|
+
|
|
1052
1260
|
/**
|
|
1053
1261
|
* A discriminated union representing either a successful value or an error.
|
|
1054
1262
|
* SDK methods return this type instead of throwing exceptions.
|
|
@@ -1078,4 +1286,4 @@ declare const err: <E>(error: E) => {
|
|
|
1078
1286
|
error: E;
|
|
1079
1287
|
};
|
|
1080
1288
|
|
|
1081
|
-
export { type ActiveConnection, type AddCardEvent, type AddCardMessageMap, type ApplePayEvent, type ApplePayEventError, type ApplePayInboundMessageMap, type ApplePayOutboundMessageMap, type Asset, type AssetBase, type BuyButtonEvent, type BuyButtonMessageMap, type BuyButtonOutboundMessageMap, type BuyEvent, type BuyMessageMap, type BuyOutboundMessageMap, type CardResponse, type ChallengeCancellation, type ChallengeCompleteResult, type ChallengeEvent, type ChallengeMessageMap, type ConfigValidationFieldError, type ConnectError, type ConnectEvent, type ConnectMessageMap, type Connection, type ConnectionError, ConnectionErrorCode, type ConnectionRequired, ConnectionStatus, type CreateSessionError, type CreateSessionTokenRequestBody, type CreateSessionTokenResponse as CreateSessionTokenReturnType, type CustomerCapabilities, type DecryptedCredentials, type DevPlatformApiError, type DevPlatformApiErrorCode, DevPlatformApiErrorCodes, type DevPlatformApiErrorDetail, type EmptyResult, type FailedConnection, type Fees, type FrameTransaction, type GetConnectionError, type GetPaymentMethodsError, type GetQuoteError, type GetQuoteBody as GetQuoteParams, type GetTransactionsError, type GooglePayEvent, type GooglePayEventError, type GooglePayInboundMessageMap, type GooglePayOutboundMessageMap, HANDSHAKE_ACK_KIND, HANDSHAKE_REQUEST_KIND, type HandshakeAck, type HandshakeRequest, type LimitWithAsset, type MoonPayPaymentsListPaymentMethodsResponse as ListPaymentMethodsResponse, type MessageUnion, type MonetaryFeeAmount, type MoonPayCorePaginationInfo as PaginationInfo, type PaymentDisclosuresRequirement, type MoonPayPaymentsPaymentMethodAvailability as PaymentMethodAvailability, type MoonPayPaymentsPaymentMethodCapabilities as PaymentMethodCapabilities, type MoonPayPaymentsPaymentMethod as PaymentMethodConfig, type PaymentMethodType, type PendingConnection, type ProtocolMessage, type GetQuoteResponse as Quote, type QuoteLimitEntry, type QuoteLimits, type QuotePaymentMethod, type RampsCapability, type RampsRequirements, type ResetConnectionError, type ResetMessageMap, type Result, type RevokeSessionError, type SetBuyButtonQuoteCommand, type SetBuyQuoteCommand, type SetGooglePayQuoteCommand, type SetQuoteCommand, type SetupAddCardError, type SetupApplePayError, type SetupBuyButtonError, type SetupBuyError, type SetupChallengeError, type SetupGooglePayError, type SetupWidgetError, type Stage, type StageKind, type StageStatus, type MoonPayPaymentsStoredCardPaymentMethod as StoredCardPaymentMethod, type MoonPayPaymentsStoredPaymentMethod as StoredPaymentMethod, type TermsAcceptanceRequiredConnection, type TermsAttestation, type Transaction, type TransactionCustomer, type TransactionPaymentMethod, type TransactionStatus, type TransactionWithStages, type TypedMessage, type UnavailableConnection, type Wallet, type WidgetEvent, type WidgetMessageMap, err, ok };
|
|
1289
|
+
export { type ActiveConnection, type AddCardEvent, type AddCardMessageMap, type ApplePayEvent, type ApplePayEventError, type ApplePayInboundMessageMap, type ApplePayOutboundMessageMap, type Asset, type AssetBase, type AuthEvent, type AuthMessageMap, type BuyButtonEvent, type BuyButtonMessageMap, type BuyButtonOutboundMessageMap, type BuyEvent, type BuyMessageMap, type BuyOutboundMessageMap, type CapabilityProduct, type CardResponse, type ChallengeCancellation, type ChallengeCompleteResult, type ChallengeEvent, type ChallengeMessageMap, type ConfigValidationFieldError, type ConnectError, type ConnectEvent, type ConnectMessageMap, type Connection, type ConnectionError, ConnectionErrorCode, type ConnectionRequired, ConnectionStatus, type CreateIdentityError, type CreateIdentityRequestBody, type CreateIdentityResidentialAddress, type CreateSessionError, type CreateSessionTokenRequestBody, type CreateSessionTokenResponse as CreateSessionTokenReturnType, type CustomerCapabilities, type DecryptedCredentials, type DevPlatformApiError, type DevPlatformApiErrorCode, DevPlatformApiErrorCodes, type DevPlatformApiErrorDetail, type EmptyResult, type FailedConnection, type Fees, type FrameTransaction, type GetConnectionError, type GetIdentityError, type GetIdentityUploadUrlError, type GetPaymentMethodsError, type GetQuoteError, type GetQuoteBody as GetQuoteParams, type GetTransactionsError, type GooglePayEvent, type GooglePayEventError, type GooglePayInboundMessageMap, type GooglePayOutboundMessageMap, HANDSHAKE_ACK_KIND, HANDSHAKE_REQUEST_KIND, type HandshakeAck, type HandshakeRequest, type Identity, type IdentityBasicDetailsSubmission, type IdentityCapability, type IdentityFileMimeType, type IdentityFileSide, type IdentityFileSubmission, type IdentityFileType, type IdentityFileUploadUrl, type IdentityFileUploadUrlHeaders, type IdentityFileUploadUrlRequestBody, type IdentityPhoneNumberSubmission, type IdentityResidentialAddressSubmission, type IdentityStatus, type IdentityTaxIdentifierGenericSubmission, type IdentityTaxIdentifierSchemeSubmission, type IdentityTaxIdentifierSubmission, type IdentityTaxIdentifierType, type IdentityVerificationChallenge, type IdentityVerificationResponse, type IdentityVerificationStatus, type LimitWithAsset, type MoonPayPaymentsListPaymentMethodsResponse as ListPaymentMethodsResponse, type MessageUnion, type MonetaryFeeAmount, type MoonPayCorePaginationInfo as PaginationInfo, type PaymentDisclosuresRequirement, type MoonPayPaymentsPaymentMethodAvailability as PaymentMethodAvailability, type MoonPayPaymentsPaymentMethodCapabilities as PaymentMethodCapabilities, type MoonPayPaymentsPaymentMethod as PaymentMethodConfig, type PaymentMethodType, type PendingConnection, type ProtocolMessage, type GetQuoteResponse as Quote, type QuoteLimitEntry, type QuoteLimits, type QuotePaymentMethod, type RampsCapability, type RampsRequirements, type RequirementEntry, type RequirementFieldName, type RequirementItemStatus, type Requirements, type ResetConnectionError, type ResetMessageMap, type Result, type RevokeSessionError, type SetBuyButtonQuoteCommand, type SetBuyQuoteCommand, type SetGooglePayQuoteCommand, type SetQuoteCommand, type SetupAddCardError, type SetupApplePayError, type SetupAuthError, type SetupBuyButtonError, type SetupBuyError, type SetupChallengeError, type SetupGooglePayError, type SetupWidgetError, type Stage, type StageKind, type StageStatus, type MoonPayPaymentsStoredCardPaymentMethod as StoredCardPaymentMethod, type MoonPayPaymentsStoredPaymentMethod as StoredPaymentMethod, type SubmitIdentityFilesError, type SubmitIdentityFilesRequestBody, type TermsAcceptanceRequiredConnection, type TermsAttestation, type Transaction, type TransactionCustomer, type TransactionPaymentMethod, type TransactionStatus, type TransactionWithStages, type TypedMessage, type UnavailableConnection, type UpdateIdentityError, type UpdateIdentityRequestBody, type VerifyIdentityError, type Wallet, type WidgetEvent, type WidgetMessageMap, err, ok };
|
package/dist/index.d.ts
CHANGED
|
@@ -45,7 +45,7 @@ type CreateSessionTokenRequestBody = {
|
|
|
45
45
|
/**
|
|
46
46
|
* A unique identifier for the customer from your system.
|
|
47
47
|
*/
|
|
48
|
-
externalCustomerId
|
|
48
|
+
externalCustomerId?: string;
|
|
49
49
|
/**
|
|
50
50
|
* The IP address of the user's device to ensure the integrity of the session. Both IPv4 and IPv6 values are supported.
|
|
51
51
|
*/
|
|
@@ -171,6 +171,10 @@ type GetQuoteResponse = {
|
|
|
171
171
|
* The rate used to convert fiat <-> crypto, expressed as the crypto value of one unit of fiat.
|
|
172
172
|
*/
|
|
173
173
|
exchangeRate: string;
|
|
174
|
+
/**
|
|
175
|
+
* Disclosures the partner must render verbatim before the customer can complete the transaction. Empty when no disclosure is required for the customer's geography, payment method, and asset combination.
|
|
176
|
+
*/
|
|
177
|
+
paymentDisclosures: Array<PaymentDisclosure>;
|
|
174
178
|
/**
|
|
175
179
|
* An opaque token representing the quote to initiate payment frames.
|
|
176
180
|
*/
|
|
@@ -289,6 +293,19 @@ type MoonPayPaymentsStoredPaymentMethodBase = {
|
|
|
289
293
|
id: string;
|
|
290
294
|
type: PaymentMethodType;
|
|
291
295
|
};
|
|
296
|
+
/**
|
|
297
|
+
* A payment disclosure that the partner must render verbatim before the customer can complete the transaction.
|
|
298
|
+
*/
|
|
299
|
+
type PaymentDisclosure = {
|
|
300
|
+
/**
|
|
301
|
+
* Stable identifier of the disclosure. Each id maps to one specific piece of text. The full list of ids and their canonical text is published in the developer documentation.
|
|
302
|
+
*/
|
|
303
|
+
id: string;
|
|
304
|
+
/**
|
|
305
|
+
* Version of the disclosure text. Bumped whenever the canonical wording for this `id` changes. Partners that receive an unknown `(id, version)` pair should fall back to a conservative disclosure and alert their integration team.
|
|
306
|
+
*/
|
|
307
|
+
version: string;
|
|
308
|
+
};
|
|
292
309
|
type PaymentMethodType = 'apple_pay' | 'card' | 'ach' | 'fps' | 'fps_open_banking' | 'google_pay' | 'sepa' | 'sepa_open_banking' | 'pix' | 'paypal' | 'venmo' | 'revolut_pay' | 'moonpay_balance' | 'interac';
|
|
293
310
|
type QuoteLimitEntry = {
|
|
294
311
|
/**
|
|
@@ -643,6 +660,12 @@ type GetPaymentMethodsError = DevPlatformApiError;
|
|
|
643
660
|
type GetTransactionsError = DevPlatformApiError;
|
|
644
661
|
type CreateSessionError = DevPlatformApiError;
|
|
645
662
|
type RevokeSessionError = DevPlatformApiError;
|
|
663
|
+
type CreateIdentityError = DevPlatformApiError;
|
|
664
|
+
type GetIdentityError = DevPlatformApiError;
|
|
665
|
+
type UpdateIdentityError = DevPlatformApiError;
|
|
666
|
+
type VerifyIdentityError = DevPlatformApiError;
|
|
667
|
+
type GetIdentityUploadUrlError = DevPlatformApiError;
|
|
668
|
+
type SubmitIdentityFilesError = DevPlatformApiError;
|
|
646
669
|
interface SetupBuyError {
|
|
647
670
|
kind: 'configurationError' | 'genericError';
|
|
648
671
|
message: string;
|
|
@@ -655,6 +678,10 @@ interface SetupChallengeError {
|
|
|
655
678
|
kind: 'configurationError' | 'genericError';
|
|
656
679
|
message: string;
|
|
657
680
|
}
|
|
681
|
+
interface SetupAuthError {
|
|
682
|
+
kind: 'configurationError' | 'genericError';
|
|
683
|
+
message: string;
|
|
684
|
+
}
|
|
658
685
|
interface SetupAddCardError {
|
|
659
686
|
kind: 'configurationError' | 'genericError';
|
|
660
687
|
message: string;
|
|
@@ -762,6 +789,23 @@ interface ConnectMessageMap {
|
|
|
762
789
|
error: ConnectionError;
|
|
763
790
|
complete: ConnectionRequired | ActiveConnection | UnavailableConnection | PendingConnection | FailedConnection | TermsAcceptanceRequiredConnection;
|
|
764
791
|
}
|
|
792
|
+
/**
|
|
793
|
+
* Maps message `kind` to its payload type for the auth frame
|
|
794
|
+
* (child → parent direction).
|
|
795
|
+
*
|
|
796
|
+
* The auth frame is the lighter-weight counterpart to the connect frame:
|
|
797
|
+
* partners (typically headless / Identity-API integrations) drive the
|
|
798
|
+
* customer through email/OTP authentication only, then receive the
|
|
799
|
+
* encrypted credentials. The frame is gated on `clientToken` rather than
|
|
800
|
+
* `sessionToken` — partners obtain the `clientToken` via the prior
|
|
801
|
+
* `getConnection()` probe (it is decrypted into `core.context` on a
|
|
802
|
+
* `connectionRequired` result).
|
|
803
|
+
*/
|
|
804
|
+
interface AuthMessageMap {
|
|
805
|
+
ready: void;
|
|
806
|
+
error: ConnectionError;
|
|
807
|
+
complete: ActiveConnection | TermsAcceptanceRequiredConnection;
|
|
808
|
+
}
|
|
765
809
|
/**
|
|
766
810
|
* Maps message `kind` to its payload type for the buy frame
|
|
767
811
|
* (child → parent direction).
|
|
@@ -1002,6 +1046,15 @@ type ConnectEvent = {
|
|
|
1002
1046
|
kind: 'complete';
|
|
1003
1047
|
payload: ConnectMessageMap['complete'];
|
|
1004
1048
|
};
|
|
1049
|
+
type AuthEvent = {
|
|
1050
|
+
kind: 'ready';
|
|
1051
|
+
} | {
|
|
1052
|
+
kind: 'error';
|
|
1053
|
+
payload: AuthMessageMap['error'];
|
|
1054
|
+
} | {
|
|
1055
|
+
kind: 'complete';
|
|
1056
|
+
payload: AuthMessageMap['complete'];
|
|
1057
|
+
};
|
|
1005
1058
|
type BuyEvent = {
|
|
1006
1059
|
kind: 'ready';
|
|
1007
1060
|
} | {
|
|
@@ -1049,6 +1102,161 @@ type AddCardEvent = {
|
|
|
1049
1102
|
payload: AddCardMessageMap['error'];
|
|
1050
1103
|
};
|
|
1051
1104
|
|
|
1105
|
+
/**
|
|
1106
|
+
* Identity API types.
|
|
1107
|
+
*
|
|
1108
|
+
* Sourced from `moonpay-api/packages/dev-platform/modules/identity/main.tsp`.
|
|
1109
|
+
* The TypeSpec is marked `@vnext` and is not yet emitted into the public
|
|
1110
|
+
* OpenAPI spec, so these types are hand-rolled. Once the spec ships, replace
|
|
1111
|
+
* with aliases re-exported from `./gen/` (same pattern as `Quote`, `Identity`,
|
|
1112
|
+
* etc. in `api.ts`).
|
|
1113
|
+
*/
|
|
1114
|
+
/** A platform capability a partner wants the customer to unlock. */
|
|
1115
|
+
type CapabilityProduct = 'ramps';
|
|
1116
|
+
/** A requested capability scoped to an identity. */
|
|
1117
|
+
interface IdentityCapability {
|
|
1118
|
+
product: CapabilityProduct;
|
|
1119
|
+
}
|
|
1120
|
+
/** The state of an identity across the KYC lifecycle. */
|
|
1121
|
+
type IdentityStatus = 'created' | 'collecting' | 'verifying' | 'challengeRequired' | 'approved' | 'rejected' | 'manualReview' | 'blocked';
|
|
1122
|
+
/** The completion state of a requirement item. */
|
|
1123
|
+
type RequirementItemStatus = 'incomplete' | 'complete';
|
|
1124
|
+
/** A field a customer must provide to fulfil a requirement. */
|
|
1125
|
+
type RequirementFieldName = 'firstName' | 'lastName' | 'dateOfBirth' | 'nationality' | 'street' | 'locality' | 'postalCode' | 'country' | 'administrativeArea' | 'ssn' | 'cpf' | 'tin';
|
|
1126
|
+
/** Status of a single requirement group on an identity. */
|
|
1127
|
+
interface RequirementEntry {
|
|
1128
|
+
status: RequirementItemStatus;
|
|
1129
|
+
requiredFields?: RequirementFieldName[];
|
|
1130
|
+
}
|
|
1131
|
+
/** Outstanding and completed requirements for the identity, keyed by category. */
|
|
1132
|
+
interface Requirements {
|
|
1133
|
+
basicDetails?: RequirementEntry;
|
|
1134
|
+
residentialAddress?: RequirementEntry;
|
|
1135
|
+
identityDocuments?: RequirementEntry;
|
|
1136
|
+
selfie?: RequirementEntry;
|
|
1137
|
+
taxIdentifiers?: RequirementEntry;
|
|
1138
|
+
proofOfAddress?: RequirementEntry;
|
|
1139
|
+
phoneNumber?: RequirementEntry;
|
|
1140
|
+
}
|
|
1141
|
+
/** Residential-address fields accepted at identity creation. */
|
|
1142
|
+
interface CreateIdentityResidentialAddress {
|
|
1143
|
+
/** ISO 3166-1 alpha-3 country code declared by the partner. */
|
|
1144
|
+
country: string;
|
|
1145
|
+
}
|
|
1146
|
+
/** Request body for creating an identity. */
|
|
1147
|
+
interface CreateIdentityRequestBody {
|
|
1148
|
+
residentialAddress: CreateIdentityResidentialAddress;
|
|
1149
|
+
/** Capabilities the partner wants the customer to unlock. Must contain at least one value. */
|
|
1150
|
+
capabilities: IdentityCapability[];
|
|
1151
|
+
}
|
|
1152
|
+
/** Customer's basic personal details. */
|
|
1153
|
+
interface IdentityBasicDetailsSubmission {
|
|
1154
|
+
firstName?: string;
|
|
1155
|
+
lastName?: string;
|
|
1156
|
+
nationality?: string;
|
|
1157
|
+
/** YYYY-MM-DD. */
|
|
1158
|
+
dateOfBirth?: string;
|
|
1159
|
+
}
|
|
1160
|
+
/** Customer's residential address. */
|
|
1161
|
+
interface IdentityResidentialAddressSubmission {
|
|
1162
|
+
country?: string;
|
|
1163
|
+
administrativeArea?: string;
|
|
1164
|
+
locality?: string;
|
|
1165
|
+
street?: string;
|
|
1166
|
+
subStreet?: string;
|
|
1167
|
+
postalCode?: string;
|
|
1168
|
+
}
|
|
1169
|
+
/** Customer's phone number in E.164 format. */
|
|
1170
|
+
interface IdentityPhoneNumberSubmission {
|
|
1171
|
+
number: string;
|
|
1172
|
+
}
|
|
1173
|
+
/** Type of tax identifier the customer is submitting. */
|
|
1174
|
+
type IdentityTaxIdentifierType = 'tin' | 'ssn' | 'cpf';
|
|
1175
|
+
/** Tax Identification Number — country must be supplied. */
|
|
1176
|
+
interface IdentityTaxIdentifierGenericSubmission {
|
|
1177
|
+
type: 'tin';
|
|
1178
|
+
country: string;
|
|
1179
|
+
value: string;
|
|
1180
|
+
}
|
|
1181
|
+
/** Country-specific tax identifier (SSN/CPF). */
|
|
1182
|
+
interface IdentityTaxIdentifierSchemeSubmission {
|
|
1183
|
+
type: 'ssn' | 'cpf';
|
|
1184
|
+
value: string;
|
|
1185
|
+
}
|
|
1186
|
+
type IdentityTaxIdentifierSubmission = IdentityTaxIdentifierGenericSubmission | IdentityTaxIdentifierSchemeSubmission;
|
|
1187
|
+
/** Request body for updating an identity by submitting one or more requirements. */
|
|
1188
|
+
interface UpdateIdentityRequestBody {
|
|
1189
|
+
residentialAddress?: IdentityResidentialAddressSubmission;
|
|
1190
|
+
basicDetails?: IdentityBasicDetailsSubmission;
|
|
1191
|
+
phoneNumber?: IdentityPhoneNumberSubmission;
|
|
1192
|
+
taxIdentifiers?: IdentityTaxIdentifierSubmission[];
|
|
1193
|
+
}
|
|
1194
|
+
/** A MoonPay-hosted challenge a partner must surface to the customer. */
|
|
1195
|
+
interface IdentityVerificationChallenge {
|
|
1196
|
+
/** Fully-formed challenge URL. */
|
|
1197
|
+
url: string;
|
|
1198
|
+
/** ISO 8601 expiry. */
|
|
1199
|
+
expiresAt: string;
|
|
1200
|
+
}
|
|
1201
|
+
/** The state of an identity verification request. */
|
|
1202
|
+
type IdentityVerificationStatus = 'approved' | 'processing' | 'challengeRequired';
|
|
1203
|
+
/** Outcome of `POST /platform/v1/identities/{id}/verifications`. */
|
|
1204
|
+
type IdentityVerificationResponse = {
|
|
1205
|
+
status: 'approved';
|
|
1206
|
+
} | {
|
|
1207
|
+
status: 'processing';
|
|
1208
|
+
} | {
|
|
1209
|
+
status: 'challengeRequired';
|
|
1210
|
+
challenge: IdentityVerificationChallenge;
|
|
1211
|
+
};
|
|
1212
|
+
/** Type of identity-related file the customer is uploading. */
|
|
1213
|
+
type IdentityFileType = 'drivingLicence' | 'nationalIdentityCard' | 'passport' | 'residencePermit' | 'selfie' | 'proofOfAddress';
|
|
1214
|
+
/** Side of a two-sided identity document. */
|
|
1215
|
+
type IdentityFileSide = 'front' | 'back';
|
|
1216
|
+
/** MIME type of the file being uploaded. */
|
|
1217
|
+
type IdentityFileMimeType = 'image/jpeg' | 'image/png' | 'application/pdf';
|
|
1218
|
+
/** Request body for issuing a presigned upload URL. */
|
|
1219
|
+
interface IdentityFileUploadUrlRequestBody {
|
|
1220
|
+
fileType: IdentityFileType;
|
|
1221
|
+
/** Required for two-sided file types (`drivingLicence`, `nationalIdentityCard`, `residencePermit`); omit for single-sided. */
|
|
1222
|
+
side?: IdentityFileSide;
|
|
1223
|
+
/** Must match the `Content-Type` header used on the subsequent upload request. */
|
|
1224
|
+
mimeType: IdentityFileMimeType;
|
|
1225
|
+
}
|
|
1226
|
+
/** Headers the partner must send when uploading the file to the presigned URL. */
|
|
1227
|
+
interface IdentityFileUploadUrlHeaders {
|
|
1228
|
+
'Content-Type': string;
|
|
1229
|
+
}
|
|
1230
|
+
/** Presigned URL the partner uses to upload an identity-related file. */
|
|
1231
|
+
interface IdentityFileUploadUrl {
|
|
1232
|
+
uploadId: string;
|
|
1233
|
+
url: string;
|
|
1234
|
+
/** ISO 8601 expiry. */
|
|
1235
|
+
expiresAt: string;
|
|
1236
|
+
headers: IdentityFileUploadUrlHeaders;
|
|
1237
|
+
}
|
|
1238
|
+
/** A single uploaded file the partner is confirming for submission. */
|
|
1239
|
+
interface IdentityFileSubmission {
|
|
1240
|
+
uploadId: string;
|
|
1241
|
+
fileType: IdentityFileType;
|
|
1242
|
+
side?: IdentityFileSide;
|
|
1243
|
+
}
|
|
1244
|
+
/** Request body for confirming one or more uploaded identity-related files. */
|
|
1245
|
+
interface SubmitIdentityFilesRequestBody {
|
|
1246
|
+
files: IdentityFileSubmission[];
|
|
1247
|
+
}
|
|
1248
|
+
/** A KYC identity. */
|
|
1249
|
+
interface Identity {
|
|
1250
|
+
id: string;
|
|
1251
|
+
status: IdentityStatus;
|
|
1252
|
+
capabilities: IdentityCapability[];
|
|
1253
|
+
requirements: Requirements;
|
|
1254
|
+
/** Present only when `status` is `challengeRequired`. */
|
|
1255
|
+
challenge?: IdentityVerificationChallenge;
|
|
1256
|
+
createdAt: string;
|
|
1257
|
+
updatedAt: string;
|
|
1258
|
+
}
|
|
1259
|
+
|
|
1052
1260
|
/**
|
|
1053
1261
|
* A discriminated union representing either a successful value or an error.
|
|
1054
1262
|
* SDK methods return this type instead of throwing exceptions.
|
|
@@ -1078,4 +1286,4 @@ declare const err: <E>(error: E) => {
|
|
|
1078
1286
|
error: E;
|
|
1079
1287
|
};
|
|
1080
1288
|
|
|
1081
|
-
export { type ActiveConnection, type AddCardEvent, type AddCardMessageMap, type ApplePayEvent, type ApplePayEventError, type ApplePayInboundMessageMap, type ApplePayOutboundMessageMap, type Asset, type AssetBase, type BuyButtonEvent, type BuyButtonMessageMap, type BuyButtonOutboundMessageMap, type BuyEvent, type BuyMessageMap, type BuyOutboundMessageMap, type CardResponse, type ChallengeCancellation, type ChallengeCompleteResult, type ChallengeEvent, type ChallengeMessageMap, type ConfigValidationFieldError, type ConnectError, type ConnectEvent, type ConnectMessageMap, type Connection, type ConnectionError, ConnectionErrorCode, type ConnectionRequired, ConnectionStatus, type CreateSessionError, type CreateSessionTokenRequestBody, type CreateSessionTokenResponse as CreateSessionTokenReturnType, type CustomerCapabilities, type DecryptedCredentials, type DevPlatformApiError, type DevPlatformApiErrorCode, DevPlatformApiErrorCodes, type DevPlatformApiErrorDetail, type EmptyResult, type FailedConnection, type Fees, type FrameTransaction, type GetConnectionError, type GetPaymentMethodsError, type GetQuoteError, type GetQuoteBody as GetQuoteParams, type GetTransactionsError, type GooglePayEvent, type GooglePayEventError, type GooglePayInboundMessageMap, type GooglePayOutboundMessageMap, HANDSHAKE_ACK_KIND, HANDSHAKE_REQUEST_KIND, type HandshakeAck, type HandshakeRequest, type LimitWithAsset, type MoonPayPaymentsListPaymentMethodsResponse as ListPaymentMethodsResponse, type MessageUnion, type MonetaryFeeAmount, type MoonPayCorePaginationInfo as PaginationInfo, type PaymentDisclosuresRequirement, type MoonPayPaymentsPaymentMethodAvailability as PaymentMethodAvailability, type MoonPayPaymentsPaymentMethodCapabilities as PaymentMethodCapabilities, type MoonPayPaymentsPaymentMethod as PaymentMethodConfig, type PaymentMethodType, type PendingConnection, type ProtocolMessage, type GetQuoteResponse as Quote, type QuoteLimitEntry, type QuoteLimits, type QuotePaymentMethod, type RampsCapability, type RampsRequirements, type ResetConnectionError, type ResetMessageMap, type Result, type RevokeSessionError, type SetBuyButtonQuoteCommand, type SetBuyQuoteCommand, type SetGooglePayQuoteCommand, type SetQuoteCommand, type SetupAddCardError, type SetupApplePayError, type SetupBuyButtonError, type SetupBuyError, type SetupChallengeError, type SetupGooglePayError, type SetupWidgetError, type Stage, type StageKind, type StageStatus, type MoonPayPaymentsStoredCardPaymentMethod as StoredCardPaymentMethod, type MoonPayPaymentsStoredPaymentMethod as StoredPaymentMethod, type TermsAcceptanceRequiredConnection, type TermsAttestation, type Transaction, type TransactionCustomer, type TransactionPaymentMethod, type TransactionStatus, type TransactionWithStages, type TypedMessage, type UnavailableConnection, type Wallet, type WidgetEvent, type WidgetMessageMap, err, ok };
|
|
1289
|
+
export { type ActiveConnection, type AddCardEvent, type AddCardMessageMap, type ApplePayEvent, type ApplePayEventError, type ApplePayInboundMessageMap, type ApplePayOutboundMessageMap, type Asset, type AssetBase, type AuthEvent, type AuthMessageMap, type BuyButtonEvent, type BuyButtonMessageMap, type BuyButtonOutboundMessageMap, type BuyEvent, type BuyMessageMap, type BuyOutboundMessageMap, type CapabilityProduct, type CardResponse, type ChallengeCancellation, type ChallengeCompleteResult, type ChallengeEvent, type ChallengeMessageMap, type ConfigValidationFieldError, type ConnectError, type ConnectEvent, type ConnectMessageMap, type Connection, type ConnectionError, ConnectionErrorCode, type ConnectionRequired, ConnectionStatus, type CreateIdentityError, type CreateIdentityRequestBody, type CreateIdentityResidentialAddress, type CreateSessionError, type CreateSessionTokenRequestBody, type CreateSessionTokenResponse as CreateSessionTokenReturnType, type CustomerCapabilities, type DecryptedCredentials, type DevPlatformApiError, type DevPlatformApiErrorCode, DevPlatformApiErrorCodes, type DevPlatformApiErrorDetail, type EmptyResult, type FailedConnection, type Fees, type FrameTransaction, type GetConnectionError, type GetIdentityError, type GetIdentityUploadUrlError, type GetPaymentMethodsError, type GetQuoteError, type GetQuoteBody as GetQuoteParams, type GetTransactionsError, type GooglePayEvent, type GooglePayEventError, type GooglePayInboundMessageMap, type GooglePayOutboundMessageMap, HANDSHAKE_ACK_KIND, HANDSHAKE_REQUEST_KIND, type HandshakeAck, type HandshakeRequest, type Identity, type IdentityBasicDetailsSubmission, type IdentityCapability, type IdentityFileMimeType, type IdentityFileSide, type IdentityFileSubmission, type IdentityFileType, type IdentityFileUploadUrl, type IdentityFileUploadUrlHeaders, type IdentityFileUploadUrlRequestBody, type IdentityPhoneNumberSubmission, type IdentityResidentialAddressSubmission, type IdentityStatus, type IdentityTaxIdentifierGenericSubmission, type IdentityTaxIdentifierSchemeSubmission, type IdentityTaxIdentifierSubmission, type IdentityTaxIdentifierType, type IdentityVerificationChallenge, type IdentityVerificationResponse, type IdentityVerificationStatus, type LimitWithAsset, type MoonPayPaymentsListPaymentMethodsResponse as ListPaymentMethodsResponse, type MessageUnion, type MonetaryFeeAmount, type MoonPayCorePaginationInfo as PaginationInfo, type PaymentDisclosuresRequirement, type MoonPayPaymentsPaymentMethodAvailability as PaymentMethodAvailability, type MoonPayPaymentsPaymentMethodCapabilities as PaymentMethodCapabilities, type MoonPayPaymentsPaymentMethod as PaymentMethodConfig, type PaymentMethodType, type PendingConnection, type ProtocolMessage, type GetQuoteResponse as Quote, type QuoteLimitEntry, type QuoteLimits, type QuotePaymentMethod, type RampsCapability, type RampsRequirements, type RequirementEntry, type RequirementFieldName, type RequirementItemStatus, type Requirements, type ResetConnectionError, type ResetMessageMap, type Result, type RevokeSessionError, type SetBuyButtonQuoteCommand, type SetBuyQuoteCommand, type SetGooglePayQuoteCommand, type SetQuoteCommand, type SetupAddCardError, type SetupApplePayError, type SetupAuthError, type SetupBuyButtonError, type SetupBuyError, type SetupChallengeError, type SetupGooglePayError, type SetupWidgetError, type Stage, type StageKind, type StageStatus, type MoonPayPaymentsStoredCardPaymentMethod as StoredCardPaymentMethod, type MoonPayPaymentsStoredPaymentMethod as StoredPaymentMethod, type SubmitIdentityFilesError, type SubmitIdentityFilesRequestBody, type TermsAcceptanceRequiredConnection, type TermsAttestation, type Transaction, type TransactionCustomer, type TransactionPaymentMethod, type TransactionStatus, type TransactionWithStages, type TypedMessage, type UnavailableConnection, type UpdateIdentityError, type UpdateIdentityRequestBody, type VerifyIdentityError, type Wallet, type WidgetEvent, type WidgetMessageMap, err, ok };
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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;\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 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// 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"]}
|
|
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"]}
|