@fun-xyz/fiat-contract 0.46.0 → 0.48.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-4ZHY4P3K.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 +137 -64
- package/dist/index.mjs +137 -64
- package/dist/providers/coinbase.d.ts +6 -1
- 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/dist/index.mjs
CHANGED
|
@@ -13,10 +13,11 @@ import {
|
|
|
13
13
|
tableEntry,
|
|
14
14
|
unofferedEndpoints,
|
|
15
15
|
unreachableStates
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-4ZHY4P3K.mjs";
|
|
17
17
|
import {
|
|
18
18
|
MOONPAY_ENDPOINTS
|
|
19
19
|
} from "./chunk-TIEGTTFY.mjs";
|
|
20
|
+
import "./chunk-LTJWGDSA.mjs";
|
|
20
21
|
import {
|
|
21
22
|
COINBASE_ENDPOINTS,
|
|
22
23
|
COINBASE_TERMS
|
|
@@ -27,7 +28,7 @@ import {
|
|
|
27
28
|
PROVIDER_CHECKOUT_DOCUMENTS,
|
|
28
29
|
PROVIDER_KYC_DOCUMENTS,
|
|
29
30
|
PUBLISHED_TERMS_DOCUMENTS
|
|
30
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-TIQALG7X.mjs";
|
|
31
32
|
import {
|
|
32
33
|
ROUTING_ENDPOINTS
|
|
33
34
|
} from "./chunk-2NZSOZHV.mjs";
|
|
@@ -377,15 +378,12 @@ var $provider = z.enum([
|
|
|
377
378
|
"SWAPPED",
|
|
378
379
|
"BANXA",
|
|
379
380
|
"MOONPAY",
|
|
381
|
+
"MOONPAY_GUEST",
|
|
380
382
|
"STRIPE",
|
|
381
383
|
"COINBASE",
|
|
382
384
|
"CROSSMINT"
|
|
383
385
|
]);
|
|
384
386
|
var FiatProviderSchema = $provider;
|
|
385
|
-
var HANDOFF_PATHS = ["MOONPAY/guest_checkout"];
|
|
386
|
-
var $handoffPath = z.enum(HANDOFF_PATHS);
|
|
387
|
-
var FiatHandoffPathSchema = $handoffPath;
|
|
388
|
-
var $handoffPathName = z.literal("guest_checkout");
|
|
389
387
|
var $kycProvider = z.enum(["SUMSUB"]);
|
|
390
388
|
var KYCProviderSchema = $kycProvider;
|
|
391
389
|
var $surfaceProvider = z.enum([...$provider.options, ...$kycProvider.options]);
|
|
@@ -567,9 +565,9 @@ var $clientExecutedDelivery = obj({
|
|
|
567
565
|
channel: z.literal("CLIENT_EXECUTED"),
|
|
568
566
|
source: z.literal("CURRENT_SESSION_INPUTS"),
|
|
569
567
|
allowedFieldIds: z.array($kycFieldId).min(1)
|
|
570
|
-
}).superRefine((delivery,
|
|
568
|
+
}).superRefine((delivery, context2) => {
|
|
571
569
|
if (new Set(delivery.allowedFieldIds).size !== delivery.allowedFieldIds.length) {
|
|
572
|
-
|
|
570
|
+
context2.addIssue({
|
|
573
571
|
code: "custom",
|
|
574
572
|
path: ["allowedFieldIds"],
|
|
575
573
|
message: "allowedFieldIds must be unique"
|
|
@@ -978,7 +976,7 @@ var compareDecimals = (left, right) => {
|
|
|
978
976
|
return leftDigits < rightDigits ? -1 : leftDigits > rightDigits ? 1 : 0;
|
|
979
977
|
};
|
|
980
978
|
var $countryCode = z.enum(Object.keys(CountryCode));
|
|
981
|
-
var $routingProvider = $provider.extract(["TRANSAK", "BANXA", "MOONPAY", "STRIPE", "COINBASE"]);
|
|
979
|
+
var $routingProvider = $provider.extract(["TRANSAK", "BANXA", "MOONPAY", "MOONPAY_GUEST", "STRIPE", "COINBASE"]);
|
|
982
980
|
var $optionalGeoField = z.union([$nonBlank, z.literal("")]).optional();
|
|
983
981
|
var US_REGION_REQUIRED = "a US buyer needs a US state code as region";
|
|
984
982
|
var hasUsRegion = (country, region) => country !== "US" || UsStateCodeSchema.safeParse(region).success;
|
|
@@ -1012,11 +1010,11 @@ var $routingTableInterval = obj({
|
|
|
1012
1010
|
var $routingTableMethod = obj({
|
|
1013
1011
|
method: z.enum(PAYMENT_METHOD_CATEGORIES),
|
|
1014
1012
|
unavailableReason: z.enum(["USER_LIMIT", "KYC_REJECTED", "PROVIDER_OUTAGE", "NOT_SERVED"]).optional(),
|
|
1015
|
-
intervals: z.array($routingTableInterval).superRefine((intervals,
|
|
1013
|
+
intervals: z.array($routingTableInterval).superRefine((intervals, context2) => {
|
|
1016
1014
|
intervals.forEach((interval, index) => {
|
|
1017
1015
|
const previous = intervals[index - 1];
|
|
1018
1016
|
if (previous !== void 0 && compareDecimals(interval.min, previous.max) <= 0) {
|
|
1019
|
-
|
|
1017
|
+
context2.addIssue({ code: "custom", path: [index, "min"], message: "intervals are sorted and do not overlap" });
|
|
1020
1018
|
}
|
|
1021
1019
|
});
|
|
1022
1020
|
})
|
|
@@ -1043,8 +1041,7 @@ var $routingQuoteTermsShape = {
|
|
|
1043
1041
|
prepareSessionAuth: z.boolean().optional(),
|
|
1044
1042
|
routingOverrides: obj({ providers: z.array($routingProvider) }).optional(),
|
|
1045
1043
|
destinationAsset: $destinationAsset.optional(),
|
|
1046
|
-
depositAddress: $nonBlank.optional()
|
|
1047
|
-
handoffPaths: z.array($handoffPath).refine(hasUniqueIds, "each handoff path is listed once").optional()
|
|
1044
|
+
depositAddress: $nonBlank.optional()
|
|
1048
1045
|
};
|
|
1049
1046
|
var $routingQuoteTerms = obj($routingQuoteTermsShape);
|
|
1050
1047
|
var FiatRoutingQuoteTermsSchema = $routingQuoteTerms;
|
|
@@ -1133,38 +1130,31 @@ var $providerBoundStepResponse = obj({
|
|
|
1133
1130
|
state: $providerBoundFlowState,
|
|
1134
1131
|
provider: $provider,
|
|
1135
1132
|
preparedPayment: $preparedPayment.optional(),
|
|
1136
|
-
handoff: obj({ provider: $provider
|
|
1137
|
-
}).superRefine((response,
|
|
1133
|
+
handoff: obj({ provider: $provider }).optional()
|
|
1134
|
+
}).superRefine((response, context2) => {
|
|
1138
1135
|
if (response.preparedPayment !== void 0 && response.preparedPayment.surface.provider !== response.provider) {
|
|
1139
|
-
|
|
1136
|
+
context2.addIssue({
|
|
1140
1137
|
code: "custom",
|
|
1141
1138
|
path: ["preparedPayment", "surface", "provider"],
|
|
1142
1139
|
message: "preparedPayment.surface.provider must match the response provider"
|
|
1143
1140
|
});
|
|
1144
1141
|
}
|
|
1145
1142
|
if (response.handoff !== void 0 && response.handoff.provider !== response.provider) {
|
|
1146
|
-
|
|
1143
|
+
context2.addIssue({
|
|
1147
1144
|
code: "custom",
|
|
1148
1145
|
path: ["handoff", "provider"],
|
|
1149
1146
|
message: "handoff.provider must match the response provider"
|
|
1150
1147
|
});
|
|
1151
1148
|
}
|
|
1152
|
-
if (response.handoff?.path !== void 0 && !HANDOFF_PATHS.includes(`${response.handoff.provider}/${response.handoff.path}`)) {
|
|
1153
|
-
context.addIssue({
|
|
1154
|
-
code: "custom",
|
|
1155
|
-
path: ["handoff", "path"],
|
|
1156
|
-
message: "handoff.path must name a handoff path of handoff.provider"
|
|
1157
|
-
});
|
|
1158
|
-
}
|
|
1159
1149
|
if (response.handoff !== void 0 && response.state.kind !== "QUOTE") {
|
|
1160
|
-
|
|
1150
|
+
context2.addIssue({
|
|
1161
1151
|
code: "custom",
|
|
1162
1152
|
path: ["handoff"],
|
|
1163
1153
|
message: "only a QUOTE response hands off to a provider"
|
|
1164
1154
|
});
|
|
1165
1155
|
}
|
|
1166
1156
|
if (response.handoff !== void 0 && response.transitions.length > 0) {
|
|
1167
|
-
|
|
1157
|
+
context2.addIssue({
|
|
1168
1158
|
code: "custom",
|
|
1169
1159
|
path: ["transitions"],
|
|
1170
1160
|
message: "a handoff response carries no transitions"
|
|
@@ -1186,15 +1176,15 @@ var $funAuthStepResponse = obj({
|
|
|
1186
1176
|
state: $funAuthState,
|
|
1187
1177
|
provider: $provider.optional(),
|
|
1188
1178
|
session: $fiatSession.optional()
|
|
1189
|
-
}).superRefine((response,
|
|
1179
|
+
}).superRefine((response, context2) => {
|
|
1190
1180
|
const { phase } = response.state;
|
|
1191
1181
|
if (response.session !== void 0 && phase !== "VERIFIED") {
|
|
1192
|
-
|
|
1182
|
+
context2.addIssue({ code: "custom", path: ["session"], message: "only a FUN_AUTH response in phase VERIFIED carries session" });
|
|
1193
1183
|
}
|
|
1194
1184
|
const allowed = FUN_AUTH_TRANSITIONS_BY_PHASE[phase];
|
|
1195
1185
|
response.transitions.forEach((transition, index) => {
|
|
1196
1186
|
if (!allowed.includes(transition.id)) {
|
|
1197
|
-
|
|
1187
|
+
context2.addIssue({
|
|
1198
1188
|
code: "custom",
|
|
1199
1189
|
path: ["transitions", index, "id"],
|
|
1200
1190
|
message: `FUN_AUTH phase ${phase} offers ${allowed.join(" or ") || "no transitions"}, not "${transition.id}"`
|
|
@@ -2542,13 +2532,10 @@ var $checkout = obj2({
|
|
|
2542
2532
|
var MoonPayCheckoutSchema = $checkout;
|
|
2543
2533
|
var $credentials = obj2({ customerId: $nonEmpty, accessToken: $nonEmpty });
|
|
2544
2534
|
var MoonPaySdkCredentialsSchema = $credentials;
|
|
2545
|
-
var $path = z2.literal("guest_checkout");
|
|
2546
|
-
var MoonPayPathSchema = $path;
|
|
2547
2535
|
var $context = {
|
|
2548
2536
|
checkout: $checkout,
|
|
2549
2537
|
credentials: $credentials.optional(),
|
|
2550
|
-
destinationAsset: DestinationAssetSchema.optional()
|
|
2551
|
-
path: $path.optional()
|
|
2538
|
+
destinationAsset: DestinationAssetSchema.optional()
|
|
2552
2539
|
};
|
|
2553
2540
|
var $requestContext = obj2($context);
|
|
2554
2541
|
var MoonPayRequestContextSchema = $requestContext;
|
|
@@ -2567,6 +2554,9 @@ var $consentFields = {
|
|
|
2567
2554
|
};
|
|
2568
2555
|
var $sessionFields = { action: z2.literal("session") };
|
|
2569
2556
|
var $connectFields = { action: z2.literal("connect"), customerId: $nonEmpty, accessToken: $nonEmpty };
|
|
2557
|
+
var $phoneNumberFields = { action: z2.literal("phone"), phoneNumber: z2.string().regex(/^\+[1-9]\d{1,14}$/) };
|
|
2558
|
+
var $phoneResendFields = { action: z2.literal("phone"), resend: $nonEmpty };
|
|
2559
|
+
var $phoneCodeFields = { action: z2.literal("phoneCode"), verificationRef: $nonEmpty, otpCode: z2.string().regex(/^\d{6}$/) };
|
|
2570
2560
|
var $guestDeclineReason = z2.enum(["NOT_OFFERED", "MISMATCH", "OVER_LIMIT"]);
|
|
2571
2561
|
var MoonPayGuestDeclineReasonSchema = $guestDeclineReason;
|
|
2572
2562
|
var $declineFields = { action: z2.literal("decline"), reason: $guestDeclineReason };
|
|
@@ -2582,6 +2572,8 @@ var $observeRequest = obj2({ ...$context, ...$observeFields });
|
|
|
2582
2572
|
var $consentRequest = obj2({ ...$context, ...$consentFields });
|
|
2583
2573
|
var $sessionRequest = obj2({ ...$context, ...$sessionFields });
|
|
2584
2574
|
var $connectRequest = obj2({ ...$context, ...$connectFields });
|
|
2575
|
+
var $phoneRequest = z2.union([obj2({ ...$context, ...$phoneNumberFields }), obj2({ ...$context, ...$phoneResendFields })]);
|
|
2576
|
+
var $phoneCodeRequest = obj2({ ...$context, ...$phoneCodeFields });
|
|
2585
2577
|
var $declineRequest = obj2({ ...$context, ...$declineFields });
|
|
2586
2578
|
var $kycRequest = obj2({ ...$context, ...$kycFields });
|
|
2587
2579
|
var $prepareCaptureRequest = obj2({ ...$context, ...$prepareCaptureFields });
|
|
@@ -2591,17 +2583,18 @@ var MoonPayObserveRequestSchema = $observeRequest;
|
|
|
2591
2583
|
var MoonPayConsentRequestSchema = $consentRequest;
|
|
2592
2584
|
var MoonPaySessionRequestSchema = $sessionRequest;
|
|
2593
2585
|
var MoonPayConnectRequestSchema = $connectRequest;
|
|
2586
|
+
var MoonPayPhoneRequestSchema = $phoneRequest;
|
|
2587
|
+
var MoonPayPhoneCodeRequestSchema = $phoneCodeRequest;
|
|
2594
2588
|
var MoonPayDeclineRequestSchema = $declineRequest;
|
|
2595
2589
|
var MoonPayKycRequestSchema = $kycRequest;
|
|
2596
2590
|
var MoonPayPrepareCaptureRequestSchema = $prepareCaptureRequest;
|
|
2597
2591
|
var MoonPayCaptureRequestSchema = $captureRequest;
|
|
2598
2592
|
var MoonPayOrderRequestSchema = $orderRequest;
|
|
2599
|
-
var $request = z2.
|
|
2593
|
+
var $request = z2.union([
|
|
2600
2594
|
$observeRequest,
|
|
2601
2595
|
$consentRequest,
|
|
2602
2596
|
$sessionRequest,
|
|
2603
2597
|
$connectRequest,
|
|
2604
|
-
$declineRequest,
|
|
2605
2598
|
$kycRequest,
|
|
2606
2599
|
$prepareCaptureRequest,
|
|
2607
2600
|
$captureRequest,
|
|
@@ -2609,12 +2602,11 @@ var $request = z2.discriminatedUnion("action", [
|
|
|
2609
2602
|
]);
|
|
2610
2603
|
var MoonPayRequestSchema = $request;
|
|
2611
2604
|
var $envelope = { provider: z2.literal("MOONPAY"), geo: FiatGeoSchema, depositAddress: $nonEmpty.optional(), ...$context };
|
|
2612
|
-
var $nextRequest2 = z2.
|
|
2605
|
+
var $nextRequest2 = z2.union([
|
|
2613
2606
|
obj2({ ...$envelope, ...$observeFields }),
|
|
2614
2607
|
obj2({ ...$envelope, ...$consentFields }),
|
|
2615
2608
|
obj2({ ...$envelope, ...$sessionFields }),
|
|
2616
2609
|
obj2({ ...$envelope, ...$connectFields }),
|
|
2617
|
-
obj2({ ...$envelope, ...$declineFields }),
|
|
2618
2610
|
obj2({ ...$envelope, ...$kycFields }),
|
|
2619
2611
|
obj2({ ...$envelope, ...$prepareCaptureFields }),
|
|
2620
2612
|
obj2({ ...$envelope, ...$captureFields }),
|
|
@@ -2631,6 +2623,13 @@ var $connectNextAction = obj2({
|
|
|
2631
2623
|
quoteInput: $quoteInput,
|
|
2632
2624
|
resetConnection: z2.literal(true).optional()
|
|
2633
2625
|
});
|
|
2626
|
+
var $phoneNextAction = obj2({ next: z2.literal("phone"), error: z2.literal("CODE_EXPIRED").nullable() });
|
|
2627
|
+
var $phoneCodeNextAction = obj2({
|
|
2628
|
+
next: z2.literal("phoneCode"),
|
|
2629
|
+
verificationRef: $nonEmpty,
|
|
2630
|
+
expiresAt: z2.string().datetime({ offset: true }),
|
|
2631
|
+
error: z2.literal("CODE_INVALID").nullable()
|
|
2632
|
+
});
|
|
2634
2633
|
var $payNextAction = obj2({ next: z2.literal("pay"), sessionToken: $nonEmpty, orderId: $nonEmpty, quoteInput: $quoteInput });
|
|
2635
2634
|
var CAPTURE_DOCUMENTS = ["IDENTITY_DOCUMENT", "SELFIE", "PROOF_OF_ADDRESS", "PROOF_OF_INCOME"];
|
|
2636
2635
|
var $captureDocument = z2.enum(CAPTURE_DOCUMENTS);
|
|
@@ -2662,35 +2661,37 @@ var $orderPendingNextAction = obj2({
|
|
|
2662
2661
|
retryAfterMs: z2.number().int().positive().max(6e4),
|
|
2663
2662
|
order: FiatStepResponseSchema.nullable()
|
|
2664
2663
|
});
|
|
2665
|
-
var checkConsent = (nextAction,
|
|
2664
|
+
var checkConsent = (nextAction, context2) => {
|
|
2666
2665
|
if (!hasUniqueIds2(nextAction.documents.map((document) => document.id))) {
|
|
2667
|
-
|
|
2666
|
+
context2.addIssue({ code: "custom", path: ["documents"], message: "document ids must be unique" });
|
|
2668
2667
|
}
|
|
2669
2668
|
};
|
|
2670
|
-
var checkKyc = (nextAction,
|
|
2669
|
+
var checkKyc = (nextAction, context2) => {
|
|
2671
2670
|
const fieldIds = nextAction.fields.map((field) => field.id);
|
|
2672
2671
|
if (!hasUniqueIds2(fieldIds)) {
|
|
2673
|
-
|
|
2672
|
+
context2.addIssue({ code: "custom", path: ["fields"], message: "field ids must be unique" });
|
|
2674
2673
|
}
|
|
2675
2674
|
if (nextAction.fieldErrors?.some((error) => !fieldIds.includes(error.fieldId))) {
|
|
2676
|
-
|
|
2675
|
+
context2.addIssue({ code: "custom", path: ["fieldErrors"], message: "a field error must name a field in this next action" });
|
|
2677
2676
|
}
|
|
2678
2677
|
if (nextAction.fieldErrors?.some((error) => error.code && FIELD_OF_CODE[error.code] !== error.fieldId)) {
|
|
2679
|
-
|
|
2678
|
+
context2.addIssue({ code: "custom", path: ["fieldErrors"], message: "a field error code must match its field" });
|
|
2680
2679
|
}
|
|
2681
2680
|
if (nextAction.reask?.requirements.some((requirement) => !fieldIds.includes(requirement))) {
|
|
2682
|
-
|
|
2681
|
+
context2.addIssue({ code: "custom", path: ["reask"], message: "a kyc reask must name fields in this next action" });
|
|
2683
2682
|
}
|
|
2684
2683
|
};
|
|
2685
2684
|
var isCaptureDocument = (requirement) => CAPTURE_DOCUMENTS.includes(requirement);
|
|
2686
|
-
var checkCapture = (nextAction,
|
|
2685
|
+
var checkCapture = (nextAction, context2) => {
|
|
2687
2686
|
if (nextAction.reask?.requirements.some((requirement) => !isCaptureDocument(requirement))) {
|
|
2688
|
-
|
|
2687
|
+
context2.addIssue({ code: "custom", path: ["reask"], message: "a capture reask must name documents only" });
|
|
2689
2688
|
}
|
|
2690
2689
|
};
|
|
2691
2690
|
var MoonPayConsentNextActionSchema = $consentShape.superRefine(checkConsent);
|
|
2692
2691
|
var MoonPaySessionNextActionSchema = $sessionNextAction;
|
|
2693
2692
|
var MoonPayConnectNextActionSchema = $connectNextAction;
|
|
2693
|
+
var MoonPayPhoneNextActionSchema = $phoneNextAction;
|
|
2694
|
+
var MoonPayPhoneCodeNextActionSchema = $phoneCodeNextAction;
|
|
2694
2695
|
var MoonPayPayNextActionSchema = $payNextAction;
|
|
2695
2696
|
var MoonPayKycNextActionSchema = $kycShape.superRefine(checkKyc);
|
|
2696
2697
|
var MoonPayPrepareCaptureNextActionSchema = $prepareCaptureNextAction;
|
|
@@ -2702,16 +2703,15 @@ var MoonPayCaptureNextActionSchema = $captureShape.superRefine(checkCapture);
|
|
|
2702
2703
|
var MoonPayWaitNextActionSchema = $waitNextAction;
|
|
2703
2704
|
var MoonPayOrderNextActionSchema = $orderNextAction;
|
|
2704
2705
|
var MoonPayOrderPendingNextActionSchema = $orderPendingNextAction;
|
|
2705
|
-
var checkNextAction = (response,
|
|
2706
|
-
if (response.next === "consent") checkConsent(response,
|
|
2707
|
-
if (response.next === "kyc") checkKyc(response,
|
|
2708
|
-
if (response.next === "capture") checkCapture(response,
|
|
2706
|
+
var checkNextAction = (response, context2) => {
|
|
2707
|
+
if (response.next === "consent") checkConsent(response, context2);
|
|
2708
|
+
if (response.next === "kyc") checkKyc(response, context2);
|
|
2709
|
+
if (response.next === "capture") checkCapture(response, context2);
|
|
2709
2710
|
};
|
|
2710
2711
|
var $nextActionOptions = [
|
|
2711
2712
|
$consentShape,
|
|
2712
2713
|
$sessionNextAction,
|
|
2713
2714
|
$connectNextAction,
|
|
2714
|
-
$payNextAction,
|
|
2715
2715
|
$kycShape,
|
|
2716
2716
|
$prepareCaptureNextAction,
|
|
2717
2717
|
$captureShape,
|
|
@@ -2741,7 +2741,6 @@ var MoonPayResponseSchemaFor = {
|
|
|
2741
2741
|
consent: MoonPayStepResponseSchema,
|
|
2742
2742
|
session: MoonPayStepResponseSchema,
|
|
2743
2743
|
connect: MoonPayStepResponseSchema,
|
|
2744
|
-
decline: MoonPayStepResponseSchema,
|
|
2745
2744
|
kyc: MoonPayStepResponseSchema,
|
|
2746
2745
|
prepareCapture: MoonPayStepResponseSchema,
|
|
2747
2746
|
capture: MoonPayStepResponseSchema,
|
|
@@ -2820,7 +2819,12 @@ var $nextRequest3 = z3.union([
|
|
|
2820
2819
|
obj3({ ...envelope, ...orderFields })
|
|
2821
2820
|
]);
|
|
2822
2821
|
var CoinbaseNextRequestSchema = $nextRequest3;
|
|
2823
|
-
var $price = obj3({
|
|
2822
|
+
var $price = obj3({
|
|
2823
|
+
total: FiatAmountSchema,
|
|
2824
|
+
fees: z3.array(FeeLineSchema),
|
|
2825
|
+
cryptoAmount: $nonEmpty2,
|
|
2826
|
+
feeSubsidy: FiatAmountSchema.optional()
|
|
2827
|
+
});
|
|
2824
2828
|
var CoinbasePriceSchema = $price;
|
|
2825
2829
|
var $reask2 = obj3({
|
|
2826
2830
|
requirements: z3.array(KycFieldIdSchema).min(1).refine(hasUniqueIds3, "requirements must be unique"),
|
|
@@ -2857,21 +2861,21 @@ var $orderPendingNextAction2 = obj3({
|
|
|
2857
2861
|
retryAfterMs: $retryAfterMs,
|
|
2858
2862
|
order: FiatStepResponseSchema.nullable()
|
|
2859
2863
|
});
|
|
2860
|
-
var checkConsent2 = (nextAction,
|
|
2864
|
+
var checkConsent2 = (nextAction, context2) => {
|
|
2861
2865
|
if (!hasUniqueIds3(nextAction.documents.map((document) => document.id))) {
|
|
2862
|
-
|
|
2866
|
+
context2.addIssue({ code: "custom", path: ["documents"], message: "document ids must be unique" });
|
|
2863
2867
|
}
|
|
2864
2868
|
};
|
|
2865
|
-
var checkKyc2 = (nextAction,
|
|
2869
|
+
var checkKyc2 = (nextAction, context2) => {
|
|
2866
2870
|
const fieldIds = nextAction.fields.map((field) => field.id);
|
|
2867
2871
|
if (!hasUniqueIds3(fieldIds)) {
|
|
2868
|
-
|
|
2872
|
+
context2.addIssue({ code: "custom", path: ["fields"], message: "field ids must be unique" });
|
|
2869
2873
|
}
|
|
2870
2874
|
if (nextAction.fieldErrors?.some((error) => !fieldIds.includes(error.fieldId))) {
|
|
2871
|
-
|
|
2875
|
+
context2.addIssue({ code: "custom", path: ["fieldErrors"], message: "a field error must name a field in this next action" });
|
|
2872
2876
|
}
|
|
2873
2877
|
if (nextAction.reask?.requirements.some((requirement) => !fieldIds.includes(requirement))) {
|
|
2874
|
-
|
|
2878
|
+
context2.addIssue({ code: "custom", path: ["reask"], message: "a kyc reask must name fields in this next action" });
|
|
2875
2879
|
}
|
|
2876
2880
|
};
|
|
2877
2881
|
var CoinbaseConsentNextActionSchema = $consentShape2.superRefine(checkConsent2);
|
|
@@ -2882,9 +2886,9 @@ var CoinbaseWaitNextActionSchema = $waitNextAction2;
|
|
|
2882
2886
|
var CoinbasePlaceOrderNextActionSchema = $placeOrderNextAction;
|
|
2883
2887
|
var CoinbasePayNextActionSchema = $payNextAction2;
|
|
2884
2888
|
var CoinbaseOrderPendingNextActionSchema = $orderPendingNextAction2;
|
|
2885
|
-
var checkNextAction2 = (response,
|
|
2886
|
-
if (response.next === "consent") checkConsent2(response,
|
|
2887
|
-
if (response.next === "kyc") checkKyc2(response,
|
|
2889
|
+
var checkNextAction2 = (response, context2) => {
|
|
2890
|
+
if (response.next === "consent") checkConsent2(response, context2);
|
|
2891
|
+
if (response.next === "kyc") checkKyc2(response, context2);
|
|
2888
2892
|
};
|
|
2889
2893
|
var $nextActionOptions2 = [
|
|
2890
2894
|
$consentShape2,
|
|
@@ -2941,6 +2945,60 @@ var $errorBody2 = obj3({
|
|
|
2941
2945
|
retryAfterSeconds: z3.number().int().positive().optional()
|
|
2942
2946
|
});
|
|
2943
2947
|
var CoinbaseErrorBodySchema = $errorBody2;
|
|
2948
|
+
|
|
2949
|
+
// src/providers/moonpay-guest.schemas.ts
|
|
2950
|
+
import { z as z4 } from "zod";
|
|
2951
|
+
var context = { checkout: MoonPayCheckoutSchema, destinationAsset: DestinationAssetSchema.optional() };
|
|
2952
|
+
var obj4 = (shape) => z4.object(shape).strict();
|
|
2953
|
+
var nonEmpty = z4.string().refine((value) => value.trim().length > 0, "must not be blank");
|
|
2954
|
+
var actions = [
|
|
2955
|
+
{ action: z4.literal("observe") },
|
|
2956
|
+
{ action: z4.literal("session") },
|
|
2957
|
+
{ action: z4.literal("consent"), acceptances: z4.array(TermsDocumentAcceptanceSchema).min(1).refine((values) => new Set(values.map((v) => v.documentId)).size === values.length, "each document is accepted once") },
|
|
2958
|
+
{ action: z4.literal("order"), orderId: nonEmpty, quotedAmount: FiatAmountSchema, transactionId: nonEmpty.optional() },
|
|
2959
|
+
{ action: z4.literal("phone"), phoneNumber: z4.string().regex(/^\+[1-9]\d{1,14}$/) },
|
|
2960
|
+
{ action: z4.literal("phone"), resend: nonEmpty },
|
|
2961
|
+
{ action: z4.literal("phoneCode"), verificationRef: nonEmpty, otpCode: z4.string().regex(/^\d{6}$/) },
|
|
2962
|
+
{ action: z4.literal("decline"), reason: MoonPayGuestDeclineReasonSchema }
|
|
2963
|
+
];
|
|
2964
|
+
var MoonPayGuestObserveRequestSchema = obj4({ ...context, ...actions[0] });
|
|
2965
|
+
var MoonPayGuestSessionRequestSchema = obj4({ ...context, ...actions[1] });
|
|
2966
|
+
var MoonPayGuestConsentRequestSchema = obj4({ ...context, ...actions[2] });
|
|
2967
|
+
var MoonPayGuestOrderRequestSchema = obj4({ ...context, ...actions[3] });
|
|
2968
|
+
var MoonPayGuestPhoneNumberRequestSchema = obj4({ ...context, ...actions[4] });
|
|
2969
|
+
var MoonPayGuestPhoneResendRequestSchema = obj4({ ...context, ...actions[5] });
|
|
2970
|
+
var MoonPayGuestPhoneCodeRequestSchema = obj4({ ...context, ...actions[6] });
|
|
2971
|
+
var MoonPayGuestDeclineRequestSchema = obj4({ ...context, ...actions[7] });
|
|
2972
|
+
var MoonPayGuestPhoneRequestSchema = z4.union([MoonPayGuestPhoneNumberRequestSchema, MoonPayGuestPhoneResendRequestSchema]);
|
|
2973
|
+
var MoonPayGuestRequestSchema = z4.union([
|
|
2974
|
+
MoonPayGuestObserveRequestSchema,
|
|
2975
|
+
MoonPayGuestSessionRequestSchema,
|
|
2976
|
+
MoonPayGuestConsentRequestSchema,
|
|
2977
|
+
MoonPayGuestOrderRequestSchema,
|
|
2978
|
+
MoonPayGuestPhoneNumberRequestSchema,
|
|
2979
|
+
MoonPayGuestPhoneResendRequestSchema,
|
|
2980
|
+
MoonPayGuestPhoneCodeRequestSchema,
|
|
2981
|
+
MoonPayGuestDeclineRequestSchema
|
|
2982
|
+
]);
|
|
2983
|
+
var MoonPayGuestNextRequestSchema = z4.union([
|
|
2984
|
+
obj4({ provider: z4.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty.optional(), ...context, ...actions[0] }),
|
|
2985
|
+
obj4({ provider: z4.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty.optional(), ...context, ...actions[1] }),
|
|
2986
|
+
obj4({ provider: z4.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty.optional(), ...context, ...actions[2] }),
|
|
2987
|
+
obj4({ provider: z4.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty.optional(), ...context, ...actions[3] }),
|
|
2988
|
+
obj4({ provider: z4.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty.optional(), ...context, ...actions[4] }),
|
|
2989
|
+
obj4({ provider: z4.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty.optional(), ...context, ...actions[5] }),
|
|
2990
|
+
obj4({ provider: z4.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty.optional(), ...context, ...actions[6] }),
|
|
2991
|
+
obj4({ provider: z4.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty.optional(), ...context, ...actions[7] })
|
|
2992
|
+
]);
|
|
2993
|
+
var MoonPayGuestStepResponseSchema = z4.union([
|
|
2994
|
+
MoonPayConsentNextActionSchema,
|
|
2995
|
+
MoonPaySessionNextActionSchema,
|
|
2996
|
+
MoonPayPhoneNextActionSchema,
|
|
2997
|
+
MoonPayPhoneCodeNextActionSchema,
|
|
2998
|
+
MoonPayPayNextActionSchema,
|
|
2999
|
+
obj4({ next: z4.literal("refused"), reason: z4.enum(["NOT_ELIGIBLE", "FINAL_REJECTION"]), recovery: z4.enum(["REQUOTE", "NONE"]) })
|
|
3000
|
+
]);
|
|
3001
|
+
var MoonPayGuestResponseSchema = z4.union([MoonPayGuestStepResponseSchema, MoonPayOrderResponseSchema]);
|
|
2944
3002
|
export {
|
|
2945
3003
|
BlockedReasonSchema,
|
|
2946
3004
|
BlockedStateSchema,
|
|
@@ -3003,7 +3061,6 @@ export {
|
|
|
3003
3061
|
FiatCurrencyCode,
|
|
3004
3062
|
FiatEndpointSchema,
|
|
3005
3063
|
FiatGeoSchema,
|
|
3006
|
-
FiatHandoffPathSchema,
|
|
3007
3064
|
FiatNextRequestSchema,
|
|
3008
3065
|
FiatProviderSchema,
|
|
3009
3066
|
FiatRoutingQuoteErrorBodySchema,
|
|
@@ -3049,7 +3106,20 @@ export {
|
|
|
3049
3106
|
MoonPayDoneSchema,
|
|
3050
3107
|
MoonPayErrorBodySchema,
|
|
3051
3108
|
MoonPayFaultSchema,
|
|
3109
|
+
MoonPayGuestConsentRequestSchema,
|
|
3052
3110
|
MoonPayGuestDeclineReasonSchema,
|
|
3111
|
+
MoonPayGuestDeclineRequestSchema,
|
|
3112
|
+
MoonPayGuestNextRequestSchema,
|
|
3113
|
+
MoonPayGuestObserveRequestSchema,
|
|
3114
|
+
MoonPayGuestOrderRequestSchema,
|
|
3115
|
+
MoonPayGuestPhoneCodeRequestSchema,
|
|
3116
|
+
MoonPayGuestPhoneNumberRequestSchema,
|
|
3117
|
+
MoonPayGuestPhoneRequestSchema,
|
|
3118
|
+
MoonPayGuestPhoneResendRequestSchema,
|
|
3119
|
+
MoonPayGuestRequestSchema,
|
|
3120
|
+
MoonPayGuestResponseSchema,
|
|
3121
|
+
MoonPayGuestSessionRequestSchema,
|
|
3122
|
+
MoonPayGuestStepResponseSchema,
|
|
3053
3123
|
MoonPayKycNextActionSchema,
|
|
3054
3124
|
MoonPayKycRequestSchema,
|
|
3055
3125
|
MoonPayNextActionSchema,
|
|
@@ -3059,8 +3129,11 @@ export {
|
|
|
3059
3129
|
MoonPayOrderPendingNextActionSchema,
|
|
3060
3130
|
MoonPayOrderRequestSchema,
|
|
3061
3131
|
MoonPayOrderResponseSchema,
|
|
3062
|
-
MoonPayPathSchema,
|
|
3063
3132
|
MoonPayPayNextActionSchema,
|
|
3133
|
+
MoonPayPhoneCodeNextActionSchema,
|
|
3134
|
+
MoonPayPhoneCodeRequestSchema,
|
|
3135
|
+
MoonPayPhoneNextActionSchema,
|
|
3136
|
+
MoonPayPhoneRequestSchema,
|
|
3064
3137
|
MoonPayPrepareCaptureNextActionSchema,
|
|
3065
3138
|
MoonPayPrepareCaptureRequestSchema,
|
|
3066
3139
|
MoonPayQuoteInputSchema,
|
|
@@ -107,11 +107,16 @@ export type CoinbaseWaitNextAction = {
|
|
|
107
107
|
next: 'wait';
|
|
108
108
|
retryAfterMs: number;
|
|
109
109
|
};
|
|
110
|
-
/** The order's price: Coinbase's own totals, never Fun's. */
|
|
110
|
+
/** The order's price: Coinbase's own totals, never Fun's, and the fee subsidy Fun decided on them. */
|
|
111
111
|
export interface CoinbasePrice {
|
|
112
112
|
total: FiatAmount;
|
|
113
113
|
fees: FeeLine[];
|
|
114
114
|
cryptoAmount: string;
|
|
115
|
+
/**
|
|
116
|
+
* The fee the partner reimburses after settlement, as on `Quote.feeSubsidy`. Absent when this deposit is not
|
|
117
|
+
* subsidized. A prediction: settlement decides again.
|
|
118
|
+
*/
|
|
119
|
+
feeSubsidy?: FiatAmount;
|
|
115
120
|
}
|
|
116
121
|
/**
|
|
117
122
|
* Coinbase priced the checkout. `orderId` is minted for this answer: send it back on `placeOrder`, and on every
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** MoonPay guest checkout is a separate provider; it never connects a MoonPay customer. */
|
|
2
|
+
import type { FiatGeo } from '../types';
|
|
3
|
+
import type { MoonPayRequestContext, MoonPayObserveRequest, MoonPayConsentRequest, MoonPaySessionRequest, MoonPayPhoneRequest, MoonPayPhoneCodeRequest, MoonPayDeclineRequest, MoonPayOrderRequest, MoonPayConsentNextAction, MoonPaySessionNextAction, MoonPayPhoneNextAction, MoonPayPhoneCodeNextAction, MoonPayPayNextAction, MoonPayRefused, MoonPayOrderResponse } from './moonpay';
|
|
4
|
+
export type MoonPayGuestRequestContext = Omit<MoonPayRequestContext, 'credentials'>;
|
|
5
|
+
export type MoonPayGuestRequest = MoonPayGuestRequestContext & (MoonPayObserveRequest | MoonPayConsentRequest | MoonPaySessionRequest | MoonPayPhoneRequest | MoonPayPhoneCodeRequest | MoonPayDeclineRequest | MoonPayOrderRequest);
|
|
6
|
+
export type MoonPayGuestNextRequest = {
|
|
7
|
+
provider: 'MOONPAY_GUEST';
|
|
8
|
+
geo: FiatGeo;
|
|
9
|
+
depositAddress?: string;
|
|
10
|
+
} & MoonPayGuestRequest;
|
|
11
|
+
export type MoonPayGuestStepResponse = MoonPayConsentNextAction | MoonPaySessionNextAction | MoonPayPhoneNextAction | MoonPayPhoneCodeNextAction | MoonPayPayNextAction | MoonPayRefused<'NOT_ELIGIBLE' | 'FINAL_REJECTION', 'REQUOTE' | 'NONE'>;
|
|
12
|
+
export type MoonPayGuestResponse = MoonPayGuestStepResponse | MoonPayOrderResponse;
|
|
@@ -0,0 +1,18 @@
|
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
|
|
16
|
+
// src/providers/moonpay-guest.ts
|
|
17
|
+
var moonpay_guest_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(moonpay_guest_exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "../chunk-LTJWGDSA.mjs";
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { MoonPayGuestRequest, MoonPayGuestNextRequest } from './moonpay-guest';
|
|
3
|
+
export declare const MoonPayGuestObserveRequestSchema: z.ZodType<Extract<MoonPayGuestRequest, {
|
|
4
|
+
action: "observe";
|
|
5
|
+
}>>;
|
|
6
|
+
export declare const MoonPayGuestSessionRequestSchema: z.ZodType<Extract<MoonPayGuestRequest, {
|
|
7
|
+
action: "session";
|
|
8
|
+
}>>;
|
|
9
|
+
export declare const MoonPayGuestConsentRequestSchema: z.ZodType<Extract<MoonPayGuestRequest, {
|
|
10
|
+
action: "consent";
|
|
11
|
+
}>>;
|
|
12
|
+
export declare const MoonPayGuestOrderRequestSchema: z.ZodType<Extract<MoonPayGuestRequest, {
|
|
13
|
+
action: "order";
|
|
14
|
+
}>>;
|
|
15
|
+
export declare const MoonPayGuestPhoneNumberRequestSchema: z.ZodType<Extract<MoonPayGuestRequest, {
|
|
16
|
+
action: "phone";
|
|
17
|
+
phoneNumber: string;
|
|
18
|
+
}>>;
|
|
19
|
+
export declare const MoonPayGuestPhoneResendRequestSchema: z.ZodType<Extract<MoonPayGuestRequest, {
|
|
20
|
+
action: "phone";
|
|
21
|
+
resend: string;
|
|
22
|
+
}>>;
|
|
23
|
+
export declare const MoonPayGuestPhoneCodeRequestSchema: z.ZodType<Extract<MoonPayGuestRequest, {
|
|
24
|
+
action: "phoneCode";
|
|
25
|
+
}>>;
|
|
26
|
+
export declare const MoonPayGuestDeclineRequestSchema: z.ZodType<Extract<MoonPayGuestRequest, {
|
|
27
|
+
action: "decline";
|
|
28
|
+
}>>;
|
|
29
|
+
export declare const MoonPayGuestPhoneRequestSchema: z.ZodType<Extract<MoonPayGuestRequest, {
|
|
30
|
+
action: "phone";
|
|
31
|
+
}>>;
|
|
32
|
+
export declare const MoonPayGuestRequestSchema: z.ZodType<MoonPayGuestRequest>;
|
|
33
|
+
export declare const MoonPayGuestNextRequestSchema: z.ZodType<MoonPayGuestNextRequest>;
|
|
34
|
+
import type { MoonPayGuestStepResponse, MoonPayGuestResponse } from './moonpay-guest';
|
|
35
|
+
export declare const MoonPayGuestStepResponseSchema: z.ZodType<MoonPayGuestStepResponse>;
|
|
36
|
+
export declare const MoonPayGuestResponseSchema: z.ZodType<MoonPayGuestResponse>;
|