@fun-xyz/fiat-contract 0.25.0 → 0.27.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 +9 -3
- package/dist/{chunk-WEXD7UEE.mjs → chunk-7ZIZANFX.mjs} +1 -1
- package/dist/{chunk-LHCED3AP.mjs → chunk-K573F2ON.mjs} +2 -2
- package/dist/{chunk-T5JAYOWY.mjs → chunk-W5HOOK34.mjs} +1 -1
- package/dist/index.js +19 -4
- package/dist/index.mjs +21 -6
- package/dist/providers/moonpay.d.ts +4 -3
- package/dist/providers/moonpay.mjs +1 -1
- package/dist/routing.d.ts +5 -1
- package/dist/routing.mjs +1 -1
- package/dist/table.js +1 -1
- package/dist/table.mjs +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -134,13 +134,18 @@ a `REQUOTE`. The schemas hold the table's invariants: each method once, sorted,
|
|
|
134
134
|
intervals, at least one provider each and none twice, and a reason only on an empty method.
|
|
135
135
|
|
|
136
136
|
`ROUTING_ENDPOINTS.quote` (`POST /fiat/routing/quote`) takes the `POST /fiat/quote` body
|
|
137
|
-
(`FiatRoutingQuoteTerms`),
|
|
137
|
+
(`FiatRoutingQuoteTerms`), plus one of two forms:
|
|
138
138
|
|
|
139
139
|
- `providers`: the interval's providers, best first. The backend prices them in order, falls
|
|
140
140
|
through on the refusals marked "next provider" below, and answers the first that prices or the
|
|
141
141
|
last provider's refusal.
|
|
142
142
|
- `provider`: one provider only. The client falls through itself.
|
|
143
143
|
|
|
144
|
+
Routing quotes may include `routingOverrides: { providers: [...] }` with the host’s full allowlist.
|
|
145
|
+
The selected `provider` or ordered `providers` must be a subset. The server preserves the allowlist
|
|
146
|
+
through later KYC rerouting; the amount-specific candidate list alone does not restrict rediscovery.
|
|
147
|
+
Omitting the field preserves existing behavior. An empty allowlist permits no quote candidate.
|
|
148
|
+
|
|
144
149
|
It answers the same `FiatStepResponse`, whose `provider` names the one that priced. A refusal is a
|
|
145
150
|
`FiatRoutingQuoteErrorBody`, and it decides whether the next provider may still price:
|
|
146
151
|
|
|
@@ -203,8 +208,9 @@ A first-time buyer goes `observe` → `consent` → `connect` → `kyc` → `wai
|
|
|
203
208
|
`test/fixtures/moonpay-next/`.
|
|
204
209
|
|
|
205
210
|
A fault is a 4xx or 5xx with a `MoonPayErrorBody`: the shared `errorCode`, `errorMsg` and `reqId`,
|
|
206
|
-
plus `reason`
|
|
207
|
-
|
|
211
|
+
plus `reason` and `recovery`. The reasons are `SESSION_BUDGET_SPENT`, `RATE_LIMITED`,
|
|
212
|
+
`PROVIDER_UNAVAILABLE` (MoonPay is down), `KYC_PROVIDER_UNAVAILABLE` (Sumsub is down),
|
|
213
|
+
`SERVICE_UNAVAILABLE` (one of Fun's own stores is down) and `INVALID_REQUEST`. The recoveries are
|
|
208
214
|
`RETRY` (send the same request again), `REQUOTE`, or `NONE`. A field error is a `kyc`
|
|
209
215
|
prompt, not a fault. The zod schemas (`MoonPay*Schema`, `FiatGeoSchema`, `FiatNextRequestSchema`,
|
|
210
216
|
`TermsDocumentSchema`, `FiatTerms*Schema`) are exported from the root only.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// package.json
|
|
2
|
-
var version = "0.
|
|
2
|
+
var version = "0.27.0";
|
|
3
3
|
|
|
4
4
|
// src/table.ts
|
|
5
5
|
var TABLE_VERSION = version;
|
|
@@ -514,4 +514,4 @@ export {
|
|
|
514
514
|
tableEntry,
|
|
515
515
|
isTerminal
|
|
516
516
|
};
|
|
517
|
-
//# sourceMappingURL=chunk-
|
|
517
|
+
//# sourceMappingURL=chunk-K573F2ON.mjs.map
|
package/dist/index.js
CHANGED
|
@@ -1099,7 +1099,8 @@ var $routingQuoteTermsShape = {
|
|
|
1099
1099
|
(geo) => hasUsRegion(geo.alpha2, geo.region),
|
|
1100
1100
|
{ message: US_REGION_REQUIRED, path: ["region"] }
|
|
1101
1101
|
),
|
|
1102
|
-
prepareSessionAuth: import_zod.z.boolean().optional()
|
|
1102
|
+
prepareSessionAuth: import_zod.z.boolean().optional(),
|
|
1103
|
+
routingOverrides: obj({ providers: import_zod.z.array($routingProvider) }).optional()
|
|
1103
1104
|
};
|
|
1104
1105
|
var $routingQuoteTerms = obj($routingQuoteTermsShape);
|
|
1105
1106
|
var FiatRoutingQuoteTermsSchema = $routingQuoteTerms;
|
|
@@ -1109,7 +1110,14 @@ var $routingQuoteRequest = import_zod.z.union([
|
|
|
1109
1110
|
providers: import_zod.z.array($routingProvider).min(1).refine((providers) => hasUniqueIds(providers), "each provider is listed once")
|
|
1110
1111
|
}),
|
|
1111
1112
|
obj({ ...$routingQuoteTermsShape, provider: $routingProvider })
|
|
1112
|
-
])
|
|
1113
|
+
]).refine(
|
|
1114
|
+
(request) => {
|
|
1115
|
+
const allowed = request.routingOverrides?.providers;
|
|
1116
|
+
const selected = "providers" in request ? request.providers : [request.provider];
|
|
1117
|
+
return allowed === void 0 || selected.every((provider) => allowed.includes(provider));
|
|
1118
|
+
},
|
|
1119
|
+
{ message: "requested providers must be allowed by routingOverrides", path: ["routingOverrides"] }
|
|
1120
|
+
);
|
|
1113
1121
|
var FiatRoutingQuoteRequestSchema = $routingQuoteRequest;
|
|
1114
1122
|
var $routingServiceableRange = obj({ min: $money, max: $money, userMax: $money.nullable().optional() });
|
|
1115
1123
|
var $noRouteFields = {
|
|
@@ -1209,7 +1217,7 @@ var $stepResponse = import_zod.z.union([$providerBoundStepResponse, $blockedStep
|
|
|
1209
1217
|
var FiatStepResponseSchema = $stepResponse;
|
|
1210
1218
|
|
|
1211
1219
|
// package.json
|
|
1212
|
-
var version = "0.
|
|
1220
|
+
var version = "0.27.0";
|
|
1213
1221
|
|
|
1214
1222
|
// src/table.ts
|
|
1215
1223
|
var TABLE_VERSION = version;
|
|
@@ -2947,7 +2955,14 @@ var MoonPayResponseSchemaFor = {
|
|
|
2947
2955
|
order: MoonPayOrderResponseSchema
|
|
2948
2956
|
};
|
|
2949
2957
|
var $faultFields = {
|
|
2950
|
-
reason: import_zod2.z.enum([
|
|
2958
|
+
reason: import_zod2.z.enum([
|
|
2959
|
+
"SESSION_BUDGET_SPENT",
|
|
2960
|
+
"RATE_LIMITED",
|
|
2961
|
+
"PROVIDER_UNAVAILABLE",
|
|
2962
|
+
"KYC_PROVIDER_UNAVAILABLE",
|
|
2963
|
+
"SERVICE_UNAVAILABLE",
|
|
2964
|
+
"INVALID_REQUEST"
|
|
2965
|
+
]),
|
|
2951
2966
|
recovery: import_zod2.z.enum(["RETRY", "REQUOTE", "NONE"])
|
|
2952
2967
|
};
|
|
2953
2968
|
var $fault = obj2($faultFields);
|
package/dist/index.mjs
CHANGED
|
@@ -12,10 +12,10 @@ import {
|
|
|
12
12
|
tableEntry,
|
|
13
13
|
unofferedEndpoints,
|
|
14
14
|
unreachableStates
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-K573F2ON.mjs";
|
|
16
16
|
import {
|
|
17
17
|
MOONPAY_ENDPOINTS
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-W5HOOK34.mjs";
|
|
19
19
|
import {
|
|
20
20
|
FIAT_TERMS_ENDPOINT,
|
|
21
21
|
FUN_KYC_CONSENT_DOCUMENTS,
|
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
} from "./chunk-CRNKRIKR.mjs";
|
|
25
25
|
import {
|
|
26
26
|
ROUTING_ENDPOINTS
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-7ZIZANFX.mjs";
|
|
28
28
|
|
|
29
29
|
// src/codes.ts
|
|
30
30
|
var US_STATE_CODES = [
|
|
@@ -963,7 +963,8 @@ var $routingQuoteTermsShape = {
|
|
|
963
963
|
(geo) => hasUsRegion(geo.alpha2, geo.region),
|
|
964
964
|
{ message: US_REGION_REQUIRED, path: ["region"] }
|
|
965
965
|
),
|
|
966
|
-
prepareSessionAuth: z.boolean().optional()
|
|
966
|
+
prepareSessionAuth: z.boolean().optional(),
|
|
967
|
+
routingOverrides: obj({ providers: z.array($routingProvider) }).optional()
|
|
967
968
|
};
|
|
968
969
|
var $routingQuoteTerms = obj($routingQuoteTermsShape);
|
|
969
970
|
var FiatRoutingQuoteTermsSchema = $routingQuoteTerms;
|
|
@@ -973,7 +974,14 @@ var $routingQuoteRequest = z.union([
|
|
|
973
974
|
providers: z.array($routingProvider).min(1).refine((providers) => hasUniqueIds(providers), "each provider is listed once")
|
|
974
975
|
}),
|
|
975
976
|
obj({ ...$routingQuoteTermsShape, provider: $routingProvider })
|
|
976
|
-
])
|
|
977
|
+
]).refine(
|
|
978
|
+
(request) => {
|
|
979
|
+
const allowed = request.routingOverrides?.providers;
|
|
980
|
+
const selected = "providers" in request ? request.providers : [request.provider];
|
|
981
|
+
return allowed === void 0 || selected.every((provider) => allowed.includes(provider));
|
|
982
|
+
},
|
|
983
|
+
{ message: "requested providers must be allowed by routingOverrides", path: ["routingOverrides"] }
|
|
984
|
+
);
|
|
977
985
|
var FiatRoutingQuoteRequestSchema = $routingQuoteRequest;
|
|
978
986
|
var $routingServiceableRange = obj({ min: $money, max: $money, userMax: $money.nullable().optional() });
|
|
979
987
|
var $noRouteFields = {
|
|
@@ -2260,7 +2268,14 @@ var MoonPayResponseSchemaFor = {
|
|
|
2260
2268
|
order: MoonPayOrderResponseSchema
|
|
2261
2269
|
};
|
|
2262
2270
|
var $faultFields = {
|
|
2263
|
-
reason: z2.enum([
|
|
2271
|
+
reason: z2.enum([
|
|
2272
|
+
"SESSION_BUDGET_SPENT",
|
|
2273
|
+
"RATE_LIMITED",
|
|
2274
|
+
"PROVIDER_UNAVAILABLE",
|
|
2275
|
+
"KYC_PROVIDER_UNAVAILABLE",
|
|
2276
|
+
"SERVICE_UNAVAILABLE",
|
|
2277
|
+
"INVALID_REQUEST"
|
|
2278
|
+
]),
|
|
2264
2279
|
recovery: z2.enum(["RETRY", "REQUOTE", "NONE"])
|
|
2265
2280
|
};
|
|
2266
2281
|
var $fault = obj2($faultFields);
|
|
@@ -188,10 +188,11 @@ export type MoonPayResponseFor = {
|
|
|
188
188
|
export type MoonPayRecovery = 'RETRY' | 'REQUOTE' | 'NONE';
|
|
189
189
|
/**
|
|
190
190
|
* `SESSION_BUDGET_SPENT`: the per-login SDK session mint budget (429). `RATE_LIMITED`: the action's
|
|
191
|
-
* request budget (429). `PROVIDER_UNAVAILABLE`: MoonPay
|
|
192
|
-
*
|
|
191
|
+
* request budget (429). `PROVIDER_UNAVAILABLE`: MoonPay is down (503). `KYC_PROVIDER_UNAVAILABLE`:
|
|
192
|
+
* the KYC provider (Sumsub) is down (503). `SERVICE_UNAVAILABLE`: one of Fun's own stores is down
|
|
193
|
+
* (503). `INVALID_REQUEST`: a bad body (400).
|
|
193
194
|
*/
|
|
194
|
-
export type MoonPayFaultReason = 'SESSION_BUDGET_SPENT' | 'RATE_LIMITED' | 'PROVIDER_UNAVAILABLE' | 'INVALID_REQUEST';
|
|
195
|
+
export type MoonPayFaultReason = 'SESSION_BUDGET_SPENT' | 'RATE_LIMITED' | 'PROVIDER_UNAVAILABLE' | 'KYC_PROVIDER_UNAVAILABLE' | 'SERVICE_UNAVAILABLE' | 'INVALID_REQUEST';
|
|
195
196
|
/** The fields a MoonPay fault adds to the shared error body. */
|
|
196
197
|
export interface MoonPayFault {
|
|
197
198
|
reason: MoonPayFaultReason;
|
package/dist/routing.d.ts
CHANGED
|
@@ -82,7 +82,7 @@ export interface FiatRoutingTableResponse {
|
|
|
82
82
|
/** In request order, duplicates removed. */
|
|
83
83
|
methods: RoutingTableMethod[];
|
|
84
84
|
}
|
|
85
|
-
/** The
|
|
85
|
+
/** The purchase terms and optional host restriction, independent of the current ordered candidates. */
|
|
86
86
|
export interface FiatRoutingQuoteTerms {
|
|
87
87
|
fiatCurrency: FiatCurrencyCode;
|
|
88
88
|
/** A positive decimal string with no leading zero, exponent or sign (`"20"`, `"20.5"`). */
|
|
@@ -101,6 +101,10 @@ export interface FiatRoutingQuoteTerms {
|
|
|
101
101
|
city?: string;
|
|
102
102
|
};
|
|
103
103
|
prepareSessionAuth?: boolean;
|
|
104
|
+
/** Host allowlist, retained for later KYC rerouting. Omitted allows every eligible provider. */
|
|
105
|
+
routingOverrides?: {
|
|
106
|
+
providers: RoutingProvider[];
|
|
107
|
+
};
|
|
104
108
|
}
|
|
105
109
|
/**
|
|
106
110
|
* `POST /fiat/routing/quote`: the terms plus which providers to price, in one of two forms.
|
package/dist/routing.mjs
CHANGED
package/dist/table.js
CHANGED
package/dist/table.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fun-xyz/fiat-contract",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.27.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": {
|