livekit-server-sdk 2.6.2 → 2.7.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/AccessToken.d.ts +2 -2
- package/dist/AccessToken.js +2 -2
- package/dist/EgressClient.d.ts +27 -27
- package/dist/EgressClient.d.ts.map +1 -1
- package/dist/EgressClient.js +23 -19
- package/dist/EgressClient.js.map +1 -1
- package/dist/IngressClient.d.ts +13 -12
- package/dist/IngressClient.d.ts.map +1 -1
- package/dist/IngressClient.js +11 -11
- package/dist/IngressClient.js.map +1 -1
- package/dist/RoomServiceClient.d.ts +24 -24
- package/dist/RoomServiceClient.js +16 -16
- package/dist/ServiceBase.d.ts +5 -5
- package/dist/ServiceBase.d.ts.map +1 -1
- package/dist/ServiceBase.js +3 -3
- package/dist/SipClient.d.ts +28 -22
- package/dist/SipClient.d.ts.map +1 -1
- package/dist/SipClient.js +36 -23
- package/dist/SipClient.js.map +1 -1
- package/dist/TwirpRPC.d.ts.map +1 -1
- package/dist/TwirpRPC.js +1 -0
- package/dist/TwirpRPC.js.map +1 -1
- package/dist/WebhookReceiver.d.ts +4 -5
- package/dist/WebhookReceiver.d.ts.map +1 -1
- package/dist/WebhookReceiver.js +3 -4
- package/dist/WebhookReceiver.js.map +1 -1
- package/dist/grants.d.ts.map +1 -1
- package/dist/grants.js +1 -0
- package/dist/grants.js.map +1 -1
- package/package.json +2 -2
- package/src/AccessToken.ts +2 -2
- package/src/EgressClient.ts +32 -28
- package/src/IngressClient.ts +17 -15
- package/src/RoomServiceClient.ts +24 -24
- package/src/ServiceBase.ts +5 -5
- package/src/SipClient.ts +49 -23
- package/src/TwirpRPC.ts +2 -0
- package/src/WebhookReceiver.ts +4 -5
- package/src/grants.test.ts +2 -1
- package/src/grants.ts +1 -0
package/src/IngressClient.ts
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: 2024 LiveKit, Inc.
|
|
2
2
|
//
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
import type { IngressAudioOptions, IngressInput, IngressVideoOptions } from '@livekit/protocol';
|
|
4
5
|
import {
|
|
5
6
|
CreateIngressRequest,
|
|
6
7
|
DeleteIngressRequest,
|
|
7
|
-
IngressAudioOptions,
|
|
8
8
|
IngressInfo,
|
|
9
|
-
IngressInput,
|
|
10
|
-
IngressVideoOptions,
|
|
11
9
|
ListIngressRequest,
|
|
12
10
|
ListIngressResponse,
|
|
13
11
|
UpdateIngressRequest,
|
|
14
12
|
} from '@livekit/protocol';
|
|
15
13
|
import ServiceBase from './ServiceBase.js';
|
|
16
|
-
import { Rpc
|
|
14
|
+
import type { Rpc } from './TwirpRPC.js';
|
|
15
|
+
import { TwirpRpc, livekitPackage } from './TwirpRPC.js';
|
|
17
16
|
|
|
18
17
|
const svc = 'Ingress';
|
|
19
18
|
|
|
@@ -122,9 +121,9 @@ export class IngressClient extends ServiceBase {
|
|
|
122
121
|
private readonly rpc: Rpc;
|
|
123
122
|
|
|
124
123
|
/**
|
|
125
|
-
* @param host hostname including protocol. i.e. 'https://cluster.livekit.io'
|
|
126
|
-
* @param apiKey API Key, can be set in env var LIVEKIT_API_KEY
|
|
127
|
-
* @param secret API Secret, can be set in env var LIVEKIT_API_SECRET
|
|
124
|
+
* @param host - hostname including protocol. i.e. 'https://cluster.livekit.io'
|
|
125
|
+
* @param apiKey - API Key, can be set in env var LIVEKIT_API_KEY
|
|
126
|
+
* @param secret - API Secret, can be set in env var LIVEKIT_API_SECRET
|
|
128
127
|
*/
|
|
129
128
|
constructor(host: string, apiKey?: string, secret?: string) {
|
|
130
129
|
super(apiKey, secret);
|
|
@@ -132,8 +131,8 @@ export class IngressClient extends ServiceBase {
|
|
|
132
131
|
}
|
|
133
132
|
|
|
134
133
|
/**
|
|
135
|
-
* @param inputType protocol for the ingress
|
|
136
|
-
* @param opts CreateIngressOptions
|
|
134
|
+
* @param inputType - protocol for the ingress
|
|
135
|
+
* @param opts - CreateIngressOptions
|
|
137
136
|
*/
|
|
138
137
|
async createIngress(inputType: IngressInput, opts?: CreateIngressOptions): Promise<IngressInfo> {
|
|
139
138
|
let name: string = '';
|
|
@@ -184,8 +183,8 @@ export class IngressClient extends ServiceBase {
|
|
|
184
183
|
}
|
|
185
184
|
|
|
186
185
|
/**
|
|
187
|
-
* @param ingressId ID of the ingress to update
|
|
188
|
-
* @param opts UpdateIngressOptions
|
|
186
|
+
* @param ingressId - ID of the ingress to update
|
|
187
|
+
* @param opts - UpdateIngressOptions
|
|
189
188
|
*/
|
|
190
189
|
async updateIngress(ingressId: string, opts: UpdateIngressOptions): Promise<IngressInfo> {
|
|
191
190
|
const name: string = opts.name || '';
|
|
@@ -218,14 +217,17 @@ export class IngressClient extends ServiceBase {
|
|
|
218
217
|
}
|
|
219
218
|
|
|
220
219
|
/**
|
|
221
|
-
* @deprecated use listIngress(opts) instead
|
|
222
|
-
* @param roomName list ingress for one room only
|
|
220
|
+
* @deprecated use `listIngress(opts)` or `listIngress(arg)` instead
|
|
221
|
+
* @param roomName - list ingress for one room only
|
|
223
222
|
*/
|
|
224
223
|
async listIngress(roomName?: string): Promise<Array<IngressInfo>>;
|
|
225
224
|
/**
|
|
226
|
-
* @param opts list options
|
|
225
|
+
* @param opts - list options
|
|
227
226
|
*/
|
|
228
227
|
async listIngress(opts?: ListIngressOptions): Promise<Array<IngressInfo>>;
|
|
228
|
+
/**
|
|
229
|
+
* @param arg - list room name or options
|
|
230
|
+
*/
|
|
229
231
|
async listIngress(arg?: string | ListIngressOptions): Promise<Array<IngressInfo>> {
|
|
230
232
|
let req: Partial<ListIngressRequest> = {};
|
|
231
233
|
if (typeof arg === 'string') {
|
|
@@ -243,7 +245,7 @@ export class IngressClient extends ServiceBase {
|
|
|
243
245
|
}
|
|
244
246
|
|
|
245
247
|
/**
|
|
246
|
-
* @param ingressId ingress to delete
|
|
248
|
+
* @param ingressId - ingress to delete
|
|
247
249
|
*/
|
|
248
250
|
async deleteIngress(ingressId: string): Promise<IngressInfo> {
|
|
249
251
|
const data = await this.rpc.request(
|
package/src/RoomServiceClient.ts
CHANGED
|
@@ -122,7 +122,7 @@ export class RoomServiceClient extends ServiceBase {
|
|
|
122
122
|
* Creates a new room. Explicit room creation is not required, since rooms will
|
|
123
123
|
* be automatically created when the first participant joins. This method can be
|
|
124
124
|
* used to customize room settings.
|
|
125
|
-
* @param options
|
|
125
|
+
* @param options -
|
|
126
126
|
*/
|
|
127
127
|
async createRoom(options: CreateOptions): Promise<Room> {
|
|
128
128
|
const data = await this.rpc.request(
|
|
@@ -162,8 +162,8 @@ export class RoomServiceClient extends ServiceBase {
|
|
|
162
162
|
|
|
163
163
|
/**
|
|
164
164
|
* Update metadata of a room
|
|
165
|
-
* @param room name of the room
|
|
166
|
-
* @param metadata the new metadata for the room
|
|
165
|
+
* @param room - name of the room
|
|
166
|
+
* @param metadata - the new metadata for the room
|
|
167
167
|
*/
|
|
168
168
|
async updateRoomMetadata(room: string, metadata: string) {
|
|
169
169
|
const data = await this.rpc.request(
|
|
@@ -177,7 +177,7 @@ export class RoomServiceClient extends ServiceBase {
|
|
|
177
177
|
|
|
178
178
|
/**
|
|
179
179
|
* List participants in a room
|
|
180
|
-
* @param room name of the room
|
|
180
|
+
* @param room - name of the room
|
|
181
181
|
*/
|
|
182
182
|
async listParticipants(room: string): Promise<ParticipantInfo[]> {
|
|
183
183
|
const data = await this.rpc.request(
|
|
@@ -193,8 +193,8 @@ export class RoomServiceClient extends ServiceBase {
|
|
|
193
193
|
/**
|
|
194
194
|
* Get information on a specific participant, including the tracks that participant
|
|
195
195
|
* has published
|
|
196
|
-
* @param room name of the room
|
|
197
|
-
* @param identity identity of the participant to return
|
|
196
|
+
* @param room - name of the room
|
|
197
|
+
* @param identity - identity of the participant to return
|
|
198
198
|
*/
|
|
199
199
|
async getParticipant(room: string, identity: string): Promise<ParticipantInfo> {
|
|
200
200
|
const data = await this.rpc.request(
|
|
@@ -211,8 +211,8 @@ export class RoomServiceClient extends ServiceBase {
|
|
|
211
211
|
* Removes a participant in the room. This will disconnect the participant
|
|
212
212
|
* and will emit a Disconnected event for that participant.
|
|
213
213
|
* Even after being removed, the participant can still re-join the room.
|
|
214
|
-
* @param room
|
|
215
|
-
* @param identity
|
|
214
|
+
* @param room -
|
|
215
|
+
* @param identity -
|
|
216
216
|
*/
|
|
217
217
|
async removeParticipant(room: string, identity: string): Promise<void> {
|
|
218
218
|
await this.rpc.request(
|
|
@@ -225,10 +225,10 @@ export class RoomServiceClient extends ServiceBase {
|
|
|
225
225
|
|
|
226
226
|
/**
|
|
227
227
|
* Mutes a track that the participant has published.
|
|
228
|
-
* @param room
|
|
229
|
-
* @param identity
|
|
230
|
-
* @param trackSid sid of the track to be muted
|
|
231
|
-
* @param muted true to mute, false to unmute
|
|
228
|
+
* @param room -
|
|
229
|
+
* @param identity -
|
|
230
|
+
* @param trackSid - sid of the track to be muted
|
|
231
|
+
* @param muted - true to mute, false to unmute
|
|
232
232
|
*/
|
|
233
233
|
async mutePublishedTrack(
|
|
234
234
|
room: string,
|
|
@@ -312,10 +312,10 @@ export class RoomServiceClient extends ServiceBase {
|
|
|
312
312
|
|
|
313
313
|
/**
|
|
314
314
|
* Updates a participant's subscription to tracks
|
|
315
|
-
* @param room
|
|
316
|
-
* @param identity
|
|
317
|
-
* @param trackSids
|
|
318
|
-
* @param subscribe true to subscribe, false to unsubscribe
|
|
315
|
+
* @param room -
|
|
316
|
+
* @param identity -
|
|
317
|
+
* @param trackSids -
|
|
318
|
+
* @param subscribe - true to subscribe, false to unsubscribe
|
|
319
319
|
*/
|
|
320
320
|
async updateSubscriptions(
|
|
321
321
|
room: string,
|
|
@@ -340,10 +340,10 @@ export class RoomServiceClient extends ServiceBase {
|
|
|
340
340
|
|
|
341
341
|
/**
|
|
342
342
|
* Sends data message to participants in the room
|
|
343
|
-
* @param room
|
|
344
|
-
* @param data opaque payload to send
|
|
345
|
-
* @param kind delivery reliability
|
|
346
|
-
* @param options optionally specify a topic and destinationSids (when destinationSids is empty, message is sent to everyone)
|
|
343
|
+
* @param room -
|
|
344
|
+
* @param data - opaque payload to send
|
|
345
|
+
* @param kind - delivery reliability
|
|
346
|
+
* @param options - optionally specify a topic and destinationSids (when destinationSids is empty, message is sent to everyone)
|
|
347
347
|
*/
|
|
348
348
|
async sendData(
|
|
349
349
|
room: string,
|
|
@@ -354,10 +354,10 @@ export class RoomServiceClient extends ServiceBase {
|
|
|
354
354
|
/**
|
|
355
355
|
* Sends data message to participants in the room
|
|
356
356
|
* @deprecated use sendData(room, data, kind, options) instead
|
|
357
|
-
* @param room
|
|
358
|
-
* @param data opaque payload to send
|
|
359
|
-
* @param kind delivery reliability
|
|
360
|
-
* @param destinationSids optional. when empty, message is sent to everyone
|
|
357
|
+
* @param room -
|
|
358
|
+
* @param data - opaque payload to send
|
|
359
|
+
* @param kind - delivery reliability
|
|
360
|
+
* @param destinationSids - optional. when empty, message is sent to everyone
|
|
361
361
|
*/
|
|
362
362
|
async sendData(
|
|
363
363
|
room: string,
|
package/src/ServiceBase.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
//
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
import { AccessToken } from './AccessToken.js';
|
|
5
|
-
import { SIPGrant, VideoGrant } from './grants.js';
|
|
5
|
+
import type { SIPGrant, VideoGrant } from './grants.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Utilities to handle authentication
|
|
@@ -15,9 +15,9 @@ export default class ServiceBase {
|
|
|
15
15
|
private readonly ttl: string;
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
|
-
* @param apiKey API Key.
|
|
19
|
-
* @param secret API Secret.
|
|
20
|
-
* @param ttl token TTL
|
|
18
|
+
* @param apiKey - API Key.
|
|
19
|
+
* @param secret - API Secret.
|
|
20
|
+
* @param ttl - token TTL
|
|
21
21
|
*/
|
|
22
22
|
constructor(apiKey?: string, secret?: string, ttl?: string) {
|
|
23
23
|
this.apiKey = apiKey;
|
|
@@ -25,7 +25,7 @@ export default class ServiceBase {
|
|
|
25
25
|
this.ttl = ttl || '10m';
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
async authHeader(grant: VideoGrant, sip?: SIPGrant): Promise<
|
|
28
|
+
async authHeader(grant: VideoGrant, sip?: SIPGrant): Promise<Record<string, string>> {
|
|
29
29
|
const at = new AccessToken(this.apiKey, this.secret, { ttl: this.ttl });
|
|
30
30
|
at.addGrant(grant);
|
|
31
31
|
if (sip) {
|
package/src/SipClient.ts
CHANGED
|
@@ -26,9 +26,11 @@ import {
|
|
|
26
26
|
SIPParticipantInfo,
|
|
27
27
|
SIPTransport,
|
|
28
28
|
SIPTrunkInfo,
|
|
29
|
+
TransferSIPParticipantRequest,
|
|
29
30
|
} from '@livekit/protocol';
|
|
30
31
|
import ServiceBase from './ServiceBase.js';
|
|
31
|
-
import { Rpc
|
|
32
|
+
import type { Rpc } from './TwirpRPC.js';
|
|
33
|
+
import { TwirpRpc, livekitPackage } from './TwirpRPC.js';
|
|
32
34
|
|
|
33
35
|
const svc = 'SIP';
|
|
34
36
|
|
|
@@ -95,9 +97,9 @@ export class SipClient extends ServiceBase {
|
|
|
95
97
|
private readonly rpc: Rpc;
|
|
96
98
|
|
|
97
99
|
/**
|
|
98
|
-
* @param host hostname including protocol. i.e. 'https://cluster.livekit.io'
|
|
99
|
-
* @param apiKey API Key, can be set in env var LIVEKIT_API_KEY
|
|
100
|
-
* @param secret API Secret, can be set in env var LIVEKIT_API_SECRET
|
|
100
|
+
* @param host - hostname including protocol. i.e. 'https://cluster.livekit.io'
|
|
101
|
+
* @param apiKey - API Key, can be set in env var LIVEKIT_API_KEY
|
|
102
|
+
* @param secret - API Secret, can be set in env var LIVEKIT_API_SECRET
|
|
101
103
|
*/
|
|
102
104
|
constructor(host: string, apiKey?: string, secret?: string) {
|
|
103
105
|
super(apiKey, secret);
|
|
@@ -105,9 +107,9 @@ export class SipClient extends ServiceBase {
|
|
|
105
107
|
}
|
|
106
108
|
|
|
107
109
|
/**
|
|
108
|
-
* @param number phone number of the trunk
|
|
109
|
-
* @param opts CreateSipTrunkOptions
|
|
110
|
-
* @deprecated use createSipInboundTrunk or createSipOutboundTrunk
|
|
110
|
+
* @param number - phone number of the trunk
|
|
111
|
+
* @param opts - CreateSipTrunkOptions
|
|
112
|
+
* @deprecated use `createSipInboundTrunk` or `createSipOutboundTrunk`
|
|
111
113
|
*/
|
|
112
114
|
async createSipTrunk(number: string, opts?: CreateSipTrunkOptions): Promise<SIPTrunkInfo> {
|
|
113
115
|
let inboundAddresses: string[] | undefined;
|
|
@@ -155,9 +157,9 @@ export class SipClient extends ServiceBase {
|
|
|
155
157
|
}
|
|
156
158
|
|
|
157
159
|
/**
|
|
158
|
-
@param name human-readable name of the trunk
|
|
159
|
-
* @param numbers phone numbers of the trunk
|
|
160
|
-
* @param opts CreateSipTrunkOptions
|
|
160
|
+
* @param name - human-readable name of the trunk
|
|
161
|
+
* @param numbers - phone numbers of the trunk
|
|
162
|
+
* @param opts - CreateSipTrunkOptions
|
|
161
163
|
*/
|
|
162
164
|
async createSipInboundTrunk(
|
|
163
165
|
name: string,
|
|
@@ -200,10 +202,10 @@ export class SipClient extends ServiceBase {
|
|
|
200
202
|
}
|
|
201
203
|
|
|
202
204
|
/**
|
|
203
|
-
* @param name human-readable name of the trunk
|
|
204
|
-
* @param address hostname and port of the SIP server to dial
|
|
205
|
-
* @param numbers phone numbers of the trunk
|
|
206
|
-
* @param opts CreateSipTrunkOptions
|
|
205
|
+
* @param name - human-readable name of the trunk
|
|
206
|
+
* @param address - hostname and port of the SIP server to dial
|
|
207
|
+
* @param numbers - phone numbers of the trunk
|
|
208
|
+
* @param opts - CreateSipTrunkOptions
|
|
207
209
|
*/
|
|
208
210
|
async createSipOutboundTrunk(
|
|
209
211
|
name: string,
|
|
@@ -245,7 +247,7 @@ export class SipClient extends ServiceBase {
|
|
|
245
247
|
}
|
|
246
248
|
|
|
247
249
|
/**
|
|
248
|
-
* @deprecated use listSipInboundTrunk or listSipOutboundTrunk
|
|
250
|
+
* @deprecated use `listSipInboundTrunk` or `listSipOutboundTrunk`
|
|
249
251
|
*/
|
|
250
252
|
async listSipTrunk(): Promise<Array<SIPTrunkInfo>> {
|
|
251
253
|
const req: Partial<ListSIPTrunkRequest> = {};
|
|
@@ -281,7 +283,7 @@ export class SipClient extends ServiceBase {
|
|
|
281
283
|
}
|
|
282
284
|
|
|
283
285
|
/**
|
|
284
|
-
* @param sipTrunkId sip trunk to delete
|
|
286
|
+
* @param sipTrunkId - sip trunk to delete
|
|
285
287
|
*/
|
|
286
288
|
async deleteSipTrunk(sipTrunkId: string): Promise<SIPTrunkInfo> {
|
|
287
289
|
const data = await this.rpc.request(
|
|
@@ -294,8 +296,8 @@ export class SipClient extends ServiceBase {
|
|
|
294
296
|
}
|
|
295
297
|
|
|
296
298
|
/**
|
|
297
|
-
* @param rule sip dispatch rule
|
|
298
|
-
* @param opts CreateSipDispatchRuleOptions
|
|
299
|
+
* @param rule - sip dispatch rule
|
|
300
|
+
* @param opts - CreateSipDispatchRuleOptions
|
|
299
301
|
*/
|
|
300
302
|
async createSipDispatchRule(
|
|
301
303
|
rule: SipDispatchRuleDirect | SipDispatchRuleIndividual,
|
|
@@ -364,7 +366,7 @@ export class SipClient extends ServiceBase {
|
|
|
364
366
|
}
|
|
365
367
|
|
|
366
368
|
/**
|
|
367
|
-
* @param sipDispatchRuleId sip trunk to delete
|
|
369
|
+
* @param sipDispatchRuleId - sip trunk to delete
|
|
368
370
|
*/
|
|
369
371
|
async deleteSipDispatchRule(sipDispatchRuleId: string): Promise<SIPDispatchRuleInfo> {
|
|
370
372
|
const data = await this.rpc.request(
|
|
@@ -377,10 +379,10 @@ export class SipClient extends ServiceBase {
|
|
|
377
379
|
}
|
|
378
380
|
|
|
379
381
|
/**
|
|
380
|
-
* @param sipTrunkId sip trunk to use for the call
|
|
381
|
-
* @param number number to dial
|
|
382
|
-
* @param roomName room to attach the call to
|
|
383
|
-
* @param opts CreateSipParticipantOptions
|
|
382
|
+
* @param sipTrunkId - sip trunk to use for the call
|
|
383
|
+
* @param number - number to dial
|
|
384
|
+
* @param roomName - room to attach the call to
|
|
385
|
+
* @param opts - CreateSipParticipantOptions
|
|
384
386
|
*/
|
|
385
387
|
async createSipParticipant(
|
|
386
388
|
sipTrunkId: string,
|
|
@@ -424,4 +426,28 @@ export class SipClient extends ServiceBase {
|
|
|
424
426
|
);
|
|
425
427
|
return SIPParticipantInfo.fromJson(data, { ignoreUnknownFields: true });
|
|
426
428
|
}
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* @param roomName - room the SIP participant to transfer is connectd to
|
|
432
|
+
* @param participantIdentity - identity of the SIP participant to transfer
|
|
433
|
+
* @param transferTo - SIP URL to transfer the participant to
|
|
434
|
+
*/
|
|
435
|
+
async transferSipParticipant(
|
|
436
|
+
roomName: string,
|
|
437
|
+
participantIdentity: string,
|
|
438
|
+
transferTo: string,
|
|
439
|
+
): Promise<void> {
|
|
440
|
+
const req = new TransferSIPParticipantRequest({
|
|
441
|
+
participantIdentity: participantIdentity,
|
|
442
|
+
roomName: roomName,
|
|
443
|
+
transferTo: transferTo,
|
|
444
|
+
}).toJson();
|
|
445
|
+
|
|
446
|
+
await this.rpc.request(
|
|
447
|
+
svc,
|
|
448
|
+
'TransferSIPParticipant',
|
|
449
|
+
req,
|
|
450
|
+
await this.authHeader({ roomAdmin: true, room: roomName }, { call: true }),
|
|
451
|
+
);
|
|
452
|
+
}
|
|
427
453
|
}
|
package/src/TwirpRPC.ts
CHANGED
|
@@ -10,6 +10,7 @@ const defaultPrefix = '/twirp';
|
|
|
10
10
|
|
|
11
11
|
export const livekitPackage = 'livekit';
|
|
12
12
|
export interface Rpc {
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
13
14
|
request(service: string, method: string, data: JsonValue, headers?: any): Promise<string>;
|
|
14
15
|
}
|
|
15
16
|
|
|
@@ -32,6 +33,7 @@ export class TwirpRpc {
|
|
|
32
33
|
this.prefix = prefix || defaultPrefix;
|
|
33
34
|
}
|
|
34
35
|
|
|
36
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
35
37
|
async request(service: string, method: string, data: any, headers?: any): Promise<any> {
|
|
36
38
|
const path = `${this.prefix}/${this.pkg}.${service}/${method}`;
|
|
37
39
|
const url = new URL(path, this.host);
|
package/src/WebhookReceiver.ts
CHANGED
|
@@ -37,7 +37,7 @@ export type WebhookEventNames =
|
|
|
37
37
|
| 'ingress_ended'
|
|
38
38
|
/**
|
|
39
39
|
* @internal
|
|
40
|
-
* @
|
|
40
|
+
* @remarks only used as a default value, not a valid webhook event
|
|
41
41
|
*/
|
|
42
42
|
| '';
|
|
43
43
|
|
|
@@ -49,10 +49,9 @@ export class WebhookReceiver {
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
/**
|
|
52
|
-
*
|
|
53
|
-
* @param
|
|
54
|
-
* @param
|
|
55
|
-
* @param skipAuth true to skip auth validation
|
|
52
|
+
* @param body - string of the posted body
|
|
53
|
+
* @param authHeader - `Authorization` header from the request
|
|
54
|
+
* @param skipAuth - true to skip auth validation
|
|
56
55
|
* @returns
|
|
57
56
|
*/
|
|
58
57
|
async receive(
|
package/src/grants.test.ts
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
import { TrackSource } from '@livekit/protocol';
|
|
5
5
|
import { describe, expect, it } from 'vitest';
|
|
6
|
-
import { ClaimGrants, VideoGrant
|
|
6
|
+
import type { ClaimGrants, VideoGrant } from './grants';
|
|
7
|
+
import { claimsToJwtPayload } from './grants';
|
|
7
8
|
|
|
8
9
|
describe('ClaimGrants are parsed correctly', () => {
|
|
9
10
|
it('parses TrackSource correctly to strings', () => {
|
package/src/grants.ts
CHANGED
|
@@ -22,6 +22,7 @@ export function trackSourceToString(source: TrackSource) {
|
|
|
22
22
|
export function claimsToJwtPayload(
|
|
23
23
|
grant: ClaimGrants,
|
|
24
24
|
): JWTPayload & { video?: Record<string, unknown> } {
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
25
26
|
const claim: Record<string, any> = { ...grant };
|
|
26
27
|
// eslint-disable-next-line no-restricted-syntax
|
|
27
28
|
if (Array.isArray(claim.video?.canPublishSources)) {
|