@fishjam-cloud/js-server-sdk 0.15.1 → 0.17.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.d.mts CHANGED
@@ -160,6 +160,19 @@ declare const TrackTypeEnum: {
160
160
  readonly Video: "video";
161
161
  };
162
162
  type TrackTypeEnum = typeof TrackTypeEnum[keyof typeof TrackTypeEnum];
163
+ /**
164
+ * Token for authorizing broadcaster viewer connection
165
+ * @export
166
+ * @interface ViewerToken
167
+ */
168
+ interface ViewerToken {
169
+ /**
170
+ *
171
+ * @type {string}
172
+ * @memberof ViewerToken
173
+ */
174
+ 'token'?: string;
175
+ }
163
176
 
164
177
  type EventMap = {
165
178
  [key: string]: (...args: any[]) => void
@@ -256,6 +269,7 @@ declare class FishjamWSNotifier extends FishjamWSNotifier_base {
256
269
  */
257
270
  declare class FishjamClient {
258
271
  private readonly roomApi;
272
+ private readonly viewerApi;
259
273
  /**
260
274
  * Create new instance of Fishjam Client.
261
275
  *
@@ -301,6 +315,11 @@ declare class FishjamClient {
301
315
  * @returns refreshed peer token
302
316
  */
303
317
  refreshPeerToken(roomId: RoomId, peerId: PeerId): Promise<string>;
318
+ /**
319
+ * Creates a broadcast viewer token for the given room.
320
+ * @returns a broadcast viewer token
321
+ */
322
+ createBroadcastViewerToken(roomId: RoomId): Promise<ViewerToken>;
304
323
  }
305
324
 
306
325
  declare class FishjamBaseException extends Error {
@@ -326,4 +345,4 @@ declare class ServiceUnavailableException extends FishjamBaseException {
326
345
  declare class UnknownException extends FishjamBaseException {
327
346
  }
328
347
 
329
- export { BadRequestException, type Brand, type CloseEventHandler, type ErrorEventHandler, type ExpectedEvents, FishjamBaseException, FishjamClient, type FishjamConfig, FishjamNotFoundException, FishjamWSNotifier, ForbiddenException, type NotificationEvents, type Peer, type PeerId, PeerNotFoundException, type PeerOptions, PeerStatus, type Room, type RoomConfig, RoomConfigRoomTypeEnum, RoomConfigVideoCodecEnum, type RoomId, RoomNotFoundException, ServiceUnavailableException, UnauthorizedException, UnknownException };
348
+ export { BadRequestException, type Brand, type CloseEventHandler, type ErrorEventHandler, type ExpectedEvents, FishjamBaseException, FishjamClient, type FishjamConfig, FishjamNotFoundException, FishjamWSNotifier, ForbiddenException, type NotificationEvents, type Peer, type PeerId, PeerNotFoundException, type PeerOptions, PeerStatus, type Room, type RoomConfig, RoomConfigRoomTypeEnum, RoomConfigVideoCodecEnum, type RoomId, RoomNotFoundException, ServiceUnavailableException, UnauthorizedException, UnknownException, type ViewerToken };
package/dist/index.d.ts CHANGED
@@ -160,6 +160,19 @@ declare const TrackTypeEnum: {
160
160
  readonly Video: "video";
161
161
  };
162
162
  type TrackTypeEnum = typeof TrackTypeEnum[keyof typeof TrackTypeEnum];
163
+ /**
164
+ * Token for authorizing broadcaster viewer connection
165
+ * @export
166
+ * @interface ViewerToken
167
+ */
168
+ interface ViewerToken {
169
+ /**
170
+ *
171
+ * @type {string}
172
+ * @memberof ViewerToken
173
+ */
174
+ 'token'?: string;
175
+ }
163
176
 
164
177
  type EventMap = {
165
178
  [key: string]: (...args: any[]) => void
@@ -256,6 +269,7 @@ declare class FishjamWSNotifier extends FishjamWSNotifier_base {
256
269
  */
257
270
  declare class FishjamClient {
258
271
  private readonly roomApi;
272
+ private readonly viewerApi;
259
273
  /**
260
274
  * Create new instance of Fishjam Client.
261
275
  *
@@ -301,6 +315,11 @@ declare class FishjamClient {
301
315
  * @returns refreshed peer token
302
316
  */
303
317
  refreshPeerToken(roomId: RoomId, peerId: PeerId): Promise<string>;
318
+ /**
319
+ * Creates a broadcast viewer token for the given room.
320
+ * @returns a broadcast viewer token
321
+ */
322
+ createBroadcastViewerToken(roomId: RoomId): Promise<ViewerToken>;
304
323
  }
305
324
 
306
325
  declare class FishjamBaseException extends Error {
@@ -326,4 +345,4 @@ declare class ServiceUnavailableException extends FishjamBaseException {
326
345
  declare class UnknownException extends FishjamBaseException {
327
346
  }
328
347
 
329
- export { BadRequestException, type Brand, type CloseEventHandler, type ErrorEventHandler, type ExpectedEvents, FishjamBaseException, FishjamClient, type FishjamConfig, FishjamNotFoundException, FishjamWSNotifier, ForbiddenException, type NotificationEvents, type Peer, type PeerId, PeerNotFoundException, type PeerOptions, PeerStatus, type Room, type RoomConfig, RoomConfigRoomTypeEnum, RoomConfigVideoCodecEnum, type RoomId, RoomNotFoundException, ServiceUnavailableException, UnauthorizedException, UnknownException };
348
+ export { BadRequestException, type Brand, type CloseEventHandler, type ErrorEventHandler, type ExpectedEvents, FishjamBaseException, FishjamClient, type FishjamConfig, FishjamNotFoundException, FishjamWSNotifier, ForbiddenException, type NotificationEvents, type Peer, type PeerId, PeerNotFoundException, type PeerOptions, PeerStatus, type Room, type RoomConfig, RoomConfigRoomTypeEnum, RoomConfigVideoCodecEnum, type RoomId, RoomNotFoundException, ServiceUnavailableException, UnauthorizedException, UnknownException, type ViewerToken };
package/dist/index.js CHANGED
@@ -10817,7 +10817,7 @@ var require_dist = __commonJS({
10817
10817
  UserApiAxiosParamCreator: () => UserApiAxiosParamCreator,
10818
10818
  UserApiFactory: () => UserApiFactory,
10819
10819
  UserApiFp: () => UserApiFp,
10820
- ViewerApi: () => ViewerApi,
10820
+ ViewerApi: () => ViewerApi2,
10821
10821
  ViewerApiAxiosParamCreator: () => ViewerApiAxiosParamCreator,
10822
10822
  ViewerApiFactory: () => ViewerApiFactory,
10823
10823
  ViewerApiFp: () => ViewerApiFp
@@ -15697,8 +15697,8 @@ var require_dist = __commonJS({
15697
15697
  return {
15698
15698
  /**
15699
15699
  *
15700
- * @summary Generate token for single viewer
15701
- * @param {string} roomId Room ID
15700
+ * @summary Generate single broadcaster access token
15701
+ * @param {string} roomId A room id.
15702
15702
  * @param {*} [options] Override http request option.
15703
15703
  * @throws {RequiredError}
15704
15704
  */
@@ -15728,8 +15728,8 @@ var require_dist = __commonJS({
15728
15728
  return {
15729
15729
  /**
15730
15730
  *
15731
- * @summary Generate token for single viewer
15732
- * @param {string} roomId Room ID
15731
+ * @summary Generate single broadcaster access token
15732
+ * @param {string} roomId A room id.
15733
15733
  * @param {*} [options] Override http request option.
15734
15734
  * @throws {RequiredError}
15735
15735
  */
@@ -15746,8 +15746,8 @@ var require_dist = __commonJS({
15746
15746
  return {
15747
15747
  /**
15748
15748
  *
15749
- * @summary Generate token for single viewer
15750
- * @param {string} roomId Room ID
15749
+ * @summary Generate single broadcaster access token
15750
+ * @param {string} roomId A room id.
15751
15751
  * @param {*} [options] Override http request option.
15752
15752
  * @throws {RequiredError}
15753
15753
  */
@@ -15756,11 +15756,11 @@ var require_dist = __commonJS({
15756
15756
  }
15757
15757
  };
15758
15758
  };
15759
- var ViewerApi = class extends BaseAPI {
15759
+ var ViewerApi2 = class extends BaseAPI {
15760
15760
  /**
15761
15761
  *
15762
- * @summary Generate token for single viewer
15763
- * @param {string} roomId Room ID
15762
+ * @summary Generate single broadcaster access token
15763
+ * @param {string} roomId A room id.
15764
15764
  * @param {*} [options] Override http request option.
15765
15765
  * @throws {RequiredError}
15766
15766
  * @memberof ViewerApi
@@ -18538,7 +18538,8 @@ __export(index_exports, {
18538
18538
  RoomNotFoundException: () => RoomNotFoundException,
18539
18539
  ServiceUnavailableException: () => ServiceUnavailableException,
18540
18540
  UnauthorizedException: () => UnauthorizedException,
18541
- UnknownException: () => UnknownException
18541
+ UnknownException: () => UnknownException,
18542
+ ViewerToken: () => import_fishjam_openapi2.ViewerToken
18542
18543
  });
18543
18544
  module.exports = __toCommonJS(index_exports);
18544
18545
  var import_fishjam_openapi2 = __toESM(require_dist());
@@ -18683,6 +18684,7 @@ var mapException = (error, entity) => {
18683
18684
  // src/client.ts
18684
18685
  var FishjamClient = class {
18685
18686
  roomApi;
18687
+ viewerApi;
18686
18688
  /**
18687
18689
  * Create new instance of Fishjam Client.
18688
18690
  *
@@ -18701,6 +18703,7 @@ var FishjamClient = class {
18701
18703
  }
18702
18704
  });
18703
18705
  this.roomApi = new import_fishjam_openapi.RoomApi(void 0, config.fishjamUrl, client2);
18706
+ this.viewerApi = new import_fishjam_openapi.ViewerApi(void 0, config.fishjamUrl, client2);
18704
18707
  }
18705
18708
  /**
18706
18709
  * Create a new room. All peers connected to the same room will be able to send/receive streams to each other.
@@ -18793,6 +18796,18 @@ var FishjamClient = class {
18793
18796
  throw mapException(error, "peer");
18794
18797
  }
18795
18798
  }
18799
+ /**
18800
+ * Creates a broadcast viewer token for the given room.
18801
+ * @returns a broadcast viewer token
18802
+ */
18803
+ async createBroadcastViewerToken(roomId) {
18804
+ try {
18805
+ const tokenResponse = await this.viewerApi.generateToken(roomId);
18806
+ return tokenResponse.data;
18807
+ } catch (error) {
18808
+ throw mapException(error);
18809
+ }
18810
+ }
18796
18811
  };
18797
18812
  // Annotate the CommonJS export names for ESM import in node:
18798
18813
  0 && (module.exports = {
@@ -18811,7 +18826,8 @@ var FishjamClient = class {
18811
18826
  RoomNotFoundException,
18812
18827
  ServiceUnavailableException,
18813
18828
  UnauthorizedException,
18814
- UnknownException
18829
+ UnknownException,
18830
+ ViewerToken
18815
18831
  });
18816
18832
  /*! Bundled license information:
18817
18833
 
package/dist/index.mjs CHANGED
@@ -10792,7 +10792,7 @@ var require_dist = __commonJS({
10792
10792
  UserApiAxiosParamCreator: () => UserApiAxiosParamCreator,
10793
10793
  UserApiFactory: () => UserApiFactory,
10794
10794
  UserApiFp: () => UserApiFp,
10795
- ViewerApi: () => ViewerApi,
10795
+ ViewerApi: () => ViewerApi2,
10796
10796
  ViewerApiAxiosParamCreator: () => ViewerApiAxiosParamCreator,
10797
10797
  ViewerApiFactory: () => ViewerApiFactory,
10798
10798
  ViewerApiFp: () => ViewerApiFp
@@ -15672,8 +15672,8 @@ var require_dist = __commonJS({
15672
15672
  return {
15673
15673
  /**
15674
15674
  *
15675
- * @summary Generate token for single viewer
15676
- * @param {string} roomId Room ID
15675
+ * @summary Generate single broadcaster access token
15676
+ * @param {string} roomId A room id.
15677
15677
  * @param {*} [options] Override http request option.
15678
15678
  * @throws {RequiredError}
15679
15679
  */
@@ -15703,8 +15703,8 @@ var require_dist = __commonJS({
15703
15703
  return {
15704
15704
  /**
15705
15705
  *
15706
- * @summary Generate token for single viewer
15707
- * @param {string} roomId Room ID
15706
+ * @summary Generate single broadcaster access token
15707
+ * @param {string} roomId A room id.
15708
15708
  * @param {*} [options] Override http request option.
15709
15709
  * @throws {RequiredError}
15710
15710
  */
@@ -15721,8 +15721,8 @@ var require_dist = __commonJS({
15721
15721
  return {
15722
15722
  /**
15723
15723
  *
15724
- * @summary Generate token for single viewer
15725
- * @param {string} roomId Room ID
15724
+ * @summary Generate single broadcaster access token
15725
+ * @param {string} roomId A room id.
15726
15726
  * @param {*} [options] Override http request option.
15727
15727
  * @throws {RequiredError}
15728
15728
  */
@@ -15731,11 +15731,11 @@ var require_dist = __commonJS({
15731
15731
  }
15732
15732
  };
15733
15733
  };
15734
- var ViewerApi = class extends BaseAPI {
15734
+ var ViewerApi2 = class extends BaseAPI {
15735
15735
  /**
15736
15736
  *
15737
- * @summary Generate token for single viewer
15738
- * @param {string} roomId Room ID
15737
+ * @summary Generate single broadcaster access token
15738
+ * @param {string} roomId A room id.
15739
15739
  * @param {*} [options] Override http request option.
15740
15740
  * @throws {RequiredError}
15741
15741
  * @memberof ViewerApi
@@ -15969,6 +15969,7 @@ var mapException = (error, entity) => {
15969
15969
  // src/client.ts
15970
15970
  var FishjamClient = class {
15971
15971
  roomApi;
15972
+ viewerApi;
15972
15973
  /**
15973
15974
  * Create new instance of Fishjam Client.
15974
15975
  *
@@ -15987,6 +15988,7 @@ var FishjamClient = class {
15987
15988
  }
15988
15989
  });
15989
15990
  this.roomApi = new import_fishjam_openapi.RoomApi(void 0, config.fishjamUrl, client2);
15991
+ this.viewerApi = new import_fishjam_openapi.ViewerApi(void 0, config.fishjamUrl, client2);
15990
15992
  }
15991
15993
  /**
15992
15994
  * Create a new room. All peers connected to the same room will be able to send/receive streams to each other.
@@ -16079,12 +16081,25 @@ var FishjamClient = class {
16079
16081
  throw mapException(error, "peer");
16080
16082
  }
16081
16083
  }
16084
+ /**
16085
+ * Creates a broadcast viewer token for the given room.
16086
+ * @returns a broadcast viewer token
16087
+ */
16088
+ async createBroadcastViewerToken(roomId) {
16089
+ try {
16090
+ const tokenResponse = await this.viewerApi.generateToken(roomId);
16091
+ return tokenResponse.data;
16092
+ } catch (error) {
16093
+ throw mapException(error);
16094
+ }
16095
+ }
16082
16096
  };
16083
16097
  var export_PeerOptions = import_fishjam_openapi2.PeerOptions;
16084
16098
  var export_PeerStatus = import_fishjam_openapi2.PeerStatus;
16085
16099
  var export_RoomConfig = import_fishjam_openapi2.RoomConfig;
16086
16100
  var export_RoomConfigRoomTypeEnum = import_fishjam_openapi2.RoomConfigRoomTypeEnum;
16087
16101
  var export_RoomConfigVideoCodecEnum = import_fishjam_openapi2.RoomConfigVideoCodecEnum;
16102
+ var export_ViewerToken = import_fishjam_openapi2.ViewerToken;
16088
16103
  export {
16089
16104
  BadRequestException,
16090
16105
  FishjamBaseException,
@@ -16101,7 +16116,8 @@ export {
16101
16116
  RoomNotFoundException,
16102
16117
  ServiceUnavailableException,
16103
16118
  UnauthorizedException,
16104
- UnknownException
16119
+ UnknownException,
16120
+ export_ViewerToken as ViewerToken
16105
16121
  };
16106
16122
  /*! Bundled license information:
16107
16123
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fishjam-cloud/js-server-sdk",
3
- "version": "0.15.1",
3
+ "version": "0.17.0",
4
4
  "description": "Fishjam server SDK for JavaScript",
5
5
  "homepage": "https://github.com/fishjam-cloud/js-server-sdk",
6
6
  "author": "Fishjam Team",
@@ -56,12 +56,12 @@
56
56
  "websocket": "^1.0.35"
57
57
  },
58
58
  "devDependencies": {
59
- "@fishjam-cloud/fishjam-openapi": "0.15.1",
60
- "@fishjam-cloud/fishjam-proto": "0.15.1",
61
- "@openapitools/openapi-generator-cli": "^2.16.3",
62
- "@types/node": "^22.13.5",
59
+ "@fishjam-cloud/fishjam-openapi": "0.17.0",
60
+ "@fishjam-cloud/fishjam-proto": "0.17.0",
61
+ "@openapitools/openapi-generator-cli": "^2.18.4",
62
+ "@types/node": "^22.13.16",
63
63
  "@types/websocket": "^1.0.10",
64
- "tsup": "^8.3.6",
64
+ "tsup": "^8.4.0",
65
65
  "typed-emitter": "^2.1.0"
66
66
  }
67
67
  }