@witbitz/sdk 4.3.0 → 4.5.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 +41 -5
- package/accountErase.js +15 -4
- package/accountIndexDoc.js +24 -7
- package/accountRecord.js +6 -2
- package/accountStores.js +21 -5
- package/acctV2App.js +111 -12
- package/acctV2Client.js +11 -1
- package/acctV2UiCore.js +27 -7
- package/agentDoorTools.js +28 -0
- package/awsKey.js +3 -1
- package/backupRecord.js +3 -0
- package/chatLock.js +16 -0
- package/cloudDevicePins.js +2 -2
- package/codeAttachments.js +101 -0
- package/codeCache.js +173 -0
- package/codeCloud.js +2 -2
- package/codeComputers.js +9 -0
- package/codeFolders.js +116 -0
- package/codeHistory.js +76 -0
- package/codeLanguage.js +54 -0
- package/codeModes.js +2 -0
- package/codeProgress.js +54 -0
- package/codeSent.js +109 -0
- package/codeSubagents.js +107 -0
- package/codeTransport.js +46 -5
- package/connections.js +37 -20
- package/decrypt.html +69 -9
- package/deviceAttest.js +9 -3
- package/eraseFile.js +15 -0
- package/idb.js +19 -3
- package/idbSeal.js +5 -2
- package/inviteReceive.js +44 -0
- package/inviteSend.js +8 -2
- package/jobAgents.js +2 -2
- package/keptMerge.js +9 -2
- package/l1-worker-src.js +1 -1
- package/l1-worker.js +122 -43
- package/laneAssociation.js +78 -0
- package/laneConfig.js +4 -3
- package/laneLinkCore.js +9 -0
- package/ledgerView.js +30 -4
- package/manifest.json +112 -87
- package/memberChange.js +4 -2
- package/mirrorBatch.js +47 -0
- package/offlineBundle.js +21 -0
- package/opRouting.js +10 -0
- package/package.json +27 -2
- package/pdfOptions.js +13 -0
- package/pdfText.js +107 -0
- package/pdfjs.mjs +28 -0
- package/pdfjs.worker.mjs +28 -0
- package/protectedLocal.js +52 -13
- package/reactionHolders.js +86 -0
- package/removedMessage.js +1 -1
- package/roomEmbed.js +111 -0
- package/roomIntake.js +324 -0
- package/roomName.js +1 -1
- package/roomRoster.js +30 -7
- package/rosterCount.js +6 -3
- package/scheduleNext.js +60 -0
- package/sdkA2A.js +200 -42
- package/sdkAccount.js +88 -18
- package/sdkAccountDoc.js +13 -5
- package/sdkAccountSections.js +172 -23
- package/sdkAgui.js +33 -6
- package/sdkBackup.js +53 -11
- package/sdkBackupV2.js +15 -3
- package/sdkCloudDevice.js +20 -5
- package/sdkComputers.js +695 -65
- package/sdkDictation.js +115 -25
- package/sdkErase.js +12 -5
- package/sdkExports.js +19 -8
- package/sdkInvitations.js +4 -2
- package/sdkKeptAgent.js +19 -3
- package/sdkKeptIntake.js +100 -0
- package/sdkLaneLink.js +8 -9
- package/sdkPlan.js +4 -2
- package/sdkRekey.js +122 -22
- package/sdkReport.js +1 -1
- package/sdkSafeMedia.js +1 -1
- package/sdkSchedules.js +8 -1
- package/sdkSpeech.js +32 -2
- package/sdkTemporaryRooms.js +124 -0
- package/sdkTurn.js +12 -4
- package/sdkVault.js +66 -10
- package/sentinelRelease.js +1 -0
- package/sharedViews.js +34 -4
- package/siri.js +140 -9
- package/spaceClient.js +112 -17
- package/spaceEmailGate.js +2 -2
- package/spaceExport.js +50 -5
- package/spaceFork.js +15 -7
- package/spaceTemplates.js +99 -0
- package/speechOut.js +21 -5
- package/store.js +134 -27
- package/sw-notif-core.js +11 -8
- package/tapTrail.js +58 -0
- package/turnVerdict.js +1 -0
- package/usageReceipts.js +12 -5
- package/vault-core.js +568 -126
- package/vault-kit.mjs +3 -3
- package/vault-screens.js +30 -18
- package/vaultAtRest.js +38 -6
- package/vaultCoreLock.js +3 -1
- package/vaultCorePush.js +58 -7
- package/vaultKeep.js +9 -3
- package/vaultWorkerHost.js +32 -7
- package/witbitz-admin.d.ts +3 -0
- package/witbitz-admin.mjs +12 -11
- package/witbitz-sdk.d.ts +170 -43
- package/witbitz-sdk.js +833 -203
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.5.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
|
}
|
|
@@ -65,7 +65,7 @@ export function parseArgs(argv) {
|
|
|
65
65
|
export function headersFor({ page, endpoint = DEFAULTS.endpoint, loginBase = DEFAULTS.loginBase, enclaveClaim = DEFAULTS.enclaveClaim, accountService = DEFAULTS.accountService, authBroker = 'https://auth.witbitz.chat' }) {
|
|
66
66
|
const csp = [
|
|
67
67
|
"default-src 'self'", "script-src 'self' 'unsafe-inline'", "worker-src 'self' blob:", "style-src 'self' 'unsafe-inline'", "img-src 'self' data: blob:",
|
|
68
|
-
`connect-src 'self' ${[...new Set([originOf(endpoint), originOf(loginBase), originOf(enclaveClaim), originOf(accountService), originOf(authBroker)])].join(' ')}`,
|
|
68
|
+
`connect-src 'self' ${[...new Set([originOf(endpoint), originOf(loginBase), originOf(enclaveClaim), originOf(accountService), originOf(authBroker), 'wss://code-relay.witbitz.chat'])].join(' ')}`,
|
|
69
69
|
`frame-src ${originOf(page)}`, "frame-ancestors 'none'", "base-uri 'self'", "object-src 'none'", "form-action 'none'",
|
|
70
70
|
].join('; ')
|
|
71
71
|
// Cross-Origin-Opener-Policy: a page that opens the vault in a window gets no handle on it (docs/hosted-app-design.md §7, as
|
|
@@ -185,7 +185,7 @@ self.addEventListener('activate', (e) => e.waitUntil(self.clients.claim()))
|
|
|
185
185
|
// no read of its own: the push carries the sealed preview (opened with the room's notification key), else the generic line
|
|
186
186
|
self.wbxWirePush({ describe: async () => null, generic: { title: BRAND, body: 'Something new in your Spaces — open ' + BRAND + ' to see it.' }, testBody: 'You’ll get a nudge here when someone posts in your Spaces.', intakeBody: 'Your assistant has a new message — open ' + BRAND + ' to read it.' })
|
|
187
187
|
// a tap: the open vault is focused and told the room (it tells your page: wb.vault.on('notifOpen')); none open → the vault at ?room=…&tap=1
|
|
188
|
-
self.wbxWireNotifClick({ coldUrl: (room) => (room ? '/?room=' + encodeURIComponent(room) + '&tap=1' : '/'), stashTap:
|
|
188
|
+
self.wbxWireNotifClick({ coldUrl: (room) => (room ? '/?room=' + encodeURIComponent(room) + '&tap=1' : '/'), stashTap: true }) // stashed: a resuming vault that missed the post still opens it (vaultCorePush.js)
|
|
189
189
|
`
|
|
190
190
|
}
|
|
191
191
|
|
package/vault-screens.js
CHANGED
|
@@ -95,9 +95,9 @@ export function defaultScreens({ brand = 'this app', accent = '' } = {}) {
|
|
|
95
95
|
input.focus()
|
|
96
96
|
})
|
|
97
97
|
},
|
|
98
|
-
share({ link, title = '' }) {
|
|
98
|
+
share({ link, title = '', gated = null }) {
|
|
99
99
|
return new Promise((resolve) => {
|
|
100
|
-
const { c, close } = card(title ? 'Invite to ' + title : 'Invite someone', 'Anyone with this link can join. Send it only to people you mean to.')
|
|
100
|
+
const { c, close } = card(title ? 'Invite to ' + title : 'Invite someone', gated ? 'Only people on the room’s member list can join. They open the link and sign in.' : gated == null ? 'Send this invite to the people you want to join. The Space’s admission settings apply.' : 'Anyone with this link can join. Send it only to people you mean to.')
|
|
101
101
|
const input = el('input'); input.readOnly = true; input.value = link
|
|
102
102
|
const row = el('div', 'wbv-row'), done = el('button', 'wbv-btn', 'Done'), copy = el('button', 'wbv-btn wbv-go', 'Copy link')
|
|
103
103
|
row.append(done)
|
|
@@ -202,27 +202,39 @@ export function defaultScreens({ brand = 'this app', accent = '' } = {}) {
|
|
|
202
202
|
const row = el('div', 'wbv-row'), cancel = el('button', 'wbv-btn', 'Cancel'), go = el('button', 'wbv-btn wbv-go', merging ? 'Verify and save' : protecting ? 'Protect backup' : moving ? 'Move account' : 'Restore')
|
|
203
203
|
row.append(cancel, go); c.append(input, err, row)
|
|
204
204
|
let code = '', addr = email, ticket = '', step = 'code'
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
identity.onclick = async () => { identity.disabled = true; try { addr = String(await signIn() || ''); identity.textContent = addr ? 'Signed in as ' + addr : signInLabel } catch { err.textContent = 'Sign-in did not finish. Try again.' } finally { identity.disabled = false } }
|
|
209
|
-
}
|
|
205
|
+
// CODE FIRST (the owner, 2026-11-27: "The email is after we enter the recovery key"): no sign-in step in front of the code
|
|
206
|
+
// (30c5fb580 had put one here). The email is asked below, after the code, when the backup or the account service needs it;
|
|
207
|
+
// `signIn` / `signInLabel` are still accepted, for a builder's own screen that wants them.
|
|
210
208
|
cancel.onclick = () => { close(); reject(Object.assign(new Error('cancelled'), { code: 'cancelled' })) }
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
} catch (e) {
|
|
209
|
+
// GOOGLE AS THE EMAIL STEP (side sweep: builder-restore-missing-google): with Google on (signInLabel names it), a backup that
|
|
210
|
+
// asks for its email offered only the address field and an emailed code. "Continue with Google" signs in through the vault's
|
|
211
|
+
// own screen (signIn), and the restore is asked again with that sign-in — the vault proves the address with it (restoreBridge).
|
|
212
|
+
const google = typeof signIn === 'function' && /google/i.test(signInLabel) ? el('button', 'wbv-btn', 'Continue with Google') : null
|
|
213
|
+
if (google) { google.style.display = 'none'; c.insertBefore(google, row) }
|
|
214
|
+
const ask = (what, placeholder, type = 'text') => { step = what; input.value = ''; input.type = type; input.placeholder = placeholder; input.focus(); if (google) google.style.display = what === 'email' || what === 'emailCode' ? '' : 'none' }
|
|
215
|
+
const attempt = async (fn) => {
|
|
216
|
+
err.textContent = ''; go.disabled = true; cancel.disabled = true; if (google) google.disabled = true // no Cancel while a restore runs: it would go on and save (side sweep 2026-11-28)
|
|
217
|
+
try { await fn(); close(); resolve() } catch (e) { refused(e) }
|
|
218
|
+
go.disabled = false; cancel.disabled = false; if (google) google.disabled = false
|
|
219
|
+
}
|
|
220
|
+
if (google) google.onclick = () => attempt(async () => { const who = await signIn(); if (typeof who === 'string' && who) addr = who; await restore({ code, email: addr || undefined }) })
|
|
221
|
+
go.onclick = () => attempt(async () => {
|
|
222
|
+
if (step === 'code') code = input.value.trim()
|
|
223
|
+
else if (step === 'email') addr = input.value.trim()
|
|
224
|
+
await restore(step === 'emailCode' ? { code, email: addr, ticket, emailCode: input.value.trim() } : { code, email: addr || undefined })
|
|
225
|
+
})
|
|
226
|
+
const refused = (e) => {
|
|
227
|
+
{
|
|
220
228
|
const k = e && e.code
|
|
221
229
|
if (k === 'email_required') { c.querySelector('p').textContent = 'This backup also needs the email it was set up with.'; ask('email', 'you@example.com', 'email') }
|
|
222
230
|
else if (k === 'email_code_required') { ticket = e.ticket || ''; c.querySelector('p').textContent = 'We emailed a code to ' + addr + '.'; ask('emailCode', '6-digit code') }
|
|
223
|
-
else err.textContent = k === 'bad_code' || k === 'not_found' ? 'That recovery code did not open a backup.' : k === 'email_code_wrong' ? 'That email code did not work.'
|
|
231
|
+
else err.textContent = k === 'bad_code' || k === 'not_found' ? 'That recovery code did not open a backup.' : k === 'email_code_wrong' ? 'That email code did not work.'
|
|
232
|
+
// another app's backup: trying again here cannot help (side sweep 2026-11-28: both said "Try again")
|
|
233
|
+
: k === 'other_app' ? 'This backup was made by another app. Open the app that created it to restore it.'
|
|
234
|
+
: k === 'backup_app_unknown' ? 'The backup service cannot verify which app created this recovery code, so it was not restored.'
|
|
235
|
+
: k === 'cancelled' ? '' // the sign-in screen was closed: nothing to say
|
|
236
|
+
: 'The backup could not be restored. Try again.'
|
|
224
237
|
}
|
|
225
|
-
go.disabled = false
|
|
226
238
|
}
|
|
227
239
|
input.onkeydown = (e) => { if (e.key === 'Enter') go.click() }
|
|
228
240
|
input.focus()
|
package/vaultAtRest.js
CHANGED
|
@@ -79,10 +79,12 @@ export function holdsSealed (storage, { rooms, backup } = {}) {
|
|
|
79
79
|
return !!(b && typeof b === 'object' && !Array.isArray(b) && Object.values(b).some((v) => isSealed(v)))
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
export function createAtRest ({ storage, key }) {
|
|
82
|
+
export function createAtRest ({ storage, key, currentRoom = () => true }) {
|
|
83
83
|
let chain = Promise.resolve()
|
|
84
84
|
const onDisk = (fn) => { const p = chain.then(fn); chain = p.catch(() => {}); return p }
|
|
85
|
-
const sealedOf = new Map()
|
|
85
|
+
const sealedOf = new Map()
|
|
86
|
+
const snapshots = new Map()
|
|
87
|
+
const signature = rows => new Map(rows.map(r => [r.room, JSON.stringify(r)])) // room → { secret (JSON), ks } — an unchanged key is not sealed again on every save
|
|
86
88
|
// ⛔ AN ENTRY THIS KEY CANNOT OPEN (another key's, or no key at all: IndexedDB failed at start) is carried over AS IT IS on every
|
|
87
89
|
// save — read as keyless and written as `rest`, the next save erased its sealed key for good (review, 2026-11-13).
|
|
88
90
|
const unopened = new Map() // room → { href, ks }
|
|
@@ -115,13 +117,42 @@ export function createAtRest ({ storage, key }) {
|
|
|
115
117
|
const raw = read(storage, k)
|
|
116
118
|
const list = Array.isArray(raw) ? raw : []
|
|
117
119
|
const out = (await Promise.all(list.map(entryIn))).filter(Boolean)
|
|
120
|
+
snapshots.set(k, signature(out))
|
|
118
121
|
if (key && list.some((e) => e && typeof e.link === 'string' && splitLink(e.link))) this.saveRooms(k, out)
|
|
119
122
|
return out
|
|
120
123
|
},
|
|
121
124
|
/** Write the list — the links' keys sealed. In the order called; resolves once this one is on disk. */
|
|
122
|
-
saveRooms (k, rooms) {
|
|
125
|
+
saveRooms (k, rooms, strict = false, replaceAll = false) {
|
|
123
126
|
const snap = (Array.isArray(rooms) ? rooms : []).map((r) => ({ ...r }))
|
|
124
|
-
return onDisk(async () => {
|
|
127
|
+
return onDisk(async () => {
|
|
128
|
+
const encoded = await Promise.all(snap.map(entryOut))
|
|
129
|
+
const next = signature(snap)
|
|
130
|
+
const commit = () => {
|
|
131
|
+
const previous = snapshots.get(k)
|
|
132
|
+
const disk = read(storage, k)
|
|
133
|
+
const rows = new Map((Array.isArray(disk) ? disk : []).filter(currentRoom).map(r => [r.room, r]))
|
|
134
|
+
if (replaceAll || !previous) rows.clear()
|
|
135
|
+
else for (const [room, baseline] of previous) {
|
|
136
|
+
if (!next.has(room) && rows.get(room)?.forgetMark === JSON.parse(baseline).forgetMark) rows.delete(room)
|
|
137
|
+
}
|
|
138
|
+
for (const row of encoded) {
|
|
139
|
+
if (!currentRoom(row)) continue
|
|
140
|
+
const old = rows.get(row.room)
|
|
141
|
+
const migrating = key && old?.link && row.ks
|
|
142
|
+
if (replaceAll || !previous || previous.get(row.room) !== next.get(row.room) || migrating) rows.set(row.room, row)
|
|
143
|
+
}
|
|
144
|
+
const list = [...rows.values()]
|
|
145
|
+
const raw = JSON.stringify(list)
|
|
146
|
+
try {
|
|
147
|
+
storage.setItem(k, raw)
|
|
148
|
+
if (storage.getItem(k) !== raw) throw new Error('vault room list was not saved')
|
|
149
|
+
snapshots.set(k, next)
|
|
150
|
+
} catch (error) { if (strict) throw error }
|
|
151
|
+
}
|
|
152
|
+
const locks = globalThis.navigator?.locks
|
|
153
|
+
if (locks) await locks.request('witbitz:room-registry:' + k, commit)
|
|
154
|
+
else commit()
|
|
155
|
+
})
|
|
125
156
|
},
|
|
126
157
|
/** Every account's backup state (the vault's `wbvault:backup` = { email: state }), opened. */
|
|
127
158
|
async loadBackups (k) {
|
|
@@ -137,7 +168,8 @@ export function createAtRest ({ storage, key }) {
|
|
|
137
168
|
if (clear && key) for (const [email, s] of Object.entries(out)) if (isState(raw[email])) this.putBackup(k, email, s)
|
|
138
169
|
return out
|
|
139
170
|
},
|
|
140
|
-
/** Move
|
|
171
|
+
/** Move the signed-out ('') state to the signed-in account in one storage write: an email request, or a restore made before
|
|
172
|
+
* signing in — only when its email is this account's and the account has none of its own. */
|
|
141
173
|
claimEmailMove(k, email) {
|
|
142
174
|
const owner = String(email || '').trim().toLowerCase()
|
|
143
175
|
return onDisk(async () => {
|
|
@@ -145,7 +177,7 @@ export function createAtRest ({ storage, key }) {
|
|
|
145
177
|
if (!owner || !slot || before[owner]) return false
|
|
146
178
|
let draft = slot
|
|
147
179
|
if (isSealed(slot) && key) { try { draft = await open(key, slot) } catch { return false } }
|
|
148
|
-
if (!isState(draft) ||
|
|
180
|
+
if (!isState(draft) || String(draft.email || '').trim().toLowerCase() !== owner) return false
|
|
149
181
|
const all = read(storage, k)
|
|
150
182
|
if (!all || all[owner] || JSON.stringify(all['']) !== JSON.stringify(slot)) return false
|
|
151
183
|
delete all['']
|
package/vaultCoreLock.js
CHANGED
|
@@ -71,7 +71,9 @@ export function createVaultLock ({ brand = 'this app', mountUi, hide, show, onSt
|
|
|
71
71
|
// A PROTECTED device whose passkey is gone can never open its sealed copy: this origin starts over (the Spaces live in the
|
|
72
72
|
// account backup and the other devices)
|
|
73
73
|
startOver: async () => {
|
|
74
|
-
|
|
74
|
+
// never a promise of recovery: the sealed copy cannot be read, so nothing here can tell whether every Space is backed up — the
|
|
75
|
+
// same words as our own apps' Start over (side sweep 11-28)
|
|
76
|
+
if (!(await confirm({ title: 'Start over on this device?', text: 'This copy can’t be unlocked anymore, so it will be cleared. Only continue if you can open your Spaces on another device or restore them from a backup. Clearing the only copy permanently loses access to those Spaces.', ok: 'Start over', cancel: 'Cancel' }).catch(() => false))) return
|
|
75
77
|
localStorage.setItem(resetMarker, '1')
|
|
76
78
|
reload()
|
|
77
79
|
},
|
package/vaultCorePush.js
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
// The page learns { available, on } and, when a notification is tapped, which Space (`notifOpen`) — only one this vault holds.
|
|
13
13
|
import { swRegBounded, subscribeRobust } from './pushCore.js'
|
|
14
14
|
import { VAPID_PUBLIC_KEY } from './config.js'
|
|
15
|
+
import { watchForTap } from './tapTrail.js'
|
|
15
16
|
|
|
16
17
|
export const PUSH_KEY = 'wbvault:push' // { on, endpoint, rooms: [the Spaces this device is listed on] } — this device's setting
|
|
17
18
|
|
|
@@ -24,11 +25,12 @@ export const PUSH_KEY = 'wbvault:push' // { on, endpoint, rooms: [the Spaces thi
|
|
|
24
25
|
* @param {(room: string) => boolean} o.held
|
|
25
26
|
* @param {(room: string) => void} o.onOpen a tapped notification's Space (warm)
|
|
26
27
|
* @param {string} [o.worker] the service worker's path (default /push-sw.js, the kit's)
|
|
28
|
+
* @param {() => Promise<object|null>} [o.takeTap] reads AND clears the tap push-sw.js stashed (idb 'spaces'/'kv' notifTap)
|
|
27
29
|
*/
|
|
28
|
-
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) }) {
|
|
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 : '') }) {
|
|
29
31
|
const read = () => { try { const v = JSON.parse(storage.getItem(PUSH_KEY) || 'null'); return v && typeof v === 'object' ? v : { on: false } } catch { return { on: false } } }
|
|
30
32
|
const save = (v) => { try { storage.setItem(PUSH_KEY, JSON.stringify(v)) } catch { /* a full store: on for this session */ } }
|
|
31
|
-
let sub = null, chain = Promise.resolve()
|
|
33
|
+
let sub = null, chain = Promise.resolve(), unknown = false // unknown: on, and this start could not load the subscription
|
|
32
34
|
// KNOWN: start() has finished (a subscription loaded, or found off / unsupported). Until then this device's endpoint is NOT KNOWN —
|
|
33
35
|
// the account service must not be told "none" (Codex sweep 2026-11-16 #2). `changed` runs after every change of it.
|
|
34
36
|
let readyOk = null
|
|
@@ -41,6 +43,11 @@ export function createVaultPush ({ storage, subscribe, unsubscribe, setSelf, hel
|
|
|
41
43
|
// what an unsubscribe names: the live subscription, else the endpoint this device was listed under (the server drops by endpoint) —
|
|
42
44
|
// a revoked permission or a missing worker must not leave every Space tickling a device that turned notifications off (review)
|
|
43
45
|
const named = (st) => (sub ? json(sub) : st && st.endpoint ? { endpoint: st.endpoint } : null)
|
|
46
|
+
// the subscription this browser already has for the kit's worker, if any (bounded: iOS can stall a push call) — never a new one
|
|
47
|
+
const liveSub = () => Promise.race([(async () => {
|
|
48
|
+
const reg = nav && nav.serviceWorker && typeof nav.serviceWorker.getRegistration === 'function' ? await nav.serviceWorker.getRegistration(worker) : null
|
|
49
|
+
return (reg && reg.pushManager && (await reg.pushManager.getSubscription())) || null
|
|
50
|
+
})().catch(() => null), new Promise((r) => setTimeout(() => r(null), 3000))])
|
|
44
51
|
// ⛔ A SPACE IS TAKEN OFF ITS LIST ONLY WHEN THE SERVER SAYS SO (review, 2026-11-13): a failed unsubscribe (offline) is kept in
|
|
45
52
|
// `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).
|
|
46
53
|
// → whether it is settled (taken off, or refused for good by the server).
|
|
@@ -58,16 +65,36 @@ export function createVaultPush ({ storage, subscribe, unsubscribe, setSelf, hel
|
|
|
58
65
|
save({ ...read(), rooms: [...had], ...(st.off ? { off: st.off } : {}) })
|
|
59
66
|
})
|
|
60
67
|
}
|
|
68
|
+
// ONE OPEN PER TAP: the worker's message and its stash (below) name the same tap; a cold tap is the address's (vault-core's welcome)
|
|
69
|
+
let last = { room: '', at: 0 }
|
|
70
|
+
const open = (room) => { if (!room || !held(room) || (room === last.room && Date.now() - last.at < 10000)) return; last = { room, at: Date.now() }; onOpen(room) }
|
|
61
71
|
try { // a TAP on a warm vault: sw-notif-core focuses this window and posts the room
|
|
62
72
|
nav && nav.serviceWorker && nav.serviceWorker.addEventListener('message', (e) => {
|
|
63
73
|
const d = e && e.data
|
|
64
|
-
if (d && d.ch === 'notif-open' && typeof d.room === 'string' && d.room
|
|
74
|
+
if (d && d.ch === 'notif-open' && typeof d.room === 'string' && d.room) { open(d.room); takeTap().catch(() => {}) } // this tap's stash is spent
|
|
65
75
|
})
|
|
66
76
|
} catch { /* no service workers here */ }
|
|
77
|
+
// …and when a resuming page MISSED that message (iOS drops it to a waking app), the tap push-sw.js stashed: read on each return to the
|
|
78
|
+
// screen, as our hosted vault does (side sweep 2026-11-28: a warm tap left the builder's page on its previous Space). A cold tap's
|
|
79
|
+
// stash is the address's tap, already in the welcome: dropped, not opened again.
|
|
80
|
+
const coldTap = (() => { try { const q = new URLSearchParams(search || ''); return q.get('tap') === '1' ? String(q.get('room') || '') : '' } catch { return '' } })()
|
|
81
|
+
const checkTap = async (cold) => {
|
|
82
|
+
const v = await takeTap().catch(() => null)
|
|
83
|
+
if (!v || typeof v.room !== 'string' || !v.room || !(Date.now() - Number(v.at) < 90000)) return false
|
|
84
|
+
// the stash of a tap the worker's message already opened (it may be written a beat after): never reopened later (review 11-28:
|
|
85
|
+
// the person moved on, came back within 90 s, and was taken back to the tapped Space)
|
|
86
|
+
if (v.room === last.room && Number(v.at) <= last.at) return true
|
|
87
|
+
if (cold) { if (v.room === coldTap) return true; last = { room: '', at: 0 } }
|
|
88
|
+
open(v.room)
|
|
89
|
+
return true
|
|
90
|
+
}
|
|
91
|
+
if (coldTap) { last = { room: coldTap, at: Date.now() }; checkTap(true) }
|
|
92
|
+
const watch = watchForTap(() => checkTap(false), { forMs: 5000 }) // for a few seconds: the worker stashes a beat after it routed
|
|
93
|
+
try { doc && doc.addEventListener('visibilitychange', () => { if (doc.visibilityState === 'visible') watch.start() }) } catch { /* */ }
|
|
67
94
|
return {
|
|
68
95
|
view,
|
|
69
96
|
sync,
|
|
70
|
-
endpoint: () => (sub ? sub.endpoint : ''),
|
|
97
|
+
endpoint: () => (sub ? sub.endpoint : unknown ? undefined : ''), // undefined: not known (on, but not loaded) — never reported as none
|
|
71
98
|
/** Resolves once start() knows this device's endpoint (or that there is none). */
|
|
72
99
|
ready,
|
|
73
100
|
/** A Space about to be forgotten: off its list NOW, while the key worker still holds its key (after, the request has none). */
|
|
@@ -94,7 +121,10 @@ export function createVaultPush ({ storage, subscribe, unsubscribe, setSelf, hel
|
|
|
94
121
|
save({ ...read(), off })
|
|
95
122
|
})
|
|
96
123
|
try { await nav.serviceWorker.register(worker); const r = await subscribeRobust(await swRegBounded({ path: worker, sw: nav.serviceWorker }), VAPID_PUBLIC_KEY); sub = r.sub } catch { sub = null }
|
|
97
|
-
|
|
124
|
+
// ON, but the subscription could not be loaded this time: its address is UNKNOWN, not "none" — the account service would
|
|
125
|
+
// clear the stored address of a subscription that may well still be live (side sweep 2026-11-28)
|
|
126
|
+
if (!sub) { unknown = true; return }
|
|
127
|
+
unknown = false
|
|
98
128
|
setSelf(sub.endpoint)
|
|
99
129
|
if (sub.endpoint !== read().endpoint) save({ ...read(), endpoint: sub.endpoint, rooms: [] }) // a new subscription: every Space lists it again
|
|
100
130
|
return sync(rooms)
|
|
@@ -108,7 +138,7 @@ export function createVaultPush ({ storage, subscribe, unsubscribe, setSelf, hel
|
|
|
108
138
|
const reg = await swRegBounded({ path: worker, sw: nav.serviceWorker })
|
|
109
139
|
const r = await subscribeRobust(reg, VAPID_PUBLIC_KEY)
|
|
110
140
|
if (!r.sub) throw Object.assign(new Error('vault: the push service did not answer — ' + r.err), { code: 'push_unavailable' })
|
|
111
|
-
sub = r.sub; setSelf(sub.endpoint)
|
|
141
|
+
sub = r.sub; unknown = false; setSelf(sub.endpoint)
|
|
112
142
|
save({ on: true, endpoint: sub.endpoint, rooms: [] })
|
|
113
143
|
await sync(rooms, { loud: true })
|
|
114
144
|
changed()
|
|
@@ -117,10 +147,12 @@ export function createVaultPush ({ storage, subscribe, unsubscribe, setSelf, hel
|
|
|
117
147
|
/** Off: every Space takes this device off its list, then the subscription goes. */
|
|
118
148
|
async disable () {
|
|
119
149
|
await serial(async () => {
|
|
150
|
+
// before start() loaded it (a sign-out resumed at launch): the browser's live subscription, looked up — never made (side sweep round 2)
|
|
151
|
+
if (!sub) sub = await liveSub()
|
|
120
152
|
const st = read(), s = named(st), off = []
|
|
121
153
|
for (const r of [...(Array.isArray(st.rooms) ? st.rooms : []), ...(Array.isArray(st.off) ? st.off.map((o) => o && o.room) : [])].filter(Boolean)) if (!(await takeOff(r, s))) off.push({ room: r, n: 0 })
|
|
122
154
|
try { if (sub) await sub.unsubscribe() } catch { /* the push service forgets it on its own */ }
|
|
123
|
-
sub = null; setSelf('')
|
|
155
|
+
sub = null; unknown = false; setSelf('')
|
|
124
156
|
save(off.length && st.endpoint ? { on: false, endpoint: st.endpoint, off } : { on: false }) // what could not be reached is tried again at the next start
|
|
125
157
|
})
|
|
126
158
|
changed()
|
|
@@ -138,3 +170,22 @@ export function createVaultPush ({ storage, subscribe, unsubscribe, setSelf, hel
|
|
|
138
170
|
},
|
|
139
171
|
}
|
|
140
172
|
}
|
|
173
|
+
|
|
174
|
+
// The tap push-sw.js stashed (sw-notif-core wbxWireNotifClick, stashTap) — read and cleared in one transaction; bounded like the worker's own reads.
|
|
175
|
+
function takeStashedTap () {
|
|
176
|
+
return new Promise((resolve) => {
|
|
177
|
+
const t = setTimeout(() => resolve(null), 2500)
|
|
178
|
+
try {
|
|
179
|
+
const r = indexedDB.open('spaces', 1)
|
|
180
|
+
r.onupgradeneeded = () => { try { r.result.createObjectStore('kv') } catch { /* */ } }
|
|
181
|
+
r.onerror = () => { clearTimeout(t); resolve(null) }
|
|
182
|
+
r.onsuccess = () => {
|
|
183
|
+
try {
|
|
184
|
+
const os = r.result.transaction('kv', 'readwrite').objectStore('kv'), g = os.get('notifTap')
|
|
185
|
+
g.onsuccess = () => { clearTimeout(t); const v = g.result; if (v) { try { os.delete('notifTap') } catch { /* */ } } resolve(v || null) }
|
|
186
|
+
g.onerror = () => { clearTimeout(t); resolve(null) }
|
|
187
|
+
} catch { clearTimeout(t); resolve(null) }
|
|
188
|
+
}
|
|
189
|
+
} catch { clearTimeout(t); resolve(null) }
|
|
190
|
+
})
|
|
191
|
+
}
|
package/vaultKeep.js
CHANGED
|
@@ -70,7 +70,7 @@ export function stampKeep (prev, cur, now = Date.now()) {
|
|
|
70
70
|
// and its Spaces never come back from a copy made before the delete.
|
|
71
71
|
const was = (p.siri && p.siri.state && p.siri.state.rooms) || {}
|
|
72
72
|
const off = Object.fromEntries(Object.keys(was).filter((r) => !(siri.rooms || {})[r]).map((r) => [r, Math.max(now, num(Number(was[r] && was[r].at)) + 1)]))
|
|
73
|
-
const gone = unionMarks(p.siri && p.siri.gone, off), rev = num(Number(p.siri && p.siri.rev)) + (blank && p.siri ? 1 : 0)
|
|
73
|
+
const gone = unionMarks(p.siri && p.siri.gone, off), rev = Math.max(num(Number(siri.rev)), num(Number(p.siri && p.siri.rev)) + (blank && p.siri ? 1 : 0))
|
|
74
74
|
out.siri = { at: now, state: siri, ...(Object.keys(gone).length ? { gone } : {}), ...(rev ? { rev } : {}) }
|
|
75
75
|
}
|
|
76
76
|
return out
|
|
@@ -109,7 +109,7 @@ function siriEntry (x, y) {
|
|
|
109
109
|
const lead = atRev[0] ? atRev[0].state : { token: '', defaultRoom: '' }
|
|
110
110
|
const keyOf = (e) => ({ token: e.state ? e.state.token : '', rev: e.rev })
|
|
111
111
|
const def = siriDefaultOf(rooms, ...atRev.map((e) => e.state.defaultRoom))
|
|
112
|
-
return { at: Math.max(num(x.at), num(y.at)), state: { ...lead, token: siriKeyOf(keyOf(base), keyOf(other)), defaultRoom: def, rooms }, ...(Object.keys(gone).length ? { gone } : {}), ...(rev ? { rev } : {}) }
|
|
112
|
+
return { at: Math.max(num(x.at), num(y.at)), state: { ...lead, ...(rev ? { rev } : {}), token: siriKeyOf(keyOf(base), keyOf(other)), defaultRoom: def, rooms }, ...(Object.keys(gone).length ? { gone } : {}), ...(rev ? { rev } : {}) }
|
|
113
113
|
}
|
|
114
114
|
/** The union of two views, the newer of each entry kept (a lane and Siri: merged by their parts). Pure — the whole agreement between devices is here. */
|
|
115
115
|
export function mergeKeep (a, b) {
|
|
@@ -150,7 +150,7 @@ export function appToKeep (doc) {
|
|
|
150
150
|
const s = obj(d.siri), { at: sAt, gone, rev, ...st } = s
|
|
151
151
|
const marks = unionMarks(gone, null), r = num(Number(rev))
|
|
152
152
|
const siri = (st.token || Object.keys(obj(st.rooms)).length || Object.keys(marks).length || r)
|
|
153
|
-
? { at: num(Number(sAt)), state: { token: typeof st.token === 'string' ? st.token : '', defaultRoom: typeof st.defaultRoom === 'string' ? st.defaultRoom : '', rooms: obj(st.rooms) }, ...(Object.keys(marks).length ? { gone: marks } : {}), ...(r ? { rev: r } : {}) }
|
|
153
|
+
? { at: num(Number(sAt)), state: { ...(r ? { rev: r } : {}), token: typeof st.token === 'string' ? st.token : '', defaultRoom: typeof st.defaultRoom === 'string' ? st.defaultRoom : '', rooms: obj(st.rooms) }, ...(Object.keys(marks).length ? { gone: marks } : {}), ...(r ? { rev: r } : {}) }
|
|
154
154
|
: null
|
|
155
155
|
return { keep: { v: 1, conns, a2a, siri }, laneGone: unionMarks(obj(d.a2a).gone, null) }
|
|
156
156
|
}
|
|
@@ -213,6 +213,11 @@ export async function syncKeep ({ loc, client, prev, cur, now = Date.now }) {
|
|
|
213
213
|
if (!(sx == null || (typeof sx === 'object' && !Object.keys(sx).length))) { try { x.doc = await openDoc(loc.app, sx) } catch { return { ok: false, why: 'unopenable', keep: local, own } } }
|
|
214
214
|
}
|
|
215
215
|
const fromApp = x ? appToKeep(x.doc) : null
|
|
216
|
+
for (const [id, at] of Object.entries(cur?.connGone || {})) {
|
|
217
|
+
if (!Number.isFinite(at) || at <= 0) continue
|
|
218
|
+
const observed = Math.max(Number(remote?.conns?.[id]?.at) || 0, Number(fromApp?.keep?.conns?.[id]?.at) || 0)
|
|
219
|
+
local.conns[id] = { at: Math.max(at, observed + 1), gone: true }
|
|
220
|
+
}
|
|
216
221
|
const merged = fromApp ? dropGoneLanes(mergeKeep(mergeKeep(local, remote), fromApp.keep), fromApp.laneGone) : mergeKeep(local, remote)
|
|
217
222
|
// DUAL WRITE: the keep's own doc for every older kit, then the app's; each only when it differs from what it holds, each over
|
|
218
223
|
// the version read. A 409 on either reads both and merges again; a failed save on either is a pass that did not save.
|
|
@@ -249,6 +254,7 @@ export function tabStores (st, keys) {
|
|
|
249
254
|
|
|
250
255
|
// What a vault holds, in one comparable shape: the connections by id (their order is not a change), Siri, the lanes.
|
|
251
256
|
const heldOf = (c) => ({
|
|
257
|
+
connGone: c?.connGone || {},
|
|
252
258
|
conns: Object.fromEntries(((c && c.conns) || []).filter((x) => x && x.id).map((x) => [String(x.id), x])),
|
|
253
259
|
siri: (c && c.siri) || null,
|
|
254
260
|
a2a: (c && c.a2a && c.a2a.lanes) || {},
|
package/vaultWorkerHost.js
CHANGED
|
@@ -27,22 +27,28 @@ import { createLiveness } from './workerLiveness.js'
|
|
|
27
27
|
export function createWorkerHost ({ make, onMessage = () => {}, onCurrent = () => {}, onRestart = () => {}, onRestarted = () => {}, graceMs = 5000, beatMs = 25000, timers = globalThis, doc = typeof document !== 'undefined' ? document : null } = {}) {
|
|
28
28
|
if (typeof make !== 'function') throw new Error('createWorkerHost: make() is required')
|
|
29
29
|
let worker = null
|
|
30
|
+
let recover = false
|
|
30
31
|
let started = Promise.resolve()
|
|
31
32
|
const steps = []
|
|
32
33
|
const set = (w) => { worker = w; try { onCurrent(w) } catch { /* the caller's mirror; never stops the host */ } }
|
|
33
34
|
function runReplay (w) {
|
|
34
35
|
let chain = null
|
|
36
|
+
// A STEP WHOSE PROMISE REJECTS is a step that throws (side sweep: builder-worker-replay-failure-blocks-room-reads): an unseal error
|
|
37
|
+
// skipped every later step and every room read awaited the same rejection — and the worker still answered pings, so nothing retried.
|
|
38
|
+
// (The worker writes no clear key over a store it could not open: l1-worker.js persist.)
|
|
39
|
+
const settle = (r) => Promise.resolve(r).catch(() => undefined)
|
|
35
40
|
for (const { step } of steps) {
|
|
36
|
-
if (chain) { chain = chain.then(() => (worker === w ? step(w) : undefined)); continue }
|
|
41
|
+
if (chain) { chain = chain.then(() => (worker === w ? settle((() => { try { return step(w) } catch { return undefined } })()) : undefined)); continue }
|
|
37
42
|
let r
|
|
38
43
|
try { r = step(w) } catch { r = undefined } // one step that throws never keeps the others from a new worker
|
|
39
|
-
if (r && typeof r.then === 'function') chain =
|
|
44
|
+
if (r && typeof r.then === 'function') chain = settle(r)
|
|
40
45
|
}
|
|
41
46
|
return chain || Promise.resolve()
|
|
42
47
|
}
|
|
43
48
|
function make1 () {
|
|
44
49
|
const w = make()
|
|
45
50
|
set(w)
|
|
51
|
+
recover = false
|
|
46
52
|
w.onmessage = (ev) => {
|
|
47
53
|
const m = (ev && ev.data) || {}
|
|
48
54
|
if (m.t === 'pong') { live.pong(m.n); return } // the heartbeat's answer
|
|
@@ -68,7 +74,9 @@ export function createWorkerHost ({ make, onMessage = () => {}, onCurrent = () =
|
|
|
68
74
|
if (at >= 0) steps[at] = { name, step }; else steps.push({ name, step })
|
|
69
75
|
return host
|
|
70
76
|
},
|
|
71
|
-
|
|
77
|
+
// after a restart whose new worker failed to start, the worker a call makes is that restart's: the frames are told, as restart() does
|
|
78
|
+
// (side sweep 2026-11-28: it was made and replayed, but nobody handed back the keys only memory held)
|
|
79
|
+
ensure () { if (worker) return worker; const was = recover; const w = make1(); if (was) { try { onRestarted(w) } catch { /* */ } } return w },
|
|
72
80
|
async ready () {
|
|
73
81
|
const current = worker
|
|
74
82
|
await started
|
|
@@ -77,15 +85,15 @@ export function createWorkerHost ({ make, onMessage = () => {}, onCurrent = () =
|
|
|
77
85
|
},
|
|
78
86
|
start () { terminate(); make1(); return started },
|
|
79
87
|
restart () {
|
|
80
|
-
if (!worker) return // dropped (signed out): nothing to bring back
|
|
88
|
+
if (!worker && !recover) return // dropped (signed out): nothing to bring back
|
|
81
89
|
try { onRestart() } catch { /* */ }
|
|
82
90
|
terminate()
|
|
83
91
|
let w
|
|
84
|
-
try { w = make1() } catch { return } // the next beat tries again
|
|
92
|
+
try { w = make1() } catch { recover = true; return } // the next beat tries again
|
|
85
93
|
try { onRestarted(w) } catch { /* */ }
|
|
86
94
|
},
|
|
87
|
-
drop () { terminate() },
|
|
88
|
-
tick () { if (worker) live.tick() },
|
|
95
|
+
drop () { recover = false; terminate() },
|
|
96
|
+
tick () { if (worker) live.tick(); else if (recover && !doc?.hidden) host.restart() },
|
|
89
97
|
pong: (n) => live.pong(n),
|
|
90
98
|
}
|
|
91
99
|
try {
|
|
@@ -96,3 +104,20 @@ export function createWorkerHost ({ make, onMessage = () => {}, onCurrent = () =
|
|
|
96
104
|
} catch { /* no timers */ }
|
|
97
105
|
return host
|
|
98
106
|
}
|
|
107
|
+
|
|
108
|
+
/** Each frame owns at most one holder per room on each worker generation. */
|
|
109
|
+
export function workerStreams() {
|
|
110
|
+
const sent = new WeakMap()
|
|
111
|
+
return (worker, room, open) => {
|
|
112
|
+
if (!worker || !room) return
|
|
113
|
+
if (!sent.has(worker)) sent.set(worker, new Set())
|
|
114
|
+
const rooms = sent.get(worker)
|
|
115
|
+
if (open && !rooms.has(room)) {
|
|
116
|
+
worker.postMessage(open)
|
|
117
|
+
rooms.add(room)
|
|
118
|
+
} else if (!open && rooms.has(room)) {
|
|
119
|
+
worker.postMessage({ t: 'streamClose', room })
|
|
120
|
+
rooms.delete(room)
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
package/witbitz-admin.d.ts
CHANGED
|
@@ -71,6 +71,9 @@ export interface Billing {
|
|
|
71
71
|
requireUserToken(on?: boolean): Promise<{ requireUserToken: boolean }>
|
|
72
72
|
/** Questions a day people who are not signed in may ask in your rooms — per network and in total; null turns it off (sdk-builder.md#visitor-limits). */
|
|
73
73
|
visitorLimit(limit: { perNetwork: number; total: number } | null): Promise<{ visitorLimit: { perNetwork: number; total: number } | null }>
|
|
74
|
+
/** The same as CSV text. Columns: `day,provider_usd,would_have_cost_usd,charged_usd,storage_bytes,from_day,span_days`, or with
|
|
75
|
+
* `{ byUser: true }` one line per user per day: `day,user_id,user_ref,provider_usd,would_have_cost_usd,charged_usd,from_day,span_days`.
|
|
76
|
+
* `from_day`/`span_days`: the days a line covers — after a missed daily reading one line holds several days' use (a one-day line: its own day, 1). */
|
|
74
77
|
csv(opts?: { byUser?: boolean }): Promise<string>
|
|
75
78
|
/** Your prepaid balance, or null when your app is not on prepaid billing. While `paused`, every op that spends in your rooms is refused (402 tenant_out_of_credit). */
|
|
76
79
|
/** `canBuy`: whether buying credit is open to your app now (while it is in testing, only to the apps in the test) — when false, topUp is refused.
|
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.5.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.5.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.5.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.5.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.5.0/sentinelRelease.js
|
|
650
650
|
var BUILD_ENCLAVE_PCR0 = Object.freeze([
|
|
651
|
+
"c6a8cbd0c05d8e003e75b266f1dde2a6426b7cd61f845e4b128e59063e40968b44f30d934bbe1925582fe33bbdd0b1d7",
|
|
651
652
|
"f490096d57e4287146e8b8d7bf4c75f423984ca52199efab0ee8684fbee6cfe6ab82c72d54f05a38f24a0d4ad6e2f557",
|
|
652
653
|
"41ec7e0e54beac5759fba7efa06c48081dbd96c7299c29c92a9c619036ce057cec357ad4ad71a165d7f881df120b043b",
|
|
653
654
|
"9f0801335a952bdbac70b6793150738d7ce30bc3a0d520fec6f573de22a822aa5ef762f78648bc8608ca0b2eeccda556",
|
|
@@ -793,7 +794,7 @@ async function recordPcrBy(r, subject, builders, verify = verifyAttestation) {
|
|
|
793
794
|
return { pcr0, builder };
|
|
794
795
|
}
|
|
795
796
|
|
|
796
|
-
// spaces/public/sdk/4.
|
|
797
|
+
// spaces/public/sdk/4.5.0/sealShare.js
|
|
797
798
|
var enc2 = new TextEncoder();
|
|
798
799
|
var b64 = (u8) => btoa(String.fromCharCode(...new Uint8Array(u8)));
|
|
799
800
|
async function sealTo(enclaveKey, nonce, bundle) {
|
|
@@ -807,14 +808,14 @@ async function sealTo(enclaveKey, nonce, bundle) {
|
|
|
807
808
|
return { epk: b64(epk), iv: b64(iv), ct: b64(ct), nonce: b64(nonce) };
|
|
808
809
|
}
|
|
809
810
|
|
|
810
|
-
// spaces/public/sdk/4.
|
|
811
|
+
// spaces/public/sdk/4.5.0/connDisp.js
|
|
811
812
|
var enc3 = new TextEncoder();
|
|
812
813
|
var dec = new TextDecoder();
|
|
813
814
|
var SALT = enc3.encode("witbitz-sentinel-display-v1");
|
|
814
815
|
var INFO = enc3.encode("sentinel-display");
|
|
815
816
|
|
|
816
|
-
// spaces/public/sdk/4.
|
|
817
|
-
var STANDING_SENTINEL_PCR0 = ["1903ce28fc5a75efe2e57a451d667f1ce8b4b6e11872fb2b81d9e62d8cd994ed80fcfa99807f289af5f281aa4e4cc010"
|
|
817
|
+
// spaces/public/sdk/4.5.0/connections.js
|
|
818
|
+
var STANDING_SENTINEL_PCR0 = ["1903ce28fc5a75efe2e57a451d667f1ce8b4b6e11872fb2b81d9e62d8cd994ed80fcfa99807f289af5f281aa4e4cc010"];
|
|
818
819
|
var b642 = (u8) => btoa(String.fromCharCode(...new Uint8Array(u8)));
|
|
819
820
|
var unb642 = (s) => Uint8Array.from(atob(s), (c) => c.charCodeAt(0));
|
|
820
821
|
var ConnectionError = class extends Error {
|
|
@@ -927,7 +928,7 @@ async function attestStandingSentinel({ post, auth = {}, pins = STANDING_SENTINE
|
|
|
927
928
|
}
|
|
928
929
|
var MCP_CURATED = CATALOG.filter((c) => c.url).map((c) => ({ label: c.name, url: c.url }));
|
|
929
930
|
|
|
930
|
-
// spaces/public/sdk/4.
|
|
931
|
+
// spaces/public/sdk/4.5.0/sdkRedact.js
|
|
931
932
|
var REDACTED = "[REDACTED]";
|
|
932
933
|
var INSPECT = /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom");
|
|
933
934
|
function hide(obj, names) {
|
|
@@ -952,7 +953,7 @@ function redacted(proto, summary) {
|
|
|
952
953
|
});
|
|
953
954
|
}
|
|
954
955
|
|
|
955
|
-
// spaces/public/sdk/4.
|
|
956
|
+
// spaces/public/sdk/4.5.0/witbitz-admin.js
|
|
956
957
|
var adminError = (code, message) => Object.assign(new Error(message), { code: String(code || "refused") });
|
|
957
958
|
var DEFAULT_ENDPOINT = "https://api.witbitz.chat/v1/space";
|
|
958
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)");
|