@moonpay/platform-protocol 0.3.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (175) hide show
  1. package/README.md +45 -0
  2. package/dist/{index.cjs → api/errors.cjs} +7 -51
  3. package/dist/api/errors.cjs.map +1 -0
  4. package/dist/api/errors.d.cts +46 -0
  5. package/dist/api/errors.d.ts +46 -0
  6. package/dist/api/errors.js +27 -0
  7. package/dist/api/errors.js.map +1 -0
  8. package/dist/api/identity.cjs +19 -0
  9. package/dist/api/identity.cjs.map +1 -0
  10. package/dist/api/identity.d.cts +156 -0
  11. package/dist/api/identity.d.ts +156 -0
  12. package/dist/api/identity.js +1 -0
  13. package/dist/api/identity.js.map +1 -0
  14. package/dist/api/index.cjs +19 -0
  15. package/dist/api/index.cjs.map +1 -0
  16. package/dist/api/index.d.cts +466 -0
  17. package/dist/api/index.d.ts +466 -0
  18. package/dist/api/index.js +1 -0
  19. package/dist/api/index.js.map +1 -0
  20. package/dist/frames/add-card.cjs +19 -0
  21. package/dist/frames/add-card.cjs.map +1 -0
  22. package/dist/frames/add-card.d.cts +24 -0
  23. package/dist/frames/add-card.d.ts +24 -0
  24. package/dist/frames/add-card.js +1 -0
  25. package/dist/frames/add-card.js.map +1 -0
  26. package/dist/frames/apple-pay.cjs +19 -0
  27. package/dist/frames/apple-pay.cjs.map +1 -0
  28. package/dist/frames/apple-pay.d.cts +22 -0
  29. package/dist/frames/apple-pay.d.ts +22 -0
  30. package/dist/frames/apple-pay.js +1 -0
  31. package/dist/frames/apple-pay.js.map +1 -0
  32. package/dist/frames/auth.cjs +19 -0
  33. package/dist/frames/auth.cjs.map +1 -0
  34. package/dist/frames/auth.d.cts +15 -0
  35. package/dist/frames/auth.d.ts +15 -0
  36. package/dist/frames/auth.js +1 -0
  37. package/dist/frames/auth.js.map +1 -0
  38. package/dist/frames/buy-button.cjs +19 -0
  39. package/dist/frames/buy-button.cjs.map +1 -0
  40. package/dist/frames/buy-button.d.cts +21 -0
  41. package/dist/frames/buy-button.d.ts +21 -0
  42. package/dist/frames/buy-button.js +1 -0
  43. package/dist/frames/buy-button.js.map +1 -0
  44. package/dist/frames/buy.cjs +19 -0
  45. package/dist/frames/buy.cjs.map +1 -0
  46. package/dist/frames/buy.d.cts +22 -0
  47. package/dist/frames/buy.d.ts +22 -0
  48. package/dist/frames/buy.js +1 -0
  49. package/dist/frames/buy.js.map +1 -0
  50. package/dist/frames/challenge.cjs +19 -0
  51. package/dist/frames/challenge.cjs.map +1 -0
  52. package/dist/frames/challenge.d.cts +30 -0
  53. package/dist/frames/challenge.d.ts +30 -0
  54. package/dist/frames/challenge.js +1 -0
  55. package/dist/frames/challenge.js.map +1 -0
  56. package/dist/frames/connect.cjs +19 -0
  57. package/dist/frames/connect.cjs.map +1 -0
  58. package/dist/frames/connect.d.cts +9 -0
  59. package/dist/frames/connect.d.ts +9 -0
  60. package/dist/frames/connect.js +1 -0
  61. package/dist/frames/connect.js.map +1 -0
  62. package/dist/frames/google-pay.cjs +19 -0
  63. package/dist/frames/google-pay.cjs.map +1 -0
  64. package/dist/frames/google-pay.d.cts +22 -0
  65. package/dist/frames/google-pay.d.ts +22 -0
  66. package/dist/frames/google-pay.js +1 -0
  67. package/dist/frames/google-pay.js.map +1 -0
  68. package/dist/frames/reset.cjs +19 -0
  69. package/dist/frames/reset.cjs.map +1 -0
  70. package/dist/frames/reset.d.cts +12 -0
  71. package/dist/frames/reset.d.ts +12 -0
  72. package/dist/frames/reset.js +1 -0
  73. package/dist/frames/reset.js.map +1 -0
  74. package/dist/frames/widget.cjs +19 -0
  75. package/dist/frames/widget.cjs.map +1 -0
  76. package/dist/frames/widget.d.cts +19 -0
  77. package/dist/frames/widget.d.ts +19 -0
  78. package/dist/frames/widget.js +1 -0
  79. package/dist/frames/widget.js.map +1 -0
  80. package/dist/models/challenge.cjs +19 -0
  81. package/dist/models/challenge.cjs.map +1 -0
  82. package/dist/models/challenge.d.cts +12 -0
  83. package/dist/models/challenge.d.ts +12 -0
  84. package/dist/models/challenge.js +1 -0
  85. package/dist/models/challenge.js.map +1 -0
  86. package/dist/models/connection.cjs +46 -0
  87. package/dist/models/connection.cjs.map +1 -0
  88. package/dist/models/connection.d.cts +154 -0
  89. package/dist/models/connection.d.ts +154 -0
  90. package/dist/models/connection.js +20 -0
  91. package/dist/models/connection.js.map +1 -0
  92. package/dist/models/transaction.cjs +19 -0
  93. package/dist/models/transaction.cjs.map +1 -0
  94. package/dist/models/transaction.d.cts +15 -0
  95. package/dist/models/transaction.d.ts +15 -0
  96. package/dist/models/transaction.js +1 -0
  97. package/dist/models/transaction.js.map +1 -0
  98. package/dist/protocol.cjs +34 -0
  99. package/dist/protocol.cjs.map +1 -0
  100. package/dist/protocol.d.cts +30 -0
  101. package/dist/protocol.d.ts +30 -0
  102. package/dist/protocol.js +8 -0
  103. package/dist/protocol.js.map +1 -0
  104. package/dist/result.cjs +40 -0
  105. package/dist/result.cjs.map +1 -0
  106. package/dist/result.d.cts +30 -0
  107. package/dist/result.d.ts +30 -0
  108. package/dist/result.js +14 -0
  109. package/dist/result.js.map +1 -0
  110. package/dist/sdks/add-card.cjs +19 -0
  111. package/dist/sdks/add-card.cjs.map +1 -0
  112. package/dist/sdks/add-card.d.cts +20 -0
  113. package/dist/sdks/add-card.d.ts +20 -0
  114. package/dist/sdks/add-card.js +1 -0
  115. package/dist/sdks/add-card.js.map +1 -0
  116. package/dist/sdks/apple-pay.cjs +19 -0
  117. package/dist/sdks/apple-pay.cjs.map +1 -0
  118. package/dist/sdks/apple-pay.d.cts +36 -0
  119. package/dist/sdks/apple-pay.d.ts +36 -0
  120. package/dist/sdks/apple-pay.js +1 -0
  121. package/dist/sdks/apple-pay.js.map +1 -0
  122. package/dist/sdks/auth.cjs +19 -0
  123. package/dist/sdks/auth.cjs.map +1 -0
  124. package/dist/sdks/auth.d.cts +18 -0
  125. package/dist/sdks/auth.d.ts +18 -0
  126. package/dist/sdks/auth.js +1 -0
  127. package/dist/sdks/auth.js.map +1 -0
  128. package/dist/sdks/buy-button.cjs +19 -0
  129. package/dist/sdks/buy-button.cjs.map +1 -0
  130. package/dist/sdks/buy-button.d.cts +21 -0
  131. package/dist/sdks/buy-button.d.ts +21 -0
  132. package/dist/sdks/buy-button.js +1 -0
  133. package/dist/sdks/buy-button.js.map +1 -0
  134. package/dist/sdks/buy.cjs +19 -0
  135. package/dist/sdks/buy.cjs.map +1 -0
  136. package/dist/sdks/buy.d.cts +23 -0
  137. package/dist/sdks/buy.d.ts +23 -0
  138. package/dist/sdks/buy.js +1 -0
  139. package/dist/sdks/buy.js.map +1 -0
  140. package/dist/sdks/challenge.cjs +19 -0
  141. package/dist/sdks/challenge.cjs.map +1 -0
  142. package/dist/sdks/challenge.d.cts +22 -0
  143. package/dist/sdks/challenge.d.ts +22 -0
  144. package/dist/sdks/challenge.js +1 -0
  145. package/dist/sdks/challenge.js.map +1 -0
  146. package/dist/sdks/connect.cjs +19 -0
  147. package/dist/sdks/connect.cjs.map +1 -0
  148. package/dist/sdks/connect.d.cts +20 -0
  149. package/dist/sdks/connect.d.ts +20 -0
  150. package/dist/sdks/connect.js +1 -0
  151. package/dist/sdks/connect.js.map +1 -0
  152. package/dist/sdks/google-pay.cjs +19 -0
  153. package/dist/sdks/google-pay.cjs.map +1 -0
  154. package/dist/sdks/google-pay.d.cts +36 -0
  155. package/dist/sdks/google-pay.d.ts +36 -0
  156. package/dist/sdks/google-pay.js +1 -0
  157. package/dist/sdks/google-pay.js.map +1 -0
  158. package/dist/sdks/reset.cjs +19 -0
  159. package/dist/sdks/reset.cjs.map +1 -0
  160. package/dist/sdks/reset.d.cts +5 -0
  161. package/dist/sdks/reset.d.ts +5 -0
  162. package/dist/sdks/reset.js +1 -0
  163. package/dist/sdks/reset.js.map +1 -0
  164. package/dist/sdks/widget.cjs +19 -0
  165. package/dist/sdks/widget.cjs.map +1 -0
  166. package/dist/sdks/widget.d.cts +26 -0
  167. package/dist/sdks/widget.d.ts +26 -0
  168. package/dist/sdks/widget.js +1 -0
  169. package/dist/sdks/widget.js.map +1 -0
  170. package/package.json +278 -11
  171. package/dist/index.cjs.map +0 -1
  172. package/dist/index.d.cts +0 -1289
  173. package/dist/index.d.ts +0 -1289
  174. package/dist/index.js +0 -63
  175. package/dist/index.js.map +0 -1
package/dist/index.d.cts DELETED
@@ -1,1289 +0,0 @@
1
- /**
2
- * A fiat currency or crypto token
3
- */
4
- type Asset = {
5
- /**
6
- * A fiat or crypto currency code.
7
- *
8
- * **Fiat**
9
- * Fiat codes are represented as [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) codes.
10
- *
11
- * Currently only `USD` is supported.
12
- *
13
- * **Crypto**
14
- * For crypto currency codes, see [supported currencies](https://dev.moonpay.com/docs/list-of-supported-cryptocurrencies).
15
- *
16
- * Examples: `BTC` `SOL` `ETH` `USDC_BASE` `USDC_SOL`
17
- */
18
- code: string;
19
- /**
20
- * The human-readable name
21
- */
22
- name?: string;
23
- /**
24
- * The number of supported decimal places
25
- */
26
- precision?: number;
27
- };
28
- type AssetBase = {
29
- /**
30
- * A fiat or crypto currency code.
31
- *
32
- * **Fiat**
33
- * Fiat codes are represented as [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) codes.
34
- *
35
- * Currently only `USD` is supported.
36
- *
37
- * **Crypto**
38
- * For crypto currency codes, see [supported currencies](https://dev.moonpay.com/docs/list-of-supported-cryptocurrencies).
39
- *
40
- * Examples: `BTC` `SOL` `ETH` `USDC_BASE` `USDC_SOL`
41
- */
42
- code: string;
43
- };
44
- type CreateSessionTokenRequestBody = {
45
- /**
46
- * A unique identifier for the customer from your system.
47
- */
48
- externalCustomerId?: string;
49
- /**
50
- * The IP address of the user's device to ensure the integrity of the session. Both IPv4 and IPv6 values are supported.
51
- */
52
- deviceIp: IPv4Address | IPv6Address;
53
- /**
54
- * The customer's email address. Must be a valid email. If provided, `phoneNumber` must also be provided.
55
- */
56
- email?: string;
57
- /**
58
- * The customer's phone number in E.164 format. If provided, `email` must also be provided.
59
- */
60
- phoneNumber?: string;
61
- };
62
- type CreateSessionTokenResponse = {
63
- /**
64
- * An opaque session token used to set up a connection on your frontend. This token is single-use and must be generated each time the customer visits your app.
65
- *
66
- * Token expires 24 hours after issuance.
67
- */
68
- sessionToken: string;
69
- };
70
- type Fees = {
71
- /**
72
- * Network fees (in fiat) for the transaction.
73
- */
74
- network?: MonetaryFeeAmount;
75
- /**
76
- * MoonPay fees (in fiat) for the transaction.
77
- */
78
- moonpay?: MonetaryFeeAmount;
79
- /**
80
- * Ecosystem fees (in fiat) for the transaction, if applicable.
81
- */
82
- ecosystem?: MonetaryFeeAmount;
83
- /**
84
- * Partner fees (in fiat) for the transaction, if applicable. Deprecated: use `fees.ecosystem` instead. This field will be removed in a future release.
85
- * @deprecated
86
- */
87
- partner?: MonetaryFeeAmount;
88
- };
89
- type GetQuoteBody = {
90
- /**
91
- * Source asset in fiat. Amount can be set in `source` or `destination`.
92
- */
93
- source: {
94
- /**
95
- * The currency or token being spent
96
- */
97
- asset: AssetBase;
98
- /**
99
- * A stringified amount, which can include decimals.
100
- */
101
- amount?: string;
102
- };
103
- /**
104
- * Destination asset in crypto. Amount can be set in `destination` or `source`.
105
- */
106
- destination: {
107
- asset: AssetBase;
108
- /**
109
- * The amount being received, if known
110
- */
111
- amount?: string;
112
- };
113
- /**
114
- * Wallet address and optional tag where the crypto will be sent. Required for the quote to be executable.
115
- */
116
- wallet?: Wallet;
117
- /**
118
- * Payment method for the transaction. Required for the quote to be executable.
119
- */
120
- paymentMethod?: QuotePaymentMethod;
121
- };
122
- /**
123
- * Quote for a fiat-to-crypto buy. Contains locked rate, fees, expiry, and signature for payment execution.
124
- */
125
- type GetQuoteResponse = {
126
- /**
127
- * Source side of the quote: amount and asset (fiat currency) you send.
128
- */
129
- source: {
130
- /**
131
- * A stringified amount, which can include decimals.
132
- */
133
- amount: string;
134
- /**
135
- * The currency or token being spent
136
- */
137
- asset: Asset;
138
- };
139
- /**
140
- * Destination side of the quote: amount and asset (cryptocurrency) the customer receives.
141
- */
142
- destination: {
143
- /**
144
- * A stringified amount, which can include decimals.
145
- */
146
- amount: string;
147
- asset: Asset;
148
- };
149
- /**
150
- * Breakdown of network, MoonPay, and ecosystem fees.
151
- */
152
- fees: Fees;
153
- /**
154
- * Wallet address and optional tag where the crypto will be sent. Null when not provided.
155
- */
156
- wallet: Wallet | null;
157
- /**
158
- * The payment method used for the quote.
159
- */
160
- paymentMethod: QuotePaymentMethod | null;
161
- limits: QuoteLimits | null;
162
- /**
163
- * An [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) timestamp of when the quote expires.
164
- */
165
- expiresAt: string;
166
- /**
167
- * Whether the quote can be executed. Only `executable` quotes can be used to initiate payment frames.
168
- */
169
- executable: boolean;
170
- /**
171
- * The rate used to convert fiat <-> crypto, expressed as the crypto value of one unit of fiat.
172
- */
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>;
178
- /**
179
- * An opaque token representing the quote to initiate payment frames.
180
- */
181
- signature: string;
182
- };
183
- type IPv4Address = string;
184
- type IPv6Address = string;
185
- type LimitWithAsset = {
186
- /**
187
- * A stringified amount, which can include decimals.
188
- */
189
- amount: string;
190
- asset: AssetBase;
191
- };
192
- type MonetaryFeeAmount = {
193
- /**
194
- * The amount of fees in fiat.
195
- */
196
- amount: string;
197
- /**
198
- * The fiat currency used to pay the fees.
199
- */
200
- asset: AssetBase;
201
- };
202
- type MoonPayCorePaginationInfo = {
203
- /**
204
- * The cursor to use as the starting point for the next page of results.
205
- */
206
- nextCursor: string | null;
207
- };
208
- /**
209
- * The card network brand.
210
- */
211
- type MoonPayPaymentsCardBrand = 'visa' | 'mastercard' | 'maestro' | 'american_express' | 'other';
212
- /**
213
- * The type of card: credit, debit, or unknown.
214
- */
215
- type MoonPayPaymentsCardType = 'credit' | 'debit' | 'unknown';
216
- type MoonPayPaymentsListPaymentMethodsResponse = {
217
- /**
218
- * List of available payment method configurations
219
- */
220
- paymentMethodConfigs?: Array<MoonPayPaymentsPaymentMethod>;
221
- /**
222
- * List of stored payment methods available for the customer
223
- */
224
- paymentMethods?: Array<MoonPayPaymentsStoredPaymentMethod>;
225
- };
226
- type MoonPayPaymentsPaymentMethod = {
227
- type: PaymentMethodType;
228
- /**
229
- * Details of how the payment method can be used.
230
- */
231
- capabilities: MoonPayPaymentsPaymentMethodCapabilities;
232
- availability: MoonPayPaymentsPaymentMethodAvailability;
233
- };
234
- type MoonPayPaymentsPaymentMethodAvailability = {
235
- /**
236
- * Whether the payment method is available
237
- */
238
- active: boolean;
239
- /**
240
- * If the payment method is not available, reasons explaining why.
241
- */
242
- reasons?: Array<string>;
243
- };
244
- type MoonPayPaymentsPaymentMethodCapabilities = {
245
- /**
246
- * [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) codes of fiat currencies supported by this payment method.
247
- */
248
- supportedCurrencies: Array<string>;
249
- /**
250
- * Transaction types supported by this payment method.
251
- */
252
- supportedTransactionTypes: Array<string>;
253
- /**
254
- * Whether this payment method can be deleted.
255
- */
256
- allowsDeletion: boolean;
257
- /**
258
- * Whether this payment method requires the MoonPay widget to complete the payment flow.
259
- */
260
- requiresWidget: boolean;
261
- };
262
- type MoonPayPaymentsStoredCardPaymentMethod = MoonPayPaymentsStoredPaymentMethodBase & {
263
- cardType: MoonPayPaymentsCardType;
264
- /**
265
- * The card network brand
266
- */
267
- brand: MoonPayPaymentsCardBrand;
268
- /**
269
- * Last 4 digits of the card number
270
- */
271
- last4: string;
272
- /**
273
- * Expiration month as 2-digit string
274
- */
275
- expirationMonth: string;
276
- /**
277
- * Expiration year as 4-digit string
278
- */
279
- expirationYear: string;
280
- /**
281
- * Current availability of this stored card
282
- */
283
- availability: MoonPayPaymentsPaymentMethodAvailability;
284
- };
285
- /**
286
- * A stored payment method.
287
- */
288
- type MoonPayPaymentsStoredPaymentMethod = MoonPayPaymentsStoredPaymentMethodBase | MoonPayPaymentsStoredCardPaymentMethod;
289
- type MoonPayPaymentsStoredPaymentMethodBase = {
290
- /**
291
- * Unique identifier for the stored payment method
292
- */
293
- id: string;
294
- type: PaymentMethodType;
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
- };
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';
310
- type QuoteLimitEntry = {
311
- /**
312
- * The maximum amount.
313
- */
314
- limit: LimitWithAsset;
315
- /**
316
- * The remaining amount.
317
- */
318
- remaining: LimitWithAsset;
319
- };
320
- /**
321
- * Limits applicable to the quote.
322
- */
323
- type QuoteLimits = {
324
- /**
325
- * The daily limit.
326
- */
327
- daily?: QuoteLimitEntry;
328
- /**
329
- * The monthly limit.
330
- */
331
- monthly?: QuoteLimitEntry;
332
- /**
333
- * The yearly limit.
334
- */
335
- yearly?: QuoteLimitEntry;
336
- };
337
- type QuotePaymentMethod = {
338
- type: PaymentMethodType;
339
- /**
340
- * Unique identifier of the payment method. Used to identify the specific card when type is card.
341
- */
342
- id?: string;
343
- };
344
- /**
345
- * A stage in the transaction lifecycle
346
- */
347
- type Stage = {
348
- kind?: StageKind;
349
- /**
350
- * The human-readable name of the stage.
351
- */
352
- name?: string;
353
- status?: StageStatus;
354
- /**
355
- * A developer-friendly message if the status is `failed`
356
- */
357
- failureReason?: string | null;
358
- };
359
- /**
360
- * The stages in a transaction lifecycle.
361
- */
362
- type StageKind = 'ordering' | 'waiting_payment' | 'waiting_authentication' | 'verification' | 'processing' | 'delivery' | 'crypto_hold';
363
- /**
364
- * The status of a transaction stage.
365
- */
366
- type StageStatus = 'not_started' | 'in_progress' | 'success' | 'failed';
367
- type TermsAttestation = {
368
- /**
369
- * The MoonPay ID of the terms attestation.
370
- */
371
- id: string;
372
- /**
373
- * Your identifier for the end customer who accepted MoonPay's terms.
374
- */
375
- externalCustomerId: string;
376
- /**
377
- * An [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) formatted string indicating when the attestation was recorded.
378
- */
379
- attestedAt: string;
380
- };
381
- type Transaction = {
382
- /**
383
- * The MoonPay ID of the transaction.
384
- */
385
- id: string;
386
- /**
387
- * An [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) timestamp of when the transaction was created.
388
- */
389
- createdAt: string;
390
- /**
391
- * An [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) timestamp of when the transaction was last updated.
392
- */
393
- updatedAt: string;
394
- status: TransactionStatus;
395
- /**
396
- * Source amount and asset (fiat currency) the customer paid.
397
- */
398
- source: {
399
- /**
400
- * A stringified amount, which can include decimals.
401
- */
402
- amount: string;
403
- /**
404
- * The currency or token being spent
405
- */
406
- asset: AssetBase;
407
- };
408
- /**
409
- * Destination amount and asset (cryptocurrency) the customer receives.
410
- */
411
- destination: {
412
- /**
413
- * A stringified amount, which can include decimals.
414
- */
415
- amount: string;
416
- asset: AssetBase;
417
- };
418
- /**
419
- * Details of fees for the transaction.
420
- */
421
- fees: Fees;
422
- /**
423
- * The wallet used for the transaction.
424
- */
425
- wallet: Wallet;
426
- customer: TransactionCustomer;
427
- paymentMethod?: TransactionPaymentMethod;
428
- };
429
- type TransactionCustomer = {
430
- /**
431
- * The MoonPay ID of the customer associated with the transaction.
432
- */
433
- id: string;
434
- };
435
- type TransactionPaymentMethod = {
436
- type: PaymentMethodType;
437
- };
438
- /**
439
- * The status of a transaction.
440
- *
441
- * - `completed`: The transaction is finalized and assets were delivered.
442
- * - `failed`: The transaction failed. No payment was executed and funds were not transferred.
443
- * - `pending`: The transaction was created and payment is accepted. The transfer is in progress.
444
- */
445
- type TransactionStatus = 'completed' | 'failed' | 'pending';
446
- /**
447
- * Transaction with lifecycle stages showing step-by-step progress.
448
- */
449
- type TransactionWithStages = Transaction & {
450
- /**
451
- * Details of the stages in the transaction lifecycle.
452
- */
453
- stages?: Array<Stage>;
454
- };
455
- type Wallet = {
456
- /**
457
- * The wallet address used for the transaction.
458
- */
459
- address: string;
460
- /**
461
- * An optional memo or destination tag (used by some blockchains such as XRP or XLM).
462
- */
463
- tag?: string;
464
- };
465
-
466
- declare enum ConnectionStatus {
467
- /**
468
- * New or expired user — needs the full connect flow.
469
- */
470
- connectionRequired = "connectionRequired",
471
- /**
472
- * Valid connection — encrypted credentials are included.
473
- */
474
- active = "active",
475
- /**
476
- * Restricted location — connection cannot be used.
477
- */
478
- unavailable = "unavailable",
479
- /**
480
- * KYC decision delayed — may resolve on a subsequent visit.
481
- */
482
- pending = "pending",
483
- /**
484
- * Terminal failure — KYC fail, rejection, etc.
485
- */
486
- failed = "failed",
487
- /**
488
- * Customer has no valid Terms of Use attestation on file (headless/Identity API partners).
489
- * Display Terms of Use in your own UI, capture acceptance, call
490
- * `POST /platform/v1/terms/attestations`, then retry the connection.
491
- */
492
- termsAcceptanceRequired = "termsAcceptanceRequired"
493
- }
494
- interface ConnectionRequired {
495
- status: ConnectionStatus.connectionRequired;
496
- /**
497
- * Base64-encoded, X25519+AES-GCM encrypted anonymous token payload.
498
- * These are frame-internal tokens used by the connect frame — they cannot be
499
- * used to call MoonPay APIs directly. Decrypt via `decryptCredentials()` only
500
- * if you need the `clientToken` to bootstrap the connect frame manually.
501
- */
502
- credentials: string;
503
- /**
504
- * Capabilities and regulatory requirements available before authentication, if any.
505
- * Present when Apple Pay 1TAP is enabled for the partner.
506
- */
507
- capabilities?: CustomerCapabilities;
508
- }
509
- interface ActiveConnection {
510
- status: ConnectionStatus.active;
511
- /** The authenticated MoonPay customer. */
512
- customer: {
513
- id: string;
514
- };
515
- /**
516
- * Base64-encoded, X25519+AES-GCM encrypted JSON containing:
517
- * ```json
518
- * {
519
- * "accessToken": "<token>",
520
- * "clientToken": "<token>",
521
- * "expiresAt": "<iso8601>"
522
- * }
523
- * ```
524
- *
525
- * - `accessToken`: A token that can be used to make API requests from the client.
526
- * - `clientToken`: A token that can be used to initialize sensitive frames such as Apple Pay.
527
- * - `expiresAt`: An ISO 8601 formatted string indicating when the tokens expire.
528
- */
529
- credentials: string;
530
- /**
531
- * Capabilities and regulatory requirements for the authenticated customer.
532
- */
533
- capabilities: CustomerCapabilities;
534
- }
535
- interface UnavailableConnection {
536
- status: ConnectionStatus.unavailable;
537
- }
538
- interface PendingConnection {
539
- status: ConnectionStatus.pending;
540
- }
541
- interface FailedConnection {
542
- status: ConnectionStatus.failed;
543
- reason: string;
544
- }
545
- interface TermsAcceptanceRequiredConnection {
546
- status: ConnectionStatus.termsAcceptanceRequired;
547
- }
548
- /** Discriminated union of all connection result statuses. */
549
- type Connection = ConnectionRequired | ActiveConnection | UnavailableConnection | PendingConnection | FailedConnection | TermsAcceptanceRequiredConnection;
550
- interface DecryptedCredentials {
551
- accessToken: string;
552
- clientToken: string;
553
- expiresAt: string;
554
- }
555
- /**
556
- * Capabilities and regulatory requirements for the authenticated customer.
557
- */
558
- interface CustomerCapabilities {
559
- /** Capabilities for the ramps (buy and sell) product. */
560
- ramps?: RampsCapability;
561
- /** Capabilities for the Apple Pay 1TAP flow. Present when 1TAP is enabled for the partner and the customer matches. */
562
- oneTapApplePay?: RampsCapability;
563
- }
564
- /**
565
- * Capabilities and requirements for the ramps (buy and sell) product.
566
- */
567
- interface RampsCapability {
568
- /** Regulatory requirements for ramps operations in the customer's jurisdiction. */
569
- requirements: RampsRequirements;
570
- }
571
- /**
572
- * Regulatory requirements that apply to ramps operations for the customer.
573
- */
574
- interface RampsRequirements {
575
- /**
576
- * Present when the customer's jurisdiction requires payment disclosures
577
- * before a ramps transaction. Omitted when no disclosures are required.
578
- */
579
- paymentDisclosures?: PaymentDisclosuresRequirement;
580
- }
581
- /**
582
- * A jurisdiction that requires payment disclosures before a ramps transaction.
583
- */
584
- interface PaymentDisclosuresRequirement {
585
- /** The ISO 3166-1 alpha-3 country code for the jurisdiction. */
586
- country: string;
587
- /** The state or province code within the country. */
588
- administrativeArea: string;
589
- }
590
-
591
- declare enum ConnectionErrorCode {
592
- validationError = "validationError",
593
- /** Wire value is `'generic'`. */
594
- connectionFailedGeneric = "generic"
595
- }
596
- interface ConfigValidationFieldError {
597
- code: 'invalidSessionToken' | 'invalidClientToken' | 'invalidPublicKey';
598
- message: string;
599
- }
600
- type ConnectionError = {
601
- code: ConnectionErrorCode.validationError;
602
- errors: ConfigValidationFieldError[];
603
- } | {
604
- code: ConnectionErrorCode.connectionFailedGeneric;
605
- message?: string;
606
- };
607
- declare const DevPlatformApiErrorCodes: {
608
- readonly unknownError: "unknown_error";
609
- readonly unauthorized: "unauthorized";
610
- readonly forbidden: "forbidden";
611
- readonly notFound: "not_found";
612
- readonly invalidRequest: "invalid_request";
613
- readonly notImplemented: "not_implemented";
614
- readonly tooManyRequests: "too_many_requests";
615
- readonly notAllowed: "not_allowed";
616
- readonly conflict: "conflict";
617
- readonly unprocessableEntity: "unprocessable_entity";
618
- readonly sseTimeout: "sse_timeout";
619
- readonly sseError: "sse_error";
620
- readonly connectionRequired: "connection_required";
621
- readonly connectionPending: "connection_pending";
622
- readonly connectionUnavailable: "connection_unavailable";
623
- readonly serviceUnavailable: "service_unavailable";
624
- readonly requirementsIncomplete: "requirements_incomplete";
625
- readonly verificationRejected: "verification_rejected";
626
- readonly countryMismatch: "country_mismatch";
627
- readonly unsupportedCountry: "unsupported_country";
628
- };
629
- type DevPlatformApiErrorCode = (typeof DevPlatformApiErrorCodes)[keyof typeof DevPlatformApiErrorCodes];
630
- interface DevPlatformApiErrorDetail {
631
- field?: string;
632
- message: string;
633
- }
634
- /** Shape returned by the MoonPay Platform API on error responses. */
635
- interface DevPlatformApiError {
636
- code: DevPlatformApiErrorCode;
637
- message: string;
638
- errors?: DevPlatformApiErrorDetail[];
639
- }
640
- interface GetConnectionError {
641
- message: string;
642
- }
643
- interface ConnectError {
644
- message: string;
645
- }
646
- interface SetupWidgetError {
647
- kind: 'configurationError' | 'apiError' | 'genericError';
648
- message: string;
649
- }
650
- interface SetupApplePayError {
651
- kind: 'invalidQuote' | 'quoteExpired' | 'applePayUnavailable' | 'oneTapApplePaySecondFactorRequired' | 'genericError';
652
- message: string;
653
- }
654
- interface SetupGooglePayError {
655
- kind: 'invalidQuote' | 'quoteExpired' | 'googlePayUnavailable' | 'genericError';
656
- message: string;
657
- }
658
- type GetQuoteError = DevPlatformApiError;
659
- type GetPaymentMethodsError = DevPlatformApiError;
660
- type GetTransactionsError = DevPlatformApiError;
661
- type CreateSessionError = DevPlatformApiError;
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;
669
- interface SetupBuyError {
670
- kind: 'configurationError' | 'genericError';
671
- message: string;
672
- }
673
- interface SetupBuyButtonError {
674
- kind: 'configurationError' | 'genericError';
675
- message: string;
676
- }
677
- interface SetupChallengeError {
678
- kind: 'configurationError' | 'genericError';
679
- message: string;
680
- }
681
- interface SetupAuthError {
682
- kind: 'configurationError' | 'genericError';
683
- message: string;
684
- }
685
- interface SetupAddCardError {
686
- kind: 'configurationError' | 'genericError';
687
- message: string;
688
- }
689
- interface ResetConnectionError {
690
- message: string;
691
- }
692
-
693
- /** The V2 protocol envelope sent over postMessage between frames and SDK. */
694
- interface ProtocolMessage<K extends string = string, P = unknown> {
695
- version: 2;
696
- meta: {
697
- channelId: string;
698
- };
699
- kind: K;
700
- payload?: P;
701
- }
702
- declare const HANDSHAKE_REQUEST_KIND: "handshake";
703
- declare const HANDSHAKE_ACK_KIND: "ack";
704
- type HandshakeRequest = ProtocolMessage<typeof HANDSHAKE_REQUEST_KIND>;
705
- type HandshakeAck = ProtocolMessage<typeof HANDSHAKE_ACK_KIND>;
706
- /**
707
- * Maps message `kind` to its payload type for the widget frame.
708
- * Frames use this to type-check what they send; SDK uses it to type-check
709
- * what it receives.
710
- */
711
- interface WidgetMessageMap {
712
- ready: void;
713
- error: {
714
- code: 'configurationError' | 'apiError' | 'generic';
715
- message: string;
716
- };
717
- transactionCreated: {
718
- transaction: {
719
- id: string;
720
- status: string;
721
- };
722
- };
723
- complete: {
724
- transaction: FrameTransaction;
725
- };
726
- close: void;
727
- }
728
- /**
729
- * Maps message `kind` to its payload type for the Apple Pay frame
730
- * (child → parent direction).
731
- */
732
- interface ApplePayInboundMessageMap {
733
- ready: void;
734
- error: {
735
- code: 'configurationError' | 'quoteExpired' | 'invalidQuote' | 'applePayUnavailable' | 'generic' | 'oneTapApplePaySecondFactorRequired';
736
- message: string;
737
- };
738
- complete: {
739
- transaction: FrameTransaction;
740
- };
741
- }
742
- /**
743
- * Maps message `kind` to its payload type for the Apple Pay frame
744
- * (parent → child direction).
745
- */
746
- interface ApplePayOutboundMessageMap {
747
- setQuote: {
748
- quote: {
749
- signature: string;
750
- };
751
- };
752
- }
753
- /**
754
- * Maps message `kind` to its payload type for the Google Pay frame
755
- * (child → parent direction).
756
- */
757
- interface GooglePayInboundMessageMap {
758
- ready: void;
759
- error: {
760
- code: 'configurationError' | 'quoteExpired' | 'invalidQuote' | 'googlePayUnavailable' | 'generic';
761
- message: string;
762
- };
763
- /** Signals that the pipeline requires a challenge step. Load `url` in a challenge frame. */
764
- challenge: {
765
- kind: 'frame';
766
- url: string;
767
- };
768
- complete: {
769
- transaction: FrameTransaction;
770
- };
771
- }
772
- /**
773
- * Maps message `kind` to its payload type for the Google Pay frame
774
- * (parent → child direction).
775
- */
776
- interface GooglePayOutboundMessageMap {
777
- setQuote: {
778
- quote: {
779
- signature: string;
780
- };
781
- };
782
- }
783
- /**
784
- * Maps message `kind` to its payload type for the connect/check-connection
785
- * frame (child → parent direction).
786
- */
787
- interface ConnectMessageMap {
788
- ready: void;
789
- error: ConnectionError;
790
- complete: ConnectionRequired | ActiveConnection | UnavailableConnection | PendingConnection | FailedConnection | TermsAcceptanceRequiredConnection;
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
- }
809
- /**
810
- * Maps message `kind` to its payload type for the buy frame
811
- * (child → parent direction).
812
- *
813
- * The buy frame executes the full buy pipeline (pre-check → create →
814
- * post-check) headlessly. It may escalate to a challenge frame mid-pipeline.
815
- */
816
- interface BuyMessageMap {
817
- ready: void;
818
- complete: {
819
- transaction: FrameTransaction;
820
- };
821
- /** Signals that the pipeline requires a challenge step. Load `url` in a challenge frame. */
822
- challenge: {
823
- kind: string;
824
- url: string;
825
- };
826
- error: {
827
- code: string;
828
- message: string;
829
- };
830
- }
831
- /**
832
- * Maps message `kind` to its payload type for the buy frame
833
- * (parent → child direction).
834
- */
835
- interface BuyOutboundMessageMap {
836
- setQuote: {
837
- quote: {
838
- signature: string;
839
- };
840
- };
841
- }
842
- /**
843
- * Maps message `kind` to its payload type for the buy-button frame
844
- * (child → parent direction).
845
- *
846
- * The buy-button frame renders a payment button (card, Apple Pay, Google Pay)
847
- * and runs the buy pipeline on tap. It may escalate to a challenge frame.
848
- */
849
- interface BuyButtonMessageMap {
850
- complete: {
851
- transaction: FrameTransaction;
852
- };
853
- /** Signals that the pipeline requires a challenge step. Load `url` in a challenge frame. */
854
- challenge: {
855
- kind: string;
856
- url: string;
857
- };
858
- error: {
859
- code: string;
860
- message: string;
861
- };
862
- }
863
- /**
864
- * Maps message `kind` to its payload type for the buy-button frame
865
- * (parent → child direction).
866
- */
867
- interface BuyButtonOutboundMessageMap {
868
- setQuote: {
869
- quote: {
870
- signature: string;
871
- };
872
- };
873
- }
874
- type ChallengeCompleteResult = {
875
- flow: 'buy';
876
- transaction: FrameTransaction;
877
- } | {
878
- flow: 'identity';
879
- identityId: string;
880
- };
881
- type ChallengeCancellation = {
882
- flow: 'buy';
883
- transactionId?: string;
884
- challengeToken?: string;
885
- } | {
886
- flow: 'identity';
887
- };
888
- /**
889
- * Maps message `kind` to its payload type for the challenge frame
890
- * (child → parent direction).
891
- *
892
- * The challenge frame is fully self-contained — it is driven by the
893
- * `challengeToken` URL param. There is no parent → child message map.
894
- */
895
- interface ChallengeMessageMap {
896
- ready: void;
897
- complete: ChallengeCompleteResult;
898
- /** User dismissed the challenge. Carry `transactionId` / `challengeToken` to resume. */
899
- cancelled: ChallengeCancellation;
900
- error: {
901
- code: string;
902
- message: string;
903
- };
904
- }
905
- /**
906
- * Maps message `kind` to its payload type for the reset frame
907
- * (child → parent direction).
908
- *
909
- * The reset frame clears the customer's MoonPay connection for the partner.
910
- * It is fully driven by the `sessionToken` URL param. There is no
911
- * parent → child message map.
912
- */
913
- interface ResetMessageMap {
914
- complete: void;
915
- error: {
916
- code: string;
917
- message: string;
918
- };
919
- }
920
- /** Card returned by the add-card frame on successful creation. */
921
- interface CardResponse {
922
- id: string;
923
- /** Payment method type, e.g. `'card'`. */
924
- type: string;
925
- /** Card sub-type, e.g. `'credit'` or `'debit'`. */
926
- cardType: string;
927
- /** Card network brand, e.g. `'visa'` or `'mastercard'`. */
928
- brand: string;
929
- last4: string;
930
- expirationMonth: string;
931
- expirationYear: string;
932
- availability: {
933
- active: true;
934
- };
935
- }
936
- /**
937
- * Maps message `kind` to its payload type for the add-card frame
938
- * (child → parent direction).
939
- *
940
- * There is no parent → child message map for the add-card frame.
941
- */
942
- interface AddCardMessageMap {
943
- complete: {
944
- card: CardResponse;
945
- };
946
- error: {
947
- code: 'generic' | 'configurationError';
948
- message: string;
949
- };
950
- }
951
-
952
- /** Transaction shape as sent within frame postMessage payloads. */
953
- type FrameTransaction = {
954
- id: string;
955
- status: string;
956
- } | {
957
- id?: string;
958
- status: 'failed';
959
- failureReason: string;
960
- };
961
- /** A ProtocolMessage typed to a specific message map entry. */
962
- type TypedMessage<Map extends Record<string, unknown>, K extends keyof Map & string> = Map[K] extends void ? ProtocolMessage<K, undefined> : ProtocolMessage<K, Map[K]>;
963
- /** Union of all typed messages for a given message map. */
964
- type MessageUnion<Map extends Record<string, unknown>> = {
965
- [K in keyof Map & string]: TypedMessage<Map, K>;
966
- }[keyof Map & string];
967
-
968
- /** A parent→child message to update the quote in the Apple Pay frame. */
969
- type SetQuoteCommand = ProtocolMessage<'setQuote', ApplePayOutboundMessageMap['setQuote']>;
970
- /** A parent→child message to update the quote in the Google Pay frame. */
971
- type SetGooglePayQuoteCommand = ProtocolMessage<'setQuote', GooglePayOutboundMessageMap['setQuote']>;
972
- /** A parent→child message to update the quote in the buy frame. */
973
- type SetBuyQuoteCommand = ProtocolMessage<'setQuote', BuyOutboundMessageMap['setQuote']>;
974
- /** A parent→child message to update the quote in the buy-button frame. */
975
- type SetBuyButtonQuoteCommand = ProtocolMessage<'setQuote', BuyButtonOutboundMessageMap['setQuote']>;
976
-
977
- type WidgetEvent = {
978
- kind: 'ready';
979
- } | {
980
- kind: 'error';
981
- payload: WidgetMessageMap['error'];
982
- } | {
983
- kind: 'transactionCreated';
984
- payload: WidgetMessageMap['transactionCreated'];
985
- } | {
986
- kind: 'complete';
987
- payload: {
988
- transaction: FrameTransaction;
989
- };
990
- } | {
991
- kind: 'close';
992
- };
993
- type ApplePayEventError = {
994
- kind: 'configurationError' | 'invalidQuote' | 'quoteExpired' | 'oneTapApplePaySecondFactorRequired' | 'genericError';
995
- message: string;
996
- };
997
- type ApplePayEvent = {
998
- kind: 'ready';
999
- } | {
1000
- kind: 'complete';
1001
- payload: {
1002
- transaction: FrameTransaction;
1003
- };
1004
- } | {
1005
- kind: 'quoteExpired';
1006
- payload: {
1007
- setQuote: (signature: string) => void;
1008
- };
1009
- } | {
1010
- kind: 'error';
1011
- payload: ApplePayEventError;
1012
- } | {
1013
- kind: 'unsupported';
1014
- };
1015
- type GooglePayEventError = {
1016
- kind: 'configurationError' | 'invalidQuote' | 'quoteExpired' | 'genericError';
1017
- message: string;
1018
- };
1019
- type GooglePayEvent = {
1020
- kind: 'ready';
1021
- } | {
1022
- kind: 'complete';
1023
- payload: {
1024
- transaction: FrameTransaction;
1025
- };
1026
- } | {
1027
- kind: 'challenge';
1028
- payload: GooglePayInboundMessageMap['challenge'];
1029
- } | {
1030
- kind: 'quoteExpired';
1031
- payload: {
1032
- setQuote: (signature: string) => void;
1033
- };
1034
- } | {
1035
- kind: 'error';
1036
- payload: GooglePayEventError;
1037
- } | {
1038
- kind: 'unsupported';
1039
- };
1040
- type ConnectEvent = {
1041
- kind: 'ready';
1042
- } | {
1043
- kind: 'error';
1044
- payload: ConnectMessageMap['error'];
1045
- } | {
1046
- kind: 'complete';
1047
- payload: ConnectMessageMap['complete'];
1048
- };
1049
- type AuthEvent = {
1050
- kind: 'ready';
1051
- } | {
1052
- kind: 'error';
1053
- payload: AuthMessageMap['error'];
1054
- } | {
1055
- kind: 'complete';
1056
- payload: AuthMessageMap['complete'];
1057
- };
1058
- type BuyEvent = {
1059
- kind: 'ready';
1060
- } | {
1061
- kind: 'complete';
1062
- payload: BuyMessageMap['complete'];
1063
- } | {
1064
- kind: 'challenge';
1065
- payload: BuyMessageMap['challenge'];
1066
- } | {
1067
- kind: 'error';
1068
- payload: BuyMessageMap['error'];
1069
- };
1070
- type BuyButtonEvent = {
1071
- kind: 'complete';
1072
- payload: BuyButtonMessageMap['complete'];
1073
- } | {
1074
- kind: 'challenge';
1075
- payload: BuyButtonMessageMap['challenge'];
1076
- } | {
1077
- kind: 'error';
1078
- payload: BuyButtonMessageMap['error'];
1079
- };
1080
- type ChallengeEvent = {
1081
- kind: 'ready';
1082
- } | {
1083
- kind: 'complete';
1084
- payload: ChallengeCompleteResult;
1085
- } | {
1086
- kind: 'cancelled';
1087
- payload: ChallengeCancellation;
1088
- } | {
1089
- kind: 'error';
1090
- payload: {
1091
- code: string;
1092
- message: string;
1093
- };
1094
- };
1095
- type AddCardEvent = {
1096
- kind: 'complete';
1097
- payload: {
1098
- card: CardResponse;
1099
- };
1100
- } | {
1101
- kind: 'error';
1102
- payload: AddCardMessageMap['error'];
1103
- };
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
-
1260
- /**
1261
- * A discriminated union representing either a successful value or an error.
1262
- * SDK methods return this type instead of throwing exceptions.
1263
- */
1264
- type Result<T, E> = {
1265
- ok: true;
1266
- value: T;
1267
- } | {
1268
- ok: false;
1269
- error: E;
1270
- };
1271
- /** A Result variant for operations that produce no value on success. */
1272
- type EmptyResult<E> = {
1273
- ok: true;
1274
- } | {
1275
- ok: false;
1276
- error: E;
1277
- };
1278
- /** Construct a successful Result. */
1279
- declare const ok: <T>(value: T) => {
1280
- ok: true;
1281
- value: T;
1282
- };
1283
- /** Construct a failed Result. */
1284
- declare const err: <E>(error: E) => {
1285
- ok: false;
1286
- error: E;
1287
- };
1288
-
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 };