@stream-io/video-react-native-sdk 1.45.1 → 1.46.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 +36 -2
- package/android/build.gradle +7 -1
- package/dist/commonjs/components/Call/CallContent/CallContent.js +1 -1
- package/dist/commonjs/components/Call/CallContent/CallContent.js.map +1 -1
- package/dist/commonjs/components/Call/CallContent/RTCViewPipIOS.js +78 -7
- package/dist/commonjs/components/Call/CallContent/RTCViewPipIOS.js.map +1 -1
- package/dist/commonjs/components/Call/CallContent/RTCViewPipNative.js +3 -0
- package/dist/commonjs/components/Call/CallContent/RTCViewPipNative.js.map +1 -1
- package/dist/commonjs/components/Call/RingingCallContent/OutgoingCall.js +4 -12
- package/dist/commonjs/components/Call/RingingCallContent/OutgoingCall.js.map +1 -1
- package/dist/commonjs/components/Participant/ParticipantView/VideoRenderer/TrackSubscriber.js +27 -4
- package/dist/commonjs/components/Participant/ParticipantView/VideoRenderer/TrackSubscriber.js.map +1 -1
- package/dist/commonjs/index.js +14 -1
- package/dist/commonjs/index.js.map +1 -1
- package/dist/commonjs/modules/encryption/EncryptionManager.js +305 -0
- package/dist/commonjs/modules/encryption/EncryptionManager.js.map +1 -0
- package/dist/commonjs/modules/encryption/eventMapping.js +143 -0
- package/dist/commonjs/modules/encryption/eventMapping.js.map +1 -0
- package/dist/commonjs/modules/encryption/index.js +13 -0
- package/dist/commonjs/modules/encryption/index.js.map +1 -0
- package/dist/commonjs/modules/encryption/parity.js +6 -0
- package/dist/commonjs/modules/encryption/parity.js.map +1 -0
- package/dist/commonjs/utils/StreamVideoRN/index.js +23 -0
- package/dist/commonjs/utils/StreamVideoRN/index.js.map +1 -1
- package/dist/commonjs/utils/internal/callingx/callingx.js +29 -4
- package/dist/commonjs/utils/internal/callingx/callingx.js.map +1 -1
- package/dist/commonjs/utils/internal/iosPipTrack.js +41 -0
- package/dist/commonjs/utils/internal/iosPipTrack.js.map +1 -0
- package/dist/commonjs/utils/internal/registerSDKGlobals.js +6 -0
- package/dist/commonjs/utils/internal/registerSDKGlobals.js.map +1 -1
- package/dist/commonjs/utils/internal/ringingCallLifecycle.js +142 -0
- package/dist/commonjs/utils/internal/ringingCallLifecycle.js.map +1 -0
- package/dist/commonjs/utils/push/internal/utils.js +4 -0
- package/dist/commonjs/utils/push/internal/utils.js.map +1 -1
- package/dist/commonjs/version.js +1 -1
- package/dist/module/components/Call/CallContent/CallContent.js +1 -1
- package/dist/module/components/Call/CallContent/CallContent.js.map +1 -1
- package/dist/module/components/Call/CallContent/RTCViewPipIOS.js +80 -9
- package/dist/module/components/Call/CallContent/RTCViewPipIOS.js.map +1 -1
- package/dist/module/components/Call/CallContent/RTCViewPipNative.js +3 -0
- package/dist/module/components/Call/CallContent/RTCViewPipNative.js.map +1 -1
- package/dist/module/components/Call/RingingCallContent/OutgoingCall.js +4 -12
- package/dist/module/components/Call/RingingCallContent/OutgoingCall.js.map +1 -1
- package/dist/module/components/Participant/ParticipantView/VideoRenderer/TrackSubscriber.js +28 -5
- package/dist/module/components/Participant/ParticipantView/VideoRenderer/TrackSubscriber.js.map +1 -1
- package/dist/module/index.js +5 -0
- package/dist/module/index.js.map +1 -1
- package/dist/module/modules/encryption/EncryptionManager.js +301 -0
- package/dist/module/modules/encryption/EncryptionManager.js.map +1 -0
- package/dist/module/modules/encryption/eventMapping.js +135 -0
- package/dist/module/modules/encryption/eventMapping.js.map +1 -0
- package/dist/module/modules/encryption/index.js +4 -0
- package/dist/module/modules/encryption/index.js.map +1 -0
- package/dist/module/modules/encryption/parity.js +4 -0
- package/dist/module/modules/encryption/parity.js.map +1 -0
- package/dist/module/utils/StreamVideoRN/index.js +23 -0
- package/dist/module/utils/StreamVideoRN/index.js.map +1 -1
- package/dist/module/utils/internal/callingx/callingx.js +29 -4
- package/dist/module/utils/internal/callingx/callingx.js.map +1 -1
- package/dist/module/utils/internal/iosPipTrack.js +35 -0
- package/dist/module/utils/internal/iosPipTrack.js.map +1 -0
- package/dist/module/utils/internal/registerSDKGlobals.js +6 -0
- package/dist/module/utils/internal/registerSDKGlobals.js.map +1 -1
- package/dist/module/utils/internal/ringingCallLifecycle.js +134 -0
- package/dist/module/utils/internal/ringingCallLifecycle.js.map +1 -0
- package/dist/module/utils/push/internal/utils.js +4 -0
- package/dist/module/utils/push/internal/utils.js.map +1 -1
- package/dist/module/version.js +1 -1
- package/dist/typescript/components/Call/CallContent/RTCViewPipIOS.d.ts.map +1 -1
- package/dist/typescript/components/Call/CallContent/RTCViewPipNative.d.ts +12 -0
- package/dist/typescript/components/Call/CallContent/RTCViewPipNative.d.ts.map +1 -1
- package/dist/typescript/components/Call/RingingCallContent/OutgoingCall.d.ts.map +1 -1
- package/dist/typescript/components/Participant/ParticipantView/VideoRenderer/TrackSubscriber.d.ts +11 -0
- package/dist/typescript/components/Participant/ParticipantView/VideoRenderer/TrackSubscriber.d.ts.map +1 -1
- package/dist/typescript/index.d.ts +1 -0
- package/dist/typescript/index.d.ts.map +1 -1
- package/dist/typescript/modules/encryption/EncryptionManager.d.ts +190 -0
- package/dist/typescript/modules/encryption/EncryptionManager.d.ts.map +1 -0
- package/dist/typescript/modules/encryption/eventMapping.d.ts +38 -0
- package/dist/typescript/modules/encryption/eventMapping.d.ts.map +1 -0
- package/dist/typescript/modules/encryption/index.d.ts +2 -0
- package/dist/typescript/modules/encryption/index.d.ts.map +1 -0
- package/dist/typescript/modules/encryption/parity.d.ts +55 -0
- package/dist/typescript/modules/encryption/parity.d.ts.map +1 -0
- package/dist/typescript/utils/StreamVideoRN/index.d.ts +20 -1
- package/dist/typescript/utils/StreamVideoRN/index.d.ts.map +1 -1
- package/dist/typescript/utils/StreamVideoRN/types.d.ts +67 -0
- package/dist/typescript/utils/StreamVideoRN/types.d.ts.map +1 -1
- package/dist/typescript/utils/internal/callingx/callingx.d.ts +1 -1
- package/dist/typescript/utils/internal/callingx/callingx.d.ts.map +1 -1
- package/dist/typescript/utils/internal/iosPipTrack.d.ts +9 -0
- package/dist/typescript/utils/internal/iosPipTrack.d.ts.map +1 -0
- package/dist/typescript/utils/internal/registerSDKGlobals.d.ts.map +1 -1
- package/dist/typescript/utils/internal/ringingCallLifecycle.d.ts +27 -0
- package/dist/typescript/utils/internal/ringingCallLifecycle.d.ts.map +1 -0
- package/dist/typescript/utils/push/internal/utils.d.ts.map +1 -1
- package/dist/typescript/version.d.ts +1 -1
- package/ios/RTCViewPip.swift +33 -8
- package/ios/RTCViewPipManager.mm +1 -0
- package/package.json +8 -8
- package/src/components/Call/CallContent/CallContent.tsx +1 -1
- package/src/components/Call/CallContent/RTCViewPipIOS.tsx +92 -10
- package/src/components/Call/CallContent/RTCViewPipNative.tsx +13 -0
- package/src/components/Call/RingingCallContent/OutgoingCall.tsx +4 -12
- package/src/components/Participant/ParticipantView/VideoRenderer/TrackSubscriber.tsx +58 -5
- package/src/index.ts +5 -0
- package/src/modules/encryption/EncryptionManager.ts +360 -0
- package/src/modules/encryption/eventMapping.ts +151 -0
- package/src/modules/encryption/index.ts +1 -0
- package/src/modules/encryption/parity.ts +83 -0
- package/src/utils/StreamVideoRN/index.ts +24 -1
- package/src/utils/StreamVideoRN/types.ts +68 -0
- package/src/utils/internal/callingx/callingx.ts +37 -2
- package/src/utils/internal/iosPipTrack.ts +39 -0
- package/src/utils/internal/registerSDKGlobals.ts +2 -0
- package/src/utils/internal/ringingCallLifecycle.ts +148 -0
- package/src/utils/push/internal/utils.ts +4 -0
- package/src/version.ts +1 -1
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.EncryptionManager = void 0;
|
|
7
|
+
var _reactNativeWebrtc = require("@stream-io/react-native-webrtc");
|
|
8
|
+
var _videoClient = require("@stream-io/video-client");
|
|
9
|
+
var _eventMapping = require("./eventMapping");
|
|
10
|
+
/**
|
|
11
|
+
* Distributes keys to the native encryption manager and attaches
|
|
12
|
+
* encrypt/decrypt transforms to RTCRtpSenders and RTCRtpReceivers.
|
|
13
|
+
*
|
|
14
|
+
* The public surface matches the web
|
|
15
|
+
* {@link https://github.com/GetStream/stream-video-js/blob/main/packages/client/src/rtc/e2ee/EncryptionManager.ts | EncryptionManager}
|
|
16
|
+
* method for method, so host code is portable between the two SDKs.
|
|
17
|
+
*
|
|
18
|
+
* The crypto itself lives in the WebRTC binary, not here: frames never cross
|
|
19
|
+
* the React Native bridge. This class carries key and attach commands over it,
|
|
20
|
+
* and diagnostic events back.
|
|
21
|
+
*
|
|
22
|
+
* Like the keys it installs, the manager is application-owned: create one per
|
|
23
|
+
* call, attach it before {@link https://github.com/GetStream/stream-video-js/blob/main/packages/client/src/Call.ts | Call}`.join()`,
|
|
24
|
+
* and {@link EncryptionManager.dispose | dispose} it when that call is done.
|
|
25
|
+
* Nothing in the SDK will do it for you, and on React Native the leak is native
|
|
26
|
+
* rather than collectable.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```ts
|
|
30
|
+
* if (EncryptionManager.isSupported()) {
|
|
31
|
+
* const e2ee = await EncryptionManager.create(call.currentUserId);
|
|
32
|
+
* e2ee.setSharedKey(0, keyBytes);
|
|
33
|
+
* call.setE2EEManager(e2ee); // must happen before call.join()
|
|
34
|
+
* }
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
class EncryptionManager {
|
|
38
|
+
bridged = [];
|
|
39
|
+
disposed = false;
|
|
40
|
+
constructor(native, algorithm) {
|
|
41
|
+
this.native = native;
|
|
42
|
+
this.algorithm = algorithm;
|
|
43
|
+
this.logger = _videoClient.videoLoggerSystem.getLogger('EncryptionManager');
|
|
44
|
+
this.events = new _videoClient.TypedEventEmitter(this.logger);
|
|
45
|
+
// Native dispatches per event name, so the one handler is registered under
|
|
46
|
+
// each of them, and each registration has to be undone on dispose.
|
|
47
|
+
for (const type of _eventMapping.E2EE_EVENT_TYPES) {
|
|
48
|
+
this.native.on(type, this.handleNativeEvent);
|
|
49
|
+
this.bridged.push([type, this.handleNativeEvent]);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
handleNativeEvent = data => {
|
|
53
|
+
const event = (0, _eventMapping.mapNativeEvent)(data);
|
|
54
|
+
if (!event) return;
|
|
55
|
+
this.events.emit(event.type, event.payload);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Whether E2EE can run here. Use it to guard UI, or to avoid calling
|
|
60
|
+
* {@link create} where it would throw.
|
|
61
|
+
*
|
|
62
|
+
* `false` means the installed `@stream-io/react-native-webrtc` predates E2EE
|
|
63
|
+
* support.
|
|
64
|
+
*/
|
|
65
|
+
static isSupported = () => _reactNativeWebrtc.RTCEncryptionManager?.isSupported() ?? false;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Create an EncryptionManager and initialize the underlying native manager.
|
|
69
|
+
*
|
|
70
|
+
* Attach it with `call.setE2EEManager()` **before** `call.join()`: the join
|
|
71
|
+
* request carries the E2EE flag, and the peer connections are built with the
|
|
72
|
+
* transforms in place.
|
|
73
|
+
*
|
|
74
|
+
* Resolves rather than returning directly because every Stream SDK exposes
|
|
75
|
+
* this as a promise; nothing here is actually asynchronous, since a blocking
|
|
76
|
+
* native create is what keeps a sender from ever existing unencrypted.
|
|
77
|
+
*
|
|
78
|
+
* @param userId - The local user's ID, normally `call.currentUserId`.
|
|
79
|
+
* @param options - the create options.
|
|
80
|
+
* @throws {Error} If E2EE is unavailable. It never degrades to plaintext.
|
|
81
|
+
*/
|
|
82
|
+
static create = async (userId, options) => {
|
|
83
|
+
if (!_reactNativeWebrtc.RTCEncryptionManager) {
|
|
84
|
+
throw new Error('E2EE requires a version of @stream-io/react-native-webrtc that supports RTCEncryptionManager');
|
|
85
|
+
}
|
|
86
|
+
if (!_reactNativeWebrtc.RTCEncryptionManager.isSupported()) {
|
|
87
|
+
throw new Error('E2EE is not supported on this device');
|
|
88
|
+
}
|
|
89
|
+
const algorithm = options?.algorithm ?? 'AES-128-GCM';
|
|
90
|
+
const native = _reactNativeWebrtc.RTCEncryptionManager.create(userId, {
|
|
91
|
+
algorithm: (0, _eventMapping.algorithmToNative)(algorithm)
|
|
92
|
+
});
|
|
93
|
+
return new EncryptionManager(native, algorithm);
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Subscribe to an E2EE event.
|
|
98
|
+
*
|
|
99
|
+
* @returns a function that unsubscribes the listener.
|
|
100
|
+
*/
|
|
101
|
+
on = (event, fn) => this.events.on(event, fn);
|
|
102
|
+
|
|
103
|
+
/** Unsubscribe a listener registered with {@link on}. */
|
|
104
|
+
off = (event, fn) => this.events.off(event, fn);
|
|
105
|
+
|
|
106
|
+
/** Drop every listener, or every listener of one event. */
|
|
107
|
+
removeAllListeners = event => this.events.removeAllListeners(event);
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Set a per-user AES-GCM encryption key in the native key store.
|
|
111
|
+
*
|
|
112
|
+
* Use it when each participant has their own key from a central authority.
|
|
113
|
+
* The receiver picks the right one by the `keyIndex` in the frame trailer.
|
|
114
|
+
*
|
|
115
|
+
* @param userId - The key owner.
|
|
116
|
+
* @param keyIndex - Increases with each rotation.
|
|
117
|
+
* @param rawKey - 16 bytes for AES-128-GCM, 32 for AES-256-GCM.
|
|
118
|
+
*/
|
|
119
|
+
setKey = (userId, keyIndex, rawKey) => {
|
|
120
|
+
this.assertUsable();
|
|
121
|
+
this.validateKeyIndex(keyIndex);
|
|
122
|
+
this.validateKeyLength(rawKey);
|
|
123
|
+
this.native.setKey(userId, keyIndex, this.copyKey(rawKey));
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Fallback key for any user without a per-user key. The simplest E2EE mode:
|
|
128
|
+
* one key for everyone, usually passphrase-derived, no distribution needed.
|
|
129
|
+
* Setting an epoch makes it active for encryption while older epochs remain
|
|
130
|
+
* available to decrypt in-flight frames until {@link removeSharedKey}.
|
|
131
|
+
*
|
|
132
|
+
* @param keyIndex - An integer 0-255, since one trailer byte carries it.
|
|
133
|
+
* @param rawKey - 16 bytes for AES-128-GCM, 32 for AES-256-GCM.
|
|
134
|
+
*/
|
|
135
|
+
setSharedKey = (keyIndex, rawKey) => {
|
|
136
|
+
this.assertUsable();
|
|
137
|
+
this.validateKeyIndex(keyIndex);
|
|
138
|
+
this.validateKeyLength(rawKey);
|
|
139
|
+
this.native.setSharedKey(keyIndex, this.copyKey(rawKey));
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Retire one of a user's key epochs, leaving their other epochs usable.
|
|
144
|
+
*
|
|
145
|
+
* @param userId - The key owner.
|
|
146
|
+
* @param keyIndex - The exact epoch to remove. Absent epochs are a no-op.
|
|
147
|
+
*/
|
|
148
|
+
removeKey = (userId, keyIndex) => {
|
|
149
|
+
this.assertUsable();
|
|
150
|
+
this.validateKeyIndex(keyIndex);
|
|
151
|
+
this.native.removeKey(userId, keyIndex);
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Drop every key a user holds from the local key store, so later frames of
|
|
156
|
+
* theirs no longer decrypt.
|
|
157
|
+
*
|
|
158
|
+
* This is local cleanup, not remote revocation: it cannot stop that
|
|
159
|
+
* participant from decrypting anything, and a shared key still decrypts them.
|
|
160
|
+
* Revoking access means withholding future keys, which the application owns.
|
|
161
|
+
*
|
|
162
|
+
* To retire one rotated epoch instead, use {@link removeKey}.
|
|
163
|
+
*/
|
|
164
|
+
removeAllKeys = userId => {
|
|
165
|
+
this.assertUsable();
|
|
166
|
+
this.native.removeAllKeys(userId);
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Remove one shared-key epoch from the native receive key ring.
|
|
171
|
+
*
|
|
172
|
+
* If this is the active epoch, shared-key encryption stops until
|
|
173
|
+
* {@link setSharedKey} succeeds again. An older epoch is not reactivated.
|
|
174
|
+
*
|
|
175
|
+
* @param keyIndex - The exact shared-key epoch to remove.
|
|
176
|
+
*/
|
|
177
|
+
removeSharedKey = keyIndex => {
|
|
178
|
+
this.assertUsable();
|
|
179
|
+
this.validateKeyIndex(keyIndex);
|
|
180
|
+
this.native.removeSharedKey(keyIndex);
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Called by the Publisher when it adds a transceiver.
|
|
185
|
+
*
|
|
186
|
+
* Synchronous all the way to the native `SetFrameTransformer` call: were it
|
|
187
|
+
* async, the sender would exist before its transform did, which is a
|
|
188
|
+
* plaintext window. A failure throws instead of publishing cleartext.
|
|
189
|
+
*
|
|
190
|
+
* @param sender - The sender to encrypt.
|
|
191
|
+
* @param codec - Codec name, e.g. 'vp8', selecting the clear-byte rules.
|
|
192
|
+
* @param trackType - `TrackType` enum name, e.g. 'SCREEN_SHARE_AUDIO'.
|
|
193
|
+
* @internal
|
|
194
|
+
*/
|
|
195
|
+
encrypt = (sender, codec, trackType) => {
|
|
196
|
+
this.assertUsable();
|
|
197
|
+
this.native.encrypt(sender, codec, (0, _eventMapping.trackTypeToNative)(trackType));
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Called by the Subscriber when a remote track arrives.
|
|
202
|
+
*
|
|
203
|
+
* @param receiver - The receiver to decrypt.
|
|
204
|
+
* @param userId - The remote user, for key lookup.
|
|
205
|
+
* @param trackType - `TrackType` enum name, e.g. 'SCREEN_SHARE_AUDIO'.
|
|
206
|
+
* @internal
|
|
207
|
+
*/
|
|
208
|
+
decrypt = (receiver, userId, trackType) => {
|
|
209
|
+
this.assertUsable();
|
|
210
|
+
this.native.decrypt(receiver, userId, (0, _eventMapping.trackTypeToNative)(trackType));
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Toggle periodic performance reporting.
|
|
215
|
+
*
|
|
216
|
+
* While on, `e2ee.perf_report` is emitted once per second with per-track FPS
|
|
217
|
+
* and crypto timings. Useful for debugging throughput.
|
|
218
|
+
*/
|
|
219
|
+
enablePerformanceReporting = enabled => {
|
|
220
|
+
this.assertUsable();
|
|
221
|
+
// Observational, so it is the one native call that need not block. Kept
|
|
222
|
+
// void-returning to match the web manager.
|
|
223
|
+
this.native.enablePerformanceReporting(enabled).catch(err => this.logger.warn('Failed to toggle performance reporting', err));
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Request a snapshot of the installed keys. It arrives later as the
|
|
228
|
+
* `e2ee.key_state` event, listing fingerprints only, never key material.
|
|
229
|
+
*/
|
|
230
|
+
requestKeyState = () => {
|
|
231
|
+
this.assertUsable();
|
|
232
|
+
this.native.requestKeyState().catch(err => this.logger.warn('Failed to request key state', err));
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Release the native manager and all resources.
|
|
237
|
+
*
|
|
238
|
+
* **The application owns this object's lifetime — the SDK never disposes it.**
|
|
239
|
+
* Nothing releases the native manager when a peer connection closes, and there
|
|
240
|
+
* is no detach API, so an undisposed manager keeps its transforms and its key
|
|
241
|
+
* material alive for the lifetime of the process. Dispose it together with the
|
|
242
|
+
* call instance whose flow has ended; a later flow gets a fresh call and a
|
|
243
|
+
* fresh manager (see `Call.setE2EEManager`).
|
|
244
|
+
*
|
|
245
|
+
* In-flight frames are dropped rather than drained.
|
|
246
|
+
*
|
|
247
|
+
* The manager is unusable afterwards and every key or attach method throws.
|
|
248
|
+
* Call {@link create} for a new one. Safe to call more than once.
|
|
249
|
+
*/
|
|
250
|
+
dispose = () => {
|
|
251
|
+
if (this.disposed) return;
|
|
252
|
+
this.disposed = true;
|
|
253
|
+
for (const [type, handler] of this.bridged) {
|
|
254
|
+
this.native.off(type, handler);
|
|
255
|
+
}
|
|
256
|
+
this.bridged.length = 0;
|
|
257
|
+
try {
|
|
258
|
+
this.native.dispose();
|
|
259
|
+
} catch (err) {
|
|
260
|
+
// Local cleanup still has to finish, or listeners outlive the manager.
|
|
261
|
+
this.logger.warn('Failed to dispose the native encryption manager', err);
|
|
262
|
+
}
|
|
263
|
+
this.events.removeAllListeners();
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* {@link dispose} releases the native manager, so an attached transform would
|
|
268
|
+
* point at nothing: frames would stall with no error and no event. Throwing
|
|
269
|
+
* is also fail-closed, since a caller that swallows it still publishes
|
|
270
|
+
* nothing rather than cleartext.
|
|
271
|
+
*/
|
|
272
|
+
assertUsable = () => {
|
|
273
|
+
if (this.disposed) throw new Error(`EncryptionManager is disposed`);
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* The caller keeps ownership of its buffer and may re-import the same bytes,
|
|
278
|
+
* so hand native a copy rather than a view onto memory that can change.
|
|
279
|
+
*/
|
|
280
|
+
copyKey = rawKey => {
|
|
281
|
+
const copy = new Uint8Array(rawKey.byteLength);
|
|
282
|
+
copy.set(new Uint8Array(rawKey));
|
|
283
|
+
return copy;
|
|
284
|
+
};
|
|
285
|
+
validateKeyLength = rawKey => {
|
|
286
|
+
const is256 = this.algorithm === 'AES-256-GCM';
|
|
287
|
+
const expected = is256 ? 32 : 16;
|
|
288
|
+
if (rawKey.byteLength !== expected) {
|
|
289
|
+
throw new Error(`Key must be exactly ${expected} bytes (${is256 ? 'AES-256' : 'AES-128'})`);
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* One trailer byte carries the keyIndex. A larger value would truncate to
|
|
295
|
+
* `keyIndex & 0xFF`, so the receiver would look up the wrong key and fail
|
|
296
|
+
* every decrypt. Reject it rather than ship a silently broken key epoch.
|
|
297
|
+
*/
|
|
298
|
+
validateKeyIndex = keyIndex => {
|
|
299
|
+
if (!Number.isInteger(keyIndex) || keyIndex < 0 || keyIndex > 255) {
|
|
300
|
+
throw new Error(`keyIndex must be an integer between 0 and 255, got ${keyIndex}`);
|
|
301
|
+
}
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
exports.EncryptionManager = EncryptionManager;
|
|
305
|
+
//# sourceMappingURL=EncryptionManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNativeWebrtc","require","_videoClient","_eventMapping","EncryptionManager","bridged","disposed","constructor","native","algorithm","logger","videoLoggerSystem","getLogger","events","TypedEventEmitter","type","E2EE_EVENT_TYPES","on","handleNativeEvent","push","data","event","mapNativeEvent","emit","payload","isSupported","RTCEncryptionManager","create","userId","options","Error","algorithmToNative","fn","off","removeAllListeners","setKey","keyIndex","rawKey","assertUsable","validateKeyIndex","validateKeyLength","copyKey","setSharedKey","removeKey","removeAllKeys","removeSharedKey","encrypt","sender","codec","trackType","trackTypeToNative","decrypt","receiver","enablePerformanceReporting","enabled","catch","err","warn","requestKeyState","dispose","handler","length","copy","Uint8Array","byteLength","set","is256","expected","Number","isInteger","exports"],"sourceRoot":"../../../../src","sources":["modules/encryption/EncryptionManager.ts"],"mappings":";;;;;;AAAA,IAAAA,kBAAA,GAAAC,OAAA;AAKA,IAAAC,YAAA,GAAAD,OAAA;AAUA,IAAAE,aAAA,GAAAF,OAAA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMG,iBAAiB,CAAwB;EAKnCC,OAAO,GAEpB,EAAE;EACEC,QAAQ,GAAG,KAAK;EAEhBC,WAAWA,CAACC,MAA4B,EAAEC,SAAwB,EAAE;IAC1E,IAAI,CAACD,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACC,SAAS,GAAGA,SAAS;IAC1B,IAAI,CAACC,MAAM,GAAGC,8BAAiB,CAACC,SAAS,CAAC,mBAAmB,CAAC;IAC9D,IAAI,CAACC,MAAM,GAAG,IAAIC,8BAAiB,CAAe,IAAI,CAACJ,MAAM,CAAC;IAC9D;IAC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C2B,UAAU,CAAC;IAC9CF,IAAI,CAACG,GAAG,CAAC,IAAIF,UAAU,CAAC1B,MAAM,CAAC,CAAC;IAChC,OAAOyB,IAAI;EACb,CAAC;EAEOtB,iBAAiB,GAAIH,MAAmB,IAAK;IACnD,MAAM6B,KAAK,GAAG,IAAI,CAACzD,SAAS,KAAK,aAAa;IAC9C,MAAM0D,QAAQ,GAAGD,KAAK,GAAG,EAAE,GAAG,EAAE;IAChC,IAAI7B,MAAM,CAAC2B,UAAU,KAAKG,QAAQ,EAAE;MAClC,MAAM,IAAIrC,KAAK,CACb,uBAAuBqC,QAAQ,WAAWD,KAAK,GAAG,SAAS,GAAG,SAAS,GACzE,CAAC;IACH;EACF,CAAC;;EAED;AACF;AACA;AACA;AACA;EACU3B,gBAAgB,GAAIH,QAAgB,IAAK;IAC/C,IAAI,CAACgC,MAAM,CAACC,SAAS,CAACjC,QAAQ,CAAC,IAAIA,QAAQ,GAAG,CAAC,IAAIA,QAAQ,GAAG,GAAG,EAAE;MACjE,MAAM,IAAIN,KAAK,CACb,sDAAsDM,QAAQ,EAChE,CAAC;IACH;EACF,CAAC;AACH;AAACkC,OAAA,CAAAlE,iBAAA,GAAAA,iBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.trackTypeToNative = exports.trackTypeFromNative = exports.mapNativeEvent = exports.algorithmToNative = exports.E2EE_EVENT_TYPES = void 0;
|
|
7
|
+
var _reactNativeWebrtc = require("@stream-io/react-native-webrtc");
|
|
8
|
+
/**
|
|
9
|
+
* The core RTC layer labels tracks with the `TrackType` enum *name*
|
|
10
|
+
* (`SfuModels.TrackType[trackType]`), while the native manager takes a numeric
|
|
11
|
+
* enum. Screen-share audio is deliberately its own value: native keeps replay
|
|
12
|
+
* state per (userId, trackType), so folding it into `AUDIO` mis-groups it.
|
|
13
|
+
*
|
|
14
|
+
* These read the native enums inside the function body on purpose. This module
|
|
15
|
+
* is reachable from the SDK's public entry point, so an app whose
|
|
16
|
+
* `@stream-io/react-native-webrtc` predates E2EE would crash on import if the
|
|
17
|
+
* enums were dereferenced at module scope - even if it never touches E2EE.
|
|
18
|
+
*/
|
|
19
|
+
const trackTypeToNative = trackType => {
|
|
20
|
+
switch (trackType) {
|
|
21
|
+
case 'AUDIO':
|
|
22
|
+
return _reactNativeWebrtc.RTCEncryptionTrackType.AUDIO;
|
|
23
|
+
case 'VIDEO':
|
|
24
|
+
return _reactNativeWebrtc.RTCEncryptionTrackType.VIDEO;
|
|
25
|
+
case 'SCREEN_SHARE':
|
|
26
|
+
return _reactNativeWebrtc.RTCEncryptionTrackType.SCREEN_SHARE;
|
|
27
|
+
case 'SCREEN_SHARE_AUDIO':
|
|
28
|
+
return _reactNativeWebrtc.RTCEncryptionTrackType.SCREEN_SHARE_AUDIO;
|
|
29
|
+
default:
|
|
30
|
+
// Native infers audio vs video from the sender rather than pinning a
|
|
31
|
+
// wrong value.
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/** Map a native track type back to the name the web events carry. */
|
|
37
|
+
exports.trackTypeToNative = trackTypeToNative;
|
|
38
|
+
const trackTypeFromNative = trackType => {
|
|
39
|
+
switch (trackType) {
|
|
40
|
+
case _reactNativeWebrtc.RTCEncryptionTrackType.AUDIO:
|
|
41
|
+
return 'AUDIO';
|
|
42
|
+
case _reactNativeWebrtc.RTCEncryptionTrackType.VIDEO:
|
|
43
|
+
return 'VIDEO';
|
|
44
|
+
case _reactNativeWebrtc.RTCEncryptionTrackType.SCREEN_SHARE:
|
|
45
|
+
return 'SCREEN_SHARE';
|
|
46
|
+
case _reactNativeWebrtc.RTCEncryptionTrackType.SCREEN_SHARE_AUDIO:
|
|
47
|
+
return 'SCREEN_SHARE_AUDIO';
|
|
48
|
+
default:
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/** Map the public algorithm name to the native enum. */
|
|
54
|
+
exports.trackTypeFromNative = trackTypeFromNative;
|
|
55
|
+
const algorithmToNative = algorithm => algorithm === 'AES-256-GCM' ? _reactNativeWebrtc.RTCEncryptionAlgorithm.AES_256_GCM : _reactNativeWebrtc.RTCEncryptionAlgorithm.AES_128_GCM;
|
|
56
|
+
exports.algorithmToNative = algorithmToNative;
|
|
57
|
+
const toTrackPerf = row => ({
|
|
58
|
+
userId: row.userId,
|
|
59
|
+
trackType: trackTypeFromNative(row.trackType) ?? '',
|
|
60
|
+
fps: row.fps,
|
|
61
|
+
maxCryptoMs: row.maxCryptoMs
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Translate a native event into the payload the web manager emits, so a host
|
|
66
|
+
* can write one set of handlers for both platforms.
|
|
67
|
+
*
|
|
68
|
+
* Two things have to be reshaped rather than passed through: native track types
|
|
69
|
+
* are numeric, and native flattens `managerId`/`type`/`userId` alongside the
|
|
70
|
+
* payload of every event, including the two (`perf_report`, `key_state`) that
|
|
71
|
+
* are not about a single user. Fields the web types require but native leaves
|
|
72
|
+
* optional get an explicit default, so a handler never reads `undefined` where
|
|
73
|
+
* its type promises a value.
|
|
74
|
+
*
|
|
75
|
+
* @returns the mapped event, or `undefined` for an unrecognized event name.
|
|
76
|
+
*/
|
|
77
|
+
const mapNativeEvent = event => {
|
|
78
|
+
const {
|
|
79
|
+
type,
|
|
80
|
+
userId,
|
|
81
|
+
trackType,
|
|
82
|
+
keyIndex,
|
|
83
|
+
version,
|
|
84
|
+
reason
|
|
85
|
+
} = event;
|
|
86
|
+
const mapped = payload => ({
|
|
87
|
+
type,
|
|
88
|
+
payload
|
|
89
|
+
});
|
|
90
|
+
switch (type) {
|
|
91
|
+
case 'e2ee.decryption_failed':
|
|
92
|
+
case 'e2ee.decryption_resumed':
|
|
93
|
+
case 'e2ee.unencrypted_frame':
|
|
94
|
+
return mapped({
|
|
95
|
+
userId,
|
|
96
|
+
trackType: trackTypeFromNative(trackType)
|
|
97
|
+
});
|
|
98
|
+
case 'e2ee.missing_key':
|
|
99
|
+
return mapped({
|
|
100
|
+
userId,
|
|
101
|
+
keyIndex,
|
|
102
|
+
trackType: trackTypeFromNative(trackType)
|
|
103
|
+
});
|
|
104
|
+
case 'e2ee.decryption_stalled':
|
|
105
|
+
return mapped({
|
|
106
|
+
userId,
|
|
107
|
+
keyIndex: keyIndex ?? 0,
|
|
108
|
+
trackType: trackTypeFromNative(trackType)
|
|
109
|
+
});
|
|
110
|
+
case 'e2ee.encryption_failed':
|
|
111
|
+
return mapped({
|
|
112
|
+
userId,
|
|
113
|
+
trackType: trackTypeFromNative(trackType),
|
|
114
|
+
reason: reason ?? ''
|
|
115
|
+
});
|
|
116
|
+
case 'e2ee.unsupported_version':
|
|
117
|
+
return mapped({
|
|
118
|
+
userId,
|
|
119
|
+
trackType: trackTypeFromNative(trackType),
|
|
120
|
+
version: version ?? 0
|
|
121
|
+
});
|
|
122
|
+
case 'e2ee.perf_report':
|
|
123
|
+
return mapped({
|
|
124
|
+
encode: (event.encode ?? []).map(row => ({
|
|
125
|
+
...toTrackPerf(row),
|
|
126
|
+
codec: row.codec ?? ''
|
|
127
|
+
})),
|
|
128
|
+
decode: (event.decode ?? []).map(toTrackPerf)
|
|
129
|
+
});
|
|
130
|
+
case 'e2ee.key_state':
|
|
131
|
+
return mapped(event.keyState ?? {
|
|
132
|
+
perUserKeys: [],
|
|
133
|
+
sharedKeys: []
|
|
134
|
+
});
|
|
135
|
+
default:
|
|
136
|
+
return undefined;
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
/** Every event the native manager emits, i.e. what the bridge subscribes to. */
|
|
141
|
+
exports.mapNativeEvent = mapNativeEvent;
|
|
142
|
+
const E2EE_EVENT_TYPES = exports.E2EE_EVENT_TYPES = ['e2ee.decryption_failed', 'e2ee.decryption_resumed', 'e2ee.decryption_stalled', 'e2ee.encryption_failed', 'e2ee.missing_key', 'e2ee.unencrypted_frame', 'e2ee.unsupported_version', 'e2ee.perf_report', 'e2ee.key_state'];
|
|
143
|
+
//# sourceMappingURL=eventMapping.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNativeWebrtc","require","trackTypeToNative","trackType","RTCEncryptionTrackType","AUDIO","VIDEO","SCREEN_SHARE","SCREEN_SHARE_AUDIO","undefined","exports","trackTypeFromNative","algorithmToNative","algorithm","RTCEncryptionAlgorithm","AES_256_GCM","AES_128_GCM","toTrackPerf","row","userId","fps","maxCryptoMs","mapNativeEvent","event","type","keyIndex","version","reason","mapped","payload","encode","map","codec","decode","keyState","perUserKeys","sharedKeys","E2EE_EVENT_TYPES"],"sourceRoot":"../../../../src","sources":["modules/encryption/eventMapping.ts"],"mappings":";;;;;;AAAA,IAAAA,kBAAA,GAAAC,OAAA;AAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,iBAAiB,GAC5BC,SAAkB,IACqB;EACvC,QAAQA,SAAS;IACf,KAAK,OAAO;MACV,OAAOC,yCAAsB,CAACC,KAAK;IACrC,KAAK,OAAO;MACV,OAAOD,yCAAsB,CAACE,KAAK;IACrC,KAAK,cAAc;MACjB,OAAOF,yCAAsB,CAACG,YAAY;IAC5C,KAAK,oBAAoB;MACvB,OAAOH,yCAAsB,CAACI,kBAAkB;IAClD;MACE;MACA;MACA,OAAOC,SAAS;EACpB;AACF,CAAC;;AAED;AAAAC,OAAA,CAAAR,iBAAA,GAAAA,iBAAA;AACO,MAAMS,mBAAmB,GAC9BR,SAA2C,IACpB;EACvB,QAAQA,SAAS;IACf,KAAKC,yCAAsB,CAACC,KAAK;MAC/B,OAAO,OAAO;IAChB,KAAKD,yCAAsB,CAACE,KAAK;MAC/B,OAAO,OAAO;IAChB,KAAKF,yCAAsB,CAACG,YAAY;MACtC,OAAO,cAAc;IAC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
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "EncryptionManager", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _EncryptionManager.EncryptionManager;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _EncryptionManager = require("./EncryptionManager");
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_EncryptionManager","require"],"sourceRoot":"../../../../src","sources":["modules/encryption/index.ts"],"mappings":";;;;;;;;;;;AAAA,IAAAA,kBAAA,GAAAC,OAAA","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["modules/encryption/parity.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.StreamVideoRN = void 0;
|
|
7
|
+
var _ringingCallLifecycle = require("../internal/ringingCallLifecycle");
|
|
7
8
|
var _pushLogoutCallback = _interopRequireDefault(require("../internal/pushLogoutCallback"));
|
|
8
9
|
var _setupIosVoipPushEvents = require("../push/setupIosVoipPushEvents");
|
|
9
10
|
var _setupAndroidPushEvents = require("../push/setupAndroidPushEvents");
|
|
@@ -111,6 +112,28 @@ class StreamVideoRN {
|
|
|
111
112
|
(0, _setupIosVoipPushEvents.setupIosVoipPushEvents)(pushConfig);
|
|
112
113
|
(0, _setupAndroidPushEvents.setupAndroidPushEvents)(pushConfig);
|
|
113
114
|
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Register hooks that run around a ringing call's join, for every ringing path:
|
|
118
|
+
* accepted from the CallKit/Telecom UI, accepted inside the app, and outgoing.
|
|
119
|
+
*
|
|
120
|
+
* Call this at your application's entry point, alongside
|
|
121
|
+
* {@link StreamVideoRN.setPushConfig} and **outside** the React tree. A call
|
|
122
|
+
* accepted from a push notification can be created and joined before any
|
|
123
|
+
* component mounts, so hooks registered from inside React would be missed on
|
|
124
|
+
* exactly the path that most needs them.
|
|
125
|
+
*
|
|
126
|
+
* Calling it again replaces the previously registered hooks.
|
|
127
|
+
*
|
|
128
|
+
* @example // in index.js
|
|
129
|
+
* StreamVideoRN.setRingingCallLifecycleHooks({
|
|
130
|
+
* onBeforeCallJoin: (call) => attachE2EEIfConfigured(call),
|
|
131
|
+
* onAfterCallLeave: (call) => disposeE2EEManager(call),
|
|
132
|
+
* });
|
|
133
|
+
*/
|
|
134
|
+
static setRingingCallLifecycleHooks = hooks => {
|
|
135
|
+
(0, _ringingCallLifecycle.setRingingCallLifecycleHooks)(hooks);
|
|
136
|
+
};
|
|
114
137
|
static getConfig() {
|
|
115
138
|
return this.config;
|
|
116
139
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_ringingCallLifecycle","require","_pushLogoutCallback","_interopRequireDefault","_setupIosVoipPushEvents","_setupAndroidPushEvents","_setupCallingExpEvents","_callingx","_reactNative","_videoClient","e","__esModule","default","deepMerge","target","source","result","key","undefined","Array","isArray","DEFAULT_STREAM_VIDEO_CONFIG","foregroundService","android","channel","id","name","notificationTexts","title","body","taskToRun","Promise","StreamVideoRN","config","updateConfig","setPushConfig","pushConfig","push","callingx","getCallingxLib","videoLoggerSystem","getLogger","info","JSON","stringify","options","extractCallingExpOptions","setup","Error","setupCallingExpEvents","setupIosVoipPushEvents","setupAndroidPushEvents","setRingingCallLifecycleHooks","hooks","storeRingingCallLifecycleHooks","getConfig","onPushLogout","callbacks","pushLogoutCallbacks","current","resolve","all","map","callback","then","clearPushLogoutCallbacks","setDisableCommunicationModeWorkaround","disabled","Platform","OS","NativeModules","StreamInCallManager","error","warn","playBusyTone","StreamVideoReactNative","stopBusyTone","androidHasAudioOutputHardware","hasAudioOutputHardware","androidHasMicrophoneHardware","hasMicrophoneHardware","androidHasCameraHardware","hasCameraHardware","exports"],"sourceRoot":"../../../../src","sources":["utils/StreamVideoRN/index.ts"],"mappings":";;;;;;AACA,IAAAA,qBAAA,GAAAC,OAAA;AACA,IAAAC,mBAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,uBAAA,GAAAH,OAAA;AACA,IAAAI,uBAAA,GAAAJ,OAAA;AACA,IAAAK,sBAAA,GAAAL,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AAIA,IAAAO,YAAA,GAAAP,OAAA;AACA,IAAAQ,YAAA,GAAAR,OAAA;AAA4D,SAAAE,uBAAAO,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE5D;;AAKA;AACA,SAASG,SAASA,CAChBC,MAAS,EACTC,MAAsB,EACnB;EACH,MAAMC,MAAM,GAAG;IAAE,GAAGF;EAAO,CAAC;EAE5B,KAAK,MAAMG,GAAG,IAAIF,MAAM,EAAE;IACxB,IAAIA,MAAM,CAACE,GAAG,CAAC,KAAKC,SAAS,EAAE;MAC7B,IACE,OAAOH,MAAM,CAACE,GAAG,CAAC,KAAK,QAAQ,IAC/BF,MAAM,CAACE,GAAG,CAAC,KAAK,IAAI,IACpB,CAACE,KAAK,CAACC,OAAO,CAACL,MAAM,CAACE,GAAG,CAAC,CAAC,IAC3B,OAAOH,MAAM,CAACG,GAAG,CAAC,KAAK,QAAQ,IAC/BH,MAAM,CAACG,GAAG,CAAC,KAAK,IAAI,IACpB,CAACE,KAAK,CAACC,OAAO,CAACN,MAAM,CAACG,GAAG,CAAC,CAAC,EAC3B;QACAD,MAAM,CAACC,GAAG,CAAC,GAAGJ,SAAS,CACrBC,MAAM,CAACG,GAAG,CAAC,EACXF,MAAM,CAACE,GAAG,CACZ,CAAC;MACH,CAAC,MAAM;QACLD,MAAM,CAACC,GAAG,CAAC,GAAGF,MAAM,CA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,CAAC,8CAA8C,EAAED,KAAK,CAAC;IAChE;EACF;;EAEA;AACF;AACA;EACE,aAAaE,YAAYA,CAAA,EAAG;IAC1B,OAAOJ,0BAAa,CAACK,sBAAsB,CAACD,YAAY,CAAC,CAAC;EAC5D;;EAEA;AACF;AACA;EACE,aAAaE,YAAYA,CAAA,EAAG;IAC1B,OAAON,0BAAa,CAACK,sBAAsB,CAACC,YAAY,CAAC,CAAC;EAC5D;;EAEA;AACF;AACA;AACA;EACE,aAAaC,6BAA6BA,CAAA,EAAqB;IAC7D,IAAIT,qBAAQ,CAACC,EAAE,KAAK,SAAS,EAC3B,MAAM,IAAIrB,KAAK,CACb,qEACF,CAAC;IACH,OAAOsB,0BAAa,CAACK,sBAAsB,CAACG,sBAAsB,CAAC,CAAC;EACtE;;EAEA;AACF;AACA;AACA;EACE,aAAaC,4BAA4BA,CAAA,EAAqB;IAC5D,IAAIX,qBAAQ,CAACC,EAAE,KAAK,SAAS,EAC3B,MAAM,IAAIrB,KAAK,CACb,oEACF,CAAC;IACH,OAAOsB,0BAAa,CAACK,sBAAsB,CAACK,qBAAqB,CAAC,CAAC;EACrE;;EAEA;AACF;AACA;AACA;EACE,aAAaC,wBAAwBA,CAAA,EAAqB;IACxD,IAAIb,qBAAQ,CAACC,EAAE,KAAK,SAAS,EAC3B,MAAM,IAAIrB,KAAK,CACb,gEACF,CAAC;IACH,OAAOsB,0BAAa,CAACK,sBAAsB,CAACO,iBAAiB,CAAC,CAAC;EACjE;AACF;AAACC,OAAA,CAAAnD,aAAA,GAAAA,aAAA","ignoreList":[]}
|
|
@@ -48,11 +48,14 @@ function getCallDisplayName(callMembers, participants, currentUserId) {
|
|
|
48
48
|
*/
|
|
49
49
|
function getCallingxCallArgs(call) {
|
|
50
50
|
const callDisplayName = call.state.custom?.display_name || getCallDisplayName(call.state.members, call.state.participants, call.currentUserId);
|
|
51
|
+
const createdByHandle = call.state.createdBy?.id ?? callDisplayName;
|
|
51
52
|
return [call.cid,
|
|
52
53
|
// unique id for call
|
|
53
|
-
call.
|
|
54
|
-
//
|
|
55
|
-
|
|
54
|
+
// handle for the native call UI. On iOS it is shown in CallKit Recents and used for
|
|
55
|
+
// call-back, so we send the caller's user id (matches the Swift SDK). On Android the
|
|
56
|
+
// self-managed Telecom address is never displayed and callingx wraps it as
|
|
57
|
+
// `<packageName>:<handle>`, so we send the call id (matches the Android SDK).
|
|
58
|
+
_reactNative.Platform.OS === 'android' ? call.id : createdByHandle, callDisplayName,
|
|
56
59
|
// display name for display in call screen
|
|
57
60
|
call.state.settings?.video?.enabled ?? false // is video call?
|
|
58
61
|
];
|
|
@@ -82,7 +85,7 @@ async function registerOutgoingCall(call) {
|
|
|
82
85
|
* 2. Displays the incoming call in the callingx library
|
|
83
86
|
* 3. Optionally for non-ringing calls also when ongoing calls are enabled.
|
|
84
87
|
*/
|
|
85
|
-
async function joinCallingxCall(call, activeCalls) {
|
|
88
|
+
async function joinCallingxCall(call, activeCalls, isCancelled) {
|
|
86
89
|
if (!CallingxModule || !CallingxModule.isSetup || call.isOwnTracksLoopbackAllowed) {
|
|
87
90
|
return;
|
|
88
91
|
}
|
|
@@ -103,16 +106,38 @@ async function joinCallingxCall(call, activeCalls) {
|
|
|
103
106
|
logger.error(`failed to leave active call ${activeCall.cid}`, e);
|
|
104
107
|
});
|
|
105
108
|
}
|
|
109
|
+
// Leaving the other calls above can take arbitrarily long, and this join may
|
|
110
|
+
// have been cancelled meanwhile. Registering now would create a native call
|
|
111
|
+
// nobody owns. The caller decides, not the call's state: a `Call` reused for
|
|
112
|
+
// a fresh ring is still `LEFT` here, because `setup()` runs after this.
|
|
113
|
+
if (isCancelled?.()) {
|
|
114
|
+
logger.debug(`joinCallingxCall: skipping registration for ${call.cid}: join cancelled while waiting for other calls`);
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
106
117
|
logger.debug(`joinCallingxCall: Joining call ${call.cid} isIncoming: ${isIncomingCall} isOutgoing: ${isOutcomingCall}`);
|
|
107
118
|
const callArgs = getCallingxCallArgs(call);
|
|
108
119
|
if (isIncomingCall) {
|
|
109
120
|
await CallingxModule.displayIncomingCall(...callArgs);
|
|
121
|
+
// never answer a call that was hung up while the OS was displaying it -
|
|
122
|
+
// the cleanup below ends the registration instead
|
|
123
|
+
if (isCancelled?.()) return;
|
|
110
124
|
await CallingxModule.answerIncomingCall(call.cid);
|
|
111
125
|
} else {
|
|
112
126
|
await CallingxModule.startCall(...callArgs);
|
|
113
127
|
}
|
|
114
128
|
} catch (error) {
|
|
115
129
|
logger.error(`startCallingxCall: Error starting call in callingx: ${call.cid} isIncoming: ${isIncomingCall} isOutgoing: ${isOutcomingCall}`, error);
|
|
130
|
+
} finally {
|
|
131
|
+
// The registration above can outlive the join that asked for it: `leave()`
|
|
132
|
+
// may land while native is still bringing the call up, and by the time the
|
|
133
|
+
// caller aborts, the call exists natively with nobody to end it. Ringing
|
|
134
|
+
// calls have a lifecycle owner that would clean up; ordinary ones do not.
|
|
135
|
+
// Nothing was registered when the check above already skipped it, and
|
|
136
|
+
// `endCallingxCall` no-ops for an untracked cid, so this is safe either way.
|
|
137
|
+
if (isCancelled?.()) {
|
|
138
|
+
logger.debug(`joinCallingxCall: ending ${call.cid}: join was cancelled while registering`);
|
|
139
|
+
await endCallingxCall(call, 'canceled');
|
|
140
|
+
}
|
|
116
141
|
}
|
|
117
142
|
}
|
|
118
143
|
async function endCallingxCall(call, reason) {
|