@cero-base/core 2.1.8 → 2.2.1
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 +7 -7
- package/src/database/index.js +1 -1
- package/src/network/index.js +7 -12
- package/src/pairing/index.js +4 -12
- package/types/database/index.d.ts +1 -1
- package/types/network/index.d.ts +7 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cero-base/core",
|
|
3
|
-
"version": "2.1
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"description": "cero p2p primitives — identity, storage, network, database, blobs, rpc, pairing.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -140,15 +140,15 @@
|
|
|
140
140
|
},
|
|
141
141
|
"dependencies": {
|
|
142
142
|
"@hyperswarm/secret-stream": "^6.9.2",
|
|
143
|
-
"autobee": "2.
|
|
143
|
+
"autobee": "2.10.0",
|
|
144
144
|
"autobee-encryption": "0.1.4",
|
|
145
|
-
"b4a": "^1.
|
|
145
|
+
"b4a": "^1.9.0",
|
|
146
146
|
"bare-crypto": "^1.15.3",
|
|
147
147
|
"bare-fs": "^4.8.1",
|
|
148
148
|
"bare-path": "^3.1.2",
|
|
149
149
|
"bip39-mnemonic": "^2.5.0",
|
|
150
150
|
"blind-pairing": "^2.3.1",
|
|
151
|
-
"blind-peering": "^2.9.
|
|
151
|
+
"blind-peering": "^2.9.5",
|
|
152
152
|
"compact-encoding": "^3.5.0",
|
|
153
153
|
"corestore": "^7.12.5",
|
|
154
154
|
"framed-stream": "^1.0.1",
|
|
@@ -158,10 +158,10 @@
|
|
|
158
158
|
"hypercore-blob-server": "^1.15.0",
|
|
159
159
|
"hypercore-crypto": "^3.7.0",
|
|
160
160
|
"hypercore-id-encoding": "^1.3.0",
|
|
161
|
-
"hypercore-storage": "^3.
|
|
161
|
+
"hypercore-storage": "^3.3.1",
|
|
162
162
|
"hyperdb": "^6.9.0",
|
|
163
163
|
"hyperdispatch": "^1.6.0",
|
|
164
|
-
"hyperschema": "^1.26.
|
|
164
|
+
"hyperschema": "^1.26.2",
|
|
165
165
|
"hyperswarm": "^4.17.1",
|
|
166
166
|
"keet-identity-key": "^3.2.0",
|
|
167
167
|
"protomux": "^3.12.0",
|
|
@@ -176,7 +176,7 @@
|
|
|
176
176
|
"@hyperswarm/testnet": "^3.1.4",
|
|
177
177
|
"bare-abort-controller": "^1.1.2",
|
|
178
178
|
"bare-events": "^2.9.2",
|
|
179
|
-
"bare-fetch": "^3.
|
|
179
|
+
"bare-fetch": "^3.4.0",
|
|
180
180
|
"bare-process": "^4.5.1",
|
|
181
181
|
"bare-url": "^2.5.4",
|
|
182
182
|
"blind-peer": "^3.15.0",
|
package/src/database/index.js
CHANGED
|
@@ -92,7 +92,7 @@ export class Database extends ReadyResource {
|
|
|
92
92
|
throw CeroError.INVALID('the identity keypair is never a writer — use a device keypair')
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
this._onerror = opts.onerror ||
|
|
95
|
+
this._onerror = opts.onerror || ((err) => console.error(err))
|
|
96
96
|
this.bee = null
|
|
97
97
|
this.dispatcher = null
|
|
98
98
|
this._presence = null
|
package/src/network/index.js
CHANGED
|
@@ -31,6 +31,7 @@ export function channelTopic(topic, channel) {
|
|
|
31
31
|
* @property {string} [channel] Optional network-isolation label; only same-channel peers meet.
|
|
32
32
|
* @property {any} [store] Corestore; required for mirrors (blind peers replicate its cores).
|
|
33
33
|
* @property {Array<string | Uint8Array>} [mirrors] Blind-peer public keys; each attached room/blob core is mirrored through them for offline sync.
|
|
34
|
+
* @property {(err: any) => void} [onerror] Background-task error handler.
|
|
34
35
|
* @property {{ active?: number, announced?: number, idle?: number }} [presence] Swarm budget for attached databases: how many search, how many only announce, and the idle ms before the rest leave.
|
|
35
36
|
*
|
|
36
37
|
* @typedef {{ replicate: (stream: any) => any }} Replicable
|
|
@@ -51,7 +52,8 @@ export class Network extends ReadyResource {
|
|
|
51
52
|
channel,
|
|
52
53
|
store,
|
|
53
54
|
mirrors,
|
|
54
|
-
presence
|
|
55
|
+
presence,
|
|
56
|
+
onerror = (err) => console.error(err)
|
|
55
57
|
} = {}) {
|
|
56
58
|
super()
|
|
57
59
|
this.identity = identity || null
|
|
@@ -76,6 +78,7 @@ export class Network extends ReadyResource {
|
|
|
76
78
|
this._injected = new Set()
|
|
77
79
|
this._blind = null
|
|
78
80
|
this._blindPeering = null
|
|
81
|
+
this._onerror = onerror
|
|
79
82
|
}
|
|
80
83
|
|
|
81
84
|
/** @returns {any} The underlying hyperswarm, or null before ready / after close. */
|
|
@@ -292,11 +295,7 @@ export class Network extends ReadyResource {
|
|
|
292
295
|
async suspend() {
|
|
293
296
|
if (this.closing || this.closed) return
|
|
294
297
|
await this._blindPeering?.suspend()
|
|
295
|
-
|
|
296
|
-
await this._swarm?.suspend()
|
|
297
|
-
} catch (err) {
|
|
298
|
-
safetyCatch(err)
|
|
299
|
-
}
|
|
298
|
+
await this._swarm?.suspend()
|
|
300
299
|
}
|
|
301
300
|
|
|
302
301
|
/**
|
|
@@ -306,11 +305,7 @@ export class Network extends ReadyResource {
|
|
|
306
305
|
*/
|
|
307
306
|
async resume() {
|
|
308
307
|
if (this.closing || this.closed) return
|
|
309
|
-
|
|
310
|
-
await this._swarm?.resume()
|
|
311
|
-
} catch (err) {
|
|
312
|
-
safetyCatch(err)
|
|
313
|
-
}
|
|
308
|
+
await this._swarm?.resume()
|
|
314
309
|
await this._blindPeering?.resume()
|
|
315
310
|
}
|
|
316
311
|
|
|
@@ -352,7 +347,7 @@ export class Network extends ReadyResource {
|
|
|
352
347
|
for (const stream of this.connections) replicateInto(core, stream)
|
|
353
348
|
// mirror the core so it stays available while its writers are offline
|
|
354
349
|
if (this._blindPeering) {
|
|
355
|
-
if (Autobee.isAutobee(core)) core.ready().then(() => this._mirror(core),
|
|
350
|
+
if (Autobee.isAutobee(core)) core.ready().then(() => this._mirror(core), this._onerror)
|
|
356
351
|
else this._blindPeering.addCoreBackground(core)
|
|
357
352
|
}
|
|
358
353
|
}
|
package/src/pairing/index.js
CHANGED
|
@@ -47,7 +47,7 @@ export class Pairing extends ReadyResource {
|
|
|
47
47
|
host = true,
|
|
48
48
|
inviteEncoding = null,
|
|
49
49
|
joinerEncoding = null,
|
|
50
|
-
onerror =
|
|
50
|
+
onerror = (err) => console.error(err),
|
|
51
51
|
onconsume = null
|
|
52
52
|
} = {}) {
|
|
53
53
|
super()
|
|
@@ -248,11 +248,7 @@ export class Pairing extends ReadyResource {
|
|
|
248
248
|
async suspend() {
|
|
249
249
|
if (!this._blind || this.closing || this.closed) return
|
|
250
250
|
if (this._blind.suspended) return
|
|
251
|
-
|
|
252
|
-
await this._blind.suspend()
|
|
253
|
-
} catch (err) {
|
|
254
|
-
safetyCatch(err)
|
|
255
|
-
}
|
|
251
|
+
await this._blind.suspend()
|
|
256
252
|
}
|
|
257
253
|
|
|
258
254
|
/**
|
|
@@ -263,11 +259,7 @@ export class Pairing extends ReadyResource {
|
|
|
263
259
|
async resume() {
|
|
264
260
|
if (!this._blind || this.closing || this.closed) return
|
|
265
261
|
if (!this._blind.suspended) return
|
|
266
|
-
|
|
267
|
-
await this._blind.resume()
|
|
268
|
-
} catch (err) {
|
|
269
|
-
safetyCatch(err)
|
|
270
|
-
}
|
|
262
|
+
await this._blind.resume()
|
|
271
263
|
}
|
|
272
264
|
|
|
273
265
|
async _oncandidate(req) {
|
|
@@ -283,7 +275,7 @@ export class Pairing extends ReadyResource {
|
|
|
283
275
|
try {
|
|
284
276
|
req.open(record.publicKey)
|
|
285
277
|
} catch (err) {
|
|
286
|
-
|
|
278
|
+
this._onerror(err)
|
|
287
279
|
return
|
|
288
280
|
}
|
|
289
281
|
|
|
@@ -215,7 +215,7 @@ export declare class Database extends ReadyResource {
|
|
|
215
215
|
key: Uint8Array<ArrayBufferLike>;
|
|
216
216
|
pinned: boolean;
|
|
217
217
|
keyPair: import("../index.js").KeyPair;
|
|
218
|
-
_onerror:
|
|
218
|
+
_onerror: (err: Error) => void;
|
|
219
219
|
bee: EpochAutobee;
|
|
220
220
|
dispatcher: {
|
|
221
221
|
dispatch: (value: Buffer, ctx: object) => Promise<void>;
|
package/types/network/index.d.ts
CHANGED
|
@@ -38,6 +38,10 @@ export type NetworkOpts = {
|
|
|
38
38
|
* Blind-peer public keys; each attached room/blob core is mirrored through them for offline sync.
|
|
39
39
|
*/
|
|
40
40
|
mirrors?: Array<string | Uint8Array>;
|
|
41
|
+
/**
|
|
42
|
+
* Background-task error handler.
|
|
43
|
+
*/
|
|
44
|
+
onerror?: (err: any) => void;
|
|
41
45
|
/**
|
|
42
46
|
* Swarm budget for attached databases: how many search, how many only announce, and the idle ms before the rest leave.
|
|
43
47
|
*/
|
|
@@ -60,6 +64,7 @@ export type Replicable = {
|
|
|
60
64
|
* @property {string} [channel] Optional network-isolation label; only same-channel peers meet.
|
|
61
65
|
* @property {any} [store] Corestore; required for mirrors (blind peers replicate its cores).
|
|
62
66
|
* @property {Array<string | Uint8Array>} [mirrors] Blind-peer public keys; each attached room/blob core is mirrored through them for offline sync.
|
|
67
|
+
* @property {(err: any) => void} [onerror] Background-task error handler.
|
|
63
68
|
* @property {{ active?: number, announced?: number, idle?: number }} [presence] Swarm budget for attached databases: how many search, how many only announce, and the idle ms before the rest leave.
|
|
64
69
|
*
|
|
65
70
|
* @typedef {{ replicate: (stream: any) => any }} Replicable
|
|
@@ -91,8 +96,9 @@ export declare class Network extends ReadyResource {
|
|
|
91
96
|
_injected: Set<any>;
|
|
92
97
|
_blind: any;
|
|
93
98
|
_blindPeering: any;
|
|
99
|
+
_onerror: (err: any) => void;
|
|
94
100
|
/** @param {NetworkOpts} [opts] */
|
|
95
|
-
constructor({ identity, bootstrap, firewall, relayThrough, backoffs, channel, store, mirrors, presence }?: NetworkOpts);
|
|
101
|
+
constructor({ identity, bootstrap, firewall, relayThrough, backoffs, channel, store, mirrors, presence, onerror }?: NetworkOpts);
|
|
96
102
|
/** @returns {any} The underlying hyperswarm, or null before ready / after close. */
|
|
97
103
|
get swarm(): any;
|
|
98
104
|
/** @returns {Map<string, any>} Known peers keyed by public-key string. */
|