@cero-base/cero 2.3.3 → 2.4.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 +1 -1
- package/package.json +8 -7
- package/src/build/index.js +1 -7
- package/src/build/internal.js +14 -16
- package/src/build/schemas.js +13 -50
- package/src/extensions/profile-sync.js +8 -2
- package/src/handle/index.js +54 -140
- package/src/handle/join.js +7 -12
- package/src/index.js +43 -76
- package/src/lib/bluetooth.js +96 -84
- package/src/lib/operators.js +43 -36
- package/src/lib/refs.js +2 -2
- package/src/rpc/client.js +57 -50
- package/src/rpc/server.js +77 -88
- package/types/build/schemas.d.ts +8 -43
- package/types/extensions/index.d.ts +5 -3
- package/types/handle/index.d.ts +7 -63
- package/types/index.d.ts +17 -40
- package/types/lib/bluetooth.d.ts +29 -24
- package/types/lib/operators.d.ts +21 -17
- package/types/lib/refs.d.ts +2 -2
- package/types/rpc/client.d.ts +7 -3
- package/types/rpc/server.d.ts +7 -12
package/types/build/schemas.d.ts
CHANGED
|
@@ -62,12 +62,6 @@ export declare const main: {
|
|
|
62
62
|
stamp: import("@cero-base/core").Prim;
|
|
63
63
|
from: import("@cero-base/core").Prim;
|
|
64
64
|
};
|
|
65
|
-
claim: {
|
|
66
|
-
identity: import("@cero-base/core").Prim;
|
|
67
|
-
writer: import("@cero-base/core").Prim;
|
|
68
|
-
sig: import("@cero-base/core").Prim;
|
|
69
|
-
ts: import("@cero-base/core").Prim;
|
|
70
|
-
};
|
|
71
65
|
epoch: {
|
|
72
66
|
epoch: import("@cero-base/core").Prim;
|
|
73
67
|
wrapped: import("@cero-base/core").Prim;
|
|
@@ -127,6 +121,10 @@ export declare const main: {
|
|
|
127
121
|
reason: import("@cero-base/core").Prim;
|
|
128
122
|
expires: import("@cero-base/core").Prim;
|
|
129
123
|
};
|
|
124
|
+
deny: {
|
|
125
|
+
id: import("@cero-base/core").Prim;
|
|
126
|
+
reason: import("@cero-base/core").Prim;
|
|
127
|
+
};
|
|
130
128
|
};
|
|
131
129
|
export declare const local: {
|
|
132
130
|
master: {
|
|
@@ -203,37 +201,24 @@ export declare const rpc: {
|
|
|
203
201
|
op: import("@cero-base/core").Prim;
|
|
204
202
|
data: import("@cero-base/core").Prim;
|
|
205
203
|
};
|
|
206
|
-
'req-
|
|
204
|
+
'req-verb': {
|
|
207
205
|
handle: import("@cero-base/core").Prim;
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
reuse: import("@cero-base/core").Prim;
|
|
211
|
-
data: import("@cero-base/core").Prim;
|
|
212
|
-
confirm: import("@cero-base/core").Prim;
|
|
213
|
-
};
|
|
214
|
-
'req-revoke': {
|
|
215
|
-
handle: import("@cero-base/core").Prim;
|
|
216
|
-
invite: import("@cero-base/core").Prim;
|
|
206
|
+
verb: import("@cero-base/core").Prim;
|
|
207
|
+
args: import("@cero-base/core").Prim;
|
|
217
208
|
};
|
|
218
209
|
'req-join': {
|
|
219
210
|
parent: import("@cero-base/core").Prim;
|
|
220
211
|
ref: import("@cero-base/core").Prim;
|
|
221
212
|
invite: import("@cero-base/core").Prim;
|
|
222
213
|
};
|
|
223
|
-
'req-cancel': {
|
|
224
|
-
invite: import("@cero-base/core").Prim;
|
|
225
|
-
};
|
|
226
214
|
'req-open': {
|
|
227
215
|
parent: import("@cero-base/core").Prim;
|
|
228
216
|
row: import("@cero-base/core").Prim;
|
|
217
|
+
type: import("@cero-base/core").Prim;
|
|
229
218
|
};
|
|
230
219
|
'req-handle': {
|
|
231
220
|
handle: import("@cero-base/core").Prim;
|
|
232
221
|
};
|
|
233
|
-
'req-set-active': {
|
|
234
|
-
handle: import("@cero-base/core").Prim;
|
|
235
|
-
active: import("@cero-base/core").Prim;
|
|
236
|
-
};
|
|
237
222
|
'res-data': {
|
|
238
223
|
data: import("@cero-base/core").Prim;
|
|
239
224
|
};
|
|
@@ -242,9 +227,6 @@ export declare const rpc: {
|
|
|
242
227
|
total: import("@cero-base/core").Prim;
|
|
243
228
|
size: import("@cero-base/core").Prim;
|
|
244
229
|
};
|
|
245
|
-
'res-invite': {
|
|
246
|
-
invite: import("@cero-base/core").Prim;
|
|
247
|
-
};
|
|
248
230
|
'res-handle': {
|
|
249
231
|
id: import("@cero-base/core").Prim;
|
|
250
232
|
type: import("@cero-base/core").Prim;
|
|
@@ -265,30 +247,13 @@ export declare const rpc: {
|
|
|
265
247
|
fileToken: import("@cero-base/core").Prim;
|
|
266
248
|
deviceName: import("@cero-base/core").Prim;
|
|
267
249
|
};
|
|
268
|
-
'res-seed': {
|
|
269
|
-
phrase: import("@cero-base/core").Prim;
|
|
270
|
-
};
|
|
271
250
|
'res-ok': {
|
|
272
251
|
ok: import("@cero-base/core").Prim;
|
|
273
252
|
};
|
|
274
|
-
'res-epoch': {
|
|
275
|
-
epoch: import("@cero-base/core").Prim;
|
|
276
|
-
};
|
|
277
253
|
'res-error': {
|
|
278
254
|
message: import("@cero-base/core").Prim;
|
|
279
255
|
code: import("@cero-base/core").Prim;
|
|
280
256
|
stack: import("@cero-base/core").Prim;
|
|
281
257
|
reason: import("@cero-base/core").Prim;
|
|
282
258
|
};
|
|
283
|
-
'req-answer': {
|
|
284
|
-
handle: import("@cero-base/core").Prim;
|
|
285
|
-
id: import("@cero-base/core").Prim;
|
|
286
|
-
accept: import("@cero-base/core").Prim;
|
|
287
|
-
role: import("@cero-base/core").Prim;
|
|
288
|
-
reason: import("@cero-base/core").Prim;
|
|
289
|
-
};
|
|
290
|
-
'req-nearby': {
|
|
291
|
-
on: import("@cero-base/core").Prim;
|
|
292
|
-
invite: import("@cero-base/core").Prim;
|
|
293
|
-
};
|
|
294
259
|
};
|
|
@@ -47,10 +47,12 @@ export declare const cero: {
|
|
|
47
47
|
cancel(me: operators.Context, code: string): Promise<boolean>;
|
|
48
48
|
suspend(me: operators.Context): Promise<void>;
|
|
49
49
|
resume(me: operators.Context): Promise<void>;
|
|
50
|
-
activate(
|
|
51
|
-
deactivate(
|
|
50
|
+
activate(ctx: operators.Context): Promise<void>;
|
|
51
|
+
deactivate(ctx: operators.Context): Promise<void>;
|
|
52
52
|
phrase(me: operators.Context): Promise<string>;
|
|
53
|
-
nearby(ctx: operators.Context,
|
|
53
|
+
nearby(ctx: operators.Context, on: boolean, opts?: {
|
|
54
|
+
topic?: string;
|
|
55
|
+
}): Promise<void>;
|
|
54
56
|
t: {
|
|
55
57
|
string: import("@cero-base/core").Prim;
|
|
56
58
|
uint: import("@cero-base/core").Prim;
|
package/types/handle/index.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ export type HandleOpts = {
|
|
|
31
31
|
*/
|
|
32
32
|
spec?: Spec;
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
34
|
+
* Root only, and required there: the device store for handle keypairs, joins and mail.
|
|
35
35
|
*/
|
|
36
36
|
local?: Local;
|
|
37
37
|
/**
|
|
@@ -75,10 +75,6 @@ export type HandleOpts = {
|
|
|
75
75
|
* Writer keypair.
|
|
76
76
|
*/
|
|
77
77
|
keyPair?: KeyPair;
|
|
78
|
-
/**
|
|
79
|
-
* When `false`, skips creating a `Pairing` session.
|
|
80
|
-
*/
|
|
81
|
-
pair?: boolean;
|
|
82
78
|
/**
|
|
83
79
|
* Root only: the radio, up before the root opens.
|
|
84
80
|
*/
|
|
@@ -99,19 +95,6 @@ export type CreateChildOpts = {
|
|
|
99
95
|
export type JoinChildOpts = {
|
|
100
96
|
timeout?: number;
|
|
101
97
|
};
|
|
102
|
-
export type StaticJoinOpts = {
|
|
103
|
-
parent?: Handle;
|
|
104
|
-
network?: Network;
|
|
105
|
-
identity?: Identity;
|
|
106
|
-
store?: import('corestore');
|
|
107
|
-
spec?: Spec;
|
|
108
|
-
namespace?: string;
|
|
109
|
-
/**
|
|
110
|
-
* Writer keypair in the joined handle; a fresh one by default.
|
|
111
|
-
*/
|
|
112
|
-
writer?: KeyPair;
|
|
113
|
-
timeout?: number;
|
|
114
|
-
};
|
|
115
98
|
export type HandleExtra = {
|
|
116
99
|
/**
|
|
117
100
|
* Display name; set on child handles by the owner flow.
|
|
@@ -140,7 +123,7 @@ export type Context = Handle & Record<string, import('../lib/refs.js').Ref>;
|
|
|
140
123
|
* @property {Network} [network] Shared swarm. Inherited from `parent` if omitted.
|
|
141
124
|
* @property {import('corestore')} [store] Pre-existing Corestore. Falls back to `parent.store.store`.
|
|
142
125
|
* @property {Spec} [spec] Built cero spec.
|
|
143
|
-
* @property {Local} [local]
|
|
126
|
+
* @property {Local} [local] Root only, and required there: the device store for handle keypairs, joins and mail.
|
|
144
127
|
* @property {import('hypercore-storage')} [storage] Owned HypercoreStorage to close on shutdown.
|
|
145
128
|
* @property {{ destroy(): Promise<void> }} [discovery] Owned identity discovery to destroy on shutdown.
|
|
146
129
|
* @property {string} [dir] Data directory (root handles only).
|
|
@@ -150,7 +133,6 @@ export type Context = Handle & Record<string, import('../lib/refs.js').Ref>;
|
|
|
150
133
|
* @property {Array<{ epoch: number, entropy: Uint8Array }>} [epochs] Rotation epochs delivered at join.
|
|
151
134
|
* @property {string} [namespace] Corestore namespace.
|
|
152
135
|
* @property {KeyPair} [keyPair] Writer keypair.
|
|
153
|
-
* @property {boolean} [pair] When `false`, skips creating a `Pairing` session.
|
|
154
136
|
* @property {import('../lib/bluetooth.js').Bluetooth | null} [bluetooth] Root only: the radio, up before the root opens.
|
|
155
137
|
* @property {{ name?: string | null, isMobile?: boolean, recovering?: boolean, timeout?: number } | null} [bootstrap] Root only: provision this device as it opens, its genesis or its recovery.
|
|
156
138
|
*
|
|
@@ -160,16 +142,6 @@ export type Context = Handle & Record<string, import('../lib/refs.js').Ref>;
|
|
|
160
142
|
* @typedef {object} JoinChildOpts
|
|
161
143
|
* @property {number} [timeout]
|
|
162
144
|
*
|
|
163
|
-
* @typedef {object} StaticJoinOpts
|
|
164
|
-
* @property {Handle} [parent]
|
|
165
|
-
* @property {Network} [network]
|
|
166
|
-
* @property {Identity} [identity]
|
|
167
|
-
* @property {import('corestore')} [store]
|
|
168
|
-
* @property {Spec} [spec]
|
|
169
|
-
* @property {string} [namespace]
|
|
170
|
-
* @property {KeyPair} [writer] Writer keypair in the joined handle; a fresh one by default.
|
|
171
|
-
* @property {number} [timeout]
|
|
172
|
-
*
|
|
173
145
|
* @typedef {object} HandleExtra
|
|
174
146
|
* @property {string | null} [name] Display name; set on child handles by the owner flow.
|
|
175
147
|
* @property {import('../lib/refs.js').Ref} [profile] `profile` ref, attached dynamically when the schema declares one.
|
|
@@ -177,7 +149,7 @@ export type Context = Handle & Record<string, import('../lib/refs.js').Ref>;
|
|
|
177
149
|
*
|
|
178
150
|
* @typedef {Handle & HandleExtra} Child A child handle plus its dynamically-attached refs.
|
|
179
151
|
*
|
|
180
|
-
* @typedef {Handle & Record<string, import('../lib/refs.js').Ref>} Context
|
|
152
|
+
* @typedef {Handle & Record<string, import('../lib/refs.js').Ref>} Context The root or an opened handle, with its refs (`me.profile`, `room.messages`).
|
|
181
153
|
*/
|
|
182
154
|
/**
|
|
183
155
|
* A cero handle — a single writable database session attached to a swarm.
|
|
@@ -230,8 +202,6 @@ export declare class Handle extends ReadyResource {
|
|
|
230
202
|
/** @private */
|
|
231
203
|
_pair;
|
|
232
204
|
/** @private */
|
|
233
|
-
_wantsPair;
|
|
234
|
-
/** @private */
|
|
235
205
|
_boot;
|
|
236
206
|
/** @private */
|
|
237
207
|
_bluetooth;
|
|
@@ -265,13 +235,13 @@ export declare class Handle extends ReadyResource {
|
|
|
265
235
|
/** The handle type of a child, null on the root. */
|
|
266
236
|
get type(): string;
|
|
267
237
|
/**
|
|
268
|
-
* Canonical id: the identity id on the root, the database key on a
|
|
238
|
+
* Canonical id: the identity id on the root, the database key on a handle.
|
|
269
239
|
*
|
|
270
240
|
* @returns {string | null}
|
|
271
241
|
*/
|
|
272
242
|
get id(): string | null;
|
|
273
243
|
/**
|
|
274
|
-
* This device's id and name. `null` on a
|
|
244
|
+
* This device's id and name. `null` on a handle.
|
|
275
245
|
*
|
|
276
246
|
* @returns {{ id: string, name: string | null } | null}
|
|
277
247
|
*/
|
|
@@ -298,13 +268,6 @@ export declare class Handle extends ReadyResource {
|
|
|
298
268
|
}>(resource: T): T;
|
|
299
269
|
/** @private */
|
|
300
270
|
private _link;
|
|
301
|
-
/**
|
|
302
|
-
* Claim writer capability on an existing database (paired-device flow).
|
|
303
|
-
* Forwards to `Database.claim`.
|
|
304
|
-
*
|
|
305
|
-
* @returns {Promise<void>}
|
|
306
|
-
*/
|
|
307
|
-
claim(): Promise<void>;
|
|
308
271
|
/** @private */
|
|
309
272
|
private _invite;
|
|
310
273
|
/** @private */
|
|
@@ -340,8 +303,6 @@ export declare class Handle extends ReadyResource {
|
|
|
340
303
|
/** @private */
|
|
341
304
|
private _nameOf;
|
|
342
305
|
/** @private */
|
|
343
|
-
private _onPeers;
|
|
344
|
-
/** @private */
|
|
345
306
|
private _onRadio;
|
|
346
307
|
/** @private */
|
|
347
308
|
private _joins;
|
|
@@ -428,8 +389,8 @@ export declare class Handle extends ReadyResource {
|
|
|
428
389
|
*/
|
|
429
390
|
private _load;
|
|
430
391
|
/**
|
|
431
|
-
* Reconstruct a child handle by id. Reuses the stored writer keypair if
|
|
432
|
-
*
|
|
392
|
+
* Reconstruct a child handle by id. Reuses the stored writer keypair if available; otherwise
|
|
393
|
+
* stores a fresh one, and a device that may write claims its seat with it.
|
|
433
394
|
*
|
|
434
395
|
* @param {string} type
|
|
435
396
|
* @param {string} id
|
|
@@ -464,21 +425,4 @@ export declare class Handle extends ReadyResource {
|
|
|
464
425
|
* @private
|
|
465
426
|
*/
|
|
466
427
|
private _loadKeyPair;
|
|
467
|
-
/**
|
|
468
|
-
* Pair into an existing handle via an invite, returning a brand-new `Handle` opened with the
|
|
469
|
-
* delivered keys. A one-shot join: the root's `_join` is the one that survives restarts.
|
|
470
|
-
*
|
|
471
|
-
* @param {string} invite
|
|
472
|
-
* @param {StaticJoinOpts} [opts]
|
|
473
|
-
* @returns {Promise<Handle>}
|
|
474
|
-
*/
|
|
475
|
-
static join(invite: string, { parent, network, identity, store, spec, namespace, writer, timeout }?: StaticJoinOpts): Promise<Handle>;
|
|
476
|
-
/**
|
|
477
|
-
* A handle opened with the keys a pairing reply delivered.
|
|
478
|
-
*
|
|
479
|
-
* @param {import('@cero-base/core/pairing').JoinResult} reply
|
|
480
|
-
* @param {Omit<HandleOpts, 'key' | 'encryptionKey' | 'epochs' | 'keyPair'>} opts
|
|
481
|
-
* @returns {Handle}
|
|
482
|
-
*/
|
|
483
|
-
static fromReply(reply: import('@cero-base/core/pairing').JoinResult, opts: Omit<HandleOpts, 'key' | 'encryptionKey' | 'epochs' | 'keyPair'>): Handle;
|
|
484
428
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Identity } from '@cero-base/core/identity';
|
|
2
1
|
import { Handle, Ref } from './handle/index.js';
|
|
3
2
|
import { Local } from './local/index.js';
|
|
4
3
|
import * as verbs from './lib/operators.js';
|
|
@@ -11,13 +10,9 @@ export { t, schema } from './lib/spec.js';
|
|
|
11
10
|
export type Context = import('./handle/index.js').Context;
|
|
12
11
|
export type CeroOpts = {
|
|
13
12
|
/**
|
|
14
|
-
*
|
|
13
|
+
* The identity's BIP-39 phrase, as `cero.phrase(me)` gives it: on a new `dir` it recovers that identity.
|
|
15
14
|
*/
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* 16- or 32-byte seed entropy: `toSeed(phrase)` restores from a phrase.
|
|
19
|
-
*/
|
|
20
|
-
seed?: Uint8Array;
|
|
15
|
+
phrase?: string;
|
|
21
16
|
/**
|
|
22
17
|
* Mnemonic length when generating a fresh identity.
|
|
23
18
|
*/
|
|
@@ -46,25 +41,17 @@ export type CeroOpts = {
|
|
|
46
41
|
*/
|
|
47
42
|
channel?: string;
|
|
48
43
|
/**
|
|
49
|
-
* Blind-peer public keys.
|
|
44
|
+
* Blind-peer public keys. Handles and files are mirrored through them so peers sync even when never online at the same time. Mirrors hold only encrypted blocks — they never read your data.
|
|
50
45
|
*/
|
|
51
46
|
mirrors?: Array<string | Uint8Array>;
|
|
52
47
|
/**
|
|
53
|
-
* How many
|
|
48
|
+
* How many handles search, how many only announce, and the idle ms before the rest leave the swarm.
|
|
54
49
|
*/
|
|
55
50
|
presence?: {
|
|
56
51
|
active?: number;
|
|
57
52
|
announced?: number;
|
|
58
53
|
idle?: number;
|
|
59
54
|
};
|
|
60
|
-
/**
|
|
61
|
-
* Existing database key to recover into, skipping the pointer lookup.
|
|
62
|
-
*/
|
|
63
|
-
key?: Uint8Array;
|
|
64
|
-
/**
|
|
65
|
-
* Pre-existing encryption key.
|
|
66
|
-
*/
|
|
67
|
-
encryptionKey?: Uint8Array;
|
|
68
55
|
/**
|
|
69
56
|
* Where background errors go; the console without one.
|
|
70
57
|
*/
|
|
@@ -82,11 +69,12 @@ export type CeroOpts = {
|
|
|
82
69
|
*/
|
|
83
70
|
extensions?: import('./extensions/index.js').Extension[];
|
|
84
71
|
/**
|
|
85
|
-
* `
|
|
72
|
+
* Bluetooth at start: `on` (off by default) and `topic` (the default one, else the channel's own); the app turns the radio on and off with `cero.nearby`, and nothing is stored. `maxOutbound`/`maxInbound` cap concurrent outbound links and inbound sessions. `pipe` picks the data pipe, `'l2cap'` (default, faster) or `'gatt'`; both peers must match. `backend` injects a bare-bluetooth-shaped backend (tests); with none on the host, `status.nearby` reads `'unsupported'`.
|
|
86
73
|
*/
|
|
87
|
-
bluetooth?:
|
|
88
|
-
|
|
89
|
-
|
|
74
|
+
bluetooth?: {
|
|
75
|
+
on?: boolean;
|
|
76
|
+
topic?: string;
|
|
77
|
+
backend?: object | null;
|
|
90
78
|
maxOutbound?: number;
|
|
91
79
|
maxInbound?: number;
|
|
92
80
|
pipe?: 'l2cap' | 'gatt';
|
|
@@ -97,23 +85,20 @@ export type CeroOpts = {
|
|
|
97
85
|
*/
|
|
98
86
|
/**
|
|
99
87
|
* @typedef {object} CeroOpts
|
|
100
|
-
* @property {
|
|
101
|
-
* @property {Uint8Array} [seed] 16- or 32-byte seed entropy: `toSeed(phrase)` restores from a phrase.
|
|
88
|
+
* @property {string} [phrase] The identity's BIP-39 phrase, as `cero.phrase(me)` gives it: on a new `dir` it recovers that identity.
|
|
102
89
|
* @property {12 | 24} [words] Mnemonic length when generating a fresh identity.
|
|
103
90
|
* @property {string | null} [name] Friendly device name persisted on the identity claim.
|
|
104
91
|
* @property {boolean} [isMobile] Marks this device as mobile.
|
|
105
92
|
* @property {Array<{ host: string, port: number }>} [bootstrap] Custom DHT bootstrap nodes.
|
|
106
93
|
* @property {number[]} [backoffs] Swarm reconnect backoff tiers in ms (testing/tuning).
|
|
107
94
|
* @property {string} [channel] Optional network-isolation label; only same-channel peers connect.
|
|
108
|
-
* @property {Array<string | Uint8Array>} [mirrors] Blind-peer public keys.
|
|
109
|
-
* @property {{ active?: number, announced?: number, idle?: number }} [presence] How many
|
|
110
|
-
* @property {Uint8Array} [key] Existing database key to recover into, skipping the pointer lookup.
|
|
111
|
-
* @property {Uint8Array} [encryptionKey] Pre-existing encryption key.
|
|
95
|
+
* @property {Array<string | Uint8Array>} [mirrors] Blind-peer public keys. Handles and files are mirrored through them so peers sync even when never online at the same time. Mirrors hold only encrypted blocks — they never read your data.
|
|
96
|
+
* @property {{ active?: number, announced?: number, idle?: number }} [presence] How many handles search, how many only announce, and the idle ms before the rest leave the swarm.
|
|
112
97
|
* @property {(err: Error) => void} [onerror] Where background errors go; the console without one.
|
|
113
98
|
* @property {number} [recoveryTimeout] Max wait to find another device and be admitted, in ms. Defaults to 30000.
|
|
114
99
|
* @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.
|
|
115
100
|
* @property {import('./extensions/index.js').Extension[]} [extensions] The extensions this instance runs, instead of the ones the spec carries. Build with the same list.
|
|
116
|
-
* @property {
|
|
101
|
+
* @property {{ on?: boolean, topic?: string, backend?: object | null, maxOutbound?: number, maxInbound?: number, pipe?: 'l2cap' | 'gatt' }} [bluetooth] Bluetooth at start: `on` (off by default) and `topic` (the default one, else the channel's own); the app turns the radio on and off with `cero.nearby`, and nothing is stored. `maxOutbound`/`maxInbound` cap concurrent outbound links and inbound sessions. `pipe` picks the data pipe, `'l2cap'` (default, faster) or `'gatt'`; both peers must match. `backend` injects a bare-bluetooth-shaped backend (tests); with none on the host, `status.nearby` reads `'unsupported'`.
|
|
117
102
|
*/
|
|
118
103
|
/**
|
|
119
104
|
* Open (or create) a cero handle at `dir`.
|
|
@@ -125,25 +110,17 @@ export type CeroOpts = {
|
|
|
125
110
|
*/
|
|
126
111
|
declare function start(dir: string, spec: import('./lib/spec.js').Spec, opts?: CeroOpts): Promise<Context>;
|
|
127
112
|
/**
|
|
128
|
-
* Restore a cero instance from a
|
|
113
|
+
* Restore a cero instance from a recovery phrase.
|
|
129
114
|
*
|
|
130
115
|
* @param {Context} me The root to restore.
|
|
131
|
-
* @param {
|
|
116
|
+
* @param {string} phrase The identity's BIP-39 phrase, as `cero.phrase(me)` gives it.
|
|
132
117
|
* @returns {Promise<Handle>} Freshly restored root handle.
|
|
133
118
|
*/
|
|
134
|
-
export declare function restore(me: Context,
|
|
135
|
-
/**
|
|
136
|
-
* The seed a BIP-39 phrase writes out, for `cero(dir, spec, { seed })` and `restore(me, seed)`.
|
|
137
|
-
*
|
|
138
|
-
* @param {string} phrase
|
|
139
|
-
* @returns {Uint8Array}
|
|
140
|
-
*/
|
|
141
|
-
export declare function toSeed(phrase: string): Uint8Array;
|
|
142
|
-
/** @type {typeof start & typeof verbs & { t: typeof t, schema: typeof schema, peek: typeof peek, restore: typeof restore, toSeed: typeof toSeed }} */
|
|
119
|
+
export declare function restore(me: Context, phrase: string): Promise<Handle>;
|
|
120
|
+
/** @type {typeof start & typeof verbs & { t: typeof t, schema: typeof schema, peek: typeof peek, restore: typeof restore }} */
|
|
143
121
|
export declare const cero: typeof start & typeof verbs & {
|
|
144
122
|
t: typeof t;
|
|
145
123
|
schema: typeof schema;
|
|
146
124
|
peek: typeof peek;
|
|
147
125
|
restore: typeof restore;
|
|
148
|
-
toSeed: typeof toSeed;
|
|
149
126
|
};
|
package/types/lib/bluetooth.d.ts
CHANGED
|
@@ -7,17 +7,17 @@ import ReadyResource from 'ready-resource';
|
|
|
7
7
|
*/
|
|
8
8
|
export declare class Bluetooth extends ReadyResource {
|
|
9
9
|
/** @private */
|
|
10
|
-
|
|
10
|
+
_on;
|
|
11
11
|
/** @private */
|
|
12
|
-
|
|
13
|
-
/** @
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
_info;
|
|
13
|
+
/** @private */
|
|
14
|
+
_heard;
|
|
15
|
+
/** @private */
|
|
16
|
+
_senders;
|
|
17
|
+
/** @private */
|
|
18
|
+
_links;
|
|
19
19
|
/** @private */
|
|
20
|
-
|
|
20
|
+
_base;
|
|
21
21
|
/** @private */
|
|
22
22
|
_topic;
|
|
23
23
|
/** @private */
|
|
@@ -32,16 +32,18 @@ export declare class Bluetooth extends ReadyResource {
|
|
|
32
32
|
* @param {import('@cero-base/core/identity').Identity} opts.identity Signs this device's key for the peers it links with.
|
|
33
33
|
* @param {import('@cero-base/core/identity').KeyPair} opts.keyPair This device's writer keypair.
|
|
34
34
|
* @param {object | null} [opts.backend] Injected bare-bluetooth-shaped backend (tests); omitted → ble-swarm loads its own, null/false → unsupported.
|
|
35
|
-
* @param {boolean} [opts.
|
|
35
|
+
* @param {boolean} [opts.on] The radio at open; off unless `true`. Nothing is stored.
|
|
36
|
+
* @param {string} [opts.topic] The default topic; without one, the channel's own.
|
|
36
37
|
* @param {number} [opts.maxOutbound] Max concurrent outbound links; gossip covers the rest.
|
|
37
38
|
* @param {number} [opts.maxInbound] Max concurrent inbound sessions; newcomers past this are refused.
|
|
38
39
|
* @param {'l2cap' | 'gatt'} [opts.pipe] Data pipe — 'l2cap' (default, faster) or 'gatt'. Both peers must match.
|
|
39
40
|
*/
|
|
40
|
-
constructor(network: import('@cero-base/core/network').Network,
|
|
41
|
+
constructor(network: import('@cero-base/core/network').Network, opts: {
|
|
41
42
|
identity: import('@cero-base/core/identity').Identity;
|
|
42
43
|
keyPair: import('@cero-base/core/identity').KeyPair;
|
|
43
44
|
backend?: object | null;
|
|
44
|
-
|
|
45
|
+
on?: boolean;
|
|
46
|
+
topic?: string;
|
|
45
47
|
maxOutbound?: number;
|
|
46
48
|
maxInbound?: number;
|
|
47
49
|
pipe?: 'l2cap' | 'gatt';
|
|
@@ -52,6 +54,17 @@ export declare class Bluetooth extends ReadyResource {
|
|
|
52
54
|
get peers(): Map<string, object>;
|
|
53
55
|
/** @private */
|
|
54
56
|
private _open;
|
|
57
|
+
/**
|
|
58
|
+
* Turn the radio on or off, on `opts.topic` or else the default topic. A new topic drops the
|
|
59
|
+
* links on the old one.
|
|
60
|
+
*
|
|
61
|
+
* @param {boolean} on
|
|
62
|
+
* @param {{ topic?: string }} [opts]
|
|
63
|
+
* @returns {Promise<void>}
|
|
64
|
+
*/
|
|
65
|
+
set(on: boolean, opts?: {
|
|
66
|
+
topic?: string;
|
|
67
|
+
}): Promise<void>;
|
|
55
68
|
/** @private */
|
|
56
69
|
private _close;
|
|
57
70
|
/**
|
|
@@ -63,6 +76,8 @@ export declare class Bluetooth extends ReadyResource {
|
|
|
63
76
|
name: string | null;
|
|
64
77
|
isMobile: boolean;
|
|
65
78
|
}): void;
|
|
79
|
+
/** @private */
|
|
80
|
+
private _say;
|
|
66
81
|
/**
|
|
67
82
|
* Who a linked device says it is: its person, who signed the key it links with, its name and
|
|
68
83
|
* whether it is a phone. `null` until it said, or when that signature is not its person's.
|
|
@@ -82,19 +97,11 @@ export declare class Bluetooth extends ReadyResource {
|
|
|
82
97
|
*/
|
|
83
98
|
start(): Promise<void>;
|
|
84
99
|
/**
|
|
85
|
-
* Stop advertising/scanning and drop links
|
|
100
|
+
* Stop advertising/scanning and drop links.
|
|
86
101
|
*
|
|
87
102
|
* @returns {Promise<void>}
|
|
88
103
|
*/
|
|
89
104
|
stop(): Promise<void>;
|
|
90
|
-
/**
|
|
91
|
-
* Offline join rendezvous: retune the radio to the invite-derived topic so holder and
|
|
92
|
-
* joiner find each other with zero DHT.
|
|
93
|
-
*
|
|
94
|
-
* @param {string} invite Z32 invite string.
|
|
95
|
-
* @returns {() => void}
|
|
96
|
-
*/
|
|
97
|
-
announce(invite: string): () => void;
|
|
98
105
|
/**
|
|
99
106
|
* Host-lifecycle pause (app backgrounded): radio down, user intent kept.
|
|
100
107
|
*
|
|
@@ -108,7 +115,5 @@ export declare class Bluetooth extends ReadyResource {
|
|
|
108
115
|
*/
|
|
109
116
|
resume(): Promise<void>;
|
|
110
117
|
/** @private */
|
|
111
|
-
private
|
|
112
|
-
/** @private */
|
|
113
|
-
private _clearAnnounce;
|
|
118
|
+
private _attach;
|
|
114
119
|
}
|
package/types/lib/operators.d.ts
CHANGED
|
@@ -44,9 +44,9 @@ export declare function call(ref: Ref, d?: Row): Promise<void>;
|
|
|
44
44
|
* peer, inside the op's transaction. Return `false` to refuse it: the writer's own call rejects
|
|
45
45
|
* with `REFUSED`. `ctx` is `{ op, name, row, existing, id, memberId, role, get, put, set, del }`;
|
|
46
46
|
* mutate `ctx.row` to rewrite what is stored. `op` is the op as it applies, so an upsert on a
|
|
47
|
-
* collection is a `put`. The four operators on `ctx` read and write the
|
|
47
|
+
* collection is a `put`. The four operators on `ctx` read and write the handle as it stands at this
|
|
48
48
|
* op, inside the transaction. Must be deterministic: read only `ctx`, never a clock or local
|
|
49
|
-
* state. On a type ref (`me.room.notes`) it reaches every
|
|
49
|
+
* state. On a type ref (`me.room.notes`) it reaches every handle of the type before the handle
|
|
50
50
|
* opens; register in an extension's `setup` to see every op the root applies too. The imported
|
|
51
51
|
* operators throw inside a hook; use the ones on `ctx`. Not available over RPC.
|
|
52
52
|
*
|
|
@@ -110,7 +110,7 @@ export declare function open(ref: Ref, arg?: string | {
|
|
|
110
110
|
name?: string;
|
|
111
111
|
} | undefined): Promise<Context>;
|
|
112
112
|
/**
|
|
113
|
-
* Mint an invite code into a
|
|
113
|
+
* Mint an invite code into a handle.
|
|
114
114
|
*
|
|
115
115
|
* @param {Context} ctx
|
|
116
116
|
* @param {import('@cero-base/core/pairing').InviteOpts} [opts]
|
|
@@ -126,7 +126,7 @@ export declare function invite(ctx: Context, opts?: import('@cero-base/core/pair
|
|
|
126
126
|
*/
|
|
127
127
|
export declare function revoke(ctx: Context, code: string): Promise<boolean>;
|
|
128
128
|
/**
|
|
129
|
-
* Re-key a
|
|
129
|
+
* Re-key a handle now: a new epoch sealed to its members, so one removed before it reads nothing
|
|
130
130
|
* written after. Needs the remove permission. A removal also re-keys on its own shortly after it
|
|
131
131
|
* lands; this is the one to await.
|
|
132
132
|
*
|
|
@@ -138,7 +138,7 @@ export declare function rotate(ctx: Context): Promise<{
|
|
|
138
138
|
}>;
|
|
139
139
|
/**
|
|
140
140
|
* Write atomically: every write `fn` makes through `tx`, the context it is handed, lands as one
|
|
141
|
-
* batch, or none does. Reads through `tx` see the
|
|
141
|
+
* batch, or none does. Reads through `tx` see the handle as it was before the batch. Not available
|
|
142
142
|
* over RPC.
|
|
143
143
|
*
|
|
144
144
|
* @template T
|
|
@@ -172,7 +172,7 @@ export declare function deny(ctx: Context, request: {
|
|
|
172
172
|
id: string;
|
|
173
173
|
}, reason?: string): Promise<void>;
|
|
174
174
|
/**
|
|
175
|
-
* Quit a
|
|
175
|
+
* Quit a handle for good: it leaves your list and closes on this device.
|
|
176
176
|
*
|
|
177
177
|
* @param {Context} ctx
|
|
178
178
|
* @returns {Promise<void>}
|
|
@@ -209,20 +209,20 @@ export declare function suspend(me: Context): Promise<void>;
|
|
|
209
209
|
*/
|
|
210
210
|
export declare function resume(me: Context): Promise<void>;
|
|
211
211
|
/**
|
|
212
|
-
* Mark a
|
|
212
|
+
* Mark a handle as the one in use: it ranks first on the swarm, searching and announcing. Handles are
|
|
213
213
|
* otherwise ranked by their last update.
|
|
214
214
|
*
|
|
215
|
-
* @param {Context}
|
|
215
|
+
* @param {Context} ctx
|
|
216
216
|
* @returns {Promise<void>}
|
|
217
217
|
*/
|
|
218
|
-
export declare function activate(
|
|
218
|
+
export declare function activate(ctx: Context): Promise<void>;
|
|
219
219
|
/**
|
|
220
|
-
* Take a
|
|
220
|
+
* Take a handle off the swarm until something lands in it.
|
|
221
221
|
*
|
|
222
|
-
* @param {Context}
|
|
222
|
+
* @param {Context} ctx
|
|
223
223
|
* @returns {Promise<void>}
|
|
224
224
|
*/
|
|
225
|
-
export declare function deactivate(
|
|
225
|
+
export declare function deactivate(ctx: Context): Promise<void>;
|
|
226
226
|
/**
|
|
227
227
|
* Reveal the recovery phrase.
|
|
228
228
|
*
|
|
@@ -231,12 +231,16 @@ export declare function deactivate(room: Context): Promise<void>;
|
|
|
231
231
|
*/
|
|
232
232
|
export declare function phrase(me: Context): Promise<string>;
|
|
233
233
|
/**
|
|
234
|
-
*
|
|
235
|
-
*
|
|
236
|
-
*
|
|
234
|
+
* Turn the device's Bluetooth radio on or off, on `opts.topic` or else the default topic: the one
|
|
235
|
+
* `cero()` opened with, or the channel's own. On, it links with the devices in range on the same
|
|
236
|
+
* channel and topic, and everything syncs and joins over those links as over the internet.
|
|
237
|
+
* Nothing is stored: the app sets it at every start.
|
|
237
238
|
*
|
|
238
239
|
* @param {Context} ctx
|
|
239
|
-
* @param {boolean
|
|
240
|
+
* @param {boolean} on
|
|
241
|
+
* @param {{ topic?: string }} [opts]
|
|
240
242
|
* @returns {Promise<void>}
|
|
241
243
|
*/
|
|
242
|
-
export declare function nearby(ctx: Context,
|
|
244
|
+
export declare function nearby(ctx: Context, on: boolean, opts?: {
|
|
245
|
+
topic?: string;
|
|
246
|
+
}): Promise<void>;
|
package/types/lib/refs.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export declare class Ref {
|
|
|
18
18
|
schema: string;
|
|
19
19
|
type: string;
|
|
20
20
|
/**
|
|
21
|
-
* @param {Owner} handle The root, a
|
|
21
|
+
* @param {Owner} handle The root, a handle or the local store the ref lives on.
|
|
22
22
|
* @param {string} name Ref name as declared in the schema.
|
|
23
23
|
* @param {string} kind Ref kind: `'collection'`, `'single'`, `'action'`, or `'handle'`.
|
|
24
24
|
* @param {string | null} [schema] Fully-qualified schema id, if any.
|
|
@@ -31,7 +31,7 @@ export declare class Ref {
|
|
|
31
31
|
*
|
|
32
32
|
* @param {Owner} target
|
|
33
33
|
* @param {Record<string, RefInfo>} refs
|
|
34
|
-
* @param {Record<string, Spec>} [handles] The handle types, so `target.room.notes` names every
|
|
34
|
+
* @param {Record<string, Spec>} [handles] The handle types, so `target.room.notes` names every handle's notes.
|
|
35
35
|
*/
|
|
36
36
|
static attach(target: Owner, refs: Record<string, RefInfo>, handles?: Record<string, Spec>): void;
|
|
37
37
|
}
|
package/types/rpc/client.d.ts
CHANGED
|
@@ -39,10 +39,12 @@ declare const remote: {
|
|
|
39
39
|
cancel(me: verbs.Context, code: string): Promise<boolean>;
|
|
40
40
|
suspend(me: verbs.Context): Promise<void>;
|
|
41
41
|
resume(me: verbs.Context): Promise<void>;
|
|
42
|
-
activate(
|
|
43
|
-
deactivate(
|
|
42
|
+
activate(ctx: verbs.Context): Promise<void>;
|
|
43
|
+
deactivate(ctx: verbs.Context): Promise<void>;
|
|
44
44
|
phrase(me: verbs.Context): Promise<string>;
|
|
45
|
-
nearby(ctx: verbs.Context,
|
|
45
|
+
nearby(ctx: verbs.Context, on: boolean, opts?: {
|
|
46
|
+
topic?: string;
|
|
47
|
+
}): Promise<void>;
|
|
46
48
|
};
|
|
47
49
|
export declare const put: typeof verbs.put, set: typeof verbs.set, get: typeof verbs.get, del: typeof verbs.del, watch: typeof verbs.watch, call: typeof verbs.call, open: typeof verbs.open, invite: typeof verbs.invite, revoke: typeof verbs.revoke, rotate: typeof verbs.rotate, accept: typeof verbs.accept, deny: typeof verbs.deny, leave: typeof verbs.leave, close: typeof verbs.close, cancel: typeof verbs.cancel, suspend: typeof verbs.suspend, resume: typeof verbs.resume, activate: typeof verbs.activate, deactivate: typeof verbs.deactivate, phrase: typeof verbs.phrase, nearby: typeof verbs.nearby;
|
|
48
50
|
export { t, schema };
|
|
@@ -120,6 +122,8 @@ export declare class Client extends RPCClient {
|
|
|
120
122
|
private _pumpErrors;
|
|
121
123
|
/** @private */
|
|
122
124
|
private _open;
|
|
125
|
+
/** @private */
|
|
126
|
+
private _identify;
|
|
123
127
|
/**
|
|
124
128
|
* Create a new child handle of the given type.
|
|
125
129
|
*
|