livekit-client 1.11.4 → 1.12.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +1 -3
- package/dist/livekit-client.e2ee.worker.js +2 -0
- package/dist/livekit-client.e2ee.worker.js.map +1 -0
- package/dist/livekit-client.e2ee.worker.mjs +1525 -0
- package/dist/livekit-client.e2ee.worker.mjs.map +1 -0
- package/dist/livekit-client.esm.mjs +4749 -4055
- package/dist/livekit-client.esm.mjs.map +1 -1
- package/dist/livekit-client.umd.js +1 -1
- package/dist/livekit-client.umd.js.map +1 -1
- package/dist/src/api/SignalClient.d.ts +4 -1
- package/dist/src/api/SignalClient.d.ts.map +1 -1
- package/dist/src/connectionHelper/checks/turn.d.ts.map +1 -1
- package/dist/src/connectionHelper/checks/websocket.d.ts.map +1 -1
- package/dist/src/e2ee/E2eeManager.d.ts +45 -0
- package/dist/src/e2ee/E2eeManager.d.ts.map +1 -0
- package/dist/src/e2ee/KeyProvider.d.ts +42 -0
- package/dist/src/e2ee/KeyProvider.d.ts.map +1 -0
- package/dist/src/e2ee/constants.d.ts +14 -0
- package/dist/src/e2ee/constants.d.ts.map +1 -0
- package/dist/src/e2ee/errors.d.ts +11 -0
- package/dist/src/e2ee/errors.d.ts.map +1 -0
- package/dist/src/e2ee/index.d.ts +4 -0
- package/dist/src/e2ee/index.d.ts.map +1 -0
- package/dist/src/e2ee/types.d.ts +129 -0
- package/dist/src/e2ee/types.d.ts.map +1 -0
- package/dist/src/e2ee/utils.d.ts +24 -0
- package/dist/src/e2ee/utils.d.ts.map +1 -0
- package/dist/src/e2ee/worker/FrameCryptor.d.ts +175 -0
- package/dist/src/e2ee/worker/FrameCryptor.d.ts.map +1 -0
- package/dist/src/e2ee/worker/ParticipantKeyHandler.d.ts +46 -0
- package/dist/src/e2ee/worker/ParticipantKeyHandler.d.ts.map +1 -0
- package/dist/src/e2ee/worker/e2ee.worker.d.ts +2 -0
- package/dist/src/e2ee/worker/e2ee.worker.d.ts.map +1 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/logger.d.ts +4 -1
- package/dist/src/logger.d.ts.map +1 -1
- package/dist/src/options.d.ts +5 -0
- package/dist/src/options.d.ts.map +1 -1
- package/dist/src/proto/livekit_models.d.ts +2 -2
- package/dist/src/proto/livekit_models.d.ts.map +1 -1
- package/dist/src/room/PCTransport.d.ts +3 -1
- package/dist/src/room/PCTransport.d.ts.map +1 -1
- package/dist/src/room/RTCEngine.d.ts +17 -3
- package/dist/src/room/RTCEngine.d.ts.map +1 -1
- package/dist/src/room/Room.d.ts +10 -0
- package/dist/src/room/Room.d.ts.map +1 -1
- package/dist/src/room/events.d.ts +14 -2
- package/dist/src/room/events.d.ts.map +1 -1
- package/dist/src/room/participant/LocalParticipant.d.ts +7 -2
- package/dist/src/room/participant/LocalParticipant.d.ts.map +1 -1
- package/dist/src/room/participant/Participant.d.ts +1 -0
- package/dist/src/room/participant/Participant.d.ts.map +1 -1
- package/dist/src/room/track/LocalTrack.d.ts.map +1 -1
- package/dist/src/room/track/RemoteVideoTrack.d.ts.map +1 -1
- package/dist/src/room/track/TrackPublication.d.ts +3 -0
- package/dist/src/room/track/TrackPublication.d.ts.map +1 -1
- package/dist/src/room/track/options.d.ts +2 -2
- package/dist/src/room/track/options.d.ts.map +1 -1
- package/dist/src/room/track/utils.d.ts +9 -0
- package/dist/src/room/track/utils.d.ts.map +1 -1
- package/dist/src/room/utils.d.ts +2 -0
- package/dist/src/room/utils.d.ts.map +1 -1
- package/dist/src/test/MockMediaStreamTrack.d.ts.map +1 -1
- package/dist/ts4.2/src/api/SignalClient.d.ts +4 -1
- package/dist/ts4.2/src/e2ee/E2eeManager.d.ts +45 -0
- package/dist/ts4.2/src/e2ee/KeyProvider.d.ts +42 -0
- package/dist/ts4.2/src/e2ee/constants.d.ts +14 -0
- package/dist/ts4.2/src/e2ee/errors.d.ts +11 -0
- package/dist/ts4.2/src/e2ee/index.d.ts +4 -0
- package/dist/ts4.2/src/e2ee/types.d.ts +129 -0
- package/dist/ts4.2/src/e2ee/utils.d.ts +24 -0
- package/dist/ts4.2/src/e2ee/worker/FrameCryptor.d.ts +175 -0
- package/dist/ts4.2/src/e2ee/worker/ParticipantKeyHandler.d.ts +46 -0
- package/dist/ts4.2/src/e2ee/worker/e2ee.worker.d.ts +2 -0
- package/dist/ts4.2/src/index.d.ts +1 -0
- package/dist/ts4.2/src/logger.d.ts +4 -1
- package/dist/ts4.2/src/options.d.ts +5 -0
- package/dist/ts4.2/src/proto/livekit_models.d.ts +2 -2
- package/dist/ts4.2/src/room/PCTransport.d.ts +3 -1
- package/dist/ts4.2/src/room/RTCEngine.d.ts +17 -3
- package/dist/ts4.2/src/room/Room.d.ts +10 -0
- package/dist/ts4.2/src/room/events.d.ts +14 -2
- package/dist/ts4.2/src/room/participant/LocalParticipant.d.ts +7 -2
- package/dist/ts4.2/src/room/participant/Participant.d.ts +1 -0
- package/dist/ts4.2/src/room/track/TrackPublication.d.ts +3 -0
- package/dist/ts4.2/src/room/track/options.d.ts +6 -6
- package/dist/ts4.2/src/room/track/utils.d.ts +9 -0
- package/dist/ts4.2/src/room/utils.d.ts +2 -0
- package/package.json +17 -7
- package/src/api/SignalClient.ts +28 -9
- package/src/connectionHelper/checks/turn.ts +1 -0
- package/src/connectionHelper/checks/websocket.ts +1 -0
- package/src/e2ee/E2eeManager.ts +374 -0
- package/src/e2ee/KeyProvider.ts +77 -0
- package/src/e2ee/constants.ts +40 -0
- package/src/e2ee/errors.ts +16 -0
- package/src/e2ee/index.ts +3 -0
- package/src/e2ee/types.ts +160 -0
- package/src/e2ee/utils.ts +127 -0
- package/src/e2ee/worker/FrameCryptor.test.ts +21 -0
- package/src/e2ee/worker/FrameCryptor.ts +614 -0
- package/src/e2ee/worker/ParticipantKeyHandler.ts +129 -0
- package/src/e2ee/worker/e2ee.worker.ts +217 -0
- package/src/e2ee/worker/tsconfig.json +6 -0
- package/src/index.ts +1 -0
- package/src/logger.ts +10 -2
- package/src/options.ts +6 -0
- package/src/proto/livekit_models.ts +12 -12
- package/src/room/PCTransport.ts +39 -9
- package/src/room/RTCEngine.ts +127 -34
- package/src/room/Room.ts +77 -22
- package/src/room/defaults.ts +1 -1
- package/src/room/events.ts +14 -0
- package/src/room/participant/LocalParticipant.ts +52 -8
- package/src/room/participant/Participant.ts +4 -0
- package/src/room/track/LocalTrack.ts +5 -4
- package/src/room/track/RemoteVideoTrack.ts +2 -2
- package/src/room/track/TrackPublication.ts +9 -1
- package/src/room/track/options.ts +3 -2
- package/src/room/track/utils.ts +27 -0
- package/src/room/utils.ts +5 -0
- package/src/room/worker.d.ts +4 -0
- package/src/test/MockMediaStreamTrack.ts +1 -0
@@ -2,13 +2,14 @@ import EventEmitter from 'eventemitter3';
|
|
2
2
|
import { SignalClient } from '../api/SignalClient';
|
3
3
|
import type { SignalOptions } from '../api/SignalClient';
|
4
4
|
import type { InternalRoomOptions } from '../options';
|
5
|
-
import { DataPacket, DataPacket_Kind, DisconnectReason, SpeakerInfo, TrackInfo, UserPacket } from '../proto/livekit_models';
|
6
|
-
import { AddTrackRequest, JoinResponse } from '../proto/livekit_rtc';
|
5
|
+
import { DataPacket, DataPacket_Kind, DisconnectReason, ParticipantInfo, Room as RoomModel, SpeakerInfo, TrackInfo, UserPacket } from '../proto/livekit_models';
|
6
|
+
import { AddTrackRequest, ConnectionQualityUpdate, JoinResponse, StreamStateUpdate, SubscriptionPermissionUpdate, SubscriptionResponse } from '../proto/livekit_rtc';
|
7
7
|
import PCTransport from './PCTransport';
|
8
8
|
import type LocalTrack from './track/LocalTrack';
|
9
9
|
import type LocalVideoTrack from './track/LocalVideoTrack';
|
10
10
|
import type { SimulcastTrackInfo } from './track/LocalVideoTrack';
|
11
|
-
import
|
11
|
+
import { Track } from './track/Track';
|
12
|
+
import type { TrackPublishOptions, VideoCodec } from './track/options';
|
12
13
|
/** @internal */
|
13
14
|
export default class RTCEngine extends EventEmitter<EngineEventCallbacks> {
|
14
15
|
private options;
|
@@ -55,6 +56,8 @@ export default class RTCEngine extends EventEmitter<EngineEventCallbacks> {
|
|
55
56
|
constructor(options: InternalRoomOptions);
|
56
57
|
join(url: string, token: string, opts: SignalOptions, abortSignal?: AbortSignal): Promise<JoinResponse>;
|
57
58
|
close(): Promise<void>;
|
59
|
+
cleanupPeerConnections(): Promise<void>;
|
60
|
+
cleanupClient(): Promise<void>;
|
58
61
|
addTrack(req: AddTrackRequest): Promise<TrackInfo>;
|
59
62
|
/**
|
60
63
|
* Removes sender from PeerConnection, returning true if it was removed successfully
|
@@ -67,6 +70,7 @@ export default class RTCEngine extends EventEmitter<EngineEventCallbacks> {
|
|
67
70
|
get dataSubscriberReadyState(): string | undefined;
|
68
71
|
getConnectedServerAddress(): Promise<string | undefined>;
|
69
72
|
private configure;
|
73
|
+
private setupSignalClientCallbacks;
|
70
74
|
private makeRTCConfiguration;
|
71
75
|
private createDataChannels;
|
72
76
|
private handleDataChannel;
|
@@ -120,6 +124,16 @@ export type EngineEventCallbacks = {
|
|
120
124
|
activeSpeakersUpdate: (speakers: Array<SpeakerInfo>) => void;
|
121
125
|
dataPacketReceived: (userPacket: UserPacket, kind: DataPacket_Kind) => void;
|
122
126
|
transportsCreated: (publisher: PCTransport, subscriber: PCTransport) => void;
|
127
|
+
/** @internal */
|
128
|
+
trackSenderAdded: (track: Track, sender: RTCRtpSender) => void;
|
129
|
+
rtpVideoMapUpdate: (rtpMap: Map<number, VideoCodec>) => void;
|
123
130
|
dcBufferStatusChanged: (isLow: boolean, kind: DataPacket_Kind) => void;
|
131
|
+
participantUpdate: (infos: ParticipantInfo[]) => void;
|
132
|
+
roomUpdate: (room: RoomModel) => void;
|
133
|
+
connectionQualityUpdate: (update: ConnectionQualityUpdate) => void;
|
134
|
+
speakersChanged: (speakerUpdates: SpeakerInfo[]) => void;
|
135
|
+
streamStateChanged: (update: StreamStateUpdate) => void;
|
136
|
+
subscriptionError: (resp: SubscriptionResponse) => void;
|
137
|
+
subscriptionPermissionUpdate: (update: SubscriptionPermissionUpdate) => void;
|
124
138
|
};
|
125
139
|
//# sourceMappingURL=RTCEngine.d.ts.map
|
@@ -44,6 +44,8 @@ declare class Room extends EventEmitter<RoomEventCallbacks> {
|
|
44
44
|
localParticipant: LocalParticipant;
|
45
45
|
/** options of room */
|
46
46
|
options: InternalRoomOptions;
|
47
|
+
/** reflects the sender encryption status of the local participant */
|
48
|
+
isE2EEEnabled: boolean;
|
47
49
|
private roomInfo?;
|
48
50
|
private identityToSid;
|
49
51
|
/** connect options of room */
|
@@ -55,6 +57,7 @@ declare class Room extends EventEmitter<RoomEventCallbacks> {
|
|
55
57
|
/** future holding client initiated connection attempt */
|
56
58
|
private connectFuture?;
|
57
59
|
private disconnectLock;
|
60
|
+
private e2eeManager;
|
58
61
|
private cachedParticipantSids;
|
59
62
|
private connectionReconcileInterval?;
|
60
63
|
/**
|
@@ -62,6 +65,11 @@ declare class Room extends EventEmitter<RoomEventCallbacks> {
|
|
62
65
|
* @param options
|
63
66
|
*/
|
64
67
|
constructor(options?: RoomOptions);
|
68
|
+
/**
|
69
|
+
* @experimental
|
70
|
+
*/
|
71
|
+
setE2EEEnabled(enabled: boolean): Promise<void>;
|
72
|
+
private setupE2EE;
|
65
73
|
/**
|
66
74
|
* if the current room has a participant with `recorder: true` in its JWT grant
|
67
75
|
**/
|
@@ -228,6 +236,8 @@ export type RoomEventCallbacks = {
|
|
228
236
|
audioPlaybackChanged: (playing: boolean) => void;
|
229
237
|
signalConnected: () => void;
|
230
238
|
recordingStatusChanged: (recording: boolean) => void;
|
239
|
+
participantEncryptionStatusChanged: (encrypted: boolean, participant?: Participant) => void;
|
240
|
+
encryptionError: (error: Error) => void;
|
231
241
|
dcBufferStatusChanged: (isLow: boolean, kind: DataPacket_Kind) => void;
|
232
242
|
activeDeviceChanged: (kind: MediaDeviceKind, deviceId: string) => void;
|
233
243
|
};
|
@@ -239,6 +239,8 @@ export declare enum RoomEvent {
|
|
239
239
|
* args: (isRecording: boolean)
|
240
240
|
*/
|
241
241
|
RecordingStatusChanged = "recordingStatusChanged",
|
242
|
+
ParticipantEncryptionStatusChanged = "participantEncryptionStatusChanged",
|
243
|
+
EncryptionError = "encryptionError",
|
242
244
|
/**
|
243
245
|
* Emits whenever the current buffer status of a data channel changes
|
244
246
|
* args: (isLow: boolean, kind: [[DataPacket_Kind]])
|
@@ -387,7 +389,9 @@ export declare enum ParticipantEvent {
|
|
387
389
|
* A participant's permission has changed. Currently only fired on LocalParticipant.
|
388
390
|
* args: (prevPermissions: [[ParticipantPermission]])
|
389
391
|
*/
|
390
|
-
ParticipantPermissionsChanged = "participantPermissionsChanged"
|
392
|
+
ParticipantPermissionsChanged = "participantPermissionsChanged",
|
393
|
+
/** @internal */
|
394
|
+
PCTrackAdded = "pcTrackAdded"
|
391
395
|
}
|
392
396
|
/** @internal */
|
393
397
|
export declare enum EngineEvent {
|
@@ -404,7 +408,15 @@ export declare enum EngineEvent {
|
|
404
408
|
MediaTrackAdded = "mediaTrackAdded",
|
405
409
|
ActiveSpeakersUpdate = "activeSpeakersUpdate",
|
406
410
|
DataPacketReceived = "dataPacketReceived",
|
407
|
-
|
411
|
+
RTPVideoMapUpdate = "rtpVideoMapUpdate",
|
412
|
+
DCBufferStatusChanged = "dcBufferStatusChanged",
|
413
|
+
ParticipantUpdate = "participantUpdate",
|
414
|
+
RoomUpdate = "roomUpdate",
|
415
|
+
SpeakersChanged = "speakersChanged",
|
416
|
+
StreamStateChanged = "streamStateChanged",
|
417
|
+
ConnectionQualityUpdate = "connectionQualityUpdate",
|
418
|
+
SubscriptionError = "subscriptionError",
|
419
|
+
SubscriptionPermissionUpdate = "subscriptionPermissionUpdate"
|
408
420
|
}
|
409
421
|
export declare enum TrackEvent {
|
410
422
|
Message = "message",
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import type { InternalRoomOptions } from '../../options';
|
2
|
-
import { DataPacket_Kind, ParticipantInfo } from '../../proto/livekit_models';
|
2
|
+
import { DataPacket_Kind, ParticipantInfo, ParticipantPermission } from '../../proto/livekit_models';
|
3
3
|
import { DataChannelInfo, TrackPublishedResponse } from '../../proto/livekit_rtc';
|
4
4
|
import type RTCEngine from '../RTCEngine';
|
5
5
|
import LocalTrack from '../track/LocalTrack';
|
@@ -26,6 +26,7 @@ export default class LocalParticipant extends Participant {
|
|
26
26
|
private participantTrackPermissions;
|
27
27
|
private allParticipantsAllowedToSubscribe;
|
28
28
|
private roomOptions;
|
29
|
+
private encryptionType;
|
29
30
|
private reconnectFuture?;
|
30
31
|
/** @internal */
|
31
32
|
constructor(sid: string, identity: string, engine: RTCEngine, options: InternalRoomOptions);
|
@@ -71,6 +72,10 @@ export default class LocalParticipant extends Participant {
|
|
71
72
|
* Resolves with a `LocalTrackPublication` instance if successful and `undefined` otherwise
|
72
73
|
*/
|
73
74
|
setScreenShareEnabled(enabled: boolean, options?: ScreenShareCaptureOptions, publishOptions?: TrackPublishOptions): Promise<LocalTrackPublication | undefined>;
|
75
|
+
/** @internal */
|
76
|
+
setPermissions(permissions: ParticipantPermission): boolean;
|
77
|
+
/** @internal */
|
78
|
+
setE2EEEnabled(enabled: boolean): Promise<void>;
|
74
79
|
/**
|
75
80
|
* Enable or disable publishing for a track by source. This serves as a simple
|
76
81
|
* way to manage the common tracks (camera, mic, or screen share).
|
@@ -108,7 +113,7 @@ export default class LocalParticipant extends Participant {
|
|
108
113
|
publishAdditionalCodecForTrack(track: LocalTrack | MediaStreamTrack, videoCodec: BackupVideoCodec, options?: TrackPublishOptions): Promise<void>;
|
109
114
|
unpublishTrack(track: LocalTrack | MediaStreamTrack, stopOnUnpublish?: boolean): Promise<LocalTrackPublication | undefined>;
|
110
115
|
unpublishTracks(tracks: LocalTrack[] | MediaStreamTrack[]): Promise<LocalTrackPublication[]>;
|
111
|
-
republishAllTracks(options?: TrackPublishOptions): Promise<void>;
|
116
|
+
republishAllTracks(options?: TrackPublishOptions, restartTracks?: boolean): Promise<void>;
|
112
117
|
/**
|
113
118
|
* Publish a new data payload to the room. Data will be forwarded to each
|
114
119
|
* participant in the room if the destination field in publishOptions is empty
|
@@ -32,6 +32,7 @@ export default class Participant extends EventEmitter<ParticipantEventCallbacks>
|
|
32
32
|
lastSpokeAt?: Date | undefined;
|
33
33
|
permissions?: ParticipantPermission;
|
34
34
|
private _connectionQuality;
|
35
|
+
get isEncrypted(): boolean;
|
35
36
|
/** @internal */
|
36
37
|
constructor(sid: string, identity: string, name?: string, metadata?: string);
|
37
38
|
getTracks(): TrackPublication[];
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import EventEmitter from 'eventemitter3';
|
2
|
+
import { Encryption_Type } from '../../proto/livekit_models';
|
2
3
|
import type { SubscriptionError, TrackInfo } from '../../proto/livekit_models';
|
3
4
|
import type { UpdateSubscription, UpdateTrackSettings } from '../../proto/livekit_rtc';
|
4
5
|
import LocalAudioTrack from './LocalAudioTrack';
|
@@ -22,12 +23,14 @@ export declare class TrackPublication extends EventEmitter<PublicationEventCallb
|
|
22
23
|
/** @internal */
|
23
24
|
trackInfo?: TrackInfo;
|
24
25
|
protected metadataMuted: boolean;
|
26
|
+
protected encryption: Encryption_Type;
|
25
27
|
constructor(kind: Track.Kind, id: string, name: string);
|
26
28
|
/** @internal */
|
27
29
|
setTrack(track?: Track): void;
|
28
30
|
get isMuted(): boolean;
|
29
31
|
get isEnabled(): boolean;
|
30
32
|
get isSubscribed(): boolean;
|
33
|
+
get isEncrypted(): boolean;
|
31
34
|
/**
|
32
35
|
* an [AudioTrack] if this publication holds an audio track
|
33
36
|
*/
|
@@ -208,17 +208,17 @@ export interface AudioPreset {
|
|
208
208
|
maxBitrate: number;
|
209
209
|
priority?: RTCPriorityType;
|
210
210
|
}
|
211
|
-
declare const
|
211
|
+
declare const backupCodecs: readonly [
|
212
|
+
"vp8",
|
213
|
+
"h264"
|
214
|
+
];
|
215
|
+
export declare const videoCodecs: readonly [
|
212
216
|
"vp8",
|
213
217
|
"h264",
|
214
218
|
"vp9",
|
215
219
|
"av1"
|
216
220
|
];
|
217
|
-
|
218
|
-
"vp8",
|
219
|
-
"h264"
|
220
|
-
];
|
221
|
-
export type VideoCodec = (typeof codecs)[number];
|
221
|
+
export type VideoCodec = (typeof videoCodecs)[number];
|
222
222
|
export type BackupVideoCodec = (typeof backupCodecs)[number];
|
223
223
|
export declare function isBackupCodec(codec: string): codec is BackupVideoCodec;
|
224
224
|
export declare function isCodecEqual(c1: string | undefined, c2: string | undefined): boolean;
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import { Track } from './Track';
|
1
2
|
import type { AudioCaptureOptions, CreateLocalTracksOptions, VideoCaptureOptions } from './options';
|
2
3
|
import type { AudioTrack } from './types';
|
3
4
|
export declare function mergeDefaultOptions(options?: CreateLocalTracksOptions, audioDefaults?: AudioCaptureOptions, videoDefaults?: VideoCaptureOptions): CreateLocalTracksOptions;
|
@@ -11,4 +12,12 @@ export declare function detectSilence(track: AudioTrack, timeOffset?: number): P
|
|
11
12
|
* @internal
|
12
13
|
*/
|
13
14
|
export declare function getNewAudioContext(): AudioContext | void;
|
15
|
+
/**
|
16
|
+
* @internal
|
17
|
+
*/
|
18
|
+
export declare function kindToSource(kind: MediaDeviceKind): Track.Source.Camera | Track.Source.Microphone | Track.Source.Unknown;
|
19
|
+
/**
|
20
|
+
* @internal
|
21
|
+
*/
|
22
|
+
export declare function sourceToKind(source: Track.Source): MediaDeviceKind | undefined;
|
14
23
|
//# sourceMappingURL=utils.d.ts.map
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import { ClientInfo } from '../proto/livekit_models';
|
2
2
|
import type LocalAudioTrack from './track/LocalAudioTrack';
|
3
3
|
import type RemoteAudioTrack from './track/RemoteAudioTrack';
|
4
|
+
import { VideoCodec } from './track/options';
|
4
5
|
export declare const ddExtensionURI = "https://aomediacodec.github.io/av1-rtp-spec/#dependency-descriptor-rtp-header-extension";
|
5
6
|
export declare function unpackStreamId(packed: string): string[];
|
6
7
|
export declare function sleep(duration: number): Promise<void>;
|
@@ -84,5 +85,6 @@ export declare class Mutex {
|
|
84
85
|
isLocked(): boolean;
|
85
86
|
lock(): Promise<() => void>;
|
86
87
|
}
|
88
|
+
export declare function isVideoCodec(maybeCodec: string): maybeCodec is VideoCodec;
|
87
89
|
export declare function unwrapConstraint(constraint: ConstrainDOMString): string;
|
88
90
|
//# sourceMappingURL=utils.d.ts.map
|
package/package.json
CHANGED
@@ -1,14 +1,21 @@
|
|
1
1
|
{
|
2
2
|
"name": "livekit-client",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.12.0",
|
4
4
|
"description": "JavaScript/TypeScript client SDK for LiveKit",
|
5
5
|
"main": "./dist/livekit-client.umd.js",
|
6
6
|
"unpkg": "./dist/livekit-client.umd.js",
|
7
7
|
"module": "./dist/livekit-client.esm.mjs",
|
8
8
|
"exports": {
|
9
|
-
"
|
10
|
-
|
11
|
-
|
9
|
+
".": {
|
10
|
+
"types": "./dist/src/index.d.ts",
|
11
|
+
"import": "./dist/livekit-client.esm.mjs",
|
12
|
+
"require": "./dist/livekit-client.umd.js"
|
13
|
+
},
|
14
|
+
"./e2ee-worker": {
|
15
|
+
"types": "./dist/src/e2ee/worker/e2ee.worker.d.ts",
|
16
|
+
"import": "./dist/livekit-client.e2ee.worker.mjs",
|
17
|
+
"require": "./dist/livekit-client.e2ee.worker.js"
|
18
|
+
}
|
12
19
|
},
|
13
20
|
"files": [
|
14
21
|
"dist",
|
@@ -18,7 +25,10 @@
|
|
18
25
|
"typesVersions": {
|
19
26
|
"<4.8": {
|
20
27
|
"./dist/src/index.d.ts": [
|
21
|
-
"./dist/
|
28
|
+
"./dist/ts4.2/src/index.d.ts"
|
29
|
+
],
|
30
|
+
"./dist/src/e2ee/worker/e2ee.worker.d.ts": [
|
31
|
+
"./dist/ts4.2//dist/src/e2ee/worker/e2ee.worker.d.ts"
|
22
32
|
]
|
23
33
|
}
|
24
34
|
},
|
@@ -26,11 +36,11 @@
|
|
26
36
|
"author": "David Zhao <david@davidzhao.com>",
|
27
37
|
"license": "Apache-2.0",
|
28
38
|
"scripts": {
|
29
|
-
"build": "rollup --config --bundleConfigAsCjs && yarn downlevel-dts",
|
39
|
+
"build": "rollup --config --bundleConfigAsCjs && rollup --config rollup.config.worker.js --bundleConfigAsCjs && yarn downlevel-dts",
|
30
40
|
"build:watch": "rollup --watch --config rollup.config.js",
|
31
41
|
"build-docs": "typedoc",
|
32
42
|
"proto": "protoc --plugin=node_modules/ts-proto/protoc-gen-ts_proto --ts_proto_opt=esModuleInterop=true --ts_proto_out=./src/proto --ts_proto_opt=outputClientImpl=false,useOptionals=messages,oneof=unions -I./protocol ./protocol/livekit_rtc.proto ./protocol/livekit_models.proto",
|
33
|
-
"sample": "vite
|
43
|
+
"sample": "vite example -c vite.config.js",
|
34
44
|
"lint": "eslint src",
|
35
45
|
"test": "jest",
|
36
46
|
"deploy": "gh-pages -d example/dist",
|
package/src/api/SignalClient.ts
CHANGED
@@ -60,6 +60,7 @@ export interface SignalOptions {
|
|
60
60
|
publishOnly?: string;
|
61
61
|
adaptiveStream?: boolean;
|
62
62
|
maxRetries: number;
|
63
|
+
e2eeEnabled: boolean;
|
63
64
|
}
|
64
65
|
|
65
66
|
type SignalMessage = SignalRequest['message'];
|
@@ -198,7 +199,7 @@ export class SignalClient {
|
|
198
199
|
return res;
|
199
200
|
}
|
200
201
|
|
201
|
-
connect(
|
202
|
+
private connect(
|
202
203
|
url: string,
|
203
204
|
token: string,
|
204
205
|
opts: ConnectOpts,
|
@@ -329,21 +330,38 @@ export class SignalClient {
|
|
329
330
|
});
|
330
331
|
}
|
331
332
|
|
333
|
+
/** @internal */
|
334
|
+
resetCallbacks = () => {
|
335
|
+
this.onAnswer = undefined;
|
336
|
+
this.onLeave = undefined;
|
337
|
+
this.onLocalTrackPublished = undefined;
|
338
|
+
this.onLocalTrackUnpublished = undefined;
|
339
|
+
this.onNegotiateRequested = undefined;
|
340
|
+
this.onOffer = undefined;
|
341
|
+
this.onRemoteMuteChanged = undefined;
|
342
|
+
this.onSubscribedQualityUpdate = undefined;
|
343
|
+
this.onTokenRefresh = undefined;
|
344
|
+
this.onTrickle = undefined;
|
345
|
+
this.onClose = undefined;
|
346
|
+
};
|
347
|
+
|
332
348
|
async close() {
|
333
349
|
const unlock = await this.closingLock.lock();
|
334
350
|
try {
|
335
351
|
this.isConnected = false;
|
336
352
|
if (this.ws) {
|
337
|
-
this.ws.onclose = null;
|
338
353
|
this.ws.onmessage = null;
|
339
354
|
this.ws.onopen = null;
|
355
|
+
this.ws.onclose = null;
|
340
356
|
|
341
357
|
// calling `ws.close()` only starts the closing handshake (CLOSING state), prefer to wait until state is actually CLOSED
|
342
|
-
const closePromise = new Promise((resolve) => {
|
358
|
+
const closePromise = new Promise<void>((resolve) => {
|
343
359
|
if (this.ws) {
|
344
|
-
this.ws.onclose =
|
360
|
+
this.ws.onclose = () => {
|
361
|
+
resolve();
|
362
|
+
};
|
345
363
|
} else {
|
346
|
-
resolve(
|
364
|
+
resolve();
|
347
365
|
}
|
348
366
|
});
|
349
367
|
|
@@ -353,9 +371,9 @@ export class SignalClient {
|
|
353
371
|
await Promise.race([closePromise, sleep(250)]);
|
354
372
|
}
|
355
373
|
this.ws = undefined;
|
356
|
-
this.clearPingInterval();
|
357
374
|
}
|
358
375
|
} finally {
|
376
|
+
this.clearPingInterval();
|
359
377
|
unlock();
|
360
378
|
}
|
361
379
|
}
|
@@ -402,7 +420,7 @@ export class SignalClient {
|
|
402
420
|
sendAddTrack(req: AddTrackRequest) {
|
403
421
|
return this.sendRequest({
|
404
422
|
$case: 'addTrack',
|
405
|
-
addTrack:
|
423
|
+
addTrack: req,
|
406
424
|
});
|
407
425
|
}
|
408
426
|
|
@@ -622,10 +640,11 @@ export class SignalClient {
|
|
622
640
|
|
623
641
|
private async handleOnClose(reason: string) {
|
624
642
|
if (!this.isConnected) return;
|
643
|
+
const onCloseCallback = this.onClose;
|
625
644
|
await this.close();
|
626
645
|
log.debug(`websocket connection closed: ${reason}`);
|
627
|
-
if (
|
628
|
-
|
646
|
+
if (onCloseCallback) {
|
647
|
+
onCloseCallback(reason);
|
629
648
|
}
|
630
649
|
}
|
631
650
|
|
@@ -15,6 +15,7 @@ export class WebSocketCheck extends Checker {
|
|
15
15
|
const joinRes = await signalClient.join(this.url, this.token, {
|
16
16
|
autoSubscribe: true,
|
17
17
|
maxRetries: 0,
|
18
|
+
e2eeEnabled: false,
|
18
19
|
});
|
19
20
|
this.appendMessage(`Connected to server, version ${joinRes.serverVersion}.`);
|
20
21
|
await signalClient.close();
|