@andco/protocol 0.0.6 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/README.md +22 -71
  2. package/dist/api-errors.d.ts +5 -5
  3. package/dist/api-errors.d.ts.map +1 -1
  4. package/dist/api-errors.js +5 -5
  5. package/dist/consent.d.ts +2 -2
  6. package/dist/consent.d.ts.map +1 -1
  7. package/dist/consent.js +10 -19
  8. package/dist/errors.d.ts +46 -7
  9. package/dist/errors.d.ts.map +1 -1
  10. package/dist/errors.js +51 -8
  11. package/dist/format-money.d.ts +3 -0
  12. package/dist/format-money.d.ts.map +1 -0
  13. package/dist/format-money.js +7 -0
  14. package/dist/index.d.ts +2 -1
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +2 -1
  17. package/dist/intent-input.d.ts +124 -124
  18. package/dist/intent-input.d.ts.map +1 -1
  19. package/dist/intent-input.js +14 -14
  20. package/dist/miniapp-icon.d.ts +2 -2
  21. package/dist/miniapp-icon.d.ts.map +1 -1
  22. package/dist/miniapp-icon.js +6 -58
  23. package/dist/native-intent.d.ts +20 -29
  24. package/dist/native-intent.d.ts.map +1 -1
  25. package/dist/native-intent.js +13 -56
  26. package/dist/pagination.d.ts +71 -0
  27. package/dist/pagination.d.ts.map +1 -0
  28. package/dist/pagination.js +63 -0
  29. package/dist/rar/account-matchers.d.ts +52 -52
  30. package/dist/rar/account-matchers.d.ts.map +1 -1
  31. package/dist/rar/account-matchers.js +81 -72
  32. package/dist/rar/bank.d.ts +86 -84
  33. package/dist/rar/bank.d.ts.map +1 -1
  34. package/dist/rar/bank.js +26 -24
  35. package/dist/rar/catalog.d.ts +57 -56
  36. package/dist/rar/catalog.d.ts.map +1 -1
  37. package/dist/rar/catalog.js +1 -0
  38. package/dist/rar/detail.d.ts +1 -1
  39. package/dist/rar/detail.d.ts.map +1 -1
  40. package/dist/rar/detail.js +1 -1
  41. package/dist/service-grants.d.ts +6 -3
  42. package/dist/service-grants.d.ts.map +1 -1
  43. package/dist/service-grants.js +17 -3
  44. package/dist/transport/financial-events.d.ts +10 -22
  45. package/dist/transport/financial-events.d.ts.map +1 -1
  46. package/dist/transport/financial-events.js +36 -62
  47. package/dist/transport/generated/oauth-api.d.ts +269 -96
  48. package/dist/transport/generated/oauth-api.d.ts.map +1 -1
  49. package/dist/transport/intents.d.ts +11 -10
  50. package/dist/transport/intents.d.ts.map +1 -1
  51. package/dist/transport/intents.js +20 -19
  52. package/dist/transport/rest.d.ts +3 -3
  53. package/dist/transport/rest.d.ts.map +1 -1
  54. package/dist/transport/rest.js +1 -1
  55. package/dist/transport/runtime.js +3 -3
  56. package/dist/utils.js +3 -3
  57. package/dist/webhooks.d.ts +92 -12
  58. package/dist/webhooks.d.ts.map +1 -1
  59. package/dist/webhooks.js +95 -20
  60. package/package.json +1 -1
  61. package/dist/native-copy.d.ts +0 -28
  62. package/dist/native-copy.d.ts.map +0 -1
  63. package/dist/native-copy.js +0 -400
@@ -1,30 +1,30 @@
1
1
  import * as v from "valibot";
2
2
  /**
3
- * Syntax of an Account Alias: the name that identifies one Cuenta Vista among the accounts of its
3
+ * Syntax of an Account Key: the name that identifies one Cuenta Vista among the accounts of its
4
4
  * Subject, unique per Subject regardless of which Project opened it.
5
5
  */
6
- export const ACCOUNT_ALIAS_SYNTAX = "^[a-z][a-z0-9_-]{0,63}$";
6
+ export const ACCOUNT_KEY_SYNTAX = "^[a-z][a-z0-9_-]{0,63}$";
7
7
  /**
8
- * Syntax of the `pattern` carried by an `alias` matcher, and the entire grammar of the language:
9
- * one alias literal (`caja-chica-1`), one alias literal followed by a single trailing `*`
8
+ * Syntax of the `pattern` carried by an `accountKey` matcher, and the entire grammar of the language:
9
+ * one accountKey literal (`caja-chica-1`), one accountKey literal followed by a single trailing `*`
10
10
  * (`caja-chica-*`), or `*` alone. There is no other metacharacter, no anchor and no alternation.
11
11
  *
12
12
  * Regular expressions were rejected on a decisive technical ground, not on taste. The
13
13
  * authorization decision has to answer whether one resolved detail is *contained* in the requested
14
14
  * one, and containment of regular languages is PSPACE-complete; with prefix globs it is the three
15
- * lines of {@link accountAliasPatternContains}. Two further reasons hold independently: the
15
+ * lines of {@link accountKeyPatternContains}. Two further reasons hold independently: the
16
16
  * decision runs in Postgres while the schema is validated in JavaScript, and POSIX and ECMAScript
17
17
  * are not the same language, so one permission would mean two things depending on where it ran;
18
18
  * and Postgres `~` is unanchored, so `cliente-1` would silently also authorize `evil-cliente-123`,
19
19
  * failing towards granting more.
20
20
  */
21
- export const ACCOUNT_ALIAS_PATTERN_SYNTAX = "^(?:\\*|[a-z][a-z0-9_-]{0,63}\\*?)$";
21
+ export const ACCOUNT_KEY_PATTERN_SYNTAX = "^(?:\\*|[a-z][a-z0-9_-]{0,63}\\*?)$";
22
22
  /** Syntax of an Andco account identifier: a UUID. */
23
23
  export const ACCOUNT_ID_PATTERN = "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$";
24
- /** An Account Alias, exactly as its holder chose it. */
25
- export const AccountAliasSchema = /* @__PURE__ */ v.pipe(v.string(), v.regex(new RegExp(ACCOUNT_ALIAS_SYNTAX)));
26
- /** A prefix glob over Account Aliases. See {@link ACCOUNT_ALIAS_PATTERN_SYNTAX} for the grammar. */
27
- export const AccountAliasPatternSchema = /* @__PURE__ */ v.pipe(v.string(), v.regex(new RegExp(ACCOUNT_ALIAS_PATTERN_SYNTAX)));
24
+ /** An Account Key, exactly as its holder chose it. */
25
+ export const AccountKeySchema = /* @__PURE__ */ v.pipe(v.string(), v.regex(new RegExp(ACCOUNT_KEY_SYNTAX)));
26
+ /** A prefix glob over Account Keys. See {@link ACCOUNT_KEY_PATTERN_SYNTAX} for the grammar. */
27
+ export const AccountKeyPatternSchema = /* @__PURE__ */ v.pipe(v.string(), v.regex(new RegExp(ACCOUNT_KEY_PATTERN_SYNTAX)));
28
28
  /** Upper bound of every matcher list. */
29
29
  export const ACCOUNT_MATCHER_LIST_CEILING = 100;
30
30
  /** Upper bound of each optional field of an `external` matcher. */
@@ -37,7 +37,7 @@ const editable = /* @__PURE__ */ v.nullish(v.boolean());
37
37
  /**
38
38
  * How many accounts the person picks at consent for an `editable` matcher of a list she narrows:
39
39
  * `"multiple"` (the default) lets her keep several, `"single"` asks for exactly one, which the
40
- * Grant then fixes as one `account` matcher. Only an `editable` own matcher (`alias` or
40
+ * Grant then fixes as one `account` matcher. Only an `editable` own matcher (`accountKey` or
41
41
  * `any`/`own`) of a source, `accounts` or Deposit destination list may carry it, and every editable
42
42
  * matcher of that list must agree.
43
43
  *
@@ -49,18 +49,18 @@ export const ACCOUNT_SELECTIONS = ["single", "multiple"];
49
49
  const selection = /* @__PURE__ */ v.nullish(v.picklist(ACCOUNT_SELECTIONS));
50
50
  // -- Grant Request matchers ---------------------------------------------------------------------
51
51
  /**
52
- * Accounts of the Subject whose Account Alias matches `pattern` (literal, `prefix*` or `*`),
52
+ * Accounts of the Subject whose Account Key matches `pattern` (literal, `prefix*` or `*`),
53
53
  * including accounts that will exist tomorrow. `type` may be omitted. With `editable`, the person
54
54
  * may narrow it at consent to accounts it currently matches, which the Grant then fixes as
55
55
  * `account` matchers.
56
56
  *
57
57
  * @example
58
- * const caja: AccountAlias = { type: "alias", pattern: "caja-*", editable: true };
59
- * const short: AccountAlias = { pattern: "ventas" };
58
+ * const caja: AccountKey = { type: "account_key", pattern: "caja-*", editable: true };
59
+ * const short: AccountKey = { pattern: "ventas" };
60
60
  */
61
- export const AccountAliasMatcherSchema = /* @__PURE__ */ v.strictObject({
62
- type: v.nullish(v.literal("alias")),
63
- pattern: AccountAliasPatternSchema,
61
+ export const AccountKeyMatcherSchema = /* @__PURE__ */ v.strictObject({
62
+ type: v.nullish(v.literal("account_key")),
63
+ pattern: AccountKeyPatternSchema,
64
64
  editable,
65
65
  selection,
66
66
  });
@@ -112,13 +112,13 @@ export const AccountExternalMatcherSchema = /* @__PURE__ */ v.strictObject({
112
112
  * destination accepts, so that no permission can debit, read or collect into someone else's account.
113
113
  */
114
114
  export const OwnAccountMatcherSchema = /* @__PURE__ */ v.union([
115
- AccountAliasMatcherSchema,
115
+ AccountKeyMatcherSchema,
116
116
  AccountInternalMatcherSchema,
117
117
  AnyOwnMatcherSchema,
118
118
  ]);
119
119
  /** Every matcher kind; what a Transfer destination accepts. */
120
120
  export const DestinationAccountMatcherSchema = /* @__PURE__ */ v.union([
121
- AccountAliasMatcherSchema,
121
+ AccountKeyMatcherSchema,
122
122
  AccountInternalMatcherSchema,
123
123
  AnyOwnMatcherSchema,
124
124
  AnyLocalMatcherSchema,
@@ -126,10 +126,10 @@ export const DestinationAccountMatcherSchema = /* @__PURE__ */ v.union([
126
126
  AccountExternalMatcherSchema,
127
127
  ]);
128
128
  // -- Grant matchers -----------------------------------------------------------------------------
129
- /** {@link AccountAliasMatcherSchema} as granted: `type` present, no `editable`. */
130
- export const GrantedAccountAliasSchema = /* @__PURE__ */ v.strictObject({
131
- type: v.literal("alias"),
132
- pattern: AccountAliasPatternSchema,
129
+ /** {@link AccountKeyMatcherSchema} as granted: `type` present, no `editable`. */
130
+ export const GrantedAccountKeySchema = /* @__PURE__ */ v.strictObject({
131
+ type: v.literal("account_key"),
132
+ pattern: AccountKeyPatternSchema,
133
133
  });
134
134
  /** {@link AccountInternalMatcherSchema} as granted. */
135
135
  export const GrantedAccountInternalSchema = /* @__PURE__ */ v.strictObject({
@@ -156,13 +156,13 @@ export const GrantedAccountExternalSchema = /* @__PURE__ */ v.strictObject({
156
156
  });
157
157
  /** {@link OwnAccountMatcherSchema} as granted. */
158
158
  export const GrantedOwnAccountMatcherSchema = /* @__PURE__ */ v.union([
159
- GrantedAccountAliasSchema,
159
+ GrantedAccountKeySchema,
160
160
  GrantedAccountInternalSchema,
161
161
  GrantedAnyOwnSchema,
162
162
  ]);
163
163
  /** {@link DestinationAccountMatcherSchema} as granted. */
164
164
  export const GrantedDestinationAccountMatcherSchema = /* @__PURE__ */ v.union([
165
- GrantedAccountAliasSchema,
165
+ GrantedAccountKeySchema,
166
166
  GrantedAccountInternalSchema,
167
167
  GrantedAnyOwnSchema,
168
168
  GrantedAnyLocalSchema,
@@ -183,7 +183,7 @@ export function accountMatcherKey(matcher) {
183
183
  case "external":
184
184
  return `external:${ACCOUNT_EXTERNAL_FIELDS.map((field) => matcher[field] ?? "").join("\u0000")}`;
185
185
  default:
186
- return `alias:${matcher.pattern}`;
186
+ return `accountKey:${matcher.pattern}`;
187
187
  }
188
188
  }
189
189
  /**
@@ -197,7 +197,7 @@ export function accountMatcherList(schema) {
197
197
  /**
198
198
  * Whether the `selection` of a list's matchers is coherent: it only sits on `editable` matchers, and
199
199
  * every editable matcher of the list asks for the same one. Lists that are never picked from (the
200
- * aliases of accounts to open, a Transfer's destinations) must carry none: {@link accountSelectionIsAbsent}.
200
+ * accountKeys of accounts to open, a Transfer's destinations) must carry none: {@link accountSelectionIsAbsent}.
201
201
  *
202
202
  * @example
203
203
  * accountSelectionIsCoherent([{ type: "any", limit: "own", editable: true, selection: "single" }]); // true
@@ -235,13 +235,13 @@ const nullable = (schema) => ({ anyOf: [{ type: "null" }, schema] });
235
235
  const editableJson = nullable({ type: "boolean" });
236
236
  const selectionJson = nullable({ enum: [...ACCOUNT_SELECTIONS] });
237
237
  const externalFieldJson = { type: "string", minLength: 1, maxLength: EXTERNAL_FIELD_CEILING, pattern: "\\S" };
238
- const aliasRequestJson = {
238
+ const accountKeyRequestJson = {
239
239
  type: "object",
240
240
  additionalProperties: false,
241
241
  required: ["pattern"],
242
242
  properties: {
243
- type: nullable({ const: "alias" }),
244
- pattern: { type: "string", pattern: ACCOUNT_ALIAS_PATTERN_SYNTAX },
243
+ type: nullable({ const: "account_key" }),
244
+ pattern: { type: "string", pattern: ACCOUNT_KEY_PATTERN_SYNTAX },
245
245
  editable: editableJson,
246
246
  selection: selectionJson,
247
247
  },
@@ -280,11 +280,11 @@ const externalRequestJson = {
280
280
  editable: editableJson,
281
281
  },
282
282
  };
283
- const aliasGrantJson = {
283
+ const accountKeyGrantJson = {
284
284
  type: "object",
285
285
  additionalProperties: false,
286
286
  required: ["type", "pattern"],
287
- properties: { type: { const: "alias" }, pattern: { type: "string", pattern: ACCOUNT_ALIAS_PATTERN_SYNTAX } },
287
+ properties: { type: { const: "account_key" }, pattern: { type: "string", pattern: ACCOUNT_KEY_PATTERN_SYNTAX } },
288
288
  };
289
289
  const accountGrantJson = {
290
290
  type: "object",
@@ -315,11 +315,13 @@ const listJson = (items) => ({
315
315
  items,
316
316
  });
317
317
  /** JSON Schema mirror of {@link OwnAccountMatcherSchema}. */
318
- export const OWN_ACCOUNT_MATCHER_JSON_SCHEMA = { anyOf: [aliasRequestJson, accountRequestJson, anyRequestJson("own")] };
318
+ export const OWN_ACCOUNT_MATCHER_JSON_SCHEMA = {
319
+ anyOf: [accountKeyRequestJson, accountRequestJson, anyRequestJson("own")],
320
+ };
319
321
  /** JSON Schema mirror of {@link DestinationAccountMatcherSchema}. */
320
322
  export const DESTINATION_ACCOUNT_MATCHER_JSON_SCHEMA = {
321
323
  anyOf: [
322
- aliasRequestJson,
324
+ accountKeyRequestJson,
323
325
  accountRequestJson,
324
326
  anyRequestJson("own"),
325
327
  anyRequestJson("local"),
@@ -329,75 +331,82 @@ export const DESTINATION_ACCOUNT_MATCHER_JSON_SCHEMA = {
329
331
  };
330
332
  /** JSON Schema mirror of {@link GrantedOwnAccountMatcherSchema}. */
331
333
  export const GRANTED_OWN_ACCOUNT_MATCHER_JSON_SCHEMA = {
332
- anyOf: [aliasGrantJson, accountGrantJson, anyGrantJson("own")],
334
+ anyOf: [accountKeyGrantJson, accountGrantJson, anyGrantJson("own")],
333
335
  };
334
336
  /** JSON Schema mirror of {@link GrantedDestinationAccountMatcherSchema}. */
335
337
  export const GRANTED_DESTINATION_ACCOUNT_MATCHER_JSON_SCHEMA = {
336
- anyOf: [aliasGrantJson, accountGrantJson, anyGrantJson("own"), anyGrantJson("local"), anyAllJson, externalGrantJson],
338
+ anyOf: [
339
+ accountKeyGrantJson,
340
+ accountGrantJson,
341
+ anyGrantJson("own"),
342
+ anyGrantJson("local"),
343
+ anyAllJson,
344
+ externalGrantJson,
345
+ ],
337
346
  };
338
347
  /**
339
348
  * JSON Schema mirror of {@link accountMatcherList}. `uniqueItems` compares whole objects, so it is
340
- * looser than the valibot check, which ignores `editable` and an omitted alias `type`; the gate's
349
+ * looser than the valibot check, which ignores `editable` and an omitted accountKey `type`; the gate's
341
350
  * own comparison closes the gap.
342
351
  */
343
352
  export function accountMatcherListJsonSchema(items) {
344
353
  return listJson(items);
345
354
  }
346
- // -- Alias patterns -----------------------------------------------------------------------------
355
+ // -- AccountKey patterns -----------------------------------------------------------------------------
347
356
  /**
348
- * Decides whether `alias` belongs to the set described by `pattern`.
357
+ * Decides whether `accountKey` belongs to the set described by `pattern`.
349
358
  *
350
- * The grammar of {@link ACCOUNT_ALIAS_PATTERN_SYNTAX} leaves only two cases: a literal matches by
359
+ * The grammar of {@link ACCOUNT_KEY_PATTERN_SYNTAX} leaves only two cases: a literal matches by
351
360
  * equality, and a trailing `*` matches by prefix. `*` alone has the empty prefix and therefore
352
- * matches every alias — but only an alias: an account that carries none is matched by nothing.
353
- * A malformed pattern can only match fewer aliases, never more: `caja*chica` has no trailing `*`,
361
+ * matches every accountKey — but only an accountKey: an account that carries none is matched by nothing.
362
+ * A malformed pattern can only match fewer accountKeys, never more: `caja*chica` has no trailing `*`,
354
363
  * so it is compared as a literal.
355
364
  *
356
365
  * @example
357
- * accountAliasPatternMatches("caja-*", "caja-chica"); // true
358
- * accountAliasPatternMatches("caja-chica", "caja-chica-1"); // false
366
+ * accountKeyPatternMatches("caja-*", "caja-chica"); // true
367
+ * accountKeyPatternMatches("caja-chica", "caja-chica-1"); // false
359
368
  */
360
- export function accountAliasPatternMatches(pattern, alias) {
369
+ export function accountKeyPatternMatches(pattern, accountKey) {
361
370
  if (!pattern.endsWith("*"))
362
- return pattern === alias;
363
- return alias.startsWith(pattern.slice(0, -1));
371
+ return pattern === accountKey;
372
+ return accountKey.startsWith(pattern.slice(0, -1));
364
373
  }
365
374
  /** The literal part of a pattern: the whole pattern for a literal, everything before the `*` otherwise. */
366
375
  function literalPrefixOf(pattern) {
367
376
  return pattern.endsWith("*") ? pattern.slice(0, -1) : pattern;
368
377
  }
369
378
  /**
370
- * Decides whether every alias matched by `inner` is also matched by `outer`, for every possible
371
- * set of aliases rather than for the ones that happen to exist right now.
379
+ * Decides whether every accountKey matched by `inner` is also matched by `outer`, for every possible
380
+ * set of accountKeys rather than for the ones that happen to exist right now.
372
381
  *
373
- * A literal `outer` denotes a single alias, so it can only contain itself — in particular
382
+ * A literal `outer` denotes a single accountKey, so it can only contain itself — in particular
374
383
  * `caja-chica` does not contain `caja-chica*`, whose language is infinite. A glob `outer` contains
375
384
  * `inner` exactly when `inner`'s literal prefix starts with `outer`'s.
376
385
  *
377
386
  * @example
378
- * accountAliasPatternContains("caja-*", "caja-chica-*"); // true
379
- * accountAliasPatternContains("caja-chica", "caja-chica*"); // false
387
+ * accountKeyPatternContains("caja-*", "caja-chica-*"); // true
388
+ * accountKeyPatternContains("caja-chica", "caja-chica*"); // false
380
389
  */
381
- export function accountAliasPatternContains(outer, inner) {
390
+ export function accountKeyPatternContains(outer, inner) {
382
391
  if (!outer.endsWith("*"))
383
392
  return inner === outer;
384
393
  return literalPrefixOf(inner).startsWith(literalPrefixOf(outer));
385
394
  }
386
- /** Classifies a matcher; an alias matcher may omit its `type`. */
395
+ /** Classifies a matcher; an accountKey matcher may omit its `type`. */
387
396
  export function accountMatcherKind(matcher) {
388
397
  if (matcher.type === "any")
389
398
  return matcher.limit;
390
399
  if (matcher.type === "account" || matcher.type === "external")
391
400
  return matcher.type;
392
- return "alias";
401
+ return "account_key";
393
402
  }
394
403
  /** Reads an own-account fact without ever reaching the prototype chain. */
395
- function ownAccountAlias(facts, id) {
404
+ function ownAccountKey(facts, id) {
396
405
  const record = facts.ownAccounts;
397
406
  if (record === undefined || !Object.hasOwn(record, id))
398
- return { own: false, alias: null };
399
- const alias = record[id];
400
- return { own: true, alias: typeof alias === "string" ? alias : null };
407
+ return { own: false, accountKey: null };
408
+ const accountKey = record[id];
409
+ return { own: true, accountKey: typeof accountKey === "string" ? accountKey : null };
401
410
  }
402
411
  /** An `external` contains another when every field it fixes is fixed to the same value there. */
403
412
  function externalContains(outer, inner) {
@@ -409,20 +418,20 @@ function externalContains(outer, inner) {
409
418
  /**
410
419
  * Decides whether every account admitted by `inner` is also admitted by `outer`. The Grant's (or the
411
420
  * Grant Request's) matcher is `outer`; the narrower Grant, or the account an operation names, is
412
- * `inner`. Containment must keep holding as accounts and aliases change.
421
+ * `inner`. Containment must keep holding as accounts and accountKeys change.
413
422
  *
414
- * The order is `any(all) ⊇ any(local) ⊇ any(own) ⊇ alias ⊇ account`, and `external` only under
423
+ * The order is `any(all) ⊇ any(local) ⊇ any(own) ⊇ accountKey ⊇ account`, and `external` only under
415
424
  * `all`:
416
425
  *
417
426
  * - `any(all)` contains every matcher; only `any(all)` contains `any(all)`.
418
427
  * - `external` is contained by `any(all)`, and by an `external` whose every fixed field `inner`
419
428
  * fixes to the same value. Nothing else contains it, and it contains nothing but such an
420
429
  * `external`.
421
- * - `any(local)` contains every Andco matcher: `any(local)`, `any(own)`, `alias` and `account`.
422
- * - `any(own)` contains `any(own)` and `alias` (an alias names an account of the Subject by
430
+ * - `any(local)` contains every Andco matcher: `any(local)`, `any(own)`, `accountKey` and `account`.
431
+ * - `any(own)` contains `any(own)` and `accountKey` (an accountKey names an account of the Subject by
423
432
  * construction), and an `account` only when `facts.ownAccounts` says it is the Subject's.
424
- * - `alias:q` contains `alias:p` per {@link accountAliasPatternContains}, and an `account` only when
425
- * `facts.ownAccounts` gives it an alias that `q` matches.
433
+ * - `accountKey:q` contains `accountKey:p` per {@link accountKeyPatternContains}, and an `account` only when
434
+ * `facts.ownAccounts` gives it an accountKey that `q` matches.
426
435
  * - `account:id` contains only `account:id`. It never contains a pattern, not even one matching
427
436
  * exactly one account today, because it could match two tomorrow.
428
437
  *
@@ -430,10 +439,10 @@ function externalContains(outer, inner) {
430
439
  * `scripts/account-matcher-containment-cases.mjs` pin both to the same table.
431
440
  *
432
441
  * @example
433
- * accountMatcherContains({ type: "any", limit: "local" }, { type: "alias", pattern: "caja-*" }); // true
442
+ * accountMatcherContains({ type: "any", limit: "local" }, { type: "account_key", pattern: "caja-*" }); // true
434
443
  * accountMatcherContains({ type: "any", limit: "local" }, { type: "external" }); // false
435
444
  * accountMatcherContains(
436
- * { type: "alias", pattern: "caja-*" },
445
+ * { type: "account_key", pattern: "caja-*" },
437
446
  * { type: "account", id: "00000000-0000-4000-8000-000000000001" },
438
447
  * { ownAccounts: { "00000000-0000-4000-8000-000000000001": "caja-chica" } },
439
448
  * ); // true
@@ -454,7 +463,7 @@ export function accountMatcherContains(outer, inner, facts = {}) {
454
463
  return false;
455
464
  if (outerKind === "own") {
456
465
  if (inner.type === "account")
457
- return ownAccountAlias(facts, inner.id).own;
466
+ return ownAccountKey(facts, inner.id).own;
458
467
  return true;
459
468
  }
460
469
  if (innerKind === "own")
@@ -462,10 +471,10 @@ export function accountMatcherContains(outer, inner, facts = {}) {
462
471
  if (outer.type === "account")
463
472
  return inner.type === "account" && inner.id === outer.id;
464
473
  if (inner.type === "account") {
465
- const { alias } = ownAccountAlias(facts, inner.id);
466
- return alias !== null && "pattern" in outer && accountAliasPatternMatches(outer.pattern, alias);
474
+ const { accountKey } = ownAccountKey(facts, inner.id);
475
+ return accountKey !== null && "pattern" in outer && accountKeyPatternMatches(outer.pattern, accountKey);
467
476
  }
468
- return "pattern" in outer && "pattern" in inner && accountAliasPatternContains(outer.pattern, inner.pattern);
477
+ return "pattern" in outer && "pattern" in inner && accountKeyPatternContains(outer.pattern, inner.pattern);
469
478
  }
470
479
  /**
471
480
  * Decides whether the set described by the `inner` list is contained in the one described by
@@ -473,7 +482,7 @@ export function accountMatcherContains(outer, inner, facts = {}) {
473
482
  *
474
483
  * An empty `inner` is contained in anything, since it admits no account at all, and a non-empty
475
484
  * `inner` is never contained in an empty `outer`. Containment is not distributed across `outer`:
476
- * `[alias:a-*, alias:b-*]` does not contain `alias:*`, and refusing it is the sound answer.
485
+ * `[accountKey:a-*, accountKey:b-*]` does not contain `accountKey:*`, and refusing it is the sound answer.
477
486
  */
478
487
  export function accountMatchersContain(outer, inner, facts = {}) {
479
488
  return inner.every((one) => outer.some((candidate) => accountMatcherContains(candidate, one, facts)));