@cero-base/core 1.11.0 → 1.13.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 +9 -13
- package/src/database/dispatch.js +5 -1
- package/src/database/encryption.js +21 -39
- package/types/database/encryption.d.ts +12 -4
- package/types/database/index.d.ts +1 -1
- package/src/network/transports/ble.js +0 -1109
- package/src/network/transports/gatt.js +0 -42
- package/src/network/transports/l2cap.js +0 -90
- package/types/network/transports/ble.d.ts +0 -180
- package/types/network/transports/gatt.d.ts +0 -21
- package/types/network/transports/l2cap.d.ts +0 -37
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cero-base/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.13.0",
|
|
4
4
|
"description": "cero p2p primitives — identity, storage, network, database, blobs, rpc, pairing.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -41,10 +41,6 @@
|
|
|
41
41
|
"types": "./types/network/index.d.ts",
|
|
42
42
|
"default": "./src/network/index.js"
|
|
43
43
|
},
|
|
44
|
-
"./network/transports/ble": {
|
|
45
|
-
"types": "./types/network/transports/ble.d.ts",
|
|
46
|
-
"default": "./src/network/transports/ble.js"
|
|
47
|
-
},
|
|
48
44
|
"./network/transports/dht": {
|
|
49
45
|
"types": "./types/network/transports/dht.d.ts",
|
|
50
46
|
"default": "./src/network/transports/dht.js"
|
|
@@ -144,7 +140,7 @@
|
|
|
144
140
|
},
|
|
145
141
|
"dependencies": {
|
|
146
142
|
"@hyperswarm/secret-stream": "^6.9.1",
|
|
147
|
-
"autobee": "2.0.0-rc.
|
|
143
|
+
"autobee": "2.0.0-rc.19",
|
|
148
144
|
"autobee-encryption": "0.1.3",
|
|
149
145
|
"b4a": "^1.8.1",
|
|
150
146
|
"bare-crypto": "^1.15.3",
|
|
@@ -152,18 +148,18 @@
|
|
|
152
148
|
"bare-path": "^3.1.1",
|
|
153
149
|
"bip39-mnemonic": "^2.5.0",
|
|
154
150
|
"blind-pairing": "^2.3.1",
|
|
155
|
-
"blind-peering": "^2.6.
|
|
156
|
-
"compact-encoding": "^3.3.
|
|
151
|
+
"blind-peering": "^2.6.3",
|
|
152
|
+
"compact-encoding": "^3.3.2",
|
|
157
153
|
"corestore": "^7.12.0",
|
|
158
154
|
"framed-stream": "^1.0.1",
|
|
159
|
-
"hrpc": "^4.3.
|
|
155
|
+
"hrpc": "^4.3.1",
|
|
160
156
|
"hyperblobs": "^2.12.1",
|
|
161
|
-
"hypercore": "^11.35.
|
|
157
|
+
"hypercore": "^11.35.2",
|
|
162
158
|
"hypercore-blob-server": "^1.15.0",
|
|
163
159
|
"hypercore-crypto": "^3.7.0",
|
|
164
160
|
"hypercore-id-encoding": "^1.3.0",
|
|
165
|
-
"hypercore-storage": "^3.2.
|
|
166
|
-
"hyperdb": "^6.
|
|
161
|
+
"hypercore-storage": "^3.2.1",
|
|
162
|
+
"hyperdb": "^6.9.0",
|
|
167
163
|
"hyperdispatch": "^1.6.0",
|
|
168
164
|
"hyperschema": "^1.22.0",
|
|
169
165
|
"hyperswarm": "^4.17.0",
|
|
@@ -182,7 +178,7 @@
|
|
|
182
178
|
"bare-fetch": "^3.2.0",
|
|
183
179
|
"bare-process": "^4.5.1",
|
|
184
180
|
"bare-url": "^2.5.2",
|
|
185
|
-
"blind-peer": "^3.13.
|
|
181
|
+
"blind-peer": "^3.13.3",
|
|
186
182
|
"brittle": "^4.1.0",
|
|
187
183
|
"typescript": "^5.9.3",
|
|
188
184
|
"which-runtime": "^1.4.0"
|
package/src/database/dispatch.js
CHANGED
|
@@ -114,7 +114,11 @@ export function makeDispatcher(
|
|
|
114
114
|
if (!isKey(op.master) || !isKey(op.writer) || !isSig(op.sig)) return
|
|
115
115
|
if (!Identity.verify(op.master, addWriterPayload(ctx.dbKey, op.writer, ctx.key), op.sig)) return
|
|
116
116
|
if (!(await isGenesis(ctx.view)) && !can(await getRole(ctx.view, op.master), INVITE)) return
|
|
117
|
-
|
|
117
|
+
// always an indexer, like claim-writer below. The op's optional isIndexer
|
|
118
|
+
// bool decodes to false when absent (nothing sets it), which silently made
|
|
119
|
+
// every device a weight-1 writer — autobee 2.0 gc's caught-up non-indexer
|
|
120
|
+
// sessions, and a gc'd writer misses later appends until a wakeup revives it
|
|
121
|
+
await ctx.host.addWriter(op.writer, { isIndexer: true })
|
|
118
122
|
const ts = op.ts || 0
|
|
119
123
|
await insert(ctx.view, 'devices', `@${ns}/devices`, {
|
|
120
124
|
id: toId(op.writer),
|
|
@@ -230,54 +230,36 @@ export class EpochAutobee extends Autobee {
|
|
|
230
230
|
await primeKeyring(this.keyring, this.local)
|
|
231
231
|
}
|
|
232
232
|
|
|
233
|
-
//
|
|
234
|
-
//
|
|
235
|
-
//
|
|
236
|
-
//
|
|
237
|
-
//
|
|
238
|
-
//
|
|
239
|
-
// instead of crashing the bee.
|
|
233
|
+
// A writer whose next blocks sit at an epoch we haven't learned yet parks:
|
|
234
|
+
// its next() reports "nothing to offer" instead of throwing, so upstream's
|
|
235
|
+
// drain keeps selecting among the other writers — the announcement carrying
|
|
236
|
+
// the missing epoch lives in one of THEIR cores and unlocks the parked
|
|
237
|
+
// writer on a later bump (the scheduled retry pokes the drain). The outer
|
|
238
|
+
// catch backstops an UNKNOWN_EPOCH surfacing from batch processing itself.
|
|
240
239
|
async _bumpPendingWriters() {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
240
|
+
for (const w of this.writers.pending) this._parkOnUnknownEpoch(w)
|
|
241
|
+
try {
|
|
242
|
+
return await super._bumpPendingWriters()
|
|
243
|
+
} catch (err) {
|
|
244
|
+
if (err?.code !== 'UNKNOWN_EPOCH') throw err
|
|
245
|
+
this._scheduleEpochRetry()
|
|
246
|
+
return false
|
|
244
247
|
}
|
|
248
|
+
}
|
|
245
249
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
const w = pending[i]
|
|
252
|
-
|
|
250
|
+
_parkOnUnknownEpoch(w) {
|
|
251
|
+
if (w._epochParking) return
|
|
252
|
+
w._epochParking = true
|
|
253
|
+
const next = w.next.bind(w)
|
|
254
|
+
w.next = async () => {
|
|
253
255
|
try {
|
|
254
|
-
|
|
255
|
-
if (batch === null) continue
|
|
256
|
-
|
|
257
|
-
if (w.isAdded || (w.isRemoved && w.hasReferrals())) {
|
|
258
|
-
await this._processBatch(batch)
|
|
259
|
-
w.notify(batch)
|
|
260
|
-
updated = true
|
|
261
|
-
continue
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
if (this.optimistic && !w.isRemoved && batch[0].optimistic) {
|
|
265
|
-
if (!(await this._optimisticBatch(batch))) {
|
|
266
|
-
w.removePending()
|
|
267
|
-
continue
|
|
268
|
-
}
|
|
269
|
-
w.notify(batch)
|
|
270
|
-
updated = true
|
|
271
|
-
continue
|
|
272
|
-
}
|
|
256
|
+
return await next()
|
|
273
257
|
} catch (err) {
|
|
274
258
|
if (err?.code !== 'UNKNOWN_EPOCH') throw err
|
|
275
259
|
this._scheduleEpochRetry()
|
|
276
|
-
|
|
260
|
+
return null
|
|
277
261
|
}
|
|
278
262
|
}
|
|
279
|
-
|
|
280
|
-
return updated
|
|
281
263
|
}
|
|
282
264
|
|
|
283
265
|
// a parked writer produces no wake-up of its own — poke the bee until the
|
|
@@ -11,13 +11,20 @@ export function blobEpochKey(entropy: Uint8Array): Uint8Array;
|
|
|
11
11
|
* Wire codec for a rotation announcement's envelope list — one sealed box
|
|
12
12
|
* per remaining member, addressed by member id.
|
|
13
13
|
*/
|
|
14
|
-
export const wraps: any
|
|
14
|
+
export const wraps: c.Encoder<any[], {
|
|
15
|
+
id: string;
|
|
16
|
+
box: Uint8Array<ArrayBufferLike>;
|
|
17
|
+
}[]>;
|
|
15
18
|
/**
|
|
16
19
|
* Wire codec for locally persisted / pairing-delivered epoch secrets.
|
|
17
20
|
* `epoch` is the apply-order sequence; `stamp` is the content-addressed
|
|
18
21
|
* uint32 written into block headers.
|
|
19
22
|
*/
|
|
20
|
-
export const epochEntries: any
|
|
23
|
+
export const epochEntries: c.Encoder<any[], {
|
|
24
|
+
epoch: number;
|
|
25
|
+
stamp: number;
|
|
26
|
+
entropy: Uint8Array<ArrayBufferLike>;
|
|
27
|
+
}[]>;
|
|
21
28
|
/**
|
|
22
29
|
* Per-database registry of rotation epochs. Stamp 0 is the base key era
|
|
23
30
|
* (no entry needed — it derives from the upstream GENESIS_ENTROPY path).
|
|
@@ -83,8 +90,9 @@ export class EpochAutobee {
|
|
|
83
90
|
_epochRetryDelay: number;
|
|
84
91
|
_epochRetrySeen: number;
|
|
85
92
|
_bootState(): Promise<void>;
|
|
86
|
-
_bumpPendingWriters(): Promise<
|
|
87
|
-
|
|
93
|
+
_bumpPendingWriters(): Promise<any>;
|
|
94
|
+
_parkOnUnknownEpoch(w: any): void;
|
|
88
95
|
_scheduleEpochRetry(): void;
|
|
89
96
|
_close(): Promise<any>;
|
|
90
97
|
}
|
|
98
|
+
import c from 'compact-encoding';
|