@cero-base/cero 1.1.1 → 1.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/README.md +53 -24
- package/package.json +18 -7
- package/src/bluetooth.js +190 -0
- package/src/build/index.js +17 -4
- package/src/build/schemas.js +3 -1
- package/src/extensions/handle-sync.js +14 -3
- package/src/extensions/profile-sync.js +10 -2
- package/src/handle/index.js +39 -11
- package/src/index.js +57 -11
- package/src/lib/internal.js +7 -1
- package/src/lib/operators.js +38 -18
- package/src/local/index.js +4 -2
- package/src/rpc/client.js +18 -5
- package/src/rpc/server.js +30 -7
- package/types/bluetooth.d.ts +66 -0
- package/types/build/index.d.ts +2 -1
- package/types/build/schemas.d.ts +2 -0
- package/types/extensions/handle-sync.d.ts +2 -0
- package/types/extensions/profile-sync.d.ts +2 -0
- package/types/handle/index.d.ts +14 -0
- package/types/index.d.ts +19 -1
- package/types/lib/internal.d.ts +22 -1
- package/types/lib/operators.d.ts +1 -7
- package/types/local/index.d.ts +6 -1
- package/src/CLAUDE.md +0 -3
- package/src/build/CLAUDE.md +0 -3
- package/src/extensions/CLAUDE.md +0 -3
- package/src/handle/CLAUDE.md +0 -3
- package/src/lib/CLAUDE.md +0 -3
- package/src/rpc/CLAUDE.md +0 -3
package/types/handle/index.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ export { Ref } from "../lib/utils.js";
|
|
|
20
20
|
* @property {Uint8Array} [encryptionKey] Existing encryption key.
|
|
21
21
|
* @property {string} [namespace] Corestore namespace.
|
|
22
22
|
* @property {KeyPair} [keyPair] Writer keypair.
|
|
23
|
+
* @property {boolean} [passive] Join discovery server-only; flip later with `setActive`.
|
|
23
24
|
* @property {boolean} [pair] When `false`, skips creating a `Pairing` session.
|
|
24
25
|
*
|
|
25
26
|
* @typedef {object} CreateChildOpts
|
|
@@ -195,6 +196,15 @@ export class Handle extends ReadyResource {
|
|
|
195
196
|
* @returns {Promise<void>}
|
|
196
197
|
*/
|
|
197
198
|
recover({ timeout }?: RecoverOpts): Promise<void>;
|
|
199
|
+
/**
|
|
200
|
+
* Flip this handle's swarm announce mode — `setActive(false)` demotes an
|
|
201
|
+
* idle/background room to server-only (still reachable, stops searching);
|
|
202
|
+
* `setActive(true)` promotes it back on focus. Cheap, safe to call often.
|
|
203
|
+
*
|
|
204
|
+
* @param {boolean} active
|
|
205
|
+
* @returns {Promise<void>}
|
|
206
|
+
*/
|
|
207
|
+
setActive(active: boolean): Promise<void>;
|
|
198
208
|
/**
|
|
199
209
|
* Mint a pairing invite for this handle.
|
|
200
210
|
*
|
|
@@ -368,6 +378,10 @@ export type HandleOpts = {
|
|
|
368
378
|
* Writer keypair.
|
|
369
379
|
*/
|
|
370
380
|
keyPair?: KeyPair;
|
|
381
|
+
/**
|
|
382
|
+
* Join discovery server-only; flip later with `setActive`.
|
|
383
|
+
*/
|
|
384
|
+
passive?: boolean;
|
|
371
385
|
/**
|
|
372
386
|
* When `false`, skips creating a `Pairing` session.
|
|
373
387
|
*/
|
package/types/index.d.ts
CHANGED
|
@@ -17,6 +17,9 @@
|
|
|
17
17
|
* @property {(err: any) => void} [onerror] Background-task error handler.
|
|
18
18
|
* @property {boolean} [recovery] Recovery flow — wipe local state and re-claim a writer slot.
|
|
19
19
|
* @property {number} [recoveryTimeout] Max wait for peer data + writer capability during recovery.
|
|
20
|
+
* @property {Uint8Array} [storageKey] 32-byte key encrypting local key material (master seed, device keypairs) at rest. Source it from the OS keychain — cero never stores it.
|
|
21
|
+
* @property {boolean} [extensions] `false` disables the bundled extensions (profileSync, handleSync) for this instance. Build with `{ extensions: false }` too so the spec matches.
|
|
22
|
+
* @property {boolean | { autoStart?: boolean, backend?: any }} [bluetooth] `true` enables nearby (Bluetooth) sync via `me.bluetooth` (auto-started). `{ autoStart: false }` creates the facade without starting the radio — the app calls `me.bluetooth.start()`/`stop()` (user toggle). `backend` injects a bare-bluetooth-shaped backend (tests); absent backend on an unsupported host → `me.bluetooth.state === 'unsupported'`.
|
|
20
23
|
*/
|
|
21
24
|
/**
|
|
22
25
|
* Open (or create) a cero handle at `dir`. Sets up storage, network and
|
|
@@ -47,7 +50,7 @@ export namespace cero {
|
|
|
47
50
|
export { bind };
|
|
48
51
|
export { define };
|
|
49
52
|
export { internal as _internal };
|
|
50
|
-
export function use(...exts: any[]):
|
|
53
|
+
export function use(...exts: any[]): void;
|
|
51
54
|
}
|
|
52
55
|
/**
|
|
53
56
|
* Restore a cero instance from a mnemonic phrase. Closes the running
|
|
@@ -121,6 +124,21 @@ export type CeroOpts = {
|
|
|
121
124
|
* Max wait for peer data + writer capability during recovery.
|
|
122
125
|
*/
|
|
123
126
|
recoveryTimeout?: number;
|
|
127
|
+
/**
|
|
128
|
+
* 32-byte key encrypting local key material (master seed, device keypairs) at rest. Source it from the OS keychain — cero never stores it.
|
|
129
|
+
*/
|
|
130
|
+
storageKey?: Uint8Array;
|
|
131
|
+
/**
|
|
132
|
+
* `false` disables the bundled extensions (profileSync, handleSync) for this instance. Build with `{ extensions: false }` too so the spec matches.
|
|
133
|
+
*/
|
|
134
|
+
extensions?: boolean;
|
|
135
|
+
/**
|
|
136
|
+
* `true` enables nearby (Bluetooth) sync via `me.bluetooth` (auto-started). `{ autoStart: false }` creates the facade without starting the radio — the app calls `me.bluetooth.start()`/`stop()` (user toggle). `backend` injects a bare-bluetooth-shaped backend (tests); absent backend on an unsupported host → `me.bluetooth.state === 'unsupported'`.
|
|
137
|
+
*/
|
|
138
|
+
bluetooth?: boolean | {
|
|
139
|
+
autoStart?: boolean;
|
|
140
|
+
backend?: any;
|
|
141
|
+
};
|
|
124
142
|
};
|
|
125
143
|
import { t } from './lib/spec.js';
|
|
126
144
|
import { put } from './lib/operators.js';
|
package/types/lib/internal.d.ts
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
1
|
export namespace internal {
|
|
2
|
-
let extensions:
|
|
2
|
+
let extensions: ({
|
|
3
|
+
name: string;
|
|
4
|
+
bundled: boolean;
|
|
5
|
+
schema: {
|
|
6
|
+
profile: import("@cero-base/core").TypeDef;
|
|
7
|
+
members: {
|
|
8
|
+
kind: "extend";
|
|
9
|
+
fields: Record<string, import("@cero-base/core").Prim>;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
setup(me: any): void;
|
|
13
|
+
} | {
|
|
14
|
+
name: string;
|
|
15
|
+
bundled: boolean;
|
|
16
|
+
schema: {
|
|
17
|
+
handles: {
|
|
18
|
+
kind: "extend";
|
|
19
|
+
fields: Record<string, import("@cero-base/core").Prim>;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
setup(me: any): void;
|
|
23
|
+
})[];
|
|
3
24
|
}
|
package/types/lib/operators.d.ts
CHANGED
|
@@ -45,13 +45,7 @@ export function bind(handle: any, arg: Record<string, any> | string | null): any
|
|
|
45
45
|
export function define(map: Record<string, any>): void;
|
|
46
46
|
/** Test seam: clear all registered operators. */
|
|
47
47
|
export function _clearDefined(): void;
|
|
48
|
-
export function put(ref: Ref, row: Record<string, any>): Promise<SingleResult
|
|
49
|
-
id: string;
|
|
50
|
-
name?: string;
|
|
51
|
-
type: string;
|
|
52
|
-
size: number;
|
|
53
|
-
url: string;
|
|
54
|
-
}>;
|
|
48
|
+
export function put(ref: Ref, row: Record<string, any>): Promise<SingleResult>;
|
|
55
49
|
export function set(ref: Ref, row: Record<string, any>, opts?: {
|
|
56
50
|
upsert?: boolean;
|
|
57
51
|
}): Promise<SingleResult>;
|
package/types/local/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* @typedef {object} LocalOpts
|
|
3
3
|
* @property {any} [root] Pre-existing HypercoreStorage to reuse.
|
|
4
4
|
* @property {any} [store] Pre-existing Corestore to reuse.
|
|
5
|
+
* @property {Uint8Array} [storageKey] 32-byte key encrypting the local store at rest.
|
|
5
6
|
*/
|
|
6
7
|
/**
|
|
7
8
|
* Per-device, single-writer storage for cero — holds the master seed,
|
|
@@ -14,7 +15,7 @@ export class Local extends ReadyResource {
|
|
|
14
15
|
* @param {any} spec Built cero spec — must include `spec.local.database` and `spec.meta.local`.
|
|
15
16
|
* @param {LocalOpts} [opts]
|
|
16
17
|
*/
|
|
17
|
-
constructor(dir: string | null, spec: any, { root, store }?: LocalOpts);
|
|
18
|
+
constructor(dir: string | null, spec: any, { root, store, storageKey }?: LocalOpts);
|
|
18
19
|
dir: string;
|
|
19
20
|
spec: any;
|
|
20
21
|
store: Storage;
|
|
@@ -28,6 +29,10 @@ export type LocalOpts = {
|
|
|
28
29
|
* Pre-existing Corestore to reuse.
|
|
29
30
|
*/
|
|
30
31
|
store?: any;
|
|
32
|
+
/**
|
|
33
|
+
* 32-byte key encrypting the local store at rest.
|
|
34
|
+
*/
|
|
35
|
+
storageKey?: Uint8Array;
|
|
31
36
|
};
|
|
32
37
|
import ReadyResource from 'ready-resource';
|
|
33
38
|
import { Storage } from '@cero-base/core/storage';
|
package/src/CLAUDE.md
DELETED
package/src/build/CLAUDE.md
DELETED
package/src/extensions/CLAUDE.md
DELETED
package/src/handle/CLAUDE.md
DELETED
package/src/lib/CLAUDE.md
DELETED
package/src/rpc/CLAUDE.md
DELETED