@cero-base/core 1.15.1 → 1.15.2
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 +2 -2
- package/src/database/dispatch.js +11 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cero-base/core",
|
|
3
|
-
"version": "1.15.
|
|
3
|
+
"version": "1.15.2",
|
|
4
4
|
"description": "cero p2p primitives — identity, storage, network, database, blobs, rpc, pairing.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -136,7 +136,7 @@
|
|
|
136
136
|
},
|
|
137
137
|
"dependencies": {
|
|
138
138
|
"@hyperswarm/secret-stream": "^6.9.1",
|
|
139
|
-
"autobee": "2.0.0-rc.
|
|
139
|
+
"autobee": "2.0.0-rc.27",
|
|
140
140
|
"autobee-encryption": "0.1.3",
|
|
141
141
|
"b4a": "^1.8.1",
|
|
142
142
|
"bare-crypto": "^1.15.3",
|
package/src/database/dispatch.js
CHANGED
|
@@ -266,15 +266,24 @@ export function makeDispatcher(
|
|
|
266
266
|
const col = `@${ns}/${b.name}`
|
|
267
267
|
if (b.verb === 'member') continue
|
|
268
268
|
if (b.verb === 'device') {
|
|
269
|
+
// A device row IS the writer→role mapping: getSignerRole resolves a
|
|
270
|
+
// writer key through it to a member, and every permission check reads
|
|
271
|
+
// that role. So memberId is never taken off the wire — it stays whatever
|
|
272
|
+
// add-writer/claim-writer/add-member bound, and an unknown id can only
|
|
273
|
+
// ever bind to the signer's own member. Otherwise one unauthenticated op
|
|
274
|
+
// would re-point a writer at the owner and inherit their authority.
|
|
275
|
+
const bind = async (op, ctx, existing) =>
|
|
276
|
+
existing?.memberId ?? (await getSignerMember(ctx.view, ctx.key))
|
|
269
277
|
add(`add-${b.verb}`, async (op, ctx) => {
|
|
270
|
-
await
|
|
278
|
+
const existing = await getDevice(ctx.view, op.id)
|
|
279
|
+
await insert(ctx.view, b.name, col, { ...op, memberId: await bind(op, ctx, existing) })
|
|
271
280
|
})
|
|
272
281
|
add(`set-${b.verb}`, async (op, ctx) => {
|
|
273
282
|
const existing = await getDevice(ctx.view, op.id)
|
|
274
283
|
const ts = op.updatedAt || 0
|
|
275
284
|
await insert(ctx.view, b.name, col, {
|
|
276
285
|
...op,
|
|
277
|
-
memberId:
|
|
286
|
+
memberId: await bind(op, ctx, existing),
|
|
278
287
|
createdAt: existing?.createdAt || op.createdAt || ts,
|
|
279
288
|
updatedAt: ts
|
|
280
289
|
})
|