@fun-xyz/fiat-contract 0.23.0 → 0.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -19,7 +19,7 @@ Four things, zero runtime logic beyond validation:
19
19
  | --- | --- | --- | --- |
20
20
  | `@fun-xyz/fiat-contract/types` | **0.1 KB** (types erase) | every type; no runtime values | production, both repos |
21
21
  | `@fun-xyz/fiat-contract/table` | **13.8 KB**, zero deps | `TRANSITION_TABLE`, `stateKey`, `tableEntry`, `isTerminal`, `walkTable`, `TABLE_VERSION`, `TERMINAL_ORDER_STATUSES`, `DOCUMENTED_ENDPOINTS`, `UNOFFERED_ENDPOINTS`, `UNREACHABLE_STATES`, `unofferedEndpoints`, `unreachableStates` | **production frontend** + backend |
22
- | `@fun-xyz/fiat-contract/moonpay` | zero deps | the MoonPay provider-owned flow: `intent` request kinds, response statuses and fault types, and `MOONPAY_ENDPOINTS` | **production frontend** (MoonPay adapter) + backend |
22
+ | `@fun-xyz/fiat-contract/moonpay` | zero deps | the MoonPay flow on `POST /fiat/next`: action requests, prompts, responses, fault types, and `MOONPAY_ENDPOINTS` | **production frontend** (MoonPay adapter) + backend |
23
23
  | `@fun-xyz/fiat-contract/terms` | zero deps | the platform terms route: `TermsDocument`, `FiatTermsRequest`, `FiatTermsResponse`, fault types, and `FIAT_TERMS_ENDPOINT` | **production frontend** + backend |
24
24
  | `@fun-xyz/fiat-contract/routing` | zero deps | the routing table and routing quote: `FiatRoutingTableQuery`, `FiatRoutingTableResponse`, `FiatRoutingQuoteRequest`, both routes' error bodies, and `ROUTING_ENDPOINTS` | **production frontend** + backend |
25
25
  | `@fun-xyz/fiat-contract` | 47.6 KB, needs zod | the above + 77 zod schemas + assertions + 18 fixtures | tests, and backend dev/test guards |
@@ -102,7 +102,7 @@ A provider can run its own flow instead of the shared step machine. `POST /fiat/
102
102
  and prices. When the request's `handoffs` lists the winning provider, the response carries
103
103
  `handoff: { provider }` and no transitions. The client shows that provider's `CHECKOUT` documents
104
104
  from `PROVIDER_CHECKOUT_DOCUMENTS`, records them with `POST /fiat/terms` on Continue, and then calls
105
- `POST /fiat/providers/{provider}/intent`. The schema refuses a handoff on any state but `QUOTE`, a
105
+ `POST /fiat/next`. The schema refuses a handoff on any state but `QUOTE`, a
106
106
  handoff to a provider other than the response's own, and a handoff that still offers transitions.
107
107
 
108
108
  **Terms (`./terms`).** Every provider records acceptances through the platform `POST /fiat/terms`
@@ -156,51 +156,51 @@ Both routes take geo under the `POST /fiat/quote` rules: a known `CountryCode`,
156
156
  region for a US buyer, and an empty `region` or `ip` read as absent. The quote route's `geo` is the
157
157
  Fun geo endpoint's response forwarded as is. The request schemas are strict like every schema here,
158
158
  so a client sends only the declared keys and no blank strings. `provider` is one of the five
159
- providers the backend routes (`RoutingProvider`). The quote route is temporary: each provider's
160
- `intent` route replaces it.
159
+ providers the backend routes (`RoutingProvider`). The quote route is temporary: `POST /fiat/next`
160
+ replaces it for each provider that moves there.
161
161
 
162
- **MoonPay (`./moonpay`).** One route, `MOONPAY_ENDPOINTS.intent`. A `MoonPayIntentRequest` is one of
163
- three kinds:
162
+ **MoonPay (`./moonpay`).** MoonPay runs on the shared `POST /fiat/next` (`MOONPAY_ENDPOINTS.next`).
163
+ Every `/next` body is a `FiatNextRequest`: `provider`, `geo` (a `FiatGeo`, the geo endpoint's
164
+ response), and the provider's own request, which names its `action`. The orchestrator reads
165
+ `provider` and `geo`; the provider's action schema reads the rest. MoonPay's body is a
166
+ `MoonPayNextRequest`, and every MoonPay request also carries the context `checkout` and, after
167
+ `connect`, `credentials` (`customerId`, `accessToken`).
164
168
 
165
- | `kind` | Carries | A repeat |
166
- | --- | --- | --- |
167
- | `observe` | `checkout`, and `credentials` (`customerId`, `accessToken`) once the SDK has them | writes nothing new |
168
- | `kyc` | `checkout`, `credentials`, `values` keyed by `KycFieldId` (no form id) | drops values MoonPay no longer asks for |
169
- | `order` | `orderId`, `transactionId?`, `quotedAmount`, `geo?` (the checkout's) | returns the recorded order |
170
-
171
- `observe` and `kyc` answer a `MoonPayStepResponse`, which says what the backend needs next:
172
-
173
- | `status` | Carries | The client then |
174
- | --- | --- | --- |
175
- | `TERMS` | `stage`, `documents` (at least one, all at `stage`) | sends `POST /fiat/terms`, then `observe` |
176
- | `SDK_AUTH` | `sessionToken`, `quoteInput`, `resetConnection?` (`true` when the device's MoonPay connection is another buyer's) | resets the connection when asked, runs the MoonPay connection check, then `observe` with credentials |
177
- | `KYC` | `fields`, `fieldErrors?` (each naming a field in `fields`, with `code?` `PHONE_IN_USE` on `PHONE_NUMBER` or `TAX_ID_IN_USE` on `TAX_IDENTIFIER` when another MoonPay customer holds the value) | shows the shared form, then sends `kyc` |
178
- | `PENDING` | `retryAfterMs` (at most 60 s) | sends `observe` after the delay, never `kyc` again |
179
- | `READY` | `orderId`, `quoteInput` | mounts Apple Pay, then sends `order` after the charge |
180
- | `REFUSED` | `reason` (`NOT_ELIGIBLE`, `DOCUMENTS_REQUIRED`, `FINAL_REJECTION`, `CUSTOMER_MISMATCH`), `recovery: REQUOTE \| NONE` | exits the provider flow |
181
-
182
- `order` runs after every charge attempt, a failed one too, and answers a `MoonPayOrderResponse`.
183
- `transactionId` is optional because a failed charge may have none; without it the backend records the
184
- failed charges MoonPay lists for `orderId`. `quotedAmount` is the fiat amount the quote showed.
185
- `geo` is the same object `observe` sends in `checkout`; the order records its `alpha2` as its
186
- country, and no country without it. A
187
- failed charge answers `DONE` with the order in `FAILED`, and the client requotes for a new `orderId`.
188
- After a failed charge with no `transactionId`, the client caps its `PENDING` polls.
189
-
190
- | `status` | Carries | The client then |
191
- | --- | --- | --- |
192
- | `DONE` | `order`, the `GET /fiat/orders/:orderId` response | shows the shared order status |
193
- | `PENDING` | `retryAfterMs` (at most 60 s) | sends the same `order` after the delay |
194
- | `REFUSED` | `reason` (`CUSTOMER_MISMATCH`, `WALLET_MISMATCH`, `UNRECORDABLE`), `recovery: NONE` | exits the provider flow |
169
+ Each `MoonPayAction` has one name. A response's prompt names it in `next` and carries what the
170
+ client needs; the client's request names it in `action` and carries the result:
195
171
 
196
- `MoonPayIntentResponseFor` maps each `kind` to its union, and `MoonPayIntentResponse` is both.
172
+ | Action | Prompt carries | Request carries | A repeat |
173
+ | --- | --- | --- | --- |
174
+ | `observe` | no prompt: the answer is the current prompt | nothing | writes nothing |
175
+ | `consent` | `documents` (at least one, unique ids) | `acceptances`, the `POST /fiat/terms` items | writes nothing new |
176
+ | `connect` | `sessionToken`, `quoteInput`, `resetConnection?` (`true` when the device's MoonPay connection is another buyer's) | `customerId`, `accessToken` | rebinds the same customer |
177
+ | `kyc` | `fields`, `fieldErrors?` (each naming a field in `fields`, with `code?` `PHONE_IN_USE` on `PHONE_NUMBER` or `TAX_ID_IN_USE` on `TAX_IDENTIFIER` when another MoonPay customer holds the value) | `credentials`, `values` keyed by `KycFieldId` (no form id) | drops values MoonPay no longer asks for |
178
+ | `wait` | `retryAfterMs` (at most 60 s) | no request: the client sends `observe` after the delay | |
179
+ | `order` | `orderId`, `quoteInput` | `orderId`, `quotedAmount`, `transactionId?` | returns the recorded order |
180
+
181
+ Every response is the next prompt, `done`, or `refused` (`MoonPayRefused`), and
182
+ `MoonPayResponseFor` maps each request action to its union. `observe`, `consent`, `connect` and `kyc`
183
+ answer a `MoonPayStepResponse`: any `MoonPayPrompt`, or `refused` with `reason` (`NOT_ELIGIBLE`,
184
+ `DOCUMENTS_REQUIRED`, `FINAL_REJECTION`, `CUSTOMER_MISMATCH`) and `recovery: REQUOTE | NONE`.
185
+
186
+ `order` runs after every charge attempt, a failed one too, and answers a `MoonPayOrderResponse`:
187
+ `done` with `order`, the `GET /fiat/orders/:orderId` response; `order` again while MoonPay does not
188
+ list the transaction yet; or `refused` with `reason` (`CUSTOMER_MISMATCH`, `WALLET_MISMATCH`,
189
+ `UNRECORDABLE`) and `recovery: NONE`. `transactionId` is optional because a failed charge may have
190
+ none; without it the backend records the failed charges MoonPay lists for `orderId`. `quotedAmount`
191
+ is the fiat amount the device quote showed. The order records the body's `geo.alpha2` as its country.
192
+ A failed charge answers `done` with the order in `FAILED`, and the client requotes for a new `orderId`.
193
+
194
+ A first-time buyer goes `observe` → `consent` → `connect` → `kyc` → `wait` → `observe` → `order` →
195
+ `done`; a returning buyer `observe` → `connect` → `order` → `done`. Both walks are recorded in
196
+ `test/fixtures/moonpay-next/`.
197
197
 
198
198
  A fault is a 4xx or 5xx with a `MoonPayErrorBody`: the shared `errorCode`, `errorMsg` and `reqId`,
199
199
  plus `reason` (`SESSION_BUDGET_SPENT`, `RATE_LIMITED`, `PROVIDER_UNAVAILABLE`, `INVALID_REQUEST`)
200
200
  and `recovery`:
201
- `RETRY` (send the same request again), `REQUOTE`, or `NONE`. A field error is a `KYC`
202
- response, not a fault. The zod schemas (`MoonPay*Schema`, `TermsDocumentSchema`, `FiatTerms*Schema`)
203
- are exported from the root only.
201
+ `RETRY` (send the same request again), `REQUOTE`, or `NONE`. A field error is a `kyc`
202
+ prompt, not a fault. The zod schemas (`MoonPay*Schema`, `FiatGeoSchema`, `FiatNextRequestSchema`,
203
+ `TermsDocumentSchema`, `FiatTerms*Schema`) are exported from the root only.
204
204
 
205
205
  ## KYC SDK hints, results, and client delivery
206
206
 
@@ -1,11 +1,11 @@
1
1
  // src/routing.ts
2
2
  var ROUTING_ENDPOINTS = {
3
3
  table: "GET /fiat/routing/table",
4
- /** Temporary: each provider's `intent` route replaces it. */
4
+ /** Temporary: `POST /fiat/next` replaces it for each provider that moves there. */
5
5
  quote: "POST /fiat/routing/quote"
6
6
  };
7
7
 
8
8
  export {
9
9
  ROUTING_ENDPOINTS
10
10
  };
11
- //# sourceMappingURL=chunk-KYE2HYV5.mjs.map
11
+ //# sourceMappingURL=chunk-5UEPWL7B.mjs.map
@@ -41,4 +41,4 @@ export {
41
41
  FUN_KYC_CONSENT_DOCUMENTS,
42
42
  PUBLISHED_TERMS_DOCUMENTS
43
43
  };
44
- //# sourceMappingURL=chunk-5GRPYE2U.mjs.map
44
+ //# sourceMappingURL=chunk-CRNKRIKR.mjs.map
@@ -1,5 +1,5 @@
1
1
  // package.json
2
- var version = "0.23.0";
2
+ var version = "0.24.0";
3
3
 
4
4
  // src/table.ts
5
5
  var TABLE_VERSION = version;
@@ -514,4 +514,4 @@ export {
514
514
  tableEntry,
515
515
  isTerminal
516
516
  };
517
- //# sourceMappingURL=chunk-EI56NQ7K.mjs.map
517
+ //# sourceMappingURL=chunk-IPOPANXS.mjs.map
@@ -0,0 +1,9 @@
1
+ // src/providers/moonpay.ts
2
+ var MOONPAY_ENDPOINTS = {
3
+ next: "POST /fiat/next"
4
+ };
5
+
6
+ export {
7
+ MOONPAY_ENDPOINTS
8
+ };
9
+ //# sourceMappingURL=chunk-T5JAYOWY.mjs.map
package/dist/index.js CHANGED
@@ -42,6 +42,8 @@ __export(index_exports, {
42
42
  FiatAmountSchema: () => FiatAmountSchema,
43
43
  FiatCurrencyCode: () => FiatCurrencyCode,
44
44
  FiatEndpointSchema: () => FiatEndpointSchema,
45
+ FiatGeoSchema: () => FiatGeoSchema,
46
+ FiatNextRequestSchema: () => FiatNextRequestSchema,
45
47
  FiatProviderSchema: () => FiatProviderSchema,
46
48
  FiatRoutingQuoteErrorBodySchema: () => FiatRoutingQuoteErrorBodySchema,
47
49
  FiatRoutingQuoteRequestSchema: () => FiatRoutingQuoteRequestSchema,
@@ -72,14 +74,28 @@ __export(index_exports, {
72
74
  KycSdkResultReportSchema: () => KycSdkResultReportSchema,
73
75
  MOONPAY_ENDPOINTS: () => MOONPAY_ENDPOINTS,
74
76
  MoonPayCheckoutSchema: () => MoonPayCheckoutSchema,
77
+ MoonPayConnectPromptSchema: () => MoonPayConnectPromptSchema,
78
+ MoonPayConnectRequestSchema: () => MoonPayConnectRequestSchema,
79
+ MoonPayConsentPromptSchema: () => MoonPayConsentPromptSchema,
80
+ MoonPayConsentRequestSchema: () => MoonPayConsentRequestSchema,
81
+ MoonPayDoneSchema: () => MoonPayDoneSchema,
75
82
  MoonPayErrorBodySchema: () => MoonPayErrorBodySchema,
76
83
  MoonPayFaultSchema: () => MoonPayFaultSchema,
77
- MoonPayIntentRequestSchema: () => MoonPayIntentRequestSchema,
78
- MoonPayIntentResponseSchema: () => MoonPayIntentResponseSchema,
84
+ MoonPayKycPromptSchema: () => MoonPayKycPromptSchema,
85
+ MoonPayKycRequestSchema: () => MoonPayKycRequestSchema,
86
+ MoonPayNextRequestSchema: () => MoonPayNextRequestSchema,
87
+ MoonPayObserveRequestSchema: () => MoonPayObserveRequestSchema,
88
+ MoonPayOrderPromptSchema: () => MoonPayOrderPromptSchema,
89
+ MoonPayOrderRequestSchema: () => MoonPayOrderRequestSchema,
79
90
  MoonPayOrderResponseSchema: () => MoonPayOrderResponseSchema,
91
+ MoonPayPromptSchema: () => MoonPayPromptSchema,
80
92
  MoonPayQuoteInputSchema: () => MoonPayQuoteInputSchema,
93
+ MoonPayRequestContextSchema: () => MoonPayRequestContextSchema,
94
+ MoonPayRequestSchema: () => MoonPayRequestSchema,
95
+ MoonPayResponseSchemaFor: () => MoonPayResponseSchemaFor,
81
96
  MoonPaySdkCredentialsSchema: () => MoonPaySdkCredentialsSchema,
82
97
  MoonPayStepResponseSchema: () => MoonPayStepResponseSchema,
98
+ MoonPayWaitPromptSchema: () => MoonPayWaitPromptSchema,
83
99
  OrderAwaitingConfirmationStateSchema: () => OrderAwaitingConfirmationStateSchema,
84
100
  OrderCreatedStateSchema: () => OrderCreatedStateSchema,
85
101
  OrderRefSchema: () => OrderRefSchema,
@@ -1121,6 +1137,10 @@ var $routingTableErrorBody = import_zod.z.union([$routingRateLimitedErrorBody, $
1121
1137
  var FiatRoutingTableErrorBodySchema = $routingTableErrorBody;
1122
1138
  var $routingQuoteErrorBody = import_zod.z.union([$routingNoRouteErrorBody, $routingAmountErrorBody, $routingFaultErrorBody]);
1123
1139
  var FiatRoutingQuoteErrorBodySchema = $routingQuoteErrorBody;
1140
+ var $fiatGeo = obj({ alpha2: import_zod.z.string().regex(/^[A-Z]{2}$/), region: $nonBlank.optional(), ip: $nonBlank.optional() });
1141
+ var FiatGeoSchema = $fiatGeo;
1142
+ var $nextRequest = import_zod.z.object({ provider: $provider, action: $nonBlank, geo: $fiatGeo }).catchall(import_zod.z.unknown());
1143
+ var FiatNextRequestSchema = $nextRequest;
1124
1144
  var $providerBoundStepResponse = obj({
1125
1145
  state: $providerBoundFlowState,
1126
1146
  provider: $provider,
@@ -1180,7 +1200,7 @@ var $stepResponse = import_zod.z.union([$providerBoundStepResponse, $blockedStep
1180
1200
  var FiatStepResponseSchema = $stepResponse;
1181
1201
 
1182
1202
  // package.json
1183
- var version = "0.23.0";
1203
+ var version = "0.24.0";
1184
1204
 
1185
1205
  // src/table.ts
1186
1206
  var TABLE_VERSION = version;
@@ -2786,13 +2806,13 @@ var PUBLISHED_TERMS_DOCUMENTS = [MOONPAY_TERMS, ...Object.values(FUN_KYC_CONSENT
2786
2806
  // src/routing.ts
2787
2807
  var ROUTING_ENDPOINTS = {
2788
2808
  table: "GET /fiat/routing/table",
2789
- /** Temporary: each provider's `intent` route replaces it. */
2809
+ /** Temporary: `POST /fiat/next` replaces it for each provider that moves there. */
2790
2810
  quote: "POST /fiat/routing/quote"
2791
2811
  };
2792
2812
 
2793
2813
  // src/providers/moonpay.ts
2794
2814
  var MOONPAY_ENDPOINTS = {
2795
- intent: "POST /fiat/providers/moonpay/intent"
2815
+ next: "POST /fiat/next"
2796
2816
  };
2797
2817
 
2798
2818
  // src/providers/moonpay.schemas.ts
@@ -2801,33 +2821,17 @@ var FIAT_CURRENCY_CODES2 = Object.keys(FIAT_CURRENCY_NAMES);
2801
2821
  var obj2 = (shape) => import_zod2.z.object(shape).strict();
2802
2822
  var $nonEmpty = import_zod2.z.string().refine((value) => value.trim().length > 0, "must not be blank");
2803
2823
  var hasUniqueIds2 = (ids) => new Set(ids).size === ids.length;
2804
- var $geo = obj2({ alpha2: import_zod2.z.string().regex(/^[A-Z]{2}$/), region: $nonEmpty.optional(), ip: $nonEmpty.optional() });
2805
2824
  var $checkout = obj2({
2806
2825
  amount: FiatAmountSchema,
2807
2826
  destination: obj2({ asset: $nonEmpty, network: $nonEmpty }),
2808
- paymentMethod: import_zod2.z.literal("apple_pay"),
2809
- geo: $geo
2827
+ paymentMethod: import_zod2.z.literal("apple_pay")
2810
2828
  });
2811
2829
  var MoonPayCheckoutSchema = $checkout;
2812
2830
  var $credentials = obj2({ customerId: $nonEmpty, accessToken: $nonEmpty });
2813
2831
  var MoonPaySdkCredentialsSchema = $credentials;
2814
- var $intentRequest = import_zod2.z.discriminatedUnion("kind", [
2815
- obj2({ kind: import_zod2.z.literal("observe"), checkout: $checkout, credentials: $credentials.optional() }),
2816
- obj2({
2817
- kind: import_zod2.z.literal("kyc"),
2818
- checkout: $checkout,
2819
- credentials: $credentials,
2820
- values: import_zod2.z.record(KycFieldIdSchema, import_zod2.z.string()).refine((values) => Object.keys(values).length > 0, "values must not be empty")
2821
- }),
2822
- obj2({
2823
- kind: import_zod2.z.literal("order"),
2824
- orderId: $nonEmpty,
2825
- transactionId: $nonEmpty.optional(),
2826
- quotedAmount: FiatAmountSchema,
2827
- geo: $geo.optional()
2828
- })
2829
- ]);
2830
- var MoonPayIntentRequestSchema = $intentRequest;
2832
+ var $context = { checkout: $checkout, credentials: $credentials.optional() };
2833
+ var $requestContext = obj2($context);
2834
+ var MoonPayRequestContextSchema = $requestContext;
2831
2835
  var $quoteInput = obj2({
2832
2836
  source: obj2({ asset: obj2({ code: import_zod2.z.enum(FIAT_CURRENCY_CODES2) }), amount: $nonEmpty }),
2833
2837
  destination: obj2({ asset: obj2({ code: $nonEmpty }) }),
@@ -2836,50 +2840,103 @@ var $quoteInput = obj2({
2836
2840
  feeBehavior: import_zod2.z.literal("inclusive")
2837
2841
  });
2838
2842
  var MoonPayQuoteInputSchema = $quoteInput;
2839
- var $stepRefusal = import_zod2.z.enum(["NOT_ELIGIBLE", "DOCUMENTS_REQUIRED", "FINAL_REJECTION", "CUSTOMER_MISMATCH"]);
2840
- var $orderRefusal = import_zod2.z.enum(["CUSTOMER_MISMATCH", "WALLET_MISMATCH", "UNRECORDABLE"]);
2843
+ var $observeFields = { action: import_zod2.z.literal("observe") };
2844
+ var $consentFields = {
2845
+ action: import_zod2.z.literal("consent"),
2846
+ acceptances: import_zod2.z.array(TermsDocumentAcceptanceSchema).min(1).refine((acceptances) => hasUniqueIds2(acceptances.map((acceptance) => acceptance.documentId)), "each document is accepted once")
2847
+ };
2848
+ var $connectFields = { action: import_zod2.z.literal("connect"), customerId: $nonEmpty, accessToken: $nonEmpty };
2849
+ var $kycFields = {
2850
+ action: import_zod2.z.literal("kyc"),
2851
+ credentials: $credentials,
2852
+ values: import_zod2.z.record(KycFieldIdSchema, import_zod2.z.string()).refine((values) => Object.keys(values).length > 0, "values must not be empty")
2853
+ };
2854
+ var $orderFields = { action: import_zod2.z.literal("order"), orderId: $nonEmpty, quotedAmount: FiatAmountSchema, transactionId: $nonEmpty.optional() };
2855
+ var $observeRequest = obj2({ ...$context, ...$observeFields });
2856
+ var $consentRequest = obj2({ ...$context, ...$consentFields });
2857
+ var $connectRequest = obj2({ ...$context, ...$connectFields });
2858
+ var $kycRequest = obj2({ ...$context, ...$kycFields });
2859
+ var $orderRequest = obj2({ ...$context, ...$orderFields });
2860
+ var MoonPayObserveRequestSchema = $observeRequest;
2861
+ var MoonPayConsentRequestSchema = $consentRequest;
2862
+ var MoonPayConnectRequestSchema = $connectRequest;
2863
+ var MoonPayKycRequestSchema = $kycRequest;
2864
+ var MoonPayOrderRequestSchema = $orderRequest;
2865
+ var $request = import_zod2.z.discriminatedUnion("action", [$observeRequest, $consentRequest, $connectRequest, $kycRequest, $orderRequest]);
2866
+ var MoonPayRequestSchema = $request;
2867
+ var $envelope = { provider: import_zod2.z.literal("MOONPAY"), geo: FiatGeoSchema, ...$context };
2868
+ var $nextRequest2 = import_zod2.z.discriminatedUnion("action", [
2869
+ obj2({ ...$envelope, ...$observeFields }),
2870
+ obj2({ ...$envelope, ...$consentFields }),
2871
+ obj2({ ...$envelope, ...$connectFields }),
2872
+ obj2({ ...$envelope, ...$kycFields }),
2873
+ obj2({ ...$envelope, ...$orderFields })
2874
+ ]);
2875
+ var MoonPayNextRequestSchema = $nextRequest2;
2841
2876
  var FIELD_OF_CODE = { PHONE_IN_USE: "PHONE_NUMBER", TAX_ID_IN_USE: "TAX_IDENTIFIER" };
2842
2877
  var $fieldError = obj2({ fieldId: $nonEmpty, message: $nonEmpty, code: import_zod2.z.enum(["PHONE_IN_USE", "TAX_ID_IN_USE"]).optional() });
2843
- var $pending = obj2({ status: import_zod2.z.literal("PENDING"), retryAfterMs: import_zod2.z.number().int().positive().max(6e4) });
2844
- var $stepStatus = import_zod2.z.discriminatedUnion("status", [
2845
- obj2({ status: import_zod2.z.literal("TERMS"), stage: import_zod2.z.enum(["CHECKOUT", "KYC"]), documents: import_zod2.z.array(TermsDocumentSchema).min(1) }),
2846
- obj2({ status: import_zod2.z.literal("SDK_AUTH"), sessionToken: $nonEmpty, quoteInput: $quoteInput, resetConnection: import_zod2.z.literal(true).optional() }),
2847
- obj2({ status: import_zod2.z.literal("KYC"), fields: import_zod2.z.array(FormFieldSchema).min(1), fieldErrors: import_zod2.z.array($fieldError).min(1).optional() }),
2848
- $pending,
2849
- obj2({ status: import_zod2.z.literal("READY"), orderId: $nonEmpty, quoteInput: $quoteInput }),
2850
- obj2({ status: import_zod2.z.literal("REFUSED"), reason: $stepRefusal, recovery: import_zod2.z.enum(["REQUOTE", "NONE"]) })
2851
- ]);
2852
- var $stepResponse2 = $stepStatus.superRefine((response, context) => {
2853
- if (response.status === "TERMS") {
2854
- if (!hasUniqueIds2(response.documents.map((document) => document.id))) {
2855
- context.addIssue({ code: "custom", path: ["documents"], message: "document ids must be unique" });
2856
- }
2857
- if (response.documents.some((document) => document.stage !== response.stage)) {
2858
- context.addIssue({ code: "custom", path: ["documents"], message: "every document must be at the response stage" });
2859
- }
2878
+ var $consentShape = obj2({ next: import_zod2.z.literal("consent"), documents: import_zod2.z.array(TermsDocumentSchema).min(1) });
2879
+ var $connectPrompt = obj2({
2880
+ next: import_zod2.z.literal("connect"),
2881
+ sessionToken: $nonEmpty,
2882
+ quoteInput: $quoteInput,
2883
+ resetConnection: import_zod2.z.literal(true).optional()
2884
+ });
2885
+ var $kycShape = obj2({ next: import_zod2.z.literal("kyc"), fields: import_zod2.z.array(FormFieldSchema).min(1), fieldErrors: import_zod2.z.array($fieldError).min(1).optional() });
2886
+ var $waitPrompt = obj2({ next: import_zod2.z.literal("wait"), retryAfterMs: import_zod2.z.number().int().positive().max(6e4) });
2887
+ var $orderPrompt = obj2({ next: import_zod2.z.literal("order"), orderId: $nonEmpty, quoteInput: $quoteInput });
2888
+ var checkConsent = (prompt, context) => {
2889
+ if (!hasUniqueIds2(prompt.documents.map((document) => document.id))) {
2890
+ context.addIssue({ code: "custom", path: ["documents"], message: "document ids must be unique" });
2860
2891
  }
2861
- if (response.status === "KYC") {
2862
- const fieldIds = response.fields.map((field) => field.id);
2863
- if (!hasUniqueIds2(fieldIds)) {
2864
- context.addIssue({ code: "custom", path: ["fields"], message: "field ids must be unique" });
2865
- }
2866
- if (response.fieldErrors?.some((error) => !fieldIds.includes(error.fieldId))) {
2867
- context.addIssue({ code: "custom", path: ["fieldErrors"], message: "a field error must name a field in this response" });
2868
- }
2869
- if (response.fieldErrors?.some((error) => error.code && FIELD_OF_CODE[error.code] !== error.fieldId)) {
2870
- context.addIssue({ code: "custom", path: ["fieldErrors"], message: "a field error code must match its field" });
2871
- }
2892
+ };
2893
+ var checkKyc = (prompt, context) => {
2894
+ const fieldIds = prompt.fields.map((field) => field.id);
2895
+ if (!hasUniqueIds2(fieldIds)) {
2896
+ context.addIssue({ code: "custom", path: ["fields"], message: "field ids must be unique" });
2897
+ }
2898
+ if (prompt.fieldErrors?.some((error) => !fieldIds.includes(error.fieldId))) {
2899
+ context.addIssue({ code: "custom", path: ["fieldErrors"], message: "a field error must name a field in this prompt" });
2900
+ }
2901
+ if (prompt.fieldErrors?.some((error) => error.code && FIELD_OF_CODE[error.code] !== error.fieldId)) {
2902
+ context.addIssue({ code: "custom", path: ["fieldErrors"], message: "a field error code must match its field" });
2872
2903
  }
2904
+ };
2905
+ var MoonPayConsentPromptSchema = $consentShape.superRefine(checkConsent);
2906
+ var MoonPayConnectPromptSchema = $connectPrompt;
2907
+ var MoonPayKycPromptSchema = $kycShape.superRefine(checkKyc);
2908
+ var MoonPayWaitPromptSchema = $waitPrompt;
2909
+ var MoonPayOrderPromptSchema = $orderPrompt;
2910
+ var checkPrompt = (response, context) => {
2911
+ if (response.next === "consent") checkConsent(response, context);
2912
+ if (response.next === "kyc") checkKyc(response, context);
2913
+ };
2914
+ var $promptOptions = [$consentShape, $connectPrompt, $kycShape, $waitPrompt, $orderPrompt];
2915
+ var $prompt = import_zod2.z.discriminatedUnion("next", [...$promptOptions]).superRefine(checkPrompt);
2916
+ var MoonPayPromptSchema = $prompt;
2917
+ var $done = obj2({ next: import_zod2.z.literal("done"), order: FiatStepResponseSchema });
2918
+ var MoonPayDoneSchema = $done;
2919
+ var $stepRefused = obj2({
2920
+ next: import_zod2.z.literal("refused"),
2921
+ reason: import_zod2.z.enum(["NOT_ELIGIBLE", "DOCUMENTS_REQUIRED", "FINAL_REJECTION", "CUSTOMER_MISMATCH"]),
2922
+ recovery: import_zod2.z.enum(["REQUOTE", "NONE"])
2923
+ });
2924
+ var $orderRefused = obj2({
2925
+ next: import_zod2.z.literal("refused"),
2926
+ reason: import_zod2.z.enum(["CUSTOMER_MISMATCH", "WALLET_MISMATCH", "UNRECORDABLE"]),
2927
+ recovery: import_zod2.z.literal("NONE")
2873
2928
  });
2929
+ var $stepResponse2 = import_zod2.z.discriminatedUnion("next", [...$promptOptions, $stepRefused]).superRefine(checkPrompt);
2874
2930
  var MoonPayStepResponseSchema = $stepResponse2;
2875
- var $orderResponse = import_zod2.z.discriminatedUnion("status", [
2876
- obj2({ status: import_zod2.z.literal("DONE"), order: FiatStepResponseSchema }),
2877
- $pending,
2878
- obj2({ status: import_zod2.z.literal("REFUSED"), reason: $orderRefusal, recovery: import_zod2.z.literal("NONE") })
2879
- ]);
2931
+ var $orderResponse = import_zod2.z.discriminatedUnion("next", [$done, $orderPrompt, $orderRefused]);
2880
2932
  var MoonPayOrderResponseSchema = $orderResponse;
2881
- var $intentResponse = import_zod2.z.union([$stepResponse2, $orderResponse]);
2882
- var MoonPayIntentResponseSchema = $intentResponse;
2933
+ var MoonPayResponseSchemaFor = {
2934
+ observe: MoonPayStepResponseSchema,
2935
+ consent: MoonPayStepResponseSchema,
2936
+ connect: MoonPayStepResponseSchema,
2937
+ kyc: MoonPayStepResponseSchema,
2938
+ order: MoonPayOrderResponseSchema
2939
+ };
2883
2940
  var $faultFields = {
2884
2941
  reason: import_zod2.z.enum(["SESSION_BUDGET_SPENT", "RATE_LIMITED", "PROVIDER_UNAVAILABLE", "INVALID_REQUEST"]),
2885
2942
  recovery: import_zod2.z.enum(["RETRY", "REQUOTE", "NONE"])
package/dist/index.mjs CHANGED
@@ -12,19 +12,19 @@ import {
12
12
  tableEntry,
13
13
  unofferedEndpoints,
14
14
  unreachableStates
15
- } from "./chunk-EI56NQ7K.mjs";
15
+ } from "./chunk-IPOPANXS.mjs";
16
16
  import {
17
17
  MOONPAY_ENDPOINTS
18
- } from "./chunk-3HCZ6JBJ.mjs";
18
+ } from "./chunk-T5JAYOWY.mjs";
19
19
  import {
20
20
  FIAT_TERMS_ENDPOINT,
21
21
  FUN_KYC_CONSENT_DOCUMENTS,
22
22
  PROVIDER_CHECKOUT_DOCUMENTS,
23
23
  PUBLISHED_TERMS_DOCUMENTS
24
- } from "./chunk-5GRPYE2U.mjs";
24
+ } from "./chunk-CRNKRIKR.mjs";
25
25
  import {
26
26
  ROUTING_ENDPOINTS
27
- } from "./chunk-KYE2HYV5.mjs";
27
+ } from "./chunk-5UEPWL7B.mjs";
28
28
 
29
29
  // src/codes.ts
30
30
  var US_STATE_CODES = [
@@ -1002,6 +1002,10 @@ var $routingTableErrorBody = z.union([$routingRateLimitedErrorBody, $routingFaul
1002
1002
  var FiatRoutingTableErrorBodySchema = $routingTableErrorBody;
1003
1003
  var $routingQuoteErrorBody = z.union([$routingNoRouteErrorBody, $routingAmountErrorBody, $routingFaultErrorBody]);
1004
1004
  var FiatRoutingQuoteErrorBodySchema = $routingQuoteErrorBody;
1005
+ var $fiatGeo = obj({ alpha2: z.string().regex(/^[A-Z]{2}$/), region: $nonBlank.optional(), ip: $nonBlank.optional() });
1006
+ var FiatGeoSchema = $fiatGeo;
1007
+ var $nextRequest = z.object({ provider: $provider, action: $nonBlank, geo: $fiatGeo }).catchall(z.unknown());
1008
+ var FiatNextRequestSchema = $nextRequest;
1005
1009
  var $providerBoundStepResponse = obj({
1006
1010
  state: $providerBoundFlowState,
1007
1011
  provider: $provider,
@@ -2131,33 +2135,17 @@ var FIAT_CURRENCY_CODES2 = Object.keys(FIAT_CURRENCY_NAMES);
2131
2135
  var obj2 = (shape) => z2.object(shape).strict();
2132
2136
  var $nonEmpty = z2.string().refine((value) => value.trim().length > 0, "must not be blank");
2133
2137
  var hasUniqueIds2 = (ids) => new Set(ids).size === ids.length;
2134
- var $geo = obj2({ alpha2: z2.string().regex(/^[A-Z]{2}$/), region: $nonEmpty.optional(), ip: $nonEmpty.optional() });
2135
2138
  var $checkout = obj2({
2136
2139
  amount: FiatAmountSchema,
2137
2140
  destination: obj2({ asset: $nonEmpty, network: $nonEmpty }),
2138
- paymentMethod: z2.literal("apple_pay"),
2139
- geo: $geo
2141
+ paymentMethod: z2.literal("apple_pay")
2140
2142
  });
2141
2143
  var MoonPayCheckoutSchema = $checkout;
2142
2144
  var $credentials = obj2({ customerId: $nonEmpty, accessToken: $nonEmpty });
2143
2145
  var MoonPaySdkCredentialsSchema = $credentials;
2144
- var $intentRequest = z2.discriminatedUnion("kind", [
2145
- obj2({ kind: z2.literal("observe"), checkout: $checkout, credentials: $credentials.optional() }),
2146
- obj2({
2147
- kind: z2.literal("kyc"),
2148
- checkout: $checkout,
2149
- credentials: $credentials,
2150
- values: z2.record(KycFieldIdSchema, z2.string()).refine((values) => Object.keys(values).length > 0, "values must not be empty")
2151
- }),
2152
- obj2({
2153
- kind: z2.literal("order"),
2154
- orderId: $nonEmpty,
2155
- transactionId: $nonEmpty.optional(),
2156
- quotedAmount: FiatAmountSchema,
2157
- geo: $geo.optional()
2158
- })
2159
- ]);
2160
- var MoonPayIntentRequestSchema = $intentRequest;
2146
+ var $context = { checkout: $checkout, credentials: $credentials.optional() };
2147
+ var $requestContext = obj2($context);
2148
+ var MoonPayRequestContextSchema = $requestContext;
2161
2149
  var $quoteInput = obj2({
2162
2150
  source: obj2({ asset: obj2({ code: z2.enum(FIAT_CURRENCY_CODES2) }), amount: $nonEmpty }),
2163
2151
  destination: obj2({ asset: obj2({ code: $nonEmpty }) }),
@@ -2166,50 +2154,103 @@ var $quoteInput = obj2({
2166
2154
  feeBehavior: z2.literal("inclusive")
2167
2155
  });
2168
2156
  var MoonPayQuoteInputSchema = $quoteInput;
2169
- var $stepRefusal = z2.enum(["NOT_ELIGIBLE", "DOCUMENTS_REQUIRED", "FINAL_REJECTION", "CUSTOMER_MISMATCH"]);
2170
- var $orderRefusal = z2.enum(["CUSTOMER_MISMATCH", "WALLET_MISMATCH", "UNRECORDABLE"]);
2157
+ var $observeFields = { action: z2.literal("observe") };
2158
+ var $consentFields = {
2159
+ action: z2.literal("consent"),
2160
+ acceptances: z2.array(TermsDocumentAcceptanceSchema).min(1).refine((acceptances) => hasUniqueIds2(acceptances.map((acceptance) => acceptance.documentId)), "each document is accepted once")
2161
+ };
2162
+ var $connectFields = { action: z2.literal("connect"), customerId: $nonEmpty, accessToken: $nonEmpty };
2163
+ var $kycFields = {
2164
+ action: z2.literal("kyc"),
2165
+ credentials: $credentials,
2166
+ values: z2.record(KycFieldIdSchema, z2.string()).refine((values) => Object.keys(values).length > 0, "values must not be empty")
2167
+ };
2168
+ var $orderFields = { action: z2.literal("order"), orderId: $nonEmpty, quotedAmount: FiatAmountSchema, transactionId: $nonEmpty.optional() };
2169
+ var $observeRequest = obj2({ ...$context, ...$observeFields });
2170
+ var $consentRequest = obj2({ ...$context, ...$consentFields });
2171
+ var $connectRequest = obj2({ ...$context, ...$connectFields });
2172
+ var $kycRequest = obj2({ ...$context, ...$kycFields });
2173
+ var $orderRequest = obj2({ ...$context, ...$orderFields });
2174
+ var MoonPayObserveRequestSchema = $observeRequest;
2175
+ var MoonPayConsentRequestSchema = $consentRequest;
2176
+ var MoonPayConnectRequestSchema = $connectRequest;
2177
+ var MoonPayKycRequestSchema = $kycRequest;
2178
+ var MoonPayOrderRequestSchema = $orderRequest;
2179
+ var $request = z2.discriminatedUnion("action", [$observeRequest, $consentRequest, $connectRequest, $kycRequest, $orderRequest]);
2180
+ var MoonPayRequestSchema = $request;
2181
+ var $envelope = { provider: z2.literal("MOONPAY"), geo: FiatGeoSchema, ...$context };
2182
+ var $nextRequest2 = z2.discriminatedUnion("action", [
2183
+ obj2({ ...$envelope, ...$observeFields }),
2184
+ obj2({ ...$envelope, ...$consentFields }),
2185
+ obj2({ ...$envelope, ...$connectFields }),
2186
+ obj2({ ...$envelope, ...$kycFields }),
2187
+ obj2({ ...$envelope, ...$orderFields })
2188
+ ]);
2189
+ var MoonPayNextRequestSchema = $nextRequest2;
2171
2190
  var FIELD_OF_CODE = { PHONE_IN_USE: "PHONE_NUMBER", TAX_ID_IN_USE: "TAX_IDENTIFIER" };
2172
2191
  var $fieldError = obj2({ fieldId: $nonEmpty, message: $nonEmpty, code: z2.enum(["PHONE_IN_USE", "TAX_ID_IN_USE"]).optional() });
2173
- var $pending = obj2({ status: z2.literal("PENDING"), retryAfterMs: z2.number().int().positive().max(6e4) });
2174
- var $stepStatus = z2.discriminatedUnion("status", [
2175
- obj2({ status: z2.literal("TERMS"), stage: z2.enum(["CHECKOUT", "KYC"]), documents: z2.array(TermsDocumentSchema).min(1) }),
2176
- obj2({ status: z2.literal("SDK_AUTH"), sessionToken: $nonEmpty, quoteInput: $quoteInput, resetConnection: z2.literal(true).optional() }),
2177
- obj2({ status: z2.literal("KYC"), fields: z2.array(FormFieldSchema).min(1), fieldErrors: z2.array($fieldError).min(1).optional() }),
2178
- $pending,
2179
- obj2({ status: z2.literal("READY"), orderId: $nonEmpty, quoteInput: $quoteInput }),
2180
- obj2({ status: z2.literal("REFUSED"), reason: $stepRefusal, recovery: z2.enum(["REQUOTE", "NONE"]) })
2181
- ]);
2182
- var $stepResponse2 = $stepStatus.superRefine((response, context) => {
2183
- if (response.status === "TERMS") {
2184
- if (!hasUniqueIds2(response.documents.map((document) => document.id))) {
2185
- context.addIssue({ code: "custom", path: ["documents"], message: "document ids must be unique" });
2186
- }
2187
- if (response.documents.some((document) => document.stage !== response.stage)) {
2188
- context.addIssue({ code: "custom", path: ["documents"], message: "every document must be at the response stage" });
2189
- }
2192
+ var $consentShape = obj2({ next: z2.literal("consent"), documents: z2.array(TermsDocumentSchema).min(1) });
2193
+ var $connectPrompt = obj2({
2194
+ next: z2.literal("connect"),
2195
+ sessionToken: $nonEmpty,
2196
+ quoteInput: $quoteInput,
2197
+ resetConnection: z2.literal(true).optional()
2198
+ });
2199
+ var $kycShape = obj2({ next: z2.literal("kyc"), fields: z2.array(FormFieldSchema).min(1), fieldErrors: z2.array($fieldError).min(1).optional() });
2200
+ var $waitPrompt = obj2({ next: z2.literal("wait"), retryAfterMs: z2.number().int().positive().max(6e4) });
2201
+ var $orderPrompt = obj2({ next: z2.literal("order"), orderId: $nonEmpty, quoteInput: $quoteInput });
2202
+ var checkConsent = (prompt, context) => {
2203
+ if (!hasUniqueIds2(prompt.documents.map((document) => document.id))) {
2204
+ context.addIssue({ code: "custom", path: ["documents"], message: "document ids must be unique" });
2190
2205
  }
2191
- if (response.status === "KYC") {
2192
- const fieldIds = response.fields.map((field) => field.id);
2193
- if (!hasUniqueIds2(fieldIds)) {
2194
- context.addIssue({ code: "custom", path: ["fields"], message: "field ids must be unique" });
2195
- }
2196
- if (response.fieldErrors?.some((error) => !fieldIds.includes(error.fieldId))) {
2197
- context.addIssue({ code: "custom", path: ["fieldErrors"], message: "a field error must name a field in this response" });
2198
- }
2199
- if (response.fieldErrors?.some((error) => error.code && FIELD_OF_CODE[error.code] !== error.fieldId)) {
2200
- context.addIssue({ code: "custom", path: ["fieldErrors"], message: "a field error code must match its field" });
2201
- }
2206
+ };
2207
+ var checkKyc = (prompt, context) => {
2208
+ const fieldIds = prompt.fields.map((field) => field.id);
2209
+ if (!hasUniqueIds2(fieldIds)) {
2210
+ context.addIssue({ code: "custom", path: ["fields"], message: "field ids must be unique" });
2211
+ }
2212
+ if (prompt.fieldErrors?.some((error) => !fieldIds.includes(error.fieldId))) {
2213
+ context.addIssue({ code: "custom", path: ["fieldErrors"], message: "a field error must name a field in this prompt" });
2214
+ }
2215
+ if (prompt.fieldErrors?.some((error) => error.code && FIELD_OF_CODE[error.code] !== error.fieldId)) {
2216
+ context.addIssue({ code: "custom", path: ["fieldErrors"], message: "a field error code must match its field" });
2202
2217
  }
2218
+ };
2219
+ var MoonPayConsentPromptSchema = $consentShape.superRefine(checkConsent);
2220
+ var MoonPayConnectPromptSchema = $connectPrompt;
2221
+ var MoonPayKycPromptSchema = $kycShape.superRefine(checkKyc);
2222
+ var MoonPayWaitPromptSchema = $waitPrompt;
2223
+ var MoonPayOrderPromptSchema = $orderPrompt;
2224
+ var checkPrompt = (response, context) => {
2225
+ if (response.next === "consent") checkConsent(response, context);
2226
+ if (response.next === "kyc") checkKyc(response, context);
2227
+ };
2228
+ var $promptOptions = [$consentShape, $connectPrompt, $kycShape, $waitPrompt, $orderPrompt];
2229
+ var $prompt = z2.discriminatedUnion("next", [...$promptOptions]).superRefine(checkPrompt);
2230
+ var MoonPayPromptSchema = $prompt;
2231
+ var $done = obj2({ next: z2.literal("done"), order: FiatStepResponseSchema });
2232
+ var MoonPayDoneSchema = $done;
2233
+ var $stepRefused = obj2({
2234
+ next: z2.literal("refused"),
2235
+ reason: z2.enum(["NOT_ELIGIBLE", "DOCUMENTS_REQUIRED", "FINAL_REJECTION", "CUSTOMER_MISMATCH"]),
2236
+ recovery: z2.enum(["REQUOTE", "NONE"])
2237
+ });
2238
+ var $orderRefused = obj2({
2239
+ next: z2.literal("refused"),
2240
+ reason: z2.enum(["CUSTOMER_MISMATCH", "WALLET_MISMATCH", "UNRECORDABLE"]),
2241
+ recovery: z2.literal("NONE")
2203
2242
  });
2243
+ var $stepResponse2 = z2.discriminatedUnion("next", [...$promptOptions, $stepRefused]).superRefine(checkPrompt);
2204
2244
  var MoonPayStepResponseSchema = $stepResponse2;
2205
- var $orderResponse = z2.discriminatedUnion("status", [
2206
- obj2({ status: z2.literal("DONE"), order: FiatStepResponseSchema }),
2207
- $pending,
2208
- obj2({ status: z2.literal("REFUSED"), reason: $orderRefusal, recovery: z2.literal("NONE") })
2209
- ]);
2245
+ var $orderResponse = z2.discriminatedUnion("next", [$done, $orderPrompt, $orderRefused]);
2210
2246
  var MoonPayOrderResponseSchema = $orderResponse;
2211
- var $intentResponse = z2.union([$stepResponse2, $orderResponse]);
2212
- var MoonPayIntentResponseSchema = $intentResponse;
2247
+ var MoonPayResponseSchemaFor = {
2248
+ observe: MoonPayStepResponseSchema,
2249
+ consent: MoonPayStepResponseSchema,
2250
+ connect: MoonPayStepResponseSchema,
2251
+ kyc: MoonPayStepResponseSchema,
2252
+ order: MoonPayOrderResponseSchema
2253
+ };
2213
2254
  var $faultFields = {
2214
2255
  reason: z2.enum(["SESSION_BUDGET_SPENT", "RATE_LIMITED", "PROVIDER_UNAVAILABLE", "INVALID_REQUEST"]),
2215
2256
  recovery: z2.enum(["RETRY", "REQUOTE", "NONE"])
@@ -2241,6 +2282,8 @@ export {
2241
2282
  FiatAmountSchema,
2242
2283
  FiatCurrencyCode,
2243
2284
  FiatEndpointSchema,
2285
+ FiatGeoSchema,
2286
+ FiatNextRequestSchema,
2244
2287
  FiatProviderSchema,
2245
2288
  FiatRoutingQuoteErrorBodySchema,
2246
2289
  FiatRoutingQuoteRequestSchema,
@@ -2271,14 +2314,28 @@ export {
2271
2314
  KycSdkResultReportSchema,
2272
2315
  MOONPAY_ENDPOINTS,
2273
2316
  MoonPayCheckoutSchema,
2317
+ MoonPayConnectPromptSchema,
2318
+ MoonPayConnectRequestSchema,
2319
+ MoonPayConsentPromptSchema,
2320
+ MoonPayConsentRequestSchema,
2321
+ MoonPayDoneSchema,
2274
2322
  MoonPayErrorBodySchema,
2275
2323
  MoonPayFaultSchema,
2276
- MoonPayIntentRequestSchema,
2277
- MoonPayIntentResponseSchema,
2324
+ MoonPayKycPromptSchema,
2325
+ MoonPayKycRequestSchema,
2326
+ MoonPayNextRequestSchema,
2327
+ MoonPayObserveRequestSchema,
2328
+ MoonPayOrderPromptSchema,
2329
+ MoonPayOrderRequestSchema,
2278
2330
  MoonPayOrderResponseSchema,
2331
+ MoonPayPromptSchema,
2279
2332
  MoonPayQuoteInputSchema,
2333
+ MoonPayRequestContextSchema,
2334
+ MoonPayRequestSchema,
2335
+ MoonPayResponseSchemaFor,
2280
2336
  MoonPaySdkCredentialsSchema,
2281
2337
  MoonPayStepResponseSchema,
2338
+ MoonPayWaitPromptSchema,
2282
2339
  OrderAwaitingConfirmationStateSchema,
2283
2340
  OrderCreatedStateSchema,
2284
2341
  OrderRefSchema,
@@ -1,28 +1,31 @@
1
1
  /**
2
- * The MoonPay provider-owned flow: one route, `POST /fiat/providers/moonpay/intent`.
2
+ * The MoonPay flow on `POST /fiat/next`.
3
3
  *
4
- * Each request carries evidence or a user action (`kind`), and each response says what the backend
5
- * needs next (`status`). `observe` and `kyc` answer a `MoonPayStepResponse`, and `order` answers a
6
- * `MoonPayOrderResponse` (`MoonPayIntentResponseFor`). Terms and consents go through
7
- * the platform `POST /fiat/terms` (`./terms`). Identity and the deposit wallet always come from the
8
- * verified partner assertion, never from a request body.
4
+ * Each action has one name and two types. A response's prompt names it in `next` and carries what
5
+ * the client needs to do it. The client's request names it in `action` and carries the result. Every
6
+ * response is the next prompt, `done`, or `refused` (`MoonPayResponseFor`). `observe` carries no
7
+ * result and answers the current prompt. `wait` has no request: the client sends `observe` after it.
8
+ *
9
+ * The body is `MoonPayNextRequest`: `provider`, the shared `geo`, the context (`checkout`, and
10
+ * `credentials` after `connect`), and the action's result. Identity and the deposit wallet always
11
+ * come from the verified partner assertion, never from a request body.
9
12
  *
10
13
  * A retry sends the same request. Each write is idempotent on data the request carries, and every
11
14
  * call, a retry too, returns the current response.
12
15
  *
13
- * A fault is a 4xx/5xx whose body is `MoonPayErrorBody`. Anything the user can act on is a 200
14
- * `MoonPayIntentResponse`.
16
+ * A fault is a 4xx/5xx whose body is `MoonPayErrorBody`. Anything the user can act on is a 200.
15
17
  *
16
18
  * Zero runtime dependencies, so production React Native code can import it. The zod schemas are in
17
19
  * `./moonpay.schemas`, exported from the package root.
18
20
  */
19
21
  import type { FiatCurrencyCode } from '../codes';
20
- import type { TermsDocument, TermsStage } from '../terms';
21
- import type { FiatAmount, FiatStepResponse, FormField, KycFieldId } from '../types';
22
+ import type { FiatTermsRequest, TermsDocument } from '../terms';
23
+ import type { FiatAmount, FiatGeo, FiatStepResponse, FormField, KycFieldId } from '../types';
22
24
  export declare const MOONPAY_ENDPOINTS: {
23
- readonly intent: "POST /fiat/providers/moonpay/intent";
25
+ readonly next: "POST /fiat/next";
24
26
  };
25
- /** The checkout terms. The client holds them and sends them on every `observe` and `kyc`. */
27
+ export type MoonPayAction = 'observe' | 'consent' | 'connect' | 'kyc' | 'wait' | 'order';
28
+ /** The checkout terms. The client holds them and sends them on every request. */
26
29
  export interface MoonPayCheckout {
27
30
  amount: FiatAmount;
28
31
  /** The quote's `crypto.currency` and `crypto.network`, unchanged. */
@@ -31,46 +34,17 @@ export interface MoonPayCheckout {
31
34
  network: string;
32
35
  };
33
36
  paymentMethod: 'apple_pay';
34
- /** The geo endpoint's response, as sent to `POST /fiat/quote`. `alpha2` is ISO 3166-1 alpha-2. */
35
- geo: {
36
- alpha2: string;
37
- region?: string;
38
- ip?: string;
39
- };
40
37
  }
41
38
  /** From the SDK's `active` connection. `accessToken` is a credential: the backend never logs it. */
42
39
  export interface MoonPaySdkCredentials {
43
40
  customerId: string;
44
41
  accessToken: string;
45
42
  }
46
- export type MoonPayIntentRequest =
47
- /** No effect. Without credentials, the answer past the gates is `SDK_AUTH`. */
48
- {
49
- kind: 'observe';
43
+ /** On every request, not part of the result. `credentials` is present after `connect`. */
44
+ export type MoonPayRequestContext = {
50
45
  checkout: MoonPayCheckout;
51
46
  credentials?: MoonPaySdkCredentials;
52
- }
53
- /** Only after a `KYC` response. `values` is keyed by the ids of that response's fields; there is no form id. */
54
- | {
55
- kind: 'kyc';
56
- checkout: MoonPayCheckout;
57
- credentials: MoonPaySdkCredentials;
58
- values: Partial<Record<KycFieldId, string>>;
59
- }
60
- /**
61
- * After every charge attempt, a failed one too. `transactionId` is from the Apple Pay event when it
62
- * has one; without it the backend records the failed charges MoonPay lists for `orderId`.
63
- * `quotedAmount` is the fiat amount the buyer saw on the quote. `geo` is the checkout's, as sent on
64
- * `observe`; the order records its `alpha2`, and no country when it is absent.
65
- */
66
- | {
67
- kind: 'order';
68
- orderId: string;
69
- transactionId?: string;
70
- quotedAmount: FiatAmount;
71
- geo?: MoonPayCheckout['geo'];
72
47
  };
73
- export type MoonPayIntentKind = MoonPayIntentRequest['kind'];
74
48
  /**
75
49
  * The parameters for the device `client.getQuote`, not a quote. The backend builds them because the
76
50
  * wallet must be the verified one and MoonPay's currency codes differ by environment.
@@ -95,18 +69,39 @@ export interface MoonPayQuoteInput {
95
69
  };
96
70
  feeBehavior: 'inclusive';
97
71
  }
98
- /** `REQUOTE` for `NOT_ELIGIBLE` and `DOCUMENTS_REQUIRED`, `NONE` for the others. */
99
- export type MoonPayStepRefusal = 'NOT_ELIGIBLE' | 'DOCUMENTS_REQUIRED' | 'FINAL_REJECTION' | 'CUSTOMER_MISMATCH';
72
+ /** No prompt of its own: the answer is the current prompt. Writes nothing. */
73
+ export type MoonPayObserveRequest = {
74
+ action: 'observe';
75
+ };
76
+ /** MoonPay's terms first. Later, before `kyc`, Fun's KYC consent if the buyer has not accepted it. */
77
+ export type MoonPayConsentPrompt = {
78
+ next: 'consent';
79
+ documents: TermsDocument[];
80
+ };
81
+ /** The `POST /fiat/terms` items, recorded under the same rules. */
82
+ export type MoonPayConsentRequest = {
83
+ action: 'consent';
84
+ acceptances: FiatTermsRequest['acceptances'];
85
+ };
100
86
  /**
101
- * After a charge, always with `recovery: NONE`. `CUSTOMER_MISMATCH`: the transaction's customer is
102
- * not bound to this buyer. `WALLET_MISMATCH`: the transaction pays another wallet than the
103
- * assertion's. `UNRECORDABLE`: a charge no retry can record, held for refund review.
87
+ * Run MoonPay's connection check with `sessionToken`; it asks for an OTP only if the hidden check
88
+ * fails. `resetConnection`: the device's connection is another buyer's, so reset it first.
104
89
  */
105
- export type MoonPayOrderRefusal = 'CUSTOMER_MISMATCH' | 'WALLET_MISMATCH' | 'UNRECORDABLE';
90
+ export type MoonPayConnectPrompt = {
91
+ next: 'connect';
92
+ sessionToken: string;
93
+ quoteInput: MoonPayQuoteInput;
94
+ resetConnection?: true;
95
+ };
96
+ export type MoonPayConnectRequest = {
97
+ action: 'connect';
98
+ customerId: string;
99
+ accessToken: string;
100
+ };
106
101
  /** Another MoonPay customer already holds the value; only a different one goes through. */
107
102
  export type MoonPayFieldErrorCode = 'PHONE_IN_USE' | 'TAX_ID_IN_USE';
108
103
  /**
109
- * A reason on one field of a `KYC` response. `fieldId` names a field in that response. `code` is set
104
+ * A reason on one field of a `kyc` prompt. `fieldId` names a field in that prompt. `code` is set
110
105
  * only for a refusal the client words itself: `PHONE_IN_USE` on `PHONE_NUMBER`, `TAX_ID_IN_USE` on `TAX_IDENTIFIER`.
111
106
  */
112
107
  export interface MoonPayFieldError {
@@ -114,82 +109,85 @@ export interface MoonPayFieldError {
114
109
  message: string;
115
110
  code?: MoonPayFieldErrorCode;
116
111
  }
117
- /** The answer to `observe` and `kyc`. */
118
- export type MoonPayStepResponse =
119
- /** Show `documents` (every one at `stage`), send `POST /fiat/terms`, then `observe`. */
120
- {
121
- status: 'TERMS';
122
- stage: TermsStage;
123
- documents: TermsDocument[];
124
- }
125
- /**
126
- * Run the MoonPay connection check with `sessionToken`, then `observe` with the credentials.
127
- * `resetConnection`: the device's connection is another buyer's, so reset it before the check.
128
- */
129
- | {
130
- status: 'SDK_AUTH';
131
- sessionToken: string;
132
- quoteInput: MoonPayQuoteInput;
133
- resetConnection?: true;
134
- }
135
- /** Show the shared form, then send `kyc`. */
136
- | {
137
- status: 'KYC';
112
+ /** Show the shared form. */
113
+ export type MoonPayKycPrompt = {
114
+ next: 'kyc';
138
115
  fields: FormField[];
139
116
  fieldErrors?: MoonPayFieldError[];
140
- }
141
- /** Send `observe` after the delay. Never `kyc` again: its write is done. */
142
- | {
143
- status: 'PENDING';
117
+ };
118
+ /** Keyed by the ids of the prompt's fields; there is no form id. Needs `credentials`: the backend reads the customer. */
119
+ export type MoonPayKycRequest = {
120
+ action: 'kyc';
121
+ credentials: MoonPaySdkCredentials;
122
+ values: Partial<Record<KycFieldId, string>>;
123
+ };
124
+ /** MoonPay is reviewing. No request of its own: send `observe` after the delay. */
125
+ export type MoonPayWaitPrompt = {
126
+ next: 'wait';
144
127
  retryAfterMs: number;
145
- }
146
- /** Mount Apple Pay with `externalTransactionId = orderId`, then send `order` after the charge. */
147
- | {
148
- status: 'READY';
128
+ };
129
+ /** Get the device quote from `quoteInput`, mount Apple Pay with `externalTransactionId = orderId`. */
130
+ export type MoonPayOrderPrompt = {
131
+ next: 'order';
149
132
  orderId: string;
150
133
  quoteInput: MoonPayQuoteInput;
151
- }
152
- /** Exit the provider flow. `REQUOTE` goes back to `POST /fiat/quote`; `NONE` ends the flow. */
153
- | {
154
- status: 'REFUSED';
155
- reason: MoonPayStepRefusal;
156
- recovery: 'REQUOTE' | 'NONE';
157
134
  };
158
135
  /**
159
- * The answer to `order`, which runs after each charge attempt. A failed charge is recorded too: it
160
- * answers `DONE` with the order in `FAILED`, and the client requotes for a new `orderId`.
136
+ * After every charge attempt, a failed one too. `quotedAmount` is the fiat amount the device quote
137
+ * showed. `transactionId` is from the Apple Pay event when it has one; without it the backend
138
+ * records the failed charges MoonPay lists for `orderId`.
161
139
  */
162
- export type MoonPayOrderResponse =
163
- /** The `GET /fiat/orders/:orderId` response; the shared order screen renders it. */
164
- {
165
- status: 'DONE';
166
- order: FiatStepResponse;
167
- }
140
+ export type MoonPayOrderRequest = {
141
+ action: 'order';
142
+ orderId: string;
143
+ quotedAmount: FiatAmount;
144
+ transactionId?: string;
145
+ };
146
+ export type MoonPayRequest = MoonPayRequestContext & (MoonPayObserveRequest | MoonPayConsentRequest | MoonPayConnectRequest | MoonPayKycRequest | MoonPayOrderRequest);
147
+ /** The wire body. The orchestrator reads `provider` and `geo`; MoonPay's action schemas read the rest. */
148
+ export type MoonPayNextRequest = {
149
+ provider: 'MOONPAY';
150
+ geo: FiatGeo;
151
+ } & MoonPayRequest;
152
+ /** `REQUOTE` for `NOT_ELIGIBLE` and `DOCUMENTS_REQUIRED`, `NONE` for the others. */
153
+ export type MoonPayStepRefusal = 'NOT_ELIGIBLE' | 'DOCUMENTS_REQUIRED' | 'FINAL_REJECTION' | 'CUSTOMER_MISMATCH';
168
154
  /**
169
- * MoonPay does not list the transaction yet. Send the same `order` after the delay. After a failed
170
- * charge with no `transactionId`, the client caps these polls.
155
+ * After a charge, always with `recovery: NONE`. `CUSTOMER_MISMATCH`: the transaction's customer is
156
+ * not bound to this buyer. `WALLET_MISMATCH`: the transaction pays another wallet than the
157
+ * assertion's. `UNRECORDABLE`: a charge no retry can record, held for refund review.
171
158
  */
172
- | {
173
- status: 'PENDING';
174
- retryAfterMs: number;
175
- }
176
- /** Exit the provider flow. A requote after a charge would start a second payment. */
177
- | {
178
- status: 'REFUSED';
179
- reason: MoonPayOrderRefusal;
180
- recovery: 'NONE';
159
+ export type MoonPayOrderRefusal = 'CUSTOMER_MISMATCH' | 'WALLET_MISMATCH' | 'UNRECORDABLE';
160
+ export type MoonPayPrompt = MoonPayConsentPrompt | MoonPayConnectPrompt | MoonPayKycPrompt | MoonPayWaitPrompt | MoonPayOrderPrompt;
161
+ /** `order` is the `GET /fiat/orders/:orderId` body; the shared order screen renders it. */
162
+ export type MoonPayDone = {
163
+ next: 'done';
164
+ order: FiatStepResponse;
181
165
  };
182
- export type MoonPayIntentResponseFor = {
166
+ /** Exit the provider flow. `REQUOTE` goes back to routing; `NONE` ends the flow. */
167
+ export type MoonPayRefused<R, V> = {
168
+ next: 'refused';
169
+ reason: R;
170
+ recovery: V;
171
+ };
172
+ /** The answer to `observe`, `consent`, `connect` and `kyc`. */
173
+ export type MoonPayStepResponse = MoonPayPrompt | MoonPayRefused<MoonPayStepRefusal, 'REQUOTE' | 'NONE'>;
174
+ /**
175
+ * The answer to `order`. A failed charge is recorded too: `done` with the order in `FAILED`, and the
176
+ * client requotes for a new `orderId`. `order` again while MoonPay does not list the transaction
177
+ * yet. A refusal after a charge never requotes: that would start a second payment.
178
+ */
179
+ export type MoonPayOrderResponse = MoonPayDone | MoonPayOrderPrompt | MoonPayRefused<MoonPayOrderRefusal, 'NONE'>;
180
+ export type MoonPayResponseFor = {
183
181
  observe: MoonPayStepResponse;
182
+ consent: MoonPayStepResponse;
183
+ connect: MoonPayStepResponse;
184
184
  kyc: MoonPayStepResponse;
185
185
  order: MoonPayOrderResponse;
186
186
  };
187
- export type MoonPayIntentResponse = MoonPayStepResponse | MoonPayOrderResponse;
188
- export type MoonPayIntentStatus = MoonPayIntentResponse['status'];
189
- /** `RETRY` sends the same request again. `REQUOTE` goes back to `POST /fiat/quote`. `NONE` ends the flow. */
187
+ /** `RETRY` sends the same request again. `REQUOTE` goes back to routing. `NONE` ends the flow. */
190
188
  export type MoonPayRecovery = 'RETRY' | 'REQUOTE' | 'NONE';
191
189
  /**
192
- * `SESSION_BUDGET_SPENT`: the per-login SDK session mint budget (429). `RATE_LIMITED`: the kind's
190
+ * `SESSION_BUDGET_SPENT`: the per-login SDK session mint budget (429). `RATE_LIMITED`: the action's
193
191
  * request budget (429). `PROVIDER_UNAVAILABLE`: MoonPay or Sumsub is down. `INVALID_REQUEST`: a bad
194
192
  * body (400).
195
193
  */
@@ -24,6 +24,6 @@ __export(moonpay_exports, {
24
24
  });
25
25
  module.exports = __toCommonJS(moonpay_exports);
26
26
  var MOONPAY_ENDPOINTS = {
27
- intent: "POST /fiat/providers/moonpay/intent"
27
+ next: "POST /fiat/next"
28
28
  };
29
29
  //# sourceMappingURL=moonpay.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  MOONPAY_ENDPOINTS
3
- } from "../chunk-3HCZ6JBJ.mjs";
3
+ } from "../chunk-T5JAYOWY.mjs";
4
4
  export {
5
5
  MOONPAY_ENDPOINTS
6
6
  };
@@ -1,16 +1,33 @@
1
1
  /**
2
- * zod schemas for the MoonPay provider-owned flow. Test-time and backend-boundary only: exported from
3
- * the package root, never from `./moonpay`, so the production entry stays free of zod.
2
+ * zod schemas for the MoonPay flow on `POST /fiat/next`. Test-time and backend-boundary only:
3
+ * exported from the package root, never from `./moonpay`, so the production entry stays free of zod.
4
4
  */
5
5
  import { z } from 'zod';
6
- import type { MoonPayCheckout, MoonPayErrorBody, MoonPayFault, MoonPayIntentRequest, MoonPayIntentResponse, MoonPayOrderResponse, MoonPayQuoteInput, MoonPaySdkCredentials, MoonPayStepResponse } from './moonpay';
6
+ import type { MoonPayCheckout, MoonPayConnectPrompt, MoonPayConnectRequest, MoonPayConsentPrompt, MoonPayConsentRequest, MoonPayDone, MoonPayErrorBody, MoonPayFault, MoonPayKycPrompt, MoonPayKycRequest, MoonPayNextRequest, MoonPayObserveRequest, MoonPayOrderPrompt, MoonPayOrderRequest, MoonPayOrderResponse, MoonPayPrompt, MoonPayQuoteInput, MoonPayRequest, MoonPayRequestContext, MoonPayResponseFor, MoonPaySdkCredentials, MoonPayStepResponse, MoonPayWaitPrompt } from './moonpay';
7
7
  export declare const MoonPayCheckoutSchema: z.ZodType<MoonPayCheckout>;
8
8
  export declare const MoonPaySdkCredentialsSchema: z.ZodType<MoonPaySdkCredentials>;
9
- export declare const MoonPayIntentRequestSchema: z.ZodType<MoonPayIntentRequest>;
9
+ export declare const MoonPayRequestContextSchema: z.ZodType<MoonPayRequestContext>;
10
10
  export declare const MoonPayQuoteInputSchema: z.ZodType<MoonPayQuoteInput>;
11
+ export declare const MoonPayObserveRequestSchema: z.ZodType<MoonPayRequestContext & MoonPayObserveRequest>;
12
+ export declare const MoonPayConsentRequestSchema: z.ZodType<MoonPayRequestContext & MoonPayConsentRequest>;
13
+ export declare const MoonPayConnectRequestSchema: z.ZodType<MoonPayRequestContext & MoonPayConnectRequest>;
14
+ export declare const MoonPayKycRequestSchema: z.ZodType<MoonPayRequestContext & MoonPayKycRequest>;
15
+ export declare const MoonPayOrderRequestSchema: z.ZodType<MoonPayRequestContext & MoonPayOrderRequest>;
16
+ export declare const MoonPayRequestSchema: z.ZodType<MoonPayRequest>;
17
+ export declare const MoonPayNextRequestSchema: z.ZodType<MoonPayNextRequest>;
18
+ export declare const MoonPayConsentPromptSchema: z.ZodType<MoonPayConsentPrompt>;
19
+ export declare const MoonPayConnectPromptSchema: z.ZodType<MoonPayConnectPrompt>;
20
+ export declare const MoonPayKycPromptSchema: z.ZodType<MoonPayKycPrompt>;
21
+ export declare const MoonPayWaitPromptSchema: z.ZodType<MoonPayWaitPrompt>;
22
+ export declare const MoonPayOrderPromptSchema: z.ZodType<MoonPayOrderPrompt>;
23
+ export declare const MoonPayPromptSchema: z.ZodType<MoonPayPrompt>;
24
+ export declare const MoonPayDoneSchema: z.ZodType<MoonPayDone>;
11
25
  export declare const MoonPayStepResponseSchema: z.ZodType<MoonPayStepResponse>;
12
26
  export declare const MoonPayOrderResponseSchema: z.ZodType<MoonPayOrderResponse>;
13
- export declare const MoonPayIntentResponseSchema: z.ZodType<MoonPayIntentResponse>;
27
+ /** The response schema for each request action, as `MoonPayResponseFor` types it. */
28
+ export declare const MoonPayResponseSchemaFor: {
29
+ readonly [A in keyof MoonPayResponseFor]: z.ZodType<MoonPayResponseFor[A]>;
30
+ };
14
31
  export declare const MoonPayFaultSchema: z.ZodType<MoonPayFault>;
15
32
  export declare const MoonPayErrorBodySchema: z.ZodType<MoonPayErrorBody>;
16
33
  //# sourceMappingURL=moonpay.schemas.d.ts.map
package/dist/routing.d.ts CHANGED
@@ -21,7 +21,7 @@ import type { CountryCode, FiatCurrencyCode, PaymentMethodCategory } from './cod
21
21
  import type { FiatAmount, FiatProvider, QuoteLimitRange } from './types';
22
22
  export declare const ROUTING_ENDPOINTS: {
23
23
  readonly table: "GET /fiat/routing/table";
24
- /** Temporary: each provider's `intent` route replaces it. */
24
+ /** Temporary: `POST /fiat/next` replaces it for each provider that moves there. */
25
25
  readonly quote: "POST /fiat/routing/quote";
26
26
  };
27
27
  /**
package/dist/routing.js CHANGED
@@ -25,7 +25,7 @@ __export(routing_exports, {
25
25
  module.exports = __toCommonJS(routing_exports);
26
26
  var ROUTING_ENDPOINTS = {
27
27
  table: "GET /fiat/routing/table",
28
- /** Temporary: each provider's `intent` route replaces it. */
28
+ /** Temporary: `POST /fiat/next` replaces it for each provider that moves there. */
29
29
  quote: "POST /fiat/routing/quote"
30
30
  };
31
31
  //# sourceMappingURL=routing.js.map
package/dist/routing.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  ROUTING_ENDPOINTS
3
- } from "./chunk-KYE2HYV5.mjs";
3
+ } from "./chunk-5UEPWL7B.mjs";
4
4
  export {
5
5
  ROUTING_ENDPOINTS
6
6
  };
package/dist/schemas.d.ts CHANGED
@@ -28,7 +28,7 @@
28
28
  */
29
29
  import { z } from 'zod';
30
30
  import type { UsStateCode } from './codes';
31
- import type { BlockedReason, CryptoAmount, FailureReason, FeeLine, FiatAmount, FiatEndpoint, FiatProvider, FiatStepResponse, FieldSpec, FlowState, FormDescriptor, FormField, FormFieldType, InstructionField, Instructions, Instrument, JsonValue, KYCProvider, OrderRef, OrderStatus, OrderSummary, PollSpec, PreparedPayment, PaymentSurface, Quote, QuoteLimitRange, QuoteLimits, Recovery, Refund, ReportSpec, SelectOption, StatusHistoryEntry, Surface, PreferredIdentityDocument, KycFieldId, ClientExecutedDelivery, KycSdkResultReport, SurfaceKind, SurfaceProvider, TermsAcceptance, Transition, TransitionInputs, TransitionParams, Tx } from './types';
31
+ import type { BlockedReason, CryptoAmount, FailureReason, FeeLine, FiatAmount, FiatEndpoint, FiatProvider, FiatStepResponse, FieldSpec, FlowState, FormDescriptor, FormField, FormFieldType, InstructionField, Instructions, Instrument, JsonValue, KYCProvider, OrderRef, OrderStatus, OrderSummary, PollSpec, PreparedPayment, PaymentSurface, Quote, QuoteLimitRange, QuoteLimits, Recovery, Refund, ReportSpec, SelectOption, StatusHistoryEntry, Surface, PreferredIdentityDocument, KycFieldId, ClientExecutedDelivery, KycSdkResultReport, SurfaceKind, SurfaceProvider, TermsAcceptance, Transition, TransitionInputs, TransitionParams, Tx, FiatGeo, FiatNextRequest } from './types';
32
32
  import type { FiatTermsErrorBody, FiatTermsRequest, FiatTermsResponse, TermsDocument, TermsDocumentAcceptance } from './terms';
33
33
  import type { FiatRoutingQuoteErrorBody, FiatRoutingQuoteRequest, FiatRoutingTableErrorBody, FiatRoutingTableQuery, FiatRoutingTableResponse } from './routing';
34
34
  export declare const JsonSchema: z.ZodType<JsonValue>;
@@ -117,6 +117,8 @@ export declare const FiatRoutingTableResponseSchema: z.ZodType<FiatRoutingTableR
117
117
  export declare const FiatRoutingQuoteRequestSchema: z.ZodType<FiatRoutingQuoteRequest>;
118
118
  export declare const FiatRoutingTableErrorBodySchema: z.ZodType<FiatRoutingTableErrorBody>;
119
119
  export declare const FiatRoutingQuoteErrorBodySchema: z.ZodType<FiatRoutingQuoteErrorBody>;
120
+ export declare const FiatGeoSchema: z.ZodType<FiatGeo>;
121
+ export declare const FiatNextRequestSchema: z.ZodType<FiatNextRequest>;
120
122
  export declare const FiatStepResponseSchema: z.ZodType<FiatStepResponse>;
121
123
  export {};
122
124
  //# sourceMappingURL=schemas.d.ts.map
package/dist/table.js CHANGED
@@ -36,7 +36,7 @@ __export(table_exports, {
36
36
  module.exports = __toCommonJS(table_exports);
37
37
 
38
38
  // package.json
39
- var version = "0.23.0";
39
+ var version = "0.24.0";
40
40
 
41
41
  // src/table.ts
42
42
  var TABLE_VERSION = version;
package/dist/table.mjs CHANGED
@@ -11,7 +11,7 @@ import {
11
11
  tableEntry,
12
12
  unofferedEndpoints,
13
13
  unreachableStates
14
- } from "./chunk-EI56NQ7K.mjs";
14
+ } from "./chunk-IPOPANXS.mjs";
15
15
  export {
16
16
  DOCUMENTED_ENDPOINTS,
17
17
  STATE_KEYS,
package/dist/terms.d.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  * The platform terms route: `POST /fiat/terms`, shared by every provider.
3
3
  *
4
4
  * A checkout shows the user documents to accept. `CHECKOUT` documents are the constants below;
5
- * `KYC` documents arrive in a provider flow's `TERMS` response. The user's Continue tap is the
5
+ * `KYC` documents arrive in a provider flow's consent prompt. The user's Continue tap is the
6
6
  * acceptance, and the client records it here before the next provider call. A repeat writes nothing.
7
7
  *
8
8
  * Zero runtime dependencies, so production React Native code can import it. The zod schemas are
@@ -39,7 +39,7 @@ export interface FiatTermsRequest {
39
39
  /** One per document the screen showed, each document at most once. */
40
40
  acceptances: TermsDocumentAcceptance[];
41
41
  }
42
- /** The recorded document ids. The client then calls the provider's `intent`. */
42
+ /** The recorded document ids. The client then calls `POST /fiat/next`. */
43
43
  export interface FiatTermsResponse {
44
44
  recorded: string[];
45
45
  }
package/dist/terms.mjs CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  FUN_KYC_CONSENT_DOCUMENTS,
4
4
  PROVIDER_CHECKOUT_DOCUMENTS,
5
5
  PUBLISHED_TERMS_DOCUMENTS
6
- } from "./chunk-5GRPYE2U.mjs";
6
+ } from "./chunk-CRNKRIKR.mjs";
7
7
  export {
8
8
  FIAT_TERMS_ENDPOINT,
9
9
  FUN_KYC_CONSENT_DOCUMENTS,
package/dist/types.d.ts CHANGED
@@ -715,7 +715,7 @@ export type FiatStepResponse = (FiatStepResponseBase & {
715
715
  /** Optional future payment artifact; never one of this response's currently active transitions. */
716
716
  preparedPayment?: PreparedPayment;
717
717
  /**
718
- * The provider runs its own flow from here (`POST /fiat/providers/{provider}/intent`). Present
718
+ * The provider runs its own flow from here (`POST /fiat/next`). Present
719
719
  * only on a `QUOTE`, when the request's `handoffs` named this provider; the response then
720
720
  * carries no transitions.
721
721
  */
@@ -723,5 +723,20 @@ export type FiatStepResponse = (FiatStepResponseBase & {
723
723
  provider: FiatProvider;
724
724
  };
725
725
  });
726
+ /** The geo endpoint's response, sent on every `/next` request. `alpha2` is ISO 3166-1 alpha-2. */
727
+ export type FiatGeo = {
728
+ alpha2: string;
729
+ region?: string;
730
+ ip?: string;
731
+ };
732
+ /**
733
+ * The body of every `POST /fiat/next`: `provider`, `geo`, and the provider's own request, which
734
+ * names its `action`. Each provider defines its actions and their fields (`./moonpay`).
735
+ */
736
+ export type FiatNextRequest = {
737
+ provider: FiatProvider;
738
+ action: string;
739
+ geo: FiatGeo;
740
+ } & Record<string, unknown>;
726
741
  export {};
727
742
  //# sourceMappingURL=types.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fun-xyz/fiat-contract",
3
- "version": "0.23.0",
3
+ "version": "0.24.0",
4
4
  "description": "Published conformance contract for Fun's headless fiat onramp: FlowState/Transition types, zod schemas, the transition table as data, recorded fixtures, assertion helpers.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -1,9 +0,0 @@
1
- // src/providers/moonpay.ts
2
- var MOONPAY_ENDPOINTS = {
3
- intent: "POST /fiat/providers/moonpay/intent"
4
- };
5
-
6
- export {
7
- MOONPAY_ENDPOINTS
8
- };
9
- //# sourceMappingURL=chunk-3HCZ6JBJ.mjs.map