@fishjam-cloud/js-server-sdk 0.15.1 → 0.17.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.
- package/dist/index.d.mts +54 -3
- package/dist/index.d.ts +54 -3
- package/dist/index.js +32 -15
- package/dist/index.mjs +31 -14
- package/package.json +6 -6
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
|
|
@@ -225,12 +238,44 @@ type Peer = Omit<Peer$1, 'id'> & {
|
|
|
225
238
|
type Room = {
|
|
226
239
|
id: RoomId;
|
|
227
240
|
peers: Peer[];
|
|
228
|
-
config:
|
|
241
|
+
config: RoomOptions;
|
|
229
242
|
};
|
|
230
243
|
type FishjamConfig = {
|
|
231
244
|
fishjamUrl: string;
|
|
232
245
|
managementToken: string;
|
|
233
246
|
};
|
|
247
|
+
type RoomOptions = {
|
|
248
|
+
/**
|
|
249
|
+
* Maximum amount of peers allowed into the room
|
|
250
|
+
* @type {number}
|
|
251
|
+
*/
|
|
252
|
+
maxPeers?: number | null;
|
|
253
|
+
/**
|
|
254
|
+
* Duration (in seconds) after which the peer will be removed if it is disconnected. If not provided, this feature is disabled.
|
|
255
|
+
* @type {number}
|
|
256
|
+
*/
|
|
257
|
+
peerDisconnectedTimeout?: number | null;
|
|
258
|
+
/**
|
|
259
|
+
* Duration (in seconds) after which the room will be removed if no peers are connected. If not provided, this feature is disabled.
|
|
260
|
+
* @type {number}
|
|
261
|
+
*/
|
|
262
|
+
peerlessPurgeTimeout?: number | null;
|
|
263
|
+
/**
|
|
264
|
+
* The use-case of the room. If not provided, this defaults to full_feature.
|
|
265
|
+
* @type {string}
|
|
266
|
+
*/
|
|
267
|
+
roomType?: RoomConfigRoomTypeEnum | 'livestream';
|
|
268
|
+
/**
|
|
269
|
+
* Enforces video codec for each peer in the room
|
|
270
|
+
* @type {string}
|
|
271
|
+
*/
|
|
272
|
+
videoCodec?: RoomConfigVideoCodecEnum | null;
|
|
273
|
+
/**
|
|
274
|
+
* URL where Fishjam notifications will be sent
|
|
275
|
+
* @type {string}
|
|
276
|
+
*/
|
|
277
|
+
webhookUrl?: string | null;
|
|
278
|
+
};
|
|
234
279
|
|
|
235
280
|
type ExpectedEvents = 'roomCreated' | 'roomDeleted' | 'roomCrashed' | 'peerAdded' | 'peerDeleted' | 'peerConnected' | 'peerDisconnected' | 'peerMetadataUpdated' | 'peerCrashed' | 'trackAdded' | 'trackRemoved' | 'trackMetadataUpdated';
|
|
236
281
|
type ErrorEventHandler = (msg: Error) => void;
|
|
@@ -256,6 +301,7 @@ declare class FishjamWSNotifier extends FishjamWSNotifier_base {
|
|
|
256
301
|
*/
|
|
257
302
|
declare class FishjamClient {
|
|
258
303
|
private readonly roomApi;
|
|
304
|
+
private readonly viewerApi;
|
|
259
305
|
/**
|
|
260
306
|
* Create new instance of Fishjam Client.
|
|
261
307
|
*
|
|
@@ -271,7 +317,7 @@ declare class FishjamClient {
|
|
|
271
317
|
/**
|
|
272
318
|
* Create a new room. All peers connected to the same room will be able to send/receive streams to each other.
|
|
273
319
|
*/
|
|
274
|
-
createRoom(config?:
|
|
320
|
+
createRoom(config?: RoomOptions): Promise<Room>;
|
|
275
321
|
/**
|
|
276
322
|
* Delete an existing room. All peers connected to this room will be disconnected and removed.
|
|
277
323
|
*/
|
|
@@ -301,6 +347,11 @@ declare class FishjamClient {
|
|
|
301
347
|
* @returns refreshed peer token
|
|
302
348
|
*/
|
|
303
349
|
refreshPeerToken(roomId: RoomId, peerId: PeerId): Promise<string>;
|
|
350
|
+
/**
|
|
351
|
+
* Creates a livestream viewer token for the given room.
|
|
352
|
+
* @returns a livestream viewer token
|
|
353
|
+
*/
|
|
354
|
+
createLivestreamViewerToken(roomId: RoomId): Promise<ViewerToken>;
|
|
304
355
|
}
|
|
305
356
|
|
|
306
357
|
declare class FishjamBaseException extends Error {
|
|
@@ -326,4 +377,4 @@ declare class ServiceUnavailableException extends FishjamBaseException {
|
|
|
326
377
|
declare class UnknownException extends FishjamBaseException {
|
|
327
378
|
}
|
|
328
379
|
|
|
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 };
|
|
380
|
+
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, type RoomOptions, 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
|
|
@@ -225,12 +238,44 @@ type Peer = Omit<Peer$1, 'id'> & {
|
|
|
225
238
|
type Room = {
|
|
226
239
|
id: RoomId;
|
|
227
240
|
peers: Peer[];
|
|
228
|
-
config:
|
|
241
|
+
config: RoomOptions;
|
|
229
242
|
};
|
|
230
243
|
type FishjamConfig = {
|
|
231
244
|
fishjamUrl: string;
|
|
232
245
|
managementToken: string;
|
|
233
246
|
};
|
|
247
|
+
type RoomOptions = {
|
|
248
|
+
/**
|
|
249
|
+
* Maximum amount of peers allowed into the room
|
|
250
|
+
* @type {number}
|
|
251
|
+
*/
|
|
252
|
+
maxPeers?: number | null;
|
|
253
|
+
/**
|
|
254
|
+
* Duration (in seconds) after which the peer will be removed if it is disconnected. If not provided, this feature is disabled.
|
|
255
|
+
* @type {number}
|
|
256
|
+
*/
|
|
257
|
+
peerDisconnectedTimeout?: number | null;
|
|
258
|
+
/**
|
|
259
|
+
* Duration (in seconds) after which the room will be removed if no peers are connected. If not provided, this feature is disabled.
|
|
260
|
+
* @type {number}
|
|
261
|
+
*/
|
|
262
|
+
peerlessPurgeTimeout?: number | null;
|
|
263
|
+
/**
|
|
264
|
+
* The use-case of the room. If not provided, this defaults to full_feature.
|
|
265
|
+
* @type {string}
|
|
266
|
+
*/
|
|
267
|
+
roomType?: RoomConfigRoomTypeEnum | 'livestream';
|
|
268
|
+
/**
|
|
269
|
+
* Enforces video codec for each peer in the room
|
|
270
|
+
* @type {string}
|
|
271
|
+
*/
|
|
272
|
+
videoCodec?: RoomConfigVideoCodecEnum | null;
|
|
273
|
+
/**
|
|
274
|
+
* URL where Fishjam notifications will be sent
|
|
275
|
+
* @type {string}
|
|
276
|
+
*/
|
|
277
|
+
webhookUrl?: string | null;
|
|
278
|
+
};
|
|
234
279
|
|
|
235
280
|
type ExpectedEvents = 'roomCreated' | 'roomDeleted' | 'roomCrashed' | 'peerAdded' | 'peerDeleted' | 'peerConnected' | 'peerDisconnected' | 'peerMetadataUpdated' | 'peerCrashed' | 'trackAdded' | 'trackRemoved' | 'trackMetadataUpdated';
|
|
236
281
|
type ErrorEventHandler = (msg: Error) => void;
|
|
@@ -256,6 +301,7 @@ declare class FishjamWSNotifier extends FishjamWSNotifier_base {
|
|
|
256
301
|
*/
|
|
257
302
|
declare class FishjamClient {
|
|
258
303
|
private readonly roomApi;
|
|
304
|
+
private readonly viewerApi;
|
|
259
305
|
/**
|
|
260
306
|
* Create new instance of Fishjam Client.
|
|
261
307
|
*
|
|
@@ -271,7 +317,7 @@ declare class FishjamClient {
|
|
|
271
317
|
/**
|
|
272
318
|
* Create a new room. All peers connected to the same room will be able to send/receive streams to each other.
|
|
273
319
|
*/
|
|
274
|
-
createRoom(config?:
|
|
320
|
+
createRoom(config?: RoomOptions): Promise<Room>;
|
|
275
321
|
/**
|
|
276
322
|
* Delete an existing room. All peers connected to this room will be disconnected and removed.
|
|
277
323
|
*/
|
|
@@ -301,6 +347,11 @@ declare class FishjamClient {
|
|
|
301
347
|
* @returns refreshed peer token
|
|
302
348
|
*/
|
|
303
349
|
refreshPeerToken(roomId: RoomId, peerId: PeerId): Promise<string>;
|
|
350
|
+
/**
|
|
351
|
+
* Creates a livestream viewer token for the given room.
|
|
352
|
+
* @returns a livestream viewer token
|
|
353
|
+
*/
|
|
354
|
+
createLivestreamViewerToken(roomId: RoomId): Promise<ViewerToken>;
|
|
304
355
|
}
|
|
305
356
|
|
|
306
357
|
declare class FishjamBaseException extends Error {
|
|
@@ -326,4 +377,4 @@ declare class ServiceUnavailableException extends FishjamBaseException {
|
|
|
326
377
|
declare class UnknownException extends FishjamBaseException {
|
|
327
378
|
}
|
|
328
379
|
|
|
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 };
|
|
380
|
+
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, type RoomOptions, ServiceUnavailableException, UnauthorizedException, UnknownException, type ViewerToken };
|
package/dist/index.js
CHANGED
|
@@ -10806,7 +10806,7 @@ var require_dist = __commonJS({
|
|
|
10806
10806
|
RoomApiAxiosParamCreator: () => RoomApiAxiosParamCreator,
|
|
10807
10807
|
RoomApiFactory: () => RoomApiFactory,
|
|
10808
10808
|
RoomApiFp: () => RoomApiFp,
|
|
10809
|
-
RoomConfigRoomTypeEnum: () =>
|
|
10809
|
+
RoomConfigRoomTypeEnum: () => RoomConfigRoomTypeEnum3,
|
|
10810
10810
|
RoomConfigVideoCodecEnum: () => RoomConfigVideoCodecEnum2,
|
|
10811
10811
|
SipApi: () => SipApi,
|
|
10812
10812
|
SipApiAxiosParamCreator: () => SipApiAxiosParamCreator,
|
|
@@ -10817,7 +10817,7 @@ var require_dist = __commonJS({
|
|
|
10817
10817
|
UserApiAxiosParamCreator: () => UserApiAxiosParamCreator,
|
|
10818
10818
|
UserApiFactory: () => UserApiFactory,
|
|
10819
10819
|
UserApiFp: () => UserApiFp,
|
|
10820
|
-
ViewerApi: () =>
|
|
10820
|
+
ViewerApi: () => ViewerApi2,
|
|
10821
10821
|
ViewerApiAxiosParamCreator: () => ViewerApiAxiosParamCreator,
|
|
10822
10822
|
ViewerApiFactory: () => ViewerApiFactory,
|
|
10823
10823
|
ViewerApiFp: () => ViewerApiFp
|
|
@@ -14084,7 +14084,7 @@ var require_dist = __commonJS({
|
|
|
14084
14084
|
Connected: "connected",
|
|
14085
14085
|
Disconnected: "disconnected"
|
|
14086
14086
|
};
|
|
14087
|
-
var
|
|
14087
|
+
var RoomConfigRoomTypeEnum3 = {
|
|
14088
14088
|
FullFeature: "full_feature",
|
|
14089
14089
|
AudioOnly: "audio_only",
|
|
14090
14090
|
Broadcaster: "broadcaster"
|
|
@@ -15697,8 +15697,8 @@ var require_dist = __commonJS({
|
|
|
15697
15697
|
return {
|
|
15698
15698
|
/**
|
|
15699
15699
|
*
|
|
15700
|
-
* @summary Generate
|
|
15701
|
-
* @param {string} roomId
|
|
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
|
|
15732
|
-
* @param {string} roomId
|
|
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
|
|
15750
|
-
* @param {string} roomId
|
|
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
|
|
15759
|
+
var ViewerApi2 = class extends BaseAPI {
|
|
15760
15760
|
/**
|
|
15761
15761
|
*
|
|
15762
|
-
* @summary Generate
|
|
15763
|
-
* @param {string} roomId
|
|
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,13 +18703,15 @@ 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.
|
|
18707
18710
|
*/
|
|
18708
18711
|
async createRoom(config = {}) {
|
|
18709
18712
|
try {
|
|
18710
|
-
const
|
|
18713
|
+
const parsedRoomType = config.roomType == "livestream" ? import_fishjam_openapi.RoomConfigRoomTypeEnum.Broadcaster : config.roomType;
|
|
18714
|
+
const response = await this.roomApi.createRoom({ ...config, roomType: parsedRoomType });
|
|
18711
18715
|
const {
|
|
18712
18716
|
data: {
|
|
18713
18717
|
data: {
|
|
@@ -18793,6 +18797,18 @@ var FishjamClient = class {
|
|
|
18793
18797
|
throw mapException(error, "peer");
|
|
18794
18798
|
}
|
|
18795
18799
|
}
|
|
18800
|
+
/**
|
|
18801
|
+
* Creates a livestream viewer token for the given room.
|
|
18802
|
+
* @returns a livestream viewer token
|
|
18803
|
+
*/
|
|
18804
|
+
async createLivestreamViewerToken(roomId) {
|
|
18805
|
+
try {
|
|
18806
|
+
const tokenResponse = await this.viewerApi.generateToken(roomId);
|
|
18807
|
+
return tokenResponse.data;
|
|
18808
|
+
} catch (error) {
|
|
18809
|
+
throw mapException(error);
|
|
18810
|
+
}
|
|
18811
|
+
}
|
|
18796
18812
|
};
|
|
18797
18813
|
// Annotate the CommonJS export names for ESM import in node:
|
|
18798
18814
|
0 && (module.exports = {
|
|
@@ -18811,7 +18827,8 @@ var FishjamClient = class {
|
|
|
18811
18827
|
RoomNotFoundException,
|
|
18812
18828
|
ServiceUnavailableException,
|
|
18813
18829
|
UnauthorizedException,
|
|
18814
|
-
UnknownException
|
|
18830
|
+
UnknownException,
|
|
18831
|
+
ViewerToken
|
|
18815
18832
|
});
|
|
18816
18833
|
/*! Bundled license information:
|
|
18817
18834
|
|
package/dist/index.mjs
CHANGED
|
@@ -10781,7 +10781,7 @@ var require_dist = __commonJS({
|
|
|
10781
10781
|
RoomApiAxiosParamCreator: () => RoomApiAxiosParamCreator,
|
|
10782
10782
|
RoomApiFactory: () => RoomApiFactory,
|
|
10783
10783
|
RoomApiFp: () => RoomApiFp,
|
|
10784
|
-
RoomConfigRoomTypeEnum: () =>
|
|
10784
|
+
RoomConfigRoomTypeEnum: () => RoomConfigRoomTypeEnum3,
|
|
10785
10785
|
RoomConfigVideoCodecEnum: () => RoomConfigVideoCodecEnum2,
|
|
10786
10786
|
SipApi: () => SipApi,
|
|
10787
10787
|
SipApiAxiosParamCreator: () => SipApiAxiosParamCreator,
|
|
@@ -10792,7 +10792,7 @@ var require_dist = __commonJS({
|
|
|
10792
10792
|
UserApiAxiosParamCreator: () => UserApiAxiosParamCreator,
|
|
10793
10793
|
UserApiFactory: () => UserApiFactory,
|
|
10794
10794
|
UserApiFp: () => UserApiFp,
|
|
10795
|
-
ViewerApi: () =>
|
|
10795
|
+
ViewerApi: () => ViewerApi2,
|
|
10796
10796
|
ViewerApiAxiosParamCreator: () => ViewerApiAxiosParamCreator,
|
|
10797
10797
|
ViewerApiFactory: () => ViewerApiFactory,
|
|
10798
10798
|
ViewerApiFp: () => ViewerApiFp
|
|
@@ -14059,7 +14059,7 @@ var require_dist = __commonJS({
|
|
|
14059
14059
|
Connected: "connected",
|
|
14060
14060
|
Disconnected: "disconnected"
|
|
14061
14061
|
};
|
|
14062
|
-
var
|
|
14062
|
+
var RoomConfigRoomTypeEnum3 = {
|
|
14063
14063
|
FullFeature: "full_feature",
|
|
14064
14064
|
AudioOnly: "audio_only",
|
|
14065
14065
|
Broadcaster: "broadcaster"
|
|
@@ -15672,8 +15672,8 @@ var require_dist = __commonJS({
|
|
|
15672
15672
|
return {
|
|
15673
15673
|
/**
|
|
15674
15674
|
*
|
|
15675
|
-
* @summary Generate
|
|
15676
|
-
* @param {string} roomId
|
|
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
|
|
15707
|
-
* @param {string} roomId
|
|
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
|
|
15725
|
-
* @param {string} roomId
|
|
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
|
|
15734
|
+
var ViewerApi2 = class extends BaseAPI {
|
|
15735
15735
|
/**
|
|
15736
15736
|
*
|
|
15737
|
-
* @summary Generate
|
|
15738
|
-
* @param {string} roomId
|
|
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,13 +15988,15 @@ 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.
|
|
15993
15995
|
*/
|
|
15994
15996
|
async createRoom(config = {}) {
|
|
15995
15997
|
try {
|
|
15996
|
-
const
|
|
15998
|
+
const parsedRoomType = config.roomType == "livestream" ? import_fishjam_openapi.RoomConfigRoomTypeEnum.Broadcaster : config.roomType;
|
|
15999
|
+
const response = await this.roomApi.createRoom({ ...config, roomType: parsedRoomType });
|
|
15997
16000
|
const {
|
|
15998
16001
|
data: {
|
|
15999
16002
|
data: {
|
|
@@ -16079,12 +16082,25 @@ var FishjamClient = class {
|
|
|
16079
16082
|
throw mapException(error, "peer");
|
|
16080
16083
|
}
|
|
16081
16084
|
}
|
|
16085
|
+
/**
|
|
16086
|
+
* Creates a livestream viewer token for the given room.
|
|
16087
|
+
* @returns a livestream viewer token
|
|
16088
|
+
*/
|
|
16089
|
+
async createLivestreamViewerToken(roomId) {
|
|
16090
|
+
try {
|
|
16091
|
+
const tokenResponse = await this.viewerApi.generateToken(roomId);
|
|
16092
|
+
return tokenResponse.data;
|
|
16093
|
+
} catch (error) {
|
|
16094
|
+
throw mapException(error);
|
|
16095
|
+
}
|
|
16096
|
+
}
|
|
16082
16097
|
};
|
|
16083
16098
|
var export_PeerOptions = import_fishjam_openapi2.PeerOptions;
|
|
16084
16099
|
var export_PeerStatus = import_fishjam_openapi2.PeerStatus;
|
|
16085
16100
|
var export_RoomConfig = import_fishjam_openapi2.RoomConfig;
|
|
16086
16101
|
var export_RoomConfigRoomTypeEnum = import_fishjam_openapi2.RoomConfigRoomTypeEnum;
|
|
16087
16102
|
var export_RoomConfigVideoCodecEnum = import_fishjam_openapi2.RoomConfigVideoCodecEnum;
|
|
16103
|
+
var export_ViewerToken = import_fishjam_openapi2.ViewerToken;
|
|
16088
16104
|
export {
|
|
16089
16105
|
BadRequestException,
|
|
16090
16106
|
FishjamBaseException,
|
|
@@ -16101,7 +16117,8 @@ export {
|
|
|
16101
16117
|
RoomNotFoundException,
|
|
16102
16118
|
ServiceUnavailableException,
|
|
16103
16119
|
UnauthorizedException,
|
|
16104
|
-
UnknownException
|
|
16120
|
+
UnknownException,
|
|
16121
|
+
export_ViewerToken as ViewerToken
|
|
16105
16122
|
};
|
|
16106
16123
|
/*! Bundled license information:
|
|
16107
16124
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fishjam-cloud/js-server-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.1",
|
|
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.
|
|
60
|
-
"@fishjam-cloud/fishjam-proto": "0.
|
|
61
|
-
"@openapitools/openapi-generator-cli": "^2.
|
|
62
|
-
"@types/node": "^22.13.
|
|
59
|
+
"@fishjam-cloud/fishjam-openapi": "0.17.1",
|
|
60
|
+
"@fishjam-cloud/fishjam-proto": "0.17.1",
|
|
61
|
+
"@openapitools/openapi-generator-cli": "^2.18.4",
|
|
62
|
+
"@types/node": "^22.13.16",
|
|
63
63
|
"@types/websocket": "^1.0.10",
|
|
64
|
-
"tsup": "^8.
|
|
64
|
+
"tsup": "^8.4.0",
|
|
65
65
|
"typed-emitter": "^2.1.0"
|
|
66
66
|
}
|
|
67
67
|
}
|