@stream-io/video-client 1.57.0 → 1.58.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.
- package/CHANGELOG.md +13 -0
- package/dist/e2ee-worker.browser.es.js +1342 -0
- package/dist/e2ee-worker.browser.es.js.map +1 -0
- package/dist/index.browser.es.js +831 -55
- package/dist/index.browser.es.js.map +1 -1
- package/dist/index.cjs.js +875 -54
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.es.js +864 -55
- package/dist/index.es.js.map +1 -1
- package/dist/src/Call.d.ts +52 -6
- package/dist/src/coordinator/connection/connection.d.ts +1 -1
- package/dist/src/devices/CameraManager.d.ts +6 -0
- package/dist/src/devices/DeviceManager.d.ts +1 -0
- package/dist/src/devices/MicrophoneManager.d.ts +6 -0
- package/dist/src/devices/SpeakerManager.d.ts +2 -1
- package/dist/src/events/participant.d.ts +10 -3
- package/dist/src/gen/coordinator/index.d.ts +1363 -243
- package/dist/src/gen/video/sfu/models/models.d.ts +8 -0
- package/dist/src/helpers/TypedEventEmitter.d.ts +23 -0
- package/dist/src/helpers/ensureExhausted.d.ts +1 -1
- package/dist/src/permissions/PermissionsContext.d.ts +2 -2
- package/dist/src/rtc/BasePeerConnection.d.ts +3 -1
- package/dist/src/rtc/e2ee/E2EEManager.d.ts +12 -0
- package/dist/src/rtc/e2ee/EncryptionManager.d.ts +148 -0
- package/dist/src/rtc/e2ee/e2ee-worker.d.ts +25 -0
- package/dist/src/rtc/e2ee/events.d.ts +163 -0
- package/dist/src/rtc/e2ee/transformSupport.d.ts +21 -0
- package/dist/src/rtc/helpers/rtcConfiguration.d.ts +2 -2
- package/dist/src/rtc/index.d.ts +1 -0
- package/dist/src/rtc/mediaEngine.d.ts +23 -0
- package/dist/src/rtc/types.d.ts +2 -0
- package/dist/src/store/CallState.d.ts +21 -0
- package/dist/src/types.d.ts +15 -6
- package/index.ts +3 -0
- package/package.json +1 -1
- package/src/Call.ts +160 -26
- package/src/__tests__/Call.test.ts +15 -0
- package/src/coordinator/connection/connection.ts +6 -3
- package/src/devices/AudioDeviceManager.ts +6 -0
- package/src/devices/CameraManager.ts +51 -4
- package/src/devices/DeviceManager.ts +17 -0
- package/src/devices/MicrophoneManager.ts +55 -5
- package/src/devices/ScreenShareManager.ts +3 -0
- package/src/devices/SpeakerManager.ts +42 -12
- package/src/devices/__tests__/MicrophoneManagerRN.test.ts +1 -20
- package/src/devices/__tests__/SpeakerManager.test.ts +138 -42
- package/src/devices/__tests__/mocks.ts +36 -3
- package/src/events/__tests__/participant.test.ts +134 -1
- package/src/events/callEventHandlers.ts +9 -3
- package/src/events/participant.ts +42 -7
- package/src/gen/coordinator/index.ts +1384 -244
- package/src/gen/video/sfu/models/models.ts +15 -0
- package/src/helpers/TypedEventEmitter.ts +71 -0
- package/src/helpers/__tests__/TypedEventEmitter.test.ts +133 -0
- package/src/helpers/ensureExhausted.ts +4 -2
- package/src/permissions/PermissionsContext.ts +10 -5
- package/src/rtc/BasePeerConnection.ts +12 -1
- package/src/rtc/Publisher.ts +8 -0
- package/src/rtc/Subscriber.ts +5 -0
- package/src/rtc/__tests__/Publisher.test.ts +101 -0
- package/src/rtc/__tests__/Subscriber.test.ts +89 -0
- package/src/rtc/__tests__/mocks/webrtc.mocks.ts +31 -0
- package/src/rtc/e2ee/E2EEManager.ts +12 -0
- package/src/rtc/e2ee/EncryptionManager.ts +336 -0
- package/src/rtc/e2ee/SPEC.md +586 -0
- package/src/rtc/e2ee/__tests__/E2EEManager.contract.test.ts +39 -0
- package/src/rtc/e2ee/__tests__/EncryptionManager.test.ts +490 -0
- package/src/rtc/e2ee/__tests__/codec.test.ts +247 -0
- package/src/rtc/e2ee/__tests__/conformance.test.ts +184 -0
- package/src/rtc/e2ee/__tests__/failureTracker.test.ts +45 -0
- package/src/rtc/e2ee/__tests__/frameCounter.test.ts +90 -0
- package/src/rtc/e2ee/__tests__/keyStore.test.ts +221 -0
- package/src/rtc/e2ee/__tests__/notifications.test.ts +166 -0
- package/src/rtc/e2ee/__tests__/perf.test.ts +139 -0
- package/src/rtc/e2ee/__tests__/queue.test.ts +61 -0
- package/src/rtc/e2ee/__tests__/replayWindow.test.ts +133 -0
- package/src/rtc/e2ee/__tests__/trailer.test.ts +143 -0
- package/src/rtc/e2ee/__tests__/transform-pipeline.test.ts +839 -0
- package/src/rtc/e2ee/__tests__/transformSupport.test.ts +65 -0
- package/src/rtc/e2ee/e2ee-worker/codec.ts +220 -0
- package/src/rtc/e2ee/e2ee-worker/constants.ts +47 -0
- package/src/rtc/e2ee/e2ee-worker/decode.ts +159 -0
- package/src/rtc/e2ee/e2ee-worker/e2ee-worker-impl.ts +137 -0
- package/src/rtc/e2ee/e2ee-worker/encode.ts +147 -0
- package/src/rtc/e2ee/e2ee-worker/failureTracker.ts +26 -0
- package/src/rtc/e2ee/e2ee-worker/frameCounter.ts +37 -0
- package/src/rtc/e2ee/e2ee-worker/keyStore.ts +211 -0
- package/src/rtc/e2ee/e2ee-worker/notifications.ts +190 -0
- package/src/rtc/e2ee/e2ee-worker/perf.ts +129 -0
- package/src/rtc/e2ee/e2ee-worker/queue.ts +12 -0
- package/src/rtc/e2ee/e2ee-worker/replayWindow.ts +131 -0
- package/src/rtc/e2ee/e2ee-worker/trailer.ts +155 -0
- package/src/rtc/e2ee/e2ee-worker/tsconfig.json +8 -0
- package/src/rtc/e2ee/e2ee-worker/types.ts +29 -0
- package/src/rtc/e2ee/e2ee-worker.ts +27 -0
- package/src/rtc/e2ee/events.ts +179 -0
- package/src/rtc/e2ee/transformSupport.ts +35 -0
- package/src/rtc/helpers/rtcConfiguration.ts +4 -2
- package/src/rtc/index.ts +1 -0
- package/src/rtc/mediaEngine.ts +44 -0
- package/src/rtc/types.ts +2 -0
- package/src/store/CallState.ts +33 -1
- package/src/store/__tests__/CallState.test.ts +82 -1
- package/src/types.ts +23 -5
|
@@ -5,7 +5,7 @@ import type {
|
|
|
5
5
|
TrackPublished,
|
|
6
6
|
TrackUnpublished,
|
|
7
7
|
} from '../gen/video/sfu/event/events';
|
|
8
|
-
import type
|
|
8
|
+
import { type Participant, TrackType } from '../gen/video/sfu/models/models';
|
|
9
9
|
import {
|
|
10
10
|
StreamVideoParticipant,
|
|
11
11
|
StreamVideoParticipantPatch,
|
|
@@ -14,11 +14,21 @@ import {
|
|
|
14
14
|
import { CallState } from '../store';
|
|
15
15
|
import { trackTypeToParticipantStreamKey } from '../rtc';
|
|
16
16
|
import { pushToIfMissing } from '../helpers/array';
|
|
17
|
+
import type { E2EEManager } from '../rtc/e2ee/E2EEManager';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Reads the call's current encryption manager. Deliberately not the manager
|
|
21
|
+
* itself: `Call.setE2EEManager` may be called after these handlers are wired up.
|
|
22
|
+
*/
|
|
23
|
+
type GetE2EEManager = () => E2EEManager | undefined;
|
|
17
24
|
|
|
18
25
|
/**
|
|
19
26
|
* An event responder which handles the `participantJoined` event.
|
|
20
27
|
*/
|
|
21
|
-
export const watchParticipantJoined = (
|
|
28
|
+
export const watchParticipantJoined = (
|
|
29
|
+
state: CallState,
|
|
30
|
+
e2ee: GetE2EEManager | undefined = undefined,
|
|
31
|
+
) => {
|
|
22
32
|
return function onParticipantJoined(e: ParticipantJoined) {
|
|
23
33
|
const { participant } = e;
|
|
24
34
|
if (!participant) return;
|
|
@@ -30,7 +40,7 @@ export const watchParticipantJoined = (state: CallState) => {
|
|
|
30
40
|
// The SFU would send participant info as part of the `join`
|
|
31
41
|
// response and then follow up with a `participantJoined` event for
|
|
32
42
|
// already announced participants.
|
|
33
|
-
const orphanedTracks = reconcileOrphanedTracks(state, participant);
|
|
43
|
+
const orphanedTracks = reconcileOrphanedTracks(state, participant, e2ee);
|
|
34
44
|
state.updateOrAddParticipant(
|
|
35
45
|
participant.sessionId,
|
|
36
46
|
Object.assign<
|
|
@@ -77,7 +87,10 @@ export const watchParticipantUpdated = (state: CallState) => {
|
|
|
77
87
|
* An event responder which handles the `trackPublished` event.
|
|
78
88
|
* The SFU will send this event when a participant publishes a track.
|
|
79
89
|
*/
|
|
80
|
-
export const watchTrackPublished = (
|
|
90
|
+
export const watchTrackPublished = (
|
|
91
|
+
state: CallState,
|
|
92
|
+
e2ee: GetE2EEManager | undefined = undefined,
|
|
93
|
+
) => {
|
|
81
94
|
return function onTrackPublished(e: TrackPublished) {
|
|
82
95
|
const { type, sessionId } = e;
|
|
83
96
|
// An optimization for large calls.
|
|
@@ -85,7 +98,11 @@ export const watchTrackPublished = (state: CallState) => {
|
|
|
85
98
|
// events, and instead, it would only provide the participant's information
|
|
86
99
|
// once they start publishing a track.
|
|
87
100
|
if (e.participant) {
|
|
88
|
-
const orphanedTracks = reconcileOrphanedTracks(
|
|
101
|
+
const orphanedTracks = reconcileOrphanedTracks(
|
|
102
|
+
state,
|
|
103
|
+
e.participant,
|
|
104
|
+
e2ee,
|
|
105
|
+
);
|
|
89
106
|
const participant = Object.assign(e.participant, orphanedTracks);
|
|
90
107
|
state.updateOrAddParticipant(sessionId, participant);
|
|
91
108
|
} else {
|
|
@@ -100,12 +117,19 @@ export const watchTrackPublished = (state: CallState) => {
|
|
|
100
117
|
* An event responder which handles the `trackUnpublished` event.
|
|
101
118
|
* The SFU will send this event when a participant unpublishes a track.
|
|
102
119
|
*/
|
|
103
|
-
export const watchTrackUnpublished = (
|
|
120
|
+
export const watchTrackUnpublished = (
|
|
121
|
+
state: CallState,
|
|
122
|
+
e2ee: GetE2EEManager | undefined = undefined,
|
|
123
|
+
) => {
|
|
104
124
|
return function onTrackUnpublished(e: TrackUnpublished) {
|
|
105
125
|
const { type, sessionId } = e;
|
|
106
126
|
// An optimization for large calls. See `watchTrackPublished`.
|
|
107
127
|
if (e.participant) {
|
|
108
|
-
const orphanedTracks = reconcileOrphanedTracks(
|
|
128
|
+
const orphanedTracks = reconcileOrphanedTracks(
|
|
129
|
+
state,
|
|
130
|
+
e.participant,
|
|
131
|
+
e2ee,
|
|
132
|
+
);
|
|
109
133
|
const participant = Object.assign(e.participant, orphanedTracks);
|
|
110
134
|
state.updateOrAddParticipant(sessionId, participant, (p) => ({
|
|
111
135
|
pausedTracks: p.pausedTracks?.filter((t) => t !== type),
|
|
@@ -124,18 +148,29 @@ export const watchTrackUnpublished = (state: CallState) => {
|
|
|
124
148
|
*
|
|
125
149
|
* @param state the call state.
|
|
126
150
|
* @param participant the participant.
|
|
151
|
+
* @param e2ee accessor for the call's encryption manager, if any.
|
|
127
152
|
*/
|
|
128
153
|
const reconcileOrphanedTracks = (
|
|
129
154
|
state: CallState,
|
|
130
155
|
participant: Participant,
|
|
156
|
+
e2ee: GetE2EEManager | undefined,
|
|
131
157
|
): StreamVideoParticipantPatch | undefined => {
|
|
132
158
|
const orphanTracks = state.takeOrphanedTracks(participant.trackLookupPrefix);
|
|
133
159
|
if (!orphanTracks.length) return;
|
|
160
|
+
const manager = e2ee?.();
|
|
134
161
|
const reconciledTracks: StreamVideoParticipantPatch = {};
|
|
135
162
|
for (const orphan of orphanTracks) {
|
|
136
163
|
const key = trackTypeToParticipantStreamKey(orphan.trackType);
|
|
137
164
|
if (!key) continue;
|
|
138
165
|
reconciledTracks[key] = orphan.track;
|
|
166
|
+
|
|
167
|
+
if (manager && orphan.receiver) {
|
|
168
|
+
manager.decrypt(
|
|
169
|
+
orphan.receiver,
|
|
170
|
+
participant.userId,
|
|
171
|
+
TrackType[orphan.trackType],
|
|
172
|
+
);
|
|
173
|
+
}
|
|
139
174
|
}
|
|
140
175
|
return reconciledTracks;
|
|
141
176
|
};
|