@fun-xyz/fiat-contract 0.56.0 → 0.59.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.
@@ -0,0 +1 @@
1
+ export * from './dist/flows/bank-transfer';
@@ -0,0 +1,2 @@
1
+ // Compat stub — see table.js. Metro before RN 0.79 resolves `@fun-xyz/fiat-contract/bank-transfer` by path.
2
+ module.exports = require('./dist/flows/bank-transfer.js');
@@ -1,5 +1,5 @@
1
1
  // package.json
2
- var version = "0.56.0";
2
+ var version = "0.59.0";
3
3
 
4
4
  // src/table.ts
5
5
  var TABLE_VERSION = version;
@@ -0,0 +1,10 @@
1
+ // src/flows/bank-transfer.ts
2
+ var BANK_TRANSFER_ENDPOINTS = {
3
+ next: "POST /fiat/next"
4
+ };
5
+ var BANK_TRANSFER_MAX_LISTED_ORDERS = 20;
6
+
7
+ export {
8
+ BANK_TRANSFER_ENDPOINTS,
9
+ BANK_TRANSFER_MAX_LISTED_ORDERS
10
+ };
@@ -0,0 +1,183 @@
1
+ /**
2
+ * The bank transfer flow on `POST /fiat/next`, shared by every provider that serves `bank_transfer` (a push from the
3
+ * buyer's bank to account details Fun shows: SEPA, FPS, FAST, a wire). The client runs it the same way for each one:
4
+ * a new bank provider ships from the backend alone.
5
+ *
6
+ * The buyer gets persistent account details, not a checkout: no amount, no quote, no order before money arrives. Fun
7
+ * creates the order when the provider reports a deposit, so the client learns of orders from `bankDetails.orders` and
8
+ * reads one with `order`. `wait` has no request: send `observe` after it. Identity and the deposit wallet come from the
9
+ * verified partner assertion, never from a request body.
10
+ *
11
+ * A retry sends the same request and gets the current response. A fault is a 4xx/5xx whose body is
12
+ * `BankTransferErrorBody`; anything the buyer can act on is a 200.
13
+ *
14
+ * Zero runtime dependencies. The zod schemas are in `./bank-transfer.schemas`, exported from the package root only.
15
+ */
16
+ import type { FiatTermsRequest, TermsDocument } from '../terms';
17
+ import type { FiatCurrencyCode } from '../codes';
18
+ import type { FiatGeo, FiatProvider, FiatStepResponse, InstructionField, KYCProvider, KycSdkResultReport, OrderPoll } from '../types';
19
+ export declare const BANK_TRANSFER_ENDPOINTS: {
20
+ readonly next: "POST /fiat/next";
21
+ };
22
+ /** The most orders one `bankDetails` lists. */
23
+ export declare const BANK_TRANSFER_MAX_LISTED_ORDERS = 20;
24
+ /** What the deposits buy, sent on every request. No amount: the provider converts whatever arrives. */
25
+ export interface BankTransferCheckout {
26
+ /** The currency the buyer sends. With the buyer's country it picks the rail and the provider. */
27
+ currency: FiatCurrencyCode;
28
+ /** The asset and its network, as the routing table named them. */
29
+ destination: {
30
+ asset: string;
31
+ network: string;
32
+ };
33
+ paymentMethod: 'bank_transfer';
34
+ }
35
+ export type BankTransferRequestContext = {
36
+ checkout: BankTransferCheckout;
37
+ };
38
+ /** No next action of its own: the answer is the current next action. Writes nothing. */
39
+ export type BankTransferObserveRequest = {
40
+ action: 'observe';
41
+ };
42
+ /** Fun's KYC consent and the provider's terms, if the buyer has not accepted them. */
43
+ export type BankTransferConsentNextAction = {
44
+ next: 'consent';
45
+ documents: TermsDocument[];
46
+ };
47
+ /** The `POST /fiat/terms` items, recorded under the same rules. */
48
+ export type BankTransferConsentRequest = {
49
+ action: 'consent';
50
+ acceptances: FiatTermsRequest['acceptances'];
51
+ };
52
+ /**
53
+ * The provider needs something the shared KYC did not give it (a document, a selfie, a check). Open the SDK
54
+ * `kycProvider` names with `accessToken`, then send `capture`. To refresh an expired token, send `observe`.
55
+ */
56
+ export type BankTransferCaptureNextAction = {
57
+ next: 'capture';
58
+ kycProvider: KYCProvider;
59
+ accessToken: string;
60
+ /** ISO-8601. */
61
+ expiresAt: string;
62
+ };
63
+ /** When the SDK closes. A report only: the backend reads the provider itself. */
64
+ export type BankTransferCaptureRequest = {
65
+ action: 'capture';
66
+ result: KycSdkResultReport;
67
+ };
68
+ /** The provider is reviewing, or the account details are being opened. No request: send `observe` after the delay. */
69
+ export type BankTransferWaitNextAction = {
70
+ next: 'wait';
71
+ retryAfterMs: number;
72
+ };
73
+ /**
74
+ * Show `wallet` and `attestationText`; the buyer confirms the wallet is theirs. Then send `openDepositInstructions`.
75
+ * Every deposit from then on goes to this wallet, replacing any earlier one. `observe` answers this again whenever the
76
+ * asserted wallet is not the one deposits go to.
77
+ */
78
+ export type BankTransferOpenDepositInstructionsNextAction = {
79
+ next: 'openDepositInstructions';
80
+ wallet: {
81
+ address: string;
82
+ network: string;
83
+ asset: string;
84
+ };
85
+ attestationText: string;
86
+ };
87
+ /**
88
+ * Registers the wallet with the provider under the buyer's confirmation and answers `bankDetails`. `walletAddress` is
89
+ * the `wallet.address` the buyer confirmed: a value that is not the asserted wallet registers nothing and answers the
90
+ * current next action.
91
+ */
92
+ export type BankTransferOpenDepositInstructionsRequest = {
93
+ action: 'openDepositInstructions';
94
+ walletConfirmed: true;
95
+ walletAddress: string;
96
+ };
97
+ /**
98
+ * Where the buyer sends money and where deposits go. `instructions.fields` are the rail's own details (an IBAN and BIC,
99
+ * a sort code and account number, a SWIFT code, a reference): show each with its `labelFallback` and a copy button,
100
+ * never by `id`. `orders` are the orders made from deposits since these details were first shown, newest first, at
101
+ * most `BANK_TRANSFER_MAX_LISTED_ORDERS`. Send `observe` after `retryAfterMs` to refresh them; send `order` for one.
102
+ */
103
+ export type BankTransferBankDetailsNextAction = {
104
+ next: 'bankDetails';
105
+ instructions: {
106
+ kind: 'BANK_FIELDS';
107
+ fields: InstructionField[];
108
+ };
109
+ wallet: {
110
+ address: string;
111
+ network: string;
112
+ asset: string;
113
+ };
114
+ orders: FiatStepResponse[];
115
+ retryAfterMs: number;
116
+ };
117
+ /** Reads the provider and moves the order `orderId` forward. `orderId` is one `bankDetails` listed. */
118
+ export type BankTransferOrderRequest = {
119
+ action: 'order';
120
+ orderId: string;
121
+ };
122
+ /** The order is not terminal. After `retryAfterMs`, send `order`. */
123
+ export type BankTransferOrderPendingNextAction = {
124
+ next: 'orderPending';
125
+ orderId: string;
126
+ retryAfterMs: number;
127
+ poll?: OrderPoll;
128
+ order: FiatStepResponse;
129
+ };
130
+ export type BankTransferRequest = BankTransferRequestContext & (BankTransferObserveRequest | BankTransferConsentRequest | BankTransferCaptureRequest | BankTransferOpenDepositInstructionsRequest | BankTransferOrderRequest);
131
+ export type BankTransferAction = BankTransferRequest['action'];
132
+ /**
133
+ * The wire body. `provider` is the one the routing table named for this corridor: the client passes it through and
134
+ * never branches on it. The backend refuses a provider that does not serve `bank_transfer`.
135
+ */
136
+ export type BankTransferNextRequest = {
137
+ provider: FiatProvider;
138
+ geo: FiatGeo;
139
+ } & BankTransferRequest;
140
+ export type BankTransferNextAction = BankTransferConsentNextAction | BankTransferCaptureNextAction | BankTransferWaitNextAction | BankTransferOpenDepositInstructionsNextAction | BankTransferBankDetailsNextAction | BankTransferOrderPendingNextAction;
141
+ /** The order is terminal. `order` is its body, which the shared order screen renders. */
142
+ export type BankTransferDone = {
143
+ next: 'done';
144
+ order: FiatStepResponse;
145
+ };
146
+ /** Read `recovery`, never derive it from the reason. `NONE` ends the flow. */
147
+ export type BankTransferStepRefusal = 'NOT_ELIGIBLE' | 'KYC_REJECTED';
148
+ export type BankTransferRefused = {
149
+ next: 'refused';
150
+ reason: BankTransferStepRefusal;
151
+ recovery: 'NONE';
152
+ };
153
+ /** Every action but `order`. */
154
+ export type BankTransferStepResponse = Exclude<BankTransferNextAction, BankTransferOrderPendingNextAction> | BankTransferRefused;
155
+ /** `order` never refuses: the buyer has already paid. */
156
+ export type BankTransferOrderResponse = BankTransferDone | BankTransferOrderPendingNextAction;
157
+ export type BankTransferResponse = BankTransferStepResponse | BankTransferOrderResponse;
158
+ export type BankTransferResponseFor = {
159
+ observe: BankTransferStepResponse;
160
+ consent: BankTransferStepResponse;
161
+ capture: BankTransferStepResponse;
162
+ openDepositInstructions: BankTransferStepResponse;
163
+ order: BankTransferOrderResponse;
164
+ };
165
+ /** `RETRY` sends the same request again. `NONE` ends the flow. */
166
+ export type BankTransferRecovery = 'RETRY' | 'NONE';
167
+ /**
168
+ * `RATE_LIMITED`: the action's request budget (429). `PROVIDER_UNAVAILABLE`: the bank provider is down (503).
169
+ * `KYC_PROVIDER_UNAVAILABLE`: the KYC provider sharing the buyer's verification is down (503).
170
+ * `SERVICE_UNAVAILABLE`: one of Fun's own stores is down (503). `INVALID_REQUEST`: a bad body, or a provider that does
171
+ * not serve `bank_transfer` (400).
172
+ */
173
+ export type BankTransferFaultReason = 'RATE_LIMITED' | 'PROVIDER_UNAVAILABLE' | 'KYC_PROVIDER_UNAVAILABLE' | 'SERVICE_UNAVAILABLE' | 'INVALID_REQUEST';
174
+ export interface BankTransferFault {
175
+ reason: BankTransferFaultReason;
176
+ recovery: BankTransferRecovery;
177
+ }
178
+ export type BankTransferErrorBody = BankTransferFault & {
179
+ errorCode: string;
180
+ errorMsg: string;
181
+ reqId?: string;
182
+ retryAfterSeconds?: number;
183
+ };
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/flows/bank-transfer.ts
21
+ var bank_transfer_exports = {};
22
+ __export(bank_transfer_exports, {
23
+ BANK_TRANSFER_ENDPOINTS: () => BANK_TRANSFER_ENDPOINTS,
24
+ BANK_TRANSFER_MAX_LISTED_ORDERS: () => BANK_TRANSFER_MAX_LISTED_ORDERS
25
+ });
26
+ module.exports = __toCommonJS(bank_transfer_exports);
27
+ var BANK_TRANSFER_ENDPOINTS = {
28
+ next: "POST /fiat/next"
29
+ };
30
+ var BANK_TRANSFER_MAX_LISTED_ORDERS = 20;
@@ -0,0 +1,8 @@
1
+ import {
2
+ BANK_TRANSFER_ENDPOINTS,
3
+ BANK_TRANSFER_MAX_LISTED_ORDERS
4
+ } from "../chunk-MEL2ZOQ5.mjs";
5
+ export {
6
+ BANK_TRANSFER_ENDPOINTS,
7
+ BANK_TRANSFER_MAX_LISTED_ORDERS
8
+ };
@@ -0,0 +1,32 @@
1
+ /**
2
+ * zod schemas for the bank transfer flow on `POST /fiat/next`. Test-time and backend-boundary only:
3
+ * exported from the package root, never from `./bank-transfer`, so the production entry stays free of zod.
4
+ */
5
+ import { z } from 'zod';
6
+ import type { BankTransferBankDetailsNextAction, BankTransferCaptureNextAction, BankTransferCaptureRequest, BankTransferCheckout, BankTransferConsentNextAction, BankTransferConsentRequest, BankTransferDone, BankTransferErrorBody, BankTransferFault, BankTransferNextAction, BankTransferNextRequest, BankTransferObserveRequest, BankTransferOpenDepositInstructionsNextAction, BankTransferOpenDepositInstructionsRequest, BankTransferOrderPendingNextAction, BankTransferOrderRequest, BankTransferOrderResponse, BankTransferRefused, BankTransferRequest, BankTransferRequestContext, BankTransferResponseFor, BankTransferStepResponse, BankTransferWaitNextAction } from './bank-transfer';
7
+ export declare const BankTransferCheckoutSchema: z.ZodType<BankTransferCheckout>;
8
+ export declare const BankTransferRequestContextSchema: z.ZodType<BankTransferRequestContext>;
9
+ export declare const BankTransferObserveRequestSchema: z.ZodType<BankTransferRequestContext & BankTransferObserveRequest>;
10
+ export declare const BankTransferConsentRequestSchema: z.ZodType<BankTransferRequestContext & BankTransferConsentRequest>;
11
+ export declare const BankTransferCaptureRequestSchema: z.ZodType<BankTransferRequestContext & BankTransferCaptureRequest>;
12
+ export declare const BankTransferOpenDepositInstructionsRequestSchema: z.ZodType<BankTransferRequestContext & BankTransferOpenDepositInstructionsRequest>;
13
+ export declare const BankTransferOrderRequestSchema: z.ZodType<BankTransferRequestContext & BankTransferOrderRequest>;
14
+ export declare const BankTransferRequestSchema: z.ZodType<BankTransferRequest>;
15
+ export declare const BankTransferNextRequestSchema: z.ZodType<BankTransferNextRequest>;
16
+ export declare const BankTransferConsentNextActionSchema: z.ZodType<BankTransferConsentNextAction>;
17
+ export declare const BankTransferCaptureNextActionSchema: z.ZodType<BankTransferCaptureNextAction>;
18
+ export declare const BankTransferWaitNextActionSchema: z.ZodType<BankTransferWaitNextAction>;
19
+ export declare const BankTransferOpenDepositInstructionsNextActionSchema: z.ZodType<BankTransferOpenDepositInstructionsNextAction>;
20
+ export declare const BankTransferBankDetailsNextActionSchema: z.ZodType<BankTransferBankDetailsNextAction>;
21
+ export declare const BankTransferOrderPendingNextActionSchema: z.ZodType<BankTransferOrderPendingNextAction>;
22
+ export declare const BankTransferNextActionSchema: z.ZodType<BankTransferNextAction>;
23
+ export declare const BankTransferDoneSchema: z.ZodType<BankTransferDone>;
24
+ export declare const BankTransferRefusedSchema: z.ZodType<BankTransferRefused>;
25
+ export declare const BankTransferStepResponseSchema: z.ZodType<BankTransferStepResponse>;
26
+ export declare const BankTransferOrderResponseSchema: z.ZodType<BankTransferOrderResponse>;
27
+ /** The response schema for each request action, as `BankTransferResponseFor` types it. */
28
+ export declare const BankTransferResponseSchemaFor: {
29
+ readonly [A in keyof BankTransferResponseFor]: z.ZodType<BankTransferResponseFor[A]>;
30
+ };
31
+ export declare const BankTransferFaultSchema: z.ZodType<BankTransferFault>;
32
+ export declare const BankTransferErrorBodySchema: z.ZodType<BankTransferErrorBody>;
package/dist/index.d.ts CHANGED
@@ -18,6 +18,8 @@ export * from './providers/coinbase';
18
18
  export * from './providers/coinbase.schemas';
19
19
  export * from './providers/stripe';
20
20
  export * from './providers/stripe.schemas';
21
+ export * from './flows/bank-transfer';
22
+ export * from './flows/bank-transfer.schemas';
21
23
  export { FIXTURES, FIXTURE_COVERAGE_GAPS, fixtureMeta, loadFixture, loadFixtures, type FixtureMeta, type FixtureSource, type LoadedFixture, } from './fixtures/index';
22
24
  export * from './providers/moonpay-guest';
23
25
  export * from './providers/moonpay-guest.schemas';
package/dist/index.js CHANGED
@@ -20,6 +20,31 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
+ BANK_TRANSFER_ENDPOINTS: () => BANK_TRANSFER_ENDPOINTS,
24
+ BANK_TRANSFER_MAX_LISTED_ORDERS: () => BANK_TRANSFER_MAX_LISTED_ORDERS,
25
+ BankTransferBankDetailsNextActionSchema: () => BankTransferBankDetailsNextActionSchema,
26
+ BankTransferCaptureNextActionSchema: () => BankTransferCaptureNextActionSchema,
27
+ BankTransferCaptureRequestSchema: () => BankTransferCaptureRequestSchema,
28
+ BankTransferCheckoutSchema: () => BankTransferCheckoutSchema,
29
+ BankTransferConsentNextActionSchema: () => BankTransferConsentNextActionSchema,
30
+ BankTransferConsentRequestSchema: () => BankTransferConsentRequestSchema,
31
+ BankTransferDoneSchema: () => BankTransferDoneSchema,
32
+ BankTransferErrorBodySchema: () => BankTransferErrorBodySchema,
33
+ BankTransferFaultSchema: () => BankTransferFaultSchema,
34
+ BankTransferNextActionSchema: () => BankTransferNextActionSchema,
35
+ BankTransferNextRequestSchema: () => BankTransferNextRequestSchema,
36
+ BankTransferObserveRequestSchema: () => BankTransferObserveRequestSchema,
37
+ BankTransferOpenDepositInstructionsNextActionSchema: () => BankTransferOpenDepositInstructionsNextActionSchema,
38
+ BankTransferOpenDepositInstructionsRequestSchema: () => BankTransferOpenDepositInstructionsRequestSchema,
39
+ BankTransferOrderPendingNextActionSchema: () => BankTransferOrderPendingNextActionSchema,
40
+ BankTransferOrderRequestSchema: () => BankTransferOrderRequestSchema,
41
+ BankTransferOrderResponseSchema: () => BankTransferOrderResponseSchema,
42
+ BankTransferRefusedSchema: () => BankTransferRefusedSchema,
43
+ BankTransferRequestContextSchema: () => BankTransferRequestContextSchema,
44
+ BankTransferRequestSchema: () => BankTransferRequestSchema,
45
+ BankTransferResponseSchemaFor: () => BankTransferResponseSchemaFor,
46
+ BankTransferStepResponseSchema: () => BankTransferStepResponseSchema,
47
+ BankTransferWaitNextActionSchema: () => BankTransferWaitNextActionSchema,
23
48
  BlockedReasonSchema: () => BlockedReasonSchema,
24
49
  BlockedStateSchema: () => BlockedStateSchema,
25
50
  COINBASE_ENDPOINTS: () => COINBASE_ENDPOINTS,
@@ -661,7 +686,8 @@ var $provider = import_zod.z.enum([
661
686
  "MOONPAY_GUEST",
662
687
  "STRIPE",
663
688
  "COINBASE",
664
- "CROSSMINT"
689
+ "CROSSMINT",
690
+ "ALCHEMYPAY"
665
691
  ]);
666
692
  var FiatProviderSchema = $provider;
667
693
  var $kycProvider = import_zod.z.enum(["SUMSUB"]);
@@ -998,12 +1024,12 @@ var OrderPollSchema = obj({
998
1024
  giveUpAfterMs: import_zod.z.number().int().positive().max(60 * 60 * 1e3)
999
1025
  });
1000
1026
  function checkOrderPendingPoll(response, context2) {
1001
- const { poll, retryAfterMs: retryAfterMs2 } = response;
1002
- if (response.next !== "orderPending" || poll === void 0 || retryAfterMs2 === void 0) return;
1003
- if (retryAfterMs2 < MIN_INTERVAL_MS) {
1027
+ const { poll, retryAfterMs: retryAfterMs3 } = response;
1028
+ if (response.next !== "orderPending" || poll === void 0 || retryAfterMs3 === void 0) return;
1029
+ if (retryAfterMs3 < MIN_INTERVAL_MS) {
1004
1030
  context2.addIssue({ code: "custom", path: ["retryAfterMs"], message: `retryAfterMs must be at least ${MIN_INTERVAL_MS} with a poll` });
1005
1031
  }
1006
- if (poll.maxIntervalMs < retryAfterMs2) {
1032
+ if (poll.maxIntervalMs < retryAfterMs3) {
1007
1033
  context2.addIssue({ code: "custom", path: ["poll", "maxIntervalMs"], message: "maxIntervalMs must be at least retryAfterMs" });
1008
1034
  }
1009
1035
  }
@@ -1271,7 +1297,7 @@ var compareDecimals = (left, right) => {
1271
1297
  return leftDigits < rightDigits ? -1 : leftDigits > rightDigits ? 1 : 0;
1272
1298
  };
1273
1299
  var $countryCode = import_zod.z.enum(Object.keys(CountryCode));
1274
- var $routingProvider = $provider.extract(["TRANSAK", "BANXA", "MOONPAY", "MOONPAY_GUEST", "STRIPE", "COINBASE"]);
1300
+ var $routingProvider = $provider.extract(["TRANSAK", "BANXA", "MOONPAY", "MOONPAY_GUEST", "STRIPE", "COINBASE", "ALCHEMYPAY"]);
1275
1301
  var $optionalGeoField = import_zod.z.union([$nonBlank, import_zod.z.literal("")]).optional();
1276
1302
  var US_REGION_REQUIRED = "a US buyer needs a US state code as region";
1277
1303
  var hasUsRegion = (country, region) => country !== "US" || UsStateCodeSchema.safeParse(region).success;
@@ -1289,7 +1315,7 @@ var $routingTableRequest = obj({
1289
1315
  providers: $routingTableProviderInputs.optional(),
1290
1316
  destinationAsset: $destinationAsset.optional(),
1291
1317
  depositAddress: $nonBlank.optional()
1292
- }).refine((request2) => hasUsRegion(request2.country, request2.region), { message: US_REGION_REQUIRED, path: ["region"] });
1318
+ }).refine((request3) => hasUsRegion(request3.country, request3.region), { message: US_REGION_REQUIRED, path: ["region"] });
1293
1319
  var FiatRoutingTableRequestSchema = $routingTableRequest;
1294
1320
  var $routingTableProvider = obj({
1295
1321
  provider: $routingProvider,
@@ -1347,9 +1373,9 @@ var $routingQuoteRequest = import_zod.z.union([
1347
1373
  }),
1348
1374
  obj({ ...$routingQuoteTermsShape, provider: $routingProvider })
1349
1375
  ]).refine(
1350
- (request2) => {
1351
- const allowed = request2.routingOverrides?.providers;
1352
- const selected = "providers" in request2 ? request2.providers : [request2.provider];
1376
+ (request3) => {
1377
+ const allowed = request3.routingOverrides?.providers;
1378
+ const selected = "providers" in request3 ? request3.providers : [request3.provider];
1353
1379
  return allowed === void 0 || selected.every((provider) => allowed.includes(provider));
1354
1380
  },
1355
1381
  { message: "requested providers must be allowed by routingOverrides", path: ["routingOverrides"] }
@@ -1491,7 +1517,7 @@ var $stepResponse = import_zod.z.union([$providerBoundStepResponse, $funAuthStep
1491
1517
  var FiatStepResponseSchema = $stepResponse;
1492
1518
 
1493
1519
  // package.json
1494
- var version = "0.56.0";
1520
+ var version = "0.59.0";
1495
1521
 
1496
1522
  // src/table.ts
1497
1523
  var TABLE_VERSION = version;
@@ -3392,14 +3418,14 @@ function walkTable(fn) {
3392
3418
  function assertFixture(id) {
3393
3419
  const meta = fixtureMeta(id);
3394
3420
  const json = loadFixture(id);
3395
- const stepResponse2 = assertFiatStepResponse(json);
3396
- if (stateKey(stepResponse2.state) !== meta.stateKey) {
3421
+ const stepResponse3 = assertFiatStepResponse(json);
3422
+ if (stateKey(stepResponse3.state) !== meta.stateKey) {
3397
3423
  throw new ContractViolation(
3398
- `fixture ${id}: manifest says ${meta.stateKey}, step response carries ${stateKey(stepResponse2.state)}`
3424
+ `fixture ${id}: manifest says ${meta.stateKey}, step response carries ${stateKey(stepResponse3.state)}`
3399
3425
  );
3400
3426
  }
3401
- assertLegalEmission(stepResponse2.state, stepResponse2.transitions);
3402
- return { meta, stepResponse: stepResponse2 };
3427
+ assertLegalEmission(stepResponse3.state, stepResponse3.transitions);
3428
+ return { meta, stepResponse: stepResponse3 };
3403
3429
  }
3404
3430
  function assertAllFixtures() {
3405
3431
  return FIXTURES.map((meta) => assertFixture(meta.id));
@@ -4037,7 +4063,8 @@ var kycShape = obj4({
4037
4063
  verifiedEmail: nonEmpty.nullable(),
4038
4064
  linkAuthToken: linkAuthToken.nullable(),
4039
4065
  fieldErrors: import_zod4.z.array(obj4({ fieldId: nonEmpty, message: nonEmpty })).min(1).optional(),
4040
- reask: reask.nullable()
4066
+ reask: reask.nullable(),
4067
+ paymentSheetFirst: import_zod4.z.boolean()
4041
4068
  });
4042
4069
  var identifiersNextAction = obj4({ next: import_zod4.z.literal("identifiers"), linkAuthToken: linkAuthToken.nullable() });
4043
4070
  var attestationNextAction = obj4({ next: import_zod4.z.literal("attestation"), linkAuthToken: linkAuthToken.nullable() });
@@ -4087,6 +4114,10 @@ var checkKyc3 = (nextAction, context2) => {
4087
4114
  if (nextAction.tier === "l2" && nextAction.round !== "IDENTITY") {
4088
4115
  context2.addIssue({ code: "custom", path: ["tier"], message: "l2 is an identity round" });
4089
4116
  }
4117
+ const firstAsk = nextAction.tier === "l0" && nextAction.correctionRound === 0 && nextAction.reask === null && !nextAction.fieldErrors;
4118
+ if (nextAction.paymentSheetFirst && !firstAsk) {
4119
+ context2.addIssue({ code: "custom", path: ["paymentSheetFirst"], message: "only a first ask at l0 opens the payment sheet first" });
4120
+ }
4090
4121
  };
4091
4122
  var checkPlaceOrder = (nextAction, context2) => {
4092
4123
  if (nextAction.paySheet.amount !== nextAction.price.total.amount) {
@@ -4176,31 +4207,161 @@ var errorBody = obj4({
4176
4207
  });
4177
4208
  var StripeErrorBodySchema = errorBody;
4178
4209
 
4179
- // src/providers/moonpay-guest.schemas.ts
4210
+ // src/flows/bank-transfer.ts
4211
+ var BANK_TRANSFER_ENDPOINTS = {
4212
+ next: "POST /fiat/next"
4213
+ };
4214
+ var BANK_TRANSFER_MAX_LISTED_ORDERS = 20;
4215
+
4216
+ // src/flows/bank-transfer.schemas.ts
4180
4217
  var import_zod5 = require("zod");
4181
- var context = { checkout: MoonPayCheckoutSchema, destinationAsset: DestinationAssetSchema.optional() };
4182
4218
  var obj5 = (shape) => import_zod5.z.object(shape).strict();
4183
4219
  var nonEmpty2 = import_zod5.z.string().refine((value) => value.trim().length > 0, "must not be blank");
4220
+ var hasUniqueIds5 = (ids) => new Set(ids).size === ids.length;
4221
+ var retryAfterMs2 = import_zod5.z.number().int().positive().max(6e4);
4222
+ var instant2 = import_zod5.z.string().datetime({ offset: true });
4223
+ var orderId = import_zod5.z.string().regex(/^bto_[A-Za-z0-9_-]{22}$/, "must be an order id bankDetails listed");
4224
+ var fiatCurrency = import_zod5.z.enum(Object.keys(FIAT_CURRENCY_NAMES));
4225
+ var checkout2 = obj5({
4226
+ currency: fiatCurrency,
4227
+ destination: obj5({ asset: nonEmpty2, network: nonEmpty2 }),
4228
+ paymentMethod: import_zod5.z.literal("bank_transfer")
4229
+ });
4230
+ var BankTransferCheckoutSchema = checkout2;
4231
+ var contextFields3 = { checkout: checkout2 };
4232
+ var requestContext2 = obj5(contextFields3);
4233
+ var BankTransferRequestContextSchema = requestContext2;
4234
+ var observeFields3 = { action: import_zod5.z.literal("observe") };
4235
+ var consentFields3 = {
4236
+ action: import_zod5.z.literal("consent"),
4237
+ acceptances: import_zod5.z.array(TermsDocumentAcceptanceSchema).min(1).refine((acceptances) => hasUniqueIds5(acceptances.map((acceptance) => acceptance.documentId)), "each document is accepted once")
4238
+ };
4239
+ var captureFields = { action: import_zod5.z.literal("capture"), result: KycSdkResultReportSchema };
4240
+ var openDepositInstructionsFields = { action: import_zod5.z.literal("openDepositInstructions"), walletConfirmed: import_zod5.z.literal(true), walletAddress: nonEmpty2 };
4241
+ var orderFields3 = { action: import_zod5.z.literal("order"), orderId };
4242
+ var observeRequest2 = obj5({ ...contextFields3, ...observeFields3 });
4243
+ var consentRequest2 = obj5({ ...contextFields3, ...consentFields3 });
4244
+ var captureRequest = obj5({ ...contextFields3, ...captureFields });
4245
+ var openDepositInstructionsRequest = obj5({ ...contextFields3, ...openDepositInstructionsFields });
4246
+ var orderRequest2 = obj5({ ...contextFields3, ...orderFields3 });
4247
+ var BankTransferObserveRequestSchema = observeRequest2;
4248
+ var BankTransferConsentRequestSchema = consentRequest2;
4249
+ var BankTransferCaptureRequestSchema = captureRequest;
4250
+ var BankTransferOpenDepositInstructionsRequestSchema = openDepositInstructionsRequest;
4251
+ var BankTransferOrderRequestSchema = orderRequest2;
4252
+ var request2 = import_zod5.z.discriminatedUnion("action", [observeRequest2, consentRequest2, captureRequest, openDepositInstructionsRequest, orderRequest2]);
4253
+ var BankTransferRequestSchema = request2;
4254
+ var envelope3 = { provider: FiatProviderSchema, geo: FiatGeoSchema, ...contextFields3 };
4255
+ var nextRequest2 = import_zod5.z.discriminatedUnion("action", [
4256
+ obj5({ ...envelope3, ...observeFields3 }),
4257
+ obj5({ ...envelope3, ...consentFields3 }),
4258
+ obj5({ ...envelope3, ...captureFields }),
4259
+ obj5({ ...envelope3, ...openDepositInstructionsFields }),
4260
+ obj5({ ...envelope3, ...orderFields3 })
4261
+ ]);
4262
+ var BankTransferNextRequestSchema = nextRequest2;
4263
+ var wallet = obj5({ address: nonEmpty2, network: nonEmpty2, asset: nonEmpty2 });
4264
+ var consentShape2 = obj5({ next: import_zod5.z.literal("consent"), documents: import_zod5.z.array(TermsDocumentSchema).min(1) });
4265
+ var captureNextAction = obj5({ next: import_zod5.z.literal("capture"), kycProvider: KYCProviderSchema, accessToken: nonEmpty2, expiresAt: instant2 });
4266
+ var waitNextAction2 = obj5({ next: import_zod5.z.literal("wait"), retryAfterMs: retryAfterMs2 });
4267
+ var openDepositInstructionsNextAction = obj5({ next: import_zod5.z.literal("openDepositInstructions"), wallet, attestationText: nonEmpty2 });
4268
+ var bankDetailsShape = obj5({
4269
+ next: import_zod5.z.literal("bankDetails"),
4270
+ instructions: obj5({ kind: import_zod5.z.literal("BANK_FIELDS"), fields: import_zod5.z.array(InstructionFieldSchema).min(1) }),
4271
+ wallet,
4272
+ orders: import_zod5.z.array(FiatStepResponseSchema).max(BANK_TRANSFER_MAX_LISTED_ORDERS),
4273
+ retryAfterMs: retryAfterMs2
4274
+ });
4275
+ var orderPendingNextAction2 = obj5({
4276
+ next: import_zod5.z.literal("orderPending"),
4277
+ orderId,
4278
+ retryAfterMs: retryAfterMs2,
4279
+ poll: OrderPollSchema.optional(),
4280
+ order: FiatStepResponseSchema
4281
+ });
4282
+ var checkConsent4 = (nextAction, context2) => {
4283
+ if (!hasUniqueIds5(nextAction.documents.map((document) => document.id))) {
4284
+ context2.addIssue({ code: "custom", path: ["documents"], message: "document ids must be unique" });
4285
+ }
4286
+ };
4287
+ var checkBankDetails = (nextAction, context2) => {
4288
+ if (!hasUniqueIds5(nextAction.instructions.fields.map((field) => field.id))) {
4289
+ context2.addIssue({ code: "custom", path: ["instructions", "fields"], message: "field ids must be unique" });
4290
+ }
4291
+ };
4292
+ var BankTransferConsentNextActionSchema = consentShape2.superRefine(checkConsent4);
4293
+ var BankTransferCaptureNextActionSchema = captureNextAction;
4294
+ var BankTransferWaitNextActionSchema = waitNextAction2;
4295
+ var BankTransferOpenDepositInstructionsNextActionSchema = openDepositInstructionsNextAction;
4296
+ var BankTransferBankDetailsNextActionSchema = bankDetailsShape.superRefine(checkBankDetails);
4297
+ var BankTransferOrderPendingNextActionSchema = orderPendingNextAction2.superRefine(checkOrderPendingPoll);
4298
+ var checkNextAction4 = (response, context2) => {
4299
+ checkOrderPendingPoll(response, context2);
4300
+ if (response.next === "consent") checkConsent4(response, context2);
4301
+ if (response.next === "bankDetails") checkBankDetails(response, context2);
4302
+ };
4303
+ var stepNextActions = [consentShape2, captureNextAction, waitNextAction2, openDepositInstructionsNextAction, bankDetailsShape];
4304
+ var anyNextAction2 = import_zod5.z.discriminatedUnion("next", [...stepNextActions, orderPendingNextAction2]).superRefine(checkNextAction4);
4305
+ var BankTransferNextActionSchema = anyNextAction2;
4306
+ var done2 = obj5({ next: import_zod5.z.literal("done"), order: FiatStepResponseSchema });
4307
+ var BankTransferDoneSchema = done2;
4308
+ var refused2 = obj5({
4309
+ next: import_zod5.z.literal("refused"),
4310
+ reason: import_zod5.z.enum(["NOT_ELIGIBLE", "KYC_REJECTED"]),
4311
+ recovery: import_zod5.z.literal("NONE")
4312
+ });
4313
+ var BankTransferRefusedSchema = refused2;
4314
+ var stepResponse2 = import_zod5.z.discriminatedUnion("next", [...stepNextActions, refused2]).superRefine(checkNextAction4);
4315
+ var BankTransferStepResponseSchema = stepResponse2;
4316
+ var orderResponse2 = import_zod5.z.discriminatedUnion("next", [done2, orderPendingNextAction2]).superRefine(checkOrderPendingPoll);
4317
+ var BankTransferOrderResponseSchema = orderResponse2;
4318
+ var BankTransferResponseSchemaFor = {
4319
+ observe: BankTransferStepResponseSchema,
4320
+ consent: BankTransferStepResponseSchema,
4321
+ capture: BankTransferStepResponseSchema,
4322
+ openDepositInstructions: BankTransferStepResponseSchema,
4323
+ order: BankTransferOrderResponseSchema
4324
+ };
4325
+ var faultFields3 = {
4326
+ reason: import_zod5.z.enum(["RATE_LIMITED", "PROVIDER_UNAVAILABLE", "KYC_PROVIDER_UNAVAILABLE", "SERVICE_UNAVAILABLE", "INVALID_REQUEST"]),
4327
+ recovery: import_zod5.z.enum(["RETRY", "NONE"])
4328
+ };
4329
+ var fault2 = obj5(faultFields3);
4330
+ var BankTransferFaultSchema = fault2;
4331
+ var errorBody2 = obj5({
4332
+ ...faultFields3,
4333
+ errorCode: nonEmpty2,
4334
+ errorMsg: import_zod5.z.string(),
4335
+ reqId: import_zod5.z.string().optional(),
4336
+ retryAfterSeconds: import_zod5.z.number().int().nonnegative().optional()
4337
+ });
4338
+ var BankTransferErrorBodySchema = errorBody2;
4339
+
4340
+ // src/providers/moonpay-guest.schemas.ts
4341
+ var import_zod6 = require("zod");
4342
+ var context = { checkout: MoonPayCheckoutSchema, destinationAsset: DestinationAssetSchema.optional() };
4343
+ var obj6 = (shape) => import_zod6.z.object(shape).strict();
4344
+ var nonEmpty3 = import_zod6.z.string().refine((value) => value.trim().length > 0, "must not be blank");
4184
4345
  var actions = [
4185
- { action: import_zod5.z.literal("observe") },
4186
- { action: import_zod5.z.literal("session") },
4187
- { action: import_zod5.z.literal("consent"), acceptances: import_zod5.z.array(TermsDocumentAcceptanceSchema).min(1).refine((values) => new Set(values.map((v) => v.documentId)).size === values.length, "each document is accepted once") },
4188
- { action: import_zod5.z.literal("order"), orderId: nonEmpty2, quotedAmount: FiatAmountSchema, transactionId: nonEmpty2.optional() },
4189
- { action: import_zod5.z.literal("phone"), phoneNumber: import_zod5.z.string().regex(/^\+[1-9]\d{1,14}$/) },
4190
- { action: import_zod5.z.literal("phone"), resend: nonEmpty2 },
4191
- { action: import_zod5.z.literal("phoneCode"), verificationRef: nonEmpty2, otpCode: import_zod5.z.string().regex(/^\d{6}$/) },
4192
- { action: import_zod5.z.literal("decline"), reason: MoonPayGuestDeclineReasonSchema }
4346
+ { action: import_zod6.z.literal("observe") },
4347
+ { action: import_zod6.z.literal("session") },
4348
+ { action: import_zod6.z.literal("consent"), acceptances: import_zod6.z.array(TermsDocumentAcceptanceSchema).min(1).refine((values) => new Set(values.map((v) => v.documentId)).size === values.length, "each document is accepted once") },
4349
+ { action: import_zod6.z.literal("order"), orderId: nonEmpty3, quotedAmount: FiatAmountSchema, transactionId: nonEmpty3.optional() },
4350
+ { action: import_zod6.z.literal("phone"), phoneNumber: import_zod6.z.string().regex(/^\+[1-9]\d{1,14}$/) },
4351
+ { action: import_zod6.z.literal("phone"), resend: nonEmpty3 },
4352
+ { action: import_zod6.z.literal("phoneCode"), verificationRef: nonEmpty3, otpCode: import_zod6.z.string().regex(/^\d{6}$/) },
4353
+ { action: import_zod6.z.literal("decline"), reason: MoonPayGuestDeclineReasonSchema }
4193
4354
  ];
4194
- var MoonPayGuestObserveRequestSchema = obj5({ ...context, ...actions[0] });
4195
- var MoonPayGuestSessionRequestSchema = obj5({ ...context, ...actions[1] });
4196
- var MoonPayGuestConsentRequestSchema = obj5({ ...context, ...actions[2] });
4197
- var MoonPayGuestOrderRequestSchema = obj5({ ...context, ...actions[3] });
4198
- var MoonPayGuestPhoneNumberRequestSchema = obj5({ ...context, ...actions[4] });
4199
- var MoonPayGuestPhoneResendRequestSchema = obj5({ ...context, ...actions[5] });
4200
- var MoonPayGuestPhoneCodeRequestSchema = obj5({ ...context, ...actions[6] });
4201
- var MoonPayGuestDeclineRequestSchema = obj5({ ...context, ...actions[7] });
4202
- var MoonPayGuestPhoneRequestSchema = import_zod5.z.union([MoonPayGuestPhoneNumberRequestSchema, MoonPayGuestPhoneResendRequestSchema]);
4203
- var MoonPayGuestRequestSchema = import_zod5.z.union([
4355
+ var MoonPayGuestObserveRequestSchema = obj6({ ...context, ...actions[0] });
4356
+ var MoonPayGuestSessionRequestSchema = obj6({ ...context, ...actions[1] });
4357
+ var MoonPayGuestConsentRequestSchema = obj6({ ...context, ...actions[2] });
4358
+ var MoonPayGuestOrderRequestSchema = obj6({ ...context, ...actions[3] });
4359
+ var MoonPayGuestPhoneNumberRequestSchema = obj6({ ...context, ...actions[4] });
4360
+ var MoonPayGuestPhoneResendRequestSchema = obj6({ ...context, ...actions[5] });
4361
+ var MoonPayGuestPhoneCodeRequestSchema = obj6({ ...context, ...actions[6] });
4362
+ var MoonPayGuestDeclineRequestSchema = obj6({ ...context, ...actions[7] });
4363
+ var MoonPayGuestPhoneRequestSchema = import_zod6.z.union([MoonPayGuestPhoneNumberRequestSchema, MoonPayGuestPhoneResendRequestSchema]);
4364
+ var MoonPayGuestRequestSchema = import_zod6.z.union([
4204
4365
  MoonPayGuestObserveRequestSchema,
4205
4366
  MoonPayGuestSessionRequestSchema,
4206
4367
  MoonPayGuestConsentRequestSchema,
@@ -4210,22 +4371,22 @@ var MoonPayGuestRequestSchema = import_zod5.z.union([
4210
4371
  MoonPayGuestPhoneCodeRequestSchema,
4211
4372
  MoonPayGuestDeclineRequestSchema
4212
4373
  ]);
4213
- var MoonPayGuestNextRequestSchema = import_zod5.z.union([
4214
- obj5({ provider: import_zod5.z.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty2.optional(), ...context, ...actions[0] }),
4215
- obj5({ provider: import_zod5.z.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty2.optional(), ...context, ...actions[1] }),
4216
- obj5({ provider: import_zod5.z.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty2.optional(), ...context, ...actions[2] }),
4217
- obj5({ provider: import_zod5.z.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty2.optional(), ...context, ...actions[3] }),
4218
- obj5({ provider: import_zod5.z.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty2.optional(), ...context, ...actions[4] }),
4219
- obj5({ provider: import_zod5.z.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty2.optional(), ...context, ...actions[5] }),
4220
- obj5({ provider: import_zod5.z.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty2.optional(), ...context, ...actions[6] }),
4221
- obj5({ provider: import_zod5.z.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty2.optional(), ...context, ...actions[7] })
4374
+ var MoonPayGuestNextRequestSchema = import_zod6.z.union([
4375
+ obj6({ provider: import_zod6.z.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty3.optional(), ...context, ...actions[0] }),
4376
+ obj6({ provider: import_zod6.z.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty3.optional(), ...context, ...actions[1] }),
4377
+ obj6({ provider: import_zod6.z.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty3.optional(), ...context, ...actions[2] }),
4378
+ obj6({ provider: import_zod6.z.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty3.optional(), ...context, ...actions[3] }),
4379
+ obj6({ provider: import_zod6.z.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty3.optional(), ...context, ...actions[4] }),
4380
+ obj6({ provider: import_zod6.z.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty3.optional(), ...context, ...actions[5] }),
4381
+ obj6({ provider: import_zod6.z.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty3.optional(), ...context, ...actions[6] }),
4382
+ obj6({ provider: import_zod6.z.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty3.optional(), ...context, ...actions[7] })
4222
4383
  ]);
4223
- var MoonPayGuestStepResponseSchema = import_zod5.z.union([
4384
+ var MoonPayGuestStepResponseSchema = import_zod6.z.union([
4224
4385
  MoonPayConsentNextActionSchema,
4225
4386
  MoonPaySessionNextActionSchema,
4226
4387
  MoonPayPhoneNextActionSchema,
4227
4388
  MoonPayPhoneCodeNextActionSchema,
4228
4389
  MoonPayPayNextActionSchema,
4229
- obj5({ next: import_zod5.z.literal("refused"), reason: import_zod5.z.enum(["NOT_ELIGIBLE", "FINAL_REJECTION"]), recovery: import_zod5.z.enum(["REQUOTE", "NONE"]) })
4390
+ obj6({ next: import_zod6.z.literal("refused"), reason: import_zod6.z.enum(["NOT_ELIGIBLE", "FINAL_REJECTION"]), recovery: import_zod6.z.enum(["REQUOTE", "NONE"]) })
4230
4391
  ]);
4231
- var MoonPayGuestResponseSchema = import_zod5.z.union([MoonPayGuestStepResponseSchema, MoonPayOrderResponseSchema]);
4392
+ var MoonPayGuestResponseSchema = import_zod6.z.union([MoonPayGuestStepResponseSchema, MoonPayOrderResponseSchema]);
package/dist/index.mjs CHANGED
@@ -1,3 +1,10 @@
1
+ import {
2
+ FIAT_TERMS_ENDPOINT,
3
+ FUN_KYC_CONSENT_DOCUMENTS,
4
+ PROVIDER_CHECKOUT_DOCUMENTS,
5
+ PROVIDER_KYC_DOCUMENTS,
6
+ PUBLISHED_TERMS_DOCUMENTS
7
+ } from "./chunk-TIQALG7X.mjs";
1
8
  import {
2
9
  ROUTING_ENDPOINTS
3
10
  } from "./chunk-2NZSOZHV.mjs";
@@ -16,7 +23,7 @@ import {
16
23
  tableEntry,
17
24
  unofferedEndpoints,
18
25
  unreachableStates
19
- } from "./chunk-T45SRB5E.mjs";
26
+ } from "./chunk-5VDSEEKQ.mjs";
20
27
  import {
21
28
  MOONPAY_ENDPOINTS
22
29
  } from "./chunk-TIEGTTFY.mjs";
@@ -29,12 +36,9 @@ import {
29
36
  STRIPE_ENDPOINTS
30
37
  } from "./chunk-KLAXY6H7.mjs";
31
38
  import {
32
- FIAT_TERMS_ENDPOINT,
33
- FUN_KYC_CONSENT_DOCUMENTS,
34
- PROVIDER_CHECKOUT_DOCUMENTS,
35
- PROVIDER_KYC_DOCUMENTS,
36
- PUBLISHED_TERMS_DOCUMENTS
37
- } from "./chunk-TIQALG7X.mjs";
39
+ BANK_TRANSFER_ENDPOINTS,
40
+ BANK_TRANSFER_MAX_LISTED_ORDERS
41
+ } from "./chunk-MEL2ZOQ5.mjs";
38
42
 
39
43
  // src/codes.ts
40
44
  var US_STATE_CODES = [
@@ -418,7 +422,8 @@ var $provider = z.enum([
418
422
  "MOONPAY_GUEST",
419
423
  "STRIPE",
420
424
  "COINBASE",
421
- "CROSSMINT"
425
+ "CROSSMINT",
426
+ "ALCHEMYPAY"
422
427
  ]);
423
428
  var FiatProviderSchema = $provider;
424
429
  var $kycProvider = z.enum(["SUMSUB"]);
@@ -755,12 +760,12 @@ var OrderPollSchema = obj({
755
760
  giveUpAfterMs: z.number().int().positive().max(60 * 60 * 1e3)
756
761
  });
757
762
  function checkOrderPendingPoll(response, context2) {
758
- const { poll, retryAfterMs: retryAfterMs2 } = response;
759
- if (response.next !== "orderPending" || poll === void 0 || retryAfterMs2 === void 0) return;
760
- if (retryAfterMs2 < MIN_INTERVAL_MS) {
763
+ const { poll, retryAfterMs: retryAfterMs3 } = response;
764
+ if (response.next !== "orderPending" || poll === void 0 || retryAfterMs3 === void 0) return;
765
+ if (retryAfterMs3 < MIN_INTERVAL_MS) {
761
766
  context2.addIssue({ code: "custom", path: ["retryAfterMs"], message: `retryAfterMs must be at least ${MIN_INTERVAL_MS} with a poll` });
762
767
  }
763
- if (poll.maxIntervalMs < retryAfterMs2) {
768
+ if (poll.maxIntervalMs < retryAfterMs3) {
764
769
  context2.addIssue({ code: "custom", path: ["poll", "maxIntervalMs"], message: "maxIntervalMs must be at least retryAfterMs" });
765
770
  }
766
771
  }
@@ -1028,7 +1033,7 @@ var compareDecimals = (left, right) => {
1028
1033
  return leftDigits < rightDigits ? -1 : leftDigits > rightDigits ? 1 : 0;
1029
1034
  };
1030
1035
  var $countryCode = z.enum(Object.keys(CountryCode));
1031
- var $routingProvider = $provider.extract(["TRANSAK", "BANXA", "MOONPAY", "MOONPAY_GUEST", "STRIPE", "COINBASE"]);
1036
+ var $routingProvider = $provider.extract(["TRANSAK", "BANXA", "MOONPAY", "MOONPAY_GUEST", "STRIPE", "COINBASE", "ALCHEMYPAY"]);
1032
1037
  var $optionalGeoField = z.union([$nonBlank, z.literal("")]).optional();
1033
1038
  var US_REGION_REQUIRED = "a US buyer needs a US state code as region";
1034
1039
  var hasUsRegion = (country, region) => country !== "US" || UsStateCodeSchema.safeParse(region).success;
@@ -1046,7 +1051,7 @@ var $routingTableRequest = obj({
1046
1051
  providers: $routingTableProviderInputs.optional(),
1047
1052
  destinationAsset: $destinationAsset.optional(),
1048
1053
  depositAddress: $nonBlank.optional()
1049
- }).refine((request2) => hasUsRegion(request2.country, request2.region), { message: US_REGION_REQUIRED, path: ["region"] });
1054
+ }).refine((request3) => hasUsRegion(request3.country, request3.region), { message: US_REGION_REQUIRED, path: ["region"] });
1050
1055
  var FiatRoutingTableRequestSchema = $routingTableRequest;
1051
1056
  var $routingTableProvider = obj({
1052
1057
  provider: $routingProvider,
@@ -1104,9 +1109,9 @@ var $routingQuoteRequest = z.union([
1104
1109
  }),
1105
1110
  obj({ ...$routingQuoteTermsShape, provider: $routingProvider })
1106
1111
  ]).refine(
1107
- (request2) => {
1108
- const allowed = request2.routingOverrides?.providers;
1109
- const selected = "providers" in request2 ? request2.providers : [request2.provider];
1112
+ (request3) => {
1113
+ const allowed = request3.routingOverrides?.providers;
1114
+ const selected = "providers" in request3 ? request3.providers : [request3.provider];
1110
1115
  return allowed === void 0 || selected.every((provider) => allowed.includes(provider));
1111
1116
  },
1112
1117
  { message: "requested providers must be allowed by routingOverrides", path: ["routingOverrides"] }
@@ -2557,14 +2562,14 @@ function walkTable(fn) {
2557
2562
  function assertFixture(id) {
2558
2563
  const meta = fixtureMeta(id);
2559
2564
  const json = loadFixture(id);
2560
- const stepResponse2 = assertFiatStepResponse(json);
2561
- if (stateKey(stepResponse2.state) !== meta.stateKey) {
2565
+ const stepResponse3 = assertFiatStepResponse(json);
2566
+ if (stateKey(stepResponse3.state) !== meta.stateKey) {
2562
2567
  throw new ContractViolation(
2563
- `fixture ${id}: manifest says ${meta.stateKey}, step response carries ${stateKey(stepResponse2.state)}`
2568
+ `fixture ${id}: manifest says ${meta.stateKey}, step response carries ${stateKey(stepResponse3.state)}`
2564
2569
  );
2565
2570
  }
2566
- assertLegalEmission(stepResponse2.state, stepResponse2.transitions);
2567
- return { meta, stepResponse: stepResponse2 };
2571
+ assertLegalEmission(stepResponse3.state, stepResponse3.transitions);
2572
+ return { meta, stepResponse: stepResponse3 };
2568
2573
  }
2569
2574
  function assertAllFixtures() {
2570
2575
  return FIXTURES.map((meta) => assertFixture(meta.id));
@@ -3107,7 +3112,8 @@ var kycShape = obj4({
3107
3112
  verifiedEmail: nonEmpty.nullable(),
3108
3113
  linkAuthToken: linkAuthToken.nullable(),
3109
3114
  fieldErrors: z4.array(obj4({ fieldId: nonEmpty, message: nonEmpty })).min(1).optional(),
3110
- reask: reask.nullable()
3115
+ reask: reask.nullable(),
3116
+ paymentSheetFirst: z4.boolean()
3111
3117
  });
3112
3118
  var identifiersNextAction = obj4({ next: z4.literal("identifiers"), linkAuthToken: linkAuthToken.nullable() });
3113
3119
  var attestationNextAction = obj4({ next: z4.literal("attestation"), linkAuthToken: linkAuthToken.nullable() });
@@ -3157,6 +3163,10 @@ var checkKyc3 = (nextAction, context2) => {
3157
3163
  if (nextAction.tier === "l2" && nextAction.round !== "IDENTITY") {
3158
3164
  context2.addIssue({ code: "custom", path: ["tier"], message: "l2 is an identity round" });
3159
3165
  }
3166
+ const firstAsk = nextAction.tier === "l0" && nextAction.correctionRound === 0 && nextAction.reask === null && !nextAction.fieldErrors;
3167
+ if (nextAction.paymentSheetFirst && !firstAsk) {
3168
+ context2.addIssue({ code: "custom", path: ["paymentSheetFirst"], message: "only a first ask at l0 opens the payment sheet first" });
3169
+ }
3160
3170
  };
3161
3171
  var checkPlaceOrder = (nextAction, context2) => {
3162
3172
  if (nextAction.paySheet.amount !== nextAction.price.total.amount) {
@@ -3246,31 +3256,155 @@ var errorBody = obj4({
3246
3256
  });
3247
3257
  var StripeErrorBodySchema = errorBody;
3248
3258
 
3249
- // src/providers/moonpay-guest.schemas.ts
3259
+ // src/flows/bank-transfer.schemas.ts
3250
3260
  import { z as z5 } from "zod";
3251
- var context = { checkout: MoonPayCheckoutSchema, destinationAsset: DestinationAssetSchema.optional() };
3252
3261
  var obj5 = (shape) => z5.object(shape).strict();
3253
3262
  var nonEmpty2 = z5.string().refine((value) => value.trim().length > 0, "must not be blank");
3263
+ var hasUniqueIds5 = (ids) => new Set(ids).size === ids.length;
3264
+ var retryAfterMs2 = z5.number().int().positive().max(6e4);
3265
+ var instant2 = z5.string().datetime({ offset: true });
3266
+ var orderId = z5.string().regex(/^bto_[A-Za-z0-9_-]{22}$/, "must be an order id bankDetails listed");
3267
+ var fiatCurrency = z5.enum(Object.keys(FIAT_CURRENCY_NAMES));
3268
+ var checkout2 = obj5({
3269
+ currency: fiatCurrency,
3270
+ destination: obj5({ asset: nonEmpty2, network: nonEmpty2 }),
3271
+ paymentMethod: z5.literal("bank_transfer")
3272
+ });
3273
+ var BankTransferCheckoutSchema = checkout2;
3274
+ var contextFields3 = { checkout: checkout2 };
3275
+ var requestContext2 = obj5(contextFields3);
3276
+ var BankTransferRequestContextSchema = requestContext2;
3277
+ var observeFields3 = { action: z5.literal("observe") };
3278
+ var consentFields3 = {
3279
+ action: z5.literal("consent"),
3280
+ acceptances: z5.array(TermsDocumentAcceptanceSchema).min(1).refine((acceptances) => hasUniqueIds5(acceptances.map((acceptance) => acceptance.documentId)), "each document is accepted once")
3281
+ };
3282
+ var captureFields = { action: z5.literal("capture"), result: KycSdkResultReportSchema };
3283
+ var openDepositInstructionsFields = { action: z5.literal("openDepositInstructions"), walletConfirmed: z5.literal(true), walletAddress: nonEmpty2 };
3284
+ var orderFields3 = { action: z5.literal("order"), orderId };
3285
+ var observeRequest2 = obj5({ ...contextFields3, ...observeFields3 });
3286
+ var consentRequest2 = obj5({ ...contextFields3, ...consentFields3 });
3287
+ var captureRequest = obj5({ ...contextFields3, ...captureFields });
3288
+ var openDepositInstructionsRequest = obj5({ ...contextFields3, ...openDepositInstructionsFields });
3289
+ var orderRequest2 = obj5({ ...contextFields3, ...orderFields3 });
3290
+ var BankTransferObserveRequestSchema = observeRequest2;
3291
+ var BankTransferConsentRequestSchema = consentRequest2;
3292
+ var BankTransferCaptureRequestSchema = captureRequest;
3293
+ var BankTransferOpenDepositInstructionsRequestSchema = openDepositInstructionsRequest;
3294
+ var BankTransferOrderRequestSchema = orderRequest2;
3295
+ var request2 = z5.discriminatedUnion("action", [observeRequest2, consentRequest2, captureRequest, openDepositInstructionsRequest, orderRequest2]);
3296
+ var BankTransferRequestSchema = request2;
3297
+ var envelope3 = { provider: FiatProviderSchema, geo: FiatGeoSchema, ...contextFields3 };
3298
+ var nextRequest2 = z5.discriminatedUnion("action", [
3299
+ obj5({ ...envelope3, ...observeFields3 }),
3300
+ obj5({ ...envelope3, ...consentFields3 }),
3301
+ obj5({ ...envelope3, ...captureFields }),
3302
+ obj5({ ...envelope3, ...openDepositInstructionsFields }),
3303
+ obj5({ ...envelope3, ...orderFields3 })
3304
+ ]);
3305
+ var BankTransferNextRequestSchema = nextRequest2;
3306
+ var wallet = obj5({ address: nonEmpty2, network: nonEmpty2, asset: nonEmpty2 });
3307
+ var consentShape2 = obj5({ next: z5.literal("consent"), documents: z5.array(TermsDocumentSchema).min(1) });
3308
+ var captureNextAction = obj5({ next: z5.literal("capture"), kycProvider: KYCProviderSchema, accessToken: nonEmpty2, expiresAt: instant2 });
3309
+ var waitNextAction2 = obj5({ next: z5.literal("wait"), retryAfterMs: retryAfterMs2 });
3310
+ var openDepositInstructionsNextAction = obj5({ next: z5.literal("openDepositInstructions"), wallet, attestationText: nonEmpty2 });
3311
+ var bankDetailsShape = obj5({
3312
+ next: z5.literal("bankDetails"),
3313
+ instructions: obj5({ kind: z5.literal("BANK_FIELDS"), fields: z5.array(InstructionFieldSchema).min(1) }),
3314
+ wallet,
3315
+ orders: z5.array(FiatStepResponseSchema).max(BANK_TRANSFER_MAX_LISTED_ORDERS),
3316
+ retryAfterMs: retryAfterMs2
3317
+ });
3318
+ var orderPendingNextAction2 = obj5({
3319
+ next: z5.literal("orderPending"),
3320
+ orderId,
3321
+ retryAfterMs: retryAfterMs2,
3322
+ poll: OrderPollSchema.optional(),
3323
+ order: FiatStepResponseSchema
3324
+ });
3325
+ var checkConsent4 = (nextAction, context2) => {
3326
+ if (!hasUniqueIds5(nextAction.documents.map((document) => document.id))) {
3327
+ context2.addIssue({ code: "custom", path: ["documents"], message: "document ids must be unique" });
3328
+ }
3329
+ };
3330
+ var checkBankDetails = (nextAction, context2) => {
3331
+ if (!hasUniqueIds5(nextAction.instructions.fields.map((field) => field.id))) {
3332
+ context2.addIssue({ code: "custom", path: ["instructions", "fields"], message: "field ids must be unique" });
3333
+ }
3334
+ };
3335
+ var BankTransferConsentNextActionSchema = consentShape2.superRefine(checkConsent4);
3336
+ var BankTransferCaptureNextActionSchema = captureNextAction;
3337
+ var BankTransferWaitNextActionSchema = waitNextAction2;
3338
+ var BankTransferOpenDepositInstructionsNextActionSchema = openDepositInstructionsNextAction;
3339
+ var BankTransferBankDetailsNextActionSchema = bankDetailsShape.superRefine(checkBankDetails);
3340
+ var BankTransferOrderPendingNextActionSchema = orderPendingNextAction2.superRefine(checkOrderPendingPoll);
3341
+ var checkNextAction4 = (response, context2) => {
3342
+ checkOrderPendingPoll(response, context2);
3343
+ if (response.next === "consent") checkConsent4(response, context2);
3344
+ if (response.next === "bankDetails") checkBankDetails(response, context2);
3345
+ };
3346
+ var stepNextActions = [consentShape2, captureNextAction, waitNextAction2, openDepositInstructionsNextAction, bankDetailsShape];
3347
+ var anyNextAction2 = z5.discriminatedUnion("next", [...stepNextActions, orderPendingNextAction2]).superRefine(checkNextAction4);
3348
+ var BankTransferNextActionSchema = anyNextAction2;
3349
+ var done2 = obj5({ next: z5.literal("done"), order: FiatStepResponseSchema });
3350
+ var BankTransferDoneSchema = done2;
3351
+ var refused2 = obj5({
3352
+ next: z5.literal("refused"),
3353
+ reason: z5.enum(["NOT_ELIGIBLE", "KYC_REJECTED"]),
3354
+ recovery: z5.literal("NONE")
3355
+ });
3356
+ var BankTransferRefusedSchema = refused2;
3357
+ var stepResponse2 = z5.discriminatedUnion("next", [...stepNextActions, refused2]).superRefine(checkNextAction4);
3358
+ var BankTransferStepResponseSchema = stepResponse2;
3359
+ var orderResponse2 = z5.discriminatedUnion("next", [done2, orderPendingNextAction2]).superRefine(checkOrderPendingPoll);
3360
+ var BankTransferOrderResponseSchema = orderResponse2;
3361
+ var BankTransferResponseSchemaFor = {
3362
+ observe: BankTransferStepResponseSchema,
3363
+ consent: BankTransferStepResponseSchema,
3364
+ capture: BankTransferStepResponseSchema,
3365
+ openDepositInstructions: BankTransferStepResponseSchema,
3366
+ order: BankTransferOrderResponseSchema
3367
+ };
3368
+ var faultFields3 = {
3369
+ reason: z5.enum(["RATE_LIMITED", "PROVIDER_UNAVAILABLE", "KYC_PROVIDER_UNAVAILABLE", "SERVICE_UNAVAILABLE", "INVALID_REQUEST"]),
3370
+ recovery: z5.enum(["RETRY", "NONE"])
3371
+ };
3372
+ var fault2 = obj5(faultFields3);
3373
+ var BankTransferFaultSchema = fault2;
3374
+ var errorBody2 = obj5({
3375
+ ...faultFields3,
3376
+ errorCode: nonEmpty2,
3377
+ errorMsg: z5.string(),
3378
+ reqId: z5.string().optional(),
3379
+ retryAfterSeconds: z5.number().int().nonnegative().optional()
3380
+ });
3381
+ var BankTransferErrorBodySchema = errorBody2;
3382
+
3383
+ // src/providers/moonpay-guest.schemas.ts
3384
+ import { z as z6 } from "zod";
3385
+ var context = { checkout: MoonPayCheckoutSchema, destinationAsset: DestinationAssetSchema.optional() };
3386
+ var obj6 = (shape) => z6.object(shape).strict();
3387
+ var nonEmpty3 = z6.string().refine((value) => value.trim().length > 0, "must not be blank");
3254
3388
  var actions = [
3255
- { action: z5.literal("observe") },
3256
- { action: z5.literal("session") },
3257
- { action: z5.literal("consent"), acceptances: z5.array(TermsDocumentAcceptanceSchema).min(1).refine((values) => new Set(values.map((v) => v.documentId)).size === values.length, "each document is accepted once") },
3258
- { action: z5.literal("order"), orderId: nonEmpty2, quotedAmount: FiatAmountSchema, transactionId: nonEmpty2.optional() },
3259
- { action: z5.literal("phone"), phoneNumber: z5.string().regex(/^\+[1-9]\d{1,14}$/) },
3260
- { action: z5.literal("phone"), resend: nonEmpty2 },
3261
- { action: z5.literal("phoneCode"), verificationRef: nonEmpty2, otpCode: z5.string().regex(/^\d{6}$/) },
3262
- { action: z5.literal("decline"), reason: MoonPayGuestDeclineReasonSchema }
3389
+ { action: z6.literal("observe") },
3390
+ { action: z6.literal("session") },
3391
+ { action: z6.literal("consent"), acceptances: z6.array(TermsDocumentAcceptanceSchema).min(1).refine((values) => new Set(values.map((v) => v.documentId)).size === values.length, "each document is accepted once") },
3392
+ { action: z6.literal("order"), orderId: nonEmpty3, quotedAmount: FiatAmountSchema, transactionId: nonEmpty3.optional() },
3393
+ { action: z6.literal("phone"), phoneNumber: z6.string().regex(/^\+[1-9]\d{1,14}$/) },
3394
+ { action: z6.literal("phone"), resend: nonEmpty3 },
3395
+ { action: z6.literal("phoneCode"), verificationRef: nonEmpty3, otpCode: z6.string().regex(/^\d{6}$/) },
3396
+ { action: z6.literal("decline"), reason: MoonPayGuestDeclineReasonSchema }
3263
3397
  ];
3264
- var MoonPayGuestObserveRequestSchema = obj5({ ...context, ...actions[0] });
3265
- var MoonPayGuestSessionRequestSchema = obj5({ ...context, ...actions[1] });
3266
- var MoonPayGuestConsentRequestSchema = obj5({ ...context, ...actions[2] });
3267
- var MoonPayGuestOrderRequestSchema = obj5({ ...context, ...actions[3] });
3268
- var MoonPayGuestPhoneNumberRequestSchema = obj5({ ...context, ...actions[4] });
3269
- var MoonPayGuestPhoneResendRequestSchema = obj5({ ...context, ...actions[5] });
3270
- var MoonPayGuestPhoneCodeRequestSchema = obj5({ ...context, ...actions[6] });
3271
- var MoonPayGuestDeclineRequestSchema = obj5({ ...context, ...actions[7] });
3272
- var MoonPayGuestPhoneRequestSchema = z5.union([MoonPayGuestPhoneNumberRequestSchema, MoonPayGuestPhoneResendRequestSchema]);
3273
- var MoonPayGuestRequestSchema = z5.union([
3398
+ var MoonPayGuestObserveRequestSchema = obj6({ ...context, ...actions[0] });
3399
+ var MoonPayGuestSessionRequestSchema = obj6({ ...context, ...actions[1] });
3400
+ var MoonPayGuestConsentRequestSchema = obj6({ ...context, ...actions[2] });
3401
+ var MoonPayGuestOrderRequestSchema = obj6({ ...context, ...actions[3] });
3402
+ var MoonPayGuestPhoneNumberRequestSchema = obj6({ ...context, ...actions[4] });
3403
+ var MoonPayGuestPhoneResendRequestSchema = obj6({ ...context, ...actions[5] });
3404
+ var MoonPayGuestPhoneCodeRequestSchema = obj6({ ...context, ...actions[6] });
3405
+ var MoonPayGuestDeclineRequestSchema = obj6({ ...context, ...actions[7] });
3406
+ var MoonPayGuestPhoneRequestSchema = z6.union([MoonPayGuestPhoneNumberRequestSchema, MoonPayGuestPhoneResendRequestSchema]);
3407
+ var MoonPayGuestRequestSchema = z6.union([
3274
3408
  MoonPayGuestObserveRequestSchema,
3275
3409
  MoonPayGuestSessionRequestSchema,
3276
3410
  MoonPayGuestConsentRequestSchema,
@@ -3280,26 +3414,51 @@ var MoonPayGuestRequestSchema = z5.union([
3280
3414
  MoonPayGuestPhoneCodeRequestSchema,
3281
3415
  MoonPayGuestDeclineRequestSchema
3282
3416
  ]);
3283
- var MoonPayGuestNextRequestSchema = z5.union([
3284
- obj5({ provider: z5.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty2.optional(), ...context, ...actions[0] }),
3285
- obj5({ provider: z5.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty2.optional(), ...context, ...actions[1] }),
3286
- obj5({ provider: z5.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty2.optional(), ...context, ...actions[2] }),
3287
- obj5({ provider: z5.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty2.optional(), ...context, ...actions[3] }),
3288
- obj5({ provider: z5.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty2.optional(), ...context, ...actions[4] }),
3289
- obj5({ provider: z5.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty2.optional(), ...context, ...actions[5] }),
3290
- obj5({ provider: z5.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty2.optional(), ...context, ...actions[6] }),
3291
- obj5({ provider: z5.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty2.optional(), ...context, ...actions[7] })
3417
+ var MoonPayGuestNextRequestSchema = z6.union([
3418
+ obj6({ provider: z6.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty3.optional(), ...context, ...actions[0] }),
3419
+ obj6({ provider: z6.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty3.optional(), ...context, ...actions[1] }),
3420
+ obj6({ provider: z6.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty3.optional(), ...context, ...actions[2] }),
3421
+ obj6({ provider: z6.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty3.optional(), ...context, ...actions[3] }),
3422
+ obj6({ provider: z6.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty3.optional(), ...context, ...actions[4] }),
3423
+ obj6({ provider: z6.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty3.optional(), ...context, ...actions[5] }),
3424
+ obj6({ provider: z6.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty3.optional(), ...context, ...actions[6] }),
3425
+ obj6({ provider: z6.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty3.optional(), ...context, ...actions[7] })
3292
3426
  ]);
3293
- var MoonPayGuestStepResponseSchema = z5.union([
3427
+ var MoonPayGuestStepResponseSchema = z6.union([
3294
3428
  MoonPayConsentNextActionSchema,
3295
3429
  MoonPaySessionNextActionSchema,
3296
3430
  MoonPayPhoneNextActionSchema,
3297
3431
  MoonPayPhoneCodeNextActionSchema,
3298
3432
  MoonPayPayNextActionSchema,
3299
- obj5({ next: z5.literal("refused"), reason: z5.enum(["NOT_ELIGIBLE", "FINAL_REJECTION"]), recovery: z5.enum(["REQUOTE", "NONE"]) })
3433
+ obj6({ next: z6.literal("refused"), reason: z6.enum(["NOT_ELIGIBLE", "FINAL_REJECTION"]), recovery: z6.enum(["REQUOTE", "NONE"]) })
3300
3434
  ]);
3301
- var MoonPayGuestResponseSchema = z5.union([MoonPayGuestStepResponseSchema, MoonPayOrderResponseSchema]);
3435
+ var MoonPayGuestResponseSchema = z6.union([MoonPayGuestStepResponseSchema, MoonPayOrderResponseSchema]);
3302
3436
  export {
3437
+ BANK_TRANSFER_ENDPOINTS,
3438
+ BANK_TRANSFER_MAX_LISTED_ORDERS,
3439
+ BankTransferBankDetailsNextActionSchema,
3440
+ BankTransferCaptureNextActionSchema,
3441
+ BankTransferCaptureRequestSchema,
3442
+ BankTransferCheckoutSchema,
3443
+ BankTransferConsentNextActionSchema,
3444
+ BankTransferConsentRequestSchema,
3445
+ BankTransferDoneSchema,
3446
+ BankTransferErrorBodySchema,
3447
+ BankTransferFaultSchema,
3448
+ BankTransferNextActionSchema,
3449
+ BankTransferNextRequestSchema,
3450
+ BankTransferObserveRequestSchema,
3451
+ BankTransferOpenDepositInstructionsNextActionSchema,
3452
+ BankTransferOpenDepositInstructionsRequestSchema,
3453
+ BankTransferOrderPendingNextActionSchema,
3454
+ BankTransferOrderRequestSchema,
3455
+ BankTransferOrderResponseSchema,
3456
+ BankTransferRefusedSchema,
3457
+ BankTransferRequestContextSchema,
3458
+ BankTransferRequestSchema,
3459
+ BankTransferResponseSchemaFor,
3460
+ BankTransferStepResponseSchema,
3461
+ BankTransferWaitNextActionSchema,
3303
3462
  BlockedReasonSchema,
3304
3463
  BlockedStateSchema,
3305
3464
  COINBASE_ENDPOINTS,
@@ -114,6 +114,11 @@ export type StripeReask = {
114
114
  * An EU buyer gets `round: 'IDENTITY'`, `tier: 'l2'`: Stripe reads `l0` and `l1` as not available there. Its fields add
115
115
  * `NATIONALITY`, `CITY_OF_BIRTH` and `COUNTRY_OF_BIRTH`, which the device passes to `attachKycInfo`. The backend sends
116
116
  * `l2`, `identifiers` and `attestation` only for an EUR checkout, so a client that sends only USD never gets them.
117
+ *
118
+ * `paymentSheetFirst`: open the Apple Pay sheet before this form, and answer the form from the sheet's contact. Only a
119
+ * first ask at `l0` (`correctionRound` 0, no `reask`, no `fieldErrors`) sets it. The backend decides it per buyer, so a
120
+ * client opens the sheet first only when it is `true`. A backend before 0.56.1 sends none; a client may then keep its
121
+ * own first-ask rule.
117
122
  */
118
123
  export type StripeKycNextAction = {
119
124
  next: 'kyc';
@@ -126,6 +131,7 @@ export type StripeKycNextAction = {
126
131
  linkAuthToken: StripeLinkAuthToken | null;
127
132
  fieldErrors?: StripeFieldError[];
128
133
  reask: StripeReask | null;
134
+ paymentSheetFirst: boolean;
129
135
  };
130
136
  /**
131
137
  * `values` is keyed by the ids of the next action's fields: the values the device gave Stripe. `correctionRound` is the
package/dist/routing.d.ts CHANGED
@@ -81,7 +81,7 @@ export type RoutingVisibility = 'COMPLETE' | 'PARTIAL' | 'AUTH_GATED';
81
81
  */
82
82
  export type RoutingUnavailableReason = 'USER_LIMIT' | 'KYC_REJECTED' | 'PROVIDER_OUTAGE' | 'NOT_SERVED';
83
83
  /** The providers the backend can route and take an order through. */
84
- export type RoutingProvider = Extract<FiatProvider, 'TRANSAK' | 'BANXA' | 'MOONPAY' | 'MOONPAY_GUEST' | 'STRIPE' | 'COINBASE'>;
84
+ export type RoutingProvider = Extract<FiatProvider, 'TRANSAK' | 'BANXA' | 'MOONPAY' | 'MOONPAY_GUEST' | 'STRIPE' | 'COINBASE' | 'ALCHEMYPAY'>;
85
85
  export interface RoutingTableProvider {
86
86
  provider: RoutingProvider;
87
87
  next: RoutingNextStep;
package/dist/table.js CHANGED
@@ -37,7 +37,7 @@ __export(table_exports, {
37
37
  module.exports = __toCommonJS(table_exports);
38
38
 
39
39
  // package.json
40
- var version = "0.56.0";
40
+ var version = "0.59.0";
41
41
 
42
42
  // src/table.ts
43
43
  var TABLE_VERSION = version;
package/dist/table.mjs CHANGED
@@ -12,7 +12,7 @@ import {
12
12
  tableEntry,
13
13
  unofferedEndpoints,
14
14
  unreachableStates
15
- } from "./chunk-T45SRB5E.mjs";
15
+ } from "./chunk-5VDSEEKQ.mjs";
16
16
  export {
17
17
  DOCUMENTED_ENDPOINTS,
18
18
  FUN_AUTH_ERROR_CODES,
package/dist/types.d.ts CHANGED
@@ -61,7 +61,7 @@ export type FiatEndpoint = 'GET /fiat/payment-methods' | 'POST /fiat/quote' | 'P
61
61
  * Routing metadata, not sequencing policy. Reserved values may be emitted only after their adapter
62
62
  * and conformance fixture land.
63
63
  */
64
- export type FiatProvider = 'TRANSAK' | 'SWAPPED' | 'BANXA' | 'MOONPAY' | 'MOONPAY_GUEST' | 'STRIPE' | 'COINBASE' | 'CROSSMINT';
64
+ export type FiatProvider = 'TRANSAK' | 'SWAPPED' | 'BANXA' | 'MOONPAY' | 'MOONPAY_GUEST' | 'STRIPE' | 'COINBASE' | 'CROSSMINT' | 'ALCHEMYPAY';
65
65
  /**
66
66
  * The order status vocabulary. Monotonic ranks, no backwards moves. Terminal outcomes are
67
67
  * OrderStatus, never FlowState kinds.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fun-xyz/fiat-contract",
3
- "version": "0.56.0",
3
+ "version": "0.59.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": {
@@ -58,6 +58,11 @@
58
58
  "types": "./dist/providers/moonpay-guest.d.ts",
59
59
  "import": "./dist/providers/moonpay-guest.mjs",
60
60
  "require": "./dist/providers/moonpay-guest.js"
61
+ },
62
+ "./bank-transfer": {
63
+ "types": "./dist/flows/bank-transfer.d.ts",
64
+ "import": "./dist/flows/bank-transfer.mjs",
65
+ "require": "./dist/flows/bank-transfer.js"
61
66
  }
62
67
  },
63
68
  "files": [
@@ -75,7 +80,9 @@
75
80
  "terms.js",
76
81
  "terms.d.ts",
77
82
  "routing.js",
78
- "routing.d.ts"
83
+ "routing.d.ts",
84
+ "bank-transfer.js",
85
+ "bank-transfer.d.ts"
79
86
  ],
80
87
  "engines": {
81
88
  "node": ">=18"
@@ -131,6 +138,9 @@
131
138
  ],
132
139
  "moonpay-guest": [
133
140
  "./dist/providers/moonpay-guest.d.ts"
141
+ ],
142
+ "bank-transfer": [
143
+ "./dist/flows/bank-transfer.d.ts"
134
144
  ]
135
145
  }
136
146
  }