@cero-base/core 1.15.0 → 1.15.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cero-base/core",
3
- "version": "1.15.0",
3
+ "version": "1.15.1",
4
4
  "description": "cero p2p primitives — identity, storage, network, database, blobs, rpc, pairing.",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -195,13 +195,16 @@ export class Database extends ReadyResource {
195
195
  // no cero row records another writer's oplog length to fall back to.
196
196
  isTrusted: async (writer, view) => {
197
197
  try {
198
- if (await view.get(`@${this.ns}/devices`, { id: toId(writer) })) return true
199
- // before any device record exists (a boot's genesis-era reference)
200
- // only the genesis writer may vouch — its core IS the db key, and
201
- // its signatures are unforgeable. Anyone else stays refused: an
202
- // empty view is exactly the window an ex-member would target.
203
- const any = await view.find(`@${this.ns}/devices`, { limit: 1 }).toArray()
204
- return any.length === 0 && !!this.key && b4a.equals(writer, this.key)
198
+ const row = await bounded(view.get(`@${this.ns}/devices`, { id: toId(writer) }))
199
+ if (!row) return false
200
+ if (row.v) return true
201
+ // only where the view PROVABLY holds no device yet (a boot's
202
+ // genesis-era reference) may the genesis writer vouch its core IS
203
+ // the db key, and its signatures are unforgeable. Everyone else
204
+ // stays refused: an empty view is the window an ex-member targets.
205
+ const any = await bounded(view.find(`@${this.ns}/devices`, { limit: 1 }).toArray())
206
+ if (!any) return false
207
+ return any.v.length === 0 && !!this.key && b4a.equals(writer, this.key)
205
208
  } catch {
206
209
  return false
207
210
  }
@@ -1240,6 +1243,17 @@ export class Database extends ReadyResource {
1240
1243
  }
1241
1244
  }
1242
1245
 
1246
+ // A trust decision reads a historic checkout view, whose blocks may not be
1247
+ // servable yet — an unbounded read there wedges autobee's drain forever. The
1248
+ // value is wrapped so a timeout (null) is never mistaken for what the read
1249
+ // would have returned; undecidable in time means "not trusted", and the
1250
+ // caller retries.
1251
+ const bounded = (promise, ms = 2000) =>
1252
+ Promise.race([
1253
+ promise.then((v) => ({ v })),
1254
+ new Promise((resolve) => setTimeout(() => resolve(null), ms))
1255
+ ])
1256
+
1243
1257
  // Fields the write path stamps itself — always allowed even if not user-declared.
1244
1258
  const SYSTEM_FIELDS = new Set(['id', 'memberId', 'index', 'createdAt', 'updatedAt'])
1245
1259