Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,12 @@ describe('ExtensionServerClient', () => {
})

describe('initialization', () => {
test('generates a random UUID as id', () => {
const client = new ExtensionServerClient(defaultOptions)
const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i
expect(client.id).toMatch(uuidRegex)
})

test('connects to the target websocket', async () => {
// Create client
const client = new ExtensionServerClient(defaultOptions)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ export class ExtensionServerClient implements ExtensionServer.Client {
private uiExtensionsByUuid: Record<string, ExtensionServer.UIExtension> = {}

constructor(options: DeepPartial<ExtensionServer.Options> = {}) {
this.id = (Math.random() + 1).toString(36).substring(7)
// Security: Use a cryptographically secure random UUID to prevent ID predictability
this.id = globalThis.crypto.randomUUID()
this.options = getValidatedOptions({
...options,
connection: {
Expand Down
Loading