@fishjam-cloud/js-server-sdk 0.27.0 → 0.28.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.js CHANGED
@@ -37,16 +37,19 @@ __export(index_exports, {
37
37
  FishjamNotFoundException: () => FishjamNotFoundException,
38
38
  FishjamWSNotifier: () => FishjamWSNotifier,
39
39
  ForbiddenException: () => ForbiddenException,
40
+ InvalidFishjamCredentialsException: () => InvalidFishjamCredentialsException,
40
41
  MissingFishjamIdException: () => MissingFishjamIdException,
41
42
  PeerNotFoundException: () => PeerNotFoundException,
42
43
  PeerStatus: () => PeerStatus,
44
+ QuotaExceededException: () => QuotaExceededException,
43
45
  RoomNotFoundException: () => RoomNotFoundException,
44
46
  RoomType: () => RoomType,
45
47
  ServerMessage: () => ServerMessage,
46
48
  ServiceUnavailableException: () => ServiceUnavailableException,
47
49
  UnauthorizedException: () => UnauthorizedException,
48
50
  UnknownException: () => UnknownException,
49
- VideoCodec: () => VideoCodec
51
+ VideoCodec: () => VideoCodec,
52
+ decodeServerNotifications: () => decodeServerNotifications
50
53
  });
51
54
  module.exports = __toCommonJS(index_exports);
52
55
 
@@ -138,12 +141,75 @@ var VideoCodec = {
138
141
  H264: "h264",
139
142
  Vp8: "vp8"
140
143
  };
144
+ var CredentialsApiAxiosParamCreator = function(configuration) {
145
+ return {
146
+ /**
147
+ * Returns 200 if the provided Fishjam Management Token is valid, 404 otherwise.
148
+ * @summary Validate Fishjam Management Token
149
+ * @param {*} [options] Override http request option.
150
+ * @throws {RequiredError}
151
+ */
152
+ validateCredentials: async (options = {}) => {
153
+ const localVarPath = `/validate`;
154
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
155
+ let baseOptions;
156
+ if (configuration) {
157
+ baseOptions = configuration.baseOptions;
158
+ }
159
+ const localVarRequestOptions = { method: "GET", ...baseOptions, ...options };
160
+ const localVarHeaderParameter = {};
161
+ const localVarQueryParameter = {};
162
+ await setBearerAuthToObject(localVarHeaderParameter, configuration);
163
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
164
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
165
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
166
+ return {
167
+ url: toPathString(localVarUrlObj),
168
+ options: localVarRequestOptions
169
+ };
170
+ }
171
+ };
172
+ };
173
+ var CredentialsApiFp = function(configuration) {
174
+ const localVarAxiosParamCreator = CredentialsApiAxiosParamCreator(configuration);
175
+ return {
176
+ /**
177
+ * Returns 200 if the provided Fishjam Management Token is valid, 404 otherwise.
178
+ * @summary Validate Fishjam Management Token
179
+ * @param {*} [options] Override http request option.
180
+ * @throws {RequiredError}
181
+ */
182
+ async validateCredentials(options) {
183
+ const localVarAxiosArgs = await localVarAxiosParamCreator.validateCredentials(options);
184
+ const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
185
+ const localVarOperationServerBasePath = operationServerMap["CredentialsApi.validateCredentials"]?.[localVarOperationServerIndex]?.url;
186
+ return (axios2, basePath) => createRequestFunction(
187
+ localVarAxiosArgs,
188
+ import_axios.default,
189
+ BASE_PATH,
190
+ configuration
191
+ )(axios2, localVarOperationServerBasePath || basePath);
192
+ }
193
+ };
194
+ };
195
+ var CredentialsApi = class extends BaseAPI {
196
+ /**
197
+ * Returns 200 if the provided Fishjam Management Token is valid, 404 otherwise.
198
+ * @summary Validate Fishjam Management Token
199
+ * @param {*} [options] Override http request option.
200
+ * @throws {RequiredError}
201
+ * @memberof CredentialsApi
202
+ */
203
+ validateCredentials(options) {
204
+ return CredentialsApiFp(this.configuration).validateCredentials(options).then((request) => request(this.axios, this.basePath));
205
+ }
206
+ };
141
207
  var MoQApiAxiosParamCreator = function(configuration) {
142
208
  return {
143
209
  /**
144
210
  * Issue a short-lived JWT for a Media over QUIC client.
145
211
  * @summary Create a MoQ token
146
- * @param {MoqTokenConfig} [moqTokenConfig]
212
+ * @param {MoqTokenConfig} [moqTokenConfig]
147
213
  * @param {*} [options] Override http request option.
148
214
  * @throws {RequiredError}
149
215
  */
@@ -176,7 +242,7 @@ var MoQApiFp = function(configuration) {
176
242
  /**
177
243
  * Issue a short-lived JWT for a Media over QUIC client.
178
244
  * @summary Create a MoQ token
179
- * @param {MoqTokenConfig} [moqTokenConfig]
245
+ * @param {MoqTokenConfig} [moqTokenConfig]
180
246
  * @param {*} [options] Override http request option.
181
247
  * @throws {RequiredError}
182
248
  */
@@ -184,7 +250,12 @@ var MoQApiFp = function(configuration) {
184
250
  const localVarAxiosArgs = await localVarAxiosParamCreator.createMoqToken(moqTokenConfig, options);
185
251
  const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
186
252
  const localVarOperationServerBasePath = operationServerMap["MoQApi.createMoqToken"]?.[localVarOperationServerIndex]?.url;
187
- return (axios2, basePath) => createRequestFunction(localVarAxiosArgs, import_axios.default, BASE_PATH, configuration)(axios2, localVarOperationServerBasePath || basePath);
253
+ return (axios2, basePath) => createRequestFunction(
254
+ localVarAxiosArgs,
255
+ import_axios.default,
256
+ BASE_PATH,
257
+ configuration
258
+ )(axios2, localVarOperationServerBasePath || basePath);
188
259
  }
189
260
  };
190
261
  };
@@ -192,7 +263,7 @@ var MoQApi = class extends BaseAPI {
192
263
  /**
193
264
  * Issue a short-lived JWT for a Media over QUIC client.
194
265
  * @summary Create a MoQ token
195
- * @param {MoqTokenConfig} [moqTokenConfig]
266
+ * @param {MoqTokenConfig} [moqTokenConfig]
196
267
  * @param {*} [options] Override http request option.
197
268
  * @throws {RequiredError}
198
269
  * @memberof MoQApi
@@ -207,7 +278,7 @@ var RoomsApiAxiosParamCreator = function(configuration) {
207
278
  * Add a peer to a room and return its connection token.
208
279
  * @summary Create a peer
209
280
  * @param {string} roomId Room id
210
- * @param {PeerConfig} [peerConfig]
281
+ * @param {PeerConfig} [peerConfig]
211
282
  * @param {*} [options] Override http request option.
212
283
  * @throws {RequiredError}
213
284
  */
@@ -236,7 +307,7 @@ var RoomsApiAxiosParamCreator = function(configuration) {
236
307
  /**
237
308
  * Create a new room with the given configuration.
238
309
  * @summary Create a room
239
- * @param {RoomConfig} [roomConfig]
310
+ * @param {RoomConfig} [roomConfig]
240
311
  * @param {*} [options] Override http request option.
241
312
  * @throws {RequiredError}
242
313
  */
@@ -457,7 +528,11 @@ var RoomsApiAxiosParamCreator = function(configuration) {
457
528
  setSearchParams(localVarUrlObj, localVarQueryParameter);
458
529
  let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
459
530
  localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
460
- localVarRequestOptions.data = serializeDataIfNeeded(subscribeTracksRequest, localVarRequestOptions, configuration);
531
+ localVarRequestOptions.data = serializeDataIfNeeded(
532
+ subscribeTracksRequest,
533
+ localVarRequestOptions,
534
+ configuration
535
+ );
461
536
  return {
462
537
  url: toPathString(localVarUrlObj),
463
538
  options: localVarRequestOptions
@@ -472,7 +547,7 @@ var RoomsApiFp = function(configuration) {
472
547
  * Add a peer to a room and return its connection token.
473
548
  * @summary Create a peer
474
549
  * @param {string} roomId Room id
475
- * @param {PeerConfig} [peerConfig]
550
+ * @param {PeerConfig} [peerConfig]
476
551
  * @param {*} [options] Override http request option.
477
552
  * @throws {RequiredError}
478
553
  */
@@ -480,12 +555,17 @@ var RoomsApiFp = function(configuration) {
480
555
  const localVarAxiosArgs = await localVarAxiosParamCreator.addPeer(roomId, peerConfig, options);
481
556
  const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
482
557
  const localVarOperationServerBasePath = operationServerMap["RoomsApi.addPeer"]?.[localVarOperationServerIndex]?.url;
483
- return (axios2, basePath) => createRequestFunction(localVarAxiosArgs, import_axios.default, BASE_PATH, configuration)(axios2, localVarOperationServerBasePath || basePath);
558
+ return (axios2, basePath) => createRequestFunction(
559
+ localVarAxiosArgs,
560
+ import_axios.default,
561
+ BASE_PATH,
562
+ configuration
563
+ )(axios2, localVarOperationServerBasePath || basePath);
484
564
  },
485
565
  /**
486
566
  * Create a new room with the given configuration.
487
567
  * @summary Create a room
488
- * @param {RoomConfig} [roomConfig]
568
+ * @param {RoomConfig} [roomConfig]
489
569
  * @param {*} [options] Override http request option.
490
570
  * @throws {RequiredError}
491
571
  */
@@ -493,7 +573,12 @@ var RoomsApiFp = function(configuration) {
493
573
  const localVarAxiosArgs = await localVarAxiosParamCreator.createRoom(roomConfig, options);
494
574
  const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
495
575
  const localVarOperationServerBasePath = operationServerMap["RoomsApi.createRoom"]?.[localVarOperationServerIndex]?.url;
496
- return (axios2, basePath) => createRequestFunction(localVarAxiosArgs, import_axios.default, BASE_PATH, configuration)(axios2, localVarOperationServerBasePath || basePath);
576
+ return (axios2, basePath) => createRequestFunction(
577
+ localVarAxiosArgs,
578
+ import_axios.default,
579
+ BASE_PATH,
580
+ configuration
581
+ )(axios2, localVarOperationServerBasePath || basePath);
497
582
  },
498
583
  /**
499
584
  * Remove a peer from a room and disconnect it.
@@ -507,7 +592,12 @@ var RoomsApiFp = function(configuration) {
507
592
  const localVarAxiosArgs = await localVarAxiosParamCreator.deletePeer(roomId, id, options);
508
593
  const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
509
594
  const localVarOperationServerBasePath = operationServerMap["RoomsApi.deletePeer"]?.[localVarOperationServerIndex]?.url;
510
- return (axios2, basePath) => createRequestFunction(localVarAxiosArgs, import_axios.default, BASE_PATH, configuration)(axios2, localVarOperationServerBasePath || basePath);
595
+ return (axios2, basePath) => createRequestFunction(
596
+ localVarAxiosArgs,
597
+ import_axios.default,
598
+ BASE_PATH,
599
+ configuration
600
+ )(axios2, localVarOperationServerBasePath || basePath);
511
601
  },
512
602
  /**
513
603
  * Delete a room by id and disconnect all of its peers.
@@ -520,7 +610,12 @@ var RoomsApiFp = function(configuration) {
520
610
  const localVarAxiosArgs = await localVarAxiosParamCreator.deleteRoom(roomId, options);
521
611
  const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
522
612
  const localVarOperationServerBasePath = operationServerMap["RoomsApi.deleteRoom"]?.[localVarOperationServerIndex]?.url;
523
- return (axios2, basePath) => createRequestFunction(localVarAxiosArgs, import_axios.default, BASE_PATH, configuration)(axios2, localVarOperationServerBasePath || basePath);
613
+ return (axios2, basePath) => createRequestFunction(
614
+ localVarAxiosArgs,
615
+ import_axios.default,
616
+ BASE_PATH,
617
+ configuration
618
+ )(axios2, localVarOperationServerBasePath || basePath);
524
619
  },
525
620
  /**
526
621
  * List all rooms and livestreams.
@@ -532,7 +627,12 @@ var RoomsApiFp = function(configuration) {
532
627
  const localVarAxiosArgs = await localVarAxiosParamCreator.getAllRooms(options);
533
628
  const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
534
629
  const localVarOperationServerBasePath = operationServerMap["RoomsApi.getAllRooms"]?.[localVarOperationServerIndex]?.url;
535
- return (axios2, basePath) => createRequestFunction(localVarAxiosArgs, import_axios.default, BASE_PATH, configuration)(axios2, localVarOperationServerBasePath || basePath);
630
+ return (axios2, basePath) => createRequestFunction(
631
+ localVarAxiosArgs,
632
+ import_axios.default,
633
+ BASE_PATH,
634
+ configuration
635
+ )(axios2, localVarOperationServerBasePath || basePath);
536
636
  },
537
637
  /**
538
638
  * Get a room by id.
@@ -545,7 +645,12 @@ var RoomsApiFp = function(configuration) {
545
645
  const localVarAxiosArgs = await localVarAxiosParamCreator.getRoom(roomId, options);
546
646
  const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
547
647
  const localVarOperationServerBasePath = operationServerMap["RoomsApi.getRoom"]?.[localVarOperationServerIndex]?.url;
548
- return (axios2, basePath) => createRequestFunction(localVarAxiosArgs, import_axios.default, BASE_PATH, configuration)(axios2, localVarOperationServerBasePath || basePath);
648
+ return (axios2, basePath) => createRequestFunction(
649
+ localVarAxiosArgs,
650
+ import_axios.default,
651
+ BASE_PATH,
652
+ configuration
653
+ )(axios2, localVarOperationServerBasePath || basePath);
549
654
  },
550
655
  /**
551
656
  * Issue a fresh connection token for an existing peer.
@@ -559,7 +664,12 @@ var RoomsApiFp = function(configuration) {
559
664
  const localVarAxiosArgs = await localVarAxiosParamCreator.refreshToken(roomId, id, options);
560
665
  const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
561
666
  const localVarOperationServerBasePath = operationServerMap["RoomsApi.refreshToken"]?.[localVarOperationServerIndex]?.url;
562
- return (axios2, basePath) => createRequestFunction(localVarAxiosArgs, import_axios.default, BASE_PATH, configuration)(axios2, localVarOperationServerBasePath || basePath);
667
+ return (axios2, basePath) => createRequestFunction(
668
+ localVarAxiosArgs,
669
+ import_axios.default,
670
+ BASE_PATH,
671
+ configuration
672
+ )(axios2, localVarOperationServerBasePath || basePath);
563
673
  },
564
674
  /**
565
675
  * Subscribe a peer to all current and future tracks published by another peer in the same room.
@@ -574,7 +684,12 @@ var RoomsApiFp = function(configuration) {
574
684
  const localVarAxiosArgs = await localVarAxiosParamCreator.subscribePeer(roomId, id, peerId, options);
575
685
  const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
576
686
  const localVarOperationServerBasePath = operationServerMap["RoomsApi.subscribePeer"]?.[localVarOperationServerIndex]?.url;
577
- return (axios2, basePath) => createRequestFunction(localVarAxiosArgs, import_axios.default, BASE_PATH, configuration)(axios2, localVarOperationServerBasePath || basePath);
687
+ return (axios2, basePath) => createRequestFunction(
688
+ localVarAxiosArgs,
689
+ import_axios.default,
690
+ BASE_PATH,
691
+ configuration
692
+ )(axios2, localVarOperationServerBasePath || basePath);
578
693
  },
579
694
  /**
580
695
  * Subscribe a peer to a specific list of track IDs in the same room.
@@ -586,10 +701,20 @@ var RoomsApiFp = function(configuration) {
586
701
  * @throws {RequiredError}
587
702
  */
588
703
  async subscribeTracks(roomId, id, subscribeTracksRequest, options) {
589
- const localVarAxiosArgs = await localVarAxiosParamCreator.subscribeTracks(roomId, id, subscribeTracksRequest, options);
704
+ const localVarAxiosArgs = await localVarAxiosParamCreator.subscribeTracks(
705
+ roomId,
706
+ id,
707
+ subscribeTracksRequest,
708
+ options
709
+ );
590
710
  const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
591
711
  const localVarOperationServerBasePath = operationServerMap["RoomsApi.subscribeTracks"]?.[localVarOperationServerIndex]?.url;
592
- return (axios2, basePath) => createRequestFunction(localVarAxiosArgs, import_axios.default, BASE_PATH, configuration)(axios2, localVarOperationServerBasePath || basePath);
712
+ return (axios2, basePath) => createRequestFunction(
713
+ localVarAxiosArgs,
714
+ import_axios.default,
715
+ BASE_PATH,
716
+ configuration
717
+ )(axios2, localVarOperationServerBasePath || basePath);
593
718
  }
594
719
  };
595
720
  };
@@ -598,7 +723,7 @@ var RoomsApi = class extends BaseAPI {
598
723
  * Add a peer to a room and return its connection token.
599
724
  * @summary Create a peer
600
725
  * @param {string} roomId Room id
601
- * @param {PeerConfig} [peerConfig]
726
+ * @param {PeerConfig} [peerConfig]
602
727
  * @param {*} [options] Override http request option.
603
728
  * @throws {RequiredError}
604
729
  * @memberof RoomsApi
@@ -609,7 +734,7 @@ var RoomsApi = class extends BaseAPI {
609
734
  /**
610
735
  * Create a new room with the given configuration.
611
736
  * @summary Create a room
612
- * @param {RoomConfig} [roomConfig]
737
+ * @param {RoomConfig} [roomConfig]
613
738
  * @param {*} [options] Override http request option.
614
739
  * @throws {RequiredError}
615
740
  * @memberof RoomsApi
@@ -711,7 +836,10 @@ var StreamersApiAxiosParamCreator = function(configuration) {
711
836
  */
712
837
  createStreamer: async (streamId, options = {}) => {
713
838
  assertParamExists("createStreamer", "streamId", streamId);
714
- const localVarPath = `/livestream/{stream_id}/streamer`.replace(`{${"stream_id"}}`, encodeURIComponent(String(streamId)));
839
+ const localVarPath = `/livestream/{stream_id}/streamer`.replace(
840
+ `{${"stream_id"}}`,
841
+ encodeURIComponent(String(streamId))
842
+ );
715
843
  const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
716
844
  let baseOptions;
717
845
  if (configuration) {
@@ -801,7 +929,12 @@ var StreamersApiFp = function(configuration) {
801
929
  const localVarAxiosArgs = await localVarAxiosParamCreator.createStreamer(streamId, options);
802
930
  const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
803
931
  const localVarOperationServerBasePath = operationServerMap["StreamersApi.createStreamer"]?.[localVarOperationServerIndex]?.url;
804
- return (axios2, basePath) => createRequestFunction(localVarAxiosArgs, import_axios.default, BASE_PATH, configuration)(axios2, localVarOperationServerBasePath || basePath);
932
+ return (axios2, basePath) => createRequestFunction(
933
+ localVarAxiosArgs,
934
+ import_axios.default,
935
+ BASE_PATH,
936
+ configuration
937
+ )(axios2, localVarOperationServerBasePath || basePath);
805
938
  },
806
939
  /**
807
940
  * Delete a streamer from a stream and revoke its token.
@@ -815,7 +948,12 @@ var StreamersApiFp = function(configuration) {
815
948
  const localVarAxiosArgs = await localVarAxiosParamCreator.deleteStreamer(streamId, streamerId, options);
816
949
  const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
817
950
  const localVarOperationServerBasePath = operationServerMap["StreamersApi.deleteStreamer"]?.[localVarOperationServerIndex]?.url;
818
- return (axios2, basePath) => createRequestFunction(localVarAxiosArgs, import_axios.default, BASE_PATH, configuration)(axios2, localVarOperationServerBasePath || basePath);
951
+ return (axios2, basePath) => createRequestFunction(
952
+ localVarAxiosArgs,
953
+ import_axios.default,
954
+ BASE_PATH,
955
+ configuration
956
+ )(axios2, localVarOperationServerBasePath || basePath);
819
957
  },
820
958
  /**
821
959
  * Issue a fresh streamer token.
@@ -828,7 +966,12 @@ var StreamersApiFp = function(configuration) {
828
966
  const localVarAxiosArgs = await localVarAxiosParamCreator.generateStreamerToken(roomId, options);
829
967
  const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
830
968
  const localVarOperationServerBasePath = operationServerMap["StreamersApi.generateStreamerToken"]?.[localVarOperationServerIndex]?.url;
831
- return (axios2, basePath) => createRequestFunction(localVarAxiosArgs, import_axios.default, BASE_PATH, configuration)(axios2, localVarOperationServerBasePath || basePath);
969
+ return (axios2, basePath) => createRequestFunction(
970
+ localVarAxiosArgs,
971
+ import_axios.default,
972
+ BASE_PATH,
973
+ configuration
974
+ )(axios2, localVarOperationServerBasePath || basePath);
832
975
  }
833
976
  };
834
977
  };
@@ -879,7 +1022,10 @@ var ViewersApiAxiosParamCreator = function(configuration) {
879
1022
  */
880
1023
  createViewer: async (streamId, options = {}) => {
881
1024
  assertParamExists("createViewer", "streamId", streamId);
882
- const localVarPath = `/livestream/{stream_id}/viewer`.replace(`{${"stream_id"}}`, encodeURIComponent(String(streamId)));
1025
+ const localVarPath = `/livestream/{stream_id}/viewer`.replace(
1026
+ `{${"stream_id"}}`,
1027
+ encodeURIComponent(String(streamId))
1028
+ );
883
1029
  const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
884
1030
  let baseOptions;
885
1031
  if (configuration) {
@@ -969,7 +1115,12 @@ var ViewersApiFp = function(configuration) {
969
1115
  const localVarAxiosArgs = await localVarAxiosParamCreator.createViewer(streamId, options);
970
1116
  const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
971
1117
  const localVarOperationServerBasePath = operationServerMap["ViewersApi.createViewer"]?.[localVarOperationServerIndex]?.url;
972
- return (axios2, basePath) => createRequestFunction(localVarAxiosArgs, import_axios.default, BASE_PATH, configuration)(axios2, localVarOperationServerBasePath || basePath);
1118
+ return (axios2, basePath) => createRequestFunction(
1119
+ localVarAxiosArgs,
1120
+ import_axios.default,
1121
+ BASE_PATH,
1122
+ configuration
1123
+ )(axios2, localVarOperationServerBasePath || basePath);
973
1124
  },
974
1125
  /**
975
1126
  * Delete a viewer from a stream and revoke its token.
@@ -983,7 +1134,12 @@ var ViewersApiFp = function(configuration) {
983
1134
  const localVarAxiosArgs = await localVarAxiosParamCreator.deleteViewer(streamId, viewerId, options);
984
1135
  const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
985
1136
  const localVarOperationServerBasePath = operationServerMap["ViewersApi.deleteViewer"]?.[localVarOperationServerIndex]?.url;
986
- return (axios2, basePath) => createRequestFunction(localVarAxiosArgs, import_axios.default, BASE_PATH, configuration)(axios2, localVarOperationServerBasePath || basePath);
1137
+ return (axios2, basePath) => createRequestFunction(
1138
+ localVarAxiosArgs,
1139
+ import_axios.default,
1140
+ BASE_PATH,
1141
+ configuration
1142
+ )(axios2, localVarOperationServerBasePath || basePath);
987
1143
  },
988
1144
  /**
989
1145
  * Issue a fresh viewer token.
@@ -996,7 +1152,12 @@ var ViewersApiFp = function(configuration) {
996
1152
  const localVarAxiosArgs = await localVarAxiosParamCreator.generateViewerToken(roomId, options);
997
1153
  const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
998
1154
  const localVarOperationServerBasePath = operationServerMap["ViewersApi.generateViewerToken"]?.[localVarOperationServerIndex]?.url;
999
- return (axios2, basePath) => createRequestFunction(localVarAxiosArgs, import_axios.default, BASE_PATH, configuration)(axios2, localVarOperationServerBasePath || basePath);
1155
+ return (axios2, basePath) => createRequestFunction(
1156
+ localVarAxiosArgs,
1157
+ import_axios.default,
1158
+ BASE_PATH,
1159
+ configuration
1160
+ )(axios2, localVarOperationServerBasePath || basePath);
1000
1161
  }
1001
1162
  };
1002
1163
  };
@@ -5815,10 +5976,14 @@ var RoomNotFoundException = class extends FishjamBaseException {
5815
5976
  };
5816
5977
  var FishjamNotFoundException = class extends FishjamBaseException {
5817
5978
  };
5979
+ var InvalidFishjamCredentialsException = class extends FishjamBaseException {
5980
+ };
5818
5981
  var PeerNotFoundException = class extends FishjamBaseException {
5819
5982
  };
5820
5983
  var ServiceUnavailableException = class extends FishjamBaseException {
5821
5984
  };
5985
+ var QuotaExceededException = class extends FishjamBaseException {
5986
+ };
5822
5987
  var UnknownException = class extends FishjamBaseException {
5823
5988
  };
5824
5989
 
@@ -5892,6 +6057,16 @@ var mapNotification = (event, msg) => {
5892
6057
  }
5893
6058
  return msg;
5894
6059
  };
6060
+ var isExpectedEvent = (event) => expectedEventsList.includes(event);
6061
+ var flattenServerMessage = (message) => message.notificationBatch?.notifications ?? [message];
6062
+ var toServerNotification = (message) => {
6063
+ const entry = Object.entries(message).find(([, value]) => value);
6064
+ if (!entry) return null;
6065
+ const [event, msg] = entry;
6066
+ if (!isExpectedEvent(event)) return null;
6067
+ return { type: event, notification: mapNotification(event, msg) };
6068
+ };
6069
+ var extractNotifications = (message) => flattenServerMessage(message).map(toServerNotification).filter((notification) => notification !== null);
5895
6070
 
5896
6071
  // src/ws_notifier.ts
5897
6072
  var FishjamWSNotifier = class extends import_events.EventEmitter {
@@ -5909,12 +6084,11 @@ var FishjamWSNotifier = class extends import_events.EventEmitter {
5909
6084
  }
5910
6085
  dispatchNotification(message) {
5911
6086
  try {
5912
- const data = new Uint8Array(message.data);
5913
- const decodedMessage = ServerMessage.decode(data);
5914
- const [notification, msg] = Object.entries(decodedMessage).find(([_k, v]) => v);
5915
- if (!this.isExpectedEvent(notification)) return;
5916
- const emit = this.emit;
5917
- emit(notification, mapNotification(notification, msg));
6087
+ const decodedMessage = ServerMessage.decode(new Uint8Array(message.data));
6088
+ const emit = this.emit.bind(this);
6089
+ for (const { type, notification } of extractNotifications(decodedMessage)) {
6090
+ emit(type, notification);
6091
+ }
5918
6092
  } catch (e) {
5919
6093
  console.error("Couldn't decode websocket server message", e, message);
5920
6094
  }
@@ -5927,11 +6101,11 @@ var FishjamWSNotifier = class extends import_events.EventEmitter {
5927
6101
  this.client.send(auth);
5928
6102
  this.client.send(subscription);
5929
6103
  }
5930
- isExpectedEvent(notification) {
5931
- return expectedEventsList.includes(notification);
5932
- }
5933
6104
  };
5934
6105
 
6106
+ // src/webhook.ts
6107
+ var decodeServerNotifications = (data) => extractNotifications(ServerMessage.decode(data instanceof Uint8Array ? data : new Uint8Array(data)));
6108
+
5935
6109
  // src/agent.ts
5936
6110
  var import_events2 = require("events");
5937
6111
  var import_uuid = require("uuid");
@@ -6092,9 +6266,14 @@ var mapException = (error, entity) => {
6092
6266
  switch (error.response?.status) {
6093
6267
  case 400:
6094
6268
  return new BadRequestException(error);
6269
+ case 402:
6270
+ return new QuotaExceededException(error);
6095
6271
  case 401:
6096
6272
  throw new UnauthorizedException(error);
6097
6273
  case 404:
6274
+ if (error.request.path.includes("validate")) {
6275
+ return new InvalidFishjamCredentialsException(error);
6276
+ }
6098
6277
  switch (entity) {
6099
6278
  case "peer":
6100
6279
  return new PeerNotFoundException(error);
@@ -6116,7 +6295,7 @@ var mapException = (error, entity) => {
6116
6295
  // package.json
6117
6296
  var package_default = {
6118
6297
  name: "@fishjam-cloud/js-server-sdk",
6119
- version: "0.27.0",
6298
+ version: "0.28.0",
6120
6299
  description: "Fishjam server SDK for JavaScript",
6121
6300
  homepage: "https://github.com/fishjam-cloud/js-server-sdk",
6122
6301
  author: "Fishjam Team",
@@ -6209,16 +6388,21 @@ var package_default = {
6209
6388
  };
6210
6389
 
6211
6390
  // src/client.ts
6212
- var FishjamClient = class {
6391
+ var FishjamClient = class _FishjamClient {
6213
6392
  moqApi;
6214
6393
  roomApi;
6215
6394
  viewerApi;
6216
6395
  streamerApi;
6396
+ credentialsApi;
6217
6397
  fishjamConfig;
6218
6398
  deprecationWarningShown = false;
6219
6399
  /**
6220
6400
  * Create new instance of Fishjam Client.
6221
6401
  *
6402
+ * Does not verify credentials against the backend — use
6403
+ * {@link FishjamClient.create} or call
6404
+ * {@link FishjamClient.checkCredentials} afterwards for that.
6405
+ *
6222
6406
  * Example usage:
6223
6407
  * ```
6224
6408
  * const fishjamClient = new FishjamClient({
@@ -6243,8 +6427,42 @@ var FishjamClient = class {
6243
6427
  this.roomApi = new RoomsApi(void 0, fishjamUrl, client);
6244
6428
  this.viewerApi = new ViewersApi(void 0, fishjamUrl, client);
6245
6429
  this.streamerApi = new StreamersApi(void 0, fishjamUrl, client);
6430
+ this.credentialsApi = new CredentialsApi(void 0, fishjamUrl, client);
6246
6431
  this.fishjamConfig = config;
6247
6432
  }
6433
+ /**
6434
+ * Async factory: constructs a client and verifies credentials against
6435
+ * the backend.
6436
+ *
6437
+ * Throws {@link InvalidFishjamCredentialsException} when the
6438
+ * `fishjamId` / `managementToken` pair is rejected by the backend.
6439
+ *
6440
+ * Example:
6441
+ * ```
6442
+ * const client = await FishjamClient.create({
6443
+ * fishjamId: process.env.FISHJAM_ID!,
6444
+ * managementToken: process.env.FISHJAM_MANAGEMENT_TOKEN!,
6445
+ * });
6446
+ * ```
6447
+ */
6448
+ static async create(config) {
6449
+ const client = new _FishjamClient(config);
6450
+ await client.checkCredentials();
6451
+ return client;
6452
+ }
6453
+ /**
6454
+ * Verifies the configured credentials by making a single lightweight
6455
+ * call to the Fishjam backend. Resolves on success, throws
6456
+ * {@link InvalidFishjamCredentialsException} on 401/404 from the backend,
6457
+ * otherwise rethrows the standard mapped exception.
6458
+ */
6459
+ async checkCredentials() {
6460
+ try {
6461
+ await this.credentialsApi.validateCredentials();
6462
+ } catch (error) {
6463
+ throw mapException(error);
6464
+ }
6465
+ }
6248
6466
  handleDeprecationHeader(headers) {
6249
6467
  try {
6250
6468
  const deprecationHeader = headers["x-fishjam-api-deprecated"];
@@ -6451,14 +6669,17 @@ var FishjamClient = class {
6451
6669
  FishjamNotFoundException,
6452
6670
  FishjamWSNotifier,
6453
6671
  ForbiddenException,
6672
+ InvalidFishjamCredentialsException,
6454
6673
  MissingFishjamIdException,
6455
6674
  PeerNotFoundException,
6456
6675
  PeerStatus,
6676
+ QuotaExceededException,
6457
6677
  RoomNotFoundException,
6458
6678
  RoomType,
6459
6679
  ServerMessage,
6460
6680
  ServiceUnavailableException,
6461
6681
  UnauthorizedException,
6462
6682
  UnknownException,
6463
- VideoCodec
6683
+ VideoCodec,
6684
+ decodeServerNotifications
6464
6685
  });