@fun-xyz/fiat-contract 0.46.0 → 0.47.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -0
- package/dist/{chunk-IAKK466V.mjs → chunk-JMJ45E27.mjs} +1 -1
- package/dist/chunk-LTJWGDSA.mjs +0 -0
- package/dist/{chunk-2CCO7UIS.mjs → chunk-TIQALG7X.mjs} +2 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +131 -63
- package/dist/index.mjs +131 -63
- package/dist/providers/moonpay-guest.d.ts +12 -0
- package/dist/providers/moonpay-guest.js +18 -0
- package/dist/providers/moonpay-guest.mjs +1 -0
- package/dist/providers/moonpay-guest.schemas.d.ts +36 -0
- package/dist/providers/moonpay.d.ts +45 -16
- package/dist/providers/moonpay.schemas.d.ts +5 -2
- package/dist/routing.d.ts +2 -8
- package/dist/schemas.d.ts +1 -2
- package/dist/table.js +1 -1
- package/dist/table.mjs +1 -1
- package/dist/terms.js +2 -1
- package/dist/terms.mjs +1 -1
- package/dist/types.d.ts +3 -13
- package/package.json +10 -2
package/README.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Fiat contract
|
|
2
|
+
|
|
3
|
+
## MoonPay guest provider
|
|
4
|
+
|
|
5
|
+
`MOONPAY_GUEST` owns guest checkout on `POST /fiat/next`; regular `MOONPAY` retains customer connection and KYC.
|
|
6
|
+
Select guest checkout through `routingOverrides.providers` on a quote (or the ordered `providers` list on a routing quote).
|
|
7
|
+
The backend requires explicit client selection and its own enablement switch. A guest quote answers `handoff: { provider: "MOONPAY_GUEST" }`.
|
|
8
|
+
Send `provider: "MOONPAY_GUEST"` on every next request, with no `path` or customer credentials.
|
|
9
|
+
After a guest refusal with `REQUOTE`, omit `MOONPAY_GUEST` from the next selection so `MOONPAY` remains available.
|
|
10
|
+
The separate `./moonpay-guest` entry exports its wire types; schemas are exported from the root.
|
|
File without changes
|
|
@@ -32,7 +32,8 @@ var MOONPAY_KYC_SHARING = {
|
|
|
32
32
|
links: [{ label: "Persona Privacy Policy", url: "https://withpersona.com/legal/privacy-policy" }]
|
|
33
33
|
};
|
|
34
34
|
var PROVIDER_CHECKOUT_DOCUMENTS = {
|
|
35
|
-
MOONPAY: [MOONPAY_TERMS]
|
|
35
|
+
MOONPAY: [MOONPAY_TERMS],
|
|
36
|
+
MOONPAY_GUEST: [MOONPAY_TERMS]
|
|
36
37
|
};
|
|
37
38
|
var PROVIDER_KYC_DOCUMENTS = {
|
|
38
39
|
MOONPAY: [MOONPAY_KYC_SHARING]
|
package/dist/index.d.ts
CHANGED
|
@@ -17,3 +17,5 @@ export * from './providers/moonpay.schemas';
|
|
|
17
17
|
export * from './providers/coinbase';
|
|
18
18
|
export * from './providers/coinbase.schemas';
|
|
19
19
|
export { FIXTURES, FIXTURE_COVERAGE_GAPS, fixtureMeta, loadFixture, loadFixtures, type FixtureMeta, type FixtureSource, type LoadedFixture, } from './fixtures/index';
|
|
20
|
+
export * from './providers/moonpay-guest';
|
|
21
|
+
export * from './providers/moonpay-guest.schemas';
|
package/dist/index.js
CHANGED
|
@@ -81,7 +81,6 @@ __export(index_exports, {
|
|
|
81
81
|
FiatCurrencyCode: () => FiatCurrencyCode,
|
|
82
82
|
FiatEndpointSchema: () => FiatEndpointSchema,
|
|
83
83
|
FiatGeoSchema: () => FiatGeoSchema,
|
|
84
|
-
FiatHandoffPathSchema: () => FiatHandoffPathSchema,
|
|
85
84
|
FiatNextRequestSchema: () => FiatNextRequestSchema,
|
|
86
85
|
FiatProviderSchema: () => FiatProviderSchema,
|
|
87
86
|
FiatRoutingQuoteErrorBodySchema: () => FiatRoutingQuoteErrorBodySchema,
|
|
@@ -127,7 +126,20 @@ __export(index_exports, {
|
|
|
127
126
|
MoonPayDoneSchema: () => MoonPayDoneSchema,
|
|
128
127
|
MoonPayErrorBodySchema: () => MoonPayErrorBodySchema,
|
|
129
128
|
MoonPayFaultSchema: () => MoonPayFaultSchema,
|
|
129
|
+
MoonPayGuestConsentRequestSchema: () => MoonPayGuestConsentRequestSchema,
|
|
130
130
|
MoonPayGuestDeclineReasonSchema: () => MoonPayGuestDeclineReasonSchema,
|
|
131
|
+
MoonPayGuestDeclineRequestSchema: () => MoonPayGuestDeclineRequestSchema,
|
|
132
|
+
MoonPayGuestNextRequestSchema: () => MoonPayGuestNextRequestSchema,
|
|
133
|
+
MoonPayGuestObserveRequestSchema: () => MoonPayGuestObserveRequestSchema,
|
|
134
|
+
MoonPayGuestOrderRequestSchema: () => MoonPayGuestOrderRequestSchema,
|
|
135
|
+
MoonPayGuestPhoneCodeRequestSchema: () => MoonPayGuestPhoneCodeRequestSchema,
|
|
136
|
+
MoonPayGuestPhoneNumberRequestSchema: () => MoonPayGuestPhoneNumberRequestSchema,
|
|
137
|
+
MoonPayGuestPhoneRequestSchema: () => MoonPayGuestPhoneRequestSchema,
|
|
138
|
+
MoonPayGuestPhoneResendRequestSchema: () => MoonPayGuestPhoneResendRequestSchema,
|
|
139
|
+
MoonPayGuestRequestSchema: () => MoonPayGuestRequestSchema,
|
|
140
|
+
MoonPayGuestResponseSchema: () => MoonPayGuestResponseSchema,
|
|
141
|
+
MoonPayGuestSessionRequestSchema: () => MoonPayGuestSessionRequestSchema,
|
|
142
|
+
MoonPayGuestStepResponseSchema: () => MoonPayGuestStepResponseSchema,
|
|
131
143
|
MoonPayKycNextActionSchema: () => MoonPayKycNextActionSchema,
|
|
132
144
|
MoonPayKycRequestSchema: () => MoonPayKycRequestSchema,
|
|
133
145
|
MoonPayNextActionSchema: () => MoonPayNextActionSchema,
|
|
@@ -137,8 +149,11 @@ __export(index_exports, {
|
|
|
137
149
|
MoonPayOrderPendingNextActionSchema: () => MoonPayOrderPendingNextActionSchema,
|
|
138
150
|
MoonPayOrderRequestSchema: () => MoonPayOrderRequestSchema,
|
|
139
151
|
MoonPayOrderResponseSchema: () => MoonPayOrderResponseSchema,
|
|
140
|
-
MoonPayPathSchema: () => MoonPayPathSchema,
|
|
141
152
|
MoonPayPayNextActionSchema: () => MoonPayPayNextActionSchema,
|
|
153
|
+
MoonPayPhoneCodeNextActionSchema: () => MoonPayPhoneCodeNextActionSchema,
|
|
154
|
+
MoonPayPhoneCodeRequestSchema: () => MoonPayPhoneCodeRequestSchema,
|
|
155
|
+
MoonPayPhoneNextActionSchema: () => MoonPayPhoneNextActionSchema,
|
|
156
|
+
MoonPayPhoneRequestSchema: () => MoonPayPhoneRequestSchema,
|
|
142
157
|
MoonPayPrepareCaptureNextActionSchema: () => MoonPayPrepareCaptureNextActionSchema,
|
|
143
158
|
MoonPayPrepareCaptureRequestSchema: () => MoonPayPrepareCaptureRequestSchema,
|
|
144
159
|
MoonPayQuoteInputSchema: () => MoonPayQuoteInputSchema,
|
|
@@ -564,15 +579,12 @@ var $provider = import_zod.z.enum([
|
|
|
564
579
|
"SWAPPED",
|
|
565
580
|
"BANXA",
|
|
566
581
|
"MOONPAY",
|
|
582
|
+
"MOONPAY_GUEST",
|
|
567
583
|
"STRIPE",
|
|
568
584
|
"COINBASE",
|
|
569
585
|
"CROSSMINT"
|
|
570
586
|
]);
|
|
571
587
|
var FiatProviderSchema = $provider;
|
|
572
|
-
var HANDOFF_PATHS = ["MOONPAY/guest_checkout"];
|
|
573
|
-
var $handoffPath = import_zod.z.enum(HANDOFF_PATHS);
|
|
574
|
-
var FiatHandoffPathSchema = $handoffPath;
|
|
575
|
-
var $handoffPathName = import_zod.z.literal("guest_checkout");
|
|
576
588
|
var $kycProvider = import_zod.z.enum(["SUMSUB"]);
|
|
577
589
|
var KYCProviderSchema = $kycProvider;
|
|
578
590
|
var $surfaceProvider = import_zod.z.enum([...$provider.options, ...$kycProvider.options]);
|
|
@@ -754,9 +766,9 @@ var $clientExecutedDelivery = obj({
|
|
|
754
766
|
channel: import_zod.z.literal("CLIENT_EXECUTED"),
|
|
755
767
|
source: import_zod.z.literal("CURRENT_SESSION_INPUTS"),
|
|
756
768
|
allowedFieldIds: import_zod.z.array($kycFieldId).min(1)
|
|
757
|
-
}).superRefine((delivery,
|
|
769
|
+
}).superRefine((delivery, context2) => {
|
|
758
770
|
if (new Set(delivery.allowedFieldIds).size !== delivery.allowedFieldIds.length) {
|
|
759
|
-
|
|
771
|
+
context2.addIssue({
|
|
760
772
|
code: "custom",
|
|
761
773
|
path: ["allowedFieldIds"],
|
|
762
774
|
message: "allowedFieldIds must be unique"
|
|
@@ -1165,7 +1177,7 @@ var compareDecimals = (left, right) => {
|
|
|
1165
1177
|
return leftDigits < rightDigits ? -1 : leftDigits > rightDigits ? 1 : 0;
|
|
1166
1178
|
};
|
|
1167
1179
|
var $countryCode = import_zod.z.enum(Object.keys(CountryCode));
|
|
1168
|
-
var $routingProvider = $provider.extract(["TRANSAK", "BANXA", "MOONPAY", "STRIPE", "COINBASE"]);
|
|
1180
|
+
var $routingProvider = $provider.extract(["TRANSAK", "BANXA", "MOONPAY", "MOONPAY_GUEST", "STRIPE", "COINBASE"]);
|
|
1169
1181
|
var $optionalGeoField = import_zod.z.union([$nonBlank, import_zod.z.literal("")]).optional();
|
|
1170
1182
|
var US_REGION_REQUIRED = "a US buyer needs a US state code as region";
|
|
1171
1183
|
var hasUsRegion = (country, region) => country !== "US" || UsStateCodeSchema.safeParse(region).success;
|
|
@@ -1199,11 +1211,11 @@ var $routingTableInterval = obj({
|
|
|
1199
1211
|
var $routingTableMethod = obj({
|
|
1200
1212
|
method: import_zod.z.enum(PAYMENT_METHOD_CATEGORIES),
|
|
1201
1213
|
unavailableReason: import_zod.z.enum(["USER_LIMIT", "KYC_REJECTED", "PROVIDER_OUTAGE", "NOT_SERVED"]).optional(),
|
|
1202
|
-
intervals: import_zod.z.array($routingTableInterval).superRefine((intervals,
|
|
1214
|
+
intervals: import_zod.z.array($routingTableInterval).superRefine((intervals, context2) => {
|
|
1203
1215
|
intervals.forEach((interval, index) => {
|
|
1204
1216
|
const previous = intervals[index - 1];
|
|
1205
1217
|
if (previous !== void 0 && compareDecimals(interval.min, previous.max) <= 0) {
|
|
1206
|
-
|
|
1218
|
+
context2.addIssue({ code: "custom", path: [index, "min"], message: "intervals are sorted and do not overlap" });
|
|
1207
1219
|
}
|
|
1208
1220
|
});
|
|
1209
1221
|
})
|
|
@@ -1230,8 +1242,7 @@ var $routingQuoteTermsShape = {
|
|
|
1230
1242
|
prepareSessionAuth: import_zod.z.boolean().optional(),
|
|
1231
1243
|
routingOverrides: obj({ providers: import_zod.z.array($routingProvider) }).optional(),
|
|
1232
1244
|
destinationAsset: $destinationAsset.optional(),
|
|
1233
|
-
depositAddress: $nonBlank.optional()
|
|
1234
|
-
handoffPaths: import_zod.z.array($handoffPath).refine(hasUniqueIds, "each handoff path is listed once").optional()
|
|
1245
|
+
depositAddress: $nonBlank.optional()
|
|
1235
1246
|
};
|
|
1236
1247
|
var $routingQuoteTerms = obj($routingQuoteTermsShape);
|
|
1237
1248
|
var FiatRoutingQuoteTermsSchema = $routingQuoteTerms;
|
|
@@ -1320,38 +1331,31 @@ var $providerBoundStepResponse = obj({
|
|
|
1320
1331
|
state: $providerBoundFlowState,
|
|
1321
1332
|
provider: $provider,
|
|
1322
1333
|
preparedPayment: $preparedPayment.optional(),
|
|
1323
|
-
handoff: obj({ provider: $provider
|
|
1324
|
-
}).superRefine((response,
|
|
1334
|
+
handoff: obj({ provider: $provider }).optional()
|
|
1335
|
+
}).superRefine((response, context2) => {
|
|
1325
1336
|
if (response.preparedPayment !== void 0 && response.preparedPayment.surface.provider !== response.provider) {
|
|
1326
|
-
|
|
1337
|
+
context2.addIssue({
|
|
1327
1338
|
code: "custom",
|
|
1328
1339
|
path: ["preparedPayment", "surface", "provider"],
|
|
1329
1340
|
message: "preparedPayment.surface.provider must match the response provider"
|
|
1330
1341
|
});
|
|
1331
1342
|
}
|
|
1332
1343
|
if (response.handoff !== void 0 && response.handoff.provider !== response.provider) {
|
|
1333
|
-
|
|
1344
|
+
context2.addIssue({
|
|
1334
1345
|
code: "custom",
|
|
1335
1346
|
path: ["handoff", "provider"],
|
|
1336
1347
|
message: "handoff.provider must match the response provider"
|
|
1337
1348
|
});
|
|
1338
1349
|
}
|
|
1339
|
-
if (response.handoff?.path !== void 0 && !HANDOFF_PATHS.includes(`${response.handoff.provider}/${response.handoff.path}`)) {
|
|
1340
|
-
context.addIssue({
|
|
1341
|
-
code: "custom",
|
|
1342
|
-
path: ["handoff", "path"],
|
|
1343
|
-
message: "handoff.path must name a handoff path of handoff.provider"
|
|
1344
|
-
});
|
|
1345
|
-
}
|
|
1346
1350
|
if (response.handoff !== void 0 && response.state.kind !== "QUOTE") {
|
|
1347
|
-
|
|
1351
|
+
context2.addIssue({
|
|
1348
1352
|
code: "custom",
|
|
1349
1353
|
path: ["handoff"],
|
|
1350
1354
|
message: "only a QUOTE response hands off to a provider"
|
|
1351
1355
|
});
|
|
1352
1356
|
}
|
|
1353
1357
|
if (response.handoff !== void 0 && response.transitions.length > 0) {
|
|
1354
|
-
|
|
1358
|
+
context2.addIssue({
|
|
1355
1359
|
code: "custom",
|
|
1356
1360
|
path: ["transitions"],
|
|
1357
1361
|
message: "a handoff response carries no transitions"
|
|
@@ -1373,15 +1377,15 @@ var $funAuthStepResponse = obj({
|
|
|
1373
1377
|
state: $funAuthState,
|
|
1374
1378
|
provider: $provider.optional(),
|
|
1375
1379
|
session: $fiatSession.optional()
|
|
1376
|
-
}).superRefine((response,
|
|
1380
|
+
}).superRefine((response, context2) => {
|
|
1377
1381
|
const { phase } = response.state;
|
|
1378
1382
|
if (response.session !== void 0 && phase !== "VERIFIED") {
|
|
1379
|
-
|
|
1383
|
+
context2.addIssue({ code: "custom", path: ["session"], message: "only a FUN_AUTH response in phase VERIFIED carries session" });
|
|
1380
1384
|
}
|
|
1381
1385
|
const allowed = FUN_AUTH_TRANSITIONS_BY_PHASE[phase];
|
|
1382
1386
|
response.transitions.forEach((transition, index) => {
|
|
1383
1387
|
if (!allowed.includes(transition.id)) {
|
|
1384
|
-
|
|
1388
|
+
context2.addIssue({
|
|
1385
1389
|
code: "custom",
|
|
1386
1390
|
path: ["transitions", index, "id"],
|
|
1387
1391
|
message: `FUN_AUTH phase ${phase} offers ${allowed.join(" or ") || "no transitions"}, not "${transition.id}"`
|
|
@@ -1393,7 +1397,7 @@ var $stepResponse = import_zod.z.union([$providerBoundStepResponse, $funAuthStep
|
|
|
1393
1397
|
var FiatStepResponseSchema = $stepResponse;
|
|
1394
1398
|
|
|
1395
1399
|
// package.json
|
|
1396
|
-
var version = "0.
|
|
1400
|
+
var version = "0.47.0";
|
|
1397
1401
|
|
|
1398
1402
|
// src/table.ts
|
|
1399
1403
|
var TABLE_VERSION = version;
|
|
@@ -3341,7 +3345,8 @@ var MOONPAY_KYC_SHARING = {
|
|
|
3341
3345
|
links: [{ label: "Persona Privacy Policy", url: "https://withpersona.com/legal/privacy-policy" }]
|
|
3342
3346
|
};
|
|
3343
3347
|
var PROVIDER_CHECKOUT_DOCUMENTS = {
|
|
3344
|
-
MOONPAY: [MOONPAY_TERMS]
|
|
3348
|
+
MOONPAY: [MOONPAY_TERMS],
|
|
3349
|
+
MOONPAY_GUEST: [MOONPAY_TERMS]
|
|
3345
3350
|
};
|
|
3346
3351
|
var PROVIDER_KYC_DOCUMENTS = {
|
|
3347
3352
|
MOONPAY: [MOONPAY_KYC_SHARING]
|
|
@@ -3397,13 +3402,10 @@ var $checkout = obj2({
|
|
|
3397
3402
|
var MoonPayCheckoutSchema = $checkout;
|
|
3398
3403
|
var $credentials = obj2({ customerId: $nonEmpty, accessToken: $nonEmpty });
|
|
3399
3404
|
var MoonPaySdkCredentialsSchema = $credentials;
|
|
3400
|
-
var $path = import_zod2.z.literal("guest_checkout");
|
|
3401
|
-
var MoonPayPathSchema = $path;
|
|
3402
3405
|
var $context = {
|
|
3403
3406
|
checkout: $checkout,
|
|
3404
3407
|
credentials: $credentials.optional(),
|
|
3405
|
-
destinationAsset: DestinationAssetSchema.optional()
|
|
3406
|
-
path: $path.optional()
|
|
3408
|
+
destinationAsset: DestinationAssetSchema.optional()
|
|
3407
3409
|
};
|
|
3408
3410
|
var $requestContext = obj2($context);
|
|
3409
3411
|
var MoonPayRequestContextSchema = $requestContext;
|
|
@@ -3422,6 +3424,9 @@ var $consentFields = {
|
|
|
3422
3424
|
};
|
|
3423
3425
|
var $sessionFields = { action: import_zod2.z.literal("session") };
|
|
3424
3426
|
var $connectFields = { action: import_zod2.z.literal("connect"), customerId: $nonEmpty, accessToken: $nonEmpty };
|
|
3427
|
+
var $phoneNumberFields = { action: import_zod2.z.literal("phone"), phoneNumber: import_zod2.z.string().regex(/^\+[1-9]\d{1,14}$/) };
|
|
3428
|
+
var $phoneResendFields = { action: import_zod2.z.literal("phone"), resend: $nonEmpty };
|
|
3429
|
+
var $phoneCodeFields = { action: import_zod2.z.literal("phoneCode"), verificationRef: $nonEmpty, otpCode: import_zod2.z.string().regex(/^\d{6}$/) };
|
|
3425
3430
|
var $guestDeclineReason = import_zod2.z.enum(["NOT_OFFERED", "MISMATCH", "OVER_LIMIT"]);
|
|
3426
3431
|
var MoonPayGuestDeclineReasonSchema = $guestDeclineReason;
|
|
3427
3432
|
var $declineFields = { action: import_zod2.z.literal("decline"), reason: $guestDeclineReason };
|
|
@@ -3437,6 +3442,8 @@ var $observeRequest = obj2({ ...$context, ...$observeFields });
|
|
|
3437
3442
|
var $consentRequest = obj2({ ...$context, ...$consentFields });
|
|
3438
3443
|
var $sessionRequest = obj2({ ...$context, ...$sessionFields });
|
|
3439
3444
|
var $connectRequest = obj2({ ...$context, ...$connectFields });
|
|
3445
|
+
var $phoneRequest = import_zod2.z.union([obj2({ ...$context, ...$phoneNumberFields }), obj2({ ...$context, ...$phoneResendFields })]);
|
|
3446
|
+
var $phoneCodeRequest = obj2({ ...$context, ...$phoneCodeFields });
|
|
3440
3447
|
var $declineRequest = obj2({ ...$context, ...$declineFields });
|
|
3441
3448
|
var $kycRequest = obj2({ ...$context, ...$kycFields });
|
|
3442
3449
|
var $prepareCaptureRequest = obj2({ ...$context, ...$prepareCaptureFields });
|
|
@@ -3446,17 +3453,18 @@ var MoonPayObserveRequestSchema = $observeRequest;
|
|
|
3446
3453
|
var MoonPayConsentRequestSchema = $consentRequest;
|
|
3447
3454
|
var MoonPaySessionRequestSchema = $sessionRequest;
|
|
3448
3455
|
var MoonPayConnectRequestSchema = $connectRequest;
|
|
3456
|
+
var MoonPayPhoneRequestSchema = $phoneRequest;
|
|
3457
|
+
var MoonPayPhoneCodeRequestSchema = $phoneCodeRequest;
|
|
3449
3458
|
var MoonPayDeclineRequestSchema = $declineRequest;
|
|
3450
3459
|
var MoonPayKycRequestSchema = $kycRequest;
|
|
3451
3460
|
var MoonPayPrepareCaptureRequestSchema = $prepareCaptureRequest;
|
|
3452
3461
|
var MoonPayCaptureRequestSchema = $captureRequest;
|
|
3453
3462
|
var MoonPayOrderRequestSchema = $orderRequest;
|
|
3454
|
-
var $request = import_zod2.z.
|
|
3463
|
+
var $request = import_zod2.z.union([
|
|
3455
3464
|
$observeRequest,
|
|
3456
3465
|
$consentRequest,
|
|
3457
3466
|
$sessionRequest,
|
|
3458
3467
|
$connectRequest,
|
|
3459
|
-
$declineRequest,
|
|
3460
3468
|
$kycRequest,
|
|
3461
3469
|
$prepareCaptureRequest,
|
|
3462
3470
|
$captureRequest,
|
|
@@ -3464,12 +3472,11 @@ var $request = import_zod2.z.discriminatedUnion("action", [
|
|
|
3464
3472
|
]);
|
|
3465
3473
|
var MoonPayRequestSchema = $request;
|
|
3466
3474
|
var $envelope = { provider: import_zod2.z.literal("MOONPAY"), geo: FiatGeoSchema, depositAddress: $nonEmpty.optional(), ...$context };
|
|
3467
|
-
var $nextRequest2 = import_zod2.z.
|
|
3475
|
+
var $nextRequest2 = import_zod2.z.union([
|
|
3468
3476
|
obj2({ ...$envelope, ...$observeFields }),
|
|
3469
3477
|
obj2({ ...$envelope, ...$consentFields }),
|
|
3470
3478
|
obj2({ ...$envelope, ...$sessionFields }),
|
|
3471
3479
|
obj2({ ...$envelope, ...$connectFields }),
|
|
3472
|
-
obj2({ ...$envelope, ...$declineFields }),
|
|
3473
3480
|
obj2({ ...$envelope, ...$kycFields }),
|
|
3474
3481
|
obj2({ ...$envelope, ...$prepareCaptureFields }),
|
|
3475
3482
|
obj2({ ...$envelope, ...$captureFields }),
|
|
@@ -3486,6 +3493,13 @@ var $connectNextAction = obj2({
|
|
|
3486
3493
|
quoteInput: $quoteInput,
|
|
3487
3494
|
resetConnection: import_zod2.z.literal(true).optional()
|
|
3488
3495
|
});
|
|
3496
|
+
var $phoneNextAction = obj2({ next: import_zod2.z.literal("phone"), error: import_zod2.z.literal("CODE_EXPIRED").nullable() });
|
|
3497
|
+
var $phoneCodeNextAction = obj2({
|
|
3498
|
+
next: import_zod2.z.literal("phoneCode"),
|
|
3499
|
+
verificationRef: $nonEmpty,
|
|
3500
|
+
expiresAt: import_zod2.z.string().datetime({ offset: true }),
|
|
3501
|
+
error: import_zod2.z.literal("CODE_INVALID").nullable()
|
|
3502
|
+
});
|
|
3489
3503
|
var $payNextAction = obj2({ next: import_zod2.z.literal("pay"), sessionToken: $nonEmpty, orderId: $nonEmpty, quoteInput: $quoteInput });
|
|
3490
3504
|
var CAPTURE_DOCUMENTS = ["IDENTITY_DOCUMENT", "SELFIE", "PROOF_OF_ADDRESS", "PROOF_OF_INCOME"];
|
|
3491
3505
|
var $captureDocument = import_zod2.z.enum(CAPTURE_DOCUMENTS);
|
|
@@ -3517,35 +3531,37 @@ var $orderPendingNextAction = obj2({
|
|
|
3517
3531
|
retryAfterMs: import_zod2.z.number().int().positive().max(6e4),
|
|
3518
3532
|
order: FiatStepResponseSchema.nullable()
|
|
3519
3533
|
});
|
|
3520
|
-
var checkConsent = (nextAction,
|
|
3534
|
+
var checkConsent = (nextAction, context2) => {
|
|
3521
3535
|
if (!hasUniqueIds2(nextAction.documents.map((document) => document.id))) {
|
|
3522
|
-
|
|
3536
|
+
context2.addIssue({ code: "custom", path: ["documents"], message: "document ids must be unique" });
|
|
3523
3537
|
}
|
|
3524
3538
|
};
|
|
3525
|
-
var checkKyc = (nextAction,
|
|
3539
|
+
var checkKyc = (nextAction, context2) => {
|
|
3526
3540
|
const fieldIds = nextAction.fields.map((field) => field.id);
|
|
3527
3541
|
if (!hasUniqueIds2(fieldIds)) {
|
|
3528
|
-
|
|
3542
|
+
context2.addIssue({ code: "custom", path: ["fields"], message: "field ids must be unique" });
|
|
3529
3543
|
}
|
|
3530
3544
|
if (nextAction.fieldErrors?.some((error) => !fieldIds.includes(error.fieldId))) {
|
|
3531
|
-
|
|
3545
|
+
context2.addIssue({ code: "custom", path: ["fieldErrors"], message: "a field error must name a field in this next action" });
|
|
3532
3546
|
}
|
|
3533
3547
|
if (nextAction.fieldErrors?.some((error) => error.code && FIELD_OF_CODE[error.code] !== error.fieldId)) {
|
|
3534
|
-
|
|
3548
|
+
context2.addIssue({ code: "custom", path: ["fieldErrors"], message: "a field error code must match its field" });
|
|
3535
3549
|
}
|
|
3536
3550
|
if (nextAction.reask?.requirements.some((requirement) => !fieldIds.includes(requirement))) {
|
|
3537
|
-
|
|
3551
|
+
context2.addIssue({ code: "custom", path: ["reask"], message: "a kyc reask must name fields in this next action" });
|
|
3538
3552
|
}
|
|
3539
3553
|
};
|
|
3540
3554
|
var isCaptureDocument = (requirement) => CAPTURE_DOCUMENTS.includes(requirement);
|
|
3541
|
-
var checkCapture = (nextAction,
|
|
3555
|
+
var checkCapture = (nextAction, context2) => {
|
|
3542
3556
|
if (nextAction.reask?.requirements.some((requirement) => !isCaptureDocument(requirement))) {
|
|
3543
|
-
|
|
3557
|
+
context2.addIssue({ code: "custom", path: ["reask"], message: "a capture reask must name documents only" });
|
|
3544
3558
|
}
|
|
3545
3559
|
};
|
|
3546
3560
|
var MoonPayConsentNextActionSchema = $consentShape.superRefine(checkConsent);
|
|
3547
3561
|
var MoonPaySessionNextActionSchema = $sessionNextAction;
|
|
3548
3562
|
var MoonPayConnectNextActionSchema = $connectNextAction;
|
|
3563
|
+
var MoonPayPhoneNextActionSchema = $phoneNextAction;
|
|
3564
|
+
var MoonPayPhoneCodeNextActionSchema = $phoneCodeNextAction;
|
|
3549
3565
|
var MoonPayPayNextActionSchema = $payNextAction;
|
|
3550
3566
|
var MoonPayKycNextActionSchema = $kycShape.superRefine(checkKyc);
|
|
3551
3567
|
var MoonPayPrepareCaptureNextActionSchema = $prepareCaptureNextAction;
|
|
@@ -3557,16 +3573,15 @@ var MoonPayCaptureNextActionSchema = $captureShape.superRefine(checkCapture);
|
|
|
3557
3573
|
var MoonPayWaitNextActionSchema = $waitNextAction;
|
|
3558
3574
|
var MoonPayOrderNextActionSchema = $orderNextAction;
|
|
3559
3575
|
var MoonPayOrderPendingNextActionSchema = $orderPendingNextAction;
|
|
3560
|
-
var checkNextAction = (response,
|
|
3561
|
-
if (response.next === "consent") checkConsent(response,
|
|
3562
|
-
if (response.next === "kyc") checkKyc(response,
|
|
3563
|
-
if (response.next === "capture") checkCapture(response,
|
|
3576
|
+
var checkNextAction = (response, context2) => {
|
|
3577
|
+
if (response.next === "consent") checkConsent(response, context2);
|
|
3578
|
+
if (response.next === "kyc") checkKyc(response, context2);
|
|
3579
|
+
if (response.next === "capture") checkCapture(response, context2);
|
|
3564
3580
|
};
|
|
3565
3581
|
var $nextActionOptions = [
|
|
3566
3582
|
$consentShape,
|
|
3567
3583
|
$sessionNextAction,
|
|
3568
3584
|
$connectNextAction,
|
|
3569
|
-
$payNextAction,
|
|
3570
3585
|
$kycShape,
|
|
3571
3586
|
$prepareCaptureNextAction,
|
|
3572
3587
|
$captureShape,
|
|
@@ -3596,7 +3611,6 @@ var MoonPayResponseSchemaFor = {
|
|
|
3596
3611
|
consent: MoonPayStepResponseSchema,
|
|
3597
3612
|
session: MoonPayStepResponseSchema,
|
|
3598
3613
|
connect: MoonPayStepResponseSchema,
|
|
3599
|
-
decline: MoonPayStepResponseSchema,
|
|
3600
3614
|
kyc: MoonPayStepResponseSchema,
|
|
3601
3615
|
prepareCapture: MoonPayStepResponseSchema,
|
|
3602
3616
|
capture: MoonPayStepResponseSchema,
|
|
@@ -3725,21 +3739,21 @@ var $orderPendingNextAction2 = obj3({
|
|
|
3725
3739
|
retryAfterMs: $retryAfterMs,
|
|
3726
3740
|
order: FiatStepResponseSchema.nullable()
|
|
3727
3741
|
});
|
|
3728
|
-
var checkConsent2 = (nextAction,
|
|
3742
|
+
var checkConsent2 = (nextAction, context2) => {
|
|
3729
3743
|
if (!hasUniqueIds3(nextAction.documents.map((document) => document.id))) {
|
|
3730
|
-
|
|
3744
|
+
context2.addIssue({ code: "custom", path: ["documents"], message: "document ids must be unique" });
|
|
3731
3745
|
}
|
|
3732
3746
|
};
|
|
3733
|
-
var checkKyc2 = (nextAction,
|
|
3747
|
+
var checkKyc2 = (nextAction, context2) => {
|
|
3734
3748
|
const fieldIds = nextAction.fields.map((field) => field.id);
|
|
3735
3749
|
if (!hasUniqueIds3(fieldIds)) {
|
|
3736
|
-
|
|
3750
|
+
context2.addIssue({ code: "custom", path: ["fields"], message: "field ids must be unique" });
|
|
3737
3751
|
}
|
|
3738
3752
|
if (nextAction.fieldErrors?.some((error) => !fieldIds.includes(error.fieldId))) {
|
|
3739
|
-
|
|
3753
|
+
context2.addIssue({ code: "custom", path: ["fieldErrors"], message: "a field error must name a field in this next action" });
|
|
3740
3754
|
}
|
|
3741
3755
|
if (nextAction.reask?.requirements.some((requirement) => !fieldIds.includes(requirement))) {
|
|
3742
|
-
|
|
3756
|
+
context2.addIssue({ code: "custom", path: ["reask"], message: "a kyc reask must name fields in this next action" });
|
|
3743
3757
|
}
|
|
3744
3758
|
};
|
|
3745
3759
|
var CoinbaseConsentNextActionSchema = $consentShape2.superRefine(checkConsent2);
|
|
@@ -3750,9 +3764,9 @@ var CoinbaseWaitNextActionSchema = $waitNextAction2;
|
|
|
3750
3764
|
var CoinbasePlaceOrderNextActionSchema = $placeOrderNextAction;
|
|
3751
3765
|
var CoinbasePayNextActionSchema = $payNextAction2;
|
|
3752
3766
|
var CoinbaseOrderPendingNextActionSchema = $orderPendingNextAction2;
|
|
3753
|
-
var checkNextAction2 = (response,
|
|
3754
|
-
if (response.next === "consent") checkConsent2(response,
|
|
3755
|
-
if (response.next === "kyc") checkKyc2(response,
|
|
3767
|
+
var checkNextAction2 = (response, context2) => {
|
|
3768
|
+
if (response.next === "consent") checkConsent2(response, context2);
|
|
3769
|
+
if (response.next === "kyc") checkKyc2(response, context2);
|
|
3756
3770
|
};
|
|
3757
3771
|
var $nextActionOptions2 = [
|
|
3758
3772
|
$consentShape2,
|
|
@@ -3809,3 +3823,57 @@ var $errorBody2 = obj3({
|
|
|
3809
3823
|
retryAfterSeconds: import_zod3.z.number().int().positive().optional()
|
|
3810
3824
|
});
|
|
3811
3825
|
var CoinbaseErrorBodySchema = $errorBody2;
|
|
3826
|
+
|
|
3827
|
+
// src/providers/moonpay-guest.schemas.ts
|
|
3828
|
+
var import_zod4 = require("zod");
|
|
3829
|
+
var context = { checkout: MoonPayCheckoutSchema, destinationAsset: DestinationAssetSchema.optional() };
|
|
3830
|
+
var obj4 = (shape) => import_zod4.z.object(shape).strict();
|
|
3831
|
+
var nonEmpty = import_zod4.z.string().refine((value) => value.trim().length > 0, "must not be blank");
|
|
3832
|
+
var actions = [
|
|
3833
|
+
{ action: import_zod4.z.literal("observe") },
|
|
3834
|
+
{ action: import_zod4.z.literal("session") },
|
|
3835
|
+
{ action: import_zod4.z.literal("consent"), acceptances: import_zod4.z.array(TermsDocumentAcceptanceSchema).min(1).refine((values) => new Set(values.map((v) => v.documentId)).size === values.length, "each document is accepted once") },
|
|
3836
|
+
{ action: import_zod4.z.literal("order"), orderId: nonEmpty, quotedAmount: FiatAmountSchema, transactionId: nonEmpty.optional() },
|
|
3837
|
+
{ action: import_zod4.z.literal("phone"), phoneNumber: import_zod4.z.string().regex(/^\+[1-9]\d{1,14}$/) },
|
|
3838
|
+
{ action: import_zod4.z.literal("phone"), resend: nonEmpty },
|
|
3839
|
+
{ action: import_zod4.z.literal("phoneCode"), verificationRef: nonEmpty, otpCode: import_zod4.z.string().regex(/^\d{6}$/) },
|
|
3840
|
+
{ action: import_zod4.z.literal("decline"), reason: MoonPayGuestDeclineReasonSchema }
|
|
3841
|
+
];
|
|
3842
|
+
var MoonPayGuestObserveRequestSchema = obj4({ ...context, ...actions[0] });
|
|
3843
|
+
var MoonPayGuestSessionRequestSchema = obj4({ ...context, ...actions[1] });
|
|
3844
|
+
var MoonPayGuestConsentRequestSchema = obj4({ ...context, ...actions[2] });
|
|
3845
|
+
var MoonPayGuestOrderRequestSchema = obj4({ ...context, ...actions[3] });
|
|
3846
|
+
var MoonPayGuestPhoneNumberRequestSchema = obj4({ ...context, ...actions[4] });
|
|
3847
|
+
var MoonPayGuestPhoneResendRequestSchema = obj4({ ...context, ...actions[5] });
|
|
3848
|
+
var MoonPayGuestPhoneCodeRequestSchema = obj4({ ...context, ...actions[6] });
|
|
3849
|
+
var MoonPayGuestDeclineRequestSchema = obj4({ ...context, ...actions[7] });
|
|
3850
|
+
var MoonPayGuestPhoneRequestSchema = import_zod4.z.union([MoonPayGuestPhoneNumberRequestSchema, MoonPayGuestPhoneResendRequestSchema]);
|
|
3851
|
+
var MoonPayGuestRequestSchema = import_zod4.z.union([
|
|
3852
|
+
MoonPayGuestObserveRequestSchema,
|
|
3853
|
+
MoonPayGuestSessionRequestSchema,
|
|
3854
|
+
MoonPayGuestConsentRequestSchema,
|
|
3855
|
+
MoonPayGuestOrderRequestSchema,
|
|
3856
|
+
MoonPayGuestPhoneNumberRequestSchema,
|
|
3857
|
+
MoonPayGuestPhoneResendRequestSchema,
|
|
3858
|
+
MoonPayGuestPhoneCodeRequestSchema,
|
|
3859
|
+
MoonPayGuestDeclineRequestSchema
|
|
3860
|
+
]);
|
|
3861
|
+
var MoonPayGuestNextRequestSchema = import_zod4.z.union([
|
|
3862
|
+
obj4({ provider: import_zod4.z.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty.optional(), ...context, ...actions[0] }),
|
|
3863
|
+
obj4({ provider: import_zod4.z.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty.optional(), ...context, ...actions[1] }),
|
|
3864
|
+
obj4({ provider: import_zod4.z.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty.optional(), ...context, ...actions[2] }),
|
|
3865
|
+
obj4({ provider: import_zod4.z.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty.optional(), ...context, ...actions[3] }),
|
|
3866
|
+
obj4({ provider: import_zod4.z.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty.optional(), ...context, ...actions[4] }),
|
|
3867
|
+
obj4({ provider: import_zod4.z.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty.optional(), ...context, ...actions[5] }),
|
|
3868
|
+
obj4({ provider: import_zod4.z.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty.optional(), ...context, ...actions[6] }),
|
|
3869
|
+
obj4({ provider: import_zod4.z.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty.optional(), ...context, ...actions[7] })
|
|
3870
|
+
]);
|
|
3871
|
+
var MoonPayGuestStepResponseSchema = import_zod4.z.union([
|
|
3872
|
+
MoonPayConsentNextActionSchema,
|
|
3873
|
+
MoonPaySessionNextActionSchema,
|
|
3874
|
+
MoonPayPhoneNextActionSchema,
|
|
3875
|
+
MoonPayPhoneCodeNextActionSchema,
|
|
3876
|
+
MoonPayPayNextActionSchema,
|
|
3877
|
+
obj4({ next: import_zod4.z.literal("refused"), reason: import_zod4.z.enum(["NOT_ELIGIBLE", "FINAL_REJECTION"]), recovery: import_zod4.z.enum(["REQUOTE", "NONE"]) })
|
|
3878
|
+
]);
|
|
3879
|
+
var MoonPayGuestResponseSchema = import_zod4.z.union([MoonPayGuestStepResponseSchema, MoonPayOrderResponseSchema]);
|