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

+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();