@fun-xyz/fiat-contract 0.21.0 → 0.22.1
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 +12 -6
- package/dist/{chunk-N6GHUS2K.mjs → chunk-5GRPYE2U.mjs} +1 -1
- package/dist/{chunk-YOMQWXTD.mjs → chunk-I63WALQK.mjs} +1 -1
- package/dist/{chunk-LBYBZDOW.mjs → chunk-PP6S7FSJ.mjs} +2 -2
- package/dist/index.js +12 -11
- package/dist/index.mjs +14 -13
- package/dist/providers/moonpay.d.ts +20 -7
- package/dist/providers/moonpay.mjs +1 -1
- 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/package.json +1 -1
package/README.md
CHANGED
|
@@ -111,7 +111,7 @@ handoff to a provider other than the response's own, and a handoff that still of
|
|
|
111
111
|
`{ provider, acceptances: [{ documentId, version, contentDigest, acceptedAt }] }`, each document at
|
|
112
112
|
most once; `FiatTermsResponse` is `{ recorded }`, the recorded document ids. A fault is a
|
|
113
113
|
`FiatTermsErrorBody`: the shared `errorCode`, `errorMsg` and `reqId`, plus `reason` (`STALE_TERMS`,
|
|
114
|
-
`
|
|
114
|
+
`INVALID_REQUEST`, `RATE_LIMITED`, `PROVIDER_UNAVAILABLE`) and `recovery`.
|
|
115
115
|
|
|
116
116
|
The package publishes every document as a constant, so the client and the backend read the same
|
|
117
117
|
text. `PROVIDER_CHECKOUT_DOCUMENTS` maps each provider to its current `CHECKOUT` documents.
|
|
@@ -126,8 +126,8 @@ three kinds:
|
|
|
126
126
|
| `kind` | Carries | A repeat |
|
|
127
127
|
| --- | --- | --- |
|
|
128
128
|
| `observe` | `checkout`, and `credentials` (`customerId`, `accessToken`) once the SDK has them | writes nothing new |
|
|
129
|
-
| `kyc` | `checkout`, `credentials`, `values` keyed by `KycFieldId` (no form id) | drops values MoonPay no longer asks for
|
|
130
|
-
| `order` | `orderId`, `transactionId` | returns the
|
|
129
|
+
| `kyc` | `checkout`, `credentials`, `values` keyed by `KycFieldId` (no form id) | drops values MoonPay no longer asks for |
|
|
130
|
+
| `order` | `orderId`, `transactionId?`, `quotedAmount`, `geo?` (the checkout's) | returns the recorded order |
|
|
131
131
|
|
|
132
132
|
`observe` and `kyc` answer a `MoonPayStepResponse`, which says what the backend needs next:
|
|
133
133
|
|
|
@@ -140,7 +140,13 @@ three kinds:
|
|
|
140
140
|
| `READY` | `orderId`, `quoteInput` | mounts Apple Pay, then sends `order` after the charge |
|
|
141
141
|
| `REFUSED` | `reason` (`NOT_ELIGIBLE`, `DOCUMENTS_REQUIRED`, `FINAL_REJECTION`, `CUSTOMER_MISMATCH`), `recovery: REQUOTE \| NONE` | exits the provider flow |
|
|
142
142
|
|
|
143
|
-
`order` runs after
|
|
143
|
+
`order` runs after every charge attempt, a failed one too, and answers a `MoonPayOrderResponse`.
|
|
144
|
+
`transactionId` is optional because a failed charge may have none; without it the backend records the
|
|
145
|
+
failed charges MoonPay lists for `orderId`. `quotedAmount` is the fiat amount the quote showed.
|
|
146
|
+
`geo` is the same object `observe` sends in `checkout`; the order records its `alpha2` as its
|
|
147
|
+
country, and no country without it. A
|
|
148
|
+
failed charge answers `DONE` with the order in `FAILED`, and the client requotes for a new `orderId`.
|
|
149
|
+
After a failed charge with no `transactionId`, the client caps its `PENDING` polls.
|
|
144
150
|
|
|
145
151
|
| `status` | Carries | The client then |
|
|
146
152
|
| --- | --- | --- |
|
|
@@ -151,8 +157,8 @@ three kinds:
|
|
|
151
157
|
`MoonPayIntentResponseFor` maps each `kind` to its union, and `MoonPayIntentResponse` is both.
|
|
152
158
|
|
|
153
159
|
A fault is a 4xx or 5xx with a `MoonPayErrorBody`: the shared `errorCode`, `errorMsg` and `reqId`,
|
|
154
|
-
plus `reason` (`SESSION_BUDGET_SPENT`, `RATE_LIMITED`, `PROVIDER_UNAVAILABLE`, `
|
|
155
|
-
|
|
160
|
+
plus `reason` (`SESSION_BUDGET_SPENT`, `RATE_LIMITED`, `PROVIDER_UNAVAILABLE`, `INVALID_REQUEST`)
|
|
161
|
+
and `recovery`:
|
|
156
162
|
`RETRY` (send the same request again), `REQUOTE`, or `NONE`. A field error is a `KYC`
|
|
157
163
|
response, not a fault. The zod schemas (`MoonPay*Schema`, `TermsDocumentSchema`, `FiatTerms*Schema`)
|
|
158
164
|
are exported from the root only.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// package.json
|
|
2
|
-
var version = "0.
|
|
2
|
+
var version = "0.22.1";
|
|
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-PP6S7FSJ.mjs.map
|
package/dist/index.js
CHANGED
|
@@ -1004,7 +1004,7 @@ var $termsErrorBody = obj({
|
|
|
1004
1004
|
errorCode: $nonBlank,
|
|
1005
1005
|
errorMsg: import_zod.z.string(),
|
|
1006
1006
|
reqId: import_zod.z.string().optional(),
|
|
1007
|
-
reason: import_zod.z.enum(["STALE_TERMS", "
|
|
1007
|
+
reason: import_zod.z.enum(["STALE_TERMS", "INVALID_REQUEST", "RATE_LIMITED", "PROVIDER_UNAVAILABLE"]),
|
|
1008
1008
|
recovery: import_zod.z.enum(["RETRY", "REQUOTE", "NONE"])
|
|
1009
1009
|
});
|
|
1010
1010
|
var FiatTermsErrorBodySchema = $termsErrorBody;
|
|
@@ -1067,7 +1067,7 @@ var $stepResponse = import_zod.z.union([$providerBoundStepResponse, $blockedStep
|
|
|
1067
1067
|
var FiatStepResponseSchema = $stepResponse;
|
|
1068
1068
|
|
|
1069
1069
|
// package.json
|
|
1070
|
-
var version = "0.
|
|
1070
|
+
var version = "0.22.1";
|
|
1071
1071
|
|
|
1072
1072
|
// src/table.ts
|
|
1073
1073
|
var TABLE_VERSION = version;
|
|
@@ -2681,11 +2681,12 @@ var FIAT_CURRENCY_CODES2 = Object.keys(FIAT_CURRENCY_NAMES);
|
|
|
2681
2681
|
var obj2 = (shape) => import_zod2.z.object(shape).strict();
|
|
2682
2682
|
var $nonEmpty = import_zod2.z.string().refine((value) => value.trim().length > 0, "must not be blank");
|
|
2683
2683
|
var hasUniqueIds2 = (ids) => new Set(ids).size === ids.length;
|
|
2684
|
+
var $geo = obj2({ alpha2: import_zod2.z.string().regex(/^[A-Z]{2}$/), region: $nonEmpty.optional(), ip: $nonEmpty.optional() });
|
|
2684
2685
|
var $checkout = obj2({
|
|
2685
2686
|
amount: FiatAmountSchema,
|
|
2686
2687
|
destination: obj2({ asset: $nonEmpty, network: $nonEmpty }),
|
|
2687
2688
|
paymentMethod: import_zod2.z.literal("apple_pay"),
|
|
2688
|
-
geo:
|
|
2689
|
+
geo: $geo
|
|
2689
2690
|
});
|
|
2690
2691
|
var MoonPayCheckoutSchema = $checkout;
|
|
2691
2692
|
var $credentials = obj2({ customerId: $nonEmpty, accessToken: $nonEmpty });
|
|
@@ -2698,7 +2699,13 @@ var $intentRequest = import_zod2.z.discriminatedUnion("kind", [
|
|
|
2698
2699
|
credentials: $credentials,
|
|
2699
2700
|
values: import_zod2.z.record(KycFieldIdSchema, import_zod2.z.string()).refine((values) => Object.keys(values).length > 0, "values must not be empty")
|
|
2700
2701
|
}),
|
|
2701
|
-
obj2({
|
|
2702
|
+
obj2({
|
|
2703
|
+
kind: import_zod2.z.literal("order"),
|
|
2704
|
+
orderId: $nonEmpty,
|
|
2705
|
+
transactionId: $nonEmpty.optional(),
|
|
2706
|
+
quotedAmount: FiatAmountSchema,
|
|
2707
|
+
geo: $geo.optional()
|
|
2708
|
+
})
|
|
2702
2709
|
]);
|
|
2703
2710
|
var MoonPayIntentRequestSchema = $intentRequest;
|
|
2704
2711
|
var $quoteInput = obj2({
|
|
@@ -2750,13 +2757,7 @@ var MoonPayOrderResponseSchema = $orderResponse;
|
|
|
2750
2757
|
var $intentResponse = import_zod2.z.union([$stepResponse2, $orderResponse]);
|
|
2751
2758
|
var MoonPayIntentResponseSchema = $intentResponse;
|
|
2752
2759
|
var $faultFields = {
|
|
2753
|
-
reason: import_zod2.z.enum([
|
|
2754
|
-
"SESSION_BUDGET_SPENT",
|
|
2755
|
-
"RATE_LIMITED",
|
|
2756
|
-
"PROVIDER_UNAVAILABLE",
|
|
2757
|
-
"IN_PROGRESS",
|
|
2758
|
-
"INVALID_REQUEST"
|
|
2759
|
-
]),
|
|
2760
|
+
reason: import_zod2.z.enum(["SESSION_BUDGET_SPENT", "RATE_LIMITED", "PROVIDER_UNAVAILABLE", "INVALID_REQUEST"]),
|
|
2760
2761
|
recovery: import_zod2.z.enum(["RETRY", "REQUOTE", "NONE"])
|
|
2761
2762
|
};
|
|
2762
2763
|
var $fault = obj2($faultFields);
|
package/dist/index.mjs
CHANGED
|
@@ -12,16 +12,16 @@ import {
|
|
|
12
12
|
tableEntry,
|
|
13
13
|
unofferedEndpoints,
|
|
14
14
|
unreachableStates
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-PP6S7FSJ.mjs";
|
|
16
16
|
import {
|
|
17
17
|
MOONPAY_ENDPOINTS
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-I63WALQK.mjs";
|
|
19
19
|
import {
|
|
20
20
|
FIAT_TERMS_ENDPOINT,
|
|
21
21
|
FUN_KYC_CONSENT_DOCUMENTS,
|
|
22
22
|
PROVIDER_CHECKOUT_DOCUMENTS,
|
|
23
23
|
PUBLISHED_TERMS_DOCUMENTS
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-5GRPYE2U.mjs";
|
|
25
25
|
|
|
26
26
|
// src/codes.ts
|
|
27
27
|
var US_STATE_CODES = [
|
|
@@ -888,7 +888,7 @@ var $termsErrorBody = obj({
|
|
|
888
888
|
errorCode: $nonBlank,
|
|
889
889
|
errorMsg: z.string(),
|
|
890
890
|
reqId: z.string().optional(),
|
|
891
|
-
reason: z.enum(["STALE_TERMS", "
|
|
891
|
+
reason: z.enum(["STALE_TERMS", "INVALID_REQUEST", "RATE_LIMITED", "PROVIDER_UNAVAILABLE"]),
|
|
892
892
|
recovery: z.enum(["RETRY", "REQUOTE", "NONE"])
|
|
893
893
|
});
|
|
894
894
|
var FiatTermsErrorBodySchema = $termsErrorBody;
|
|
@@ -2021,11 +2021,12 @@ var FIAT_CURRENCY_CODES2 = Object.keys(FIAT_CURRENCY_NAMES);
|
|
|
2021
2021
|
var obj2 = (shape) => z2.object(shape).strict();
|
|
2022
2022
|
var $nonEmpty = z2.string().refine((value) => value.trim().length > 0, "must not be blank");
|
|
2023
2023
|
var hasUniqueIds2 = (ids) => new Set(ids).size === ids.length;
|
|
2024
|
+
var $geo = obj2({ alpha2: z2.string().regex(/^[A-Z]{2}$/), region: $nonEmpty.optional(), ip: $nonEmpty.optional() });
|
|
2024
2025
|
var $checkout = obj2({
|
|
2025
2026
|
amount: FiatAmountSchema,
|
|
2026
2027
|
destination: obj2({ asset: $nonEmpty, network: $nonEmpty }),
|
|
2027
2028
|
paymentMethod: z2.literal("apple_pay"),
|
|
2028
|
-
geo:
|
|
2029
|
+
geo: $geo
|
|
2029
2030
|
});
|
|
2030
2031
|
var MoonPayCheckoutSchema = $checkout;
|
|
2031
2032
|
var $credentials = obj2({ customerId: $nonEmpty, accessToken: $nonEmpty });
|
|
@@ -2038,7 +2039,13 @@ var $intentRequest = z2.discriminatedUnion("kind", [
|
|
|
2038
2039
|
credentials: $credentials,
|
|
2039
2040
|
values: z2.record(KycFieldIdSchema, z2.string()).refine((values) => Object.keys(values).length > 0, "values must not be empty")
|
|
2040
2041
|
}),
|
|
2041
|
-
obj2({
|
|
2042
|
+
obj2({
|
|
2043
|
+
kind: z2.literal("order"),
|
|
2044
|
+
orderId: $nonEmpty,
|
|
2045
|
+
transactionId: $nonEmpty.optional(),
|
|
2046
|
+
quotedAmount: FiatAmountSchema,
|
|
2047
|
+
geo: $geo.optional()
|
|
2048
|
+
})
|
|
2042
2049
|
]);
|
|
2043
2050
|
var MoonPayIntentRequestSchema = $intentRequest;
|
|
2044
2051
|
var $quoteInput = obj2({
|
|
@@ -2090,13 +2097,7 @@ var MoonPayOrderResponseSchema = $orderResponse;
|
|
|
2090
2097
|
var $intentResponse = z2.union([$stepResponse2, $orderResponse]);
|
|
2091
2098
|
var MoonPayIntentResponseSchema = $intentResponse;
|
|
2092
2099
|
var $faultFields = {
|
|
2093
|
-
reason: z2.enum([
|
|
2094
|
-
"SESSION_BUDGET_SPENT",
|
|
2095
|
-
"RATE_LIMITED",
|
|
2096
|
-
"PROVIDER_UNAVAILABLE",
|
|
2097
|
-
"IN_PROGRESS",
|
|
2098
|
-
"INVALID_REQUEST"
|
|
2099
|
-
]),
|
|
2100
|
+
reason: z2.enum(["SESSION_BUDGET_SPENT", "RATE_LIMITED", "PROVIDER_UNAVAILABLE", "INVALID_REQUEST"]),
|
|
2100
2101
|
recovery: z2.enum(["RETRY", "REQUOTE", "NONE"])
|
|
2101
2102
|
};
|
|
2102
2103
|
var $fault = obj2($faultFields);
|
|
@@ -57,11 +57,18 @@ export type MoonPayIntentRequest =
|
|
|
57
57
|
credentials: MoonPaySdkCredentials;
|
|
58
58
|
values: Partial<Record<KycFieldId, string>>;
|
|
59
59
|
}
|
|
60
|
-
/**
|
|
60
|
+
/**
|
|
61
|
+
* After every charge attempt, a failed one too. `transactionId` is from the Apple Pay event when it
|
|
62
|
+
* has one; without it the backend records the failed charges MoonPay lists for `orderId`.
|
|
63
|
+
* `quotedAmount` is the fiat amount the buyer saw on the quote. `geo` is the checkout's, as sent on
|
|
64
|
+
* `observe`; the order records its `alpha2`, and no country when it is absent.
|
|
65
|
+
*/
|
|
61
66
|
| {
|
|
62
67
|
kind: 'order';
|
|
63
68
|
orderId: string;
|
|
64
|
-
transactionId
|
|
69
|
+
transactionId?: string;
|
|
70
|
+
quotedAmount: FiatAmount;
|
|
71
|
+
geo?: MoonPayCheckout['geo'];
|
|
65
72
|
};
|
|
66
73
|
export type MoonPayIntentKind = MoonPayIntentRequest['kind'];
|
|
67
74
|
/**
|
|
@@ -138,14 +145,20 @@ export type MoonPayStepResponse =
|
|
|
138
145
|
reason: MoonPayStepRefusal;
|
|
139
146
|
recovery: 'REQUOTE' | 'NONE';
|
|
140
147
|
};
|
|
141
|
-
/**
|
|
148
|
+
/**
|
|
149
|
+
* The answer to `order`, which runs after each charge attempt. A failed charge is recorded too: it
|
|
150
|
+
* answers `DONE` with the order in `FAILED`, and the client requotes for a new `orderId`.
|
|
151
|
+
*/
|
|
142
152
|
export type MoonPayOrderResponse =
|
|
143
153
|
/** The `GET /fiat/orders/:orderId` response; the shared order screen renders it. */
|
|
144
154
|
{
|
|
145
155
|
status: 'DONE';
|
|
146
156
|
order: FiatStepResponse;
|
|
147
157
|
}
|
|
148
|
-
/**
|
|
158
|
+
/**
|
|
159
|
+
* MoonPay does not list the transaction yet. Send the same `order` after the delay. After a failed
|
|
160
|
+
* charge with no `transactionId`, the client caps these polls.
|
|
161
|
+
*/
|
|
149
162
|
| {
|
|
150
163
|
status: 'PENDING';
|
|
151
164
|
retryAfterMs: number;
|
|
@@ -167,10 +180,10 @@ export type MoonPayIntentStatus = MoonPayIntentResponse['status'];
|
|
|
167
180
|
export type MoonPayRecovery = 'RETRY' | 'REQUOTE' | 'NONE';
|
|
168
181
|
/**
|
|
169
182
|
* `SESSION_BUDGET_SPENT`: the per-login SDK session mint budget (429). `RATE_LIMITED`: the kind's
|
|
170
|
-
* request budget (429). `PROVIDER_UNAVAILABLE`: MoonPay or Sumsub is down. `
|
|
171
|
-
*
|
|
183
|
+
* request budget (429). `PROVIDER_UNAVAILABLE`: MoonPay or Sumsub is down. `INVALID_REQUEST`: a bad
|
|
184
|
+
* body (400).
|
|
172
185
|
*/
|
|
173
|
-
export type MoonPayFaultReason = 'SESSION_BUDGET_SPENT' | 'RATE_LIMITED' | 'PROVIDER_UNAVAILABLE' | '
|
|
186
|
+
export type MoonPayFaultReason = 'SESSION_BUDGET_SPENT' | 'RATE_LIMITED' | 'PROVIDER_UNAVAILABLE' | 'INVALID_REQUEST';
|
|
174
187
|
/** The fields a MoonPay fault adds to the shared error body. */
|
|
175
188
|
export interface MoonPayFault {
|
|
176
189
|
reason: MoonPayFaultReason;
|
package/dist/table.js
CHANGED
package/dist/table.mjs
CHANGED
package/dist/terms.d.ts
CHANGED
|
@@ -45,11 +45,11 @@ export interface FiatTermsResponse {
|
|
|
45
45
|
}
|
|
46
46
|
/**
|
|
47
47
|
* `STALE_TERMS`: an unpublished version, a wrong digest, or an `acceptedAt` older than 5 minutes
|
|
48
|
-
* (400). `
|
|
48
|
+
* (400). `INVALID_REQUEST`: a bad body (400).
|
|
49
49
|
* `RATE_LIMITED`: the per-login terms budget is spent (429). `PROVIDER_UNAVAILABLE`: the KYC service
|
|
50
50
|
* or a store is down (503); nothing is recorded, so retry.
|
|
51
51
|
*/
|
|
52
|
-
export type FiatTermsFaultReason = 'STALE_TERMS' | '
|
|
52
|
+
export type FiatTermsFaultReason = 'STALE_TERMS' | 'INVALID_REQUEST' | 'RATE_LIMITED' | 'PROVIDER_UNAVAILABLE';
|
|
53
53
|
/** `RETRY` sends the same request again. `REQUOTE` goes back to `POST /fiat/quote`. `NONE` ends the flow. */
|
|
54
54
|
export type FiatTermsRecovery = 'RETRY' | 'REQUOTE' | 'NONE';
|
|
55
55
|
/** The 4xx/5xx body of `POST /fiat/terms`: the shared error body plus `reason` and `recovery`. */
|
package/dist/terms.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.22.1",
|
|
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": {
|