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:
SchluffeandClaude Opus 5.5 committed 2026-10-17 13:44:08 +02:00
1 parent 58c3e2af86
commit 5f8c6a1916
21 files changed
+879 -306

No files matched your search

+32
View File
@@ -0,0 +1,32 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { emptyConnection, updateConnection, HISTORY_LIMIT, type ConnectionActivity } from '../src/lib/connections.ts';
test('renaming and pairing preserve a slot identity and its activity', () => {
const initial = emptyConnection(2);
const activity: ConnectionActivity = { id: 'transfer', time: 1, direction: 'send', name: 'example.txt', size: 123, result: 'complete' };
const withHistory = updateConnection(initial, { activity });
const renamed = updateConnection(withHistory, { name: ' Work laptop ' });
const paired = updateConnection(renamed, { peerKey: '04' + 'a'.repeat(128) });
assert.equal(initial.name, 'Con 2');
assert.equal(paired.id, initial.id);
assert.equal(paired.name, 'Work laptop');
assert.deepEqual(paired.history, [activity]);
assert.equal(initial.history.length, 0);
assert.throws(() => updateConnection(paired, { name: ' ' }));
assert.throws(() => updateConnection(paired, { name: 'a'.repeat(81) }));
assert.throws(() => updateConnection(paired, { peerKey: 'invalid' }));
});
test('history is bounded, ordered, and does not duplicate an event', () => {
let connection = emptyConnection();
for (let i = 0; i < HISTORY_LIMIT + 10; i++) {
connection = updateConnection(connection, { activity: { id: String(i), time: i, direction: 'receive', name: 'file', size: 0, result: 'declined' } });
}
const last = connection.history.at(-1)!;
connection = updateConnection(connection, { activity: last });
assert.equal(connection.history.length, HISTORY_LIMIT);
assert.equal(connection.history[0]!.time, 10);
assert.throws(() => updateConnection(connection, { activity: { ...last, size: -1 } }));
assert.throws(() => updateConnection(connection, { activity: { ...last, direction: 'invalid' as 'send' } }));
});
+7 -17
View File
@@ -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);
});