@fun-xyz/fiat-contract 0.22.1 → 0.22.2

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
@@ -134,8 +134,8 @@ three kinds:
134
134
  | `status` | Carries | The client then |
135
135
  | --- | --- | --- |
136
136
  | `TERMS` | `stage`, `documents` (at least one, all at `stage`) | sends `POST /fiat/terms`, then `observe` |
137
- | `SDK_AUTH` | `sessionToken`, `quoteInput` | runs the MoonPay connection check, then `observe` with credentials |
138
- | `KYC` | `fields`, `fieldErrors?` (each naming a field in `fields`) | shows the shared form, then sends `kyc` |
137
+ | `SDK_AUTH` | `sessionToken`, `quoteInput`, `resetConnection?` (`true` when the device's MoonPay connection is another buyer's) | resets the connection when asked, runs the MoonPay connection check, then `observe` with credentials |
138
+ | `KYC` | `fields`, `fieldErrors?` (each naming a field in `fields`, with `code?` `PHONE_IN_USE` on `PHONE_NUMBER` or `TAX_ID_IN_USE` on `TAX_IDENTIFIER` when another MoonPay customer holds the value) | shows the shared form, then sends `kyc` |
139
139
  | `PENDING` | `retryAfterMs` (at most 60 s) | sends `observe` after the delay, never `kyc` again |
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 |
@@ -6,4 +6,4 @@ var MOONPAY_ENDPOINTS = {
6
6
  export {
7
7
  MOONPAY_ENDPOINTS
8
8
  };
9
- //# sourceMappingURL=chunk-I63WALQK.mjs.map
9
+ //# sourceMappingURL=chunk-3HCZ6JBJ.mjs.map
@@ -1,5 +1,5 @@
1
1
  // package.json
2
- var version = "0.22.1";
2
+ var version = "0.22.2";
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-PP6S7FSJ.mjs.map
517
+ //# sourceMappingURL=chunk-DTHUNDA7.mjs.map
package/dist/index.js CHANGED
@@ -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.22.1";
1070
+ var version = "0.22.2";
1071
1071
 
1072
1072
  // src/table.ts
1073
1073
  var TABLE_VERSION = version;
@@ -2718,11 +2718,12 @@ var $quoteInput = obj2({
2718
2718
  var MoonPayQuoteInputSchema = $quoteInput;
2719
2719
  var $stepRefusal = import_zod2.z.enum(["NOT_ELIGIBLE", "DOCUMENTS_REQUIRED", "FINAL_REJECTION", "CUSTOMER_MISMATCH"]);
2720
2720
  var $orderRefusal = import_zod2.z.enum(["CUSTOMER_MISMATCH", "WALLET_MISMATCH", "UNRECORDABLE"]);
2721
- var $fieldError = obj2({ fieldId: $nonEmpty, message: $nonEmpty });
2721
+ var FIELD_OF_CODE = { PHONE_IN_USE: "PHONE_NUMBER", TAX_ID_IN_USE: "TAX_IDENTIFIER" };
2722
+ var $fieldError = obj2({ fieldId: $nonEmpty, message: $nonEmpty, code: import_zod2.z.enum(["PHONE_IN_USE", "TAX_ID_IN_USE"]).optional() });
2722
2723
  var $pending = obj2({ status: import_zod2.z.literal("PENDING"), retryAfterMs: import_zod2.z.number().int().positive().max(6e4) });
2723
2724
  var $stepStatus = import_zod2.z.discriminatedUnion("status", [
2724
2725
  obj2({ status: import_zod2.z.literal("TERMS"), stage: import_zod2.z.enum(["CHECKOUT", "KYC"]), documents: import_zod2.z.array(TermsDocumentSchema).min(1) }),
2725
- obj2({ status: import_zod2.z.literal("SDK_AUTH"), sessionToken: $nonEmpty, quoteInput: $quoteInput }),
2726
+ obj2({ status: import_zod2.z.literal("SDK_AUTH"), sessionToken: $nonEmpty, quoteInput: $quoteInput, resetConnection: import_zod2.z.literal(true).optional() }),
2726
2727
  obj2({ status: import_zod2.z.literal("KYC"), fields: import_zod2.z.array(FormFieldSchema).min(1), fieldErrors: import_zod2.z.array($fieldError).min(1).optional() }),
2727
2728
  $pending,
2728
2729
  obj2({ status: import_zod2.z.literal("READY"), orderId: $nonEmpty, quoteInput: $quoteInput }),
@@ -2745,6 +2746,9 @@ var $stepResponse2 = $stepStatus.superRefine((response, context) => {
2745
2746
  if (response.fieldErrors?.some((error) => !fieldIds.includes(error.fieldId))) {
2746
2747
  context.addIssue({ code: "custom", path: ["fieldErrors"], message: "a field error must name a field in this response" });
2747
2748
  }
2749
+ if (response.fieldErrors?.some((error) => error.code && FIELD_OF_CODE[error.code] !== error.fieldId)) {
2750
+ context.addIssue({ code: "custom", path: ["fieldErrors"], message: "a field error code must match its field" });
2751
+ }
2748
2752
  }
2749
2753
  });
2750
2754
  var MoonPayStepResponseSchema = $stepResponse2;
package/dist/index.mjs CHANGED
@@ -12,10 +12,10 @@ import {
12
12
  tableEntry,
13
13
  unofferedEndpoints,
14
14
  unreachableStates
15
- } from "./chunk-PP6S7FSJ.mjs";
15
+ } from "./chunk-DTHUNDA7.mjs";
16
16
  import {
17
17
  MOONPAY_ENDPOINTS
18
- } from "./chunk-I63WALQK.mjs";
18
+ } from "./chunk-3HCZ6JBJ.mjs";
19
19
  import {
20
20
  FIAT_TERMS_ENDPOINT,
21
21
  FUN_KYC_CONSENT_DOCUMENTS,
@@ -2058,11 +2058,12 @@ var $quoteInput = obj2({
2058
2058
  var MoonPayQuoteInputSchema = $quoteInput;
2059
2059
  var $stepRefusal = z2.enum(["NOT_ELIGIBLE", "DOCUMENTS_REQUIRED", "FINAL_REJECTION", "CUSTOMER_MISMATCH"]);
2060
2060
  var $orderRefusal = z2.enum(["CUSTOMER_MISMATCH", "WALLET_MISMATCH", "UNRECORDABLE"]);
2061
- var $fieldError = obj2({ fieldId: $nonEmpty, message: $nonEmpty });
2061
+ var FIELD_OF_CODE = { PHONE_IN_USE: "PHONE_NUMBER", TAX_ID_IN_USE: "TAX_IDENTIFIER" };
2062
+ var $fieldError = obj2({ fieldId: $nonEmpty, message: $nonEmpty, code: z2.enum(["PHONE_IN_USE", "TAX_ID_IN_USE"]).optional() });
2062
2063
  var $pending = obj2({ status: z2.literal("PENDING"), retryAfterMs: z2.number().int().positive().max(6e4) });
2063
2064
  var $stepStatus = z2.discriminatedUnion("status", [
2064
2065
  obj2({ status: z2.literal("TERMS"), stage: z2.enum(["CHECKOUT", "KYC"]), documents: z2.array(TermsDocumentSchema).min(1) }),
2065
- obj2({ status: z2.literal("SDK_AUTH"), sessionToken: $nonEmpty, quoteInput: $quoteInput }),
2066
+ obj2({ status: z2.literal("SDK_AUTH"), sessionToken: $nonEmpty, quoteInput: $quoteInput, resetConnection: z2.literal(true).optional() }),
2066
2067
  obj2({ status: z2.literal("KYC"), fields: z2.array(FormFieldSchema).min(1), fieldErrors: z2.array($fieldError).min(1).optional() }),
2067
2068
  $pending,
2068
2069
  obj2({ status: z2.literal("READY"), orderId: $nonEmpty, quoteInput: $quoteInput }),
@@ -2085,6 +2086,9 @@ var $stepResponse2 = $stepStatus.superRefine((response, context) => {
2085
2086
  if (response.fieldErrors?.some((error) => !fieldIds.includes(error.fieldId))) {
2086
2087
  context.addIssue({ code: "custom", path: ["fieldErrors"], message: "a field error must name a field in this response" });
2087
2088
  }
2089
+ if (response.fieldErrors?.some((error) => error.code && FIELD_OF_CODE[error.code] !== error.fieldId)) {
2090
+ context.addIssue({ code: "custom", path: ["fieldErrors"], message: "a field error code must match its field" });
2091
+ }
2088
2092
  }
2089
2093
  });
2090
2094
  var MoonPayStepResponseSchema = $stepResponse2;
@@ -103,10 +103,16 @@ export type MoonPayStepRefusal = 'NOT_ELIGIBLE' | 'DOCUMENTS_REQUIRED' | 'FINAL_
103
103
  * assertion's. `UNRECORDABLE`: a charge no retry can record, held for refund review.
104
104
  */
105
105
  export type MoonPayOrderRefusal = 'CUSTOMER_MISMATCH' | 'WALLET_MISMATCH' | 'UNRECORDABLE';
106
- /** A reason on one field of a `KYC` response. `fieldId` names a field in that response. */
106
+ /** Another MoonPay customer already holds the value; only a different one goes through. */
107
+ export type MoonPayFieldErrorCode = 'PHONE_IN_USE' | 'TAX_ID_IN_USE';
108
+ /**
109
+ * A reason on one field of a `KYC` response. `fieldId` names a field in that response. `code` is set
110
+ * only for a refusal the client words itself: `PHONE_IN_USE` on `PHONE_NUMBER`, `TAX_ID_IN_USE` on `TAX_IDENTIFIER`.
111
+ */
107
112
  export interface MoonPayFieldError {
108
113
  fieldId: string;
109
114
  message: string;
115
+ code?: MoonPayFieldErrorCode;
110
116
  }
111
117
  /** The answer to `observe` and `kyc`. */
112
118
  export type MoonPayStepResponse =
@@ -116,11 +122,15 @@ export type MoonPayStepResponse =
116
122
  stage: TermsStage;
117
123
  documents: TermsDocument[];
118
124
  }
119
- /** Run the MoonPay connection check with `sessionToken`, then `observe` with the credentials. */
125
+ /**
126
+ * Run the MoonPay connection check with `sessionToken`, then `observe` with the credentials.
127
+ * `resetConnection`: the device's connection is another buyer's, so reset it before the check.
128
+ */
120
129
  | {
121
130
  status: 'SDK_AUTH';
122
131
  sessionToken: string;
123
132
  quoteInput: MoonPayQuoteInput;
133
+ resetConnection?: true;
124
134
  }
125
135
  /** Show the shared form, then send `kyc`. */
126
136
  | {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  MOONPAY_ENDPOINTS
3
- } from "../chunk-I63WALQK.mjs";
3
+ } from "../chunk-3HCZ6JBJ.mjs";
4
4
  export {
5
5
  MOONPAY_ENDPOINTS
6
6
  };
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.22.1";
39
+ var version = "0.22.2";
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-PP6S7FSJ.mjs";
14
+ } from "./chunk-DTHUNDA7.mjs";
15
15
  export {
16
16
  DOCUMENTED_ENDPOINTS,
17
17
  STATE_KEYS,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fun-xyz/fiat-contract",
3
- "version": "0.22.1",
3
+ "version": "0.22.2",
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": {