OverviewFilesCommitsIssuesDocsReleasesPeers

keet-daemon commits / 08a3864

router: identity.lookupMember passes the member id, not the room id
keet-core's lookupUserByMemberId takes ONE argument, the member key (4.22.28 _lookupUserByMemberId(e) decodes e for the username registry). The router called it as (roomId, memberId), so keet-core looked up the ROOM key — hyper-games #89 defect 8. roomId is still accepted, no longer required. Test: test/identity-lookup-member.test.js (stub backend), red before the fix (called with ["ROOMKEY","MEMBERKEY"]), green after. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
08a3864be72482717ec100981da7de8239bfb067
by plankatron <fleeky@gmail.com> · 2026-10-04T17:34:34.000Z

Changed files (2) +53 -2

lib/router.js +5 -2
……@@ -1315,10 +1315,13 @@ export class Router {
13151315 return this.backend.api.core.lookupUsername(params.username)
13161316 }
13171317
1318 // keet-core's lookupUserByMemberId takes ONE argument, the member key (4.22.28
1319 // _lookupUserByMemberId(e) decodes e for the username registry). This passed
1320 // (roomId, memberId), so keet-core looked up the ROOM key (hyper-games #89 defect
1321 // 8). roomId is still accepted from callers but the lookup is identity-wide.
13181322 async _identityLookupMember (params) {
1319 if (!params.roomId) throw new Error('Missing required param: roomId')
13201323 if (!params.memberId) throw new Error('Missing required param: memberId')
1321 return this.backend.api.core.lookupUserByMemberId(params.roomId, params.memberId)
1324 return this.backend.api.core.lookupUserByMemberId(params.memberId)
13221325 }
13231326
13241327 // --- Room Config & Management ---
test/identity-lookup-member.test.js +48 -0
……@@ -0,0 +1,48 @@
1// identity-lookup-member.test.js — identity.lookupMember passes the MEMBER id
2// (hyper-games #89 defect 8: "passes roomId where keet-core expects the member id").
3//
4// keet-core's lookupUserByMemberId takes ONE argument — the member key — and
5// decodes it for the username registry (keet-core 4.22.28 lib/api/v1/index.js
6// _lookupUserByMemberId(e): hypercoreIdEncoding.decode(e) -> userRegistry.lookupByKey).
7// The router called it as (roomId, memberId), so keet-core looked up the ROOM key.
8//
9// No keet-core needed: the backend is a stub that records what it was called with.
10//
11// Run: cd hyper-fleeky/packages/keet-daemon && bare test/identity-lookup-member.test.js
12
13import fs from 'bare-fs'
14import path from 'bare-path'
15import os from 'bare-os'
16import { Router } from '../lib/router.js'
17
18let exitCode = 0
19function ok (cond, msg) {
20 if (cond) console.log(' ok ' + msg)
21 else { console.log(' FAIL ' + msg); exitCode = 1 }
22}
23
24const storage = path.join(os.tmpdir(), 'keet-daemon-test-lookup-' + Date.now())
25fs.mkdirSync(storage, { recursive: true })
26
27const calls = []
28const backend = {
29 api: {
30 core: {
31 lookupUserByMemberId: async (...args) => { calls.push(args); return { username: 'alice0' } }
32 }
33 }
34}
35const router = new Router(backend, null, { storage })
36
37const res = await router._identityLookupMember({ roomId: 'ROOMKEY', memberId: 'MEMBERKEY' })
38ok(calls.length === 1, 'keet-core lookupUserByMemberId called once')
39ok(calls[0] && calls[0].length === 1 && calls[0][0] === 'MEMBERKEY',
40 'with the MEMBER id as its only argument (got ' + JSON.stringify(calls[0]) + ')')
41ok(res && res.username === 'alice0', 'and its result is returned')
42
43let threw = false
44try { await router._identityLookupMember({ roomId: 'ROOMKEY' }) } catch { threw = true }
45ok(threw, 'a missing memberId is refused')
46
47console.log(exitCode === 0 ? '\nPASS' : '\nFAIL')
48Bare.exit(exitCode)