-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix to allow key ring size of 256 and not 255 (#1268)
* Fix to allow key ring size of 256 and not 255 * Changeset * Add unit test * Lint * Fix tests * Lint
- Loading branch information
Showing
3 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'livekit-client': patch | ||
--- | ||
|
||
Actually allow E2EE keyring size of 256 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { describe, expect, it } from 'vitest'; | ||
import { KEY_PROVIDER_DEFAULTS } from '../constants'; | ||
import { createKeyMaterialFromString } from '../utils'; | ||
import { ParticipantKeyHandler } from './ParticipantKeyHandler'; | ||
|
||
describe('ParticipantKeyHandler', () => { | ||
const participantIdentity = 'testParticipant'; | ||
|
||
it('keyringSize must be greater than 0', () => { | ||
expect(() => { | ||
new ParticipantKeyHandler(participantIdentity, { ...KEY_PROVIDER_DEFAULTS, keyringSize: 0 }); | ||
}).toThrowError(TypeError); | ||
}); | ||
|
||
it('keyringSize must be max 256', () => { | ||
expect(() => { | ||
new ParticipantKeyHandler(participantIdentity, { | ||
...KEY_PROVIDER_DEFAULTS, | ||
keyringSize: 257, | ||
}); | ||
}).toThrowError(TypeError); | ||
}); | ||
|
||
it('get and sets keys at an index', async () => { | ||
const keyHandler = new ParticipantKeyHandler(participantIdentity, { | ||
...KEY_PROVIDER_DEFAULTS, | ||
keyringSize: 128, | ||
}); | ||
const materialA = await createKeyMaterialFromString('passwordA'); | ||
const materialB = await createKeyMaterialFromString('passwordB'); | ||
await keyHandler.setKey(materialA, 0); | ||
expect(keyHandler.getKeySet(0)).toBeDefined(); | ||
expect(keyHandler.getKeySet(0)?.material).toEqual(materialA); | ||
await keyHandler.setKey(materialB, 0); | ||
expect(keyHandler.getKeySet(0)?.material).toEqual(materialB); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters