WIP IV improve UX [snapshot task 2]
This commit is contained in:
1 parent
28c90d1d71
commit
58c3e2af86
16 files changed
+779
-36
No files matched your search
@@ -108,6 +108,7 @@ test('reused file IDs and stale receipts fail closed', async t => {
|
||||
await until(() => first.state.results.length === 1);
|
||||
const target = stale === 'start' ? second : first;
|
||||
target.channel.onmessage?.(new MessageEvent('message', { data: JSON.stringify({ v: 3, type: stale, id: 1, data: JSON.stringify({ v: 2, type: 'complete', bytes: 0 }) }) }));
|
||||
await until(() => target.state.closed);
|
||||
assert.equal(target.state.closed, true); assert.equal(target.state.errors.length, 1);
|
||||
}
|
||||
});
|
||||
@@ -116,5 +117,30 @@ test('unsolicited offers before verification and excess binary payload fail clos
|
||||
const { first, second } = pair(t);
|
||||
first.channel.onmessage?.(new MessageEvent('message', { data: JSON.stringify({ v: 3, type: 'start', id: 2 }) }));
|
||||
second.channel.onmessage?.(new MessageEvent('message', { data: new ArrayBuffer(100000) }));
|
||||
await until(() => first.state.closed && second.state.closed);
|
||||
assert.equal(first.state.closed, true); assert.equal(second.state.closed, true);
|
||||
});
|
||||
|
||||
test('identity proofs gate metadata even when a remembered contact requests automatic verification', async t => {
|
||||
const { first, second } = pair(t);
|
||||
let release!: () => void;
|
||||
const pending = new Promise<void>(resolve => { release = resolve; });
|
||||
first.session.authenticate({ sign: async () => 'sender-proof', verify: async proof => { assert.equal(proof, 'receiver-proof'); await pending; } });
|
||||
second.session.authenticate({ sign: async () => 'receiver-proof', verify: async proof => { assert.equal(proof, 'sender-proof'); await pending; } });
|
||||
first.session.add([file('private-name')]); first.session.verify(); second.session.verify();
|
||||
await tick();
|
||||
assert.equal(first.state.ready, false); assert.equal(second.state.ready, false);
|
||||
assert.doesNotMatch(first.channel.frames.join(''), /private-name/);
|
||||
release(); await until(() => second.state.receive === 'choose-storage');
|
||||
second.session.accept(); await until(() => first.state.results.length === 1);
|
||||
assert.deepEqual(first.state.errors, []); assert.deepEqual(second.state.errors, []);
|
||||
});
|
||||
|
||||
test('invalid or missing identity proof closes the session without releasing file metadata', async t => {
|
||||
const { first, second } = pair(t);
|
||||
first.session.authenticate({ sign: async () => 'proof', verify: async () => { throw new Error('Device proof failed'); } });
|
||||
first.session.add([file('private-name')]); first.session.verify(); second.session.verify();
|
||||
await until(() => first.state.closed);
|
||||
assert.match(first.state.errors.join(''), /Device proof failed/);
|
||||
assert.doesNotMatch(first.channel.frames.join(''), /private-name/);
|
||||
});
|
||||
Reference in new issue
Block a user