@fun-xyz/fiat-contract 0.23.0 → 0.25.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 +61 -54
- package/dist/{chunk-5GRPYE2U.mjs → chunk-CRNKRIKR.mjs} +1 -1
- package/dist/{chunk-EI56NQ7K.mjs → chunk-LHCED3AP.mjs} +2 -2
- package/dist/chunk-T5JAYOWY.mjs +9 -0
- package/dist/{chunk-KYE2HYV5.mjs → chunk-WEXD7UEE.mjs} +2 -2
- package/dist/index.js +131 -65
- package/dist/index.mjs +132 -66
- package/dist/providers/moonpay.d.ts +107 -109
- package/dist/providers/moonpay.js +1 -1
- package/dist/providers/moonpay.mjs +1 -1
- package/dist/providers/moonpay.schemas.d.ts +22 -5
- package/dist/routing.d.ts +25 -10
- package/dist/routing.js +1 -1
- package/dist/routing.mjs +1 -1
- package/dist/schemas.d.ts +5 -2
- package/dist/table.js +1 -1
- package/dist/table.mjs +1 -1
- package/dist/terms.d.ts +2 -2
- package/dist/terms.mjs +1 -1
- package/dist/types.d.ts +16 -1
- package/package.json +1 -1
- package/dist/chunk-3HCZ6JBJ.mjs +0 -9
package/dist/routing.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ import type { CountryCode, FiatCurrencyCode, PaymentMethodCategory } from './cod
|
|
|
21
21
|
import type { FiatAmount, FiatProvider, QuoteLimitRange } from './types';
|
|
22
22
|
export declare const ROUTING_ENDPOINTS: {
|
|
23
23
|
readonly table: "GET /fiat/routing/table";
|
|
24
|
-
/** Temporary: each provider
|
|
24
|
+
/** Temporary: `POST /fiat/next` replaces it for each provider that moves there. */
|
|
25
25
|
readonly quote: "POST /fiat/routing/quote";
|
|
26
26
|
};
|
|
27
27
|
/**
|
|
@@ -82,13 +82,8 @@ export interface FiatRoutingTableResponse {
|
|
|
82
82
|
/** In request order, duplicates removed. */
|
|
83
83
|
methods: RoutingTableMethod[];
|
|
84
84
|
}
|
|
85
|
-
/**
|
|
86
|
-
|
|
87
|
-
* provider, and never `routingOverrides`. The response is the same `FiatStepResponse` as
|
|
88
|
-
* `POST /fiat/quote`; a refusal is a `FiatRoutingQuoteErrorBody`.
|
|
89
|
-
*/
|
|
90
|
-
export interface FiatRoutingQuoteRequest {
|
|
91
|
-
provider: RoutingProvider;
|
|
85
|
+
/** The `POST /fiat/quote` body without `routingOverrides`: everything but which providers to price. */
|
|
86
|
+
export interface FiatRoutingQuoteTerms {
|
|
92
87
|
fiatCurrency: FiatCurrencyCode;
|
|
93
88
|
/** A positive decimal string with no leading zero, exponent or sign (`"20"`, `"20.5"`). */
|
|
94
89
|
fiatAmount: string;
|
|
@@ -107,6 +102,25 @@ export interface FiatRoutingQuoteRequest {
|
|
|
107
102
|
};
|
|
108
103
|
prepareSessionAuth?: boolean;
|
|
109
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* `POST /fiat/routing/quote`: the terms plus which providers to price, in one of two forms.
|
|
107
|
+
*
|
|
108
|
+
* - `providers`: the interval's providers, best first. The backend prices the first, and falls
|
|
109
|
+
* through to the next on a refusal that is that provider's alone (a `FiatNoRouteError` of any
|
|
110
|
+
* `reason`, or either amount error), as the client did before. It answers the first provider that
|
|
111
|
+
* prices, or the last provider's refusal. Any other refusal stops at once.
|
|
112
|
+
* - `provider`: one provider only, with no fall-through. Kept for clients that fall through themselves.
|
|
113
|
+
*
|
|
114
|
+
* The response is the same `FiatStepResponse` as `POST /fiat/quote`, and its `provider` names the
|
|
115
|
+
* one that priced. A refusal is a `FiatRoutingQuoteErrorBody`.
|
|
116
|
+
*/
|
|
117
|
+
export type FiatRoutingQuoteRequest = FiatRoutingQuoteTerms & ({
|
|
118
|
+
providers: RoutingProvider[];
|
|
119
|
+
provider?: never;
|
|
120
|
+
} | {
|
|
121
|
+
provider: RoutingProvider;
|
|
122
|
+
providers?: never;
|
|
123
|
+
});
|
|
110
124
|
/** One serviceable range of the named provider. `userMax` is this buyer's own ceiling inside it, `null` when unmeasured. */
|
|
111
125
|
export interface RoutingServiceableRange {
|
|
112
126
|
min: FiatAmount;
|
|
@@ -160,8 +174,9 @@ export type RoutingFaultErrorBody = ErrorBodyFields & {
|
|
|
160
174
|
export type FiatRoutingTableErrorBody = RoutingRateLimitedErrorBody | RoutingFaultErrorBody;
|
|
161
175
|
/**
|
|
162
176
|
* `POST /fiat/routing/quote` refusals. A `FiatNoRouteError` (any `reason`) or either amount error is
|
|
163
|
-
* the named provider's alone
|
|
164
|
-
*
|
|
177
|
+
* the named provider's alone, so the next provider may still price: with `providers` the backend
|
|
178
|
+
* tries it, with `provider` the client does. Anything else stops the fall-through: a validation or
|
|
179
|
+
* auth refusal, a 5xx, or no provider left to try.
|
|
165
180
|
*/
|
|
166
181
|
export type FiatRoutingQuoteErrorBody = RoutingNoRouteErrorBody | RoutingAmountErrorBody | RoutingFaultErrorBody;
|
|
167
182
|
export {};
|
package/dist/routing.js
CHANGED
|
@@ -25,7 +25,7 @@ __export(routing_exports, {
|
|
|
25
25
|
module.exports = __toCommonJS(routing_exports);
|
|
26
26
|
var ROUTING_ENDPOINTS = {
|
|
27
27
|
table: "GET /fiat/routing/table",
|
|
28
|
-
/** Temporary: each provider
|
|
28
|
+
/** Temporary: `POST /fiat/next` replaces it for each provider that moves there. */
|
|
29
29
|
quote: "POST /fiat/routing/quote"
|
|
30
30
|
};
|
|
31
31
|
//# sourceMappingURL=routing.js.map
|
package/dist/routing.mjs
CHANGED
package/dist/schemas.d.ts
CHANGED
|
@@ -28,9 +28,9 @@
|
|
|
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, FiatStepResponse, FieldSpec, FlowState, FormDescriptor, FormField, FormFieldType, InstructionField, Instructions, Instrument, JsonValue, KYCProvider, 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 } from './types';
|
|
31
|
+
import type { BlockedReason, CryptoAmount, FailureReason, FeeLine, FiatAmount, FiatEndpoint, FiatProvider, FiatStepResponse, FieldSpec, FlowState, FormDescriptor, FormField, FormFieldType, InstructionField, Instructions, Instrument, JsonValue, KYCProvider, 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, FiatGeo, FiatNextRequest } from './types';
|
|
32
32
|
import type { FiatTermsErrorBody, FiatTermsRequest, FiatTermsResponse, TermsDocument, TermsDocumentAcceptance } from './terms';
|
|
33
|
-
import type { FiatRoutingQuoteErrorBody, FiatRoutingQuoteRequest, FiatRoutingTableErrorBody, FiatRoutingTableQuery, FiatRoutingTableResponse } from './routing';
|
|
33
|
+
import type { FiatRoutingQuoteErrorBody, FiatRoutingQuoteRequest, FiatRoutingQuoteTerms, FiatRoutingTableErrorBody, FiatRoutingTableQuery, FiatRoutingTableResponse } from './routing';
|
|
34
34
|
export declare const JsonSchema: z.ZodType<JsonValue>;
|
|
35
35
|
export declare const HTTP_VERBS: readonly ["GET", "POST"];
|
|
36
36
|
/** `"POST /fiat/session/verify"`, `"GET /fiat/orders/o_31c"` — the verb rides the string. */
|
|
@@ -114,9 +114,12 @@ export declare const FiatTermsResponseSchema: z.ZodType<FiatTermsResponse>;
|
|
|
114
114
|
export declare const FiatTermsErrorBodySchema: z.ZodType<FiatTermsErrorBody>;
|
|
115
115
|
export declare const FiatRoutingTableQuerySchema: z.ZodType<FiatRoutingTableQuery>;
|
|
116
116
|
export declare const FiatRoutingTableResponseSchema: z.ZodType<FiatRoutingTableResponse>;
|
|
117
|
+
export declare const FiatRoutingQuoteTermsSchema: z.ZodType<FiatRoutingQuoteTerms>;
|
|
117
118
|
export declare const FiatRoutingQuoteRequestSchema: z.ZodType<FiatRoutingQuoteRequest>;
|
|
118
119
|
export declare const FiatRoutingTableErrorBodySchema: z.ZodType<FiatRoutingTableErrorBody>;
|
|
119
120
|
export declare const FiatRoutingQuoteErrorBodySchema: z.ZodType<FiatRoutingQuoteErrorBody>;
|
|
121
|
+
export declare const FiatGeoSchema: z.ZodType<FiatGeo>;
|
|
122
|
+
export declare const FiatNextRequestSchema: z.ZodType<FiatNextRequest>;
|
|
120
123
|
export declare const FiatStepResponseSchema: z.ZodType<FiatStepResponse>;
|
|
121
124
|
export {};
|
|
122
125
|
//# sourceMappingURL=schemas.d.ts.map
|
package/dist/table.js
CHANGED
package/dist/table.mjs
CHANGED
package/dist/terms.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* The platform terms route: `POST /fiat/terms`, shared by every provider.
|
|
3
3
|
*
|
|
4
4
|
* A checkout shows the user documents to accept. `CHECKOUT` documents are the constants below;
|
|
5
|
-
* `KYC` documents arrive in a provider flow's
|
|
5
|
+
* `KYC` documents arrive in a provider flow's consent prompt. The user's Continue tap is the
|
|
6
6
|
* acceptance, and the client records it here before the next provider call. A repeat writes nothing.
|
|
7
7
|
*
|
|
8
8
|
* Zero runtime dependencies, so production React Native code can import it. The zod schemas are
|
|
@@ -39,7 +39,7 @@ export interface FiatTermsRequest {
|
|
|
39
39
|
/** One per document the screen showed, each document at most once. */
|
|
40
40
|
acceptances: TermsDocumentAcceptance[];
|
|
41
41
|
}
|
|
42
|
-
/** The recorded document ids. The client then calls
|
|
42
|
+
/** The recorded document ids. The client then calls `POST /fiat/next`. */
|
|
43
43
|
export interface FiatTermsResponse {
|
|
44
44
|
recorded: string[];
|
|
45
45
|
}
|
package/dist/terms.mjs
CHANGED
package/dist/types.d.ts
CHANGED
|
@@ -715,7 +715,7 @@ export type FiatStepResponse = (FiatStepResponseBase & {
|
|
|
715
715
|
/** Optional future payment artifact; never one of this response's currently active transitions. */
|
|
716
716
|
preparedPayment?: PreparedPayment;
|
|
717
717
|
/**
|
|
718
|
-
* The provider runs its own flow from here (`POST /fiat/
|
|
718
|
+
* The provider runs its own flow from here (`POST /fiat/next`). Present
|
|
719
719
|
* only on a `QUOTE`, when the request's `handoffs` named this provider; the response then
|
|
720
720
|
* carries no transitions.
|
|
721
721
|
*/
|
|
@@ -723,5 +723,20 @@ export type FiatStepResponse = (FiatStepResponseBase & {
|
|
|
723
723
|
provider: FiatProvider;
|
|
724
724
|
};
|
|
725
725
|
});
|
|
726
|
+
/** The geo endpoint's response, sent on every `/next` request. `alpha2` is ISO 3166-1 alpha-2. */
|
|
727
|
+
export type FiatGeo = {
|
|
728
|
+
alpha2: string;
|
|
729
|
+
region?: string;
|
|
730
|
+
ip?: string;
|
|
731
|
+
};
|
|
732
|
+
/**
|
|
733
|
+
* The body of every `POST /fiat/next`: `provider`, `geo`, and the provider's own request, which
|
|
734
|
+
* names its `action`. Each provider defines its actions and their fields (`./moonpay`).
|
|
735
|
+
*/
|
|
736
|
+
export type FiatNextRequest = {
|
|
737
|
+
provider: FiatProvider;
|
|
738
|
+
action: string;
|
|
739
|
+
geo: FiatGeo;
|
|
740
|
+
} & Record<string, unknown>;
|
|
726
741
|
export {};
|
|
727
742
|
//# sourceMappingURL=types.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fun-xyz/fiat-contract",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.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": {
|