livekit-client 2.21.0 → 2.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/README.md +10 -10
  2. package/dist/livekit-client.e2ee.worker.js +1 -1
  3. package/dist/livekit-client.e2ee.worker.js.map +1 -1
  4. package/dist/livekit-client.e2ee.worker.mjs +2 -1
  5. package/dist/livekit-client.e2ee.worker.mjs.map +1 -1
  6. package/dist/livekit-client.esm.mjs +480 -150
  7. package/dist/livekit-client.esm.mjs.map +1 -1
  8. package/dist/livekit-client.fm.worker.js +1 -1
  9. package/dist/livekit-client.fm.worker.js.map +1 -1
  10. package/dist/livekit-client.fm.worker.mjs +2 -1
  11. package/dist/livekit-client.fm.worker.mjs.map +1 -1
  12. package/dist/livekit-client.umd.js +1 -1
  13. package/dist/livekit-client.umd.js.map +1 -1
  14. package/dist/src/room/PCTransport.d.ts +49 -2
  15. package/dist/src/room/PCTransport.d.ts.map +1 -1
  16. package/dist/src/room/RTCEngine.d.ts +20 -1
  17. package/dist/src/room/RTCEngine.d.ts.map +1 -1
  18. package/dist/src/room/Room.d.ts +2 -0
  19. package/dist/src/room/Room.d.ts.map +1 -1
  20. package/dist/src/room/errors.d.ts.map +1 -1
  21. package/dist/src/room/participant/LocalParticipant.d.ts +1 -1
  22. package/dist/src/room/token-source/TokenSource.d.ts +19 -10
  23. package/dist/src/room/token-source/TokenSource.d.ts.map +1 -1
  24. package/dist/src/room/track/LocalVideoTrack.d.ts +12 -1
  25. package/dist/src/room/track/LocalVideoTrack.d.ts.map +1 -1
  26. package/dist/src/room/track/RemoteTrack.d.ts +3 -0
  27. package/dist/src/room/track/RemoteTrack.d.ts.map +1 -1
  28. package/dist/src/room/track/Track.d.ts.map +1 -1
  29. package/dist/src/room/utils.d.ts +15 -0
  30. package/dist/src/room/utils.d.ts.map +1 -1
  31. package/dist/src/test/promiseState.d.ts +12 -0
  32. package/dist/src/test/promiseState.d.ts.map +1 -0
  33. package/dist/src/test/signalToken.d.ts.map +1 -1
  34. package/dist/src/utils/AsyncQueue.d.ts +3 -3
  35. package/dist/src/utils/AsyncQueue.d.ts.map +1 -1
  36. package/dist/ts4.2/room/PCTransport.d.ts +49 -2
  37. package/dist/ts4.2/room/RTCEngine.d.ts +20 -1
  38. package/dist/ts4.2/room/Room.d.ts +2 -0
  39. package/dist/ts4.2/room/participant/LocalParticipant.d.ts +1 -1
  40. package/dist/ts4.2/room/token-source/TokenSource.d.ts +17 -8
  41. package/dist/ts4.2/room/track/LocalVideoTrack.d.ts +12 -1
  42. package/dist/ts4.2/room/track/RemoteTrack.d.ts +3 -0
  43. package/dist/ts4.2/room/utils.d.ts +15 -0
  44. package/dist/ts4.2/test/promiseState.d.ts +12 -0
  45. package/dist/ts4.2/utils/AsyncQueue.d.ts +3 -3
  46. package/package.json +13 -12
  47. package/src/api/SignalClient.e2e.test.ts +16 -9
  48. package/src/e2ee/utils.ts +1 -1
  49. package/src/room/PCTransport.test.ts +243 -1
  50. package/src/room/PCTransport.ts +181 -80
  51. package/src/room/RTCEngine.test.ts +339 -2
  52. package/src/room/RTCEngine.ts +152 -11
  53. package/src/room/Room.test.ts +134 -3
  54. package/src/room/Room.ts +52 -17
  55. package/src/room/data-stream/incoming/IncomingDataStreamManager.ts +1 -1
  56. package/src/room/data-stream/incoming/StreamReader.ts +1 -1
  57. package/src/room/errors.ts +1 -2
  58. package/src/room/token-source/TokenSource.ts +25 -12
  59. package/src/room/track/LocalVideoTrack.test.ts +105 -2
  60. package/src/room/track/LocalVideoTrack.ts +36 -10
  61. package/src/room/track/RemoteTrack.test.ts +144 -0
  62. package/src/room/track/RemoteTrack.ts +39 -12
  63. package/src/room/track/Track.ts +2 -1
  64. package/src/room/utils.test.ts +71 -2
  65. package/src/room/utils.ts +52 -0
  66. package/src/test/promiseState.ts +23 -0
  67. package/src/test/signalServerSetup.ts +2 -1
  68. package/src/test/signalToken.ts +17 -13
  69. package/src/type-polyfills/header-extensions.d.ts +13 -0
  70. package/src/utils/AsyncQueue.ts +3 -3
@@ -1,4 +1,4 @@
1
- import { SignJWT } from 'jose';
1
+ import { AccessToken } from 'livekit-server-sdk';
2
2
 
3
3
  /**
4
4
  * Mint a LiveKit access token for the mock test-server (HS256, dev secret).
@@ -33,24 +33,28 @@ export async function createToken(opts: TokenOptions = {}): Promise<string> {
33
33
  secret = 'secret',
34
34
  ttlSeconds = 600,
35
35
  } = opts;
36
- const key = new TextEncoder().encode(secret);
37
- const payload: Record<string, unknown> = {
38
- video: { room, roomJoin: true, canPublish: true, canSubscribe: true, canPublishData: true },
39
- };
36
+ const attributes: Record<string, string> = {};
40
37
  if (signal) {
41
38
  const control: Record<string, unknown> = { signal };
42
39
  if (leaveAction !== undefined) {
43
40
  control.leaveAction = leaveAction;
44
41
  }
45
- payload.attributes = { 'lk.mock': JSON.stringify(control) };
42
+ attributes['lk.mock'] = JSON.stringify(control);
46
43
  }
47
- return new SignJWT(payload)
48
- .setProtectedHeader({ alg: 'HS256' })
49
- .setIssuer(apiKey)
50
- .setSubject(identity)
51
- .setIssuedAt()
52
- .setExpirationTime(`${ttlSeconds}s`)
53
- .sign(key);
44
+ const token = new AccessToken(apiKey, secret, {
45
+ ttl: ttlSeconds,
46
+ identity,
47
+ attributes,
48
+ });
49
+ token.addGrant({
50
+ room,
51
+ roomJoin: true,
52
+ canPublish: true,
53
+ canSubscribe: true,
54
+ canPublishData: true,
55
+ });
56
+
57
+ return token.toJwt();
54
58
  }
55
59
 
56
60
  /** A syntactically-valid token signed with the WRONG secret — for 401 tests. */
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Per-transceiver control over which RTP header extensions get negotiated. Declared as optional
3
+ * because it is not in lib.dom yet and not every browser implements it.
4
+ * https://w3c.github.io/webrtc-extensions/#rtcrtptransceiver-interface-extensions
5
+ */
6
+ interface RTCRtpTransceiver {
7
+ getHeaderExtensionsToNegotiate?(): RTCRtpHeaderExtensionCapability[];
8
+ setHeaderExtensionsToNegotiate?(extensions: RTCRtpHeaderExtensionCapability[]): void;
9
+ }
10
+
11
+ interface RTCRtpHeaderExtensionCapability {
12
+ direction?: 'sendrecv' | 'sendonly' | 'recvonly' | 'stopped';
13
+ }
@@ -3,9 +3,9 @@ import { Mutex } from '@livekit/mutex';
3
3
  type QueueTask<T> = () => PromiseLike<T>;
4
4
 
5
5
  enum QueueTaskStatus {
6
- 'WAITING',
7
- 'RUNNING',
8
- 'COMPLETED',
6
+ WAITING,
7
+ RUNNING,
8
+ COMPLETED,
9
9
  }
10
10
 
11
11
  type QueueTaskInfo = {