@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.
- package/README.md +2 -2
- package/dist/api-errors.d.ts +9 -9
- package/dist/api-errors.js +9 -9
- package/dist/authorization-preparation.js +2 -2
- package/dist/authorization.d.ts +1 -1
- package/dist/authorization.js +1 -1
- package/dist/consent.d.ts +2 -2
- package/dist/consent.js +2 -2
- package/dist/errors.d.ts +9 -9
- package/dist/errors.js +9 -9
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/intent-input.d.ts +431 -872
- package/dist/intent-input.d.ts.map +1 -1
- package/dist/intent-input.js +142 -121
- package/dist/miniapp-manifest.d.ts +1 -1
- package/dist/native-intent.d.ts +82 -68
- package/dist/native-intent.d.ts.map +1 -1
- package/dist/native-intent.js +134 -84
- package/dist/native.d.ts +1 -1
- package/dist/rar/account-matchers.d.ts +35 -30
- package/dist/rar/account-matchers.d.ts.map +1 -1
- package/dist/rar/account-matchers.js +27 -21
- package/dist/rar/bank.d.ts +81 -81
- package/dist/rar/bank.js +1 -1
- package/dist/rar/catalog.d.ts +48 -48
- package/dist/rar/catalog.js +6 -6
- package/dist/rar/detail.d.ts +1 -1
- package/dist/rar/detail.js +1 -1
- package/dist/rar/json-schemas.generated.d.ts +1 -1
- package/dist/rar/json-schemas.generated.d.ts.map +1 -1
- package/dist/rar/json-schemas.generated.js +25 -21
- package/dist/rar/subject-data.d.ts +1 -1
- package/dist/rar/subject-data.js +1 -1
- package/dist/rar/subject.d.ts +1 -1
- package/dist/rar/subject.js +1 -1
- package/dist/rest/accounts.d.ts +28 -28
- package/dist/rest/accounts.d.ts.map +1 -1
- package/dist/rest/accounts.js +22 -22
- package/dist/rest/api-error.d.ts +1 -1
- package/dist/rest/api-error.js +1 -1
- package/dist/rest/catalog.d.ts +3 -3
- package/dist/rest/catalog.js +2 -2
- package/dist/rest/common.d.ts +3 -3
- package/dist/rest/common.js +3 -3
- package/dist/rest/contract.d.ts +905 -528
- package/dist/rest/contract.d.ts.map +1 -1
- package/dist/rest/contract.js +17 -5
- package/dist/rest/events.d.ts +1 -1
- package/dist/rest/events.d.ts.map +1 -1
- package/dist/rest/events.js +2 -2
- package/dist/rest/identity.d.ts +22 -22
- package/dist/rest/identity.js +5 -5
- package/dist/rest/index.d.ts +1 -0
- package/dist/rest/index.d.ts.map +1 -1
- package/dist/rest/index.js +1 -0
- package/dist/rest/intents.d.ts +787 -716
- package/dist/rest/intents.d.ts.map +1 -1
- package/dist/rest/intents.js +62 -53
- package/dist/rest/signatures.d.ts +11 -5
- package/dist/rest/signatures.d.ts.map +1 -1
- package/dist/rest/signatures.js +10 -0
- package/dist/rest/transfers.d.ts +612 -0
- package/dist/rest/transfers.d.ts.map +1 -0
- package/dist/rest/transfers.js +115 -0
- package/dist/scopes.d.ts +1 -1
- package/dist/signing.d.ts +12 -2
- package/dist/signing.d.ts.map +1 -1
- package/dist/signing.js +6 -0
- package/dist/transfer.d.ts +363 -0
- package/dist/transfer.d.ts.map +1 -0
- package/dist/transfer.js +287 -0
- package/dist/transport/financial-events.d.ts +21 -17
- package/dist/transport/financial-events.d.ts.map +1 -1
- package/dist/transport/generated/oauth-api.d.ts +1017 -194
- package/dist/transport/generated/oauth-api.d.ts.map +1 -1
- package/dist/transport/intents.d.ts +28 -12
- package/dist/transport/intents.d.ts.map +1 -1
- package/dist/transport/intents.js +1 -1
- package/dist/transport/rest.d.ts +4 -4
- package/dist/urls.d.ts +2 -2
- package/dist/urls.js +3 -3
- package/dist/userinfo.d.ts +2 -2
- package/dist/userinfo.js +2 -2
- package/dist/webhooks.d.ts +16 -16
- package/dist/webhooks.js +14 -14
- package/dist/window-features.d.ts +2 -2
- package/dist/window-features.js +2 -2
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intent-input.d.ts","sourceRoot":"","sources":["../src/intent-input.ts"],"names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,kBAAkB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAEhF,8EAA8E;AAC9E,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,GAAG,WAAW,CAAC,kBAAkB,CAAC,CAEvF;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB;;aAA6D,CAAC;AAEhG,uFAAuF;AACvF,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAE1E,2EAA2E;AAC3E,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,WAAW,CAAC,eAAe,CAAC,CAEjF;AAED;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB;IACnC,4EAA4E;;IAE5E;;;OAGG;;IAEH;;;;;;OAMG;;IAEH;;;;;;OAMG;;IAEH;;;;;;OAMG;;CAEK,CAAC;AAEX;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAWzE;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;aASrC,CAAC;AAEH,sFAAsF;AACtF,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAEpF;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,IAAI,CAAC,oBAAoB,EAAE,SAAS,GAAG,UAAU,CAAC,GAAG,KAAK,EAAE,CAE7G;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,OAAO,GAAG,WAAW,CAAC,oBAAoB,CAAC,CAE3F"}
|
package/dist/intent-input.js
CHANGED
|
@@ -3,6 +3,7 @@ import { ANDCO_API_ORIGIN } from "./constants.js";
|
|
|
3
3
|
import { parseWithRules } from "./issues.js";
|
|
4
4
|
import { AccountKeySchema } from "./rar/account-matchers.js";
|
|
5
5
|
import { MoneySchema } from "./rar/money.js";
|
|
6
|
+
import { BankCodeSchema, PesosSchema, TransferAccountTypeSchema, transferCommentIssues } from "./transfer.js";
|
|
6
7
|
const text = (max) => v.pipe(v.string(), v.trim(), v.minLength(1), v.maxLength(max));
|
|
7
8
|
/** A person's or an account's name, trimmed and never blank. Its length is a rule, in code points. */
|
|
8
9
|
const nameText = /* @__PURE__ */ v.pipe(v.string(), v.trim(), v.minLength(1));
|
|
@@ -21,97 +22,114 @@ export const IntentAmountSchema = /* @__PURE__ */ v.pipe(v.strictObject({
|
|
|
21
22
|
}), v.description("The amount a deposit asks for. `editable: true` lets the payer change it on the screen. It is never what moved: a deposit answers that in `progress.credited`."));
|
|
22
23
|
/**
|
|
23
24
|
* The amount a transfer proposes. `editable: true` lets the person who confirms set the amount on
|
|
24
|
-
*
|
|
25
|
-
* against the Grant's `transactions.minimum` and `transactions.maximum` and the
|
|
26
|
-
* Without `editable` (or with `false`) the amount is locked. What moved is `settled`.
|
|
25
|
+
* AndCo's confirmation screen, and `value` is the initial proposal shown there; the server checks it
|
|
26
|
+
* against the Grant's `transactions.minimum` and `transactions.maximum` and the balance.
|
|
27
|
+
* Without `editable` (or with `false`) the amount is locked. What moved is `settled`. `value` is
|
|
28
|
+
* an integer in the minor unit of the currency (CLP: whole pesos), at most 2147483647, as Core's body carries it.
|
|
27
29
|
*
|
|
28
30
|
* @example
|
|
29
|
-
* const amount = { currency: "CLP", value:
|
|
31
|
+
* const amount = { currency: "CLP", value: 40000, editable: true };
|
|
30
32
|
*/
|
|
31
33
|
export const TransferAmountProposalSchema = /* @__PURE__ */ v.pipe(v.strictObject({
|
|
32
34
|
currency: v.literal("CLP"),
|
|
33
|
-
value:
|
|
35
|
+
value: PesosSchema,
|
|
34
36
|
editable: v.pipe(v.optional(v.boolean(), false), v.description("Defaults to false when omitted.")),
|
|
35
|
-
}), v.description("The amount a transfer proposes. `editable: true` lets the person who confirms set the amount on
|
|
37
|
+
}), v.description("The amount a transfer proposes: `value` is an integer in the minor unit of the currency (CLP: whole pesos), at most 2147483647 (int4, as Core stores it). `editable: true` lets the person who confirms set the amount on AndCo's confirmation screen, and `value` is the initial proposal shown there; the amount must fall within the Grant's `transactions.minimum` and `transactions.maximum` and not exceed the balance. Without `editable` (or with `false`) the amount is locked. What moved is `settled`."));
|
|
36
38
|
/**
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
+
* An amount with nothing left for a person to change: the same `{ currency, value }` as a request,
|
|
40
|
+
* without `editable`. It is how an event reports an amount.
|
|
39
41
|
*/
|
|
40
|
-
export const SignedAmountSchema = /* @__PURE__ */ v.pipe(v.strictObject({ currency: v.literal("CLP"), value: MoneySchema }), v.description("
|
|
42
|
+
export const SignedAmountSchema = /* @__PURE__ */ v.pipe(v.strictObject({ currency: v.literal("CLP"), value: MoneySchema }), v.description("An amount with nothing left for a person to change: the same `{ currency, value }` as a request, without `editable`."));
|
|
43
|
+
/**
|
|
44
|
+
* The comment a transfer asks for, Core's `comment`: at most 60 bytes of UTF-8, which is a rule
|
|
45
|
+
* (`comment_too_long`). `editable: true` lets the person who confirms change it.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* const comment = { value: "Factura 42", editable: true };
|
|
49
|
+
*/
|
|
50
|
+
export const TransferCommentProposalSchema = /* @__PURE__ */ v.pipe(v.strictObject({
|
|
51
|
+
value: v.pipe(v.pipe(v.string(), v.trim()), v.description("Trimmed comment. An empty one is allowed.")),
|
|
52
|
+
editable: v.pipe(v.optional(v.boolean(), false), v.description("Defaults to false when omitted.")),
|
|
53
|
+
}), v.description("The comment a transfer asks for, as Core's `comment`: at most 60 bytes of UTF-8 (`comment_too_long`). `editable: true` lets the person who confirms change it; the comment freezes at confirmation."));
|
|
41
54
|
// `MoneySchema`'s pattern is the whole bound of an amount: at most 15 digits, which also keeps every
|
|
42
55
|
// value inside `Number.MAX_SAFE_INTEGER` for whoever converts it. JSON Schema says the same pattern,
|
|
43
56
|
// so no numeric check sits on top, and an amount never goes through `Number()` here.
|
|
44
57
|
/** A note's text, trimmed. Its length is a rule ({@link NOTE_MAX_LENGTH}), counted in code points. */
|
|
45
58
|
const noteText = /* @__PURE__ */ v.pipe(v.string(), v.trim());
|
|
46
59
|
/**
|
|
47
|
-
* The
|
|
60
|
+
* The comment a request asks for. `editable: true` lets the person who confirms change it.
|
|
48
61
|
*
|
|
49
62
|
* @example
|
|
50
63
|
* const note = { value: "Factura 42", editable: true };
|
|
51
64
|
*/
|
|
52
65
|
export const IntentNoteSchema = /* @__PURE__ */ v.pipe(v.strictObject({
|
|
53
|
-
value: v.pipe(noteText, v.description("Trimmed
|
|
66
|
+
value: v.pipe(noteText, v.description("Trimmed comment. An empty reference is allowed.")),
|
|
54
67
|
editable: v.pipe(v.optional(v.boolean(), false), v.description("Defaults to false when omitted.")),
|
|
55
|
-
}), v.description("The
|
|
68
|
+
}), v.description("The comment a request asks for. `editable: true` lets the person who confirms change it; each operation freezes its own final note at confirmation."));
|
|
56
69
|
/**
|
|
57
70
|
* The account a transfer names, in the vocabulary of the `bank_transfer` matchers it has to fit:
|
|
58
|
-
* `{ type: "account_key", accountKey }` and `{ type: "account", id }` name one
|
|
59
|
-
* `{ type: "external", ... }` names
|
|
60
|
-
* `external` matcher can fix. A transfer names exactly one account, so nothing
|
|
71
|
+
* `{ type: "account_key", accountKey }` and `{ type: "account", id }` name one AndCo account, and
|
|
72
|
+
* `{ type: "external", ... }` names a Receptor at a Chilean bank in Core's vocabulary (ADR 0093),
|
|
73
|
+
* with every field the `external` matcher can fix. A transfer names exactly one account, so nothing
|
|
74
|
+
* here is a pattern.
|
|
61
75
|
*
|
|
62
76
|
* @example
|
|
63
77
|
* const source: TransferAccount = { type: "account_key", accountKey: "caja-santiago" };
|
|
64
78
|
* const payroll: TransferAccount = {
|
|
65
|
-
* type: "external",
|
|
66
|
-
*
|
|
79
|
+
* type: "external", country: "CL", bank_code: "0001", account_type: "20", account_number: "1234567890",
|
|
80
|
+
* name: "Ada Lovelace", national_kind_id: "RUT", national_id: "12345678-5",
|
|
67
81
|
* };
|
|
68
82
|
*/
|
|
69
83
|
const transferAccountKey = { type: /* @__PURE__ */ v.literal("account_key"), accountKey: AccountKeySchema };
|
|
70
84
|
const transferAccount = { type: /* @__PURE__ */ v.literal("account"), id: accountId };
|
|
71
85
|
const transferExternal = {
|
|
72
86
|
type: /* @__PURE__ */ v.literal("external"),
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
87
|
+
country: /* @__PURE__ */ v.literal("CL"),
|
|
88
|
+
bank_code: BankCodeSchema,
|
|
89
|
+
account_type: TransferAccountTypeSchema,
|
|
90
|
+
account_number: text(64),
|
|
91
|
+
name: /* @__PURE__ */ v.pipe(nameText, v.description("The holder's name, at most 256 code points (`holder_name_too_long`).")),
|
|
92
|
+
national_kind_id: /* @__PURE__ */ v.literal("RUT"),
|
|
93
|
+
national_id: /* @__PURE__ */ v.pipe(text(64), v.description("The holder's RUT.")),
|
|
78
94
|
};
|
|
79
|
-
/** One
|
|
80
|
-
export const IntentAccountKeySchema = /* @__PURE__ */ v.pipe(v.strictObject(transferAccountKey), v.description("One
|
|
81
|
-
/** One
|
|
82
|
-
export const IntentAccountIdSchema = /* @__PURE__ */ v.pipe(v.strictObject(transferAccount), v.description("One
|
|
83
|
-
/**
|
|
84
|
-
|
|
95
|
+
/** One AndCo account of the Grant's subject, named by its Account Key. */
|
|
96
|
+
export const IntentAccountKeySchema = /* @__PURE__ */ v.pipe(v.strictObject(transferAccountKey), v.description("One AndCo account of the Grant's subject, named by its Account Key."));
|
|
97
|
+
/** One AndCo account, named by its identifier. */
|
|
98
|
+
export const IntentAccountIdSchema = /* @__PURE__ */ v.pipe(v.strictObject(transferAccount), v.description("One AndCo account, named by its identifier."));
|
|
99
|
+
/**
|
|
100
|
+
* A Receptor at a Chilean bank, in Core's vocabulary: the fields of Core's `receiver` without the
|
|
101
|
+
* amount, which the Intent carries apart. `country` and `national_kind_id` are always declared.
|
|
102
|
+
*/
|
|
103
|
+
export const IntentAccountExternalSchema = /* @__PURE__ */ v.pipe(v.strictObject(transferExternal), v.description('A Receptor at a Chilean bank, in Core\'s vocabulary (`receiver` without the amount): the four-digit `bank_code` (Andco is `0739`), the `account_type` code (`"10"` savings, `"20"` checking, `"40"` debit), the `account_number`, and the holder\'s `name` and RUT. `country` and `national_kind_id` are always declared. It carries every field a `bank_transfer` `external` matcher can fix, so the Grant\'s destinations are asked about exactly this account.'));
|
|
85
104
|
/**
|
|
86
|
-
* One
|
|
105
|
+
* One AndCo account of the Grant's subject, named by Account Key or by identifier: where a
|
|
87
106
|
* transfer's money leaves from, where a deposit lands, and the account a closure closes.
|
|
88
107
|
*
|
|
89
108
|
* @example
|
|
90
109
|
* const account: IntentAccount = { type: "account_key", accountKey: "ventas" };
|
|
91
110
|
*/
|
|
92
|
-
export const IntentAccountSchema = /* @__PURE__ */ v.pipe(v.variant("type", [IntentAccountKeySchema, IntentAccountIdSchema]), v.description('One
|
|
111
|
+
export const IntentAccountSchema = /* @__PURE__ */ v.pipe(v.variant("type", [IntentAccountKeySchema, IntentAccountIdSchema]), v.description('One AndCo account of the Grant\'s subject, in the account matcher vocabulary: by Account Key (`{ type: "account_key", accountKey }`) or by identifier (`{ type: "account", id }`). It is where a transfer\'s money leaves from, where a deposit lands and the account a closure closes. An AccountKey is answered back as an AccountKey: it resolves to an account at execution.'));
|
|
93
112
|
const andcoAccount = IntentAccountSchema;
|
|
94
|
-
/**
|
|
95
|
-
const
|
|
96
|
-
/**
|
|
97
|
-
export const
|
|
98
|
-
const signedTransferDestination = TransferDestinationSchema;
|
|
113
|
+
/** The Remitente of a transfer Intent: always an AndCo account of the Grant's subject. */
|
|
114
|
+
const transferSender = andcoAccount;
|
|
115
|
+
/** The Receptor of a transfer, with nothing left to complete: how an event reports it. */
|
|
116
|
+
export const TransferIntentReceiverSchema = /* @__PURE__ */ v.pipe(v.variant("type", [IntentAccountKeySchema, IntentAccountIdSchema, IntentAccountExternalSchema]), v.description("The Receptor of a transfer, in the `bank_transfer` matcher vocabulary: an AndCo account by AccountKey or identifier, or a Receptor at a Chilean bank in Core's vocabulary."));
|
|
99
117
|
/**
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
118
|
+
* The Receptor of a proposed transfer when the request names it: locked on the confirmation screen,
|
|
119
|
+
* which shows it and lets the person confirm it or not. `editable` only accepts `false`: a named
|
|
120
|
+
* Receptor is never redirected at confirmation, so `editable: true` is an `invalid_request` at
|
|
121
|
+
* creation. To let the person choose where the money goes, leave it out with `receiver: null` (see
|
|
122
|
+
* {@link IntentCreateSchema}).
|
|
105
123
|
*/
|
|
106
|
-
const
|
|
107
|
-
export const
|
|
108
|
-
v.strictObject({ ...transferAccountKey, ...
|
|
109
|
-
v.strictObject({ ...transferAccount, ...
|
|
110
|
-
v.strictObject({ ...transferExternal, ...
|
|
111
|
-
]), v.description("
|
|
112
|
-
const
|
|
124
|
+
const lockedReceiver = { editable: /* @__PURE__ */ v.optional(v.literal(false), false) };
|
|
125
|
+
export const TransferIntentReceiverProposalSchema = /* @__PURE__ */ v.pipe(v.variant("type", [
|
|
126
|
+
v.strictObject({ ...transferAccountKey, ...lockedReceiver }),
|
|
127
|
+
v.strictObject({ ...transferAccount, ...lockedReceiver }),
|
|
128
|
+
v.strictObject({ ...transferExternal, ...lockedReceiver }),
|
|
129
|
+
]), v.description("The Receptor of a transfer when it is named, in the request and in the answered Intent alike. A named Receptor is always locked on the confirmation screen: `editable` only admits `false`, and `editable: true` fails at creation with `invalid_request`. To let the person choose where the money goes, the request says `receiver: null` instead (`TransferIntentCreate`). Defaults to false in a request; an answered Intent always states it, including a Receptor the person completed on the screen, which is locked once she confirms."));
|
|
130
|
+
const proposedTransferReceiver = TransferIntentReceiverProposalSchema;
|
|
113
131
|
/**
|
|
114
|
-
* The display label a
|
|
132
|
+
* The display label a cuenta digital is opened with. Mutable afterwards, and read by no permission. Its
|
|
115
133
|
* length is a rule ({@link ACCOUNT_NAME_MAX_LENGTH}), counted in code points.
|
|
116
134
|
*/
|
|
117
135
|
const accountName = nameText;
|
|
@@ -166,16 +184,17 @@ export const DepositIntentCreateSchema = /* @__PURE__ */ v.pipe(withOneExpiratio
|
|
|
166
184
|
}, expiresAtOrNever), v.description("The `application/json` half of collecting money into an account of the Grant's subject: an Intent born waiting for a payer. Exactly one of `expires_in` and `expires_at`; `expires_at: null` (never expires) only when `amount` is omitted."));
|
|
167
185
|
/** A proposal to move money, born waiting for an Approval. See {@link IntentCreateSchema}. */
|
|
168
186
|
export const TransferIntentCreateSchema = /* @__PURE__ */ v.pipe(withOneExpiration({
|
|
169
|
-
|
|
187
|
+
metadata: common.metadata,
|
|
170
188
|
type: v.literal("transfer"),
|
|
171
189
|
amount: TransferAmountProposalSchema,
|
|
172
190
|
// Null or omitted: the person picks among the Grant's sources on the confirmation screen.
|
|
173
|
-
|
|
191
|
+
sender: v.pipe(v.optional(v.nullable(transferSender), null), v.description("The Remitente: the AndCo account the money leaves. Null leaves that choice to a person on a screen.")),
|
|
174
192
|
// Null or omitted: the person completes where the money goes on the confirmation screen, within
|
|
175
193
|
// the Grant's destinations. A named one is locked there.
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
194
|
+
receiver: v.pipe(v.optional(v.nullable(proposedTransferReceiver), null), v.description("The Receptor: where the money lands. Null leaves it to a person on the screen, within the Grant's destinations.")),
|
|
195
|
+
comment: v.optional(TransferCommentProposalSchema),
|
|
196
|
+
}, expiresAtOrNever), v.description("The `application/json` half of creating a transfer: an Intent born waiting for an Approval, in Core's vocabulary (ADR 0093): `sender`, `receiver`, an integer `amount.value` and a `comment` of at most 60 bytes. A null `sender` is the confirmation screen, where a person picks the account the money leaves from among the Grant's sources, and a null `receiver` is the screen too: the person completes where the money goes (the bank, the type and number of the account, and its holder's RUT and name), and the server checks what she wrote against the Grant's `destinations` when she confirms, refusing one outside them with `invalid_destination`. Both default to null when omitted. A Receptor the request names is locked on the screen (`editable: true` is an `invalid_request`), and the amount is too unless `amount.editable` is true, in which case the person sets it. A Receptor at a bank is named in Core's vocabulary (`IntentAccountExternal`). A signed transfer is not an Intent: it is uploaded to `POST /transfers` as a `SignedTransferEnvelope`."));
|
|
197
|
+
/** A proposal to open a cuenta digital, born waiting for an Approval. See {@link IntentCreateSchema}. */
|
|
179
198
|
export const AccountOpeningIntentCreateSchema = /* @__PURE__ */ v.pipe(withOneExpiration({
|
|
180
199
|
...common,
|
|
181
200
|
type: v.literal("account_opening"),
|
|
@@ -184,9 +203,9 @@ export const AccountOpeningIntentCreateSchema = /* @__PURE__ */ v.pipe(withOneEx
|
|
|
184
203
|
accountKey: AccountKeySchema,
|
|
185
204
|
name: v.pipe(v.optional(accountName), v.description("The display label the account opens with. Mutable afterwards, and read by no permission.")),
|
|
186
205
|
upsert: v.pipe(v.optional(v.boolean(), false), v.description("Whether naming an AccountKey that already exists answers with that account instead of failing. It defaults to false, so one name never quietly becomes two accounts.")),
|
|
187
|
-
}, expiresAtOrNever), v.description("The `application/json` half of opening a
|
|
188
|
-
/** A proposal to close a
|
|
189
|
-
export const AccountClosureIntentCreateSchema = /* @__PURE__ */ v.pipe(withOneExpiration({ ...common, type: v.literal("account_closure"), account: andcoAccount }, expiresAt), v.description("The `application/json` half of closing a
|
|
206
|
+
}, expiresAtOrNever), v.description("The `application/json` half of opening a cuenta digital: an Intent born waiting for an Approval. `/accounts` has no `POST` because everything that changes an account happens through an Intent, and an opening carries no amount, no source and no destination -- only the name the account will answer to. Opening is asynchronous: the answer is the Intent and its status, and the Número de Cuenta arrives on the account's event stream."));
|
|
207
|
+
/** A proposal to close a cuenta digital, born waiting for an Approval. See {@link IntentCreateSchema}. */
|
|
208
|
+
export const AccountClosureIntentCreateSchema = /* @__PURE__ */ v.pipe(withOneExpiration({ ...common, type: v.literal("account_closure"), account: andcoAccount }, expiresAt), v.description("The `application/json` half of closing a cuenta digital: an Intent born waiting for an Approval. `/accounts` has no `DELETE` because everything that changes an account happens through an Intent. It carries no amount, no source and no destination -- only a reference to the account it closes."));
|
|
190
209
|
/**
|
|
191
210
|
* Public creation validation shared by the API and SDK. SQL resolves deadlines and enforces authorization.
|
|
192
211
|
*
|
|
@@ -196,33 +215,33 @@ export const AccountClosureIntentCreateSchema = /* @__PURE__ */ v.pipe(withOneEx
|
|
|
196
215
|
* on purpose — when signed and unsigned members share an object, something eventually reads the
|
|
197
216
|
* wrong ones.
|
|
198
217
|
*
|
|
199
|
-
* `transfer` is the only way money movement is expressed: money leaving
|
|
200
|
-
* `
|
|
201
|
-
* `external
|
|
202
|
-
* the screen's
|
|
203
|
-
* another
|
|
204
|
-
* when she confirms. Both are the screen's when omitted. A
|
|
218
|
+
* `transfer` is the only way money movement is expressed: money leaving a `sender` account towards a
|
|
219
|
+
* `receiver`, both named in the `bank_transfer` matcher vocabulary (`account_key`, `account`,
|
|
220
|
+
* `external`, whose Receptor speaks Core's vocabulary). A null `sender` is the confirmation screen's
|
|
221
|
+
* source picker, and a null `receiver` is the screen's receiver form: the person completes where the
|
|
222
|
+
* money goes (another bank's account, or another AndCo customer's), and the server checks what she
|
|
223
|
+
* wrote against the Grant's `destinations` when she confirms. Both are the screen's when omitted. A
|
|
224
|
+
* Receptor the request does name is locked
|
|
205
225
|
* there (`editable: true` is refused), and so is the amount unless it says `editable: true`, in which
|
|
206
226
|
* case the person sets it. Who may approve the Intent without a person belongs to the Grant, never to
|
|
207
227
|
* the operation itself.
|
|
208
228
|
*
|
|
209
229
|
* @example
|
|
210
230
|
* parseIntentInput({
|
|
211
|
-
* type: "transfer", expires_in: "30 minutes",
|
|
212
|
-
*
|
|
213
|
-
* amount: { currency: "CLP", value:
|
|
214
|
-
*
|
|
231
|
+
* type: "transfer", expires_in: "30 minutes", sender: null,
|
|
232
|
+
* receiver: { type: "account_key", accountKey: "proveedores" },
|
|
233
|
+
* amount: { currency: "CLP", value: 40000 },
|
|
234
|
+
* comment: { value: "Factura 42", editable: true },
|
|
215
235
|
* });
|
|
216
236
|
*
|
|
217
237
|
* @example
|
|
218
|
-
* // The person picks both accounts on
|
|
238
|
+
* // The person picks both accounts on AndCo's confirmation screen.
|
|
219
239
|
* parseIntentInput({
|
|
220
|
-
* type: "transfer", expires_in: "30 minutes",
|
|
221
|
-
* amount: { currency: "CLP", value:
|
|
240
|
+
* type: "transfer", expires_in: "30 minutes", sender: null, receiver: null,
|
|
241
|
+
* amount: { currency: "CLP", value: 40000, editable: true },
|
|
222
242
|
* });
|
|
223
243
|
*
|
|
224
|
-
* `account_opening` is here for the same reason money movement is: everything
|
|
225
|
-
* consequence happens through an Intent, so `/accounts` has no `POST`. It carries no amount, no
|
|
244
|
+
* `account_opening` is here for the same reason money movement is: everything that changes an account * consequence happens through an Intent, so `/accounts` has no `POST`. It carries no amount, no
|
|
226
245
|
* source and no destination — only the name the account will answer to, and whether naming one that
|
|
227
246
|
* already exists is an error or a request for the account that is already there.
|
|
228
247
|
*/
|
|
@@ -269,14 +288,14 @@ function nameIssues(input) {
|
|
|
269
288
|
issues.push({ type: "name_too_long", path: [{ key: "name" }], requirement: ACCOUNT_NAME_MAX_LENGTH });
|
|
270
289
|
}
|
|
271
290
|
if (input.type === "transfer")
|
|
272
|
-
issues.push(...holderNameIssues(input.
|
|
291
|
+
issues.push(...holderNameIssues(input.receiver));
|
|
273
292
|
return issues;
|
|
274
293
|
}
|
|
275
|
-
function holderNameIssues(
|
|
276
|
-
if (
|
|
294
|
+
function holderNameIssues(receiver) {
|
|
295
|
+
if (receiver?.name === undefined || codePoints(receiver.name) <= HOLDER_NAME_MAX_LENGTH) {
|
|
277
296
|
return [];
|
|
278
297
|
}
|
|
279
|
-
const path = [{ key: "
|
|
298
|
+
const path = [{ key: "receiver" }, { key: "name" }];
|
|
280
299
|
return [{ type: "holder_name_too_long", path, requirement: HOLDER_NAME_MAX_LENGTH }];
|
|
281
300
|
}
|
|
282
301
|
function metadataIssues(metadata) {
|
|
@@ -290,9 +309,11 @@ function metadataIssues(metadata) {
|
|
|
290
309
|
*
|
|
291
310
|
* - `invalid_expiration_interval`: `expires_in` is not a whole number of seconds, minutes, hours or days.
|
|
292
311
|
* - `invalid_expiration_datetime`: `expires_at` is not a real calendar datetime with a timezone.
|
|
293
|
-
* - `note_too_long`: the note has more than {@link NOTE_MAX_LENGTH}
|
|
312
|
+
* - `note_too_long`: the note of a deposit or an account Intent has more than {@link NOTE_MAX_LENGTH}
|
|
313
|
+
* code points.
|
|
314
|
+
* - `comment_too_long`: a transfer's comment has more than 60 bytes of UTF-8, Core's limit.
|
|
294
315
|
* - `name_too_long`: an account opening's `name` has more than {@link ACCOUNT_NAME_MAX_LENGTH} code points.
|
|
295
|
-
* - `holder_name_too_long`: an external
|
|
316
|
+
* - `holder_name_too_long`: an external Receptor's holder `name` has more than
|
|
296
317
|
* {@link HOLDER_NAME_MAX_LENGTH} code points.
|
|
297
318
|
* - `passive_deposit_requires_no_target`: a deposit that never expires names an amount; only a
|
|
298
319
|
* deposit with a target must expire.
|
|
@@ -304,7 +325,12 @@ function metadataIssues(metadata) {
|
|
|
304
325
|
*/
|
|
305
326
|
export function intentInputIssues(input) {
|
|
306
327
|
const issues = expirationIssues(input);
|
|
307
|
-
|
|
328
|
+
if (input.type === "transfer") {
|
|
329
|
+
issues.push(...transferCommentIssues(input.comment?.value, [{ key: "comment" }, { key: "value" }]));
|
|
330
|
+
}
|
|
331
|
+
else {
|
|
332
|
+
issues.push(...noteIssues(input.note?.value, [{ key: "note" }, { key: "value" }]));
|
|
333
|
+
}
|
|
308
334
|
issues.push(...nameIssues(input));
|
|
309
335
|
if (input.type === "deposit" && input.expires_at === null && input.amount !== undefined) {
|
|
310
336
|
issues.push({ type: "passive_deposit_requires_no_target", path: undefined, requirement: undefined });
|
|
@@ -319,10 +345,10 @@ export function intentInputIssues(input) {
|
|
|
319
345
|
*
|
|
320
346
|
* @example
|
|
321
347
|
* const parsed = parseIntentInput({
|
|
322
|
-
* type: "transfer", expires_in: "30 minutes",
|
|
323
|
-
*
|
|
324
|
-
* amount: { currency: "CLP", value:
|
|
325
|
-
*
|
|
348
|
+
* type: "transfer", expires_in: "30 minutes", sender: null,
|
|
349
|
+
* receiver: { type: "account_key", accountKey: "proveedores" },
|
|
350
|
+
* amount: { currency: "CLP", value: 40000 },
|
|
351
|
+
* comment: { value: "Factura 42", editable: true },
|
|
326
352
|
* });
|
|
327
353
|
* if (!parsed.success) console.log(parsed.issues.map((issue) => issue.type)); // e.g. ["note_too_long"]
|
|
328
354
|
*/
|
|
@@ -338,15 +364,6 @@ const signedEnvelope = {
|
|
|
338
364
|
nbf: /* @__PURE__ */ v.optional(v.pipe(v.number(), v.integer())),
|
|
339
365
|
metadata: /* @__PURE__ */ v.optional(v.record(v.string(), v.unknown()), {}),
|
|
340
366
|
};
|
|
341
|
-
/** The verified claims of a Signed Instruction that moves money. See {@link SignedIntentSchema}. */
|
|
342
|
-
export const SignedTransferIntentClaimsSchema = /* @__PURE__ */ v.pipe(withOneExpiration({
|
|
343
|
-
...signedEnvelope,
|
|
344
|
-
type: v.literal("transfer"),
|
|
345
|
-
source: transferSource,
|
|
346
|
-
destination: signedTransferDestination,
|
|
347
|
-
amount: SignedAmountSchema,
|
|
348
|
-
note: v.pipe(v.optional(noteText), v.description("A plain bank reference; a Signed Instruction proposes nothing.")),
|
|
349
|
-
}, expiresAtOrNever), v.description("The verified claims of a Signed Instruction, sent to the same endpoint as `application/jwt`. Nothing here is optional that the transfer needs and nothing here is editable: an instruction that does not say where the money comes from or where it goes is not signable, so `source` and `destination` are required (and neither may be `null`: there is no screen on this path to complete it) and the amount carries no `editable`. `note` is a plain reference for the same reason -- there is no screen on this path, so there is nobody to propose it to. When a signature is present, every value the transfer uses comes from these claims and none from the envelope carrying them. `exp` bounds how long the instruction may be submitted; `expires_in` or `expires_at` bounds how long the Intent may be approved and executed. They are different deadlines."));
|
|
350
367
|
/** The verified claims of a Signed Instruction that opens an account. See {@link SignedIntentSchema}. */
|
|
351
368
|
export const SignedAccountOpeningIntentClaimsSchema = /* @__PURE__ */ v.pipe(withOneExpiration({
|
|
352
369
|
...signedEnvelope,
|
|
@@ -366,20 +383,18 @@ export const SignedAccountClosureIntentClaimsSchema = /* @__PURE__ */ v.pipe(wit
|
|
|
366
383
|
account: andcoAccount,
|
|
367
384
|
}, expiresAt), v.description("The verified claims of a Signed Instruction that closes an account. `account` is required and never editable: an instruction that does not say which account it closes is not signable."));
|
|
368
385
|
/**
|
|
369
|
-
* The verified claims of a Signed Instruction: the `application/jwt` half of the same creation
|
|
386
|
+
* The verified claims of a Signed Instruction: the `application/jwt` half of the same creation, for
|
|
387
|
+
* opening and closing an account.
|
|
370
388
|
*
|
|
371
|
-
*
|
|
372
|
-
*
|
|
373
|
-
* `destination` are required (a `null` for either is refused: there is no screen on this path to
|
|
374
|
-
* complete it) and the amount carries no `editable`. `note` is a plain reference for the same reason:
|
|
375
|
-
* there is nobody to propose it to.
|
|
389
|
+
* A signed transfer is not here: it is a Transfer of its own, uploaded to `POST /transfers` as a
|
|
390
|
+
* `SignedTransferEnvelope` whose claims are `SignedTransferClaims` (ADR 0093).
|
|
376
391
|
*
|
|
377
392
|
* There is no `org_id`: the subject is the one of the Grant behind the access token that submits the
|
|
378
393
|
* instruction, and nothing inside the signature may name another.
|
|
379
394
|
*
|
|
380
395
|
* The expiration is present on this side too, and it is not `exp`. `exp` bounds how long the
|
|
381
396
|
* instruction may be *submitted*; the Intent expiration bounds how long the Intent may be approved
|
|
382
|
-
* and executed. They are different deadlines, and because every value a signed
|
|
397
|
+
* and executed. They are different deadlines, and because every value a signed Intent uses has to
|
|
383
398
|
* come from inside the signature, the second one cannot arrive in a header or a query string.
|
|
384
399
|
*
|
|
385
400
|
* `account_opening` is signed on the same terms, and `upsert` is the reason it matters here. The
|
|
@@ -390,24 +405,20 @@ export const SignedAccountClosureIntentClaimsSchema = /* @__PURE__ */ v.pipe(wit
|
|
|
390
405
|
*
|
|
391
406
|
* @example
|
|
392
407
|
* const claims = parseSignedIntentInput(verification.claims);
|
|
393
|
-
* if (claims.success && claims.output.type === "
|
|
408
|
+
* if (claims.success && claims.output.type === "account_opening") console.log(claims.output.jti, claims.output.accountKey);
|
|
394
409
|
*/
|
|
395
410
|
export const SignedIntentSchema = /* @__PURE__ */ v.variant("type", [
|
|
396
|
-
SignedTransferIntentClaimsSchema,
|
|
397
411
|
SignedAccountOpeningIntentClaimsSchema,
|
|
398
412
|
SignedAccountClosureIntentClaimsSchema,
|
|
399
413
|
]);
|
|
400
414
|
/**
|
|
401
415
|
* The rules of a Signed Instruction's claims that JSON Schema does not say, over claims that already
|
|
402
416
|
* have their shape ({@link SignedIntentSchema}): `invalid_expiration_interval`,
|
|
403
|
-
* `invalid_expiration_datetime`, `
|
|
404
|
-
* `metadata_too_large`, as in
|
|
417
|
+
* `invalid_expiration_datetime`, `name_too_long` and `metadata_too_large`, as in
|
|
405
418
|
* {@link intentInputIssues}.
|
|
406
419
|
*/
|
|
407
420
|
export function signedIntentInputIssues(input) {
|
|
408
421
|
const issues = expirationIssues(input);
|
|
409
|
-
if (input.type === "transfer")
|
|
410
|
-
issues.push(...noteIssues(input.note, [{ key: "note" }]));
|
|
411
422
|
issues.push(...nameIssues(input));
|
|
412
423
|
issues.push(...metadataIssues(input.metadata));
|
|
413
424
|
return issues;
|
|
@@ -476,7 +487,7 @@ export const ANDCO_INTENT_ERROR_CODES = {
|
|
|
476
487
|
*/
|
|
477
488
|
ACCOUNT_CLOSURE_NOT_IMPLEMENTED: "account_closure_not_implemented",
|
|
478
489
|
/**
|
|
479
|
-
* Opening an additional account by Account Key works where
|
|
490
|
+
* Opening an additional account by Account Key works where AndCo serves it. Where it does not,
|
|
480
491
|
* the server answers `not_implemented` (501) with this stable `code`: at Intent creation, once the
|
|
481
492
|
* request is valid and the Grant holds `bank_account` `create` (otherwise `400` or `403` come
|
|
482
493
|
* first) and nothing is created, and at approval, with the `intent_id`, leaving the Intent as it
|
|
@@ -485,12 +496,20 @@ export const ANDCO_INTENT_ERROR_CODES = {
|
|
|
485
496
|
ACCOUNT_OPENING_NOT_IMPLEMENTED: "account_opening_not_implemented",
|
|
486
497
|
/**
|
|
487
498
|
* A transfer between two accounts of the same holder (the destination is an Account Key or an
|
|
488
|
-
*
|
|
499
|
+
* AndCo account of the Grant's subject) works where AndCo serves it. Where it does not, the
|
|
489
500
|
* server answers `not_implemented` (501) with this stable `code`: at Intent creation, with
|
|
490
501
|
* nothing created, and at approval, with the `intent_id`. A transfer to another bank or to
|
|
491
|
-
* another
|
|
502
|
+
* another AndCo customer is not affected.
|
|
492
503
|
*/
|
|
493
504
|
OWN_ACCOUNT_TRANSFER_NOT_IMPLEMENTED: "own_account_transfer_not_implemented",
|
|
505
|
+
/**
|
|
506
|
+
* A signed transfer that leaves its holder (to another bank or to another AndCo customer) moves
|
|
507
|
+
* only where AndCo's core verifies signatures (ADR 0092). Where it does not, `POST /transfers`
|
|
508
|
+
* answers `not_implemented` (501) with this stable `code` once the instruction verified and the
|
|
509
|
+
* Grant covers it, and nothing is created. A signed transfer between two accounts of the same
|
|
510
|
+
* holder is not affected.
|
|
511
|
+
*/
|
|
512
|
+
SIGNED_OUTGOING_TRANSFER_NOT_IMPLEMENTED: "signed_outgoing_transfer_not_implemented",
|
|
494
513
|
};
|
|
495
514
|
/**
|
|
496
515
|
* Identifies recognized unsupported Intents without silently dropping their extra instructions: an
|
|
@@ -504,7 +523,8 @@ export function unsupportedIntentShape(input) {
|
|
|
504
523
|
return ANDCO_INTENT_ERROR_CODES.ACCOUNT_CLOSURE_NOT_IMPLEMENTED;
|
|
505
524
|
if (!["deposit", "transfer"].includes(String(record["type"])))
|
|
506
525
|
return undefined;
|
|
507
|
-
|
|
526
|
+
const several = record["type"] === "transfer" ? "receiver" : "destination";
|
|
527
|
+
if (Object.hasOwn(record, `${several}s`) || Array.isArray(record[several]))
|
|
508
528
|
return "multiple_destinations_not_implemented";
|
|
509
529
|
if (Object.hasOwn(record, "allocations") || Object.hasOwn(record, "split"))
|
|
510
530
|
return "split_payments_not_implemented";
|
|
@@ -517,26 +537,27 @@ export function unsupportedIntentShape(input) {
|
|
|
517
537
|
*
|
|
518
538
|
* Every member but `intent_id` is optional because nothing here is necessarily editable: a screen
|
|
519
539
|
* sends only what the Intent left open, and a value that was frozen has nowhere to arrive from.
|
|
520
|
-
* `
|
|
521
|
-
*
|
|
522
|
-
* when the Intent was created with `amount.editable: true`. The server checks the
|
|
523
|
-
* the Grant's `destinations` and refuses one outside them with `invalid_destination`.
|
|
540
|
+
* `receiver` is the one the person completes when the Intent was created with `receiver: null`, and
|
|
541
|
+
* is required then; a transfer that named its Receptor takes none. `amount` (in the minor unit of the currency) is accepted
|
|
542
|
+
* only when the Intent was created with `amount.editable: true`. The server checks the Receptor
|
|
543
|
+
* against the Grant's `destinations` and refuses one outside them with `invalid_destination`.
|
|
524
544
|
*/
|
|
525
545
|
export const TransferConfirmationSchema = /* @__PURE__ */ v.strictObject({
|
|
526
546
|
intent_id: accountId,
|
|
527
|
-
|
|
528
|
-
amount: v.optional(
|
|
529
|
-
// What the person wrote is always
|
|
530
|
-
// `
|
|
531
|
-
|
|
532
|
-
|
|
547
|
+
sender_account_id: v.optional(accountId),
|
|
548
|
+
amount: v.optional(PesosSchema),
|
|
549
|
+
// What the person wrote is always a Receptor at a bank, in Core's vocabulary: another bank's, or
|
|
550
|
+
// another Andco customer's with bank code `0739`. An AndCo account of the Grant's subject is not
|
|
551
|
+
// offered on the screen yet.
|
|
552
|
+
receiver: v.optional(v.strictObject(transferExternal)),
|
|
553
|
+
comment: v.optional(noteText),
|
|
533
554
|
});
|
|
534
555
|
/**
|
|
535
|
-
* The rules of a confirmation that JSON Schema does not say
|
|
536
|
-
*
|
|
556
|
+
* The rules of a confirmation that JSON Schema does not say: `comment_too_long`, past Core's 60 bytes
|
|
557
|
+
* of UTF-8, and `holder_name_too_long`, past {@link HOLDER_NAME_MAX_LENGTH} code points.
|
|
537
558
|
*/
|
|
538
559
|
export function transferConfirmationIssues(input) {
|
|
539
|
-
return [...
|
|
560
|
+
return [...transferCommentIssues(input.comment, [{ key: "comment" }]), ...holderNameIssues(input.receiver)];
|
|
540
561
|
}
|
|
541
562
|
/**
|
|
542
563
|
* Parses proposed confirmation fields: their shape and then {@link transferConfirmationIssues}. The
|
|
@@ -62,7 +62,7 @@ export declare const AndCoMiniappManifestSchema: v.ObjectSchema<{
|
|
|
62
62
|
readonly auth_url: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 2048, undefined>]>, undefined>;
|
|
63
63
|
}, undefined>;
|
|
64
64
|
}, undefined>;
|
|
65
|
-
/** Parsed Miniapp Descriptor consumed by
|
|
65
|
+
/** Parsed Miniapp Descriptor consumed by AndCo Host Applications. */
|
|
66
66
|
export type AndCoMiniappManifest = v.InferOutput<typeof AndCoMiniappManifestSchema>;
|
|
67
67
|
/** Public OAuth registration loaded from andco-webapp. */
|
|
68
68
|
export type AndCoOAuthClientConfiguration = v.InferOutput<typeof AndCoOAuthClientConfigurationSchema>;
|