@cero-base/core 1.18.2 → 1.19.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.
Files changed (46) hide show
  1. package/README.md +5 -6
  2. package/package.json +8 -8
  3. package/src/blobs/index.js +2 -2
  4. package/src/database/changes.js +37 -59
  5. package/src/database/dispatch.js +31 -45
  6. package/src/database/index.js +395 -343
  7. package/src/database/rotation.js +201 -189
  8. package/src/identity/index.js +3 -3
  9. package/src/lib/utils.js +50 -18
  10. package/src/pairing/candidate.js +125 -0
  11. package/src/pairing/index.js +6 -223
  12. package/src/pairing/request.js +102 -0
  13. package/src/storage/index.js +11 -18
  14. package/types/blobs/codec.d.ts +8 -8
  15. package/types/blobs/index.d.ts +34 -33
  16. package/types/blobs/server.d.ts +8 -8
  17. package/types/database/changes.d.ts +5 -7
  18. package/types/database/dispatch.d.ts +30 -23
  19. package/types/database/encryption.d.ts +14 -10
  20. package/types/database/envelope.d.ts +2 -2
  21. package/types/database/index.d.ts +173 -181
  22. package/types/database/rotation.d.ts +53 -30
  23. package/types/identity/index.d.ts +81 -81
  24. package/types/index.d.ts +37 -51
  25. package/types/lib/constants.d.ts +34 -38
  26. package/types/lib/errors.d.ts +10 -10
  27. package/types/lib/schema.d.ts +47 -37
  28. package/types/lib/spec/index.d.ts +29 -55
  29. package/types/lib/utils.d.ts +27 -17
  30. package/types/network/discovery.d.ts +7 -7
  31. package/types/network/index.d.ts +50 -48
  32. package/types/pairing/candidate.d.ts +37 -0
  33. package/types/pairing/index.d.ts +87 -139
  34. package/types/pairing/invite.d.ts +88 -88
  35. package/types/pairing/request.d.ts +135 -0
  36. package/types/rpc/client.d.ts +2 -2
  37. package/types/rpc/index.d.ts +33 -33
  38. package/types/rpc/peer.d.ts +9 -7
  39. package/types/rpc/server.d.ts +2 -2
  40. package/types/storage/index.d.ts +70 -68
  41. package/src/database/bootstrap.js +0 -133
  42. package/src/database/hooks.js +0 -112
  43. package/src/database/membership.js +0 -67
  44. package/types/database/bootstrap.d.ts +0 -20
  45. package/types/database/hooks.d.ts +0 -8
  46. package/types/database/membership.d.ts +0 -7
@@ -1,3 +1,95 @@
1
+ import ReadyResource from 'ready-resource';
2
+ import { EpochAutobee, Keyring } from './encryption.js';
3
+ import { Identity } from '../identity/index.js';
4
+ import { Rotation } from './rotation.js';
5
+ export type DatabaseOpts = {
6
+ /**
7
+ * Corestore (or compatible) used to materialize the autobee.
8
+ */
9
+ store: any;
10
+ /**
11
+ * Long-lived member identity used to sign writer changes.
12
+ */
13
+ identity: import('../identity/index.js').Identity;
14
+ /**
15
+ * Optional swarm; required for multi-writer replication.
16
+ */
17
+ network?: import('../network/index.js').Network;
18
+ /**
19
+ * Generated hyperdb + hyperdispatch spec.
20
+ */
21
+ spec: {
22
+ database: any;
23
+ dispatch: any;
24
+ meta?: {
25
+ ns?: string;
26
+ refs?: Record<string, {
27
+ kind?: string;
28
+ verb?: string;
29
+ }>;
30
+ };
31
+ };
32
+ /**
33
+ * Custom action handlers keyed by route name.
34
+ */
35
+ routes?: Record<string, Function>;
36
+ /**
37
+ * Corestore namespace; defaults to `cero`.
38
+ */
39
+ namespace?: string;
40
+ /**
41
+ * Optional encryption key; falls back to identity's key.
42
+ */
43
+ encryptionKey?: Uint8Array | null;
44
+ /**
45
+ * Rotation epochs to prime the keyring with (delivered at join).
46
+ */
47
+ epochs?: Array<{
48
+ epoch: number;
49
+ entropy: Uint8Array;
50
+ }> | null;
51
+ /**
52
+ * Existing autobee key to reopen.
53
+ */
54
+ key?: Uint8Array | null;
55
+ /**
56
+ * Join discovery server-only (reachable but not searching). Flip at runtime with `setActive`.
57
+ */
58
+ passive?: boolean;
59
+ /**
60
+ * This device's writer keypair; a fresh random one by default. Never the identity's, never the database key.
61
+ */
62
+ keyPair?: import('../identity/index.js').KeyPair;
63
+ /**
64
+ * Called when a background after-hook or onApply callback fails, a malformed node is skipped, or the bee errors.
65
+ */
66
+ onerror?: (err: Error) => void;
67
+ };
68
+ export type SingleResult = {
69
+ data: any | null;
70
+ };
71
+ export type ListResult = {
72
+ data: any[];
73
+ total: number | null;
74
+ size: number;
75
+ };
76
+ export type Query = {
77
+ gt?: string;
78
+ gte?: string;
79
+ lt?: string;
80
+ lte?: string;
81
+ reverse?: boolean;
82
+ limit?: number;
83
+ search?: string;
84
+ fields?: string[];
85
+ total?: boolean;
86
+ };
87
+ export type Ref = {
88
+ kind: string;
89
+ verb: string;
90
+ name: string;
91
+ };
92
+ export type HookFn = (ctx: any) => any | Promise<any>;
1
93
  /**
2
94
  * @typedef {object} DatabaseOpts
3
95
  * @property {any} store Corestore (or compatible) used to materialize the autobee.
@@ -8,10 +100,9 @@
8
100
  * @property {string} [namespace] Corestore namespace; defaults to `cero`.
9
101
  * @property {Uint8Array | null} [encryptionKey] Optional encryption key; falls back to identity's key.
10
102
  * @property {Array<{ epoch: number, entropy: Uint8Array }> | null} [epochs] Rotation epochs to prime the keyring with (delivered at join).
11
- * @property {(nodes: any, view: any, host: any) => Promise<void>} [apply] Override the default apply function.
12
103
  * @property {Uint8Array | null} [key] Existing autobee key to reopen.
13
104
  * @property {boolean} [passive] Join discovery server-only (reachable but not searching). Flip at runtime with `setActive`.
14
- * @property {import('../identity/index.js').KeyPair} [keyPair] Device writer keypair; defaults to identity's keypair.
105
+ * @property {import('../identity/index.js').KeyPair} [keyPair] This device's writer keypair; a fresh random one by default. Never the identity's, never the database key.
15
106
  * @property {(err: Error) => void} [onerror] Called when a background after-hook or onApply callback fails, a malformed node is skipped, or the bee errors.
16
107
  *
17
108
  * @typedef {{ data: any | null }} SingleResult
@@ -23,14 +114,12 @@
23
114
  /**
24
115
  * Multi-writer database built on Autobee + HyperDB. Persists rows via a
25
116
  * hyperdispatch-encoded log and exposes a `put/get/...` surface mirroring
26
- * `Storage`, plus membership ops (claim/addWriter/removeWriter) for the
117
+ * `Storage`, plus writer ops (claim/addWriter/removeWriter) for the
27
118
  * shared writer set.
28
119
  */
29
- export class Database extends ReadyResource {
30
- /** @param {Partial<DatabaseOpts>} [opts] */
31
- constructor(opts?: Partial<DatabaseOpts>);
120
+ export declare class Database extends ReadyResource {
32
121
  store: any;
33
- identity: import("../index.js").Identity;
122
+ identity: Identity;
34
123
  network: import("../index.js").Network;
35
124
  spec: {
36
125
  database: any;
@@ -56,21 +145,15 @@ export class Database extends ReadyResource {
56
145
  verb?: string;
57
146
  }>;
58
147
  version: any;
59
- behind: number;
148
+ behind: any;
60
149
  routes: Record<string, Function>;
61
150
  namespace: string;
62
151
  encryptionKey: Uint8Array<ArrayBufferLike>;
63
152
  keyring: Keyring;
64
- _rotation: any;
65
- _healTimer: any;
66
- _healedFor: any;
67
- applyOverride: (nodes: any, view: any, host: any) => Promise<void>;
153
+ rotation: Rotation;
68
154
  key: Uint8Array<ArrayBufferLike>;
69
155
  passive: boolean;
70
- keyPair: import("../index.js").KeyPair | {
71
- publicKey: Uint8Array<ArrayBufferLike>;
72
- secretKey: Uint8Array<ArrayBufferLike>;
73
- };
156
+ keyPair: import("../index.js").KeyPair;
74
157
  _onerror: any;
75
158
  bee: EpochAutobee;
76
159
  dispatcher: {
@@ -80,16 +163,26 @@ export class Database extends ReadyResource {
80
163
  key: Buffer;
81
164
  }>, view: object, host: object) => Promise<void>;
82
165
  };
83
- beforeHooks: Map<any, any>;
84
- afterHooks: Map<any, any>;
85
- updaters: Map<any, any>;
86
- onApplyHooks: Set<any>;
87
- _applySeq: number;
166
+ _discovery: import("../network/discovery.js").Discovery;
167
+ _txChain: any;
168
+ _before: Map<any, any>;
169
+ _after: Map<any, any>;
170
+ _updaters: Map<any, any>;
171
+ _observers: Set<any>;
172
+ _verbs: Map<any, any>;
88
173
  _touched: Set<any>;
174
+ _seq: number;
89
175
  txQueue: any;
90
- _discovery: import("../network/discovery.js").Discovery;
91
- /** Open the underlying autobee, wire dispatcher + apply, attach to network. */
92
- openBee(): Promise<void>;
176
+ /** @param {Partial<DatabaseOpts>} [opts] */
177
+ constructor(opts?: Partial<DatabaseOpts>);
178
+ _open(): Promise<void>;
179
+ _close(): Promise<void>;
180
+ _preload(): Promise<void>;
181
+ _boot(): Promise<void>;
182
+ _replay(): Promise<boolean>;
183
+ _isTrusted(writer: any, view: any): Promise<any>;
184
+ _apply(nodes: any, view: any, host: any): Promise<void>;
185
+ _update(db: any): Promise<void>;
93
186
  _joinSwarm(bee: any, discoveryKey: any): void;
94
187
  /**
95
188
  * Flip announce mode at runtime — passive stays reachable (server) but
@@ -150,22 +243,15 @@ export class Database extends ReadyResource {
150
243
  writerKey: any;
151
244
  seq: number;
152
245
  }) => void): () => void;
153
- /**
154
- * Run all registered `before:op` hooks and emit the corresponding event.
155
- *
156
- * @param {string} op
157
- * @param {any} ctx
158
- * @returns {Promise<boolean>} `false` if any hook vetoed the op
159
- */
160
- runBefore(op: string, ctx: any): Promise<boolean>;
161
- /**
162
- * Run all registered `after:op` hooks and emit the corresponding event.
163
- *
164
- * @param {string} op
165
- * @param {any} ctx
166
- * @returns {Promise<void>}
167
- */
168
- runAfter(op: string, ctx: any): Promise<void>;
246
+ _runBefore(op: any, ctx: any): Promise<boolean>;
247
+ _runAfter(op: any, ctx: any): Promise<void>;
248
+ _opOf(node: any): {
249
+ op: any;
250
+ name: any;
251
+ value: any;
252
+ };
253
+ _touch(nodes: any): void;
254
+ _observe(nodes: any): void;
169
255
  /**
170
256
  * Insert (or overwrite by id) a row, stamping `id`/`createdAt`/`updatedAt`.
171
257
  *
@@ -184,9 +270,16 @@ export class Database extends ReadyResource {
184
270
  * @param {{ upsert?: boolean }} [opts]
185
271
  * @returns {Promise<SingleResult | null>}
186
272
  */
187
- set(name: string, row: Record<string, any>, { upsert }?: {
273
+ set(name: string, row: Record<string, any>, opts?: {
188
274
  upsert?: boolean;
189
275
  }): Promise<SingleResult | null>;
276
+ _merge(name: any, row: any, { upsert }?: {
277
+ upsert?: boolean;
278
+ }): Promise<{
279
+ op: string;
280
+ name: any;
281
+ row: any;
282
+ }>;
190
283
  /**
191
284
  * Delete by id (collection) or wipe the whole single-row table.
192
285
  *
@@ -213,11 +306,10 @@ export class Database extends ReadyResource {
213
306
  *
214
307
  * @returns {Promise<{ epoch: number }>}
215
308
  */
216
- rotate(retried?: boolean): Promise<{
309
+ rotate(): Promise<{
217
310
  epoch: number;
218
311
  }>;
219
- _onepoch(row: any): Promise<void>;
220
- _loadEpochs(): Promise<void>;
312
+ _onfuture(version: any): void;
221
313
  /**
222
314
  * Batch every write made through the transaction handle passed to `fn`
223
315
  * into a single autobee append. The handle is this database with its own
@@ -232,7 +324,6 @@ export class Database extends ReadyResource {
232
324
  * @returns {Promise<T>}
233
325
  */
234
326
  tx<T>(fn: (tx: Database) => Promise<T> | T): Promise<T>;
235
- _txChain: any;
236
327
  /**
237
328
  * Encode and append dispatch ops. Buffers into the active `tx` queue if one
238
329
  * is open.
@@ -241,17 +332,7 @@ export class Database extends ReadyResource {
241
332
  * @returns {Promise<void>}
242
333
  */
243
334
  write(ops: Array<[string, any]>): Promise<void>;
244
- /**
245
- * Validate ops against the committed view before appending: each op runs in
246
- * a throwaway transaction with host effects stubbed, so a throwing handler
247
- * rejects the write and nothing enters the permanent log. Permission gates
248
- * that `return` are not rejections — apply stays the authority at
249
- * linearization time.
250
- *
251
- * @param {Uint8Array[]} encoded
252
- * @returns {Promise<boolean>} whether the ops change anything
253
- */
254
- _dryRun(encoded: Uint8Array[]): Promise<boolean>;
335
+ _dryRun(encoded: any): Promise<any>;
255
336
  /**
256
337
  * Read a row. With no `query`: list all (collection) or fetch the one
257
338
  * record (single). With a string id: fetch that specific row.
@@ -261,9 +342,21 @@ export class Database extends ReadyResource {
261
342
  * @returns {Promise<SingleResult | ListResult>}
262
343
  */
263
344
  get(name: string, query?: string | Query): Promise<SingleResult | ListResult>;
264
- _orderReady(name: any, col: any): Promise<any>;
265
- _orderOk: Map<any, any>;
266
- _total(col: any, query: any, rows: any): Promise<any>;
345
+ _plan(name: any, query?: {}): {
346
+ path: string;
347
+ range: {
348
+ gte: {};
349
+ lte: {};
350
+ };
351
+ rest: {};
352
+ sorted: boolean;
353
+ } | {
354
+ path: string;
355
+ range: {};
356
+ rest: {};
357
+ sorted: boolean;
358
+ };
359
+ _total(path: any, range: any, rows: any, query: any): Promise<any>;
267
360
  /**
268
361
  * Number of rows that match `query` (or total if omitted).
269
362
  *
@@ -282,7 +375,7 @@ export class Database extends ReadyResource {
282
375
  * @param {Query} [query]
283
376
  * @returns {import('streamx').Readable}
284
377
  */
285
- watch(name: string, query?: Query): import("streamx").Readable;
378
+ watch(name: string, query?: Query): import('streamx').Readable;
286
379
  /**
287
380
  * Delta subscription: batches of `{ prev, next }` row pairs instead of
288
381
  * full snapshots. The first batch (and any batch after a view swap) carries
@@ -294,20 +387,25 @@ export class Database extends ReadyResource {
294
387
  * @param {Query} [query]
295
388
  * @returns {import('streamx').Readable}
296
389
  */
297
- changes(name: string, query?: Query): import("streamx").Readable;
390
+ changes(name: string, query?: Query): import('streamx').Readable;
298
391
  /**
299
- * First-run bootstrap: create the device writer, save it, and swap into it.
392
+ * Provision this device. Its writer core was minted when the database opened
393
+ * and this device is its only author, ever. A first device records itself as
394
+ * a writer and a device in one write. A recovering device waits for the other
395
+ * devices' state, admits itself with the same master-signed add-writer
396
+ * appended optimistically, then records the device.
300
397
  *
301
- * @param {{ name?: string | null, isMobile?: boolean, recovering?: boolean }} [opts]
398
+ * @param {{ name?: string | null, isMobile?: boolean, recovering?: boolean, timeout?: number }} [opts]
302
399
  * @returns {Promise<{ id: Uint8Array, writer: import('../identity/index.js').KeyPair }>}
303
400
  */
304
- bootstrap(opts?: {
401
+ bootstrap({ name, isMobile, recovering, timeout }?: {
305
402
  name?: string | null;
306
403
  isMobile?: boolean;
307
404
  recovering?: boolean;
405
+ timeout?: number;
308
406
  }): Promise<{
309
407
  id: Uint8Array;
310
- writer: import("../identity/index.js").KeyPair;
408
+ writer: import('../identity/index.js').KeyPair;
311
409
  }>;
312
410
  /**
313
411
  * Claim writership on an existing room by signing our writer key with the
@@ -317,15 +415,13 @@ export class Database extends ReadyResource {
317
415
  * @returns {Promise<void>}
318
416
  */
319
417
  claim(): Promise<void>;
320
- /** The claim-writer op for this device, signed by the member identity. */
321
- claimOp(): any;
322
418
  /**
323
419
  * Resolve once the bee becomes writable, or reject after `timeout` ms.
324
420
  *
325
421
  * @param {{ timeout?: number }} [opts]
326
422
  * @returns {Promise<void>}
327
423
  */
328
- whenWritable(opts?: {
424
+ whenWritable({ timeout }?: {
329
425
  timeout?: number;
330
426
  }): Promise<void>;
331
427
  /**
@@ -342,6 +438,14 @@ export class Database extends ReadyResource {
342
438
  * @returns {Promise<void>}
343
439
  */
344
440
  removeWriter(publicKey: Uint8Array): Promise<void>;
441
+ _optimistic(op: any, opts: any): Promise<void>;
442
+ _backfilled(timeout: any): Promise<void>;
443
+ _admission(writer: any, ts?: number): {
444
+ master: Uint8Array<ArrayBufferLike>;
445
+ writer: any;
446
+ sig: Uint8Array<ArrayBufferLike>;
447
+ ts: number;
448
+ };
345
449
  /**
346
450
  * Throw if the handle is closing/closed or the bee isn't ready yet.
347
451
  *
@@ -363,117 +467,5 @@ export class Database extends ReadyResource {
363
467
  */
364
468
  col(ref: Ref): string;
365
469
  _checkFields(name: any, row: any): void;
366
- /**
367
- * Find a secondary index whose fields exactly match the query's equality keys.
368
- *
369
- * @param {string} name
370
- * @param {Query} [query]
371
- * @returns {{ path: string, range: { gte: object, lte: object } } | null}
372
- */
373
- matchIndex(name: string, query?: Query): {
374
- path: string;
375
- range: {
376
- gte: object;
377
- lte: object;
378
- };
379
- } | null;
380
- _write(verb: any, hook: any, publicKey: any): Promise<void>;
470
+ _admit(verb: any, hook: any, publicKey: any): Promise<void>;
381
471
  }
382
- export type DatabaseOpts = {
383
- /**
384
- * Corestore (or compatible) used to materialize the autobee.
385
- */
386
- store: any;
387
- /**
388
- * Long-lived member identity used to sign writer changes.
389
- */
390
- identity: import("../identity/index.js").Identity;
391
- /**
392
- * Optional swarm; required for multi-writer replication.
393
- */
394
- network?: import("../network/index.js").Network;
395
- /**
396
- * Generated hyperdb + hyperdispatch spec.
397
- */
398
- spec: {
399
- database: any;
400
- dispatch: any;
401
- meta?: {
402
- ns?: string;
403
- refs?: Record<string, {
404
- kind?: string;
405
- verb?: string;
406
- }>;
407
- };
408
- };
409
- /**
410
- * Custom action handlers keyed by route name.
411
- */
412
- routes?: Record<string, Function>;
413
- /**
414
- * Corestore namespace; defaults to `cero`.
415
- */
416
- namespace?: string;
417
- /**
418
- * Optional encryption key; falls back to identity's key.
419
- */
420
- encryptionKey?: Uint8Array | null;
421
- /**
422
- * Rotation epochs to prime the keyring with (delivered at join).
423
- */
424
- epochs?: Array<{
425
- epoch: number;
426
- entropy: Uint8Array;
427
- }> | null;
428
- /**
429
- * Override the default apply function.
430
- */
431
- apply?: (nodes: any, view: any, host: any) => Promise<void>;
432
- /**
433
- * Existing autobee key to reopen.
434
- */
435
- key?: Uint8Array | null;
436
- /**
437
- * Join discovery server-only (reachable but not searching). Flip at runtime with `setActive`.
438
- */
439
- passive?: boolean;
440
- /**
441
- * Device writer keypair; defaults to identity's keypair.
442
- */
443
- keyPair?: import("../identity/index.js").KeyPair;
444
- /**
445
- * Called when a background after-hook or onApply callback fails, a malformed node is skipped, or the bee errors.
446
- */
447
- onerror?: (err: Error) => void;
448
- };
449
- export type SingleResult = {
450
- data: any | null;
451
- };
452
- /**
453
- * `total` is null when a limited read skipped the full count — pass `{ total: true }` to force it.
454
- */
455
- export type ListResult = {
456
- data: any[];
457
- total: number | null;
458
- size: number;
459
- };
460
- export type Query = {
461
- gt?: string;
462
- gte?: string;
463
- lt?: string;
464
- lte?: string;
465
- reverse?: boolean;
466
- limit?: number;
467
- search?: string;
468
- fields?: string[];
469
- total?: boolean;
470
- };
471
- export type Ref = {
472
- kind: string;
473
- verb: string;
474
- name: string;
475
- };
476
- export type HookFn = (ctx: any) => any | Promise<any>;
477
- import ReadyResource from 'ready-resource';
478
- import { Keyring } from './encryption.js';
479
- import { EpochAutobee } from './encryption.js';
@@ -1,32 +1,55 @@
1
- export function rotate(db: any, retried?: boolean): Promise<any>;
2
1
  /**
3
- * Per-peer side of an applied rotation: open our envelope, learn the epoch
4
- * secret, persist it locally. Peers without an envelope (removed members)
5
- * simply stop here — every block after the announcement is noise to them.
6
- * Our own in-flight rotation is deferred to `rotate()` (see above).
7
- *
8
- * @param {import('./index.js').Database} db
9
- * @param {{ epoch: number, wrapped: Uint8Array, createdAt: number }} row
2
+ * Epoch key rotation for a database: mint a secret, seal it to every member,
3
+ * announce it through the log, and on every peer learn the secrets addressed
4
+ * to it. A debounced audit re-keys when the current epoch's recipients drift
5
+ * from the member set.
10
6
  */
11
- export function onepoch(db: import("./index.js").Database, row: {
12
- epoch: number;
13
- wrapped: Uint8Array;
14
- createdAt: number;
15
- }): Promise<void>;
16
- /**
17
- * Safety net after boot (userData priming happens in EpochAutobee's
18
- * `_bootState`): scan the epochs collection for anything applied but never
19
- * hydrated — e.g. a crash between a rotation's append and its save.
20
- */
21
- export function hydrateEpochs(db: any): Promise<void>;
22
- /** Debounced trigger for the epoch/membership consistency check. */
23
- export function scheduleHeal(db: any): void;
24
- /**
25
- * Record that the log contains ops from a newer app version than this
26
- * peer understands. Fires `'behind'` once per version so apps can prompt
27
- * an upgrade; the marker survives restarts via local core userData.
28
- *
29
- * @param {import('./index.js').Database} db
30
- * @param {number} version
31
- */
32
- export function onfuture(db: import("./index.js").Database, version: number): void;
7
+ export declare class Rotation {
8
+ db: import("./index.js").Database;
9
+ current: {
10
+ entropy: Uint8Array<ArrayBufferLike>;
11
+ stamp: any;
12
+ epoch: number;
13
+ };
14
+ _timer: number;
15
+ _healedFor: any;
16
+ /** @param {import('./index.js').Database} db */
17
+ constructor(db: import('./index.js').Database);
18
+ close(): void;
19
+ /** @returns {Promise<{ epoch: number }>} */
20
+ rotate(): Promise<{
21
+ epoch: number;
22
+ }>;
23
+ _rotate(retried: any): any;
24
+ _members(): Promise<any[]>;
25
+ _seal(members: any, entropy: any): any;
26
+ _announce(stamp: any, entropy: any, wrapped: any): Promise<number>;
27
+ _mint(): any;
28
+ _taken(stamp: any): Promise<any>;
29
+ _epochs(): any;
30
+ /**
31
+ * An applied rotation announcement: open our envelope, learn the secret,
32
+ * persist it. Removed members have no envelope and stop here, every block
33
+ * after the announcement is noise to them. Our own in-flight rotation is left
34
+ * to `rotate()`, which adds the secret once the announcement flushed.
35
+ *
36
+ * @param {{ epoch: number, stamp: number, wrapped: Uint8Array, commit: Uint8Array }} row
37
+ */
38
+ learn(row: {
39
+ epoch: number;
40
+ stamp: number;
41
+ wrapped: Uint8Array;
42
+ commit: Uint8Array;
43
+ }): Promise<void>;
44
+ _unseal(row: any): Uint8Array<ArrayBufferLike>;
45
+ /**
46
+ * Safety net after boot: an epoch applied but never saved, e.g. a crash
47
+ * between a rotation's append and its save, is learned from the epochs
48
+ * collection.
49
+ */
50
+ hydrate(): Promise<void>;
51
+ _save(): any;
52
+ /** Debounced audit, run after every update. */
53
+ heal(): void;
54
+ _audit(): Promise<void>;
55
+ }