@cero-base/cero 2.12.0 → 3.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.
- package/package.json +6 -5
- package/src/build/index.js +296 -57
- package/src/build/internal.js +80 -5
- package/src/build/schemas.js +118 -25
- package/src/extensions/profile-sync.js +17 -1
- package/src/handle/index.js +1217 -189
- package/src/index.js +68 -35
- package/src/lib/constants.js +4 -4
- package/src/lib/operators.js +53 -14
- package/src/lib/peek.js +14 -8
- package/src/lib/reserved.js +61 -0
- package/src/lib/spec.js +7 -1
- package/src/lib/swap.js +59 -6
- package/src/local/index.js +6 -2
- package/src/push/index.js +26 -13
- package/src/rpc/client.js +24 -10
- package/src/rpc/push.js +9 -3
- package/src/rpc/server.js +132 -51
- package/types/build/internal.d.ts +57 -0
- package/types/build/schemas.d.ts +58 -5
- package/types/extensions/index.d.ts +2 -0
- package/types/extensions/profile-sync.d.ts +1 -1
- package/types/handle/index.d.ts +121 -15
- package/types/index.d.ts +9 -6
- package/types/lib/constants.d.ts +2 -2
- package/types/lib/operators.d.ts +16 -6
- package/types/lib/peek.d.ts +7 -4
- package/types/lib/reserved.d.ts +1 -0
- package/types/lib/spec.d.ts +35 -2
- package/types/lib/swap.d.ts +28 -3
- package/types/push/index.d.ts +4 -12
- package/types/rpc/client.d.ts +34 -18
- package/types/rpc/server.d.ts +24 -3
- package/src/handle/join.js +0 -139
- package/types/handle/join.d.ts +0 -63
|
@@ -14,6 +14,10 @@ export declare const defs: {
|
|
|
14
14
|
};
|
|
15
15
|
handles: {
|
|
16
16
|
type: string;
|
|
17
|
+
indexes: {
|
|
18
|
+
state: string[];
|
|
19
|
+
type: string[];
|
|
20
|
+
};
|
|
17
21
|
};
|
|
18
22
|
files: {
|
|
19
23
|
type: string;
|
|
@@ -57,8 +61,20 @@ export declare const defs: {
|
|
|
57
61
|
topics: {
|
|
58
62
|
type: string;
|
|
59
63
|
};
|
|
64
|
+
told: {
|
|
65
|
+
type: string;
|
|
66
|
+
kind: string;
|
|
67
|
+
};
|
|
68
|
+
asks: {
|
|
69
|
+
type: string;
|
|
70
|
+
};
|
|
60
71
|
};
|
|
61
72
|
};
|
|
73
|
+
export declare const base: {
|
|
74
|
+
name: string;
|
|
75
|
+
type: string;
|
|
76
|
+
required: boolean;
|
|
77
|
+
}[];
|
|
62
78
|
export type RefInfo = import('../lib/spec.js').RefInfo;
|
|
63
79
|
export type FieldType = {
|
|
64
80
|
prim: string;
|
|
@@ -123,6 +139,25 @@ export declare function collections(ns: string, scope: 'main' | 'local'): Array<
|
|
|
123
139
|
schema: string;
|
|
124
140
|
key: string[];
|
|
125
141
|
}>;
|
|
142
|
+
/**
|
|
143
|
+
* @param {string} ns
|
|
144
|
+
* @returns {Array<{ name: string, schema: string, key: string[] }>}
|
|
145
|
+
*/
|
|
146
|
+
export declare function added(ns: string): Array<{
|
|
147
|
+
name: string;
|
|
148
|
+
schema: string;
|
|
149
|
+
key: string[];
|
|
150
|
+
}>;
|
|
151
|
+
/**
|
|
152
|
+
* @param {string} ns
|
|
153
|
+
* @param {'main' | 'local'} scope
|
|
154
|
+
* @returns {Array<{ name: string, collection: string, key: string[] }>}
|
|
155
|
+
*/
|
|
156
|
+
export declare function indexes(ns: string, scope: 'main' | 'local'): Array<{
|
|
157
|
+
name: string;
|
|
158
|
+
collection: string;
|
|
159
|
+
key: string[];
|
|
160
|
+
}>;
|
|
126
161
|
/**
|
|
127
162
|
* @param {string} ns
|
|
128
163
|
* @returns {Array<{ name: string, requestType: string }>}
|
|
@@ -131,6 +166,28 @@ export declare function dispatches(ns: string): Array<{
|
|
|
131
166
|
name: string;
|
|
132
167
|
requestType: string;
|
|
133
168
|
}>;
|
|
169
|
+
/**
|
|
170
|
+
* @param {string} ns
|
|
171
|
+
* @returns {Array<{ name: string, requestType: string }>}
|
|
172
|
+
*/
|
|
173
|
+
export declare function appended(ns: string): Array<{
|
|
174
|
+
name: string;
|
|
175
|
+
requestType: string;
|
|
176
|
+
}>;
|
|
177
|
+
/**
|
|
178
|
+
* The names Cero takes in a scope, which an app ref would shadow: its refs and collections, its
|
|
179
|
+
* types and its routes.
|
|
180
|
+
*
|
|
181
|
+
* @param {string} ns
|
|
182
|
+
* @param {'main' | 'local'} scope
|
|
183
|
+
* @param {boolean} root
|
|
184
|
+
* @returns {{ refs: Set<string>, types: Set<string>, routes: Set<string> }}
|
|
185
|
+
*/
|
|
186
|
+
export declare function reserved(ns: string, scope: 'main' | 'local', root: boolean): {
|
|
187
|
+
refs: Set<string>;
|
|
188
|
+
types: Set<string>;
|
|
189
|
+
routes: Set<string>;
|
|
190
|
+
};
|
|
134
191
|
/**
|
|
135
192
|
* @param {string} ns
|
|
136
193
|
* @returns {Array<{ name: string, request: { name: string }, response: { name: string, stream?: boolean } }>}
|
package/types/build/schemas.d.ts
CHANGED
|
@@ -34,6 +34,7 @@ export declare const main: {
|
|
|
34
34
|
index: import("@cero-base/core").Prim;
|
|
35
35
|
key: import("@cero-base/core").Prim;
|
|
36
36
|
proof: import("@cero-base/core").Prim;
|
|
37
|
+
chain: import("@cero-base/core").Prim;
|
|
37
38
|
};
|
|
38
39
|
invite: {
|
|
39
40
|
id: import("@cero-base/core").Prim;
|
|
@@ -43,6 +44,7 @@ export declare const main: {
|
|
|
43
44
|
createdAt: import("@cero-base/core").Prim;
|
|
44
45
|
index: import("@cero-base/core").Prim;
|
|
45
46
|
confirm: import("@cero-base/core").Prim;
|
|
47
|
+
secret: import("@cero-base/core").Prim;
|
|
46
48
|
};
|
|
47
49
|
handle: {
|
|
48
50
|
id: import("@cero-base/core").Prim;
|
|
@@ -54,6 +56,11 @@ export declare const main: {
|
|
|
54
56
|
updatedAt: import("@cero-base/core").Prim;
|
|
55
57
|
index: import("@cero-base/core").Prim;
|
|
56
58
|
epochs: import("@cero-base/core").Prim;
|
|
59
|
+
state: import("@cero-base/core").Prim;
|
|
60
|
+
reason: import("@cero-base/core").Prim;
|
|
61
|
+
by: import("@cero-base/core").Prim;
|
|
62
|
+
invite: import("@cero-base/core").Prim;
|
|
63
|
+
writer: import("@cero-base/core").Prim;
|
|
57
64
|
};
|
|
58
65
|
file: {
|
|
59
66
|
id: import("@cero-base/core").Prim;
|
|
@@ -71,9 +78,11 @@ export declare const main: {
|
|
|
71
78
|
createdAt: import("@cero-base/core").Prim;
|
|
72
79
|
commit: import("@cero-base/core").Prim;
|
|
73
80
|
stamp: import("@cero-base/core").Prim;
|
|
81
|
+
aside: import("@cero-base/core").Prim;
|
|
74
82
|
};
|
|
75
83
|
join: {
|
|
76
84
|
box: import("@cero-base/core").Prim;
|
|
85
|
+
invite: import("@cero-base/core").Prim;
|
|
77
86
|
};
|
|
78
87
|
accept: {
|
|
79
88
|
id: import("@cero-base/core").Prim;
|
|
@@ -91,10 +100,17 @@ export declare const main: {
|
|
|
91
100
|
expires: import("@cero-base/core").Prim;
|
|
92
101
|
role: import("@cero-base/core").Prim;
|
|
93
102
|
key: import("@cero-base/core").Prim;
|
|
103
|
+
promised: import("@cero-base/core").Prim;
|
|
104
|
+
proof: import("@cero-base/core").Prim;
|
|
105
|
+
accepted: import("@cero-base/core").Prim;
|
|
94
106
|
};
|
|
95
107
|
removal: {
|
|
96
108
|
id: import("@cero-base/core").Prim;
|
|
97
109
|
index: import("@cero-base/core").Prim;
|
|
110
|
+
by: import("@cero-base/core").Prim;
|
|
111
|
+
removed: import("@cero-base/core").Prim;
|
|
112
|
+
standing: import("@cero-base/core").Prim;
|
|
113
|
+
spent: import("@cero-base/core").Prim;
|
|
98
114
|
};
|
|
99
115
|
status: {
|
|
100
116
|
role: import("@cero-base/core").Prim;
|
|
@@ -102,12 +118,9 @@ export declare const main: {
|
|
|
102
118
|
epoch: import("@cero-base/core").Prim;
|
|
103
119
|
suspended: import("@cero-base/core").Prim;
|
|
104
120
|
behind: import("@cero-base/core").Prim;
|
|
121
|
+
version: import("@cero-base/core").Prim;
|
|
105
122
|
nearby: import("@cero-base/core").Prim;
|
|
106
|
-
|
|
107
|
-
joining: {
|
|
108
|
-
id: import("@cero-base/core").Prim;
|
|
109
|
-
type: import("@cero-base/core").Prim;
|
|
110
|
-
invite: import("@cero-base/core").Prim;
|
|
123
|
+
owed: import("@cero-base/core").Prim;
|
|
111
124
|
};
|
|
112
125
|
peer: {
|
|
113
126
|
id: import("@cero-base/core").Prim;
|
|
@@ -120,11 +133,20 @@ export declare const main: {
|
|
|
120
133
|
reply: import("@cero-base/core").Prim;
|
|
121
134
|
reason: import("@cero-base/core").Prim;
|
|
122
135
|
expires: import("@cero-base/core").Prim;
|
|
136
|
+
invite: import("@cero-base/core").Prim;
|
|
137
|
+
spent: import("@cero-base/core").Prim;
|
|
138
|
+
identity: import("@cero-base/core").Prim;
|
|
123
139
|
};
|
|
124
140
|
spent: {
|
|
125
141
|
id: import("@cero-base/core").Prim;
|
|
126
142
|
reason: import("@cero-base/core").Prim;
|
|
127
143
|
expires: import("@cero-base/core").Prim;
|
|
144
|
+
secret: import("@cero-base/core").Prim;
|
|
145
|
+
confirm: import("@cero-base/core").Prim;
|
|
146
|
+
};
|
|
147
|
+
owed: {
|
|
148
|
+
id: import("@cero-base/core").Prim;
|
|
149
|
+
reply: import("@cero-base/core").Prim;
|
|
128
150
|
};
|
|
129
151
|
deny: {
|
|
130
152
|
id: import("@cero-base/core").Prim;
|
|
@@ -136,6 +158,14 @@ export declare const main: {
|
|
|
136
158
|
type: import("@cero-base/core").Prim;
|
|
137
159
|
name: import("@cero-base/core").Prim;
|
|
138
160
|
};
|
|
161
|
+
upgrade: {
|
|
162
|
+
version: import("@cero-base/core").Prim;
|
|
163
|
+
};
|
|
164
|
+
revoke: {
|
|
165
|
+
removed: import("@cero-base/core").Prim;
|
|
166
|
+
standing: import("@cero-base/core").Prim;
|
|
167
|
+
proof: import("@cero-base/core").Prim;
|
|
168
|
+
};
|
|
139
169
|
};
|
|
140
170
|
export declare const local: {
|
|
141
171
|
master: {
|
|
@@ -158,6 +188,11 @@ export declare const local: {
|
|
|
158
188
|
publicKey: import("@cero-base/core").Prim;
|
|
159
189
|
secretKey: import("@cero-base/core").Prim;
|
|
160
190
|
encryptionKey: import("@cero-base/core").Prim;
|
|
191
|
+
invite: import("@cero-base/core").Prim;
|
|
192
|
+
used: import("@cero-base/core").Prim;
|
|
193
|
+
told: import("@cero-base/core").Prim;
|
|
194
|
+
stamp: import("@cero-base/core").Prim;
|
|
195
|
+
waited: import("@cero-base/core").Prim;
|
|
161
196
|
};
|
|
162
197
|
serving: {
|
|
163
198
|
id: import("@cero-base/core").Prim;
|
|
@@ -183,6 +218,8 @@ export declare const local: {
|
|
|
183
218
|
name: import("@cero-base/core").Prim;
|
|
184
219
|
erase: import("@cero-base/core").Prim;
|
|
185
220
|
fetched: import("@cero-base/core").Prim;
|
|
221
|
+
handled: import("@cero-base/core").Prim;
|
|
222
|
+
sealed: import("@cero-base/core").Prim;
|
|
186
223
|
};
|
|
187
224
|
environment: {
|
|
188
225
|
channel: import("@cero-base/core").Prim;
|
|
@@ -195,6 +232,21 @@ export declare const local: {
|
|
|
195
232
|
name: import("@cero-base/core").Prim;
|
|
196
233
|
encryptionKey: import("@cero-base/core").Prim;
|
|
197
234
|
epochs: import("@cero-base/core").Prim;
|
|
235
|
+
writers: import("@cero-base/core").Prim;
|
|
236
|
+
};
|
|
237
|
+
told: {
|
|
238
|
+
removed: import("@cero-base/core").Prim;
|
|
239
|
+
standing: import("@cero-base/core").Prim;
|
|
240
|
+
stamp: import("@cero-base/core").Prim;
|
|
241
|
+
};
|
|
242
|
+
ask: {
|
|
243
|
+
id: import("@cero-base/core").Prim;
|
|
244
|
+
handle: import("@cero-base/core").Prim;
|
|
245
|
+
type: import("@cero-base/core").Prim;
|
|
246
|
+
invite: import("@cero-base/core").Prim;
|
|
247
|
+
publicKey: import("@cero-base/core").Prim;
|
|
248
|
+
secretKey: import("@cero-base/core").Prim;
|
|
249
|
+
createdAt: import("@cero-base/core").Prim;
|
|
198
250
|
};
|
|
199
251
|
};
|
|
200
252
|
export declare const contract: {
|
|
@@ -219,6 +271,7 @@ export declare const rpc: {
|
|
|
219
271
|
fields: {
|
|
220
272
|
prim: string;
|
|
221
273
|
required?: boolean;
|
|
274
|
+
later?: boolean;
|
|
222
275
|
array: boolean;
|
|
223
276
|
};
|
|
224
277
|
};
|
|
@@ -18,6 +18,7 @@ export declare const cero: {
|
|
|
18
18
|
signal?: AbortSignal;
|
|
19
19
|
}): () => void;
|
|
20
20
|
get(ref: operators.Ref, q?: string | Record<string, unknown>): Promise<operators.SingleResult | operators.ListResult>;
|
|
21
|
+
supports(ref: operators.Ref, field?: string): Promise<boolean>;
|
|
21
22
|
watch(ref: operators.Ref, query?: string | (Record<string, unknown> & {
|
|
22
23
|
changes?: boolean;
|
|
23
24
|
}), opts?: {
|
|
@@ -83,6 +84,7 @@ export declare const cero: {
|
|
|
83
84
|
fixed64: import("@cero-base/core").Prim;
|
|
84
85
|
file: import("@cero-base/core").Prim;
|
|
85
86
|
required: (marker: import("@cero-base/core").Prim) => import("@cero-base/core").Prim;
|
|
87
|
+
later: <T extends import("@cero-base/core").Prim | import("@cero-base/core").TypeDef>(def: T) => T;
|
|
86
88
|
single(fields: Record<string, import("@cero-base/core").Prim>, opts?: {
|
|
87
89
|
push?: boolean;
|
|
88
90
|
}): import("@cero-base/core").TypeDef;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Mirror your `profile` onto your `member` row in every handle you're in.
|
|
2
|
+
* Mirror your `profile` onto your `member` row in every handle you're in, open or closed here.
|
|
3
3
|
*
|
|
4
4
|
* @param {{ fields?: Record<string, object> }} [opts] Extra fields, as `t` types.
|
|
5
5
|
* @returns {import('./index.js').Extension}
|
package/types/handle/index.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ export type HandleOpts = {
|
|
|
31
31
|
*/
|
|
32
32
|
spec?: Spec;
|
|
33
33
|
/**
|
|
34
|
-
* Root only, and required there: the device store for handle keypairs
|
|
34
|
+
* Root only, and required there: the device store for handle keypairs and mail.
|
|
35
35
|
*/
|
|
36
36
|
local?: Local;
|
|
37
37
|
/**
|
|
@@ -123,7 +123,7 @@ export type Context = Handle & Record<string, import('../lib/refs.js').Ref>;
|
|
|
123
123
|
* @property {Network} [network] Shared swarm. Inherited from `parent` if omitted.
|
|
124
124
|
* @property {import('corestore')} [store] Pre-existing Corestore. Falls back to `parent.store.store`.
|
|
125
125
|
* @property {Spec} [spec] Built cero spec.
|
|
126
|
-
* @property {Local} [local] Root only, and required there: the device store for handle keypairs
|
|
126
|
+
* @property {Local} [local] Root only, and required there: the device store for handle keypairs and mail.
|
|
127
127
|
* @property {import('hypercore-storage')} [storage] Owned HypercoreStorage to close on shutdown.
|
|
128
128
|
* @property {{ destroy(): Promise<void> }} [discovery] Owned identity discovery to destroy on shutdown.
|
|
129
129
|
* @property {string} [dir] Data directory (root handles only).
|
|
@@ -181,14 +181,24 @@ export declare class Handle extends ReadyResource {
|
|
|
181
181
|
/** @private */
|
|
182
182
|
_pending;
|
|
183
183
|
/** @private */
|
|
184
|
+
_ending;
|
|
185
|
+
/** @private */
|
|
184
186
|
_typeHooks;
|
|
185
187
|
/** @private */
|
|
186
188
|
_loading;
|
|
187
189
|
/** @private */
|
|
188
190
|
_joining;
|
|
189
191
|
/** @private */
|
|
192
|
+
_taking;
|
|
193
|
+
/** @private */
|
|
190
194
|
_coreKeys;
|
|
191
195
|
/** @private */
|
|
196
|
+
_offJoins;
|
|
197
|
+
/** @private */
|
|
198
|
+
_departing;
|
|
199
|
+
/** @private */
|
|
200
|
+
_leaving;
|
|
201
|
+
/** @private */
|
|
192
202
|
_fileServer;
|
|
193
203
|
/** @private */
|
|
194
204
|
_blobs;
|
|
@@ -199,9 +209,27 @@ export declare class Handle extends ReadyResource {
|
|
|
199
209
|
/** @private */
|
|
200
210
|
_owned;
|
|
201
211
|
/** @private */
|
|
212
|
+
_kept;
|
|
213
|
+
/** @private */
|
|
214
|
+
_arriving;
|
|
215
|
+
/** @private */
|
|
202
216
|
_refs;
|
|
203
217
|
/** @private */
|
|
218
|
+
_pruning;
|
|
219
|
+
/** @private */
|
|
204
220
|
_idle;
|
|
221
|
+
/** @private */
|
|
222
|
+
_tellings;
|
|
223
|
+
/** @private */
|
|
224
|
+
_waiting;
|
|
225
|
+
/** @private */
|
|
226
|
+
_waiters;
|
|
227
|
+
/** @private */
|
|
228
|
+
_telling;
|
|
229
|
+
/** @private @type {Array<{ stamp: () => Promise<string | null>, tell: (child: Handle) => Promise<void> }> | null} */
|
|
230
|
+
_tellers;
|
|
231
|
+
/** @private */
|
|
232
|
+
_retell;
|
|
205
233
|
store: Database;
|
|
206
234
|
/** @private */
|
|
207
235
|
_pair;
|
|
@@ -213,6 +241,10 @@ export declare class Handle extends ReadyResource {
|
|
|
213
241
|
_live;
|
|
214
242
|
/** @private */
|
|
215
243
|
_ac;
|
|
244
|
+
_queued: {
|
|
245
|
+
root: boolean;
|
|
246
|
+
children: Set<any>;
|
|
247
|
+
};
|
|
216
248
|
_indexing: any;
|
|
217
249
|
/** @param {HandleOpts} [opts] */
|
|
218
250
|
constructor(opts?: HandleOpts);
|
|
@@ -259,9 +291,9 @@ export declare class Handle extends ReadyResource {
|
|
|
259
291
|
/** @private */
|
|
260
292
|
private _close;
|
|
261
293
|
/**
|
|
262
|
-
* Tie a destroyable resource (a `watch` stream, a timer, any `{ destroy }`) to this
|
|
263
|
-
*
|
|
264
|
-
*
|
|
294
|
+
* Tie a destroyable resource (a `watch` stream, a timer, any `{ destroy }`) to this handle, so callers
|
|
295
|
+
* don't track cleanup. Tied by a holder, it is destroyed once the last holder closes the handle; tied by
|
|
296
|
+
* a `handle` listener as it runs, an extension's watch, it follows the handle for as long as it is open.
|
|
265
297
|
*
|
|
266
298
|
* @template {{ destroy?: Function, once?: Function }} T
|
|
267
299
|
* @param {T} resource
|
|
@@ -272,6 +304,8 @@ export declare class Handle extends ReadyResource {
|
|
|
272
304
|
once?: Function;
|
|
273
305
|
}>(resource: T): T;
|
|
274
306
|
/** @private */
|
|
307
|
+
private _disown;
|
|
308
|
+
/** @private */
|
|
275
309
|
private _link;
|
|
276
310
|
/** @private */
|
|
277
311
|
private _invite;
|
|
@@ -287,19 +321,25 @@ export declare class Handle extends ReadyResource {
|
|
|
287
321
|
private _tx;
|
|
288
322
|
/** @private */
|
|
289
323
|
private _leave;
|
|
324
|
+
/** @private */
|
|
325
|
+
private _depart;
|
|
326
|
+
/** @private */
|
|
327
|
+
private _ousted;
|
|
290
328
|
/**
|
|
291
|
-
* One holder done with it: a child stays open for the others. With its last
|
|
292
|
-
*
|
|
329
|
+
* One holder done with it: a child stays open for the others. With its last, what they tied to it ends and it
|
|
330
|
+
* stays open, idle, so a reopen finds it as it is; the root keeps `keepOpen` of them (16 by default) and one more
|
|
331
|
+
* closes the least recently used, on its own. The root closes at once, after any `cero.link` or `cero.restore` on
|
|
332
|
+
* it: one still waiting stops, one taking its place finishes first.
|
|
293
333
|
* @returns {Promise<void>}
|
|
294
334
|
*/
|
|
295
335
|
close(): Promise<void>;
|
|
336
|
+
/** @private one more holder: an idle handle is kept */
|
|
337
|
+
private _hold;
|
|
296
338
|
/**
|
|
297
|
-
* Closed for every holder at once:
|
|
339
|
+
* Closed for every holder at once: pushed out past `keepOpen`, the parent closing, or the handle left for good.
|
|
298
340
|
* @private
|
|
299
341
|
*/
|
|
300
|
-
|
|
301
|
-
private _hold;
|
|
302
|
-
_end(): Promise<void>;
|
|
342
|
+
private _end;
|
|
303
343
|
/** @private */
|
|
304
344
|
private _suspend;
|
|
305
345
|
/** @private */
|
|
@@ -323,15 +363,23 @@ export declare class Handle extends ReadyResource {
|
|
|
323
363
|
/** @private */
|
|
324
364
|
private _onRadio;
|
|
325
365
|
/** @private */
|
|
326
|
-
private
|
|
327
|
-
/** @private */
|
|
328
|
-
private _onLocal;
|
|
366
|
+
private _onTopics;
|
|
329
367
|
/** @private */
|
|
330
368
|
private _topics;
|
|
331
369
|
/** @private */
|
|
332
370
|
private _index;
|
|
333
371
|
/** @private */
|
|
334
|
-
private
|
|
372
|
+
private _seal;
|
|
373
|
+
/** @private */
|
|
374
|
+
private _follow;
|
|
375
|
+
/** @private */
|
|
376
|
+
private _put;
|
|
377
|
+
/** @private */
|
|
378
|
+
private _drop;
|
|
379
|
+
/** @private */
|
|
380
|
+
private _topic;
|
|
381
|
+
/** @private */
|
|
382
|
+
private _row;
|
|
335
383
|
/** @private */
|
|
336
384
|
private _receive;
|
|
337
385
|
/** @private */
|
|
@@ -392,10 +440,36 @@ export declare class Handle extends ReadyResource {
|
|
|
392
440
|
*/
|
|
393
441
|
private _join;
|
|
394
442
|
/** @private */
|
|
443
|
+
private _left;
|
|
444
|
+
/** @private */
|
|
445
|
+
private _landed;
|
|
446
|
+
/** @private */
|
|
447
|
+
private _asked;
|
|
448
|
+
/** @private */
|
|
395
449
|
private _start;
|
|
396
450
|
/** @private */
|
|
451
|
+
private _run;
|
|
452
|
+
/** @private */
|
|
397
453
|
private _cancel;
|
|
398
454
|
/** @private */
|
|
455
|
+
private _check;
|
|
456
|
+
/** @private */
|
|
457
|
+
private _takeBack;
|
|
458
|
+
/** @private */
|
|
459
|
+
private _retract;
|
|
460
|
+
/** @private */
|
|
461
|
+
private _announce;
|
|
462
|
+
/** @private */
|
|
463
|
+
private _forget;
|
|
464
|
+
/** @private */
|
|
465
|
+
private _stop;
|
|
466
|
+
/** @private */
|
|
467
|
+
private _ask;
|
|
468
|
+
/** @private */
|
|
469
|
+
private _stand;
|
|
470
|
+
/** @private */
|
|
471
|
+
private _over;
|
|
472
|
+
/** @private */
|
|
399
473
|
private _joined;
|
|
400
474
|
/**
|
|
401
475
|
* Open a joined handle with the keys its reply delivered, once this writer is admitted.
|
|
@@ -407,6 +481,8 @@ export declare class Handle extends ReadyResource {
|
|
|
407
481
|
*/
|
|
408
482
|
private _enter;
|
|
409
483
|
/** @private */
|
|
484
|
+
private _sweep;
|
|
485
|
+
/** @private */
|
|
410
486
|
private _carryOn;
|
|
411
487
|
/**
|
|
412
488
|
* Get an open child by id, or re-open it. Concurrent calls for the same id share one
|
|
@@ -437,10 +513,40 @@ export declare class Handle extends ReadyResource {
|
|
|
437
513
|
/** @private */
|
|
438
514
|
private _adopt;
|
|
439
515
|
/** @private */
|
|
516
|
+
private _seats;
|
|
517
|
+
/** @private */
|
|
440
518
|
private _prune;
|
|
441
519
|
/** @private */
|
|
520
|
+
private _compare;
|
|
521
|
+
/** @private */
|
|
522
|
+
private _teach;
|
|
523
|
+
/** @private */
|
|
524
|
+
private _record;
|
|
525
|
+
/** @private */
|
|
526
|
+
private _mark;
|
|
527
|
+
/** @private */
|
|
528
|
+
private _unseat;
|
|
529
|
+
/** @private */
|
|
442
530
|
private _pruneAll;
|
|
443
531
|
/** @private */
|
|
532
|
+
private _tellClosed;
|
|
533
|
+
/** @private */
|
|
534
|
+
private _pass;
|
|
535
|
+
/** @private */
|
|
536
|
+
private _marked;
|
|
537
|
+
/** @private */
|
|
538
|
+
private _lists;
|
|
539
|
+
/** @private */
|
|
540
|
+
private _stamp;
|
|
541
|
+
/** @private */
|
|
542
|
+
private _tellOne;
|
|
543
|
+
/** @private */
|
|
544
|
+
private _wait;
|
|
545
|
+
/** @private */
|
|
546
|
+
private _turns;
|
|
547
|
+
/** @private */
|
|
548
|
+
private _tellRoom;
|
|
549
|
+
/** @private */
|
|
444
550
|
private _carry;
|
|
445
551
|
/** @private */
|
|
446
552
|
private _hookType;
|
package/types/index.d.ts
CHANGED
|
@@ -74,9 +74,9 @@ export type CeroOpts = {
|
|
|
74
74
|
*/
|
|
75
75
|
onerror?: (err: Error) => void;
|
|
76
76
|
/**
|
|
77
|
-
*
|
|
77
|
+
* How many handles stay open after their last close, for a reopen; one more closes the least recently used, 0 closes at once. Defaults to 16.
|
|
78
78
|
*/
|
|
79
|
-
|
|
79
|
+
keepOpen?: number;
|
|
80
80
|
/**
|
|
81
81
|
* Max wait to find another device and be admitted, in ms. Defaults to 30000.
|
|
82
82
|
*/
|
|
@@ -120,7 +120,7 @@ export type CeroOpts = {
|
|
|
120
120
|
* @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.
|
|
121
121
|
* @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.
|
|
122
122
|
* @property {(err: Error) => void} [onerror] Where background errors go; the console without one.
|
|
123
|
-
* @property {number} [
|
|
123
|
+
* @property {number} [keepOpen] How many handles stay open after their last close, for a reopen; one more closes the least recently used, 0 closes at once. Defaults to 16.
|
|
124
124
|
* @property {number} [recoveryTimeout] Max wait to find another device and be admitted, in ms. Defaults to 30000.
|
|
125
125
|
* @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.
|
|
126
126
|
* @property {import('./extensions/index.js').Extension[]} [extensions] The extensions this instance runs, instead of the ones the spec carries. Build with the same list.
|
|
@@ -136,7 +136,9 @@ export type CeroOpts = {
|
|
|
136
136
|
*/
|
|
137
137
|
declare function start(dir: string, spec: import('./lib/spec.js').Spec, opts?: CeroOpts): Promise<Context>;
|
|
138
138
|
/**
|
|
139
|
-
*
|
|
139
|
+
* Switch this device to the identity of a recovery phrase. That identity opens beside `me` and
|
|
140
|
+
* recovers from a device of it; once it has opened, `me` closes and its data is deleted. A failure
|
|
141
|
+
* leaves `me` as it was, and the phrase of `me`'s own identity resolves `me`.
|
|
140
142
|
*
|
|
141
143
|
* @param {Context} me The root to restore.
|
|
142
144
|
* @param {string} phrase The identity's BIP-39 phrase, as `cero.phrase(me)` gives it.
|
|
@@ -144,8 +146,9 @@ declare function start(dir: string, spec: import('./lib/spec.js').Spec, opts?: C
|
|
|
144
146
|
*/
|
|
145
147
|
export declare function restore(me: Context, phrase: string): Promise<Handle>;
|
|
146
148
|
/**
|
|
147
|
-
* Link this device to the identity behind a device invite
|
|
148
|
-
* opens
|
|
149
|
+
* Link this device to the identity behind a device invite, as a new device of it with no phrase on
|
|
150
|
+
* it. It opens beside `me`; once accepted, `me` closes and its data is deleted. A denial or a failure
|
|
151
|
+
* leaves `me` as it was.
|
|
149
152
|
*
|
|
150
153
|
* @param {Context} me The root to replace.
|
|
151
154
|
* @param {string} invite A device invite, as `cero.invite(me)` gives it on a device of that identity.
|
package/types/lib/constants.d.ts
CHANGED
|
@@ -4,6 +4,6 @@ export declare const EPOCHS = "epochs";
|
|
|
4
4
|
export declare const REMOVALS = "removals";
|
|
5
5
|
export declare const REFUSALS = "refusals";
|
|
6
6
|
export declare const SPENT = "spent";
|
|
7
|
+
export declare const ASKS = "owed";
|
|
7
8
|
export declare const TIMEOUT = 30000;
|
|
8
|
-
export declare const
|
|
9
|
-
export declare const LINGER = 20000;
|
|
9
|
+
export declare const KEEP_OPEN = 16;
|
package/types/lib/operators.d.ts
CHANGED
|
@@ -86,6 +86,16 @@ export declare function after(ref: Ref, fn: (ctx: HookContext) => unknown, opts?
|
|
|
86
86
|
* @returns {Promise<SingleResult | ListResult>}
|
|
87
87
|
*/
|
|
88
88
|
export declare function get(ref: Ref, q?: string | Record<string, unknown>): Promise<SingleResult | ListResult>;
|
|
89
|
+
/**
|
|
90
|
+
* Whether a handle has turned on a collection, a single or an action, or a field of one with
|
|
91
|
+
* `field`. What a release holds back with `t.later` turns on once the handle's `status.version`
|
|
92
|
+
* reaches the release that brought it; until then a write naming it fails with `UNSUPPORTED`.
|
|
93
|
+
*
|
|
94
|
+
* @param {Ref} ref A ref of the root or of an open handle (`room.notes`).
|
|
95
|
+
* @param {string} [field]
|
|
96
|
+
* @returns {Promise<boolean>}
|
|
97
|
+
*/
|
|
98
|
+
export declare function supports(ref: Ref, field?: string): Promise<boolean>;
|
|
89
99
|
/**
|
|
90
100
|
* Read a ref as it changes. Each item is what `get(ref, query)` returns now; a slow reader gets
|
|
91
101
|
* only the newest. With `changes: true` in the query each item also carries `changes`, the
|
|
@@ -127,14 +137,14 @@ export declare function invite(ctx: Context, opts?: import('@cero-base/core/pair
|
|
|
127
137
|
* Kill an invite, for every member.
|
|
128
138
|
*
|
|
129
139
|
* @param {Context} ctx
|
|
130
|
-
* @param {string} code
|
|
140
|
+
* @param {string} code The code `invite` returned, or the id its `invites` row holds.
|
|
131
141
|
* @returns {Promise<boolean>} Whether it was live.
|
|
132
142
|
*/
|
|
133
143
|
export declare function revoke(ctx: Context, code: string): Promise<boolean>;
|
|
134
144
|
/**
|
|
135
|
-
*
|
|
136
|
-
* written after. Needs the remove permission. A removal
|
|
137
|
-
*
|
|
145
|
+
* Rotate a handle's key now: a new epoch sealed to its members, so one removed before it reads
|
|
146
|
+
* nothing written after. Needs the remove permission. A removal by an admin or the owner rotates
|
|
147
|
+
* it as it resolves; this is for any other time.
|
|
138
148
|
*
|
|
139
149
|
* @param {Context} ctx
|
|
140
150
|
* @returns {Promise<{ epoch: number }>}
|
|
@@ -188,7 +198,7 @@ export declare function deny(ctx: Context, request: {
|
|
|
188
198
|
*/
|
|
189
199
|
export declare function removed(ctx: Context, id: string): Promise<'removed' | 'left' | null>;
|
|
190
200
|
/**
|
|
191
|
-
* Quit a handle for good:
|
|
201
|
+
* Quit a handle for good: its row reads `leaving`, then `left` once the handle holds it, and it closes.
|
|
192
202
|
*
|
|
193
203
|
* @param {Context} ctx
|
|
194
204
|
* @returns {Promise<void>}
|
|
@@ -258,7 +268,7 @@ export declare function receive(me: Context, payload: Uint8Array): Promise<{
|
|
|
258
268
|
/**
|
|
259
269
|
* Send a value to an address, signed by this identity. Resolves once the outbox keeps it; it is
|
|
260
270
|
* delivered in the background, from a mirror too when the owner is offline. `keep: false` erases
|
|
261
|
-
* this device's copy once
|
|
271
|
+
* this device's copy once a device or a mirror stored it.
|
|
262
272
|
*
|
|
263
273
|
* @param {Context} me
|
|
264
274
|
* @param {string} address As `cero.address(secret)` gives it.
|
package/types/lib/peek.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* What the directory at `dir` holds, read without opening it: nothing yet, an identity, or a recovery or a link
|
|
3
|
+
* still waiting for a device of its identity, which the next `cero(dir, spec)` goes on with.
|
|
4
4
|
*
|
|
5
5
|
* @param {string} dir Cero data directory.
|
|
6
6
|
* @param {import('./spec.js').Spec} spec Built spec, the value passed to `cero(dir, spec)`.
|
|
7
|
-
* @
|
|
7
|
+
* @param {{ storageKey?: Uint8Array }} [opts] The key `cero()` encrypts the local store with, if any.
|
|
8
|
+
* @returns {Promise<'ready' | 'recovering' | 'linking' | null>} `null` when it holds nothing.
|
|
8
9
|
*/
|
|
9
|
-
export declare function peek(dir: string, spec: import('./spec.js').Spec
|
|
10
|
+
export declare function peek(dir: string, spec: import('./spec.js').Spec, { storageKey }?: {
|
|
11
|
+
storageKey?: Uint8Array;
|
|
12
|
+
}): Promise<'ready' | 'recovering' | 'linking' | null>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const reserved: string[];
|