@fun-xyz/fiat-contract 0.56.0-alchemypay.0 → 0.58.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/bank-transfer.d.ts +1 -0
- package/bank-transfer.js +2 -0
- package/dist/chunk-MEL2ZOQ5.mjs +10 -0
- package/dist/{chunk-HPIXK4BM.mjs → chunk-X5HMCOMZ.mjs} +1 -1
- package/dist/flows/bank-transfer.d.ts +183 -0
- package/dist/flows/bank-transfer.js +30 -0
- package/dist/flows/bank-transfer.mjs +8 -0
- package/dist/flows/bank-transfer.schemas.d.ts +32 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +209 -50
- package/dist/index.mjs +213 -56
- package/dist/providers/stripe.d.ts +6 -0
- package/dist/routing.d.ts +1 -1
- package/dist/table.js +1 -1
- package/dist/table.mjs +1 -1
- package/dist/types.d.ts +1 -1
- package/package.json +12 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dist/flows/bank-transfer';
|
package/bank-transfer.js
ADDED
|
@@ -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,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,8 +686,7 @@ var $provider = import_zod.z.enum([
|
|
|
661
686
|
"MOONPAY_GUEST",
|
|
662
687
|
"STRIPE",
|
|
663
688
|
"COINBASE",
|
|
664
|
-
"CROSSMINT"
|
|
665
|
-
"ALCHEMYPAY"
|
|
689
|
+
"CROSSMINT"
|
|
666
690
|
]);
|
|
667
691
|
var FiatProviderSchema = $provider;
|
|
668
692
|
var $kycProvider = import_zod.z.enum(["SUMSUB"]);
|
|
@@ -999,12 +1023,12 @@ var OrderPollSchema = obj({
|
|
|
999
1023
|
giveUpAfterMs: import_zod.z.number().int().positive().max(60 * 60 * 1e3)
|
|
1000
1024
|
});
|
|
1001
1025
|
function checkOrderPendingPoll(response, context2) {
|
|
1002
|
-
const { poll, retryAfterMs:
|
|
1003
|
-
if (response.next !== "orderPending" || poll === void 0 ||
|
|
1004
|
-
if (
|
|
1026
|
+
const { poll, retryAfterMs: retryAfterMs3 } = response;
|
|
1027
|
+
if (response.next !== "orderPending" || poll === void 0 || retryAfterMs3 === void 0) return;
|
|
1028
|
+
if (retryAfterMs3 < MIN_INTERVAL_MS) {
|
|
1005
1029
|
context2.addIssue({ code: "custom", path: ["retryAfterMs"], message: `retryAfterMs must be at least ${MIN_INTERVAL_MS} with a poll` });
|
|
1006
1030
|
}
|
|
1007
|
-
if (poll.maxIntervalMs <
|
|
1031
|
+
if (poll.maxIntervalMs < retryAfterMs3) {
|
|
1008
1032
|
context2.addIssue({ code: "custom", path: ["poll", "maxIntervalMs"], message: "maxIntervalMs must be at least retryAfterMs" });
|
|
1009
1033
|
}
|
|
1010
1034
|
}
|
|
@@ -1272,7 +1296,7 @@ var compareDecimals = (left, right) => {
|
|
|
1272
1296
|
return leftDigits < rightDigits ? -1 : leftDigits > rightDigits ? 1 : 0;
|
|
1273
1297
|
};
|
|
1274
1298
|
var $countryCode = import_zod.z.enum(Object.keys(CountryCode));
|
|
1275
|
-
var $routingProvider = $provider.extract(["TRANSAK", "BANXA", "MOONPAY", "MOONPAY_GUEST", "STRIPE", "COINBASE"
|
|
1299
|
+
var $routingProvider = $provider.extract(["TRANSAK", "BANXA", "MOONPAY", "MOONPAY_GUEST", "STRIPE", "COINBASE"]);
|
|
1276
1300
|
var $optionalGeoField = import_zod.z.union([$nonBlank, import_zod.z.literal("")]).optional();
|
|
1277
1301
|
var US_REGION_REQUIRED = "a US buyer needs a US state code as region";
|
|
1278
1302
|
var hasUsRegion = (country, region) => country !== "US" || UsStateCodeSchema.safeParse(region).success;
|
|
@@ -1290,7 +1314,7 @@ var $routingTableRequest = obj({
|
|
|
1290
1314
|
providers: $routingTableProviderInputs.optional(),
|
|
1291
1315
|
destinationAsset: $destinationAsset.optional(),
|
|
1292
1316
|
depositAddress: $nonBlank.optional()
|
|
1293
|
-
}).refine((
|
|
1317
|
+
}).refine((request3) => hasUsRegion(request3.country, request3.region), { message: US_REGION_REQUIRED, path: ["region"] });
|
|
1294
1318
|
var FiatRoutingTableRequestSchema = $routingTableRequest;
|
|
1295
1319
|
var $routingTableProvider = obj({
|
|
1296
1320
|
provider: $routingProvider,
|
|
@@ -1348,9 +1372,9 @@ var $routingQuoteRequest = import_zod.z.union([
|
|
|
1348
1372
|
}),
|
|
1349
1373
|
obj({ ...$routingQuoteTermsShape, provider: $routingProvider })
|
|
1350
1374
|
]).refine(
|
|
1351
|
-
(
|
|
1352
|
-
const allowed =
|
|
1353
|
-
const selected = "providers" in
|
|
1375
|
+
(request3) => {
|
|
1376
|
+
const allowed = request3.routingOverrides?.providers;
|
|
1377
|
+
const selected = "providers" in request3 ? request3.providers : [request3.provider];
|
|
1354
1378
|
return allowed === void 0 || selected.every((provider) => allowed.includes(provider));
|
|
1355
1379
|
},
|
|
1356
1380
|
{ message: "requested providers must be allowed by routingOverrides", path: ["routingOverrides"] }
|
|
@@ -1492,7 +1516,7 @@ var $stepResponse = import_zod.z.union([$providerBoundStepResponse, $funAuthStep
|
|
|
1492
1516
|
var FiatStepResponseSchema = $stepResponse;
|
|
1493
1517
|
|
|
1494
1518
|
// package.json
|
|
1495
|
-
var version = "0.
|
|
1519
|
+
var version = "0.58.0";
|
|
1496
1520
|
|
|
1497
1521
|
// src/table.ts
|
|
1498
1522
|
var TABLE_VERSION = version;
|
|
@@ -3393,14 +3417,14 @@ function walkTable(fn) {
|
|
|
3393
3417
|
function assertFixture(id) {
|
|
3394
3418
|
const meta = fixtureMeta(id);
|
|
3395
3419
|
const json = loadFixture(id);
|
|
3396
|
-
const
|
|
3397
|
-
if (stateKey(
|
|
3420
|
+
const stepResponse3 = assertFiatStepResponse(json);
|
|
3421
|
+
if (stateKey(stepResponse3.state) !== meta.stateKey) {
|
|
3398
3422
|
throw new ContractViolation(
|
|
3399
|
-
`fixture ${id}: manifest says ${meta.stateKey}, step response carries ${stateKey(
|
|
3423
|
+
`fixture ${id}: manifest says ${meta.stateKey}, step response carries ${stateKey(stepResponse3.state)}`
|
|
3400
3424
|
);
|
|
3401
3425
|
}
|
|
3402
|
-
assertLegalEmission(
|
|
3403
|
-
return { meta, stepResponse:
|
|
3426
|
+
assertLegalEmission(stepResponse3.state, stepResponse3.transitions);
|
|
3427
|
+
return { meta, stepResponse: stepResponse3 };
|
|
3404
3428
|
}
|
|
3405
3429
|
function assertAllFixtures() {
|
|
3406
3430
|
return FIXTURES.map((meta) => assertFixture(meta.id));
|
|
@@ -4038,7 +4062,8 @@ var kycShape = obj4({
|
|
|
4038
4062
|
verifiedEmail: nonEmpty.nullable(),
|
|
4039
4063
|
linkAuthToken: linkAuthToken.nullable(),
|
|
4040
4064
|
fieldErrors: import_zod4.z.array(obj4({ fieldId: nonEmpty, message: nonEmpty })).min(1).optional(),
|
|
4041
|
-
reask: reask.nullable()
|
|
4065
|
+
reask: reask.nullable(),
|
|
4066
|
+
paymentSheetFirst: import_zod4.z.boolean()
|
|
4042
4067
|
});
|
|
4043
4068
|
var identifiersNextAction = obj4({ next: import_zod4.z.literal("identifiers"), linkAuthToken: linkAuthToken.nullable() });
|
|
4044
4069
|
var attestationNextAction = obj4({ next: import_zod4.z.literal("attestation"), linkAuthToken: linkAuthToken.nullable() });
|
|
@@ -4088,6 +4113,10 @@ var checkKyc3 = (nextAction, context2) => {
|
|
|
4088
4113
|
if (nextAction.tier === "l2" && nextAction.round !== "IDENTITY") {
|
|
4089
4114
|
context2.addIssue({ code: "custom", path: ["tier"], message: "l2 is an identity round" });
|
|
4090
4115
|
}
|
|
4116
|
+
const firstAsk = nextAction.tier === "l0" && nextAction.correctionRound === 0 && nextAction.reask === null && !nextAction.fieldErrors;
|
|
4117
|
+
if (nextAction.paymentSheetFirst && !firstAsk) {
|
|
4118
|
+
context2.addIssue({ code: "custom", path: ["paymentSheetFirst"], message: "only a first ask at l0 opens the payment sheet first" });
|
|
4119
|
+
}
|
|
4091
4120
|
};
|
|
4092
4121
|
var checkPlaceOrder = (nextAction, context2) => {
|
|
4093
4122
|
if (nextAction.paySheet.amount !== nextAction.price.total.amount) {
|
|
@@ -4177,31 +4206,161 @@ var errorBody = obj4({
|
|
|
4177
4206
|
});
|
|
4178
4207
|
var StripeErrorBodySchema = errorBody;
|
|
4179
4208
|
|
|
4180
|
-
// src/
|
|
4209
|
+
// src/flows/bank-transfer.ts
|
|
4210
|
+
var BANK_TRANSFER_ENDPOINTS = {
|
|
4211
|
+
next: "POST /fiat/next"
|
|
4212
|
+
};
|
|
4213
|
+
var BANK_TRANSFER_MAX_LISTED_ORDERS = 20;
|
|
4214
|
+
|
|
4215
|
+
// src/flows/bank-transfer.schemas.ts
|
|
4181
4216
|
var import_zod5 = require("zod");
|
|
4182
|
-
var context = { checkout: MoonPayCheckoutSchema, destinationAsset: DestinationAssetSchema.optional() };
|
|
4183
4217
|
var obj5 = (shape) => import_zod5.z.object(shape).strict();
|
|
4184
4218
|
var nonEmpty2 = import_zod5.z.string().refine((value) => value.trim().length > 0, "must not be blank");
|
|
4219
|
+
var hasUniqueIds5 = (ids) => new Set(ids).size === ids.length;
|
|
4220
|
+
var retryAfterMs2 = import_zod5.z.number().int().positive().max(6e4);
|
|
4221
|
+
var instant2 = import_zod5.z.string().datetime({ offset: true });
|
|
4222
|
+
var orderId = import_zod5.z.string().regex(/^bto_[A-Za-z0-9_-]{22}$/, "must be an order id bankDetails listed");
|
|
4223
|
+
var fiatCurrency = import_zod5.z.enum(Object.keys(FIAT_CURRENCY_NAMES));
|
|
4224
|
+
var checkout2 = obj5({
|
|
4225
|
+
currency: fiatCurrency,
|
|
4226
|
+
destination: obj5({ asset: nonEmpty2, network: nonEmpty2 }),
|
|
4227
|
+
paymentMethod: import_zod5.z.literal("bank_transfer")
|
|
4228
|
+
});
|
|
4229
|
+
var BankTransferCheckoutSchema = checkout2;
|
|
4230
|
+
var contextFields3 = { checkout: checkout2 };
|
|
4231
|
+
var requestContext2 = obj5(contextFields3);
|
|
4232
|
+
var BankTransferRequestContextSchema = requestContext2;
|
|
4233
|
+
var observeFields3 = { action: import_zod5.z.literal("observe") };
|
|
4234
|
+
var consentFields3 = {
|
|
4235
|
+
action: import_zod5.z.literal("consent"),
|
|
4236
|
+
acceptances: import_zod5.z.array(TermsDocumentAcceptanceSchema).min(1).refine((acceptances) => hasUniqueIds5(acceptances.map((acceptance) => acceptance.documentId)), "each document is accepted once")
|
|
4237
|
+
};
|
|
4238
|
+
var captureFields = { action: import_zod5.z.literal("capture"), result: KycSdkResultReportSchema };
|
|
4239
|
+
var openDepositInstructionsFields = { action: import_zod5.z.literal("openDepositInstructions"), walletConfirmed: import_zod5.z.literal(true), walletAddress: nonEmpty2 };
|
|
4240
|
+
var orderFields3 = { action: import_zod5.z.literal("order"), orderId };
|
|
4241
|
+
var observeRequest2 = obj5({ ...contextFields3, ...observeFields3 });
|
|
4242
|
+
var consentRequest2 = obj5({ ...contextFields3, ...consentFields3 });
|
|
4243
|
+
var captureRequest = obj5({ ...contextFields3, ...captureFields });
|
|
4244
|
+
var openDepositInstructionsRequest = obj5({ ...contextFields3, ...openDepositInstructionsFields });
|
|
4245
|
+
var orderRequest2 = obj5({ ...contextFields3, ...orderFields3 });
|
|
4246
|
+
var BankTransferObserveRequestSchema = observeRequest2;
|
|
4247
|
+
var BankTransferConsentRequestSchema = consentRequest2;
|
|
4248
|
+
var BankTransferCaptureRequestSchema = captureRequest;
|
|
4249
|
+
var BankTransferOpenDepositInstructionsRequestSchema = openDepositInstructionsRequest;
|
|
4250
|
+
var BankTransferOrderRequestSchema = orderRequest2;
|
|
4251
|
+
var request2 = import_zod5.z.discriminatedUnion("action", [observeRequest2, consentRequest2, captureRequest, openDepositInstructionsRequest, orderRequest2]);
|
|
4252
|
+
var BankTransferRequestSchema = request2;
|
|
4253
|
+
var envelope3 = { provider: FiatProviderSchema, geo: FiatGeoSchema, ...contextFields3 };
|
|
4254
|
+
var nextRequest2 = import_zod5.z.discriminatedUnion("action", [
|
|
4255
|
+
obj5({ ...envelope3, ...observeFields3 }),
|
|
4256
|
+
obj5({ ...envelope3, ...consentFields3 }),
|
|
4257
|
+
obj5({ ...envelope3, ...captureFields }),
|
|
4258
|
+
obj5({ ...envelope3, ...openDepositInstructionsFields }),
|
|
4259
|
+
obj5({ ...envelope3, ...orderFields3 })
|
|
4260
|
+
]);
|
|
4261
|
+
var BankTransferNextRequestSchema = nextRequest2;
|
|
4262
|
+
var wallet = obj5({ address: nonEmpty2, network: nonEmpty2, asset: nonEmpty2 });
|
|
4263
|
+
var consentShape2 = obj5({ next: import_zod5.z.literal("consent"), documents: import_zod5.z.array(TermsDocumentSchema).min(1) });
|
|
4264
|
+
var captureNextAction = obj5({ next: import_zod5.z.literal("capture"), kycProvider: KYCProviderSchema, accessToken: nonEmpty2, expiresAt: instant2 });
|
|
4265
|
+
var waitNextAction2 = obj5({ next: import_zod5.z.literal("wait"), retryAfterMs: retryAfterMs2 });
|
|
4266
|
+
var openDepositInstructionsNextAction = obj5({ next: import_zod5.z.literal("openDepositInstructions"), wallet, attestationText: nonEmpty2 });
|
|
4267
|
+
var bankDetailsShape = obj5({
|
|
4268
|
+
next: import_zod5.z.literal("bankDetails"),
|
|
4269
|
+
instructions: obj5({ kind: import_zod5.z.literal("BANK_FIELDS"), fields: import_zod5.z.array(InstructionFieldSchema).min(1) }),
|
|
4270
|
+
wallet,
|
|
4271
|
+
orders: import_zod5.z.array(FiatStepResponseSchema).max(BANK_TRANSFER_MAX_LISTED_ORDERS),
|
|
4272
|
+
retryAfterMs: retryAfterMs2
|
|
4273
|
+
});
|
|
4274
|
+
var orderPendingNextAction2 = obj5({
|
|
4275
|
+
next: import_zod5.z.literal("orderPending"),
|
|
4276
|
+
orderId,
|
|
4277
|
+
retryAfterMs: retryAfterMs2,
|
|
4278
|
+
poll: OrderPollSchema.optional(),
|
|
4279
|
+
order: FiatStepResponseSchema
|
|
4280
|
+
});
|
|
4281
|
+
var checkConsent4 = (nextAction, context2) => {
|
|
4282
|
+
if (!hasUniqueIds5(nextAction.documents.map((document) => document.id))) {
|
|
4283
|
+
context2.addIssue({ code: "custom", path: ["documents"], message: "document ids must be unique" });
|
|
4284
|
+
}
|
|
4285
|
+
};
|
|
4286
|
+
var checkBankDetails = (nextAction, context2) => {
|
|
4287
|
+
if (!hasUniqueIds5(nextAction.instructions.fields.map((field) => field.id))) {
|
|
4288
|
+
context2.addIssue({ code: "custom", path: ["instructions", "fields"], message: "field ids must be unique" });
|
|
4289
|
+
}
|
|
4290
|
+
};
|
|
4291
|
+
var BankTransferConsentNextActionSchema = consentShape2.superRefine(checkConsent4);
|
|
4292
|
+
var BankTransferCaptureNextActionSchema = captureNextAction;
|
|
4293
|
+
var BankTransferWaitNextActionSchema = waitNextAction2;
|
|
4294
|
+
var BankTransferOpenDepositInstructionsNextActionSchema = openDepositInstructionsNextAction;
|
|
4295
|
+
var BankTransferBankDetailsNextActionSchema = bankDetailsShape.superRefine(checkBankDetails);
|
|
4296
|
+
var BankTransferOrderPendingNextActionSchema = orderPendingNextAction2.superRefine(checkOrderPendingPoll);
|
|
4297
|
+
var checkNextAction4 = (response, context2) => {
|
|
4298
|
+
checkOrderPendingPoll(response, context2);
|
|
4299
|
+
if (response.next === "consent") checkConsent4(response, context2);
|
|
4300
|
+
if (response.next === "bankDetails") checkBankDetails(response, context2);
|
|
4301
|
+
};
|
|
4302
|
+
var stepNextActions = [consentShape2, captureNextAction, waitNextAction2, openDepositInstructionsNextAction, bankDetailsShape];
|
|
4303
|
+
var anyNextAction2 = import_zod5.z.discriminatedUnion("next", [...stepNextActions, orderPendingNextAction2]).superRefine(checkNextAction4);
|
|
4304
|
+
var BankTransferNextActionSchema = anyNextAction2;
|
|
4305
|
+
var done2 = obj5({ next: import_zod5.z.literal("done"), order: FiatStepResponseSchema });
|
|
4306
|
+
var BankTransferDoneSchema = done2;
|
|
4307
|
+
var refused2 = obj5({
|
|
4308
|
+
next: import_zod5.z.literal("refused"),
|
|
4309
|
+
reason: import_zod5.z.enum(["NOT_ELIGIBLE", "KYC_REJECTED"]),
|
|
4310
|
+
recovery: import_zod5.z.literal("NONE")
|
|
4311
|
+
});
|
|
4312
|
+
var BankTransferRefusedSchema = refused2;
|
|
4313
|
+
var stepResponse2 = import_zod5.z.discriminatedUnion("next", [...stepNextActions, refused2]).superRefine(checkNextAction4);
|
|
4314
|
+
var BankTransferStepResponseSchema = stepResponse2;
|
|
4315
|
+
var orderResponse2 = import_zod5.z.discriminatedUnion("next", [done2, orderPendingNextAction2]).superRefine(checkOrderPendingPoll);
|
|
4316
|
+
var BankTransferOrderResponseSchema = orderResponse2;
|
|
4317
|
+
var BankTransferResponseSchemaFor = {
|
|
4318
|
+
observe: BankTransferStepResponseSchema,
|
|
4319
|
+
consent: BankTransferStepResponseSchema,
|
|
4320
|
+
capture: BankTransferStepResponseSchema,
|
|
4321
|
+
openDepositInstructions: BankTransferStepResponseSchema,
|
|
4322
|
+
order: BankTransferOrderResponseSchema
|
|
4323
|
+
};
|
|
4324
|
+
var faultFields3 = {
|
|
4325
|
+
reason: import_zod5.z.enum(["RATE_LIMITED", "PROVIDER_UNAVAILABLE", "KYC_PROVIDER_UNAVAILABLE", "SERVICE_UNAVAILABLE", "INVALID_REQUEST"]),
|
|
4326
|
+
recovery: import_zod5.z.enum(["RETRY", "NONE"])
|
|
4327
|
+
};
|
|
4328
|
+
var fault2 = obj5(faultFields3);
|
|
4329
|
+
var BankTransferFaultSchema = fault2;
|
|
4330
|
+
var errorBody2 = obj5({
|
|
4331
|
+
...faultFields3,
|
|
4332
|
+
errorCode: nonEmpty2,
|
|
4333
|
+
errorMsg: import_zod5.z.string(),
|
|
4334
|
+
reqId: import_zod5.z.string().optional(),
|
|
4335
|
+
retryAfterSeconds: import_zod5.z.number().int().nonnegative().optional()
|
|
4336
|
+
});
|
|
4337
|
+
var BankTransferErrorBodySchema = errorBody2;
|
|
4338
|
+
|
|
4339
|
+
// src/providers/moonpay-guest.schemas.ts
|
|
4340
|
+
var import_zod6 = require("zod");
|
|
4341
|
+
var context = { checkout: MoonPayCheckoutSchema, destinationAsset: DestinationAssetSchema.optional() };
|
|
4342
|
+
var obj6 = (shape) => import_zod6.z.object(shape).strict();
|
|
4343
|
+
var nonEmpty3 = import_zod6.z.string().refine((value) => value.trim().length > 0, "must not be blank");
|
|
4185
4344
|
var actions = [
|
|
4186
|
-
{ action:
|
|
4187
|
-
{ action:
|
|
4188
|
-
{ action:
|
|
4189
|
-
{ action:
|
|
4190
|
-
{ action:
|
|
4191
|
-
{ action:
|
|
4192
|
-
{ action:
|
|
4193
|
-
{ action:
|
|
4345
|
+
{ action: import_zod6.z.literal("observe") },
|
|
4346
|
+
{ action: import_zod6.z.literal("session") },
|
|
4347
|
+
{ 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") },
|
|
4348
|
+
{ action: import_zod6.z.literal("order"), orderId: nonEmpty3, quotedAmount: FiatAmountSchema, transactionId: nonEmpty3.optional() },
|
|
4349
|
+
{ action: import_zod6.z.literal("phone"), phoneNumber: import_zod6.z.string().regex(/^\+[1-9]\d{1,14}$/) },
|
|
4350
|
+
{ action: import_zod6.z.literal("phone"), resend: nonEmpty3 },
|
|
4351
|
+
{ action: import_zod6.z.literal("phoneCode"), verificationRef: nonEmpty3, otpCode: import_zod6.z.string().regex(/^\d{6}$/) },
|
|
4352
|
+
{ action: import_zod6.z.literal("decline"), reason: MoonPayGuestDeclineReasonSchema }
|
|
4194
4353
|
];
|
|
4195
|
-
var MoonPayGuestObserveRequestSchema =
|
|
4196
|
-
var MoonPayGuestSessionRequestSchema =
|
|
4197
|
-
var MoonPayGuestConsentRequestSchema =
|
|
4198
|
-
var MoonPayGuestOrderRequestSchema =
|
|
4199
|
-
var MoonPayGuestPhoneNumberRequestSchema =
|
|
4200
|
-
var MoonPayGuestPhoneResendRequestSchema =
|
|
4201
|
-
var MoonPayGuestPhoneCodeRequestSchema =
|
|
4202
|
-
var MoonPayGuestDeclineRequestSchema =
|
|
4203
|
-
var MoonPayGuestPhoneRequestSchema =
|
|
4204
|
-
var MoonPayGuestRequestSchema =
|
|
4354
|
+
var MoonPayGuestObserveRequestSchema = obj6({ ...context, ...actions[0] });
|
|
4355
|
+
var MoonPayGuestSessionRequestSchema = obj6({ ...context, ...actions[1] });
|
|
4356
|
+
var MoonPayGuestConsentRequestSchema = obj6({ ...context, ...actions[2] });
|
|
4357
|
+
var MoonPayGuestOrderRequestSchema = obj6({ ...context, ...actions[3] });
|
|
4358
|
+
var MoonPayGuestPhoneNumberRequestSchema = obj6({ ...context, ...actions[4] });
|
|
4359
|
+
var MoonPayGuestPhoneResendRequestSchema = obj6({ ...context, ...actions[5] });
|
|
4360
|
+
var MoonPayGuestPhoneCodeRequestSchema = obj6({ ...context, ...actions[6] });
|
|
4361
|
+
var MoonPayGuestDeclineRequestSchema = obj6({ ...context, ...actions[7] });
|
|
4362
|
+
var MoonPayGuestPhoneRequestSchema = import_zod6.z.union([MoonPayGuestPhoneNumberRequestSchema, MoonPayGuestPhoneResendRequestSchema]);
|
|
4363
|
+
var MoonPayGuestRequestSchema = import_zod6.z.union([
|
|
4205
4364
|
MoonPayGuestObserveRequestSchema,
|
|
4206
4365
|
MoonPayGuestSessionRequestSchema,
|
|
4207
4366
|
MoonPayGuestConsentRequestSchema,
|
|
@@ -4211,22 +4370,22 @@ var MoonPayGuestRequestSchema = import_zod5.z.union([
|
|
|
4211
4370
|
MoonPayGuestPhoneCodeRequestSchema,
|
|
4212
4371
|
MoonPayGuestDeclineRequestSchema
|
|
4213
4372
|
]);
|
|
4214
|
-
var MoonPayGuestNextRequestSchema =
|
|
4215
|
-
|
|
4216
|
-
|
|
4217
|
-
|
|
4218
|
-
|
|
4219
|
-
|
|
4220
|
-
|
|
4221
|
-
|
|
4222
|
-
|
|
4373
|
+
var MoonPayGuestNextRequestSchema = import_zod6.z.union([
|
|
4374
|
+
obj6({ provider: import_zod6.z.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty3.optional(), ...context, ...actions[0] }),
|
|
4375
|
+
obj6({ provider: import_zod6.z.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty3.optional(), ...context, ...actions[1] }),
|
|
4376
|
+
obj6({ provider: import_zod6.z.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty3.optional(), ...context, ...actions[2] }),
|
|
4377
|
+
obj6({ provider: import_zod6.z.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty3.optional(), ...context, ...actions[3] }),
|
|
4378
|
+
obj6({ provider: import_zod6.z.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty3.optional(), ...context, ...actions[4] }),
|
|
4379
|
+
obj6({ provider: import_zod6.z.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty3.optional(), ...context, ...actions[5] }),
|
|
4380
|
+
obj6({ provider: import_zod6.z.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty3.optional(), ...context, ...actions[6] }),
|
|
4381
|
+
obj6({ provider: import_zod6.z.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty3.optional(), ...context, ...actions[7] })
|
|
4223
4382
|
]);
|
|
4224
|
-
var MoonPayGuestStepResponseSchema =
|
|
4383
|
+
var MoonPayGuestStepResponseSchema = import_zod6.z.union([
|
|
4225
4384
|
MoonPayConsentNextActionSchema,
|
|
4226
4385
|
MoonPaySessionNextActionSchema,
|
|
4227
4386
|
MoonPayPhoneNextActionSchema,
|
|
4228
4387
|
MoonPayPhoneCodeNextActionSchema,
|
|
4229
4388
|
MoonPayPayNextActionSchema,
|
|
4230
|
-
|
|
4389
|
+
obj6({ next: import_zod6.z.literal("refused"), reason: import_zod6.z.enum(["NOT_ELIGIBLE", "FINAL_REJECTION"]), recovery: import_zod6.z.enum(["REQUOTE", "NONE"]) })
|
|
4231
4390
|
]);
|
|
4232
|
-
var MoonPayGuestResponseSchema =
|
|
4391
|
+
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-
|
|
26
|
+
} from "./chunk-X5HMCOMZ.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
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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,8 +422,7 @@ var $provider = z.enum([
|
|
|
418
422
|
"MOONPAY_GUEST",
|
|
419
423
|
"STRIPE",
|
|
420
424
|
"COINBASE",
|
|
421
|
-
"CROSSMINT"
|
|
422
|
-
"ALCHEMYPAY"
|
|
425
|
+
"CROSSMINT"
|
|
423
426
|
]);
|
|
424
427
|
var FiatProviderSchema = $provider;
|
|
425
428
|
var $kycProvider = z.enum(["SUMSUB"]);
|
|
@@ -756,12 +759,12 @@ var OrderPollSchema = obj({
|
|
|
756
759
|
giveUpAfterMs: z.number().int().positive().max(60 * 60 * 1e3)
|
|
757
760
|
});
|
|
758
761
|
function checkOrderPendingPoll(response, context2) {
|
|
759
|
-
const { poll, retryAfterMs:
|
|
760
|
-
if (response.next !== "orderPending" || poll === void 0 ||
|
|
761
|
-
if (
|
|
762
|
+
const { poll, retryAfterMs: retryAfterMs3 } = response;
|
|
763
|
+
if (response.next !== "orderPending" || poll === void 0 || retryAfterMs3 === void 0) return;
|
|
764
|
+
if (retryAfterMs3 < MIN_INTERVAL_MS) {
|
|
762
765
|
context2.addIssue({ code: "custom", path: ["retryAfterMs"], message: `retryAfterMs must be at least ${MIN_INTERVAL_MS} with a poll` });
|
|
763
766
|
}
|
|
764
|
-
if (poll.maxIntervalMs <
|
|
767
|
+
if (poll.maxIntervalMs < retryAfterMs3) {
|
|
765
768
|
context2.addIssue({ code: "custom", path: ["poll", "maxIntervalMs"], message: "maxIntervalMs must be at least retryAfterMs" });
|
|
766
769
|
}
|
|
767
770
|
}
|
|
@@ -1029,7 +1032,7 @@ var compareDecimals = (left, right) => {
|
|
|
1029
1032
|
return leftDigits < rightDigits ? -1 : leftDigits > rightDigits ? 1 : 0;
|
|
1030
1033
|
};
|
|
1031
1034
|
var $countryCode = z.enum(Object.keys(CountryCode));
|
|
1032
|
-
var $routingProvider = $provider.extract(["TRANSAK", "BANXA", "MOONPAY", "MOONPAY_GUEST", "STRIPE", "COINBASE"
|
|
1035
|
+
var $routingProvider = $provider.extract(["TRANSAK", "BANXA", "MOONPAY", "MOONPAY_GUEST", "STRIPE", "COINBASE"]);
|
|
1033
1036
|
var $optionalGeoField = z.union([$nonBlank, z.literal("")]).optional();
|
|
1034
1037
|
var US_REGION_REQUIRED = "a US buyer needs a US state code as region";
|
|
1035
1038
|
var hasUsRegion = (country, region) => country !== "US" || UsStateCodeSchema.safeParse(region).success;
|
|
@@ -1047,7 +1050,7 @@ var $routingTableRequest = obj({
|
|
|
1047
1050
|
providers: $routingTableProviderInputs.optional(),
|
|
1048
1051
|
destinationAsset: $destinationAsset.optional(),
|
|
1049
1052
|
depositAddress: $nonBlank.optional()
|
|
1050
|
-
}).refine((
|
|
1053
|
+
}).refine((request3) => hasUsRegion(request3.country, request3.region), { message: US_REGION_REQUIRED, path: ["region"] });
|
|
1051
1054
|
var FiatRoutingTableRequestSchema = $routingTableRequest;
|
|
1052
1055
|
var $routingTableProvider = obj({
|
|
1053
1056
|
provider: $routingProvider,
|
|
@@ -1105,9 +1108,9 @@ var $routingQuoteRequest = z.union([
|
|
|
1105
1108
|
}),
|
|
1106
1109
|
obj({ ...$routingQuoteTermsShape, provider: $routingProvider })
|
|
1107
1110
|
]).refine(
|
|
1108
|
-
(
|
|
1109
|
-
const allowed =
|
|
1110
|
-
const selected = "providers" in
|
|
1111
|
+
(request3) => {
|
|
1112
|
+
const allowed = request3.routingOverrides?.providers;
|
|
1113
|
+
const selected = "providers" in request3 ? request3.providers : [request3.provider];
|
|
1111
1114
|
return allowed === void 0 || selected.every((provider) => allowed.includes(provider));
|
|
1112
1115
|
},
|
|
1113
1116
|
{ message: "requested providers must be allowed by routingOverrides", path: ["routingOverrides"] }
|
|
@@ -2558,14 +2561,14 @@ function walkTable(fn) {
|
|
|
2558
2561
|
function assertFixture(id) {
|
|
2559
2562
|
const meta = fixtureMeta(id);
|
|
2560
2563
|
const json = loadFixture(id);
|
|
2561
|
-
const
|
|
2562
|
-
if (stateKey(
|
|
2564
|
+
const stepResponse3 = assertFiatStepResponse(json);
|
|
2565
|
+
if (stateKey(stepResponse3.state) !== meta.stateKey) {
|
|
2563
2566
|
throw new ContractViolation(
|
|
2564
|
-
`fixture ${id}: manifest says ${meta.stateKey}, step response carries ${stateKey(
|
|
2567
|
+
`fixture ${id}: manifest says ${meta.stateKey}, step response carries ${stateKey(stepResponse3.state)}`
|
|
2565
2568
|
);
|
|
2566
2569
|
}
|
|
2567
|
-
assertLegalEmission(
|
|
2568
|
-
return { meta, stepResponse:
|
|
2570
|
+
assertLegalEmission(stepResponse3.state, stepResponse3.transitions);
|
|
2571
|
+
return { meta, stepResponse: stepResponse3 };
|
|
2569
2572
|
}
|
|
2570
2573
|
function assertAllFixtures() {
|
|
2571
2574
|
return FIXTURES.map((meta) => assertFixture(meta.id));
|
|
@@ -3108,7 +3111,8 @@ var kycShape = obj4({
|
|
|
3108
3111
|
verifiedEmail: nonEmpty.nullable(),
|
|
3109
3112
|
linkAuthToken: linkAuthToken.nullable(),
|
|
3110
3113
|
fieldErrors: z4.array(obj4({ fieldId: nonEmpty, message: nonEmpty })).min(1).optional(),
|
|
3111
|
-
reask: reask.nullable()
|
|
3114
|
+
reask: reask.nullable(),
|
|
3115
|
+
paymentSheetFirst: z4.boolean()
|
|
3112
3116
|
});
|
|
3113
3117
|
var identifiersNextAction = obj4({ next: z4.literal("identifiers"), linkAuthToken: linkAuthToken.nullable() });
|
|
3114
3118
|
var attestationNextAction = obj4({ next: z4.literal("attestation"), linkAuthToken: linkAuthToken.nullable() });
|
|
@@ -3158,6 +3162,10 @@ var checkKyc3 = (nextAction, context2) => {
|
|
|
3158
3162
|
if (nextAction.tier === "l2" && nextAction.round !== "IDENTITY") {
|
|
3159
3163
|
context2.addIssue({ code: "custom", path: ["tier"], message: "l2 is an identity round" });
|
|
3160
3164
|
}
|
|
3165
|
+
const firstAsk = nextAction.tier === "l0" && nextAction.correctionRound === 0 && nextAction.reask === null && !nextAction.fieldErrors;
|
|
3166
|
+
if (nextAction.paymentSheetFirst && !firstAsk) {
|
|
3167
|
+
context2.addIssue({ code: "custom", path: ["paymentSheetFirst"], message: "only a first ask at l0 opens the payment sheet first" });
|
|
3168
|
+
}
|
|
3161
3169
|
};
|
|
3162
3170
|
var checkPlaceOrder = (nextAction, context2) => {
|
|
3163
3171
|
if (nextAction.paySheet.amount !== nextAction.price.total.amount) {
|
|
@@ -3247,31 +3255,155 @@ var errorBody = obj4({
|
|
|
3247
3255
|
});
|
|
3248
3256
|
var StripeErrorBodySchema = errorBody;
|
|
3249
3257
|
|
|
3250
|
-
// src/
|
|
3258
|
+
// src/flows/bank-transfer.schemas.ts
|
|
3251
3259
|
import { z as z5 } from "zod";
|
|
3252
|
-
var context = { checkout: MoonPayCheckoutSchema, destinationAsset: DestinationAssetSchema.optional() };
|
|
3253
3260
|
var obj5 = (shape) => z5.object(shape).strict();
|
|
3254
3261
|
var nonEmpty2 = z5.string().refine((value) => value.trim().length > 0, "must not be blank");
|
|
3262
|
+
var hasUniqueIds5 = (ids) => new Set(ids).size === ids.length;
|
|
3263
|
+
var retryAfterMs2 = z5.number().int().positive().max(6e4);
|
|
3264
|
+
var instant2 = z5.string().datetime({ offset: true });
|
|
3265
|
+
var orderId = z5.string().regex(/^bto_[A-Za-z0-9_-]{22}$/, "must be an order id bankDetails listed");
|
|
3266
|
+
var fiatCurrency = z5.enum(Object.keys(FIAT_CURRENCY_NAMES));
|
|
3267
|
+
var checkout2 = obj5({
|
|
3268
|
+
currency: fiatCurrency,
|
|
3269
|
+
destination: obj5({ asset: nonEmpty2, network: nonEmpty2 }),
|
|
3270
|
+
paymentMethod: z5.literal("bank_transfer")
|
|
3271
|
+
});
|
|
3272
|
+
var BankTransferCheckoutSchema = checkout2;
|
|
3273
|
+
var contextFields3 = { checkout: checkout2 };
|
|
3274
|
+
var requestContext2 = obj5(contextFields3);
|
|
3275
|
+
var BankTransferRequestContextSchema = requestContext2;
|
|
3276
|
+
var observeFields3 = { action: z5.literal("observe") };
|
|
3277
|
+
var consentFields3 = {
|
|
3278
|
+
action: z5.literal("consent"),
|
|
3279
|
+
acceptances: z5.array(TermsDocumentAcceptanceSchema).min(1).refine((acceptances) => hasUniqueIds5(acceptances.map((acceptance) => acceptance.documentId)), "each document is accepted once")
|
|
3280
|
+
};
|
|
3281
|
+
var captureFields = { action: z5.literal("capture"), result: KycSdkResultReportSchema };
|
|
3282
|
+
var openDepositInstructionsFields = { action: z5.literal("openDepositInstructions"), walletConfirmed: z5.literal(true), walletAddress: nonEmpty2 };
|
|
3283
|
+
var orderFields3 = { action: z5.literal("order"), orderId };
|
|
3284
|
+
var observeRequest2 = obj5({ ...contextFields3, ...observeFields3 });
|
|
3285
|
+
var consentRequest2 = obj5({ ...contextFields3, ...consentFields3 });
|
|
3286
|
+
var captureRequest = obj5({ ...contextFields3, ...captureFields });
|
|
3287
|
+
var openDepositInstructionsRequest = obj5({ ...contextFields3, ...openDepositInstructionsFields });
|
|
3288
|
+
var orderRequest2 = obj5({ ...contextFields3, ...orderFields3 });
|
|
3289
|
+
var BankTransferObserveRequestSchema = observeRequest2;
|
|
3290
|
+
var BankTransferConsentRequestSchema = consentRequest2;
|
|
3291
|
+
var BankTransferCaptureRequestSchema = captureRequest;
|
|
3292
|
+
var BankTransferOpenDepositInstructionsRequestSchema = openDepositInstructionsRequest;
|
|
3293
|
+
var BankTransferOrderRequestSchema = orderRequest2;
|
|
3294
|
+
var request2 = z5.discriminatedUnion("action", [observeRequest2, consentRequest2, captureRequest, openDepositInstructionsRequest, orderRequest2]);
|
|
3295
|
+
var BankTransferRequestSchema = request2;
|
|
3296
|
+
var envelope3 = { provider: FiatProviderSchema, geo: FiatGeoSchema, ...contextFields3 };
|
|
3297
|
+
var nextRequest2 = z5.discriminatedUnion("action", [
|
|
3298
|
+
obj5({ ...envelope3, ...observeFields3 }),
|
|
3299
|
+
obj5({ ...envelope3, ...consentFields3 }),
|
|
3300
|
+
obj5({ ...envelope3, ...captureFields }),
|
|
3301
|
+
obj5({ ...envelope3, ...openDepositInstructionsFields }),
|
|
3302
|
+
obj5({ ...envelope3, ...orderFields3 })
|
|
3303
|
+
]);
|
|
3304
|
+
var BankTransferNextRequestSchema = nextRequest2;
|
|
3305
|
+
var wallet = obj5({ address: nonEmpty2, network: nonEmpty2, asset: nonEmpty2 });
|
|
3306
|
+
var consentShape2 = obj5({ next: z5.literal("consent"), documents: z5.array(TermsDocumentSchema).min(1) });
|
|
3307
|
+
var captureNextAction = obj5({ next: z5.literal("capture"), kycProvider: KYCProviderSchema, accessToken: nonEmpty2, expiresAt: instant2 });
|
|
3308
|
+
var waitNextAction2 = obj5({ next: z5.literal("wait"), retryAfterMs: retryAfterMs2 });
|
|
3309
|
+
var openDepositInstructionsNextAction = obj5({ next: z5.literal("openDepositInstructions"), wallet, attestationText: nonEmpty2 });
|
|
3310
|
+
var bankDetailsShape = obj5({
|
|
3311
|
+
next: z5.literal("bankDetails"),
|
|
3312
|
+
instructions: obj5({ kind: z5.literal("BANK_FIELDS"), fields: z5.array(InstructionFieldSchema).min(1) }),
|
|
3313
|
+
wallet,
|
|
3314
|
+
orders: z5.array(FiatStepResponseSchema).max(BANK_TRANSFER_MAX_LISTED_ORDERS),
|
|
3315
|
+
retryAfterMs: retryAfterMs2
|
|
3316
|
+
});
|
|
3317
|
+
var orderPendingNextAction2 = obj5({
|
|
3318
|
+
next: z5.literal("orderPending"),
|
|
3319
|
+
orderId,
|
|
3320
|
+
retryAfterMs: retryAfterMs2,
|
|
3321
|
+
poll: OrderPollSchema.optional(),
|
|
3322
|
+
order: FiatStepResponseSchema
|
|
3323
|
+
});
|
|
3324
|
+
var checkConsent4 = (nextAction, context2) => {
|
|
3325
|
+
if (!hasUniqueIds5(nextAction.documents.map((document) => document.id))) {
|
|
3326
|
+
context2.addIssue({ code: "custom", path: ["documents"], message: "document ids must be unique" });
|
|
3327
|
+
}
|
|
3328
|
+
};
|
|
3329
|
+
var checkBankDetails = (nextAction, context2) => {
|
|
3330
|
+
if (!hasUniqueIds5(nextAction.instructions.fields.map((field) => field.id))) {
|
|
3331
|
+
context2.addIssue({ code: "custom", path: ["instructions", "fields"], message: "field ids must be unique" });
|
|
3332
|
+
}
|
|
3333
|
+
};
|
|
3334
|
+
var BankTransferConsentNextActionSchema = consentShape2.superRefine(checkConsent4);
|
|
3335
|
+
var BankTransferCaptureNextActionSchema = captureNextAction;
|
|
3336
|
+
var BankTransferWaitNextActionSchema = waitNextAction2;
|
|
3337
|
+
var BankTransferOpenDepositInstructionsNextActionSchema = openDepositInstructionsNextAction;
|
|
3338
|
+
var BankTransferBankDetailsNextActionSchema = bankDetailsShape.superRefine(checkBankDetails);
|
|
3339
|
+
var BankTransferOrderPendingNextActionSchema = orderPendingNextAction2.superRefine(checkOrderPendingPoll);
|
|
3340
|
+
var checkNextAction4 = (response, context2) => {
|
|
3341
|
+
checkOrderPendingPoll(response, context2);
|
|
3342
|
+
if (response.next === "consent") checkConsent4(response, context2);
|
|
3343
|
+
if (response.next === "bankDetails") checkBankDetails(response, context2);
|
|
3344
|
+
};
|
|
3345
|
+
var stepNextActions = [consentShape2, captureNextAction, waitNextAction2, openDepositInstructionsNextAction, bankDetailsShape];
|
|
3346
|
+
var anyNextAction2 = z5.discriminatedUnion("next", [...stepNextActions, orderPendingNextAction2]).superRefine(checkNextAction4);
|
|
3347
|
+
var BankTransferNextActionSchema = anyNextAction2;
|
|
3348
|
+
var done2 = obj5({ next: z5.literal("done"), order: FiatStepResponseSchema });
|
|
3349
|
+
var BankTransferDoneSchema = done2;
|
|
3350
|
+
var refused2 = obj5({
|
|
3351
|
+
next: z5.literal("refused"),
|
|
3352
|
+
reason: z5.enum(["NOT_ELIGIBLE", "KYC_REJECTED"]),
|
|
3353
|
+
recovery: z5.literal("NONE")
|
|
3354
|
+
});
|
|
3355
|
+
var BankTransferRefusedSchema = refused2;
|
|
3356
|
+
var stepResponse2 = z5.discriminatedUnion("next", [...stepNextActions, refused2]).superRefine(checkNextAction4);
|
|
3357
|
+
var BankTransferStepResponseSchema = stepResponse2;
|
|
3358
|
+
var orderResponse2 = z5.discriminatedUnion("next", [done2, orderPendingNextAction2]).superRefine(checkOrderPendingPoll);
|
|
3359
|
+
var BankTransferOrderResponseSchema = orderResponse2;
|
|
3360
|
+
var BankTransferResponseSchemaFor = {
|
|
3361
|
+
observe: BankTransferStepResponseSchema,
|
|
3362
|
+
consent: BankTransferStepResponseSchema,
|
|
3363
|
+
capture: BankTransferStepResponseSchema,
|
|
3364
|
+
openDepositInstructions: BankTransferStepResponseSchema,
|
|
3365
|
+
order: BankTransferOrderResponseSchema
|
|
3366
|
+
};
|
|
3367
|
+
var faultFields3 = {
|
|
3368
|
+
reason: z5.enum(["RATE_LIMITED", "PROVIDER_UNAVAILABLE", "KYC_PROVIDER_UNAVAILABLE", "SERVICE_UNAVAILABLE", "INVALID_REQUEST"]),
|
|
3369
|
+
recovery: z5.enum(["RETRY", "NONE"])
|
|
3370
|
+
};
|
|
3371
|
+
var fault2 = obj5(faultFields3);
|
|
3372
|
+
var BankTransferFaultSchema = fault2;
|
|
3373
|
+
var errorBody2 = obj5({
|
|
3374
|
+
...faultFields3,
|
|
3375
|
+
errorCode: nonEmpty2,
|
|
3376
|
+
errorMsg: z5.string(),
|
|
3377
|
+
reqId: z5.string().optional(),
|
|
3378
|
+
retryAfterSeconds: z5.number().int().nonnegative().optional()
|
|
3379
|
+
});
|
|
3380
|
+
var BankTransferErrorBodySchema = errorBody2;
|
|
3381
|
+
|
|
3382
|
+
// src/providers/moonpay-guest.schemas.ts
|
|
3383
|
+
import { z as z6 } from "zod";
|
|
3384
|
+
var context = { checkout: MoonPayCheckoutSchema, destinationAsset: DestinationAssetSchema.optional() };
|
|
3385
|
+
var obj6 = (shape) => z6.object(shape).strict();
|
|
3386
|
+
var nonEmpty3 = z6.string().refine((value) => value.trim().length > 0, "must not be blank");
|
|
3255
3387
|
var actions = [
|
|
3256
|
-
{ action:
|
|
3257
|
-
{ action:
|
|
3258
|
-
{ action:
|
|
3259
|
-
{ action:
|
|
3260
|
-
{ action:
|
|
3261
|
-
{ action:
|
|
3262
|
-
{ action:
|
|
3263
|
-
{ action:
|
|
3388
|
+
{ action: z6.literal("observe") },
|
|
3389
|
+
{ action: z6.literal("session") },
|
|
3390
|
+
{ 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") },
|
|
3391
|
+
{ action: z6.literal("order"), orderId: nonEmpty3, quotedAmount: FiatAmountSchema, transactionId: nonEmpty3.optional() },
|
|
3392
|
+
{ action: z6.literal("phone"), phoneNumber: z6.string().regex(/^\+[1-9]\d{1,14}$/) },
|
|
3393
|
+
{ action: z6.literal("phone"), resend: nonEmpty3 },
|
|
3394
|
+
{ action: z6.literal("phoneCode"), verificationRef: nonEmpty3, otpCode: z6.string().regex(/^\d{6}$/) },
|
|
3395
|
+
{ action: z6.literal("decline"), reason: MoonPayGuestDeclineReasonSchema }
|
|
3264
3396
|
];
|
|
3265
|
-
var MoonPayGuestObserveRequestSchema =
|
|
3266
|
-
var MoonPayGuestSessionRequestSchema =
|
|
3267
|
-
var MoonPayGuestConsentRequestSchema =
|
|
3268
|
-
var MoonPayGuestOrderRequestSchema =
|
|
3269
|
-
var MoonPayGuestPhoneNumberRequestSchema =
|
|
3270
|
-
var MoonPayGuestPhoneResendRequestSchema =
|
|
3271
|
-
var MoonPayGuestPhoneCodeRequestSchema =
|
|
3272
|
-
var MoonPayGuestDeclineRequestSchema =
|
|
3273
|
-
var MoonPayGuestPhoneRequestSchema =
|
|
3274
|
-
var MoonPayGuestRequestSchema =
|
|
3397
|
+
var MoonPayGuestObserveRequestSchema = obj6({ ...context, ...actions[0] });
|
|
3398
|
+
var MoonPayGuestSessionRequestSchema = obj6({ ...context, ...actions[1] });
|
|
3399
|
+
var MoonPayGuestConsentRequestSchema = obj6({ ...context, ...actions[2] });
|
|
3400
|
+
var MoonPayGuestOrderRequestSchema = obj6({ ...context, ...actions[3] });
|
|
3401
|
+
var MoonPayGuestPhoneNumberRequestSchema = obj6({ ...context, ...actions[4] });
|
|
3402
|
+
var MoonPayGuestPhoneResendRequestSchema = obj6({ ...context, ...actions[5] });
|
|
3403
|
+
var MoonPayGuestPhoneCodeRequestSchema = obj6({ ...context, ...actions[6] });
|
|
3404
|
+
var MoonPayGuestDeclineRequestSchema = obj6({ ...context, ...actions[7] });
|
|
3405
|
+
var MoonPayGuestPhoneRequestSchema = z6.union([MoonPayGuestPhoneNumberRequestSchema, MoonPayGuestPhoneResendRequestSchema]);
|
|
3406
|
+
var MoonPayGuestRequestSchema = z6.union([
|
|
3275
3407
|
MoonPayGuestObserveRequestSchema,
|
|
3276
3408
|
MoonPayGuestSessionRequestSchema,
|
|
3277
3409
|
MoonPayGuestConsentRequestSchema,
|
|
@@ -3281,26 +3413,51 @@ var MoonPayGuestRequestSchema = z5.union([
|
|
|
3281
3413
|
MoonPayGuestPhoneCodeRequestSchema,
|
|
3282
3414
|
MoonPayGuestDeclineRequestSchema
|
|
3283
3415
|
]);
|
|
3284
|
-
var MoonPayGuestNextRequestSchema =
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3416
|
+
var MoonPayGuestNextRequestSchema = z6.union([
|
|
3417
|
+
obj6({ provider: z6.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty3.optional(), ...context, ...actions[0] }),
|
|
3418
|
+
obj6({ provider: z6.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty3.optional(), ...context, ...actions[1] }),
|
|
3419
|
+
obj6({ provider: z6.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty3.optional(), ...context, ...actions[2] }),
|
|
3420
|
+
obj6({ provider: z6.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty3.optional(), ...context, ...actions[3] }),
|
|
3421
|
+
obj6({ provider: z6.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty3.optional(), ...context, ...actions[4] }),
|
|
3422
|
+
obj6({ provider: z6.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty3.optional(), ...context, ...actions[5] }),
|
|
3423
|
+
obj6({ provider: z6.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty3.optional(), ...context, ...actions[6] }),
|
|
3424
|
+
obj6({ provider: z6.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty3.optional(), ...context, ...actions[7] })
|
|
3293
3425
|
]);
|
|
3294
|
-
var MoonPayGuestStepResponseSchema =
|
|
3426
|
+
var MoonPayGuestStepResponseSchema = z6.union([
|
|
3295
3427
|
MoonPayConsentNextActionSchema,
|
|
3296
3428
|
MoonPaySessionNextActionSchema,
|
|
3297
3429
|
MoonPayPhoneNextActionSchema,
|
|
3298
3430
|
MoonPayPhoneCodeNextActionSchema,
|
|
3299
3431
|
MoonPayPayNextActionSchema,
|
|
3300
|
-
|
|
3432
|
+
obj6({ next: z6.literal("refused"), reason: z6.enum(["NOT_ELIGIBLE", "FINAL_REJECTION"]), recovery: z6.enum(["REQUOTE", "NONE"]) })
|
|
3301
3433
|
]);
|
|
3302
|
-
var MoonPayGuestResponseSchema =
|
|
3434
|
+
var MoonPayGuestResponseSchema = z6.union([MoonPayGuestStepResponseSchema, MoonPayOrderResponseSchema]);
|
|
3303
3435
|
export {
|
|
3436
|
+
BANK_TRANSFER_ENDPOINTS,
|
|
3437
|
+
BANK_TRANSFER_MAX_LISTED_ORDERS,
|
|
3438
|
+
BankTransferBankDetailsNextActionSchema,
|
|
3439
|
+
BankTransferCaptureNextActionSchema,
|
|
3440
|
+
BankTransferCaptureRequestSchema,
|
|
3441
|
+
BankTransferCheckoutSchema,
|
|
3442
|
+
BankTransferConsentNextActionSchema,
|
|
3443
|
+
BankTransferConsentRequestSchema,
|
|
3444
|
+
BankTransferDoneSchema,
|
|
3445
|
+
BankTransferErrorBodySchema,
|
|
3446
|
+
BankTransferFaultSchema,
|
|
3447
|
+
BankTransferNextActionSchema,
|
|
3448
|
+
BankTransferNextRequestSchema,
|
|
3449
|
+
BankTransferObserveRequestSchema,
|
|
3450
|
+
BankTransferOpenDepositInstructionsNextActionSchema,
|
|
3451
|
+
BankTransferOpenDepositInstructionsRequestSchema,
|
|
3452
|
+
BankTransferOrderPendingNextActionSchema,
|
|
3453
|
+
BankTransferOrderRequestSchema,
|
|
3454
|
+
BankTransferOrderResponseSchema,
|
|
3455
|
+
BankTransferRefusedSchema,
|
|
3456
|
+
BankTransferRequestContextSchema,
|
|
3457
|
+
BankTransferRequestSchema,
|
|
3458
|
+
BankTransferResponseSchemaFor,
|
|
3459
|
+
BankTransferStepResponseSchema,
|
|
3460
|
+
BankTransferWaitNextActionSchema,
|
|
3304
3461
|
BlockedReasonSchema,
|
|
3305
3462
|
BlockedStateSchema,
|
|
3306
3463
|
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'>;
|
|
85
85
|
export interface RoutingTableProvider {
|
|
86
86
|
provider: RoutingProvider;
|
|
87
87
|
next: RoutingNextStep;
|
package/dist/table.js
CHANGED
package/dist/table.mjs
CHANGED
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';
|
|
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.
|
|
3
|
+
"version": "0.58.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
|
}
|