@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/{chunk-GFB6IWU4.mjs → chunk-7QSC3SIL.mjs} +1 -1
- package/dist/index.d.mts +166 -94
- package/dist/index.d.ts +166 -94
- package/dist/index.js +263 -42
- package/dist/index.mjs +259 -41
- package/dist/integrations/gemini.js +1 -1
- package/dist/integrations/gemini.mjs +1 -1
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -12,13 +12,13 @@ interface AgentOutput {
|
|
|
12
12
|
* @type {AudioFormat}
|
|
13
13
|
* @memberof AgentOutput
|
|
14
14
|
*/
|
|
15
|
-
|
|
15
|
+
audioFormat?: AudioFormat;
|
|
16
16
|
/**
|
|
17
17
|
*
|
|
18
18
|
* @type {AudioSampleRate}
|
|
19
19
|
* @memberof AgentOutput
|
|
20
20
|
*/
|
|
21
|
-
|
|
21
|
+
audioSampleRate?: AudioSampleRate;
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
24
|
* The format of the output audio
|
|
@@ -28,7 +28,7 @@ interface AgentOutput {
|
|
|
28
28
|
declare const AudioFormat: {
|
|
29
29
|
readonly Pcm16: "pcm16";
|
|
30
30
|
};
|
|
31
|
-
type AudioFormat = typeof AudioFormat[keyof typeof AudioFormat];
|
|
31
|
+
type AudioFormat = (typeof AudioFormat)[keyof typeof AudioFormat];
|
|
32
32
|
/**
|
|
33
33
|
* The sample rate of the output audio
|
|
34
34
|
* @export
|
|
@@ -38,7 +38,7 @@ declare const AudioSampleRate: {
|
|
|
38
38
|
readonly NUMBER_16000: 16000;
|
|
39
39
|
readonly NUMBER_24000: 24000;
|
|
40
40
|
};
|
|
41
|
-
type AudioSampleRate = typeof AudioSampleRate[keyof typeof AudioSampleRate];
|
|
41
|
+
type AudioSampleRate = (typeof AudioSampleRate)[keyof typeof AudioSampleRate];
|
|
42
42
|
/**
|
|
43
43
|
* Token for authorizing a MoQ relay connection
|
|
44
44
|
* @export
|
|
@@ -50,7 +50,7 @@ interface MoqToken {
|
|
|
50
50
|
* @type {string}
|
|
51
51
|
* @memberof MoqToken
|
|
52
52
|
*/
|
|
53
|
-
|
|
53
|
+
token: string;
|
|
54
54
|
}
|
|
55
55
|
/**
|
|
56
56
|
* MoQ token configuration
|
|
@@ -63,13 +63,13 @@ interface MoqTokenConfig {
|
|
|
63
63
|
* @type {string}
|
|
64
64
|
* @memberof MoqTokenConfig
|
|
65
65
|
*/
|
|
66
|
-
|
|
66
|
+
publishPath?: string | null;
|
|
67
67
|
/**
|
|
68
68
|
* Path under the root the token grants subscribe access to
|
|
69
69
|
* @type {string}
|
|
70
70
|
* @memberof MoqTokenConfig
|
|
71
71
|
*/
|
|
72
|
-
|
|
72
|
+
subscribePath?: string | null;
|
|
73
73
|
}
|
|
74
74
|
/**
|
|
75
75
|
* Describes peer status
|
|
@@ -82,43 +82,43 @@ interface Peer$1 {
|
|
|
82
82
|
* @type {string}
|
|
83
83
|
* @memberof Peer
|
|
84
84
|
*/
|
|
85
|
-
|
|
85
|
+
id: string;
|
|
86
86
|
/**
|
|
87
87
|
* Custom metadata set by the peer
|
|
88
88
|
* @type {object}
|
|
89
89
|
* @memberof Peer
|
|
90
90
|
*/
|
|
91
|
-
|
|
91
|
+
metadata: object | null;
|
|
92
92
|
/**
|
|
93
93
|
*
|
|
94
94
|
* @type {PeerStatus}
|
|
95
95
|
* @memberof Peer
|
|
96
96
|
*/
|
|
97
|
-
|
|
97
|
+
status: PeerStatus;
|
|
98
98
|
/**
|
|
99
99
|
*
|
|
100
100
|
* @type {SubscribeMode}
|
|
101
101
|
* @memberof Peer
|
|
102
102
|
*/
|
|
103
|
-
|
|
103
|
+
subscribeMode: SubscribeMode;
|
|
104
104
|
/**
|
|
105
105
|
*
|
|
106
106
|
* @type {Subscriptions}
|
|
107
107
|
* @memberof Peer
|
|
108
108
|
*/
|
|
109
|
-
|
|
109
|
+
subscriptions: Subscriptions;
|
|
110
110
|
/**
|
|
111
111
|
* List of all peer\'s tracks
|
|
112
112
|
* @type {Array<Track>}
|
|
113
113
|
* @memberof Peer
|
|
114
114
|
*/
|
|
115
|
-
|
|
115
|
+
tracks: Array<Track$2>;
|
|
116
116
|
/**
|
|
117
117
|
*
|
|
118
118
|
* @type {PeerType}
|
|
119
119
|
* @memberof Peer
|
|
120
120
|
*/
|
|
121
|
-
|
|
121
|
+
type: PeerType$1;
|
|
122
122
|
}
|
|
123
123
|
/**
|
|
124
124
|
* @type PeerOptions
|
|
@@ -137,13 +137,13 @@ interface PeerOptionsAgent {
|
|
|
137
137
|
* @type {AgentOutput}
|
|
138
138
|
* @memberof PeerOptionsAgent
|
|
139
139
|
*/
|
|
140
|
-
|
|
140
|
+
output?: AgentOutput;
|
|
141
141
|
/**
|
|
142
142
|
*
|
|
143
143
|
* @type {SubscribeMode}
|
|
144
144
|
* @memberof PeerOptionsAgent
|
|
145
145
|
*/
|
|
146
|
-
|
|
146
|
+
subscribeMode?: SubscribeMode;
|
|
147
147
|
}
|
|
148
148
|
/**
|
|
149
149
|
* Options specific to the VAPI peer
|
|
@@ -156,19 +156,19 @@ interface PeerOptionsVapi {
|
|
|
156
156
|
* @type {string}
|
|
157
157
|
* @memberof PeerOptionsVapi
|
|
158
158
|
*/
|
|
159
|
-
|
|
159
|
+
apiKey: string;
|
|
160
160
|
/**
|
|
161
161
|
* VAPI call ID
|
|
162
162
|
* @type {string}
|
|
163
163
|
* @memberof PeerOptionsVapi
|
|
164
164
|
*/
|
|
165
|
-
|
|
165
|
+
callId: string;
|
|
166
166
|
/**
|
|
167
167
|
*
|
|
168
168
|
* @type {SubscribeMode}
|
|
169
169
|
* @memberof PeerOptionsVapi
|
|
170
170
|
*/
|
|
171
|
-
|
|
171
|
+
subscribeMode?: SubscribeMode;
|
|
172
172
|
}
|
|
173
173
|
/**
|
|
174
174
|
* Options specific to the WebRTC peer
|
|
@@ -181,7 +181,7 @@ interface PeerOptionsWebRTC {
|
|
|
181
181
|
* @type {{ [key: string]: any; }}
|
|
182
182
|
* @memberof PeerOptionsWebRTC
|
|
183
183
|
*/
|
|
184
|
-
|
|
184
|
+
metadata?: {
|
|
185
185
|
[key: string]: any;
|
|
186
186
|
};
|
|
187
187
|
/**
|
|
@@ -189,7 +189,7 @@ interface PeerOptionsWebRTC {
|
|
|
189
189
|
* @type {SubscribeMode}
|
|
190
190
|
* @memberof PeerOptionsWebRTC
|
|
191
191
|
*/
|
|
192
|
-
|
|
192
|
+
subscribeMode?: SubscribeMode;
|
|
193
193
|
}
|
|
194
194
|
/**
|
|
195
195
|
* Informs about the peer status
|
|
@@ -200,7 +200,7 @@ declare const PeerStatus: {
|
|
|
200
200
|
readonly Connected: "connected";
|
|
201
201
|
readonly Disconnected: "disconnected";
|
|
202
202
|
};
|
|
203
|
-
type PeerStatus = typeof PeerStatus[keyof typeof PeerStatus];
|
|
203
|
+
type PeerStatus = (typeof PeerStatus)[keyof typeof PeerStatus];
|
|
204
204
|
/**
|
|
205
205
|
* Peer type
|
|
206
206
|
* @export
|
|
@@ -211,7 +211,7 @@ declare const PeerType$1: {
|
|
|
211
211
|
readonly Agent: "agent";
|
|
212
212
|
readonly Vapi: "vapi";
|
|
213
213
|
};
|
|
214
|
-
type PeerType$1 = typeof PeerType$1[keyof typeof PeerType$1];
|
|
214
|
+
type PeerType$1 = (typeof PeerType$1)[keyof typeof PeerType$1];
|
|
215
215
|
/**
|
|
216
216
|
* Room configuration
|
|
217
217
|
* @export
|
|
@@ -223,37 +223,37 @@ interface RoomConfig {
|
|
|
223
223
|
* @type {boolean}
|
|
224
224
|
* @memberof RoomConfig
|
|
225
225
|
*/
|
|
226
|
-
|
|
226
|
+
batchWebhookNotifications?: boolean;
|
|
227
227
|
/**
|
|
228
228
|
* Maximum amount of peers allowed into the room
|
|
229
229
|
* @type {number}
|
|
230
230
|
* @memberof RoomConfig
|
|
231
231
|
*/
|
|
232
|
-
|
|
232
|
+
maxPeers?: number | null;
|
|
233
233
|
/**
|
|
234
234
|
* True if livestream viewers can omit specifying a token.
|
|
235
235
|
* @type {boolean}
|
|
236
236
|
* @memberof RoomConfig
|
|
237
237
|
*/
|
|
238
|
-
|
|
238
|
+
public?: boolean;
|
|
239
239
|
/**
|
|
240
240
|
*
|
|
241
241
|
* @type {RoomType}
|
|
242
242
|
* @memberof RoomConfig
|
|
243
243
|
*/
|
|
244
|
-
|
|
244
|
+
roomType?: RoomType;
|
|
245
245
|
/**
|
|
246
246
|
*
|
|
247
247
|
* @type {VideoCodec}
|
|
248
248
|
* @memberof RoomConfig
|
|
249
249
|
*/
|
|
250
|
-
|
|
250
|
+
videoCodec?: VideoCodec;
|
|
251
251
|
/**
|
|
252
252
|
* URL where Fishjam notifications will be sent
|
|
253
253
|
* @type {string}
|
|
254
254
|
* @memberof RoomConfig
|
|
255
255
|
*/
|
|
256
|
-
|
|
256
|
+
webhookUrl?: string | null;
|
|
257
257
|
}
|
|
258
258
|
/**
|
|
259
259
|
* The use-case of the room. If not provided, this defaults to conference.
|
|
@@ -268,7 +268,7 @@ declare const RoomType: {
|
|
|
268
268
|
readonly Conference: "conference";
|
|
269
269
|
readonly AudioOnlyLivestream: "audio_only_livestream";
|
|
270
270
|
};
|
|
271
|
-
type RoomType = typeof RoomType[keyof typeof RoomType];
|
|
271
|
+
type RoomType = (typeof RoomType)[keyof typeof RoomType];
|
|
272
272
|
/**
|
|
273
273
|
* Streamer authorization token
|
|
274
274
|
* @export
|
|
@@ -280,7 +280,7 @@ interface StreamerToken {
|
|
|
280
280
|
* @type {string}
|
|
281
281
|
* @memberof StreamerToken
|
|
282
282
|
*/
|
|
283
|
-
|
|
283
|
+
token: string;
|
|
284
284
|
}
|
|
285
285
|
/**
|
|
286
286
|
* Configuration of peer\'s subscribing policy
|
|
@@ -291,7 +291,7 @@ declare const SubscribeMode: {
|
|
|
291
291
|
readonly Auto: "auto";
|
|
292
292
|
readonly Manual: "manual";
|
|
293
293
|
};
|
|
294
|
-
type SubscribeMode = typeof SubscribeMode[keyof typeof SubscribeMode];
|
|
294
|
+
type SubscribeMode = (typeof SubscribeMode)[keyof typeof SubscribeMode];
|
|
295
295
|
/**
|
|
296
296
|
* Describes peer\'s subscriptions in manual mode
|
|
297
297
|
* @export
|
|
@@ -303,13 +303,13 @@ interface Subscriptions {
|
|
|
303
303
|
* @type {Array<string>}
|
|
304
304
|
* @memberof Subscriptions
|
|
305
305
|
*/
|
|
306
|
-
|
|
306
|
+
peers: Array<string>;
|
|
307
307
|
/**
|
|
308
308
|
* List of track IDs this peer subscribes to
|
|
309
309
|
* @type {Array<string>}
|
|
310
310
|
* @memberof Subscriptions
|
|
311
311
|
*/
|
|
312
|
-
|
|
312
|
+
tracks: Array<string>;
|
|
313
313
|
}
|
|
314
314
|
/**
|
|
315
315
|
* Media track of a Peer
|
|
@@ -322,19 +322,19 @@ interface Track$2 {
|
|
|
322
322
|
* @type {string}
|
|
323
323
|
* @memberof Track
|
|
324
324
|
*/
|
|
325
|
-
|
|
325
|
+
id?: string;
|
|
326
326
|
/**
|
|
327
327
|
* Metadata attached to the track by the peer
|
|
328
328
|
* @type {object}
|
|
329
329
|
* @memberof Track
|
|
330
330
|
*/
|
|
331
|
-
|
|
331
|
+
metadata?: object | null;
|
|
332
332
|
/**
|
|
333
333
|
*
|
|
334
334
|
* @type {TrackType}
|
|
335
335
|
* @memberof Track
|
|
336
336
|
*/
|
|
337
|
-
|
|
337
|
+
type?: TrackType$2;
|
|
338
338
|
}
|
|
339
339
|
/**
|
|
340
340
|
* Media type carried by the track
|
|
@@ -345,7 +345,7 @@ declare const TrackType$2: {
|
|
|
345
345
|
readonly Audio: "audio";
|
|
346
346
|
readonly Video: "video";
|
|
347
347
|
};
|
|
348
|
-
type TrackType$2 = typeof TrackType$2[keyof typeof TrackType$2];
|
|
348
|
+
type TrackType$2 = (typeof TrackType$2)[keyof typeof TrackType$2];
|
|
349
349
|
/**
|
|
350
350
|
* Enforces video codec for each peer in the room
|
|
351
351
|
* @export
|
|
@@ -355,7 +355,7 @@ declare const VideoCodec: {
|
|
|
355
355
|
readonly H264: "h264";
|
|
356
356
|
readonly Vp8: "vp8";
|
|
357
357
|
};
|
|
358
|
-
type VideoCodec = typeof VideoCodec[keyof typeof VideoCodec];
|
|
358
|
+
type VideoCodec = (typeof VideoCodec)[keyof typeof VideoCodec];
|
|
359
359
|
/**
|
|
360
360
|
* Viewer authorization token
|
|
361
361
|
* @export
|
|
@@ -367,7 +367,7 @@ interface ViewerToken {
|
|
|
367
367
|
* @type {string}
|
|
368
368
|
* @memberof ViewerToken
|
|
369
369
|
*/
|
|
370
|
-
|
|
370
|
+
token: string;
|
|
371
371
|
}
|
|
372
372
|
|
|
373
373
|
/** Defines types of tracks being published by peers and component */
|
|
@@ -797,6 +797,21 @@ declare const brand: unique symbol;
|
|
|
797
797
|
type Brand<T, TBrand extends string> = T & {
|
|
798
798
|
[brand]: TBrand;
|
|
799
799
|
};
|
|
800
|
+
/**
|
|
801
|
+
* Replaces the types of fields in `T` whose names appear in `M`, leaving the rest untouched.
|
|
802
|
+
* Produces a flat object type (single mapped type, no `Omit & {...}` chain) so editor hover
|
|
803
|
+
* displays the resulting properties directly.
|
|
804
|
+
*
|
|
805
|
+
* Keys present in `M` but not in `T` are ignored — only fields that already exist on `T`
|
|
806
|
+
* are overridden, so a shared override map can be reused across multiple source types.
|
|
807
|
+
*
|
|
808
|
+
* `undefined` is re-added to the override when the original field allowed it, so optional
|
|
809
|
+
* fields on generated proto types (e.g. `peerId?: string | undefined`) remain assignable
|
|
810
|
+
* from `undefined` under `exactOptionalPropertyTypes`.
|
|
811
|
+
*/
|
|
812
|
+
type Override<T, M> = {
|
|
813
|
+
[K in keyof T]: K extends keyof M ? (undefined extends T[K] ? M[K] | undefined : M[K]) : T[K];
|
|
814
|
+
};
|
|
800
815
|
/**
|
|
801
816
|
* ID of the Room.
|
|
802
817
|
* Room can be created with {@link FishjamClient.createRoom}.
|
|
@@ -806,9 +821,9 @@ type RoomId = Brand<string, 'RoomId'>;
|
|
|
806
821
|
* ID of Peer. Peer is associated with Room and can be created with {@link FishjamClient.createPeer}.
|
|
807
822
|
*/
|
|
808
823
|
type PeerId = Brand<string, 'PeerId'>;
|
|
809
|
-
type Peer =
|
|
824
|
+
type Peer = Override<Peer$1, {
|
|
810
825
|
id: PeerId;
|
|
811
|
-
}
|
|
826
|
+
}>;
|
|
812
827
|
/**
|
|
813
828
|
* Peer type as emitted by {@link FishjamWSNotifier}. Matches the REST API's `PeerType`,
|
|
814
829
|
* with the addition of `'unspecified'` for messages whose peer type is not set on the wire.
|
|
@@ -835,21 +850,6 @@ type AgentCallbacks = {
|
|
|
835
850
|
onClose?: CloseEventHandler;
|
|
836
851
|
};
|
|
837
852
|
|
|
838
|
-
type WithRoomId<T> = {
|
|
839
|
-
[P in keyof T]: NonNullable<T[P]> extends {
|
|
840
|
-
roomId: string;
|
|
841
|
-
} ? Omit<NonNullable<T[P]>, 'roomId'> & {
|
|
842
|
-
roomId: RoomId;
|
|
843
|
-
} : T[P];
|
|
844
|
-
};
|
|
845
|
-
type WithPeerId<T> = {
|
|
846
|
-
[P in keyof T]: NonNullable<T[P]> extends {
|
|
847
|
-
peerId: string;
|
|
848
|
-
} ? Omit<NonNullable<T[P]>, 'peerId'> & {
|
|
849
|
-
peerId: PeerId;
|
|
850
|
-
} : T[P];
|
|
851
|
-
};
|
|
852
|
-
|
|
853
853
|
/**
|
|
854
854
|
* Track payload embedded in {@link TrackAdded}, {@link TrackRemoved}, {@link TrackMetadataUpdated}.
|
|
855
855
|
*/
|
|
@@ -868,39 +868,42 @@ type ExpectedEvents = (typeof expectedEventsList$1)[number];
|
|
|
868
868
|
declare const ignoredEventsList: readonly ["authenticated", "authRequest", "subscribeRequest", "subscribeResponse", "trackForwarding", "trackForwardingRemoved", "vadNotification", "notificationBatch", "streamConnected", "streamDisconnected", "hlsPlayable", "hlsUploaded", "hlsUploadCrashed", "componentCrashed"];
|
|
869
869
|
type IgnoredEvents = (typeof ignoredEventsList)[number];
|
|
870
870
|
/**
|
|
871
|
+
* Field-level overrides applied to every notification payload: branded ID types
|
|
872
|
+
* and the user-facing enums replace their raw protobuf counterparts. {@link Override}
|
|
873
|
+
* only swaps keys that exist on the source type, so a single map covers all variants.
|
|
874
|
+
*
|
|
871
875
|
* @inline
|
|
872
876
|
*/
|
|
873
|
-
type
|
|
874
|
-
|
|
875
|
-
|
|
877
|
+
type NotificationOverrides = {
|
|
878
|
+
roomId: RoomId;
|
|
879
|
+
peerId: PeerId;
|
|
876
880
|
peerType: PeerType;
|
|
877
|
-
};
|
|
878
|
-
/** @inline */
|
|
879
|
-
type WithMappedTrack<T> = Omit<T, 'track'> & {
|
|
880
881
|
track: Track | undefined;
|
|
881
882
|
};
|
|
883
|
+
/** @inline */
|
|
884
|
+
type Notification<K extends keyof ServerMessage> = Override<NonNullable<ServerMessage[K]>, NotificationOverrides>;
|
|
882
885
|
/**
|
|
883
886
|
* @inline
|
|
884
887
|
*/
|
|
885
888
|
type Notifications = {
|
|
886
|
-
roomCreated:
|
|
887
|
-
roomDeleted:
|
|
888
|
-
roomCrashed:
|
|
889
|
-
peerAdded:
|
|
890
|
-
peerDeleted:
|
|
891
|
-
peerConnected:
|
|
892
|
-
peerDisconnected:
|
|
893
|
-
peerMetadataUpdated:
|
|
894
|
-
peerCrashed:
|
|
895
|
-
streamerConnected:
|
|
896
|
-
streamerDisconnected:
|
|
897
|
-
viewerConnected:
|
|
898
|
-
viewerDisconnected:
|
|
899
|
-
trackAdded:
|
|
900
|
-
trackRemoved:
|
|
901
|
-
trackMetadataUpdated:
|
|
902
|
-
channelAdded:
|
|
903
|
-
channelRemoved:
|
|
889
|
+
roomCreated: Notification<'roomCreated'>;
|
|
890
|
+
roomDeleted: Notification<'roomDeleted'>;
|
|
891
|
+
roomCrashed: Notification<'roomCrashed'>;
|
|
892
|
+
peerAdded: Notification<'peerAdded'>;
|
|
893
|
+
peerDeleted: Notification<'peerDeleted'>;
|
|
894
|
+
peerConnected: Notification<'peerConnected'>;
|
|
895
|
+
peerDisconnected: Notification<'peerDisconnected'>;
|
|
896
|
+
peerMetadataUpdated: Notification<'peerMetadataUpdated'>;
|
|
897
|
+
peerCrashed: Notification<'peerCrashed'>;
|
|
898
|
+
streamerConnected: Notification<'streamerConnected'>;
|
|
899
|
+
streamerDisconnected: Notification<'streamerDisconnected'>;
|
|
900
|
+
viewerConnected: Notification<'viewerConnected'>;
|
|
901
|
+
viewerDisconnected: Notification<'viewerDisconnected'>;
|
|
902
|
+
trackAdded: Notification<'trackAdded'>;
|
|
903
|
+
trackRemoved: Notification<'trackRemoved'>;
|
|
904
|
+
trackMetadataUpdated: Notification<'trackMetadataUpdated'>;
|
|
905
|
+
channelAdded: Notification<'channelAdded'>;
|
|
906
|
+
channelRemoved: Notification<'channelRemoved'>;
|
|
904
907
|
};
|
|
905
908
|
type RoomCreated = Notifications['roomCreated'];
|
|
906
909
|
type RoomDeleted = Notifications['roomDeleted'];
|
|
@@ -923,6 +926,17 @@ type ChannelRemoved = Notifications['channelRemoved'];
|
|
|
923
926
|
type NotificationEvents = {
|
|
924
927
|
[K in ExpectedEvents]: (message: Notifications[K]) => void;
|
|
925
928
|
};
|
|
929
|
+
/**
|
|
930
|
+
* A single decoded, mapped server notification tagged with its event type.
|
|
931
|
+
* The discriminated `type` lets consumers narrow `notification` to the matching
|
|
932
|
+
* payload (e.g. `if (n.type === 'peerConnected') n.notification.peerType`).
|
|
933
|
+
*/
|
|
934
|
+
type ServerNotification = {
|
|
935
|
+
[K in ExpectedEvents]: {
|
|
936
|
+
type: K;
|
|
937
|
+
notification: Notifications[K];
|
|
938
|
+
};
|
|
939
|
+
}[ExpectedEvents];
|
|
926
940
|
|
|
927
941
|
declare const FishjamWSNotifier_base: new () => TypedEventEmitter<NotificationEvents>;
|
|
928
942
|
/**
|
|
@@ -934,36 +948,62 @@ declare class FishjamWSNotifier extends FishjamWSNotifier_base {
|
|
|
934
948
|
constructor(config: FishjamConfig, onError: ErrorEventHandler, onClose: CloseEventHandler);
|
|
935
949
|
private dispatchNotification;
|
|
936
950
|
private setupConnection;
|
|
937
|
-
private isExpectedEvent;
|
|
938
951
|
}
|
|
939
952
|
|
|
953
|
+
/**
|
|
954
|
+
* Decode a raw Fishjam webhook body (`application/x-protobuf`) into typed,
|
|
955
|
+
* mapped notifications.
|
|
956
|
+
*
|
|
957
|
+
* A room/stream created with `batchWebhookNotifications: true` may deliver
|
|
958
|
+
* several notifications coalesced into a single `NotificationBatch`; this helper
|
|
959
|
+
* transparently unwraps that batch, so a single message and a batch are handled
|
|
960
|
+
* the same way. Notifications are returned in wire order, with the same payload
|
|
961
|
+
* mapping the {@link FishjamWSNotifier} applies (branded ids, `peerType`/`track`
|
|
962
|
+
* enums). Non-surfaced variants (handshake, deprecated) are omitted.
|
|
963
|
+
*
|
|
964
|
+
* Accepts a Node `Buffer` (a `Uint8Array` subclass), a `Uint8Array`, or an
|
|
965
|
+
* `ArrayBuffer`.
|
|
966
|
+
*
|
|
967
|
+
* @example
|
|
968
|
+
* ```ts
|
|
969
|
+
* import { decodeServerNotifications } from '@fishjam-cloud/js-server-sdk';
|
|
970
|
+
*
|
|
971
|
+
* declare const body: Uint8Array;
|
|
972
|
+
* declare const handlePeerConnected: (notification: unknown) => void;
|
|
973
|
+
* // ---cut---
|
|
974
|
+
* for (const { type, notification } of decodeServerNotifications(body)) {
|
|
975
|
+
* if (type === 'peerConnected') handlePeerConnected(notification);
|
|
976
|
+
* }
|
|
977
|
+
* ```
|
|
978
|
+
* @category Notifications
|
|
979
|
+
*/
|
|
980
|
+
declare const decodeServerNotifications: (data: Uint8Array | ArrayBuffer) => ServerNotification[];
|
|
981
|
+
|
|
940
982
|
declare const expectedEventsList: readonly ["trackData"];
|
|
941
983
|
/**
|
|
942
984
|
* @useDeclaredType
|
|
943
985
|
*/
|
|
944
986
|
type ExpectedAgentEvents = (typeof expectedEventsList)[number];
|
|
945
|
-
type IncomingTrackData =
|
|
987
|
+
type IncomingTrackData = Override<NonNullable<AgentResponse_TrackData>, {
|
|
946
988
|
peerId: PeerId;
|
|
947
|
-
}
|
|
989
|
+
}>;
|
|
948
990
|
type IncomingTrackImage = NonNullable<AgentResponse_TrackImage>;
|
|
949
|
-
type OutgoingTrackData =
|
|
991
|
+
type OutgoingTrackData = Override<NonNullable<AgentRequest_TrackData>, {
|
|
950
992
|
peerId: PeerId;
|
|
951
|
-
}
|
|
952
|
-
type AgentTrack =
|
|
993
|
+
}>;
|
|
994
|
+
type AgentTrack = Override<Track$1, {
|
|
953
995
|
id: TrackId;
|
|
954
|
-
}
|
|
996
|
+
}>;
|
|
955
997
|
type AudioCodecParameters = {
|
|
956
998
|
encoding: 'opus' | 'pcm16';
|
|
957
999
|
sampleRate: 16000 | 24000 | 48000;
|
|
958
1000
|
channels: 1;
|
|
959
1001
|
};
|
|
960
1002
|
type TrackId = Brand<string, 'TrackId'>;
|
|
961
|
-
/**
|
|
962
|
-
* @inline
|
|
963
|
-
*/
|
|
964
|
-
type ResponseWithPeerId = WithPeerId<AgentResponse>;
|
|
965
1003
|
type AgentEvents = {
|
|
966
|
-
[K in ExpectedAgentEvents]: (message: NonNullable<
|
|
1004
|
+
[K in ExpectedAgentEvents]: (message: Override<NonNullable<AgentResponse[K]>, {
|
|
1005
|
+
peerId: PeerId;
|
|
1006
|
+
}>) => void;
|
|
967
1007
|
};
|
|
968
1008
|
declare const FishjamAgent_base: new () => TypedEventEmitter<AgentEvents>;
|
|
969
1009
|
declare class FishjamAgent extends FishjamAgent_base {
|
|
@@ -1023,11 +1063,16 @@ declare class FishjamClient {
|
|
|
1023
1063
|
private readonly roomApi;
|
|
1024
1064
|
private readonly viewerApi;
|
|
1025
1065
|
private readonly streamerApi;
|
|
1066
|
+
private readonly credentialsApi;
|
|
1026
1067
|
private readonly fishjamConfig;
|
|
1027
1068
|
private deprecationWarningShown;
|
|
1028
1069
|
/**
|
|
1029
1070
|
* Create new instance of Fishjam Client.
|
|
1030
1071
|
*
|
|
1072
|
+
* Does not verify credentials against the backend — use
|
|
1073
|
+
* {@link FishjamClient.create} or call
|
|
1074
|
+
* {@link FishjamClient.checkCredentials} afterwards for that.
|
|
1075
|
+
*
|
|
1031
1076
|
* Example usage:
|
|
1032
1077
|
* ```
|
|
1033
1078
|
* const fishjamClient = new FishjamClient({
|
|
@@ -1037,6 +1082,29 @@ declare class FishjamClient {
|
|
|
1037
1082
|
* ```
|
|
1038
1083
|
*/
|
|
1039
1084
|
constructor(config: FishjamConfig);
|
|
1085
|
+
/**
|
|
1086
|
+
* Async factory: constructs a client and verifies credentials against
|
|
1087
|
+
* the backend.
|
|
1088
|
+
*
|
|
1089
|
+
* Throws {@link InvalidFishjamCredentialsException} when the
|
|
1090
|
+
* `fishjamId` / `managementToken` pair is rejected by the backend.
|
|
1091
|
+
*
|
|
1092
|
+
* Example:
|
|
1093
|
+
* ```
|
|
1094
|
+
* const client = await FishjamClient.create({
|
|
1095
|
+
* fishjamId: process.env.FISHJAM_ID!,
|
|
1096
|
+
* managementToken: process.env.FISHJAM_MANAGEMENT_TOKEN!,
|
|
1097
|
+
* });
|
|
1098
|
+
* ```
|
|
1099
|
+
*/
|
|
1100
|
+
static create(config: FishjamConfig): Promise<FishjamClient>;
|
|
1101
|
+
/**
|
|
1102
|
+
* Verifies the configured credentials by making a single lightweight
|
|
1103
|
+
* call to the Fishjam backend. Resolves on success, throws
|
|
1104
|
+
* {@link InvalidFishjamCredentialsException} on 401/404 from the backend,
|
|
1105
|
+
* otherwise rethrows the standard mapped exception.
|
|
1106
|
+
*/
|
|
1107
|
+
checkCredentials(): Promise<void>;
|
|
1040
1108
|
private handleDeprecationHeader;
|
|
1041
1109
|
/**
|
|
1042
1110
|
* Create a new room. All peers connected to the same room will be able to send/receive streams to each other.
|
|
@@ -1130,11 +1198,15 @@ declare class RoomNotFoundException extends FishjamBaseException {
|
|
|
1130
1198
|
}
|
|
1131
1199
|
declare class FishjamNotFoundException extends FishjamBaseException {
|
|
1132
1200
|
}
|
|
1201
|
+
declare class InvalidFishjamCredentialsException extends FishjamBaseException {
|
|
1202
|
+
}
|
|
1133
1203
|
declare class PeerNotFoundException extends FishjamBaseException {
|
|
1134
1204
|
}
|
|
1135
1205
|
declare class ServiceUnavailableException extends FishjamBaseException {
|
|
1136
1206
|
}
|
|
1207
|
+
declare class QuotaExceededException extends FishjamBaseException {
|
|
1208
|
+
}
|
|
1137
1209
|
declare class UnknownException extends FishjamBaseException {
|
|
1138
1210
|
}
|
|
1139
1211
|
|
|
1140
|
-
export { type AgentCallbacks, type AgentEvents, type AgentTrack, type AudioCodecParameters, BadRequestException, type Brand, type ChannelAdded, type ChannelRemoved, type CloseEventHandler, type ErrorEventHandler, type ExpectedAgentEvents, type ExpectedEvents, FishjamAgent, FishjamBaseException, FishjamClient, type FishjamConfig, FishjamNotFoundException, FishjamWSNotifier, ForbiddenException, type IgnoredEvents, type IncomingTrackData, type IncomingTrackImage, MissingFishjamIdException, type MoqToken, type MoqTokenConfig, type NotificationEvents, type OutgoingTrackData, type Peer, type PeerAdded, type PeerConnected, type PeerCrashed, type PeerDeleted, type PeerDisconnected, type PeerId, type PeerMetadataUpdated, PeerNotFoundException, type PeerOptions, type PeerOptionsAgent, type PeerOptionsVapi, type PeerOptionsWebRTC, PeerStatus, type PeerType, type Room, type RoomConfig, type RoomCrashed, type RoomCreated, type RoomDeleted, type RoomId, RoomNotFoundException, RoomType, ServerMessage, ServiceUnavailableException, type StreamerConnected, type StreamerDisconnected, type StreamerToken, type Track, type TrackAdded, type TrackId, type TrackMetadataUpdated, type TrackRemoved, type TrackType, UnauthorizedException, UnknownException, VideoCodec, type ViewerConnected, type ViewerDisconnected, type ViewerToken };
|
|
1212
|
+
export { type AgentCallbacks, type AgentEvents, type AgentTrack, type AudioCodecParameters, BadRequestException, type Brand, type ChannelAdded, type ChannelRemoved, type CloseEventHandler, type ErrorEventHandler, type ExpectedAgentEvents, type ExpectedEvents, FishjamAgent, FishjamBaseException, FishjamClient, type FishjamConfig, FishjamNotFoundException, FishjamWSNotifier, ForbiddenException, type IgnoredEvents, type IncomingTrackData, type IncomingTrackImage, InvalidFishjamCredentialsException, MissingFishjamIdException, type MoqToken, type MoqTokenConfig, type NotificationEvents, type OutgoingTrackData, type Override, type Peer, type PeerAdded, type PeerConnected, type PeerCrashed, type PeerDeleted, type PeerDisconnected, type PeerId, type PeerMetadataUpdated, PeerNotFoundException, type PeerOptions, type PeerOptionsAgent, type PeerOptionsVapi, type PeerOptionsWebRTC, PeerStatus, type PeerType, QuotaExceededException, type Room, type RoomConfig, type RoomCrashed, type RoomCreated, type RoomDeleted, type RoomId, RoomNotFoundException, RoomType, ServerMessage, type ServerNotification, ServiceUnavailableException, type StreamerConnected, type StreamerDisconnected, type StreamerToken, type Track, type TrackAdded, type TrackId, type TrackMetadataUpdated, type TrackRemoved, type TrackType, UnauthorizedException, UnknownException, VideoCodec, type ViewerConnected, type ViewerDisconnected, type ViewerToken, decodeServerNotifications };
|