@andco/protocol 0.0.11 → 0.0.12

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.
Files changed (120) hide show
  1. package/dist/api-errors.d.ts +5 -128
  2. package/dist/api-errors.d.ts.map +1 -1
  3. package/dist/api-errors.js +5 -131
  4. package/dist/authorization-preparation.d.ts +3 -3
  5. package/dist/authorization-preparation.d.ts.map +1 -1
  6. package/dist/authorization-preparation.js +4 -0
  7. package/dist/authorization.js +2 -2
  8. package/dist/errors.d.ts +52 -16
  9. package/dist/errors.d.ts.map +1 -1
  10. package/dist/errors.js +52 -12
  11. package/dist/index.d.ts +1 -0
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +1 -0
  14. package/dist/intent-input.d.ts +1791 -725
  15. package/dist/intent-input.d.ts.map +1 -1
  16. package/dist/intent-input.js +325 -157
  17. package/dist/issues.d.ts +61 -0
  18. package/dist/issues.d.ts.map +1 -0
  19. package/dist/issues.js +61 -0
  20. package/dist/messages/index.d.ts +2 -2
  21. package/dist/messages/index.d.ts.map +1 -1
  22. package/dist/messages/index.js +10 -3
  23. package/dist/messages/set-preferences.d.ts +13 -1
  24. package/dist/messages/set-preferences.d.ts.map +1 -1
  25. package/dist/messages/set-preferences.js +31 -9
  26. package/dist/miniapp-manifest.d.ts +2 -2
  27. package/dist/miniapp-manifest.d.ts.map +1 -1
  28. package/dist/miniapp-manifest.js +1 -1
  29. package/dist/native-intent.d.ts +48 -28
  30. package/dist/native-intent.d.ts.map +1 -1
  31. package/dist/native-intent.js +76 -24
  32. package/dist/pagination.d.ts +37 -31
  33. package/dist/pagination.d.ts.map +1 -1
  34. package/dist/pagination.js +72 -24
  35. package/dist/rar/account-matchers.d.ts +47 -240
  36. package/dist/rar/account-matchers.d.ts.map +1 -1
  37. package/dist/rar/account-matchers.js +52 -131
  38. package/dist/rar/bank.d.ts +280 -392
  39. package/dist/rar/bank.d.ts.map +1 -1
  40. package/dist/rar/bank.js +68 -137
  41. package/dist/rar/catalog.d.ts +305 -288
  42. package/dist/rar/catalog.d.ts.map +1 -1
  43. package/dist/rar/catalog.js +69 -29
  44. package/dist/rar/detail.d.ts +15 -32
  45. package/dist/rar/detail.d.ts.map +1 -1
  46. package/dist/rar/detail.js +14 -34
  47. package/dist/rar/index.d.ts +2 -1
  48. package/dist/rar/index.d.ts.map +1 -1
  49. package/dist/rar/index.js +2 -1
  50. package/dist/rar/json-schemas.generated.d.ts +4 -0
  51. package/dist/rar/json-schemas.generated.d.ts.map +1 -0
  52. package/dist/rar/json-schemas.generated.js +3570 -0
  53. package/dist/rar/money.d.ts +5 -5
  54. package/dist/rar/money.d.ts.map +1 -1
  55. package/dist/rar/money.js +5 -5
  56. package/dist/rar/project-users.d.ts +40 -14
  57. package/dist/rar/project-users.d.ts.map +1 -1
  58. package/dist/rar/project-users.js +20 -23
  59. package/dist/rar/subject-data.d.ts +96 -48
  60. package/dist/rar/subject-data.d.ts.map +1 -1
  61. package/dist/rar/subject-data.js +61 -34
  62. package/dist/rar/subject.d.ts +18 -85
  63. package/dist/rar/subject.d.ts.map +1 -1
  64. package/dist/rar/subject.js +23 -51
  65. package/dist/rest/accounts.d.ts +347 -0
  66. package/dist/rest/accounts.d.ts.map +1 -0
  67. package/dist/rest/accounts.js +108 -0
  68. package/dist/rest/addresses.d.ts +581 -0
  69. package/dist/rest/addresses.d.ts.map +1 -0
  70. package/dist/rest/addresses.js +190 -0
  71. package/dist/rest/api-error.d.ts +104 -0
  72. package/dist/rest/api-error.d.ts.map +1 -0
  73. package/dist/rest/api-error.js +103 -0
  74. package/dist/rest/authorization.d.ts +123 -0
  75. package/dist/rest/authorization.d.ts.map +1 -0
  76. package/dist/rest/authorization.js +62 -0
  77. package/dist/rest/catalog.d.ts +199 -0
  78. package/dist/rest/catalog.d.ts.map +1 -0
  79. package/dist/rest/catalog.js +63 -0
  80. package/dist/rest/common.d.ts +637 -0
  81. package/dist/rest/common.d.ts.map +1 -0
  82. package/dist/rest/common.js +172 -0
  83. package/dist/rest/contract.d.ts +3480 -0
  84. package/dist/rest/contract.d.ts.map +1 -0
  85. package/dist/rest/contract.js +120 -0
  86. package/dist/rest/events.d.ts +145 -0
  87. package/dist/rest/events.d.ts.map +1 -0
  88. package/dist/rest/events.js +42 -0
  89. package/dist/rest/http.d.ts +49 -0
  90. package/dist/rest/http.d.ts.map +1 -0
  91. package/dist/rest/http.js +25 -0
  92. package/dist/rest/identity.d.ts +627 -0
  93. package/dist/rest/identity.d.ts.map +1 -0
  94. package/dist/rest/identity.js +128 -0
  95. package/dist/rest/index.d.ts +14 -0
  96. package/dist/rest/index.d.ts.map +1 -0
  97. package/dist/rest/index.js +13 -0
  98. package/dist/rest/intents.d.ts +4556 -0
  99. package/dist/rest/intents.d.ts.map +1 -0
  100. package/dist/rest/intents.js +551 -0
  101. package/dist/rest/signatures.d.ts +110 -0
  102. package/dist/rest/signatures.d.ts.map +1 -0
  103. package/dist/rest/signatures.js +113 -0
  104. package/dist/rest/subjects.d.ts +14 -0
  105. package/dist/rest/subjects.d.ts.map +1 -0
  106. package/dist/rest/subjects.js +22 -0
  107. package/dist/service-grants.d.ts +2 -2
  108. package/dist/service-grants.d.ts.map +1 -1
  109. package/dist/service-grants.js +1 -1
  110. package/dist/transport/generated/oauth-api.d.ts +5547 -1448
  111. package/dist/transport/generated/oauth-api.d.ts.map +1 -1
  112. package/dist/transport/intents.d.ts +9 -134
  113. package/dist/transport/intents.d.ts.map +1 -1
  114. package/dist/transport/intents.js +21 -405
  115. package/dist/transport/rest.d.ts +15 -5
  116. package/dist/transport/rest.d.ts.map +1 -1
  117. package/dist/userinfo.d.ts +22 -9
  118. package/dist/userinfo.d.ts.map +1 -1
  119. package/dist/userinfo.js +17 -12
  120. package/package.json +13 -2
@@ -1,16 +1,12 @@
1
1
  import * as v from "valibot";
2
2
  import { ANDCO_API_ORIGIN } from "./constants.js";
3
+ import { parseWithRules } from "./issues.js";
3
4
  import { AccountKeySchema } from "./rar/account-matchers.js";
4
5
  import { MoneySchema } from "./rar/money.js";
5
6
  const text = (max) => v.pipe(v.string(), v.trim(), v.minLength(1), v.maxLength(max));
7
+ /** A person's or an account's name, trimmed and never blank. Its length is a rule, in code points. */
8
+ const nameText = /* @__PURE__ */ v.pipe(v.string(), v.trim(), v.minLength(1));
6
9
  const accountId = /* @__PURE__ */ v.pipe(v.string(), v.uuid());
7
- // The regex ceiling of `MoneySchema` (15 digits) already keeps `Number(value)` inside
8
- // `Number.isSafeInteger` range, so this check can no longer reject anything the regex accepts.
9
- // Kept anyway as cheap defense in depth: valibot is the only gate this scalar passes through here
10
- // (unlike the JSON Schema mirrors of the RAR types, which have nowhere to hang a numeric check),
11
- // so a future edit to the regex that reintroduces the gap fails safely at this check instead of
12
- // silently shipping an unsafe integer.
13
- const amountValue = /* @__PURE__ */ v.pipe(MoneySchema, v.check((value) => Number.isSafeInteger(Number(value))));
14
10
  /**
15
11
  * The amount a deposit asks for: `value` is the number, and `editable: true` lets the payer change
16
12
  * it on the screen. It is never what moved; an answered Intent says that apart (`progress.credited`).
@@ -18,11 +14,11 @@ const amountValue = /* @__PURE__ */ v.pipe(MoneySchema, v.check((value) => Numbe
18
14
  * @example
19
15
  * const amount = { currency: "CLP", value: "40000", editable: true };
20
16
  */
21
- const depositAmount = {
17
+ export const IntentAmountSchema = /* @__PURE__ */ v.pipe(v.strictObject({
22
18
  currency: v.literal("CLP"),
23
- value: amountValue,
24
- editable: v.optional(v.boolean(), false),
25
- };
19
+ value: MoneySchema,
20
+ editable: v.pipe(v.optional(v.boolean(), false), v.description("Defaults to false when omitted.")),
21
+ }), v.description("The amount a deposit asks for. `editable: true` lets the payer change it on the screen. It is never what moved: a deposit answers that in `progress.credited`."));
26
22
  /**
27
23
  * The amount a transfer proposes. `editable: true` lets the person who confirms set the amount on
28
24
  * Andco's confirmation screen, and `value` is the initial proposal shown there; the server checks it
@@ -32,18 +28,31 @@ const depositAmount = {
32
28
  * @example
33
29
  * const amount = { currency: "CLP", value: "40000", editable: true };
34
30
  */
35
- const transferAmount = {
31
+ export const TransferAmountProposalSchema = /* @__PURE__ */ v.pipe(v.strictObject({
36
32
  currency: v.literal("CLP"),
37
- value: amountValue,
38
- editable: v.optional(v.boolean(), false),
39
- };
33
+ value: MoneySchema,
34
+ editable: v.pipe(v.optional(v.boolean(), false), v.description("Defaults to false when omitted.")),
35
+ }), v.description("The amount a transfer proposes. `editable: true` lets the person who confirms set the amount on Andco's confirmation screen, and `value` is the initial proposal shown there; the amount must fall within the Grant's `transactions.minimum` and `transactions.maximum` and not exceed the available balance. Without `editable` (or with `false`) the amount is locked. What moved is `settled`."));
40
36
  /**
41
37
  * The amount a Signed Instruction orders: the same `{ currency, value }` as a request, with nothing
42
38
  * left for a person to change, so there is no `editable`.
43
39
  */
44
- const signedAmount = { currency: v.literal("CLP"), value: amountValue };
45
- /** A note's text: trimmed, and at most 140 Unicode code points, the way PostgreSQL counts them. */
46
- const noteText = /* @__PURE__ */ v.pipe(v.string(), v.trim(), v.check((value) => [...value].length <= 140, "note_too_long"));
40
+ export const SignedAmountSchema = /* @__PURE__ */ v.pipe(v.strictObject({ currency: v.literal("CLP"), value: MoneySchema }), v.description("The amount a Signed Instruction orders: the same `{ currency, value }` as a request, with nothing left for a person to change."));
41
+ // `MoneySchema`'s pattern is the whole bound of an amount: at most 15 digits, which also keeps every
42
+ // value inside `Number.MAX_SAFE_INTEGER` for whoever converts it. JSON Schema says the same pattern,
43
+ // so no numeric check sits on top, and an amount never goes through `Number()` here.
44
+ /** A note's text, trimmed. Its length is a rule ({@link NOTE_MAX_LENGTH}), counted in code points. */
45
+ const noteText = /* @__PURE__ */ v.pipe(v.string(), v.trim());
46
+ /**
47
+ * The bank reference a request asks for. `editable: true` lets the person who confirms change it.
48
+ *
49
+ * @example
50
+ * const note = { value: "Factura 42", editable: true };
51
+ */
52
+ export const IntentNoteSchema = /* @__PURE__ */ v.pipe(v.strictObject({
53
+ value: v.pipe(noteText, v.description("Trimmed bank reference. An empty reference is allowed.")),
54
+ editable: v.pipe(v.optional(v.boolean(), false), v.description("Defaults to false when omitted.")),
55
+ }), v.description("The bank reference a request asks for. `editable: true` lets the person who confirms change it; each bank operation freezes its own final note at confirmation."));
47
56
  /**
48
57
  * The account a transfer names, in the vocabulary of the `bank_transfer` matchers it has to fit:
49
58
  * `{ type: "account_key", accountKey }` and `{ type: "account", id }` name one Andco account, and
@@ -65,8 +74,14 @@ const transferExternal = {
65
74
  account_type: /* @__PURE__ */ v.picklist(["checking", "debit", "savings"]),
66
75
  account_id: text(64),
67
76
  holder_id: text(64),
68
- holder_name: text(256),
77
+ holder_name: /* @__PURE__ */ v.pipe(nameText, v.description("The holder's name, at most 256 code points (`holder_name_too_long`).")),
69
78
  };
79
+ /** One Andco account of the Grant's subject, named by its Account Key. */
80
+ export const IntentAccountKeySchema = /* @__PURE__ */ v.pipe(v.strictObject(transferAccountKey), v.description("One Andco account of the Grant's subject, named by its Account Key."));
81
+ /** One Andco account, named by its identifier. */
82
+ export const IntentAccountIdSchema = /* @__PURE__ */ v.pipe(v.strictObject(transferAccount), v.description("One Andco account, named by its identifier."));
83
+ /** One account at another Chilean bank, with every field a `bank_transfer` `external` matcher can fix. */
84
+ export const IntentAccountExternalSchema = /* @__PURE__ */ v.pipe(v.strictObject(transferExternal), v.description("One account at another Chilean bank, with every field a `bank_transfer` `external` matcher can fix, so the Grant's destinations are asked about exactly this account."));
70
85
  /**
71
86
  * One Andco account of the Grant's subject, named by Account Key or by identifier: where a
72
87
  * transfer's money leaves from, where a deposit lands, and the account a closure closes.
@@ -74,31 +89,32 @@ const transferExternal = {
74
89
  * @example
75
90
  * const account: IntentAccount = { type: "account_key", accountKey: "ventas" };
76
91
  */
77
- const andcoAccount = /* @__PURE__ */ v.variant("type", [
78
- v.strictObject(transferAccountKey),
79
- v.strictObject(transferAccount),
80
- ]);
92
+ export const IntentAccountSchema = /* @__PURE__ */ v.pipe(v.variant("type", [IntentAccountKeySchema, IntentAccountIdSchema]), v.description('One Andco account of the Grant\'s subject, in the account matcher vocabulary: by Account Key (`{ type: "account_key", accountKey }`) or by identifier (`{ type: "account", id }`). It is where a transfer\'s money leaves from, where a deposit lands and the account a closure closes. An AccountKey is answered back as an AccountKey: it resolves to an account at execution.'));
93
+ const andcoAccount = IntentAccountSchema;
81
94
  /** Where a transfer's money leaves from: always an Andco account of the Grant's subject. */
82
95
  const transferSource = andcoAccount;
83
96
  /** Where a signed transfer's money lands: nothing on this path is left for a person to complete. */
84
- const signedTransferDestination = /* @__PURE__ */ v.variant("type", [
85
- v.strictObject(transferAccountKey),
86
- v.strictObject(transferAccount),
87
- v.strictObject(transferExternal),
88
- ]);
97
+ export const TransferDestinationSchema = /* @__PURE__ */ v.pipe(v.variant("type", [IntentAccountKeySchema, IntentAccountIdSchema, IntentAccountExternalSchema]), v.description("Where a signed transfer's money lands, in the `bank_transfer` matcher vocabulary: an Andco account by AccountKey or identifier, or an account at another Chilean bank."));
98
+ const signedTransferDestination = TransferDestinationSchema;
89
99
  /**
90
- * Where a proposed transfer's money lands, always locked on the confirmation screen. `editable`
91
- * only accepts `false`: redirecting a transfer at confirmation is not implemented yet (TODO), so
92
- * `editable: true` is an `invalid_request` at creation instead of an Intent nobody can confirm.
100
+ * Where a proposed transfer's money lands when the request names it: locked on the confirmation
101
+ * screen, which shows it and lets the person confirm it or not. `editable` only accepts `false`: a
102
+ * named destination is never redirected at confirmation, so `editable: true` is an `invalid_request`
103
+ * at creation. To let the person choose where the money goes, leave the destination out with `null`
104
+ * (see {@link IntentCreateSchema}).
93
105
  */
94
106
  const lockedDestination = { editable: /* @__PURE__ */ v.optional(v.literal(false), false) };
95
- const proposedTransferDestination = /* @__PURE__ */ v.variant("type", [
107
+ export const TransferDestinationProposalSchema = /* @__PURE__ */ v.pipe(v.variant("type", [
96
108
  v.strictObject({ ...transferAccountKey, ...lockedDestination }),
97
109
  v.strictObject({ ...transferAccount, ...lockedDestination }),
98
110
  v.strictObject({ ...transferExternal, ...lockedDestination }),
99
- ]);
100
- /** The display label a Cuenta Vista is opened with. Mutable afterwards, and read by no permission. */
101
- const accountName = /* @__PURE__ */ v.pipe(v.string(), v.trim(), v.minLength(1), v.maxLength(80));
111
+ ]), v.description("Where a transfer's money lands when it is named, in the request and in the answered Intent alike. A named destination is always locked on the confirmation screen: `editable` only admits `false`, and `editable: true` fails at creation with `invalid_request`. To let the person choose where the money goes, the request says `destination: null` instead (`TransferIntentCreate`). Defaults to false in a request; an answered Intent always states it, including a destination the person completed on the screen, which is locked once she confirms."));
112
+ const proposedTransferDestination = TransferDestinationProposalSchema;
113
+ /**
114
+ * The display label a Cuenta Vista is opened with. Mutable afterwards, and read by no permission. Its
115
+ * length is a rule ({@link ACCOUNT_NAME_MAX_LENGTH}), counted in code points.
116
+ */
117
+ const accountName = nameText;
102
118
  /** Validates fixed-duration syntax without anchoring it to a changing clock. */
103
119
  export function isIntentDuration(value) {
104
120
  const match = /^([1-9][0-9]*)\s+(seconds?|minutes?|hours?|days?)$/.exec(value.trim());
@@ -119,16 +135,58 @@ export function isIntentDeadline(value) {
119
135
  Number.isFinite(midnight.getTime()) &&
120
136
  midnight.toISOString().slice(0, 10) === date);
121
137
  }
122
- const expiresIn = /* @__PURE__ */ v.pipe(v.string(), v.check(isIntentDuration, "invalid_expiration_interval"));
123
- const expiresAt = /* @__PURE__ */ v.pipe(v.string(), v.check(isIntentDeadline, "invalid_expiration_datetime"));
138
+ const expiresIn = /* @__PURE__ */ v.string();
139
+ const expiresAt = /* @__PURE__ */ v.string();
124
140
  // `null` is an explicit "never expires": a transfer and an account opening accept it, signed or not.
125
141
  const expiresAtOrNever = /* @__PURE__ */ v.nullable(expiresAt);
142
+ // The member an object leaves out: present, it is refused (JSON Schema's `not: {}`); `undefined` counts as absent.
143
+ const absent = /* @__PURE__ */ v.optional(v.never());
144
+ /**
145
+ * Exactly one of `expires_in` and `expires_at`, said in the shape: the object with the duration
146
+ * refuses a deadline and the one with the deadline refuses a duration, so neither and both fail
147
+ * alike, in any order, and JSON Schema reads it as a `oneOf`.
148
+ */
149
+ /* @__NO_SIDE_EFFECTS__ */
150
+ function withOneExpiration(entries, deadline) {
151
+ return v.variant("expires_in", [
152
+ v.strictObject({ ...entries, expires_in: expiresIn, expires_at: absent }),
153
+ v.strictObject({ ...entries, expires_in: absent, expires_at: deadline }),
154
+ ]);
155
+ }
126
156
  const common = {
127
- expires_in: v.optional(expiresIn),
128
- expires_at: v.optional(expiresAt),
129
- note: v.optional(v.strictObject({ value: noteText, editable: v.optional(v.boolean(), false) })),
157
+ note: v.optional(IntentNoteSchema),
130
158
  metadata: v.optional(v.record(v.string(), v.unknown()), {}),
131
159
  };
160
+ /** A proposal to collect money into an account of the Grant's subject. See {@link IntentCreateSchema}. */
161
+ export const DepositIntentCreateSchema = /* @__PURE__ */ v.pipe(withOneExpiration({
162
+ ...common,
163
+ type: v.literal("deposit"),
164
+ destination: v.pipe(v.optional(andcoAccount), v.description("The account of the Grant's subject the money lands on. Omitted, the Grant's `bank_deposit` destinations must admit exactly one active account, or the request fails with `deposit_destination_ambiguous`; named, it must be one of them, or the request fails with `invalid_destination`.")),
165
+ amount: v.optional(IntentAmountSchema),
166
+ }, expiresAtOrNever), v.description("The `application/json` half of collecting money into an account of the Grant's subject: an Intent born waiting for a payer. Exactly one of `expires_in` and `expires_at`; `expires_at: null` (never expires) only when `amount` is omitted."));
167
+ /** A proposal to move money, born waiting for an Approval. See {@link IntentCreateSchema}. */
168
+ export const TransferIntentCreateSchema = /* @__PURE__ */ v.pipe(withOneExpiration({
169
+ ...common,
170
+ type: v.literal("transfer"),
171
+ amount: TransferAmountProposalSchema,
172
+ // Null or omitted: the person picks among the Grant's sources on the confirmation screen.
173
+ source: v.pipe(v.optional(v.nullable(transferSource), null), v.description("The Andco account the money leaves. Null leaves that choice to a person on a screen.")),
174
+ // Null or omitted: the person completes where the money goes on the confirmation screen, within
175
+ // the Grant's destinations. A named one is locked there.
176
+ destination: v.pipe(v.optional(v.nullable(proposedTransferDestination), null), v.description("Where the money lands. Null leaves it to a person on the screen, within the Grant's destinations.")),
177
+ }, expiresAtOrNever), v.description("The `application/json` half of creating a transfer: an Intent born waiting for an Approval. A null `source` is the confirmation screen, where a person picks the account the money leaves from among the Grant's sources, and a null `destination` is the screen too: the person completes where the money goes (the bank, the type and number of the account, and its holder's RUT and name), and the server checks what she wrote against the Grant's `destinations` when she confirms, refusing one outside them with `invalid_destination`. Both default to null when omitted. A destination the request names is locked on the screen (`editable: true` is an `invalid_request`), and the amount is too unless `amount.editable` is true, in which case the person sets it. The `application/jwt` half is `SignedTransferIntentClaims`, and the two are separate schemas rather than one with optional fields on purpose: when signed and unsigned members share an object, something eventually reads the wrong ones."));
178
+ /** A proposal to open a Cuenta Vista, born waiting for an Approval. See {@link IntentCreateSchema}. */
179
+ export const AccountOpeningIntentCreateSchema = /* @__PURE__ */ v.pipe(withOneExpiration({
180
+ ...common,
181
+ type: v.literal("account_opening"),
182
+ // The holder's own name for the account, unique per subject (ADR 0028) and never reused once
183
+ // the account closes.
184
+ accountKey: AccountKeySchema,
185
+ name: v.pipe(v.optional(accountName), v.description("The display label the account opens with. Mutable afterwards, and read by no permission.")),
186
+ upsert: v.pipe(v.optional(v.boolean(), false), v.description("Whether naming an AccountKey that already exists answers with that account instead of failing. It defaults to false, so one name never quietly becomes two accounts.")),
187
+ }, expiresAtOrNever), v.description("The `application/json` half of opening a Cuenta Vista: an Intent born waiting for an Approval. `/accounts` has no `POST` because everything with banking consequence happens through an Intent, and an opening carries no amount, no source and no destination -- only the name the account will answer to. Opening is asynchronous: the answer is the Intent and its status, and the Número de Cuenta arrives on the account's event stream."));
188
+ /** A proposal to close a Cuenta Vista, born waiting for an Approval. See {@link IntentCreateSchema}. */
189
+ export const AccountClosureIntentCreateSchema = /* @__PURE__ */ v.pipe(withOneExpiration({ ...common, type: v.literal("account_closure"), account: andcoAccount }, expiresAt), v.description("The `application/json` half of closing a Cuenta Vista: an Intent born waiting for an Approval. `/accounts` has no `DELETE` because everything with banking consequence happens through an Intent. It carries no amount, no source and no destination -- only a reference to the account it closes."));
132
190
  /**
133
191
  * Public creation validation shared by the API and SDK. SQL resolves deadlines and enforces authorization.
134
192
  *
@@ -140,70 +198,181 @@ const common = {
140
198
  *
141
199
  * `transfer` is the only way money movement is expressed: money leaving an account towards a
142
200
  * `destination`, both named in the `bank_transfer` matcher vocabulary (`account_key`, `account`,
143
- * `external`). A null `source` is the confirmation screen's source picker; the destination is always
144
- * locked there (`editable: true` is refused), and so is the amount unless it says `editable: true`, in
145
- * which case the person sets it. Who may approve the Intent without a person belongs to the Grant, never to
201
+ * `external`). A null `source` is the confirmation screen's source picker, and a null `destination` is
202
+ * the screen's destination form: the person completes where the money goes (another bank's account, or
203
+ * another Andco customer's), and the server checks what she wrote against the Grant's `destinations`
204
+ * when she confirms. Both are the screen's when omitted. A destination the request does name is locked
205
+ * there (`editable: true` is refused), and so is the amount unless it says `editable: true`, in which
206
+ * case the person sets it. Who may approve the Intent without a person belongs to the Grant, never to
146
207
  * the operation itself.
147
208
  *
148
209
  * @example
149
- * safeParseIntentCreate({
210
+ * parseIntentInput({
150
211
  * type: "transfer", expires_in: "30 minutes", source: null,
151
212
  * destination: { type: "account_key", accountKey: "proveedores" },
152
213
  * amount: { currency: "CLP", value: "40000" },
153
214
  * note: { value: "Factura 42", editable: true },
154
215
  * });
155
216
  *
217
+ * @example
218
+ * // The person picks both accounts on Andco's confirmation screen.
219
+ * parseIntentInput({
220
+ * type: "transfer", expires_in: "30 minutes", source: null, destination: null,
221
+ * amount: { currency: "CLP", value: "40000", editable: true },
222
+ * });
223
+ *
156
224
  * `account_opening` is here for the same reason money movement is: everything with banking
157
225
  * consequence happens through an Intent, so `/accounts` has no `POST`. It carries no amount, no
158
226
  * source and no destination — only the name the account will answer to, and whether naming one that
159
227
  * already exists is an error or a request for the account that is already there.
160
228
  */
161
- export const IntentCreateSchema = /* @__PURE__ */ v.pipe(v.variant("type", [
162
- v.strictObject({
163
- ...common,
164
- type: v.literal("deposit"),
165
- destination: v.optional(andcoAccount),
166
- amount: v.optional(v.strictObject(depositAmount)),
167
- expires_at: v.optional(expiresAtOrNever),
168
- }),
169
- v.strictObject({
170
- ...common,
171
- type: v.literal("transfer"),
172
- expires_at: v.optional(expiresAtOrNever),
173
- amount: v.strictObject(transferAmount),
174
- // Null or omitted: the person picks among the Grant's sources on the confirmation screen.
175
- source: v.optional(v.nullable(transferSource), null),
176
- destination: proposedTransferDestination,
177
- }),
178
- v.strictObject({
179
- ...common,
180
- type: v.literal("account_opening"),
181
- expires_at: v.optional(expiresAtOrNever),
182
- // The holder's own name for the account, unique per subject (ADR 0028) and never reused once
183
- // the account closes.
184
- accountKey: AccountKeySchema,
185
- name: v.optional(accountName),
186
- upsert: v.optional(v.boolean(), false),
187
- }),
188
- v.strictObject({
189
- ...common,
190
- type: v.literal("account_closure"),
191
- account: andcoAccount,
192
- }),
193
- ]), v.check((input) => (input.expires_in !== undefined) !== (input.expires_at !== undefined), "exactly_one_expiration_required"), v.check(
194
- // Only a deposit with a target must expire; for a transfer or an account opening `null` means "never".
195
- (input) => input.type !== "deposit" || input.expires_at !== null || input.amount === undefined, "passive_deposit_requires_no_target"), v.check((input) => JSON.stringify(input.metadata).length <= 16384, "metadata_too_large"));
196
- /** Returns validation issues without throwing across the HTTP boundary. */
197
- export function safeParseIntentCreate(input) {
198
- return v.safeParse(IntentCreateSchema, input);
229
+ export const IntentCreateSchema = /* @__PURE__ */ v.variant("type", [
230
+ DepositIntentCreateSchema,
231
+ TransferIntentCreateSchema,
232
+ AccountOpeningIntentCreateSchema,
233
+ AccountClosureIntentCreateSchema,
234
+ ]);
235
+ /** The longest note, in Unicode code points: what PostgreSQL and JSON Schema's `maxLength` count. */
236
+ export const NOTE_MAX_LENGTH = 140;
237
+ /** The longest reason of a Cancellation or a Rejection, in Unicode code points. */
238
+ export const REASON_MAX_LENGTH = 280;
239
+ /** The longest name of an account, in Unicode code points. */
240
+ export const ACCOUNT_NAME_MAX_LENGTH = 80;
241
+ /** The longest name of an external account's holder, in Unicode code points. */
242
+ export const HOLDER_NAME_MAX_LENGTH = 256;
243
+ /** The largest `metadata`, in characters of its JSON. */
244
+ export const METADATA_MAX_LENGTH = 16384;
245
+ /** Counts Unicode code points, not UTF-16 units: an emoji is one, as PostgreSQL counts it. */
246
+ function codePoints(value) {
247
+ return [...value].length;
248
+ }
249
+ function expirationIssues(input) {
250
+ const issues = [];
251
+ if (input.expires_in !== undefined && !isIntentDuration(input.expires_in)) {
252
+ issues.push({ type: "invalid_expiration_interval", path: [{ key: "expires_in" }], requirement: undefined });
253
+ }
254
+ if (typeof input.expires_at === "string" && !isIntentDeadline(input.expires_at)) {
255
+ issues.push({ type: "invalid_expiration_datetime", path: [{ key: "expires_at" }], requirement: undefined });
256
+ }
257
+ return issues;
258
+ }
259
+ function noteIssues(note, path) {
260
+ if (note === undefined || codePoints(note) <= NOTE_MAX_LENGTH)
261
+ return [];
262
+ return [{ type: "note_too_long", path, requirement: NOTE_MAX_LENGTH }];
263
+ }
264
+ function nameIssues(input) {
265
+ const issues = [];
266
+ if (input.type === "account_opening" &&
267
+ input.name !== undefined &&
268
+ codePoints(input.name) > ACCOUNT_NAME_MAX_LENGTH) {
269
+ issues.push({ type: "name_too_long", path: [{ key: "name" }], requirement: ACCOUNT_NAME_MAX_LENGTH });
270
+ }
271
+ if (input.type === "transfer")
272
+ issues.push(...holderNameIssues(input.destination));
273
+ return issues;
274
+ }
275
+ function holderNameIssues(destination) {
276
+ if (destination?.holder_name === undefined || codePoints(destination.holder_name) <= HOLDER_NAME_MAX_LENGTH) {
277
+ return [];
278
+ }
279
+ const path = [{ key: "destination" }, { key: "holder_name" }];
280
+ return [{ type: "holder_name_too_long", path, requirement: HOLDER_NAME_MAX_LENGTH }];
281
+ }
282
+ function metadataIssues(metadata) {
283
+ if (JSON.stringify(metadata).length <= METADATA_MAX_LENGTH)
284
+ return [];
285
+ return [{ type: "metadata_too_large", path: [{ key: "metadata" }], requirement: METADATA_MAX_LENGTH }];
286
+ }
287
+ /**
288
+ * The rules of an Intent proposal that JSON Schema does not say, over an input that already has its
289
+ * shape ({@link IntentCreateSchema}). Each issue carries its public code in `type`:
290
+ *
291
+ * - `invalid_expiration_interval`: `expires_in` is not a whole number of seconds, minutes, hours or days.
292
+ * - `invalid_expiration_datetime`: `expires_at` is not a real calendar datetime with a timezone.
293
+ * - `note_too_long`: the note has more than {@link NOTE_MAX_LENGTH} code points.
294
+ * - `name_too_long`: an account opening's `name` has more than {@link ACCOUNT_NAME_MAX_LENGTH} code points.
295
+ * - `holder_name_too_long`: an external destination's `holder_name` has more than
296
+ * {@link HOLDER_NAME_MAX_LENGTH} code points.
297
+ * - `passive_deposit_requires_no_target`: a deposit that never expires names an amount; only a
298
+ * deposit with a target must expire.
299
+ * - `metadata_too_large`: `metadata` is longer than {@link METADATA_MAX_LENGTH} characters of JSON.
300
+ *
301
+ * @example
302
+ * const shaped = v.safeParse(IntentCreateSchema, input);
303
+ * if (shaped.success) console.log(intentInputIssues(shaped.output).map((issue) => issue.type));
304
+ */
305
+ export function intentInputIssues(input) {
306
+ const issues = expirationIssues(input);
307
+ issues.push(...noteIssues(input.note?.value, [{ key: "note" }, { key: "value" }]));
308
+ issues.push(...nameIssues(input));
309
+ if (input.type === "deposit" && input.expires_at === null && input.amount !== undefined) {
310
+ issues.push({ type: "passive_deposit_requires_no_target", path: undefined, requirement: undefined });
311
+ }
312
+ issues.push(...metadataIssues(input.metadata));
313
+ return issues;
199
314
  }
315
+ /**
316
+ * Parses an Intent proposal: its shape ({@link IntentCreateSchema}) and then its rules
317
+ * ({@link intentInputIssues}). The server does the same, so an application only needs this to
318
+ * answer a form before sending; the SDK sends without it.
319
+ *
320
+ * @example
321
+ * const parsed = parseIntentInput({
322
+ * type: "transfer", expires_in: "30 minutes", source: null,
323
+ * destination: { type: "account_key", accountKey: "proveedores" },
324
+ * amount: { currency: "CLP", value: "40000" },
325
+ * note: { value: "Factura 42", editable: true },
326
+ * });
327
+ * if (!parsed.success) console.log(parsed.issues.map((issue) => issue.type)); // e.g. ["note_too_long"]
328
+ */
329
+ export function parseIntentInput(input) {
330
+ return parseWithRules(IntentCreateSchema, intentInputIssues, input);
331
+ }
332
+ const signedEnvelope = {
333
+ iss: text(64),
334
+ aud: /* @__PURE__ */ v.literal(ANDCO_API_ORIGIN),
335
+ jti: /* @__PURE__ */ v.pipe(text(128), v.description("The idempotency key, inside the signature, reused verbatim when retrying.")),
336
+ exp: /* @__PURE__ */ v.pipe(v.number(), v.integer()),
337
+ iat: /* @__PURE__ */ v.optional(v.pipe(v.number(), v.integer())),
338
+ nbf: /* @__PURE__ */ v.optional(v.pipe(v.number(), v.integer())),
339
+ metadata: /* @__PURE__ */ v.optional(v.record(v.string(), v.unknown()), {}),
340
+ };
341
+ /** The verified claims of a Signed Instruction that moves money. See {@link SignedIntentSchema}. */
342
+ export const SignedTransferIntentClaimsSchema = /* @__PURE__ */ v.pipe(withOneExpiration({
343
+ ...signedEnvelope,
344
+ type: v.literal("transfer"),
345
+ source: transferSource,
346
+ destination: signedTransferDestination,
347
+ amount: SignedAmountSchema,
348
+ note: v.pipe(v.optional(noteText), v.description("A plain bank reference; a Signed Instruction proposes nothing.")),
349
+ }, expiresAtOrNever), v.description("The verified claims of a Signed Instruction, sent to the same endpoint as `application/jwt`. Nothing here is optional that the transfer needs and nothing here is editable: an instruction that does not say where the money comes from or where it goes is not signable, so `source` and `destination` are required (and neither may be `null`: there is no screen on this path to complete it) and the amount carries no `editable`. `note` is a plain reference for the same reason -- there is no screen on this path, so there is nobody to propose it to. When a signature is present, every value the transfer uses comes from these claims and none from the envelope carrying them. `exp` bounds how long the instruction may be submitted; `expires_in` or `expires_at` bounds how long the Intent may be approved and executed. They are different deadlines."));
350
+ /** The verified claims of a Signed Instruction that opens an account. See {@link SignedIntentSchema}. */
351
+ export const SignedAccountOpeningIntentClaimsSchema = /* @__PURE__ */ v.pipe(withOneExpiration({
352
+ ...signedEnvelope,
353
+ type: v.literal("account_opening"),
354
+ accountKey: AccountKeySchema,
355
+ name: v.optional(accountName),
356
+ // Inside the signature, never beside it: outside the claims anyone holding the assertion could
357
+ // turn "create this account" into "create it or hand me the one that is already there".
358
+ upsert: v.optional(v.boolean(), false),
359
+ }, expiresAtOrNever), v.description("The verified claims of a Signed Instruction that opens an account. `upsert` lives here and nowhere else: it decides whether naming an AccountKey that already exists is a refusal or a request for the account already carrying it, which is a difference in what the instruction *orders*. Carried as a transport option, anybody holding the signed instruction could flip it, and what executed would not be what was signed."));
360
+ /** The verified claims of a Signed Instruction that closes an account. See {@link SignedIntentSchema}. */
361
+ export const SignedAccountClosureIntentClaimsSchema = /* @__PURE__ */ v.pipe(withOneExpiration({
362
+ ...signedEnvelope,
363
+ type: v.literal("account_closure"),
364
+ // Required and never editable: an instruction that does not say which account it closes is
365
+ // not signable.
366
+ account: andcoAccount,
367
+ }, expiresAt), v.description("The verified claims of a Signed Instruction that closes an account. `account` is required and never editable: an instruction that does not say which account it closes is not signable."));
200
368
  /**
201
369
  * The verified claims of a Signed Instruction: the `application/jwt` half of the same creation.
202
370
  *
203
371
  * Nothing here is optional that the transfer needs and nothing here is editable. An instruction that
204
372
  * does not say where the money comes from or where it goes is not signable, so `source` and
205
- * `destination` are required and the amount carries no `editable`. `note` is a plain reference for
206
- * the same reason: there is no screen on this path, so there is nobody to propose it to.
373
+ * `destination` are required (a `null` for either is refused: there is no screen on this path to
374
+ * complete it) and the amount carries no `editable`. `note` is a plain reference for the same reason:
375
+ * there is nobody to propose it to.
207
376
  *
208
377
  * There is no `org_id`: the subject is the one of the Grant behind the access token that submits the
209
378
  * instruction, and nothing inside the signature may name another.
@@ -220,72 +389,63 @@ export function safeParseIntentCreate(input) {
220
389
  * signed instruction could flip it, and the order executed would not be the order signed.
221
390
  *
222
391
  * @example
223
- * const claims = safeParseSignedIntent(verification.claims);
224
- * if (claims.success) console.log(claims.output.jti, claims.output.amount.value);
392
+ * const claims = parseSignedIntentInput(verification.claims);
393
+ * if (claims.success && claims.output.type === "transfer") console.log(claims.output.jti, claims.output.amount.value);
225
394
  */
226
- export const SignedIntentSchema = /* @__PURE__ */ v.pipe(v.variant("type", [
227
- v.strictObject({
228
- iss: text(64),
229
- aud: v.literal(ANDCO_API_ORIGIN),
230
- jti: text(128),
231
- exp: v.pipe(v.number(), v.integer()),
232
- iat: v.optional(v.pipe(v.number(), v.integer())),
233
- nbf: v.optional(v.pipe(v.number(), v.integer())),
234
- type: v.literal("transfer"),
235
- source: transferSource,
236
- destination: signedTransferDestination,
237
- amount: v.strictObject(signedAmount),
238
- expires_in: v.optional(expiresIn),
239
- expires_at: v.optional(expiresAtOrNever),
240
- note: v.optional(noteText),
241
- metadata: v.optional(v.record(v.string(), v.unknown()), {}),
242
- }),
243
- v.strictObject({
244
- iss: text(64),
245
- aud: v.literal(ANDCO_API_ORIGIN),
246
- jti: text(128),
247
- exp: v.pipe(v.number(), v.integer()),
248
- iat: v.optional(v.pipe(v.number(), v.integer())),
249
- nbf: v.optional(v.pipe(v.number(), v.integer())),
250
- type: v.literal("account_opening"),
251
- accountKey: AccountKeySchema,
252
- name: v.optional(accountName),
253
- // Inside the signature, never beside it: outside the claims anyone holding the assertion could
254
- // turn "create this account" into "create it or hand me the one that is already there".
255
- upsert: v.optional(v.boolean(), false),
256
- expires_in: v.optional(expiresIn),
257
- expires_at: v.optional(expiresAtOrNever),
258
- metadata: v.optional(v.record(v.string(), v.unknown()), {}),
259
- }),
260
- v.strictObject({
261
- iss: text(64),
262
- aud: v.literal(ANDCO_API_ORIGIN),
263
- jti: text(128),
264
- exp: v.pipe(v.number(), v.integer()),
265
- iat: v.optional(v.pipe(v.number(), v.integer())),
266
- nbf: v.optional(v.pipe(v.number(), v.integer())),
267
- type: v.literal("account_closure"),
268
- // Required and never editable: an instruction that does not say which account it closes is
269
- // not signable.
270
- account: andcoAccount,
271
- expires_in: v.optional(expiresIn),
272
- expires_at: v.optional(expiresAt),
273
- metadata: v.optional(v.record(v.string(), v.unknown()), {}),
274
- }),
275
- ]), v.check((input) => (input.expires_in !== undefined) !== (input.expires_at !== undefined), "exactly_one_expiration_required"), v.check((input) => JSON.stringify(input.metadata).length <= 16384, "metadata_too_large"));
276
- const decisionReason = /* @__PURE__ */ v.pipe(v.string(), v.trim(), v.minLength(1), v.check((value) => [...value].length <= 280, "reason_too_long"));
395
+ export const SignedIntentSchema = /* @__PURE__ */ v.variant("type", [
396
+ SignedTransferIntentClaimsSchema,
397
+ SignedAccountOpeningIntentClaimsSchema,
398
+ SignedAccountClosureIntentClaimsSchema,
399
+ ]);
400
+ /**
401
+ * The rules of a Signed Instruction's claims that JSON Schema does not say, over claims that already
402
+ * have their shape ({@link SignedIntentSchema}): `invalid_expiration_interval`,
403
+ * `invalid_expiration_datetime`, `note_too_long`, `name_too_long`, `holder_name_too_long` and
404
+ * `metadata_too_large`, as in
405
+ * {@link intentInputIssues}.
406
+ */
407
+ export function signedIntentInputIssues(input) {
408
+ const issues = expirationIssues(input);
409
+ if (input.type === "transfer")
410
+ issues.push(...noteIssues(input.note, [{ key: "note" }]));
411
+ issues.push(...nameIssues(input));
412
+ issues.push(...metadataIssues(input.metadata));
413
+ return issues;
414
+ }
415
+ /**
416
+ * Parses the verified claims of a Signed Instruction: their shape ({@link SignedIntentSchema}) and
417
+ * then their rules ({@link signedIntentInputIssues}). Parsing never verifies a signature.
418
+ *
419
+ * @example
420
+ * const claims = parseSignedIntentInput(verification.claims);
421
+ * if (!claims.success) console.log(claims.issues.map((issue) => issue.type));
422
+ */
423
+ export function parseSignedIntentInput(input) {
424
+ return parseWithRules(SignedIntentSchema, signedIntentInputIssues, input);
425
+ }
426
+ /** Why an Intent is cancelled or rejected: trimmed and never blank. Its length is a rule. */
427
+ const decisionReason = /* @__PURE__ */ v.pipe(v.string(), v.trim(), v.minLength(1));
428
+ /**
429
+ * The rule of a Cancellation's or a Rejection's reason that JSON Schema does not say in code points
430
+ * the way the server counts them: `reason_too_long`, past {@link REASON_MAX_LENGTH}.
431
+ */
432
+ export function intentDecisionIssues(input) {
433
+ if (codePoints(input.reason) <= REASON_MAX_LENGTH)
434
+ return [];
435
+ return [{ type: "reason_too_long", path: [{ key: "reason" }], requirement: REASON_MAX_LENGTH }];
436
+ }
277
437
  /**
278
438
  * Cancelling names why, because an Intent that vanished without a reason is an unexplained gap.
279
439
  * A Cancellation is the creator withdrawing its own request: only the client that created the
280
440
  * Intent may cancel it. An approver declining it is a Rejection ({@link IntentRejectionSchema}).
281
441
  *
282
442
  * @example
283
- * safeParseIntentCancellation({ reason: "rejected_by_erp" });
443
+ * parseIntentCancellation({ reason: "rejected_by_erp" });
284
444
  */
285
445
  export const IntentCancellationSchema = /* @__PURE__ */ v.strictObject({ reason: decisionReason });
286
- /** Returns validation issues for a cancellation reason without throwing across the HTTP boundary. */
287
- export function safeParseIntentCancellation(input) {
288
- return v.safeParse(IntentCancellationSchema, input);
446
+ /** Parses a cancellation: its shape and then {@link intentDecisionIssues}. */
447
+ export function parseIntentCancellation(input) {
448
+ return parseWithRules(IntentCancellationSchema, intentDecisionIssues, input);
289
449
  }
290
450
  /**
291
451
  * Rejecting names why. A Rejection is an approver declining an Intent with a Grant holding the
@@ -293,12 +453,12 @@ export function safeParseIntentCancellation(input) {
293
453
  * Cancellation, which is the creator withdrawing its own request.
294
454
  *
295
455
  * @example
296
- * safeParseIntentRejection({ reason: "duplicated_invoice" });
456
+ * parseIntentRejection({ reason: "duplicated_invoice" });
297
457
  */
298
458
  export const IntentRejectionSchema = /* @__PURE__ */ v.strictObject({ reason: decisionReason });
299
- /** Returns validation issues for a rejection reason without throwing across the HTTP boundary. */
300
- export function safeParseIntentRejection(input) {
301
- return v.safeParse(IntentRejectionSchema, input);
459
+ /** Parses a rejection: its shape and then {@link intentDecisionIssues}. */
460
+ export function parseIntentRejection(input) {
461
+ return parseWithRules(IntentRejectionSchema, intentDecisionIssues, input);
302
462
  }
303
463
  /**
304
464
  * Error codes an Intent's Approval lifecycle answers with, beyond the generic transport codes.
@@ -332,10 +492,6 @@ export const ANDCO_INTENT_ERROR_CODES = {
332
492
  */
333
493
  OWN_ACCOUNT_TRANSFER_NOT_IMPLEMENTED: "own_account_transfer_not_implemented",
334
494
  };
335
- /** Returns validation issues for the verified claims without throwing across the HTTP boundary. */
336
- export function safeParseSignedIntent(input) {
337
- return v.safeParse(SignedIntentSchema, input);
338
- }
339
495
  /**
340
496
  * Identifies recognized unsupported Intents without silently dropping their extra instructions: an
341
497
  * account closure, and payment shapes that carry several destinations, allocations or instructions.
@@ -361,19 +517,31 @@ export function unsupportedIntentShape(input) {
361
517
  *
362
518
  * Every member but `intent_id` is optional because nothing here is necessarily editable: a screen
363
519
  * sends only what the Intent left open, and a value that was frozen has nowhere to arrive from.
364
- * A transfer is created with its destination locked (`editable: true` is refused at creation), so
365
- * today `destination` always meets `transfer_value_editing_not_implemented`; `amount` is accepted only
366
- * when the Intent was created with `amount.editable: true`.
520
+ * `destination` is the one the person completes when the Intent was created with `destination: null`,
521
+ * and is required then; a transfer that named its destination takes none. `amount` is accepted only
522
+ * when the Intent was created with `amount.editable: true`. The server checks the destination against
523
+ * the Grant's `destinations` and refuses one outside them with `invalid_destination`.
367
524
  */
368
525
  export const TransferConfirmationSchema = /* @__PURE__ */ v.strictObject({
369
526
  intent_id: accountId,
370
527
  source_account_id: v.optional(accountId),
371
- amount: v.optional(amountValue),
372
- // Only another bank's account is ever editable, so a correction is always an `external` account.
528
+ amount: v.optional(MoneySchema),
529
+ // What the person wrote is always the account of a bank: another bank's, or Andco's own as the bank
530
+ // `andco`. An Andco account of the Grant's subject is not offered on the screen yet.
373
531
  destination: v.optional(v.strictObject(transferExternal)),
374
532
  note: v.optional(noteText),
375
533
  });
376
- /** Validates proposed confirmation fields without throwing; the server enforces editability. */
377
- export function safeParseTransferConfirmation(input) {
378
- return v.safeParse(TransferConfirmationSchema, input);
534
+ /**
535
+ * The rules of a confirmation that JSON Schema does not say in code points: `note_too_long`, past
536
+ * {@link NOTE_MAX_LENGTH}, and `holder_name_too_long`, past {@link HOLDER_NAME_MAX_LENGTH}.
537
+ */
538
+ export function transferConfirmationIssues(input) {
539
+ return [...noteIssues(input.note, [{ key: "note" }]), ...holderNameIssues(input.destination)];
540
+ }
541
+ /**
542
+ * Parses proposed confirmation fields: their shape and then {@link transferConfirmationIssues}. The
543
+ * server enforces editability.
544
+ */
545
+ export function parseTransferConfirmation(input) {
546
+ return parseWithRules(TransferConfirmationSchema, transferConfirmationIssues, input);
379
547
  }