@fun-xyz/fiat-contract 0.48.0 → 0.50.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/dist/{chunk-4ZHY4P3K.mjs → chunk-BK2XD3JT.mjs} +1 -1
- package/dist/chunk-KLAXY6H7.mjs +8 -0
- package/dist/codes.d.ts +6 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +359 -42
- package/dist/index.mjs +360 -45
- package/dist/providers/stripe.d.ts +305 -0
- package/dist/providers/stripe.js +28 -0
- package/dist/providers/stripe.mjs +6 -0
- package/dist/providers/stripe.schemas.d.ts +46 -0
- package/dist/table.js +1 -1
- package/dist/table.mjs +1 -1
- package/package.json +11 -1
- package/stripe.d.ts +1 -0
- package/stripe.js +2 -0
package/dist/codes.d.ts
CHANGED
|
@@ -1269,4 +1269,10 @@ export declare const COUNTRY_TO_CURRENCY: { [K in CountryCodeLiteral]: FiatCurre
|
|
|
1269
1269
|
/** fun-backend/provider vocabulary, not a standard — extend when a new payment rail ships. */
|
|
1270
1270
|
export declare const PAYMENT_METHOD_CATEGORIES: readonly ["card", "apple_pay", "google_pay", "bank_transfer"];
|
|
1271
1271
|
export type PaymentMethodCategory = (typeof PAYMENT_METHOD_CATEGORIES)[number];
|
|
1272
|
+
/** The EU-27 member states. */
|
|
1273
|
+
export declare const EU_COUNTRIES: readonly ["AT", "BE", "BG", "HR", "CY", "CZ", "DK", "EE", "FI", "FR", "DE", "GR", "HU", "IE", "IT", "LV", "LT", "LU", "MT", "NL", "PL", "PT", "RO", "SK", "SI", "ES", "SE"];
|
|
1274
|
+
/** The EEA-30: the EU-27 plus Iceland, Liechtenstein and Norway. */
|
|
1275
|
+
export declare const EEA_COUNTRIES: readonly ["AT", "BE", "BG", "HR", "CY", "CZ", "DK", "EE", "FI", "FR", "DE", "GR", "HU", "IE", "IT", "LV", "LT", "LU", "MT", "NL", "PL", "PT", "RO", "SK", "SI", "ES", "SE", "IS", "LI", "NO"];
|
|
1276
|
+
export declare const isEuCountry: (country: string) => boolean;
|
|
1277
|
+
export declare const isEeaCountry: (country: string) => boolean;
|
|
1272
1278
|
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -16,6 +16,8 @@ export * from './providers/moonpay';
|
|
|
16
16
|
export * from './providers/moonpay.schemas';
|
|
17
17
|
export * from './providers/coinbase';
|
|
18
18
|
export * from './providers/coinbase.schemas';
|
|
19
|
+
export * from './providers/stripe';
|
|
20
|
+
export * from './providers/stripe.schemas';
|
|
19
21
|
export { FIXTURES, FIXTURE_COVERAGE_GAPS, fixtureMeta, loadFixture, loadFixtures, type FixtureMeta, type FixtureSource, type LoadedFixture, } from './fixtures/index';
|
|
20
22
|
export * from './providers/moonpay-guest';
|
|
21
23
|
export * from './providers/moonpay-guest.schemas';
|
package/dist/index.js
CHANGED
|
@@ -62,7 +62,9 @@ __export(index_exports, {
|
|
|
62
62
|
DOCUMENTED_ENDPOINTS: () => DOCUMENTED_ENDPOINTS,
|
|
63
63
|
DeliveryStateSchema: () => DeliveryStateSchema,
|
|
64
64
|
DestinationAssetSchema: () => DestinationAssetSchema,
|
|
65
|
+
EEA_COUNTRIES: () => EEA_COUNTRIES,
|
|
65
66
|
ENDPOINT_PATTERN: () => ENDPOINT_PATTERN,
|
|
67
|
+
EU_COUNTRIES: () => EU_COUNTRIES,
|
|
66
68
|
FIAT_CURRENCY_NAMES: () => FIAT_CURRENCY_NAMES,
|
|
67
69
|
FIAT_TERMS_ENDPOINT: () => FIAT_TERMS_ENDPOINT,
|
|
68
70
|
FIELD_SPEC_TYPES: () => FIELD_SPEC_TYPES,
|
|
@@ -194,9 +196,47 @@ __export(index_exports, {
|
|
|
194
196
|
ReportSpecSchema: () => ReportSpecSchema,
|
|
195
197
|
STANDARD_KYC_FIELD_IDS: () => STANDARD_KYC_FIELD_IDS,
|
|
196
198
|
STATE_KEYS: () => STATE_KEYS,
|
|
199
|
+
STRIPE_ENDPOINTS: () => STRIPE_ENDPOINTS,
|
|
197
200
|
SelectOptionSchema: () => SelectOptionSchema,
|
|
198
201
|
SessionAuthStateSchema: () => SessionAuthStateSchema,
|
|
199
202
|
StatusHistoryEntrySchema: () => StatusHistoryEntrySchema,
|
|
203
|
+
StripeAttestationNextActionSchema: () => StripeAttestationNextActionSchema,
|
|
204
|
+
StripeAuthorizeNextActionSchema: () => StripeAuthorizeNextActionSchema,
|
|
205
|
+
StripeAuthorizeRequestSchema: () => StripeAuthorizeRequestSchema,
|
|
206
|
+
StripeCheckoutRequestSchema: () => StripeCheckoutRequestSchema,
|
|
207
|
+
StripeCheckoutResponseSchema: () => StripeCheckoutResponseSchema,
|
|
208
|
+
StripeCheckoutSchema: () => StripeCheckoutSchema,
|
|
209
|
+
StripeCheckoutSecretNextActionSchema: () => StripeCheckoutSecretNextActionSchema,
|
|
210
|
+
StripeConsentNextActionSchema: () => StripeConsentNextActionSchema,
|
|
211
|
+
StripeConsentRequestSchema: () => StripeConsentRequestSchema,
|
|
212
|
+
StripeDoneSchema: () => StripeDoneSchema,
|
|
213
|
+
StripeErrorBodySchema: () => StripeErrorBodySchema,
|
|
214
|
+
StripeFaultSchema: () => StripeFaultSchema,
|
|
215
|
+
StripeIdentifiersNextActionSchema: () => StripeIdentifiersNextActionSchema,
|
|
216
|
+
StripeKycNextActionSchema: () => StripeKycNextActionSchema,
|
|
217
|
+
StripeKycRequestSchema: () => StripeKycRequestSchema,
|
|
218
|
+
StripeLinkAuthTokenSchema: () => StripeLinkAuthTokenSchema,
|
|
219
|
+
StripeNextActionSchema: () => StripeNextActionSchema,
|
|
220
|
+
StripeNextRequestSchema: () => StripeNextRequestSchema,
|
|
221
|
+
StripeObserveRequestSchema: () => StripeObserveRequestSchema,
|
|
222
|
+
StripeOrderPendingNextActionSchema: () => StripeOrderPendingNextActionSchema,
|
|
223
|
+
StripeOrderRequestSchema: () => StripeOrderRequestSchema,
|
|
224
|
+
StripeOrderResponseSchema: () => StripeOrderResponseSchema,
|
|
225
|
+
StripePayNextActionSchema: () => StripePayNextActionSchema,
|
|
226
|
+
StripePaySheetSchema: () => StripePaySheetSchema,
|
|
227
|
+
StripePlaceOrderNextActionSchema: () => StripePlaceOrderNextActionSchema,
|
|
228
|
+
StripePlaceOrderRequestSchema: () => StripePlaceOrderRequestSchema,
|
|
229
|
+
StripePriceSchema: () => StripePriceSchema,
|
|
230
|
+
StripeReaskSchema: () => StripeReaskSchema,
|
|
231
|
+
StripeRefusedSchema: () => StripeRefusedSchema,
|
|
232
|
+
StripeRequestContextSchema: () => StripeRequestContextSchema,
|
|
233
|
+
StripeRequestSchema: () => StripeRequestSchema,
|
|
234
|
+
StripeResponseSchemaFor: () => StripeResponseSchemaFor,
|
|
235
|
+
StripeSessionNextActionSchema: () => StripeSessionNextActionSchema,
|
|
236
|
+
StripeSessionRequestSchema: () => StripeSessionRequestSchema,
|
|
237
|
+
StripeStepResponseSchema: () => StripeStepResponseSchema,
|
|
238
|
+
StripeVerifyIdentityNextActionSchema: () => StripeVerifyIdentityNextActionSchema,
|
|
239
|
+
StripeWaitNextActionSchema: () => StripeWaitNextActionSchema,
|
|
200
240
|
SurfaceKindSchema: () => SurfaceKindSchema,
|
|
201
241
|
SurfaceProviderSchema: () => SurfaceProviderSchema,
|
|
202
242
|
SurfaceSchema: () => SurfaceSchema,
|
|
@@ -222,6 +262,8 @@ __export(index_exports, {
|
|
|
222
262
|
checkLegalEmission: () => checkLegalEmission,
|
|
223
263
|
endpointMatches: () => endpointMatches,
|
|
224
264
|
fixtureMeta: () => fixtureMeta,
|
|
265
|
+
isEeaCountry: () => isEeaCountry,
|
|
266
|
+
isEuCountry: () => isEuCountry,
|
|
225
267
|
isTerminal: () => isTerminal,
|
|
226
268
|
loadFixture: () => loadFixture,
|
|
227
269
|
loadFixtures: () => loadFixtures,
|
|
@@ -554,6 +596,40 @@ var COUNTRY_NAMES = Object.fromEntries(COUNTRY_CURRENCY_LIST.map((e) => [e.count
|
|
|
554
596
|
var FIAT_CURRENCY_NAMES = Object.fromEntries(uniqueCurrencies);
|
|
555
597
|
var COUNTRY_TO_CURRENCY = Object.fromEntries(COUNTRY_CURRENCY_LIST.map((e) => [e.country, e.currency]));
|
|
556
598
|
var PAYMENT_METHOD_CATEGORIES = ["card", "apple_pay", "google_pay", "bank_transfer"];
|
|
599
|
+
var EU_COUNTRIES = [
|
|
600
|
+
"AT",
|
|
601
|
+
"BE",
|
|
602
|
+
"BG",
|
|
603
|
+
"HR",
|
|
604
|
+
"CY",
|
|
605
|
+
"CZ",
|
|
606
|
+
"DK",
|
|
607
|
+
"EE",
|
|
608
|
+
"FI",
|
|
609
|
+
"FR",
|
|
610
|
+
"DE",
|
|
611
|
+
"GR",
|
|
612
|
+
"HU",
|
|
613
|
+
"IE",
|
|
614
|
+
"IT",
|
|
615
|
+
"LV",
|
|
616
|
+
"LT",
|
|
617
|
+
"LU",
|
|
618
|
+
"MT",
|
|
619
|
+
"NL",
|
|
620
|
+
"PL",
|
|
621
|
+
"PT",
|
|
622
|
+
"RO",
|
|
623
|
+
"SK",
|
|
624
|
+
"SI",
|
|
625
|
+
"ES",
|
|
626
|
+
"SE"
|
|
627
|
+
];
|
|
628
|
+
var EEA_COUNTRIES = [...EU_COUNTRIES, "IS", "LI", "NO"];
|
|
629
|
+
var EU_COUNTRY_SET = new Set(EU_COUNTRIES);
|
|
630
|
+
var EEA_COUNTRY_SET = new Set(EEA_COUNTRIES);
|
|
631
|
+
var isEuCountry = (country) => EU_COUNTRY_SET.has(country);
|
|
632
|
+
var isEeaCountry = (country) => EEA_COUNTRY_SET.has(country);
|
|
557
633
|
|
|
558
634
|
// src/schemas.ts
|
|
559
635
|
var import_zod = require("zod");
|
|
@@ -1195,7 +1271,7 @@ var $routingTableRequest = obj({
|
|
|
1195
1271
|
providers: $routingTableProviderInputs.optional(),
|
|
1196
1272
|
destinationAsset: $destinationAsset.optional(),
|
|
1197
1273
|
depositAddress: $nonBlank.optional()
|
|
1198
|
-
}).refine((
|
|
1274
|
+
}).refine((request2) => hasUsRegion(request2.country, request2.region), { message: US_REGION_REQUIRED, path: ["region"] });
|
|
1199
1275
|
var FiatRoutingTableRequestSchema = $routingTableRequest;
|
|
1200
1276
|
var $routingTableProvider = obj({
|
|
1201
1277
|
provider: $routingProvider,
|
|
@@ -1253,9 +1329,9 @@ var $routingQuoteRequest = import_zod.z.union([
|
|
|
1253
1329
|
}),
|
|
1254
1330
|
obj({ ...$routingQuoteTermsShape, provider: $routingProvider })
|
|
1255
1331
|
]).refine(
|
|
1256
|
-
(
|
|
1257
|
-
const allowed =
|
|
1258
|
-
const selected = "providers" in
|
|
1332
|
+
(request2) => {
|
|
1333
|
+
const allowed = request2.routingOverrides?.providers;
|
|
1334
|
+
const selected = "providers" in request2 ? request2.providers : [request2.provider];
|
|
1259
1335
|
return allowed === void 0 || selected.every((provider) => allowed.includes(provider));
|
|
1260
1336
|
},
|
|
1261
1337
|
{ message: "requested providers must be allowed by routingOverrides", path: ["routingOverrides"] }
|
|
@@ -1397,7 +1473,7 @@ var $stepResponse = import_zod.z.union([$providerBoundStepResponse, $funAuthStep
|
|
|
1397
1473
|
var FiatStepResponseSchema = $stepResponse;
|
|
1398
1474
|
|
|
1399
1475
|
// package.json
|
|
1400
|
-
var version = "0.
|
|
1476
|
+
var version = "0.50.0";
|
|
1401
1477
|
|
|
1402
1478
|
// src/table.ts
|
|
1403
1479
|
var TABLE_VERSION = version;
|
|
@@ -3298,14 +3374,14 @@ function walkTable(fn) {
|
|
|
3298
3374
|
function assertFixture(id) {
|
|
3299
3375
|
const meta = fixtureMeta(id);
|
|
3300
3376
|
const json = loadFixture(id);
|
|
3301
|
-
const
|
|
3302
|
-
if (stateKey(
|
|
3377
|
+
const stepResponse2 = assertFiatStepResponse(json);
|
|
3378
|
+
if (stateKey(stepResponse2.state) !== meta.stateKey) {
|
|
3303
3379
|
throw new ContractViolation(
|
|
3304
|
-
`fixture ${id}: manifest says ${meta.stateKey}, step response carries ${stateKey(
|
|
3380
|
+
`fixture ${id}: manifest says ${meta.stateKey}, step response carries ${stateKey(stepResponse2.state)}`
|
|
3305
3381
|
);
|
|
3306
3382
|
}
|
|
3307
|
-
assertLegalEmission(
|
|
3308
|
-
return { meta, stepResponse };
|
|
3383
|
+
assertLegalEmission(stepResponse2.state, stepResponse2.transitions);
|
|
3384
|
+
return { meta, stepResponse: stepResponse2 };
|
|
3309
3385
|
}
|
|
3310
3386
|
function assertAllFixtures() {
|
|
3311
3387
|
return FIXTURES.map((meta) => assertFixture(meta.id));
|
|
@@ -3829,31 +3905,272 @@ var $errorBody2 = obj3({
|
|
|
3829
3905
|
});
|
|
3830
3906
|
var CoinbaseErrorBodySchema = $errorBody2;
|
|
3831
3907
|
|
|
3832
|
-
// src/providers/
|
|
3908
|
+
// src/providers/stripe.ts
|
|
3909
|
+
var STRIPE_ENDPOINTS = {
|
|
3910
|
+
next: "POST /fiat/next"
|
|
3911
|
+
};
|
|
3912
|
+
|
|
3913
|
+
// src/providers/stripe.schemas.ts
|
|
3833
3914
|
var import_zod4 = require("zod");
|
|
3834
|
-
var context = { checkout: MoonPayCheckoutSchema, destinationAsset: DestinationAssetSchema.optional() };
|
|
3835
3915
|
var obj4 = (shape) => import_zod4.z.object(shape).strict();
|
|
3836
3916
|
var nonEmpty = import_zod4.z.string().refine((value) => value.trim().length > 0, "must not be blank");
|
|
3917
|
+
var hasUniqueIds4 = (ids) => new Set(ids).size === ids.length;
|
|
3918
|
+
var retryAfterMs = import_zod4.z.number().int().positive().max(6e4);
|
|
3919
|
+
var centsAmount = import_zod4.z.string().regex(/^(?:0|[1-9]\d*)(?:\.\d{1,2})?$/, "must be an amount in cents").refine((amount) => Number(amount) > 0, "must be positive");
|
|
3920
|
+
var kycValues = import_zod4.z.record(KycFieldIdSchema, import_zod4.z.string());
|
|
3921
|
+
var instant = import_zod4.z.string().datetime({ offset: true });
|
|
3922
|
+
var chargeCurrency = import_zod4.z.enum(["USD", "EUR"]);
|
|
3923
|
+
var countryCode = import_zod4.z.enum(Object.keys(CountryCode));
|
|
3924
|
+
var checkout = obj4({
|
|
3925
|
+
amount: obj4({ currency: chargeCurrency, amount: centsAmount }),
|
|
3926
|
+
destination: obj4({ asset: nonEmpty, network: nonEmpty }),
|
|
3927
|
+
paymentMethod: import_zod4.z.literal("apple_pay")
|
|
3928
|
+
});
|
|
3929
|
+
var StripeCheckoutSchema = checkout;
|
|
3930
|
+
var contextFields2 = { checkout };
|
|
3931
|
+
var requestContext = obj4(contextFields2);
|
|
3932
|
+
var StripeRequestContextSchema = requestContext;
|
|
3933
|
+
var mintedOrderId = import_zod4.z.string().regex(/^sto_[A-Za-z0-9_-]{22}$/, "must be an order id a placeOrder answer minted");
|
|
3934
|
+
var heldOrder = { orderId: mintedOrderId.optional() };
|
|
3935
|
+
var observeFields2 = { action: import_zod4.z.literal("observe"), ...heldOrder };
|
|
3936
|
+
var consentFields2 = {
|
|
3937
|
+
action: import_zod4.z.literal("consent"),
|
|
3938
|
+
acceptances: import_zod4.z.array(TermsDocumentAcceptanceSchema).min(1).refine((acceptances) => hasUniqueIds4(acceptances.map((acceptance) => acceptance.documentId)), "each document is accepted once"),
|
|
3939
|
+
...heldOrder
|
|
3940
|
+
};
|
|
3941
|
+
var sessionFields = { action: import_zod4.z.literal("session"), ...heldOrder };
|
|
3942
|
+
var authorizeConsentedFields = {
|
|
3943
|
+
action: import_zod4.z.literal("authorize"),
|
|
3944
|
+
linkAuthIntentId: nonEmpty,
|
|
3945
|
+
outcome: import_zod4.z.literal("Consented"),
|
|
3946
|
+
customerId: nonEmpty,
|
|
3947
|
+
...heldOrder
|
|
3948
|
+
};
|
|
3949
|
+
var authorizeDeclinedFields = { action: import_zod4.z.literal("authorize"), linkAuthIntentId: nonEmpty, outcome: import_zod4.z.enum(["Denied", "Cancelled"]), ...heldOrder };
|
|
3950
|
+
var correctionRound = import_zod4.z.number().int().nonnegative();
|
|
3951
|
+
var kycFields2 = { action: import_zod4.z.literal("kyc"), correctionRound, values: kycValues, ...heldOrder };
|
|
3952
|
+
var placeOrderFields2 = { action: import_zod4.z.literal("placeOrder"), orderId: mintedOrderId, cryptoPaymentToken: nonEmpty };
|
|
3953
|
+
var checkoutFields = { action: import_zod4.z.literal("checkout"), orderId: mintedOrderId, callbackId: import_zod4.z.string().regex(/^[A-Za-z0-9_-]{1,200}$/) };
|
|
3954
|
+
var orderFields2 = { action: import_zod4.z.literal("order"), orderId: mintedOrderId };
|
|
3955
|
+
var observeRequest = obj4({ ...contextFields2, ...observeFields2 });
|
|
3956
|
+
var consentRequest = obj4({ ...contextFields2, ...consentFields2 });
|
|
3957
|
+
var sessionRequest = obj4({ ...contextFields2, ...sessionFields });
|
|
3958
|
+
var authorizeRequest = import_zod4.z.union([obj4({ ...contextFields2, ...authorizeConsentedFields }), obj4({ ...contextFields2, ...authorizeDeclinedFields })]);
|
|
3959
|
+
var kycRequest = obj4({ ...contextFields2, ...kycFields2 });
|
|
3960
|
+
var placeOrderRequest = obj4({ ...contextFields2, ...placeOrderFields2 });
|
|
3961
|
+
var checkoutRequest = obj4({ ...contextFields2, ...checkoutFields });
|
|
3962
|
+
var orderRequest = obj4({ ...contextFields2, ...orderFields2 });
|
|
3963
|
+
var StripeObserveRequestSchema = observeRequest;
|
|
3964
|
+
var StripeConsentRequestSchema = consentRequest;
|
|
3965
|
+
var StripeSessionRequestSchema = sessionRequest;
|
|
3966
|
+
var StripeAuthorizeRequestSchema = authorizeRequest;
|
|
3967
|
+
var StripeKycRequestSchema = kycRequest;
|
|
3968
|
+
var StripePlaceOrderRequestSchema = placeOrderRequest;
|
|
3969
|
+
var StripeCheckoutRequestSchema = checkoutRequest;
|
|
3970
|
+
var StripeOrderRequestSchema = orderRequest;
|
|
3971
|
+
var request = import_zod4.z.union([observeRequest, consentRequest, sessionRequest, authorizeRequest, kycRequest, placeOrderRequest, checkoutRequest, orderRequest]);
|
|
3972
|
+
var StripeRequestSchema = request;
|
|
3973
|
+
var envelope2 = { provider: import_zod4.z.literal("STRIPE"), geo: FiatGeoSchema, ...contextFields2 };
|
|
3974
|
+
var nextRequest = import_zod4.z.union([
|
|
3975
|
+
obj4({ ...envelope2, ...observeFields2 }),
|
|
3976
|
+
obj4({ ...envelope2, ...consentFields2 }),
|
|
3977
|
+
obj4({ ...envelope2, ...sessionFields }),
|
|
3978
|
+
obj4({ ...envelope2, ...authorizeConsentedFields }),
|
|
3979
|
+
obj4({ ...envelope2, ...authorizeDeclinedFields }),
|
|
3980
|
+
obj4({ ...envelope2, ...kycFields2 }),
|
|
3981
|
+
obj4({ ...envelope2, ...placeOrderFields2 }),
|
|
3982
|
+
obj4({ ...envelope2, ...checkoutFields }),
|
|
3983
|
+
obj4({ ...envelope2, ...orderFields2 })
|
|
3984
|
+
]);
|
|
3985
|
+
var StripeNextRequestSchema = nextRequest;
|
|
3986
|
+
var price = obj4({ total: FiatAmountSchema, fees: import_zod4.z.array(FeeLineSchema), cryptoAmount: nonEmpty });
|
|
3987
|
+
var StripePriceSchema = price;
|
|
3988
|
+
var paySheet = obj4({
|
|
3989
|
+
destinationCurrency: nonEmpty,
|
|
3990
|
+
destinationNetwork: nonEmpty,
|
|
3991
|
+
walletAddress: nonEmpty,
|
|
3992
|
+
merchantCountryCode: countryCode,
|
|
3993
|
+
currencyCode: chargeCurrency,
|
|
3994
|
+
amount: centsAmount,
|
|
3995
|
+
label: nonEmpty
|
|
3996
|
+
});
|
|
3997
|
+
var StripePaySheetSchema = paySheet;
|
|
3998
|
+
var linkAuthToken = obj4({ clientSecret: nonEmpty, expiresAt: instant });
|
|
3999
|
+
var StripeLinkAuthTokenSchema = linkAuthToken;
|
|
4000
|
+
var reask = obj4({
|
|
4001
|
+
requirements: import_zod4.z.array(KycFieldIdSchema).min(1).refine(hasUniqueIds4, "requirements must be unique"),
|
|
4002
|
+
reason: import_zod4.z.enum(["REJECTED"]).nullable()
|
|
4003
|
+
});
|
|
4004
|
+
var StripeReaskSchema = reask;
|
|
4005
|
+
var consentShape = obj4({ next: import_zod4.z.literal("consent"), documents: import_zod4.z.array(TermsDocumentSchema).min(1) });
|
|
4006
|
+
var sessionNextAction = obj4({ next: import_zod4.z.literal("session") });
|
|
4007
|
+
var authorizeNextAction = obj4({ next: import_zod4.z.literal("authorize"), linkAuthIntentId: nonEmpty, expiresAt: instant });
|
|
4008
|
+
var kycShape = obj4({
|
|
4009
|
+
next: import_zod4.z.literal("kyc"),
|
|
4010
|
+
round: import_zod4.z.enum(["ACCOUNT", "IDENTITY"]),
|
|
4011
|
+
tier: import_zod4.z.enum(["l0", "l1", "l2"]),
|
|
4012
|
+
correctionRound,
|
|
4013
|
+
fields: import_zod4.z.array(FormFieldSchema),
|
|
4014
|
+
heldValues: kycValues,
|
|
4015
|
+
verifiedEmail: nonEmpty.nullable(),
|
|
4016
|
+
linkAuthToken: linkAuthToken.nullable(),
|
|
4017
|
+
fieldErrors: import_zod4.z.array(obj4({ fieldId: nonEmpty, message: nonEmpty })).min(1).optional(),
|
|
4018
|
+
reask: reask.nullable()
|
|
4019
|
+
});
|
|
4020
|
+
var identifiersNextAction = obj4({ next: import_zod4.z.literal("identifiers"), linkAuthToken: linkAuthToken.nullable() });
|
|
4021
|
+
var attestationNextAction = obj4({ next: import_zod4.z.literal("attestation"), linkAuthToken: linkAuthToken.nullable() });
|
|
4022
|
+
var verifyIdentityNextAction = obj4({ next: import_zod4.z.literal("verifyIdentity"), linkAuthToken: linkAuthToken.nullable() });
|
|
4023
|
+
var waitNextAction = obj4({ next: import_zod4.z.literal("wait"), retryAfterMs });
|
|
4024
|
+
var placeOrderNextAction = obj4({
|
|
4025
|
+
next: import_zod4.z.literal("placeOrder"),
|
|
4026
|
+
orderId: mintedOrderId,
|
|
4027
|
+
price,
|
|
4028
|
+
paySheet,
|
|
4029
|
+
linkAuthToken: linkAuthToken.nullable()
|
|
4030
|
+
});
|
|
4031
|
+
var payNextAction = obj4({ next: import_zod4.z.literal("pay"), orderId: mintedOrderId, sessionId: nonEmpty, linkAuthToken: linkAuthToken.nullable() });
|
|
4032
|
+
var checkoutSecretNextAction = obj4({ next: import_zod4.z.literal("checkoutSecret"), clientSecret: nonEmpty });
|
|
4033
|
+
var orderPendingNextAction = obj4({
|
|
4034
|
+
next: import_zod4.z.literal("orderPending"),
|
|
4035
|
+
orderId: mintedOrderId,
|
|
4036
|
+
retryAfterMs,
|
|
4037
|
+
order: FiatStepResponseSchema.nullable()
|
|
4038
|
+
});
|
|
4039
|
+
var checkConsent3 = (nextAction, context2) => {
|
|
4040
|
+
if (!hasUniqueIds4(nextAction.documents.map((document) => document.id))) {
|
|
4041
|
+
context2.addIssue({ code: "custom", path: ["documents"], message: "document ids must be unique" });
|
|
4042
|
+
}
|
|
4043
|
+
};
|
|
4044
|
+
var checkKyc3 = (nextAction, context2) => {
|
|
4045
|
+
const fieldIds = nextAction.fields.map((field) => field.id);
|
|
4046
|
+
if (!hasUniqueIds4(fieldIds)) {
|
|
4047
|
+
context2.addIssue({ code: "custom", path: ["fields"], message: "field ids must be unique" });
|
|
4048
|
+
}
|
|
4049
|
+
if (nextAction.fieldErrors?.some((error) => !fieldIds.includes(error.fieldId))) {
|
|
4050
|
+
context2.addIssue({ code: "custom", path: ["fieldErrors"], message: "a field error must name a field in this next action" });
|
|
4051
|
+
}
|
|
4052
|
+
if (nextAction.reask?.requirements.some((requirement) => !fieldIds.includes(requirement))) {
|
|
4053
|
+
context2.addIssue({ code: "custom", path: ["reask"], message: "a kyc reask must name fields in this next action" });
|
|
4054
|
+
}
|
|
4055
|
+
if (nextAction.round === "ACCOUNT" !== (nextAction.verifiedEmail !== null)) {
|
|
4056
|
+
context2.addIssue({ code: "custom", path: ["verifiedEmail"], message: "only the account round carries the verified email" });
|
|
4057
|
+
}
|
|
4058
|
+
if (nextAction.tier === "l2" && nextAction.round !== "IDENTITY") {
|
|
4059
|
+
context2.addIssue({ code: "custom", path: ["tier"], message: "l2 is an identity round" });
|
|
4060
|
+
}
|
|
4061
|
+
};
|
|
4062
|
+
var checkPlaceOrder = (nextAction, context2) => {
|
|
4063
|
+
if (nextAction.paySheet.amount !== nextAction.price.total.amount) {
|
|
4064
|
+
context2.addIssue({ code: "custom", path: ["paySheet", "amount"], message: "the sheet charges the price shown" });
|
|
4065
|
+
}
|
|
4066
|
+
if (nextAction.paySheet.currencyCode !== nextAction.price.total.currency) {
|
|
4067
|
+
context2.addIssue({ code: "custom", path: ["paySheet", "currencyCode"], message: "the sheet charges the price currency" });
|
|
4068
|
+
}
|
|
4069
|
+
};
|
|
4070
|
+
var StripeConsentNextActionSchema = consentShape.superRefine(checkConsent3);
|
|
4071
|
+
var StripeSessionNextActionSchema = sessionNextAction;
|
|
4072
|
+
var StripeAuthorizeNextActionSchema = authorizeNextAction;
|
|
4073
|
+
var StripeKycNextActionSchema = kycShape.superRefine(checkKyc3);
|
|
4074
|
+
var StripeIdentifiersNextActionSchema = identifiersNextAction;
|
|
4075
|
+
var StripeAttestationNextActionSchema = attestationNextAction;
|
|
4076
|
+
var StripeVerifyIdentityNextActionSchema = verifyIdentityNextAction;
|
|
4077
|
+
var StripeWaitNextActionSchema = waitNextAction;
|
|
4078
|
+
var StripePlaceOrderNextActionSchema = placeOrderNextAction.superRefine(checkPlaceOrder);
|
|
4079
|
+
var StripePayNextActionSchema = payNextAction;
|
|
4080
|
+
var StripeCheckoutSecretNextActionSchema = checkoutSecretNextAction;
|
|
4081
|
+
var StripeOrderPendingNextActionSchema = orderPendingNextAction;
|
|
4082
|
+
var checkNextAction3 = (response, context2) => {
|
|
4083
|
+
if (response.next === "consent") checkConsent3(response, context2);
|
|
4084
|
+
if (response.next === "kyc") checkKyc3(response, context2);
|
|
4085
|
+
if (response.next === "placeOrder") checkPlaceOrder(response, context2);
|
|
4086
|
+
};
|
|
4087
|
+
var nextActionOptions = [
|
|
4088
|
+
consentShape,
|
|
4089
|
+
sessionNextAction,
|
|
4090
|
+
authorizeNextAction,
|
|
4091
|
+
kycShape,
|
|
4092
|
+
identifiersNextAction,
|
|
4093
|
+
attestationNextAction,
|
|
4094
|
+
verifyIdentityNextAction,
|
|
4095
|
+
waitNextAction,
|
|
4096
|
+
placeOrderNextAction,
|
|
4097
|
+
payNextAction,
|
|
4098
|
+
orderPendingNextAction
|
|
4099
|
+
];
|
|
4100
|
+
var anyNextAction = import_zod4.z.discriminatedUnion("next", [...nextActionOptions]).superRefine(checkNextAction3);
|
|
4101
|
+
var StripeNextActionSchema = anyNextAction;
|
|
4102
|
+
var done = obj4({ next: import_zod4.z.literal("done"), order: FiatStepResponseSchema });
|
|
4103
|
+
var StripeDoneSchema = done;
|
|
4104
|
+
var refused = import_zod4.z.union([
|
|
4105
|
+
obj4({
|
|
4106
|
+
next: import_zod4.z.literal("refused"),
|
|
4107
|
+
reason: import_zod4.z.enum(["NOT_ELIGIBLE", "KYC_REJECTED", "FINAL_REJECTION", "TOTAL_MISMATCH"]),
|
|
4108
|
+
recovery: import_zod4.z.enum(["REQUOTE", "NONE"])
|
|
4109
|
+
}),
|
|
4110
|
+
obj4({
|
|
4111
|
+
next: import_zod4.z.literal("refused"),
|
|
4112
|
+
reason: import_zod4.z.literal("LIMITS_EXCEEDED"),
|
|
4113
|
+
recovery: import_zod4.z.literal("REQUOTE"),
|
|
4114
|
+
maxAmount: FiatAmountSchema.nullable()
|
|
4115
|
+
})
|
|
4116
|
+
]);
|
|
4117
|
+
var StripeRefusedSchema = refused;
|
|
4118
|
+
var stepResponse = import_zod4.z.union([import_zod4.z.discriminatedUnion("next", [...nextActionOptions, done]), refused]).superRefine(checkNextAction3);
|
|
4119
|
+
var StripeStepResponseSchema = stepResponse;
|
|
4120
|
+
var checkoutResponse = import_zod4.z.union([import_zod4.z.discriminatedUnion("next", [...nextActionOptions, done, checkoutSecretNextAction]), refused]).superRefine(checkNextAction3);
|
|
4121
|
+
var StripeCheckoutResponseSchema = checkoutResponse;
|
|
4122
|
+
var orderResponse = import_zod4.z.discriminatedUnion("next", [done, orderPendingNextAction]);
|
|
4123
|
+
var StripeOrderResponseSchema = orderResponse;
|
|
4124
|
+
var StripeResponseSchemaFor = {
|
|
4125
|
+
observe: StripeStepResponseSchema,
|
|
4126
|
+
consent: StripeStepResponseSchema,
|
|
4127
|
+
session: StripeStepResponseSchema,
|
|
4128
|
+
authorize: StripeStepResponseSchema,
|
|
4129
|
+
kyc: StripeStepResponseSchema,
|
|
4130
|
+
placeOrder: StripeStepResponseSchema,
|
|
4131
|
+
checkout: StripeCheckoutResponseSchema,
|
|
4132
|
+
order: StripeOrderResponseSchema
|
|
4133
|
+
};
|
|
4134
|
+
var faultFields2 = {
|
|
4135
|
+
reason: import_zod4.z.enum(["SESSION_BUDGET_SPENT", "RATE_LIMITED", "PROVIDER_UNAVAILABLE", "KYC_PROVIDER_UNAVAILABLE", "SERVICE_UNAVAILABLE", "INVALID_REQUEST"]),
|
|
4136
|
+
recovery: import_zod4.z.enum(["RETRY", "REQUOTE", "NONE"])
|
|
4137
|
+
};
|
|
4138
|
+
var fault = obj4(faultFields2);
|
|
4139
|
+
var StripeFaultSchema = fault;
|
|
4140
|
+
var errorBody = obj4({
|
|
4141
|
+
...faultFields2,
|
|
4142
|
+
errorCode: nonEmpty,
|
|
4143
|
+
errorMsg: import_zod4.z.string(),
|
|
4144
|
+
reqId: import_zod4.z.string().optional(),
|
|
4145
|
+
retryAfterSeconds: import_zod4.z.number().int().nonnegative().optional()
|
|
4146
|
+
});
|
|
4147
|
+
var StripeErrorBodySchema = errorBody;
|
|
4148
|
+
|
|
4149
|
+
// src/providers/moonpay-guest.schemas.ts
|
|
4150
|
+
var import_zod5 = require("zod");
|
|
4151
|
+
var context = { checkout: MoonPayCheckoutSchema, destinationAsset: DestinationAssetSchema.optional() };
|
|
4152
|
+
var obj5 = (shape) => import_zod5.z.object(shape).strict();
|
|
4153
|
+
var nonEmpty2 = import_zod5.z.string().refine((value) => value.trim().length > 0, "must not be blank");
|
|
3837
4154
|
var actions = [
|
|
3838
|
-
{ action:
|
|
3839
|
-
{ action:
|
|
3840
|
-
{ action:
|
|
3841
|
-
{ action:
|
|
3842
|
-
{ action:
|
|
3843
|
-
{ action:
|
|
3844
|
-
{ action:
|
|
3845
|
-
{ action:
|
|
4155
|
+
{ action: import_zod5.z.literal("observe") },
|
|
4156
|
+
{ action: import_zod5.z.literal("session") },
|
|
4157
|
+
{ 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") },
|
|
4158
|
+
{ action: import_zod5.z.literal("order"), orderId: nonEmpty2, quotedAmount: FiatAmountSchema, transactionId: nonEmpty2.optional() },
|
|
4159
|
+
{ action: import_zod5.z.literal("phone"), phoneNumber: import_zod5.z.string().regex(/^\+[1-9]\d{1,14}$/) },
|
|
4160
|
+
{ action: import_zod5.z.literal("phone"), resend: nonEmpty2 },
|
|
4161
|
+
{ action: import_zod5.z.literal("phoneCode"), verificationRef: nonEmpty2, otpCode: import_zod5.z.string().regex(/^\d{6}$/) },
|
|
4162
|
+
{ action: import_zod5.z.literal("decline"), reason: MoonPayGuestDeclineReasonSchema }
|
|
3846
4163
|
];
|
|
3847
|
-
var MoonPayGuestObserveRequestSchema =
|
|
3848
|
-
var MoonPayGuestSessionRequestSchema =
|
|
3849
|
-
var MoonPayGuestConsentRequestSchema =
|
|
3850
|
-
var MoonPayGuestOrderRequestSchema =
|
|
3851
|
-
var MoonPayGuestPhoneNumberRequestSchema =
|
|
3852
|
-
var MoonPayGuestPhoneResendRequestSchema =
|
|
3853
|
-
var MoonPayGuestPhoneCodeRequestSchema =
|
|
3854
|
-
var MoonPayGuestDeclineRequestSchema =
|
|
3855
|
-
var MoonPayGuestPhoneRequestSchema =
|
|
3856
|
-
var MoonPayGuestRequestSchema =
|
|
4164
|
+
var MoonPayGuestObserveRequestSchema = obj5({ ...context, ...actions[0] });
|
|
4165
|
+
var MoonPayGuestSessionRequestSchema = obj5({ ...context, ...actions[1] });
|
|
4166
|
+
var MoonPayGuestConsentRequestSchema = obj5({ ...context, ...actions[2] });
|
|
4167
|
+
var MoonPayGuestOrderRequestSchema = obj5({ ...context, ...actions[3] });
|
|
4168
|
+
var MoonPayGuestPhoneNumberRequestSchema = obj5({ ...context, ...actions[4] });
|
|
4169
|
+
var MoonPayGuestPhoneResendRequestSchema = obj5({ ...context, ...actions[5] });
|
|
4170
|
+
var MoonPayGuestPhoneCodeRequestSchema = obj5({ ...context, ...actions[6] });
|
|
4171
|
+
var MoonPayGuestDeclineRequestSchema = obj5({ ...context, ...actions[7] });
|
|
4172
|
+
var MoonPayGuestPhoneRequestSchema = import_zod5.z.union([MoonPayGuestPhoneNumberRequestSchema, MoonPayGuestPhoneResendRequestSchema]);
|
|
4173
|
+
var MoonPayGuestRequestSchema = import_zod5.z.union([
|
|
3857
4174
|
MoonPayGuestObserveRequestSchema,
|
|
3858
4175
|
MoonPayGuestSessionRequestSchema,
|
|
3859
4176
|
MoonPayGuestConsentRequestSchema,
|
|
@@ -3863,22 +4180,22 @@ var MoonPayGuestRequestSchema = import_zod4.z.union([
|
|
|
3863
4180
|
MoonPayGuestPhoneCodeRequestSchema,
|
|
3864
4181
|
MoonPayGuestDeclineRequestSchema
|
|
3865
4182
|
]);
|
|
3866
|
-
var MoonPayGuestNextRequestSchema =
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
4183
|
+
var MoonPayGuestNextRequestSchema = import_zod5.z.union([
|
|
4184
|
+
obj5({ provider: import_zod5.z.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty2.optional(), ...context, ...actions[0] }),
|
|
4185
|
+
obj5({ provider: import_zod5.z.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty2.optional(), ...context, ...actions[1] }),
|
|
4186
|
+
obj5({ provider: import_zod5.z.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty2.optional(), ...context, ...actions[2] }),
|
|
4187
|
+
obj5({ provider: import_zod5.z.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty2.optional(), ...context, ...actions[3] }),
|
|
4188
|
+
obj5({ provider: import_zod5.z.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty2.optional(), ...context, ...actions[4] }),
|
|
4189
|
+
obj5({ provider: import_zod5.z.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty2.optional(), ...context, ...actions[5] }),
|
|
4190
|
+
obj5({ provider: import_zod5.z.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty2.optional(), ...context, ...actions[6] }),
|
|
4191
|
+
obj5({ provider: import_zod5.z.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty2.optional(), ...context, ...actions[7] })
|
|
3875
4192
|
]);
|
|
3876
|
-
var MoonPayGuestStepResponseSchema =
|
|
4193
|
+
var MoonPayGuestStepResponseSchema = import_zod5.z.union([
|
|
3877
4194
|
MoonPayConsentNextActionSchema,
|
|
3878
4195
|
MoonPaySessionNextActionSchema,
|
|
3879
4196
|
MoonPayPhoneNextActionSchema,
|
|
3880
4197
|
MoonPayPhoneCodeNextActionSchema,
|
|
3881
4198
|
MoonPayPayNextActionSchema,
|
|
3882
|
-
|
|
4199
|
+
obj5({ next: import_zod5.z.literal("refused"), reason: import_zod5.z.enum(["NOT_ELIGIBLE", "FINAL_REJECTION"]), recovery: import_zod5.z.enum(["REQUOTE", "NONE"]) })
|
|
3883
4200
|
]);
|
|
3884
|
-
var MoonPayGuestResponseSchema =
|
|
4201
|
+
var MoonPayGuestResponseSchema = import_zod5.z.union([MoonPayGuestStepResponseSchema, MoonPayOrderResponseSchema]);
|