@whereby.com/core 0.9.2 → 0.11.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/dist/index.cjs +203 -111
- package/dist/index.d.cts +189 -32
- package/dist/index.d.mts +189 -32
- package/dist/index.d.ts +189 -32
- package/dist/index.mjs +195 -111
- package/package.json +1 -10
package/dist/index.cjs
CHANGED
|
@@ -13,6 +13,16 @@ function createAppAsyncThunk(typePrefix, payloadCreator) {
|
|
|
13
13
|
function createAppThunk(thunk) {
|
|
14
14
|
return thunk;
|
|
15
15
|
}
|
|
16
|
+
function createAppAuthorizedThunk(authorizationSelector, thunk) {
|
|
17
|
+
return createAppThunk((payload) => (dispatch, getState, extra) => {
|
|
18
|
+
const isAuthorized = authorizationSelector(getState());
|
|
19
|
+
if (!isAuthorized) {
|
|
20
|
+
console.warn("Not authorized to perform this action");
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
return thunk(payload)(dispatch, getState, extra);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
16
26
|
|
|
17
27
|
const listenerMiddleware = toolkit.createListenerMiddleware();
|
|
18
28
|
const startAppListening = listenerMiddleware.startListening;
|
|
@@ -35,13 +45,12 @@ const createReactor = (selectors, callback) => {
|
|
|
35
45
|
});
|
|
36
46
|
};
|
|
37
47
|
|
|
38
|
-
const coreVersion = "0.
|
|
48
|
+
const coreVersion = "0.11.0";
|
|
39
49
|
|
|
40
|
-
const initialState$
|
|
50
|
+
const initialState$d = {
|
|
41
51
|
isNodeSdk: false,
|
|
42
52
|
wantsToJoin: false,
|
|
43
53
|
roomName: null,
|
|
44
|
-
roomKey: null,
|
|
45
54
|
roomUrl: null,
|
|
46
55
|
displayName: null,
|
|
47
56
|
userAgent: `core:${coreVersion}`,
|
|
@@ -49,7 +58,7 @@ const initialState$c = {
|
|
|
49
58
|
};
|
|
50
59
|
const appSlice = toolkit.createSlice({
|
|
51
60
|
name: "app",
|
|
52
|
-
initialState: initialState$
|
|
61
|
+
initialState: initialState$d,
|
|
53
62
|
reducers: {
|
|
54
63
|
doAppJoin: (state, action) => {
|
|
55
64
|
const url = new URL(action.payload.roomUrl);
|
|
@@ -58,17 +67,13 @@ const appSlice = toolkit.createSlice({
|
|
|
58
67
|
appLeft: (state) => {
|
|
59
68
|
return Object.assign(Object.assign({}, state), { wantsToJoin: false });
|
|
60
69
|
},
|
|
61
|
-
setRoomKey: (state, action) => {
|
|
62
|
-
return Object.assign(Object.assign({}, state), { roomKey: action.payload });
|
|
63
|
-
},
|
|
64
70
|
},
|
|
65
71
|
});
|
|
66
|
-
const { doAppJoin, appLeft
|
|
72
|
+
const { doAppJoin, appLeft } = appSlice.actions;
|
|
67
73
|
const selectAppRaw = (state) => state.app;
|
|
68
74
|
const selectAppWantsToJoin = (state) => state.app.wantsToJoin;
|
|
69
75
|
const selectAppRoomName = (state) => state.app.roomName;
|
|
70
76
|
const selectAppRoomUrl = (state) => state.app.roomUrl;
|
|
71
|
-
const selectAppRoomKey = (state) => state.app.roomKey;
|
|
72
77
|
const selectAppDisplayName = (state) => state.app.displayName;
|
|
73
78
|
const selectAppUserAgent = (state) => state.app.userAgent;
|
|
74
79
|
const selectAppExternalId = (state) => state.app.externalId;
|
|
@@ -79,6 +84,7 @@ function createSignalEventAction(name) {
|
|
|
79
84
|
}
|
|
80
85
|
const signalEvents = {
|
|
81
86
|
audioEnabled: createSignalEventAction("audioEnabled"),
|
|
87
|
+
audioEnableRequested: createSignalEventAction("audioEnableRequested"),
|
|
82
88
|
chatMessage: createSignalEventAction("chatMessage"),
|
|
83
89
|
clientLeft: createSignalEventAction("clientLeft"),
|
|
84
90
|
clientKicked: createSignalEventAction("clientKicked"),
|
|
@@ -91,6 +97,7 @@ const signalEvents = {
|
|
|
91
97
|
newClient: createSignalEventAction("newClient"),
|
|
92
98
|
roomJoined: createSignalEventAction("roomJoined"),
|
|
93
99
|
roomKnocked: createSignalEventAction("roomKnocked"),
|
|
100
|
+
roomLocked: createSignalEventAction("roomLocked"),
|
|
94
101
|
roomSessionEnded: createSignalEventAction("roomSessionEnded"),
|
|
95
102
|
screenshareStarted: createSignalEventAction("screenshareStarted"),
|
|
96
103
|
screenshareStopped: createSignalEventAction("screenshareStopped"),
|
|
@@ -142,13 +149,13 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
142
149
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
143
150
|
};
|
|
144
151
|
|
|
145
|
-
const initialState$
|
|
152
|
+
const initialState$c = {
|
|
146
153
|
isFetching: false,
|
|
147
154
|
data: null,
|
|
148
155
|
};
|
|
149
156
|
const deviceCredentialsSlice = toolkit.createSlice({
|
|
150
157
|
name: "deviceCredentials",
|
|
151
|
-
initialState: initialState$
|
|
158
|
+
initialState: initialState$c,
|
|
152
159
|
reducers: {},
|
|
153
160
|
extraReducers: (builder) => {
|
|
154
161
|
builder.addCase(doGetDeviceCredentials.pending, (state) => {
|
|
@@ -193,10 +200,12 @@ function forwardSocketEvents(socket, dispatch) {
|
|
|
193
200
|
socket.on("client_kicked", (payload) => dispatch(signalEvents.clientKicked(payload)));
|
|
194
201
|
socket.on("audio_enabled", (payload) => dispatch(signalEvents.audioEnabled(payload)));
|
|
195
202
|
socket.on("video_enabled", (payload) => dispatch(signalEvents.videoEnabled(payload)));
|
|
203
|
+
socket.on("audio_enable_requested", (payload) => dispatch(signalEvents.audioEnableRequested(payload)));
|
|
196
204
|
socket.on("client_metadata_received", (payload) => dispatch(signalEvents.clientMetadataReceived(payload)));
|
|
197
205
|
socket.on("chat_message", (payload) => dispatch(signalEvents.chatMessage(payload)));
|
|
198
206
|
socket.on("disconnect", () => dispatch(signalEvents.disconnect()));
|
|
199
207
|
socket.on("room_knocked", (payload) => dispatch(signalEvents.roomKnocked(payload)));
|
|
208
|
+
socket.on("room_locked", (payload) => dispatch(signalEvents.roomLocked(payload)));
|
|
200
209
|
socket.on("room_session_ended", (payload) => dispatch(signalEvents.roomSessionEnded(payload)));
|
|
201
210
|
socket.on("knocker_left", (payload) => dispatch(signalEvents.knockerLeft(payload)));
|
|
202
211
|
socket.on("knock_handled", (payload) => dispatch(signalEvents.knockHandled(payload)));
|
|
@@ -215,7 +224,7 @@ function createSocket() {
|
|
|
215
224
|
};
|
|
216
225
|
return new media.ServerSocket(socketHost, socketOverrides);
|
|
217
226
|
}
|
|
218
|
-
const initialState$
|
|
227
|
+
const initialState$b = {
|
|
219
228
|
deviceIdentified: false,
|
|
220
229
|
isIdentifyingDevice: false,
|
|
221
230
|
status: "",
|
|
@@ -223,7 +232,7 @@ const initialState$a = {
|
|
|
223
232
|
};
|
|
224
233
|
const signalConnectionSlice = toolkit.createSlice({
|
|
225
234
|
name: "signalConnection",
|
|
226
|
-
initialState: initialState$
|
|
235
|
+
initialState: initialState$b,
|
|
227
236
|
reducers: {
|
|
228
237
|
socketConnecting: (state) => {
|
|
229
238
|
return Object.assign(Object.assign({}, state), { status: "connecting" });
|
|
@@ -322,92 +331,6 @@ createReactor([selectShouldIdentifyDevice, selectDeviceCredentialsRaw], ({ dispa
|
|
|
322
331
|
}
|
|
323
332
|
});
|
|
324
333
|
|
|
325
|
-
const initialState$9 = {
|
|
326
|
-
chatMessages: [],
|
|
327
|
-
};
|
|
328
|
-
const chatSlice = toolkit.createSlice({
|
|
329
|
-
name: "chat",
|
|
330
|
-
initialState: initialState$9,
|
|
331
|
-
reducers: {},
|
|
332
|
-
extraReducers(builder) {
|
|
333
|
-
builder.addCase(signalEvents.chatMessage, (state, action) => {
|
|
334
|
-
const message = {
|
|
335
|
-
senderId: action.payload.senderId,
|
|
336
|
-
timestamp: action.payload.timestamp,
|
|
337
|
-
text: action.payload.text,
|
|
338
|
-
};
|
|
339
|
-
return Object.assign(Object.assign({}, state), { chatMessages: [...state.chatMessages, message] });
|
|
340
|
-
});
|
|
341
|
-
},
|
|
342
|
-
});
|
|
343
|
-
const doSendChatMessage = createAppThunk((payload) => (_, getState) => {
|
|
344
|
-
const state = getState();
|
|
345
|
-
const socket = selectSignalConnectionRaw(state).socket;
|
|
346
|
-
socket === null || socket === void 0 ? void 0 : socket.emit("chat_message", { text: payload.text });
|
|
347
|
-
});
|
|
348
|
-
const selectChatRaw = (state) => state.chat;
|
|
349
|
-
const selectChatMessages = (state) => state.chat.chatMessages;
|
|
350
|
-
|
|
351
|
-
const initialCloudRecordingState = {
|
|
352
|
-
isRecording: false,
|
|
353
|
-
error: null,
|
|
354
|
-
startedAt: undefined,
|
|
355
|
-
};
|
|
356
|
-
const cloudRecordingSlice = toolkit.createSlice({
|
|
357
|
-
name: "cloudRecording",
|
|
358
|
-
initialState: initialCloudRecordingState,
|
|
359
|
-
reducers: {
|
|
360
|
-
recordingRequestStarted: (state) => {
|
|
361
|
-
return Object.assign(Object.assign({}, state), { status: "requested" });
|
|
362
|
-
},
|
|
363
|
-
},
|
|
364
|
-
extraReducers: (builder) => {
|
|
365
|
-
builder.addCase(signalEvents.cloudRecordingStopped, (state) => {
|
|
366
|
-
return Object.assign(Object.assign({}, state), { isRecording: false, status: undefined });
|
|
367
|
-
});
|
|
368
|
-
builder.addCase(signalEvents.cloudRecordingStarted, (state, action) => {
|
|
369
|
-
const { payload } = action;
|
|
370
|
-
if (!payload.error) {
|
|
371
|
-
return state;
|
|
372
|
-
}
|
|
373
|
-
return Object.assign(Object.assign({}, state), { isRecording: false, status: "error", error: payload.error });
|
|
374
|
-
});
|
|
375
|
-
builder.addCase(signalEvents.newClient, (state, { payload }) => {
|
|
376
|
-
var _a;
|
|
377
|
-
const { client } = payload;
|
|
378
|
-
if (((_a = client.role) === null || _a === void 0 ? void 0 : _a.roleName) === "recorder") {
|
|
379
|
-
return Object.assign(Object.assign({}, state), { isRecording: true, status: "recording", startedAt: client.startedCloudRecordingAt
|
|
380
|
-
? new Date(client.startedCloudRecordingAt).getTime()
|
|
381
|
-
: new Date().getTime() });
|
|
382
|
-
}
|
|
383
|
-
return state;
|
|
384
|
-
});
|
|
385
|
-
},
|
|
386
|
-
});
|
|
387
|
-
const { recordingRequestStarted } = cloudRecordingSlice.actions;
|
|
388
|
-
const doStartCloudRecording = createAppThunk(() => (dispatch, getState) => {
|
|
389
|
-
const state = getState();
|
|
390
|
-
const socket = selectSignalConnectionRaw(state).socket;
|
|
391
|
-
const status = selectCloudRecordingStatus(state);
|
|
392
|
-
if (status && ["recording", "requested"].includes(status)) {
|
|
393
|
-
return;
|
|
394
|
-
}
|
|
395
|
-
socket === null || socket === void 0 ? void 0 : socket.emit("start_recording", {
|
|
396
|
-
recording: "cloud",
|
|
397
|
-
});
|
|
398
|
-
dispatch(recordingRequestStarted());
|
|
399
|
-
});
|
|
400
|
-
const doStopCloudRecording = createAppThunk(() => (dispatch, getState) => {
|
|
401
|
-
const state = getState();
|
|
402
|
-
const socket = selectSignalConnectionRaw(state).socket;
|
|
403
|
-
socket === null || socket === void 0 ? void 0 : socket.emit("stop_recording");
|
|
404
|
-
});
|
|
405
|
-
const selectCloudRecordingRaw = (state) => state.cloudRecording;
|
|
406
|
-
const selectCloudRecordingStatus = (state) => state.cloudRecording.status;
|
|
407
|
-
const selectCloudRecordingStartedAt = (state) => state.cloudRecording.startedAt;
|
|
408
|
-
const selectCloudRecordingError = (state) => state.cloudRecording.error;
|
|
409
|
-
const selectIsCloudRecording = (state) => state.cloudRecording.isRecording;
|
|
410
|
-
|
|
411
334
|
function fakeAudioStream() {
|
|
412
335
|
const audioCtx = new AudioContext();
|
|
413
336
|
const oscillator = audioCtx.createOscillator();
|
|
@@ -515,6 +438,22 @@ function parseRoomUrlAndSubdomain(roomAttribute, subdomainAttribute) {
|
|
|
515
438
|
};
|
|
516
439
|
}
|
|
517
440
|
|
|
441
|
+
function parseUnverifiedRoomKeyData(roomKey) {
|
|
442
|
+
const [, roomKeyData] = /\.(.*)\./i.exec(roomKey) || [];
|
|
443
|
+
if (!roomKeyData) {
|
|
444
|
+
return {};
|
|
445
|
+
}
|
|
446
|
+
else {
|
|
447
|
+
try {
|
|
448
|
+
const base64DecodedJwtData = atob(roomKeyData);
|
|
449
|
+
return JSON.parse(base64DecodedJwtData);
|
|
450
|
+
}
|
|
451
|
+
catch (e) {
|
|
452
|
+
return {};
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
|
|
518
457
|
const initialLocalMediaState = {
|
|
519
458
|
busyDeviceIds: [],
|
|
520
459
|
cameraEnabled: false,
|
|
@@ -943,8 +882,17 @@ startAppListening({
|
|
|
943
882
|
dispatch(localStreamMetadataUpdated(deviceData));
|
|
944
883
|
},
|
|
945
884
|
});
|
|
885
|
+
startAppListening({
|
|
886
|
+
actionCreator: signalEvents.audioEnableRequested,
|
|
887
|
+
effect: ({ payload }, { dispatch }) => {
|
|
888
|
+
const { enable } = payload;
|
|
889
|
+
if (!enable) {
|
|
890
|
+
dispatch(toggleMicrophoneEnabled({ enabled: false }));
|
|
891
|
+
}
|
|
892
|
+
},
|
|
893
|
+
});
|
|
946
894
|
|
|
947
|
-
const initialState$
|
|
895
|
+
const initialState$a = {
|
|
948
896
|
displayName: "",
|
|
949
897
|
id: "",
|
|
950
898
|
isAudioEnabled: true,
|
|
@@ -952,7 +900,7 @@ const initialState$8 = {
|
|
|
952
900
|
isLocalParticipant: true,
|
|
953
901
|
stream: undefined,
|
|
954
902
|
isScreenSharing: false,
|
|
955
|
-
roleName: "",
|
|
903
|
+
roleName: "none",
|
|
956
904
|
clientClaim: undefined,
|
|
957
905
|
};
|
|
958
906
|
const doEnableAudio = createAppAsyncThunk("localParticipant/doEnableAudio", (payload, { getState }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -978,7 +926,7 @@ const doSetDisplayName = createAppAsyncThunk("localParticipant/doSetDisplayName"
|
|
|
978
926
|
}));
|
|
979
927
|
const localParticipantSlice = toolkit.createSlice({
|
|
980
928
|
name: "localParticipant",
|
|
981
|
-
initialState: initialState$
|
|
929
|
+
initialState: initialState$a,
|
|
982
930
|
reducers: {
|
|
983
931
|
doSetLocalParticipant: (state, action) => {
|
|
984
932
|
return Object.assign(Object.assign({}, state), action.payload);
|
|
@@ -1000,7 +948,7 @@ const localParticipantSlice = toolkit.createSlice({
|
|
|
1000
948
|
builder.addCase(signalEvents.roomJoined, (state, action) => {
|
|
1001
949
|
var _a, _b;
|
|
1002
950
|
const client = (_b = (_a = action.payload) === null || _a === void 0 ? void 0 : _a.room) === null || _b === void 0 ? void 0 : _b.clients.find((c) => { var _a; return c.id === ((_a = action.payload) === null || _a === void 0 ? void 0 : _a.selfId); });
|
|
1003
|
-
return Object.assign(Object.assign({}, state), { id: action.payload.selfId,
|
|
951
|
+
return Object.assign(Object.assign({}, state), { id: action.payload.selfId, roleName: (client === null || client === void 0 ? void 0 : client.role.roleName) || "none", clientClaim: action.payload.clientClaim });
|
|
1004
952
|
});
|
|
1005
953
|
},
|
|
1006
954
|
});
|
|
@@ -1027,6 +975,136 @@ startAppListening({
|
|
|
1027
975
|
},
|
|
1028
976
|
});
|
|
1029
977
|
|
|
978
|
+
const ACTION_PERMISSIONS_BY_ROLE = {
|
|
979
|
+
canLockRoom: ["host"],
|
|
980
|
+
canRequestAudioEnable: ["host"],
|
|
981
|
+
};
|
|
982
|
+
const initialState$9 = {
|
|
983
|
+
roomKey: null,
|
|
984
|
+
roomLocked: false,
|
|
985
|
+
};
|
|
986
|
+
const authorizationSlice = toolkit.createSlice({
|
|
987
|
+
name: "authorization",
|
|
988
|
+
initialState: initialState$9,
|
|
989
|
+
reducers: {
|
|
990
|
+
setRoomKey: (state, action) => {
|
|
991
|
+
return Object.assign(Object.assign({}, state), { roomKey: action.payload });
|
|
992
|
+
},
|
|
993
|
+
},
|
|
994
|
+
extraReducers: (builder) => {
|
|
995
|
+
builder.addCase(doAppJoin, (state, action) => {
|
|
996
|
+
return Object.assign(Object.assign({}, state), { roomKey: action.payload.roomKey });
|
|
997
|
+
});
|
|
998
|
+
builder.addCase(signalEvents.roomJoined, (state, action) => {
|
|
999
|
+
const { error, isLocked } = action.payload;
|
|
1000
|
+
if (error) {
|
|
1001
|
+
return state;
|
|
1002
|
+
}
|
|
1003
|
+
return Object.assign(Object.assign({}, state), { roomLocked: isLocked });
|
|
1004
|
+
});
|
|
1005
|
+
builder.addCase(signalEvents.roomLocked, (state, action) => {
|
|
1006
|
+
const { isLocked } = action.payload;
|
|
1007
|
+
return Object.assign(Object.assign({}, state), { roomLocked: isLocked });
|
|
1008
|
+
});
|
|
1009
|
+
},
|
|
1010
|
+
});
|
|
1011
|
+
const { setRoomKey } = authorizationSlice.actions;
|
|
1012
|
+
const doLockRoom = createAppAuthorizedThunk((state) => selectIsAuthorizedToLockRoom(state), (payload) => (_, getState) => {
|
|
1013
|
+
const state = getState();
|
|
1014
|
+
const { socket } = selectSignalConnectionRaw(state);
|
|
1015
|
+
socket === null || socket === void 0 ? void 0 : socket.emit("set_lock", { locked: payload.locked });
|
|
1016
|
+
});
|
|
1017
|
+
const selectAuthorizationRoomKey = (state) => state.authorization.roomKey;
|
|
1018
|
+
const selectAuthorizationRoomLocked = (state) => state.authorization.roomLocked;
|
|
1019
|
+
const selectIsAuthorizedToLockRoom = toolkit.createSelector(selectLocalParticipantRole, (localParticipantRole) => ACTION_PERMISSIONS_BY_ROLE.canLockRoom.includes(localParticipantRole));
|
|
1020
|
+
const selectIsAuthorizedToRequestAudioEnable = toolkit.createSelector(selectLocalParticipantRole, (localParticipantRole) => ACTION_PERMISSIONS_BY_ROLE.canRequestAudioEnable.includes(localParticipantRole));
|
|
1021
|
+
|
|
1022
|
+
const initialState$8 = {
|
|
1023
|
+
chatMessages: [],
|
|
1024
|
+
};
|
|
1025
|
+
const chatSlice = toolkit.createSlice({
|
|
1026
|
+
name: "chat",
|
|
1027
|
+
initialState: initialState$8,
|
|
1028
|
+
reducers: {},
|
|
1029
|
+
extraReducers(builder) {
|
|
1030
|
+
builder.addCase(signalEvents.chatMessage, (state, action) => {
|
|
1031
|
+
const message = {
|
|
1032
|
+
senderId: action.payload.senderId,
|
|
1033
|
+
timestamp: action.payload.timestamp,
|
|
1034
|
+
text: action.payload.text,
|
|
1035
|
+
};
|
|
1036
|
+
return Object.assign(Object.assign({}, state), { chatMessages: [...state.chatMessages, message] });
|
|
1037
|
+
});
|
|
1038
|
+
},
|
|
1039
|
+
});
|
|
1040
|
+
const doSendChatMessage = createAppThunk((payload) => (_, getState) => {
|
|
1041
|
+
const state = getState();
|
|
1042
|
+
const socket = selectSignalConnectionRaw(state).socket;
|
|
1043
|
+
socket === null || socket === void 0 ? void 0 : socket.emit("chat_message", { text: payload.text });
|
|
1044
|
+
});
|
|
1045
|
+
const selectChatRaw = (state) => state.chat;
|
|
1046
|
+
const selectChatMessages = (state) => state.chat.chatMessages;
|
|
1047
|
+
|
|
1048
|
+
const initialCloudRecordingState = {
|
|
1049
|
+
isRecording: false,
|
|
1050
|
+
error: null,
|
|
1051
|
+
startedAt: undefined,
|
|
1052
|
+
};
|
|
1053
|
+
const cloudRecordingSlice = toolkit.createSlice({
|
|
1054
|
+
name: "cloudRecording",
|
|
1055
|
+
initialState: initialCloudRecordingState,
|
|
1056
|
+
reducers: {
|
|
1057
|
+
recordingRequestStarted: (state) => {
|
|
1058
|
+
return Object.assign(Object.assign({}, state), { status: "requested" });
|
|
1059
|
+
},
|
|
1060
|
+
},
|
|
1061
|
+
extraReducers: (builder) => {
|
|
1062
|
+
builder.addCase(signalEvents.cloudRecordingStopped, (state) => {
|
|
1063
|
+
return Object.assign(Object.assign({}, state), { isRecording: false, status: undefined });
|
|
1064
|
+
});
|
|
1065
|
+
builder.addCase(signalEvents.cloudRecordingStarted, (state, action) => {
|
|
1066
|
+
const { payload } = action;
|
|
1067
|
+
if (!payload.error) {
|
|
1068
|
+
return state;
|
|
1069
|
+
}
|
|
1070
|
+
return Object.assign(Object.assign({}, state), { isRecording: false, status: "error", error: payload.error });
|
|
1071
|
+
});
|
|
1072
|
+
builder.addCase(signalEvents.newClient, (state, { payload }) => {
|
|
1073
|
+
var _a;
|
|
1074
|
+
const { client } = payload;
|
|
1075
|
+
if (((_a = client.role) === null || _a === void 0 ? void 0 : _a.roleName) === "recorder") {
|
|
1076
|
+
return Object.assign(Object.assign({}, state), { isRecording: true, status: "recording", startedAt: client.startedCloudRecordingAt
|
|
1077
|
+
? new Date(client.startedCloudRecordingAt).getTime()
|
|
1078
|
+
: new Date().getTime() });
|
|
1079
|
+
}
|
|
1080
|
+
return state;
|
|
1081
|
+
});
|
|
1082
|
+
},
|
|
1083
|
+
});
|
|
1084
|
+
const { recordingRequestStarted } = cloudRecordingSlice.actions;
|
|
1085
|
+
const doStartCloudRecording = createAppThunk(() => (dispatch, getState) => {
|
|
1086
|
+
const state = getState();
|
|
1087
|
+
const socket = selectSignalConnectionRaw(state).socket;
|
|
1088
|
+
const status = selectCloudRecordingStatus(state);
|
|
1089
|
+
if (status && ["recording", "requested"].includes(status)) {
|
|
1090
|
+
return;
|
|
1091
|
+
}
|
|
1092
|
+
socket === null || socket === void 0 ? void 0 : socket.emit("start_recording", {
|
|
1093
|
+
recording: "cloud",
|
|
1094
|
+
});
|
|
1095
|
+
dispatch(recordingRequestStarted());
|
|
1096
|
+
});
|
|
1097
|
+
const doStopCloudRecording = createAppThunk(() => (dispatch, getState) => {
|
|
1098
|
+
const state = getState();
|
|
1099
|
+
const socket = selectSignalConnectionRaw(state).socket;
|
|
1100
|
+
socket === null || socket === void 0 ? void 0 : socket.emit("stop_recording");
|
|
1101
|
+
});
|
|
1102
|
+
const selectCloudRecordingRaw = (state) => state.cloudRecording;
|
|
1103
|
+
const selectCloudRecordingStatus = (state) => state.cloudRecording.status;
|
|
1104
|
+
const selectCloudRecordingStartedAt = (state) => state.cloudRecording.startedAt;
|
|
1105
|
+
const selectCloudRecordingError = (state) => state.cloudRecording.error;
|
|
1106
|
+
const selectIsCloudRecording = (state) => state.cloudRecording.isRecording;
|
|
1107
|
+
|
|
1030
1108
|
const initialState$7 = {
|
|
1031
1109
|
status: "",
|
|
1032
1110
|
stream: null,
|
|
@@ -1167,9 +1245,9 @@ const rtcEvents = {
|
|
|
1167
1245
|
};
|
|
1168
1246
|
|
|
1169
1247
|
const NON_PERSON_ROLES = ["recorder", "streamer"];
|
|
1170
|
-
function
|
|
1171
|
-
const { streams } = client, rest = __rest(client, ["streams"]);
|
|
1172
|
-
return Object.assign(Object.assign({}, rest), { stream: null, streams: streams.map((streamId) => ({ id: streamId, state: newJoiner ? "new_accept" : "to_accept" })), isLocalParticipant: false, presentationStream: null, newJoiner });
|
|
1248
|
+
function createRemoteParticipant(client, newJoiner = false) {
|
|
1249
|
+
const { streams, role } = client, rest = __rest(client, ["streams", "role"]);
|
|
1250
|
+
return Object.assign(Object.assign({}, rest), { stream: null, streams: streams.map((streamId) => ({ id: streamId, state: newJoiner ? "new_accept" : "to_accept" })), isLocalParticipant: false, roleName: (role === null || role === void 0 ? void 0 : role.roleName) || "none", presentationStream: null, newJoiner });
|
|
1173
1251
|
}
|
|
1174
1252
|
function findParticipant(state, participantId) {
|
|
1175
1253
|
const index = state.remoteParticipants.findIndex((c) => c.id === participantId);
|
|
@@ -1293,7 +1371,7 @@ const remoteParticipantsSlice = toolkit.createSlice({
|
|
|
1293
1371
|
return Object.assign(Object.assign({}, state), { remoteParticipants: clients
|
|
1294
1372
|
.filter((c) => c.id !== selfId)
|
|
1295
1373
|
.filter((c) => !NON_PERSON_ROLES.includes(c.role.roleName))
|
|
1296
|
-
.map((c) =>
|
|
1374
|
+
.map((c) => createRemoteParticipant(c)) });
|
|
1297
1375
|
});
|
|
1298
1376
|
builder.addCase(rtcEvents.streamAdded, (state, action) => {
|
|
1299
1377
|
return addStream(state, action.payload);
|
|
@@ -1303,7 +1381,7 @@ const remoteParticipantsSlice = toolkit.createSlice({
|
|
|
1303
1381
|
if (NON_PERSON_ROLES.includes(client.role.roleName)) {
|
|
1304
1382
|
return state;
|
|
1305
1383
|
}
|
|
1306
|
-
return addParticipant(state,
|
|
1384
|
+
return addParticipant(state, createRemoteParticipant(client, true));
|
|
1307
1385
|
});
|
|
1308
1386
|
builder.addCase(signalEvents.clientLeft, (state, action) => {
|
|
1309
1387
|
const { clientId } = action.payload;
|
|
@@ -1338,6 +1416,11 @@ const remoteParticipantsSlice = toolkit.createSlice({
|
|
|
1338
1416
|
},
|
|
1339
1417
|
});
|
|
1340
1418
|
const { participantStreamAdded, participantStreamIdAdded, streamStatusUpdated } = remoteParticipantsSlice.actions;
|
|
1419
|
+
const doRequestAudioEnable = createAppAuthorizedThunk((state) => selectIsAuthorizedToRequestAudioEnable(state), (payload) => (_, getState) => {
|
|
1420
|
+
const state = getState();
|
|
1421
|
+
const socket = selectSignalConnectionRaw(state).socket;
|
|
1422
|
+
socket === null || socket === void 0 ? void 0 : socket.emit("request_audio_enable", payload);
|
|
1423
|
+
});
|
|
1341
1424
|
const selectRemoteParticipantsRaw = (state) => state.remoteParticipants;
|
|
1342
1425
|
const selectRemoteParticipants = (state) => state.remoteParticipants.remoteParticipants;
|
|
1343
1426
|
const selectScreenshares = toolkit.createSelector(selectLocalScreenshareStream, selectRemoteParticipants, (localScreenshareStream, remoteParticipants) => {
|
|
@@ -1417,7 +1500,7 @@ const doKnockRoom = createAppThunk(() => (dispatch, getState) => {
|
|
|
1417
1500
|
const state = getState();
|
|
1418
1501
|
const socket = selectSignalConnectionRaw(state).socket;
|
|
1419
1502
|
const roomName = selectAppRoomName(state);
|
|
1420
|
-
const roomKey =
|
|
1503
|
+
const roomKey = selectAuthorizationRoomKey(state);
|
|
1421
1504
|
const displayName = selectAppDisplayName(state);
|
|
1422
1505
|
const userAgent = selectAppUserAgent(state);
|
|
1423
1506
|
const externalId = selectAppExternalId(state);
|
|
@@ -1446,7 +1529,7 @@ const doConnectRoom = createAppThunk(() => (dispatch, getState) => {
|
|
|
1446
1529
|
const state = getState();
|
|
1447
1530
|
const socket = selectSignalConnectionRaw(state).socket;
|
|
1448
1531
|
const roomName = selectAppRoomName(state);
|
|
1449
|
-
const roomKey =
|
|
1532
|
+
const roomKey = selectAuthorizationRoomKey(state);
|
|
1450
1533
|
const displayName = selectAppDisplayName(state);
|
|
1451
1534
|
const userAgent = selectAppUserAgent(state);
|
|
1452
1535
|
const externalId = selectAppExternalId(state);
|
|
@@ -2037,6 +2120,7 @@ var _a;
|
|
|
2037
2120
|
const IS_DEV = (_a = undefined === "true") !== null && _a !== void 0 ? _a : false;
|
|
2038
2121
|
const rootReducer = toolkit.combineReducers({
|
|
2039
2122
|
app: appSlice.reducer,
|
|
2123
|
+
authorization: authorizationSlice.reducer,
|
|
2040
2124
|
chat: chatSlice.reducer,
|
|
2041
2125
|
cloudRecording: cloudRecordingSlice.reducer,
|
|
2042
2126
|
deviceCredentials: deviceCredentialsSlice.reducer,
|
|
@@ -3097,9 +3181,11 @@ exports.RoomService = RoomService;
|
|
|
3097
3181
|
exports.addAppListener = addAppListener;
|
|
3098
3182
|
exports.appLeft = appLeft;
|
|
3099
3183
|
exports.appSlice = appSlice;
|
|
3184
|
+
exports.authorizationSlice = authorizationSlice;
|
|
3100
3185
|
exports.chatSlice = chatSlice;
|
|
3101
3186
|
exports.cloudRecordingSlice = cloudRecordingSlice;
|
|
3102
3187
|
exports.createAppAsyncThunk = createAppAsyncThunk;
|
|
3188
|
+
exports.createAppAuthorizedThunk = createAppAuthorizedThunk;
|
|
3103
3189
|
exports.createAppThunk = createAppThunk;
|
|
3104
3190
|
exports.createReactor = createReactor;
|
|
3105
3191
|
exports.createServices = createServices;
|
|
@@ -3122,8 +3208,10 @@ exports.doHandleAcceptStreams = doHandleAcceptStreams;
|
|
|
3122
3208
|
exports.doHandleStreamingStarted = doHandleStreamingStarted;
|
|
3123
3209
|
exports.doHandleStreamingStopped = doHandleStreamingStopped;
|
|
3124
3210
|
exports.doKnockRoom = doKnockRoom;
|
|
3211
|
+
exports.doLockRoom = doLockRoom;
|
|
3125
3212
|
exports.doOrganizationFetch = doOrganizationFetch;
|
|
3126
3213
|
exports.doRejectWaitingParticipant = doRejectWaitingParticipant;
|
|
3214
|
+
exports.doRequestAudioEnable = doRequestAudioEnable;
|
|
3127
3215
|
exports.doRtcAnalyticsCustomEventsInitialize = doRtcAnalyticsCustomEventsInitialize;
|
|
3128
3216
|
exports.doRtcManagerCreated = doRtcManagerCreated;
|
|
3129
3217
|
exports.doRtcManagerInitialize = doRtcManagerInitialize;
|
|
@@ -3159,6 +3247,7 @@ exports.localStreamMetadataUpdated = localStreamMetadataUpdated;
|
|
|
3159
3247
|
exports.observeStore = observeStore;
|
|
3160
3248
|
exports.organizationSlice = organizationSlice;
|
|
3161
3249
|
exports.parseRoomUrlAndSubdomain = parseRoomUrlAndSubdomain;
|
|
3250
|
+
exports.parseUnverifiedRoomKeyData = parseUnverifiedRoomKeyData;
|
|
3162
3251
|
exports.participantStreamAdded = participantStreamAdded;
|
|
3163
3252
|
exports.participantStreamIdAdded = participantStreamIdAdded;
|
|
3164
3253
|
exports.recordingRequestStarted = recordingRequestStarted;
|
|
@@ -3178,11 +3267,12 @@ exports.selectAppDisplayName = selectAppDisplayName;
|
|
|
3178
3267
|
exports.selectAppExternalId = selectAppExternalId;
|
|
3179
3268
|
exports.selectAppIsNodeSdk = selectAppIsNodeSdk;
|
|
3180
3269
|
exports.selectAppRaw = selectAppRaw;
|
|
3181
|
-
exports.selectAppRoomKey = selectAppRoomKey;
|
|
3182
3270
|
exports.selectAppRoomName = selectAppRoomName;
|
|
3183
3271
|
exports.selectAppRoomUrl = selectAppRoomUrl;
|
|
3184
3272
|
exports.selectAppUserAgent = selectAppUserAgent;
|
|
3185
3273
|
exports.selectAppWantsToJoin = selectAppWantsToJoin;
|
|
3274
|
+
exports.selectAuthorizationRoomKey = selectAuthorizationRoomKey;
|
|
3275
|
+
exports.selectAuthorizationRoomLocked = selectAuthorizationRoomLocked;
|
|
3186
3276
|
exports.selectBusyDeviceIds = selectBusyDeviceIds;
|
|
3187
3277
|
exports.selectCameraDeviceError = selectCameraDeviceError;
|
|
3188
3278
|
exports.selectCameraDevices = selectCameraDevices;
|
|
@@ -3198,6 +3288,8 @@ exports.selectDeviceCredentialsRaw = selectDeviceCredentialsRaw;
|
|
|
3198
3288
|
exports.selectDeviceId = selectDeviceId;
|
|
3199
3289
|
exports.selectHasFetchedDeviceCredentials = selectHasFetchedDeviceCredentials;
|
|
3200
3290
|
exports.selectIsAcceptingStreams = selectIsAcceptingStreams;
|
|
3291
|
+
exports.selectIsAuthorizedToLockRoom = selectIsAuthorizedToLockRoom;
|
|
3292
|
+
exports.selectIsAuthorizedToRequestAudioEnable = selectIsAuthorizedToRequestAudioEnable;
|
|
3201
3293
|
exports.selectIsCameraEnabled = selectIsCameraEnabled;
|
|
3202
3294
|
exports.selectIsCloudRecording = selectIsCloudRecording;
|
|
3203
3295
|
exports.selectIsLocalMediaStarting = selectIsLocalMediaStarting;
|