WIP V improve UX [snapshot task 2]

This commit is contained in:
Schluffe committed 2026-10-17 14:51:48 +02:00
1 parent 5f8c6a1916
commit a73b3075b6
16 files changed
+238 -232

No files matched your search

+5 -1
View File
@@ -7,8 +7,12 @@ test('renaming and pairing preserve a slot identity and its activity', () => {
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) });
const remembering = updateConnection(renamed, { rememberDevice: true });
const paired = updateConnection(remembering, { peerKey: '04' + 'a'.repeat(128) });
assert.equal(initial.name, 'Con 2');
assert.equal(initial.rememberDevice, false);
assert.equal(paired.rememberDevice, true);
assert.equal(updateConnection(paired, { peerKey: '' }).rememberDevice, true, 'Forgetting a device keeps the opt-in');
assert.equal(paired.id, initial.id);
assert.equal(paired.name, 'Work laptop');
assert.deepEqual(paired.history, [activity]);
+2 -5
View File
@@ -1,6 +1,6 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { createIdentity, hello, signIdentity, verifyIdentity, parseHello, validateContacts, type IdentityContext } from '../src/lib/identity.ts';
import { createIdentity, hello, signIdentity, verifyIdentity, parseHello, 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();
@@ -22,13 +22,10 @@ test('device proof binds both keys, fresh nonces, roles, and both DTLS fingerpri
await assert.rejects(signIdentity(imposter, context, true));
await assert.rejects(verifyIdentity('00'.repeat(64), context, true));
});
test('identity input is bounded and contacts cannot supply duplicate identities', async () => {
test('identity input is bounded', async () => {
const identity = await createIdentity();
assert.throws(() => parseHello({ key: identity.publicKey, nonce: 'bad' }));
assert.throws(() => parseHello({ key: 'ff'.repeat(65), nonce: '00'.repeat(32) }));
assert.throws(() => validateContacts([{ key: identity.publicKey, name: ' ' }]));
assert.throws(() => validateContacts(Array(101).fill({ key: identity.publicKey, name: 'friend' })));
assert.throws(() => validateContacts(Array(2).fill({ key: identity.publicKey, name: 'friend' })));
});
test('device private keys cannot be extracted and still sign after storage cloning', async () => {
const { first, context } = await setup();