@stream-io/video-client 0.0.2-alpha.10 → 0.0.2-alpha.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/dist/index.browser.es.js +51 -41
- package/dist/index.browser.es.js.map +1 -1
- package/dist/index.cjs.js +51 -41
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +51 -41
- package/dist/index.es.js.map +1 -1
- package/dist/src/Call.d.ts +2 -9
- package/dist/src/gen/coordinator/index.d.ts +24 -64
- package/dist/src/rtc/flows/join.d.ts +1 -0
- package/dist/src/store/CallState.d.ts +22 -1
- package/dist/src/types.d.ts +7 -1
- package/package.json +1 -1
- package/src/Call.ts +22 -30
- package/src/StreamVideoClient.ts +1 -0
- package/src/events/__tests__/call-permissions.test.ts +4 -8
- package/src/events/__tests__/sessions.test.ts +0 -2
- package/src/events/call-permissions.ts +3 -11
- package/src/events/sessions.ts +2 -12
- package/src/gen/coordinator/index.ts +24 -62
- package/src/rtc/flows/join.ts +2 -1
- package/src/store/CallState.ts +31 -0
- package/src/types.ts +8 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [0.0.2-alpha.12](https://github.com/GetStream/stream-video-js/compare/client0.0.2-alpha.11...client0.0.2-alpha.12) (2023-05-31)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* Adjust OwnCapabilities handling ([#574](https://github.com/GetStream/stream-video-js/issues/574)) ([d9e27db](https://github.com/GetStream/stream-video-js/commit/d9e27db65e641241d5ec5a9a72a94f118ece284d))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [0.0.2-alpha.11](https://github.com/GetStream/stream-video-js/compare/client0.0.2-alpha.10...client0.0.2-alpha.11) (2023-05-31)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
5
18
|
## [0.0.2-alpha.10](https://github.com/GetStream/stream-video-js/compare/client0.0.2-alpha.9...client0.0.2-alpha.10) (2023-05-31)
|
|
6
19
|
|
|
7
20
|
|
package/dist/index.browser.es.js
CHANGED
|
@@ -6615,6 +6615,12 @@ class CallState {
|
|
|
6615
6615
|
* @internal
|
|
6616
6616
|
*/
|
|
6617
6617
|
this.membersSubject = new BehaviorSubject([]);
|
|
6618
|
+
/**
|
|
6619
|
+
* The list of capabilities of the current user.
|
|
6620
|
+
*
|
|
6621
|
+
* @private
|
|
6622
|
+
*/
|
|
6623
|
+
this.ownCapabilitiesSubject = new BehaviorSubject([]);
|
|
6618
6624
|
/**
|
|
6619
6625
|
* The calling state.
|
|
6620
6626
|
*
|
|
@@ -6797,6 +6803,15 @@ class CallState {
|
|
|
6797
6803
|
this.setMembers = (members) => {
|
|
6798
6804
|
this.setCurrentValue(this.membersSubject, members);
|
|
6799
6805
|
};
|
|
6806
|
+
/**
|
|
6807
|
+
* Sets the own capabilities.
|
|
6808
|
+
*
|
|
6809
|
+
* @internal
|
|
6810
|
+
* @param capabilities the capabilities to set.
|
|
6811
|
+
*/
|
|
6812
|
+
this.setOwnCapabilities = (capabilities) => {
|
|
6813
|
+
return this.setCurrentValue(this.ownCapabilitiesSubject, capabilities);
|
|
6814
|
+
};
|
|
6800
6815
|
/**
|
|
6801
6816
|
* Will try to find the participant with the given sessionId in the current call.
|
|
6802
6817
|
*
|
|
@@ -6886,6 +6901,7 @@ class CallState {
|
|
|
6886
6901
|
this.callRecordingList$ = this.callRecordingListSubject.asObservable();
|
|
6887
6902
|
this.metadata$ = this.metadataSubject.asObservable();
|
|
6888
6903
|
this.members$ = this.membersSubject.asObservable();
|
|
6904
|
+
this.ownCapabilities$ = this.ownCapabilitiesSubject.asObservable();
|
|
6889
6905
|
this.callingState$ = this.callingStateSubject.asObservable();
|
|
6890
6906
|
}
|
|
6891
6907
|
/**
|
|
@@ -6981,6 +6997,12 @@ class CallState {
|
|
|
6981
6997
|
get members() {
|
|
6982
6998
|
return this.getCurrentValue(this.members$);
|
|
6983
6999
|
}
|
|
7000
|
+
/**
|
|
7001
|
+
* The capabilities of the current user for the current call.
|
|
7002
|
+
*/
|
|
7003
|
+
get ownCapabilities() {
|
|
7004
|
+
return this.getCurrentValue(this.ownCapabilities$);
|
|
7005
|
+
}
|
|
6984
7006
|
}
|
|
6985
7007
|
|
|
6986
7008
|
class StreamVideoWriteableStateStore {
|
|
@@ -7257,7 +7279,7 @@ const watchCallPermissionsUpdated = (state) => {
|
|
|
7257
7279
|
return;
|
|
7258
7280
|
const { localParticipant } = state;
|
|
7259
7281
|
if (event.user.id === (localParticipant === null || localParticipant === void 0 ? void 0 : localParticipant.userId)) {
|
|
7260
|
-
state.
|
|
7282
|
+
state.setOwnCapabilities(event.own_capabilities);
|
|
7261
7283
|
}
|
|
7262
7284
|
};
|
|
7263
7285
|
};
|
|
@@ -7268,7 +7290,6 @@ const watchCallPermissionsUpdated = (state) => {
|
|
|
7268
7290
|
*/
|
|
7269
7291
|
const watchCallGrantsUpdated = (state) => {
|
|
7270
7292
|
return function onCallGrantsUpdated(event) {
|
|
7271
|
-
var _a;
|
|
7272
7293
|
if (event.eventPayload.oneofKind !== 'callGrantsUpdated')
|
|
7273
7294
|
return;
|
|
7274
7295
|
const { currentGrants } = event.eventPayload.callGrantsUpdated;
|
|
@@ -7279,15 +7300,13 @@ const watchCallGrantsUpdated = (state) => {
|
|
|
7279
7300
|
[OwnCapability.SEND_VIDEO]: canPublishVideo,
|
|
7280
7301
|
[OwnCapability.SCREENSHARE]: canScreenshare,
|
|
7281
7302
|
};
|
|
7282
|
-
const nextCapabilities =
|
|
7303
|
+
const nextCapabilities = state.ownCapabilities.filter((capability) => update[capability] !== false);
|
|
7283
7304
|
Object.entries(update).forEach(([capability, value]) => {
|
|
7284
7305
|
if (value && !nextCapabilities.includes(capability)) {
|
|
7285
7306
|
nextCapabilities.push(capability);
|
|
7286
7307
|
}
|
|
7287
7308
|
});
|
|
7288
|
-
state.
|
|
7289
|
-
return Object.assign(Object.assign({}, metadata), { own_capabilities: nextCapabilities });
|
|
7290
|
-
});
|
|
7309
|
+
state.setOwnCapabilities(nextCapabilities);
|
|
7291
7310
|
}
|
|
7292
7311
|
};
|
|
7293
7312
|
};
|
|
@@ -7580,10 +7599,7 @@ const watchCallSessionStarted = (state) => {
|
|
|
7580
7599
|
return function onCallSessionStarted(event) {
|
|
7581
7600
|
if (event.type !== 'call.session_started')
|
|
7582
7601
|
return;
|
|
7583
|
-
|
|
7584
|
-
state.setMetadata((metadata) => (Object.assign(Object.assign({}, call), {
|
|
7585
|
-
// FIXME OL: temporary, until the backend sends the own_capabilities
|
|
7586
|
-
own_capabilities: (metadata === null || metadata === void 0 ? void 0 : metadata.own_capabilities) || [] })));
|
|
7602
|
+
state.setMetadata(event.call);
|
|
7587
7603
|
};
|
|
7588
7604
|
};
|
|
7589
7605
|
/**
|
|
@@ -7595,10 +7611,7 @@ const watchCallSessionEnded = (state) => {
|
|
|
7595
7611
|
return function onCallSessionEnded(event) {
|
|
7596
7612
|
if (event.type !== 'call.session_ended')
|
|
7597
7613
|
return;
|
|
7598
|
-
|
|
7599
|
-
state.setMetadata((metadata) => (Object.assign(Object.assign({}, call), {
|
|
7600
|
-
// FIXME OL: temporary, until the backend sends the own_capabilities
|
|
7601
|
-
own_capabilities: (metadata === null || metadata === void 0 ? void 0 : metadata.own_capabilities) || [] })));
|
|
7614
|
+
state.setMetadata(event.call);
|
|
7602
7615
|
};
|
|
7603
7616
|
};
|
|
7604
7617
|
/**
|
|
@@ -7760,13 +7773,14 @@ const registerRingingCallEventHandlers = (call) => {
|
|
|
7760
7773
|
const join = (httpClient, type, id, data) => __awaiter(void 0, void 0, void 0, function* () {
|
|
7761
7774
|
yield httpClient.connectionIdPromise;
|
|
7762
7775
|
const joinCallResponse = yield doJoin(httpClient, type, id, data);
|
|
7763
|
-
const { call, credentials, members } = joinCallResponse;
|
|
7776
|
+
const { call, credentials, members, own_capabilities } = joinCallResponse;
|
|
7764
7777
|
return {
|
|
7765
7778
|
connectionConfig: toRtcConfiguration(credentials.ice_servers),
|
|
7766
7779
|
sfuServer: credentials.server,
|
|
7767
7780
|
token: credentials.token,
|
|
7768
7781
|
metadata: call,
|
|
7769
7782
|
members,
|
|
7783
|
+
ownCapabilities: own_capabilities,
|
|
7770
7784
|
};
|
|
7771
7785
|
});
|
|
7772
7786
|
const doJoin = (httpClient, type, id, data) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -8302,7 +8316,7 @@ class Call {
|
|
|
8302
8316
|
* Use the [`StreamVideoClient.call`](./StreamVideoClient.md/#call)
|
|
8303
8317
|
* method to construct a `Call` instance.
|
|
8304
8318
|
*/
|
|
8305
|
-
constructor({ type, id, streamClient, metadata, members, sortParticipantsBy, clientStore, ringing = false, watching = false, }) {
|
|
8319
|
+
constructor({ type, id, streamClient, metadata, members, ownCapabilities, sortParticipantsBy, clientStore, ringing = false, watching = false, }) {
|
|
8306
8320
|
/**
|
|
8307
8321
|
* ViewportTracker instance
|
|
8308
8322
|
*/
|
|
@@ -8394,6 +8408,7 @@ class Call {
|
|
|
8394
8408
|
}
|
|
8395
8409
|
this.state.setMetadata(response.call);
|
|
8396
8410
|
this.state.setMembers(response.members);
|
|
8411
|
+
this.state.setOwnCapabilities(response.own_capabilities);
|
|
8397
8412
|
if (this.streamClient._hasConnectionID()) {
|
|
8398
8413
|
this.watching = true;
|
|
8399
8414
|
this.clientStore.registerCall(this);
|
|
@@ -8412,6 +8427,7 @@ class Call {
|
|
|
8412
8427
|
}
|
|
8413
8428
|
this.state.setMetadata(response.call);
|
|
8414
8429
|
this.state.setMembers(response.members);
|
|
8430
|
+
this.state.setOwnCapabilities(response.own_capabilities);
|
|
8415
8431
|
if (this.streamClient._hasConnectionID()) {
|
|
8416
8432
|
this.watching = true;
|
|
8417
8433
|
this.clientStore.registerCall(this);
|
|
@@ -8478,6 +8494,7 @@ class Call {
|
|
|
8478
8494
|
const call = yield join(this.streamClient, this.type, this.id, data);
|
|
8479
8495
|
this.state.setMetadata(call.metadata);
|
|
8480
8496
|
this.state.setMembers(call.members);
|
|
8497
|
+
this.state.setOwnCapabilities(call.ownCapabilities);
|
|
8481
8498
|
connectionConfig = call.connectionConfig;
|
|
8482
8499
|
sfuServer = call.sfuServer;
|
|
8483
8500
|
sfuToken = call.token;
|
|
@@ -9200,15 +9217,6 @@ class Call {
|
|
|
9200
9217
|
this.state.setCallRecordingsList(response.recordings);
|
|
9201
9218
|
return response;
|
|
9202
9219
|
});
|
|
9203
|
-
/**
|
|
9204
|
-
* Returns a list of Edge Serves for current call.
|
|
9205
|
-
*
|
|
9206
|
-
* @deprecated merged with `call.join`.
|
|
9207
|
-
* @param data the data.
|
|
9208
|
-
*/
|
|
9209
|
-
this.getEdgeServer = (data) => {
|
|
9210
|
-
return this.streamClient.post(`${this.streamClientBasePath}/get_edge_server`, data);
|
|
9211
|
-
};
|
|
9212
9220
|
/**
|
|
9213
9221
|
* Sends an event to all call participants.
|
|
9214
9222
|
*
|
|
@@ -9232,6 +9240,7 @@ class Call {
|
|
|
9232
9240
|
}
|
|
9233
9241
|
this.state.setMetadata(metadata);
|
|
9234
9242
|
this.state.setMembers(members || []);
|
|
9243
|
+
this.state.setOwnCapabilities(ownCapabilities || []);
|
|
9235
9244
|
this.state.setCallingState(ringing ? CallingState.RINGING : CallingState.IDLE);
|
|
9236
9245
|
this.leaveCallHooks.push(registerEventHandlers(this, this.state, this.dispatcher));
|
|
9237
9246
|
this.registerEffects();
|
|
@@ -9243,23 +9252,13 @@ class Call {
|
|
|
9243
9252
|
createSubscription(this.state.metadata$, (metadata) => {
|
|
9244
9253
|
if (!metadata)
|
|
9245
9254
|
return;
|
|
9246
|
-
this.permissionsContext.setPermissions(metadata.own_capabilities);
|
|
9247
9255
|
this.permissionsContext.setCallSettings(metadata.settings);
|
|
9248
9256
|
}),
|
|
9249
|
-
//
|
|
9250
|
-
createSubscription(this.state.
|
|
9251
|
-
|
|
9252
|
-
|
|
9253
|
-
|
|
9254
|
-
if (currentUserId &&
|
|
9255
|
-
metadata.blocked_user_ids.includes(currentUserId)) {
|
|
9256
|
-
yield this.leave();
|
|
9257
|
-
}
|
|
9258
|
-
})),
|
|
9259
|
-
// handle the case when the user permissions are revoked.
|
|
9260
|
-
createSubscription(this.state.metadata$, (metadata) => {
|
|
9261
|
-
if (!metadata)
|
|
9262
|
-
return;
|
|
9257
|
+
// handle the case when the user permissions are modified.
|
|
9258
|
+
createSubscription(this.state.ownCapabilities$, (ownCapabilities) => {
|
|
9259
|
+
// update the permission context.
|
|
9260
|
+
this.permissionsContext.setPermissions(ownCapabilities);
|
|
9261
|
+
// check if the user still has publishing permissions and stop publishing if not.
|
|
9263
9262
|
const permissionToTrackType = {
|
|
9264
9263
|
[OwnCapability.SEND_AUDIO]: TrackType.AUDIO,
|
|
9265
9264
|
[OwnCapability.SEND_VIDEO]: TrackType.VIDEO,
|
|
@@ -9274,6 +9273,16 @@ class Call {
|
|
|
9274
9273
|
}
|
|
9275
9274
|
});
|
|
9276
9275
|
}),
|
|
9276
|
+
// handles the case when the user is blocked by the call owner.
|
|
9277
|
+
createSubscription(this.state.metadata$, (metadata) => __awaiter(this, void 0, void 0, function* () {
|
|
9278
|
+
if (!metadata)
|
|
9279
|
+
return;
|
|
9280
|
+
const currentUserId = this.currentUserId;
|
|
9281
|
+
if (currentUserId &&
|
|
9282
|
+
metadata.blocked_user_ids.includes(currentUserId)) {
|
|
9283
|
+
yield this.leave();
|
|
9284
|
+
}
|
|
9285
|
+
})),
|
|
9277
9286
|
// watch for auto drop cancellation
|
|
9278
9287
|
createSubscription(this.state.callingState$, (callingState) => {
|
|
9279
9288
|
if (!this.ringing)
|
|
@@ -10963,7 +10972,7 @@ class StreamClient {
|
|
|
10963
10972
|
}
|
|
10964
10973
|
getUserAgent() {
|
|
10965
10974
|
return (this.userAgent ||
|
|
10966
|
-
`stream-video-javascript-client-${this.node ? 'node' : 'browser'}-${"0.0.2-alpha.
|
|
10975
|
+
`stream-video-javascript-client-${this.node ? 'node' : 'browser'}-${"0.0.2-alpha.11"}`);
|
|
10967
10976
|
}
|
|
10968
10977
|
setUserAgent(userAgent) {
|
|
10969
10978
|
this.userAgent = userAgent;
|
|
@@ -11171,6 +11180,7 @@ class StreamVideoClient {
|
|
|
11171
11180
|
type: c.call.type,
|
|
11172
11181
|
metadata: c.call,
|
|
11173
11182
|
members: c.members,
|
|
11183
|
+
ownCapabilities: c.own_capabilities,
|
|
11174
11184
|
watching: data.watch,
|
|
11175
11185
|
clientStore: this.writeableStateStore,
|
|
11176
11186
|
});
|