@fun-xyz/fiat-contract 0.13.0 → 0.15.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 CHANGED
@@ -8,6 +8,7 @@ Four things, zero runtime logic beyond validation:
8
8
  | File | What it is |
9
9
  | --- | --- |
10
10
  | `src/types.ts` | `FlowState` · `Transition` · `FailureReason` · `Surface` · `Instructions` · `FormDescriptor` · `OrderStatus` · `FiatStepResponse` |
11
+ | `src/codes.ts` | Shared country, currency, US subdivision, and payment-method vocabularies |
11
12
  | `src/schemas.ts` | zod mirrors of every type — the single runtime validator |
12
13
  | `src/table.ts` | the transition table **as data**: per state, its legal transition set, the states any call from it may return, and `terminal: boolean` |
13
14
  | `src/assert.ts` + `src/fixtures/` | `assertFiatStepResponse` · `assertLegalEmission` · `assertLegalReturn` · `walkTable` · fixture loader + 18 recorded step responses (inlined as data — no filesystem, so React Native can bundle it) |
@@ -1,5 +1,5 @@
1
1
  // package.json
2
- var version = "0.13.0";
2
+ var version = "0.15.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-AI66DLZT.mjs.map
517
+ //# sourceMappingURL=chunk-CXYGWKAG.mjs.map
package/dist/codes.d.ts CHANGED
@@ -3,6 +3,9 @@
3
3
  * (circulating fiat only, no precious-metal/SDR codes); `paymentMethod` is fun-backend/provider
4
4
  * vocabulary, not a standard. `COUNTRY_CURRENCY_LIST` is the source of truth; everything below derives from it.
5
5
  */
6
+ /** ISO 3166-2:US subdivision codes for the 50 states, DC, and five inhabited territories. */
7
+ export declare const US_STATE_CODES: readonly ["AL", "AK", "AZ", "AR", "CA", "CO", "CT", "DE", "DC", "FL", "GA", "HI", "ID", "IL", "IN", "IA", "KS", "KY", "LA", "ME", "MD", "MA", "MI", "MN", "MS", "MO", "MT", "NE", "NV", "NH", "NJ", "NM", "NY", "NC", "ND", "OH", "OK", "OR", "PA", "RI", "SC", "SD", "TN", "TX", "UT", "VT", "VA", "WA", "WV", "WI", "WY", "AS", "GU", "MP", "PR", "VI"];
8
+ export type UsStateCode = (typeof US_STATE_CODES)[number];
6
9
  declare const COUNTRY_CURRENCY_LIST: readonly [{
7
10
  readonly country: "AD";
8
11
  readonly countryName: "Andorra";
package/dist/index.js CHANGED
@@ -95,6 +95,8 @@ __export(index_exports, {
95
95
  TxSchema: () => TxSchema,
96
96
  UNOFFERED_ENDPOINTS: () => UNOFFERED_ENDPOINTS,
97
97
  UNREACHABLE_STATES: () => UNREACHABLE_STATES,
98
+ US_STATE_CODES: () => US_STATE_CODES,
99
+ UsStateCodeSchema: () => UsStateCodeSchema,
98
100
  assertAllFixtures: () => assertAllFixtures,
99
101
  assertFiatStepResponse: () => assertFiatStepResponse,
100
102
  assertFixture: () => assertFixture,
@@ -116,6 +118,64 @@ __export(index_exports, {
116
118
  module.exports = __toCommonJS(index_exports);
117
119
 
118
120
  // src/codes.ts
121
+ var US_STATE_CODES = [
122
+ "AL",
123
+ "AK",
124
+ "AZ",
125
+ "AR",
126
+ "CA",
127
+ "CO",
128
+ "CT",
129
+ "DE",
130
+ "DC",
131
+ "FL",
132
+ "GA",
133
+ "HI",
134
+ "ID",
135
+ "IL",
136
+ "IN",
137
+ "IA",
138
+ "KS",
139
+ "KY",
140
+ "LA",
141
+ "ME",
142
+ "MD",
143
+ "MA",
144
+ "MI",
145
+ "MN",
146
+ "MS",
147
+ "MO",
148
+ "MT",
149
+ "NE",
150
+ "NV",
151
+ "NH",
152
+ "NJ",
153
+ "NM",
154
+ "NY",
155
+ "NC",
156
+ "ND",
157
+ "OH",
158
+ "OK",
159
+ "OR",
160
+ "PA",
161
+ "RI",
162
+ "SC",
163
+ "SD",
164
+ "TN",
165
+ "TX",
166
+ "UT",
167
+ "VT",
168
+ "VA",
169
+ "WA",
170
+ "WV",
171
+ "WI",
172
+ "WY",
173
+ "AS",
174
+ "GU",
175
+ "MP",
176
+ "PR",
177
+ "VI"
178
+ ];
119
179
  var COUNTRY_CURRENCY_LIST = [
120
180
  { country: "AD", countryName: "Andorra", currency: "EUR", currencyName: "Euro" },
121
181
  { country: "AE", countryName: "United Arab Emirates", currency: "AED", currencyName: "UAE Dirham" },
@@ -396,6 +456,7 @@ var HTTP_VERBS = ["GET", "POST"];
396
456
  var ENDPOINT_PATTERN = /^(GET|POST) \/fiat\/[^\s]*$/;
397
457
  var $endpoint = import_zod.z.string().regex(ENDPOINT_PATTERN, 'endpoint must read "<GET|POST> /fiat/\u2026"');
398
458
  var FiatEndpointSchema = $endpoint;
459
+ var UsStateCodeSchema = import_zod.z.enum(US_STATE_CODES);
399
460
  var $provider = import_zod.z.enum([
400
461
  "TRANSAK",
401
462
  "SWAPPED",
@@ -880,7 +941,8 @@ var $providerBoundStepResponse = obj({
880
941
  clientSecret: import_zod.z.string(),
881
942
  expiresAt: import_zod.z.string()
882
943
  }).optional(),
883
- orderId: import_zod.z.string().optional()
944
+ orderId: import_zod.z.string().optional(),
945
+ refreshLimits: import_zod.z.literal(true).optional()
884
946
  });
885
947
  var $blockedStepResponse = obj({
886
948
  state: $blockedState,
@@ -891,13 +953,14 @@ var $blockedStepResponse = obj({
891
953
  clientSecret: import_zod.z.string(),
892
954
  expiresAt: import_zod.z.string()
893
955
  }).optional(),
894
- orderId: import_zod.z.string().optional()
956
+ orderId: import_zod.z.string().optional(),
957
+ refreshLimits: import_zod.z.literal(true).optional()
895
958
  });
896
959
  var $stepResponse = import_zod.z.union([$providerBoundStepResponse, $blockedStepResponse]);
897
960
  var FiatStepResponseSchema = $stepResponse;
898
961
 
899
962
  // package.json
900
- var version = "0.13.0";
963
+ var version = "0.15.0";
901
964
 
902
965
  // src/table.ts
903
966
  var TABLE_VERSION = version;
package/dist/index.mjs CHANGED
@@ -12,9 +12,67 @@ import {
12
12
  tableEntry,
13
13
  unofferedEndpoints,
14
14
  unreachableStates
15
- } from "./chunk-AI66DLZT.mjs";
15
+ } from "./chunk-CXYGWKAG.mjs";
16
16
 
17
17
  // src/codes.ts
18
+ var US_STATE_CODES = [
19
+ "AL",
20
+ "AK",
21
+ "AZ",
22
+ "AR",
23
+ "CA",
24
+ "CO",
25
+ "CT",
26
+ "DE",
27
+ "DC",
28
+ "FL",
29
+ "GA",
30
+ "HI",
31
+ "ID",
32
+ "IL",
33
+ "IN",
34
+ "IA",
35
+ "KS",
36
+ "KY",
37
+ "LA",
38
+ "ME",
39
+ "MD",
40
+ "MA",
41
+ "MI",
42
+ "MN",
43
+ "MS",
44
+ "MO",
45
+ "MT",
46
+ "NE",
47
+ "NV",
48
+ "NH",
49
+ "NJ",
50
+ "NM",
51
+ "NY",
52
+ "NC",
53
+ "ND",
54
+ "OH",
55
+ "OK",
56
+ "OR",
57
+ "PA",
58
+ "RI",
59
+ "SC",
60
+ "SD",
61
+ "TN",
62
+ "TX",
63
+ "UT",
64
+ "VT",
65
+ "VA",
66
+ "WA",
67
+ "WV",
68
+ "WI",
69
+ "WY",
70
+ "AS",
71
+ "GU",
72
+ "MP",
73
+ "PR",
74
+ "VI"
75
+ ];
18
76
  var COUNTRY_CURRENCY_LIST = [
19
77
  { country: "AD", countryName: "Andorra", currency: "EUR", currencyName: "Euro" },
20
78
  { country: "AE", countryName: "United Arab Emirates", currency: "AED", currencyName: "UAE Dirham" },
@@ -295,6 +353,7 @@ var HTTP_VERBS = ["GET", "POST"];
295
353
  var ENDPOINT_PATTERN = /^(GET|POST) \/fiat\/[^\s]*$/;
296
354
  var $endpoint = z.string().regex(ENDPOINT_PATTERN, 'endpoint must read "<GET|POST> /fiat/\u2026"');
297
355
  var FiatEndpointSchema = $endpoint;
356
+ var UsStateCodeSchema = z.enum(US_STATE_CODES);
298
357
  var $provider = z.enum([
299
358
  "TRANSAK",
300
359
  "SWAPPED",
@@ -779,7 +838,8 @@ var $providerBoundStepResponse = obj({
779
838
  clientSecret: z.string(),
780
839
  expiresAt: z.string()
781
840
  }).optional(),
782
- orderId: z.string().optional()
841
+ orderId: z.string().optional(),
842
+ refreshLimits: z.literal(true).optional()
783
843
  });
784
844
  var $blockedStepResponse = obj({
785
845
  state: $blockedState,
@@ -790,7 +850,8 @@ var $blockedStepResponse = obj({
790
850
  clientSecret: z.string(),
791
851
  expiresAt: z.string()
792
852
  }).optional(),
793
- orderId: z.string().optional()
853
+ orderId: z.string().optional(),
854
+ refreshLimits: z.literal(true).optional()
794
855
  });
795
856
  var $stepResponse = z.union([$providerBoundStepResponse, $blockedStepResponse]);
796
857
  var FiatStepResponseSchema = $stepResponse;
@@ -1931,6 +1992,8 @@ export {
1931
1992
  TxSchema,
1932
1993
  UNOFFERED_ENDPOINTS,
1933
1994
  UNREACHABLE_STATES,
1995
+ US_STATE_CODES,
1996
+ UsStateCodeSchema,
1934
1997
  assertAllFixtures,
1935
1998
  assertFiatStepResponse,
1936
1999
  assertFixture,
package/dist/schemas.d.ts CHANGED
@@ -27,12 +27,14 @@
27
27
  * They are module-private, so none of it reaches the published declarations.
28
28
  */
29
29
  import { z } from 'zod';
30
+ import type { UsStateCode } from './codes';
30
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, Quote, QuoteLimitRange, QuoteLimits, Recovery, Refund, ReportSpec, SelectOption, StatusHistoryEntry, Surface, PreferredIdentityDocument, ClientExecutedDelivery, KycSdkResultReport, SurfaceKind, SurfaceProvider, TermsAcceptance, Transition, TransitionInputs, TransitionParams, Tx } from './types';
31
32
  export declare const JsonSchema: z.ZodType<JsonValue>;
32
33
  export declare const HTTP_VERBS: readonly ["GET", "POST"];
33
34
  /** `"POST /fiat/session/verify"`, `"GET /fiat/orders/o_31c"` — the verb rides the string. */
34
35
  export declare const ENDPOINT_PATTERN: RegExp;
35
36
  export declare const FiatEndpointSchema: z.ZodType<FiatEndpoint>;
37
+ export declare const UsStateCodeSchema: z.ZodType<UsStateCode>;
36
38
  export declare const FiatProviderSchema: z.ZodType<FiatProvider>;
37
39
  export declare const KYCProviderSchema: z.ZodType<KYCProvider>;
38
40
  export declare const SurfaceProviderSchema: z.ZodType<SurfaceProvider>;
package/dist/table.js CHANGED
@@ -36,7 +36,7 @@ __export(table_exports, {
36
36
  module.exports = __toCommonJS(table_exports);
37
37
 
38
38
  // package.json
39
- var version = "0.13.0";
39
+ var version = "0.15.0";
40
40
 
41
41
  // src/table.ts
42
42
  var TABLE_VERSION = version;
package/dist/table.mjs CHANGED
@@ -11,7 +11,7 @@ import {
11
11
  tableEntry,
12
12
  unofferedEndpoints,
13
13
  unreachableStates
14
- } from "./chunk-AI66DLZT.mjs";
14
+ } from "./chunk-CXYGWKAG.mjs";
15
15
  export {
16
16
  DOCUMENTED_ENDPOINTS,
17
17
  STATE_KEYS,
package/dist/types.d.ts CHANGED
@@ -662,6 +662,15 @@ type FiatStepResponseBase = {
662
662
  };
663
663
  /** TODO(open-decision): `orderId` placement — see `PAYMENT{INSTRUCT}.orderId` above. */
664
664
  orderId?: string;
665
+ /**
666
+ * Best-effort: what this response did may have changed what the buyer can spend, so a cached
667
+ * discovery ceiling is no longer trusted. Absent is not a promise that nothing changed, only
668
+ * that this response is not reporting one, so a client must still tolerate a stale ceiling.
669
+ *
670
+ * Never `false`. A widened or dropped ceiling costs one discovery call; one left too low
671
+ * refuses a purchase the backend would have served, so the uncertain direction is to send it.
672
+ */
673
+ refreshLimits?: true;
665
674
  };
666
675
  /**
667
676
  * Provider is absent only when routing ended before a provider could be selected. A BLOCKED response
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fun-xyz/fiat-contract",
3
- "version": "0.13.0",
3
+ "version": "0.15.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": {