@stream-io/video-client 0.6.10 → 0.7.1

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.
Files changed (34) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/index.browser.es.js +60 -157
  3. package/dist/index.browser.es.js.map +1 -1
  4. package/dist/index.cjs.js +59 -164
  5. package/dist/index.cjs.js.map +1 -1
  6. package/dist/index.d.ts +0 -1
  7. package/dist/index.es.js +60 -162
  8. package/dist/index.es.js.map +1 -1
  9. package/dist/src/Call.d.ts +13 -1
  10. package/dist/src/coordinator/connection/client.d.ts +0 -11
  11. package/dist/src/coordinator/connection/signing.d.ts +1 -24
  12. package/dist/src/coordinator/connection/token_manager.d.ts +2 -3
  13. package/dist/src/coordinator/connection/types.d.ts +4 -4
  14. package/dist/src/gen/coordinator/index.d.ts +382 -1018
  15. package/dist/src/stats/utils.d.ts +11 -0
  16. package/dist/src/store/CallState.d.ts +2 -2
  17. package/index.ts +0 -1
  18. package/package.json +2 -3
  19. package/src/Call.ts +53 -0
  20. package/src/__tests__/StreamVideoClient.test.ts +8 -3
  21. package/src/coordinator/connection/client.ts +1 -40
  22. package/src/coordinator/connection/signing.ts +10 -89
  23. package/src/coordinator/connection/token_manager.ts +3 -17
  24. package/src/coordinator/connection/types.ts +4 -4
  25. package/src/gen/coordinator/index.ts +361 -983
  26. package/src/stats/utils.ts +23 -0
  27. package/src/store/CallState.ts +5 -4
  28. package/dist/src/StreamVideoServerClient.d.ts +0 -33
  29. package/src/StreamVideoServerClient.ts +0 -106
  30. package/src/__tests__/server-side/call-members.test.ts +0 -93
  31. package/src/__tests__/server-side/call-types.test.ts +0 -127
  32. package/src/__tests__/server-side/call.test.ts +0 -158
  33. package/src/__tests__/server-side/create-token.test.ts +0 -44
  34. package/src/__tests__/server-side/server-side-user.test.ts +0 -28
package/CHANGELOG.md CHANGED
@@ -2,6 +2,24 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ### [0.7.1](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-client-0.7.0...@stream-io/video-client-0.7.1) (2024-04-09)
6
+
7
+
8
+ ### Features
9
+
10
+ * user feedback ([#1310](https://github.com/GetStream/stream-video-js/issues/1310)) ([256b775](https://github.com/GetStream/stream-video-js/commit/256b7756e89b261e0efa37952611139bf94a641e))
11
+
12
+ ## [0.7.0](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-client-0.6.10...@stream-io/video-client-0.7.0) (2024-04-09)
13
+
14
+
15
+ ### ⚠ BREAKING CHANGES
16
+
17
+ * remove server-side capabilities from JS client (#1282)
18
+
19
+ ### Features
20
+
21
+ * remove server-side capabilities from JS client ([#1282](https://github.com/GetStream/stream-video-js/issues/1282)) ([362b6b5](https://github.com/GetStream/stream-video-js/commit/362b6b501e6aa1864eb8486e3129a1705a4d41fb))
22
+
5
23
  ### [0.6.10](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-client-0.6.9...@stream-io/video-client-0.6.10) (2024-04-05)
6
24
 
7
25
 
@@ -33,26 +33,6 @@ const CreateDeviceRequestPushProviderEnum = {
33
33
  HUAWEI: 'huawei',
34
34
  XIAOMI: 'xiaomi',
35
35
  };
36
- /**
37
- * @export
38
- */
39
- const LayoutSettingsNameEnum = {
40
- SPOTLIGHT: 'spotlight',
41
- GRID: 'grid',
42
- SINGLE_PARTICIPANT: 'single-participant',
43
- MOBILE: 'mobile',
44
- CUSTOM: 'custom',
45
- };
46
- /**
47
- * @export
48
- */
49
- const LayoutSettingsRequestNameEnum = {
50
- SPOTLIGHT: 'spotlight',
51
- GRID: 'grid',
52
- SINGLE_PARTICIPANT: 'single-participant',
53
- MOBILE: 'mobile',
54
- CUSTOM: 'custom',
55
- };
56
36
  /**
57
37
  * All possibility of string to use
58
38
  * @export
@@ -7106,6 +7086,7 @@ class CallState {
7106
7086
  'call.session_started': (e) => this.updateFromCallResponse(e.call),
7107
7087
  'call.unblocked_user': this.unblockUser,
7108
7088
  'call.updated': (e) => this.updateFromCallResponse(e.call),
7089
+ 'call.deleted': undefined,
7109
7090
  };
7110
7091
  }
7111
7092
  /**
@@ -9258,6 +9239,22 @@ const flatten$1 = (report) => {
9258
9239
  });
9259
9240
  return stats;
9260
9241
  };
9242
+ const getSdkSignature = (clientDetails) => {
9243
+ const { sdk, ...platform } = clientDetails;
9244
+ const sdkName = sdk && sdk.type === SdkType.REACT
9245
+ ? 'stream-react'
9246
+ : sdk && sdk.type === SdkType.REACT_NATIVE
9247
+ ? 'stream-react-native'
9248
+ : 'stream-js';
9249
+ const sdkVersion = sdk
9250
+ ? `${sdk.major}.${sdk.minor}.${sdk.patch}`
9251
+ : '0.0.0-development';
9252
+ return {
9253
+ sdkName,
9254
+ sdkVersion,
9255
+ ...platform,
9256
+ };
9257
+ };
9261
9258
 
9262
9259
  /**
9263
9260
  * Creates a new StatsReporter instance that collects metrics about the ongoing call and reports them to the state store
@@ -12609,6 +12606,37 @@ class Call {
12609
12606
  const endpoint = `${this.streamClientBasePath}/stats/${callSessionID}`;
12610
12607
  return this.streamClient.get(endpoint);
12611
12608
  };
12609
+ /**
12610
+ * Submit user feedback for the call
12611
+ *
12612
+ * @param rating Rating between 1 and 5 denoting the experience of the user in the call
12613
+ * @param reason The reason/description for the rating
12614
+ * @param custom Custom data
12615
+ * @returns
12616
+ */
12617
+ this.submitFeedback = async (rating, { reason, custom, } = {}) => {
12618
+ if (rating < 1 || rating > 5) {
12619
+ throw new Error('Rating must be between 1 and 5');
12620
+ }
12621
+ const userSessionId = this.sfuClient?.sessionId;
12622
+ const callSessionId = this.state.session?.id;
12623
+ if (!callSessionId || !userSessionId) {
12624
+ throw new Error('Feedback can be submitted only in the context of a call session');
12625
+ }
12626
+ const { sdkName, sdkVersion, ...platform } = getSdkSignature(getClientDetails());
12627
+ const endpoint = `${this.streamClientBasePath}/feedback/${callSessionId}`;
12628
+ return this.streamClient.post(endpoint, {
12629
+ rating,
12630
+ reason,
12631
+ user_session_id: userSessionId,
12632
+ sdk: sdkName,
12633
+ sdk_version: sdkVersion,
12634
+ custom: {
12635
+ ...custom,
12636
+ 'x-stream-platform-data': platform,
12637
+ },
12638
+ });
12639
+ };
12612
12640
  /**
12613
12641
  * Sends a custom event to all call participants.
12614
12642
  *
@@ -13564,8 +13592,6 @@ class StableWSConnection {
13564
13592
  }
13565
13593
  }
13566
13594
 
13567
- var jwt = null;
13568
-
13569
13595
  function isString(arrayOrString) {
13570
13596
  return typeof arrayOrString === 'string';
13571
13597
  }
@@ -13617,47 +13643,6 @@ const decodeBase64 = (s) => {
13617
13643
  return r;
13618
13644
  };
13619
13645
 
13620
- /**
13621
- * Creates the JWT token that can be used for a UserSession
13622
- * @method JWTUserToken
13623
- * @memberof signing
13624
- * @private
13625
- * @param {Secret} apiSecret - API Secret key
13626
- * @param {string} userId - The user_id key in the JWT payload
13627
- * @param {UR} [extraData] - Extra that should be part of the JWT token
13628
- * @param {SignOptions} [jwtOptions] - Options that can be past to jwt.sign
13629
- * @return {string} JWT Token
13630
- */
13631
- function JWTUserToken(apiSecret, userId, extraData = {}, jwtOptions = {}) {
13632
- if (typeof userId !== 'string') {
13633
- throw new TypeError('userId should be a string');
13634
- }
13635
- ({
13636
- user_id: userId,
13637
- ...extraData,
13638
- });
13639
- // make sure we return a clear error when jwt is shimmed (ie. browser build)
13640
- {
13641
- throw Error(`Unable to find jwt crypto, if you are getting this error is probably because you are trying to generate tokens on browser or React Native (or other environment where crypto functions are not available). Please Note: token should only be generated server-side.`);
13642
- }
13643
- }
13644
- function JWTServerToken(apiSecret, jwtOptions = {}) {
13645
- const payload = {
13646
- server: true,
13647
- };
13648
- const opts = Object.assign({ algorithm: 'HS256', noTimestamp: true }, jwtOptions);
13649
- return jwt.sign(payload, apiSecret, opts);
13650
- }
13651
- function UserFromToken(token) {
13652
- const fragments = token.split('.');
13653
- if (fragments.length !== 3) {
13654
- return '';
13655
- }
13656
- const b64Payload = fragments[1];
13657
- const payload = decodeBase64(b64Payload);
13658
- const data = JSON.parse(payload);
13659
- return data.user_id;
13660
- }
13661
13646
  /**
13662
13647
  *
13663
13648
  * @param {string} userId the id of the user
@@ -13670,6 +13655,16 @@ function DevToken(userId) {
13670
13655
  'devtoken', // hardcoded signature
13671
13656
  ].join('.');
13672
13657
  }
13658
+ function UserFromToken(token) {
13659
+ const fragments = token.split('.');
13660
+ if (fragments.length !== 3) {
13661
+ return '';
13662
+ }
13663
+ const b64Payload = fragments[1];
13664
+ const payload = decodeBase64(b64Payload);
13665
+ const data = JSON.parse(payload);
13666
+ return data.user_id;
13667
+ }
13673
13668
 
13674
13669
  /**
13675
13670
  * TokenManager
@@ -13702,10 +13697,6 @@ class TokenManager {
13702
13697
  this.token = tokenOrProvider;
13703
13698
  this.type = 'static';
13704
13699
  }
13705
- if (!tokenOrProvider && this.user && this.secret) {
13706
- this.token = JWTUserToken(this.secret, user.id, {}, {});
13707
- this.type = 'static';
13708
- }
13709
13700
  await this.loadToken();
13710
13701
  };
13711
13702
  /**
@@ -13775,9 +13766,6 @@ class TokenManager {
13775
13766
  if (this.user && !this.token) {
13776
13767
  return this.token;
13777
13768
  }
13778
- if (this.secret) {
13779
- return JWTServerToken(this.secret);
13780
- }
13781
13769
  throw new Error(`Both secret and user tokens are not set. Either client.connectUser wasn't called or client.disconnect was called`);
13782
13770
  };
13783
13771
  this.isStatic = () => this.type === 'static';
@@ -13786,9 +13774,6 @@ class TokenManager {
13786
13774
  this.secret = secret;
13787
13775
  }
13788
13776
  this.type = 'static';
13789
- if (this.secret) {
13790
- this.token = JWTServerToken(this.secret);
13791
- }
13792
13777
  }
13793
13778
  }
13794
13779
 
@@ -14215,7 +14200,6 @@ class StreamClient {
14215
14200
  this.guestUserCreatePromise = this.doAxiosRequest('post', '/guest', {
14216
14201
  user: {
14217
14202
  ...user,
14218
- role: 'guest',
14219
14203
  },
14220
14204
  }, { publicEndpoint: true });
14221
14205
  const response = await this.guestUserCreatePromise;
@@ -14477,7 +14461,7 @@ class StreamClient {
14477
14461
  });
14478
14462
  };
14479
14463
  this.getUserAgent = () => {
14480
- const version = "0.6.10" ;
14464
+ const version = "0.7.1" ;
14481
14465
  return (this.userAgent ||
14482
14466
  `stream-video-javascript-client-${this.node ? 'node' : 'browser'}-${version}`);
14483
14467
  };
@@ -14549,32 +14533,6 @@ class StreamClient {
14549
14533
  this.createAbortControllerForNextRequest = () => {
14550
14534
  return (this.nextRequestAbortController = new AbortController());
14551
14535
  };
14552
- /**
14553
- * createToken - Creates a token to authenticate this user. This function is used server side.
14554
- * The resulting token should be passed to the client side when the users registers or logs in.
14555
- *
14556
- * @param {string} userID The UserWithId ID
14557
- * @param {number} [exp] The expiration time for the token expressed in the number of seconds since the epoch
14558
- * @param call_cids for anonymous tokens you have to provide the call cids the use can join
14559
- *
14560
- * @return {string} Returns a token
14561
- */
14562
- this.createToken = (userID, exp, iat, call_cids) => {
14563
- if (this.secret == null) {
14564
- throw Error(`tokens can only be created server-side using the API Secret`);
14565
- }
14566
- const extra = {};
14567
- if (exp) {
14568
- extra.exp = exp;
14569
- }
14570
- if (iat) {
14571
- extra.iat = iat;
14572
- }
14573
- if (call_cids) {
14574
- extra.call_cids = call_cids;
14575
- }
14576
- return JWTUserToken(this.secret, userID, extra, {});
14577
- };
14578
14536
  // set the key
14579
14537
  this.key = key;
14580
14538
  // set the secret
@@ -14979,60 +14937,5 @@ class StreamVideoClient {
14979
14937
  }
14980
14938
  }
14981
14939
 
14982
- /**
14983
- * @deprecated Please use the `@stream-io/node-sdk` package instead.
14984
- *
14985
- * @see https://getstream.io/video/docs/api/
14986
- */
14987
- class StreamVideoServerClient extends StreamVideoClient {
14988
- constructor(apiKey, options) {
14989
- super({ apiKey, options });
14990
- this.getCallTypes = () => {
14991
- return this.streamClient.get('/calltypes');
14992
- };
14993
- this.getCallType = (name) => {
14994
- return this.streamClient.get(`/calltypes/${name}`);
14995
- };
14996
- this.createCallType = (data) => {
14997
- return this.streamClient.post('/calltypes', data);
14998
- };
14999
- this.deleteCallType = (name) => {
15000
- return this.streamClient.delete(`/calltypes/${name}`);
15001
- };
15002
- this.updateCallType = (name, data) => {
15003
- return this.streamClient.put(`/calltypes/${name}`, data);
15004
- };
15005
- this.listExternalStorage = () => {
15006
- return this.streamClient.get('/external_storage');
15007
- };
15008
- this.createExternalStorage = (request) => {
15009
- return this.streamClient.post('/external_storage', request);
15010
- };
15011
- this.deleteExternalStorage = (name) => {
15012
- return this.streamClient.delete(`/external_storage/${name}`);
15013
- };
15014
- this.updateExternalStorage = (name, request) => {
15015
- return this.streamClient.put(`/external_storage/${name}`, request);
15016
- };
15017
- this.checkExternalStorage = (name) => {
15018
- return this.streamClient.get(`/external_storage/${name}/check`);
15019
- };
15020
- }
15021
- /**
15022
- * createToken - Creates a token to authenticate this user. This function is used server side.
15023
- * The resulting token should be passed to the client side when the users register or logs in.
15024
- *
15025
- * @param {string} userID The User ID
15026
- * @param {number} [exp] The expiration time for the token expressed in the number of seconds since the epoch
15027
- * @param {number} [iat] The timestamp when a token has been issued
15028
- * @param call_cids for anonymous tokens you have to provide the call cids the use can join
15029
- *
15030
- * @return {string} Returns a token
15031
- */
15032
- createToken(userID, exp, iat, call_cids) {
15033
- return this.streamClient.createToken(userID, exp, iat, call_cids);
15034
- }
15035
- }
15036
-
15037
- export { AudioSettingsDefaultDeviceEnum, AudioSettingsRequestDefaultDeviceEnum, browsers as Browsers, Call, CallState, CallType, CallTypes, CallingState, CameraManager, CameraManagerState, CreateDeviceRequestPushProviderEnum, DebounceType, DynascaleManager, ErrorFromResponse, InputMediaDeviceManager, InputMediaDeviceManagerState, LayoutSettingsNameEnum, LayoutSettingsRequestNameEnum, MicrophoneManager, MicrophoneManagerState, OwnCapability, RecordSettingsRequestModeEnum, RecordSettingsRequestQualityEnum, rxUtils as RxUtils, ScreenShareManager, ScreenShareState, events as SfuEvents, models as SfuModels, SpeakerManager, SpeakerState, StreamSfuClient, StreamVideoClient, StreamVideoReadOnlyStateStore, StreamVideoServerClient, StreamVideoWriteableStateStore, TranscriptionSettingsModeEnum, TranscriptionSettingsRequestModeEnum, VideoSettingsCameraFacingEnum, VideoSettingsRequestCameraFacingEnum, ViewportTracker, VisibilityState, checkIfAudioOutputChangeSupported, combineComparators, conditional, createSoundDetector, defaultSortPreset, descending, deviceIds$, disposeOfMediaStream, dominantSpeaker, getAudioDevices, getAudioOutputDevices, getAudioStream, getClientDetails, getDeviceInfo, getLogger, getOSInfo, getScreenShareStream, getSdkInfo, getVideoDevices, getVideoStream, getWebRTCInfo, livestreamOrAudioRoomSortPreset, logLevels, logToConsole, name, noopComparator, paginatedLayoutSortPreset, pinned, publishingAudio, publishingVideo, reactionType, role, screenSharing, setDeviceInfo, setLogLevel, setLogger, setOSInfo, setSdkInfo, setWebRTCInfo, speakerLayoutSortPreset, speaking };
14940
+ export { AudioSettingsDefaultDeviceEnum, AudioSettingsRequestDefaultDeviceEnum, browsers as Browsers, Call, CallState, CallType, CallTypes, CallingState, CameraManager, CameraManagerState, CreateDeviceRequestPushProviderEnum, DebounceType, DynascaleManager, ErrorFromResponse, InputMediaDeviceManager, InputMediaDeviceManagerState, MicrophoneManager, MicrophoneManagerState, OwnCapability, RecordSettingsRequestModeEnum, RecordSettingsRequestQualityEnum, rxUtils as RxUtils, ScreenShareManager, ScreenShareState, events as SfuEvents, models as SfuModels, SpeakerManager, SpeakerState, StreamSfuClient, StreamVideoClient, StreamVideoReadOnlyStateStore, StreamVideoWriteableStateStore, TranscriptionSettingsModeEnum, TranscriptionSettingsRequestModeEnum, VideoSettingsCameraFacingEnum, VideoSettingsRequestCameraFacingEnum, ViewportTracker, VisibilityState, checkIfAudioOutputChangeSupported, combineComparators, conditional, createSoundDetector, defaultSortPreset, descending, deviceIds$, disposeOfMediaStream, dominantSpeaker, getAudioDevices, getAudioOutputDevices, getAudioStream, getClientDetails, getDeviceInfo, getLogger, getOSInfo, getScreenShareStream, getSdkInfo, getVideoDevices, getVideoStream, getWebRTCInfo, livestreamOrAudioRoomSortPreset, logLevels, logToConsole, name, noopComparator, paginatedLayoutSortPreset, pinned, publishingAudio, publishingVideo, reactionType, role, screenSharing, setDeviceInfo, setLogLevel, setLogger, setOSInfo, setSdkInfo, setWebRTCInfo, speakerLayoutSortPreset, speaking };
15038
14941
  //# sourceMappingURL=index.browser.es.js.map