@andco/protocol 0.0.15 → 0.1.0-ti.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/authorization-preparation.d.ts +1 -1
- package/dist/errors.d.ts +1 -1
- package/dist/errors.js +1 -1
- package/dist/intent-input.d.ts +67 -54
- package/dist/intent-input.d.ts.map +1 -1
- package/dist/intent-input.js +39 -23
- package/dist/intent-status.d.ts +5 -6
- package/dist/intent-status.d.ts.map +1 -1
- package/dist/intent-status.js +12 -7
- package/dist/miniapp-manifest.d.ts +2 -2
- package/dist/miniapp-manifest.js +1 -1
- package/dist/native-intent.d.ts +12 -12
- package/dist/native-intent.d.ts.map +1 -1
- package/dist/native-intent.js +7 -4
- package/dist/rar/account-matchers.d.ts +10 -10
- package/dist/rar/account-matchers.js +2 -2
- package/dist/rar/bank.d.ts +295 -23
- package/dist/rar/bank.d.ts.map +1 -1
- package/dist/rar/bank.js +54 -16
- package/dist/rar/catalog.d.ts +134 -9
- package/dist/rar/catalog.d.ts.map +1 -1
- package/dist/rar/catalog.js +6 -6
- package/dist/rar/json-schemas.generated.d.ts.map +1 -1
- package/dist/rar/json-schemas.generated.js +375 -7
- package/dist/rar/money.d.ts +1 -1
- package/dist/rar/money.js +1 -1
- package/dist/rar/subject-data.d.ts +1 -1
- package/dist/rar/subject-data.js +1 -1
- package/dist/rest/accounts.d.ts +69 -47
- package/dist/rest/accounts.d.ts.map +1 -1
- package/dist/rest/accounts.js +32 -22
- package/dist/rest/catalog.d.ts +3 -3
- package/dist/rest/catalog.js +2 -2
- package/dist/rest/contract.d.ts +581 -316
- package/dist/rest/contract.d.ts.map +1 -1
- package/dist/rest/contract.js +10 -6
- package/dist/rest/events.js +1 -1
- package/dist/rest/identity.d.ts +22 -22
- package/dist/rest/identity.d.ts.map +1 -1
- package/dist/rest/identity.js +4 -4
- package/dist/rest/intents.d.ts +301 -142
- package/dist/rest/intents.d.ts.map +1 -1
- package/dist/rest/intents.js +67 -53
- package/dist/rest/signatures.d.ts +19 -5
- package/dist/rest/signatures.d.ts.map +1 -1
- package/dist/rest/signatures.js +47 -5
- package/dist/rest/transfers.d.ts +738 -362
- package/dist/rest/transfers.d.ts.map +1 -1
- package/dist/rest/transfers.js +71 -44
- package/dist/signing.d.ts +6 -2
- package/dist/signing.d.ts.map +1 -1
- package/dist/signing.js +2 -1
- package/dist/transfer.d.ts +101 -65
- package/dist/transfer.d.ts.map +1 -1
- package/dist/transfer.js +69 -43
- package/dist/transport/financial-events.d.ts +65 -14
- package/dist/transport/financial-events.d.ts.map +1 -1
- package/dist/transport/financial-events.js +34 -0
- package/dist/transport/generated/oauth-api.d.ts +384 -110
- package/dist/transport/generated/oauth-api.d.ts.map +1 -1
- package/dist/transport/intents.d.ts +6 -6
- package/dist/transport/intents.d.ts.map +1 -1
- package/dist/transport/rest.d.ts +9 -8
- package/dist/transport/rest.d.ts.map +1 -1
- package/dist/transport/rest.js +1 -1
- package/package.json +1 -1
package/dist/transfer.d.ts
CHANGED
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
2
|
import { type Issue, type ParseResult } from "./issues.js";
|
|
3
3
|
/**
|
|
4
|
-
* A transfer in
|
|
5
|
-
* Receptor is `receiver
|
|
6
|
-
* system translates between the Platform and the core.
|
|
4
|
+
* A transfer in the transfer vocabulary of the API: the Remitente is `sender` and the
|
|
5
|
+
* Receptor is `receiver`.
|
|
7
6
|
*/
|
|
8
7
|
/**
|
|
9
|
-
* A bank as
|
|
10
|
-
* code against its
|
|
11
|
-
* the known ones, and no validation reads it.
|
|
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.
|
|
12
11
|
*
|
|
13
12
|
* @example
|
|
14
13
|
* v.parse(BankCodeSchema, CHILEAN_BANK_CODES.andco); // "0739"
|
|
15
14
|
*/
|
|
16
|
-
export declare const BankCodeSchema: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>, v.DescriptionAction<string, "The bank's four-digit code
|
|
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`.">]>;
|
|
17
16
|
/**
|
|
18
|
-
* The Chilean banks
|
|
19
|
-
*
|
|
20
|
-
*
|
|
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.
|
|
21
20
|
*
|
|
22
21
|
* @example
|
|
23
22
|
* const receiver = { bank_code: CHILEAN_BANK_CODES.banco_estado }; // "0012"
|
|
@@ -58,28 +57,27 @@ export declare const CHILEAN_BANK_CODES: {
|
|
|
58
57
|
readonly fintoc: "0764";
|
|
59
58
|
readonly mercado_pago: "0875";
|
|
60
59
|
};
|
|
61
|
-
/** The largest transfer amount
|
|
60
|
+
/** The largest transfer amount. */
|
|
62
61
|
export declare const TRANSFER_AMOUNT_MAX = 2147483647;
|
|
63
62
|
/**
|
|
64
|
-
* A transfer amount
|
|
65
|
-
*
|
|
66
|
-
* refused with the issue type `max_value` and `requirement` 2147483647.
|
|
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.
|
|
67
65
|
*
|
|
68
66
|
* @example
|
|
69
67
|
* v.parse(PesosSchema, 40000); // 40000
|
|
70
68
|
*/
|
|
71
|
-
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
|
|
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`.">]>;
|
|
72
70
|
/**
|
|
73
|
-
* A Chilean account type
|
|
74
|
-
* debit (cuenta vista). Every
|
|
71
|
+
* A Chilean account type, by its code: `"10"` savings, `"20"` checking and `"40"`
|
|
72
|
+
* debit (cuenta vista). Every AndCo account is `"40"`.
|
|
75
73
|
*/
|
|
76
|
-
export declare const TransferAccountTypeSchema: v.SchemaWithPipe<readonly [v.PicklistSchema<["10", "20", "40"], undefined>, v.DescriptionAction<"10" | "20" | "40", "
|
|
77
|
-
/** A Chilean account type
|
|
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. */
|
|
78
76
|
export type TransferAccountType = v.InferOutput<typeof TransferAccountTypeSchema>;
|
|
79
77
|
/**
|
|
80
|
-
* The Remitente: the account the money leaves and its holder
|
|
81
|
-
*
|
|
82
|
-
*
|
|
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.
|
|
83
81
|
*
|
|
84
82
|
* @example
|
|
85
83
|
* const sender: TransferSender = {
|
|
@@ -89,12 +87,12 @@ export type TransferAccountType = v.InferOutput<typeof TransferAccountTypeSchema
|
|
|
89
87
|
*/
|
|
90
88
|
export declare const TransferSenderSchema: v.SchemaWithPipe<readonly [v.VariantSchema<"country", [v.StrictObjectSchema<{
|
|
91
89
|
country: v.LiteralSchema<"CL", undefined>;
|
|
92
|
-
bank_code: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>, v.DescriptionAction<string, "The bank's four-digit code
|
|
93
|
-
account_type: v.SchemaWithPipe<readonly [v.PicklistSchema<["10", "20", "40"], undefined>, v.DescriptionAction<"10" | "20" | "40", "
|
|
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).">]>;
|
|
94
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.">]>;
|
|
95
|
-
name: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.DescriptionAction<string, "The holder's name
|
|
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.">]>;
|
|
96
94
|
national_kind_id: v.LiteralSchema<"RUT", undefined>;
|
|
97
|
-
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
|
|
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.">]>;
|
|
98
96
|
}, undefined>], undefined>, v.DescriptionAction<{
|
|
99
97
|
country: "CL";
|
|
100
98
|
bank_code: string;
|
|
@@ -103,11 +101,11 @@ export declare const TransferSenderSchema: v.SchemaWithPipe<readonly [v.VariantS
|
|
|
103
101
|
name: string;
|
|
104
102
|
national_kind_id: "RUT";
|
|
105
103
|
national_id: string;
|
|
106
|
-
}, "The Remitente
|
|
107
|
-
/** The Remitente
|
|
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. */
|
|
108
106
|
export type TransferSender = v.InferOutput<typeof TransferSenderSchema>;
|
|
109
107
|
/**
|
|
110
|
-
* The Receptor: the account the money lands on, its holder and the amount
|
|
108
|
+
* The Receptor: the account the money lands on, its holder and the amount.
|
|
111
109
|
* The amount is an integer number of pesos.
|
|
112
110
|
*
|
|
113
111
|
* @example
|
|
@@ -118,16 +116,16 @@ export type TransferSender = v.InferOutput<typeof TransferSenderSchema>;
|
|
|
118
116
|
* };
|
|
119
117
|
*/
|
|
120
118
|
export declare const TransferReceiverSchema: v.SchemaWithPipe<readonly [v.VariantSchema<"country", [v.StrictObjectSchema<{
|
|
121
|
-
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
|
|
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`.">]>;
|
|
122
120
|
readonly currency: v.LiteralSchema<"CLP", undefined>;
|
|
123
|
-
readonly email: v.SchemaWithPipe<readonly [v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.EmailAction<string, undefined>]>, undefined>, v.DescriptionAction<string | undefined, "Where
|
|
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.">]>;
|
|
124
122
|
readonly country: v.LiteralSchema<"CL", undefined>;
|
|
125
|
-
readonly bank_code: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>, v.DescriptionAction<string, "The bank's four-digit code
|
|
126
|
-
readonly account_type: v.SchemaWithPipe<readonly [v.PicklistSchema<["10", "20", "40"], undefined>, v.DescriptionAction<"10" | "20" | "40", "
|
|
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).">]>;
|
|
127
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.">]>;
|
|
128
|
-
readonly name: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.DescriptionAction<string, "The holder's name
|
|
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.">]>;
|
|
129
127
|
readonly national_kind_id: v.LiteralSchema<"RUT", undefined>;
|
|
130
|
-
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
|
|
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.">]>;
|
|
131
129
|
}, undefined>], undefined>, v.DescriptionAction<{
|
|
132
130
|
amount: number;
|
|
133
131
|
currency: "CLP";
|
|
@@ -139,20 +137,59 @@ export declare const TransferReceiverSchema: v.SchemaWithPipe<readonly [v.Varian
|
|
|
139
137
|
name: string;
|
|
140
138
|
national_kind_id: "RUT";
|
|
141
139
|
national_id: string;
|
|
142
|
-
}, "The Receptor
|
|
143
|
-
/** The Receptor
|
|
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. */
|
|
144
142
|
export type TransferReceiver = v.InferOutput<typeof TransferReceiverSchema>;
|
|
145
143
|
/**
|
|
146
|
-
*
|
|
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
|
|
147
185
|
* envelope (`iss`, `aud`, `jti`, `exp`) and `approved`. `metadata` is the signer's own data, kept as
|
|
148
186
|
* it arrives and read by nothing that decides; there is no `expires_at`, `iat` or `nbf`, because the
|
|
149
|
-
* deadline is `exp`. The
|
|
150
|
-
*
|
|
151
|
-
* unknown claim is refused.
|
|
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.
|
|
152
189
|
*
|
|
153
|
-
* - `jti` is a UUID: it names the Transfer and is
|
|
154
|
-
* - `exp` bounds execution
|
|
155
|
-
* - `approved: true` orders the transfer sent as soon as it is
|
|
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`
|
|
156
193
|
* `approve` in the Project's Grant.
|
|
157
194
|
*
|
|
158
195
|
* @example
|
|
@@ -164,17 +201,17 @@ export type TransferReceiver = v.InferOutput<typeof TransferReceiverSchema>;
|
|
|
164
201
|
export declare const SignedTransferClaimsSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
|
|
165
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`.">]>;
|
|
166
203
|
readonly aud: v.LiteralSchema<"https://api.andco.com", undefined>;
|
|
167
|
-
readonly jti: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.UuidAction<string, undefined>, v.DescriptionAction<string, "
|
|
168
|
-
readonly exp: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.DescriptionAction<number, "Unix seconds after which the
|
|
169
|
-
readonly approved: v.SchemaWithPipe<readonly [v.BooleanSchema<undefined>, v.DescriptionAction<boolean, "`true` orders the transfer sent
|
|
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.">]>;
|
|
170
207
|
readonly sender: v.SchemaWithPipe<readonly [v.VariantSchema<"country", [v.StrictObjectSchema<{
|
|
171
208
|
country: v.LiteralSchema<"CL", undefined>;
|
|
172
|
-
bank_code: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>, v.DescriptionAction<string, "The bank's four-digit code
|
|
173
|
-
account_type: v.SchemaWithPipe<readonly [v.PicklistSchema<["10", "20", "40"], undefined>, v.DescriptionAction<"10" | "20" | "40", "
|
|
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).">]>;
|
|
174
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.">]>;
|
|
175
|
-
name: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.DescriptionAction<string, "The holder's name
|
|
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.">]>;
|
|
176
213
|
national_kind_id: v.LiteralSchema<"RUT", undefined>;
|
|
177
|
-
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
|
|
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.">]>;
|
|
178
215
|
}, undefined>], undefined>, v.DescriptionAction<{
|
|
179
216
|
country: "CL";
|
|
180
217
|
bank_code: string;
|
|
@@ -183,18 +220,18 @@ export declare const SignedTransferClaimsSchema: v.SchemaWithPipe<readonly [v.St
|
|
|
183
220
|
name: string;
|
|
184
221
|
national_kind_id: "RUT";
|
|
185
222
|
national_id: string;
|
|
186
|
-
}, "The Remitente
|
|
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.">]>;
|
|
187
224
|
readonly receiver: v.SchemaWithPipe<readonly [v.VariantSchema<"country", [v.StrictObjectSchema<{
|
|
188
|
-
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
|
|
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`.">]>;
|
|
189
226
|
readonly currency: v.LiteralSchema<"CLP", undefined>;
|
|
190
|
-
readonly email: v.SchemaWithPipe<readonly [v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.EmailAction<string, undefined>]>, undefined>, v.DescriptionAction<string | undefined, "Where
|
|
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.">]>;
|
|
191
228
|
readonly country: v.LiteralSchema<"CL", undefined>;
|
|
192
|
-
readonly bank_code: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>, v.DescriptionAction<string, "The bank's four-digit code
|
|
193
|
-
readonly account_type: v.SchemaWithPipe<readonly [v.PicklistSchema<["10", "20", "40"], undefined>, v.DescriptionAction<"10" | "20" | "40", "
|
|
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).">]>;
|
|
194
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.">]>;
|
|
195
|
-
readonly name: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.DescriptionAction<string, "The holder's name
|
|
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.">]>;
|
|
196
233
|
readonly national_kind_id: v.LiteralSchema<"RUT", undefined>;
|
|
197
|
-
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
|
|
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.">]>;
|
|
198
235
|
}, undefined>], undefined>, v.DescriptionAction<{
|
|
199
236
|
amount: number;
|
|
200
237
|
currency: "CLP";
|
|
@@ -206,7 +243,7 @@ export declare const SignedTransferClaimsSchema: v.SchemaWithPipe<readonly [v.St
|
|
|
206
243
|
name: string;
|
|
207
244
|
national_kind_id: "RUT";
|
|
208
245
|
national_id: string;
|
|
209
|
-
}, "The Receptor
|
|
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.">]>;
|
|
210
247
|
readonly comment: v.SchemaWithPipe<readonly [v.OptionalSchema<v.StringSchema<undefined>, undefined>, v.DescriptionAction<string | undefined, "What both sides read next to the movement.">]>;
|
|
211
248
|
readonly metadata: v.SchemaWithPipe<readonly [v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, undefined>, v.DescriptionAction<{
|
|
212
249
|
[x: string]: unknown;
|
|
@@ -242,10 +279,10 @@ export declare const SignedTransferClaimsSchema: v.SchemaWithPipe<readonly [v.St
|
|
|
242
279
|
metadata?: {
|
|
243
280
|
[x: string]: unknown;
|
|
244
281
|
} | undefined;
|
|
245
|
-
}, "The claims of a signed transfer (`typ` `transfer.v1+jwt`):
|
|
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`.">]>;
|
|
246
283
|
/** The claims of a signed transfer, version 2. */
|
|
247
284
|
export type SignedTransferClaims = v.InferOutput<typeof SignedTransferClaimsSchema>;
|
|
248
|
-
/** The most bytes
|
|
285
|
+
/** The most bytes of a transfer's comment, counted in UTF-8. */
|
|
249
286
|
export declare const TRANSFER_COMMENT_MAX_BYTES = 60;
|
|
250
287
|
/**
|
|
251
288
|
* The rules of signed transfer claims that JSON Schema does not say, over claims that already have
|
|
@@ -281,7 +318,7 @@ export declare function parseSignedTransferClaims(input: unknown): ParseResult<S
|
|
|
281
318
|
export declare const SIGNED_TRANSFER_TYP = "transfer.v1+jwt";
|
|
282
319
|
/**
|
|
283
320
|
* The protected header of one signature, decoded: the algorithm, the `kid` of a Signing Key Pair
|
|
284
|
-
* registered
|
|
321
|
+
* registered with AndCo, and the versioned `typ`. Strict, so a parameter the
|
|
285
322
|
* verifiers do not understand (`crit`, `b64`) is refused rather than ignored.
|
|
286
323
|
*
|
|
287
324
|
* @example
|
|
@@ -301,8 +338,7 @@ export type SignedTransferHeader = v.InferOutput<typeof SignedTransferHeaderSche
|
|
|
301
338
|
/**
|
|
302
339
|
* A signed transfer as it travels: a JWS in the General JSON Serialization (RFC 7515 §7.2.1), one
|
|
303
340
|
* `payload` (the base64url of {@link SignedTransferClaimsSchema}) and a `signatures` array with at
|
|
304
|
-
* least one entry. One signature is an array of one.
|
|
305
|
-
* which verifies every signature. Every header member is protected: an unprotected `header` is
|
|
341
|
+
* least one entry. One signature is an array of one. Every signature is verified. Every header member is protected: an unprotected `header` is
|
|
306
342
|
* refused, because nothing outside the signature may name the key.
|
|
307
343
|
*
|
|
308
344
|
* Each `protected` must decode to {@link SignedTransferHeaderSchema}; that is a rule, because JSON
|
|
@@ -325,7 +361,7 @@ export declare const SignedTransferEnvelopeSchema: v.SchemaWithPipe<readonly [v.
|
|
|
325
361
|
}[], 1, undefined>, v.DescriptionAction<{
|
|
326
362
|
protected: string;
|
|
327
363
|
signature: string;
|
|
328
|
-
}[], "At least one signature over the same payload;
|
|
364
|
+
}[], "At least one signature over the same payload; every one is verified.">]>;
|
|
329
365
|
}, undefined>, v.DescriptionAction<{
|
|
330
366
|
payload: string;
|
|
331
367
|
signatures: {
|
package/dist/transfer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transfer.d.ts","sourceRoot":"","sources":["../src/transfer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAE7B,OAAO,EAAE,KAAK,KAAK,EAAsB,KAAK,WAAW,EAAkB,MAAM,aAAa,CAAC;AAE/F
|
|
1
|
+
{"version":3,"file":"transfer.d.ts","sourceRoot":"","sources":["../src/transfer.ts"],"names":[],"mappings":"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"}
|
package/dist/transfer.js
CHANGED
|
@@ -2,23 +2,22 @@ import * as v from "valibot";
|
|
|
2
2
|
import { ANDCO_API_ORIGIN } from "./constants.js";
|
|
3
3
|
import { issuesAt, issuesOf, parseWithRules } from "./issues.js";
|
|
4
4
|
/**
|
|
5
|
-
* A transfer in
|
|
6
|
-
* Receptor is `receiver
|
|
7
|
-
* system translates between the Platform and the core.
|
|
5
|
+
* A transfer in the transfer vocabulary of the API: the Remitente is `sender` and the
|
|
6
|
+
* Receptor is `receiver`.
|
|
8
7
|
*/
|
|
9
8
|
/**
|
|
10
|
-
* A bank as
|
|
11
|
-
* code against its
|
|
12
|
-
* the known ones, and no validation reads it.
|
|
9
|
+
* A bank as the API names it: four digits. The schema checks only the form, because the API
|
|
10
|
+
* validates the code against its bank catalog and a copy of that list would drift.
|
|
11
|
+
* {@link CHILEAN_BANK_CODES} names the known ones, and no validation reads it.
|
|
13
12
|
*
|
|
14
13
|
* @example
|
|
15
14
|
* v.parse(BankCodeSchema, CHILEAN_BANK_CODES.andco); // "0739"
|
|
16
15
|
*/
|
|
17
|
-
export const BankCodeSchema = /* @__PURE__ */ v.pipe(v.string(), v.regex(/^\d{4}$/), v.description("The bank's four-digit code
|
|
16
|
+
export const BankCodeSchema = /* @__PURE__ */ v.pipe(v.string(), v.regex(/^\d{4}$/), v.description("The bank's four-digit code, as `GET /catalogs/banks` lists it. AndCo is `0739`."));
|
|
18
17
|
/**
|
|
19
|
-
* The Chilean banks
|
|
20
|
-
*
|
|
21
|
-
*
|
|
18
|
+
* The Chilean banks by code, as `GET /catalogs/banks` lists them. A helper for whoever writes a
|
|
19
|
+
* `bank_code`: no schema reads it, so a bank the catalog adds later is accepted before this list
|
|
20
|
+
* knows it.
|
|
22
21
|
*
|
|
23
22
|
* @example
|
|
24
23
|
* const receiver = { bank_code: CHILEAN_BANK_CODES.banco_estado }; // "0012"
|
|
@@ -59,25 +58,24 @@ export const CHILEAN_BANK_CODES = {
|
|
|
59
58
|
fintoc: "0764",
|
|
60
59
|
mercado_pago: "0875",
|
|
61
60
|
};
|
|
62
|
-
/** The largest transfer amount
|
|
61
|
+
/** The largest transfer amount. */
|
|
63
62
|
export const TRANSFER_AMOUNT_MAX = 2_147_483_647;
|
|
64
63
|
/**
|
|
65
|
-
* A transfer amount
|
|
66
|
-
*
|
|
67
|
-
* refused with the issue type `max_value` and `requirement` 2147483647.
|
|
64
|
+
* A transfer amount: a JSON integer in the minor unit of the currency (CLP: whole pesos), from 1 to
|
|
65
|
+
* {@link TRANSFER_AMOUNT_MAX}. A larger one is refused with the issue type `max_value` and `requirement` 2147483647.
|
|
68
66
|
*
|
|
69
67
|
* @example
|
|
70
68
|
* v.parse(PesosSchema, 40000); // 40000
|
|
71
69
|
*/
|
|
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
|
|
70
|
+
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. A larger one is refused with `max_value`."));
|
|
73
71
|
/**
|
|
74
|
-
* A Chilean account type
|
|
75
|
-
* debit (cuenta vista). Every
|
|
72
|
+
* A Chilean account type, by its code: `"10"` savings, `"20"` checking and `"40"`
|
|
73
|
+
* debit (cuenta vista). Every AndCo account is `"40"`.
|
|
76
74
|
*/
|
|
77
|
-
export const TransferAccountTypeSchema = /* @__PURE__ */ v.pipe(v.picklist(["10", "20", "40"]), v.description('
|
|
75
|
+
export const TransferAccountTypeSchema = /* @__PURE__ */ v.pipe(v.picklist(["10", "20", "40"]), v.description('The account type code: `"10"` savings, `"20"` checking, `"40"` debit (cuenta vista).'));
|
|
78
76
|
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
|
|
80
|
-
const holderName = /* @__PURE__ */ v.pipe(v.string(), v.minLength(1), v.description("The holder's name
|
|
77
|
+
const nationalId = /* @__PURE__ */ v.pipe(v.string(), v.minLength(1), v.maxLength(64), v.description("The holder's RUT, compared as a normalized RUT."));
|
|
78
|
+
const holderName = /* @__PURE__ */ v.pipe(v.string(), v.minLength(1), v.description("The holder's name, kept as it arrives and never compared."));
|
|
81
79
|
/**
|
|
82
80
|
* An account in Chile and its holder, with nothing inferred: the country and the kind of document
|
|
83
81
|
* are always declared. Another country is a new variant, never a code clash.
|
|
@@ -92,9 +90,9 @@ const chileanAccount = {
|
|
|
92
90
|
national_id: nationalId,
|
|
93
91
|
};
|
|
94
92
|
/**
|
|
95
|
-
* The Remitente: the account the money leaves and its holder
|
|
96
|
-
*
|
|
97
|
-
*
|
|
93
|
+
* The Remitente: the account the money leaves and its holder. It is checked against the account's
|
|
94
|
+
* holder (`country`, `bank_code` `0739`, the account's own `account_type` and the holder's RUT);
|
|
95
|
+
* `name` is kept as it arrives.
|
|
98
96
|
*
|
|
99
97
|
* @example
|
|
100
98
|
* const sender: TransferSender = {
|
|
@@ -102,9 +100,9 @@ const chileanAccount = {
|
|
|
102
100
|
* name: "ACME SpA", national_kind_id: "RUT", national_id: "76.111.111-1",
|
|
103
101
|
* };
|
|
104
102
|
*/
|
|
105
|
-
export const TransferSenderSchema = /* @__PURE__ */ v.pipe(v.variant("country", [v.strictObject(chileanAccount)]), v.description("The Remitente
|
|
103
|
+
export const TransferSenderSchema = /* @__PURE__ */ v.pipe(v.variant("country", [v.strictObject(chileanAccount)]), v.description("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."));
|
|
106
104
|
/**
|
|
107
|
-
* The Receptor: the account the money lands on, its holder and the amount
|
|
105
|
+
* The Receptor: the account the money lands on, its holder and the amount.
|
|
108
106
|
* The amount is an integer number of pesos.
|
|
109
107
|
*
|
|
110
108
|
* @example
|
|
@@ -119,20 +117,49 @@ export const TransferReceiverSchema = /* @__PURE__ */ v.pipe(v.variant("country"
|
|
|
119
117
|
...chileanAccount,
|
|
120
118
|
amount: PesosSchema,
|
|
121
119
|
currency: v.literal("CLP"),
|
|
122
|
-
email: v.pipe(v.optional(v.pipe(v.string(), v.email())), v.description("Where
|
|
120
|
+
email: v.pipe(v.optional(v.pipe(v.string(), v.email())), v.description("Where the Receptor is notified.")),
|
|
123
121
|
}),
|
|
124
|
-
]), v.description("The Receptor
|
|
122
|
+
]), v.description("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."));
|
|
125
123
|
/**
|
|
126
|
-
*
|
|
124
|
+
* One side of a Transfer as the API answers it: the account and its holder, without the amount. The
|
|
125
|
+
* Remitente and the Receptor have these same seven fields. A Transfer made in the issuer's own
|
|
126
|
+
* channels can lack the holder's `name` and document, so those three are nullable.
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* const party: TransferParty = {
|
|
130
|
+
* country: "CL", bank_code: "0739", account_type: "40", account_number: "000123456789",
|
|
131
|
+
* name: "ACME SpA", national_kind_id: "RUT", national_id: "76111111-1",
|
|
132
|
+
* };
|
|
133
|
+
*/
|
|
134
|
+
export const TransferPartySchema = /* @__PURE__ */ v.pipe(v.strictObject({
|
|
135
|
+
country: v.pipe(v.string(), v.minLength(1), v.description("The country of the account, for example `CL`.")),
|
|
136
|
+
bank_code: BankCodeSchema,
|
|
137
|
+
account_type: TransferAccountTypeSchema,
|
|
138
|
+
account_number: accountNumber,
|
|
139
|
+
name: v.pipe(v.nullable(v.string()), v.description("The holder's name, or null when it is not known.")),
|
|
140
|
+
national_kind_id: v.pipe(v.nullable(v.string()), v.description("The kind of the holder's document, for example `RUT`, or null when it is not known.")),
|
|
141
|
+
national_id: v.pipe(v.nullable(v.string()), v.description("The holder's document number, or null when it is not known.")),
|
|
142
|
+
}), v.description("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."));
|
|
143
|
+
/**
|
|
144
|
+
* The `jti` of a signed transfer: a UUID written in lowercase. It names the Transfer and is its
|
|
145
|
+
* idempotency-key, which a bank compares as a string, so two spellings of one UUID would be two
|
|
146
|
+
* different keys. The same schema reads the `jti` query of `GET /transfers`.
|
|
147
|
+
*
|
|
148
|
+
* @example
|
|
149
|
+
* v.parse(SignedTransferJtiSchema, crypto.randomUUID()); // a lowercase UUID passes
|
|
150
|
+
* v.is(SignedTransferJtiSchema, crypto.randomUUID().toUpperCase()); // false
|
|
151
|
+
*/
|
|
152
|
+
export const SignedTransferJtiSchema = /* @__PURE__ */ v.pipe(v.string(), v.uuid(), v.regex(/^[0-9a-f-]{36}$/, "jti must be a lowercase UUID"), v.description("A UUID in lowercase. It names the Transfer: it is its idempotency-key. The same `jti` with other content is a conflict."));
|
|
153
|
+
/**
|
|
154
|
+
* The claims of a signed transfer, version 2: `sender`, `receiver` and `comment`, signed, plus the
|
|
127
155
|
* envelope (`iss`, `aud`, `jti`, `exp`) and `approved`. `metadata` is the signer's own data, kept as
|
|
128
156
|
* it arrives and read by nothing that decides; there is no `expires_at`, `iat` or `nbf`, because the
|
|
129
|
-
* deadline is `exp`. The
|
|
130
|
-
*
|
|
131
|
-
* unknown claim is refused.
|
|
157
|
+
* deadline is `exp`. The API verifies the signature and executes the payload as signed, so nothing
|
|
158
|
+
* here names an Account Key or an AndCo account id, and an unknown claim is refused.
|
|
132
159
|
*
|
|
133
|
-
* - `jti` is a UUID: it names the Transfer and is
|
|
134
|
-
* - `exp` bounds execution
|
|
135
|
-
* - `approved: true` orders the transfer sent as soon as it is
|
|
160
|
+
* - `jti` is a lowercase UUID: it names the Transfer and is its idempotency-key.
|
|
161
|
+
* - `exp` bounds execution, and is part of what the `jti` names.
|
|
162
|
+
* - `approved: true` orders the transfer sent as soon as it is submitted; it needs `bank_transfer`
|
|
136
163
|
* `approve` in the Project's Grant.
|
|
137
164
|
*
|
|
138
165
|
* @example
|
|
@@ -144,15 +171,15 @@ export const TransferReceiverSchema = /* @__PURE__ */ v.pipe(v.variant("country"
|
|
|
144
171
|
export const SignedTransferClaimsSchema = /* @__PURE__ */ v.pipe(v.strictObject({
|
|
145
172
|
iss: v.pipe(v.string(), v.minLength(1), v.maxLength(64), v.description("The signing Project's `client_id`.")),
|
|
146
173
|
aud: v.literal(ANDCO_API_ORIGIN),
|
|
147
|
-
jti:
|
|
148
|
-
exp: v.pipe(v.number(), v.integer(), v.description("Unix seconds after which the
|
|
149
|
-
approved: v.pipe(v.boolean(), v.description("`true` orders the transfer sent
|
|
174
|
+
jti: SignedTransferJtiSchema,
|
|
175
|
+
exp: v.pipe(v.number(), v.integer(), v.description("Unix seconds after which the transfer is refused.")),
|
|
176
|
+
approved: v.pipe(v.boolean(), v.description("`true` orders the transfer sent as soon as it is submitted, which needs `bank_transfer` `approve` in the Grant.")),
|
|
150
177
|
sender: TransferSenderSchema,
|
|
151
178
|
receiver: TransferReceiverSchema,
|
|
152
179
|
comment: v.pipe(v.optional(v.string()), v.description("What both sides read next to the movement.")),
|
|
153
180
|
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`):
|
|
155
|
-
/** The most bytes
|
|
181
|
+
}), v.description("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`."));
|
|
182
|
+
/** The most bytes of a transfer's comment, counted in UTF-8. */
|
|
156
183
|
export const TRANSFER_COMMENT_MAX_BYTES = 60;
|
|
157
184
|
/**
|
|
158
185
|
* The rules of signed transfer claims that JSON Schema does not say, over claims that already have
|
|
@@ -198,7 +225,7 @@ export const SIGNED_TRANSFER_TYP = "transfer.v1+jwt";
|
|
|
198
225
|
const base64url = /* @__PURE__ */ v.pipe(v.string(), v.regex(/^[A-Za-z0-9_-]+$/));
|
|
199
226
|
/**
|
|
200
227
|
* The protected header of one signature, decoded: the algorithm, the `kid` of a Signing Key Pair
|
|
201
|
-
* registered
|
|
228
|
+
* registered with AndCo, and the versioned `typ`. Strict, so a parameter the
|
|
202
229
|
* verifiers do not understand (`crit`, `b64`) is refused rather than ignored.
|
|
203
230
|
*
|
|
204
231
|
* @example
|
|
@@ -212,8 +239,7 @@ export const SignedTransferHeaderSchema = /* @__PURE__ */ v.pipe(v.strictObject(
|
|
|
212
239
|
/**
|
|
213
240
|
* A signed transfer as it travels: a JWS in the General JSON Serialization (RFC 7515 §7.2.1), one
|
|
214
241
|
* `payload` (the base64url of {@link SignedTransferClaimsSchema}) and a `signatures` array with at
|
|
215
|
-
* least one entry. One signature is an array of one.
|
|
216
|
-
* which verifies every signature. Every header member is protected: an unprotected `header` is
|
|
242
|
+
* least one entry. One signature is an array of one. Every signature is verified. Every header member is protected: an unprotected `header` is
|
|
217
243
|
* refused, because nothing outside the signature may name the key.
|
|
218
244
|
*
|
|
219
245
|
* Each `protected` must decode to {@link SignedTransferHeaderSchema}; that is a rule, because JSON
|
|
@@ -230,7 +256,7 @@ export const SignedTransferEnvelopeSchema = /* @__PURE__ */ v.pipe(v.strictObjec
|
|
|
230
256
|
signatures: v.pipe(v.array(v.strictObject({
|
|
231
257
|
protected: v.pipe(base64url, v.description("The base64url of the JSON protected header (`SignedTransferHeader`).")),
|
|
232
258
|
signature: base64url,
|
|
233
|
-
})), v.minLength(1), v.description("At least one signature over the same payload;
|
|
259
|
+
})), v.minLength(1), v.description("At least one signature over the same payload; every one is verified.")),
|
|
234
260
|
}), 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
261
|
/** Decodes base64url into the JSON value it carries, or `undefined` when it carries none. */
|
|
236
262
|
function DECODE_BASE64URL_JSON(value) {
|