@serfab/cadre-core 1.22.0 → 1.23.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/dist/cadre-node.d.ts +14 -9
- package/dist/cadre-node.js +37 -10
- package/dist/cadre-node.js.map +1 -1
- package/dist/membership-view.js +4 -1
- package/dist/membership-view.js.map +1 -1
- package/dist/strand-instance-manager.d.ts +67 -9
- package/dist/strand-instance-manager.js +168 -22
- package/dist/strand-instance-manager.js.map +1 -1
- package/dist/types.d.ts +11 -2
- package/package.json +8 -8
- package/src/cadre-node.ts +38 -10
- package/src/membership-view.ts +4 -1
- package/src/strand-instance-manager.ts +194 -23
- package/src/types.ts +11 -2
package/dist/cadre-node.d.ts
CHANGED
|
@@ -4447,19 +4447,22 @@ export declare class CadreNode implements SAppIdLookup {
|
|
|
4447
4447
|
* the party still holds, own or joined. A row left behind by a joined strand the party has left
|
|
4448
4448
|
* waits for a re-formation and is not listed. Public columns only, so a row sealed to other
|
|
4449
4449
|
* machines lists too. Empty on a machine removed from the cadre, which cannot act on what it holds.
|
|
4450
|
+
* A recipient the party lost but has not removed stays in `sealedTo`; removing it writes a
|
|
4451
|
+
* replacement sealed to the machines present (`ControlDatabase.removeMachine`).
|
|
4450
4452
|
*
|
|
4451
4453
|
* NOTE: no event announces a change here; an app reads this on `strand:party-key-rotation-blocked`,
|
|
4452
4454
|
* `strand:party-key-rotated` and after its own {@link removeMachine}, so a second device of the
|
|
4453
4455
|
* party sees a row replicated to it on its next read. If an app ever needs a push, emit from
|
|
4454
4456
|
* {@link onPartyKeyTablesChanged}.
|
|
4455
|
-
*
|
|
4456
|
-
* NOTE: `waitingOn` does not look at who the key is sealed to. If the party loses every machine a
|
|
4457
|
-
* row is sealed to and recovers as docs/strands.md describes (deleting its `StrandPartyKey` row,
|
|
4458
|
-
* re-joining under a fresh key), the row stays listed as `owner-machine`, then `another-party`,
|
|
4459
|
-
* though no machine can open it; only a later removal replaces it. If an app ever reaches this,
|
|
4460
|
-
* compare `partyKeyRecipients(row.sealedKey)` with the live machines and add a state for it.
|
|
4461
4457
|
*/
|
|
4462
4458
|
listPendingPartyKeyRotations(): Promise<PendingPartyKeyRotation[]>;
|
|
4459
|
+
/** The peer ids {@link listMachines} lists, and this node's own, which is a machine of the cadre before its `CadrePeer` row lands. */
|
|
4460
|
+
private presentMachinePeerIds;
|
|
4461
|
+
/**
|
|
4462
|
+
* {@link PendingPartyKeyRotation.sealedTo}: the row's recipients still in the cadre. An envelope
|
|
4463
|
+
* that does not decode opens for nobody, so it lists none, logged; the rest of the listing stands.
|
|
4464
|
+
*/
|
|
4465
|
+
private pendingKeyRecipientsPresent;
|
|
4463
4466
|
/** {@link closedStrandState} plus the strand reads only a pending replacement asks about; a read that fails is `unknown`, so one strand mid-teardown leaves the rest of the listing standing. */
|
|
4464
4467
|
private pendingRotationStrandState;
|
|
4465
4468
|
/**
|
|
@@ -4519,9 +4522,11 @@ export declare class CadreNode implements SAppIdLookup {
|
|
|
4519
4522
|
* key to seal to.
|
|
4520
4523
|
*
|
|
4521
4524
|
* NOTE: a machine admitted after the removal is not a recipient, so an owner machine enrolled
|
|
4522
|
-
* while a rotation is pending cannot drive it
|
|
4523
|
-
*
|
|
4524
|
-
*
|
|
4525
|
+
* while a rotation is pending cannot drive it or redeem the host's invitation under the new key;
|
|
4526
|
+
* a recipient owner machine has to. The app learns which machines those are from
|
|
4527
|
+
* {@link PendingPartyKeyRotation.sealedTo}. If a party is seen stuck that way, the remedy is the
|
|
4528
|
+
* replacement a second removal already writes (`ControlDatabase.removeMachine`), minted for the
|
|
4529
|
+
* machines present then.
|
|
4525
4530
|
*/
|
|
4526
4531
|
private pendingPartyKeyRecipients;
|
|
4527
4532
|
/** This machine as a sealed party key sees it: its control peer id with the identity key behind it ({@link getSelfSigningKey}), or null on an ephemeral identity. */
|
package/dist/cadre-node.js
CHANGED
|
@@ -9110,17 +9110,13 @@ export class CadreNode {
|
|
|
9110
9110
|
* the party still holds, own or joined. A row left behind by a joined strand the party has left
|
|
9111
9111
|
* waits for a re-formation and is not listed. Public columns only, so a row sealed to other
|
|
9112
9112
|
* machines lists too. Empty on a machine removed from the cadre, which cannot act on what it holds.
|
|
9113
|
+
* A recipient the party lost but has not removed stays in `sealedTo`; removing it writes a
|
|
9114
|
+
* replacement sealed to the machines present (`ControlDatabase.removeMachine`).
|
|
9113
9115
|
*
|
|
9114
9116
|
* NOTE: no event announces a change here; an app reads this on `strand:party-key-rotation-blocked`,
|
|
9115
9117
|
* `strand:party-key-rotated` and after its own {@link removeMachine}, so a second device of the
|
|
9116
9118
|
* party sees a row replicated to it on its next read. If an app ever needs a push, emit from
|
|
9117
9119
|
* {@link onPartyKeyTablesChanged}.
|
|
9118
|
-
*
|
|
9119
|
-
* NOTE: `waitingOn` does not look at who the key is sealed to. If the party loses every machine a
|
|
9120
|
-
* row is sealed to and recovers as docs/strands.md describes (deleting its `StrandPartyKey` row,
|
|
9121
|
-
* re-joining under a fresh key), the row stays listed as `owner-machine`, then `another-party`,
|
|
9122
|
-
* though no machine can open it; only a later removal replaces it. If an app ever reaches this,
|
|
9123
|
-
* compare `partyKeyRecipients(row.sealedKey)` with the live machines and add a state for it.
|
|
9124
9120
|
*/
|
|
9125
9121
|
async listPendingPartyKeyRotations() {
|
|
9126
9122
|
if (!this.controlDatabase) {
|
|
@@ -9135,16 +9131,45 @@ export class CadreNode {
|
|
|
9135
9131
|
return [];
|
|
9136
9132
|
}
|
|
9137
9133
|
const held = new Set((await this.heldStrandRows(controlDatabase)).map((row) => row.Id));
|
|
9134
|
+
const present = await this.presentMachinePeerIds(controlDatabase);
|
|
9138
9135
|
const rotations = [];
|
|
9139
9136
|
for (const [strandId, row] of pending) {
|
|
9140
9137
|
if (held.has(strandId)) {
|
|
9141
9138
|
const partyKey = await controlDatabase.queryStrandPartyKey(strandId);
|
|
9142
9139
|
const strand = await this.pendingRotationStrandState(strandId, partyKey, row.publicKey);
|
|
9143
|
-
rotations.push({
|
|
9140
|
+
rotations.push({
|
|
9141
|
+
strandId,
|
|
9142
|
+
publicKey: row.publicKey,
|
|
9143
|
+
superseded: row.superseded,
|
|
9144
|
+
waitingOn: pendingRotationWaitingOn(strand),
|
|
9145
|
+
sealedTo: this.pendingKeyRecipientsPresent(strandId, row, present),
|
|
9146
|
+
});
|
|
9144
9147
|
}
|
|
9145
9148
|
}
|
|
9146
9149
|
return rotations;
|
|
9147
9150
|
}
|
|
9151
|
+
/** The peer ids {@link listMachines} lists, and this node's own, which is a machine of the cadre before its `CadrePeer` row lands. */
|
|
9152
|
+
async presentMachinePeerIds(controlDatabase) {
|
|
9153
|
+
const present = new Set((await controlDatabase.queryCadrePeers()).map((row) => row.peerId));
|
|
9154
|
+
const self = this.peerId?.toString();
|
|
9155
|
+
if (self !== undefined) {
|
|
9156
|
+
present.add(self);
|
|
9157
|
+
}
|
|
9158
|
+
return present;
|
|
9159
|
+
}
|
|
9160
|
+
/**
|
|
9161
|
+
* {@link PendingPartyKeyRotation.sealedTo}: the row's recipients still in the cadre. An envelope
|
|
9162
|
+
* that does not decode opens for nobody, so it lists none, logged; the rest of the listing stands.
|
|
9163
|
+
*/
|
|
9164
|
+
pendingKeyRecipientsPresent(strandId, row, present) {
|
|
9165
|
+
try {
|
|
9166
|
+
return partyKeyRecipients(row.sealedKey).filter((peerId) => present.has(peerId));
|
|
9167
|
+
}
|
|
9168
|
+
catch (error) {
|
|
9169
|
+
log('The pending party key of strand %s does not decode, so no machine can open it: %o', strandId, error);
|
|
9170
|
+
return [];
|
|
9171
|
+
}
|
|
9172
|
+
}
|
|
9148
9173
|
/** {@link closedStrandState} plus the strand reads only a pending replacement asks about; a read that fails is `unknown`, so one strand mid-teardown leaves the rest of the listing standing. */
|
|
9149
9174
|
async pendingRotationStrandState(strandId, partyKey, pendingPublicKey) {
|
|
9150
9175
|
const closed = await this.closedStrandState(strandId, partyKey);
|
|
@@ -9264,9 +9289,11 @@ export class CadreNode {
|
|
|
9264
9289
|
* key to seal to.
|
|
9265
9290
|
*
|
|
9266
9291
|
* NOTE: a machine admitted after the removal is not a recipient, so an owner machine enrolled
|
|
9267
|
-
* while a rotation is pending cannot drive it
|
|
9268
|
-
*
|
|
9269
|
-
*
|
|
9292
|
+
* while a rotation is pending cannot drive it or redeem the host's invitation under the new key;
|
|
9293
|
+
* a recipient owner machine has to. The app learns which machines those are from
|
|
9294
|
+
* {@link PendingPartyKeyRotation.sealedTo}. If a party is seen stuck that way, the remedy is the
|
|
9295
|
+
* replacement a second removal already writes (`ControlDatabase.removeMachine`), minted for the
|
|
9296
|
+
* machines present then.
|
|
9270
9297
|
*/
|
|
9271
9298
|
pendingPartyKeyRecipients(machines, removedPeerId) {
|
|
9272
9299
|
const recipients = new Map();
|