@whereby.com/core 1.31.6 → 1.32.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 +149 -28
- package/dist/index.d.cts +741 -1
- package/dist/index.d.mts +741 -1
- package/dist/index.d.ts +741 -1
- package/dist/index.mjs +149 -29
- package/dist/legacy-esm.js +149 -29
- package/dist/redux/index.cjs +400 -15
- package/dist/redux/index.d.cts +559 -4
- package/dist/redux/index.d.mts +559 -4
- package/dist/redux/index.d.ts +559 -4
- package/dist/redux/index.js +393 -16
- package/dist/redux/index.mjs +393 -16
- package/package.json +9 -9
package/dist/redux/index.cjs
CHANGED
|
@@ -76,7 +76,7 @@ const createReactor = (selectors, callback) => {
|
|
|
76
76
|
});
|
|
77
77
|
};
|
|
78
78
|
|
|
79
|
-
const coreVersion = "1.
|
|
79
|
+
const coreVersion = "1.32.0";
|
|
80
80
|
|
|
81
81
|
function decodeRoomName(roomName) {
|
|
82
82
|
if (!roomName) {
|
|
@@ -710,8 +710,9 @@ const doToggleCamera = createAppAsyncThunk("localMedia/doToggleCamera", (_1, _a)
|
|
|
710
710
|
if (!stream) {
|
|
711
711
|
return;
|
|
712
712
|
}
|
|
713
|
-
|
|
713
|
+
const track = stream.getVideoTracks()[0];
|
|
714
714
|
const enabled = selectIsCameraEnabled(state);
|
|
715
|
+
const before = snapshotTracks(stream);
|
|
715
716
|
try {
|
|
716
717
|
if (enabled) {
|
|
717
718
|
if (track) {
|
|
@@ -721,7 +722,6 @@ const doToggleCamera = createAppAsyncThunk("localMedia/doToggleCamera", (_1, _a)
|
|
|
721
722
|
const constraintsOptions = selectLocalMediaConstraintsOptions(state);
|
|
722
723
|
const cameraDeviceId = selectCurrentCameraDeviceId(state);
|
|
723
724
|
yield media.getStream(Object.assign(Object.assign({}, constraintsOptions), { audioId: false, videoId: cameraDeviceId, type: "exact" }), { replaceStream: stream });
|
|
724
|
-
track = stream.getVideoTracks()[0];
|
|
725
725
|
}
|
|
726
726
|
}
|
|
727
727
|
else {
|
|
@@ -732,7 +732,7 @@ const doToggleCamera = createAppAsyncThunk("localMedia/doToggleCamera", (_1, _a)
|
|
|
732
732
|
track.stop();
|
|
733
733
|
stream.removeTrack(track);
|
|
734
734
|
}
|
|
735
|
-
|
|
735
|
+
return { changedTracks: findChangedTracks(stream, before) };
|
|
736
736
|
}
|
|
737
737
|
catch (error) {
|
|
738
738
|
return rejectWithValue(error);
|
|
@@ -2423,32 +2423,80 @@ function isStreamerClient(client) {
|
|
|
2423
2423
|
function isRecorderClient(client) {
|
|
2424
2424
|
return client.roleName === "recorder";
|
|
2425
2425
|
}
|
|
2426
|
+
function lockStateFromSignal(state, isLocked) {
|
|
2427
|
+
if (!state.isInRoom) {
|
|
2428
|
+
return state;
|
|
2429
|
+
}
|
|
2430
|
+
return Object.assign(Object.assign({}, state), { isLocked, lockStateSource: "signal", roomFetchStatus: "fetched", roomFetchRequestId: null });
|
|
2431
|
+
}
|
|
2426
2432
|
const roomSliceInitialState = {
|
|
2427
2433
|
isLocked: false,
|
|
2434
|
+
lockStateSource: null,
|
|
2435
|
+
lockStateRoomUrl: null,
|
|
2436
|
+
requestedRoomUrl: null,
|
|
2437
|
+
roomFetchStatus: "idle",
|
|
2438
|
+
roomFetchRequestId: null,
|
|
2439
|
+
isInRoom: false,
|
|
2428
2440
|
mode: null,
|
|
2429
2441
|
};
|
|
2430
2442
|
const roomSlice = toolkit.createSlice({
|
|
2431
2443
|
name: "room",
|
|
2432
2444
|
initialState: roomSliceInitialState,
|
|
2433
|
-
reducers: {
|
|
2445
|
+
reducers: {
|
|
2446
|
+
setRequestedRoomUrl: (state, action) => {
|
|
2447
|
+
if (state.roomFetchStatus === "failed") {
|
|
2448
|
+
return Object.assign(Object.assign({}, state), { requestedRoomUrl: action.payload, roomFetchStatus: "idle" });
|
|
2449
|
+
}
|
|
2450
|
+
if (action.payload === state.requestedRoomUrl) {
|
|
2451
|
+
return state;
|
|
2452
|
+
}
|
|
2453
|
+
return Object.assign(Object.assign({}, state), { requestedRoomUrl: action.payload });
|
|
2454
|
+
},
|
|
2455
|
+
},
|
|
2434
2456
|
extraReducers: (builder) => {
|
|
2457
|
+
builder.addCase(appSlice.actions.doAppStart, (state) => {
|
|
2458
|
+
return Object.assign(Object.assign({}, state), { isInRoom: true });
|
|
2459
|
+
});
|
|
2460
|
+
builder.addCase(appSlice.actions.doAppStop, (state) => {
|
|
2461
|
+
return Object.assign(Object.assign({}, state), { isInRoom: false });
|
|
2462
|
+
});
|
|
2435
2463
|
builder.addCase(signalEvents.roomJoined, (state, action) => {
|
|
2436
2464
|
var _a;
|
|
2437
2465
|
if ("error" in action.payload) {
|
|
2438
2466
|
if (action.payload.error === "room_locked") {
|
|
2439
|
-
return
|
|
2467
|
+
return lockStateFromSignal(state, Boolean(action.payload.isLocked));
|
|
2440
2468
|
}
|
|
2441
2469
|
return state;
|
|
2442
2470
|
}
|
|
2443
2471
|
const { room } = action.payload;
|
|
2444
|
-
return Object.assign(Object.assign({}, state
|
|
2472
|
+
return Object.assign(Object.assign({}, lockStateFromSignal(state, Boolean(room.isLocked))), { mode: (_a = room.mode) !== null && _a !== void 0 ? _a : (room.sfuServer ? "group" : "normal") });
|
|
2445
2473
|
});
|
|
2446
2474
|
builder.addCase(signalEvents.roomLocked, (state, action) => {
|
|
2447
|
-
|
|
2448
|
-
|
|
2475
|
+
return lockStateFromSignal(state, Boolean(action.payload.isLocked));
|
|
2476
|
+
});
|
|
2477
|
+
builder.addCase(doFetchRoom.pending, (state, action) => {
|
|
2478
|
+
return Object.assign(Object.assign({}, state), { isLocked: false, lockStateSource: null, lockStateRoomUrl: action.meta.arg, roomFetchStatus: "fetching", roomFetchRequestId: action.meta.requestId });
|
|
2479
|
+
});
|
|
2480
|
+
builder.addCase(doFetchRoom.fulfilled, (state, action) => {
|
|
2481
|
+
var _a;
|
|
2482
|
+
if (action.meta.requestId !== state.roomFetchRequestId) {
|
|
2483
|
+
return state;
|
|
2484
|
+
}
|
|
2485
|
+
return Object.assign(Object.assign({}, state), { isLocked: (_a = action.payload.isLocked) !== null && _a !== void 0 ? _a : false, lockStateSource: action.payload.isLocked === null ? null : "fetch", roomFetchStatus: "fetched" });
|
|
2486
|
+
});
|
|
2487
|
+
builder.addCase(doFetchRoom.rejected, (state, action) => {
|
|
2488
|
+
if (action.meta.requestId !== state.roomFetchRequestId) {
|
|
2489
|
+
return state;
|
|
2490
|
+
}
|
|
2491
|
+
return Object.assign(Object.assign({}, state), { roomFetchStatus: "failed" });
|
|
2449
2492
|
});
|
|
2450
2493
|
},
|
|
2451
2494
|
});
|
|
2495
|
+
const { setRequestedRoomUrl } = roomSlice.actions;
|
|
2496
|
+
const doFetchRoom = createAppAsyncThunk("room/doFetchRoom", (roomUrl_1, _a) => __awaiter(void 0, [roomUrl_1, _a], void 0, function* (roomUrl, { extra }) {
|
|
2497
|
+
const room = yield extra.services.fetchRoomFromRoomUrl(roomUrl);
|
|
2498
|
+
return { isLocked: room.isClaimed && !room.isBanned ? Boolean(room.isLocked) : null };
|
|
2499
|
+
}));
|
|
2452
2500
|
const doLockRoom = createAppAuthorizedThunk((state) => selectIsAuthorizedToLockRoom(state), (payload) => (_, getState) => {
|
|
2453
2501
|
const state = getState();
|
|
2454
2502
|
const { socket } = selectSignalConnectionRaw(state);
|
|
@@ -2471,6 +2519,12 @@ const doEndMeeting = createAppAuthorizedThunk((state) => selectIsAuthorizedToEnd
|
|
|
2471
2519
|
}
|
|
2472
2520
|
});
|
|
2473
2521
|
const selectRoomIsLocked = (state) => state.room.isLocked;
|
|
2522
|
+
const selectRoomLockStateSource = (state) => state.room.lockStateSource;
|
|
2523
|
+
const selectRoomLockStateRoomUrl = (state) => state.room.lockStateRoomUrl;
|
|
2524
|
+
const selectRoomRequestedUrl = (state) => state.room.requestedRoomUrl;
|
|
2525
|
+
const selectRoomFetchStatus = (state) => state.room.roomFetchStatus;
|
|
2526
|
+
const selectRoomLockState = toolkit.createSelector(selectRoomIsLocked, selectRoomLockStateSource, (isLocked, source) => source ? isLocked : null);
|
|
2527
|
+
const selectShouldFetchRoom = toolkit.createSelector(selectAppIsActive, selectRoomRequestedUrl, selectRoomLockStateRoomUrl, selectRoomFetchStatus, (appIsActive, requestedRoomUrl, lockStateRoomUrl, roomFetchStatus) => !appIsActive && !!requestedRoomUrl && (requestedRoomUrl !== lockStateRoomUrl || roomFetchStatus === "idle"));
|
|
2474
2528
|
const selectRoomMode = (state) => state.room.mode;
|
|
2475
2529
|
const selectScreenshares = toolkit.createSelector(selectLocalScreenshareStream, selectLocalParticipantRaw, selectRemoteParticipants, (localScreenshareStream, localParticipant, remoteParticipants) => {
|
|
2476
2530
|
const screenshares = [];
|
|
@@ -2563,6 +2617,12 @@ const selectBreakoutGroupedParticipants = toolkit.createSelector(selectAllClient
|
|
|
2563
2617
|
}));
|
|
2564
2618
|
return [mainRoom, ...groups];
|
|
2565
2619
|
});
|
|
2620
|
+
createReactor([selectShouldFetchRoom], ({ dispatch, getState }, shouldFetchRoom) => {
|
|
2621
|
+
const roomUrl = selectRoomRequestedUrl(getState());
|
|
2622
|
+
if (shouldFetchRoom && roomUrl) {
|
|
2623
|
+
dispatch(doFetchRoom(roomUrl));
|
|
2624
|
+
}
|
|
2625
|
+
});
|
|
2566
2626
|
|
|
2567
2627
|
function streamIdForClient({ isPresentation, stream }) {
|
|
2568
2628
|
var _a, _b;
|
|
@@ -2906,6 +2966,21 @@ const handOverChangedTracks = ({ payload }, { getState }) => {
|
|
|
2906
2966
|
startAppListening({ actionCreator: doSetDevice.fulfilled, effect: handOverChangedTracks });
|
|
2907
2967
|
startAppListening({ actionCreator: doSwitchLocalStream.fulfilled, effect: handOverChangedTracks });
|
|
2908
2968
|
startAppListening({ actionCreator: doLocalStreamEffect.fulfilled, effect: handOverChangedTracks });
|
|
2969
|
+
startAppListening({
|
|
2970
|
+
actionCreator: doToggleCamera.fulfilled,
|
|
2971
|
+
effect: (action, { getState }) => {
|
|
2972
|
+
handOverChangedTracks(action, { getState });
|
|
2973
|
+
const { rtcManager } = selectRtcConnectionRaw(getState());
|
|
2974
|
+
rtcManager === null || rtcManager === void 0 ? void 0 : rtcManager.stopOrResumeVideo({ enable: selectIsCameraEnabled(getState()) });
|
|
2975
|
+
},
|
|
2976
|
+
});
|
|
2977
|
+
startAppListening({
|
|
2978
|
+
predicate: (_action, currentState, previousState) => selectIsMicrophoneEnabled(currentState) !== selectIsMicrophoneEnabled(previousState),
|
|
2979
|
+
effect: (_action, { getState }) => {
|
|
2980
|
+
const { rtcManager } = selectRtcConnectionRaw(getState());
|
|
2981
|
+
rtcManager === null || rtcManager === void 0 ? void 0 : rtcManager.stopOrResumeAudio({ enable: selectIsMicrophoneEnabled(getState()) });
|
|
2982
|
+
},
|
|
2983
|
+
});
|
|
2909
2984
|
startAppListening({
|
|
2910
2985
|
actionCreator: doStartScreenshare.fulfilled,
|
|
2911
2986
|
effect: ({ payload }, { getState }) => {
|
|
@@ -4906,13 +4981,15 @@ const appReducer = toolkit.combineReducers({
|
|
|
4906
4981
|
waitingParticipants: waitingParticipantsSlice.reducer,
|
|
4907
4982
|
});
|
|
4908
4983
|
const rootReducer = (state, action) => {
|
|
4909
|
-
var _a;
|
|
4984
|
+
var _a, _b, _c;
|
|
4910
4985
|
if (doAppStart.match(action)) {
|
|
4911
4986
|
const resetState = {
|
|
4912
4987
|
app: Object.assign(Object.assign({}, appSlice.getInitialState()), { initialConfig: (_a = state === null || state === void 0 ? void 0 : state.app) === null || _a === void 0 ? void 0 : _a.initialConfig }),
|
|
4913
4988
|
localMedia: Object.assign(Object.assign({}, localMediaSlice.getInitialState()), state === null || state === void 0 ? void 0 : state.localMedia),
|
|
4914
4989
|
cameraEffects: Object.assign(Object.assign({}, cameraEffectsSlice.getInitialState()), state === null || state === void 0 ? void 0 : state.cameraEffects),
|
|
4915
4990
|
audioDenoiser: Object.assign(Object.assign({}, audioDenoiserSlice.getInitialState()), state === null || state === void 0 ? void 0 : state.audioDenoiser),
|
|
4991
|
+
room: (state === null || state === void 0 ? void 0 : state.room) && action.payload.roomUrl === state.room.lockStateRoomUrl
|
|
4992
|
+
? Object.assign(Object.assign({}, state.room), { mode: null }) : Object.assign(Object.assign({}, roomSlice.getInitialState()), { lockStateRoomUrl: action.payload.roomUrl, requestedRoomUrl: (_c = (_b = state === null || state === void 0 ? void 0 : state.room) === null || _b === void 0 ? void 0 : _b.requestedRoomUrl) !== null && _c !== void 0 ? _c : null }),
|
|
4916
4993
|
};
|
|
4917
4994
|
return appReducer(resetState, action);
|
|
4918
4995
|
}
|
|
@@ -4976,10 +5053,24 @@ function assertInstanceOf(value, type, parameterName) {
|
|
|
4976
5053
|
media.assert.ok(value instanceof type, `${resolvedParameterName}<${type.name}> is required`);
|
|
4977
5054
|
return value;
|
|
4978
5055
|
}
|
|
5056
|
+
function assertRoomName(roomName, parameterName = "roomName") {
|
|
5057
|
+
assertString(roomName, parameterName);
|
|
5058
|
+
media.assert.ok(typeof roomName === "string" && roomName[0] === "/", `${parameterName} must begin with a '/'`);
|
|
5059
|
+
return roomName;
|
|
5060
|
+
}
|
|
4979
5061
|
function assertArray(array, parameterName) {
|
|
4980
5062
|
media.assert.ok(Array.isArray(array), `${parameterName}<array> is required`);
|
|
4981
5063
|
return array;
|
|
4982
5064
|
}
|
|
5065
|
+
function assertOneOf(value, allowedValues, parameterName) {
|
|
5066
|
+
assertTruthy(value, "value");
|
|
5067
|
+
assertArray(allowedValues, "allowedValues");
|
|
5068
|
+
const isAllowed = allowedValues.includes(value);
|
|
5069
|
+
if (!isAllowed) {
|
|
5070
|
+
throw new Error(`${parameterName}<string> must be one of the following: ${allowedValues.join(", ")}`);
|
|
5071
|
+
}
|
|
5072
|
+
return value;
|
|
5073
|
+
}
|
|
4983
5074
|
function assertRecord(ref, name) {
|
|
4984
5075
|
if (ref === null || ref === undefined || typeof ref !== "object" || Array.isArray(ref)) {
|
|
4985
5076
|
throw new Error(`${name} must be a record. ${JSON.stringify(ref)}`);
|
|
@@ -5139,6 +5230,14 @@ function extractString(data, propertyName) {
|
|
|
5139
5230
|
return assertString(record[propertyName], propertyName);
|
|
5140
5231
|
}
|
|
5141
5232
|
const extractNullOrString = nullOrExtract(extractString);
|
|
5233
|
+
function extractDate(data, propertyName) {
|
|
5234
|
+
const dateString = extractString(data, propertyName);
|
|
5235
|
+
const d = new Date(dateString);
|
|
5236
|
+
if (isNaN(d.getTime())) {
|
|
5237
|
+
throw new Error(`Invalid date for ${dateString}`);
|
|
5238
|
+
}
|
|
5239
|
+
return d;
|
|
5240
|
+
}
|
|
5142
5241
|
function extractArrayOfJson(data, propertyName) {
|
|
5143
5242
|
const record = assertRecord(data, "data");
|
|
5144
5243
|
return assertArray(record[propertyName], propertyName);
|
|
@@ -5348,6 +5447,33 @@ class CredentialsService extends events$1.EventEmitter {
|
|
|
5348
5447
|
}
|
|
5349
5448
|
}
|
|
5350
5449
|
|
|
5450
|
+
const noOrganization = () => Promise.resolve(undefined);
|
|
5451
|
+
class OrganizationApiClient {
|
|
5452
|
+
constructor({ apiClient, fetchOrganization = noOrganization, }) {
|
|
5453
|
+
this._apiClient = apiClient;
|
|
5454
|
+
this._fetchOrganization = fetchOrganization;
|
|
5455
|
+
this._apiClient = apiClient;
|
|
5456
|
+
}
|
|
5457
|
+
_callRequestMethod(method, url, options) {
|
|
5458
|
+
assertString(url, "url");
|
|
5459
|
+
media.assert.ok(url[0] === "/", 'url<String> only accepts relative URLs beginning with "/".');
|
|
5460
|
+
media.assert.ok(options, "options are required");
|
|
5461
|
+
return this._fetchOrganization().then((organization) => {
|
|
5462
|
+
if (!organization) {
|
|
5463
|
+
return this._apiClient[method](url, options);
|
|
5464
|
+
}
|
|
5465
|
+
const { organizationId } = organization;
|
|
5466
|
+
return this._apiClient[method](`/organizations/${encodeURIComponent(organizationId)}${url}`, options);
|
|
5467
|
+
});
|
|
5468
|
+
}
|
|
5469
|
+
request(url, options) {
|
|
5470
|
+
return this._callRequestMethod("request", url, options);
|
|
5471
|
+
}
|
|
5472
|
+
requestMultipart(url, options) {
|
|
5473
|
+
return this._callRequestMethod("requestMultipart", url, options);
|
|
5474
|
+
}
|
|
5475
|
+
}
|
|
5476
|
+
|
|
5351
5477
|
class EmbeddedFreeTierStatus {
|
|
5352
5478
|
constructor({ isExhausted, renewsAt, totalMinutesLimit, totalMinutesUsed, }) {
|
|
5353
5479
|
this.isExhausted = isExhausted;
|
|
@@ -5639,6 +5765,229 @@ class OrganizationServiceCache {
|
|
|
5639
5765
|
}
|
|
5640
5766
|
}
|
|
5641
5767
|
|
|
5768
|
+
class Room {
|
|
5769
|
+
constructor(properties = {}) {
|
|
5770
|
+
media.assert.ok(properties instanceof Object, "properties<object> must be empty or an object");
|
|
5771
|
+
this.isClaimed = false;
|
|
5772
|
+
this.isBanned = false;
|
|
5773
|
+
this.isLocked = false;
|
|
5774
|
+
this.knockPage = {
|
|
5775
|
+
backgroundImageUrl: null,
|
|
5776
|
+
backgroundThumbnailUrl: null,
|
|
5777
|
+
};
|
|
5778
|
+
this.logoUrl = null;
|
|
5779
|
+
this.backgroundImageUrl = null;
|
|
5780
|
+
this.backgroundThumbnailUrl = null;
|
|
5781
|
+
this.type = null;
|
|
5782
|
+
this.legacyRoomType = null;
|
|
5783
|
+
this.mode = null;
|
|
5784
|
+
this.product = null;
|
|
5785
|
+
this.roomName = null;
|
|
5786
|
+
this.theme = null;
|
|
5787
|
+
this.preferences = {};
|
|
5788
|
+
this.protectedPreferences = {};
|
|
5789
|
+
this.publicProfile = null;
|
|
5790
|
+
const validProperties = {};
|
|
5791
|
+
Object.getOwnPropertyNames(properties).forEach((prop) => {
|
|
5792
|
+
if (Object.getOwnPropertyNames(this).indexOf(prop) !== -1) {
|
|
5793
|
+
validProperties[prop] = properties[prop];
|
|
5794
|
+
}
|
|
5795
|
+
});
|
|
5796
|
+
if (properties.ownerId !== undefined) {
|
|
5797
|
+
this.ownerId = properties.ownerId;
|
|
5798
|
+
}
|
|
5799
|
+
if (properties.meeting !== undefined) {
|
|
5800
|
+
this.meeting = properties.meeting;
|
|
5801
|
+
}
|
|
5802
|
+
Object.assign(this, validProperties);
|
|
5803
|
+
}
|
|
5804
|
+
}
|
|
5805
|
+
|
|
5806
|
+
class Meeting {
|
|
5807
|
+
constructor({ meetingId, roomName, roomUrl, startDate, endDate, hostRoomUrl, viewerRoomUrl }) {
|
|
5808
|
+
assertString(meetingId, "meetingId");
|
|
5809
|
+
assertString(roomName, "roomName");
|
|
5810
|
+
assertString(roomUrl, "roomUrl");
|
|
5811
|
+
assertInstanceOf(startDate, Date, "startDate");
|
|
5812
|
+
assertInstanceOf(endDate, Date, "endDate");
|
|
5813
|
+
this.meetingId = meetingId;
|
|
5814
|
+
this.roomName = roomName;
|
|
5815
|
+
this.roomUrl = roomUrl;
|
|
5816
|
+
this.startDate = startDate;
|
|
5817
|
+
this.endDate = endDate;
|
|
5818
|
+
this.hostRoomUrl = hostRoomUrl;
|
|
5819
|
+
this.viewerRoomUrl = viewerRoomUrl;
|
|
5820
|
+
}
|
|
5821
|
+
static fromJson(data) {
|
|
5822
|
+
return new Meeting({
|
|
5823
|
+
meetingId: extractString(data, "meetingId"),
|
|
5824
|
+
roomName: extractString(data, "roomName"),
|
|
5825
|
+
roomUrl: extractString(data, "roomUrl"),
|
|
5826
|
+
startDate: extractDate(data, "startDate"),
|
|
5827
|
+
endDate: extractDate(data, "endDate"),
|
|
5828
|
+
hostRoomUrl: extractNullOrString(data, "hostRoomUrl"),
|
|
5829
|
+
viewerRoomUrl: extractNullOrString(data, "viewerRoomUrl"),
|
|
5830
|
+
});
|
|
5831
|
+
}
|
|
5832
|
+
}
|
|
5833
|
+
|
|
5834
|
+
function createRoomUrl(roomName, path = "") {
|
|
5835
|
+
const encodedDisplayName = encodeURIComponent(roomName.substring(1));
|
|
5836
|
+
return `/room/${encodedDisplayName}${path}`;
|
|
5837
|
+
}
|
|
5838
|
+
class RoomService {
|
|
5839
|
+
constructor({ organizationApiClient }) {
|
|
5840
|
+
this._organizationApiClient = assertInstanceOf(organizationApiClient, OrganizationApiClient);
|
|
5841
|
+
}
|
|
5842
|
+
getRooms({ types, fields = [] } = {}) {
|
|
5843
|
+
assertArray(types, "types");
|
|
5844
|
+
assertArray(fields, "fields");
|
|
5845
|
+
return this._organizationApiClient
|
|
5846
|
+
.request("/room", {
|
|
5847
|
+
method: "GET",
|
|
5848
|
+
params: { types: types.join(","), fields: fields.join(","), includeOnlyLegacyRoomType: "false" },
|
|
5849
|
+
})
|
|
5850
|
+
.then(({ data }) => data.rooms.map((room) => new Room(room)));
|
|
5851
|
+
}
|
|
5852
|
+
getRoom({ roomName, fields }) {
|
|
5853
|
+
assertRoomName(roomName);
|
|
5854
|
+
const encodedDisplayName = encodeURIComponent(roomName.substring(1));
|
|
5855
|
+
return this._organizationApiClient
|
|
5856
|
+
.request(`/rooms/${encodedDisplayName}`, {
|
|
5857
|
+
method: "GET",
|
|
5858
|
+
params: Object.assign({ includeOnlyLegacyRoomType: "false" }, (fields && { fields: fields.join(",") })),
|
|
5859
|
+
})
|
|
5860
|
+
.then(({ data }) => new Room(Object.assign({}, data, Object.assign({ roomName }, (data.meeting && { meeting: Meeting.fromJson(data.meeting) })))))
|
|
5861
|
+
.catch((response) => {
|
|
5862
|
+
if (response.status === 404) {
|
|
5863
|
+
return new Room({
|
|
5864
|
+
roomName,
|
|
5865
|
+
isClaimed: false,
|
|
5866
|
+
mode: "normal",
|
|
5867
|
+
product: {
|
|
5868
|
+
categoryName: "personal_free",
|
|
5869
|
+
},
|
|
5870
|
+
type: "personal",
|
|
5871
|
+
legacyRoomType: "free",
|
|
5872
|
+
});
|
|
5873
|
+
}
|
|
5874
|
+
if (response.status === 400 && response.data.error === "Banned room") {
|
|
5875
|
+
return new Room({ roomName, isBanned: true });
|
|
5876
|
+
}
|
|
5877
|
+
throw new Error(response.data ? response.data.error : "Could not fetch room information");
|
|
5878
|
+
});
|
|
5879
|
+
}
|
|
5880
|
+
claimRoom({ roomName, type, mode, isLocked }) {
|
|
5881
|
+
assertRoomName(roomName);
|
|
5882
|
+
assertString(type, "type");
|
|
5883
|
+
return this._organizationApiClient
|
|
5884
|
+
.request("/room/claim", {
|
|
5885
|
+
method: "POST",
|
|
5886
|
+
data: Object.assign(Object.assign({ roomName,
|
|
5887
|
+
type }, (typeof mode === "string" && { mode })), (typeof isLocked === "boolean" && { isLocked })),
|
|
5888
|
+
})
|
|
5889
|
+
.then(() => undefined)
|
|
5890
|
+
.catch((response) => {
|
|
5891
|
+
throw new Error(response.data.error || "Failed to claim room");
|
|
5892
|
+
});
|
|
5893
|
+
}
|
|
5894
|
+
unclaimRoom(roomName) {
|
|
5895
|
+
assertRoomName(roomName);
|
|
5896
|
+
const encodedDisplayName = encodeURIComponent(roomName.substring(1));
|
|
5897
|
+
return this._organizationApiClient
|
|
5898
|
+
.request(`/room/${encodedDisplayName}`, {
|
|
5899
|
+
method: "DELETE",
|
|
5900
|
+
})
|
|
5901
|
+
.then(() => undefined);
|
|
5902
|
+
}
|
|
5903
|
+
renameRoom({ roomName, newRoomName }) {
|
|
5904
|
+
assertRoomName(roomName);
|
|
5905
|
+
assertString(newRoomName, "newRoomName");
|
|
5906
|
+
const encodedRoomName = encodeURIComponent(roomName.substring(1));
|
|
5907
|
+
return this._organizationApiClient
|
|
5908
|
+
.request(`/room/${encodedRoomName}/roomName`, {
|
|
5909
|
+
method: "PUT",
|
|
5910
|
+
data: { newRoomName },
|
|
5911
|
+
})
|
|
5912
|
+
.then(() => undefined);
|
|
5913
|
+
}
|
|
5914
|
+
changeMode({ roomName, mode }) {
|
|
5915
|
+
assertRoomName(roomName);
|
|
5916
|
+
assertString(mode, "mode");
|
|
5917
|
+
const encodedDisplayName = encodeURIComponent(roomName.substring(1));
|
|
5918
|
+
return this._organizationApiClient
|
|
5919
|
+
.request(`/room/${encodedDisplayName}/mode`, {
|
|
5920
|
+
method: "PUT",
|
|
5921
|
+
data: { mode },
|
|
5922
|
+
})
|
|
5923
|
+
.then(() => undefined);
|
|
5924
|
+
}
|
|
5925
|
+
updatePreferences({ roomName, preferences }) {
|
|
5926
|
+
assertRoomName(roomName);
|
|
5927
|
+
assertInstanceOf(preferences, Object, "preferences");
|
|
5928
|
+
const encodedDisplayName = encodeURIComponent(roomName.substring(1));
|
|
5929
|
+
return this._organizationApiClient
|
|
5930
|
+
.request(`/room/${encodedDisplayName}/preferences`, {
|
|
5931
|
+
method: "PATCH",
|
|
5932
|
+
data: preferences,
|
|
5933
|
+
})
|
|
5934
|
+
.then(() => undefined);
|
|
5935
|
+
}
|
|
5936
|
+
updateProtectedPreferences({ roomName, preferences }) {
|
|
5937
|
+
assertRoomName(roomName);
|
|
5938
|
+
assertInstanceOf(preferences, Object, "preferences");
|
|
5939
|
+
const encodedDisplayName = encodeURIComponent(roomName.substring(1));
|
|
5940
|
+
return this._organizationApiClient
|
|
5941
|
+
.request(`/room/${encodedDisplayName}/protected-preferences`, {
|
|
5942
|
+
method: "PATCH",
|
|
5943
|
+
data: preferences,
|
|
5944
|
+
})
|
|
5945
|
+
.then(() => undefined);
|
|
5946
|
+
}
|
|
5947
|
+
getRoomPermissions(roomName, { roomKey } = {}) {
|
|
5948
|
+
assertRoomName(roomName);
|
|
5949
|
+
return this._organizationApiClient
|
|
5950
|
+
.request(createRoomUrl(roomName, "/permissions"), Object.assign({ method: "GET" }, (roomKey && { headers: { "X-Whereby-Room-Key": roomKey } })))
|
|
5951
|
+
.then((response) => {
|
|
5952
|
+
const { permissions, limits } = response.data;
|
|
5953
|
+
return {
|
|
5954
|
+
permissions,
|
|
5955
|
+
limits,
|
|
5956
|
+
};
|
|
5957
|
+
});
|
|
5958
|
+
}
|
|
5959
|
+
getRoomMetrics({ roomName, metrics, from, to }) {
|
|
5960
|
+
assertRoomName(roomName);
|
|
5961
|
+
assertString(metrics, "metrics");
|
|
5962
|
+
return this._organizationApiClient
|
|
5963
|
+
.request(createRoomUrl(roomName, "/metrics"), {
|
|
5964
|
+
method: "GET",
|
|
5965
|
+
params: { metrics, from, to },
|
|
5966
|
+
})
|
|
5967
|
+
.then((response) => response.data);
|
|
5968
|
+
}
|
|
5969
|
+
changeType({ roomName, type }) {
|
|
5970
|
+
assertRoomName(roomName);
|
|
5971
|
+
assertOneOf(type, ["personal", "personal_xl"], "type");
|
|
5972
|
+
const encodedDisplayName = encodeURIComponent(roomName.substring(1));
|
|
5973
|
+
return this._organizationApiClient
|
|
5974
|
+
.request(`/room/${encodedDisplayName}/type`, {
|
|
5975
|
+
method: "PUT",
|
|
5976
|
+
data: { type },
|
|
5977
|
+
})
|
|
5978
|
+
.then(() => undefined);
|
|
5979
|
+
}
|
|
5980
|
+
getForestSocialImage({ roomName, count }) {
|
|
5981
|
+
assertRoomName(roomName);
|
|
5982
|
+
assertNumber(count, "count");
|
|
5983
|
+
return this._organizationApiClient
|
|
5984
|
+
.request(createRoomUrl(roomName, `/forest-social-image/${count}`), {
|
|
5985
|
+
method: "GET",
|
|
5986
|
+
})
|
|
5987
|
+
.then((response) => response.data.imageUrl);
|
|
5988
|
+
}
|
|
5989
|
+
}
|
|
5990
|
+
|
|
5642
5991
|
function roomPath(organizationId, roomName, suffix = "") {
|
|
5643
5992
|
const encodedRoomName = encodeURIComponent(roomName.replace(/^\//, ""));
|
|
5644
5993
|
return `/organizations/${encodeURIComponent(organizationId)}/room/${encodedRoomName}${suffix}`;
|
|
@@ -5686,21 +6035,49 @@ function createServices({ apiBaseUrl, signalBaseUrl } = {}) {
|
|
|
5686
6035
|
});
|
|
5687
6036
|
const organizationService = new OrganizationService({ apiClient });
|
|
5688
6037
|
const roomIntegrationService = new RoomIntegrationService({ apiClient });
|
|
6038
|
+
const organizationServiceCaches = new Map();
|
|
5689
6039
|
const fetchOrganizationFromRoomUrl = (roomUrl) => {
|
|
5690
6040
|
const roomUrlObj = new URL(roomUrl);
|
|
5691
|
-
const
|
|
5692
|
-
|
|
5693
|
-
|
|
5694
|
-
subdomain
|
|
6041
|
+
const { subdomain } = media.fromLocation({ host: roomUrlObj.host });
|
|
6042
|
+
let organizationServiceCache = organizationServiceCaches.get(subdomain);
|
|
6043
|
+
if (!organizationServiceCache) {
|
|
6044
|
+
organizationServiceCache = new OrganizationServiceCache({ organizationService, subdomain });
|
|
6045
|
+
organizationServiceCaches.set(subdomain, organizationServiceCache);
|
|
6046
|
+
}
|
|
6047
|
+
return organizationServiceCache.fetchOrganization().then((organization) => {
|
|
6048
|
+
if (!organization) {
|
|
6049
|
+
organizationServiceCaches.delete(subdomain);
|
|
6050
|
+
}
|
|
6051
|
+
return organization;
|
|
6052
|
+
}, (error) => {
|
|
6053
|
+
organizationServiceCaches.delete(subdomain);
|
|
6054
|
+
throw error;
|
|
5695
6055
|
});
|
|
5696
|
-
return organizationServiceCache.fetchOrganization();
|
|
5697
6056
|
};
|
|
6057
|
+
const fetchRoomFromRoomUrl = (roomUrl) => __awaiter(this, void 0, void 0, function* () {
|
|
6058
|
+
const roomName = decodeRoomName(new URL(roomUrl).pathname);
|
|
6059
|
+
if (!roomName || roomName === "/") {
|
|
6060
|
+
throw new Error("Invalid room url");
|
|
6061
|
+
}
|
|
6062
|
+
const organization = yield fetchOrganizationFromRoomUrl(roomUrl);
|
|
6063
|
+
if (!organization) {
|
|
6064
|
+
throw new Error("Organization not found");
|
|
6065
|
+
}
|
|
6066
|
+
const roomService = new RoomService({
|
|
6067
|
+
organizationApiClient: new OrganizationApiClient({
|
|
6068
|
+
apiClient,
|
|
6069
|
+
fetchOrganization: () => Promise.resolve(organization),
|
|
6070
|
+
}),
|
|
6071
|
+
});
|
|
6072
|
+
return roomService.getRoom({ roomName });
|
|
6073
|
+
});
|
|
5698
6074
|
return {
|
|
5699
6075
|
credentialsService,
|
|
5700
6076
|
apiClient,
|
|
5701
6077
|
organizationService,
|
|
5702
6078
|
roomIntegrationService,
|
|
5703
6079
|
fetchOrganizationFromRoomUrl,
|
|
6080
|
+
fetchRoomFromRoomUrl,
|
|
5704
6081
|
signalBaseUrl: signalBaseUrl || SIGNAL_BASE_URL,
|
|
5705
6082
|
};
|
|
5706
6083
|
}
|
|
@@ -5768,6 +6145,7 @@ exports.doEnableAudio = doEnableAudio;
|
|
|
5768
6145
|
exports.doEnableVideo = doEnableVideo;
|
|
5769
6146
|
exports.doEndMeeting = doEndMeeting;
|
|
5770
6147
|
exports.doExtendBreakoutTimer = doExtendBreakoutTimer;
|
|
6148
|
+
exports.doFetchRoom = doFetchRoom;
|
|
5771
6149
|
exports.doFetchRoomIntegrations = doFetchRoomIntegrations;
|
|
5772
6150
|
exports.doGetDeviceCredentials = doGetDeviceCredentials;
|
|
5773
6151
|
exports.doHandleAcceptStreams = doHandleAcceptStreams;
|
|
@@ -6041,6 +6419,7 @@ exports.selectRoomConnectionRaw = selectRoomConnectionRaw;
|
|
|
6041
6419
|
exports.selectRoomConnectionSession = selectRoomConnectionSession;
|
|
6042
6420
|
exports.selectRoomConnectionSessionId = selectRoomConnectionSessionId;
|
|
6043
6421
|
exports.selectRoomConnectionStatus = selectRoomConnectionStatus;
|
|
6422
|
+
exports.selectRoomFetchStatus = selectRoomFetchStatus;
|
|
6044
6423
|
exports.selectRoomIntegrationForUrl = selectRoomIntegrationForUrl;
|
|
6045
6424
|
exports.selectRoomIntegrationsEnabled = selectRoomIntegrationsEnabled;
|
|
6046
6425
|
exports.selectRoomIntegrationsError = selectRoomIntegrationsError;
|
|
@@ -6049,7 +6428,11 @@ exports.selectRoomIntegrationsIsFetching = selectRoomIntegrationsIsFetching;
|
|
|
6049
6428
|
exports.selectRoomIntegrationsRaw = selectRoomIntegrationsRaw;
|
|
6050
6429
|
exports.selectRoomIsLocked = selectRoomIsLocked;
|
|
6051
6430
|
exports.selectRoomKey = selectRoomKey;
|
|
6431
|
+
exports.selectRoomLockState = selectRoomLockState;
|
|
6432
|
+
exports.selectRoomLockStateRoomUrl = selectRoomLockStateRoomUrl;
|
|
6433
|
+
exports.selectRoomLockStateSource = selectRoomLockStateSource;
|
|
6052
6434
|
exports.selectRoomMode = selectRoomMode;
|
|
6435
|
+
exports.selectRoomRequestedUrl = selectRoomRequestedUrl;
|
|
6053
6436
|
exports.selectRtcConnectionRaw = selectRtcConnectionRaw;
|
|
6054
6437
|
exports.selectRtcDispatcherCreated = selectRtcDispatcherCreated;
|
|
6055
6438
|
exports.selectRtcIsCreatingDispatcher = selectRtcIsCreatingDispatcher;
|
|
@@ -6066,6 +6449,7 @@ exports.selectShouldConnectSignal = selectShouldConnectSignal;
|
|
|
6066
6449
|
exports.selectShouldDisconnectRtc = selectShouldDisconnectRtc;
|
|
6067
6450
|
exports.selectShouldFetchDeviceCredentials = selectShouldFetchDeviceCredentials;
|
|
6068
6451
|
exports.selectShouldFetchOrganization = selectShouldFetchOrganization;
|
|
6452
|
+
exports.selectShouldFetchRoom = selectShouldFetchRoom;
|
|
6069
6453
|
exports.selectShouldFetchRoomIntegrations = selectShouldFetchRoomIntegrations;
|
|
6070
6454
|
exports.selectShouldIdentifyDevice = selectShouldIdentifyDevice;
|
|
6071
6455
|
exports.selectShouldInitializeRtc = selectShouldInitializeRtc;
|
|
@@ -6094,6 +6478,7 @@ exports.setCurrentSpeakerDeviceId = setCurrentSpeakerDeviceId;
|
|
|
6094
6478
|
exports.setDisplayName = setDisplayName;
|
|
6095
6479
|
exports.setLocalMediaOptions = setLocalMediaOptions;
|
|
6096
6480
|
exports.setLocalMediaStream = setLocalMediaStream;
|
|
6481
|
+
exports.setRequestedRoomUrl = setRequestedRoomUrl;
|
|
6097
6482
|
exports.setRoomIntegrationsError = setRoomIntegrationsError;
|
|
6098
6483
|
exports.setRoomKey = setRoomKey;
|
|
6099
6484
|
exports.signalConnectionSlice = signalConnectionSlice;
|