@andco/protocol 0.0.14 → 0.1.0-ti.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.
Files changed (101) 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.d.ts +1 -1
  5. package/dist/authorization-preparation.js +2 -2
  6. package/dist/authorization.d.ts +1 -1
  7. package/dist/authorization.js +1 -1
  8. package/dist/consent.d.ts +2 -2
  9. package/dist/consent.js +2 -2
  10. package/dist/errors.d.ts +10 -10
  11. package/dist/errors.js +10 -10
  12. package/dist/index.d.ts +1 -0
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +1 -0
  15. package/dist/intent-input.d.ts +452 -880
  16. package/dist/intent-input.d.ts.map +1 -1
  17. package/dist/intent-input.js +164 -127
  18. package/dist/intent-status.d.ts +5 -6
  19. package/dist/intent-status.d.ts.map +1 -1
  20. package/dist/intent-status.js +12 -7
  21. package/dist/miniapp-manifest.d.ts +3 -3
  22. package/dist/miniapp-manifest.js +1 -1
  23. package/dist/native-intent.d.ts +82 -68
  24. package/dist/native-intent.d.ts.map +1 -1
  25. package/dist/native-intent.js +137 -84
  26. package/dist/native.d.ts +1 -1
  27. package/dist/rar/account-matchers.d.ts +35 -30
  28. package/dist/rar/account-matchers.d.ts.map +1 -1
  29. package/dist/rar/account-matchers.js +27 -21
  30. package/dist/rar/bank.d.ts +357 -85
  31. package/dist/rar/bank.d.ts.map +1 -1
  32. package/dist/rar/bank.js +43 -5
  33. package/dist/rar/catalog.d.ts +174 -49
  34. package/dist/rar/catalog.d.ts.map +1 -1
  35. package/dist/rar/catalog.js +6 -6
  36. package/dist/rar/detail.d.ts +1 -1
  37. package/dist/rar/detail.js +1 -1
  38. package/dist/rar/json-schemas.generated.d.ts +1 -1
  39. package/dist/rar/json-schemas.generated.d.ts.map +1 -1
  40. package/dist/rar/json-schemas.generated.js +393 -21
  41. package/dist/rar/money.d.ts +1 -1
  42. package/dist/rar/money.js +1 -1
  43. package/dist/rar/subject-data.d.ts +1 -1
  44. package/dist/rar/subject-data.js +1 -1
  45. package/dist/rar/subject.d.ts +1 -1
  46. package/dist/rar/subject.js +1 -1
  47. package/dist/rest/accounts.d.ts +28 -28
  48. package/dist/rest/accounts.d.ts.map +1 -1
  49. package/dist/rest/accounts.js +22 -22
  50. package/dist/rest/api-error.d.ts +1 -1
  51. package/dist/rest/api-error.js +1 -1
  52. package/dist/rest/catalog.d.ts +3 -3
  53. package/dist/rest/catalog.js +2 -2
  54. package/dist/rest/common.d.ts +3 -3
  55. package/dist/rest/common.js +3 -3
  56. package/dist/rest/contract.d.ts +1183 -547
  57. package/dist/rest/contract.d.ts.map +1 -1
  58. package/dist/rest/contract.js +21 -5
  59. package/dist/rest/events.d.ts +1 -1
  60. package/dist/rest/events.d.ts.map +1 -1
  61. package/dist/rest/events.js +2 -2
  62. package/dist/rest/identity.d.ts +22 -22
  63. package/dist/rest/identity.d.ts.map +1 -1
  64. package/dist/rest/identity.js +5 -5
  65. package/dist/rest/index.d.ts +1 -0
  66. package/dist/rest/index.d.ts.map +1 -1
  67. package/dist/rest/index.js +1 -0
  68. package/dist/rest/intents.d.ts +973 -743
  69. package/dist/rest/intents.d.ts.map +1 -1
  70. package/dist/rest/intents.js +112 -89
  71. package/dist/rest/signatures.d.ts +25 -5
  72. package/dist/rest/signatures.d.ts.map +1 -1
  73. package/dist/rest/signatures.js +52 -0
  74. package/dist/rest/transfers.d.ts +988 -0
  75. package/dist/rest/transfers.d.ts.map +1 -0
  76. package/dist/rest/transfers.js +142 -0
  77. package/dist/scopes.d.ts +1 -1
  78. package/dist/signing.d.ts +17 -3
  79. package/dist/signing.d.ts.map +1 -1
  80. package/dist/signing.js +8 -1
  81. package/dist/transfer.d.ts +399 -0
  82. package/dist/transfer.d.ts.map +1 -0
  83. package/dist/transfer.js +313 -0
  84. package/dist/transport/financial-events.d.ts +82 -27
  85. package/dist/transport/financial-events.d.ts.map +1 -1
  86. package/dist/transport/financial-events.js +34 -0
  87. package/dist/transport/generated/oauth-api.d.ts +1420 -333
  88. package/dist/transport/generated/oauth-api.d.ts.map +1 -1
  89. package/dist/transport/intents.d.ts +29 -13
  90. package/dist/transport/intents.d.ts.map +1 -1
  91. package/dist/transport/intents.js +1 -1
  92. package/dist/transport/rest.d.ts +5 -5
  93. package/dist/urls.d.ts +2 -2
  94. package/dist/urls.js +3 -3
  95. package/dist/userinfo.d.ts +2 -2
  96. package/dist/userinfo.js +2 -2
  97. package/dist/webhooks.d.ts +16 -16
  98. package/dist/webhooks.js +14 -14
  99. package/dist/window-features.d.ts +2 -2
  100. package/dist/window-features.js +2 -2
  101. package/package.json +2 -2
@@ -0,0 +1,399 @@
1
+ import * as v from "valibot";
2
+ import { type Issue, type ParseResult } from "./issues.js";
3
+ /**
4
+ * A transfer in the transfer vocabulary of the API: the Remitente is `sender` and the
5
+ * Receptor is `receiver`.
6
+ */
7
+ /**
8
+ * A bank as the API names it: four digits. The schema checks only the form, because the API
9
+ * validates the code against its bank catalog and a copy of that list would drift.
10
+ * {@link CHILEAN_BANK_CODES} names the known ones, and no validation reads it.
11
+ *
12
+ * @example
13
+ * v.parse(BankCodeSchema, CHILEAN_BANK_CODES.andco); // "0739"
14
+ */
15
+ export declare const BankCodeSchema: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>, v.DescriptionAction<string, "The bank's four-digit code, as `GET /catalogs/banks` lists it. AndCo is `0739`.">]>;
16
+ /**
17
+ * The Chilean banks by code, as `GET /catalogs/banks` lists them. A helper for whoever writes a
18
+ * `bank_code`: no schema reads it, so a bank the catalog adds later is accepted before this list
19
+ * knows it.
20
+ *
21
+ * @example
22
+ * const receiver = { bank_code: CHILEAN_BANK_CODES.banco_estado }; // "0012"
23
+ */
24
+ export declare const CHILEAN_BANK_CODES: {
25
+ readonly banco_de_chile: "0001";
26
+ readonly banco_internacional: "0009";
27
+ readonly banco_estado: "0012";
28
+ readonly scotiabank: "0014";
29
+ readonly bci: "0016";
30
+ readonly banco_do_brasil: "0017";
31
+ readonly corpbanca: "0027";
32
+ readonly bice: "0028";
33
+ readonly hsbc_bank_chile: "0031";
34
+ readonly santander: "0037";
35
+ readonly banco_itau: "0039";
36
+ readonly jp_morgan: "0041";
37
+ readonly security: "0049";
38
+ readonly banco_falabella: "0051";
39
+ readonly banco_ripley: "0053";
40
+ readonly banco_consorcio: "0055";
41
+ readonly banco_paris: "0057";
42
+ readonly tanner: "0062";
43
+ readonly scotiabank_azul: "0504";
44
+ readonly banco_del_desarrollo: "0507";
45
+ readonly coopeuch: "0672";
46
+ readonly la_polar_prepago: "0697";
47
+ readonly prepago_los_heroes: "0729";
48
+ readonly tenpo_prepago: "0730";
49
+ readonly tapp: "0732";
50
+ readonly global_66: "0738";
51
+ readonly andco: "0739";
52
+ readonly copec_pay: "0741";
53
+ readonly prex: "0743";
54
+ readonly sumup: "0744";
55
+ readonly fintual: "0746";
56
+ readonly metromuv: "0747";
57
+ readonly fintoc: "0764";
58
+ readonly mercado_pago: "0875";
59
+ };
60
+ /** The largest transfer amount. */
61
+ export declare const TRANSFER_AMOUNT_MAX = 2147483647;
62
+ /**
63
+ * A transfer amount: a JSON integer in the minor unit of the currency (CLP: whole pesos), from 1 to
64
+ * {@link TRANSFER_AMOUNT_MAX}. A larger one is refused with the issue type `max_value` and `requirement` 2147483647.
65
+ *
66
+ * @example
67
+ * v.parse(PesosSchema, 40000); // 40000
68
+ */
69
+ export declare const PesosSchema: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>, v.MaxValueAction<number, 2147483647, undefined>, v.DescriptionAction<number, "An integer in the minor unit of the currency (CLP: whole pesos), from 1 to 2147483647. A larger one is refused with `max_value`.">]>;
70
+ /**
71
+ * A Chilean account type, by its code: `"10"` savings, `"20"` checking and `"40"`
72
+ * debit (cuenta vista). Every AndCo account is `"40"`.
73
+ */
74
+ export declare const TransferAccountTypeSchema: v.SchemaWithPipe<readonly [v.PicklistSchema<["10", "20", "40"], undefined>, v.DescriptionAction<"10" | "20" | "40", "The account type code: `\"10\"` savings, `\"20\"` checking, `\"40\"` debit (cuenta vista).">]>;
75
+ /** A Chilean account type, by its code. */
76
+ export type TransferAccountType = v.InferOutput<typeof TransferAccountTypeSchema>;
77
+ /**
78
+ * The Remitente: the account the money leaves and its holder. It is checked against the account's
79
+ * holder (`country`, `bank_code` `0739`, the account's own `account_type` and the holder's RUT);
80
+ * `name` is kept as it arrives.
81
+ *
82
+ * @example
83
+ * const sender: TransferSender = {
84
+ * country: "CL", bank_code: "0739", account_type: "40", account_number: "000123456789",
85
+ * name: "ACME SpA", national_kind_id: "RUT", national_id: "76.111.111-1",
86
+ * };
87
+ */
88
+ export declare const TransferSenderSchema: v.SchemaWithPipe<readonly [v.VariantSchema<"country", [v.StrictObjectSchema<{
89
+ country: v.LiteralSchema<"CL", undefined>;
90
+ bank_code: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>, v.DescriptionAction<string, "The bank's four-digit code, as `GET /catalogs/banks` lists it. AndCo is `0739`.">]>;
91
+ account_type: v.SchemaWithPipe<readonly [v.PicklistSchema<["10", "20", "40"], undefined>, v.DescriptionAction<"10" | "20" | "40", "The account type code: `\"10\"` savings, `\"20\"` checking, `\"40\"` debit (cuenta vista).">]>;
92
+ account_number: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 64, undefined>, v.DescriptionAction<string, "The account number, as its bank writes it.">]>;
93
+ name: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.DescriptionAction<string, "The holder's name, kept as it arrives and never compared.">]>;
94
+ national_kind_id: v.LiteralSchema<"RUT", undefined>;
95
+ national_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 64, undefined>, v.DescriptionAction<string, "The holder's RUT, compared as a normalized RUT.">]>;
96
+ }, undefined>], undefined>, v.DescriptionAction<{
97
+ country: "CL";
98
+ bank_code: string;
99
+ account_type: "10" | "20" | "40";
100
+ account_number: string;
101
+ name: string;
102
+ national_kind_id: "RUT";
103
+ national_id: string;
104
+ }, "The Remitente: the account the money leaves and its holder. `country` and `national_kind_id` are always declared. The country, the bank (`0739`), the account's own type and the holder's RUT are checked; `name` is kept as it arrives.">]>;
105
+ /** The Remitente of a transfer. */
106
+ export type TransferSender = v.InferOutput<typeof TransferSenderSchema>;
107
+ /**
108
+ * The Receptor: the account the money lands on, its holder and the amount.
109
+ * The amount is an integer number of pesos.
110
+ *
111
+ * @example
112
+ * const receiver: TransferReceiver = {
113
+ * country: "CL", bank_code: "0012", account_type: "20", account_number: "12345678",
114
+ * name: "Proveedor SpA", national_kind_id: "RUT", national_id: "76.123.456-7",
115
+ * amount: 500000, currency: "CLP",
116
+ * };
117
+ */
118
+ export declare const TransferReceiverSchema: v.SchemaWithPipe<readonly [v.VariantSchema<"country", [v.StrictObjectSchema<{
119
+ readonly amount: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>, v.MaxValueAction<number, 2147483647, undefined>, v.DescriptionAction<number, "An integer in the minor unit of the currency (CLP: whole pesos), from 1 to 2147483647. A larger one is refused with `max_value`.">]>;
120
+ readonly currency: v.LiteralSchema<"CLP", undefined>;
121
+ readonly email: v.SchemaWithPipe<readonly [v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.EmailAction<string, undefined>]>, undefined>, v.DescriptionAction<string | undefined, "Where the Receptor is notified.">]>;
122
+ readonly country: v.LiteralSchema<"CL", undefined>;
123
+ readonly bank_code: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>, v.DescriptionAction<string, "The bank's four-digit code, as `GET /catalogs/banks` lists it. AndCo is `0739`.">]>;
124
+ readonly account_type: v.SchemaWithPipe<readonly [v.PicklistSchema<["10", "20", "40"], undefined>, v.DescriptionAction<"10" | "20" | "40", "The account type code: `\"10\"` savings, `\"20\"` checking, `\"40\"` debit (cuenta vista).">]>;
125
+ readonly account_number: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 64, undefined>, v.DescriptionAction<string, "The account number, as its bank writes it.">]>;
126
+ readonly name: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.DescriptionAction<string, "The holder's name, kept as it arrives and never compared.">]>;
127
+ readonly national_kind_id: v.LiteralSchema<"RUT", undefined>;
128
+ readonly national_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 64, undefined>, v.DescriptionAction<string, "The holder's RUT, compared as a normalized RUT.">]>;
129
+ }, undefined>], undefined>, v.DescriptionAction<{
130
+ amount: number;
131
+ currency: "CLP";
132
+ email?: string | undefined;
133
+ country: "CL";
134
+ bank_code: string;
135
+ account_type: "10" | "20" | "40";
136
+ account_number: string;
137
+ name: string;
138
+ national_kind_id: "RUT";
139
+ national_id: string;
140
+ }, "The Receptor: 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.">]>;
141
+ /** The Receptor of a transfer. */
142
+ export type TransferReceiver = v.InferOutput<typeof TransferReceiverSchema>;
143
+ /**
144
+ * One side of a Transfer as the API answers it: the account and its holder, without the amount. The
145
+ * Remitente and the Receptor have these same seven fields. A Transfer made in the issuer's own
146
+ * channels can lack the holder's `name` and document, so those three are nullable.
147
+ *
148
+ * @example
149
+ * const party: TransferParty = {
150
+ * country: "CL", bank_code: "0739", account_type: "40", account_number: "000123456789",
151
+ * name: "ACME SpA", national_kind_id: "RUT", national_id: "76111111-1",
152
+ * };
153
+ */
154
+ export declare const TransferPartySchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
155
+ readonly country: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.DescriptionAction<string, "The country of the account, for example `CL`.">]>;
156
+ readonly bank_code: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>, v.DescriptionAction<string, "The bank's four-digit code, as `GET /catalogs/banks` lists it. AndCo is `0739`.">]>;
157
+ readonly account_type: v.SchemaWithPipe<readonly [v.PicklistSchema<["10", "20", "40"], undefined>, v.DescriptionAction<"10" | "20" | "40", "The account type code: `\"10\"` savings, `\"20\"` checking, `\"40\"` debit (cuenta vista).">]>;
158
+ readonly account_number: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 64, undefined>, v.DescriptionAction<string, "The account number, as its bank writes it.">]>;
159
+ readonly name: v.SchemaWithPipe<readonly [v.NullableSchema<v.StringSchema<undefined>, undefined>, v.DescriptionAction<string | null, "The holder's name, or null when it is not known.">]>;
160
+ readonly national_kind_id: v.SchemaWithPipe<readonly [v.NullableSchema<v.StringSchema<undefined>, undefined>, v.DescriptionAction<string | null, "The kind of the holder's document, for example `RUT`, or null when it is not known.">]>;
161
+ readonly national_id: v.SchemaWithPipe<readonly [v.NullableSchema<v.StringSchema<undefined>, undefined>, v.DescriptionAction<string | null, "The holder's document number, or null when it is not known.">]>;
162
+ }, undefined>, v.DescriptionAction<{
163
+ country: string;
164
+ bank_code: string;
165
+ account_type: "10" | "20" | "40";
166
+ account_number: string;
167
+ name: string | null;
168
+ national_kind_id: string | null;
169
+ national_id: string | null;
170
+ }, "One side of a Transfer: the account and its holder, with the same seven fields for the Remitente and the Receptor. The amount is on the Transfer.">]>;
171
+ /** One side of a Transfer: the account and its holder, without the amount. */
172
+ export type TransferParty = v.InferOutput<typeof TransferPartySchema>;
173
+ /**
174
+ * The `jti` of a signed transfer: a UUID written in lowercase. It names the Transfer and is its
175
+ * idempotency-key, which a bank compares as a string, so two spellings of one UUID would be two
176
+ * different keys. The same schema reads the `jti` query of `GET /transfers`.
177
+ *
178
+ * @example
179
+ * v.parse(SignedTransferJtiSchema, crypto.randomUUID()); // a lowercase UUID passes
180
+ * v.is(SignedTransferJtiSchema, crypto.randomUUID().toUpperCase()); // false
181
+ */
182
+ export declare const SignedTransferJtiSchema: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.UuidAction<string, undefined>, v.RegexAction<string, "jti must be a lowercase UUID">, v.DescriptionAction<string, "A UUID in lowercase. It names the Transfer: it is its idempotency-key. The same `jti` with other content is a conflict.">]>;
183
+ /**
184
+ * The claims of a signed transfer, version 2: `sender`, `receiver` and `comment`, signed, plus the
185
+ * envelope (`iss`, `aud`, `jti`, `exp`) and `approved`. `metadata` is the signer's own data, kept as
186
+ * it arrives and read by nothing that decides; there is no `expires_at`, `iat` or `nbf`, because the
187
+ * deadline is `exp`. The API verifies the signature and executes the payload as signed, so nothing
188
+ * here names an Account Key or an AndCo account id, and an unknown claim is refused.
189
+ *
190
+ * - `jti` is a lowercase UUID: it names the Transfer and is its idempotency-key.
191
+ * - `exp` bounds execution, and is part of what the `jti` names.
192
+ * - `approved: true` orders the transfer sent as soon as it is submitted; it needs `bank_transfer`
193
+ * `approve` in the Project's Grant.
194
+ *
195
+ * @example
196
+ * const claims: SignedTransferClaims = {
197
+ * iss: clientId, aud: "https://api.andco.com", jti: crypto.randomUUID(), exp: 1795000000, approved: true,
198
+ * sender, receiver, comment: "Factura 42",
199
+ * };
200
+ */
201
+ export declare const SignedTransferClaimsSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
202
+ readonly iss: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 64, undefined>, v.DescriptionAction<string, "The signing Project's `client_id`.">]>;
203
+ readonly aud: v.LiteralSchema<"https://api.andco.com", undefined>;
204
+ readonly jti: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.UuidAction<string, undefined>, v.RegexAction<string, "jti must be a lowercase UUID">, v.DescriptionAction<string, "A UUID in lowercase. It names the Transfer: it is its idempotency-key. The same `jti` with other content is a conflict.">]>;
205
+ readonly exp: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.DescriptionAction<number, "Unix seconds after which the transfer is refused.">]>;
206
+ readonly approved: v.SchemaWithPipe<readonly [v.BooleanSchema<undefined>, v.DescriptionAction<boolean, "`true` orders the transfer sent as soon as it is submitted, which needs `bank_transfer` `approve` in the Grant.">]>;
207
+ readonly sender: v.SchemaWithPipe<readonly [v.VariantSchema<"country", [v.StrictObjectSchema<{
208
+ country: v.LiteralSchema<"CL", undefined>;
209
+ bank_code: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>, v.DescriptionAction<string, "The bank's four-digit code, as `GET /catalogs/banks` lists it. AndCo is `0739`.">]>;
210
+ account_type: v.SchemaWithPipe<readonly [v.PicklistSchema<["10", "20", "40"], undefined>, v.DescriptionAction<"10" | "20" | "40", "The account type code: `\"10\"` savings, `\"20\"` checking, `\"40\"` debit (cuenta vista).">]>;
211
+ account_number: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 64, undefined>, v.DescriptionAction<string, "The account number, as its bank writes it.">]>;
212
+ name: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.DescriptionAction<string, "The holder's name, kept as it arrives and never compared.">]>;
213
+ national_kind_id: v.LiteralSchema<"RUT", undefined>;
214
+ national_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 64, undefined>, v.DescriptionAction<string, "The holder's RUT, compared as a normalized RUT.">]>;
215
+ }, undefined>], undefined>, v.DescriptionAction<{
216
+ country: "CL";
217
+ bank_code: string;
218
+ account_type: "10" | "20" | "40";
219
+ account_number: string;
220
+ name: string;
221
+ national_kind_id: "RUT";
222
+ national_id: string;
223
+ }, "The Remitente: the account the money leaves and its holder. `country` and `national_kind_id` are always declared. The country, the bank (`0739`), the account's own type and the holder's RUT are checked; `name` is kept as it arrives.">]>;
224
+ readonly receiver: v.SchemaWithPipe<readonly [v.VariantSchema<"country", [v.StrictObjectSchema<{
225
+ readonly amount: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>, v.MaxValueAction<number, 2147483647, undefined>, v.DescriptionAction<number, "An integer in the minor unit of the currency (CLP: whole pesos), from 1 to 2147483647. A larger one is refused with `max_value`.">]>;
226
+ readonly currency: v.LiteralSchema<"CLP", undefined>;
227
+ readonly email: v.SchemaWithPipe<readonly [v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.EmailAction<string, undefined>]>, undefined>, v.DescriptionAction<string | undefined, "Where the Receptor is notified.">]>;
228
+ readonly country: v.LiteralSchema<"CL", undefined>;
229
+ readonly bank_code: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>, v.DescriptionAction<string, "The bank's four-digit code, as `GET /catalogs/banks` lists it. AndCo is `0739`.">]>;
230
+ readonly account_type: v.SchemaWithPipe<readonly [v.PicklistSchema<["10", "20", "40"], undefined>, v.DescriptionAction<"10" | "20" | "40", "The account type code: `\"10\"` savings, `\"20\"` checking, `\"40\"` debit (cuenta vista).">]>;
231
+ readonly account_number: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 64, undefined>, v.DescriptionAction<string, "The account number, as its bank writes it.">]>;
232
+ readonly name: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.DescriptionAction<string, "The holder's name, kept as it arrives and never compared.">]>;
233
+ readonly national_kind_id: v.LiteralSchema<"RUT", undefined>;
234
+ readonly national_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 64, undefined>, v.DescriptionAction<string, "The holder's RUT, compared as a normalized RUT.">]>;
235
+ }, undefined>], undefined>, v.DescriptionAction<{
236
+ amount: number;
237
+ currency: "CLP";
238
+ email?: string | undefined;
239
+ country: "CL";
240
+ bank_code: string;
241
+ account_type: "10" | "20" | "40";
242
+ account_number: string;
243
+ name: string;
244
+ national_kind_id: "RUT";
245
+ national_id: string;
246
+ }, "The Receptor: 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.">]>;
247
+ readonly comment: v.SchemaWithPipe<readonly [v.OptionalSchema<v.StringSchema<undefined>, undefined>, v.DescriptionAction<string | undefined, "What both sides read next to the movement.">]>;
248
+ readonly metadata: v.SchemaWithPipe<readonly [v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, undefined>, v.DescriptionAction<{
249
+ [x: string]: unknown;
250
+ } | undefined, "The signer's own data, signed and kept as it arrives. Nothing reads it to decide anything.">]>;
251
+ }, undefined>, v.DescriptionAction<{
252
+ iss: string;
253
+ aud: "https://api.andco.com";
254
+ jti: string;
255
+ exp: number;
256
+ approved: boolean;
257
+ sender: {
258
+ country: "CL";
259
+ bank_code: string;
260
+ account_type: "10" | "20" | "40";
261
+ account_number: string;
262
+ name: string;
263
+ national_kind_id: "RUT";
264
+ national_id: string;
265
+ };
266
+ receiver: {
267
+ amount: number;
268
+ currency: "CLP";
269
+ email?: string | undefined;
270
+ country: "CL";
271
+ bank_code: string;
272
+ account_type: "10" | "20" | "40";
273
+ account_number: string;
274
+ name: string;
275
+ national_kind_id: "RUT";
276
+ national_id: string;
277
+ };
278
+ comment?: string | undefined;
279
+ metadata?: {
280
+ [x: string]: unknown;
281
+ } | undefined;
282
+ }, "The claims of a signed transfer (`typ` `transfer.v1+jwt`): `sender`, `receiver` and `comment` (with an 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`.">]>;
283
+ /** The claims of a signed transfer, version 2. */
284
+ export type SignedTransferClaims = v.InferOutput<typeof SignedTransferClaimsSchema>;
285
+ /** The most bytes of a transfer's comment, counted in UTF-8. */
286
+ export declare const TRANSFER_COMMENT_MAX_BYTES = 60;
287
+ /**
288
+ * The rules of signed transfer claims that JSON Schema does not say, over claims that already have
289
+ * their shape ({@link SignedTransferClaimsSchema}): `comment_too_long` when the comment has more
290
+ * than {@link TRANSFER_COMMENT_MAX_BYTES} bytes of UTF-8. JSON Schema counts characters, never
291
+ * bytes, so this limit is a rule.
292
+ *
293
+ * @example
294
+ * signedTransferClaimsIssues({ ...claims, comment: "ñ".repeat(31) });
295
+ * // [{ type: "comment_too_long", path: [{ key: "comment" }], requirement: 60 }]
296
+ */
297
+ export declare function signedTransferClaimsIssues(claims: SignedTransferClaims): Issue[];
298
+ /**
299
+ * The rule of a transfer's comment, wherever it sits (signed claims, an Intent proposal, a
300
+ * confirmation): `comment_too_long` at `path` when it has more than
301
+ * {@link TRANSFER_COMMENT_MAX_BYTES} bytes of UTF-8.
302
+ *
303
+ * @example
304
+ * transferCommentIssues("ñ".repeat(31), [{ key: "comment" }]);
305
+ * // [{ type: "comment_too_long", path: [{ key: "comment" }], requirement: 60 }]
306
+ */
307
+ export declare function transferCommentIssues(comment: string | undefined, path: Issue["path"]): Issue[];
308
+ /**
309
+ * Parses the claims of a signed transfer: their shape and then their rules. Parsing never verifies
310
+ * a signature.
311
+ *
312
+ * @example
313
+ * const parsed = parseSignedTransferClaims(claims);
314
+ * if (!parsed.success) console.log(parsed.issues.map((issue) => issue.type));
315
+ */
316
+ export declare function parseSignedTransferClaims(input: unknown): ParseResult<SignedTransferClaims>;
317
+ /** The `typ` of the protected header of every signature over transfer claims v2. */
318
+ export declare const SIGNED_TRANSFER_TYP = "transfer.v1+jwt";
319
+ /**
320
+ * The protected header of one signature, decoded: the algorithm, the `kid` of a Signing Key Pair
321
+ * registered with AndCo, and the versioned `typ`. Strict, so a parameter the
322
+ * verifiers do not understand (`crit`, `b64`) is refused rather than ignored.
323
+ *
324
+ * @example
325
+ * const header: SignedTransferHeader = { alg: "ES256", kid, typ: "transfer.v1+jwt" };
326
+ */
327
+ export declare const SignedTransferHeaderSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
328
+ readonly alg: v.PicklistSchema<["ES256", "RS256"], undefined>;
329
+ readonly kid: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
330
+ readonly typ: v.LiteralSchema<"transfer.v1+jwt", undefined>;
331
+ }, undefined>, v.DescriptionAction<{
332
+ alg: "ES256" | "RS256";
333
+ kid: string;
334
+ typ: "transfer.v1+jwt";
335
+ }, "The protected header of one signature, decoded: `alg` (`ES256` or `RS256`), the `kid` of a registered Signing Key Pair, and `typ` `transfer.v1+jwt`.">]>;
336
+ /** The protected header of one signature over transfer claims, decoded. */
337
+ export type SignedTransferHeader = v.InferOutput<typeof SignedTransferHeaderSchema>;
338
+ /**
339
+ * A signed transfer as it travels: a JWS in the General JSON Serialization (RFC 7515 §7.2.1), one
340
+ * `payload` (the base64url of {@link SignedTransferClaimsSchema}) and a `signatures` array with at
341
+ * least one entry. One signature is an array of one. Every signature is verified. Every header member is protected: an unprotected `header` is
342
+ * refused, because nothing outside the signature may name the key.
343
+ *
344
+ * Each `protected` must decode to {@link SignedTransferHeaderSchema}; that is a rule, because JSON
345
+ * Schema cannot read inside base64url ({@link parseSignedTransferEnvelope}).
346
+ *
347
+ * @example
348
+ * const envelope: SignedTransferEnvelope = {
349
+ * payload: "eyJpc3MiOi…",
350
+ * signatures: [{ protected: "eyJhbGciOiJFUzI1NiIs…", signature: "MEUCIQ…" }],
351
+ * };
352
+ */
353
+ export declare const SignedTransferEnvelopeSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
354
+ readonly payload: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>, v.DescriptionAction<string, "The base64url of the JSON claims (`SignedTransferClaims`).">]>;
355
+ readonly signatures: v.SchemaWithPipe<readonly [v.ArraySchema<v.StrictObjectSchema<{
356
+ readonly protected: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>, v.DescriptionAction<string, "The base64url of the JSON protected header (`SignedTransferHeader`).">]>;
357
+ readonly signature: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>;
358
+ }, undefined>, undefined>, v.MinLengthAction<{
359
+ protected: string;
360
+ signature: string;
361
+ }[], 1, undefined>, v.DescriptionAction<{
362
+ protected: string;
363
+ signature: string;
364
+ }[], "At least one signature over the same payload; every one is verified.">]>;
365
+ }, undefined>, v.DescriptionAction<{
366
+ payload: string;
367
+ signatures: {
368
+ protected: string;
369
+ signature: string;
370
+ }[];
371
+ }, "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`.">]>;
372
+ /** A signed transfer as it travels: a JWS in the General JSON Serialization. */
373
+ export type SignedTransferEnvelope = v.InferOutput<typeof SignedTransferEnvelopeSchema>;
374
+ /**
375
+ * The rules of an envelope that JSON Schema does not say, over an envelope that already has its
376
+ * shape ({@link SignedTransferEnvelopeSchema}). At each signature's `protected`:
377
+ *
378
+ * - `malformed_protected_header` when it is not the base64url of a JSON value;
379
+ * - the issues of {@link SignedTransferHeaderSchema} when the header it decodes to is not one (a
380
+ * `typ` other than `transfer.v1+jwt`, no `kid`, another algorithm).
381
+ *
382
+ * It never verifies a signature.
383
+ *
384
+ * @example
385
+ * signedTransferEnvelopeIssues({ payload, signatures: [{ protected: "bm90LWpzb24", signature }] });
386
+ * // [{ type: "malformed_protected_header", path: [{ key: "signatures" }, { key: 0 }, { key: "protected" }] }]
387
+ */
388
+ export declare function signedTransferEnvelopeIssues(envelope: SignedTransferEnvelope): Issue[];
389
+ /**
390
+ * Parses a signed transfer envelope: its shape and then each signature's protected header. It
391
+ * neither verifies a signature nor reads the payload; the claims are parsed apart with
392
+ * {@link parseSignedTransferClaims} once a signature verifies.
393
+ *
394
+ * @example
395
+ * const parsed = parseSignedTransferEnvelope(await request.json());
396
+ * if (!parsed.success) console.log(parsed.issues.map((issue) => issue.type));
397
+ */
398
+ export declare function parseSignedTransferEnvelope(input: unknown): ParseResult<SignedTransferEnvelope>;
399
+ //# sourceMappingURL=transfer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transfer.d.ts","sourceRoot":"","sources":["../src/transfer.ts"],"names":[],"mappings":"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"}