@witbitz/sdk 4.6.0 → 4.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/acctV2Switch.js +3 -2
- package/acctV2UiCore.js +2 -2
- package/codeBrowse.js +3 -3
- package/codeCache.js +4 -3
- package/codeCloud.js +4 -0
- package/earlierHistory.js +32 -0
- package/emailFork.js +3 -1
- package/l1-worker-src.js +1 -1
- package/manifest.json +24 -22
- package/memberChange.js +9 -2
- package/package.json +4 -2
- package/roomRoles.js +116 -0
- package/roomRoster.js +4 -1
- package/sdkA2A.js +2 -2
- package/sdkBackup.js +1 -0
- package/sdkComputers.js +1 -0
- package/sdkExports.js +11 -3
- package/sdkRekey.js +51 -4
- package/spaceClient.js +6 -3
- package/vault-core.js +51 -28
- package/vault-kit.mjs +1 -1
- package/witbitz-admin.mjs +10 -10
- package/witbitz-sdk.d.ts +20 -6
- package/witbitz-sdk.js +101 -16
package/README.md
CHANGED
|
@@ -16,6 +16,6 @@ The guide: https://witbitz.chat/docs/sdk
|
|
|
16
16
|
|
|
17
17
|
## The same bytes as the hosted release
|
|
18
18
|
|
|
19
|
-
Version 4.
|
|
20
|
-
`
|
|
19
|
+
Version 4.7.0 of this package is the release folder https://witbitz.chat/sdk/4.7.0/ unchanged (from commit
|
|
20
|
+
`a98d5ae3b3fceb654ceed8264e49babac09f8d62`), plus this README, `package.json` and `LICENSE`. Its `manifest.json` lists the sha384 of every file; each file in the
|
|
21
21
|
package matches it.
|
package/acctV2Switch.js
CHANGED
|
@@ -50,9 +50,10 @@ export function prodSwitch(loc = globalThis.location, storage = globalThis.local
|
|
|
50
50
|
// made on the new service stay on it.
|
|
51
51
|
export const NEW_ACCOUNTS_ON_V2 = true
|
|
52
52
|
/** Where a NEW account made here starts: the new service's address, or '' (the old service, as before). The production
|
|
53
|
-
* regular app and the production vault (the hosted app's v2 client runs there — acctV2VaultWiring.js); the staging app
|
|
54
|
-
*
|
|
53
|
+
* regular app and the production vault (the hosted app's v2 client runs there — acctV2VaultWiring.js); the staging app uses
|
|
54
|
+
* the staging service by default. A device switched off (?acctv2=off) stays off. */
|
|
55
55
|
export function newAccountService({ host, stored, releaseOn = NEW_ACCOUNTS_ON_V2 }) {
|
|
56
|
+
if (host === STAGING_APP) return stored === 'off' ? '' : STAGING_SERVICE
|
|
56
57
|
if (host === PROD_VAULT && stored !== 'off') return releaseOn ? PROD_SERVICE : '' // the hosted app: its vault
|
|
57
58
|
if (host !== PROD_APP || stored === 'off') return ''
|
|
58
59
|
if (stored === PROD_SERVICE) return PROD_SERVICE
|
package/acctV2UiCore.js
CHANGED
|
@@ -48,7 +48,7 @@ const MESSAGES = {
|
|
|
48
48
|
attestation_refused: 'That key can’t be used for Advanced Backup. It must be a YubiKey with a PIN (or fingerprint) set up.',
|
|
49
49
|
advanced_not_enabled: 'Advanced Backup isn’t available yet.',
|
|
50
50
|
possession_pending: 'Set up your recovery code first.',
|
|
51
|
-
email_only: 'This
|
|
51
|
+
email_only: 'This action is unavailable because the old backup was moved using email alone.',
|
|
52
52
|
too_many_keys: 'This account already has the most security keys it can hold (5).',
|
|
53
53
|
no_other_key: 'Removing a key needs another of your keys to confirm it.',
|
|
54
54
|
keys_mismatch: 'The service answered with keys this device didn’t register. Nothing was changed.',
|
|
@@ -569,7 +569,7 @@ async function moveAccount(rerender, { auto = false } = {}) {
|
|
|
569
569
|
else { try { others = dep().afterMove ? await dep().afterMove({ trust: r.legacy_trust }) : null } catch { others = null } }
|
|
570
570
|
const emailOnly = r.legacy_trust === 'email_only'
|
|
571
571
|
await notice('Done. This account now uses the new account service, with the same recovery code.'
|
|
572
|
-
+ (emailOnly ? '\n\nIt was moved with your email only (its old backup had no account key),
|
|
572
|
+
+ (emailOnly ? '\n\nIt was moved with your email only (its old backup had no account key), and the original backup is kept as it was for a year.' : '')
|
|
573
573
|
+ (others && others.unconfirmed ? '\n\nThis device could not confirm that your other devices were told to sign out. If one still shows your Spaces, sign it out from Settings → Your devices on this device.'
|
|
574
574
|
: r.silent ? '\n\nYour other devices join it by themselves the next time they open.'
|
|
575
575
|
: Array.isArray(others) && !others.length ? '' : '\n\nYour other devices are being signed out: each clears itself the next time it’s online and says why. To use one again, restore your Spaces on it with your recovery code, or add it from this device (Add a device).'))
|
package/codeBrowse.js
CHANGED
|
@@ -39,9 +39,9 @@ export function browseRow (report, cloud, egress, { session = '' } = {}) {
|
|
|
39
39
|
if (!watch) return null // no key on this computer: there is nothing to open, so there is nothing to say
|
|
40
40
|
// ★ A BROWSER PER SESSION (the owner, 2026-11-29: "when you see the browser is open in one session it could show it is
|
|
41
41
|
// closed in another. The state is completely separate"). A computer that says `perSession` reports each session's browser
|
|
42
|
-
// in `sessions`; only THIS session's entry decides here. An older
|
|
43
|
-
const per = !!
|
|
44
|
-
const mine = per && /^[A-Za-z0-9_-]{1,128}$/.test(String(session || '')) ? report.sessions[session] : null
|
|
42
|
+
// in `sessions`; only THIS session's entry decides here. An older connector or image has one browser: `running`, as before.
|
|
43
|
+
const per = !!report.perSession
|
|
44
|
+
const mine = per && /^[A-Za-z0-9_-]{1,128}$/.test(String(session || '')) ? report.sessions?.[session] : null
|
|
45
45
|
const running = per ? !!(mine && mine.open) : !!report.running
|
|
46
46
|
// the controls are held PER SESSION (the owner, 2026-11-29): this session's entry says `held`
|
|
47
47
|
const taken = per ? !!((mine && mine.held) || (Array.isArray(report.held) && report.held.includes('*'))) : !!report.takeover
|
package/codeCache.js
CHANGED
|
@@ -98,7 +98,8 @@ export async function clearSession(cid, sid, store = idb, strict = false) {
|
|
|
98
98
|
export async function removeCachedSession(cid, sid, store = idb, local) {
|
|
99
99
|
if (cid && sid) removed.add(SESS(cid, sid))
|
|
100
100
|
await clearSession(cid, sid, store, true)
|
|
101
|
-
|
|
101
|
+
// read strictly: a failed read is not "no list" — the deleted session's title would stay listed offline (sync sweep 11-27 P3)
|
|
102
|
+
const saved = await loadList(cid, store, { strict: true })
|
|
102
103
|
if (saved?.list.some(row => row.id === sid)) {
|
|
103
104
|
await saveList(cid, saved.list.filter(row => row.id !== sid), store, { allowEmpty: true })
|
|
104
105
|
if ((await loadList(cid, store))?.list.some(row => row.id === sid)) throw new Error('The cached session directory could not be updated')
|
|
@@ -128,9 +129,9 @@ export async function saveList(cid, list, store = idb, { allowEmpty = false } =
|
|
|
128
129
|
await store.set(LIST(cid), { list: list.slice(0, 200), at: Date.now() })
|
|
129
130
|
}
|
|
130
131
|
|
|
131
|
-
export async function loadList(cid, store = idb) {
|
|
132
|
+
export async function loadList(cid, store = idb, { strict = false } = {}) {
|
|
132
133
|
if (!cid) return null
|
|
133
|
-
const c = await store.get(LIST(cid))
|
|
134
|
+
const c = await (strict && store.getStrict ? store.getStrict(LIST(cid)) : store.get(LIST(cid)))
|
|
134
135
|
return c && Array.isArray(c.list) ? c : null
|
|
135
136
|
}
|
|
136
137
|
|
package/codeCloud.js
CHANGED
|
@@ -49,6 +49,7 @@ export const CLOUD_API = 'https://api.witbitz.chat/v1/cloud-computer'
|
|
|
49
49
|
// now seen in the other direction. Per-image epochs remain the fix, and until they land NEITHER number is a usable
|
|
50
50
|
// stop condition on its own; the check that holds is the file-by-file tarball diff.
|
|
51
51
|
export const CLOUD_PCR0 = [
|
|
52
|
+
'2f92640e0cd5a84e96de0d0fa1857a7643eddd1bac5c6a2512e0a1879919c7720db7b403c9daa0cd088b946aa6ba31f0', // p3j, reproduced on both fleet hosts from 95eaefba
|
|
52
53
|
'66c77a098b36a21fa4a7612ecad202ef2c8e46e34f14e9ab56a3a2a9f3108190f6d2bac14c526f501b1e0109d9605a72', // p3i, reproduced twice from c6ca1e6b
|
|
53
54
|
]
|
|
54
55
|
// The published Credential Sentinel image.
|
|
@@ -88,6 +89,7 @@ export const CLOUD_PCR0 = [
|
|
|
88
89
|
// ⚑ So "SENTINEL_PCR0 must not move when the Sentinel did not change" is a usable stop condition again — the check
|
|
89
90
|
// that caught the esbuild-cwd leak, and which caught nothing for four cycles because the number always moved.
|
|
90
91
|
export const SENTINEL_PCR0 = [
|
|
92
|
+
'cad3d3e47d1a512fcac60c136b840e83ce28304c37da6e8d66bed205ef5d257cc62e1c118191f1c2561bc749a33cd161', // p3j, reproduced on both fleet hosts from 95eaefba
|
|
91
93
|
'aaeb3d3f64efa4f072372a7f257eaa89fd969614139ca08a8ce817ec46cd0d32cf2b4e6103b984a2b7f9d7ce3354c248', // p3i, reproduced twice from c6ca1e6b
|
|
92
94
|
]
|
|
93
95
|
export const GRANT_TTL_MS = 24 * 3600_000
|
|
@@ -308,6 +310,8 @@ export async function openCloud(computer, { token, aws = null, onStep = () => {}
|
|
|
308
310
|
if (r.status === 401 && out.code) throw new CloudError(`your AWS key was not accepted: ${out.error || out.code}`, { status: 401, code: out.code })
|
|
309
311
|
if (r.status === 401 && !askedAgain) { askedAgain = true; await tokenNow(true); continue } // once more, with a fresh one
|
|
310
312
|
if (r.status === 401) throw new CloudError(`your sign-in was not accepted${out.reason ? ` (${out.reason})` : ''} — sign in again with your email`, { status: 401, code: 'no_token' })
|
|
313
|
+
// heldUsd: what your OTHER open cloud computers hold — the month is not used, they hold the rest of it for now
|
|
314
|
+
if (r.status === 429 && out.code === 'aws_limit' && Number(out.heldUsd) > 0) throw new CloudError(`your other open cloud computer holds the rest of this month's allowance — close it, or wait a few minutes, and try again`, { status: 429, code: 'aws_limit' })
|
|
311
315
|
if (r.status === 429 && out.code === 'aws_limit') throw new CloudError(`this month's cloud computer allowance is used${out.resetsAt ? ` — it starts again on ${String(out.resetsAt).slice(0, 10)}` : ''}`, { status: 429, code: 'aws_limit' })
|
|
312
316
|
if (r.status !== 200 || out.error) throw new CloudError(out.error || `the cloud computer service said ${r.status}`, { status: r.status, code: out.code || out.error || '' })
|
|
313
317
|
return out
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// earlierHistory.js — a linked continuation's EARLIER VERSIONS in an export (side sweep: room-export-omits-linked-earlier-history).
|
|
2
|
+
// The conversation draws the parent chain's messages when this device holds their keys (space.js loadEpochChainHistory), but both
|
|
3
|
+
// exports read the selected room's record alone and finished as if that were all of it. The portable file now carries the earlier
|
|
4
|
+
// versions' messages beside its own (`earlier`, additive — a recreate replays `entries` as before), and when they cannot be read, or
|
|
5
|
+
// the export cannot carry them (the sealed download: one Space's record), it SAYS so. Pure — the caller passes the reader.
|
|
6
|
+
|
|
7
|
+
/** This device's keys for a room's earlier versions ({ parentRoom: mk, … }), or null (not a linked continuation here). */
|
|
8
|
+
export function epochKeysOf(room, storage = globalThis.localStorage) {
|
|
9
|
+
try { const s = storage && storage.getItem('space:epoch:' + room); const o = s ? JSON.parse(s) : null; return o && typeof o === 'object' && Object.keys(o).length ? o : null } catch { return null }
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** → { earlier: { from, count, entries } | null, note: '' | a sentence for the toast }.
|
|
13
|
+
* `parent` is the room's config's parent; `readChain(parent, mk, epochKeys)` reads the chain (spaceFork readEpochChain).
|
|
14
|
+
* `configRead: false` = the room's settings (where the parent is named) could not be read: a room this device follows earlier
|
|
15
|
+
* versions of then says they are left out, not nothing (side sweep: room-export-omits-linked-earlier-history, reopened). */
|
|
16
|
+
const UNREAD = ' Its earlier versions’ messages couldn’t be read just now, so they are not in the file — export again to try once more.'
|
|
17
|
+
export async function earlierForExport({ parent, epochKeys, readChain, configRead = true }) {
|
|
18
|
+
if (!parent && epochKeys && configRead === false) return { earlier: null, note: UNREAD }
|
|
19
|
+
if (!parent || !epochKeys) return { earlier: null, note: '' } // not a continuation of an earlier version this device follows
|
|
20
|
+
if (!epochKeys[parent] || typeof readChain !== 'function') return { earlier: null, note: ' Its earlier versions’ messages aren’t on this device, so they are not in the file.' }
|
|
21
|
+
try {
|
|
22
|
+
const entries = await readChain(parent, epochKeys[parent], epochKeys)
|
|
23
|
+
if (!Array.isArray(entries)) throw new Error('no_history')
|
|
24
|
+
// the note counts MESSAGES as drawn: a photo's Safe media copy (`kind: 'safe'`) is its own entry, drawn in the photo's place — as
|
|
25
|
+
// spaceExport.js messageCount (side sweep: room-export-counts-hidden-records-as-messages); the file keeps both, `count` = entries
|
|
26
|
+
const shown = entries.filter((e) => !(e && e.kind === 'safe')).length
|
|
27
|
+
return { earlier: { from: parent, count: entries.length, entries }, note: shown ? ' Its earlier versions’ ' + shown + ' message' + (shown === 1 ? ' is' : 's are') + ' included too.' : '' }
|
|
28
|
+
} catch { return { earlier: null, note: UNREAD } }
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** The sealed download holds ONE version's record: a continuation says its earlier versions are not in it. */
|
|
32
|
+
export const sealedEarlierNote = (epochKeys) => (epochKeys ? 'This file holds this version of the Space only — its earlier versions’ messages are not in it.' : '')
|
package/emailFork.js
CHANGED
|
@@ -81,7 +81,9 @@ export const govOf = (cfg) => ({ owners: lower(cfg && cfg.owners && cfg.owners.e
|
|
|
81
81
|
* (the server's rule — spaceService refuses a fork notice from a non-admin where there are admins). */
|
|
82
82
|
export function mayMove(cfg, email) {
|
|
83
83
|
const { owners, admins } = govOf(cfg), me = String(email || '').toLowerCase()
|
|
84
|
-
|
|
84
|
+
// a room whose roles name only @username tags (docs/spaces-usernames.md § 13.1) HAS owners: an email alone is not one of them
|
|
85
|
+
const tagged = !!cfg && ['owners', 'admins'].some((k) => cfg[k] && Array.isArray(cfg[k].tags) && cfg[k].tags.length)
|
|
86
|
+
return !(admins.length || owners.length || tagged) || admins.includes(me) || owners.includes(me)
|
|
85
87
|
}
|
|
86
88
|
|
|
87
89
|
/** The OWNERS step of a move, before anything is minted: fills the new gate's owners (and, unless stated, the admins it
|