@interop/wallet-core 0.71.0 → 0.72.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -3
- package/dist/clientAnnex/forget.d.ts.map +1 -1
- package/dist/clientAnnex/forget.js +4 -3
- package/dist/clientAnnex/forget.js.map +1 -1
- package/dist/clientAnnex/forgetLast.d.ts +55 -35
- package/dist/clientAnnex/forgetLast.d.ts.map +1 -1
- package/dist/clientAnnex/forgetLast.js +87 -35
- package/dist/clientAnnex/forgetLast.js.map +1 -1
- package/dist/clientAnnex/gc.d.ts +48 -19
- package/dist/clientAnnex/gc.d.ts.map +1 -1
- package/dist/clientAnnex/gc.js +82 -31
- package/dist/clientAnnex/gc.js.map +1 -1
- package/dist/clientAnnex/grantRevocation.d.ts +137 -0
- package/dist/clientAnnex/grantRevocation.d.ts.map +1 -0
- package/dist/clientAnnex/grantRevocation.js +135 -0
- package/dist/clientAnnex/grantRevocation.js.map +1 -0
- package/dist/clientAnnex/index.d.ts +4 -2
- package/dist/clientAnnex/index.d.ts.map +1 -1
- package/dist/clientAnnex/index.js +2 -1
- package/dist/clientAnnex/index.js.map +1 -1
- package/dist/clientAnnex/ladderAnchored.d.ts +0 -22
- package/dist/clientAnnex/ladderAnchored.d.ts.map +1 -1
- package/dist/clientAnnex/ladderAnchored.js +8 -34
- package/dist/clientAnnex/ladderAnchored.js.map +1 -1
- package/dist/clientAnnex/log.d.ts +65 -13
- package/dist/clientAnnex/log.d.ts.map +1 -1
- package/dist/clientAnnex/log.js +160 -67
- package/dist/clientAnnex/log.js.map +1 -1
- package/dist/clientAnnex/mend.js +51 -24
- package/dist/clientAnnex/mend.js.map +1 -1
- package/dist/clients/grantState.d.ts +6 -3
- package/dist/clients/grantState.d.ts.map +1 -1
- package/dist/clients/grantState.js +6 -3
- package/dist/clients/grantState.js.map +1 -1
- package/dist/clients/policy.d.ts.map +1 -1
- package/dist/clients/policy.js +3 -0
- package/dist/clients/policy.js.map +1 -1
- package/dist/keyring/fetch.d.ts +6 -2
- package/dist/keyring/fetch.d.ts.map +1 -1
- package/dist/keyring/fetch.js +7 -3
- package/dist/keyring/fetch.js.map +1 -1
- package/dist/keyring/index.d.ts +7 -5
- package/dist/keyring/index.d.ts.map +1 -1
- package/dist/keyring/index.js +7 -5
- package/dist/keyring/index.js.map +1 -1
- package/dist/keyring/kdf.d.ts +1 -1
- package/dist/keyring/kdf.d.ts.map +1 -1
- package/dist/keyring/kdf.js +1 -1
- package/dist/keyring/kdf.js.map +1 -1
- package/dist/keyring/unlockSpace.d.ts +45 -68
- package/dist/keyring/unlockSpace.d.ts.map +1 -1
- package/dist/keyring/unlockSpace.js +66 -88
- package/dist/keyring/unlockSpace.js.map +1 -1
- package/dist/menders/derive.d.ts +85 -0
- package/dist/menders/derive.d.ts.map +1 -0
- package/dist/menders/derive.js +138 -0
- package/dist/menders/derive.js.map +1 -0
- package/dist/menders/ids.d.ts +20 -0
- package/dist/menders/ids.d.ts.map +1 -0
- package/dist/menders/ids.js +85 -0
- package/dist/menders/ids.js.map +1 -0
- package/dist/menders/index.d.ts +42 -0
- package/dist/menders/index.d.ts.map +1 -0
- package/dist/menders/index.js +37 -0
- package/dist/menders/index.js.map +1 -0
- package/dist/menders/registry.d.ts +84 -0
- package/dist/menders/registry.d.ts.map +1 -0
- package/dist/menders/registry.js +62 -0
- package/dist/menders/registry.js.map +1 -0
- package/dist/menders/runner.d.ts +143 -0
- package/dist/menders/runner.d.ts.map +1 -0
- package/dist/menders/runner.js +222 -0
- package/dist/menders/runner.js.map +1 -0
- package/dist/menders/types.d.ts +146 -0
- package/dist/menders/types.d.ts.map +1 -0
- package/dist/menders/types.js +2 -0
- package/dist/menders/types.js.map +1 -0
- package/dist/menders/vocabulary.d.ts +88 -0
- package/dist/menders/vocabulary.d.ts.map +1 -0
- package/dist/menders/vocabulary.js +83 -0
- package/dist/menders/vocabulary.js.map +1 -0
- package/dist/recovery/index.d.ts +1 -1
- package/dist/recovery/index.js +1 -1
- package/dist/recovery/recoveryWebvh.d.ts.map +1 -1
- package/dist/recovery/recoveryWebvh.js +11 -17
- package/dist/recovery/recoveryWebvh.js.map +1 -1
- package/dist/resourceLog/document.d.ts.map +1 -1
- package/dist/resourceLog/document.js +30 -6
- package/dist/resourceLog/document.js.map +1 -1
- package/dist/space/activity.d.ts +70 -0
- package/dist/space/activity.d.ts.map +1 -1
- package/dist/space/activity.js +82 -0
- package/dist/space/activity.js.map +1 -1
- package/dist/space/deleteSpace.d.ts.map +1 -1
- package/dist/space/deleteSpace.js +6 -5
- package/dist/space/deleteSpace.js.map +1 -1
- package/dist/space/index.d.ts +1 -1
- package/dist/space/index.d.ts.map +1 -1
- package/dist/space/index.js +1 -1
- package/dist/space/index.js.map +1 -1
- package/dist/testing.d.ts +78 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +89 -0
- package/dist/testing.js.map +1 -0
- package/dist/unlock/index.d.ts +2 -2
- package/dist/unlock/index.d.ts.map +1 -1
- package/dist/unlock/index.js +1 -1
- package/dist/unlock/retire.d.ts +20 -5
- package/dist/unlock/retire.d.ts.map +1 -1
- package/dist/unlock/retire.js.map +1 -1
- package/dist/unlock/standingWebvh.d.ts +22 -2
- package/dist/unlock/standingWebvh.d.ts.map +1 -1
- package/dist/unlock/standingWebvh.js +22 -2
- package/dist/unlock/standingWebvh.js.map +1 -1
- package/dist/webvh/didWebvh.d.ts +33 -0
- package/dist/webvh/didWebvh.d.ts.map +1 -1
- package/dist/webvh/didWebvh.js +50 -11
- package/dist/webvh/didWebvh.js.map +1 -1
- package/dist/webvh/enrollClient.d.ts.map +1 -1
- package/dist/webvh/enrollClient.js +4 -16
- package/dist/webvh/enrollClient.js.map +1 -1
- package/dist/webvh/index.d.ts +13 -3
- package/dist/webvh/index.d.ts.map +1 -1
- package/dist/webvh/index.js +13 -3
- package/dist/webvh/index.js.map +1 -1
- package/dist/webvh/listClients.d.ts +47 -0
- package/dist/webvh/listClients.d.ts.map +1 -1
- package/dist/webvh/listClients.js +40 -1
- package/dist/webvh/listClients.js.map +1 -1
- package/dist/webvh/standingZcap.d.ts +66 -0
- package/dist/webvh/standingZcap.d.ts.map +1 -1
- package/dist/webvh/standingZcap.js +96 -0
- package/dist/webvh/standingZcap.js.map +1 -1
- package/dist/webvh/zcap.d.ts +1 -1
- package/package.json +18 -6
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2026 Interop Alliance. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* The `@interop/wallet-core/menders` subpath: the mender registry keyed by
|
|
6
|
+
* invariant. A wallet declares its own table of invariants (data: what must
|
|
7
|
+
* hold between ceremonies) and its own registrations (code: what converges a
|
|
8
|
+
* violated one); this module carries the structure both wallets share.
|
|
9
|
+
*
|
|
10
|
+
* - the vocabularies: `AUTHORITIES`, `TRIGGERS`, `CHAIN_TRIGGERS`,
|
|
11
|
+
* `ACCOUNT_SHAPES`, `EVIDENCE`, `MEND_OUTCOMES`, `GAP_KINDS`, and
|
|
12
|
+
* `INVARIANT_IDS`, each an `as const` array with its union
|
|
13
|
+
* - the types: `InvariantDeclaration`, `RegistrationSite`, `Registration`,
|
|
14
|
+
* `MendOutcome`, `MendReportEntry`, `MendReport`, `InvariantGap`,
|
|
15
|
+
* `LoginRoute`
|
|
16
|
+
* - the readers: `menderRegistry` (`all`, `byId`, `sites`, `admits`,
|
|
17
|
+
* `dueAt`), which refuses a duplicated id, an undeclared report, or a
|
|
18
|
+
* guard on a non-routing site at construction, and `heldAuthorities`, the
|
|
19
|
+
* held set a session's account-ceremony context derives
|
|
20
|
+
* - the runner: `runMenderBlock`, one try, warn, and skip discipline over
|
|
21
|
+
* one chain trigger's registrations, `mendReportAccumulator`, the
|
|
22
|
+
* pre-session report collector its `onOutcome` feeds, and `errorNameOf`,
|
|
23
|
+
* the name a report carries for a thrown value of any shape
|
|
24
|
+
* - the derived sets a wallet's audit tests pin:
|
|
25
|
+
* `transientReachableInvariants`, `deriveGaps`, `undeclaredGaps`, and
|
|
26
|
+
* `undeclaredInvariants`
|
|
27
|
+
*
|
|
28
|
+
* Nothing here executes a ceremony. The runner calls the convergers a
|
|
29
|
+
* wallet registers and nothing else; the ceremonies stay explicit sequenced
|
|
30
|
+
* code, and the registry describes the menders from the outside.
|
|
31
|
+
*/
|
|
32
|
+
export { deriveGaps, transientReachableInvariants, undeclaredGaps, undeclaredInvariants } from './derive.js';
|
|
33
|
+
export { INVARIANT_IDS } from './ids.js';
|
|
34
|
+
export { heldAuthorities, menderRegistry } from './registry.js';
|
|
35
|
+
export { errorNameOf, MEND_REPORT_SHAPE_ERROR, mendReportAccumulator, runMenderBlock } from './runner.js';
|
|
36
|
+
export { ACCOUNT_SHAPES, AUTHORITIES, CHAIN_TRIGGERS, EVIDENCE, GAP_KINDS, MEND_OUTCOMES, TRIGGERS } from './vocabulary.js';
|
|
37
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/menders/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,EACL,UAAU,EACV,4BAA4B,EAC5B,cAAc,EACd,oBAAoB,EACrB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAExC,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAE/D,OAAO,EACL,WAAW,EACX,uBAAuB,EACvB,qBAAqB,EACrB,cAAc,EACf,MAAM,aAAa,CAAA;AAYpB,OAAO,EACL,cAAc,EACd,WAAW,EACX,cAAc,EACd,QAAQ,EACR,SAAS,EACT,aAAa,EACb,QAAQ,EACT,MAAM,iBAAiB,CAAA"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2026 Interop Alliance. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* The registry readers over a declaration table and its per-trigger
|
|
6
|
+
* registration sites: `all` and `byId` read declarations, `admits` is the
|
|
7
|
+
* one admission test (every reported invariant declares an authority the
|
|
8
|
+
* session holds and admits this login route), and `dueAt` reads the sites
|
|
9
|
+
* listed under one chain trigger that `admits` passes, in list order.
|
|
10
|
+
* Registration order is execution order; there is no dependency graph and
|
|
11
|
+
* no priority. The table and the sites are checked once, at construction: a
|
|
12
|
+
* duplicated declaration id, a site reporting an undeclared invariant, or a
|
|
13
|
+
* guard on a non-routing site is a `TypeError` there, so no reader meets the
|
|
14
|
+
* defect later, depending on what a login happens to hold.
|
|
15
|
+
*/
|
|
16
|
+
import type { InvariantId } from './ids.js';
|
|
17
|
+
import type { InvariantDeclaration, LoginRoute, RegistrationSite } from './types.js';
|
|
18
|
+
import type { Authority, ChainTrigger } from './vocabulary.js';
|
|
19
|
+
/**
|
|
20
|
+
* The two authorities a session's account-ceremony context resolves to; the
|
|
21
|
+
* remaining values, `none` and `account`, are the ones every resolved kind
|
|
22
|
+
* subsumes. Derived from the vocabulary, so a new authority is a compile
|
|
23
|
+
* error in `heldAuthorities` rather than a value it can never return.
|
|
24
|
+
*/
|
|
25
|
+
export type ResolvedAuthority = Exclude<Authority, 'none' | 'account'>;
|
|
26
|
+
/**
|
|
27
|
+
* The readers over one wallet's table. `Site` is the converge-free index
|
|
28
|
+
* shape or a wallet's registration type extending it, so the same readers
|
|
29
|
+
* serve the audit and the runner.
|
|
30
|
+
*/
|
|
31
|
+
export interface MenderRegistry<Site extends RegistrationSite, Deps, Ceremony extends string = string> {
|
|
32
|
+
all(): ReadonlyArray<InvariantDeclaration<Deps, Ceremony>>;
|
|
33
|
+
byId(id: InvariantId): InvariantDeclaration<Deps, Ceremony> | undefined;
|
|
34
|
+
sites(): ReadonlyArray<Site>;
|
|
35
|
+
/**
|
|
36
|
+
* Whether a site's every reported invariant declares an authority in
|
|
37
|
+
* `held` and, when a route is given, admits it. The one admission test,
|
|
38
|
+
* shared by `dueAt` and by a runner admitting a site the caller supplies.
|
|
39
|
+
*
|
|
40
|
+
* @throws {TypeError} when the site reports an undeclared invariant,
|
|
41
|
+
* reachable only for a site the registry does not index
|
|
42
|
+
*/
|
|
43
|
+
admits(options: {
|
|
44
|
+
site: RegistrationSite;
|
|
45
|
+
held: ReadonlyArray<Authority>;
|
|
46
|
+
route?: LoginRoute;
|
|
47
|
+
}): boolean;
|
|
48
|
+
dueAt(options: {
|
|
49
|
+
held: ReadonlyArray<Authority>;
|
|
50
|
+
trigger: ChainTrigger;
|
|
51
|
+
route?: LoginRoute;
|
|
52
|
+
}): ReadonlyArray<Site>;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* The held set a session derives from its account-ceremony context: `none`
|
|
56
|
+
* always, plus `account` and the resolved kind when a context resolves.
|
|
57
|
+
*
|
|
58
|
+
* @param options {object}
|
|
59
|
+
* @param [options.kind] {ResolvedAuthority} the resolved context kind,
|
|
60
|
+
* absent for a guest, a no-WAS session, or a transient session whose
|
|
61
|
+
* record carries no standing members
|
|
62
|
+
* @returns {ReadonlyArray<Authority>}
|
|
63
|
+
*/
|
|
64
|
+
export declare function heldAuthorities({ kind }: {
|
|
65
|
+
kind?: ResolvedAuthority;
|
|
66
|
+
}): ReadonlyArray<Authority>;
|
|
67
|
+
/**
|
|
68
|
+
* Builds the readers over one wallet's declarations and sites, checking
|
|
69
|
+
* both once: every declaration id is unique, every reported id is declared,
|
|
70
|
+
* and only a `login-routing` site carries `guardedBy`.
|
|
71
|
+
*
|
|
72
|
+
* @param options {object}
|
|
73
|
+
* @param options.declarations {ReadonlyArray<InvariantDeclaration>}
|
|
74
|
+
* @param options.sites {ReadonlyArray<RegistrationSite>} every
|
|
75
|
+
* registration site, any trigger, in execution order within a trigger
|
|
76
|
+
* @returns {MenderRegistry}
|
|
77
|
+
* @throws {TypeError} on a duplicated declaration id, an undeclared
|
|
78
|
+
* report, or a guard on a non-routing site
|
|
79
|
+
*/
|
|
80
|
+
export declare function menderRegistry<Site extends RegistrationSite, Deps, Ceremony extends string = string>({ declarations, sites }: {
|
|
81
|
+
declarations: ReadonlyArray<InvariantDeclaration<Deps, Ceremony>>;
|
|
82
|
+
sites: ReadonlyArray<Site>;
|
|
83
|
+
}): MenderRegistry<Site, Deps, Ceremony>;
|
|
84
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/menders/registry.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAC3C,OAAO,KAAK,EACV,oBAAoB,EACpB,UAAU,EACV,gBAAgB,EACjB,MAAM,YAAY,CAAA;AACnB,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAE9D;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,GAAG,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC,CAAA;AAEtE;;;;GAIG;AACH,MAAM,WAAW,cAAc,CAC7B,IAAI,SAAS,gBAAgB,EAC7B,IAAI,EACJ,QAAQ,SAAS,MAAM,GAAG,MAAM;IAEhC,GAAG,IAAI,aAAa,CAAC,oBAAoB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAA;IAC1D,IAAI,CAAC,EAAE,EAAE,WAAW,GAAG,oBAAoB,CAAC,IAAI,EAAE,QAAQ,CAAC,GAAG,SAAS,CAAA;IACvE,KAAK,IAAI,aAAa,CAAC,IAAI,CAAC,CAAA;IAC5B;;;;;;;OAOG;IACH,MAAM,CAAC,OAAO,EAAE;QACd,IAAI,EAAE,gBAAgB,CAAA;QACtB,IAAI,EAAE,aAAa,CAAC,SAAS,CAAC,CAAA;QAC9B,KAAK,CAAC,EAAE,UAAU,CAAA;KACnB,GAAG,OAAO,CAAA;IACX,KAAK,CAAC,OAAO,EAAE;QACb,IAAI,EAAE,aAAa,CAAC,SAAS,CAAC,CAAA;QAC9B,OAAO,EAAE,YAAY,CAAA;QACrB,KAAK,CAAC,EAAE,UAAU,CAAA;KACnB,GAAG,aAAa,CAAC,IAAI,CAAC,CAAA;CACxB;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,EAC9B,IAAI,EACL,EAAE;IACD,IAAI,CAAC,EAAE,iBAAiB,CAAA;CACzB,GAAG,aAAa,CAAC,SAAS,CAAC,CAE3B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAC5B,IAAI,SAAS,gBAAgB,EAC7B,IAAI,EACJ,QAAQ,SAAS,MAAM,GAAG,MAAM,EAChC,EACA,YAAY,EACZ,KAAK,EACN,EAAE;IACD,YAAY,EAAE,aAAa,CAAC,oBAAoB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAA;IACjE,KAAK,EAAE,aAAa,CAAC,IAAI,CAAC,CAAA;CAC3B,GAAG,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,CAAC,CAsDvC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The held set a session derives from its account-ceremony context: `none`
|
|
3
|
+
* always, plus `account` and the resolved kind when a context resolves.
|
|
4
|
+
*
|
|
5
|
+
* @param options {object}
|
|
6
|
+
* @param [options.kind] {ResolvedAuthority} the resolved context kind,
|
|
7
|
+
* absent for a guest, a no-WAS session, or a transient session whose
|
|
8
|
+
* record carries no standing members
|
|
9
|
+
* @returns {ReadonlyArray<Authority>}
|
|
10
|
+
*/
|
|
11
|
+
export function heldAuthorities({ kind }) {
|
|
12
|
+
return kind ? ['none', 'account', kind] : ['none'];
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Builds the readers over one wallet's declarations and sites, checking
|
|
16
|
+
* both once: every declaration id is unique, every reported id is declared,
|
|
17
|
+
* and only a `login-routing` site carries `guardedBy`.
|
|
18
|
+
*
|
|
19
|
+
* @param options {object}
|
|
20
|
+
* @param options.declarations {ReadonlyArray<InvariantDeclaration>}
|
|
21
|
+
* @param options.sites {ReadonlyArray<RegistrationSite>} every
|
|
22
|
+
* registration site, any trigger, in execution order within a trigger
|
|
23
|
+
* @returns {MenderRegistry}
|
|
24
|
+
* @throws {TypeError} on a duplicated declaration id, an undeclared
|
|
25
|
+
* report, or a guard on a non-routing site
|
|
26
|
+
*/
|
|
27
|
+
export function menderRegistry({ declarations, sites }) {
|
|
28
|
+
const index = new Map();
|
|
29
|
+
for (const decl of declarations) {
|
|
30
|
+
if (index.has(decl.id)) {
|
|
31
|
+
throw new TypeError(`An invariant is declared twice: ${decl.id}`);
|
|
32
|
+
}
|
|
33
|
+
index.set(decl.id, decl);
|
|
34
|
+
}
|
|
35
|
+
const requireDeclared = (id) => {
|
|
36
|
+
const decl = index.get(id);
|
|
37
|
+
if (!decl) {
|
|
38
|
+
throw new TypeError(`A registration reports an undeclared invariant: ${id}`);
|
|
39
|
+
}
|
|
40
|
+
return decl;
|
|
41
|
+
};
|
|
42
|
+
for (const site of sites) {
|
|
43
|
+
site.reports.forEach(requireDeclared);
|
|
44
|
+
const { trigger, guardedBy } = site;
|
|
45
|
+
if (guardedBy !== undefined && trigger !== 'login-routing') {
|
|
46
|
+
throw new TypeError(`A ${trigger} site carries a guard; only a login-routing site may`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const admits = ({ site, held, route }) => site.reports.every(id => {
|
|
50
|
+
const decl = requireDeclared(id);
|
|
51
|
+
return (held.includes(decl.authority) &&
|
|
52
|
+
(route === undefined || !decl.when || decl.when(route)));
|
|
53
|
+
});
|
|
54
|
+
return {
|
|
55
|
+
all: () => declarations,
|
|
56
|
+
byId: id => index.get(id),
|
|
57
|
+
sites: () => sites,
|
|
58
|
+
admits,
|
|
59
|
+
dueAt: ({ held, trigger, route }) => sites.filter(site => site.trigger === trigger && admits({ site, held, route }))
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/menders/registry.ts"],"names":[],"mappings":"AAgEA;;;;;;;;;GASG;AACH,MAAM,UAAU,eAAe,CAAC,EAC9B,IAAI,EAGL;IACC,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAA;AACpD,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,cAAc,CAI5B,EACA,YAAY,EACZ,KAAK,EAIN;IACC,MAAM,KAAK,GAAG,IAAI,GAAG,EAAqD,CAAA;IAC1E,KAAK,MAAM,IAAI,IAAI,YAAY,EAAE,CAAC;QAChC,IAAI,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;YACvB,MAAM,IAAI,SAAS,CAAC,mCAAmC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAA;QACnE,CAAC;QACD,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,CAAA;IAC1B,CAAC;IACD,MAAM,eAAe,GAAG,CACtB,EAAe,EACuB,EAAE;QACxC,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;QAC1B,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,MAAM,IAAI,SAAS,CACjB,mDAAmD,EAAE,EAAE,CACxD,CAAA;QACH,CAAC;QACD,OAAO,IAAI,CAAA;IACb,CAAC,CAAA;IACD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,eAAe,CAAC,CAAA;QACrC,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,IAAI,CAAA;QACnC,IAAI,SAAS,KAAK,SAAS,IAAI,OAAO,KAAK,eAAe,EAAE,CAAC;YAC3D,MAAM,IAAI,SAAS,CACjB,KAAK,OAAO,sDAAsD,CACnE,CAAA;QACH,CAAC;IACH,CAAC;IACD,MAAM,MAAM,GAAG,CAAC,EACd,IAAI,EACJ,IAAI,EACJ,KAAK,EAKN,EAAW,EAAE,CACZ,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE;QACtB,MAAM,IAAI,GAAG,eAAe,CAAC,EAAE,CAAC,CAAA;QAChC,OAAO,CACL,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC;YAC7B,CAAC,KAAK,KAAK,SAAS,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CACxD,CAAA;IACH,CAAC,CAAC,CAAA;IACJ,OAAO;QACL,GAAG,EAAE,GAAG,EAAE,CAAC,YAAY;QACvB,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;QACzB,KAAK,EAAE,GAAG,EAAE,CAAC,KAAK;QAClB,MAAM;QACN,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,CAClC,KAAK,CAAC,MAAM,CACV,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,KAAK,OAAO,IAAI,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAClE;KACJ,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2026 Interop Alliance. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* The mender runner: one try, warn, and skip discipline over the
|
|
6
|
+
* registrations listed under one chain trigger. `runMenderBlock` runs them
|
|
7
|
+
* in list order, since registration order is execution order and there is
|
|
8
|
+
* no dependency graph. A seed step's failure aborts the block; a
|
|
9
|
+
* registration's failure warns through the wallet's own `Logger` and the
|
|
10
|
+
* block continues. Beside it sits `mendReportAccumulator`, the report
|
|
11
|
+
* collector a wallet creates before a `Session` exists, so the entries a
|
|
12
|
+
* routing site reports and the entries this runner reports assemble into
|
|
13
|
+
* one `MendReport`.
|
|
14
|
+
*/
|
|
15
|
+
import type { Logger } from '../log.js';
|
|
16
|
+
import type { MenderRegistry } from './registry.js';
|
|
17
|
+
import type { LoginRoute, MendReport, MendReportEntry, Registration, RegistrationSite } from './types.js';
|
|
18
|
+
import type { Authority, ChainTrigger } from './vocabulary.js';
|
|
19
|
+
/**
|
|
20
|
+
* The `errorName` a normalized entry carries when a registration resolves
|
|
21
|
+
* with entries that do not match the invariants it reports.
|
|
22
|
+
*/
|
|
23
|
+
export declare const MEND_REPORT_SHAPE_ERROR = "MendReportShapeError";
|
|
24
|
+
/**
|
|
25
|
+
* The report collector a wallet creates ahead of session assembly. A
|
|
26
|
+
* routing entry reports into it from its own call site before a `Session`
|
|
27
|
+
* exists, {@link runMenderBlock} reports the chain's entries into it
|
|
28
|
+
* through `onOutcome`, and the wallet hands `settled` to the session as its
|
|
29
|
+
* mend report.
|
|
30
|
+
*/
|
|
31
|
+
export interface MendReportAccumulator<Ceremony extends string = string> {
|
|
32
|
+
/**
|
|
33
|
+
* Records one entry. Bound to the accumulator, so it can be passed
|
|
34
|
+
* directly as {@link runMenderBlock}'s `onOutcome`.
|
|
35
|
+
*/
|
|
36
|
+
report(entry: MendReportEntry<Ceremony>): void;
|
|
37
|
+
/**
|
|
38
|
+
* Every entry recorded so far, in report order.
|
|
39
|
+
*/
|
|
40
|
+
entries(): MendReport<Ceremony>;
|
|
41
|
+
/**
|
|
42
|
+
* Resolves {@link MendReportAccumulator.settled} with the entries
|
|
43
|
+
* recorded so far. Idempotent: the first call fixes the resolved report,
|
|
44
|
+
* and a later `report` call still lands in `entries()`.
|
|
45
|
+
*/
|
|
46
|
+
settle(): MendReport<Ceremony>;
|
|
47
|
+
/**
|
|
48
|
+
* The assembled report, resolved by `settle`. It never rejects.
|
|
49
|
+
*/
|
|
50
|
+
readonly settled: Promise<MendReport<Ceremony>>;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Creates a report accumulator. Generic over the wallet's ceremony-id
|
|
54
|
+
* union, which defaults to `string`.
|
|
55
|
+
*
|
|
56
|
+
* @returns {MendReportAccumulator}
|
|
57
|
+
*/
|
|
58
|
+
export declare function mendReportAccumulator<Ceremony extends string = string>(): MendReportAccumulator<Ceremony>;
|
|
59
|
+
/**
|
|
60
|
+
* Runs one registration block: the registrations listed under `trigger`
|
|
61
|
+
* whose every reported invariant declares an authority the session holds
|
|
62
|
+
* and admits this login route, in list order.
|
|
63
|
+
*
|
|
64
|
+
* The discipline, in one place. An optional `seed` registration runs first,
|
|
65
|
+
* and its failure aborts the block: nothing behind it runs, which is what a
|
|
66
|
+
* rejected chain seed does today. Past the seed, a registration that throws
|
|
67
|
+
* warns once per reported invariant with that declaration's own `warn`
|
|
68
|
+
* string, reports `failed` for each of them, and the block carries on to
|
|
69
|
+
* the next registration. Only `err.name` rides a report: a thrown error's
|
|
70
|
+
* message routinely carries a DID or a Space id, so the error itself goes
|
|
71
|
+
* to the logger alone.
|
|
72
|
+
*
|
|
73
|
+
* A registration that resolves with the wrong number of entries, or with an
|
|
74
|
+
* entry whose `invariant` is not the id it reports at that position, is a
|
|
75
|
+
* programming error. It warns and is normalized to `failed` entries
|
|
76
|
+
* carrying {@link MEND_REPORT_SHAPE_ERROR} rather than throwing, so a
|
|
77
|
+
* mismatched adapter cannot tear a login.
|
|
78
|
+
*
|
|
79
|
+
* `trigger` is one of the two chain values, so a `ceremony-tail` entry is
|
|
80
|
+
* out of reach here. Such an entry has no registration at all: its body
|
|
81
|
+
* stays inside its ceremony's sequenced code and it reports from there.
|
|
82
|
+
*
|
|
83
|
+
* `Deps` is the wallet's own type, one object per registration block,
|
|
84
|
+
* handed to the seed and to every `converge` unread. This runner never
|
|
85
|
+
* inspects it, and the raw passphrase does not cross into this package.
|
|
86
|
+
*
|
|
87
|
+
* `registrations` overrides which registrations the block runs, for a wallet
|
|
88
|
+
* that runs one trigger's list in parts (a settle point partway through, say).
|
|
89
|
+
* The same authority and route tests still admit each one, and one listed
|
|
90
|
+
* under another trigger is refused, so the override narrows the block and
|
|
91
|
+
* never widens it.
|
|
92
|
+
*
|
|
93
|
+
* A registry may index converge-free sites beside its registrations -- a
|
|
94
|
+
* wallet's routing entries, or an entry whose own call site fires it -- and
|
|
95
|
+
* such a site is never executed here, whichever list the block runs from.
|
|
96
|
+
*
|
|
97
|
+
* @param options {object}
|
|
98
|
+
* @param options.registry {MenderRegistry} the wallet's declarations and
|
|
99
|
+
* its registrations
|
|
100
|
+
* @param options.trigger {ChainTrigger} which chain is running
|
|
101
|
+
* @param options.held {ReadonlyArray<Authority>} the session's held
|
|
102
|
+
* authorities, from `heldAuthorities`
|
|
103
|
+
* @param options.route {LoginRoute} the login route each declaration's
|
|
104
|
+
* `when` predicate reads
|
|
105
|
+
* @param options.deps {Deps} passed to the seed and to every `converge`
|
|
106
|
+
* @param options.logger {Logger} the wallet's own sink, so its warn
|
|
107
|
+
* copy keeps the wallet's namespace
|
|
108
|
+
* @param [options.registrations] {ReadonlyArray<Registration>} the
|
|
109
|
+
* registrations to run, in place of the ones the registry lists under
|
|
110
|
+
* `trigger`. Each is admitted by the same authority and route tests
|
|
111
|
+
* @param [options.seed] {Registration} the step whose failure aborts the
|
|
112
|
+
* block. Admitted by the same authority and route tests as any other
|
|
113
|
+
* registration; one it does not pass is skipped rather than failed
|
|
114
|
+
* @param [options.onOutcome] {(entry: MendReportEntry) => void} called
|
|
115
|
+
* once per reported entry, in order. The single place a chain entry's
|
|
116
|
+
* outcome is reported
|
|
117
|
+
* @returns {Promise<MendReport>} the block's entries in order. It never
|
|
118
|
+
* rejects; a seed failure resolves with the seed's `failed` entries alone
|
|
119
|
+
* @throws {TypeError} when the seed or an override registration is listed
|
|
120
|
+
* under a trigger other than `trigger`, a programming error
|
|
121
|
+
*/
|
|
122
|
+
export declare function runMenderBlock<Deps, Ceremony extends string = string, Site extends RegistrationSite = Registration<Deps, Ceremony>>({ registry, trigger, held, route, deps, logger, registrations, seed, onOutcome }: {
|
|
123
|
+
registry: MenderRegistry<Site, Deps, Ceremony>;
|
|
124
|
+
trigger: ChainTrigger;
|
|
125
|
+
held: ReadonlyArray<Authority>;
|
|
126
|
+
route: LoginRoute;
|
|
127
|
+
deps: Deps;
|
|
128
|
+
logger: Logger;
|
|
129
|
+
registrations?: ReadonlyArray<Registration<Deps, Ceremony>>;
|
|
130
|
+
seed?: Registration<Deps, Ceremony>;
|
|
131
|
+
onOutcome?: (entry: MendReportEntry<Ceremony>) => void;
|
|
132
|
+
}): Promise<MendReport<Ceremony>>;
|
|
133
|
+
/**
|
|
134
|
+
* The thrown value's class name alone. Its message may carry a DID or a
|
|
135
|
+
* Space id, so a report keeps the name and the logger keeps the error. A
|
|
136
|
+
* value that is not an `Error` still yields a name, so a report site never
|
|
137
|
+
* carries `undefined` where a name belongs.
|
|
138
|
+
*
|
|
139
|
+
* @param err {unknown}
|
|
140
|
+
* @returns {string}
|
|
141
|
+
*/
|
|
142
|
+
export declare function errorNameOf(err: unknown): string;
|
|
143
|
+
//# sourceMappingURL=runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../src/menders/runner.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AACvC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,KAAK,EACV,UAAU,EACV,UAAU,EACV,eAAe,EACf,YAAY,EACZ,gBAAgB,EACjB,MAAM,YAAY,CAAA;AACnB,OAAO,KA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,aAAa,CAAC,YAAY,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAA;IAC3D,IAAI,CAAC,EAAE,YAAY,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;IACnC,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAA;CACvD,GAAG,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAqChC;AA6HD;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAQhD"}
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `errorName` a normalized entry carries when a registration resolves
|
|
3
|
+
* with entries that do not match the invariants it reports.
|
|
4
|
+
*/
|
|
5
|
+
export const MEND_REPORT_SHAPE_ERROR = 'MendReportShapeError';
|
|
6
|
+
/**
|
|
7
|
+
* Creates a report accumulator. Generic over the wallet's ceremony-id
|
|
8
|
+
* union, which defaults to `string`.
|
|
9
|
+
*
|
|
10
|
+
* @returns {MendReportAccumulator}
|
|
11
|
+
*/
|
|
12
|
+
export function mendReportAccumulator() {
|
|
13
|
+
const recorded = [];
|
|
14
|
+
let resolveSettled = () => undefined;
|
|
15
|
+
const settled = new Promise(resolve => {
|
|
16
|
+
resolveSettled = resolve;
|
|
17
|
+
});
|
|
18
|
+
let assembled;
|
|
19
|
+
return {
|
|
20
|
+
report(entry) {
|
|
21
|
+
recorded.push(entry);
|
|
22
|
+
},
|
|
23
|
+
entries: () => [...recorded],
|
|
24
|
+
settle() {
|
|
25
|
+
if (!assembled) {
|
|
26
|
+
assembled = [...recorded];
|
|
27
|
+
resolveSettled(assembled);
|
|
28
|
+
}
|
|
29
|
+
return assembled;
|
|
30
|
+
},
|
|
31
|
+
settled
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Runs one registration block: the registrations listed under `trigger`
|
|
36
|
+
* whose every reported invariant declares an authority the session holds
|
|
37
|
+
* and admits this login route, in list order.
|
|
38
|
+
*
|
|
39
|
+
* The discipline, in one place. An optional `seed` registration runs first,
|
|
40
|
+
* and its failure aborts the block: nothing behind it runs, which is what a
|
|
41
|
+
* rejected chain seed does today. Past the seed, a registration that throws
|
|
42
|
+
* warns once per reported invariant with that declaration's own `warn`
|
|
43
|
+
* string, reports `failed` for each of them, and the block carries on to
|
|
44
|
+
* the next registration. Only `err.name` rides a report: a thrown error's
|
|
45
|
+
* message routinely carries a DID or a Space id, so the error itself goes
|
|
46
|
+
* to the logger alone.
|
|
47
|
+
*
|
|
48
|
+
* A registration that resolves with the wrong number of entries, or with an
|
|
49
|
+
* entry whose `invariant` is not the id it reports at that position, is a
|
|
50
|
+
* programming error. It warns and is normalized to `failed` entries
|
|
51
|
+
* carrying {@link MEND_REPORT_SHAPE_ERROR} rather than throwing, so a
|
|
52
|
+
* mismatched adapter cannot tear a login.
|
|
53
|
+
*
|
|
54
|
+
* `trigger` is one of the two chain values, so a `ceremony-tail` entry is
|
|
55
|
+
* out of reach here. Such an entry has no registration at all: its body
|
|
56
|
+
* stays inside its ceremony's sequenced code and it reports from there.
|
|
57
|
+
*
|
|
58
|
+
* `Deps` is the wallet's own type, one object per registration block,
|
|
59
|
+
* handed to the seed and to every `converge` unread. This runner never
|
|
60
|
+
* inspects it, and the raw passphrase does not cross into this package.
|
|
61
|
+
*
|
|
62
|
+
* `registrations` overrides which registrations the block runs, for a wallet
|
|
63
|
+
* that runs one trigger's list in parts (a settle point partway through, say).
|
|
64
|
+
* The same authority and route tests still admit each one, and one listed
|
|
65
|
+
* under another trigger is refused, so the override narrows the block and
|
|
66
|
+
* never widens it.
|
|
67
|
+
*
|
|
68
|
+
* A registry may index converge-free sites beside its registrations -- a
|
|
69
|
+
* wallet's routing entries, or an entry whose own call site fires it -- and
|
|
70
|
+
* such a site is never executed here, whichever list the block runs from.
|
|
71
|
+
*
|
|
72
|
+
* @param options {object}
|
|
73
|
+
* @param options.registry {MenderRegistry} the wallet's declarations and
|
|
74
|
+
* its registrations
|
|
75
|
+
* @param options.trigger {ChainTrigger} which chain is running
|
|
76
|
+
* @param options.held {ReadonlyArray<Authority>} the session's held
|
|
77
|
+
* authorities, from `heldAuthorities`
|
|
78
|
+
* @param options.route {LoginRoute} the login route each declaration's
|
|
79
|
+
* `when` predicate reads
|
|
80
|
+
* @param options.deps {Deps} passed to the seed and to every `converge`
|
|
81
|
+
* @param options.logger {Logger} the wallet's own sink, so its warn
|
|
82
|
+
* copy keeps the wallet's namespace
|
|
83
|
+
* @param [options.registrations] {ReadonlyArray<Registration>} the
|
|
84
|
+
* registrations to run, in place of the ones the registry lists under
|
|
85
|
+
* `trigger`. Each is admitted by the same authority and route tests
|
|
86
|
+
* @param [options.seed] {Registration} the step whose failure aborts the
|
|
87
|
+
* block. Admitted by the same authority and route tests as any other
|
|
88
|
+
* registration; one it does not pass is skipped rather than failed
|
|
89
|
+
* @param [options.onOutcome] {(entry: MendReportEntry) => void} called
|
|
90
|
+
* once per reported entry, in order. The single place a chain entry's
|
|
91
|
+
* outcome is reported
|
|
92
|
+
* @returns {Promise<MendReport>} the block's entries in order. It never
|
|
93
|
+
* rejects; a seed failure resolves with the seed's `failed` entries alone
|
|
94
|
+
* @throws {TypeError} when the seed or an override registration is listed
|
|
95
|
+
* under a trigger other than `trigger`, a programming error
|
|
96
|
+
*/
|
|
97
|
+
export async function runMenderBlock({ registry, trigger, held, route, deps, logger, registrations, seed, onOutcome }) {
|
|
98
|
+
const report = [];
|
|
99
|
+
const collect = (entries) => {
|
|
100
|
+
for (const entry of entries) {
|
|
101
|
+
report.push(entry);
|
|
102
|
+
onOutcome?.(entry);
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
for (const supplied of [...(seed ? [seed] : []), ...(registrations ?? [])]) {
|
|
106
|
+
if (supplied.trigger !== trigger) {
|
|
107
|
+
throw new TypeError(`A ${supplied.trigger} registration was handed to the ${trigger} block`);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
const admitted = (site) => registry.admits({ site, held, route });
|
|
111
|
+
const listed = (registrations?.filter(admitted) ?? registry.dueAt({ held, trigger, route })).filter((isRegistration));
|
|
112
|
+
// One ordered list, the seed first: the seed is the one step whose throw
|
|
113
|
+
// ends the block.
|
|
114
|
+
const steps = seed && admitted(seed) ? [seed, ...listed] : listed;
|
|
115
|
+
for (const registration of steps) {
|
|
116
|
+
const outcome = await runRegistration({
|
|
117
|
+
registry,
|
|
118
|
+
registration,
|
|
119
|
+
deps,
|
|
120
|
+
logger,
|
|
121
|
+
trigger
|
|
122
|
+
});
|
|
123
|
+
collect(outcome.entries);
|
|
124
|
+
if (outcome.threw && registration === seed) {
|
|
125
|
+
return report;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return report;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Runs one registration under the block's discipline, returning its entries
|
|
132
|
+
* and whether it threw.
|
|
133
|
+
*/
|
|
134
|
+
async function runRegistration({ registry, registration, deps, logger, trigger }) {
|
|
135
|
+
try {
|
|
136
|
+
const entries = await registration.converge(deps);
|
|
137
|
+
if (!matchesReports({ registration, entries })) {
|
|
138
|
+
logger.warn('A mender registration returned entries that do not match the invariants it reports', { trigger, reports: [...registration.reports] });
|
|
139
|
+
// A malformed return is a defect in the adapter rather than a mend
|
|
140
|
+
// failure: the step ran to completion, so a malformed seed does not
|
|
141
|
+
// abort the block.
|
|
142
|
+
return {
|
|
143
|
+
entries: failedEntries({
|
|
144
|
+
registry,
|
|
145
|
+
registration,
|
|
146
|
+
errorName: MEND_REPORT_SHAPE_ERROR
|
|
147
|
+
}),
|
|
148
|
+
threw: false
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
return { entries, threw: false };
|
|
152
|
+
}
|
|
153
|
+
catch (err) {
|
|
154
|
+
for (const id of registration.reports) {
|
|
155
|
+
logger.warn(registry.byId(id)?.warn ?? `Could not converge ${id}`, {
|
|
156
|
+
invariant: id,
|
|
157
|
+
trigger,
|
|
158
|
+
err
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
return {
|
|
162
|
+
entries: failedEntries({
|
|
163
|
+
registry,
|
|
164
|
+
registration,
|
|
165
|
+
errorName: errorNameOf(err)
|
|
166
|
+
}),
|
|
167
|
+
threw: true
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Whether a site carries a converger, so the block can run it. A wallet's
|
|
173
|
+
* registry indexes its converge-free sites beside its registrations.
|
|
174
|
+
*
|
|
175
|
+
* @param site {RegistrationSite}
|
|
176
|
+
* @returns {boolean}
|
|
177
|
+
*/
|
|
178
|
+
function isRegistration(site) {
|
|
179
|
+
return typeof site.converge === 'function';
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Whether a registration's entries name the invariants it reports, in that
|
|
183
|
+
* order.
|
|
184
|
+
*/
|
|
185
|
+
function matchesReports({ registration, entries }) {
|
|
186
|
+
return (entries.length === registration.reports.length &&
|
|
187
|
+
entries.every((entry, index) => entry.invariant === registration.reports[index]));
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* One `failed` entry per reported invariant, carrying the declaration's
|
|
191
|
+
* ceremonies where it names any.
|
|
192
|
+
*/
|
|
193
|
+
function failedEntries({ registry, registration, errorName }) {
|
|
194
|
+
return registration.reports.map(id => {
|
|
195
|
+
const ceremonies = registry.byId(id)?.ceremonies;
|
|
196
|
+
return {
|
|
197
|
+
invariant: id,
|
|
198
|
+
outcome: 'failed',
|
|
199
|
+
errorName,
|
|
200
|
+
...(ceremonies && ceremonies.length > 0 ? { ceremonies } : {})
|
|
201
|
+
};
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* The thrown value's class name alone. Its message may carry a DID or a
|
|
206
|
+
* Space id, so a report keeps the name and the logger keeps the error. A
|
|
207
|
+
* value that is not an `Error` still yields a name, so a report site never
|
|
208
|
+
* carries `undefined` where a name belongs.
|
|
209
|
+
*
|
|
210
|
+
* @param err {unknown}
|
|
211
|
+
* @returns {string}
|
|
212
|
+
*/
|
|
213
|
+
export function errorNameOf(err) {
|
|
214
|
+
if (err instanceof Error) {
|
|
215
|
+
return err.name;
|
|
216
|
+
}
|
|
217
|
+
if (typeof err === 'object' && err !== null && 'name' in err) {
|
|
218
|
+
return String(err.name);
|
|
219
|
+
}
|
|
220
|
+
return 'Error';
|
|
221
|
+
}
|
|
222
|
+
//# sourceMappingURL=runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../../src/menders/runner.ts"],"names":[],"mappings":"AAyBA;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,sBAAsB,CAAA;AA+B7D;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB;IAGnC,MAAM,QAAQ,GAAqC,EAAE,CAAA;IACrD,IAAI,cAAc,GAA2C,GAAG,EAAE,CAAC,SAAS,CAAA;IAC5E,MAAM,OAAO,GAAG,IAAI,OAAO,CAAuB,OAAO,CAAC,EAAE;QAC1D,cAAc,GAAG,OAAO,CAAA;IAC1B,CAAC,CAAC,CAAA;IACF,IAAI,SAA2C,CAAA;IAC/C,OAAO;QACL,MAAM,CAAC,KAAK;YACV,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QACtB,CAAC;QACD,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,QAAQ,CAAC;QAC5B,MAAM;YACJ,IAAI,CAAC,SAAS,EAAE,CAAC;gBACf,SAAS,GAAG,CAAC,GAAG,QAAQ,CAAC,CAAA;gBACzB,cAAc,CAAC,SAAS,CAAC,CAAA;YAC3B,CAAC;YACD,OAAO,SAAS,CAAA;QAClB,CAAC;QACD,OAAO;KACR,CAAA;AACH,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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