@witbitz/sdk 4.6.0 → 4.7.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/vault-core.js CHANGED
@@ -22,7 +22,7 @@ import { routingIndex } from './opRouting.js'
22
22
  import { memberHash } from './rosterHash.js'
23
23
  import { Witbitz, Space, Lane } from './witbitz-sdk.js'
24
24
  import { LaneA2A, assertAgentTarget } from './sdkA2A.js'
25
- import { openGrant, relink, changeMembers, rotateKey, changeable, planMembers } from './sdkRekey.js' // a Space's members changed in place (https://witbitz.chat/docs/sdk-people.md#members)
25
+ import { openGrant, relink, changeMembers, rotateKey, changeable, planMembers, sessionRole } from './sdkRekey.js' // a Space's members changed in place (https://witbitz.chat/docs/sdk-people.md#members)
26
26
  import { setPendingKeyStore } from './connections.js' // the SDK's pending-key store (N#7): this vault's
27
27
  import { adoptPendingKeys } from './connPending.js'
28
28
  import { idb } from './idb.js'
@@ -34,6 +34,7 @@ import { liveLocks } from './chatLock.js'
34
34
  import { openItem, cardUrlOf, mcpUrlOf } from './a2aCore.js'
35
35
  import { judgeMove, checkNewRoomGov } from './emailFork.js'
36
36
  import { ROSTER_DOC, selfRow, ensureSelf, unseenIn, entriesMissing, announcedIn } from './roomRoster.js'
37
+ import { signedInRoomTags } from './roomRoles.js'
37
38
  import { findEmptySpaces, removeEmptySpaces, ownAdmissionEntries } from './emptySpaces.js'
38
39
  import { readAllPages } from './ledgerView.js'
39
40
  import { commit as keyCommit } from './e2ee.js'
@@ -57,6 +58,17 @@ export const VAULT_PROTOCOL = 1
57
58
  // cross-room), subscribe/unsubscribe (push belongs to the vault), and the intake ops (the account's). Sealed exports and supported chat imports are allowed.
58
59
  // (no 'safeCopy': a safe copy is made only where the sign-in and the key are — space.safeMedia.make is refused in a vault, and
59
60
  // nothing in vault mode posts one; sync sweep backlog P7)
61
+ export function roleSummary(emails, tags, roleUsers) {
62
+ const labels = [...emails]
63
+ let unknown = 0
64
+ for (const tag of tags || []) {
65
+ if (Object.hasOwn(roleUsers, tag)) labels.push('@' + roleUsers[tag])
66
+ else unknown++
67
+ }
68
+ if (unknown) labels.push(unknown + (unknown === 1 ? ' unidentified member' : ' unidentified members'))
69
+ return labels.join(', ') || 'none'
70
+ }
71
+
60
72
  export const PAGE_OPS = new Set(['poll', 'pollSealed', 'turn', 'state', 'data', 'title', 'decide', 'pending', 'mirror', 'toolResult', 'getConfig', 'setConfig', 'blob', 'react', 'mark', 'sealed', 'exportSealed', 'stop', 'toolRules', 'importChat', 'importWhatsApp'])
61
73
  const KEYS = { rooms: 'wbvault:rooms', session: 'wbvault:session', siri: 'wbvault:siri', a2a: 'wbvault:a2a', invite: 'wbvault:invite', connections: 'wbvault:connections', backup: 'wbvault:backup', keep: 'wbvault:keep', connPending: 'wbvault:connPending', connGone: 'wbvault:connGone', pendingForget: 'wbvault:pendingForget', pendingGrants: 'wbvault:pendingGrants' }
62
74
  // THE ACCOUNT, through the vault's session (docs/sdk-vault-mode.md § The account). The page asks; the vault runs it on its
@@ -82,7 +94,7 @@ export const ACCOUNT_CALLS = {
82
94
  /** The backup calls that need an account on the Witbitz account service (sync sweep 11-16 #15). */
83
95
  const SERVICE_CALLS = new Set(['manageSecurityKeys', 'signOutOthers', 'newRecoveryCode', 'emailMove', 'requestMoveTime', 'cancelEmailMove'])
84
96
  export const ROOM_ACCOUNT_CALLS = {
85
- roster: { list: {}, admission: {} },
97
+ roster: { list: {}, admission: {}, isOwner: {}, isAdmin: {}, sessionRole: {} },
86
98
  portable: { export: { confirm: true } },
87
99
  privateRoom: { link: { confirm: true }, unlink: { confirm: true } },
88
100
  keptAgent: { link: { confirm: true }, unlink: { confirm: true } },
@@ -778,17 +790,20 @@ export async function startVault(o = {}) {
778
790
  const get = () => read(st, key, {}) || {}
779
791
  const unchanged = () => who() === owner && privacyEpoch === epoch && JSON.stringify(get()[pending]) === JSON.stringify(entry)
780
792
  if (!unchanged()) return
793
+ // ★ A DROPPED SIRI ENTRY MAY ALREADY BE AT THE SENTINEL (its answer was lost — why it was pending), naming an inbox key only it held:
794
+ // captures nobody here could open. The record this vault DOES hold is sent at once, as the app's siri.js converge (sync sweep 11-28 P8)
795
+ const converge = async () => { const held = (read(st, key, {}) || {})[owner]; if (key === KEYS.siri && held?.token && who() === owner && privacyEpoch === epoch) await api._push(held).catch(() => {}) }
781
796
  for (let attempt = 0; attempt < 3 && unchanged(); attempt++) {
782
797
  const current = get()[owner] || null
783
798
  if (key === KEYS.siri && entry.next && ((current?.rev || 0) > (entry.base?.rev || 0) || (entry.base?.token && current?.token && entry.base.token !== current.token) || ((entry.base?.token || entry.base?.tokenHash) && !current?.token && !current?.tokenHash))) {
784
- const kept = get(); delete kept[pending]; put(key, kept); return
799
+ const kept = get(); delete kept[pending]; put(key, kept); await converge(); return
785
800
  }
786
801
  const next = applyEdit(entry.next ? entry.base : committed, entry.next || entry, current)
787
802
  if (!next) return
788
803
  try {
789
804
  await api._push(next)
790
805
  } catch (error) {
791
- if (unchanged() && error.definiteRefusal) { const kept = get(); delete kept[pending]; put(key, kept) }
806
+ if (unchanged() && error.definiteRefusal) { const kept = get(); delete kept[pending]; put(key, kept); await converge() }
792
807
  return
793
808
  }
794
809
  if (!unchanged()) return
@@ -807,7 +822,7 @@ export async function startVault(o = {}) {
807
822
  const saveA2A = () => { const w = who(); if (!w) return; const all = read(st, KEYS.a2a, {}); all[w] = sdk.a2a.state; put(KEYS.a2a, all); keepSoon() }
808
823
  // A LANE GIVEN A NEW ADDRESS mid-grant (handle_taken: the old one was the person's other Witbitz app's account's; sdkA2A _readdress):
809
824
  // kept in the vault's store BEFORE the grant is sent again, and the page's lane views read again (cardUrl / mcpUrl move with it)
810
- sdk.a2a.onReaddressed = (lanes) => { saveA2A(); emit({ ev: 'a2aChanged', readdressed: lanes.map((l) => l.room) }) }
825
+ sdk.a2a.onReaddressed = (lanes) => { saveA2A(); emit({ ev: 'a2aChanged', readdressed: lanes.map((l) => l.room), addresses: lanes.map(({ room, cardUrl, mcpUrl }) => ({ room, cardUrl, mcpUrl })) }) } // addresses: public, the page's wb.a2a.onReaddressed (sync sweep 11-29 #12)
811
826
  // ── THE SAME THREE ON EVERY DEVICE OF THE ACCOUNT (vaultKeep.js; sync sweep 2026-11-11 P7): a second device listed this account's
812
827
  // connections but could not use one (`not_in_vault`), and could not open Siri or an outside agent's message. Synced, sealed,
813
828
  // through the account's index room — only while the backup is on (it is what derives that room). One pass at a time; a pass
@@ -1071,8 +1086,8 @@ export async function startVault(o = {}) {
1071
1086
  const summary = plan ? [
1072
1087
  'Members: ' + plan.emails.join(', '),
1073
1088
  'Domains: ' + ((plan.m.allow.domains || []).join(', ') || 'none'),
1074
- 'Owners: ' + (plan.want.owners.join(', ') || 'none'),
1075
- 'Admins: ' + (plan.want.admins.join(', ') || 'none'),
1089
+ 'Owners: ' + roleSummary(plan.want.owners, plan.want.ownerTags, plan.roleUsers),
1090
+ 'Admins: ' + roleSummary(plan.want.admins, plan.want.adminTags, plan.roleUsers),
1076
1091
  ...(plan.m.allow.users?.length ? ['Usernames: ' + plan.m.allow.users.map(u => u.handle).join(', ')] : []),
1077
1092
  ...(plan.m.allow.mh?.length ? ['Private membership entries: ' + plan.m.allow.mh.length] : []),
1078
1093
  ].join('\n') : ''
@@ -1188,7 +1203,7 @@ export async function startVault(o = {}) {
1188
1203
  'backup.newRecoveryCode': { title: 'Make a new recovery code?', text: 'Your current code stops working, and every other device is signed out. We email you a code to confirm, then show the new recovery code once.', ok: 'New code' },
1189
1204
  // a move already under way resumes in ITS saved mode, whatever this call asks (sdkBackupV2.js migrate) — the words say what it will do
1190
1205
  // (side sweep 2026-11-28: a resumed emailed-code move promised that devices could join, then signed them out)
1191
- 'backup.migrate': (sdk.backup._s?.v2?.moving ? (sdk.backup._s.v2.moveMode === 'signed' || sdk.backup._s.v2.svc?.silent === 'moved') : a?.silent === true) ? { title: 'Move this account with its signing key?', text: 'Your Spaces and recovery code stay the same. Other eligible devices can join using their existing account keys.', ok: 'Move account' } : { title: 'Move to the new account service?', text: 'Your Spaces and recovery code stay the same. Other devices are signed out and can restore on the new service. This legacy backup has no account key, so it moves with email-only trust; Advanced Backup remains unavailable.', ok: 'Move account' },
1206
+ 'backup.migrate': (sdk.backup._s?.v2?.moving ? (sdk.backup._s.v2.moveMode === 'signed' || sdk.backup._s.v2.svc?.silent === 'moved') : a?.silent === true) ? { title: 'Move this account with its signing key?', text: 'Your Spaces and recovery code stay the same. Other eligible devices can join using their existing account keys.', ok: 'Move account' } : { title: 'Move to the new account service?', text: 'Your Spaces and recovery code stay the same. Other devices are signed out and can restore on the new service. This legacy backup has no account key, so it moves using email alone. After the move, you can enroll security keys if Advanced Backup is available on this service.', ok: 'Move account' },
1192
1207
  'cloudDevice.enroll': { title: 'Sign the cloud device in?', text: 'We email a code so this secure cloud device can sign in to this app’s account. No Space is handed over yet.', ok: 'Send code' },
1193
1208
  'cloudDevice.register': { title: 'Add the cloud device to your account?', text: 'Register its public device key on the account service. You can sign it out later from Your devices. We email a code to confirm.', ok: 'Add device' },
1194
1209
  'cloudDevice.setBuilds': { title: 'Update the cloud device’s secure builds?', text: 'The cloud device will follow this account’s accepted secure-build list and automatic-acceptance choice.', ok: 'Update' },
@@ -1229,7 +1244,7 @@ export async function startVault(o = {}) {
1229
1244
  const syncError = a.lastError || (lastKeepFailure?.owner === who() && lastKeepFailure?.master === b._s?.master ? lastKeepFailure?.error : null)
1230
1245
  return {
1231
1246
  enabled: b.enabled, format: b.format, service: b.service, deviceId: a.deviceId, // service: 'account' (the Witbitz account service) | 'legacy' | null
1232
- rooms: b.rooms.map(({ room, kind, label, shared, detachedLane, archived, pinned, lastOpenedAt }) => ({ room, kind, ...(detachedLane ? { detachedLane: true } : {}), ...(pinned ? { pinned: true } : {}), ...(label ? { label } : {}), ...(shared ? { shared } : {}), ...(archived ? { archived: true } : {}), ...(lastOpenedAt > 0 ? { lastOpenedAt } : {}), ...(a._keptMarks && a._keptMarks.has(room) ? { alwaysOn: true } : {}) })), // lastOpenedAt: read-only, as the direct SDK (side sweep: sdk-account-room-list-omits-recency)
1247
+ rooms: b.rooms.map(({ room, kind, label, shared, laneOrigin, mintedFor, detachedLane, archived, pinned, lastOpenedAt }) => ({ room, kind, ...(detachedLane ? { detachedLane: true } : {}), ...(pinned ? { pinned: true } : {}), ...(label ? { label } : {}), ...(shared ? { shared } : {}), ...(laneOrigin ? { laneOrigin } : {}), ...(mintedFor ? { mintedFor } : {}), ...(archived ? { archived: true } : {}), ...(lastOpenedAt > 0 ? { lastOpenedAt } : {}), ...(a._keptMarks && a._keptMarks.has(room) ? { alwaysOn: true } : {}) })), // lastOpenedAt: read-only, as the direct SDK (side sweep: sdk-account-room-list-omits-recency)
1233
1248
  devices: a.devices, links: a.links, lastError: syncError ? { message: String(syncError.message || syncError).slice(0, 200), ...(typeof syncError.code === 'string' ? { code: syncError.code.slice(0, 60) } : {}), ...(Number.isInteger(syncError.status) ? { status: syncError.status } : {}) } : null,
1234
1249
  erasure: sdk.erasure.available,
1235
1250
  gated: !!b.gated, // a restore and deleting the account need the emailed code as well (sync sweep 11-09 #24)
@@ -1446,7 +1461,12 @@ export async function startVault(o = {}) {
1446
1461
  if (forgetMark(room) !== mark) throw new Error('vault could not save the room removal')
1447
1462
  pendingForget.add(room)
1448
1463
  write(st, KEYS.pendingForget, [...pendingForget])
1449
- rooms = rooms.filter(r => r.room !== room)
1464
+ // its private lanes stay as rooms of their own — never lanes of a Space this device no longer holds (as backup.remove, sdkBackup.js)
1465
+ rooms = rooms.filter(r => r.room !== room).map(r => {
1466
+ if (r.lane !== room) return r
1467
+ const { lane, laneOrigin, ...rest } = r
1468
+ return { ...rest, ...(laneOrigin === 'minted' && !r.mintedFor ? { mintedFor: lane } : {}), detachedLane: true, associationAt: Math.max(Date.now(), Number(r.associationAt) || 0) }
1469
+ })
1450
1470
  emit({ ev: 'rooms', rooms: publicRooms() })
1451
1471
  streamGrants.delete(room)
1452
1472
  if (streaming.delete(room)) syncStream(worker, room, null)
@@ -1727,7 +1747,7 @@ export async function startVault(o = {}) {
1727
1747
  const config = await wop('getConfig', room, { plainMark: true })
1728
1748
  if (epoch === privacyEpoch && held(room) && (config?.help || config?.lane || config?.bridge)) return { excluded: true }
1729
1749
  const history = await readAllPages(since => wop('poll', room, undefined, since))
1730
- return epoch === privacyEpoch && held(room) && config && !config.help && !config.lane && !config.bridge && history.status === 200 && !history.incomplete ? { config, entries: history.entries, etag: history.etag, selfEntries: await ownAdmissionEntries(config, signedIn() && sdk.session.email, () => wop('state', room, ROSTER_DOC)), selfHash: signedIn() ? await memberHash(sdk.session.email, room) : null } : null
1750
+ return epoch === privacyEpoch && held(room) && config && !config.help && !config.lane && !config.bridge && history.status === 200 && !history.incomplete ? { config, entries: history.entries, etag: history.etag, selfEntries: await ownAdmissionEntries(config, signedIn() && sdk.session.email, () => wop('state', room, ROSTER_DOC), () => signedInRoomTags(sdk._client, room, sdk.session?.idToken)), selfHash: signedIn() ? await memberHash(sdk.session.email, room) : null } : null
1731
1751
  },
1732
1752
  forget: async room => { if (epoch === privacyEpoch && held(room)) { await base.forget(room); await dropRoom(room) } },
1733
1753
  }
@@ -1764,26 +1784,29 @@ export async function startVault(o = {}) {
1764
1784
  if (!sec || !sec._calls.includes(op)) throw Object.assign(new Error('vault: account.' + String(name).slice(0, 20) + '.' + String(op).slice(0, 20) + ' is not available to the page'), { code: 'vault_refused' })
1765
1785
  if (!watchedSections.has(name)) { watchedSections.add(name); sec.on('change', (value) => emit({ ev: 'accountSection', section: name, value })) } // another device's change reaches the page
1766
1786
  let result
1767
- if (name === 'chatLocks' && op === 'deleteAll') {
1768
- const owner = sdk.backup._s, epoch = privacyEpoch, { targets: locks, privateAssistants: assistants } = await sec.previewDeleteAll()
1769
- if (!locks.length) return []
1770
- const lockedRooms = new Set(locks.filter(l => l.kind === 'room').map(l => l.target))
1771
- const extra = assistants.length ? ' Their private assistants will also be removed: ' + assistants.map(r => r.title || r.room).join(', ') + '.' : ''
1772
- const roomCount = lockedRooms.size
1773
- const confirmed = await confirmWith({ title: 'Delete all locked chats?', text: 'Remove ' + roomCount + ' locked Spaces from this account and delete ' + (locks.length - roomCount) + ' Code sessions on their computers? Forgetting a Space leaves its sealed messages on the server. Independently linked rooms keep their copies.' + extra, ok: 'Delete all', cancel: 'Cancel' })
1774
- if (!confirmed) throw Object.assign(new Error('Cancelled'), { code: 'cancelled' })
1775
- if (epoch !== privacyEpoch || owner !== sdk.backup._s) throw Object.assign(new Error('The account changed.'), { code: 'account_changed' })
1776
- result = await sec._deleteTargets(locks, owner, async (kind, room) => {
1777
- if (epoch !== privacyEpoch) throw new Error('Account changed')
1778
- if (kind === 'room' && held(room)) await dropRoom(room)
1779
- }, assistants.map(r => r.room))
1780
- if (epoch === privacyEpoch && owner === sdk.backup._s) {
1781
- await fromBackup()
1782
- emit({ ev: 'accountSection', section: name, value: sec.value })
1787
+ // the page's chatLocks.value follows every call, a refused or cancelled one too: a preview's sync or a wrong PIN's try changed it
1788
+ // (sync sweep 11-27 P7) — never another account's
1789
+ const shown0 = sdk.backup._s, shownEpoch = privacyEpoch
1790
+ try {
1791
+ if (name === 'chatLocks' && op === 'deleteAll') {
1792
+ const owner = sdk.backup._s, epoch = privacyEpoch, { targets: locks, privateAssistants: assistants } = await sec.previewDeleteAll()
1793
+ if (!locks.length) return []
1794
+ const lockedRooms = new Set(locks.filter(l => l.kind === 'room').map(l => l.target))
1795
+ const extra = assistants.length ? ' Their private assistants will also be removed: ' + assistants.map(r => r.title || r.room).join(', ') + '.' : ''
1796
+ const roomCount = lockedRooms.size
1797
+ const confirmed = await confirmWith({ title: 'Delete all locked chats?', text: 'Remove ' + roomCount + ' locked Spaces from this account and delete ' + (locks.length - roomCount) + ' Code sessions on their computers? Forgetting a Space leaves its sealed messages on the server. Independently linked rooms keep their copies.' + extra, ok: 'Delete all', cancel: 'Cancel' })
1798
+ if (!confirmed) throw Object.assign(new Error('Cancelled'), { code: 'cancelled' })
1799
+ if (epoch !== privacyEpoch || owner !== sdk.backup._s) throw Object.assign(new Error('The account changed.'), { code: 'account_changed' })
1800
+ result = await sec._deleteTargets(locks, owner, async (kind, room) => {
1801
+ if (epoch !== privacyEpoch) throw new Error('Account changed')
1802
+ if (kind === 'room' && held(room)) await dropRoom(room)
1803
+ }, assistants.map(r => r.room))
1804
+ if (epoch === privacyEpoch && owner === sdk.backup._s) await fromBackup()
1805
+ } else {
1806
+ result = await sec[op](...rest.slice(0, 1))
1783
1807
  }
1784
- } else {
1785
- result = await sec[op](...rest.slice(0, 1))
1786
- if (name === 'chatLocks' && (op === 'match' || op === 'check')) emit({ ev: 'accountSection', section: name, value: sec.value })
1808
+ } finally {
1809
+ if (name === 'chatLocks' && shownEpoch === privacyEpoch && shown0 === sdk.backup._s) emit({ ev: 'accountSection', section: name, value: sec.value })
1787
1810
  }
1788
1811
  if (name === 'blocks' || name === 'chatLocks') {
1789
1812
  // A refresh already in flight may have read the list before this change.
@@ -1825,9 +1848,9 @@ export async function startVault(o = {}) {
1825
1848
  if (ns === 'backup' && SERVICE_CALLS.has(m) && !(sdk.backup._v2 && sdk.backup.service === 'account' && sdk.backup.enabled)) throw Object.assign(new Error('witbitz: this call is for an account on the Witbitz account service, in a vault that names its tenant (wb.backup.service === \'account\')'), { code: 'not_on_service' })
1826
1849
  if (ns === 'cloudDevice' && m === 'register' && !(sdk.backup._v2 && sdk.backup.service === 'account' && sdk.backup.enabled)) throw Object.assign(new Error('register the cloud device from an account on the account service'), { code: 'not_on_service' })
1827
1850
  if (spec.confirm) {
1828
- const epoch = privacyEpoch, owner = who()
1851
+ const epoch = privacyEpoch, owner = who(), account = sdk.backup._s
1829
1852
  await confirmCall(ns, m, args)
1830
- if (epoch !== privacyEpoch || owner !== who()) throw Object.assign(new Error('the account changed during confirmation'), { code: 'account_changed' })
1853
+ if (epoch !== privacyEpoch || owner !== who() || account !== sdk.backup._s) throw Object.assign(new Error('the account changed during confirmation'), { code: 'account_changed' })
1831
1854
  }
1832
1855
  if (ns === 'cloudDevice' && (m === 'enroll' || m === 'register')) return sdk.cloudDevice[m]({ getCode: await emailCodeAsker('cloud-device', accountAddress) })
1833
1856
  if (ns === 'backup') return backupCall(m, args)
@@ -1922,11 +1945,14 @@ export async function startVault(o = {}) {
1922
1945
  if (ns === 'a2a') return laneA2A(room, m, args)
1923
1946
  const sp = roomSpace(room)
1924
1947
  try {
1948
+ if (ns === 'roster' && m === 'sessionRole') return sessionRole(sp, await sp._gateConfig({ fresh: true, plainMark: true }))
1949
+ if (ns === 'roster' && (m === 'isOwner' || m === 'isAdmin')) return sp[m](args[0])
1925
1950
  if (ns === 'roster') return await (m === 'list' ? sp.roster() : sp.admission())
1926
1951
  if (ns === 'portable') {
1927
1952
  const { saveRoomExport } = await import('./sdkExports.js')
1928
1953
  const epoch = privacyEpoch, it = held(room) && rooms.find((r) => r.room === room)
1929
- return await saveRoomExport(sp, it?.enc ? 'enclave' : 'standard', () => epoch === privacyEpoch && !!held(room), it?.title || '')
1954
+ const earlierKeys = Object.fromEntries(rooms.filter((r) => currentRoom(r) && r.room !== room).map((r) => [r.room, 'held'])) // the worker reads each with its own key
1955
+ return await saveRoomExport(sp, it?.enc ? 'enclave' : 'standard', () => epoch === privacyEpoch && !!held(room), it?.title || '', earlierKeys)
1930
1956
  }
1931
1957
  if (ns === 'privateRoom') {
1932
1958
  const target = rooms.find(r => currentRoom(r) && r.room === args[0])
@@ -2136,7 +2162,9 @@ export async function startVault(o = {}) {
2136
2162
  if (op === 'getConfig') r = configForPage(r)
2137
2163
  if ((op === 'poll' || op === 'pollSealed') && r?.streamGrants) { const { streamGrants: _grants, ...visible } = r; r = visible }
2138
2164
  const lanes = op === 'getConfig' ? r && r.lanes : op === 'setConfig' && r && r.status === 200 && args[0] ? args[0].lanes : undefined
2139
- if (op === 'setConfig' && lanes === false) await disconnectRoomLanes(sdk, room)
2165
+ if (lanes === false && (op === 'setConfig' || sdk._heldLaneRooms(room).length ||
2166
+ sdk.backup.rooms.some(r => r.kind === 'lane' && r.shared === room) ||
2167
+ sdk.account.links.some(l => l.a === room || l.b === room))) await disconnectRoomLanes(sdk, room)
2140
2168
  if (typeof lanes === 'boolean') {
2141
2169
  const it = rooms.find((x) => x.room === room)
2142
2170
  if (it && it.link) { const url = new URL(it.link); url.searchParams.delete('lanes'); const hash = new URLSearchParams(url.hash.slice(1)); if (lanes) hash.set('lanes', '1'); else hash.delete('lanes'); url.hash = hash.toString(); const link = url.href; if (link !== it.link) { it.link = link; await saveRooms(); emit({ ev: 'rooms', rooms: publicRooms() }) } }
@@ -2145,13 +2173,26 @@ export async function startVault(o = {}) {
2145
2173
  return r
2146
2174
  },
2147
2175
  async create(cfg, opts) { // opts { enclave, split }: the confidential tier, a split-key room; anything else is refused, never ignored
2148
- if (opts !== undefined && opts !== null && (typeof opts !== 'object' || Object.keys(opts).some((k) => k !== 'enclave' && k !== 'split'))) throw Object.assign(new Error('vault: create takes { enclave, split } and nothing else'), { code: 'invalid_argument' })
2176
+ if (opts !== undefined && opts !== null && (typeof opts !== 'object' || Object.keys(opts).some((k) => k !== 'enclave' && k !== 'split' && k !== 'creator'))) throw Object.assign(new Error('vault: create takes { enclave, split } and nothing else'), { code: 'invalid_argument' })
2177
+ if (opts?.creator !== undefined && (opts.creator?.accountEpoch !== creationAccount() || opts.creator?.email !== who())) throw Object.assign(new Error('The creating account changed'), { code: 'account_changed' })
2149
2178
  return makeRoom(cfg, null, { enclave: !!(opts && opts.enclave === true), split: !!(opts && opts.split === true) })
2150
2179
  },
2151
2180
  }
2181
+ // An opaque revision lets the page bind a create to the current vault account without receiving its backup key.
2182
+ const creatorScopes = new WeakMap(), withoutBackup = {}
2183
+ let creatorRevision = 0
2184
+ function creationAccount() {
2185
+ const record = sdk.backup._s || withoutBackup
2186
+ const scope = JSON.stringify([privacyEpoch, sdk._archiveGeneration, who(), sdk.backup._restoreEpoch || 0])
2187
+ const previous = creatorScopes.get(record)
2188
+ if (previous?.scope === scope) return previous.revision
2189
+ const revision = ++creatorRevision
2190
+ creatorScopes.set(record, { scope, revision })
2191
+ return revision
2192
+ }
2152
2193
  async function makeRoom(cfg, lane, { enclave = false, split = false } = {}) {
2153
- const epoch = privacyEpoch, owner = who()
2154
- const current = () => { if (privacyEpoch !== epoch || who() !== owner) throw Object.assign(new Error('the account changed during creation'), { code: 'account_changed' }) }
2194
+ const revision = creationAccount()
2195
+ const current = () => { if (creationAccount() !== revision) throw Object.assign(new Error('the account changed during creation'), { code: 'account_changed' }) }
2155
2196
  // SPLIT: the room's key is two halves — the link holds one, the builder's app-half function (/api/appshare on THIS
2156
2197
  // origin; spaces/templates/appshare) the other. A vault that serves none cannot make one (`appShare: true` says it does).
2157
2198
  if (split && !o.appShare) throw Object.assign(new Error('vault: this vault serves no app-half function — a split-key Space needs one at /api/appshare (startVault({ appShare: true }))'), { code: 'vault_unsupported' })
@@ -2163,9 +2204,19 @@ export async function startVault(o = {}) {
2163
2204
  creates.push(now)
2164
2205
  if (cfg.usernames !== undefined && (cfg.usernames !== false || cfg.admission !== 'email')) throw Object.assign(new Error('vault: only verified Spaces can hide usernames'), { code: 'invalid_argument' })
2165
2206
  if (cfg.direct !== undefined && (cfg.direct !== true || cfg.admission !== 'email')) throw Object.assign(new Error('vault: a direct chat is an email-gated Space'), { code: 'invalid_argument' })
2207
+ // OWNERS AND ADMINS AS THEY PREFER (docs/spaces-usernames.md § 13.1): the vault's signed-in member, and anyone made owner or admin, by
2208
+ // the room's tag for their @username when they prefer it (the SDK's own rule, _rolesAsPreferred) — chosen HERE, never by the page
2209
+ // …and the hidden addresses whose person prefers their @username go on the list as that name's tag (§ 13; the SDK's _addAsPreferred —
2210
+ // the page sent the emails as typed: sync sweep 11-29 #6)
2211
+ if (cfg.admission === 'email' && cfg.allow) {
2212
+ cfg = { ...cfg, allow: { ...cfg.allow } }
2213
+ if (cfg.direct !== true) { try { await sdk._addAsPreferred(cfg) } catch { /* a lookup that fails: the addresses stay as typed */ } }
2214
+ try { await sdk._rolesAsPreferred(cfg) } catch { /* a lookup that fails: the roles name the emails, as before */ }
2215
+ }
2166
2216
  // Attest FIRST — loud on a configuration failure (no published claim: never mint a confidential room that pins
2167
2217
  // nothing), soft on a cold enclave (woken below) — then mint, wake, and hand the enclave its own sealed config.
2168
2218
  if (enclave) { await sdk._encAttestSoft(); pushEnclave() }
2219
+ current()
2169
2220
  const r = await wcall({ t: 'create', cfg, base: location.origin, ...(enclave && !split ? { enclave: true } : {}), ...(split ? { split: true, ...(sdk.backup.enabled ? { returnMk: true } : {}) } : {}), ...(sdk.backup.enabled ? { delAsk: true } : {}) })
2170
2221
  current()
2171
2222
  const mark = (l, m) => l + (l.includes('#') ? '&' : '#') + m
@@ -2349,14 +2400,16 @@ export async function startVault(o = {}) {
2349
2400
  if (epoch !== privacyEpoch) throw Object.assign(new Error('The account changed'), { code: 'account_changed' })
2350
2401
  await wipeSignedOut(); emit({ ev: 'signedOut' }); return { signedIn: false } },
2351
2402
  async enclaveAvailable() { return sdk._encClaimDoc().then(() => true, () => false) },
2352
- async whoami() { return signedIn() ? { signedIn: true, email: sdk.session.email, keyId: sessionKeyId() } : { signedIn: false } },
2403
+ async whoami(options) { return { ...(signedIn() ? { signedIn: true, email: sdk.session.email, keyId: sessionKeyId() } : { signedIn: false }), ...(options?.forCreate === true ? { accountEpoch: creationAccount() } : {}) } },
2353
2404
  async forget(room) {
2354
2405
  if (pendingForget.has(room)) { await purgeForgotten(room); return { forgotten: true } }
2355
2406
  if (!held(room)) return { forgotten: false }
2356
2407
  // removing a Space's key from this device can lose it for good (no other copy): the PERSON confirms it (security review)
2357
2408
  const it = rooms.find((x) => x.room === room)
2358
- const accountWide = sdk.backup.enabled
2409
+ const accountWide = sdk.backup.enabled, epoch = privacyEpoch, owner = who(), account = sdk.backup._s
2359
2410
  if (!(await confirmWith({ title: 'Remove ' + (it && it.title ? '“' + it.title + '”' : 'this Space') + (accountWide ? ' from your account?' : ' from this device?'), text: accountWide ? 'This removes it from every device that syncs this account.' : 'Without its invite link you cannot open it here again.', ok: 'Remove', cancel: 'Keep' }).catch(() => false))) throw Object.assign(new Error('cancelled'), { code: 'cancelled' })
2411
+ // what the person confirmed was THIS account's room: a sign-in, a restore or a backup turned on meanwhile is another (sync sweep 11-27 P7)
2412
+ if (epoch !== privacyEpoch || owner !== who() || account !== sdk.backup._s || accountWide !== sdk.backup.enabled || !held(room)) throw Object.assign(new Error('the account changed during confirmation'), { code: 'account_changed' })
2360
2413
  if (accountWide && sdk.backup.enabled) { sdk.account.forget(room); await fromBackup() }
2361
2414
  await dropRoom(room) // and from the account, on every device
2362
2415
  return { forgotten: true }
package/vault-kit.mjs CHANGED
@@ -20,7 +20,7 @@ import { createHash } from 'node:crypto'
20
20
  import { join, dirname } from 'node:path'
21
21
 
22
22
  export const DEFAULTS = { endpoint: 'https://api.witbitz.chat/v1/space', loginBase: 'https://witbitz-spaces.pages.dev', from: 'https://witbitz.chat/sdk/latest/', enclaveClaim: 'https://witbitz-spaces.pages.dev/enclave-claim.json', accountService: 'https://api.witbitz.chat/v1' } // enclaveClaim: the confidential tier's published measurement (and its policy text, beside it)
23
- export const KIT_RELEASE = '4.6.0' // tools/sdk-release.mjs stamps the version here, so a downloaded copy builds from ITS release
23
+ export const KIT_RELEASE = '4.7.1' // tools/sdk-release.mjs stamps the version here, so a downloaded copy builds from ITS release
24
24
  export function stampSdkAuth(src) {
25
25
  return src.replaceAll('__' + 'SPACE_AUTH_BROKER' + '__', 'https://auth.witbitz.chat').replaceAll('__' + 'SPACE_AUTH_FORCE_BROKER' + '__', '0')
26
26
  }
package/witbitz-admin.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  // Witbitz admin client — one file for your SERVER (https://witbitz.chat/docs/sdk#builder-calls). Never ship it in a page.
2
2
 
3
- // spaces/public/sdk/4.6.0/connCatalog.js
3
+ // spaces/public/sdk/4.7.1/connCatalog.js
4
4
  var GCAL_PROVIDER = "prov_XE5FdiPdAx881HKs";
5
5
  var CATALOG = [
6
6
  // AN AGENT YOU SEND JOBS TO, not a service you sign in to (the owner, 2026-10-15: "Doesn't grokbot have a connector like
@@ -154,7 +154,7 @@ var CATALOG = [
154
154
  { name: "Gmail", kind: "mail", host: "mail.google.com", desc: "Forward the mail you choose into a Space of your own \u2014 the assistant reads it when you ask.", cat: "Email" }
155
155
  ];
156
156
 
157
- // spaces/public/sdk/4.6.0/cbor.js
157
+ // spaces/public/sdk/4.7.1/cbor.js
158
158
  var MAX_LEN = 1 << 22;
159
159
  function decode(bytes) {
160
160
  const b = toBytes(bytes);
@@ -348,7 +348,7 @@ function concat(...parts) {
348
348
  return out;
349
349
  }
350
350
 
351
- // spaces/public/sdk/4.6.0/x509.js
351
+ // spaces/public/sdk/4.7.1/x509.js
352
352
  var TAG = { INT: 2, BITSTRING: 3, OID: 6, SEQ: 48, UTCTIME: 23, GENTIME: 24 };
353
353
  var SIG_OIDS = /* @__PURE__ */ new Map([
354
354
  ["1.2.840.10045.4.3.2", { hash: "SHA-256" }],
@@ -522,7 +522,7 @@ async function verifyChain(chainDer, { now = Date.now() } = {}) {
522
522
  return certs[certs.length - 1];
523
523
  }
524
524
 
525
- // spaces/public/sdk/4.6.0/nitroVerify.js
525
+ // spaces/public/sdk/4.7.1/nitroVerify.js
526
526
  var NITRO_ROOT_G1_B64 = "MIICETCCAZagAwIBAgIRAPkxdWgbkK/hHUbMtOTn+FYwCgYIKoZIzj0EAwMwSTELMAkGA1UEBhMCVVMxDzANBgNVBAoMBkFtYXpvbjEMMAoGA1UECwwDQVdTMRswGQYDVQQDDBJhd3Mubml0cm8tZW5jbGF2ZXMwHhcNMTkxMDI4MTMyODA1WhcNNDkxMDI4MTQyODA1WjBJMQswCQYDVQQGEwJVUzEPMA0GA1UECgwGQW1hem9uMQwwCgYDVQQLDANBV1MxGzAZBgNVBAMMEmF3cy5uaXRyby1lbmNsYXZlczB2MBAGByqGSM49AgEGBSuBBAAiA2IABPwCVOumCMHzaHDimtqQvkY4MpJzbolL//Zy2YlES1BR5TSksfbb48C8WBoyt7F2Bw7eEtaaP+ohG2bnUs990d0JX28TcPQXCEPZ3BABIeTPYwEoCWZEh8l5YoQwTcU/9KNCMEAwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUkCW1DdkFR+eWw5b6cp3PmanfS5YwDgYDVR0PAQH/BAQDAgGGMAoGCCqGSM49BAMDA2kAMGYCMQCjfy+Rocm9Xue4YnwWmNJVA44fA0P5W2OpYow9OYCVRaEevL8uO1XYru5xtMPWrfMCMQCi85sWBbJwKKXdS6BptQFuZbT73o/gBh1qUxl/nNr12UO8Yfwr6wPLb+6NIwLz3/Y=";
527
527
  var COSE_ALG_ES384 = -35;
528
528
  var MAX_DOC = 1 << 20;
@@ -646,7 +646,7 @@ async function verifyAttestation(cose, { root, now = Date.now(), maxAgeMs = 0, e
646
646
  return { ok: true, ...doc, leaf };
647
647
  }
648
648
 
649
- // spaces/public/sdk/4.6.0/sentinelRelease.js
649
+ // spaces/public/sdk/4.7.1/sentinelRelease.js
650
650
  var BUILD_ENCLAVE_PCR0 = Object.freeze([
651
651
  "c6a8cbd0c05d8e003e75b266f1dde2a6426b7cd61f845e4b128e59063e40968b44f30d934bbe1925582fe33bbdd0b1d7",
652
652
  "f490096d57e4287146e8b8d7bf4c75f423984ca52199efab0ee8684fbee6cfe6ab82c72d54f05a38f24a0d4ad6e2f557",
@@ -794,7 +794,7 @@ async function recordPcrBy(r, subject, builders, verify = verifyAttestation) {
794
794
  return { pcr0, builder };
795
795
  }
796
796
 
797
- // spaces/public/sdk/4.6.0/sealShare.js
797
+ // spaces/public/sdk/4.7.1/sealShare.js
798
798
  var enc2 = new TextEncoder();
799
799
  var b64 = (u8) => btoa(String.fromCharCode(...new Uint8Array(u8)));
800
800
  async function sealTo(enclaveKey, nonce, bundle) {
@@ -808,13 +808,13 @@ async function sealTo(enclaveKey, nonce, bundle) {
808
808
  return { epk: b64(epk), iv: b64(iv), ct: b64(ct), nonce: b64(nonce) };
809
809
  }
810
810
 
811
- // spaces/public/sdk/4.6.0/connDisp.js
811
+ // spaces/public/sdk/4.7.1/connDisp.js
812
812
  var enc3 = new TextEncoder();
813
813
  var dec = new TextDecoder();
814
814
  var SALT = enc3.encode("witbitz-sentinel-display-v1");
815
815
  var INFO = enc3.encode("sentinel-display");
816
816
 
817
- // spaces/public/sdk/4.6.0/connections.js
817
+ // spaces/public/sdk/4.7.1/connections.js
818
818
  var STANDING_SENTINEL_PCR0 = ["0e424db41977965bc6edf225229eae70fe162dd8264b1ac0b5670cb3f71bf8b923001341e85a665354b25cd8418ac6d3"];
819
819
  var b642 = (u8) => btoa(String.fromCharCode(...new Uint8Array(u8)));
820
820
  var unb642 = (s) => Uint8Array.from(atob(s), (c) => c.charCodeAt(0));
@@ -928,7 +928,7 @@ async function attestStandingSentinel({ post, auth = {}, pins = STANDING_SENTINE
928
928
  }
929
929
  var MCP_CURATED = CATALOG.filter((c) => c.url).map((c) => ({ label: c.name, url: c.url }));
930
930
 
931
- // spaces/public/sdk/4.6.0/sdkRedact.js
931
+ // spaces/public/sdk/4.7.1/sdkRedact.js
932
932
  var REDACTED = "[REDACTED]";
933
933
  var INSPECT = /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom");
934
934
  function hide(obj, names) {
@@ -953,7 +953,7 @@ function redacted(proto, summary) {
953
953
  });
954
954
  }
955
955
 
956
- // spaces/public/sdk/4.6.0/witbitz-admin.js
956
+ // spaces/public/sdk/4.7.1/witbitz-admin.js
957
957
  var adminError = (code, message) => Object.assign(new Error(message), { code: String(code || "refused") });
958
958
  var DEFAULT_ENDPOINT = "https://api.witbitz.chat/v1/space";
959
959
  var ownerRetired = () => adminError("owner_rule_retired", "witbitz: the owner rule (rooms only your app may use) is retired \u2014 a web page cannot prove which app it is (sdk-changes.md, 4.0.0)");
package/witbitz-sdk.d.ts CHANGED
@@ -137,9 +137,14 @@ export interface Admission {
137
137
  domains?: string[]
138
138
  /** true: every address is readable to members; an array: just those (each must be in `emails`). Else room-salted hashes. */
139
139
  advertise?: boolean | string[]
140
- /** Admins and owners, by email; each must also be admitted by the gate. */
140
+ /** Admins and owners, by email; each must also be admitted by the gate. One who prefers their @username ("Add me to Spaces as
141
+ * @username") is named in the role by the room's tag for it instead of the email, once the service takes such roles. */
141
142
  admins?: string[]
142
143
  owners?: string[]
144
+ /** changeMembers only: the roles held by @username tag, stated in full (as `admission()` reports them). Unstated: kept, less a holder
145
+ * whose email the guest book knows and `owners`/`admins` leave out. */
146
+ ownerTags?: string[]
147
+ adminTags?: string[]
143
148
  }
144
149
  /** What `space.admission()` reads back from the room's sealed config. */
145
150
  export interface AdmissionInfo {
@@ -152,6 +157,12 @@ export interface AdmissionInfo {
152
157
  unopenedPrivateInvites?: number
153
158
  admins?: string[]
154
159
  owners?: string[]
160
+ /** Owners and admins named by their @username's tag (not their email) — present only when some are. `ownerUsers`/`adminUsers`: the
161
+ * @usernames matched to those tags (a holder not matched yet is counted in the tags only). */
162
+ ownerTags?: string[]
163
+ adminTags?: string[]
164
+ ownerUsers?: string[]
165
+ adminUsers?: string[]
155
166
  /** This room is a member's private lane (not a Space). */
156
167
  lane?: true
157
168
  /** This Space gives every member a private lane (`createSpace({ lanes: true })`, the app's option). */
@@ -411,6 +422,7 @@ export declare class Space {
411
422
  }>
412
423
  admission(): Promise<AdmissionInfo>
413
424
  admits(email: string): Promise<boolean>
425
+ /** `email` or `'@username'` — an owner or admin named by their @username's tag is found by the name. */
414
426
  isAdmin(email: string): Promise<boolean>
415
427
  isOwner(email: string): Promise<boolean>
416
428
  /** Import a public ChatGPT, Claude, Gemini or Grok share URL. The server validates the source. */
@@ -454,8 +466,10 @@ export declare class Space {
454
466
  static readonly REPORT_REASONS: readonly ReportReason[]
455
467
  /** Does this Space take only a page proved to be one named app (an attested app)? From its public policy; a failed read throws `policy_unreadable`. In a vault: `vault_unsupported`. */
456
468
  attested(): Promise<{ required: boolean; confidential: boolean }>
457
- /** `attachmentsMissing`: attachments whose bytes could not be read — the file holds only a pointer to this room for them; export again to include them. */
458
- exportFile(): Promise<{ count: number; attachmentsMissing?: number }>
469
+ /** `attachmentsMissing`: attachments whose bytes could not be read — the file holds only a pointer to this room for them; export again to include them.
470
+ * A linked continuation (a Space that replaced an earlier version of itself): `earlierCount` — its earlier versions' messages, included in the
471
+ * file's `earlier`; or `historyIncomplete` — a sentence saying why they are not in it (no key for them on this client, or they could not be read). */
472
+ exportFile(): Promise<{ count: number; attachmentsMissing?: number; earlierCount?: number; historyIncomplete?: string }>
459
473
  sealedProof(): Promise<Record<string, unknown> | null>
460
474
  /** Confidential rooms: verify every reply's turn certificate on this device. */
461
475
  certificates(): Promise<{ verified: number; failed: Array<{ id: string; reason: string }>; unchecked: number; before: number; /** a private lane's copies of its Space's replies: not signed by the lane's enclave, so counted here and never in `failed` */ copies: number; builds: Array<{ pcr16: string; pcr17: string; audit: string; replies: number; /** the build enclave's release: rebuilt from `commit`, entry `logIndex` in Rekor (`rekor` links it); null = not in the published log; absent = the log could not be read */ source?: { commit: string; logIndex: number; rekor: string } | null }>; calls: Record<string, number>; tools: Record<string, number> }>
@@ -592,7 +606,7 @@ export declare class VaultSession {
592
606
  /** The vault's origin. */
593
607
  readonly origin: string
594
608
  /** Connection details and the latest room, sign-in and account state reported by the vault. */
595
- readonly info: { v: number; tenant: string; endpoint: string; signedIn: boolean; email: string; /** the vault session key's PUBLIC id (what `space.isMine` compares) — '' when signed out; an older vault sends none */ keyId?: string; rooms: VaultRoom[]; /** the Siri Shortcut: never its key */ siri: { key: null; hasKey: boolean; endpoint: string }; /** the backup and account, as `wb.backup` / `wb.account` read them */ account: { enabled: boolean; format: string | null; /** 'account' (the Witbitz account service) | 'legacy' | null */ service: 'account' | 'legacy' | null; /** a restore and deleting the account need the emailed code as well */ gated: boolean; deviceId: string; rooms: Array<{ room: string; kind: string; label?: string; /** a lane's Space: its room id */ shared?: string; archived?: boolean; pinned?: boolean; /** when the room was last opened or recorded on any of the account's devices — at most an hour behind */ lastOpenedAt?: number }>; devices: unknown[]; links: unknown[]; lastError: { message: string; code?: string; status?: number } | string | null; erasure: boolean }; /** only a vault started with `lock: true` says it: the lock (a passkey at every launch) and storage protection, as the person set them */ lock?: VaultLock; /** only a vault started with `push: true` says it: notifications on this device */ push?: VaultPush; /** the Space whose notification the person tapped to open the vault */ notifOpen?: string }
609
+ readonly info: { v: number; tenant: string; endpoint: string; signedIn: boolean; email: string; /** the vault session key's PUBLIC id (what `space.isMine` compares) — '' when signed out; an older vault sends none */ keyId?: string; rooms: VaultRoom[]; /** the Siri Shortcut: never its key */ siri: { key: null; hasKey: boolean; endpoint: string }; /** the backup and account, as `wb.backup` / `wb.account` read them */ account: { enabled: boolean; format: string | null; /** 'account' (the Witbitz account service) | 'legacy' | null */ service: 'account' | 'legacy' | null; /** a restore and deleting the account need the emailed code as well */ gated: boolean; deviceId: string; rooms: Array<{ room: string; kind: string; label?: string; /** a lane's Space: its room id */ shared?: string; /** 'minted': the lane was made for its Space (it goes when that Space is deleted) */ laneOrigin?: 'minted'; /** the Space this room was first made as a lane of */ mintedFor?: string; archived?: boolean; pinned?: boolean; /** when the room was last opened or recorded on any of the account's devices — at most an hour behind */ lastOpenedAt?: number }>; devices: unknown[]; links: unknown[]; lastError: { message: string; code?: string; status?: number } | string | null; erasure: boolean }; /** only a vault started with `lock: true` says it: the lock (a passkey at every launch) and storage protection, as the person set them */ lock?: VaultLock; /** only a vault started with `push: true` says it: notifications on this device */ push?: VaultPush; /** the Space whose notification the person tapped to open the vault */ notifOpen?: string }
596
610
  /** The Spaces this vault holds, newest first. */
597
611
  rooms(): Promise<VaultRoom[]>
598
612
  /** A live Space for a room the vault holds; its key stays in the vault (`space.key` and `space.shareLink` are null). A private
@@ -735,7 +749,7 @@ export interface AccountBackup {
735
749
  /** Where the account is kept: 'account' (the Witbitz account service — a new account in a vault that names its tenant),
736
750
  * 'legacy' (the backup store every account used before), null when there is none on this client. */
737
751
  readonly service: 'account' | 'legacy' | null
738
- readonly rooms: Array<{ room: string; link: string; kind: 'space' | 'lane'; label?: string; shared?: string; laneOrigin?: 'minted'; mintedFor?: string; archived?: boolean; pinned?: boolean; /** read-only: when the room was last opened or recorded on any of the account's devices (ms since 1970) — at most an hour behind; sort by it, newest first, for the app's order (sdk-accounts.md#account-index) */ lastOpenedAt?: number }>
752
+ readonly rooms: Array<{ room: string; link: string; kind: 'space' | 'lane'; label?: string; shared?: string; laneOrigin?: 'minted'; mintedFor?: string; archived?: boolean; pinned?: boolean; /** read-only: when the room was last opened or recorded on any of the account's devices (ms since 1970) — at most an hour behind; sorting by it orders by the last OPEN — the Spaces app also counts new messages its device saw, which the account does not hold (sdk-accounts.md#account-index) */ lastOpenedAt?: number }>
739
753
  onState: ((state: unknown) => void) | null
740
754
  enable(opts?: { email?: string }): Promise<{ code: string }>
741
755
  restore(opts: { code: string; email?: string; ticket?: string; emailCode?: string }): Promise<{ rooms: AccountBackup['rooms'] }>
@@ -896,7 +910,7 @@ export interface InviteAccount {
896
910
  * this device's invite key. The inbox keeps them all: every call returns every one. Open one with `openSpace(link)`. In vault
897
911
  * mode the vault opens them, asks the person before joining a Space it does not hold, and returns only the rooms it holds, each
898
912
  * with `link: ''` — open one with `wb.vault.openRoom(room)` (an older vault kit: `vault_unsupported`). Throws
899
- * `no_invite_key`, `unreachable`. Anyone who finds the inbox can drop an invitation: `link` is
913
+ * `no_invite_key`, `unreachable`, `account_changed` (another account signed in during the read). Anyone who finds the inbox can drop an invitation: `link` is
900
914
  * always an https address of `room` carrying its key (others are skipped), but `title` and `from` are the sender's own words —
901
915
  * show them as text, never as markup. */
902
916
  collect(): Promise<Array<{ room: string; link: string; title: string; from: string; at: number }>>