diff --git a/__tests__/agent.test.ts b/__tests__/agent.test.ts index c415c2b..d725f1f 100644 --- a/__tests__/agent.test.ts +++ b/__tests__/agent.test.ts @@ -1,4 +1,4 @@ -import { v4 as uuidv4 } from 'uuid'; +import { randomUUID } from 'crypto'; import { vi, describe, expect, it } from 'vitest'; import { createTestClient } from './create-test-client.js'; import { StreamClient } from '../src/StreamClient.js'; @@ -8,7 +8,7 @@ const enableDebugLogging = false; async function createTestStreamAndRealtimeClients() { const streamClient = createTestClient(); - const call = streamClient.video.call('default', `call${uuidv4()}`); + const call = streamClient.video.call('default', `call${randomUUID()}`); const realtimeClient = await streamClient.video.connectOpenAi({ call, @@ -37,7 +37,7 @@ describe.skip('AI agent integration', () => { it('should throw on invalid OpenAI credentials', async () => { const streamClient = createTestClient(); - const call = streamClient.video.call('default', `call${uuidv4()}`); + const call = streamClient.video.call('default', `call${randomUUID()}`); await expect( streamClient.video.connectOpenAi({ @@ -51,7 +51,7 @@ describe.skip('AI agent integration', () => { it('should throw on invalid Stream credentials', async () => { const streamClient = new StreamClient('', 'secret'); - const call = streamClient.video.call('default', `call${uuidv4()}`); + const call = streamClient.video.call('default', `call${randomUUID()}`); await expect( streamClient.video.connectOpenAi({ diff --git a/__tests__/block-lists.test.ts b/__tests__/block-lists.test.ts index 103d96f..20eb5e4 100644 --- a/__tests__/block-lists.test.ts +++ b/__tests__/block-lists.test.ts @@ -1,5 +1,5 @@ import { beforeAll, describe, expect, it } from 'vitest'; -import { v4 as uuidv4 } from 'uuid'; +import { randomUUID } from 'crypto'; import { createTestClient } from './create-test-client'; import { StreamClient } from '../src/StreamClient'; import { CreateBlockListRequest } from '../src/gen/models'; @@ -11,7 +11,7 @@ describe('block lists CRUD API', () => { beforeAll(() => { client = createTestClient(); blockList = { - name: 'streamnodetest-F1' + uuidv4(), + name: 'streamnodetest-F1' + randomUUID(), words: ['Ricciardo should retire'], }; }); diff --git a/__tests__/call-members.test.ts b/__tests__/call-members.test.ts index fd323c3..20fbf20 100644 --- a/__tests__/call-members.test.ts +++ b/__tests__/call-members.test.ts @@ -1,5 +1,5 @@ import { beforeAll, describe, expect, it } from 'vitest'; -import { v4 as uuidv4 } from 'uuid'; +import { randomUUID } from 'crypto'; import { createTestClient } from './create-test-client'; import { StreamCall } from '../src/StreamCall'; import { StreamClient } from '../src/StreamClient'; @@ -7,7 +7,7 @@ import { OwnCapability } from '../src/gen/models'; describe('call members API', () => { let client: StreamClient; - const callId = `call${uuidv4()}`; + const callId = `call${randomUUID()}`; let call: StreamCall; beforeAll(async () => { diff --git a/__tests__/call-types.test.ts b/__tests__/call-types.test.ts index 7242868..090604a 100644 --- a/__tests__/call-types.test.ts +++ b/__tests__/call-types.test.ts @@ -1,12 +1,12 @@ import { beforeAll, describe, expect, it } from 'vitest'; -import { v4 as uuidv4 } from 'uuid'; +import { randomUUID } from 'crypto'; import { createTestClient } from './create-test-client'; import { StreamClient } from '../src/StreamClient'; import { OwnCapability } from '../src/gen/models'; describe('call types CRUD API', () => { let client: StreamClient; - const callTypeName = `streamnodetest${uuidv4()}`; + const callTypeName = `streamnodetest${randomUUID()}`; beforeAll(() => { client = createTestClient(); diff --git a/__tests__/call.test.ts b/__tests__/call.test.ts index 6e92417..469bdae 100644 --- a/__tests__/call.test.ts +++ b/__tests__/call.test.ts @@ -1,12 +1,12 @@ import { beforeAll, describe, expect, it } from 'vitest'; -import { v4 as uuidv4 } from 'uuid'; +import { randomUUID } from 'crypto'; import { createTestClient } from './create-test-client'; import { StreamCall } from '../src/StreamCall'; import { StreamClient } from '../src/StreamClient'; describe('call API', () => { let client: StreamClient; - const callId = `call${uuidv4()}`; + const callId = `call${randomUUID()}`; let call: StreamCall; beforeAll(async () => { @@ -207,7 +207,7 @@ describe('call API', () => { }); it('generate SRT credentials', async () => { - const call = client.video.call('default', `call${uuidv4()}`); + const call = client.video.call('default', `call${randomUUID()}`); await call.getOrCreate({ data: { created_by_id: 'john', diff --git a/__tests__/channel-types.test.ts b/__tests__/channel-types.test.ts index b12caa6..53e48ea 100644 --- a/__tests__/channel-types.test.ts +++ b/__tests__/channel-types.test.ts @@ -1,11 +1,11 @@ import { beforeAll, describe, expect, it } from 'vitest'; -import { v4 as uuidv4 } from 'uuid'; +import { randomUUID } from 'crypto'; import { createTestClient } from './create-test-client'; import { StreamClient } from '../src/StreamClient'; describe('channel types CRUD API', () => { let client: StreamClient; - const channelType = 'streamnodetest' + uuidv4(); + const channelType = 'streamnodetest' + randomUUID(); beforeAll(() => { client = createTestClient(); diff --git a/__tests__/channel.test.ts b/__tests__/channel.test.ts index 6905822..adda7a9 100644 --- a/__tests__/channel.test.ts +++ b/__tests__/channel.test.ts @@ -1,12 +1,12 @@ import { beforeAll, describe, expect, it } from 'vitest'; -import { v4 as uuidv4 } from 'uuid'; +import { randomUUID } from 'crypto'; import { createTestClient } from './create-test-client'; import { StreamClient } from '../src/StreamClient'; import { StreamChannel } from '../src/StreamChannel'; describe('channel API', () => { let client: StreamClient; - const channelId = 'streamnodetest' + uuidv4(); + const channelId = 'streamnodetest' + randomUUID(); let channel: StreamChannel; const user = { id: 'stream-node-test-user', diff --git a/__tests__/command.test.ts b/__tests__/command.test.ts index e10cca2..42f5e8e 100644 --- a/__tests__/command.test.ts +++ b/__tests__/command.test.ts @@ -1,11 +1,11 @@ import { beforeAll, describe, expect, it } from 'vitest'; -import { v4 as uuidv4 } from 'uuid'; +import { randomUUID } from 'crypto'; import { createTestClient } from './create-test-client'; import { StreamClient } from '../src/StreamClient'; describe('commands CRUD API', () => { let client: StreamClient; - const commandName = 'stream-node-test-command' + uuidv4(); + const commandName = 'stream-node-test-command' + randomUUID(); beforeAll(() => { client = createTestClient(); diff --git a/__tests__/date-transform.test.ts b/__tests__/date-transform.test.ts index 72f4a1f..526f46a 100644 --- a/__tests__/date-transform.test.ts +++ b/__tests__/date-transform.test.ts @@ -1,5 +1,5 @@ import { beforeAll, describe, expect, it } from 'vitest'; -import { v4 as uuidv4 } from 'uuid'; +import { randomUUID } from 'crypto'; import { createTestClient } from './create-test-client'; import { StreamClient } from '../src/StreamClient'; import { UserRequest } from '../src/gen/models'; @@ -21,7 +21,7 @@ describe('Date conversion', () => { }); it('call + members', async () => { - const id = uuidv4(); + const id = randomUUID(); const call = client.video.call('default', id); const startsAt = new Date(); const response = await call.create({ @@ -62,7 +62,7 @@ describe('Date conversion', () => { }); it('channel + members', async () => { - const id = uuidv4(); + const id = randomUUID(); const channel = client.chat.channel('messaging', id); const response = await channel.getOrCreate({ data: { @@ -104,8 +104,8 @@ describe('Date conversion', () => { it('users', async () => { const newUser: UserRequest = { - id: uuidv4(), - name: 'streamnodetest' + uuidv4(), + id: randomUUID(), + name: 'streamnodetest' + randomUUID(), custom: { created_at: new Date(), }, diff --git a/__tests__/devices-push.test.ts b/__tests__/devices-push.test.ts index 3a082c5..ef34c6d 100644 --- a/__tests__/devices-push.test.ts +++ b/__tests__/devices-push.test.ts @@ -1,5 +1,5 @@ import { beforeAll, describe, expect, it } from 'vitest'; -import { v4 as uuidv4 } from 'uuid'; +import { randomUUID } from 'crypto'; import { createTestClient } from './create-test-client'; import { StreamClient } from '../src/StreamClient'; import { CreateDeviceRequest, PushProvider } from '../src/gen/models'; @@ -11,7 +11,7 @@ describe('devices and push', () => { role: 'admin', }; const device: CreateDeviceRequest = { - id: uuidv4(), + id: randomUUID(), push_provider: 'firebase', push_provider_name: 'firebase', user_id: user.id, diff --git a/__tests__/external-storage.test.ts b/__tests__/external-storage.test.ts index 513cdc3..77dde7d 100644 --- a/__tests__/external-storage.test.ts +++ b/__tests__/external-storage.test.ts @@ -1,14 +1,14 @@ import { afterAll, beforeAll, describe, expect, it } from 'vitest'; -import { v4 as uuidv4 } from 'uuid'; +import { randomUUID } from 'crypto'; import { createTestClient } from './create-test-client'; import { StreamClient } from '../src/StreamClient'; describe('external storage CRUD API', () => { let client: StreamClient; - const storageName = `streamnodetest${uuidv4()}`; - const s3name = `streamnodetest-${uuidv4()}`; - const gcsName = `streamnodetest-${uuidv4()}`; - const azureName = `streamnodetest-${uuidv4()}`; + const storageName = `streamnodetest${randomUUID()}`; + const s3name = `streamnodetest-${randomUUID()}`; + const gcsName = `streamnodetest-${randomUUID()}`; + const azureName = `streamnodetest-${randomUUID()}`; beforeAll(() => { client = createTestClient(); diff --git a/__tests__/messages.test.ts b/__tests__/messages.test.ts index 1d2167c..2fe689f 100644 --- a/__tests__/messages.test.ts +++ b/__tests__/messages.test.ts @@ -3,11 +3,11 @@ import { afterAll, beforeAll, describe, expect, it } from 'vitest'; import { createTestClient } from './create-test-client'; import { StreamChannel } from '../src/StreamChannel'; import { StreamClient } from '../src/StreamClient'; -import { v4 as uuidv4 } from 'uuid'; +import { randomUUID } from 'crypto'; describe('messages API', () => { let client: StreamClient; - const channelId = 'streamnodetest' + uuidv4(); + const channelId = 'streamnodetest' + randomUUID(); let channel: StreamChannel; const user = { id: 'stream-node-test-user', diff --git a/__tests__/permissions-app-settings.test.ts b/__tests__/permissions-app-settings.test.ts index 5350b5e..480bacd 100644 --- a/__tests__/permissions-app-settings.test.ts +++ b/__tests__/permissions-app-settings.test.ts @@ -1,5 +1,5 @@ import { beforeAll, describe, expect, it } from 'vitest'; -import { v4 as uuidv4 } from 'uuid'; +import { randomUUID } from 'crypto'; import { createTestClient } from './create-test-client'; import { StreamClient } from '../src/StreamClient'; import { CreateRoleRequest, OwnCapability } from '../src/gen/models'; @@ -10,7 +10,7 @@ describe('permissions and app settings API', () => { beforeAll(() => { role = { - name: 'streamnodetest' + uuidv4(), + name: 'streamnodetest' + randomUUID(), }; client = createTestClient(); }); diff --git a/__tests__/ring-call.test.ts b/__tests__/ring-call.test.ts index 9eb4f9f..4bf8be9 100644 --- a/__tests__/ring-call.test.ts +++ b/__tests__/ring-call.test.ts @@ -2,11 +2,11 @@ import { beforeAll, describe, expect, it } from 'vitest'; import { createTestClient } from './create-test-client'; import { StreamCall } from '../src/StreamCall'; import { StreamClient } from '../src/StreamClient'; -import { v4 as uuidv4 } from 'uuid'; +import { randomUUID } from 'crypto'; describe('ring call API', () => { let client: StreamClient; - const callId = `call${uuidv4()}`; + const callId = `call${randomUUID()}`; let call: StreamCall; beforeAll(async () => { diff --git a/__tests__/teams.test.ts b/__tests__/teams.test.ts index 528ba8c..0be145c 100644 --- a/__tests__/teams.test.ts +++ b/__tests__/teams.test.ts @@ -1,5 +1,5 @@ import { beforeAll, describe, expect, it } from 'vitest'; -import { v4 as uuidv4 } from 'uuid'; +import { randomUUID } from 'crypto'; import { createTestClient } from './create-test-client'; import { StreamClient } from '../src/StreamClient'; import { StreamCall } from '../src/StreamCall'; @@ -8,7 +8,7 @@ import { UserRequest } from '../src/gen/models'; // Skipping to avoid issues when tests run in parallel describe.skip('teams', () => { let client: StreamClient; - const userId = 'streamnodetest' + uuidv4(); + const userId = 'streamnodetest' + randomUUID(); const newUser: UserRequest = { id: userId, role: 'user', @@ -23,7 +23,7 @@ describe.skip('teams', () => { id: 'stream-node-test-user', role: 'admin', }; - const callId = `call${uuidv4()}`; + const callId = `call${randomUUID()}`; let call: StreamCall; beforeAll(async () => { diff --git a/__tests__/user-compat.test.ts b/__tests__/user-compat.test.ts index 62e6281..5d1be74 100644 --- a/__tests__/user-compat.test.ts +++ b/__tests__/user-compat.test.ts @@ -1,12 +1,12 @@ import { beforeAll, describe, expect, it } from 'vitest'; -import { v4 as uuidv4 } from 'uuid'; +import { randomUUID } from 'crypto'; import { createTestClient } from './create-test-client'; import { StreamClient } from '../src/StreamClient'; describe('user-video compatibility API', () => { let client: StreamClient; const user = { - id: uuidv4(), + id: randomUUID(), role: 'admin', name: 'Test User for user API compatibily', custom: { @@ -20,7 +20,7 @@ describe('user-video compatibility API', () => { }); it('create call', async () => { - const call = client.video.call('default', uuidv4()); + const call = client.video.call('default', randomUUID()); const response = await call.create({ data: { created_by: user } }); // Backend returns: {custom: { custom: { note: 'compatibilty test' } }} diff --git a/__tests__/users.test.ts b/__tests__/users.test.ts index 53e66c1..71aca06 100644 --- a/__tests__/users.test.ts +++ b/__tests__/users.test.ts @@ -1,12 +1,12 @@ import { beforeAll, describe, expect, it } from 'vitest'; -import { v4 as uuidv4 } from 'uuid'; +import { randomUUID } from 'crypto'; import { createTestClient } from './create-test-client'; import { StreamClient } from '../src/StreamClient'; import { UserRequest } from '../src/gen/models'; describe('user API', () => { let client: StreamClient; - const userId = 'streamnodetest' + uuidv4(); + const userId = 'streamnodetest' + randomUUID(); const newUser: UserRequest = { id: userId, role: 'user', @@ -77,7 +77,7 @@ describe('user API', () => { it('create guest', async () => { const guest: UserRequest = { - id: uuidv4(), + id: randomUUID(), name: 'Guest 3', image: ': )', custom: { diff --git a/package.json b/package.json index 638d57f..6c02714 100644 --- a/package.json +++ b/package.json @@ -72,8 +72,7 @@ "dependencies": { "@types/jsonwebtoken": "^9.0.10", "@types/node": "^18.3.0", - "jsonwebtoken": "^9.0.3", - "uuid": "^13.0.0" + "jsonwebtoken": "^9.0.3" }, "peerDependencies": { "@stream-io/openai-realtime-api": "~0.1.3 || ~0.2.0 || ~0.3.0 || ~0.4.0" diff --git a/src/ApiClient.ts b/src/ApiClient.ts index b16f62b..e8359e1 100644 --- a/src/ApiClient.ts +++ b/src/ApiClient.ts @@ -1,4 +1,4 @@ -import { v4 as uuidv4 } from 'uuid'; +import { randomUUID } from 'crypto'; import { ApiConfig, RequestMetadata, StreamError } from './types'; import { APIError } from './gen/models'; import { getRateLimitFromResponseHeader } from './utils/rate-limit'; @@ -32,7 +32,7 @@ export class ApiClient { } url += `?${encodedParams}`; - const clientRequestId = uuidv4(); + const clientRequestId = randomUUID(); const headers: Record = { Authorization: this.apiConfig.token, 'stream-auth-type': 'jwt', diff --git a/yarn.lock b/yarn.lock index 3a61eee..0e34cce 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2903,11 +2903,6 @@ uri-js@^4.2.2: dependencies: punycode "^2.1.0" -uuid@^13.0.0: - version "13.0.0" - resolved "https://registry.yarnpkg.com/uuid/-/uuid-13.0.0.tgz#263dc341b19b4d755eb8fe36b78d95a6b65707e8" - integrity sha512-XQegIaBTVUjSHliKqcnFqYypAd4S+WCYt5NIeRs6w/UAry7z8Y9j5ZwRRL4kzq9U3sD6v+85er9FvkEaBpji2w== - vite-node@3.1.4: version "3.1.4" resolved "https://registry.yarnpkg.com/vite-node/-/vite-node-3.1.4.tgz#13f10b2cb155197a971cb2761664ec952c6cae18"