@serfab/cadre-core 1.15.0 → 1.17.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 +1 -1
- package/dist/bootstrap-peer-store-file.js +1 -1
- package/dist/bootstrap-peer-store.d.ts +1 -1
- package/dist/bootstrap-peer-store.js +4 -4
- package/dist/cadre-invite-protocol.d.ts +55 -138
- package/dist/cadre-invite-protocol.js +94 -449
- package/dist/cadre-invite-protocol.js.map +1 -1
- package/dist/cadre-join-request.d.ts +15 -2
- package/dist/cadre-join-request.js +22 -3
- package/dist/cadre-join-request.js.map +1 -1
- package/dist/cadre-node.d.ts +530 -247
- package/dist/cadre-node.js +1046 -525
- package/dist/cadre-node.js.map +1 -1
- package/dist/control-authorization.d.ts +36 -14
- package/dist/control-authorization.js +20 -3
- package/dist/control-authorization.js.map +1 -1
- package/dist/control-cohort.d.ts +22 -23
- package/dist/control-cohort.js +24 -24
- package/dist/control-cohort.js.map +1 -1
- package/dist/control-database.d.ts +416 -136
- package/dist/control-database.js +757 -378
- package/dist/control-database.js.map +1 -1
- package/dist/control-protocol-guard.d.ts +5 -4
- package/dist/control-protocol-guard.js +6 -3
- package/dist/control-protocol-guard.js.map +1 -1
- package/dist/control-schema-version.d.ts +80 -0
- package/dist/control-schema-version.js +203 -0
- package/dist/control-schema-version.js.map +1 -0
- package/dist/control-schema.d.ts +45 -5
- package/dist/control-schema.js +254 -70
- package/dist/control-schema.js.map +1 -1
- package/dist/control-write-retry.d.ts +5 -5
- package/dist/control-write-retry.js +10 -8
- package/dist/control-write-retry.js.map +1 -1
- package/dist/delegate-admission.d.ts +13 -0
- package/dist/delegate-admission.js +27 -0
- package/dist/delegate-admission.js.map +1 -1
- package/dist/ed25519-key.d.ts +10 -7
- package/dist/ed25519-key.js +23 -20
- package/dist/ed25519-key.js.map +1 -1
- package/dist/edge-node/config.d.ts +122 -0
- package/dist/edge-node/config.js +199 -0
- package/dist/edge-node/config.js.map +1 -0
- package/dist/edge-node/dissolve.d.ts +95 -0
- package/dist/edge-node/dissolve.js +184 -0
- package/dist/edge-node/dissolve.js.map +1 -0
- package/dist/edge-node/edge-join.d.ts +44 -0
- package/dist/edge-node/edge-join.js +227 -0
- package/dist/edge-node/edge-join.js.map +1 -0
- package/dist/edge-node/edge-node.d.ts +295 -0
- package/dist/edge-node/edge-node.js +704 -0
- package/dist/edge-node/edge-node.js.map +1 -0
- package/dist/edge-node/index.d.ts +18 -0
- package/dist/edge-node/index.js +18 -0
- package/dist/edge-node/index.js.map +1 -0
- package/dist/edge-node/join-credential.d.ts +11 -0
- package/dist/edge-node/join-credential.js +11 -0
- package/dist/edge-node/join-credential.js.map +1 -0
- package/dist/edge-node/lazy-raw-storage.d.ts +40 -0
- package/dist/edge-node/lazy-raw-storage.js +134 -0
- package/dist/edge-node/lazy-raw-storage.js.map +1 -0
- package/dist/edge-node/node-local.d.ts +60 -0
- package/dist/edge-node/node-local.js +58 -0
- package/dist/edge-node/node-local.js.map +1 -0
- package/dist/edge-node/options.d.ts +83 -0
- package/dist/edge-node/options.js +110 -0
- package/dist/edge-node/options.js.map +1 -0
- package/dist/edge-node/owner-grant.d.ts +41 -0
- package/dist/edge-node/owner-grant.js +38 -0
- package/dist/edge-node/owner-grant.js.map +1 -0
- package/dist/edge-node/platform.d.ts +140 -0
- package/dist/edge-node/platform.js +12 -0
- package/dist/edge-node/platform.js.map +1 -0
- package/dist/edge-node/strand-move.d.ts +115 -0
- package/dist/edge-node/strand-move.js +223 -0
- package/dist/edge-node/strand-move.js.map +1 -0
- package/dist/edge-node/strands.d.ts +28 -0
- package/dist/edge-node/strands.js +60 -0
- package/dist/edge-node/strands.js.map +1 -0
- package/dist/index.d.ts +16 -7
- package/dist/index.js +26 -7
- package/dist/index.js.map +1 -1
- package/dist/joined-strand-store.d.ts +3 -3
- package/dist/joined-strand-store.js +3 -3
- package/dist/joined-strand-store.js.map +1 -1
- package/dist/key-store.d.ts +9 -4
- package/dist/key-store.js +9 -4
- package/dist/key-store.js.map +1 -1
- package/dist/machine-removal.d.ts +19 -39
- package/dist/machine-removal.js +24 -98
- package/dist/machine-removal.js.map +1 -1
- package/dist/member-redemption.d.ts +250 -0
- package/dist/member-redemption.js +485 -0
- package/dist/member-redemption.js.map +1 -0
- package/dist/owner-anchor-sync.d.ts +4 -4
- package/dist/owner-anchor-sync.js +16 -15
- package/dist/owner-anchor-sync.js.map +1 -1
- package/dist/owner-grant-protocol.d.ts +247 -0
- package/dist/owner-grant-protocol.js +330 -0
- package/dist/owner-grant-protocol.js.map +1 -0
- package/dist/owner-key-export.d.ts +70 -0
- package/dist/owner-key-export.js +279 -0
- package/dist/owner-key-export.js.map +1 -0
- package/dist/owner-key-flows.d.ts +55 -0
- package/dist/owner-key-flows.js +60 -0
- package/dist/owner-key-flows.js.map +1 -0
- package/dist/owner-key-store.d.ts +31 -0
- package/dist/owner-key-store.js +81 -0
- package/dist/owner-key-store.js.map +1 -0
- package/dist/owner-keys.d.ts +78 -0
- package/dist/owner-keys.js +133 -0
- package/dist/owner-keys.js.map +1 -0
- package/dist/owner-signer.d.ts +54 -0
- package/dist/owner-signer.js +51 -0
- package/dist/owner-signer.js.map +1 -0
- package/dist/peer-authorization.d.ts +83 -18
- package/dist/peer-authorization.js +123 -53
- package/dist/peer-authorization.js.map +1 -1
- package/dist/provider/rent-node.js +1 -1
- package/dist/provider/rent-node.js.map +1 -1
- package/dist/seed-bootstrap.d.ts +131 -109
- package/dist/seed-bootstrap.js +260 -248
- package/dist/seed-bootstrap.js.map +1 -1
- package/dist/seed-trust-policy.js +4 -4
- package/dist/strand-addr-protocol.d.ts +4 -1
- package/dist/strand-addr-protocol.js +8 -2
- package/dist/strand-addr-protocol.js.map +1 -1
- package/dist/strand-cohort.d.ts +3 -0
- package/dist/strand-cohort.js.map +1 -1
- package/dist/strand-database.d.ts +1 -0
- package/dist/strand-database.js +3 -0
- package/dist/strand-database.js.map +1 -1
- package/dist/strand-first-sync-gate.d.ts +4 -3
- package/dist/strand-first-sync-gate.js +4 -3
- package/dist/strand-first-sync-gate.js.map +1 -1
- package/dist/strand-instance-manager.d.ts +1 -1
- package/dist/strand-membership-writer.d.ts +13 -2
- package/dist/strand-membership-writer.js +52 -16
- package/dist/strand-membership-writer.js.map +1 -1
- package/dist/strand-move.d.ts +6 -5
- package/dist/strand-move.js +31 -30
- package/dist/strand-move.js.map +1 -1
- package/dist/strand-peer-redial.js +2 -3
- package/dist/strand-peer-redial.js.map +1 -1
- package/dist/types.d.ts +286 -103
- package/dist/types.js.map +1 -1
- package/package.json +16 -7
- package/src/bootstrap-peer-store-file.ts +44 -44
- package/src/bootstrap-peer-store.ts +214 -214
- package/src/cadre-invite-protocol.ts +131 -531
- package/src/cadre-join-request.ts +188 -167
- package/src/cadre-node.ts +1166 -541
- package/src/control-authorization.ts +47 -14
- package/src/control-cohort.ts +127 -128
- package/src/control-database.ts +940 -456
- package/src/control-protocol-guard.ts +7 -4
- package/src/control-schema-version.ts +251 -0
- package/src/control-schema.ts +265 -70
- package/src/control-write-retry.ts +569 -567
- package/src/delegate-admission.ts +37 -0
- package/src/ed25519-key.ts +174 -171
- package/src/edge-node/config.ts +277 -0
- package/src/edge-node/dissolve.ts +251 -0
- package/src/edge-node/edge-join.ts +319 -0
- package/src/edge-node/edge-node.ts +1045 -0
- package/src/edge-node/index.ts +59 -0
- package/src/edge-node/join-credential.ts +16 -0
- package/src/edge-node/lazy-raw-storage.ts +178 -0
- package/src/edge-node/node-local.ts +84 -0
- package/src/edge-node/options.ts +179 -0
- package/src/edge-node/owner-grant.ts +63 -0
- package/src/edge-node/platform.ts +151 -0
- package/src/edge-node/strand-move.ts +270 -0
- package/src/edge-node/strands.ts +72 -0
- package/src/index.ts +102 -5
- package/src/joined-strand-store.ts +4 -4
- package/src/key-store.ts +10 -4
- package/src/machine-removal.ts +26 -111
- package/src/member-redemption.ts +642 -0
- package/src/owner-anchor-sync.ts +19 -18
- package/src/owner-grant-protocol.ts +532 -0
- package/src/owner-key-export.ts +348 -0
- package/src/owner-key-flows.ts +109 -0
- package/src/owner-key-store.ts +85 -0
- package/src/owner-keys.ts +178 -0
- package/src/owner-signer.ts +94 -0
- package/src/peer-authorization.ts +558 -488
- package/src/provider/rent-node.ts +1 -1
- package/src/seed-bootstrap.ts +301 -312
- package/src/seed-trust-policy.ts +4 -4
- package/src/strand-addr-protocol.ts +547 -538
- package/src/strand-cohort.ts +4 -0
- package/src/strand-database.ts +3 -0
- package/src/strand-first-sync-gate.ts +4 -3
- package/src/strand-instance-manager.ts +1 -1
- package/src/strand-membership-writer.ts +61 -16
- package/src/strand-move.ts +45 -36
- package/src/strand-peer-redial.ts +2 -3
- package/src/types.ts +304 -103
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Owner keys as an app lists, adds and removes them (`CadreNode.listOwnerKeys`,
|
|
3
|
+
* `CadreNode.addOwner`, `CadreNode.planOwnerKeyRemoval`, `CadreNode.removeOwner`): the
|
|
4
|
+
* projection of the live `OwnerKey` rows an owner-key screen shows, the read-only plan behind a
|
|
5
|
+
* removal's confirmation step, the check that a requested re-vouch stays inside that plan, and
|
|
6
|
+
* the by-name refusals. Pure; the reads and writes themselves are `CadreNode`'s and
|
|
7
|
+
* `ControlDatabase`'s.
|
|
8
|
+
*/
|
|
9
|
+
import type { CadreOwnerKey, CadrePeerRow, OwnerGrantStatus, OwnerKeyAddRefusal, OwnerKeyDependents, OwnerKeyRemovalPlan, OwnerKeyRemovalRefusal, OwnerKeyRow, RemoveOwnerOptions } from './types.js';
|
|
10
|
+
/**
|
|
11
|
+
* `CadreNode.addOwner` refused by name, before any write. `code` says which rule
|
|
12
|
+
* ({@link OwnerKeyAddRefusal}), for an app to switch on; the message is for a log.
|
|
13
|
+
*/
|
|
14
|
+
export declare class OwnerKeyAddRefusedError extends Error {
|
|
15
|
+
readonly code: OwnerKeyAddRefusal;
|
|
16
|
+
readonly key: string;
|
|
17
|
+
constructor(key: string, code: OwnerKeyAddRefusal);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* `CadreNode.removeOwner` refused by name, before any write. `code` says which rule
|
|
21
|
+
* ({@link OwnerKeyRemovalRefusal}), for an app to switch on; the message is for a log.
|
|
22
|
+
*/
|
|
23
|
+
export declare class OwnerKeyRemovalRefusedError extends Error {
|
|
24
|
+
readonly code: OwnerKeyRemovalRefusal;
|
|
25
|
+
readonly key: string;
|
|
26
|
+
constructor(key: string, code: OwnerKeyRemovalRefusal);
|
|
27
|
+
}
|
|
28
|
+
/** An owner key as an approval prompt names it: `"label" (key)`, or the key alone when it has no label. */
|
|
29
|
+
export declare function namedOwnerKey(key: string, label: string | null): string;
|
|
30
|
+
/**
|
|
31
|
+
* One {@link CadreOwnerKey} per live row, in the rows' order. `heldKey` is the key of this
|
|
32
|
+
* node's owner signer, if one is wired; `anchor` is this node's trusted-owner anchor.
|
|
33
|
+
*/
|
|
34
|
+
export declare function describeOwnerKeys(rows: readonly OwnerKeyRow[], heldKey: string | null, anchor: ReadonlySet<string>): CadreOwnerKey[];
|
|
35
|
+
/** What {@link planOwnerKeyRemoval} judges from: one node's live rows and its own standing. */
|
|
36
|
+
export interface OwnerKeyRemovalPlanInput {
|
|
37
|
+
key: string;
|
|
38
|
+
/** Live `CadrePeer` rows (`ControlDatabase.queryCadrePeers`). */
|
|
39
|
+
rows: readonly CadrePeerRow[];
|
|
40
|
+
/** Live `OwnerKey` rows (`ControlDatabase.queryOwnerKeyRows`). */
|
|
41
|
+
owners: readonly OwnerKeyRow[];
|
|
42
|
+
/** Every owner grant with its standing (`ControlDatabase.listOwnerGrantStatuses`); the live ones the key issued are the plan's `grants`. */
|
|
43
|
+
grants: readonly OwnerGrantStatus[];
|
|
44
|
+
selfPeerId: string | null;
|
|
45
|
+
/** The key of this node's owner signer when it is an enrolled owner (`CadreNode.ownerSignerEnrolledIn`), or null when it cannot sign owner writes. */
|
|
46
|
+
selfOwnerKey: string | null;
|
|
47
|
+
/** This node's trusted-owner anchor, for the listed entry's `trusted`. */
|
|
48
|
+
anchor: ReadonlySet<string>;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* The plan for removing owner key `key` from these rows. The refusals come first and by name: a
|
|
52
|
+
* node that cannot sign; a key with no live row; the only live owner key (`MinOneOwner`), ahead
|
|
53
|
+
* of `self` so a sole owner asking to remove its own key hears the rule no other owner could
|
|
54
|
+
* get past either; and this node's own key, since the schema's remove branch wants a signer
|
|
55
|
+
* other than the removed key. With this node enrolled, a different live key always leaves two
|
|
56
|
+
* owners in one read, so `last-owner` reaches only that case, and concurrent removals elsewhere
|
|
57
|
+
* leave the schema to decide.
|
|
58
|
+
*
|
|
59
|
+
* `dependents` are the rows the key vouched, which every reader judges against its anchor
|
|
60
|
+
* through `VouchOwner`: once the key is removed they stop passing the membership predicate on
|
|
61
|
+
* every machine unless re-vouched first. This node's own rows are not among them. Its own
|
|
62
|
+
* `CadrePeer` row is re-vouched unasked (`revouchesOwnRow`): left on the removed key, every other
|
|
63
|
+
* machine would drop the remover. Its own `OwnerKey` row is reported as `ownDependency`, since
|
|
64
|
+
* re-vouching it would mean signing its own removal.
|
|
65
|
+
*
|
|
66
|
+
* `grants` are the live owner grants the key issued: a redemption wants a live issuer, so they
|
|
67
|
+
* stop working with the removal. They are listed, not withdrawn (`removeOwner` leaves them: a
|
|
68
|
+
* tombstone over a grant that can no longer be redeemed would add nothing).
|
|
69
|
+
*/
|
|
70
|
+
export declare function planOwnerKeyRemoval(input: OwnerKeyRemovalPlanInput): OwnerKeyRemovalPlan;
|
|
71
|
+
/**
|
|
72
|
+
* The re-vouch `CadreNode.removeOwner` makes: what the caller asked for, checked against the
|
|
73
|
+
* plan, plus this node's own row (`selfPeerId`, first) when `plan.revouchesOwnRow`. Every
|
|
74
|
+
* requested key and peer must be in `plan.dependents`, so a caller cannot re-vouch a row the
|
|
75
|
+
* removed key never vouched. Throws naming the offenders, before anything is written.
|
|
76
|
+
* Duplicates are dropped.
|
|
77
|
+
*/
|
|
78
|
+
export declare function revouchWithinPlan(plan: OwnerKeyRemovalPlan, revouch: RemoveOwnerOptions['revouch'], selfPeerId: string | null): OwnerKeyDependents;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Owner keys as an app lists, adds and removes them (`CadreNode.listOwnerKeys`,
|
|
3
|
+
* `CadreNode.addOwner`, `CadreNode.planOwnerKeyRemoval`, `CadreNode.removeOwner`): the
|
|
4
|
+
* projection of the live `OwnerKey` rows an owner-key screen shows, the read-only plan behind a
|
|
5
|
+
* removal's confirmation step, the check that a requested re-vouch stays inside that plan, and
|
|
6
|
+
* the by-name refusals. Pure; the reads and writes themselves are `CadreNode`'s and
|
|
7
|
+
* `ControlDatabase`'s.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* `CadreNode.addOwner` refused by name, before any write. `code` says which rule
|
|
11
|
+
* ({@link OwnerKeyAddRefusal}), for an app to switch on; the message is for a log.
|
|
12
|
+
*/
|
|
13
|
+
export class OwnerKeyAddRefusedError extends Error {
|
|
14
|
+
constructor(key, code) {
|
|
15
|
+
super(`Cannot add owner key ${key}: ${OWNER_KEY_ADD_REFUSAL_REASON[code]}`);
|
|
16
|
+
this.name = 'OwnerKeyAddRefusedError';
|
|
17
|
+
this.code = code;
|
|
18
|
+
this.key = key;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
const OWNER_KEY_ADD_REFUSAL_REASON = {
|
|
22
|
+
'alone': 'this node has no connection to the rest of the cadre, and an owner key added now would reach no other machine; try again once connected',
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* `CadreNode.removeOwner` refused by name, before any write. `code` says which rule
|
|
26
|
+
* ({@link OwnerKeyRemovalRefusal}), for an app to switch on; the message is for a log.
|
|
27
|
+
*/
|
|
28
|
+
export class OwnerKeyRemovalRefusedError extends Error {
|
|
29
|
+
constructor(key, code) {
|
|
30
|
+
super(`Cannot remove owner key ${key}: ${OWNER_KEY_REMOVAL_REFUSAL_REASON[code]}`);
|
|
31
|
+
this.name = 'OwnerKeyRemovalRefusedError';
|
|
32
|
+
this.code = code;
|
|
33
|
+
this.key = key;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const OWNER_KEY_REMOVAL_REFUSAL_REASON = {
|
|
37
|
+
'not-an-owner': 'this node holds no enrolled owner key',
|
|
38
|
+
'unknown': 'it is not a live owner key here',
|
|
39
|
+
'last-owner': 'it is the only live owner key',
|
|
40
|
+
'self': 'it is the owner key of this node, and an owner key cannot sign its own removal; ask another owner key',
|
|
41
|
+
'alone': 'this node has no connection to the rest of the cadre, and an owner key re-vouched now would reach no other machine; try again once connected',
|
|
42
|
+
};
|
|
43
|
+
/** An owner key as an approval prompt names it: `"label" (key)`, or the key alone when it has no label. */
|
|
44
|
+
export function namedOwnerKey(key, label) {
|
|
45
|
+
return label === null ? key : `"${label}" (${key})`;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* One {@link CadreOwnerKey} per live row, in the rows' order. `heldKey` is the key of this
|
|
49
|
+
* node's owner signer, if one is wired; `anchor` is this node's trusted-owner anchor.
|
|
50
|
+
*/
|
|
51
|
+
export function describeOwnerKeys(rows, heldKey, anchor) {
|
|
52
|
+
return rows.map((row) => ({
|
|
53
|
+
key: row.key,
|
|
54
|
+
label: row.label,
|
|
55
|
+
vouchedBy: row.vouchOwner,
|
|
56
|
+
heldHere: row.key === heldKey,
|
|
57
|
+
trusted: anchor.has(row.key),
|
|
58
|
+
}));
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* The plan for removing owner key `key` from these rows. The refusals come first and by name: a
|
|
62
|
+
* node that cannot sign; a key with no live row; the only live owner key (`MinOneOwner`), ahead
|
|
63
|
+
* of `self` so a sole owner asking to remove its own key hears the rule no other owner could
|
|
64
|
+
* get past either; and this node's own key, since the schema's remove branch wants a signer
|
|
65
|
+
* other than the removed key. With this node enrolled, a different live key always leaves two
|
|
66
|
+
* owners in one read, so `last-owner` reaches only that case, and concurrent removals elsewhere
|
|
67
|
+
* leave the schema to decide.
|
|
68
|
+
*
|
|
69
|
+
* `dependents` are the rows the key vouched, which every reader judges against its anchor
|
|
70
|
+
* through `VouchOwner`: once the key is removed they stop passing the membership predicate on
|
|
71
|
+
* every machine unless re-vouched first. This node's own rows are not among them. Its own
|
|
72
|
+
* `CadrePeer` row is re-vouched unasked (`revouchesOwnRow`): left on the removed key, every other
|
|
73
|
+
* machine would drop the remover. Its own `OwnerKey` row is reported as `ownDependency`, since
|
|
74
|
+
* re-vouching it would mean signing its own removal.
|
|
75
|
+
*
|
|
76
|
+
* `grants` are the live owner grants the key issued: a redemption wants a live issuer, so they
|
|
77
|
+
* stop working with the removal. They are listed, not withdrawn (`removeOwner` leaves them: a
|
|
78
|
+
* tombstone over a grant that can no longer be redeemed would add nothing).
|
|
79
|
+
*/
|
|
80
|
+
export function planOwnerKeyRemoval(input) {
|
|
81
|
+
const row = input.owners.find((owner) => owner.key === input.key) ?? null;
|
|
82
|
+
return {
|
|
83
|
+
ownerKey: row === null ? null : describeOwnerKeys([row], input.selfOwnerKey, input.anchor)[0],
|
|
84
|
+
refusal: removalRefusalFor(input, row !== null),
|
|
85
|
+
dependents: dependentsOf(input),
|
|
86
|
+
revouchesOwnRow: input.rows.some((own) => own.peerId === input.selfPeerId && own.vouchOwner === input.key),
|
|
87
|
+
ownDependency: input.owners.some((own) => own.key === input.selfOwnerKey && own.vouchOwner === input.key),
|
|
88
|
+
grants: input.grants.filter((status) => status.live && status.grant.issuerKey === input.key).map((status) => status.grant),
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
function removalRefusalFor(input, live) {
|
|
92
|
+
if (input.selfOwnerKey === null) {
|
|
93
|
+
return 'not-an-owner';
|
|
94
|
+
}
|
|
95
|
+
if (!live) {
|
|
96
|
+
return 'unknown';
|
|
97
|
+
}
|
|
98
|
+
if (input.owners.length <= 1) {
|
|
99
|
+
return 'last-owner';
|
|
100
|
+
}
|
|
101
|
+
if (input.key === input.selfOwnerKey) {
|
|
102
|
+
return 'self';
|
|
103
|
+
}
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
function dependentsOf(input) {
|
|
107
|
+
return {
|
|
108
|
+
owners: input.owners
|
|
109
|
+
.filter((owner) => owner.vouchOwner === input.key && owner.key !== input.key && owner.key !== input.selfOwnerKey)
|
|
110
|
+
.map((owner) => owner.key),
|
|
111
|
+
peers: input.rows
|
|
112
|
+
.filter((row) => row.vouchOwner === input.key && row.peerId !== input.selfPeerId)
|
|
113
|
+
.map((row) => row.peerId),
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* The re-vouch `CadreNode.removeOwner` makes: what the caller asked for, checked against the
|
|
118
|
+
* plan, plus this node's own row (`selfPeerId`, first) when `plan.revouchesOwnRow`. Every
|
|
119
|
+
* requested key and peer must be in `plan.dependents`, so a caller cannot re-vouch a row the
|
|
120
|
+
* removed key never vouched. Throws naming the offenders, before anything is written.
|
|
121
|
+
* Duplicates are dropped.
|
|
122
|
+
*/
|
|
123
|
+
export function revouchWithinPlan(plan, revouch, selfPeerId) {
|
|
124
|
+
const owners = [...new Set(revouch?.owners ?? [])];
|
|
125
|
+
const peers = [...new Set(revouch?.peers ?? [])];
|
|
126
|
+
const strayOwners = owners.filter((key) => !plan.dependents.owners.includes(key));
|
|
127
|
+
const strayPeers = peers.filter((peerId) => !plan.dependents.peers.includes(peerId));
|
|
128
|
+
if (strayOwners.length > 0 || strayPeers.length > 0) {
|
|
129
|
+
throw new Error(`removeOwner: re-vouch names rows the removed owner key did not vouch: ${[...strayOwners, ...strayPeers].join(', ')}`);
|
|
130
|
+
}
|
|
131
|
+
return { owners, peers: plan.revouchesOwnRow && selfPeerId !== null ? [selfPeerId, ...peers] : peers };
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=owner-keys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"owner-keys.js","sourceRoot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AE,CAAC,GAAG,CAAC,MAAM,CAAC;KAC1B,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAyB,EAAE,OAAsC,EAAE,UAAyB;IAC7H,MAAM,MAAM,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,OAAO,EAAE,MAAM,IAAI,EAAE,CAAC,CAAC,CAAC;IACnD,MAAM,KAAK,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,OAAO,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC;IACjD,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;IAClF,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;IACrF,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACrD,MAAM,IAAI,KAAK,CACd,yEAAyE,CAAC,GAAG,WAAW,EAAE,GAAG,UAAU,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACrH,CAAC;IACH,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,eAAe,IAAI,UAAU,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC;AACxG,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/** What a backend that asks the user shows them. */
|
|
2
|
+
export interface OwnerSigningRequest {
|
|
3
|
+
/** The cadre the signatures are for. Every owner digest already binds it (`party_id()`); a prompting backend shows it. */
|
|
4
|
+
partyId: string;
|
|
5
|
+
/** What the user is approving, in plain words ("Remove the machine 12D3…", "Add owner key ‹label›"). */
|
|
6
|
+
action: string;
|
|
7
|
+
}
|
|
8
|
+
/** Signs one message (the raw bytes of an owner digest, e.g. `buildAuthorizationMessage` output); resolves to a base64url Ed25519 signature. */
|
|
9
|
+
export type OwnerSign = (message: Uint8Array) => Promise<string>;
|
|
10
|
+
/**
|
|
11
|
+
* An owner key the node can ask for signatures.
|
|
12
|
+
*
|
|
13
|
+
* One action, one {@link approve} call, however many rows it signs: the control schema verifies
|
|
14
|
+
* one signature per row, and one owner action writes several (a removal signs the delete and its
|
|
15
|
+
* `Revocation` tombstone; a machine removal signs many). A hardware or biometric backend prompts
|
|
16
|
+
* once per call, as PIV touch caching and the platform vaults' authentication-validity windows
|
|
17
|
+
* allow. Handing the signer every digest up front was declined: each writer reads the stamps it
|
|
18
|
+
* signs inside its write lock, so precomputing them would duplicate each writer's digest
|
|
19
|
+
* construction outside it.
|
|
20
|
+
*/
|
|
21
|
+
export interface OwnerSigner {
|
|
22
|
+
/** base64url Ed25519 public key — the `OwnerKey.Key` this signer signs for. */
|
|
23
|
+
readonly publicKey: string;
|
|
24
|
+
/**
|
|
25
|
+
* Run one user-approved action. A backend that prompts does so at most once per call and may
|
|
26
|
+
* keep the user's presence until `body` settles. Rejects with {@link OwnerSigningDeclinedError}
|
|
27
|
+
* when the user declines, and with whatever `body` rejects with otherwise.
|
|
28
|
+
*/
|
|
29
|
+
approve<T>(request: OwnerSigningRequest, body: (sign: OwnerSign) => Promise<T>): Promise<T>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Run `body` inside the caller's open approval when it passes `sign`, else inside one new
|
|
33
|
+
* approval of `signer` for `request`. An owner write that is sometimes a whole action and
|
|
34
|
+
* sometimes one step of a larger one takes an optional `sign` and goes through this, so the
|
|
35
|
+
* larger action still asks once.
|
|
36
|
+
*/
|
|
37
|
+
export declare function withinOwnerApproval<T>(signer: OwnerSigner, request: OwnerSigningRequest, sign: OwnerSign | undefined, body: (sign: OwnerSign) => Promise<T>): Promise<T>;
|
|
38
|
+
/** Thrown by a prompting backend when the user declines or the prompt times out. */
|
|
39
|
+
export declare class OwnerSigningDeclinedError extends Error {
|
|
40
|
+
readonly request: OwnerSigningRequest;
|
|
41
|
+
constructor(request: OwnerSigningRequest, options?: {
|
|
42
|
+
cause?: unknown;
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* An {@link OwnerSigner} over a private key held in memory: never prompts, signs whatever its
|
|
47
|
+
* `approve` body asks. Its signed input is the digest bytes, base64url-encoded, so its signatures
|
|
48
|
+
* are byte-for-byte those of any signer that signs the raw bytes with the same key (Ed25519 is
|
|
49
|
+
* deterministic).
|
|
50
|
+
*
|
|
51
|
+
* @param privateKeyB64 - The owner key's 32-byte Ed25519 seed, base64url.
|
|
52
|
+
* @throws If `privateKeyB64` is not a 32-byte seed in base64url.
|
|
53
|
+
*/
|
|
54
|
+
export declare function softwareOwnerSigner(privateKeyB64: string): OwnerSigner;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The owner signer: the one interface a node's owner signatures go through
|
|
3
|
+
* (`docs/architecture.md` → Owner Keys → The owner signer).
|
|
4
|
+
*
|
|
5
|
+
* cadre-core needs owner signatures, never an owner private key, so a backend that keeps the
|
|
6
|
+
* key where the node cannot read it (a hardware key, a vault behind biometrics) fits the same
|
|
7
|
+
* seam as {@link softwareOwnerSigner}.
|
|
8
|
+
*
|
|
9
|
+
* Imports only `@optimystic/quereus-plugin-crypto` and `uint8arrays`, so it loads on React
|
|
10
|
+
* Native and in the browser.
|
|
11
|
+
*/
|
|
12
|
+
import { toString as uint8ArrayToString } from 'uint8arrays';
|
|
13
|
+
import { sign } from '@optimystic/quereus-plugin-crypto';
|
|
14
|
+
import { ed25519PublicKeyFromPrivate, requireEd25519PrivateKeyB64 } from './ed25519-key.js';
|
|
15
|
+
/**
|
|
16
|
+
* Run `body` inside the caller's open approval when it passes `sign`, else inside one new
|
|
17
|
+
* approval of `signer` for `request`. An owner write that is sometimes a whole action and
|
|
18
|
+
* sometimes one step of a larger one takes an optional `sign` and goes through this, so the
|
|
19
|
+
* larger action still asks once.
|
|
20
|
+
*/
|
|
21
|
+
export async function withinOwnerApproval(signer, request, sign, body) {
|
|
22
|
+
return sign ? await body(sign) : await signer.approve(request, body);
|
|
23
|
+
}
|
|
24
|
+
/** Thrown by a prompting backend when the user declines or the prompt times out. */
|
|
25
|
+
export class OwnerSigningDeclinedError extends Error {
|
|
26
|
+
constructor(request, options) {
|
|
27
|
+
super(`Owner approval was declined or timed out: ${request.action}`, options);
|
|
28
|
+
this.name = 'OwnerSigningDeclinedError';
|
|
29
|
+
this.request = request;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* An {@link OwnerSigner} over a private key held in memory: never prompts, signs whatever its
|
|
34
|
+
* `approve` body asks. Its signed input is the digest bytes, base64url-encoded, so its signatures
|
|
35
|
+
* are byte-for-byte those of any signer that signs the raw bytes with the same key (Ed25519 is
|
|
36
|
+
* deterministic).
|
|
37
|
+
*
|
|
38
|
+
* @param privateKeyB64 - The owner key's 32-byte Ed25519 seed, base64url.
|
|
39
|
+
* @throws If `privateKeyB64` is not a 32-byte seed in base64url.
|
|
40
|
+
*/
|
|
41
|
+
export function softwareOwnerSigner(privateKeyB64) {
|
|
42
|
+
const privateKey = requireEd25519PrivateKeyB64(privateKeyB64, 'owner private key');
|
|
43
|
+
const signMessage = async (message) => sign(uint8ArrayToString(message, 'base64url'), privateKey, 'ed25519', 'base64url', 'base64url', 'base64url');
|
|
44
|
+
return {
|
|
45
|
+
publicKey: ed25519PublicKeyFromPrivate(privateKey),
|
|
46
|
+
async approve(_request, body) {
|
|
47
|
+
return await body(signMessage);
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=owner-signer.js.map
|
|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I,QAA6B,EAAE,IAAqC;YACpF,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,CAAC;QAChC,CAAC;KACD,CAAC;AACH,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { CadreInviteSignedFields, RevocableTable } from './control-authorization.js';
|
|
2
|
-
import type { CadreInviteRow, CadreInviteUsageRow, CadrePeerVoucherFields, OwnerKeyRow, RevocationRow } from './types.js';
|
|
1
|
+
import type { CadreInviteSignedFields, OwnerGrantSignedFields, RevocableTable } from './control-authorization.js';
|
|
2
|
+
import type { CadreInviteRow, CadreInviteUsageRow, CadrePeerVoucherFields, OwnerGrantRow, OwnerGrantUsageRow, OwnerKeyRow, RevocationRow } from './types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Canonical digest an owner signs to vouch a peer's ENROLLMENT — the offline
|
|
5
5
|
* credential `cadre enroll register` verifies. No table checks this digest, so it
|
|
@@ -117,16 +117,18 @@ export declare function verifyRevocationSigner(partyId: string, row: RevocationR
|
|
|
117
117
|
/**
|
|
118
118
|
* Canonical digest an owner signs to seat a further `OwnerKey` row — the signed-add branch
|
|
119
119
|
* of `OwnerKey.Authorized`, which stores the pair as `VouchOwner` / `VouchSig`. SQL mirror:
|
|
120
|
-
* `digest('CadreControl.OwnerKey', 'add', party_id(), new.Key, new.StampId)`.
|
|
121
|
-
* digest needs no builder here: it is the generic guarded `'remove'` digest over
|
|
120
|
+
* `digest('CadreControl.OwnerKey', 'add', party_id(), new.Key, coalesce(new.Label, ''), new.StampId)`.
|
|
121
|
+
* The removal digest needs no builder here: it is the generic guarded `'remove'` digest over
|
|
122
|
+
* (Key, StampId).
|
|
122
123
|
*/
|
|
123
|
-
export declare function ownerKeyAddDigest(partyId: string, key: string, stampId: string): string;
|
|
124
|
+
export declare function ownerKeyAddDigest(partyId: string, key: string, label: string | null, stampId: string): string;
|
|
124
125
|
/**
|
|
125
126
|
* Does an owner-signed `OwnerKey` row's stored voucher verify — `vouchSig` by `vouchOwner`
|
|
126
|
-
* over {@link ownerKeyAddDigest} for (`partyId`, `key`, `stampId`)? Whether
|
|
127
|
-
* anchored is the caller's question, as for {@link verifyCadrePeerVoucher}.
|
|
127
|
+
* over {@link ownerKeyAddDigest} for (`partyId`, `key`, `label`, `stampId`)? Whether
|
|
128
|
+
* `vouchOwner` is anchored is the caller's question, as for {@link verifyCadrePeerVoucher}.
|
|
129
|
+
* Never throws.
|
|
128
130
|
*/
|
|
129
|
-
export declare function verifyOwnerKeyVoucher(partyId: string, key: string, stampId: string, vouchOwner: string, vouchSig: string): boolean;
|
|
131
|
+
export declare function verifyOwnerKeyVoucher(partyId: string, key: string, label: string | null, stampId: string, vouchOwner: string, vouchSig: string): boolean;
|
|
130
132
|
/**
|
|
131
133
|
* Verify that `signature` is a valid owner ed25519 signature over `peerId`'s
|
|
132
134
|
* authorization digest, using `ownerPublicKey` (base64url).
|
|
@@ -236,8 +238,20 @@ export declare function verifyCadreInviteRedemption(partyId: string, fields: {
|
|
|
236
238
|
* Is an invitation-admitted `CadrePeer` row (`vouchSig` null, `vouchUsage` set) a
|
|
237
239
|
* member this node should trust? The read-side mirror of the consent branch of
|
|
238
240
|
* `CadrePeer.AuthorizedInsert`, re-checked against THIS node's anchor because the
|
|
239
|
-
* replicated `OwnerKey` table can be polluted. The
|
|
240
|
-
*
|
|
241
|
+
* replicated `OwnerKey` table can be polluted. The chain is
|
|
242
|
+
*
|
|
243
|
+
* row --vouchUsage--> usage --inviteKey--> invitation --issuerKey--> anchored owner
|
|
244
|
+
*
|
|
245
|
+
* and every link is verified: the issuer is anchored (`isAnchored`) and is the row's
|
|
246
|
+
* `vouchOwner`; the usage is the row's `vouchUsage`, names this peer id and this exact row
|
|
247
|
+
* incarnation (`peerStampId`), and names this invitation; a targeted invitation names the
|
|
248
|
+
* redeeming device; the stored `peerKey` really is the key behind the usage's `peerId` (the
|
|
249
|
+
* schema cannot unwrap a multihash, so a writer could assert any pair); the invitation's
|
|
250
|
+
* stored `'add'` signature verifies over the row rebuilt from its columns; the holder's
|
|
251
|
+
* `'redeem'` signature verifies with the invitation key and the device's `'consent'`
|
|
252
|
+
* signature with its own key. All three signatures are judged for `partyId`. A machine
|
|
253
|
+
* invitation admits a machine and nothing else, so no `OwnerKey` row is ever verified
|
|
254
|
+
* through this chain; a grant-seated owner row is {@link verifyOwnerGrantAdmission}'s.
|
|
241
255
|
*
|
|
242
256
|
* Expiry, use count and withdrawal are deliberately NOT re-checked: they were conditions
|
|
243
257
|
* at redemption (`CadreInviteUsage.Authorized`), and membership persists until an owner
|
|
@@ -249,12 +263,63 @@ export declare function verifyCadreInviteRedemption(partyId: string, fields: {
|
|
|
249
263
|
*/
|
|
250
264
|
export declare function verifyInvitationAdmission(partyId: string, row: CadrePeerVoucherFields, usage: CadreInviteUsageRow, invite: CadreInviteRow, isAnchored: (ownerKey: string) => boolean): boolean;
|
|
251
265
|
/**
|
|
252
|
-
*
|
|
253
|
-
*
|
|
254
|
-
*
|
|
255
|
-
*
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
266
|
+
* Canonical digest an owner signs to seat an `OwnerGrant` row — the read-side mirror of
|
|
267
|
+
* `ownerGrantAddMessage` in control-database.ts, base64url instead of raw bytes. The whole
|
|
268
|
+
* row is bound, the label included, through the one field builder both sides share
|
|
269
|
+
* (`ownerGrantRowFields`). SQL mirror: `OwnerGrant.AuthorizedInsert`.
|
|
270
|
+
*/
|
|
271
|
+
export declare function ownerGrantAddDigest(partyId: string, row: OwnerGrantSignedFields): string;
|
|
272
|
+
/**
|
|
273
|
+
* Canonical digest the HOLDER of an `OwnerGrant`'s private key signs to redeem it once:
|
|
274
|
+
* proof of possession, verified against the grant key itself
|
|
275
|
+
* (`OwnerGrantUsage.GrantPossessed`). Binds the redemption's nonce and the key being seated,
|
|
276
|
+
* so one redemption cannot be re-presented for another key or another use. Mirror of
|
|
277
|
+
* `ownerGrantRedeemMessage` in control-database.ts.
|
|
278
|
+
*/
|
|
279
|
+
export declare function ownerGrantRedeemDigest(partyId: string, grantKey: string, usageStampId: string, seatedKey: string): string;
|
|
280
|
+
/**
|
|
281
|
+
* Canonical digest the key being SEATED signs to prove it is held by the redeemer
|
|
282
|
+
* (`OwnerGrantUsage.OwnerConsented`), over the same fields as {@link ownerGrantRedeemDigest}
|
|
283
|
+
* under a distinct action tag, so the holder's and the key's signatures are never
|
|
284
|
+
* interchangeable. Mirror of `ownerGrantConsentMessage` in control-database.ts.
|
|
285
|
+
*/
|
|
286
|
+
export declare function ownerGrantConsentDigest(partyId: string, grantKey: string, usageStampId: string, seatedKey: string): string;
|
|
287
|
+
/**
|
|
288
|
+
* Does an `OwnerGrant` row carry a valid `'add'` signature by its own `issuerKey`, for
|
|
289
|
+
* `partyId`? The grant twin of {@link verifyCadreInviteRow}, with the same contract: whether
|
|
290
|
+
* that issuer IS an owner is the caller's question, and a malformed row verifies as `false`.
|
|
291
|
+
*/
|
|
292
|
+
export declare function verifyOwnerGrantRow(partyId: string, grant: OwnerGrantRow): boolean;
|
|
293
|
+
/**
|
|
294
|
+
* The two signatures an owner-grant redemption carries, checked before any database work:
|
|
295
|
+
* the holder's `'redeem'` signature with the grant key and the seated key's `'consent'`
|
|
296
|
+
* signature with itself, both over (`grantKey`, `usageStampId`, `seatedKey`). The grant twin
|
|
297
|
+
* of {@link verifyCadreInviteRedemption}, with the same contract: the schema
|
|
298
|
+
* (`OwnerGrantUsage.GrantPossessed` / `OwnerConsented`) stays the authority, this turns a bad
|
|
299
|
+
* signature into a clean refusal instead of a constraint failure at commit. Never throws.
|
|
300
|
+
*/
|
|
301
|
+
export declare function verifyOwnerGrantRedemption(partyId: string, fields: {
|
|
302
|
+
grantKey: string;
|
|
303
|
+
usageStampId: string;
|
|
304
|
+
seatedKey: string;
|
|
305
|
+
}, grantSig: string, ownerSig: string): boolean;
|
|
306
|
+
/**
|
|
307
|
+
* Is a grant-seated `OwnerKey` row (`vouchSig` null, `vouchUsage` naming an `OwnerGrantUsage`
|
|
308
|
+
* row) an owner this node should derive into its anchor? The read-side mirror of the grant
|
|
309
|
+
* branch of `OwnerKey.Authorized` (`owner-anchor-sync.ts` → `deriveOwnerAnchor`). The chain is
|
|
310
|
+
*
|
|
311
|
+
* row --vouchUsage--> usage --grantKey--> grant --issuerKey--> anchored owner
|
|
312
|
+
*
|
|
313
|
+
* and every link is verified: the issuer is anchored and is the row's `vouchOwner`; the usage
|
|
314
|
+
* is the row's `vouchUsage` and names this key and this exact row incarnation
|
|
315
|
+
* (`seatedStampId`); the usage names this grant; the row carries the grant's label; the
|
|
316
|
+
* grant's stored `'add'` signature verifies over the row rebuilt from its columns; the
|
|
317
|
+
* holder's `'redeem'` signature verifies with the grant key and the seated key's `'consent'`
|
|
318
|
+
* signature with itself. All three signatures are judged for `partyId`.
|
|
319
|
+
*
|
|
320
|
+
* Expiry, use count and withdrawal are deliberately NOT re-checked, as
|
|
321
|
+
* {@link verifyInvitationAdmission} omits them: they were conditions at redemption
|
|
322
|
+
* (`OwnerGrantUsage.Authorized`), and ownership persists until an owner removes the row.
|
|
323
|
+
* Same never-throws contract as the siblings.
|
|
259
324
|
*/
|
|
260
|
-
export declare function
|
|
325
|
+
export declare function verifyOwnerGrantAdmission(partyId: string, row: OwnerKeyRow, usage: OwnerGrantUsageRow, grant: OwnerGrantRow, isAnchored: (ownerKey: string) => boolean): boolean;
|