@plane31/blind-relay 0.2.0 → 0.3.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/adapters/index.d.ts +1 -0
- package/dist/adapters/index.d.ts.map +1 -1
- package/dist/adapters/index.js +1 -0
- package/dist/adapters/index.js.map +1 -1
- package/dist/client.d.ts +81 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +211 -19
- package/dist/client.js.map +1 -1
- package/dist/crypto/noble.d.ts.map +1 -1
- package/dist/crypto/noble.js +19 -1
- package/dist/crypto/noble.js.map +1 -1
- package/dist/errors.d.ts +1 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/store.d.ts +2 -0
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +2 -0
- package/dist/store.js.map +1 -1
- package/dist/testing/faults.d.ts +3 -1
- package/dist/testing/faults.d.ts.map +1 -1
- package/dist/testing/faults.js +3 -0
- package/dist/testing/faults.js.map +1 -1
- package/package.json +1 -1
- package/src/adapters/index.ts +1 -0
- package/src/client.ts +286 -20
- package/src/crypto/noble.ts +18 -1
- package/src/errors.ts +1 -0
- package/src/index.ts +5 -0
- package/src/store.ts +3 -0
- package/src/testing/faults.ts +5 -1
package/dist/adapters/index.d.ts
CHANGED
|
@@ -15,4 +15,5 @@ export { MemorySecretStore, MemoryStore, invokeSync, type ActivationRow, type Ce
|
|
|
15
15
|
export type { AppendOutcome, AppendStatus, CircleListing, CirclePage, Directory, EpochBundle, JoinRequest, MutationOutcome, MutationStatus, PreferenceOutcome, ReadRecordsResult, Relay, ResolvedAccount, SuccessionLink, SuccessionPage, Transport } from "../transport.js";
|
|
16
16
|
export type { BackupState, ProviderLoadResult, ProviderSaveResult, ProviderStatus, ProviderStatusResult, RecoveryProvider } from "../vault.js";
|
|
17
17
|
export { openStore, t1Activate, t1Header, t1Secrets, t3ApplyChange, type ChangeResult, type OpenedState } from "../transactions.js";
|
|
18
|
+
export { SECRET_NAMES } from "../store.js";
|
|
18
19
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/adapters/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAG9G,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,KAAK,EAAE,QAAQ,EAAE,sBAAsB,EAAE,QAAQ,EAAE,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAGzI,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAG1E,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,UAAU,EACV,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,MAAM,EACX,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,WAAW,EACjB,MAAM,aAAa,CAAC;AAGrB,OAAO,EACL,iBAAiB,EACjB,WAAW,EACX,UAAU,EACV,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,SAAS,EACd,KAAK,QAAQ,EACb,KAAK,QAAQ,EACb,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,kBAAkB,EACvB,KAAK,OAAO,EACZ,KAAK,SAAS,EACd,KAAK,YAAY,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ACV,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,SAAS,EACd,KAAK,MAAM,EACX,KAAK,EAAE,EACP,KAAK,aAAa,EAClB,KAAK,QAAQ,EACd,MAAM,aAAa,CAAC;AAGrB,YAAY,EACV,aAAa,EACb,YAAY,EACZ,aAAa,EACb,UAAU,EACV,SAAS,EACT,WAAW,EACX,WAAW,EACX,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,iBAAiB,EACjB,KAAK,EACL,eAAe,EACf,cAAc,EACd,cAAc,EACd,SAAS,EACV,MAAM,iBAAiB,CAAC;AAGzB,YAAY,EAAE,WAAW,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,cAAc,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAG/I,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,aAAa,EAAE,KAAK,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACpI,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/adapters/index.js
CHANGED
|
@@ -19,4 +19,5 @@ export { DocumentType, buildResetKeyList, buildResetReceipt, buildSuccession, ex
|
|
|
19
19
|
export { MemorySecretStore, MemoryStore, invokeSync, inKeyRange } from "../store.js";
|
|
20
20
|
// The transactions an adapter test drives against a store -----------------------------------------
|
|
21
21
|
export { openStore, t1Activate, t1Header, t1Secrets, t3ApplyChange } from "../transactions.js";
|
|
22
|
+
export { SECRET_NAMES } from "../store.js";
|
|
22
23
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/adapters/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,qGAAqG;AACrG,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE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AU,EACV,aAAa,EACb,gBAAgB,EAChB,cAAc,EAYf,MAAM,aAAa,CAAC;AAErB,qGAAqG;AACrG,OAAO,EACL,iBAAiB,EACjB,WAAW,EACX,UAAU,EAsBV,UAAU,EAoBX,MAAM,aAAa,CAAC;AAyBrB,oGAAoG;AACpG,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,aAAa,EAAuC,MAAM,oBAAoB,CAAC;AACpI,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/client.d.ts
CHANGED
|
@@ -178,6 +178,22 @@ export interface Client {
|
|
|
178
178
|
accountId?: Uint8Array;
|
|
179
179
|
limit?: number;
|
|
180
180
|
}): Promise<KeyChangeEntry[]>;
|
|
181
|
+
/**
|
|
182
|
+
* Account recovery as one call over `prepareReplacement` and `completeReplacement`, with the
|
|
183
|
+
* protocol's retry rules: an earlier proposal is settled through the chain first; the same
|
|
184
|
+
* proposal is kept through an unknown outcome and a refused authorization; a new proposal is
|
|
185
|
+
* made only after a definitive conflict, and then only by the next call. The product supplies
|
|
186
|
+
* `authorize`, which obtains the host's token for a proposal after its own fresh sign-in, or
|
|
187
|
+
* answers `"reauthenticate"` when it cannot. Attempts are bounded; `pending` means call again.
|
|
188
|
+
*/
|
|
189
|
+
replaceDevice(options: ReplaceDeviceOptions): Promise<ReplaceDeviceResult>;
|
|
190
|
+
/**
|
|
191
|
+
* Synchronise in rounds until nothing is left that this device can do now: the relay has no
|
|
192
|
+
* more records within the budget, bootstrap is complete, or progress needs someone else (an
|
|
193
|
+
* authorization, another person, metadata the host does not serve). Bounded by rounds and by
|
|
194
|
+
* time; the result says why it stopped and what remains.
|
|
195
|
+
*/
|
|
196
|
+
syncUntilDrained(options?: DrainOptions): Promise<DrainReport>;
|
|
181
197
|
/** A durable outbound record of a declared kind; the payload is the product's bytes, never read by the SDK. */
|
|
182
198
|
enqueue(kind: RecordKind, payload: Uint8Array, options?: EnqueueOptions): Promise<EnqueueResult>;
|
|
183
199
|
/** One synchronisation; `options.catchUp` bounds how much of a backlog this call reads (`SyncReport.inbox.hasMore` says when to call again). */
|
|
@@ -216,8 +232,73 @@ export interface Client {
|
|
|
216
232
|
}): Promise<{
|
|
217
233
|
identityId: Uint8Array;
|
|
218
234
|
}>;
|
|
235
|
+
/**
|
|
236
|
+
* Stop: no new operation is accepted (`CLOSED`), the operations in flight finish their current
|
|
237
|
+
* transaction and a running sync stops at its next phase boundary, then listeners are cleared
|
|
238
|
+
* so nothing is emitted afterwards. Closes nothing it did not open: the store and the secret
|
|
239
|
+
* store are the caller's. Idempotent.
|
|
240
|
+
*/
|
|
219
241
|
close(): Promise<void>;
|
|
220
242
|
}
|
|
243
|
+
export interface ReplaceDeviceOptions {
|
|
244
|
+
/** Obtain the host's authorization for this proposal after the product's fresh sign-in, or say that a sign-in is needed first. */
|
|
245
|
+
readonly authorize: (proposal: ReplacementProposal) => Promise<Uint8Array | "reauthenticate">;
|
|
246
|
+
/** Commit attempts per call, over unknown outcomes and refused authorizations. Default 3. */
|
|
247
|
+
readonly maxAttempts?: number;
|
|
248
|
+
}
|
|
249
|
+
export type ReplaceDeviceResult = {
|
|
250
|
+
readonly status: "activated";
|
|
251
|
+
readonly identityId: Uint8Array;
|
|
252
|
+
readonly generation: bigint;
|
|
253
|
+
}
|
|
254
|
+
/** The outcome is still unknown or the attempts are spent: the proposal is kept; call again. */
|
|
255
|
+
| {
|
|
256
|
+
readonly status: "pending";
|
|
257
|
+
readonly proposal: ReplacementProposal;
|
|
258
|
+
}
|
|
259
|
+
/** The account moved under the proposal, which is discarded; the next call prepares a new one after a fresh sign-in. */
|
|
260
|
+
| {
|
|
261
|
+
readonly status: "conflict";
|
|
262
|
+
readonly currentGeneration: bigint | undefined;
|
|
263
|
+
}
|
|
264
|
+
/** The product's `authorize` asked for a fresh sign-in; the proposal is kept for the next call. */
|
|
265
|
+
| {
|
|
266
|
+
readonly status: "reauthenticate";
|
|
267
|
+
readonly proposal: ReplacementProposal;
|
|
268
|
+
};
|
|
269
|
+
export interface DrainOptions {
|
|
270
|
+
readonly catchUp?: SyncOptions["catchUp"];
|
|
271
|
+
/** Rounds at most. Default 10. */
|
|
272
|
+
readonly maxRounds?: number;
|
|
273
|
+
/** A soft bound in milliseconds across every round: no round starts past it and each round's reading budget is the time left, but a transport call already in flight ends on its own timeout. Default 30,000. */
|
|
274
|
+
readonly maxMs?: number;
|
|
275
|
+
}
|
|
276
|
+
export type DrainStop =
|
|
277
|
+
/** Nothing is left that this device can do now. */
|
|
278
|
+
"drained" | "maxRounds" | "maxMs"
|
|
279
|
+
/** A round changed nothing and reported the same errors as the one before. */
|
|
280
|
+
| "noProgress"
|
|
281
|
+
/** Progress needs metadata the host does not serve yet (a chain, a certificate, the key list). */
|
|
282
|
+
| "metadata"
|
|
283
|
+
/** Progress needs an authorization or a sign-in (a prepared replacement, an account to recover). */
|
|
284
|
+
| "authentication"
|
|
285
|
+
/** Nothing more is reported, but a round could not read its inbox fully (discovery or a stream failed), so emptiness is not established. */
|
|
286
|
+
| "incomplete" | "closed";
|
|
287
|
+
/** The merged report of every round, with why the loop stopped and what remains. */
|
|
288
|
+
export interface DrainReport extends SyncReport {
|
|
289
|
+
readonly rounds: number;
|
|
290
|
+
readonly stoppedBecause: DrainStop;
|
|
291
|
+
readonly remaining: {
|
|
292
|
+
/** The relay still holds records this device has not read; `"unknown"` when the last round could not read its inbox fully. */
|
|
293
|
+
readonly inboxHasMore: boolean | "unknown";
|
|
294
|
+
/** Bootstrap after account recovery has circles left to adopt. */
|
|
295
|
+
readonly bootstrapIncomplete: boolean;
|
|
296
|
+
/** Contacts whose succession chain this device has verified only partly; the next rounds continue them. */
|
|
297
|
+
readonly chainsIncomplete: number;
|
|
298
|
+
/** Authors whose current epoch has not reached this device: nothing to do but wait for them. */
|
|
299
|
+
readonly waitingFor: number;
|
|
300
|
+
};
|
|
301
|
+
}
|
|
221
302
|
export interface SyncOptions {
|
|
222
303
|
/**
|
|
223
304
|
* The inbox budget of this sync, shared by every stream: at most this many records
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAOA,OAAO,EAA0G,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AACvJ,OAAO,EAA8I,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAGzL,OAAO,EAA8B,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAGzE,OAAO,EAA2I,KAAK,YAAY,EAAE,KAAK,WAAW,EAAE,KAAK,YAAY,EAAE,KAAK,MAAM,EAAmB,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AAC/Q,OAAO,EAA0D,KAAK,cAAc,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAC7H,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,2GAA2G;AAC3G,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAC;IAC9B,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;CAC7B;AACD,OAAO,EAA+D,KAAK,gBAAgB,EAAwB,MAAM,aAAa,CAAC;AACvI,OAAO,EAAc,KAAK,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE/D,OAAO,KAAK,EAA0E,WAAW,EAAE,KAAK,EAAgB,MAAM,YAAY,CAAC;AAG3I,OAAO,KAAK,EAAmC,eAAe,EAAkB,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAClH,OAAO,EAAuG,KAAK,oBAAoB,EAAE,KAAK,gBAAgB,EAAmB,MAAM,YAAY,CAAC;AAEpM,kFAAkF;AAClF,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAqBjG,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,qBAAqB,GAAG,OAAO,GAAG,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,9 @@ class ClientImpl {
|
|
|
84
84
|
selfPin;
|
|
85
85
|
trust;
|
|
86
86
|
syncing;
|
|
87
|
+
closed = false;
|
|
88
|
+
/** Every public operation in flight, so `close()` can wait for them. */
|
|
89
|
+
running = new Set();
|
|
87
90
|
/** The current sync's reading budget: records, and the links of a succession chain, count against it. */
|
|
88
91
|
syncBudget;
|
|
89
92
|
backupChecked = false;
|
|
@@ -99,16 +102,45 @@ class ClientImpl {
|
|
|
99
102
|
this.now = options.now ?? (() => BigInt(Date.now()));
|
|
100
103
|
this.trust = new ResetTrust(options.resetTrust);
|
|
101
104
|
this.circles = {
|
|
102
|
-
create: () => this.createCircle(),
|
|
103
|
-
requestJoin: (c, o, opts) => this.requestJoin(c, o, opts?.shareOnApproval ?? true),
|
|
104
|
-
approve: (c, n) => this.approve(c, n),
|
|
105
|
-
remove: (c, m) => this.changeMembership(c, { remove: m }),
|
|
106
|
-
leave: (c) => this.leave(c),
|
|
107
|
-
setEnabled: (c, e) => this.setEnabled(c, e),
|
|
108
|
-
closeCircle: (c) => this.closeCircle(c),
|
|
105
|
+
create: () => this.track("createCircle", () => this.createCircle()),
|
|
106
|
+
requestJoin: (c, o, opts) => this.track("requestJoin", () => this.requestJoin(c, o, opts?.shareOnApproval ?? true)),
|
|
107
|
+
approve: (c, n) => this.track("approve", () => this.approve(c, n)),
|
|
108
|
+
remove: (c, m) => this.track("changeMembership", () => this.changeMembership(c, { remove: m })),
|
|
109
|
+
leave: (c) => this.track("leave", () => this.leave(c)),
|
|
110
|
+
setEnabled: (c, e) => this.track("setEnabled", () => this.setEnabled(c, e)),
|
|
111
|
+
closeCircle: (c) => this.track("closeCircle", () => this.closeCircle(c)),
|
|
109
112
|
list: () => this.listCircles()
|
|
110
113
|
};
|
|
111
114
|
}
|
|
115
|
+
// Every public operation that writes enters through `track`, explicitly and typed, so `close()`
|
|
116
|
+
// refuses new ones and waits for those in flight. Reads stay untracked.
|
|
117
|
+
initializeAccount() {
|
|
118
|
+
return this.track("initializeAccount", () => this.initializeAccountNow());
|
|
119
|
+
}
|
|
120
|
+
restoreAccount(recoveryCode) {
|
|
121
|
+
return this.track("restoreAccount", () => this.restoreAccountNow(recoveryCode));
|
|
122
|
+
}
|
|
123
|
+
enqueue(kind, payload, options = {}) {
|
|
124
|
+
return this.track("enqueue", () => this.enqueueNow(kind, payload, options));
|
|
125
|
+
}
|
|
126
|
+
receive(wire) {
|
|
127
|
+
return this.track("receive", () => receiveRecord(this.inboxDeps(), wire));
|
|
128
|
+
}
|
|
129
|
+
prepareReplacement() {
|
|
130
|
+
return this.track("prepareReplacement", () => this.prepareReplacementNow());
|
|
131
|
+
}
|
|
132
|
+
completeReplacement(input) {
|
|
133
|
+
return this.track("completeReplacement", () => this.completeReplacementNow(input));
|
|
134
|
+
}
|
|
135
|
+
resetAccount(options) {
|
|
136
|
+
return this.track("resetAccount", () => this.resetAccountNow(options));
|
|
137
|
+
}
|
|
138
|
+
replaceDevice(options) {
|
|
139
|
+
return this.track("replaceDevice", () => this.replaceDeviceNow(options));
|
|
140
|
+
}
|
|
141
|
+
syncUntilDrained(options = {}) {
|
|
142
|
+
return this.track("syncUntilDrained", () => this.drainNow(options));
|
|
143
|
+
}
|
|
112
144
|
// Loading ---------------------------------------------------------------------------------------
|
|
113
145
|
async load() {
|
|
114
146
|
await this.finishInterruptedReset();
|
|
@@ -143,8 +175,19 @@ class ClientImpl {
|
|
|
143
175
|
retired: rows.retired
|
|
144
176
|
});
|
|
145
177
|
}
|
|
146
|
-
/**
|
|
178
|
+
/** Refuse after `close()`, and keep the operation's promise until it settles. */
|
|
179
|
+
track(stage, fn) {
|
|
180
|
+
if (this.closed)
|
|
181
|
+
return Promise.reject(new KavachError("CLOSED", stage, "the client is closed"));
|
|
182
|
+
const p = fn();
|
|
183
|
+
this.running.add(p);
|
|
184
|
+
void p.finally(() => this.running.delete(p)).catch(() => undefined);
|
|
185
|
+
return p;
|
|
186
|
+
}
|
|
187
|
+
/** Each listener on its own: a throwing subscriber affects neither the other listeners nor the protocol. Nothing after `close()`. */
|
|
147
188
|
emit(event) {
|
|
189
|
+
if (this.closed)
|
|
190
|
+
return;
|
|
148
191
|
for (const l of this.listeners) {
|
|
149
192
|
try {
|
|
150
193
|
l(event);
|
|
@@ -284,7 +327,7 @@ class ClientImpl {
|
|
|
284
327
|
});
|
|
285
328
|
}
|
|
286
329
|
// Enrollment ------------------------------------------------------------------------------------
|
|
287
|
-
async
|
|
330
|
+
async initializeAccountNow() {
|
|
288
331
|
const stage = "initializeAccount";
|
|
289
332
|
const opened = await openStore(this.store, this.secrets, this.accountName);
|
|
290
333
|
if (opened.kind !== "fresh" && opened.kind !== "initializing")
|
|
@@ -351,7 +394,7 @@ class ClientImpl {
|
|
|
351
394
|
throw new KavachError("ACCOUNT_RECOVERY_REQUIRED", "recoveryCode");
|
|
352
395
|
return encodeRecoveryCode(key);
|
|
353
396
|
}
|
|
354
|
-
async
|
|
397
|
+
async restoreAccountNow(recoveryCode) {
|
|
355
398
|
const stage = "restoreAccount";
|
|
356
399
|
const opened = await openStore(this.store, this.secrets, this.accountName);
|
|
357
400
|
if (opened.kind === "ACTIVE" || opened.kind === "RETIRED")
|
|
@@ -528,7 +571,7 @@ class ClientImpl {
|
|
|
528
571
|
this.emit({ kind: "stateChanged", state: await this.getState() });
|
|
529
572
|
}
|
|
530
573
|
// Sending ---------------------------------------------------------------------------------------
|
|
531
|
-
async
|
|
574
|
+
async enqueueNow(kind, payload, options) {
|
|
532
575
|
const deps = this.outboxDeps();
|
|
533
576
|
// A key answered before anything that may need the network: the record it names is already
|
|
534
577
|
// durable, so a retry offline, or with a rotation due, returns it. The outbox checks the key
|
|
@@ -658,11 +701,109 @@ class ClientImpl {
|
|
|
658
701
|
async sync(options = {}) {
|
|
659
702
|
if (this.syncing)
|
|
660
703
|
return this.syncing;
|
|
661
|
-
|
|
704
|
+
if (this.closed)
|
|
705
|
+
throw new KavachError("CLOSED", "sync", "the client is closed");
|
|
706
|
+
this.syncing = this.track("sync", () => this.runSync(options)).finally(() => {
|
|
662
707
|
this.syncing = undefined;
|
|
663
708
|
});
|
|
664
709
|
return this.syncing;
|
|
665
710
|
}
|
|
711
|
+
async drainNow(options) {
|
|
712
|
+
const maxRounds = Math.max(1, Math.floor(options.maxRounds ?? 10));
|
|
713
|
+
const maxMs = Math.max(0, Math.floor(options.maxMs ?? 30_000));
|
|
714
|
+
const deadline = this.now() + BigInt(maxMs);
|
|
715
|
+
const merged = {
|
|
716
|
+
metadata: { certificates: 0, snapshots: 0, rotations: 0, quarantined: 0, resets: 0, successions: 0 },
|
|
717
|
+
epoch: "unchanged",
|
|
718
|
+
outbox: { sent: 0, accepted: 0, cancelled: 0, unknown: 0, retry: 0 },
|
|
719
|
+
inbox: { streams: 0, stored: 0, keyPending: 0, invalid: 0, acked: 0, hasMore: false },
|
|
720
|
+
purged: 0,
|
|
721
|
+
errors: []
|
|
722
|
+
};
|
|
723
|
+
let rounds = 0;
|
|
724
|
+
let previousErrors;
|
|
725
|
+
let stop = "drained";
|
|
726
|
+
let last;
|
|
727
|
+
// An inbox this device could not fully read this round: discovery or a stream failed, or metadata it
|
|
728
|
+
// depends on did. Such a round never establishes that the inbox is empty.
|
|
729
|
+
const inboxUncertain = (r) => r.errors.some((e) => e.operation === "listSubscriptions" || e.operation === "inbox" || e.operation === "metadata");
|
|
730
|
+
// Chains verified only partly: remaining work, and their cursors moving is progress.
|
|
731
|
+
const chains = () => this.store.read((tx) => new Map(tx.list("chainProgress").filter(([, c]) => !c.complete).map(([k, c]) => [k, c.nextGeneration])));
|
|
732
|
+
let previousChains = await chains();
|
|
733
|
+
for (;;) {
|
|
734
|
+
if (this.closed) {
|
|
735
|
+
stop = "closed";
|
|
736
|
+
break;
|
|
737
|
+
}
|
|
738
|
+
// The time left is this round's reading budget too, so a round never starts work the deadline
|
|
739
|
+
// does not cover; a transport call already in flight ends on its own timeout.
|
|
740
|
+
const remainingMs = Number(deadline - this.now());
|
|
741
|
+
if (rounds > 0 && remainingMs <= 0) {
|
|
742
|
+
stop = "maxMs";
|
|
743
|
+
break;
|
|
744
|
+
}
|
|
745
|
+
const roundMs = Math.max(0, Math.min(remainingMs, options.catchUp?.maxMs ?? DEFAULT_CATCH_UP.maxMs));
|
|
746
|
+
const r = await this.sync({ catchUp: { maxMs: roundMs, ...(options.catchUp?.maxRecords !== undefined ? { maxRecords: options.catchUp.maxRecords } : {}) } });
|
|
747
|
+
rounds++;
|
|
748
|
+
last = r;
|
|
749
|
+
// The round's work counts whether or not it was the last: what it accepted, stored and failed
|
|
750
|
+
// is merged first, and only then is a close that landed meanwhile reported.
|
|
751
|
+
for (const k of Object.keys(merged.metadata))
|
|
752
|
+
merged.metadata[k] += r.metadata[k];
|
|
753
|
+
for (const k of Object.keys(merged.outbox))
|
|
754
|
+
merged.outbox[k] += r.outbox[k];
|
|
755
|
+
merged.inbox.streams += r.inbox.streams;
|
|
756
|
+
merged.inbox.stored += r.inbox.stored;
|
|
757
|
+
merged.inbox.keyPending += r.inbox.keyPending;
|
|
758
|
+
merged.inbox.invalid += r.inbox.invalid;
|
|
759
|
+
merged.inbox.acked += r.inbox.acked;
|
|
760
|
+
merged.purged += r.purged;
|
|
761
|
+
merged.epoch = r.epoch;
|
|
762
|
+
merged.errors.push(...r.errors);
|
|
763
|
+
if (r.bootstrap)
|
|
764
|
+
merged.bootstrap = r.bootstrap;
|
|
765
|
+
if (this.closed) {
|
|
766
|
+
// The round may have stopped at a boundary before its inbox: nothing it reports is complete.
|
|
767
|
+
stop = "closed";
|
|
768
|
+
break;
|
|
769
|
+
}
|
|
770
|
+
const bootstrapIncomplete = (await this.inspect()).bootstrap?.complete === false;
|
|
771
|
+
const currentChains = await chains();
|
|
772
|
+
const more = r.inbox.hasMore || bootstrapIncomplete || currentChains.size > 0;
|
|
773
|
+
const status = (await this.getState()).status;
|
|
774
|
+
if (status === "replacementPrepared" || status === "accountRecoveryRequired") {
|
|
775
|
+
stop = "authentication";
|
|
776
|
+
break;
|
|
777
|
+
}
|
|
778
|
+
if (!more) {
|
|
779
|
+
stop = inboxUncertain(r) ? "incomplete" : "drained";
|
|
780
|
+
break;
|
|
781
|
+
}
|
|
782
|
+
const signature = r.errors.map((e) => `${e.operation}:${e.code}`).sort().join(",");
|
|
783
|
+
const chainsAdvanced = [...currentChains].some(([k, next]) => previousChains.get(k) !== next) || [...previousChains.keys()].some((k) => !currentChains.has(k));
|
|
784
|
+
previousChains = currentChains;
|
|
785
|
+
const changed = chainsAdvanced || r.inbox.stored + r.metadata.certificates + r.metadata.snapshots + r.metadata.successions + (r.bootstrap?.circles ?? 0) + (r.bootstrap?.pending ?? 0) > 0;
|
|
786
|
+
if (!changed && signature !== "" && signature === previousErrors) {
|
|
787
|
+
stop = r.errors.some((e) => e.code === "METADATA_REQUIRED" || e.code === "RESET_KEYS_REQUIRED" || e.code === "RESET_CLOCK_UNTRUSTED") ? "metadata" : "noProgress";
|
|
788
|
+
break;
|
|
789
|
+
}
|
|
790
|
+
previousErrors = signature;
|
|
791
|
+
if (rounds >= maxRounds) {
|
|
792
|
+
stop = "maxRounds";
|
|
793
|
+
break;
|
|
794
|
+
}
|
|
795
|
+
if (this.now() >= deadline) {
|
|
796
|
+
stop = "maxMs";
|
|
797
|
+
break;
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
merged.inbox.hasMore = last?.inbox.hasMore ?? false;
|
|
801
|
+
const bootstrapIncomplete = this.closed ? false : (await this.inspect()).bootstrap?.complete === false;
|
|
802
|
+
const chainsIncomplete = this.closed ? previousChains.size : (await chains()).size;
|
|
803
|
+
const waitingFor = this.closed ? 0 : (await this.getState()).waitingFor.length;
|
|
804
|
+
const inboxHasMore = !last || inboxUncertain(last) || stop === "closed" ? "unknown" : merged.inbox.hasMore;
|
|
805
|
+
return { ...merged, rounds, stoppedBecause: stop, remaining: { inboxHasMore, bootstrapIncomplete, chainsIncomplete, waitingFor } };
|
|
806
|
+
}
|
|
666
807
|
async runSync(options) {
|
|
667
808
|
const report = {
|
|
668
809
|
metadata: { certificates: 0, snapshots: 0, rotations: 0, quarantined: 0, resets: 0, successions: 0 },
|
|
@@ -743,7 +884,7 @@ class ClientImpl {
|
|
|
743
884
|
report.errors.push(syncError("preference", e));
|
|
744
885
|
}
|
|
745
886
|
const after = await this.store.read((tx) => tx.get("meta", META));
|
|
746
|
-
if (after?.state === "RETIRED")
|
|
887
|
+
if (after?.state === "RETIRED" || this.closed)
|
|
747
888
|
return report;
|
|
748
889
|
try {
|
|
749
890
|
report.epoch = await this.ensureEpoch();
|
|
@@ -751,12 +892,16 @@ class ClientImpl {
|
|
|
751
892
|
catch (e) {
|
|
752
893
|
report.errors.push(syncError("epoch", e));
|
|
753
894
|
}
|
|
895
|
+
if (this.closed)
|
|
896
|
+
return report;
|
|
754
897
|
try {
|
|
755
898
|
report.outbox = await drain(this.outboxDeps());
|
|
756
899
|
}
|
|
757
900
|
catch (e) {
|
|
758
901
|
report.errors.push(syncError("outbox", e));
|
|
759
902
|
}
|
|
903
|
+
if (this.closed)
|
|
904
|
+
return report;
|
|
760
905
|
let subs = [];
|
|
761
906
|
try {
|
|
762
907
|
subs = await this.transport.relay.listSubscriptions();
|
|
@@ -771,6 +916,8 @@ class ClientImpl {
|
|
|
771
916
|
if (budget.remainingRecords < 1)
|
|
772
917
|
budget.remainingRecords = 1; // every stream reads at least one page
|
|
773
918
|
for (const s of subs) {
|
|
919
|
+
if (this.closed)
|
|
920
|
+
return report;
|
|
774
921
|
try {
|
|
775
922
|
const known = await this.store.read((tx) => tx.list("certificates").some(([, c]) => c.streamId === toHex(s.streamId)));
|
|
776
923
|
if (!known)
|
|
@@ -1383,9 +1530,6 @@ class ClientImpl {
|
|
|
1383
1530
|
await this.emitState();
|
|
1384
1531
|
}
|
|
1385
1532
|
// Receiving and reads ---------------------------------------------------------------------------
|
|
1386
|
-
receive(wire) {
|
|
1387
|
-
return receiveRecord(this.inboxDeps(), wire);
|
|
1388
|
-
}
|
|
1389
1533
|
history(query) {
|
|
1390
1534
|
return history(this.store, this.policy, query);
|
|
1391
1535
|
}
|
|
@@ -1760,7 +1904,7 @@ class ClientImpl {
|
|
|
1760
1904
|
await this.changeMembership(circleId, { close: true });
|
|
1761
1905
|
}
|
|
1762
1906
|
// Account recovery (amendment A1) ---------------------------------------------------------------
|
|
1763
|
-
async
|
|
1907
|
+
async prepareReplacementNow() {
|
|
1764
1908
|
const stage = "prepareReplacement";
|
|
1765
1909
|
if (!acceptsSuccession(this.policy))
|
|
1766
1910
|
throw new KavachError("NOT_AUTHORIZED", stage, "this deployment does not use account recovery");
|
|
@@ -1808,7 +1952,7 @@ class ClientImpl {
|
|
|
1808
1952
|
await this.emitState();
|
|
1809
1953
|
return proposalOf(row);
|
|
1810
1954
|
}
|
|
1811
|
-
async
|
|
1955
|
+
async completeReplacementNow(input) {
|
|
1812
1956
|
const stage = "completeReplacement";
|
|
1813
1957
|
// Already activated (by an earlier call, or by a sync that found the commit on the chain): idempotent.
|
|
1814
1958
|
if (this.selfPin && this.account && !this.retired)
|
|
@@ -2088,7 +2232,7 @@ class ClientImpl {
|
|
|
2088
2232
|
return state.status === "requested" ? "pending" : "member";
|
|
2089
2233
|
}
|
|
2090
2234
|
// Reset -----------------------------------------------------------------------------------------
|
|
2091
|
-
async
|
|
2235
|
+
async resetAccountNow(options) {
|
|
2092
2236
|
const stage = "resetAccount";
|
|
2093
2237
|
if (!options.confirmed)
|
|
2094
2238
|
throw new KavachError("NOT_AUTHORIZED", stage, "reset requires confirmation");
|
|
@@ -2177,7 +2321,55 @@ class ClientImpl {
|
|
|
2177
2321
|
await this.finishReset("load", row, roots);
|
|
2178
2322
|
}
|
|
2179
2323
|
async close() {
|
|
2324
|
+
this.closed = true;
|
|
2325
|
+
// Everything in flight finishes its current transaction; a sync stops at its next boundary.
|
|
2326
|
+
while (this.running.size > 0)
|
|
2327
|
+
await Promise.allSettled([...this.running]);
|
|
2180
2328
|
this.listeners.clear();
|
|
2181
2329
|
}
|
|
2330
|
+
// The replacement helper ------------------------------------------------------------------------
|
|
2331
|
+
async replaceDeviceNow(options) {
|
|
2332
|
+
const maxAttempts = Math.max(1, Math.floor(options.maxAttempts ?? 3));
|
|
2333
|
+
const activated = () => (this.selfPin && this.account && !this.retired ? { status: "activated", identityId: this.selfPin.identityId, generation: this.selfPin.generation } : undefined);
|
|
2334
|
+
const done = activated();
|
|
2335
|
+
if (done)
|
|
2336
|
+
return done;
|
|
2337
|
+
// A proposal left by an earlier run may have committed: the chain settles it before anything else.
|
|
2338
|
+
const existing = await this.store.read((tx) => tx.get("replacement", "pending"));
|
|
2339
|
+
if (existing && !existing.stale) {
|
|
2340
|
+
await this.sync();
|
|
2341
|
+
const settled = activated();
|
|
2342
|
+
if (settled)
|
|
2343
|
+
return settled;
|
|
2344
|
+
}
|
|
2345
|
+
const proposal = await this.prepareReplacementNow();
|
|
2346
|
+
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
2347
|
+
const authorization = await options.authorize(proposal);
|
|
2348
|
+
if (authorization === "reauthenticate")
|
|
2349
|
+
return { status: "reauthenticate", proposal };
|
|
2350
|
+
for (;;) {
|
|
2351
|
+
try {
|
|
2352
|
+
const r = await this.completeReplacementNow({ successionId: proposal.successionId, authorization });
|
|
2353
|
+
return { status: "activated", identityId: r.identityId, generation: r.generation };
|
|
2354
|
+
}
|
|
2355
|
+
catch (e) {
|
|
2356
|
+
if (isKavachError(e, "SUCCESSION_PENDING")) {
|
|
2357
|
+
// The same call again with the same bytes; the host answers a committed id first.
|
|
2358
|
+
if (++attempt >= maxAttempts)
|
|
2359
|
+
return { status: "pending", proposal };
|
|
2360
|
+
continue;
|
|
2361
|
+
}
|
|
2362
|
+
if (isKavachError(e, "AUTHORIZATION_REQUIRED"))
|
|
2363
|
+
break; // a fresh token for the same proposal
|
|
2364
|
+
if (isKavachError(e, "REPLACEMENT_CONFLICT")) {
|
|
2365
|
+
const conflict = (await this.inspect()).replacement;
|
|
2366
|
+
return { status: "conflict", currentGeneration: conflict?.conflictGeneration };
|
|
2367
|
+
}
|
|
2368
|
+
throw e;
|
|
2369
|
+
}
|
|
2370
|
+
}
|
|
2371
|
+
}
|
|
2372
|
+
return { status: "pending", proposal };
|
|
2373
|
+
}
|
|
2182
2374
|
}
|
|
2183
2375
|
//# sourceMappingURL=client.js.map
|