@witbitz/sdk 4.7.1 → 4.8.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/acctV2Client.js +3 -3
- package/acctV2UiCore.js +1 -0
- package/acctV2WebAuthn.js +4 -4
- package/idb.js +1 -0
- package/l1-worker-src.js +1 -1
- package/l1-worker.js +22 -1
- package/manifest.json +16 -16
- package/package.json +2 -2
- package/sentinelRelease.js +1 -0
- package/spaceClient.js +32 -13
- package/sw-notif-core.js +4 -2
- package/vault-kit.mjs +1 -1
- package/vaultAtRest.js +3 -2
- package/witbitz-admin.mjs +11 -10
- package/witbitz-sdk.js +1 -1
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.8.0 of this package is the release folder https://witbitz.chat/sdk/4.8.0/ unchanged (from commit
|
|
20
|
+
`b47312c7930f4196ede9d28eb94ce9e6f56e30b3`), 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/acctV2Client.js
CHANGED
|
@@ -83,7 +83,7 @@ export function accountClient({ base, fetch: f = globalThis.fetch, now = () => M
|
|
|
83
83
|
if (!keys) throw Object.assign(new Error('need_security_key'), { code: 'need_security_key' })
|
|
84
84
|
const allow = (c.keys || []).filter((k) => k.id !== except)
|
|
85
85
|
if (!allow.length) throw Object.assign(new Error('no_other_key'), { code: 'no_other_key' })
|
|
86
|
-
return { hwkey: await keys.get({ challenge: await sha256(Tb), allow }) }
|
|
86
|
+
return { hwkey: await keys.get({ challenge: await sha256(Tb), allow, rpId: c.rpId }) }
|
|
87
87
|
}
|
|
88
88
|
const fail = (code) => { throw Object.assign(new Error(code), { code }) }
|
|
89
89
|
/** A new code's parameters (§ 8.2): every value derived HERE from the new code and master, before anything is sent. */
|
|
@@ -360,11 +360,11 @@ export function accountClient({ base, fetch: f = globalThis.fetch, now = () => M
|
|
|
360
360
|
const assertions = []
|
|
361
361
|
for (const [i, m] of made.entries()) {
|
|
362
362
|
onStep({ step: 'confirm', index: i, of: made.length })
|
|
363
|
-
assertions.push(await keys.get({ challenge: ch, allow: [m] }))
|
|
363
|
+
assertions.push(await keys.get({ challenge: ch, allow: [m], rpId: f.rpId }))
|
|
364
364
|
}
|
|
365
365
|
if (purpose === 'key_add') {
|
|
366
366
|
onStep({ step: 'existing' })
|
|
367
|
-
assertions.push(await keys.get({ challenge: ch, allow: (f.active || []).filter((k) => !creds.includes(k.id)) }))
|
|
367
|
+
assertions.push(await keys.get({ challenge: ch, rpId: f.rpId, allow: (f.active || []).filter((k) => !creds.includes(k.id)) }))
|
|
368
368
|
}
|
|
369
369
|
return req('POST', `/v2/account/enrol/${eid}/finish`, { body: { device_sig: await sigOf(device, Tf), assertions, idem: b64u(rand(16)) }, signer: device })
|
|
370
370
|
},
|
package/acctV2UiCore.js
CHANGED
|
@@ -42,6 +42,7 @@ const MESSAGES = {
|
|
|
42
42
|
already_migrated: 'This device already has an account on the new service.',
|
|
43
43
|
need_security_key: 'This needs one of your security keys, and this device can’t ask for one.',
|
|
44
44
|
key_cancelled: 'The security key didn’t answer — the prompt was closed, timed out, or a key that isn’t on this account was touched. Nothing changed.',
|
|
45
|
+
key_domain_mismatch: 'Open the vault on the website where you set up your security keys.',
|
|
45
46
|
key_wrong_site: 'Security keys can’t be used in this app yet.', // accounts are per app (sync sweep 11-16 #17): never sent to another app's address
|
|
46
47
|
webauthn_unavailable: 'This browser can’t use security keys.',
|
|
47
48
|
key_already_registered: 'That key is already on this account. Use a different key.',
|
package/acctV2WebAuthn.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// acctV2WebAuthn.js — the security-key ceremonies of account recovery v2 (docs/account-recovery-protocol.md § 10), as the
|
|
2
2
|
// small adapter the client takes (acctV2Client.js `keys`): create(options) → the registration, get({challenge, allow}) →
|
|
3
3
|
// an assertion, everything in base64url. This file is the BROWSER's adapter (navigator.credentials); the tests pass a
|
|
4
|
-
// simulated key with the same shape. The
|
|
4
|
+
// simulated key with the same shape. The service chooses the verified vault's RP (§ 10.2). Older responses use the shared Spaces RP.
|
|
5
5
|
import { b64u, unb64u } from './acctV2Wire.js'
|
|
6
6
|
|
|
7
7
|
export const RP_ID = 'witbitz.chat'
|
|
@@ -21,7 +21,7 @@ const rethrow = (e) => { throw (e && e.code === 'cancelled' ? e : why(e)) }
|
|
|
21
21
|
function why(e) {
|
|
22
22
|
if (e && e.name === 'NotAllowedError') return err('key_cancelled') // closed, timed out, or no matching key touched
|
|
23
23
|
if (e && e.name === 'InvalidStateError') return err('key_already_registered') // excludeCredentials matched
|
|
24
|
-
if (e && e.name === 'SecurityError') return err('key_wrong_site') // this origin may not use
|
|
24
|
+
if (e && e.name === 'SecurityError') return err('key_wrong_site') // this origin may not use the requested RP (§ 10.2)
|
|
25
25
|
return err('key_failed')
|
|
26
26
|
}
|
|
27
27
|
|
|
@@ -45,11 +45,11 @@ export function browserKeys({ rpId = RP_ID } = {}) {
|
|
|
45
45
|
return { attestationObject: ab(r.attestationObject), clientDataJSON: ab(r.clientDataJSON), transports: (r.getTransports && r.getTransports()) || [] }
|
|
46
46
|
},
|
|
47
47
|
/** An assertion over `challenge` (bytes) by one of `allow` ([{ id, transports }]). */
|
|
48
|
-
async get({ challenge, allow }) {
|
|
48
|
+
async get({ challenge, allow, rpId: requestRpId = rpId }) {
|
|
49
49
|
if (!available()) throw err('webauthn_unavailable')
|
|
50
50
|
let a
|
|
51
51
|
const publicKey = {
|
|
52
|
-
rpId, challenge, userVerification: 'required', timeout: 120000,
|
|
52
|
+
rpId: requestRpId, challenge, userVerification: 'required', timeout: 120000,
|
|
53
53
|
allowCredentials: (allow || []).map((c) => ({ type: 'public-key', id: unb64u(c.id), transports: c.transports || [] })),
|
|
54
54
|
}
|
|
55
55
|
try { a = await ceremony('get', () => navigator.credentials.get({ publicKey })) } catch (e) { rethrow(e) }
|
package/idb.js
CHANGED
|
@@ -121,6 +121,7 @@ export const idb = (() => {
|
|
|
121
121
|
})().catch(() => []),
|
|
122
122
|
// §NAMES: the real names under a prefix, values never read (the protection migration and listings).
|
|
123
123
|
names: (pfx) => (idbNamingState().on && idbNamingState().namer ? nameIndex().then(async (ix) => [...ix.map(([, n]) => n).filter((n) => n.startsWith(pfx)), ...await keysRaw(pfx)]) : keysRaw(pfx)).catch(() => []),
|
|
124
|
+
setDeviceRaw: (k, v) => tx('readwrite', (s) => s.put(v, k)),
|
|
124
125
|
getRaw, setRaw, setRawStrict, delRaw, entriesRaw, keysRaw, nameIndex,
|
|
125
126
|
/** A read that THROWS when it failed (never null for an error) — for a value that must not be replaced on a failed read. */
|
|
126
127
|
async getStrict(k) {
|