@cero-base/core 2.2.1 → 2.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.
Files changed (55) hide show
  1. package/README.md +32 -212
  2. package/package.json +18 -9
  3. package/src/blobs/index.js +9 -0
  4. package/src/blobs/server.js +2 -0
  5. package/src/database/changes.js +1 -1
  6. package/src/database/dispatch.js +341 -209
  7. package/src/database/encryption.js +83 -33
  8. package/src/database/index.js +184 -83
  9. package/src/database/rotation.js +43 -30
  10. package/src/identity/index.js +20 -78
  11. package/src/index.js +3 -10
  12. package/src/lib/constants.js +2 -0
  13. package/src/lib/errors.js +3 -11
  14. package/src/lib/spec/index.js +136 -132
  15. package/src/lib/spec/schema.json +84 -99
  16. package/src/lib/utils.js +57 -3
  17. package/src/mailbox/inbox.js +103 -0
  18. package/src/mailbox/index.js +146 -0
  19. package/src/mailbox/post.js +69 -0
  20. package/src/network/discovery.js +26 -1
  21. package/src/network/index.js +105 -64
  22. package/src/network/presence.js +6 -2
  23. package/src/pairing/index.js +330 -254
  24. package/src/pairing/invite.js +83 -144
  25. package/src/pairing/request.js +54 -56
  26. package/src/rpc/index.js +18 -93
  27. package/src/rpc/peer.js +4 -1
  28. package/src/storage/index.js +78 -39
  29. package/types/blobs/index.d.ts +22 -9
  30. package/types/blobs/server.d.ts +4 -2
  31. package/types/database/changes.d.ts +2 -2
  32. package/types/database/dispatch.d.ts +19 -13
  33. package/types/database/encryption.d.ts +67 -29
  34. package/types/database/index.d.ts +144 -119
  35. package/types/database/rotation.d.ts +32 -13
  36. package/types/identity/index.d.ts +6 -47
  37. package/types/index.d.ts +3 -16
  38. package/types/lib/constants.d.ts +1 -0
  39. package/types/lib/errors.d.ts +3 -9
  40. package/types/lib/spec/index.d.ts +52 -16
  41. package/types/lib/utils.d.ts +40 -8
  42. package/types/mailbox/inbox.d.ts +52 -0
  43. package/types/mailbox/index.d.ts +111 -0
  44. package/types/mailbox/post.d.ts +37 -0
  45. package/types/network/discovery.d.ts +21 -5
  46. package/types/network/index.d.ts +64 -48
  47. package/types/network/presence.d.ts +17 -4
  48. package/types/pairing/index.d.ts +143 -134
  49. package/types/pairing/invite.d.ts +70 -114
  50. package/types/pairing/request.d.ts +58 -98
  51. package/types/rpc/index.d.ts +26 -44
  52. package/types/rpc/peer.d.ts +10 -7
  53. package/types/storage/index.d.ts +64 -54
  54. package/src/pairing/candidate.js +0 -123
  55. package/types/pairing/candidate.d.ts +0 -36
@@ -6,7 +6,7 @@ export type DatabaseOpts = {
6
6
  /**
7
7
  * Corestore (or compatible) used to materialize the autobee.
8
8
  */
9
- store: any;
9
+ store: import('corestore');
10
10
  /**
11
11
  * Long-lived member identity used to sign writer changes.
12
12
  */
@@ -19,20 +19,24 @@ export type DatabaseOpts = {
19
19
  * Generated hyperdb + hyperdispatch spec.
20
20
  */
21
21
  spec: {
22
- database: any;
23
- dispatch: any;
22
+ database: object;
23
+ dispatch: {
24
+ Router: new () => object;
25
+ encode: (name: string, value: unknown) => Uint8Array;
26
+ decode: (buf: Uint8Array) => {
27
+ name: string;
28
+ value: unknown;
29
+ };
30
+ };
24
31
  meta?: {
25
32
  ns?: string;
33
+ version?: number;
26
34
  refs?: Record<string, {
27
35
  kind?: string;
28
36
  verb?: string;
29
37
  }>;
30
38
  };
31
39
  };
32
- /**
33
- * Custom action handlers keyed by route name.
34
- */
35
- routes?: Record<string, Function>;
36
40
  /**
37
41
  * Corestore namespace; defaults to `cero`.
38
42
  */
@@ -69,11 +73,12 @@ export type DatabaseOpts = {
69
73
  */
70
74
  onerror?: (err: Error) => void;
71
75
  };
76
+ export type Row = Record<string, unknown>;
72
77
  export type SingleResult = {
73
- data: any | null;
78
+ data: Row | null;
74
79
  };
75
80
  export type ListResult = {
76
- data: any[];
81
+ data: Row[];
77
82
  total: number | null;
78
83
  size: number;
79
84
  };
@@ -115,13 +120,13 @@ export type HookContext = {
115
120
  */
116
121
  id: string | null;
117
122
  /**
118
- * The writer's member id.
123
+ * The writer's member id, null for a core no member owns yet (a join, a claim, genesis).
119
124
  */
120
- memberId: string;
125
+ memberId: string | null;
121
126
  /**
122
- * The writer's role.
127
+ * The writer's role, null likewise.
123
128
  */
124
- role: string;
129
+ role: string | null;
125
130
  get: (ref: string | {
126
131
  name: string;
127
132
  }, query?: string | Record<string, unknown>) => Promise<{
@@ -140,11 +145,10 @@ export type HookContext = {
140
145
  export type HookFn = (ctx: HookContext) => unknown;
141
146
  /**
142
147
  * @typedef {object} DatabaseOpts
143
- * @property {any} store Corestore (or compatible) used to materialize the autobee.
148
+ * @property {import('corestore')} store Corestore (or compatible) used to materialize the autobee.
144
149
  * @property {import('../identity/index.js').Identity} identity Long-lived member identity used to sign writer changes.
145
150
  * @property {import('../network/index.js').Network} [network] Optional swarm; required for multi-writer replication.
146
- * @property {{ database: any, dispatch: any, meta?: { ns?: string, refs?: Record<string, { kind?: string, verb?: string }> } }} spec Generated hyperdb + hyperdispatch spec.
147
- * @property {Record<string, Function>} [routes] Custom action handlers keyed by route name.
151
+ * @property {{ database: object, dispatch: { Router: new () => object, encode: (name: string, value: unknown) => Uint8Array, decode: (buf: Uint8Array) => { name: string, value: unknown } }, meta?: { ns?: string, version?: number, refs?: Record<string, { kind?: string, verb?: string }> } }} spec Generated hyperdb + hyperdispatch spec.
148
152
  * @property {string} [namespace] Corestore namespace; defaults to `cero`.
149
153
  * @property {Uint8Array | null} [encryptionKey] Optional encryption key; falls back to identity's key.
150
154
  * @property {Array<{ epoch: number, entropy: Uint8Array }> | null} [epochs] Rotation epochs to prime the keyring with (delivered at join).
@@ -157,8 +161,9 @@ export type HookFn = (ctx: HookContext) => unknown;
157
161
  * op: `{ op, name, row, writerKey, seq }`, local and replicated), `writable`, `unwritable`,
158
162
  * `behind` (an op from a newer app version was skipped).
159
163
  *
160
- * @typedef {{ data: any | null }} SingleResult
161
- * @typedef {{ data: any[], total: number | null, size: number }} ListResult `total` is null when a limited read skipped the full count — pass `{ total: true }` to force it.
164
+ * @typedef {Record<string, unknown>} Row A row, fields by name.
165
+ * @typedef {{ data: Row | null }} SingleResult
166
+ * @typedef {{ data: Row[], total: number | null, size: number }} ListResult `total` is null when a limited read skipped the full count — pass `{ total: true }` to force it.
162
167
  * @typedef {{ gt?: string, gte?: string, lt?: string, lte?: string, reverse?: boolean, limit?: number, search?: string, fields?: string[], total?: boolean }} Query
163
168
  * @typedef {{ kind: string, verb: string, name: string }} Ref
164
169
  * @typedef {object} HookContext
@@ -167,8 +172,8 @@ export type HookFn = (ctx: HookContext) => unknown;
167
172
  * @property {Record<string, unknown> | null} row The incoming row; mutate it in `before` to change what lands.
168
173
  * @property {Record<string, unknown> | null} existing The stored row, or null.
169
174
  * @property {string | null} id The row id for a `del`.
170
- * @property {string} memberId The writer's member id.
171
- * @property {string} role The writer's role.
175
+ * @property {string | null} memberId The writer's member id, null for a core no member owns yet (a join, a claim, genesis).
176
+ * @property {string | null} role The writer's role, null likewise.
172
177
  * @property {(ref: string | { name: string }, query?: string | Record<string, unknown>) => Promise<{ data: unknown }>} get
173
178
  * @property {(ref: string | { name: string }, row: Record<string, unknown>) => Promise<void>} put
174
179
  * @property {(ref: string | { name: string }, row: Record<string, unknown>) => Promise<void>} set
@@ -179,14 +184,23 @@ export type HookFn = (ctx: HookContext) => unknown;
179
184
  * Multi-writer database built on Autobee + HyperDB.
180
185
  */
181
186
  export declare class Database extends ReadyResource {
182
- store: any;
187
+ /** @type {import('corestore')} */
188
+ store: import('corestore');
183
189
  identity: Identity;
184
190
  network: import("../index.js").Network;
185
191
  spec: {
186
- database: any;
187
- dispatch: any;
192
+ database: object;
193
+ dispatch: {
194
+ Router: new () => object;
195
+ encode: (name: string, value: unknown) => Uint8Array;
196
+ decode: (buf: Uint8Array) => {
197
+ name: string;
198
+ value: unknown;
199
+ };
200
+ };
188
201
  meta?: {
189
202
  ns?: string;
203
+ version?: number;
190
204
  refs?: Record<string, {
191
205
  kind?: string;
192
206
  verb?: string;
@@ -195,6 +209,7 @@ export declare class Database extends ReadyResource {
195
209
  };
196
210
  meta: {
197
211
  ns?: string;
212
+ version?: number;
198
213
  refs?: Record<string, {
199
214
  kind?: string;
200
215
  verb?: string;
@@ -205,9 +220,9 @@ export declare class Database extends ReadyResource {
205
220
  kind?: string;
206
221
  verb?: string;
207
222
  }>;
208
- version: any;
209
- behind: any;
210
- routes: Record<string, Function>;
223
+ version: number;
224
+ /** @type {number | null} */
225
+ behind: number | null;
211
226
  namespace: string;
212
227
  encryptionKey: Uint8Array<ArrayBufferLike>;
213
228
  keyring: Keyring;
@@ -215,7 +230,10 @@ export declare class Database extends ReadyResource {
215
230
  key: Uint8Array<ArrayBufferLike>;
216
231
  pinned: boolean;
217
232
  keyPair: import("../index.js").KeyPair;
218
- _onerror: (err: Error) => void;
233
+ /** @private */
234
+ _onerror;
235
+ /** @private */
236
+ _room;
219
237
  bee: EpochAutobee;
220
238
  dispatcher: {
221
239
  dispatch: (value: Buffer, ctx: object) => Promise<void>;
@@ -224,19 +242,32 @@ export declare class Database extends ReadyResource {
224
242
  key: Buffer;
225
243
  }>, view: object, host: object) => Promise<void>;
226
244
  };
227
- _presence: import("../network/presence.js").Slot;
228
- _txChain: any;
229
- _before: Map<any, any>;
230
- _after: Map<any, any>;
231
- _hooking: number;
232
- _verbs: Map<any, any>;
233
- _touched: Set<any>;
234
- _seq: number;
235
- txQueue: any;
245
+ /** @private */
246
+ _presence;
247
+ /** @private */
248
+ _txChain;
249
+ /** @private */
250
+ _held;
251
+ /** @private */
252
+ _before;
253
+ /** @private */
254
+ _after;
255
+ /** @private */
256
+ _hooking;
257
+ /** @private */
258
+ _verbs;
259
+ /** @private */
260
+ _touched;
261
+ /** @private */
262
+ _seq;
263
+ /** @type {Array<[string, unknown]> | null} */
264
+ txQueue: Array<[string, unknown]> | null;
236
265
  /** @param {Partial<DatabaseOpts>} [opts] */
237
266
  constructor(opts?: Partial<DatabaseOpts>);
238
267
  /** @returns {Uint8Array | null} discovery key of the underlying bee */
239
268
  get discoveryKey(): Uint8Array | null;
269
+ /** @returns {Uint8Array | null} where a join is sealed to: the address the encryption key owns */
270
+ get address(): Uint8Array | null;
240
271
  /** @returns {Uint8Array | null} this device's local writer key */
241
272
  get writerKey(): Uint8Array | null;
242
273
  /** @returns {boolean} whether the bee accepts local writes */
@@ -245,8 +276,10 @@ export declare class Database extends ReadyResource {
245
276
  get length(): number;
246
277
  /** @returns {object | null} the materialized HyperDB view */
247
278
  get view(): object | null;
248
- _open(): Promise<void>;
249
- _close(): Promise<void>;
279
+ /** @private */
280
+ private _open;
281
+ /** @private */
282
+ private _close;
250
283
  /**
251
284
  * `true` ranks this database as just touched, `false` takes it out of the swarm until the
252
285
  * next update lands in it.
@@ -258,37 +291,39 @@ export declare class Database extends ReadyResource {
258
291
  * Register a pre-op hook. It runs at apply on every peer, inside the op's transaction;
259
292
  * returning `false` (or throwing) refuses the op everywhere.
260
293
  *
261
- * @param {string} op
294
+ * @param {string} op A write (`put`, `set`, `del`), or an action's name.
262
295
  * @param {HookFn} fn
263
296
  * @returns {() => void} disposer
264
297
  */
265
298
  before(op: string, fn: HookFn): () => void;
266
299
  /**
267
300
  * Register a post-op hook. It runs at apply on every peer, in the op's transaction, so it
268
- * may write derived rows through `ctx.put` / `ctx.set` / `ctx.del`.
301
+ * may write derived rows through `ctx.put` / `ctx.set` / `ctx.del`. On an action it is what
302
+ * the action does.
269
303
  *
270
- * @param {string} op
304
+ * @param {string} op A write (`put`, `set`, `del`), or an action's name.
271
305
  * @param {HookFn} fn
272
306
  * @returns {() => void} disposer
273
307
  */
274
308
  after(op: string, fn: HookFn): () => void;
275
309
  /**
276
- * Insert (or overwrite by id) a row, stamping `id`/`createdAt`/`updatedAt`.
310
+ * Insert (or overwrite by id) a row, stamping `id`/`createdAt`/`updatedAt`: an overwrite keeps
311
+ * the row's `createdAt`, and timestamps the caller passes are ignored.
277
312
  *
278
313
  * @param {string} name
279
- * @param {Record<string, any>} row
314
+ * @param {Record<string, unknown>} row
280
315
  * @returns {Promise<SingleResult | null>}
281
316
  */
282
- put(name: string, row: Record<string, any>): Promise<SingleResult | null>;
317
+ put(name: string, row: Record<string, unknown>): Promise<SingleResult | null>;
283
318
  /**
284
319
  * Upsert by merging with the existing row, preserving `createdAt`.
285
320
  *
286
321
  * @param {string} name
287
- * @param {Record<string, any>} row
322
+ * @param {Record<string, unknown>} row
288
323
  * @param {{ upsert?: boolean }} [opts]
289
324
  * @returns {Promise<SingleResult | null>}
290
325
  */
291
- set(name: string, row: Record<string, any>, opts?: {
326
+ set(name: string, row: Record<string, unknown>, opts?: {
292
327
  upsert?: boolean;
293
328
  }): Promise<SingleResult | null>;
294
329
  /**
@@ -300,13 +335,13 @@ export declare class Database extends ReadyResource {
300
335
  */
301
336
  del(name: string, id?: string): Promise<void | null>;
302
337
  /**
303
- * Dispatch a custom action route by name.
338
+ * Run a declared action: what the `after` hooks on its name do, at apply on every peer.
304
339
  *
305
340
  * @param {string} op
306
- * @param {Record<string, any>} [data]
341
+ * @param {Record<string, unknown>} [data]
307
342
  * @returns {Promise<void>}
308
343
  */
309
- call(op: string, data?: Record<string, any>): Promise<void>;
344
+ call(op: string, data?: Record<string, unknown>): Promise<void>;
310
345
  /**
311
346
  * Rotate the encryption epoch: generate a fresh 32-byte secret, seal it to every current
312
347
  * member's identity key, and announce it through the log.
@@ -325,14 +360,16 @@ export declare class Database extends ReadyResource {
325
360
  * @returns {Promise<T>}
326
361
  */
327
362
  tx<T>(fn: (tx: Database) => Promise<T> | T): Promise<T>;
363
+ /** @private */
364
+ private _chain;
328
365
  /**
329
366
  * Encode and append dispatch ops. Buffers into the active `tx` queue if one
330
367
  * is open.
331
368
  *
332
- * @param {Array<[string, any]>} ops
369
+ * @param {Array<[string, unknown]>} ops
333
370
  * @returns {Promise<void>}
334
371
  */
335
- write(ops: Array<[string, any]>): Promise<void>;
372
+ write(ops: Array<[string, unknown]>): Promise<void>;
336
373
  /**
337
374
  * Read a row. With no `query`: list all (collection) or fetch the one
338
375
  * record (single). With a string id: fetch that specific row.
@@ -342,15 +379,8 @@ export declare class Database extends ReadyResource {
342
379
  * @returns {Promise<SingleResult | ListResult>}
343
380
  */
344
381
  get(name: string, query?: string | Query): Promise<SingleResult | ListResult>;
345
- _read(view: any, name: any, query: any): Promise<{
346
- data: any;
347
- total?: undefined;
348
- size?: undefined;
349
- } | {
350
- data: any[];
351
- total: any;
352
- size: number;
353
- }>;
382
+ /** @private */
383
+ private _read;
354
384
  /**
355
385
  * Live snapshot stream — re-emits the latest `get()` result on every
356
386
  * underlying mutation. Destroy the stream to stop watching.
@@ -401,14 +431,12 @@ export declare class Database extends ReadyResource {
401
431
  timeout?: number;
402
432
  }): Promise<void>;
403
433
  /**
404
- * Admit a device as a writer for `memberId`, an existing member. Omit it to
405
- * admit another device of this identity.
434
+ * Admit another device of this identity as a writer. Another member's device seats itself.
406
435
  *
407
436
  * @param {Uint8Array} publicKey
408
- * @param {string} [memberId]
409
437
  * @returns {Promise<void>}
410
438
  */
411
- addWriter(publicKey: Uint8Array, memberId?: string): Promise<void>;
439
+ addWriter(publicKey: Uint8Array): Promise<void>;
412
440
  /**
413
441
  * Remove a peer's writer key from the indexer set.
414
442
  *
@@ -436,59 +464,56 @@ export declare class Database extends ReadyResource {
436
464
  * @returns {string}
437
465
  */
438
466
  col(ref: Ref): string;
439
- _preload(): Promise<void>;
440
- _boot(): Promise<void>;
441
- _replay(): Promise<boolean>;
442
- _isTrusted(writer: any, view: any): Promise<boolean>;
443
- _apply(nodes: any, view: any, host: any): Promise<void>;
444
- _update(db: any): Promise<void>;
445
- _joinSwarm(bee: any, discoveryKey: any): void;
446
- _hooks(phase: any, op: any): any;
447
- _inHook(fn: any): (ctx: any) => Promise<any>;
448
- onUpdate(name: any, fn: any): () => this;
449
- _opOf(node: any): {
450
- op: any;
451
- name: any;
452
- value: any;
453
- };
454
- _notify(nodes: any): void;
455
- _merge(name: any, row: any, { upsert }?: {
456
- upsert?: boolean;
457
- }): Promise<{
458
- row: any;
459
- }>;
460
- _prepare(name: any, row: any): Ref;
461
- _append(stored: any, verb: any): Promise<{
462
- row: any;
463
- }>;
464
- _done(ctx: any): {
465
- data: any;
466
- };
467
- _onfuture(version: any): void;
468
- _dryRun(encoded: any): Promise<any>;
469
- _plan(name: any, query?: {}): {
470
- path: string;
471
- range: {
472
- gte: {};
473
- lte: {};
474
- };
475
- rest: {};
476
- sorted: boolean;
477
- } | {
478
- path: string;
479
- range: {};
480
- rest: {};
481
- sorted: boolean;
482
- };
483
- _total(view: any, path: any, range: any, matched: any, query: any): Promise<any>;
484
- _optimistic(op: any, opts: any): Promise<void>;
485
- _backfilled(timeout: any): Promise<void>;
486
- _admission(writer: any, ts?: number): {
487
- master: Uint8Array<ArrayBufferLike>;
488
- writer: any;
489
- sig: Uint8Array<ArrayBufferLike>;
490
- ts: number;
491
- };
492
- _checkFields(name: any, row: any): void;
493
- _admit(verb: any, publicKey: any, memberId: any): Promise<void>;
467
+ /** @private */
468
+ private _preload;
469
+ /** @private */
470
+ private _boot;
471
+ /** @private */
472
+ private _replay;
473
+ /** @private */
474
+ private _isTrusted;
475
+ /** @private */
476
+ private _apply;
477
+ /** @private */
478
+ private _update;
479
+ /** @private */
480
+ private _joinSwarm;
481
+ /** @private */
482
+ private _holdRoom;
483
+ /** @private */
484
+ private _hold;
485
+ /** @private */
486
+ private _hooks;
487
+ /** @private */
488
+ private _inHook;
489
+ /** @param {string} name @param {() => void} fn @returns {() => void} */
490
+ onUpdate(name: string, fn: () => void): () => void;
491
+ /** @private */
492
+ private _opOf;
493
+ /** @private */
494
+ private _notify;
495
+ /** @private */
496
+ private _merge;
497
+ /** @private */
498
+ private _prepare;
499
+ /** @private */
500
+ private _append;
501
+ /** @private */
502
+ private _done;
503
+ /** @private */
504
+ private _onfuture;
505
+ /** @private */
506
+ private _dryRun;
507
+ /** @private */
508
+ private _plan;
509
+ /** @private */
510
+ private _total;
511
+ /** @private */
512
+ private _optimistic;
513
+ /** @private */
514
+ private _backfilled;
515
+ /** @private */
516
+ private _admission;
517
+ /** @private */
518
+ private _admit;
494
519
  }
@@ -9,12 +9,21 @@ export declare class Rotation {
9
9
  stamp: number;
10
10
  epoch: number;
11
11
  };
12
- _timer: number;
13
- _healedFor: any;
12
+ /** @private */
13
+ _queue;
14
+ /** @private */
15
+ _timer;
16
+ /** @private */
17
+ _healedFor;
14
18
  /** @param {import('./index.js').Database} db */
15
19
  constructor(db: import('./index.js').Database);
16
20
  close(): void;
17
- /** @returns {Promise<{ epoch: number }>} */
21
+ /**
22
+ * One at a time: a rotation asked for during another runs after it, sealed to the members as
23
+ * they stand then.
24
+ *
25
+ * @returns {Promise<{ epoch: number }>}
26
+ */
18
27
  rotate(): Promise<{
19
28
  epoch: number;
20
29
  }>;
@@ -36,14 +45,24 @@ export declare class Rotation {
36
45
  hydrate(): Promise<void>;
37
46
  /** Debounced audit, run after every update. */
38
47
  heal(): void;
39
- _rotate(retried: any): any;
40
- _members(): Promise<any[]>;
41
- _seal(members: any, entropy: any): any;
42
- _announce(stamp: any, entropy: any, wrapped: any): Promise<number>;
43
- _mint(): number;
44
- _taken(stamp: any): Promise<any>;
45
- _epochs(): any;
46
- _unseal(row: any): Uint8Array<ArrayBufferLike>;
47
- _save(): any;
48
- _audit(): Promise<void>;
48
+ /** @private */
49
+ private _rotate;
50
+ /** @private */
51
+ private _members;
52
+ /** @private */
53
+ private _announce;
54
+ /** @private */
55
+ private _mint;
56
+ /** @private */
57
+ private _taken;
58
+ /** @private */
59
+ private _epochs;
60
+ /** @private */
61
+ private _unseal;
62
+ /** @private */
63
+ private _save;
64
+ /** @private */
65
+ private _audit;
66
+ /** @private */
67
+ private _heal;
49
68
  }
@@ -86,63 +86,29 @@ export declare class Identity {
86
86
  */
87
87
  toPhrase(): string;
88
88
  /**
89
- * Build an identity from 16- or 32-byte entropy.
89
+ * An identity from its seed, 16 or 32 bytes; a fresh one without.
90
90
  *
91
- * @param {Uint8Array} seed
92
- * @returns {Promise<Identity>}
93
- */
94
- static fromSeed(seed: Uint8Array): Promise<Identity>;
95
- /**
96
- * Build an identity from a BIP-39 mnemonic.
97
- *
98
- * @param {string} phrase
91
+ * @param {{ seed?: Uint8Array | null, words?: 12 | 24 }} [opts] `words` sizes a fresh one.
99
92
  * @returns {Promise<Identity>}
100
93
  */
101
- static fromPhrase(phrase: string): Promise<Identity>;
102
- /**
103
- * Generate a fresh identity from CSPRNG entropy.
104
- *
105
- * @param {{ words?: 12 | 24 }} [opts]
106
- * @returns {Promise<Identity>}
107
- */
108
- static generate({ words }?: {
94
+ static create({ seed, words }?: {
95
+ seed?: Uint8Array | null;
109
96
  words?: 12 | 24;
110
97
  }): Promise<Identity>;
111
98
  /**
112
- * Generate a random BIP-39 mnemonic.
113
- *
114
- * @param {12 | 24} [words]
115
- * @returns {string}
116
- */
117
- static genPhrase(words?: 12 | 24): string;
118
- /**
119
- * Phrase → seed entropy.
99
+ * The seed a BIP-39 phrase writes out.
120
100
  *
121
101
  * @param {string} phrase
122
102
  * @returns {Uint8Array}
123
103
  */
124
104
  static toSeed(phrase: string): Uint8Array;
125
105
  /**
126
- * Seed entropy → phrase.
106
+ * A seed written out as a BIP-39 phrase.
127
107
  *
128
108
  * @param {Uint8Array} seed
129
109
  * @returns {string}
130
110
  */
131
111
  static toPhrase(seed: Uint8Array): string;
132
- /**
133
- * Validate that a value is a 16- or 32-byte buffer.
134
- *
135
- * @param {any} x
136
- * @returns {x is Uint8Array}
137
- */
138
- static isSeed(x: any): x is Uint8Array;
139
- /**
140
- * Validate that a string is a BIP-39 mnemonic.
141
- *
142
- * @param {unknown} x
143
- * @returns {x is string}
144
- */
145
- static isPhrase(x: unknown): x is string;
146
112
  /**
147
113
  * Verify a signature against an arbitrary public key.
148
114
  *
@@ -174,11 +140,4 @@ export declare class Identity {
174
140
  * @returns {Uint8Array}
175
141
  */
176
142
  static randomBytes(n?: number): Uint8Array;
177
- /**
178
- * Fresh seed entropy sized for the chosen mnemonic length.
179
- *
180
- * @param {12 | 24} [words]
181
- * @returns {Uint8Array}
182
- */
183
- static randomSeed(words?: 12 | 24): Uint8Array;
184
143
  }
package/types/index.d.ts CHANGED
@@ -9,37 +9,24 @@
9
9
  export * from './identity/index.js';
10
10
  export { Storage } from './storage/index.js';
11
11
  export type StorageRef = import('./storage/index.js').Ref;
12
- export type StorageSingleResult = import('./storage/index.js').SingleResult;
13
- export type StorageListResult = import('./storage/index.js').ListResult;
14
12
  export type StorageOpts = import('./storage/index.js').StorageOpts;
15
- export type StoredRow = import('./storage/index.js').StoredRow;
16
- export type GetByIdResult = import('./storage/index.js').GetByIdResult;
17
13
  /**
18
- * `Ref` / `SingleResult` / `ListResult` are JSDoc typedefs (types, not runtime exports),
19
- * so they are re-exported as namespaced type aliases — `export { Ref as StorageRef }`
20
- * fails at import because the.
14
+ * The database exports its `Ref` already, so storage's typedefs come under storage names; rows
15
+ * and results are the database's.
21
16
  *
22
17
  * @typedef {import('./storage/index.js').Ref} StorageRef
23
- * @typedef {import('./storage/index.js').SingleResult} StorageSingleResult
24
- * @typedef {import('./storage/index.js').ListResult} StorageListResult
25
18
  * @typedef {import('./storage/index.js').StorageOpts} StorageOpts
26
- * @typedef {import('./storage/index.js').StoredRow} StoredRow
27
- * @typedef {import('./storage/index.js').GetByIdResult} GetByIdResult
28
19
  */
29
20
  export * from './network/index.js';
30
21
  export * from './database/index.js';
31
22
  export * from './blobs/index.js';
32
23
  export * from './rpc/index.js';
24
+ export * from './mailbox/index.js';
33
25
  export * from './pairing/index.js';
34
26
  export { Invite } from './pairing/invite.js';
35
- export type MintInviteOpts = import('./pairing/invite.js').CreateInviteOpts;
36
27
  export type InviteFields = import('./pairing/invite.js').InviteFields;
37
- export type ParseInviteOpts = import('./pairing/invite.js').ParseInviteOpts;
38
28
  /**
39
- * `CreateInviteOpts` is a typedef (not a runtime export); re-export it as a type alias.
40
- * @typedef {import('./pairing/invite.js').CreateInviteOpts} MintInviteOpts
41
29
  * @typedef {import('./pairing/invite.js').InviteFields} InviteFields
42
- * @typedef {import('./pairing/invite.js').ParseInviteOpts} ParseInviteOpts
43
30
  */
44
31
  export * from './lib/schema.js';
45
32
  export * from './lib/utils.js';
@@ -32,3 +32,4 @@ export declare const NAMESPACE = "cero";
32
32
  export declare const QUERY_RESERVED: Set<string>;
33
33
  export declare const COUNTERS = "counters";
34
34
  export declare const EPOCHS = "epochs";
35
+ export declare const REMOVALS = "removals";