@cero-base/cero 3.4.1 → 3.5.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 +7 -7
- package/src/handle/index.js +7 -7
- package/src/index.js +1 -3
- package/src/lib/operators.js +1 -1
- package/types/index.d.ts +2 -8
- package/types/lib/operators.d.ts +1 -1
package/README.md
CHANGED
|
@@ -77,7 +77,7 @@ That is a working, encrypted, offline-first, peer-to-peer app. Your phrase, `awa
|
|
|
77
77
|
|
|
78
78
|
The 24 operators, each also on the facade as `cero.put` and so on: `put`, `set`, `get`, `del`, `watch`, `call`, `open`, `tx`, `invite`, `revoke`, `rotate`, `accept`, `deny`, `leave`, `close`, `cancel`, `suspend`, `resume`, `activate`, `deactivate`, `phrase`, `nearby`, `before`, `after`.
|
|
79
79
|
|
|
80
|
-
Built on the [Pear](https://pears.com) stack: Hypercore, Autobee, HyperDB, Hyperblobs,
|
|
80
|
+
Built on the [Pear](https://pears.com) stack: Hypercore, Autobee, HyperDB, Hyperblobs, Hyperjoin, blind-peering and Bare. Runs on Node and Bare, with TypeScript declarations.
|
|
81
81
|
|
|
82
82
|
## License
|
|
83
83
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cero-base/cero",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.5.0",
|
|
4
4
|
"description": "The ideal p2p API — everything is a handle, handles contain refs, refs contain rows.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -113,18 +113,18 @@
|
|
|
113
113
|
"test:node": "find test -name '*.test.js' | sort | xargs -P4 -n1 brittle-node"
|
|
114
114
|
},
|
|
115
115
|
"dependencies": {
|
|
116
|
-
"@cero-base/core": "^3.
|
|
116
|
+
"@cero-base/core": "^3.5.0",
|
|
117
117
|
"b4a": "^1.9.0",
|
|
118
118
|
"bare-abort-controller": "^1.1.2",
|
|
119
119
|
"bare-crypto": "^1.16.1",
|
|
120
|
-
"bare-fs": "^4.8.
|
|
120
|
+
"bare-fs": "^4.8.7",
|
|
121
121
|
"bare-path": "^3.1.3",
|
|
122
122
|
"ble-swarm": "^2.4.0",
|
|
123
|
-
"compact-encoding": "^3.7.
|
|
123
|
+
"compact-encoding": "^3.7.1",
|
|
124
124
|
"corestore": "^7.16.1",
|
|
125
125
|
"fd-lock": "^2.2.0",
|
|
126
126
|
"hrpc": "^4.3.2",
|
|
127
|
-
"hypercore": "^11.40.
|
|
127
|
+
"hypercore": "^11.40.5",
|
|
128
128
|
"hypercore-crypto": "^3.7.0",
|
|
129
129
|
"hypercore-id-encoding": "^1.3.0",
|
|
130
130
|
"hypercore-storage": "^3.4.0",
|
|
@@ -144,8 +144,8 @@
|
|
|
144
144
|
"bare-fetch": "^3.5.0",
|
|
145
145
|
"bare-process": "^4.5.1",
|
|
146
146
|
"bare-url": "^2.5.8",
|
|
147
|
-
"blind-peer": "^3.
|
|
148
|
-
"brittle": "^4.
|
|
147
|
+
"blind-peer": "^3.20.1",
|
|
148
|
+
"brittle": "^4.6.0",
|
|
149
149
|
"typescript": "^7.0.2"
|
|
150
150
|
},
|
|
151
151
|
"license": "Apache-2.0"
|
package/src/handle/index.js
CHANGED
|
@@ -16,7 +16,7 @@ import { Invite } from '@cero-base/core/invite'
|
|
|
16
16
|
import { Mailbox } from '@cero-base/core/mailbox'
|
|
17
17
|
import { seal, unseal, decodeAddress } from '../lib/mail.js'
|
|
18
18
|
import hid from 'hypercore-id-encoding'
|
|
19
|
-
import { admission, onAbort, filter, can, WRITE } from '@cero-base/core/utils'
|
|
19
|
+
import { admission, onAbort, filter, can, inTurn, WRITE } from '@cero-base/core/utils'
|
|
20
20
|
import { CeroError } from '@cero-base/core/errors'
|
|
21
21
|
import { Blobs } from '@cero-base/core/blobs'
|
|
22
22
|
import { decodeId, servedType } from '@cero-base/core/blobs/codec'
|
|
@@ -711,7 +711,7 @@ export class Handle extends ReadyResource {
|
|
|
711
711
|
return this._sus
|
|
712
712
|
}
|
|
713
713
|
|
|
714
|
-
// true ranks a handle as just used, false
|
|
714
|
+
// true ranks a handle as just used, false ranks it last until something lands in it
|
|
715
715
|
/** @private */
|
|
716
716
|
_active(on) {
|
|
717
717
|
this.store.setActive(on)
|
|
@@ -833,7 +833,7 @@ export class Handle extends ReadyResource {
|
|
|
833
833
|
for (const child of queued.children) await this._topic(child).catch(this._onerror)
|
|
834
834
|
}
|
|
835
835
|
}
|
|
836
|
-
this._indexing = (this._indexing
|
|
836
|
+
this._indexing = inTurn(this._indexing, run)
|
|
837
837
|
return this._indexing
|
|
838
838
|
}
|
|
839
839
|
|
|
@@ -842,7 +842,7 @@ export class Handle extends ReadyResource {
|
|
|
842
842
|
/** @private */
|
|
843
843
|
_seal(child) {
|
|
844
844
|
const run = () => this._topic(child, true)
|
|
845
|
-
this._indexing = (this._indexing
|
|
845
|
+
this._indexing = inTurn(this._indexing, run)
|
|
846
846
|
return this._indexing
|
|
847
847
|
}
|
|
848
848
|
|
|
@@ -2307,9 +2307,9 @@ export class Handle extends ReadyResource {
|
|
|
2307
2307
|
if (row?.epochs) await child.store.learn(c.decode(epochEntries, row.epochs))
|
|
2308
2308
|
}
|
|
2309
2309
|
const touches = (name) => (touched) => touched.has('*') || touched.has(name)
|
|
2310
|
-
|
|
2311
|
-
// a room that closed under the read says nothing
|
|
2310
|
+
// a store that closed under the read or the write says nothing: the next open carries them
|
|
2312
2311
|
const report = (err) => err.code === 'CLOSED' || this._onerror(err)
|
|
2312
|
+
const onepoch = () => save().catch(report)
|
|
2313
2313
|
const onroot = (touched) => touches('handles')(touched) && read().catch(report)
|
|
2314
2314
|
const onchild = (touched) => touches('epochs')(touched) && read().catch(report)
|
|
2315
2315
|
child.store.on('epoch', onepoch)
|
|
@@ -2323,7 +2323,7 @@ export class Handle extends ReadyResource {
|
|
|
2323
2323
|
this.store.off('epoch', onepoch)
|
|
2324
2324
|
})
|
|
2325
2325
|
// one that rotated before it is carried, as a room made while the root owes a rotation
|
|
2326
|
-
if (child.store.keyring.seq > 0) read().then(save).catch(
|
|
2326
|
+
if (child.store.keyring.seq > 0) read().then(save).catch(report)
|
|
2327
2327
|
}
|
|
2328
2328
|
|
|
2329
2329
|
// before(me.room.notes, fn): on every handle open now and every one opened later
|
package/src/index.js
CHANGED
|
@@ -47,10 +47,9 @@ export { t, schema } from './lib/spec.js'
|
|
|
47
47
|
* @property {Array<{ host: string, port: number }>} [bootstrap] Custom DHT bootstrap nodes.
|
|
48
48
|
* @property {Array<string | Uint8Array>} [relayThrough] Blind relay public keys. Two devices that cannot connect direct, as on mobile carriers, connect through one; the relay forwards encrypted bytes and reads nothing. Direct connections stay direct.
|
|
49
49
|
* @property {(remotePublicKey: Uint8Array, payload: unknown) => boolean} [firewall] Incoming-connection filter: `true` refuses the connection.
|
|
50
|
-
* @property {number[]} [backoffs] Swarm reconnect backoff tiers in ms (testing/tuning).
|
|
51
50
|
* @property {string} [channel] Optional network-isolation label; only same-channel peers connect.
|
|
52
51
|
* @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.
|
|
53
|
-
* @property {{ active?: number,
|
|
52
|
+
* @property {{ active?: number, idle?: number }} [presence] How many handles announce and search at once, and the ms one keeps its slot before a touched one may take it.
|
|
54
53
|
* @property {(err: Error) => void} [onerror] Where background errors go; the console without one.
|
|
55
54
|
* @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.
|
|
56
55
|
* @property {number} [recoveryTimeout] Max wait to find another device and be admitted, in ms. Defaults to 30000.
|
|
@@ -150,7 +149,6 @@ async function start(dir, spec, opts = {}) {
|
|
|
150
149
|
bootstrap: opts.bootstrap,
|
|
151
150
|
relayThrough: opts.relayThrough,
|
|
152
151
|
firewall: opts.firewall,
|
|
153
|
-
backoffs: opts.backoffs,
|
|
154
152
|
channel: opts.channel,
|
|
155
153
|
store,
|
|
156
154
|
mirrors: opts.mirrors,
|
package/src/lib/operators.js
CHANGED
|
@@ -537,7 +537,7 @@ export async function activate(ctx) {
|
|
|
537
537
|
}
|
|
538
538
|
|
|
539
539
|
/**
|
|
540
|
-
*
|
|
540
|
+
* Rank a handle last: it is on the swarm only while a slot is spare, until something lands in it.
|
|
541
541
|
*
|
|
542
542
|
* @param {Context} ctx
|
|
543
543
|
* @returns {Promise<void>}
|
package/types/index.d.ts
CHANGED
|
@@ -49,10 +49,6 @@ export type CeroOpts = {
|
|
|
49
49
|
* Incoming-connection filter: `true` refuses the connection.
|
|
50
50
|
*/
|
|
51
51
|
firewall?: (remotePublicKey: Uint8Array, payload: unknown) => boolean;
|
|
52
|
-
/**
|
|
53
|
-
* Swarm reconnect backoff tiers in ms (testing/tuning).
|
|
54
|
-
*/
|
|
55
|
-
backoffs?: number[];
|
|
56
52
|
/**
|
|
57
53
|
* Optional network-isolation label; only same-channel peers connect.
|
|
58
54
|
*/
|
|
@@ -62,11 +58,10 @@ export type CeroOpts = {
|
|
|
62
58
|
*/
|
|
63
59
|
mirrors?: Array<string | Uint8Array>;
|
|
64
60
|
/**
|
|
65
|
-
* How many handles
|
|
61
|
+
* How many handles announce and search at once, and the ms one keeps its slot before a touched one may take it.
|
|
66
62
|
*/
|
|
67
63
|
presence?: {
|
|
68
64
|
active?: number;
|
|
69
|
-
announced?: number;
|
|
70
65
|
idle?: number;
|
|
71
66
|
};
|
|
72
67
|
/**
|
|
@@ -115,10 +110,9 @@ export type CeroOpts = {
|
|
|
115
110
|
* @property {Array<{ host: string, port: number }>} [bootstrap] Custom DHT bootstrap nodes.
|
|
116
111
|
* @property {Array<string | Uint8Array>} [relayThrough] Blind relay public keys. Two devices that cannot connect direct, as on mobile carriers, connect through one; the relay forwards encrypted bytes and reads nothing. Direct connections stay direct.
|
|
117
112
|
* @property {(remotePublicKey: Uint8Array, payload: unknown) => boolean} [firewall] Incoming-connection filter: `true` refuses the connection.
|
|
118
|
-
* @property {number[]} [backoffs] Swarm reconnect backoff tiers in ms (testing/tuning).
|
|
119
113
|
* @property {string} [channel] Optional network-isolation label; only same-channel peers connect.
|
|
120
114
|
* @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
|
-
* @property {{ active?: number,
|
|
115
|
+
* @property {{ active?: number, idle?: number }} [presence] How many handles announce and search at once, and the ms one keeps its slot before a touched one may take it.
|
|
122
116
|
* @property {(err: Error) => void} [onerror] Where background errors go; the console without one.
|
|
123
117
|
* @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
118
|
* @property {number} [recoveryTimeout] Max wait to find another device and be admitted, in ms. Defaults to 30000.
|
package/types/lib/operators.d.ts
CHANGED
|
@@ -249,7 +249,7 @@ export declare function resume(me: Context): Promise<void>;
|
|
|
249
249
|
*/
|
|
250
250
|
export declare function activate(ctx: Context): Promise<void>;
|
|
251
251
|
/**
|
|
252
|
-
*
|
|
252
|
+
* Rank a handle last: it is on the swarm only while a slot is spare, until something lands in it.
|
|
253
253
|
*
|
|
254
254
|
* @param {Context} ctx
|
|
255
255
|
* @returns {Promise<void>}
|