refactor(core): drop per-terminal device labels
Remove sealLabel/openLabel and their label constants; devices are no longer named per channel. Rename the create setting seats to max_members and point the e2e join helper at POST /join.
This commit is contained in:
1 parent
d946fc5e8a
commit
5fd4ddd411
6 files changed
+12
-171
No files matched your search
@@ -3,7 +3,6 @@ import { fromBase64Url, toBase64Url } from '../src/bytes.js';
|
||||
import {
|
||||
CapabilityError,
|
||||
ChannelSession,
|
||||
IntegrityError,
|
||||
LimitError,
|
||||
LinkError,
|
||||
ModeMismatchError,
|
||||
@@ -61,8 +60,8 @@ describe('创建 enc 频道', () => {
|
||||
});
|
||||
|
||||
it('设置原样放进请求体', async () => {
|
||||
const { request } = await ChannelSession.create({ settings: { seats: 3, delete_policy: 'anyone' } });
|
||||
expect(request.body.settings).toEqual({ seats: 3, delete_policy: 'anyone' });
|
||||
const { request } = await ChannelSession.create({ settings: { max_members: 3, delete_policy: 'anyone' } });
|
||||
expect(request.body.settings).toEqual({ max_members: 3, delete_policy: 'anyone' });
|
||||
});
|
||||
});
|
||||
|
||||
@@ -281,39 +280,6 @@ describe('发送和接收(enc)', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('设备名', () => {
|
||||
it('所有者能读出成员的设备名,其他人换个终端哈希读不出', async () => {
|
||||
const { session: owner } = await ChannelSession.create();
|
||||
const member = await ChannelSession.open(owner.link(ORIGIN));
|
||||
const blob = await member.sealLabel('办公室电脑');
|
||||
|
||||
expect(await owner.openLabel(blob, member.endpointHash)).toBe('办公室电脑');
|
||||
expect(await owner.openLabel(toBase64Url(blob), toBase64Url(member.endpointHash))).toBe('办公室电脑');
|
||||
await expect(owner.openLabel(blob, owner.endpointHash)).rejects.toThrowError(IntegrityError);
|
||||
});
|
||||
|
||||
it('每次加密使用新的随机 IV', async () => {
|
||||
const { session } = await ChannelSession.create();
|
||||
const a = await session.sealLabel('x');
|
||||
const b = await session.sealLabel('x');
|
||||
expect(toHex(a.slice(0, 12))).not.toBe(toHex(b.slice(0, 12)));
|
||||
});
|
||||
|
||||
it('篡改后解不开', async () => {
|
||||
const { session } = await ChannelSession.create();
|
||||
const blob = await session.sealLabel('abc');
|
||||
blob[blob.length - 1]! ^= 1;
|
||||
await expect(session.openLabel(blob, session.endpointHash)).rejects.toThrowError(IntegrityError);
|
||||
});
|
||||
|
||||
it('raw 模式下设备名是明文', async () => {
|
||||
const { session } = await ChannelSession.create({ mode: 'raw' });
|
||||
const blob = await session.sealLabel('plain');
|
||||
expect(new TextDecoder().decode(blob)).toBe('plain');
|
||||
expect(await session.openLabel(blob, session.endpointHash)).toBe('plain');
|
||||
});
|
||||
});
|
||||
|
||||
describe('raw 模式往返', () => {
|
||||
it('单帧:保留统一元数据,没有加密标志', async () => {
|
||||
const { session: owner } = await ChannelSession.create({ mode: 'raw' });
|
||||
|
||||
Reference in new issue
Block a user