WIP V improve UX [snapshot task 2]
Add the connections workspace (sidebar, editable slots, per-slot activity, removal dialog with focus wrapping), remove the downloadable local HTML and unreleased identity backup/restore, and start the 0.0.5 draft changelog. Restore the released 0.0.3/0.0.4 changelog entries. Enable focus emulation in browser checks so background tabs receive focus/blur events. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
58c3e2af86
commit
5f8c6a1916
21 files changed
+879
-306
No files matched your search
+7
-17
@@ -1,6 +1,6 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { createIdentity, hello, signIdentity, verifyIdentity, exportBackup, importBackup, parseHello, validateContacts, type IdentityContext } from '../src/lib/identity.ts';
|
||||
import { createIdentity, hello, signIdentity, verifyIdentity, parseHello, validateContacts, type IdentityContext } from '../src/lib/identity.ts';
|
||||
const fingerprint = (byte: string) => Array(32).fill(byte).join(' ');
|
||||
async function setup() {
|
||||
const first = await createIdentity(), second = await createIdentity();
|
||||
@@ -30,20 +30,10 @@ test('identity input is bounded and contacts cannot supply duplicate identities'
|
||||
assert.throws(() => validateContacts(Array(101).fill({ key: identity.publicKey, name: 'friend' })));
|
||||
assert.throws(() => validateContacts(Array(2).fill({ key: identity.publicKey, name: 'friend' })));
|
||||
});
|
||||
test('encrypted backup restores signing identity and contacts; wrong password and tampering fail', async () => {
|
||||
const { first, second, context } = await setup();
|
||||
const state = { identity: first, contacts: [{ key: second.publicKey, name: 'Other device' }] };
|
||||
const password = 'a long private backup passphrase';
|
||||
const backup = await exportBackup(state, password);
|
||||
assert.doesNotMatch(backup, /Other device|privateKey/);
|
||||
const restored = await importBackup(backup, password);
|
||||
assert.deepEqual(restored.contacts, state.contacts);
|
||||
assert.equal(restored.identity!.publicKey, first.publicKey);
|
||||
await verifyIdentity(await signIdentity(restored.identity!, context, true), context, true);
|
||||
await assert.rejects(importBackup(backup, 'the incorrect password'));
|
||||
const damaged = JSON.parse(backup); damaged.data = (damaged.data.startsWith('00') ? 'ff' : '00') + damaged.data.slice(2);
|
||||
await assert.rejects(importBackup(JSON.stringify(damaged), password));
|
||||
damaged.iterations = 1; await assert.rejects(importBackup(JSON.stringify(damaged), password));
|
||||
await assert.rejects(importBackup('x'.repeat(100001), password));
|
||||
await assert.rejects(exportBackup(state, 'short'));
|
||||
test('device private keys cannot be extracted and still sign after storage cloning', async () => {
|
||||
const { first, context } = await setup();
|
||||
const stored = structuredClone(first);
|
||||
assert.equal(stored.privateKey.extractable, false);
|
||||
await assert.rejects(crypto.subtle.exportKey('jwk', stored.privateKey));
|
||||
await verifyIdentity(await signIdentity(stored, context, true), context, true);
|
||||
});
|
||||
Reference in new issue
Block a user