@andco/protocol 0.0.1 → 0.0.4
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/LICENSE +1 -1
- package/README.md +33 -3
- package/dist/api-errors.d.ts +109 -0
- package/dist/api-errors.d.ts.map +1 -0
- package/dist/api-errors.js +111 -0
- package/dist/authorization-preparation.d.ts +52 -543
- package/dist/authorization-preparation.d.ts.map +1 -1
- package/dist/authorization-preparation.js +19 -42
- package/dist/authorization.d.ts +64 -22
- package/dist/authorization.d.ts.map +1 -1
- package/dist/authorization.js +136 -55
- package/dist/consent.d.ts +5 -8
- package/dist/consent.d.ts.map +1 -1
- package/dist/consent.js +5 -62
- package/dist/constants.d.ts +19 -3
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +19 -3
- package/dist/errors.d.ts +156 -58
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +176 -57
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -5
- package/dist/intent-input.d.ts +1010 -279
- package/dist/intent-input.d.ts.map +1 -1
- package/dist/intent-input.js +268 -40
- package/dist/messages/error.d.ts +1 -2
- package/dist/messages/error.d.ts.map +1 -1
- package/dist/messages/error.js +5 -2
- package/dist/messages/index.d.ts +3 -3
- package/dist/messages/index.js +2 -2
- package/dist/messages/presentation-response.d.ts +20 -0
- package/dist/messages/presentation-response.d.ts.map +1 -0
- package/dist/messages/presentation-response.js +17 -0
- package/dist/native-copy.d.ts +23 -2
- package/dist/native-copy.d.ts.map +1 -1
- package/dist/native-copy.js +42 -98
- package/dist/native-intent.d.ts +126 -75
- package/dist/native-intent.d.ts.map +1 -1
- package/dist/native-intent.js +140 -48
- package/dist/rar/account-matchers.d.ts +579 -0
- package/dist/rar/account-matchers.d.ts.map +1 -0
- package/dist/rar/account-matchers.js +480 -0
- package/dist/rar/bank.d.ts +1549 -0
- package/dist/rar/bank.d.ts.map +1 -0
- package/dist/rar/bank.js +379 -0
- package/dist/rar/catalog.d.ts +1155 -0
- package/dist/rar/catalog.d.ts.map +1 -0
- package/dist/rar/catalog.js +175 -0
- package/dist/rar/detail.d.ts +39 -0
- package/dist/rar/detail.d.ts.map +1 -0
- package/dist/rar/detail.js +44 -0
- package/dist/rar/index.d.ts +9 -0
- package/dist/rar/index.d.ts.map +1 -0
- package/dist/rar/index.js +8 -0
- package/dist/rar/money.d.ts +58 -0
- package/dist/rar/money.d.ts.map +1 -0
- package/dist/rar/money.js +61 -0
- package/dist/rar/project-users.d.ts +43 -0
- package/dist/rar/project-users.d.ts.map +1 -0
- package/dist/rar/project-users.js +63 -0
- package/dist/rar/subject-data.d.ts +170 -0
- package/dist/rar/subject-data.d.ts.map +1 -0
- package/dist/rar/subject-data.js +127 -0
- package/dist/rar/subject.d.ts +166 -0
- package/dist/rar/subject.d.ts.map +1 -0
- package/dist/rar/subject.js +119 -0
- package/dist/scopes.d.ts +5 -30
- package/dist/scopes.d.ts.map +1 -1
- package/dist/scopes.js +0 -13
- package/dist/service-grants.d.ts +44 -0
- package/dist/service-grants.d.ts.map +1 -0
- package/dist/service-grants.js +45 -0
- package/dist/signing.d.ts +56 -0
- package/dist/signing.d.ts.map +1 -0
- package/dist/signing.js +233 -0
- package/dist/transport/financial-events.d.ts +90 -35
- package/dist/transport/financial-events.d.ts.map +1 -1
- package/dist/transport/financial-events.js +7 -1
- package/dist/transport/generated/oauth-api.d.ts +908 -440
- package/dist/transport/generated/oauth-api.d.ts.map +1 -1
- package/dist/transport/index.d.ts +0 -1
- package/dist/transport/index.d.ts.map +1 -1
- package/dist/transport/index.js +0 -1
- package/dist/transport/intents.d.ts +155 -23
- package/dist/transport/intents.d.ts.map +1 -1
- package/dist/transport/intents.js +192 -59
- package/dist/transport/rest.d.ts +18 -8
- package/dist/transport/rest.d.ts.map +1 -1
- package/dist/transport/rest.js +1 -1
- package/dist/urls.d.ts.map +1 -1
- package/dist/urls.js +1 -1
- package/dist/userinfo.d.ts +10 -1
- package/dist/userinfo.d.ts.map +1 -1
- package/dist/userinfo.js +10 -1
- package/dist/utils.d.ts +15 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +31 -0
- package/dist/webhooks.d.ts +154 -0
- package/dist/webhooks.d.ts.map +1 -0
- package/dist/webhooks.js +249 -0
- package/package.json +18 -1
- package/dist/automatic-charge.d.ts +0 -314
- package/dist/automatic-charge.d.ts.map +0 -1
- package/dist/automatic-charge.js +0 -126
- package/dist/bank-account-authorization.d.ts +0 -6
- package/dist/bank-account-authorization.d.ts.map +0 -1
- package/dist/bank-account-authorization.js +0 -13
- package/dist/messages/authorization-response.d.ts +0 -12
- package/dist/messages/authorization-response.d.ts.map +0 -1
- package/dist/messages/authorization-response.js +0 -9
- package/dist/transport/webhooks.d.ts +0 -27
- package/dist/transport/webhooks.d.ts.map +0 -1
- package/dist/transport/webhooks.js +0 -68
- package/dist/webhook-input.d.ts +0 -22
- package/dist/webhook-input.d.ts.map +0 -1
- package/dist/webhook-input.js +0 -11
- package/dist/webhook-signature.d.ts +0 -54
- package/dist/webhook-signature.d.ts.map +0 -1
- package/dist/webhook-signature.js +0 -74
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intent-input.d.ts","sourceRoot":"","sources":["../src/intent-input.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"intent-input.d.ts","sourceRoot":"","sources":["../src/intent-input.ts"],"names":[],"mappings":"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"}
|
package/dist/intent-input.js
CHANGED
|
@@ -1,19 +1,90 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
|
+
import { ANDCO_API_ORIGIN } from "./constants.js";
|
|
3
|
+
import { AccountAliasSchema } from "./rar/account-matchers.js";
|
|
4
|
+
import { MoneySchema } from "./rar/money.js";
|
|
2
5
|
const text = (max) => v.pipe(v.string(), v.trim(), v.minLength(1), v.maxLength(max));
|
|
3
6
|
const accountId = /* @__PURE__ */ v.pipe(v.string(), v.uuid());
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
// The regex ceiling of `MoneySchema` (15 digits) already keeps `Number(value)` inside
|
|
8
|
+
// `Number.isSafeInteger` range, so this check can no longer reject anything the regex accepts.
|
|
9
|
+
// Kept anyway as cheap defense in depth: valibot is the only gate this scalar passes through here
|
|
10
|
+
// (unlike the JSON Schema mirrors of the RAR types, which have nowhere to hang a numeric check),
|
|
11
|
+
// so a future edit to the regex that reintroduces the gap fails safely at this check instead of
|
|
12
|
+
// silently shipping an unsafe integer.
|
|
13
|
+
const amountValue = /* @__PURE__ */ v.pipe(MoneySchema, v.check((value) => Number.isSafeInteger(Number(value))));
|
|
14
|
+
/**
|
|
15
|
+
* The amount a request asks for: `value` is the number, and `editable: true` lets the person who
|
|
16
|
+
* confirms change it on the screen. It is never what moved; an answered Intent says that apart
|
|
17
|
+
* (`settled` on a transfer, `progress.credited` on a deposit).
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* const amount = { currency: "CLP", value: "40000", editable: false };
|
|
21
|
+
*/
|
|
22
|
+
const proposedAmount = {
|
|
13
23
|
currency: v.literal("CLP"),
|
|
24
|
+
value: amountValue,
|
|
14
25
|
editable: v.optional(v.boolean(), false),
|
|
15
|
-
suggested: v.pipe(v.string(), v.regex(/^[1-9][0-9]{0,15}$/), v.check((value) => Number.isSafeInteger(Number(value)))),
|
|
16
26
|
};
|
|
27
|
+
/**
|
|
28
|
+
* The amount a Signed Instruction orders: the same `{ currency, value }` as a request, with nothing
|
|
29
|
+
* left for a person to change, so there is no `editable`.
|
|
30
|
+
*/
|
|
31
|
+
const signedAmount = { currency: v.literal("CLP"), value: amountValue };
|
|
32
|
+
/** A note's text: trimmed, and at most 140 Unicode code points, the way PostgreSQL counts them. */
|
|
33
|
+
const noteText = /* @__PURE__ */ v.pipe(v.string(), v.trim(), v.check((value) => [...value].length <= 140, "note_too_long"));
|
|
34
|
+
/**
|
|
35
|
+
* The account a transfer names, in the vocabulary of the `bank_transfer` matchers it has to fit:
|
|
36
|
+
* `{ type: "alias", alias }` and `{ type: "account", id }` name one Andco account, and
|
|
37
|
+
* `{ type: "external", ... }` names one account at another Chilean bank with every field the
|
|
38
|
+
* `external` matcher can fix. A transfer names exactly one account, so nothing here is a pattern.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* const source: TransferAccount = { type: "alias", alias: "caja-santiago" };
|
|
42
|
+
* const payroll: TransferAccount = {
|
|
43
|
+
* type: "external", bank_id: "banco_de_chile", account_type: "checking", account_id: "1234567890",
|
|
44
|
+
* holder_id: "12345678-5", holder_name: "Ada Lovelace",
|
|
45
|
+
* };
|
|
46
|
+
*/
|
|
47
|
+
const transferAlias = { type: /* @__PURE__ */ v.literal("alias"), alias: AccountAliasSchema };
|
|
48
|
+
const transferAccount = { type: /* @__PURE__ */ v.literal("account"), id: accountId };
|
|
49
|
+
const transferExternal = {
|
|
50
|
+
type: /* @__PURE__ */ v.literal("external"),
|
|
51
|
+
bank_id: /* @__PURE__ */ v.pipe(v.string(), v.regex(/^[a-z0-9][a-z0-9_-]{0,63}$/)),
|
|
52
|
+
account_type: /* @__PURE__ */ v.picklist(["checking", "debit", "savings"]),
|
|
53
|
+
account_id: text(64),
|
|
54
|
+
holder_id: text(64),
|
|
55
|
+
holder_name: text(256),
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* One Andco account of the Grant's subject, named by Account Alias or by identifier: where a
|
|
59
|
+
* transfer's money leaves from, where a deposit lands, and the account a closure closes.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* const account: IntentAccount = { type: "alias", alias: "ventas" };
|
|
63
|
+
*/
|
|
64
|
+
const andcoAccount = /* @__PURE__ */ v.variant("type", [
|
|
65
|
+
v.strictObject(transferAlias),
|
|
66
|
+
v.strictObject(transferAccount),
|
|
67
|
+
]);
|
|
68
|
+
/** Where a transfer's money leaves from: always an Andco account of the Grant's subject. */
|
|
69
|
+
const transferSource = andcoAccount;
|
|
70
|
+
/** Where a signed transfer's money lands: nothing on this path is left for a person to complete. */
|
|
71
|
+
const signedTransferDestination = /* @__PURE__ */ v.variant("type", [
|
|
72
|
+
v.strictObject(transferAlias),
|
|
73
|
+
v.strictObject(transferAccount),
|
|
74
|
+
v.strictObject(transferExternal),
|
|
75
|
+
]);
|
|
76
|
+
/**
|
|
77
|
+
* Where a proposed transfer's money lands. `editable: false` locks it on the confirmation screen;
|
|
78
|
+
* only another bank's account can ever be editable, because an Andco account named by Alias or by
|
|
79
|
+
* identifier already denotes exactly one account.
|
|
80
|
+
*/
|
|
81
|
+
const proposedTransferDestination = /* @__PURE__ */ v.variant("type", [
|
|
82
|
+
v.strictObject({ ...transferAlias, editable: v.optional(v.literal(false), false) }),
|
|
83
|
+
v.strictObject({ ...transferAccount, editable: v.optional(v.literal(false), false) }),
|
|
84
|
+
v.strictObject({ ...transferExternal, editable: v.optional(v.boolean(), false) }),
|
|
85
|
+
]);
|
|
86
|
+
/** The display label a Cuenta Vista is opened with. Mutable afterwards, and read by no permission. */
|
|
87
|
+
const accountName = /* @__PURE__ */ v.pipe(v.string(), v.trim(), v.minLength(1), v.maxLength(80));
|
|
17
88
|
/** Validates fixed-duration syntax without anchoring it to a changing clock. */
|
|
18
89
|
export function isIntentDuration(value) {
|
|
19
90
|
const match = /^([1-9][0-9]*)\s+(seconds?|minutes?|hours?|days?)$/.exec(value.trim());
|
|
@@ -34,68 +105,225 @@ export function isIntentDeadline(value) {
|
|
|
34
105
|
Number.isFinite(midnight.getTime()) &&
|
|
35
106
|
midnight.toISOString().slice(0, 10) === date);
|
|
36
107
|
}
|
|
108
|
+
const expiresIn = /* @__PURE__ */ v.pipe(v.string(), v.check(isIntentDuration, "invalid_expiration_interval"));
|
|
109
|
+
const expiresAt = /* @__PURE__ */ v.pipe(v.string(), v.check(isIntentDeadline, "invalid_expiration_datetime"));
|
|
37
110
|
const common = {
|
|
38
|
-
expires_in: v.optional(
|
|
39
|
-
expires_at: v.optional(
|
|
40
|
-
note: v.optional(v.strictObject({
|
|
41
|
-
suggested: v.pipe(v.string(), v.trim(), v.check((value) => [...value].length <= 140, "note_too_long")),
|
|
42
|
-
editable: v.optional(v.boolean(), false),
|
|
43
|
-
})),
|
|
111
|
+
expires_in: v.optional(expiresIn),
|
|
112
|
+
expires_at: v.optional(expiresAt),
|
|
113
|
+
note: v.optional(v.strictObject({ value: noteText, editable: v.optional(v.boolean(), false) })),
|
|
44
114
|
metadata: v.optional(v.record(v.string(), v.unknown()), {}),
|
|
45
115
|
};
|
|
46
|
-
/**
|
|
116
|
+
/**
|
|
117
|
+
* Public creation validation shared by the API and SDK. SQL resolves deadlines and enforces authorization.
|
|
118
|
+
*
|
|
119
|
+
* This is the `application/json` half of the creation contract: an Intent born waiting for an
|
|
120
|
+
* Approval, where a `null` means a person will choose. The `application/jwt` half is
|
|
121
|
+
* {@link SignedIntentSchema}, and the two are separate schemas rather than one with optional fields
|
|
122
|
+
* on purpose — when signed and unsigned members share an object, something eventually reads the
|
|
123
|
+
* wrong ones.
|
|
124
|
+
*
|
|
125
|
+
* `transfer` is the only way money movement is expressed: money leaving an account towards a
|
|
126
|
+
* `destination`, both named in the `bank_transfer` matcher vocabulary (`alias`, `account`,
|
|
127
|
+
* `external`). A null `source` is the confirmation screen's source picker; `editable: false` locks
|
|
128
|
+
* the destination there. Who may approve the Intent without a person belongs to the Grant, never to
|
|
129
|
+
* the operation itself.
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* safeParseIntentCreate({
|
|
133
|
+
* type: "transfer", expires_in: "30 minutes", source: null,
|
|
134
|
+
* destination: { type: "alias", alias: "proveedores" },
|
|
135
|
+
* amount: { currency: "CLP", value: "40000" },
|
|
136
|
+
* note: { value: "Factura 42", editable: true },
|
|
137
|
+
* });
|
|
138
|
+
*
|
|
139
|
+
* `account_opening` is here for the same reason money movement is: everything with banking
|
|
140
|
+
* consequence happens through an Intent, so `/accounts` has no `POST`. It carries no amount, no
|
|
141
|
+
* source and no destination — only the name the account will answer to, and whether naming one that
|
|
142
|
+
* already exists is an error or a request for the account that is already there.
|
|
143
|
+
*/
|
|
47
144
|
export const IntentCreateSchema = /* @__PURE__ */ v.pipe(v.variant("type", [
|
|
48
145
|
v.strictObject({
|
|
49
146
|
...common,
|
|
50
147
|
type: v.literal("deposit"),
|
|
51
|
-
|
|
52
|
-
|
|
148
|
+
destination: v.optional(andcoAccount),
|
|
149
|
+
amount: v.optional(v.strictObject(proposedAmount)),
|
|
150
|
+
expires_at: v.optional(v.nullable(expiresAt)),
|
|
151
|
+
}),
|
|
152
|
+
v.strictObject({
|
|
153
|
+
...common,
|
|
154
|
+
type: v.literal("transfer"),
|
|
155
|
+
amount: v.strictObject(proposedAmount),
|
|
156
|
+
// Null or omitted: the person picks among the Grant's sources on the confirmation screen.
|
|
157
|
+
source: v.optional(v.nullable(transferSource), null),
|
|
158
|
+
destination: proposedTransferDestination,
|
|
53
159
|
}),
|
|
54
160
|
v.strictObject({
|
|
55
161
|
...common,
|
|
56
|
-
type: v.literal("
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
]),
|
|
162
|
+
type: v.literal("account_opening"),
|
|
163
|
+
// The holder's own name for the account, unique per subject (ADR 0028) and never reused once
|
|
164
|
+
// the account closes.
|
|
165
|
+
alias: AccountAliasSchema,
|
|
166
|
+
name: v.optional(accountName),
|
|
167
|
+
upsert: v.optional(v.boolean(), false),
|
|
63
168
|
}),
|
|
64
169
|
v.strictObject({
|
|
65
170
|
...common,
|
|
66
|
-
type: v.literal("
|
|
67
|
-
|
|
68
|
-
source: v.optional(v.nullable(v.strictObject({ bank_account_id: accountId })), null),
|
|
69
|
-
beneficiary: v.strictObject({ bank_account_id: accountId }),
|
|
171
|
+
type: v.literal("account_closure"),
|
|
172
|
+
account: andcoAccount,
|
|
70
173
|
}),
|
|
71
174
|
]), v.check((input) => (input.expires_in !== undefined) !== (input.expires_at !== undefined), "exactly_one_expiration_required"), v.check((input) => input.expires_at !== null || (input.type === "deposit" && input.amount === undefined), "passive_deposit_requires_no_target"), v.check((input) => JSON.stringify(input.metadata).length <= 16384, "metadata_too_large"));
|
|
72
175
|
/** Returns validation issues without throwing across the HTTP boundary. */
|
|
73
176
|
export function safeParseIntentCreate(input) {
|
|
74
177
|
return v.safeParse(IntentCreateSchema, input);
|
|
75
178
|
}
|
|
179
|
+
/**
|
|
180
|
+
* The verified claims of a Signed Instruction: the `application/jwt` half of the same creation.
|
|
181
|
+
*
|
|
182
|
+
* Nothing here is optional that the transfer needs and nothing here is editable. An instruction that
|
|
183
|
+
* does not say where the money comes from or where it goes is not signable, so `source` and
|
|
184
|
+
* `destination` are required and the amount carries no `editable`. `note` is a plain reference for
|
|
185
|
+
* the same reason: there is no screen on this path, so there is nobody to propose it to.
|
|
186
|
+
*
|
|
187
|
+
* There is no `org_id`: the subject is the one of the Grant behind the access token that submits the
|
|
188
|
+
* instruction, and nothing inside the signature may name another.
|
|
189
|
+
*
|
|
190
|
+
* The expiration is present on this side too, and it is not `exp`. `exp` bounds how long the
|
|
191
|
+
* instruction may be *submitted*; the Intent expiration bounds how long the Intent may be approved
|
|
192
|
+
* and executed. They are different deadlines, and because every value a signed transfer uses has to
|
|
193
|
+
* come from inside the signature, the second one cannot arrive in a header or a query string.
|
|
194
|
+
*
|
|
195
|
+
* `account_opening` is signed on the same terms, and `upsert` is the reason it matters here. The
|
|
196
|
+
* flag decides whether naming an Account Alias that already exists is a refusal or a request for the
|
|
197
|
+
* account already carrying it, which is a difference in what the instruction *orders*. Carried as a
|
|
198
|
+
* transport option — a header, a query parameter, a field beside the assertion — anybody holding the
|
|
199
|
+
* signed instruction could flip it, and the order executed would not be the order signed.
|
|
200
|
+
*
|
|
201
|
+
* @example
|
|
202
|
+
* const claims = safeParseSignedIntent(verification.claims);
|
|
203
|
+
* if (claims.success) console.log(claims.output.jti, claims.output.amount.value);
|
|
204
|
+
*/
|
|
205
|
+
export const SignedIntentSchema = /* @__PURE__ */ v.pipe(v.variant("type", [
|
|
206
|
+
v.strictObject({
|
|
207
|
+
iss: text(64),
|
|
208
|
+
aud: v.literal(ANDCO_API_ORIGIN),
|
|
209
|
+
jti: text(128),
|
|
210
|
+
exp: v.pipe(v.number(), v.integer()),
|
|
211
|
+
iat: v.optional(v.pipe(v.number(), v.integer())),
|
|
212
|
+
nbf: v.optional(v.pipe(v.number(), v.integer())),
|
|
213
|
+
type: v.literal("transfer"),
|
|
214
|
+
source: transferSource,
|
|
215
|
+
destination: signedTransferDestination,
|
|
216
|
+
amount: v.strictObject(signedAmount),
|
|
217
|
+
expires_in: v.optional(expiresIn),
|
|
218
|
+
expires_at: v.optional(expiresAt),
|
|
219
|
+
note: v.optional(noteText),
|
|
220
|
+
metadata: v.optional(v.record(v.string(), v.unknown()), {}),
|
|
221
|
+
}),
|
|
222
|
+
v.strictObject({
|
|
223
|
+
iss: text(64),
|
|
224
|
+
aud: v.literal(ANDCO_API_ORIGIN),
|
|
225
|
+
jti: text(128),
|
|
226
|
+
exp: v.pipe(v.number(), v.integer()),
|
|
227
|
+
iat: v.optional(v.pipe(v.number(), v.integer())),
|
|
228
|
+
nbf: v.optional(v.pipe(v.number(), v.integer())),
|
|
229
|
+
type: v.literal("account_opening"),
|
|
230
|
+
alias: AccountAliasSchema,
|
|
231
|
+
name: v.optional(accountName),
|
|
232
|
+
// Inside the signature, never beside it: outside the claims anyone holding the assertion could
|
|
233
|
+
// turn "create this account" into "create it or hand me the one that is already there".
|
|
234
|
+
upsert: v.optional(v.boolean(), false),
|
|
235
|
+
expires_in: v.optional(expiresIn),
|
|
236
|
+
expires_at: v.optional(expiresAt),
|
|
237
|
+
metadata: v.optional(v.record(v.string(), v.unknown()), {}),
|
|
238
|
+
}),
|
|
239
|
+
v.strictObject({
|
|
240
|
+
iss: text(64),
|
|
241
|
+
aud: v.literal(ANDCO_API_ORIGIN),
|
|
242
|
+
jti: text(128),
|
|
243
|
+
exp: v.pipe(v.number(), v.integer()),
|
|
244
|
+
iat: v.optional(v.pipe(v.number(), v.integer())),
|
|
245
|
+
nbf: v.optional(v.pipe(v.number(), v.integer())),
|
|
246
|
+
type: v.literal("account_closure"),
|
|
247
|
+
// Required and never editable: an instruction that does not say which account it closes is
|
|
248
|
+
// not signable.
|
|
249
|
+
account: andcoAccount,
|
|
250
|
+
expires_in: v.optional(expiresIn),
|
|
251
|
+
expires_at: v.optional(expiresAt),
|
|
252
|
+
metadata: v.optional(v.record(v.string(), v.unknown()), {}),
|
|
253
|
+
}),
|
|
254
|
+
]), v.check((input) => (input.expires_in !== undefined) !== (input.expires_at !== undefined), "exactly_one_expiration_required"), v.check((input) => JSON.stringify(input.metadata).length <= 16384, "metadata_too_large"));
|
|
255
|
+
const decisionReason = /* @__PURE__ */ v.pipe(v.string(), v.trim(), v.minLength(1), v.check((value) => [...value].length <= 280, "reason_too_long"));
|
|
256
|
+
/**
|
|
257
|
+
* Cancelling names why, because an Intent that vanished without a reason is an unexplained gap.
|
|
258
|
+
* A Cancellation is the creator withdrawing its own request: only the client that created the
|
|
259
|
+
* Intent may cancel it. An approver declining it is a Rejection ({@link IntentRejectionSchema}).
|
|
260
|
+
*
|
|
261
|
+
* @example
|
|
262
|
+
* safeParseIntentCancellation({ reason: "rejected_by_erp" });
|
|
263
|
+
*/
|
|
264
|
+
export const IntentCancellationSchema = /* @__PURE__ */ v.strictObject({ reason: decisionReason });
|
|
265
|
+
/** Returns validation issues for a cancellation reason without throwing across the HTTP boundary. */
|
|
266
|
+
export function safeParseIntentCancellation(input) {
|
|
267
|
+
return v.safeParse(IntentCancellationSchema, input);
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Rejecting names why. A Rejection is an approver declining an Intent with a Grant holding the
|
|
271
|
+
* family's `reject` action (`bank_transfer` for a transfer); the audit keeps it apart from a
|
|
272
|
+
* Cancellation, which is the creator withdrawing its own request.
|
|
273
|
+
*
|
|
274
|
+
* @example
|
|
275
|
+
* safeParseIntentRejection({ reason: "duplicated_invoice" });
|
|
276
|
+
*/
|
|
277
|
+
export const IntentRejectionSchema = /* @__PURE__ */ v.strictObject({ reason: decisionReason });
|
|
278
|
+
/** Returns validation issues for a rejection reason without throwing across the HTTP boundary. */
|
|
279
|
+
export function safeParseIntentRejection(input) {
|
|
280
|
+
return v.safeParse(IntentRejectionSchema, input);
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Error codes an Intent's Approval lifecycle answers with, beyond the generic transport codes.
|
|
284
|
+
*
|
|
285
|
+
* A cancellation or an approval may observe an Intent whose deadline to be approved and executed
|
|
286
|
+
* has already passed; `intent_expired` names that failure so a caller can distinguish it from an
|
|
287
|
+
* ordinary rejection.
|
|
288
|
+
*/
|
|
289
|
+
export const ANDCO_INTENT_ERROR_CODES = {
|
|
290
|
+
/** The Intent's deadline to be approved and executed has already passed. */
|
|
291
|
+
INTENT_EXPIRED: "intent_expired",
|
|
292
|
+
};
|
|
293
|
+
/** Returns validation issues for the verified claims without throwing across the HTTP boundary. */
|
|
294
|
+
export function safeParseSignedIntent(input) {
|
|
295
|
+
return v.safeParse(SignedIntentSchema, input);
|
|
296
|
+
}
|
|
76
297
|
/** Identifies recognized unsupported payment shapes without silently dropping their extra instructions. */
|
|
77
298
|
export function unsupportedIntentPaymentShape(input) {
|
|
78
299
|
if (!input || typeof input !== "object" || Array.isArray(input))
|
|
79
300
|
return undefined;
|
|
80
301
|
const record = input;
|
|
81
|
-
if (!["deposit", "
|
|
302
|
+
if (!["deposit", "transfer"].includes(String(record["type"])))
|
|
82
303
|
return undefined;
|
|
83
|
-
if (Object.hasOwn(record, "
|
|
84
|
-
return "
|
|
304
|
+
if (Object.hasOwn(record, "destinations") || Array.isArray(record["destination"]))
|
|
305
|
+
return "multiple_destinations_not_implemented";
|
|
85
306
|
if (Object.hasOwn(record, "allocations") || Object.hasOwn(record, "split"))
|
|
86
307
|
return "split_payments_not_implemented";
|
|
87
308
|
if (Object.hasOwn(record, "instructions"))
|
|
88
309
|
return "multiple_instructions_not_implemented";
|
|
89
310
|
return undefined;
|
|
90
311
|
}
|
|
91
|
-
/**
|
|
92
|
-
|
|
312
|
+
/**
|
|
313
|
+
* Values proposed by the account holder; the database enforces editability and freezes confirmation.
|
|
314
|
+
*
|
|
315
|
+
* Every member but `intent_id` is optional because nothing here is necessarily editable: a screen
|
|
316
|
+
* sends only what the Intent left open, and a value that was frozen has nowhere to arrive from.
|
|
317
|
+
*/
|
|
318
|
+
export const TransferConfirmationSchema = /* @__PURE__ */ v.strictObject({
|
|
93
319
|
intent_id: accountId,
|
|
94
320
|
source_account_id: v.optional(accountId),
|
|
95
|
-
amount: v.optional(
|
|
96
|
-
|
|
97
|
-
|
|
321
|
+
amount: v.optional(amountValue),
|
|
322
|
+
// Only another bank's account is ever editable, so a correction is always an `external` account.
|
|
323
|
+
destination: v.optional(v.strictObject(transferExternal)),
|
|
324
|
+
note: v.optional(noteText),
|
|
98
325
|
});
|
|
99
|
-
|
|
100
|
-
|
|
326
|
+
/** Validates proposed confirmation fields without throwing; the server enforces editability. */
|
|
327
|
+
export function safeParseTransferConfirmation(input) {
|
|
328
|
+
return v.safeParse(TransferConfirmationSchema, input);
|
|
101
329
|
}
|
package/dist/messages/error.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
|
-
import { ANDCO_ERROR_CODES } from "../errors.js";
|
|
3
2
|
export declare const AndCoErrorEventSchema: v.StrictObjectSchema<{
|
|
4
3
|
readonly type: v.LiteralSchema<"error", undefined>;
|
|
5
4
|
readonly error: v.StrictObjectSchema<{
|
|
6
|
-
readonly code: v.PicklistSchema<[
|
|
5
|
+
readonly code: v.PicklistSchema<readonly ["invalid_endpoint_auth", "invalid_auth_mode", "invalid_client_id", "invalid_redirect_to", "invalid_scope", "invalid_version", "unsupported_theme", "unsupported_theme_mode", "presentation_unsupported", "popup_blocked", "popup_navigation_failed", "popup_timeout", "handshake_timeout", "untrusted_origin", "unknown_error"], undefined>;
|
|
7
6
|
}, undefined>;
|
|
8
7
|
readonly protocol: v.LiteralSchema<"andco:sdk", undefined>;
|
|
9
8
|
readonly version: v.LiteralSchema<2, undefined>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/messages/error.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/messages/error.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAS7B,eAAO,MAAM,qBAAqB;;;;;;;aAIhC,CAAC;AACH,gEAAgE;AAChE,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,qBAAqB,CAAC,CAAC"}
|
package/dist/messages/error.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
|
-
import {
|
|
2
|
+
import { ANDCO_BRIDGE_ERROR_CODES } from "../errors.js";
|
|
3
3
|
import { AndCoMessageBaseEntries } from "./base.js";
|
|
4
|
-
|
|
4
|
+
// Only what a widget can actually report, not the whole vocabulary: a host-page condition has no
|
|
5
|
+
// way to arrive from the iframe, and accepting one here would widen the wire to admit a message
|
|
6
|
+
// nothing can send. A refused code means a new producer appeared and belongs in the list.
|
|
7
|
+
const AndCoErrorCodeSchema = /* @__PURE__ */ v.picklist(ANDCO_BRIDGE_ERROR_CODES);
|
|
5
8
|
export const AndCoErrorEventSchema = /* @__PURE__ */ v.strictObject({
|
|
6
9
|
...AndCoMessageBaseEntries,
|
|
7
10
|
type: v.literal("error"),
|
package/dist/messages/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
2
|
/** Schema for every valid message sent through the AndCo bridge. */
|
|
3
3
|
export declare const AndCoBridgeMessageSchema: v.VariantSchema<"type", [v.StrictObjectSchema<{
|
|
4
|
-
readonly type: v.LiteralSchema<"
|
|
4
|
+
readonly type: v.LiteralSchema<"presentation-response", undefined>;
|
|
5
5
|
readonly presentationId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 128, undefined>, v.RegexAction<string, undefined>]>;
|
|
6
|
-
readonly
|
|
6
|
+
readonly url: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 8192, undefined>]>, undefined>;
|
|
7
7
|
readonly protocol: v.LiteralSchema<"andco:sdk", undefined>;
|
|
8
8
|
readonly version: v.LiteralSchema<2, undefined>;
|
|
9
9
|
}, undefined>, v.StrictObjectSchema<{
|
|
@@ -18,7 +18,7 @@ export declare const AndCoBridgeMessageSchema: v.VariantSchema<"type", [v.Strict
|
|
|
18
18
|
}, undefined>, v.StrictObjectSchema<{
|
|
19
19
|
readonly type: v.LiteralSchema<"error", undefined>;
|
|
20
20
|
readonly error: v.StrictObjectSchema<{
|
|
21
|
-
readonly code: v.PicklistSchema<[
|
|
21
|
+
readonly code: v.PicklistSchema<readonly ["invalid_endpoint_auth", "invalid_auth_mode", "invalid_client_id", "invalid_redirect_to", "invalid_scope", "invalid_version", "unsupported_theme", "unsupported_theme_mode", "presentation_unsupported", "popup_blocked", "popup_navigation_failed", "popup_timeout", "handshake_timeout", "untrusted_origin", "unknown_error"], undefined>;
|
|
22
22
|
}, undefined>;
|
|
23
23
|
readonly protocol: v.LiteralSchema<"andco:sdk", undefined>;
|
|
24
24
|
readonly version: v.LiteralSchema<2, undefined>;
|
package/dist/messages/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
|
-
import { AndCoAuthorizationResponseMessageSchema } from "./authorization-response.js";
|
|
3
2
|
import { AndCoClickEventSchema } from "./click.js";
|
|
4
3
|
import { AndCoErrorEventSchema } from "./error.js";
|
|
5
4
|
import { AndCoInitMessageSchema } from "./init.js";
|
|
6
5
|
import { AndCoIntentCompleteEventSchema, AndCoIntentDismissEventSchema, AndCoOAuthAuthorizationCodeEventSchema, AndCoOAuthCompleteEventSchema, AndCoOAuthDismissEventSchema, AndCoOAuthErrorEventSchema, } from "./popup.js";
|
|
6
|
+
import { AndCoPresentationResponseMessageSchema } from "./presentation-response.js";
|
|
7
7
|
import { AndCoReadyEventSchema } from "./ready.js";
|
|
8
8
|
import { AndCoSetPreferencesMessageSchema } from "./set-preferences.js";
|
|
9
9
|
/** Schema for every valid message sent through the AndCo bridge. */
|
|
10
10
|
export const AndCoBridgeMessageSchema = /* @__PURE__ */ v.variant("type", [
|
|
11
|
-
|
|
11
|
+
AndCoPresentationResponseMessageSchema,
|
|
12
12
|
AndCoReadyEventSchema,
|
|
13
13
|
AndCoClickEventSchema,
|
|
14
14
|
AndCoErrorEventSchema,
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
/**
|
|
3
|
+
* Resolves or cancels a deferred presentation the hosted button asked the parent SDK to prepare.
|
|
4
|
+
*
|
|
5
|
+
* One message for both flows on purpose. The hosted surface opens its window during the user's
|
|
6
|
+
* activation and only then asks where to send it, and that question is the same whether the
|
|
7
|
+
* destination is an authorization or an Intent — naming it after OAuth is what previously invited a
|
|
8
|
+
* second, parallel message for Intents.
|
|
9
|
+
*/
|
|
10
|
+
export declare const AndCoPresentationResponseMessageSchema: v.StrictObjectSchema<{
|
|
11
|
+
readonly type: v.LiteralSchema<"presentation-response", undefined>;
|
|
12
|
+
readonly presentationId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 128, undefined>, v.RegexAction<string, undefined>]>;
|
|
13
|
+
/** The resolved destination. Absent when resolution failed, which closes the pending window. */
|
|
14
|
+
readonly url: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 8192, undefined>]>, undefined>;
|
|
15
|
+
readonly protocol: v.LiteralSchema<"andco:sdk", undefined>;
|
|
16
|
+
readonly version: v.LiteralSchema<2, undefined>;
|
|
17
|
+
}, undefined>;
|
|
18
|
+
/** Host response carrying a deferred presentation URL, or no URL when resolution failed. */
|
|
19
|
+
export type AndCoPresentationResponseMessage = v.InferOutput<typeof AndCoPresentationResponseMessageSchema>;
|
|
20
|
+
//# sourceMappingURL=presentation-response.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presentation-response.d.ts","sourceRoot":"","sources":["../../src/messages/presentation-response.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAG7B;;;;;;;GAOG;AACH,eAAO,MAAM,sCAAsC;;;IAIjD,gGAAgG;;;;aAEhG,CAAC;AACH,4FAA4F;AAC5F,MAAM,MAAM,gCAAgC,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,sCAAsC,CAAC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
import { AndCoMessageBaseEntries, AndCoPresentationIdSchema } from "./base.js";
|
|
3
|
+
/**
|
|
4
|
+
* Resolves or cancels a deferred presentation the hosted button asked the parent SDK to prepare.
|
|
5
|
+
*
|
|
6
|
+
* One message for both flows on purpose. The hosted surface opens its window during the user's
|
|
7
|
+
* activation and only then asks where to send it, and that question is the same whether the
|
|
8
|
+
* destination is an authorization or an Intent — naming it after OAuth is what previously invited a
|
|
9
|
+
* second, parallel message for Intents.
|
|
10
|
+
*/
|
|
11
|
+
export const AndCoPresentationResponseMessageSchema = /* @__PURE__ */ v.strictObject({
|
|
12
|
+
...AndCoMessageBaseEntries,
|
|
13
|
+
type: v.literal("presentation-response"),
|
|
14
|
+
presentationId: AndCoPresentationIdSchema,
|
|
15
|
+
/** The resolved destination. Absent when resolution failed, which closes the pending window. */
|
|
16
|
+
url: v.optional(v.pipe(v.string(), v.minLength(1), v.maxLength(8_192))),
|
|
17
|
+
});
|
package/dist/native-copy.d.ts
CHANGED
|
@@ -1,7 +1,28 @@
|
|
|
1
1
|
/** Selects the supported language while preserving Platform's Spanish fallback. */
|
|
2
2
|
export declare function ANDCO_NATIVE_LOCALE(language?: string): "es" | "en" | "pt";
|
|
3
3
|
/** Formats CLP on Hermes without BigInt coercion or rounding unsafe integers. */
|
|
4
|
-
export declare function ANDCO_NATIVE_MONEY(value: string, locale?: "
|
|
4
|
+
export declare function ANDCO_NATIVE_MONEY(value: string, locale?: "es" | "en" | "pt"): string;
|
|
5
|
+
/**
|
|
6
|
+
* Formats a monetary string Andco returned, in any currency and locale, guarding the same way
|
|
7
|
+
* {@link ANDCO_NATIVE_MONEY} does against a value that would silently lose precision going through
|
|
8
|
+
* `Number()`. Every consumer that renders an Andco balance or amount as a string -- example apps
|
|
9
|
+
* included -- should format through this function instead of re-implementing the guard, or skipping
|
|
10
|
+
* it, on its own.
|
|
11
|
+
*/
|
|
12
|
+
export declare function ANDCO_FORMAT_MONEY(value: string, currency: string, locale?: string): string;
|
|
5
13
|
/** Native equivalents of Platform's localized labels; server-owned resource descriptions remain unchanged. */
|
|
6
|
-
export declare function ANDCO_NATIVE_TEXT(text: string, values?: Record<string, string | number>, locale?: "
|
|
14
|
+
export declare function ANDCO_NATIVE_TEXT(text: string, values?: Record<string, string | number>, locale?: "es" | "en" | "pt"): string;
|
|
15
|
+
/**
|
|
16
|
+
* Untranslated copy keys that vary only by Intent type, shared by every native renderer.
|
|
17
|
+
*
|
|
18
|
+
* Every consumer -- {@link ANDCO_NATIVE_INTENT_VIEW} and both platform Intent drawers -- reads this
|
|
19
|
+
* record instead of re-deriving the same three-way branch with its own chain of ternaries. Each
|
|
20
|
+
* value is a key into {@link ANDCO_NATIVE_TEXT}'s copy table, so callers still translate it with
|
|
21
|
+
* `ANDCO_NATIVE_TEXT(...)` at the point where it is rendered.
|
|
22
|
+
*/
|
|
23
|
+
export declare const ANDCO_NATIVE_INTENT_TYPE_COPY: Record<"deposit" | "transfer", {
|
|
24
|
+
title: string;
|
|
25
|
+
amountLabel: string;
|
|
26
|
+
destinationLabel: string;
|
|
27
|
+
}>;
|
|
7
28
|
//# sourceMappingURL=native-copy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native-copy.d.ts","sourceRoot":"","sources":["../src/native-copy.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,wBAAgB,mBAAmB,CAAC,QAAQ,SAAiD,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAGjH;AACD,iFAAiF;AACjF,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAwB,
|
|
1
|
+
{"version":3,"file":"native-copy.d.ts","sourceRoot":"","sources":["../src/native-copy.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,wBAAgB,mBAAmB,CAAC,QAAQ,SAAiD,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAGjH;AACD,iFAAiF;AACjF,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAwB,UAE/E;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,SAAU,GAAG,MAAM,CAI5F;AAED,8GAA8G;AAC9G,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,EACZ,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAM,EAC5C,MAAM,qBAAwB,UAK/B;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,6BAA6B,EAAE,MAAM,CAChD,SAAS,GAAG,UAAU,EACtB;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,gBAAgB,EAAE,MAAM,CAAA;CAAE,CAYjE,CAAC"}
|