@fun-xyz/fiat-contract 0.49.0 → 0.51.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-6NZFTT7Q.mjs → chunk-ICIHTCZN.mjs} +1 -1
- package/dist/codes.d.ts +6 -0
- package/dist/index.js +89 -13
- package/dist/index.mjs +89 -13
- package/dist/providers/coinbase.d.ts +2 -1
- package/dist/providers/moonpay.d.ts +2 -1
- package/dist/providers/stripe.d.ts +36 -13
- package/dist/providers/stripe.schemas.d.ts +3 -1
- package/dist/schemas.d.ts +12 -1
- package/dist/table.js +1 -1
- package/dist/table.mjs +1 -1
- package/dist/types.d.ts +14 -0
- package/package.json +1 -1
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.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,
|
|
@@ -170,6 +172,7 @@ __export(index_exports, {
|
|
|
170
172
|
MoonPayWaitNextActionSchema: () => MoonPayWaitNextActionSchema,
|
|
171
173
|
OrderAwaitingConfirmationStateSchema: () => OrderAwaitingConfirmationStateSchema,
|
|
172
174
|
OrderCreatedStateSchema: () => OrderCreatedStateSchema,
|
|
175
|
+
OrderPollSchema: () => OrderPollSchema,
|
|
173
176
|
OrderRefSchema: () => OrderRefSchema,
|
|
174
177
|
OrderStatusSchema: () => OrderStatusSchema,
|
|
175
178
|
OrderSummarySchema: () => OrderSummarySchema,
|
|
@@ -198,6 +201,7 @@ __export(index_exports, {
|
|
|
198
201
|
SelectOptionSchema: () => SelectOptionSchema,
|
|
199
202
|
SessionAuthStateSchema: () => SessionAuthStateSchema,
|
|
200
203
|
StatusHistoryEntrySchema: () => StatusHistoryEntrySchema,
|
|
204
|
+
StripeAttestationNextActionSchema: () => StripeAttestationNextActionSchema,
|
|
201
205
|
StripeAuthorizeNextActionSchema: () => StripeAuthorizeNextActionSchema,
|
|
202
206
|
StripeAuthorizeRequestSchema: () => StripeAuthorizeRequestSchema,
|
|
203
207
|
StripeCheckoutRequestSchema: () => StripeCheckoutRequestSchema,
|
|
@@ -209,6 +213,7 @@ __export(index_exports, {
|
|
|
209
213
|
StripeDoneSchema: () => StripeDoneSchema,
|
|
210
214
|
StripeErrorBodySchema: () => StripeErrorBodySchema,
|
|
211
215
|
StripeFaultSchema: () => StripeFaultSchema,
|
|
216
|
+
StripeIdentifiersNextActionSchema: () => StripeIdentifiersNextActionSchema,
|
|
212
217
|
StripeKycNextActionSchema: () => StripeKycNextActionSchema,
|
|
213
218
|
StripeKycRequestSchema: () => StripeKycRequestSchema,
|
|
214
219
|
StripeLinkAuthTokenSchema: () => StripeLinkAuthTokenSchema,
|
|
@@ -256,8 +261,11 @@ __export(index_exports, {
|
|
|
256
261
|
assertLegalEmission: () => assertLegalEmission,
|
|
257
262
|
assertLegalReturn: () => assertLegalReturn,
|
|
258
263
|
checkLegalEmission: () => checkLegalEmission,
|
|
264
|
+
checkOrderPendingPoll: () => checkOrderPendingPoll,
|
|
259
265
|
endpointMatches: () => endpointMatches,
|
|
260
266
|
fixtureMeta: () => fixtureMeta,
|
|
267
|
+
isEeaCountry: () => isEeaCountry,
|
|
268
|
+
isEuCountry: () => isEuCountry,
|
|
261
269
|
isTerminal: () => isTerminal,
|
|
262
270
|
loadFixture: () => loadFixture,
|
|
263
271
|
loadFixtures: () => loadFixtures,
|
|
@@ -590,6 +598,40 @@ var COUNTRY_NAMES = Object.fromEntries(COUNTRY_CURRENCY_LIST.map((e) => [e.count
|
|
|
590
598
|
var FIAT_CURRENCY_NAMES = Object.fromEntries(uniqueCurrencies);
|
|
591
599
|
var COUNTRY_TO_CURRENCY = Object.fromEntries(COUNTRY_CURRENCY_LIST.map((e) => [e.country, e.currency]));
|
|
592
600
|
var PAYMENT_METHOD_CATEGORIES = ["card", "apple_pay", "google_pay", "bank_transfer"];
|
|
601
|
+
var EU_COUNTRIES = [
|
|
602
|
+
"AT",
|
|
603
|
+
"BE",
|
|
604
|
+
"BG",
|
|
605
|
+
"HR",
|
|
606
|
+
"CY",
|
|
607
|
+
"CZ",
|
|
608
|
+
"DK",
|
|
609
|
+
"EE",
|
|
610
|
+
"FI",
|
|
611
|
+
"FR",
|
|
612
|
+
"DE",
|
|
613
|
+
"GR",
|
|
614
|
+
"HU",
|
|
615
|
+
"IE",
|
|
616
|
+
"IT",
|
|
617
|
+
"LV",
|
|
618
|
+
"LT",
|
|
619
|
+
"LU",
|
|
620
|
+
"MT",
|
|
621
|
+
"NL",
|
|
622
|
+
"PL",
|
|
623
|
+
"PT",
|
|
624
|
+
"RO",
|
|
625
|
+
"SK",
|
|
626
|
+
"SI",
|
|
627
|
+
"ES",
|
|
628
|
+
"SE"
|
|
629
|
+
];
|
|
630
|
+
var EEA_COUNTRIES = [...EU_COUNTRIES, "IS", "LI", "NO"];
|
|
631
|
+
var EU_COUNTRY_SET = new Set(EU_COUNTRIES);
|
|
632
|
+
var EEA_COUNTRY_SET = new Set(EEA_COUNTRIES);
|
|
633
|
+
var isEuCountry = (country) => EU_COUNTRY_SET.has(country);
|
|
634
|
+
var isEeaCountry = (country) => EEA_COUNTRY_SET.has(country);
|
|
593
635
|
|
|
594
636
|
// src/schemas.ts
|
|
595
637
|
var import_zod = require("zod");
|
|
@@ -949,6 +991,21 @@ var $pollSpec = obj({
|
|
|
949
991
|
}
|
|
950
992
|
});
|
|
951
993
|
var PollSpecSchema = $pollSpec;
|
|
994
|
+
var OrderPollSchema = obj({
|
|
995
|
+
backoffFactor: import_zod.z.number().finite().min(1).max(4),
|
|
996
|
+
maxIntervalMs: import_zod.z.number().int().min(MIN_INTERVAL_MS).max(6e4),
|
|
997
|
+
giveUpAfterMs: import_zod.z.number().int().positive().max(60 * 60 * 1e3)
|
|
998
|
+
});
|
|
999
|
+
function checkOrderPendingPoll(response, context2) {
|
|
1000
|
+
const { poll, retryAfterMs: retryAfterMs2 } = response;
|
|
1001
|
+
if (response.next !== "orderPending" || poll === void 0 || retryAfterMs2 === void 0) return;
|
|
1002
|
+
if (retryAfterMs2 < MIN_INTERVAL_MS) {
|
|
1003
|
+
context2.addIssue({ code: "custom", path: ["retryAfterMs"], message: `retryAfterMs must be at least ${MIN_INTERVAL_MS} with a poll` });
|
|
1004
|
+
}
|
|
1005
|
+
if (poll.maxIntervalMs < retryAfterMs2) {
|
|
1006
|
+
context2.addIssue({ code: "custom", path: ["poll", "maxIntervalMs"], message: "maxIntervalMs must be at least retryAfterMs" });
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
952
1009
|
var $reportSpec = obj({
|
|
953
1010
|
endpoint: $endpoint,
|
|
954
1011
|
params: $params.optional(),
|
|
@@ -1433,7 +1490,7 @@ var $stepResponse = import_zod.z.union([$providerBoundStepResponse, $funAuthStep
|
|
|
1433
1490
|
var FiatStepResponseSchema = $stepResponse;
|
|
1434
1491
|
|
|
1435
1492
|
// package.json
|
|
1436
|
-
var version = "0.
|
|
1493
|
+
var version = "0.51.0";
|
|
1437
1494
|
|
|
1438
1495
|
// src/table.ts
|
|
1439
1496
|
var TABLE_VERSION = version;
|
|
@@ -3565,6 +3622,7 @@ var $orderPendingNextAction = obj2({
|
|
|
3565
3622
|
next: import_zod2.z.literal("orderPending"),
|
|
3566
3623
|
orderId: $nonEmpty,
|
|
3567
3624
|
retryAfterMs: import_zod2.z.number().int().positive().max(6e4),
|
|
3625
|
+
poll: OrderPollSchema.optional(),
|
|
3568
3626
|
order: FiatStepResponseSchema.nullable()
|
|
3569
3627
|
});
|
|
3570
3628
|
var checkConsent = (nextAction, context2) => {
|
|
@@ -3608,7 +3666,7 @@ var MoonPayReaskSchema = $reask;
|
|
|
3608
3666
|
var MoonPayCaptureNextActionSchema = $captureShape.superRefine(checkCapture);
|
|
3609
3667
|
var MoonPayWaitNextActionSchema = $waitNextAction;
|
|
3610
3668
|
var MoonPayOrderNextActionSchema = $orderNextAction;
|
|
3611
|
-
var MoonPayOrderPendingNextActionSchema = $orderPendingNextAction;
|
|
3669
|
+
var MoonPayOrderPendingNextActionSchema = $orderPendingNextAction.superRefine(checkOrderPendingPoll);
|
|
3612
3670
|
var checkNextAction = (response, context2) => {
|
|
3613
3671
|
if (response.next === "consent") checkConsent(response, context2);
|
|
3614
3672
|
if (response.next === "kyc") checkKyc(response, context2);
|
|
@@ -3640,7 +3698,7 @@ var $orderRefused = obj2({
|
|
|
3640
3698
|
});
|
|
3641
3699
|
var $stepResponse2 = import_zod2.z.discriminatedUnion("next", [...$nextActionOptions, $stepRefused]).superRefine(checkNextAction);
|
|
3642
3700
|
var MoonPayStepResponseSchema = $stepResponse2;
|
|
3643
|
-
var $orderResponse = import_zod2.z.discriminatedUnion("next", [$done, $orderNextAction, $orderPendingNextAction, $orderRefused]);
|
|
3701
|
+
var $orderResponse = import_zod2.z.discriminatedUnion("next", [$done, $orderNextAction, $orderPendingNextAction, $orderRefused]).superRefine(checkOrderPendingPoll);
|
|
3644
3702
|
var MoonPayOrderResponseSchema = $orderResponse;
|
|
3645
3703
|
var MoonPayResponseSchemaFor = {
|
|
3646
3704
|
observe: MoonPayStepResponseSchema,
|
|
@@ -3778,6 +3836,7 @@ var $orderPendingNextAction2 = obj3({
|
|
|
3778
3836
|
next: import_zod3.z.literal("orderPending"),
|
|
3779
3837
|
orderId: $nonEmpty2,
|
|
3780
3838
|
retryAfterMs: $retryAfterMs,
|
|
3839
|
+
poll: OrderPollSchema.optional(),
|
|
3781
3840
|
order: FiatStepResponseSchema.nullable()
|
|
3782
3841
|
});
|
|
3783
3842
|
var checkConsent2 = (nextAction, context2) => {
|
|
@@ -3804,8 +3863,9 @@ var CoinbaseKycNextActionSchema = $kycShape2.superRefine(checkKyc2);
|
|
|
3804
3863
|
var CoinbaseWaitNextActionSchema = $waitNextAction2;
|
|
3805
3864
|
var CoinbasePlaceOrderNextActionSchema = $placeOrderNextAction;
|
|
3806
3865
|
var CoinbasePayNextActionSchema = $payNextAction2;
|
|
3807
|
-
var CoinbaseOrderPendingNextActionSchema = $orderPendingNextAction2;
|
|
3866
|
+
var CoinbaseOrderPendingNextActionSchema = $orderPendingNextAction2.superRefine(checkOrderPendingPoll);
|
|
3808
3867
|
var checkNextAction2 = (response, context2) => {
|
|
3868
|
+
checkOrderPendingPoll(response, context2);
|
|
3809
3869
|
if (response.next === "consent") checkConsent2(response, context2);
|
|
3810
3870
|
if (response.next === "kyc") checkKyc2(response, context2);
|
|
3811
3871
|
};
|
|
@@ -3839,7 +3899,7 @@ var $refused = import_zod3.z.union([
|
|
|
3839
3899
|
var CoinbaseRefusedSchema = $refused;
|
|
3840
3900
|
var $stepResponse3 = import_zod3.z.union([import_zod3.z.discriminatedUnion("next", [...$nextActionOptions2, $done2]), $refused]).superRefine(checkNextAction2);
|
|
3841
3901
|
var CoinbaseStepResponseSchema = $stepResponse3;
|
|
3842
|
-
var $orderResponse2 = import_zod3.z.discriminatedUnion("next", [$done2, $orderPendingNextAction2]);
|
|
3902
|
+
var $orderResponse2 = import_zod3.z.discriminatedUnion("next", [$done2, $orderPendingNextAction2]).superRefine(checkOrderPendingPoll);
|
|
3843
3903
|
var CoinbaseOrderResponseSchema = $orderResponse2;
|
|
3844
3904
|
var CoinbaseResponseSchemaFor = {
|
|
3845
3905
|
observe: CoinbaseStepResponseSchema,
|
|
@@ -3876,11 +3936,13 @@ var obj4 = (shape) => import_zod4.z.object(shape).strict();
|
|
|
3876
3936
|
var nonEmpty = import_zod4.z.string().refine((value) => value.trim().length > 0, "must not be blank");
|
|
3877
3937
|
var hasUniqueIds4 = (ids) => new Set(ids).size === ids.length;
|
|
3878
3938
|
var retryAfterMs = import_zod4.z.number().int().positive().max(6e4);
|
|
3879
|
-
var
|
|
3939
|
+
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");
|
|
3880
3940
|
var kycValues = import_zod4.z.record(KycFieldIdSchema, import_zod4.z.string());
|
|
3881
3941
|
var instant = import_zod4.z.string().datetime({ offset: true });
|
|
3942
|
+
var chargeCurrency = import_zod4.z.enum(["USD", "EUR"]);
|
|
3943
|
+
var countryCode = import_zod4.z.enum(Object.keys(CountryCode));
|
|
3882
3944
|
var checkout = obj4({
|
|
3883
|
-
amount: obj4({ currency:
|
|
3945
|
+
amount: obj4({ currency: chargeCurrency, amount: centsAmount }),
|
|
3884
3946
|
destination: obj4({ asset: nonEmpty, network: nonEmpty }),
|
|
3885
3947
|
paymentMethod: import_zod4.z.literal("apple_pay")
|
|
3886
3948
|
});
|
|
@@ -3947,9 +4009,9 @@ var paySheet = obj4({
|
|
|
3947
4009
|
destinationCurrency: nonEmpty,
|
|
3948
4010
|
destinationNetwork: nonEmpty,
|
|
3949
4011
|
walletAddress: nonEmpty,
|
|
3950
|
-
merchantCountryCode:
|
|
3951
|
-
currencyCode:
|
|
3952
|
-
amount:
|
|
4012
|
+
merchantCountryCode: countryCode,
|
|
4013
|
+
currencyCode: chargeCurrency,
|
|
4014
|
+
amount: centsAmount,
|
|
3953
4015
|
label: nonEmpty
|
|
3954
4016
|
});
|
|
3955
4017
|
var StripePaySheetSchema = paySheet;
|
|
@@ -3966,7 +4028,7 @@ var authorizeNextAction = obj4({ next: import_zod4.z.literal("authorize"), linkA
|
|
|
3966
4028
|
var kycShape = obj4({
|
|
3967
4029
|
next: import_zod4.z.literal("kyc"),
|
|
3968
4030
|
round: import_zod4.z.enum(["ACCOUNT", "IDENTITY"]),
|
|
3969
|
-
tier: import_zod4.z.enum(["l0", "l1"]),
|
|
4031
|
+
tier: import_zod4.z.enum(["l0", "l1", "l2"]),
|
|
3970
4032
|
correctionRound,
|
|
3971
4033
|
fields: import_zod4.z.array(FormFieldSchema),
|
|
3972
4034
|
heldValues: kycValues,
|
|
@@ -3975,6 +4037,8 @@ var kycShape = obj4({
|
|
|
3975
4037
|
fieldErrors: import_zod4.z.array(obj4({ fieldId: nonEmpty, message: nonEmpty })).min(1).optional(),
|
|
3976
4038
|
reask: reask.nullable()
|
|
3977
4039
|
});
|
|
4040
|
+
var identifiersNextAction = obj4({ next: import_zod4.z.literal("identifiers"), linkAuthToken: linkAuthToken.nullable() });
|
|
4041
|
+
var attestationNextAction = obj4({ next: import_zod4.z.literal("attestation"), linkAuthToken: linkAuthToken.nullable() });
|
|
3978
4042
|
var verifyIdentityNextAction = obj4({ next: import_zod4.z.literal("verifyIdentity"), linkAuthToken: linkAuthToken.nullable() });
|
|
3979
4043
|
var waitNextAction = obj4({ next: import_zod4.z.literal("wait"), retryAfterMs });
|
|
3980
4044
|
var placeOrderNextAction = obj4({
|
|
@@ -3990,6 +4054,7 @@ var orderPendingNextAction = obj4({
|
|
|
3990
4054
|
next: import_zod4.z.literal("orderPending"),
|
|
3991
4055
|
orderId: mintedOrderId,
|
|
3992
4056
|
retryAfterMs,
|
|
4057
|
+
poll: OrderPollSchema.optional(),
|
|
3993
4058
|
order: FiatStepResponseSchema.nullable()
|
|
3994
4059
|
});
|
|
3995
4060
|
var checkConsent3 = (nextAction, context2) => {
|
|
@@ -4011,23 +4076,32 @@ var checkKyc3 = (nextAction, context2) => {
|
|
|
4011
4076
|
if (nextAction.round === "ACCOUNT" !== (nextAction.verifiedEmail !== null)) {
|
|
4012
4077
|
context2.addIssue({ code: "custom", path: ["verifiedEmail"], message: "only the account round carries the verified email" });
|
|
4013
4078
|
}
|
|
4079
|
+
if (nextAction.tier === "l2" && nextAction.round !== "IDENTITY") {
|
|
4080
|
+
context2.addIssue({ code: "custom", path: ["tier"], message: "l2 is an identity round" });
|
|
4081
|
+
}
|
|
4014
4082
|
};
|
|
4015
4083
|
var checkPlaceOrder = (nextAction, context2) => {
|
|
4016
4084
|
if (nextAction.paySheet.amount !== nextAction.price.total.amount) {
|
|
4017
4085
|
context2.addIssue({ code: "custom", path: ["paySheet", "amount"], message: "the sheet charges the price shown" });
|
|
4018
4086
|
}
|
|
4087
|
+
if (nextAction.paySheet.currencyCode !== nextAction.price.total.currency) {
|
|
4088
|
+
context2.addIssue({ code: "custom", path: ["paySheet", "currencyCode"], message: "the sheet charges the price currency" });
|
|
4089
|
+
}
|
|
4019
4090
|
};
|
|
4020
4091
|
var StripeConsentNextActionSchema = consentShape.superRefine(checkConsent3);
|
|
4021
4092
|
var StripeSessionNextActionSchema = sessionNextAction;
|
|
4022
4093
|
var StripeAuthorizeNextActionSchema = authorizeNextAction;
|
|
4023
4094
|
var StripeKycNextActionSchema = kycShape.superRefine(checkKyc3);
|
|
4095
|
+
var StripeIdentifiersNextActionSchema = identifiersNextAction;
|
|
4096
|
+
var StripeAttestationNextActionSchema = attestationNextAction;
|
|
4024
4097
|
var StripeVerifyIdentityNextActionSchema = verifyIdentityNextAction;
|
|
4025
4098
|
var StripeWaitNextActionSchema = waitNextAction;
|
|
4026
4099
|
var StripePlaceOrderNextActionSchema = placeOrderNextAction.superRefine(checkPlaceOrder);
|
|
4027
4100
|
var StripePayNextActionSchema = payNextAction;
|
|
4028
4101
|
var StripeCheckoutSecretNextActionSchema = checkoutSecretNextAction;
|
|
4029
|
-
var StripeOrderPendingNextActionSchema = orderPendingNextAction;
|
|
4102
|
+
var StripeOrderPendingNextActionSchema = orderPendingNextAction.superRefine(checkOrderPendingPoll);
|
|
4030
4103
|
var checkNextAction3 = (response, context2) => {
|
|
4104
|
+
checkOrderPendingPoll(response, context2);
|
|
4031
4105
|
if (response.next === "consent") checkConsent3(response, context2);
|
|
4032
4106
|
if (response.next === "kyc") checkKyc3(response, context2);
|
|
4033
4107
|
if (response.next === "placeOrder") checkPlaceOrder(response, context2);
|
|
@@ -4037,6 +4111,8 @@ var nextActionOptions = [
|
|
|
4037
4111
|
sessionNextAction,
|
|
4038
4112
|
authorizeNextAction,
|
|
4039
4113
|
kycShape,
|
|
4114
|
+
identifiersNextAction,
|
|
4115
|
+
attestationNextAction,
|
|
4040
4116
|
verifyIdentityNextAction,
|
|
4041
4117
|
waitNextAction,
|
|
4042
4118
|
placeOrderNextAction,
|
|
@@ -4065,7 +4141,7 @@ var stepResponse = import_zod4.z.union([import_zod4.z.discriminatedUnion("next",
|
|
|
4065
4141
|
var StripeStepResponseSchema = stepResponse;
|
|
4066
4142
|
var checkoutResponse = import_zod4.z.union([import_zod4.z.discriminatedUnion("next", [...nextActionOptions, done, checkoutSecretNextAction]), refused]).superRefine(checkNextAction3);
|
|
4067
4143
|
var StripeCheckoutResponseSchema = checkoutResponse;
|
|
4068
|
-
var orderResponse = import_zod4.z.discriminatedUnion("next", [done, orderPendingNextAction]);
|
|
4144
|
+
var orderResponse = import_zod4.z.discriminatedUnion("next", [done, orderPendingNextAction]).superRefine(checkOrderPendingPoll);
|
|
4069
4145
|
var StripeOrderResponseSchema = orderResponse;
|
|
4070
4146
|
var StripeResponseSchemaFor = {
|
|
4071
4147
|
observe: StripeStepResponseSchema,
|
package/dist/index.mjs
CHANGED
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
tableEntry,
|
|
17
17
|
unofferedEndpoints,
|
|
18
18
|
unreachableStates
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-ICIHTCZN.mjs";
|
|
20
20
|
import {
|
|
21
21
|
MOONPAY_ENDPOINTS
|
|
22
22
|
} from "./chunk-TIEGTTFY.mjs";
|
|
@@ -356,6 +356,40 @@ var COUNTRY_NAMES = Object.fromEntries(COUNTRY_CURRENCY_LIST.map((e) => [e.count
|
|
|
356
356
|
var FIAT_CURRENCY_NAMES = Object.fromEntries(uniqueCurrencies);
|
|
357
357
|
var COUNTRY_TO_CURRENCY = Object.fromEntries(COUNTRY_CURRENCY_LIST.map((e) => [e.country, e.currency]));
|
|
358
358
|
var PAYMENT_METHOD_CATEGORIES = ["card", "apple_pay", "google_pay", "bank_transfer"];
|
|
359
|
+
var EU_COUNTRIES = [
|
|
360
|
+
"AT",
|
|
361
|
+
"BE",
|
|
362
|
+
"BG",
|
|
363
|
+
"HR",
|
|
364
|
+
"CY",
|
|
365
|
+
"CZ",
|
|
366
|
+
"DK",
|
|
367
|
+
"EE",
|
|
368
|
+
"FI",
|
|
369
|
+
"FR",
|
|
370
|
+
"DE",
|
|
371
|
+
"GR",
|
|
372
|
+
"HU",
|
|
373
|
+
"IE",
|
|
374
|
+
"IT",
|
|
375
|
+
"LV",
|
|
376
|
+
"LT",
|
|
377
|
+
"LU",
|
|
378
|
+
"MT",
|
|
379
|
+
"NL",
|
|
380
|
+
"PL",
|
|
381
|
+
"PT",
|
|
382
|
+
"RO",
|
|
383
|
+
"SK",
|
|
384
|
+
"SI",
|
|
385
|
+
"ES",
|
|
386
|
+
"SE"
|
|
387
|
+
];
|
|
388
|
+
var EEA_COUNTRIES = [...EU_COUNTRIES, "IS", "LI", "NO"];
|
|
389
|
+
var EU_COUNTRY_SET = new Set(EU_COUNTRIES);
|
|
390
|
+
var EEA_COUNTRY_SET = new Set(EEA_COUNTRIES);
|
|
391
|
+
var isEuCountry = (country) => EU_COUNTRY_SET.has(country);
|
|
392
|
+
var isEeaCountry = (country) => EEA_COUNTRY_SET.has(country);
|
|
359
393
|
|
|
360
394
|
// src/schemas.ts
|
|
361
395
|
import { z } from "zod";
|
|
@@ -715,6 +749,21 @@ var $pollSpec = obj({
|
|
|
715
749
|
}
|
|
716
750
|
});
|
|
717
751
|
var PollSpecSchema = $pollSpec;
|
|
752
|
+
var OrderPollSchema = obj({
|
|
753
|
+
backoffFactor: z.number().finite().min(1).max(4),
|
|
754
|
+
maxIntervalMs: z.number().int().min(MIN_INTERVAL_MS).max(6e4),
|
|
755
|
+
giveUpAfterMs: z.number().int().positive().max(60 * 60 * 1e3)
|
|
756
|
+
});
|
|
757
|
+
function checkOrderPendingPoll(response, context2) {
|
|
758
|
+
const { poll, retryAfterMs: retryAfterMs2 } = response;
|
|
759
|
+
if (response.next !== "orderPending" || poll === void 0 || retryAfterMs2 === void 0) return;
|
|
760
|
+
if (retryAfterMs2 < MIN_INTERVAL_MS) {
|
|
761
|
+
context2.addIssue({ code: "custom", path: ["retryAfterMs"], message: `retryAfterMs must be at least ${MIN_INTERVAL_MS} with a poll` });
|
|
762
|
+
}
|
|
763
|
+
if (poll.maxIntervalMs < retryAfterMs2) {
|
|
764
|
+
context2.addIssue({ code: "custom", path: ["poll", "maxIntervalMs"], message: "maxIntervalMs must be at least retryAfterMs" });
|
|
765
|
+
}
|
|
766
|
+
}
|
|
718
767
|
var $reportSpec = obj({
|
|
719
768
|
endpoint: $endpoint,
|
|
720
769
|
params: $params.optional(),
|
|
@@ -2662,6 +2711,7 @@ var $orderPendingNextAction = obj2({
|
|
|
2662
2711
|
next: z2.literal("orderPending"),
|
|
2663
2712
|
orderId: $nonEmpty,
|
|
2664
2713
|
retryAfterMs: z2.number().int().positive().max(6e4),
|
|
2714
|
+
poll: OrderPollSchema.optional(),
|
|
2665
2715
|
order: FiatStepResponseSchema.nullable()
|
|
2666
2716
|
});
|
|
2667
2717
|
var checkConsent = (nextAction, context2) => {
|
|
@@ -2705,7 +2755,7 @@ var MoonPayReaskSchema = $reask;
|
|
|
2705
2755
|
var MoonPayCaptureNextActionSchema = $captureShape.superRefine(checkCapture);
|
|
2706
2756
|
var MoonPayWaitNextActionSchema = $waitNextAction;
|
|
2707
2757
|
var MoonPayOrderNextActionSchema = $orderNextAction;
|
|
2708
|
-
var MoonPayOrderPendingNextActionSchema = $orderPendingNextAction;
|
|
2758
|
+
var MoonPayOrderPendingNextActionSchema = $orderPendingNextAction.superRefine(checkOrderPendingPoll);
|
|
2709
2759
|
var checkNextAction = (response, context2) => {
|
|
2710
2760
|
if (response.next === "consent") checkConsent(response, context2);
|
|
2711
2761
|
if (response.next === "kyc") checkKyc(response, context2);
|
|
@@ -2737,7 +2787,7 @@ var $orderRefused = obj2({
|
|
|
2737
2787
|
});
|
|
2738
2788
|
var $stepResponse2 = z2.discriminatedUnion("next", [...$nextActionOptions, $stepRefused]).superRefine(checkNextAction);
|
|
2739
2789
|
var MoonPayStepResponseSchema = $stepResponse2;
|
|
2740
|
-
var $orderResponse = z2.discriminatedUnion("next", [$done, $orderNextAction, $orderPendingNextAction, $orderRefused]);
|
|
2790
|
+
var $orderResponse = z2.discriminatedUnion("next", [$done, $orderNextAction, $orderPendingNextAction, $orderRefused]).superRefine(checkOrderPendingPoll);
|
|
2741
2791
|
var MoonPayOrderResponseSchema = $orderResponse;
|
|
2742
2792
|
var MoonPayResponseSchemaFor = {
|
|
2743
2793
|
observe: MoonPayStepResponseSchema,
|
|
@@ -2862,6 +2912,7 @@ var $orderPendingNextAction2 = obj3({
|
|
|
2862
2912
|
next: z3.literal("orderPending"),
|
|
2863
2913
|
orderId: $nonEmpty2,
|
|
2864
2914
|
retryAfterMs: $retryAfterMs,
|
|
2915
|
+
poll: OrderPollSchema.optional(),
|
|
2865
2916
|
order: FiatStepResponseSchema.nullable()
|
|
2866
2917
|
});
|
|
2867
2918
|
var checkConsent2 = (nextAction, context2) => {
|
|
@@ -2888,8 +2939,9 @@ var CoinbaseKycNextActionSchema = $kycShape2.superRefine(checkKyc2);
|
|
|
2888
2939
|
var CoinbaseWaitNextActionSchema = $waitNextAction2;
|
|
2889
2940
|
var CoinbasePlaceOrderNextActionSchema = $placeOrderNextAction;
|
|
2890
2941
|
var CoinbasePayNextActionSchema = $payNextAction2;
|
|
2891
|
-
var CoinbaseOrderPendingNextActionSchema = $orderPendingNextAction2;
|
|
2942
|
+
var CoinbaseOrderPendingNextActionSchema = $orderPendingNextAction2.superRefine(checkOrderPendingPoll);
|
|
2892
2943
|
var checkNextAction2 = (response, context2) => {
|
|
2944
|
+
checkOrderPendingPoll(response, context2);
|
|
2893
2945
|
if (response.next === "consent") checkConsent2(response, context2);
|
|
2894
2946
|
if (response.next === "kyc") checkKyc2(response, context2);
|
|
2895
2947
|
};
|
|
@@ -2923,7 +2975,7 @@ var $refused = z3.union([
|
|
|
2923
2975
|
var CoinbaseRefusedSchema = $refused;
|
|
2924
2976
|
var $stepResponse3 = z3.union([z3.discriminatedUnion("next", [...$nextActionOptions2, $done2]), $refused]).superRefine(checkNextAction2);
|
|
2925
2977
|
var CoinbaseStepResponseSchema = $stepResponse3;
|
|
2926
|
-
var $orderResponse2 = z3.discriminatedUnion("next", [$done2, $orderPendingNextAction2]);
|
|
2978
|
+
var $orderResponse2 = z3.discriminatedUnion("next", [$done2, $orderPendingNextAction2]).superRefine(checkOrderPendingPoll);
|
|
2927
2979
|
var CoinbaseOrderResponseSchema = $orderResponse2;
|
|
2928
2980
|
var CoinbaseResponseSchemaFor = {
|
|
2929
2981
|
observe: CoinbaseStepResponseSchema,
|
|
@@ -2955,11 +3007,13 @@ var obj4 = (shape) => z4.object(shape).strict();
|
|
|
2955
3007
|
var nonEmpty = z4.string().refine((value) => value.trim().length > 0, "must not be blank");
|
|
2956
3008
|
var hasUniqueIds4 = (ids) => new Set(ids).size === ids.length;
|
|
2957
3009
|
var retryAfterMs = z4.number().int().positive().max(6e4);
|
|
2958
|
-
var
|
|
3010
|
+
var centsAmount = z4.string().regex(/^(?:0|[1-9]\d*)(?:\.\d{1,2})?$/, "must be an amount in cents").refine((amount) => Number(amount) > 0, "must be positive");
|
|
2959
3011
|
var kycValues = z4.record(KycFieldIdSchema, z4.string());
|
|
2960
3012
|
var instant = z4.string().datetime({ offset: true });
|
|
3013
|
+
var chargeCurrency = z4.enum(["USD", "EUR"]);
|
|
3014
|
+
var countryCode = z4.enum(Object.keys(CountryCode));
|
|
2961
3015
|
var checkout = obj4({
|
|
2962
|
-
amount: obj4({ currency:
|
|
3016
|
+
amount: obj4({ currency: chargeCurrency, amount: centsAmount }),
|
|
2963
3017
|
destination: obj4({ asset: nonEmpty, network: nonEmpty }),
|
|
2964
3018
|
paymentMethod: z4.literal("apple_pay")
|
|
2965
3019
|
});
|
|
@@ -3026,9 +3080,9 @@ var paySheet = obj4({
|
|
|
3026
3080
|
destinationCurrency: nonEmpty,
|
|
3027
3081
|
destinationNetwork: nonEmpty,
|
|
3028
3082
|
walletAddress: nonEmpty,
|
|
3029
|
-
merchantCountryCode:
|
|
3030
|
-
currencyCode:
|
|
3031
|
-
amount:
|
|
3083
|
+
merchantCountryCode: countryCode,
|
|
3084
|
+
currencyCode: chargeCurrency,
|
|
3085
|
+
amount: centsAmount,
|
|
3032
3086
|
label: nonEmpty
|
|
3033
3087
|
});
|
|
3034
3088
|
var StripePaySheetSchema = paySheet;
|
|
@@ -3045,7 +3099,7 @@ var authorizeNextAction = obj4({ next: z4.literal("authorize"), linkAuthIntentId
|
|
|
3045
3099
|
var kycShape = obj4({
|
|
3046
3100
|
next: z4.literal("kyc"),
|
|
3047
3101
|
round: z4.enum(["ACCOUNT", "IDENTITY"]),
|
|
3048
|
-
tier: z4.enum(["l0", "l1"]),
|
|
3102
|
+
tier: z4.enum(["l0", "l1", "l2"]),
|
|
3049
3103
|
correctionRound,
|
|
3050
3104
|
fields: z4.array(FormFieldSchema),
|
|
3051
3105
|
heldValues: kycValues,
|
|
@@ -3054,6 +3108,8 @@ var kycShape = obj4({
|
|
|
3054
3108
|
fieldErrors: z4.array(obj4({ fieldId: nonEmpty, message: nonEmpty })).min(1).optional(),
|
|
3055
3109
|
reask: reask.nullable()
|
|
3056
3110
|
});
|
|
3111
|
+
var identifiersNextAction = obj4({ next: z4.literal("identifiers"), linkAuthToken: linkAuthToken.nullable() });
|
|
3112
|
+
var attestationNextAction = obj4({ next: z4.literal("attestation"), linkAuthToken: linkAuthToken.nullable() });
|
|
3057
3113
|
var verifyIdentityNextAction = obj4({ next: z4.literal("verifyIdentity"), linkAuthToken: linkAuthToken.nullable() });
|
|
3058
3114
|
var waitNextAction = obj4({ next: z4.literal("wait"), retryAfterMs });
|
|
3059
3115
|
var placeOrderNextAction = obj4({
|
|
@@ -3069,6 +3125,7 @@ var orderPendingNextAction = obj4({
|
|
|
3069
3125
|
next: z4.literal("orderPending"),
|
|
3070
3126
|
orderId: mintedOrderId,
|
|
3071
3127
|
retryAfterMs,
|
|
3128
|
+
poll: OrderPollSchema.optional(),
|
|
3072
3129
|
order: FiatStepResponseSchema.nullable()
|
|
3073
3130
|
});
|
|
3074
3131
|
var checkConsent3 = (nextAction, context2) => {
|
|
@@ -3090,23 +3147,32 @@ var checkKyc3 = (nextAction, context2) => {
|
|
|
3090
3147
|
if (nextAction.round === "ACCOUNT" !== (nextAction.verifiedEmail !== null)) {
|
|
3091
3148
|
context2.addIssue({ code: "custom", path: ["verifiedEmail"], message: "only the account round carries the verified email" });
|
|
3092
3149
|
}
|
|
3150
|
+
if (nextAction.tier === "l2" && nextAction.round !== "IDENTITY") {
|
|
3151
|
+
context2.addIssue({ code: "custom", path: ["tier"], message: "l2 is an identity round" });
|
|
3152
|
+
}
|
|
3093
3153
|
};
|
|
3094
3154
|
var checkPlaceOrder = (nextAction, context2) => {
|
|
3095
3155
|
if (nextAction.paySheet.amount !== nextAction.price.total.amount) {
|
|
3096
3156
|
context2.addIssue({ code: "custom", path: ["paySheet", "amount"], message: "the sheet charges the price shown" });
|
|
3097
3157
|
}
|
|
3158
|
+
if (nextAction.paySheet.currencyCode !== nextAction.price.total.currency) {
|
|
3159
|
+
context2.addIssue({ code: "custom", path: ["paySheet", "currencyCode"], message: "the sheet charges the price currency" });
|
|
3160
|
+
}
|
|
3098
3161
|
};
|
|
3099
3162
|
var StripeConsentNextActionSchema = consentShape.superRefine(checkConsent3);
|
|
3100
3163
|
var StripeSessionNextActionSchema = sessionNextAction;
|
|
3101
3164
|
var StripeAuthorizeNextActionSchema = authorizeNextAction;
|
|
3102
3165
|
var StripeKycNextActionSchema = kycShape.superRefine(checkKyc3);
|
|
3166
|
+
var StripeIdentifiersNextActionSchema = identifiersNextAction;
|
|
3167
|
+
var StripeAttestationNextActionSchema = attestationNextAction;
|
|
3103
3168
|
var StripeVerifyIdentityNextActionSchema = verifyIdentityNextAction;
|
|
3104
3169
|
var StripeWaitNextActionSchema = waitNextAction;
|
|
3105
3170
|
var StripePlaceOrderNextActionSchema = placeOrderNextAction.superRefine(checkPlaceOrder);
|
|
3106
3171
|
var StripePayNextActionSchema = payNextAction;
|
|
3107
3172
|
var StripeCheckoutSecretNextActionSchema = checkoutSecretNextAction;
|
|
3108
|
-
var StripeOrderPendingNextActionSchema = orderPendingNextAction;
|
|
3173
|
+
var StripeOrderPendingNextActionSchema = orderPendingNextAction.superRefine(checkOrderPendingPoll);
|
|
3109
3174
|
var checkNextAction3 = (response, context2) => {
|
|
3175
|
+
checkOrderPendingPoll(response, context2);
|
|
3110
3176
|
if (response.next === "consent") checkConsent3(response, context2);
|
|
3111
3177
|
if (response.next === "kyc") checkKyc3(response, context2);
|
|
3112
3178
|
if (response.next === "placeOrder") checkPlaceOrder(response, context2);
|
|
@@ -3116,6 +3182,8 @@ var nextActionOptions = [
|
|
|
3116
3182
|
sessionNextAction,
|
|
3117
3183
|
authorizeNextAction,
|
|
3118
3184
|
kycShape,
|
|
3185
|
+
identifiersNextAction,
|
|
3186
|
+
attestationNextAction,
|
|
3119
3187
|
verifyIdentityNextAction,
|
|
3120
3188
|
waitNextAction,
|
|
3121
3189
|
placeOrderNextAction,
|
|
@@ -3144,7 +3212,7 @@ var stepResponse = z4.union([z4.discriminatedUnion("next", [...nextActionOptions
|
|
|
3144
3212
|
var StripeStepResponseSchema = stepResponse;
|
|
3145
3213
|
var checkoutResponse = z4.union([z4.discriminatedUnion("next", [...nextActionOptions, done, checkoutSecretNextAction]), refused]).superRefine(checkNextAction3);
|
|
3146
3214
|
var StripeCheckoutResponseSchema = checkoutResponse;
|
|
3147
|
-
var orderResponse = z4.discriminatedUnion("next", [done, orderPendingNextAction]);
|
|
3215
|
+
var orderResponse = z4.discriminatedUnion("next", [done, orderPendingNextAction]).superRefine(checkOrderPendingPoll);
|
|
3148
3216
|
var StripeOrderResponseSchema = orderResponse;
|
|
3149
3217
|
var StripeResponseSchemaFor = {
|
|
3150
3218
|
observe: StripeStepResponseSchema,
|
|
@@ -3267,7 +3335,9 @@ export {
|
|
|
3267
3335
|
DOCUMENTED_ENDPOINTS,
|
|
3268
3336
|
DeliveryStateSchema,
|
|
3269
3337
|
DestinationAssetSchema,
|
|
3338
|
+
EEA_COUNTRIES,
|
|
3270
3339
|
ENDPOINT_PATTERN,
|
|
3340
|
+
EU_COUNTRIES,
|
|
3271
3341
|
FIAT_CURRENCY_NAMES,
|
|
3272
3342
|
FIAT_TERMS_ENDPOINT,
|
|
3273
3343
|
FIELD_SPEC_TYPES,
|
|
@@ -3375,6 +3445,7 @@ export {
|
|
|
3375
3445
|
MoonPayWaitNextActionSchema,
|
|
3376
3446
|
OrderAwaitingConfirmationStateSchema,
|
|
3377
3447
|
OrderCreatedStateSchema,
|
|
3448
|
+
OrderPollSchema,
|
|
3378
3449
|
OrderRefSchema,
|
|
3379
3450
|
OrderStatusSchema,
|
|
3380
3451
|
OrderSummarySchema,
|
|
@@ -3403,6 +3474,7 @@ export {
|
|
|
3403
3474
|
SelectOptionSchema,
|
|
3404
3475
|
SessionAuthStateSchema,
|
|
3405
3476
|
StatusHistoryEntrySchema,
|
|
3477
|
+
StripeAttestationNextActionSchema,
|
|
3406
3478
|
StripeAuthorizeNextActionSchema,
|
|
3407
3479
|
StripeAuthorizeRequestSchema,
|
|
3408
3480
|
StripeCheckoutRequestSchema,
|
|
@@ -3414,6 +3486,7 @@ export {
|
|
|
3414
3486
|
StripeDoneSchema,
|
|
3415
3487
|
StripeErrorBodySchema,
|
|
3416
3488
|
StripeFaultSchema,
|
|
3489
|
+
StripeIdentifiersNextActionSchema,
|
|
3417
3490
|
StripeKycNextActionSchema,
|
|
3418
3491
|
StripeKycRequestSchema,
|
|
3419
3492
|
StripeLinkAuthTokenSchema,
|
|
@@ -3461,8 +3534,11 @@ export {
|
|
|
3461
3534
|
assertLegalEmission,
|
|
3462
3535
|
assertLegalReturn,
|
|
3463
3536
|
checkLegalEmission,
|
|
3537
|
+
checkOrderPendingPoll,
|
|
3464
3538
|
endpointMatches,
|
|
3465
3539
|
fixtureMeta,
|
|
3540
|
+
isEeaCountry,
|
|
3541
|
+
isEuCountry,
|
|
3466
3542
|
isTerminal,
|
|
3467
3543
|
loadFixture,
|
|
3468
3544
|
loadFixtures,
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* `./coinbase.schemas`, exported from the package root only.
|
|
14
14
|
*/
|
|
15
15
|
import type { FiatTermsRequest, TermsDocument } from '../terms';
|
|
16
|
-
import type { DestinationAsset, FeeLine, FiatAmount, FiatGeo, FiatStepResponse, FormField, KycFieldId } from '../types';
|
|
16
|
+
import type { DestinationAsset, FeeLine, FiatAmount, FiatGeo, FiatStepResponse, FormField, KycFieldId, OrderPoll } from '../types';
|
|
17
17
|
export declare const COINBASE_ENDPOINTS: {
|
|
18
18
|
readonly next: "POST /fiat/next";
|
|
19
19
|
};
|
|
@@ -155,6 +155,7 @@ export type CoinbaseOrderPendingNextAction = {
|
|
|
155
155
|
next: 'orderPending';
|
|
156
156
|
orderId: string;
|
|
157
157
|
retryAfterMs: number;
|
|
158
|
+
poll?: OrderPoll;
|
|
158
159
|
order: FiatStepResponse | null;
|
|
159
160
|
};
|
|
160
161
|
export type CoinbaseRequest = CoinbaseRequestContext & (CoinbaseObserveRequest | CoinbaseConsentRequest | CoinbaseSessionRequest | CoinbaseOtpRequest | CoinbaseKycRequest | CoinbasePlaceOrderRequest | CoinbaseOrderRequest);
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
*/
|
|
27
27
|
import type { FiatCurrencyCode } from '../codes';
|
|
28
28
|
import type { FiatTermsRequest, TermsDocument } from '../terms';
|
|
29
|
-
import type { FiatAmount, DestinationAsset, FiatGeo, FiatStepResponse, FormField, KYCProvider, KycFieldId, KycSdkResultReport } from '../types';
|
|
29
|
+
import type { FiatAmount, DestinationAsset, FiatGeo, FiatStepResponse, FormField, KYCProvider, KycFieldId, KycSdkResultReport, OrderPoll } from '../types';
|
|
30
30
|
export declare const MOONPAY_ENDPOINTS: {
|
|
31
31
|
readonly next: "POST /fiat/next";
|
|
32
32
|
};
|
|
@@ -294,6 +294,7 @@ export type MoonPayOrderPendingNextAction = {
|
|
|
294
294
|
next: 'orderPending';
|
|
295
295
|
orderId: string;
|
|
296
296
|
retryAfterMs: number;
|
|
297
|
+
poll?: OrderPoll;
|
|
297
298
|
order: FiatStepResponse | null;
|
|
298
299
|
};
|
|
299
300
|
export type MoonPayRequest = MoonPayRequestContext & (MoonPayObserveRequest | MoonPayConsentRequest | MoonPaySessionRequest | MoonPayConnectRequest | MoonPayKycRequest | MoonPayPrepareCaptureRequest | MoonPayCaptureRequest | MoonPayOrderRequest);
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* The Stripe flow on `POST /fiat/next`.
|
|
3
3
|
*
|
|
4
4
|
* A response names the next action in `next`; the client's request names it in `action`. `observe` answers the
|
|
5
|
-
* current next action. `wait` and `verifyIdentity` have no request: send `observe` after
|
|
6
|
-
* answered by `order`. Identity, the verified email and the deposit wallet come from the
|
|
7
|
-
* never from a request body.
|
|
5
|
+
* current next action. `wait`, `identifiers`, `attestation` and `verifyIdentity` have no request: send `observe` after
|
|
6
|
+
* them. `orderPending` is answered by `order`. Identity, the verified email and the deposit wallet come from the
|
|
7
|
+
* verified partner assertion, never from a request body.
|
|
8
8
|
*
|
|
9
9
|
* A retry sends the same request and gets the current response. A fault is a 4xx/5xx whose body is
|
|
10
10
|
* `StripeErrorBody`; anything the buyer can act on is a 200.
|
|
@@ -12,8 +12,9 @@
|
|
|
12
12
|
* Zero runtime dependencies, so production React Native code can import it. The zod schemas are in
|
|
13
13
|
* `./stripe.schemas`, exported from the package root only.
|
|
14
14
|
*/
|
|
15
|
+
import type { CountryCode } from '../codes';
|
|
15
16
|
import type { FiatTermsRequest, TermsDocument } from '../terms';
|
|
16
|
-
import type { FeeLine, FiatAmount, FiatGeo, FiatStepResponse, FormField, KycFieldId } from '../types';
|
|
17
|
+
import type { FeeLine, FiatAmount, FiatGeo, FiatStepResponse, FormField, KycFieldId, OrderPoll } from '../types';
|
|
17
18
|
export declare const STRIPE_ENDPOINTS: {
|
|
18
19
|
readonly next: "POST /fiat/next";
|
|
19
20
|
};
|
|
@@ -23,9 +24,9 @@ export declare const STRIPE_ENDPOINTS: {
|
|
|
23
24
|
* retried under the same `orderId` places nothing new.
|
|
24
25
|
*/
|
|
25
26
|
export interface StripeCheckout {
|
|
26
|
-
/**
|
|
27
|
+
/** USD for a US buyer, EUR for an EU buyer. */
|
|
27
28
|
amount: FiatAmount & {
|
|
28
|
-
currency: 'USD';
|
|
29
|
+
currency: 'USD' | 'EUR';
|
|
29
30
|
};
|
|
30
31
|
/** The asset and its network, as the routing table or `/fiat/quote` named them. */
|
|
31
32
|
destination: {
|
|
@@ -102,13 +103,17 @@ export type StripeReask = {
|
|
|
102
103
|
/**
|
|
103
104
|
* Show the shared form, prefilled with `heldValues`. `ACCOUNT`: call `registerLinkUser` with the values and
|
|
104
105
|
* `verifiedEmail`. `IDENTITY`: sign in with `linkAuthToken`, then call `attachKycInfo` with the values. Then send `kyc`
|
|
105
|
-
* with `correctionRound`, which names this form: how many
|
|
106
|
-
* `null` when the backend could not mint one: the device pushes under the Link session `authorize` left it.
|
|
106
|
+
* with `correctionRound`, which names this form: how many identity forms Stripe was handed before it. `linkAuthToken`
|
|
107
|
+
* is `null` when the backend could not mint one: the device pushes under the Link session `authorize` left it.
|
|
108
|
+
*
|
|
109
|
+
* An EU buyer gets `round: 'IDENTITY'`, `tier: 'l2'`: Stripe reads `l0` and `l1` as not available there. Its fields add
|
|
110
|
+
* `NATIONALITY`, `CITY_OF_BIRTH` and `COUNTRY_OF_BIRTH`, which the device passes to `attachKycInfo`. The backend sends
|
|
111
|
+
* `l2`, `identifiers` and `attestation` only for an EUR checkout, so a client that sends only USD never gets them.
|
|
107
112
|
*/
|
|
108
113
|
export type StripeKycNextAction = {
|
|
109
114
|
next: 'kyc';
|
|
110
115
|
round: 'ACCOUNT' | 'IDENTITY';
|
|
111
|
-
tier: 'l0' | 'l1';
|
|
116
|
+
tier: 'l0' | 'l1' | 'l2';
|
|
112
117
|
correctionRound: number;
|
|
113
118
|
fields: FormField[];
|
|
114
119
|
heldValues: Partial<Record<KycFieldId, string>>;
|
|
@@ -127,6 +132,19 @@ export type StripeKycRequest = {
|
|
|
127
132
|
correctionRound: number;
|
|
128
133
|
values: Partial<Record<KycFieldId, string>>;
|
|
129
134
|
} & StripeHeldOrder;
|
|
135
|
+
/**
|
|
136
|
+
* Sign in with `linkAuthToken` and run the SDK's `retrieveMissingIdentifiers`. Collect each listed identifier from the
|
|
137
|
+
* buyer, pass them to `submitIdentifiers`, then send `observe`. Fun stores none of them.
|
|
138
|
+
*/
|
|
139
|
+
export type StripeIdentifiersNextAction = {
|
|
140
|
+
next: 'identifiers';
|
|
141
|
+
linkAuthToken: StripeLinkAuthToken | null;
|
|
142
|
+
};
|
|
143
|
+
/** Sign in with `linkAuthToken`, run the SDK's `presentUserAttestation` (Stripe's terms), then send `observe`. */
|
|
144
|
+
export type StripeAttestationNextAction = {
|
|
145
|
+
next: 'attestation';
|
|
146
|
+
linkAuthToken: StripeLinkAuthToken | null;
|
|
147
|
+
};
|
|
130
148
|
/** Sign in with `linkAuthToken`, run the SDK's `verifyIdentity`, then send `observe`. */
|
|
131
149
|
export type StripeVerifyIdentityNextAction = {
|
|
132
150
|
next: 'verifyIdentity';
|
|
@@ -148,8 +166,9 @@ export interface StripePaySheet {
|
|
|
148
166
|
destinationCurrency: string;
|
|
149
167
|
destinationNetwork: string;
|
|
150
168
|
walletAddress: string;
|
|
151
|
-
merchantCountryCode:
|
|
152
|
-
|
|
169
|
+
merchantCountryCode: CountryCode;
|
|
170
|
+
/** The charge currency: the checkout's. */
|
|
171
|
+
currencyCode: 'USD' | 'EUR';
|
|
153
172
|
amount: string;
|
|
154
173
|
label: string;
|
|
155
174
|
}
|
|
@@ -211,10 +230,14 @@ export type StripeOrderPendingNextAction = {
|
|
|
211
230
|
next: 'orderPending';
|
|
212
231
|
orderId: string;
|
|
213
232
|
retryAfterMs: number;
|
|
233
|
+
poll?: OrderPoll;
|
|
214
234
|
order: FiatStepResponse | null;
|
|
215
235
|
};
|
|
216
236
|
export type StripeRequest = StripeRequestContext & (StripeObserveRequest | StripeConsentRequest | StripeSessionRequest | StripeAuthorizeRequest | StripeKycRequest | StripePlaceOrderRequest | StripeCheckoutRequest | StripeOrderRequest);
|
|
217
|
-
/**
|
|
237
|
+
/**
|
|
238
|
+
* Every `action` a Stripe request names. `wait`, `identifiers`, `attestation` and `verifyIdentity` are next actions the
|
|
239
|
+
* client answers with `observe`.
|
|
240
|
+
*/
|
|
218
241
|
export type StripeAction = StripeRequest['action'];
|
|
219
242
|
/** The wire body. The orchestrator reads `provider` and `geo`; Stripe's action schemas read the rest. */
|
|
220
243
|
export type StripeNextRequest = {
|
|
@@ -222,7 +245,7 @@ export type StripeNextRequest = {
|
|
|
222
245
|
geo: FiatGeo;
|
|
223
246
|
} & StripeRequest;
|
|
224
247
|
/** Every next action but `checkoutSecret`, which only `checkout` answers. */
|
|
225
|
-
export type StripeNextAction = StripeConsentNextAction | StripeSessionNextAction | StripeAuthorizeNextAction | StripeKycNextAction | StripeVerifyIdentityNextAction | StripeWaitNextAction | StripePlaceOrderNextAction | StripePayNextAction | StripeOrderPendingNextAction;
|
|
248
|
+
export type StripeNextAction = StripeConsentNextAction | StripeSessionNextAction | StripeAuthorizeNextAction | StripeKycNextAction | StripeIdentifiersNextAction | StripeAttestationNextAction | StripeVerifyIdentityNextAction | StripeWaitNextAction | StripePlaceOrderNextAction | StripePayNextAction | StripeOrderPendingNextAction;
|
|
226
249
|
/** The order is terminal. `order` is its body, which the shared order screen renders. */
|
|
227
250
|
export type StripeDone = {
|
|
228
251
|
next: 'done';
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* exported from the package root, never from `./stripe`, so the production entry stays free of zod.
|
|
4
4
|
*/
|
|
5
5
|
import { z } from 'zod';
|
|
6
|
-
import type { StripeAuthorizeNextAction, StripeAuthorizeRequest, StripeCheckout, StripeCheckoutRequest, StripeCheckoutResponse, StripeCheckoutSecretNextAction, StripeConsentNextAction, StripeConsentRequest, StripeDone, StripeErrorBody, StripeFault, StripeKycNextAction, StripeKycRequest, StripeLinkAuthToken, StripeNextAction, StripeNextRequest, StripeObserveRequest, StripeOrderPendingNextAction, StripeOrderRequest, StripeOrderResponse, StripePayNextAction, StripePaySheet, StripePlaceOrderNextAction, StripePlaceOrderRequest, StripePrice, StripeReask, StripeRefused, StripeRequest, StripeRequestContext, StripeResponseFor, StripeSessionNextAction, StripeSessionRequest, StripeStepResponse, StripeVerifyIdentityNextAction, StripeWaitNextAction } from './stripe';
|
|
6
|
+
import type { StripeAttestationNextAction, StripeAuthorizeNextAction, StripeAuthorizeRequest, StripeCheckout, StripeCheckoutRequest, StripeCheckoutResponse, StripeCheckoutSecretNextAction, StripeConsentNextAction, StripeConsentRequest, StripeDone, StripeErrorBody, StripeFault, StripeIdentifiersNextAction, StripeKycNextAction, StripeKycRequest, StripeLinkAuthToken, StripeNextAction, StripeNextRequest, StripeObserveRequest, StripeOrderPendingNextAction, StripeOrderRequest, StripeOrderResponse, StripePayNextAction, StripePaySheet, StripePlaceOrderNextAction, StripePlaceOrderRequest, StripePrice, StripeReask, StripeRefused, StripeRequest, StripeRequestContext, StripeResponseFor, StripeSessionNextAction, StripeSessionRequest, StripeStepResponse, StripeVerifyIdentityNextAction, StripeWaitNextAction } from './stripe';
|
|
7
7
|
export declare const StripeCheckoutSchema: z.ZodType<StripeCheckout>;
|
|
8
8
|
export declare const StripeRequestContextSchema: z.ZodType<StripeRequestContext>;
|
|
9
9
|
export declare const StripeObserveRequestSchema: z.ZodType<StripeRequestContext & StripeObserveRequest>;
|
|
@@ -24,6 +24,8 @@ export declare const StripeConsentNextActionSchema: z.ZodType<StripeConsentNextA
|
|
|
24
24
|
export declare const StripeSessionNextActionSchema: z.ZodType<StripeSessionNextAction>;
|
|
25
25
|
export declare const StripeAuthorizeNextActionSchema: z.ZodType<StripeAuthorizeNextAction>;
|
|
26
26
|
export declare const StripeKycNextActionSchema: z.ZodType<StripeKycNextAction>;
|
|
27
|
+
export declare const StripeIdentifiersNextActionSchema: z.ZodType<StripeIdentifiersNextAction>;
|
|
28
|
+
export declare const StripeAttestationNextActionSchema: z.ZodType<StripeAttestationNextAction>;
|
|
27
29
|
export declare const StripeVerifyIdentityNextActionSchema: z.ZodType<StripeVerifyIdentityNextAction>;
|
|
28
30
|
export declare const StripeWaitNextActionSchema: z.ZodType<StripeWaitNextAction>;
|
|
29
31
|
export declare const StripePlaceOrderNextActionSchema: z.ZodType<StripePlaceOrderNextAction>;
|
package/dist/schemas.d.ts
CHANGED
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
*/
|
|
29
29
|
import { z } from 'zod';
|
|
30
30
|
import type { UsStateCode } from './codes';
|
|
31
|
-
import type { BlockedReason, CryptoAmount, FailureReason, FeeLine, FiatAmount, FiatEndpoint, FiatProvider, FiatAuthRefreshRequest, FiatAuthRefreshResponse, FiatAuthRevokeRequest, FiatAuthStartRequest, FiatAuthVerifyRequest, FiatSession, FiatStepResponse, FieldSpec, FlowState, FormDescriptor, FormField, FormFieldType, InstructionField, Instructions, Instrument, JsonValue, KYCProvider, KycReviewDuration, OrderRef, OrderStatus, OrderSummary, PollSpec, PreparedPayment, PaymentSurface, Quote, QuoteLimitRange, QuoteLimits, Recovery, Refund, ReportSpec, SelectOption, StatusHistoryEntry, Surface, PreferredIdentityDocument, KycFieldId, ClientExecutedDelivery, KycSdkResultReport, SurfaceKind, SurfaceProvider, TermsAcceptance, Transition, TransitionInputs, TransitionParams, Tx, DestinationAsset, FiatGeo, FiatNextRequest } from './types';
|
|
31
|
+
import type { BlockedReason, CryptoAmount, FailureReason, FeeLine, FiatAmount, FiatEndpoint, FiatProvider, FiatAuthRefreshRequest, FiatAuthRefreshResponse, FiatAuthRevokeRequest, FiatAuthStartRequest, FiatAuthVerifyRequest, FiatSession, FiatStepResponse, FieldSpec, FlowState, FormDescriptor, FormField, FormFieldType, InstructionField, Instructions, Instrument, JsonValue, KYCProvider, KycReviewDuration, OrderPoll, OrderRef, OrderStatus, OrderSummary, PollSpec, PreparedPayment, PaymentSurface, Quote, QuoteLimitRange, QuoteLimits, Recovery, Refund, ReportSpec, SelectOption, StatusHistoryEntry, Surface, PreferredIdentityDocument, KycFieldId, ClientExecutedDelivery, KycSdkResultReport, SurfaceKind, SurfaceProvider, TermsAcceptance, Transition, TransitionInputs, TransitionParams, Tx, DestinationAsset, FiatGeo, FiatNextRequest } from './types';
|
|
32
32
|
import type { FiatTermsErrorBody, FiatTermsRequest, FiatTermsResponse, TermsDocument, TermsDocumentAcceptance } from './terms';
|
|
33
33
|
import type { FiatRoutingQuoteErrorBody, FiatRoutingQuoteRequest, FiatRoutingQuoteTerms, FiatRoutingTableErrorBody, FiatRoutingTableRequest, FiatRoutingTableResponse } from './routing';
|
|
34
34
|
export declare const JsonSchema: z.ZodType<JsonValue>;
|
|
@@ -81,6 +81,17 @@ export declare const looksLikeFieldSpec: (value: unknown) => boolean;
|
|
|
81
81
|
export declare const TransitionParamsSchema: z.ZodType<TransitionParams>;
|
|
82
82
|
export declare const TransitionInputsSchema: z.ZodType<TransitionInputs>;
|
|
83
83
|
export declare const PollSpecSchema: z.ZodType<PollSpec>;
|
|
84
|
+
/** A `/fiat/next` provider's order poll on `orderPending`; see {@link OrderPoll}. */
|
|
85
|
+
export declare const OrderPollSchema: z.ZodType<OrderPoll>;
|
|
86
|
+
/**
|
|
87
|
+
* `orderPending`'s cross-field rules, as {@link PollSpec}'s: with a `poll`, `retryAfterMs` is at least
|
|
88
|
+
* 500 and `maxIntervalMs` at least `retryAfterMs`, so no wait drops below the first one.
|
|
89
|
+
*/
|
|
90
|
+
export declare function checkOrderPendingPoll(response: {
|
|
91
|
+
next: string;
|
|
92
|
+
retryAfterMs?: number;
|
|
93
|
+
poll?: OrderPoll;
|
|
94
|
+
}, context: z.RefinementCtx): void;
|
|
84
95
|
export declare const ReportSpecSchema: z.ZodType<ReportSpec>;
|
|
85
96
|
export declare const KycSdkResultReportSchema: z.ZodType<KycSdkResultReport>;
|
|
86
97
|
export declare const TransitionSchema: z.ZodType<Transition>;
|
package/dist/table.js
CHANGED
package/dist/table.mjs
CHANGED
package/dist/types.d.ts
CHANGED
|
@@ -800,6 +800,20 @@ type FiatStepResponseBase = {
|
|
|
800
800
|
*/
|
|
801
801
|
refreshLimits?: true;
|
|
802
802
|
};
|
|
803
|
+
/**
|
|
804
|
+
* How the client re-sends `order` while a `/fiat/next` provider answers `orderPending`: wait the
|
|
805
|
+
* answer's `retryAfterMs`, grow each later wait by `backoffFactor` up to `maxIntervalMs`, and stop
|
|
806
|
+
* reading once the waits add up to `giveUpAfterMs`. The window starts at the first `orderPending`
|
|
807
|
+
* for that `orderId`; a later answer does not restart it. Each provider's backend names its own.
|
|
808
|
+
* Bounds follow {@link PollSpec}: `backoffFactor` `1 … 4`; `maxIntervalMs` an integer `500 … 60000`
|
|
809
|
+
* and at least the answer's `retryAfterMs`, which is then at least 500; `giveUpAfterMs` an integer
|
|
810
|
+
* `1 … 3600000`.
|
|
811
|
+
*/
|
|
812
|
+
export type OrderPoll = {
|
|
813
|
+
backoffFactor: number;
|
|
814
|
+
maxIntervalMs: number;
|
|
815
|
+
giveUpAfterMs: number;
|
|
816
|
+
};
|
|
803
817
|
/**
|
|
804
818
|
* Provider is absent only when routing ended before a provider could be selected. A BLOCKED response
|
|
805
819
|
* may still name a provider for compatibility with provider-specific terminal decisions. `FUN_AUTH`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fun-xyz/fiat-contract",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.51.0",
|
|
4
4
|
"description": "Published conformance contract for Fun's headless fiat onramp: FlowState/Transition types, zod schemas, the transition table as data, recorded fixtures, assertion helpers.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|