@witbitz/sdk 4.5.0 → 4.7.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/README.md +2 -2
- package/a2aCore.js +32 -0
- package/acctV2Switch.js +3 -2
- package/acctV2UiCore.js +2 -2
- package/addPreferred.js +62 -0
- package/cloudDevicePins.js +1 -1
- package/codeBrowse.js +17 -7
- package/codeCache.js +4 -3
- package/codeCloud.js +4 -0
- package/connections.js +1 -1
- package/earlierHistory.js +32 -0
- package/emailFork.js +3 -1
- package/emptySpaces.js +2 -0
- package/l1-worker-src.js +1 -1
- package/manifest.json +33 -30
- package/memberChange.js +16 -4
- package/ownAgentLink.js +4 -1
- package/package.json +5 -2
- package/roomRoles.js +116 -0
- package/roomRoster.js +15 -6
- package/sdkA2A.js +58 -13
- package/sdkBackup.js +1 -0
- package/sdkBackupV2.js +25 -6
- package/sdkBrowserPrivate.js +5 -0
- package/sdkComputers.js +1 -0
- package/sdkExports.js +11 -3
- package/sdkRekey.js +87 -12
- package/spaceClient.js +7 -3
- package/vault-core.js +58 -29
- package/vault-kit.mjs +1 -1
- package/witbitz-admin.mjs +11 -11
- package/witbitz-sdk.d.ts +32 -8
- package/witbitz-sdk.js +139 -20
package/vault-core.js
CHANGED
|
@@ -65,7 +65,7 @@ const KEYS = { rooms: 'wbvault:rooms', session: 'wbvault:session', siri: 'wbvaul
|
|
|
65
65
|
export const ACCOUNT_CALLS = {
|
|
66
66
|
cloudDevice: { status: {}, enroll: { confirm: true }, register: { confirm: true }, setBuilds: { confirm: true }, forget: { confirm: true } },
|
|
67
67
|
connections: { catalog: {}, spacesUsing: {}, attach: {}, list: {}, detach: { confirm: true }, startConnect: {}, finishConnect: {}, startMcp: {}, attachMcp: {}, finishMcp: {}, mcpTools: {} }, // MCP servers (2026-10-23): the callKey stays here, as attach's
|
|
68
|
-
usernames: { claim: { confirm: true }, release: { confirm: true }, mine: {}, resolve: {} },
|
|
68
|
+
usernames: { claim: { confirm: true }, release: { confirm: true }, mine: {}, resolve: {}, addAsUsername: { confirm: true } }, // addAsUsername: "Add me to Spaces as @username" (docs/spaces-usernames.md § 13)
|
|
69
69
|
siri: { status: {}, sync: {}, rotateKey: { confirm: true }, revoke: { confirm: true }, shortcut: {}, showKey: {} },
|
|
70
70
|
a2a: { status: {}, revoke: { confirm: true }, stopJobAgent: { confirm: true } },
|
|
71
71
|
// the account BACKUP and the account INDEX across devices: the vault's own, over the Spaces it holds. The recovery code
|
|
@@ -778,17 +778,20 @@ export async function startVault(o = {}) {
|
|
|
778
778
|
const get = () => read(st, key, {}) || {}
|
|
779
779
|
const unchanged = () => who() === owner && privacyEpoch === epoch && JSON.stringify(get()[pending]) === JSON.stringify(entry)
|
|
780
780
|
if (!unchanged()) return
|
|
781
|
+
// ★ 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:
|
|
782
|
+
// 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)
|
|
783
|
+
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
784
|
for (let attempt = 0; attempt < 3 && unchanged(); attempt++) {
|
|
782
785
|
const current = get()[owner] || null
|
|
783
786
|
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
|
|
787
|
+
const kept = get(); delete kept[pending]; put(key, kept); await converge(); return
|
|
785
788
|
}
|
|
786
789
|
const next = applyEdit(entry.next ? entry.base : committed, entry.next || entry, current)
|
|
787
790
|
if (!next) return
|
|
788
791
|
try {
|
|
789
792
|
await api._push(next)
|
|
790
793
|
} catch (error) {
|
|
791
|
-
if (unchanged() && error.definiteRefusal) { const kept = get(); delete kept[pending]; put(key, kept) }
|
|
794
|
+
if (unchanged() && error.definiteRefusal) { const kept = get(); delete kept[pending]; put(key, kept); await converge() }
|
|
792
795
|
return
|
|
793
796
|
}
|
|
794
797
|
if (!unchanged()) return
|
|
@@ -805,6 +808,9 @@ export async function startVault(o = {}) {
|
|
|
805
808
|
}
|
|
806
809
|
const saveSiri = () => { const w = who(); if (!w) return; const all = read(st, KEYS.siri, {}); all[w] = sdk.siri.state; put(KEYS.siri, all); keepSoon() }
|
|
807
810
|
const saveA2A = () => { const w = who(); if (!w) return; const all = read(st, KEYS.a2a, {}); all[w] = sdk.a2a.state; put(KEYS.a2a, all); keepSoon() }
|
|
811
|
+
// 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):
|
|
812
|
+
// 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)
|
|
813
|
+
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)
|
|
808
814
|
// ── THE SAME THREE ON EVERY DEVICE OF THE ACCOUNT (vaultKeep.js; sync sweep 2026-11-11 P7): a second device listed this account's
|
|
809
815
|
// connections but could not use one (`not_in_vault`), and could not open Siri or an outside agent's message. Synced, sealed,
|
|
810
816
|
// 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
|
|
@@ -935,7 +941,9 @@ export async function startVault(o = {}) {
|
|
|
935
941
|
} else if (m === 'ack') { const a = args[0] || {}; result = await sdk.a2a._plain('a2aack', { items: [{ taskId: String(a.taskId || ''), n: Number(a.n) || 0 }] }) }
|
|
936
942
|
else if (m === 'reply') {
|
|
937
943
|
const id = args[2]?.autoPeerId
|
|
938
|
-
|
|
944
|
+
// an AUTO reply goes only while its home still is a lane or a solo verified Space (sync sweep 2026-11-25 investigation 4): a draft matched
|
|
945
|
+
// after a second member came — possibly an answer to them — is held for the member's review (the page re-offers it as 'ask')
|
|
946
|
+
result = id && (!shim.peers.some(p => p.id === id && p.reply === 'auto') || !(await shim._homeOk())) ? { held: true } : await shim.reply(args[0], args[1], args[2] || {})
|
|
939
947
|
}
|
|
940
948
|
else result = await shim[m](...args)
|
|
941
949
|
// THE TOKEN STAYS IN THE VAULT (sync sweep 2026-11-14 #3): it is the outside agent's bearer for as long as it lives, so it is shown
|
|
@@ -1168,6 +1176,7 @@ export async function startVault(o = {}) {
|
|
|
1168
1176
|
'connections.detach': { title: 'Remove this connection?', text: 'Every Space that uses it stops being able to.', ok: 'Remove' },
|
|
1169
1177
|
'usernames.claim': { title: 'Take the username @' + String(a || '').replace(/^@/, '').slice(0, 40) + '?', text: (args[1] && args[1].publish) ? 'It will be listed, so people can find you by it.' : 'It is yours until you release it.', ok: 'Take it' },
|
|
1170
1178
|
'usernames.release': { title: 'Release your username?', text: 'Someone else may take it.', ok: 'Release' },
|
|
1179
|
+
'usernames.addAsUsername': a === false ? { title: 'Be added to Spaces by your email?', text: 'People who add you by email will add you by your email, and the other members will see it.', ok: 'Use my email' } : { title: 'Be added to Spaces as your @username?', text: 'People who add you by email add you by your @username instead, and the other members see the @username, not your email.', ok: 'Use my @username' },
|
|
1171
1180
|
'siri.rotateKey': { title: 'Make a new Siri key?', text: 'The Shortcut stops working until you give it the new key.', ok: 'New key' },
|
|
1172
1181
|
'siri.revoke': { title: 'Turn the Siri inbox off?', text: 'Siri stops delivering to every Space.', ok: 'Turn off' },
|
|
1173
1182
|
'a2a.addPeer': { title: (args[1]?.reconnect || args[1]?.previousPeerId) ? 'Move this outside agent here and replace its previous pairing?' : 'Let the outside agent “' + String(a || '').slice(0, 40) + '” reach this lane?', text: (args[1] && args[1].job === true) ? 'An agent that takes jobs: it reports here and reads no answer — its reports are told to you.' : (kept || args[1]?.reply === 'auto') ? 'Its messages will be answered by the assistant on its own, without asking you.' : 'You approve every answer before it is sent.', ok: 'Allow' }, // a job agent reads no answers (sweep 10-25 #9)
|
|
@@ -1223,7 +1232,7 @@ export async function startVault(o = {}) {
|
|
|
1223
1232
|
const syncError = a.lastError || (lastKeepFailure?.owner === who() && lastKeepFailure?.master === b._s?.master ? lastKeepFailure?.error : null)
|
|
1224
1233
|
return {
|
|
1225
1234
|
enabled: b.enabled, format: b.format, service: b.service, deviceId: a.deviceId, // service: 'account' (the Witbitz account service) | 'legacy' | null
|
|
1226
|
-
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)
|
|
1235
|
+
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)
|
|
1227
1236
|
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,
|
|
1228
1237
|
erasure: sdk.erasure.available,
|
|
1229
1238
|
gated: !!b.gated, // a restore and deleting the account need the emailed code as well (sync sweep 11-09 #24)
|
|
@@ -1440,7 +1449,12 @@ export async function startVault(o = {}) {
|
|
|
1440
1449
|
if (forgetMark(room) !== mark) throw new Error('vault could not save the room removal')
|
|
1441
1450
|
pendingForget.add(room)
|
|
1442
1451
|
write(st, KEYS.pendingForget, [...pendingForget])
|
|
1443
|
-
rooms
|
|
1452
|
+
// its private lanes stay as rooms of their own — never lanes of a Space this device no longer holds (as backup.remove, sdkBackup.js)
|
|
1453
|
+
rooms = rooms.filter(r => r.room !== room).map(r => {
|
|
1454
|
+
if (r.lane !== room) return r
|
|
1455
|
+
const { lane, laneOrigin, ...rest } = r
|
|
1456
|
+
return { ...rest, ...(laneOrigin === 'minted' && !r.mintedFor ? { mintedFor: lane } : {}), detachedLane: true, associationAt: Math.max(Date.now(), Number(r.associationAt) || 0) }
|
|
1457
|
+
})
|
|
1444
1458
|
emit({ ev: 'rooms', rooms: publicRooms() })
|
|
1445
1459
|
streamGrants.delete(room)
|
|
1446
1460
|
if (streaming.delete(room)) syncStream(worker, room, null)
|
|
@@ -1758,26 +1772,29 @@ export async function startVault(o = {}) {
|
|
|
1758
1772
|
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' })
|
|
1759
1773
|
if (!watchedSections.has(name)) { watchedSections.add(name); sec.on('change', (value) => emit({ ev: 'accountSection', section: name, value })) } // another device's change reaches the page
|
|
1760
1774
|
let result
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
if (
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1775
|
+
// 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
|
|
1776
|
+
// (sync sweep 11-27 P7) — never another account's
|
|
1777
|
+
const shown0 = sdk.backup._s, shownEpoch = privacyEpoch
|
|
1778
|
+
try {
|
|
1779
|
+
if (name === 'chatLocks' && op === 'deleteAll') {
|
|
1780
|
+
const owner = sdk.backup._s, epoch = privacyEpoch, { targets: locks, privateAssistants: assistants } = await sec.previewDeleteAll()
|
|
1781
|
+
if (!locks.length) return []
|
|
1782
|
+
const lockedRooms = new Set(locks.filter(l => l.kind === 'room').map(l => l.target))
|
|
1783
|
+
const extra = assistants.length ? ' Their private assistants will also be removed: ' + assistants.map(r => r.title || r.room).join(', ') + '.' : ''
|
|
1784
|
+
const roomCount = lockedRooms.size
|
|
1785
|
+
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' })
|
|
1786
|
+
if (!confirmed) throw Object.assign(new Error('Cancelled'), { code: 'cancelled' })
|
|
1787
|
+
if (epoch !== privacyEpoch || owner !== sdk.backup._s) throw Object.assign(new Error('The account changed.'), { code: 'account_changed' })
|
|
1788
|
+
result = await sec._deleteTargets(locks, owner, async (kind, room) => {
|
|
1789
|
+
if (epoch !== privacyEpoch) throw new Error('Account changed')
|
|
1790
|
+
if (kind === 'room' && held(room)) await dropRoom(room)
|
|
1791
|
+
}, assistants.map(r => r.room))
|
|
1792
|
+
if (epoch === privacyEpoch && owner === sdk.backup._s) await fromBackup()
|
|
1793
|
+
} else {
|
|
1794
|
+
result = await sec[op](...rest.slice(0, 1))
|
|
1777
1795
|
}
|
|
1778
|
-
}
|
|
1779
|
-
|
|
1780
|
-
if (name === 'chatLocks' && (op === 'match' || op === 'check')) emit({ ev: 'accountSection', section: name, value: sec.value })
|
|
1796
|
+
} finally {
|
|
1797
|
+
if (name === 'chatLocks' && shownEpoch === privacyEpoch && shown0 === sdk.backup._s) emit({ ev: 'accountSection', section: name, value: sec.value })
|
|
1781
1798
|
}
|
|
1782
1799
|
if (name === 'blocks' || name === 'chatLocks') {
|
|
1783
1800
|
// A refresh already in flight may have read the list before this change.
|
|
@@ -1819,9 +1836,9 @@ export async function startVault(o = {}) {
|
|
|
1819
1836
|
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' })
|
|
1820
1837
|
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' })
|
|
1821
1838
|
if (spec.confirm) {
|
|
1822
|
-
const epoch = privacyEpoch, owner = who()
|
|
1839
|
+
const epoch = privacyEpoch, owner = who(), account = sdk.backup._s
|
|
1823
1840
|
await confirmCall(ns, m, args)
|
|
1824
|
-
if (epoch !== privacyEpoch || owner !== who()) throw Object.assign(new Error('the account changed during confirmation'), { code: 'account_changed' })
|
|
1841
|
+
if (epoch !== privacyEpoch || owner !== who() || account !== sdk.backup._s) throw Object.assign(new Error('the account changed during confirmation'), { code: 'account_changed' })
|
|
1825
1842
|
}
|
|
1826
1843
|
if (ns === 'cloudDevice' && (m === 'enroll' || m === 'register')) return sdk.cloudDevice[m]({ getCode: await emailCodeAsker('cloud-device', accountAddress) })
|
|
1827
1844
|
if (ns === 'backup') return backupCall(m, args)
|
|
@@ -1920,7 +1937,8 @@ export async function startVault(o = {}) {
|
|
|
1920
1937
|
if (ns === 'portable') {
|
|
1921
1938
|
const { saveRoomExport } = await import('./sdkExports.js')
|
|
1922
1939
|
const epoch = privacyEpoch, it = held(room) && rooms.find((r) => r.room === room)
|
|
1923
|
-
|
|
1940
|
+
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
|
|
1941
|
+
return await saveRoomExport(sp, it?.enc ? 'enclave' : 'standard', () => epoch === privacyEpoch && !!held(room), it?.title || '', earlierKeys)
|
|
1924
1942
|
}
|
|
1925
1943
|
if (ns === 'privateRoom') {
|
|
1926
1944
|
const target = rooms.find(r => currentRoom(r) && r.room === args[0])
|
|
@@ -2157,6 +2175,15 @@ export async function startVault(o = {}) {
|
|
|
2157
2175
|
creates.push(now)
|
|
2158
2176
|
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' })
|
|
2159
2177
|
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' })
|
|
2178
|
+
// 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
|
|
2179
|
+
// the room's tag for their @username when they prefer it (the SDK's own rule, _rolesAsPreferred) — chosen HERE, never by the page
|
|
2180
|
+
// …and the hidden addresses whose person prefers their @username go on the list as that name's tag (§ 13; the SDK's _addAsPreferred —
|
|
2181
|
+
// the page sent the emails as typed: sync sweep 11-29 #6)
|
|
2182
|
+
if (cfg.admission === 'email' && cfg.allow) {
|
|
2183
|
+
cfg = { ...cfg, allow: { ...cfg.allow } }
|
|
2184
|
+
if (cfg.direct !== true) { try { await sdk._addAsPreferred(cfg) } catch { /* a lookup that fails: the addresses stay as typed */ } }
|
|
2185
|
+
try { await sdk._rolesAsPreferred(cfg) } catch { /* a lookup that fails: the roles name the emails, as before */ }
|
|
2186
|
+
}
|
|
2160
2187
|
// Attest FIRST — loud on a configuration failure (no published claim: never mint a confidential room that pins
|
|
2161
2188
|
// nothing), soft on a cold enclave (woken below) — then mint, wake, and hand the enclave its own sealed config.
|
|
2162
2189
|
if (enclave) { await sdk._encAttestSoft(); pushEnclave() }
|
|
@@ -2349,8 +2376,10 @@ export async function startVault(o = {}) {
|
|
|
2349
2376
|
if (!held(room)) return { forgotten: false }
|
|
2350
2377
|
// removing a Space's key from this device can lose it for good (no other copy): the PERSON confirms it (security review)
|
|
2351
2378
|
const it = rooms.find((x) => x.room === room)
|
|
2352
|
-
const accountWide = sdk.backup.enabled
|
|
2379
|
+
const accountWide = sdk.backup.enabled, epoch = privacyEpoch, owner = who(), account = sdk.backup._s
|
|
2353
2380
|
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' })
|
|
2381
|
+
// 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)
|
|
2382
|
+
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' })
|
|
2354
2383
|
if (accountWide && sdk.backup.enabled) { sdk.account.forget(room); await fromBackup() }
|
|
2355
2384
|
await dropRoom(room) // and from the account, on every device
|
|
2356
2385
|
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.
|
|
23
|
+
export const KIT_RELEASE = '4.7.0' // 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.
|
|
3
|
+
// spaces/public/sdk/4.7.0/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.
|
|
157
|
+
// spaces/public/sdk/4.7.0/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.
|
|
351
|
+
// spaces/public/sdk/4.7.0/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.
|
|
525
|
+
// spaces/public/sdk/4.7.0/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.
|
|
649
|
+
// spaces/public/sdk/4.7.0/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.
|
|
797
|
+
// spaces/public/sdk/4.7.0/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,14 +808,14 @@ 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.
|
|
811
|
+
// spaces/public/sdk/4.7.0/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.
|
|
818
|
-
var STANDING_SENTINEL_PCR0 = ["
|
|
817
|
+
// spaces/public/sdk/4.7.0/connections.js
|
|
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));
|
|
821
821
|
var ConnectionError = class extends Error {
|
|
@@ -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.
|
|
931
|
+
// spaces/public/sdk/4.7.0/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.
|
|
956
|
+
// spaces/public/sdk/4.7.0/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
|
-
|
|
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;
|
|
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
|
|
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 }>>
|
|
@@ -908,6 +922,9 @@ export interface A2AAccount {
|
|
|
908
922
|
readonly state: unknown
|
|
909
923
|
readonly endpoint: string
|
|
910
924
|
onState: ((state: unknown) => void) | null
|
|
925
|
+
/** Lanes given a NEW address because the old one was another account's (the Sentinel's `handle_taken` — a state restored from
|
|
926
|
+
* the person's other Witbitz app). Saved in `state` before the grant is sent again; agents set up with the old address need the new one. */
|
|
927
|
+
onReaddressed: ((lanes: Array<{ room: string; cardUrl: string; mcpUrl: string }>) => void) | null
|
|
911
928
|
restore(state: unknown): this
|
|
912
929
|
status(): Promise<unknown>
|
|
913
930
|
revoke(): Promise<unknown>
|
|
@@ -1096,8 +1113,15 @@ export interface Usernames {
|
|
|
1096
1113
|
/** → `{ username }`; whether it is listed in the directory: `mine()`. */
|
|
1097
1114
|
claim(name: string, opts?: { publish?: boolean; name?: string }): Promise<{ username: string }>
|
|
1098
1115
|
release(): Promise<unknown>
|
|
1099
|
-
|
|
1100
|
-
|
|
1116
|
+
/** `addAsUsername`: "Add me to Spaces as @username" — on unless the member switched it off (sdk-people.md#added-as-username). */
|
|
1117
|
+
mine(): Promise<{ username: string | null; published?: boolean; addAsUsername: boolean }>
|
|
1118
|
+
/** "Add me to Spaces as @username" (sdk-people.md#added-as-username): how the signed-in member is added and shown — `true` (the
|
|
1119
|
+
* default once they have a username): someone who adds them by email adds them as their @username (only where "find me by email" is
|
|
1120
|
+
* on), and the other members see the @username, not the email; `false`: they are added by email. Published with the name. In a vault
|
|
1121
|
+
* the vault asks the person. Rejects `invalid_argument` for a non-boolean, `sign_in_required` without a sign-in. */
|
|
1122
|
+
addAsUsername(on: boolean): Promise<{ addAsUsername: boolean }>
|
|
1123
|
+
/** `addAsUsername`: that person's preference, published with the name (absent from an older server). */
|
|
1124
|
+
resolve(name: string): Promise<{ username: string; exists: boolean; addAsUsername?: boolean }>
|
|
1101
1125
|
}
|
|
1102
1126
|
|
|
1103
1127
|
/** wb.speech (sdk-assistant.md#speak). `play` rejects with `no_hebrew`, `empty`, `sign_in_required`, `tts_rate_limited`, `tts_unavailable`, `http_<n>`, `audio`, `play`. */
|