@cero-base/core 1.18.2 → 2.0.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 (57) hide show
  1. package/README.md +5 -6
  2. package/package.json +14 -11
  3. package/src/blobs/index.js +17 -17
  4. package/src/blobs/server.js +0 -2
  5. package/src/database/changes.js +34 -60
  6. package/src/database/dispatch.js +156 -245
  7. package/src/database/encryption.js +22 -52
  8. package/src/database/envelope.js +1 -3
  9. package/src/database/index.js +514 -513
  10. package/src/database/rotation.js +191 -193
  11. package/src/identity/index.js +8 -12
  12. package/src/index.js +5 -9
  13. package/src/lib/constants.js +3 -12
  14. package/src/lib/errors.js +6 -10
  15. package/src/lib/schema.js +2 -5
  16. package/src/lib/utils.js +55 -38
  17. package/src/network/index.js +138 -166
  18. package/src/pairing/candidate.js +123 -0
  19. package/src/pairing/index.js +36 -267
  20. package/src/pairing/invite.js +3 -4
  21. package/src/pairing/request.js +96 -0
  22. package/src/rpc/index.js +4 -14
  23. package/src/rpc/peer.js +3 -7
  24. package/src/storage/index.js +36 -49
  25. package/types/blobs/codec.d.ts +8 -8
  26. package/types/blobs/index.d.ts +38 -37
  27. package/types/blobs/server.d.ts +8 -10
  28. package/types/database/changes.d.ts +3 -8
  29. package/types/database/dispatch.d.ts +28 -25
  30. package/types/database/encryption.d.ts +22 -30
  31. package/types/database/envelope.d.ts +2 -2
  32. package/types/database/index.d.ts +196 -221
  33. package/types/database/rotation.d.ts +47 -30
  34. package/types/identity/index.d.ts +83 -87
  35. package/types/index.d.ts +42 -55
  36. package/types/lib/constants.d.ts +34 -38
  37. package/types/lib/errors.d.ts +16 -20
  38. package/types/lib/schema.d.ts +49 -42
  39. package/types/lib/spec/index.d.ts +29 -55
  40. package/types/lib/utils.d.ts +26 -20
  41. package/types/network/discovery.d.ts +7 -7
  42. package/types/network/index.d.ts +64 -72
  43. package/types/pairing/candidate.d.ts +36 -0
  44. package/types/pairing/index.d.ts +91 -151
  45. package/types/pairing/invite.d.ts +91 -91
  46. package/types/pairing/request.d.ts +133 -0
  47. package/types/rpc/client.d.ts +2 -2
  48. package/types/rpc/index.d.ts +30 -33
  49. package/types/rpc/peer.d.ts +11 -11
  50. package/types/rpc/server.d.ts +2 -2
  51. package/types/storage/index.d.ts +70 -71
  52. package/src/database/bootstrap.js +0 -133
  53. package/src/database/hooks.js +0 -112
  54. package/src/database/membership.js +0 -67
  55. package/types/database/bootstrap.d.ts +0 -20
  56. package/types/database/hooks.d.ts +0 -8
  57. package/types/database/membership.d.ts +0 -7
@@ -6,19 +6,9 @@ import HyperDB from 'hyperdb'
6
6
  import ReadyResource from 'ready-resource'
7
7
 
8
8
  import { ROCKS, BEE, SINGLE, COLLECTION, QUERY_RESERVED } from '../lib/constants.js'
9
- import { genId, subscribe, searchHit } from '../lib/utils.js'
9
+ import { genId, subscribe, filter } from '../lib/utils.js'
10
10
  import { CeroError } from '../lib/errors.js'
11
11
 
12
- // The subset of the query grammar hyperdb itself honors (pushed down);
13
- // the rest of QUERY_RESERVED is applied in memory here.
14
- const RANGE_OPS = ['gt', 'gte', 'lt', 'lte', 'reverse', 'limit']
15
-
16
- const pick = (query, keys) => {
17
- const out = {}
18
- if (query) for (const k of keys) if (query[k] !== undefined) out[k] = query[k]
19
- return out
20
- }
21
-
22
12
  /**
23
13
  * @typedef {object} StorageOpts
24
14
  * @property {{ database: any, meta?: { ns?: string, refs?: Record<string, { kind?: string }> } }} spec
@@ -35,9 +25,8 @@ const pick = (query, keys) => {
35
25
  */
36
26
 
37
27
  /**
38
- * Local, single-writer storage. Backed by either RocksDB (`rocks`) or a
39
- * Hyperbee on top of corestore (`bee`). Exposes the same `put/get/...`
40
- * surface as `Database` but without networking or multi-writer apply.
28
+ * Local, single-writer storage. Backed by either RocksDB (`rocks`) or a Hyperbee on top of
29
+ * corestore (`bee`).
41
30
  */
42
31
  export class Storage extends ReadyResource {
43
32
  /**
@@ -75,26 +64,6 @@ export class Storage extends ReadyResource {
75
64
  this.db = null
76
65
  }
77
66
 
78
- /**
79
- * Construct a RocksDB-backed Storage.
80
- *
81
- * @param {string} dir
82
- * @param {Omit<StorageOpts, 'backend'>} opts
83
- */
84
- static rocks(dir, opts) {
85
- return new Storage(dir, { ...opts, backend: ROCKS })
86
- }
87
-
88
- /**
89
- * Construct a Hyperbee-backed Storage.
90
- *
91
- * @param {string} dir
92
- * @param {Omit<StorageOpts, 'backend'>} opts
93
- */
94
- static bee(dir, opts) {
95
- return new Storage(dir, { ...opts, backend: BEE })
96
- }
97
-
98
67
  async _open() {
99
68
  if (this._ownsRoot) {
100
69
  this.root = new HypercoreStorage(this.dir, { columnFamilies: [this._cf] })
@@ -155,9 +124,7 @@ export class Storage extends ReadyResource {
155
124
  }
156
125
 
157
126
  /**
158
- * Upsert by merging with the existing row, preserving `createdAt`. Pass
159
- * `{ upsert: false }` to update-only — a missing row is left untouched
160
- * (returns `null`) instead of created. Mirrors `Database.set`.
127
+ * Upsert by merging with the existing row, preserving `createdAt`.
161
128
  *
162
129
  * @param {string} name
163
130
  * @param {Record<string, any>} row
@@ -212,25 +179,21 @@ export class Storage extends ReadyResource {
212
179
 
213
180
  if (ref.kind === SINGLE) return { data: await this.db.findOne(col, {}) }
214
181
 
215
- // keyed lookup, not a full scan + in-memory find
216
182
  if (typeof query === 'string') {
217
183
  return { data: (await this.db.get(col, { id: query })) ?? null }
218
184
  }
219
185
 
220
- // hyperdb only honors range/limit operators — equality fields and search
221
- // must be applied here or they are silently ignored and every row comes back
186
+ // hyperdb ignores equality fields and search, apply them here
222
187
  const eq = Object.keys(query || {}).filter((k) => !QUERY_RESERVED.has(k))
223
188
  if (eq.length || query?.search) {
224
189
  const rows = await this.db.find(col, {}).toArray()
225
- let matched = rows.filter((r) => eq.every((k) => r[k] === query[k]))
226
- if (query.search) matched = matched.filter((r) => searchHit(r, query.search, query.fields))
190
+ const matched = filter(rows, { ...query, limit: undefined })
227
191
  const data = query.limit != null ? matched.slice(0, query.limit) : matched
228
192
  return { data, total: matched.length, size: data.length }
229
193
  }
230
194
 
231
- const data = await this.db.find(col, pick(query, RANGE_OPS)).toArray()
232
- // a limit caps `data`, so `total` needs a full count; with no query
233
- // `data` is already everything — skip the second scan.
195
+ const data = await this.db.find(col, range(query)).toArray()
196
+ // a limit caps data, so total needs a full count
234
197
  const filtered = query && Object.keys(query).length > 0
235
198
  const total = filtered ? (await this.db.find(col, {}).toArray()).length : data.length
236
199
  return { data, total, size: data.length }
@@ -249,10 +212,8 @@ export class Storage extends ReadyResource {
249
212
  const col = this._col(ref)
250
213
  const eq = Object.keys(query || {}).filter((k) => !QUERY_RESERVED.has(k))
251
214
  const filtered = eq.length || query?.search
252
- const rows = await this.db.find(col, filtered ? {} : pick(query, RANGE_OPS)).toArray()
253
- let matched = filtered ? rows.filter((r) => eq.every((k) => r[k] === query[k])) : rows
254
- if (query?.search) matched = matched.filter((r) => searchHit(r, query.search, query.fields))
255
- return { data: matched.length }
215
+ const rows = await this.db.find(col, filtered ? {} : range(query)).toArray()
216
+ return { data: (filtered ? filter(rows, query) : rows).length }
256
217
  }
257
218
 
258
219
  /**
@@ -307,4 +268,30 @@ export class Storage extends ReadyResource {
307
268
  await this.db.insert(this._col(ref), row)
308
269
  await this.db.flush()
309
270
  }
271
+
272
+ /**
273
+ * Construct a RocksDB-backed Storage.
274
+ *
275
+ * @param {string} dir
276
+ * @param {Omit<StorageOpts, 'backend'>} opts
277
+ */
278
+ static rocks(dir, opts) {
279
+ return new Storage(dir, { ...opts, backend: ROCKS })
280
+ }
281
+
282
+ /**
283
+ * Construct a Hyperbee-backed Storage.
284
+ *
285
+ * @param {string} dir
286
+ * @param {Omit<StorageOpts, 'backend'>} opts
287
+ */
288
+ static bee(dir, opts) {
289
+ return new Storage(dir, { ...opts, backend: BEE })
290
+ }
291
+ }
292
+
293
+ // hyperdb bounds are records, a bare id must be wrapped
294
+ function range({ gt, gte, lt, lte, reverse, limit } = {}) {
295
+ const id = (v) => (v === undefined ? undefined : { id: v })
296
+ return { gt: id(gt), gte: id(gte), lt: id(lt), lte: id(lte), reverse, limit }
310
297
  }
@@ -1,3 +1,9 @@
1
+ export type RawBlobId = {
2
+ blockOffset: number;
3
+ blockLength: number;
4
+ byteOffset: number;
5
+ byteLength: number;
6
+ };
1
7
  /**
2
8
  * Encode a coreKey + raw hyperblobs blobId + type into a durable string id.
3
9
  *
@@ -6,21 +12,15 @@
6
12
  * @param {string} type
7
13
  * @returns {string}
8
14
  */
9
- export function encodeId(coreKey: Uint8Array, blobId: RawBlobId, type: string): string;
15
+ export declare function encodeId(coreKey: Uint8Array, blobId: RawBlobId, type: string): string;
10
16
  /**
11
17
  * Decode a string id back into its coreKey, raw blobId and type.
12
18
  *
13
19
  * @param {string} id
14
20
  * @returns {{ coreKey: Uint8Array, blobId: RawBlobId, type: string }}
15
21
  */
16
- export function decodeId(id: string): {
22
+ export declare function decodeId(id: string): {
17
23
  coreKey: Uint8Array;
18
24
  blobId: RawBlobId;
19
25
  type: string;
20
26
  };
21
- export type RawBlobId = {
22
- blockOffset: number;
23
- blockLength: number;
24
- byteOffset: number;
25
- byteLength: number;
26
- };
@@ -1,3 +1,28 @@
1
+ import ReadyResource from 'ready-resource';
2
+ import { encodeId, decodeId } from './codec.js';
3
+ export type BlobsOpts = {
4
+ /**
5
+ * Corestore (or compatible) used to host the blob core.
6
+ */
7
+ store: object;
8
+ /**
9
+ * Identity supplying the default encryption key.
10
+ */
11
+ identity?: import('../identity/index.js').Identity;
12
+ /**
13
+ * Optional network used to announce + replicate the core.
14
+ */
15
+ network?: import('../network/index.js').Network;
16
+ /**
17
+ * Pre-existing blob core key — joins an existing blob feed.
18
+ */
19
+ key?: Uint8Array;
20
+ /**
21
+ * Explicit encryption key, overrides `identity.encryptionKey`.
22
+ */
23
+ encryptionKey?: Uint8Array;
24
+ };
25
+ export type RawBlobId = import('./codec.js').RawBlobId;
1
26
  /**
2
27
  * @typedef {object} BlobsOpts
3
28
  * @property {object} store Corestore (or compatible) used to host the blob core.
@@ -9,10 +34,8 @@
9
34
  * @typedef {import('./codec.js').RawBlobId} RawBlobId
10
35
  */
11
36
  /** Thin wrapper over a single Hyperblobs core; deals only in raw blobIds. */
12
- export class Blobs extends ReadyResource {
13
- /** @param {BlobsOpts} [opts] */
14
- constructor({ store, identity, network, key, encryptionKey, name }?: BlobsOpts);
15
- store: any;
37
+ export declare class Blobs extends ReadyResource {
38
+ store: object;
16
39
  identity: import("../index.js").Identity;
17
40
  network: import("../index.js").Network;
18
41
  encryptionKey: Uint8Array<ArrayBufferLike>;
@@ -21,6 +44,8 @@ export class Blobs extends ReadyResource {
21
44
  core: any;
22
45
  hyperblobs: any;
23
46
  _discovery: import("../network/discovery.js").Discovery;
47
+ /** @param {BlobsOpts} [opts] */
48
+ constructor({ store, identity, network, key, encryptionKey, name }?: BlobsOpts);
24
49
  /**
25
50
  * Canonical z32 id of the underlying core (null until ready).
26
51
  *
@@ -39,18 +64,15 @@ export class Blobs extends ReadyResource {
39
64
  * @returns {Uint8Array | null}
40
65
  */
41
66
  get discoveryKey(): Uint8Array | null;
67
+ _open(): Promise<void>;
68
+ _close(): Promise<void>;
42
69
  /**
43
70
  * Store a buffer or readable stream, returning its raw hyperblobs blobId.
44
71
  *
45
72
  * @param {Uint8Array | import('streamx').Readable} input
46
73
  * @returns {Promise<RawBlobId>}
47
74
  */
48
- put(input: Uint8Array | import("streamx").Readable): Promise<RawBlobId>;
49
- /**
50
- * @param {import('streamx').Readable} input
51
- * @returns {Promise<RawBlobId>}
52
- */
53
- _putStream(input: import("streamx").Readable): Promise<RawBlobId>;
75
+ put(input: Uint8Array | import('streamx').Readable): Promise<RawBlobId>;
54
76
  /**
55
77
  * Resolve the blob bytes for a raw blobId. Fetches from peers if not local.
56
78
  *
@@ -66,7 +88,7 @@ export class Blobs extends ReadyResource {
66
88
  * @param {object} [opts]
67
89
  * @returns {import('streamx').Readable}
68
90
  */
69
- createReadStream(blobId: RawBlobId, opts?: object): import("streamx").Readable;
91
+ createReadStream(blobId: RawBlobId, opts?: object): import('streamx').Readable;
70
92
  /**
71
93
  * Clear the blocks backing a raw blobId from the local core.
72
94
  *
@@ -74,32 +96,11 @@ export class Blobs extends ReadyResource {
74
96
  * @returns {Promise<void>}
75
97
  */
76
98
  clear(blobId: RawBlobId): Promise<void>;
77
- _guard(): void;
78
- }
79
- export type BlobsOpts = {
80
- /**
81
- * Corestore (or compatible) used to host the blob core.
82
- */
83
- store: object;
84
99
  /**
85
- * Identity supplying the default encryption key.
86
- */
87
- identity?: import("../identity/index.js").Identity;
88
- /**
89
- * Optional network used to announce + replicate the core.
90
- */
91
- network?: import("../network/index.js").Network;
92
- /**
93
- * Pre-existing blob core key — joins an existing blob feed.
94
- */
95
- key?: Uint8Array;
96
- /**
97
- * Explicit encryption key, overrides `identity.encryptionKey`.
100
+ * @param {import('streamx').Readable} input
101
+ * @returns {Promise<RawBlobId>}
98
102
  */
99
- encryptionKey?: Uint8Array;
100
- };
101
- export type RawBlobId = import("./codec.js").RawBlobId;
102
- import ReadyResource from 'ready-resource';
103
- import { encodeId } from './codec.js';
104
- import { decodeId } from './codec.js';
103
+ _putStream(input: import('streamx').Readable): Promise<RawBlobId>;
104
+ _guard(): void;
105
+ }
105
106
  export { encodeId, decodeId };
@@ -1,23 +1,25 @@
1
+ export type Resolved = {
2
+ key: Buffer;
3
+ encryptionKey: Buffer | null;
4
+ };
1
5
  /**
2
6
  * @typedef {{ key: Buffer, encryptionKey: Buffer | null }} Resolved
3
7
  */
4
8
  /**
5
9
  * HTTP server that turns a string file id into a renderable localhost URL.
6
- * Wraps hypercore-blob-server; the underlying store session is owned by
7
- * BlobServer and closed when `close()` is called.
8
10
  */
9
- export class FileServer {
11
+ export declare class FileServer {
12
+ resolve: (coreKey: Buffer, info: object) => Resolved | null | Promise<Resolved | null>;
13
+ server: any;
10
14
  /**
11
15
  * @param {object} opts
12
16
  * @param {import('corestore')} opts.store
13
17
  * @param {(coreKey: Buffer, info: object) => Resolved | null | Promise<Resolved | null>} opts.resolve
14
18
  */
15
19
  constructor({ store, resolve }: {
16
- store: any;
20
+ store: import('corestore');
17
21
  resolve: (coreKey: Buffer, info: object) => Resolved | null | Promise<Resolved | null>;
18
22
  });
19
- resolve: (coreKey: Buffer, info: object) => Resolved | null | Promise<Resolved | null>;
20
- server: any;
21
23
  get port(): any;
22
24
  listen(): Promise<void>;
23
25
  /**
@@ -29,7 +31,3 @@ export class FileServer {
29
31
  getLink(id: string): string;
30
32
  close(): Promise<void>;
31
33
  }
32
- export type Resolved = {
33
- key: Buffer;
34
- encryptionKey: Buffer | null;
35
- };
@@ -1,11 +1,6 @@
1
1
  /**
2
- * Pull-driven delta stream over a collection: batches of `{ prev, next }`
3
- * pairs diffed between per-stream head cursors (`db.diff(col, { from })`).
4
- * Update ticks only mark the stream dirty — the diff runs when the reader
5
- * demands, so backpressure folds bursts into one bigger batch and nothing is
6
- * ever dropped. The first batch, and any batch after the view is swapped or
7
- * fast-forwarded to a new core, carries the full matching state as inserts
8
- * with `reset: true`.
2
+ * Pull-driven delta stream over a collection: batches of `{ prev, next }` pairs diffed
3
+ * from the head this stream last reported.
9
4
  *
10
5
  * @param {import('./index.js').Database} db
11
6
  * @param {string} name Ref name (scopes the update ticks).
@@ -13,4 +8,4 @@
13
8
  * @param {(row: any) => boolean} matches
14
9
  * @returns {import('streamx').Readable}
15
10
  */
16
- export function makeChanges(db: import("./index.js").Database, name: string, col: string, matches: (row: any) => boolean): import("streamx").Readable;
11
+ export declare function makeChanges(db: import('./index.js').Database, name: string, col: string, matches: (row: any) => boolean): import('streamx').Readable;
@@ -2,39 +2,42 @@
2
2
  * Build the hyperdispatch router for a spec: wires membership, builtin, and
3
3
  * spec-defined collection/action ops, returning the router plus an apply loop.
4
4
  *
5
- * @param {{ dispatch: { Router: Function }, meta?: { refs?: Record<string, { kind?: string, builtin?: boolean, verb?: string }> } }} spec Generated hyperdispatch spec.
6
- * @param {string} ns Namespace prefix for collection and op names.
7
- * @param {Record<string, Function>} routes Custom action handlers keyed by route name.
8
- * @param {(err: Error) => void} [onerror] Called when a malformed node is skipped.
9
- * @param {() => Uint8Array | null} [getDbKey]
10
- * @param {{ onEpoch?: (row: { epoch: number, wrapped: Uint8Array, createdAt: number }) => Promise<void> }} [hooks] Per-peer side effects fired after an op applies (skipped in dry runs).
11
- * @returns {{ dispatcher: object, apply: (nodes: Array<{ value: Buffer, key: Buffer }>, view: object, host: object) => Promise<void> }}
5
+ * @param {object} opts
6
+ * @param {{ dispatch: { Router: Function }, meta?: { refs?: Record<string, { kind?: string, builtin?: boolean, verb?: string }> } }} opts.spec Generated hyperdispatch spec.
7
+ * @param {string} opts.ns Namespace prefix for collection and op names.
8
+ * @param {Record<string, Function>} opts.routes Custom action handlers keyed by route name.
9
+ * @param {(err: Error) => void} opts.onerror Called when a malformed node is skipped.
10
+ * @param {() => Uint8Array | null} opts.key The database key, null until the bee booted.
11
+ * @param {(row: { epoch: number, stamp: number, wrapped: Uint8Array, commit: Uint8Array }) => Promise<void>} opts.onepoch Per-peer side of an applied rotation (skipped in dry runs).
12
+ * @returns {{ dispatch: (value: Buffer, ctx: object) => Promise<void>, apply: (nodes: Array<{ value: Buffer, key: Buffer }>, view: object, host: object) => Promise<void> }}
12
13
  */
13
- export function makeDispatcher(spec: {
14
- dispatch: {
15
- Router: Function;
14
+ export declare function makeDispatcher({ spec, ns, routes, onerror, key, onepoch }: {
15
+ spec: {
16
+ dispatch: {
17
+ Router: Function;
18
+ };
19
+ meta?: {
20
+ refs?: Record<string, {
21
+ kind?: string;
22
+ builtin?: boolean;
23
+ verb?: string;
24
+ }>;
25
+ };
16
26
  };
17
- meta?: {
18
- refs?: Record<string, {
19
- kind?: string;
20
- builtin?: boolean;
21
- verb?: string;
22
- }>;
23
- };
24
- }, ns: string, routes: Record<string, Function>, onerror?: (err: Error) => void, getDbKey?: () => Uint8Array | null, hooks?: {
25
- onEpoch?: (row: {
27
+ ns: string;
28
+ routes: Record<string, Function>;
29
+ onerror: (err: Error) => void;
30
+ key: () => Uint8Array | null;
31
+ onepoch: (row: {
26
32
  epoch: number;
33
+ stamp: number;
27
34
  wrapped: Uint8Array;
28
- createdAt: number;
35
+ commit: Uint8Array;
29
36
  }) => Promise<void>;
30
37
  }): {
31
- dispatcher: object;
38
+ dispatch: (value: Buffer, ctx: object) => Promise<void>;
32
39
  apply: (nodes: Array<{
33
40
  value: Buffer;
34
41
  key: Buffer;
35
42
  }>, view: object, host: object) => Promise<void>;
36
43
  };
37
- export const BUILTINS: {
38
- name: string;
39
- verb: string;
40
- }[];
@@ -1,43 +1,35 @@
1
+ import Autobee from 'autobee';
2
+ import c from 'compact-encoding';
3
+ declare const WriterEncryption: any;
1
4
  /**
2
- * Encryption key for a rotation epoch's blob cores. New files land in a core
3
- * keyed by the epoch entropy, so file confidentiality rotates with the room:
4
- * only holders of the epoch secret can derive the core key.
5
+ * Encryption key for a rotation epoch's blob cores.
5
6
  *
6
7
  * @param {Uint8Array} entropy
7
8
  * @returns {Uint8Array}
8
9
  */
9
- export function blobEpochKey(entropy: Uint8Array): Uint8Array;
10
+ export declare function blobEpochKey(entropy: Uint8Array): Uint8Array;
10
11
  /** Prime a keyring from a local core's persisted epoch stash. */
11
- export function loadEpochs(keyring: any, local: any): Promise<void>;
12
+ export declare function loadEpochs(keyring: any, local: any): Promise<void>;
12
13
  /**
13
14
  * Wire codec for a rotation announcement's envelope list — one sealed box
14
15
  * per remaining member, addressed by member id.
15
16
  */
16
- export const wraps: c.Encoder<any[], {
17
+ export declare const wraps: c.Encoder<any[], {
17
18
  id: string;
18
19
  box: Uint8Array<ArrayBufferLike>;
19
20
  }[]>;
20
21
  /**
21
22
  * Wire codec for locally persisted / pairing-delivered epoch secrets.
22
- * `epoch` is the apply-order sequence; `stamp` is the content-addressed
23
- * uint32 written into block headers.
24
23
  */
25
- export const epochEntries: c.Encoder<any[], {
24
+ export declare const epochEntries: c.Encoder<any[], {
26
25
  epoch: number;
27
26
  stamp: number;
28
27
  entropy: Uint8Array<ArrayBufferLike>;
29
28
  }[]>;
30
29
  /**
31
- * Per-database registry of rotation epochs. Stamp 0 is the base key era
32
- * (no entry needed — it derives from the upstream GENESIS_ENTROPY path).
33
- * Every rotation adds an entry keyed by its content-addressed `stamp` (the
34
- * uint32 written into block headers, chosen randomly by the rotator and
35
- * validated unique at apply) alongside its apply-order `seq`. Because the
36
- * stamp is chosen before any block is written and can never be renumbered
37
- * by linearization, a block's header always identifies its true key —
38
- * concurrent rotations cannot make blocks undecryptable.
30
+ * Per-database registry of rotation epochs.
39
31
  */
40
- export class Keyring {
32
+ export declare class Keyring {
41
33
  /** @type {Map<number, Uint8Array>} stamp → entropy */
42
34
  entropies: Map<number, Uint8Array>;
43
35
  /** @type {Map<number, number>} stamp → apply-order sequence */
@@ -48,6 +40,7 @@ export class Keyring {
48
40
  seq: number;
49
41
  /** bumped on every add/remove — cheap change detection for retries */
50
42
  version: number;
43
+ constructor();
51
44
  /** @returns {Array<{ epoch: number, stamp: number, entropy: Uint8Array }>} ascending by seq */
52
45
  all(): Array<{
53
46
  epoch: number;
@@ -73,27 +66,26 @@ export class Keyring {
73
66
  remove(stamp: number): void;
74
67
  }
75
68
  /**
76
- * The epoch-aware provider — the class itself is upstream WriterEncryption;
77
- * the epoch behavior lives on the (patched) base prototype above. Named for
78
- * call sites and tests.
69
+ * The epoch-aware provider — the class itself is upstream WriterEncryption; the epoch
70
+ * behavior lives on the (patched) base prototype above.
79
71
  */
80
- export class EpochEncryption {
72
+ export declare class EpochEncryption extends WriterEncryption {
81
73
  }
82
74
  /**
83
- * Autobee with a rotation keyring. Every provider autobee constructs
84
- * (view/system factory, foreign cores, ActiveWriters) picks the epochs up
85
- * through the patched base class and this `keyring` property.
75
+ * Autobee with a rotation keyring. Every provider autobee constructs (view/system factory,
76
+ * foreign cores, ActiveWriters) picks the epochs up through the patched base class and
77
+ * this `keyring` property.
86
78
  */
87
- export class EpochAutobee {
88
- constructor(store: any, key: any, handlers?: {});
79
+ export declare class EpochAutobee extends Autobee {
89
80
  keyring: any;
90
81
  _epochStalled: Set<any>;
91
- _epochRetry: any;
82
+ _epochRetry: number;
92
83
  _epochRetryDelay: number;
93
84
  _epochRetrySeen: number;
85
+ constructor(store: any, key: any, handlers?: {});
86
+ _close(): Promise<any>;
94
87
  _bumpPendingWriters(...args: any[]): Promise<any>;
95
88
  _applyWakeupHints(): Promise<any>;
96
89
  _scheduleEpochRetry(): void;
97
- _close(): Promise<any>;
98
90
  }
99
- import c from 'compact-encoding';
91
+ export {};
@@ -5,7 +5,7 @@
5
5
  * @param {Uint8Array} body
6
6
  * @returns {Uint8Array}
7
7
  */
8
- export function wrap(version: number, body: Uint8Array): Uint8Array;
8
+ export declare function wrap(version: number, body: Uint8Array): Uint8Array;
9
9
  /**
10
10
  * Split an op into contract version and payload. Ops written before the
11
11
  * envelope existed carry no sentinel and read as version 0.
@@ -13,7 +13,7 @@ export function wrap(version: number, body: Uint8Array): Uint8Array;
13
13
  * @param {Uint8Array} buf
14
14
  * @returns {{ version: number, body: Uint8Array }}
15
15
  */
16
- export function unwrap(buf: Uint8Array): {
16
+ export declare function unwrap(buf: Uint8Array): {
17
17
  version: number;
18
18
  body: Uint8Array;
19
19
  };