@andco/protocol 0.0.14 → 0.0.15

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 (90) hide show
  1. package/README.md +2 -2
  2. package/dist/api-errors.d.ts +9 -9
  3. package/dist/api-errors.js +9 -9
  4. package/dist/authorization-preparation.js +2 -2
  5. package/dist/authorization.d.ts +1 -1
  6. package/dist/authorization.js +1 -1
  7. package/dist/consent.d.ts +2 -2
  8. package/dist/consent.js +2 -2
  9. package/dist/errors.d.ts +9 -9
  10. package/dist/errors.js +9 -9
  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 +431 -872
  15. package/dist/intent-input.d.ts.map +1 -1
  16. package/dist/intent-input.js +142 -121
  17. package/dist/miniapp-manifest.d.ts +1 -1
  18. package/dist/native-intent.d.ts +82 -68
  19. package/dist/native-intent.d.ts.map +1 -1
  20. package/dist/native-intent.js +134 -84
  21. package/dist/native.d.ts +1 -1
  22. package/dist/rar/account-matchers.d.ts +35 -30
  23. package/dist/rar/account-matchers.d.ts.map +1 -1
  24. package/dist/rar/account-matchers.js +27 -21
  25. package/dist/rar/bank.d.ts +81 -81
  26. package/dist/rar/bank.js +1 -1
  27. package/dist/rar/catalog.d.ts +48 -48
  28. package/dist/rar/catalog.js +6 -6
  29. package/dist/rar/detail.d.ts +1 -1
  30. package/dist/rar/detail.js +1 -1
  31. package/dist/rar/json-schemas.generated.d.ts +1 -1
  32. package/dist/rar/json-schemas.generated.d.ts.map +1 -1
  33. package/dist/rar/json-schemas.generated.js +25 -21
  34. package/dist/rar/subject-data.d.ts +1 -1
  35. package/dist/rar/subject-data.js +1 -1
  36. package/dist/rar/subject.d.ts +1 -1
  37. package/dist/rar/subject.js +1 -1
  38. package/dist/rest/accounts.d.ts +28 -28
  39. package/dist/rest/accounts.d.ts.map +1 -1
  40. package/dist/rest/accounts.js +22 -22
  41. package/dist/rest/api-error.d.ts +1 -1
  42. package/dist/rest/api-error.js +1 -1
  43. package/dist/rest/catalog.d.ts +3 -3
  44. package/dist/rest/catalog.js +2 -2
  45. package/dist/rest/common.d.ts +3 -3
  46. package/dist/rest/common.js +3 -3
  47. package/dist/rest/contract.d.ts +905 -528
  48. package/dist/rest/contract.d.ts.map +1 -1
  49. package/dist/rest/contract.js +17 -5
  50. package/dist/rest/events.d.ts +1 -1
  51. package/dist/rest/events.d.ts.map +1 -1
  52. package/dist/rest/events.js +2 -2
  53. package/dist/rest/identity.d.ts +22 -22
  54. package/dist/rest/identity.js +5 -5
  55. package/dist/rest/index.d.ts +1 -0
  56. package/dist/rest/index.d.ts.map +1 -1
  57. package/dist/rest/index.js +1 -0
  58. package/dist/rest/intents.d.ts +787 -716
  59. package/dist/rest/intents.d.ts.map +1 -1
  60. package/dist/rest/intents.js +62 -53
  61. package/dist/rest/signatures.d.ts +11 -5
  62. package/dist/rest/signatures.d.ts.map +1 -1
  63. package/dist/rest/signatures.js +10 -0
  64. package/dist/rest/transfers.d.ts +612 -0
  65. package/dist/rest/transfers.d.ts.map +1 -0
  66. package/dist/rest/transfers.js +115 -0
  67. package/dist/scopes.d.ts +1 -1
  68. package/dist/signing.d.ts +12 -2
  69. package/dist/signing.d.ts.map +1 -1
  70. package/dist/signing.js +6 -0
  71. package/dist/transfer.d.ts +363 -0
  72. package/dist/transfer.d.ts.map +1 -0
  73. package/dist/transfer.js +287 -0
  74. package/dist/transport/financial-events.d.ts +21 -17
  75. package/dist/transport/financial-events.d.ts.map +1 -1
  76. package/dist/transport/generated/oauth-api.d.ts +1017 -194
  77. package/dist/transport/generated/oauth-api.d.ts.map +1 -1
  78. package/dist/transport/intents.d.ts +28 -12
  79. package/dist/transport/intents.d.ts.map +1 -1
  80. package/dist/transport/intents.js +1 -1
  81. package/dist/transport/rest.d.ts +4 -4
  82. package/dist/urls.d.ts +2 -2
  83. package/dist/urls.js +3 -3
  84. package/dist/userinfo.d.ts +2 -2
  85. package/dist/userinfo.js +2 -2
  86. package/dist/webhooks.d.ts +16 -16
  87. package/dist/webhooks.js +14 -14
  88. package/dist/window-features.d.ts +2 -2
  89. package/dist/window-features.js +2 -2
  90. package/package.json +2 -2
@@ -0,0 +1,287 @@
1
+ import * as v from "valibot";
2
+ import { ANDCO_API_ORIGIN } from "./constants.js";
3
+ import { issuesAt, issuesOf, parseWithRules } from "./issues.js";
4
+ /**
5
+ * A transfer in Andco Core's own vocabulary (ADR 0093, ADR 0092): the Remitente is `sender`, the
6
+ * Receptor is `receiver`, and each carries the fields of Core's `POST /api/transfer` body, so no
7
+ * system translates between the Platform and the core.
8
+ */
9
+ /**
10
+ * A bank as Core names it: four digits. The schema checks only the form, because Core validates the
11
+ * code against its own catalog and a copy of that list would drift. {@link CHILEAN_BANK_CODES} names
12
+ * the known ones, and no validation reads it.
13
+ *
14
+ * @example
15
+ * v.parse(BankCodeSchema, CHILEAN_BANK_CODES.andco); // "0739"
16
+ */
17
+ export const BankCodeSchema = /* @__PURE__ */ v.pipe(v.string(), v.regex(/^\d{4}$/), v.description("The bank's four-digit code in Core's catalog. Andco is `0739`."));
18
+ /**
19
+ * The Chilean banks of Core's catalog by code, as Core lists them (`GET /catalogs/banks`). A helper
20
+ * for whoever writes a `bank_code`: no schema reads it, so a bank Core adds later is accepted
21
+ * before this list knows it.
22
+ *
23
+ * @example
24
+ * const receiver = { bank_code: CHILEAN_BANK_CODES.banco_estado }; // "0012"
25
+ */
26
+ export const CHILEAN_BANK_CODES = {
27
+ banco_de_chile: "0001",
28
+ banco_internacional: "0009",
29
+ banco_estado: "0012",
30
+ scotiabank: "0014",
31
+ bci: "0016",
32
+ banco_do_brasil: "0017",
33
+ corpbanca: "0027",
34
+ bice: "0028",
35
+ hsbc_bank_chile: "0031",
36
+ santander: "0037",
37
+ banco_itau: "0039",
38
+ jp_morgan: "0041",
39
+ security: "0049",
40
+ banco_falabella: "0051",
41
+ banco_ripley: "0053",
42
+ banco_consorcio: "0055",
43
+ banco_paris: "0057",
44
+ tanner: "0062",
45
+ scotiabank_azul: "0504",
46
+ banco_del_desarrollo: "0507",
47
+ coopeuch: "0672",
48
+ la_polar_prepago: "0697",
49
+ prepago_los_heroes: "0729",
50
+ tenpo_prepago: "0730",
51
+ tapp: "0732",
52
+ global_66: "0738",
53
+ andco: "0739",
54
+ copec_pay: "0741",
55
+ prex: "0743",
56
+ sumup: "0744",
57
+ fintual: "0746",
58
+ metromuv: "0747",
59
+ fintoc: "0764",
60
+ mercado_pago: "0875",
61
+ };
62
+ /** The largest transfer amount: Core stores an amount as int4. */
63
+ export const TRANSFER_AMOUNT_MAX = 2_147_483_647;
64
+ /**
65
+ * A transfer amount as Core's body carries it: a JSON integer in the minor unit of the currency (CLP:
66
+ * whole pesos), from 1 to {@link TRANSFER_AMOUNT_MAX}, because Core stores it as int4. A larger one is
67
+ * refused with the issue type `max_value` and `requirement` 2147483647.
68
+ *
69
+ * @example
70
+ * v.parse(PesosSchema, 40000); // 40000
71
+ */
72
+ export const PesosSchema = /* @__PURE__ */ v.pipe(v.number(), v.integer(), v.minValue(1), v.maxValue(TRANSFER_AMOUNT_MAX), v.description("An integer in the minor unit of the currency (CLP: whole pesos), from 1 to 2147483647, because Core stores it as int4. A larger one is refused with `max_value`."));
73
+ /**
74
+ * A Chilean account type as Core's catalog codes it: `"10"` savings, `"20"` checking and `"40"`
75
+ * debit (cuenta vista). Every Andco account is `"40"`.
76
+ */
77
+ export const TransferAccountTypeSchema = /* @__PURE__ */ v.pipe(v.picklist(["10", "20", "40"]), v.description('Core\'s account type code: `"10"` savings, `"20"` checking, `"40"` debit (cuenta vista).'));
78
+ const accountNumber = /* @__PURE__ */ v.pipe(v.string(), v.minLength(1), v.maxLength(64), v.description("The account number, as its bank writes it."));
79
+ const nationalId = /* @__PURE__ */ v.pipe(v.string(), v.minLength(1), v.maxLength(64), v.description("The holder's RUT. Core compares it as a normalized RUT."));
80
+ const holderName = /* @__PURE__ */ v.pipe(v.string(), v.minLength(1), v.description("The holder's name. Core stores it as it arrives and never compares it."));
81
+ /**
82
+ * An account in Chile and its holder, with nothing inferred: the country and the kind of document
83
+ * are always declared. Another country is a new variant, never a code clash.
84
+ */
85
+ const chileanAccount = {
86
+ country: /* @__PURE__ */ v.literal("CL"),
87
+ bank_code: BankCodeSchema,
88
+ account_type: TransferAccountTypeSchema,
89
+ account_number: accountNumber,
90
+ name: holderName,
91
+ national_kind_id: /* @__PURE__ */ v.literal("RUT"),
92
+ national_id: nationalId,
93
+ };
94
+ /**
95
+ * The Remitente: the account the money leaves and its holder, as Core's `sender`. Core checks it
96
+ * against the account's holder (`country`, `bank_code` `0739`, the account's own `account_type` and
97
+ * the holder's RUT) and stores `name` as it arrives.
98
+ *
99
+ * @example
100
+ * const sender: TransferSender = {
101
+ * country: "CL", bank_code: "0739", account_type: "40", account_number: "000123456789",
102
+ * name: "ACME SpA", national_kind_id: "RUT", national_id: "76.111.111-1",
103
+ * };
104
+ */
105
+ export const TransferSenderSchema = /* @__PURE__ */ v.pipe(v.variant("country", [v.strictObject(chileanAccount)]), v.description("The Remitente, as Core's `sender`: the account the money leaves and its holder. `country` and `national_kind_id` are always declared. Core checks the country, the bank (`0739`), the account's own type and the holder's RUT; it stores `name` as it arrives."));
106
+ /**
107
+ * The Receptor: the account the money lands on, its holder and the amount, as Core's `receiver`.
108
+ * The amount is an integer number of pesos.
109
+ *
110
+ * @example
111
+ * const receiver: TransferReceiver = {
112
+ * country: "CL", bank_code: "0012", account_type: "20", account_number: "12345678",
113
+ * name: "Proveedor SpA", national_kind_id: "RUT", national_id: "76.123.456-7",
114
+ * amount: 500000, currency: "CLP",
115
+ * };
116
+ */
117
+ export const TransferReceiverSchema = /* @__PURE__ */ v.pipe(v.variant("country", [
118
+ v.strictObject({
119
+ ...chileanAccount,
120
+ amount: PesosSchema,
121
+ currency: v.literal("CLP"),
122
+ email: v.pipe(v.optional(v.pipe(v.string(), v.email())), v.description("Where Core notifies the Receptor.")),
123
+ }),
124
+ ]), v.description("The Receptor, as Core's `receiver`: the account the money lands on, its holder, and the amount, an integer in the minor unit of the currency. `country` and `national_kind_id` are always declared."));
125
+ /**
126
+ * The claims of a signed transfer, version 2: Core's `POST /api/transfer` body, signed, plus the
127
+ * envelope (`iss`, `aud`, `jti`, `exp`) and `approved`. `metadata` is the signer's own data, kept as
128
+ * it arrives and read by nothing that decides; there is no `expires_at`, `iat` or `nbf`, because the
129
+ * deadline is `exp`. The core verifies the signature and runs the
130
+ * payload as its command, so nothing here names an Account Key or an Andco account id, and an
131
+ * unknown claim is refused.
132
+ *
133
+ * - `jti` is a UUID: it names the Transfer and is Core's `Idempotency-Key`.
134
+ * - `exp` bounds execution in the core, and is part of what the `jti` names.
135
+ * - `approved: true` orders the transfer sent as soon as it is uploaded; it needs `bank_transfer`
136
+ * `approve` in the Project's Grant.
137
+ *
138
+ * @example
139
+ * const claims: SignedTransferClaims = {
140
+ * iss: clientId, aud: "https://api.andco.com", jti: crypto.randomUUID(), exp: 1795000000, approved: true,
141
+ * sender, receiver, comment: "Factura 42",
142
+ * };
143
+ */
144
+ export const SignedTransferClaimsSchema = /* @__PURE__ */ v.pipe(v.strictObject({
145
+ iss: v.pipe(v.string(), v.minLength(1), v.maxLength(64), v.description("The signing Project's `client_id`.")),
146
+ aud: v.literal(ANDCO_API_ORIGIN),
147
+ jti: v.pipe(v.string(), v.uuid(), v.description("Names the Transfer: Core's `Idempotency-Key`. The same `jti` with other content is a conflict.")),
148
+ exp: v.pipe(v.number(), v.integer(), v.description("Unix seconds after which the core refuses to execute the transfer.")),
149
+ approved: v.pipe(v.boolean(), v.description("`true` orders the transfer sent to the core as soon as it is uploaded, which needs `bank_transfer` `approve` in the Grant.")),
150
+ sender: TransferSenderSchema,
151
+ receiver: TransferReceiverSchema,
152
+ comment: v.pipe(v.optional(v.string()), v.description("What both sides read next to the movement.")),
153
+ metadata: v.pipe(v.optional(v.record(v.string(), v.unknown())), v.description("The signer's own data, signed and kept as it arrives. Nothing reads it to decide anything.")),
154
+ }), v.description("The claims of a signed transfer (`typ` `transfer.v1+jwt`): Core's `POST /api/transfer` body (with its optional `metadata`) plus `iss`, `aud`, `jti`, `exp` and `approved`. Strict: an unknown claim, country or document is refused, nothing names an Account Key or an Andco account id, and the only deadline is `exp`."));
155
+ /** The most bytes Core keeps of a transfer's comment, counted in UTF-8. */
156
+ export const TRANSFER_COMMENT_MAX_BYTES = 60;
157
+ /**
158
+ * The rules of signed transfer claims that JSON Schema does not say, over claims that already have
159
+ * their shape ({@link SignedTransferClaimsSchema}): `comment_too_long` when the comment has more
160
+ * than {@link TRANSFER_COMMENT_MAX_BYTES} bytes of UTF-8. JSON Schema counts characters, never
161
+ * bytes, so this limit is a rule.
162
+ *
163
+ * @example
164
+ * signedTransferClaimsIssues({ ...claims, comment: "ñ".repeat(31) });
165
+ * // [{ type: "comment_too_long", path: [{ key: "comment" }], requirement: 60 }]
166
+ */
167
+ export function signedTransferClaimsIssues(claims) {
168
+ return transferCommentIssues(claims.comment, [{ key: "comment" }]);
169
+ }
170
+ /**
171
+ * The rule of a transfer's comment, wherever it sits (signed claims, an Intent proposal, a
172
+ * confirmation): `comment_too_long` at `path` when it has more than
173
+ * {@link TRANSFER_COMMENT_MAX_BYTES} bytes of UTF-8.
174
+ *
175
+ * @example
176
+ * transferCommentIssues("ñ".repeat(31), [{ key: "comment" }]);
177
+ * // [{ type: "comment_too_long", path: [{ key: "comment" }], requirement: 60 }]
178
+ */
179
+ export function transferCommentIssues(comment, path) {
180
+ if (comment === undefined || new TextEncoder().encode(comment).length <= TRANSFER_COMMENT_MAX_BYTES) {
181
+ return [];
182
+ }
183
+ return [{ type: "comment_too_long", path, requirement: TRANSFER_COMMENT_MAX_BYTES }];
184
+ }
185
+ /**
186
+ * Parses the claims of a signed transfer: their shape and then their rules. Parsing never verifies
187
+ * a signature.
188
+ *
189
+ * @example
190
+ * const parsed = parseSignedTransferClaims(claims);
191
+ * if (!parsed.success) console.log(parsed.issues.map((issue) => issue.type));
192
+ */
193
+ export function parseSignedTransferClaims(input) {
194
+ return parseWithRules(SignedTransferClaimsSchema, signedTransferClaimsIssues, input);
195
+ }
196
+ /** The `typ` of the protected header of every signature over transfer claims v2. */
197
+ export const SIGNED_TRANSFER_TYP = "transfer.v1+jwt";
198
+ const base64url = /* @__PURE__ */ v.pipe(v.string(), v.regex(/^[A-Za-z0-9_-]+$/));
199
+ /**
200
+ * The protected header of one signature, decoded: the algorithm, the `kid` of a Signing Key Pair
201
+ * registered in the Platform and in the core, and the versioned `typ`. Strict, so a parameter the
202
+ * verifiers do not understand (`crit`, `b64`) is refused rather than ignored.
203
+ *
204
+ * @example
205
+ * const header: SignedTransferHeader = { alg: "ES256", kid, typ: "transfer.v1+jwt" };
206
+ */
207
+ export const SignedTransferHeaderSchema = /* @__PURE__ */ v.pipe(v.strictObject({
208
+ alg: v.picklist(["ES256", "RS256"]),
209
+ kid: v.pipe(v.string(), v.minLength(1)),
210
+ typ: v.literal(SIGNED_TRANSFER_TYP),
211
+ }), v.description("The protected header of one signature, decoded: `alg` (`ES256` or `RS256`), the `kid` of a registered Signing Key Pair, and `typ` `transfer.v1+jwt`."));
212
+ /**
213
+ * A signed transfer as it travels: a JWS in the General JSON Serialization (RFC 7515 §7.2.1), one
214
+ * `payload` (the base64url of {@link SignedTransferClaimsSchema}) and a `signatures` array with at
215
+ * least one entry. One signature is an array of one. The same object travels unchanged to the core,
216
+ * which verifies every signature. Every header member is protected: an unprotected `header` is
217
+ * refused, because nothing outside the signature may name the key.
218
+ *
219
+ * Each `protected` must decode to {@link SignedTransferHeaderSchema}; that is a rule, because JSON
220
+ * Schema cannot read inside base64url ({@link parseSignedTransferEnvelope}).
221
+ *
222
+ * @example
223
+ * const envelope: SignedTransferEnvelope = {
224
+ * payload: "eyJpc3MiOi…",
225
+ * signatures: [{ protected: "eyJhbGciOiJFUzI1NiIs…", signature: "MEUCIQ…" }],
226
+ * };
227
+ */
228
+ export const SignedTransferEnvelopeSchema = /* @__PURE__ */ v.pipe(v.strictObject({
229
+ payload: v.pipe(base64url, v.description("The base64url of the JSON claims (`SignedTransferClaims`).")),
230
+ signatures: v.pipe(v.array(v.strictObject({
231
+ protected: v.pipe(base64url, v.description("The base64url of the JSON protected header (`SignedTransferHeader`).")),
232
+ signature: base64url,
233
+ })), v.minLength(1), v.description("At least one signature over the same payload; the core verifies every one.")),
234
+ }), v.description("A signed transfer: a JWS in the General JSON Serialization (RFC 7515 §7.2.1), with one `payload` and at least one signature, each with a protected header of `typ` `transfer.v1+jwt`. Sent as `application/jose+json`."));
235
+ /** Decodes base64url into the JSON value it carries, or `undefined` when it carries none. */
236
+ function DECODE_BASE64URL_JSON(value) {
237
+ try {
238
+ const binary = atob(value.replace(/-/g, "+").replace(/_/g, "/"));
239
+ const bytes = Uint8Array.from(binary, (character) => character.charCodeAt(0));
240
+ return JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes));
241
+ }
242
+ catch {
243
+ return undefined;
244
+ }
245
+ }
246
+ /**
247
+ * The rules of an envelope that JSON Schema does not say, over an envelope that already has its
248
+ * shape ({@link SignedTransferEnvelopeSchema}). At each signature's `protected`:
249
+ *
250
+ * - `malformed_protected_header` when it is not the base64url of a JSON value;
251
+ * - the issues of {@link SignedTransferHeaderSchema} when the header it decodes to is not one (a
252
+ * `typ` other than `transfer.v1+jwt`, no `kid`, another algorithm).
253
+ *
254
+ * It never verifies a signature.
255
+ *
256
+ * @example
257
+ * signedTransferEnvelopeIssues({ payload, signatures: [{ protected: "bm90LWpzb24", signature }] });
258
+ * // [{ type: "malformed_protected_header", path: [{ key: "signatures" }, { key: 0 }, { key: "protected" }] }]
259
+ */
260
+ export function signedTransferEnvelopeIssues(envelope) {
261
+ const issues = [];
262
+ envelope.signatures.forEach((signature, index) => {
263
+ const at = [{ key: "signatures" }, { key: index }, { key: "protected" }];
264
+ const header = DECODE_BASE64URL_JSON(signature.protected);
265
+ if (header === undefined) {
266
+ issues.push({ type: "malformed_protected_header", path: at });
267
+ return;
268
+ }
269
+ const parsed = v.safeParse(SignedTransferHeaderSchema, header);
270
+ if (!parsed.success) {
271
+ issues.push(...issuesAt(["signatures", index, "protected"], issuesOf(parsed.issues)));
272
+ }
273
+ });
274
+ return issues;
275
+ }
276
+ /**
277
+ * Parses a signed transfer envelope: its shape and then each signature's protected header. It
278
+ * neither verifies a signature nor reads the payload; the claims are parsed apart with
279
+ * {@link parseSignedTransferClaims} once a signature verifies.
280
+ *
281
+ * @example
282
+ * const parsed = parseSignedTransferEnvelope(await request.json());
283
+ * if (!parsed.success) console.log(parsed.issues.map((issue) => issue.type));
284
+ */
285
+ export function parseSignedTransferEnvelope(input) {
286
+ return parseWithRules(SignedTransferEnvelopeSchema, signedTransferEnvelopeIssues, input);
287
+ }
@@ -7,7 +7,7 @@ export type AndCoFinancialEvent<T extends string = string, P = Record<string, un
7
7
  occurred_at: string;
8
8
  };
9
9
  /**
10
- * An Andco account as an event names it: `{ type: "account", id }`, the same vocabulary a request
10
+ * An AndCo account as an event names it: `{ type: "account", id }`, the same vocabulary a request
11
11
  * uses to name an account by identifier.
12
12
  *
13
13
  * @example
@@ -54,7 +54,7 @@ export type AndCoIntentDepositEvent = AndCoFinancialEvent<"deposit.target_update
54
54
  completed_at: string;
55
55
  }>;
56
56
  /**
57
- * An account-wide bank fact, independent of application attribution.
57
+ * An account-wide fact, independent of application attribution.
58
58
  *
59
59
  * Account events keep saying `deposit` and `withdrawal` on purpose. Here the word names the
60
60
  * direction of a Movement — the entry a Transaction leaves in one account — and not the kind of
@@ -81,7 +81,7 @@ export type AndCoDepositEvent = AndCoFinancialEvent<"deposit.received", {
81
81
  observed_at: string;
82
82
  }>;
83
83
  /**
84
- * A posted debit or bank reversal, independent of any application request.
84
+ * A posted debit or reversal, independent of any application request.
85
85
  *
86
86
  * See {@link AndCoDepositEvent} for why an account event is still called a withdrawal once the
87
87
  * request that caused it is a `transfer`.
@@ -105,25 +105,29 @@ export type AndCoWithdrawalEvent = AndCoFinancialEvent<"withdrawal.posted", {
105
105
  observed_at: string;
106
106
  }>;
107
107
  /**
108
- * Frozen values of a confirmed transfer; these do not assert that a debit was posted.
108
+ * Frozen values of a confirmed transfer, in Core's vocabulary; these do not assert that a debit was
109
+ * posted.
109
110
  *
110
- * `destination` is whatever the money was aimed at: an Andco account by identifier, an Andco
111
- * account by the Account Key its holder chose, or an account at another Chilean bank. An AccountKey
112
- * stays an AccountKey here because it resolves at execution, not at confirmation.
111
+ * `receiver` is whatever the money was aimed at: an AndCo account by identifier, an AndCo account by
112
+ * the Account Key its holder chose, or a Receptor at a Chilean bank. An AccountKey stays an AccountKey
113
+ * here because it resolves at execution, not at confirmation. `amount.value` is an integer in the minor unit of the currency.
113
114
  *
114
115
  * @example
115
116
  * const operation: AndCoConfirmedTransfer = {
116
- * source: { type: "account", id: "0198d482-82aa-7ef2-ae1b-0cfae7ea5d8a" },
117
- * destination: { type: "account_key", accountKey: "proveedores" },
118
- * amount: { currency: "CLP", value: "30000" },
119
- * note: "Factura 42",
117
+ * sender: { type: "account", id: "0198d482-82aa-7ef2-ae1b-0cfae7ea5d8a" },
118
+ * receiver: { type: "account_key", accountKey: "proveedores" },
119
+ * amount: { currency: "CLP", value: 30000 },
120
+ * comment: "Factura 42",
120
121
  * };
121
122
  */
122
123
  export type AndCoConfirmedTransfer = {
123
- source: AndCoEventAccount;
124
- destination: import("./intents.js").AndCoTransferDestination;
125
- amount: AndCoEventAmount;
126
- note: string;
124
+ sender: AndCoEventAccount;
125
+ receiver: import("./intents.js").AndCoTransferIntentReceiver;
126
+ amount: {
127
+ currency: "CLP";
128
+ value: number;
129
+ };
130
+ comment: string;
127
131
  };
128
132
  /**
129
133
  * The lifecycle of one transfer Intent, as its Project sees it.
@@ -131,8 +135,8 @@ export type AndCoConfirmedTransfer = {
131
135
  * These are the Intent events; an account's own entries keep their direction-shaped names. A
132
136
  * `transfer.approval_required` says the Intent is waiting on a person's Approval, so an integrator
133
137
  * can notify its own people without standing up a separate webhook. A `transfer.confirmed` says
134
- * the bank holds the command and nobody has to do anything: for a transfer that leaves its holder's
135
- * own accounts it is published once, when the bank accepts the transfer (until then the Intent stays
138
+ * AndCo holds the command and nobody has to do anything: for a transfer that leaves its holder's
139
+ * own accounts it is published once, when AndCo accepts the transfer (until then the Intent stays
136
140
  * `requires_action` with `interaction_reason` `bank_verification_required`, even after the person
137
141
  * pressed Confirm), and for a transfer between two accounts of the same holder it is published from
138
142
  * its release. A `transfer.succeeded` says the money moved.
@@ -1 +1 @@
1
- {"version":3,"file":"financial-events.d.ts","sourceRoot":"","sources":["../../src/transport/financial-events.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,MAAM,MAAM,mBAAmB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI;IACxF,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,CAAC,CAAC;IACR,OAAO,EAAE,CAAC,CAAC;IACX,OAAO,EAAE,CAAC,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,iBAAiB,GAAG,OAAO,CAAC,OAAO,cAAc,EAAE,kBAAkB,EAAE;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,CAAC,CAAC;AAExG,mGAAmG;AACnG,MAAM,MAAM,gBAAgB,GAAG,OAAO,cAAc,EAAE,iBAAiB,CAAC;AAExE,8EAA8E;AAC9E,MAAM,MAAM,uBAAuB,GAC/B,mBAAmB,CACjB,wBAAwB,EACxB;IACE,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,gBAAgB,CAAC;CAC1B,CACF,GACD,mBAAmB,CACjB,gBAAgB,EAChB;IACE,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,QAAQ,CAAC;IACjB,KAAK,EAAE,gBAAgB,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;CACnB,CACF,GACD,mBAAmB,CACjB,i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AG,IAAI;AAChD,kFAAkF;AAClF,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,EAC3D,OAAO,EAAE,6BAA6B,GACrC,sBAAsB,CAmFxB"}
1
+ {"version":3,"file":"financial-events.d.ts","sourceRoot":"","sources":["../../src/transport/financial-events.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,MAAM,MAAM,mBAAmB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI;IACxF,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,CAAC,CAAC;IACR,OAAO,EAAE,CAAC,CAAC;IACX,OAAO,EAAE,CAAC,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,iBAAiB,GAAG,OAAO,CAAC,OAAO,cAAc,EAAE,kBAAkB,EAAE;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,CAAC,CAAC;AAExG,mGAAmG;AACnG,MAAM,MAAM,gBAAgB,GAAG,OAAO,cAAc,EAAE,iBAAiB,CAAC;AAExE,8EAA8E;AAC9E,MAAM,MAAM,uBAAuB,GAC/B,mBAAmB,CACjB,wBAAwB,EACxB;IACE,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,gBAAgB,CAAC;CAC1B,CACF,GACD,mBAAmB,CACjB,gBAAgB,EAChB;IACE,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,QAAQ,CAAC;IACjB,KAAK,EAAE,gBAAgB,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;CACnB,CACF,GACD,mBAAmB,CACjB,iBAAiB,EACjB;IACE,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,SAAS,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB,CACF,G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