@witbitz/sdk 4.7.1 → 4.9.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/accountRoomPointers.js +54 -0
- package/accountRooms.js +79 -0
- package/accountStores.js +13 -2
- package/acctV2App.js +74 -8
- package/acctV2Client.js +16 -9
- package/acctV2Switch.js +5 -0
- package/acctV2UiCore.js +16 -2
- package/acctV2WebAuthn.js +4 -4
- package/acctV2Wire.js +21 -1
- package/backupRecord.js +6 -2
- package/changePush.js +5 -2
- package/cloudDevicePins.js +1 -1
- package/codeCloud.js +23 -5
- package/connections.js +1 -1
- package/followImage.js +2 -2
- package/idb.js +12 -1
- package/idbSeal.js +4 -2
- package/inviteReceive.js +15 -1
- package/inviteSend.js +21 -1
- package/l1-worker-src.js +1 -1
- package/l1-worker.js +146 -11
- package/manifest.json +45 -42
- package/package.json +5 -2
- package/roomDelete.js +4 -0
- package/roomName.js +4 -1
- package/roomPass.js +57 -0
- package/roomStreamClient.js +11 -6
- package/sdkAccount.js +10 -4
- package/sdkBackup.js +2 -0
- package/sdkBackupV2.js +23 -7
- package/sdkPlan.js +8 -2
- package/sealedRoomWire.js +68 -0
- package/sentinelRelease.js +1 -0
- package/spaceClient.js +123 -27
- package/spaceConfig.js +4 -2
- package/splitKeyClient.js +4 -0
- package/sw-notif-core.js +52 -4
- package/vault-core.js +69 -19
- package/vault-kit.mjs +1 -1
- package/vaultAtRest.js +3 -2
- package/vaultCorePush.js +27 -6
- package/witbitz-admin.mjs +12 -11
- package/witbitz-sdk.d.ts +4 -4
- package/witbitz-sdk.js +42 -10
package/vault-core.js
CHANGED
|
@@ -48,10 +48,9 @@ import { sealedStorage } from './vaultSealedStore.js' // the vault's other secre
|
|
|
48
48
|
import { createAtRest, deviceWrapKey, holdsSealed } from './vaultAtRest.js' // the room list's keys and the backup state, sealed on disk (2026-11-13)
|
|
49
49
|
import { deviceStorageKey } from './vaultDeviceKey.js' // the key worker's store sealed at rest too (11-21 sweep P8): our hosted vault's device key
|
|
50
50
|
import { pushAcctSecretOf } from './spaceClient.js' // the account's push tag secret (handDownPushAcct)
|
|
51
|
-
import { indexRoomOf } from './sdkAccount.js'
|
|
52
51
|
import { accountService, restoreBridge, restoreSignInProof, idbKeyStore } from './sdkBackupV2.js' // NEW accounts on the Witbitz account service (account v2; the owner, 2026-11-16: "Yes. Do the sdk.")
|
|
53
52
|
import { roomRegion } from './regions.js' // a lane's region is its Space's
|
|
54
|
-
import { makeRoomPassHolder, roomPassSwitchOn, isRoomPassAsk, isSigninRenewAsk } from './roomPass.js' // the room pass of an account on the account service (docs/device-gate-design.md)
|
|
53
|
+
import { answerAccountRoomAsk, isAccountRoomAsk, makeRoomPassHolder, roomPassSwitchOn, isRoomPassAsk, isSigninRenewAsk } from './roomPass.js' // the room pass of an account on the account service (docs/device-gate-design.md)
|
|
55
54
|
|
|
56
55
|
export const VAULT_PROTOCOL = 1
|
|
57
56
|
// The room operations a page may run, on a room this vault holds. Left out on purpose: purge/carry (destructive or
|
|
@@ -94,7 +93,7 @@ export const ACCOUNT_CALLS = {
|
|
|
94
93
|
/** The backup calls that need an account on the Witbitz account service (sync sweep 11-16 #15). */
|
|
95
94
|
const SERVICE_CALLS = new Set(['manageSecurityKeys', 'signOutOthers', 'newRecoveryCode', 'emailMove', 'requestMoveTime', 'cancelEmailMove'])
|
|
96
95
|
export const ROOM_ACCOUNT_CALLS = {
|
|
97
|
-
roster: { list: {}, admission: {}, isOwner: {}, isAdmin: {}, sessionRole: {} },
|
|
96
|
+
roster: { list: {}, admission: {}, isOwner: {}, isAdmin: {}, sessionRole: {}, directPeer: {} }, // directPeer: sync sweep 12-04 O26 (a two-tag chat's peer needs the vault's sign-in)
|
|
98
97
|
portable: { export: { confirm: true } },
|
|
99
98
|
privateRoom: { link: { confirm: true }, unlink: { confirm: true } },
|
|
100
99
|
keptAgent: { link: { confirm: true }, unlink: { confirm: true } },
|
|
@@ -115,6 +114,7 @@ export function publicVaultRooms(rooms, currentRoom) {
|
|
|
115
114
|
...(detachedLane ? { detachedLane: true } : {}),
|
|
116
115
|
...(enc ? { tier: 'enclave' } : {}),
|
|
117
116
|
...(roomInviteFlags(link).lanes ? { lanes: true } : {}),
|
|
117
|
+
...(roomInviteFlags(link).gated ? { gated: true } : {}), // the link's gate mark, as a direct handle keeps it — without it a reopened handle read an incomplete config as open admission (sync sweep 2026-12-04 O24)
|
|
118
118
|
})).sort((a, b) => (Number(b.at) || 0) - (Number(a.at) || 0))
|
|
119
119
|
}
|
|
120
120
|
|
|
@@ -136,7 +136,10 @@ export function linkParts(href) {
|
|
|
136
136
|
try {
|
|
137
137
|
const u = new URL(href)
|
|
138
138
|
const room = u.searchParams.get('room') || ''
|
|
139
|
-
|
|
139
|
+
// only the part before the first `?`: a legacy signed-member link appends `?gk=…>=…&sk=…` (spaceConfig.js parseConfiguredLink),
|
|
140
|
+
// and its identity became part of the room key (sync sweep 2026-12-04 O25)
|
|
141
|
+
const raw = u.hash.replace(/^#/, ''), q = raw.indexOf('?')
|
|
142
|
+
const frag = new URLSearchParams(q >= 0 ? raw.slice(0, q) : raw)
|
|
140
143
|
const mk = frag.get('mk') || '', us = frag.get('us') || ''
|
|
141
144
|
if (room && mk) return { room, mk }
|
|
142
145
|
if (room && us) return { room, userShare: us, commit: frag.get('spc') || '', split: true }
|
|
@@ -368,6 +371,12 @@ export async function startVault(o = {}) {
|
|
|
368
371
|
const m = e.data || {}
|
|
369
372
|
if (m.t === 'presence') { if (Array.isArray(m.rooms)) workerRooms = m.rooms.filter((r) => typeof r === 'string' && r).slice(0, 5000); return }
|
|
370
373
|
if (m.authReq != null && isSigninRenewAsk(m.room)) { const a = m.authReq, w = worker; renewSession().then((v) => { try { w.postMessage({ t: 'authRes', a, v: v || {} }) } catch { /* a restarted worker asks again */ } }); return } // the sign-in renewed to name its app (above)
|
|
374
|
+
if (m.authReq != null && isAccountRoomAsk(m.room)) {
|
|
375
|
+
const w = worker, a = m.authReq, backup = sdk.backup
|
|
376
|
+
answerAccountRoomAsk(m.room, (room, pub, kind, proofs) => backup._v2.accountRoomPassFor(backup, room, pub, kind, proofs))
|
|
377
|
+
.catch(() => null).then(v => { try { w.postMessage({ t: 'authRes', a, v }) } catch { /* worker restarted */ } })
|
|
378
|
+
return
|
|
379
|
+
}
|
|
371
380
|
if (m.authReq != null && isRoomPassAsk(m.room)) { const a = m.authReq, w = worker; (roomPass ? roomPass.answer(m.room) : Promise.resolve({})).then((v) => { try { w.postMessage({ t: 'authRes', a, v: v?.retryable ? { retryable: true } : v && v.pass && v.psig ? { pass: v.pass, psig: v.psig } : {} }) } catch { /* a restarted worker asks again */ } }); return } // the room pass (above)
|
|
372
381
|
if (m.authReq != null) { worker.postMessage({ t: 'authRes', a: m.authReq, v: authFor(m.room) }); return }
|
|
373
382
|
if (m.attestReq != null) { worker.postMessage({ t: 'attestRes', a: m.attestReq, v: null }); return }
|
|
@@ -485,6 +494,8 @@ export async function startVault(o = {}) {
|
|
|
485
494
|
storage: st, worker: typeof o.pushWorker === 'string' ? o.pushWorker : '/push-sw.js',
|
|
486
495
|
subscribe: (room, sub, quiet) => wop('subscribe', room, sub, '', quiet),
|
|
487
496
|
unsubscribe: (room, sub) => wop('unsubscribe', room, sub),
|
|
497
|
+
// a refused unsubscribe (a verified Space this device is not signed in to): the keyless removal, as withdrawPushEverywhere (sync sweep 12-04 O3)
|
|
498
|
+
pushDrop: async (room, sub) => { const r = await fetch(endpoint, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ op: 'pushdrop', room, subscription: { endpoint: sub && sub.endpoint } }) }); return { status: r.status } },
|
|
488
499
|
setSelf: (endpoint) => { try { worker.postMessage({ t: 'setPushSelf', endpoint }) } catch { /* the replay sends it to the next one */ } },
|
|
489
500
|
held: (room) => held(room),
|
|
490
501
|
onOpen: (room) => emit({ ev: 'notifOpen', room }),
|
|
@@ -843,7 +854,14 @@ export async function startVault(o = {}) {
|
|
|
843
854
|
try { await sdk.account._ensureRoom(loc) } catch (e) { return { ok: false, why: 'unreachable' } }
|
|
844
855
|
if (who() !== w) return { ok: false, why: 'moved' } // signed out during that round trip (pass 9, K#2): a pass over the EMPTIED stores stamped every lane and Siri gone, on every device
|
|
845
856
|
const allKeep = read(st, KEYS.keep, {}) || {}
|
|
846
|
-
|
|
857
|
+
let prev = allKeep[w] || null
|
|
858
|
+
// ⛔ A RESTORE OF ANOTHER ACCOUNT UNDER THE SAME ADDRESS (sync sweep 2026-12-04 O18; the app's roomSync guards by master): the
|
|
859
|
+
// kept view and this vault's connections, Siri and outside agents are keyed by the ADDRESS, so the first pass after it stamped
|
|
860
|
+
// the previous account's records as this device's and wrote them into the restored account. The view names the master it was
|
|
861
|
+
// merged under; another one → what this vault held was that account's: dropped here, and the restored account's view applies.
|
|
862
|
+
const keepOwner = await keepOwnerOf(loc.master)
|
|
863
|
+
if (who() !== w) return { ok: false, why: 'moved' }
|
|
864
|
+
if (prev && prev.owner && prev.owner !== keepOwner) { dropHeldForAccount(acct, w); prev = null }
|
|
847
865
|
// ⛔ WHAT IS KEPT AS `prev` AND WHAT IS APPLIED IS keepPass's WORD (vaultKeep.js; sync sweep 2026-11-12 #1 #2): the merged view
|
|
848
866
|
// only from a pass that saved while nothing changed here. It was recorded whatever the pass answered — after one failed
|
|
849
867
|
// save the next pass deleted the other devices' connections, Siri and outside agents on every device — and applied over
|
|
@@ -863,7 +881,7 @@ export async function startVault(o = {}) {
|
|
|
863
881
|
if (tomb?.gone && tomb.at >= at) connectionChange(acct, id, false, at).catch(() => keepSoon())
|
|
864
882
|
}
|
|
865
883
|
} // into the stores FIRST: were it to throw, `prev` stays what the stores hold
|
|
866
|
-
const all2 = read(st, KEYS.keep, {}) || {}; all2[w] = p.record; write(st, KEYS.keep, all2)
|
|
884
|
+
const all2 = read(st, KEYS.keep, {}) || {}; all2[w] = { ...p.record, owner: keepOwner }; write(st, KEYS.keep, all2) // owner: O18 above
|
|
867
885
|
} })
|
|
868
886
|
if (who() !== w) return { ok: false, why: 'moved' }
|
|
869
887
|
const ch = keepMoved; keepMoved = null; await pushAfterApply(w, ch) // what the apply moved at the Sentinel's side (K#8)
|
|
@@ -913,6 +931,12 @@ export async function startVault(o = {}) {
|
|
|
913
931
|
}
|
|
914
932
|
if (who() === w) { save(); if (pending.siri || pending.a2a) keepSoon(30000) }
|
|
915
933
|
}
|
|
934
|
+
const keepOwnerOf = async (master) => [...new Uint8Array(await crypto.subtle.digest('SHA-256', new TextEncoder().encode('vault-keep-owner|' + String(master || ''))))].slice(0, 12).map((x) => x.toString(16).padStart(2, '0')).join('')
|
|
935
|
+
function dropHeldForAccount (acct, w) { // O18: the previous account's three, off this vault before the restored account's pass
|
|
936
|
+
conns = conns.filter((c) => c.account !== acct); put(KEYS.connections, conns)
|
|
937
|
+
try { sdk.siri.restore(null); const all = read(st, KEYS.siri, {}) || {}; delete all[w]; put(KEYS.siri, all); emit({ ev: 'siri', siri: siriShortcut() }) } catch { /* */ }
|
|
938
|
+
try { sdk.a2a.restore(null); const all = read(st, KEYS.a2a, {}) || {}; delete all[w]; put(KEYS.a2a, all); emit({ ev: 'a2aChanged' }) } catch { /* */ }
|
|
939
|
+
}
|
|
916
940
|
function applyKeep (acct, keep) { // the merged view into this vault — written straight to storage (no new stamp: it IS the merged state)
|
|
917
941
|
const v = viewOfKeep(keep), w = who()
|
|
918
942
|
const was = { a2a: a2aSent(), siri: siriSent(), hadKey: !!sdk.siri.state.token }
|
|
@@ -1039,8 +1063,9 @@ export async function startVault(o = {}) {
|
|
|
1039
1063
|
// bridge to its shared room and none of the lane's actions or links. Keyless both ways — the worker holds both keys.
|
|
1040
1064
|
const roomSpace = (room) => {
|
|
1041
1065
|
const it = rooms.find((x) => x.room === room)
|
|
1042
|
-
const
|
|
1043
|
-
|
|
1066
|
+
const gated = !!(it && roomInviteFlags(it.link).gated) // 12-04 O24: the link's gate mark, as a direct handle keeps it
|
|
1067
|
+
const sp = it?.lane ? new Lane(workerClient, { room, mk: null, link: null, wb: sdk, live: false, poll: false, sharedRoom: it.lane, sharedMk: null, gated })
|
|
1068
|
+
: new Space(workerClient, { room, mk: null, link: null, wb: sdk, live: false, poll: false, gated })
|
|
1044
1069
|
if (it?.title) sp._title = { title: it.title }
|
|
1045
1070
|
return sp
|
|
1046
1071
|
}
|
|
@@ -1304,7 +1329,7 @@ export async function startVault(o = {}) {
|
|
|
1304
1329
|
async function handDownPushAcct() {
|
|
1305
1330
|
if (!vpush) return
|
|
1306
1331
|
const b = sdk.backup, m = b && b.enabled && b._s && b._s.master
|
|
1307
|
-
const secret = m ? await pushAcctSecretOf((await
|
|
1332
|
+
const secret = m ? await pushAcctSecretOf((await sdk.account._where()).mk) : ''
|
|
1308
1333
|
if (secret === pushAcctSecret) return
|
|
1309
1334
|
pushAcctSecret = secret
|
|
1310
1335
|
try { worker.postMessage({ t: 'setPushAcct', secret }) } catch { /* the replay sends it to the next one */ }
|
|
@@ -1364,6 +1389,8 @@ export async function startVault(o = {}) {
|
|
|
1364
1389
|
return sdk._session === session ? held : null
|
|
1365
1390
|
}, ...(typeof o.accountService === 'string' && o.accountService ? { base: o.accountService } : {}), fetch: (...a) => fetch(...a), keyStore: idbKeyStore('wbvault-acct'), persistNow, onRevoked: () => accountStatus(true), afterSignOut: (address) => { if (roomPass) roomPass.renewNow(address) },
|
|
1366
1391
|
// the endpoint once the subscription is KNOWN (vpush.ready) — not known within 15 s: undefined, and nothing is sent (Codex 11-16 #2)
|
|
1392
|
+
// the whole subscription too — its keys carry the email-move security notice to this device (sync sweep 12-04 O8)
|
|
1393
|
+
...(vpush ? { pushSubscription: async () => ((await Promise.race([vpush.ready.then(() => true), new Promise((r) => setTimeout(() => r(false), 15000))])) ? vpush.subscription() : undefined) } : {}),
|
|
1367
1394
|
...(vpush ? { pushEndpoint: async () => ((await Promise.race([vpush.ready.then(() => true), new Promise((r) => setTimeout(() => r(false), 15000))])) ? ((e) => (e === undefined ? undefined : e || null))(vpush.endpoint()) : undefined), /* undefined = not known (on, but not loaded): nothing is sent (side sweep 2026-11-28) */ withdrawPush: withdrawPushEverywhere } : {}) }) // § 8.8, only where this vault sends notifications (sync sweep 11-16 #14)
|
|
1368
1395
|
roomPass = makeRoomPassHolder({
|
|
1369
1396
|
on: () => roomPassSwitchOn(st),
|
|
@@ -1455,6 +1482,12 @@ export async function startVault(o = {}) {
|
|
|
1455
1482
|
write(st, KEYS.pendingForget, [...pendingForget])
|
|
1456
1483
|
await st.flushed()
|
|
1457
1484
|
}
|
|
1485
|
+
// a lane of a forgotten Space becomes a room of its own (as backup.remove) — this tab's drop AND another tab's (sync sweep 2026-12-04 O4: the second tab dropped only the Space, and its lane stayed pointing at it)
|
|
1486
|
+
const detachFrom = (room) => (r) => {
|
|
1487
|
+
if (r.lane !== room) return r
|
|
1488
|
+
const { lane, laneOrigin, ...rest } = r
|
|
1489
|
+
return { ...rest, ...(laneOrigin === 'minted' && !r.mintedFor ? { mintedFor: lane } : {}), detachedLane: true, associationAt: Math.max(Date.now(), Number(r.associationAt) || 0) }
|
|
1490
|
+
}
|
|
1458
1491
|
async function dropRoom(room) {
|
|
1459
1492
|
const mark = Date.now() + ':' + crypto.randomUUID()
|
|
1460
1493
|
st.setItem(forgetPrefix + room, mark)
|
|
@@ -1462,11 +1495,7 @@ export async function startVault(o = {}) {
|
|
|
1462
1495
|
pendingForget.add(room)
|
|
1463
1496
|
write(st, KEYS.pendingForget, [...pendingForget])
|
|
1464
1497
|
// 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(
|
|
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
|
-
})
|
|
1498
|
+
rooms = rooms.filter(r => r.room !== room).map(detachFrom(room))
|
|
1470
1499
|
emit({ ev: 'rooms', rooms: publicRooms() })
|
|
1471
1500
|
streamGrants.delete(room)
|
|
1472
1501
|
if (streaming.delete(room)) syncStream(worker, room, null)
|
|
@@ -1557,7 +1586,9 @@ export async function startVault(o = {}) {
|
|
|
1557
1586
|
const selection = args[1] === undefined ? null : new Set(Array.isArray(args[1]) ? args[1] : [])
|
|
1558
1587
|
if (selection && (selection.size > 1000 || [...selection].some(id => typeof id !== 'string' || !id || id.length > 160))) throw Object.assign(new Error('Invalid room selection'), { code: 'invalid_argument' })
|
|
1559
1588
|
const heldById = new Map(rooms.map(r => [r.room, r]))
|
|
1560
|
-
|
|
1589
|
+
// a COPY of each record (sync sweep 2026-12-04 O21): a re-key in place rewrites the held record's link (relinkRoom), and the final
|
|
1590
|
+
// check compared that same record with itself — a key collected before the rotation was exported as current
|
|
1591
|
+
const selected = (selection ? [...selection].map(id => heldById.get(id) || { room: id }) : rooms.slice()).filter(r => !r.room.startsWith('tmp-')).map(r => ({ ...r }))
|
|
1561
1592
|
return saveAccountArchive(selected, async (r, keysOnly, attachments) => {
|
|
1562
1593
|
if (!r.link) return {}
|
|
1563
1594
|
const parts = linkParts(r.link)
|
|
@@ -1947,6 +1978,7 @@ export async function startVault(o = {}) {
|
|
|
1947
1978
|
try {
|
|
1948
1979
|
if (ns === 'roster' && m === 'sessionRole') return sessionRole(sp, await sp._gateConfig({ fresh: true, plainMark: true }))
|
|
1949
1980
|
if (ns === 'roster' && (m === 'isOwner' || m === 'isAdmin')) return sp[m](args[0])
|
|
1981
|
+
if (ns === 'roster' && m === 'directPeer') return await sp.directPeer()
|
|
1950
1982
|
if (ns === 'roster') return await (m === 'list' ? sp.roster() : sp.admission())
|
|
1951
1983
|
if (ns === 'portable') {
|
|
1952
1984
|
const { saveRoomExport } = await import('./sdkExports.js')
|
|
@@ -2011,7 +2043,12 @@ export async function startVault(o = {}) {
|
|
|
2011
2043
|
if (shared) {
|
|
2012
2044
|
const cfg = await wop('getConfig', shared, { plainMark: true })
|
|
2013
2045
|
if (!cfg || cfg.gated && !cfg.allow) throw Object.assign(new Error('vault: the shared Space policy could not be read'), { code: 'policy_unreadable' })
|
|
2014
|
-
if (cfg.lanes === false)
|
|
2046
|
+
if (cfg.lanes === false) {
|
|
2047
|
+
// …and the association goes too, as the app's mirror does (deleteNegotiation) and a config read here does (op getConfig): the mirror
|
|
2048
|
+
// stopped this one copy and kept the lane pointing at its Space (sync sweep 2026-12-04 O37). A failed sync is sent at the next one.
|
|
2049
|
+
await disconnectRoomLanes(sdk, shared).catch(() => {})
|
|
2050
|
+
throw Object.assign(new Error('vault: private assistants are disabled in the shared Space'), { code: 'lanes_disabled' })
|
|
2051
|
+
}
|
|
2015
2052
|
}
|
|
2016
2053
|
if (mirrorOk.get(lane)) return
|
|
2017
2054
|
if (!shared || typeof sdk._client.attestedRoom !== 'function') return
|
|
@@ -2085,7 +2122,7 @@ export async function startVault(o = {}) {
|
|
|
2085
2122
|
if (event.key?.startsWith(forgetPrefix) && event.newValue) {
|
|
2086
2123
|
const room = event.key.slice(forgetPrefix.length)
|
|
2087
2124
|
if (rooms.some(r => r.room === room && !currentRoom(r))) {
|
|
2088
|
-
rooms = rooms.filter(r => r.room !== room || currentRoom(r))
|
|
2125
|
+
rooms = rooms.filter(r => r.room !== room || currentRoom(r)).map(detachFrom(room))
|
|
2089
2126
|
streamGrants.delete(room)
|
|
2090
2127
|
if (streaming.delete(room)) syncStream(worker, room, null)
|
|
2091
2128
|
wcall({ t: 'forget', room }).catch(() => {})
|
|
@@ -2419,7 +2456,20 @@ export async function startVault(o = {}) {
|
|
|
2419
2456
|
// the lock sheet and the notifications card: ONE at a time, however often the page asks (as the sign-in screen)
|
|
2420
2457
|
const asking = { lock: null, push: null }
|
|
2421
2458
|
async function notificationsOnce() {
|
|
2422
|
-
|
|
2459
|
+
// sync sweep 2026-12-04 N9: what the browser can do and whether the subscription was made are shown apart from the saved switch
|
|
2460
|
+
const now = vpush.view(), on = now.on
|
|
2461
|
+
if (!now.available || now.denied) {
|
|
2462
|
+
await confirmWith(!now.available
|
|
2463
|
+
? { title: 'Notifications are not available here', text: 'This browser cannot receive notifications for this site. On an iPhone or iPad, add it to your Home Screen and open it from there.', ok: 'OK', cancel: '' }
|
|
2464
|
+
: { title: 'Notifications are blocked', text: 'This browser blocks notifications for this site. Allow them in the browser’s site settings, then try again.', ok: 'OK', cancel: '' }).catch(() => false)
|
|
2465
|
+
return now
|
|
2466
|
+
}
|
|
2467
|
+
if (now.incomplete) { // on, but this device's subscription could not be set up: Try again (the person's click is the gesture it needs)
|
|
2468
|
+
if (!(await confirmWith({ title: 'Notifications are not set up on this device', text: 'They are switched on, but this device could not finish setting them up, so nothing reaches it yet.', ok: 'Try again', cancel: 'Not now' }).catch(() => false))) return vpush.view()
|
|
2469
|
+
const v = await vpush.enable(rooms.map((r) => r.room))
|
|
2470
|
+
emit({ ev: 'push', push: v })
|
|
2471
|
+
return v
|
|
2472
|
+
}
|
|
2423
2473
|
const ok = await confirmWith(on
|
|
2424
2474
|
? { title: 'Turn off notifications?', text: 'This device stops getting a nudge when someone posts in your Spaces.', ok: 'Turn off', cancel: 'Keep them' }
|
|
2425
2475
|
: { title: 'Get notifications on this device?', text: 'A nudge when someone posts in your Spaces. What it says is sealed until it reaches this device.', ok: 'Turn on', cancel: 'Not now' }).catch(() => false)
|
|
@@ -2454,6 +2504,6 @@ export async function startVault(o = {}) {
|
|
|
2454
2504
|
// the page never says hello: tell the person, in the vault's own pixels
|
|
2455
2505
|
setTimeout(() => { if (!greeted && typeof screens.failed === 'function') try { screens.failed({ page: pageUrl.href }) } catch { /* */ } }, o.loadTimeoutMs || 20_000)
|
|
2456
2506
|
|
|
2457
|
-
if (vpush) vpush.start(rooms.map((r) => r.room)).catch(() => {}) // a device that turned notifications on: its subscription, kept current
|
|
2507
|
+
if (vpush) vpush.start(rooms.map((r) => r.room)).catch(() => {}).then(() => { if (vpush.view().incomplete) emit({ ev: 'push', push: vpush.view() }) }) // a device that turned notifications on: its subscription, kept current — one that could not be set up is said (sync sweep 12-04 N9)
|
|
2458
2508
|
return { frame, rooms: publicRooms, signedIn, worker: () => worker, _sdk: sdk, _store: st } // _sdk: tests stand a Sentinel in; _store: the sealed secrets as the vault reads them (tests)
|
|
2459
2509
|
}
|
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.9.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/vaultAtRest.js
CHANGED
|
@@ -127,7 +127,8 @@ export function createAtRest ({ storage, key, currentRoom = () => true }) {
|
|
|
127
127
|
return onDisk(async () => {
|
|
128
128
|
const encoded = await Promise.all(snap.map(entryOut))
|
|
129
129
|
const next = signature(snap)
|
|
130
|
-
|
|
130
|
+
// Reject the lock callback promise on a failed write so the next save can acquire the lock.
|
|
131
|
+
const commit = async () => {
|
|
131
132
|
const previous = snapshots.get(k)
|
|
132
133
|
const disk = read(storage, k)
|
|
133
134
|
const rows = new Map((Array.isArray(disk) ? disk : []).filter(currentRoom).map(r => [r.room, r]))
|
|
@@ -151,7 +152,7 @@ export function createAtRest ({ storage, key, currentRoom = () => true }) {
|
|
|
151
152
|
}
|
|
152
153
|
const locks = globalThis.navigator?.locks
|
|
153
154
|
if (locks) await locks.request('witbitz:room-registry:' + k, commit)
|
|
154
|
-
else commit()
|
|
155
|
+
else await commit()
|
|
155
156
|
})
|
|
156
157
|
},
|
|
157
158
|
/** Every account's backup state (the vault's `wbvault:backup` = { email: state }), opened. */
|
package/vaultCorePush.js
CHANGED
|
@@ -21,16 +21,17 @@ export const PUSH_KEY = 'wbvault:push' // { on, endpoint, rooms: [the Spaces thi
|
|
|
21
21
|
* @param {Storage} o.storage
|
|
22
22
|
* @param {(room: string, sub: object, quiet: boolean) => Promise<object>} o.subscribe through the vault's key worker
|
|
23
23
|
* @param {(room: string, sub: object) => Promise<object>} o.unsubscribe
|
|
24
|
+
* @param {(room: string, sub: object) => Promise<object>} [o.pushDrop] keyless removal (op pushdrop) when the keyed one is refused
|
|
24
25
|
* @param {(endpoint: string) => void} o.setSelf the key worker's turns skip this device (its own posts do not tickle it)
|
|
25
26
|
* @param {(room: string) => boolean} o.held
|
|
26
27
|
* @param {(room: string) => void} o.onOpen a tapped notification's Space (warm)
|
|
27
28
|
* @param {string} [o.worker] the service worker's path (default /push-sw.js, the kit's)
|
|
28
29
|
* @param {() => Promise<object|null>} [o.takeTap] reads AND clears the tap push-sw.js stashed (idb 'spaces'/'kv' notifTap)
|
|
29
30
|
*/
|
|
30
|
-
export function createVaultPush ({ storage, subscribe, unsubscribe, setSelf, held, onOpen, onChange = null, worker = '/push-sw.js', nav = (typeof navigator !== 'undefined' ? navigator : null), N = (typeof Notification !== 'undefined' ? Notification : null), takeTap = takeStashedTap, doc = (typeof document !== 'undefined' ? document : null), search = (typeof location !== 'undefined' ? location.search : '') }) {
|
|
31
|
+
export function createVaultPush ({ storage, subscribe, unsubscribe, pushDrop = null, setSelf, held, onOpen, onChange = null, worker = '/push-sw.js', nav = (typeof navigator !== 'undefined' ? navigator : null), N = (typeof Notification !== 'undefined' ? Notification : null), takeTap = takeStashedTap, doc = (typeof document !== 'undefined' ? document : null), search = (typeof location !== 'undefined' ? location.search : '') }) {
|
|
31
32
|
const read = () => { try { const v = JSON.parse(storage.getItem(PUSH_KEY) || 'null'); return v && typeof v === 'object' ? v : { on: false } } catch { return { on: false } } }
|
|
32
33
|
const save = (v) => { try { storage.setItem(PUSH_KEY, JSON.stringify(v)) } catch { /* a full store: on for this session */ } }
|
|
33
|
-
let sub = null, chain = Promise.resolve(), unknown = false // unknown: on, and this start could not load the subscription
|
|
34
|
+
let sub = null, chain = Promise.resolve(), unknown = false, started = false // unknown: on, and this start could not load the subscription
|
|
34
35
|
// KNOWN: start() has finished (a subscription loaded, or found off / unsupported). Until then this device's endpoint is NOT KNOWN —
|
|
35
36
|
// the account service must not be told "none" (Codex sweep 2026-11-16 #2). `changed` runs after every change of it.
|
|
36
37
|
let readyOk = null
|
|
@@ -38,7 +39,13 @@ export function createVaultPush ({ storage, subscribe, unsubscribe, setSelf, hel
|
|
|
38
39
|
const changed = () => { readyOk(); try { if (typeof onChange === 'function') onChange() } catch { /* */ } }
|
|
39
40
|
const serial = (fn) => { const p = chain.then(fn); chain = p.catch(() => {}); return p } // one change of the list at a time
|
|
40
41
|
const supported = () => !!(nav && nav.serviceWorker && N && typeof globalThis.PushManager !== 'undefined')
|
|
41
|
-
|
|
42
|
+
// sync sweep 2026-12-04 N9: the card read only the saved switch — "on" (and only "Turn off") after the subscription could not be
|
|
43
|
+
// made, and "Turn on" in a browser that cannot receive them. Now: `available` is this browser's, `incomplete` = on, but this
|
|
44
|
+
// start could not set the subscription up (the card offers Try again), `denied` = the browser blocks them (nothing to turn on).
|
|
45
|
+
const view = () => {
|
|
46
|
+
const on = !!read().on, available = supported()
|
|
47
|
+
return { available, on, ...(on && available && started && !sub ? { incomplete: true } : {}), ...(available && !on && N.permission === 'denied' ? { denied: true } : {}) }
|
|
48
|
+
}
|
|
42
49
|
const json = (s) => (s && typeof s.toJSON === 'function' ? s.toJSON() : s)
|
|
43
50
|
// what an unsubscribe names: the live subscription, else the endpoint this device was listed under (the server drops by endpoint) —
|
|
44
51
|
// a revoked permission or a missing worker must not leave every Space tickling a device that turned notifications off (review)
|
|
@@ -51,7 +58,17 @@ export function createVaultPush ({ storage, subscribe, unsubscribe, setSelf, hel
|
|
|
51
58
|
// ⛔ A SPACE IS TAKEN OFF ITS LIST ONLY WHEN THE SERVER SAYS SO (review, 2026-11-13): a failed unsubscribe (offline) is kept in
|
|
52
59
|
// `off` and tried again at the next start — three starts, then it is let go (a Space whose key is gone can never be asked).
|
|
53
60
|
// → whether it is settled (taken off, or refused for good by the server).
|
|
54
|
-
|
|
61
|
+
// sync sweep 2026-12-04 O3: a REFUSED unsubscribe (a verified Space this device is not signed in to answers 401/403) counted as
|
|
62
|
+
// settled, and the Space kept tickling a device that had forgotten it. A refusal now files the keyless removal (op pushdrop,
|
|
63
|
+
// agent/pushDrop.mjs — the room's next turn removes the address), as the app and our vault do; only its 200 settles it.
|
|
64
|
+
const takeOff = async (room, s) => {
|
|
65
|
+
const a = s ? await unsubscribe(room, s).catch(() => null) : null
|
|
66
|
+
if (a && a.status === 200) return true
|
|
67
|
+
if (!(a && a.status >= 400 && a.status < 500)) return false // offline, a 5xx: tried again at the next start
|
|
68
|
+
if (typeof pushDrop !== 'function') return true // no keyless door here: as before, the refusal stands
|
|
69
|
+
const d = await pushDrop(room, s).catch(() => null)
|
|
70
|
+
return !!(d && d.status === 200)
|
|
71
|
+
}
|
|
55
72
|
const stillOff = (st, room) => { const off = (Array.isArray(st.off) ? st.off : []).filter((o) => o && o.room !== room); return [...off, { room, n: 0 }].slice(-200) }
|
|
56
73
|
|
|
57
74
|
// THE LIST, kept in step: every Space held is listed, a Space dropped is taken off — the vault calls it after each change
|
|
@@ -95,6 +112,9 @@ export function createVaultPush ({ storage, subscribe, unsubscribe, setSelf, hel
|
|
|
95
112
|
view,
|
|
96
113
|
sync,
|
|
97
114
|
endpoint: () => (sub ? sub.endpoint : unknown ? undefined : ''), // undefined: not known (on, but not loaded) — never reported as none
|
|
115
|
+
// sync sweep 2026-12-04 O8: the whole subscription (endpoint AND its encryption keys) — the account service needs the keys to send the
|
|
116
|
+
// email-move security notice to this device (acctV2App.syncPush deps.pushSubscription). undefined = not known, null = none.
|
|
117
|
+
subscription: () => (sub ? json(sub) : unknown ? undefined : null),
|
|
98
118
|
/** Resolves once start() knows this device's endpoint (or that there is none). */
|
|
99
119
|
ready,
|
|
100
120
|
/** A Space about to be forgotten: off its list NOW, while the key worker still holds its key (after, the request has none). */
|
|
@@ -108,7 +128,7 @@ export function createVaultPush ({ storage, subscribe, unsubscribe, setSelf, hel
|
|
|
108
128
|
},
|
|
109
129
|
/** At start: a device that turned notifications on keeps its subscription (and the worker, its current bytes). */
|
|
110
130
|
async start (rooms) {
|
|
111
|
-
try { return await this._start(rooms) } finally { changed() } // known now, whatever the outcome
|
|
131
|
+
try { return await this._start(rooms) } finally { started = true; changed() } // known now, whatever the outcome
|
|
112
132
|
},
|
|
113
133
|
/** @private */
|
|
114
134
|
async _start (rooms) {
|
|
@@ -139,7 +159,8 @@ export function createVaultPush ({ storage, subscribe, unsubscribe, setSelf, hel
|
|
|
139
159
|
const r = await subscribeRobust(reg, VAPID_PUBLIC_KEY)
|
|
140
160
|
if (!r.sub) throw Object.assign(new Error('vault: the push service did not answer — ' + r.err), { code: 'push_unavailable' })
|
|
141
161
|
sub = r.sub; unknown = false; setSelf(sub.endpoint)
|
|
142
|
-
|
|
162
|
+
const prevOff = read().off // a Try again (N9) over an earlier "off" that could not reach every Space: still tried at the next start
|
|
163
|
+
save({ on: true, endpoint: sub.endpoint, rooms: [], ...(Array.isArray(prevOff) && prevOff.length ? { off: prevOff } : {}) })
|
|
143
164
|
await sync(rooms, { loud: true })
|
|
144
165
|
changed()
|
|
145
166
|
return view()
|
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.9.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.9.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.9.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.9.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,8 +646,9 @@ 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.9.0/sentinelRelease.js
|
|
650
650
|
var BUILD_ENCLAVE_PCR0 = Object.freeze([
|
|
651
|
+
"5efd30e7333e33104dcc238d6d876b4019ee7cb0c80ee423786473199225de8bb11eb5edbb60b787b1f87741e8876e34",
|
|
651
652
|
"c6a8cbd0c05d8e003e75b266f1dde2a6426b7cd61f845e4b128e59063e40968b44f30d934bbe1925582fe33bbdd0b1d7",
|
|
652
653
|
"f490096d57e4287146e8b8d7bf4c75f423984ca52199efab0ee8684fbee6cfe6ab82c72d54f05a38f24a0d4ad6e2f557",
|
|
653
654
|
"41ec7e0e54beac5759fba7efa06c48081dbd96c7299c29c92a9c619036ce057cec357ad4ad71a165d7f881df120b043b",
|
|
@@ -794,7 +795,7 @@ async function recordPcrBy(r, subject, builders, verify = verifyAttestation) {
|
|
|
794
795
|
return { pcr0, builder };
|
|
795
796
|
}
|
|
796
797
|
|
|
797
|
-
// spaces/public/sdk/4.
|
|
798
|
+
// spaces/public/sdk/4.9.0/sealShare.js
|
|
798
799
|
var enc2 = new TextEncoder();
|
|
799
800
|
var b64 = (u8) => btoa(String.fromCharCode(...new Uint8Array(u8)));
|
|
800
801
|
async function sealTo(enclaveKey, nonce, bundle) {
|
|
@@ -808,14 +809,14 @@ async function sealTo(enclaveKey, nonce, bundle) {
|
|
|
808
809
|
return { epk: b64(epk), iv: b64(iv), ct: b64(ct), nonce: b64(nonce) };
|
|
809
810
|
}
|
|
810
811
|
|
|
811
|
-
// spaces/public/sdk/4.
|
|
812
|
+
// spaces/public/sdk/4.9.0/connDisp.js
|
|
812
813
|
var enc3 = new TextEncoder();
|
|
813
814
|
var dec = new TextDecoder();
|
|
814
815
|
var SALT = enc3.encode("witbitz-sentinel-display-v1");
|
|
815
816
|
var INFO = enc3.encode("sentinel-display");
|
|
816
817
|
|
|
817
|
-
// spaces/public/sdk/4.
|
|
818
|
-
var STANDING_SENTINEL_PCR0 = ["0e424db41977965bc6edf225229eae70fe162dd8264b1ac0b5670cb3f71bf8b923001341e85a665354b25cd8418ac6d3"];
|
|
818
|
+
// spaces/public/sdk/4.9.0/connections.js
|
|
819
|
+
var STANDING_SENTINEL_PCR0 = ["170c11ba34cb4521e138e822ff29ffcf5e78144d344882294a8c00102a6ba8a56d8f36e3ad912f70b799fe7856c46266", "0e424db41977965bc6edf225229eae70fe162dd8264b1ac0b5670cb3f71bf8b923001341e85a665354b25cd8418ac6d3"];
|
|
819
820
|
var b642 = (u8) => btoa(String.fromCharCode(...new Uint8Array(u8)));
|
|
820
821
|
var unb642 = (s) => Uint8Array.from(atob(s), (c) => c.charCodeAt(0));
|
|
821
822
|
var ConnectionError = class extends Error {
|
|
@@ -928,7 +929,7 @@ async function attestStandingSentinel({ post, auth = {}, pins = STANDING_SENTINE
|
|
|
928
929
|
}
|
|
929
930
|
var MCP_CURATED = CATALOG.filter((c) => c.url).map((c) => ({ label: c.name, url: c.url }));
|
|
930
931
|
|
|
931
|
-
// spaces/public/sdk/4.
|
|
932
|
+
// spaces/public/sdk/4.9.0/sdkRedact.js
|
|
932
933
|
var REDACTED = "[REDACTED]";
|
|
933
934
|
var INSPECT = /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom");
|
|
934
935
|
function hide(obj, names) {
|
|
@@ -953,7 +954,7 @@ function redacted(proto, summary) {
|
|
|
953
954
|
});
|
|
954
955
|
}
|
|
955
956
|
|
|
956
|
-
// spaces/public/sdk/4.
|
|
957
|
+
// spaces/public/sdk/4.9.0/witbitz-admin.js
|
|
957
958
|
var adminError = (code, message) => Object.assign(new Error(message), { code: String(code || "refused") });
|
|
958
959
|
var DEFAULT_ENDPOINT = "https://api.witbitz.chat/v1/space";
|
|
959
960
|
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
|
@@ -218,7 +218,7 @@ export interface WriteResult { ok: true; id: string; ops: unknown[] }
|
|
|
218
218
|
* `source` 'provider-partial' | 'none' = some calls reported no cost, and the total counts only the priced ones. */
|
|
219
219
|
export interface UsageTotals { turns: number; calls: number; in: number; out: number; cached: number; costMicros: number }
|
|
220
220
|
export interface TurnUsage { tokensIn: number; tokensOut: number; tokensCached: number; costMicros: number; costUsd: number; calls: number; models: string[]; source: 'provider' | 'provider-partial' | 'none'; estimated?: true; funded?: true }
|
|
221
|
-
export interface SendResult { /** 0 when the request got no answer (network, enclave unreachable) — such a send MAY have been posted: read the room before resending */ status: number; /** always present: false for any refusal, busy or failure; true when posted, silent or pending */ ok: boolean; /** when !ok: 'busy', 'not_authorized' (with `reason`: not_on_list, grant_required, …), 'gate_unreadable', 'policy_invalid', 'bad_mkseal', 'enclave_warming', 'user_token_required', 'run_needs_payer', 'reply_not_stored', 'unavailable' / 'enclave_unavailable' (status 0), 'enclave_policy_unknown' (503, retryable: nothing was sent — the enclave could not be checked yet), 'answer_unsealed' (502: a sealed request's answer came back unsealed — not from the enclave), 'answer_unopenable' (its sealed answer did not open), 'store_unavailable' (503: the server could not save just now — retry), 'envelope_op_refused' / 'envelope_stale' / 'envelope_replay' / 'bad_envelope' (400: the enclave refused a sealed request; nothing ran), 'aborted' (space.turn()'s abort/timeout while held for busy — not stored), … — sdk-reference.md#errors */ error?: string; reason?: string; /** status 0: what failed */ detail?: string; pending?: true; reply?: string; silent?: true; proposed?: unknown[]; /** absent on a pending turn — read it from space.turn()'s result, or the reply message's `usage` */ usage?: TurnUsage; /** with `showPrompt: true` and a turn that finished inside the request */ prompt?: SentPrompt; [k: string]: unknown }
|
|
221
|
+
export interface SendResult { /** 0 when the request got no answer (network, enclave unreachable) — such a send MAY have been posted: read the room before resending */ status: number; /** always present: false for any refusal, busy or failure; true when posted, silent or pending */ ok: boolean; /** when !ok: 'busy', 'not_authorized' (with `reason`: not_on_list, grant_required, …), 'gate_unreadable', 'policy_invalid', 'bad_mkseal', 'enclave_warming', 'user_token_required', 'run_needs_payer', 'reply_not_stored', 'unavailable' / 'enclave_unavailable' (status 0), 'enclave_policy_unknown' (503, retryable: nothing was sent — the enclave could not be checked yet), 'answer_unsealed' (502: a sealed request's answer came back unsealed — not from the enclave), 'answer_unopenable' (its sealed answer did not open), 'store_unavailable' (503: the server could not save just now — retry), 'envelope_op_refused' / 'envelope_stale' / 'envelope_replay' / 'bad_envelope' (400: the enclave refused a sealed request; nothing ran), 'not_stored' (200 with `memberStored: false`: the room did not keep your message — send it again), 'aborted' (space.turn()'s abort/timeout while held for busy — not stored), … — sdk-reference.md#errors */ error?: string; reason?: string; /** status 0: what failed */ detail?: string; pending?: true; reply?: string; silent?: true; proposed?: unknown[]; /** absent on a pending turn — read it from space.turn()'s result, or the reply message's `usage` */ usage?: TurnUsage; /** with `showPrompt: true` and a turn that finished inside the request */ prompt?: SentPrompt; /** the room's receipt for YOUR message: true = stored by this request, false = the room failed to store it (then `ok` is false, error 'not_stored'); absent from older servers and continuations */ memberStored?: boolean; retryable?: boolean; [k: string]: unknown }
|
|
222
222
|
export interface DictationResult { readonly text: string; readonly room: string; readonly certificate: Record<string, unknown> | null }
|
|
223
223
|
export interface SendOptions {
|
|
224
224
|
dictation?: DictationResult
|
|
@@ -598,9 +598,9 @@ export interface WitbitzOptions {
|
|
|
598
598
|
/** A vault's lock, as the person set it (a vault started with `lock: true`): `on` — a passkey at every launch; `protect` — its storage encrypted until unlocked. */
|
|
599
599
|
export interface VaultLock { available: true; on: boolean; protect: boolean }
|
|
600
600
|
/** A vault's notifications on this device, as the person set them (a vault started with `push: true`). */
|
|
601
|
-
export interface VaultPush { available:
|
|
601
|
+
export interface VaultPush { /** this browser can receive notifications here */ available: boolean; /** the person turned them on on this device */ on: boolean; /** on, but this device's subscription could not be set up — showNotifications() offers Try again */ incomplete?: true; /** the browser blocks notifications for this site */ denied?: true }
|
|
602
602
|
/** A Space in the vault's list — never its link (the link carries the key). */
|
|
603
|
-
export interface VaultRoom { detachedLane?: true; room: string; title: string; at: number; /** a private lane: the room of its Space */ lane?: string; /** a confidential Space */ tier?: 'enclave'; /** every member gets a private assistant (sdk-agents.md#lanes-for-everyone) */ lanes?: true }
|
|
603
|
+
export interface VaultRoom { detachedLane?: true; room: string; title: string; at: number; /** a private lane: the room of its Space */ lane?: string; /** a confidential Space */ tier?: 'enclave'; /** every member gets a private assistant (sdk-agents.md#lanes-for-everyone) */ lanes?: true; /** an email-gated (verified) Space */ gated?: true }
|
|
604
604
|
/** `wb.vault` — the vault this page runs in (docs: § Vault mode). The keys are there; this page never holds one. */
|
|
605
605
|
export declare class VaultSession {
|
|
606
606
|
/** The vault's origin. */
|
|
@@ -648,7 +648,7 @@ export declare class VaultSession {
|
|
|
648
648
|
/** The vault's lock changed (startVault({ lock: true })): whether this device can lock, whether it is on, whether stored data is sealed. */
|
|
649
649
|
on(event: 'lock', cb: (e: { lock: { available: boolean, on: boolean, protect: boolean } }) => void): () => void
|
|
650
650
|
/** The vault's notifications changed (startVault({ push: true })). */
|
|
651
|
-
on(event: 'push', cb: (e: { push:
|
|
651
|
+
on(event: 'push', cb: (e: { push: VaultPush }) => void): () => void
|
|
652
652
|
/** A notification was tapped: open this Space. */
|
|
653
653
|
on(event: 'notifOpen', cb: (e: { room: string }) => void): () => void
|
|
654
654
|
}
|