livekit-server-sdk 2.12.0 → 2.13.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/EgressClient.cjs +4 -1
- package/dist/EgressClient.cjs.map +1 -1
- package/dist/EgressClient.d.cts +6 -2
- package/dist/EgressClient.d.ts +6 -2
- package/dist/EgressClient.d.ts.map +1 -1
- package/dist/EgressClient.js +5 -1
- package/dist/EgressClient.js.map +1 -1
- package/dist/RoomServiceClient.cjs +19 -0
- package/dist/RoomServiceClient.cjs.map +1 -1
- package/dist/RoomServiceClient.d.cts +12 -0
- package/dist/RoomServiceClient.d.ts +12 -0
- package/dist/RoomServiceClient.d.ts.map +1 -1
- package/dist/RoomServiceClient.js +20 -0
- package/dist/RoomServiceClient.js.map +1 -1
- package/dist/SipClient.cjs +196 -14
- package/dist/SipClient.cjs.map +1 -1
- package/dist/SipClient.d.cts +150 -9
- package/dist/SipClient.d.ts +150 -9
- package/dist/SipClient.d.ts.map +1 -1
- package/dist/SipClient.js +200 -15
- package/dist/SipClient.js.map +1 -1
- package/dist/TwirpRPC.cjs +14 -6
- package/dist/TwirpRPC.cjs.map +1 -1
- package/dist/TwirpRPC.d.cts +7 -3
- package/dist/TwirpRPC.d.ts +7 -3
- package/dist/TwirpRPC.d.ts.map +1 -1
- package/dist/TwirpRPC.js +14 -6
- package/dist/TwirpRPC.js.map +1 -1
- package/dist/index.d.cts +1 -1
- package/package.json +2 -2
- package/src/EgressClient.ts +10 -0
- package/src/RoomServiceClient.ts +21 -0
- package/src/SipClient.ts +298 -26
- package/src/TwirpRPC.ts +37 -9
package/dist/TwirpRPC.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
const defaultPrefix = "/twirp";
|
|
2
2
|
const livekitPackage = "livekit";
|
|
3
3
|
class TwirpError extends Error {
|
|
4
|
-
constructor(name, message, status, code) {
|
|
4
|
+
constructor(name, message, status, code, metadata) {
|
|
5
5
|
super(message);
|
|
6
6
|
this.name = name;
|
|
7
7
|
this.status = status;
|
|
8
8
|
this.code = code;
|
|
9
|
+
this.metadata = metadata;
|
|
9
10
|
}
|
|
10
11
|
}
|
|
11
12
|
class TwirpRpc {
|
|
@@ -17,22 +18,26 @@ class TwirpRpc {
|
|
|
17
18
|
this.pkg = pkg;
|
|
18
19
|
this.prefix = prefix || defaultPrefix;
|
|
19
20
|
}
|
|
20
|
-
|
|
21
|
-
async request(service, method, data, headers) {
|
|
21
|
+
async request(service, method, data, headers, timeout = 60) {
|
|
22
22
|
const path = `${this.prefix}/${this.pkg}.${service}/${method}`;
|
|
23
23
|
const url = new URL(path, this.host);
|
|
24
|
-
const
|
|
24
|
+
const init = {
|
|
25
25
|
method: "POST",
|
|
26
26
|
headers: {
|
|
27
27
|
"Content-Type": "application/json;charset=UTF-8",
|
|
28
28
|
...headers
|
|
29
29
|
},
|
|
30
30
|
body: JSON.stringify(data)
|
|
31
|
-
}
|
|
31
|
+
};
|
|
32
|
+
if (timeout) {
|
|
33
|
+
init.signal = AbortSignal.timeout(timeout * 1e3);
|
|
34
|
+
}
|
|
35
|
+
const response = await fetch(url, init);
|
|
32
36
|
if (!response.ok) {
|
|
33
37
|
const isJson = response.headers.get("content-type") === "application/json";
|
|
34
38
|
let errorMessage = "Unknown internal error";
|
|
35
39
|
let errorCode = void 0;
|
|
40
|
+
let metadata = void 0;
|
|
36
41
|
try {
|
|
37
42
|
if (isJson) {
|
|
38
43
|
const parsedError = await response.json();
|
|
@@ -42,13 +47,16 @@ class TwirpRpc {
|
|
|
42
47
|
if ("code" in parsedError) {
|
|
43
48
|
errorCode = parsedError.code;
|
|
44
49
|
}
|
|
50
|
+
if ("meta" in parsedError) {
|
|
51
|
+
metadata = parsedError.meta;
|
|
52
|
+
}
|
|
45
53
|
} else {
|
|
46
54
|
errorMessage = await response.text();
|
|
47
55
|
}
|
|
48
56
|
} catch (e) {
|
|
49
57
|
console.debug(`Error when trying to parse error message, using defaults`, e);
|
|
50
58
|
}
|
|
51
|
-
throw new TwirpError(response.statusText, errorMessage, response.status, errorCode);
|
|
59
|
+
throw new TwirpError(response.statusText, errorMessage, response.status, errorCode, metadata);
|
|
52
60
|
}
|
|
53
61
|
const parsedResp = await response.json();
|
|
54
62
|
const camelcaseKeys = await import("camelcase-keys").then((mod) => mod.default);
|
package/dist/TwirpRPC.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/TwirpRPC.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type { JsonValue } from '@bufbuild/protobuf';\n\n// twirp RPC adapter for client implementation\n\nconst defaultPrefix = '/twirp';\n\nexport const livekitPackage = 'livekit';\nexport interface Rpc {\n // eslint-disable-
|
|
1
|
+
{"version":3,"sources":["../src/TwirpRPC.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type { JsonValue } from '@bufbuild/protobuf';\n\n// twirp RPC adapter for client implementation\n\nconst defaultPrefix = '/twirp';\n\nexport const livekitPackage = 'livekit';\nexport interface Rpc {\n request(\n service: string,\n method: string,\n data: JsonValue,\n headers: any, // eslint-disable-line @typescript-eslint/no-explicit-any\n timeout?: number,\n ): Promise<string>;\n}\n\nexport class TwirpError extends Error {\n status: number;\n code?: string;\n metadata?: Record<string, string>;\n\n constructor(\n name: string,\n message: string,\n status: number,\n code?: string,\n metadata?: Record<string, string>,\n ) {\n super(message);\n this.name = name;\n this.status = status;\n this.code = code;\n this.metadata = metadata;\n }\n}\n\n/**\n * JSON based Twirp V7 RPC\n */\nexport class TwirpRpc {\n host: string;\n\n pkg: string;\n\n prefix: string;\n\n constructor(host: string, pkg: string, prefix?: string) {\n if (host.startsWith('ws')) {\n host = host.replace('ws', 'http');\n }\n this.host = host;\n this.pkg = pkg;\n this.prefix = prefix || defaultPrefix;\n }\n\n async request(\n service: string,\n method: string,\n data: any, // eslint-disable-line @typescript-eslint/no-explicit-any\n headers: any, // eslint-disable-line @typescript-eslint/no-explicit-any\n timeout = 60,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ): Promise<any> {\n const path = `${this.prefix}/${this.pkg}.${service}/${method}`;\n const url = new URL(path, this.host);\n const init: RequestInit = {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json;charset=UTF-8',\n ...headers,\n },\n body: JSON.stringify(data),\n };\n\n if (timeout) {\n init.signal = AbortSignal.timeout(timeout * 1000);\n }\n\n const response = await fetch(url, init);\n\n if (!response.ok) {\n const isJson = response.headers.get('content-type') === 'application/json';\n let errorMessage = 'Unknown internal error';\n let errorCode: string | undefined = undefined;\n let metadata: Record<string, string> | undefined = undefined;\n try {\n if (isJson) {\n const parsedError = (await response.json()) as Record<string, unknown>;\n if ('msg' in parsedError) {\n errorMessage = <string>parsedError.msg;\n }\n if ('code' in parsedError) {\n errorCode = <string>parsedError.code;\n }\n if ('meta' in parsedError) {\n metadata = <Record<string, string>>parsedError.meta;\n }\n } else {\n errorMessage = await response.text();\n }\n } catch (e) {\n // parsing went wrong, no op and we keep default error message\n console.debug(`Error when trying to parse error message, using defaults`, e);\n }\n\n throw new TwirpError(response.statusText, errorMessage, response.status, errorCode, metadata);\n }\n const parsedResp = (await response.json()) as Record<string, unknown>;\n\n const camelcaseKeys = await import('camelcase-keys').then((mod) => mod.default);\n return camelcaseKeys(parsedResp, { deep: true });\n }\n}\n"],"mappings":"AAOA,MAAM,gBAAgB;AAEf,MAAM,iBAAiB;AAWvB,MAAM,mBAAmB,MAAM;AAAA,EAKpC,YACE,MACA,SACA,QACA,MACA,UACA;AACA,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,SAAS;AACd,SAAK,OAAO;AACZ,SAAK,WAAW;AAAA,EAClB;AACF;AAKO,MAAM,SAAS;AAAA,EAOpB,YAAY,MAAc,KAAa,QAAiB;AACtD,QAAI,KAAK,WAAW,IAAI,GAAG;AACzB,aAAO,KAAK,QAAQ,MAAM,MAAM;AAAA,IAClC;AACA,SAAK,OAAO;AACZ,SAAK,MAAM;AACX,SAAK,SAAS,UAAU;AAAA,EAC1B;AAAA,EAEA,MAAM,QACJ,SACA,QACA,MACA,SACA,UAAU,IAEI;AACd,UAAM,OAAO,GAAG,KAAK,MAAM,IAAI,KAAK,GAAG,IAAI,OAAO,IAAI,MAAM;AAC5D,UAAM,MAAM,IAAI,IAAI,MAAM,KAAK,IAAI;AACnC,UAAM,OAAoB;AAAA,MACxB,QAAQ;AAAA,MACR,SAAS;AAAA,QACP,gBAAgB;AAAA,QAChB,GAAG;AAAA,MACL;AAAA,MACA,MAAM,KAAK,UAAU,IAAI;AAAA,IAC3B;AAEA,QAAI,SAAS;AACX,WAAK,SAAS,YAAY,QAAQ,UAAU,GAAI;AAAA,IAClD;AAEA,UAAM,WAAW,MAAM,MAAM,KAAK,IAAI;AAEtC,QAAI,CAAC,SAAS,IAAI;AAChB,YAAM,SAAS,SAAS,QAAQ,IAAI,cAAc,MAAM;AACxD,UAAI,eAAe;AACnB,UAAI,YAAgC;AACpC,UAAI,WAA+C;AACnD,UAAI;AACF,YAAI,QAAQ;AACV,gBAAM,cAAe,MAAM,SAAS,KAAK;AACzC,cAAI,SAAS,aAAa;AACxB,2BAAuB,YAAY;AAAA,UACrC;AACA,cAAI,UAAU,aAAa;AACzB,wBAAoB,YAAY;AAAA,UAClC;AACA,cAAI,UAAU,aAAa;AACzB,uBAAmC,YAAY;AAAA,UACjD;AAAA,QACF,OAAO;AACL,yBAAe,MAAM,SAAS,KAAK;AAAA,QACrC;AAAA,MACF,SAAS,GAAG;AAEV,gBAAQ,MAAM,4DAA4D,CAAC;AAAA,MAC7E;AAEA,YAAM,IAAI,WAAW,SAAS,YAAY,cAAc,SAAS,QAAQ,WAAW,QAAQ;AAAA,IAC9F;AACA,UAAM,aAAc,MAAM,SAAS,KAAK;AAExC,UAAM,gBAAgB,MAAM,OAAO,gBAAgB,EAAE,KAAK,CAAC,QAAQ,IAAI,OAAO;AAC9E,WAAO,cAAc,YAAY,EAAE,MAAM,KAAK,CAAC;AAAA,EACjD;AACF;","names":[]}
|
package/dist/index.d.cts
CHANGED
|
@@ -5,7 +5,7 @@ export { EgressClient, EncodedOutputs, ListEgressOptions, ParticipantEgressOptio
|
|
|
5
5
|
export { ClaimGrants, SIPGrant, VideoGrant, claimsToJwtPayload, trackSourceToString } from './grants.cjs';
|
|
6
6
|
export { CreateIngressOptions, IngressClient, ListIngressOptions, UpdateIngressOptions } from './IngressClient.cjs';
|
|
7
7
|
export { CreateOptions, RoomServiceClient, SendDataOptions, UpdateParticipantOptions } from './RoomServiceClient.cjs';
|
|
8
|
-
export { CreateSipDispatchRuleOptions, CreateSipInboundTrunkOptions, CreateSipOutboundTrunkOptions, CreateSipParticipantOptions, CreateSipTrunkOptions, SipClient, SipDispatchRuleDirect, SipDispatchRuleIndividual, TransferSipParticipantOptions } from './SipClient.cjs';
|
|
8
|
+
export { CreateSipDispatchRuleOptions, CreateSipInboundTrunkOptions, CreateSipOutboundTrunkOptions, CreateSipParticipantOptions, CreateSipTrunkOptions, ListSipDispatchRuleOptions, ListSipTrunkOptions, SipClient, SipDispatchRuleDirect, SipDispatchRuleIndividual, SipDispatchRuleUpdateOptions, SipTrunkUpdateOptions, TransferSipParticipantOptions } from './SipClient.cjs';
|
|
9
9
|
export { WebhookEvent, WebhookEventNames, WebhookReceiver, authorizeHeader } from './WebhookReceiver.cjs';
|
|
10
10
|
import './ServiceBase.cjs';
|
|
11
11
|
import 'jose';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "livekit-server-sdk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.13.0",
|
|
4
4
|
"description": "Server-side SDK for LiveKit",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"require": "dist/index.cjs",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@bufbuild/protobuf": "^1.7.2",
|
|
33
|
-
"@livekit/protocol": "^1.
|
|
33
|
+
"@livekit/protocol": "^1.38.0",
|
|
34
34
|
"camelcase-keys": "^9.0.0",
|
|
35
35
|
"jose": "^5.1.2"
|
|
36
36
|
},
|
package/src/EgressClient.ts
CHANGED
|
@@ -11,6 +11,7 @@ import type {
|
|
|
11
11
|
StreamOutput,
|
|
12
12
|
} from '@livekit/protocol';
|
|
13
13
|
import {
|
|
14
|
+
AudioMixing,
|
|
14
15
|
EgressInfo,
|
|
15
16
|
ListEgressRequest,
|
|
16
17
|
ListEgressResponse,
|
|
@@ -50,6 +51,10 @@ export interface RoomCompositeOptions {
|
|
|
50
51
|
* custom template url. optional
|
|
51
52
|
*/
|
|
52
53
|
customBaseUrl?: string;
|
|
54
|
+
/**
|
|
55
|
+
* audio mixing options. optional
|
|
56
|
+
*/
|
|
57
|
+
audioMixing?: AudioMixing;
|
|
53
58
|
}
|
|
54
59
|
|
|
55
60
|
export interface WebOptions {
|
|
@@ -151,6 +156,7 @@ export class EgressClient extends ServiceBase {
|
|
|
151
156
|
audioOnly?: boolean,
|
|
152
157
|
videoOnly?: boolean,
|
|
153
158
|
customBaseUrl?: string,
|
|
159
|
+
audioMixing?: AudioMixing,
|
|
154
160
|
): Promise<EgressInfo>;
|
|
155
161
|
async startRoomCompositeEgress(
|
|
156
162
|
roomName: string,
|
|
@@ -160,6 +166,7 @@ export class EgressClient extends ServiceBase {
|
|
|
160
166
|
audioOnly?: boolean,
|
|
161
167
|
videoOnly?: boolean,
|
|
162
168
|
customBaseUrl?: string,
|
|
169
|
+
audioMixing?: AudioMixing,
|
|
163
170
|
): Promise<EgressInfo> {
|
|
164
171
|
let layout: string | undefined;
|
|
165
172
|
if (optsOrLayout !== undefined) {
|
|
@@ -172,6 +179,7 @@ export class EgressClient extends ServiceBase {
|
|
|
172
179
|
audioOnly = opts.audioOnly;
|
|
173
180
|
videoOnly = opts.videoOnly;
|
|
174
181
|
customBaseUrl = opts.customBaseUrl;
|
|
182
|
+
audioMixing = opts.audioMixing;
|
|
175
183
|
}
|
|
176
184
|
}
|
|
177
185
|
|
|
@@ -179,6 +187,7 @@ export class EgressClient extends ServiceBase {
|
|
|
179
187
|
audioOnly ??= false;
|
|
180
188
|
videoOnly ??= false;
|
|
181
189
|
customBaseUrl ??= '';
|
|
190
|
+
audioMixing ??= AudioMixing.DEFAULT_MIXING;
|
|
182
191
|
|
|
183
192
|
const {
|
|
184
193
|
output: legacyOutput,
|
|
@@ -193,6 +202,7 @@ export class EgressClient extends ServiceBase {
|
|
|
193
202
|
roomName,
|
|
194
203
|
layout,
|
|
195
204
|
audioOnly,
|
|
205
|
+
audioMixing,
|
|
196
206
|
videoOnly,
|
|
197
207
|
customBaseUrl,
|
|
198
208
|
output: legacyOutput,
|
package/src/RoomServiceClient.ts
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
ListParticipantsResponse,
|
|
11
11
|
ListRoomsRequest,
|
|
12
12
|
ListRoomsResponse,
|
|
13
|
+
MoveParticipantRequest,
|
|
13
14
|
MuteRoomTrackRequest,
|
|
14
15
|
MuteRoomTrackResponse,
|
|
15
16
|
ParticipantInfo,
|
|
@@ -233,6 +234,9 @@ export class RoomServiceClient extends ServiceBase {
|
|
|
233
234
|
* participant. When the source participant disconnects or the
|
|
234
235
|
* `RemoveParticipant` method is called in the destination room, the
|
|
235
236
|
* forwarding will be stopped.
|
|
237
|
+
* @param room -
|
|
238
|
+
* @param identity -
|
|
239
|
+
* @param destinationRoom - the room to forward the participant to
|
|
236
240
|
*/
|
|
237
241
|
async forwardParticipant(room: string, identity: string, destinationRoom: string): Promise<void> {
|
|
238
242
|
await this.rpc.request(
|
|
@@ -243,6 +247,23 @@ export class RoomServiceClient extends ServiceBase {
|
|
|
243
247
|
);
|
|
244
248
|
}
|
|
245
249
|
|
|
250
|
+
/**
|
|
251
|
+
* Move a connected participant to a different room. Requires `roomAdmin` and `destinationRoom`.
|
|
252
|
+
* The participant will be removed from the current room and added to the destination room.
|
|
253
|
+
* From the other observers' perspective, the participant would've disconnected from the previous room and joined the new one.
|
|
254
|
+
* @param room -
|
|
255
|
+
* @param identity -
|
|
256
|
+
* @param destinationRoom - the room to move the participant to
|
|
257
|
+
*/
|
|
258
|
+
async moveParticipant(room: string, identity: string, destinationRoom: string): Promise<void> {
|
|
259
|
+
await this.rpc.request(
|
|
260
|
+
svc,
|
|
261
|
+
'MoveParticipant',
|
|
262
|
+
new MoveParticipantRequest({ room, identity, destinationRoom }).toJson(),
|
|
263
|
+
await this.authHeader({ roomAdmin: true, room, destinationRoom }),
|
|
264
|
+
);
|
|
265
|
+
}
|
|
266
|
+
|
|
246
267
|
/**
|
|
247
268
|
* Mutes a track that the participant has published.
|
|
248
269
|
* @param room -
|
package/src/SipClient.ts
CHANGED
|
@@ -2,7 +2,12 @@
|
|
|
2
2
|
//
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
import { Duration } from '@bufbuild/protobuf';
|
|
5
|
-
import type {
|
|
5
|
+
import type {
|
|
6
|
+
ListUpdate,
|
|
7
|
+
Pagination,
|
|
8
|
+
RoomConfiguration,
|
|
9
|
+
SIPHeaderOptions,
|
|
10
|
+
} from '@livekit/protocol';
|
|
6
11
|
import {
|
|
7
12
|
CreateSIPDispatchRuleRequest,
|
|
8
13
|
CreateSIPInboundTrunkRequest,
|
|
@@ -29,6 +34,9 @@ import {
|
|
|
29
34
|
SIPTransport,
|
|
30
35
|
SIPTrunkInfo,
|
|
31
36
|
TransferSIPParticipantRequest,
|
|
37
|
+
UpdateSIPDispatchRuleRequest,
|
|
38
|
+
UpdateSIPInboundTrunkRequest,
|
|
39
|
+
UpdateSIPOutboundTrunkRequest,
|
|
32
40
|
} from '@livekit/protocol';
|
|
33
41
|
import { ServiceBase } from './ServiceBase.js';
|
|
34
42
|
import type { Rpc } from './TwirpRPC.js';
|
|
@@ -108,30 +116,74 @@ export interface CreateSipDispatchRuleOptions {
|
|
|
108
116
|
}
|
|
109
117
|
|
|
110
118
|
export interface CreateSipParticipantOptions {
|
|
111
|
-
|
|
119
|
+
/** Optional SIP From number to use. If empty, trunk number is used. */
|
|
112
120
|
fromNumber?: string;
|
|
113
|
-
|
|
121
|
+
/** Optional identity of the SIP participant */
|
|
114
122
|
participantIdentity?: string;
|
|
115
|
-
|
|
123
|
+
/** Optional name of the participant */
|
|
116
124
|
participantName?: string;
|
|
117
|
-
|
|
125
|
+
/** Optional metadata to attach to the participant */
|
|
118
126
|
participantMetadata?: string;
|
|
119
|
-
|
|
127
|
+
/** Optional attributes to attach to the participant */
|
|
120
128
|
participantAttributes?: { [key: string]: string };
|
|
121
|
-
|
|
122
|
-
|
|
129
|
+
/** Optionally send following DTMF digits (extension codes) when making a call.
|
|
130
|
+
* Character 'w' can be used to add a 0.5 sec delay. */
|
|
123
131
|
dtmf?: string;
|
|
124
|
-
/** @deprecated
|
|
125
|
-
playRingtone?: boolean;
|
|
132
|
+
/** @deprecated use `playDialtone` instead */
|
|
133
|
+
playRingtone?: boolean;
|
|
134
|
+
/** If `true`, the SIP Participant plays a dial tone to the room until the phone is picked up. */
|
|
126
135
|
playDialtone?: boolean;
|
|
127
|
-
|
|
136
|
+
/** These headers are sent as-is and may help identify this call as coming from LiveKit for the other SIP endpoint. */
|
|
128
137
|
headers?: { [key: string]: string };
|
|
129
|
-
|
|
138
|
+
/** Map SIP response headers from INVITE to sip.h.* participant attributes automatically. */
|
|
130
139
|
includeHeaders?: SIPHeaderOptions;
|
|
131
140
|
hidePhoneNumber?: boolean;
|
|
132
|
-
|
|
133
|
-
|
|
141
|
+
/** Maximum time for the call to ring in seconds. */
|
|
142
|
+
ringingTimeout?: number;
|
|
143
|
+
/** Maximum call duration in seconds. */
|
|
144
|
+
maxCallDuration?: number;
|
|
145
|
+
/** If `true`, Krisp noise cancellation will be enabled for the caller. */
|
|
134
146
|
krispEnabled?: boolean;
|
|
147
|
+
/** If `true`, this will wait until the call is answered before returning. */
|
|
148
|
+
waitUntilAnswered?: boolean;
|
|
149
|
+
/** Optional request timeout in seconds. */
|
|
150
|
+
timeout?: number;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export interface ListSipDispatchRuleOptions {
|
|
154
|
+
/** Pagination options. */
|
|
155
|
+
page?: Pagination;
|
|
156
|
+
/** Rule IDs to list. If this option is set, the response will contains rules in the same order. If any of the rules is missing, a nil item in that position will be sent in the response. */
|
|
157
|
+
dispatchRuleIds?: string[];
|
|
158
|
+
/** Only list rules that contain one of the Trunk IDs, including wildcard rules. */
|
|
159
|
+
trunkIds?: string[];
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export interface ListSipTrunkOptions {
|
|
163
|
+
/** Pagination options. */
|
|
164
|
+
page?: Pagination;
|
|
165
|
+
/** Trunk IDs to list. If this option is set, the response will contains trunks in the same order. If any of the trunks is missing, a nil item in that position will be sent in the response. */
|
|
166
|
+
trunkIds?: string[];
|
|
167
|
+
/** Only list trunks that contain one of the numbers, including wildcard trunks. */
|
|
168
|
+
numbers?: string[];
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export interface SipDispatchRuleUpdateOptions {
|
|
172
|
+
trunkIds?: ListUpdate;
|
|
173
|
+
rule?: SIPDispatchRule;
|
|
174
|
+
name?: string;
|
|
175
|
+
metadata?: string;
|
|
176
|
+
attributes?: { [key: string]: string };
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export interface SipTrunkUpdateOptions {
|
|
180
|
+
numbers?: ListUpdate;
|
|
181
|
+
allowedAddresses?: ListUpdate;
|
|
182
|
+
allowedNumbers?: ListUpdate;
|
|
183
|
+
authUsername?: string;
|
|
184
|
+
authPassword?: string;
|
|
185
|
+
name?: string;
|
|
186
|
+
metadata?: string;
|
|
135
187
|
}
|
|
136
188
|
|
|
137
189
|
export interface TransferSipParticipantOptions {
|
|
@@ -206,9 +258,12 @@ export class SipClient extends ServiceBase {
|
|
|
206
258
|
}
|
|
207
259
|
|
|
208
260
|
/**
|
|
261
|
+
* Create a new SIP inbound trunk.
|
|
262
|
+
*
|
|
209
263
|
* @param name - human-readable name of the trunk
|
|
210
264
|
* @param numbers - phone numbers of the trunk
|
|
211
265
|
* @param opts - CreateSipTrunkOptions
|
|
266
|
+
* @returns Created SIP inbound trunk
|
|
212
267
|
*/
|
|
213
268
|
async createSipInboundTrunk(
|
|
214
269
|
name: string,
|
|
@@ -244,10 +299,13 @@ export class SipClient extends ServiceBase {
|
|
|
244
299
|
}
|
|
245
300
|
|
|
246
301
|
/**
|
|
302
|
+
* Create a new SIP outbound trunk.
|
|
303
|
+
*
|
|
247
304
|
* @param name - human-readable name of the trunk
|
|
248
305
|
* @param address - hostname and port of the SIP server to dial
|
|
249
306
|
* @param numbers - phone numbers of the trunk
|
|
250
307
|
* @param opts - CreateSipTrunkOptions
|
|
308
|
+
* @returns Created SIP outbound trunk
|
|
251
309
|
*/
|
|
252
310
|
async createSipOutboundTrunk(
|
|
253
311
|
name: string,
|
|
@@ -299,30 +357,45 @@ export class SipClient extends ServiceBase {
|
|
|
299
357
|
return ListSIPTrunkResponse.fromJson(data, { ignoreUnknownFields: true }).items ?? [];
|
|
300
358
|
}
|
|
301
359
|
|
|
302
|
-
|
|
303
|
-
|
|
360
|
+
/**
|
|
361
|
+
* List SIP inbound trunks with optional filtering.
|
|
362
|
+
*
|
|
363
|
+
* @param list - Request with optional filtering parameters
|
|
364
|
+
* @returns Response containing list of SIP inbound trunks
|
|
365
|
+
*/
|
|
366
|
+
async listSipInboundTrunk(list: ListSipTrunkOptions = {}): Promise<Array<SIPInboundTrunkInfo>> {
|
|
367
|
+
const req = new ListSIPInboundTrunkRequest(list).toJson();
|
|
304
368
|
const data = await this.rpc.request(
|
|
305
369
|
svc,
|
|
306
370
|
'ListSIPInboundTrunk',
|
|
307
|
-
|
|
371
|
+
req,
|
|
308
372
|
await this.authHeader({}, { admin: true }),
|
|
309
373
|
);
|
|
310
374
|
return ListSIPInboundTrunkResponse.fromJson(data, { ignoreUnknownFields: true }).items ?? [];
|
|
311
375
|
}
|
|
312
376
|
|
|
313
|
-
|
|
314
|
-
|
|
377
|
+
/**
|
|
378
|
+
* List SIP outbound trunks with optional filtering.
|
|
379
|
+
*
|
|
380
|
+
* @param list - Request with optional filtering parameters
|
|
381
|
+
* @returns Response containing list of SIP outbound trunks
|
|
382
|
+
*/
|
|
383
|
+
async listSipOutboundTrunk(list: ListSipTrunkOptions = {}): Promise<Array<SIPOutboundTrunkInfo>> {
|
|
384
|
+
const req = new ListSIPOutboundTrunkRequest(list).toJson();
|
|
315
385
|
const data = await this.rpc.request(
|
|
316
386
|
svc,
|
|
317
387
|
'ListSIPOutboundTrunk',
|
|
318
|
-
|
|
388
|
+
req,
|
|
319
389
|
await this.authHeader({}, { admin: true }),
|
|
320
390
|
);
|
|
321
391
|
return ListSIPOutboundTrunkResponse.fromJson(data, { ignoreUnknownFields: true }).items ?? [];
|
|
322
392
|
}
|
|
323
393
|
|
|
324
394
|
/**
|
|
325
|
-
*
|
|
395
|
+
* Delete a SIP trunk.
|
|
396
|
+
*
|
|
397
|
+
* @param sipTrunkId - ID of the SIP trunk to delete
|
|
398
|
+
* @returns Deleted trunk information
|
|
326
399
|
*/
|
|
327
400
|
async deleteSipTrunk(sipTrunkId: string): Promise<SIPTrunkInfo> {
|
|
328
401
|
const data = await this.rpc.request(
|
|
@@ -335,8 +408,11 @@ export class SipClient extends ServiceBase {
|
|
|
335
408
|
}
|
|
336
409
|
|
|
337
410
|
/**
|
|
338
|
-
*
|
|
411
|
+
* Create a new SIP dispatch rule.
|
|
412
|
+
*
|
|
413
|
+
* @param rule - SIP dispatch rule to create
|
|
339
414
|
* @param opts - CreateSipDispatchRuleOptions
|
|
415
|
+
* @returns Created SIP dispatch rule
|
|
340
416
|
*/
|
|
341
417
|
async createSipDispatchRule(
|
|
342
418
|
rule: SipDispatchRuleDirect | SipDispatchRuleIndividual,
|
|
@@ -388,19 +464,207 @@ export class SipClient extends ServiceBase {
|
|
|
388
464
|
return SIPDispatchRuleInfo.fromJson(data, { ignoreUnknownFields: true });
|
|
389
465
|
}
|
|
390
466
|
|
|
391
|
-
|
|
392
|
-
|
|
467
|
+
/**
|
|
468
|
+
* Updates an existing SIP dispatch rule by replacing it entirely.
|
|
469
|
+
*
|
|
470
|
+
* @param sipDispatchRuleId - ID of the SIP dispatch rule to update
|
|
471
|
+
* @param rule - new SIP dispatch rule
|
|
472
|
+
* @returns Updated SIP dispatch rule
|
|
473
|
+
*/
|
|
474
|
+
async updateSipDispatchRule(
|
|
475
|
+
sipDispatchRuleId: string,
|
|
476
|
+
rule: SIPDispatchRuleInfo,
|
|
477
|
+
): Promise<SIPDispatchRuleInfo> {
|
|
478
|
+
const req = new UpdateSIPDispatchRuleRequest({
|
|
479
|
+
sipDispatchRuleId: sipDispatchRuleId,
|
|
480
|
+
action: {
|
|
481
|
+
case: 'replace',
|
|
482
|
+
value: rule,
|
|
483
|
+
},
|
|
484
|
+
}).toJson();
|
|
485
|
+
|
|
486
|
+
const data = await this.rpc.request(
|
|
487
|
+
svc,
|
|
488
|
+
'UpdateSIPDispatchRule',
|
|
489
|
+
req,
|
|
490
|
+
await this.authHeader({}, { admin: true }),
|
|
491
|
+
);
|
|
492
|
+
|
|
493
|
+
return SIPDispatchRuleInfo.fromJson(data, { ignoreUnknownFields: true });
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
/**
|
|
497
|
+
* Updates specific fields of an existing SIP dispatch rule.
|
|
498
|
+
* Only provided fields will be updated.
|
|
499
|
+
*
|
|
500
|
+
* @param sipDispatchRuleId - ID of the SIP dispatch rule to update
|
|
501
|
+
* @param fields - Fields of the dispatch rule to update
|
|
502
|
+
* @returns Updated SIP dispatch rule
|
|
503
|
+
*/
|
|
504
|
+
async updateSipDispatchRuleFields(
|
|
505
|
+
sipDispatchRuleId: string,
|
|
506
|
+
fields: SipDispatchRuleUpdateOptions = {},
|
|
507
|
+
): Promise<SIPDispatchRuleInfo> {
|
|
508
|
+
const req = new UpdateSIPDispatchRuleRequest({
|
|
509
|
+
sipDispatchRuleId: sipDispatchRuleId,
|
|
510
|
+
action: {
|
|
511
|
+
case: 'update',
|
|
512
|
+
value: fields,
|
|
513
|
+
},
|
|
514
|
+
}).toJson();
|
|
515
|
+
|
|
516
|
+
const data = await this.rpc.request(
|
|
517
|
+
svc,
|
|
518
|
+
'UpdateSIPDispatchRule',
|
|
519
|
+
req,
|
|
520
|
+
await this.authHeader({}, { admin: true }),
|
|
521
|
+
);
|
|
522
|
+
|
|
523
|
+
return SIPDispatchRuleInfo.fromJson(data, { ignoreUnknownFields: true });
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
* Updates an existing SIP inbound trunk by replacing it entirely.
|
|
528
|
+
*
|
|
529
|
+
* @param sipTrunkId - ID of the SIP inbound trunk to update
|
|
530
|
+
* @param trunk - SIP inbound trunk to update with
|
|
531
|
+
* @returns Updated SIP inbound trunk
|
|
532
|
+
*/
|
|
533
|
+
async updateSipInboundTrunk(
|
|
534
|
+
sipTrunkId: string,
|
|
535
|
+
trunk: SIPInboundTrunkInfo,
|
|
536
|
+
): Promise<SIPInboundTrunkInfo> {
|
|
537
|
+
const req = new UpdateSIPInboundTrunkRequest({
|
|
538
|
+
sipTrunkId,
|
|
539
|
+
action: {
|
|
540
|
+
case: 'replace',
|
|
541
|
+
value: trunk,
|
|
542
|
+
},
|
|
543
|
+
}).toJson();
|
|
544
|
+
|
|
545
|
+
const data = await this.rpc.request(
|
|
546
|
+
svc,
|
|
547
|
+
'UpdateSIPInboundTrunk',
|
|
548
|
+
req,
|
|
549
|
+
await this.authHeader({}, { admin: true }),
|
|
550
|
+
);
|
|
551
|
+
|
|
552
|
+
return SIPInboundTrunkInfo.fromJson(data, { ignoreUnknownFields: true });
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
/**
|
|
556
|
+
* Updates specific fields of an existing SIP inbound trunk.
|
|
557
|
+
* Only provided fields will be updated.
|
|
558
|
+
*
|
|
559
|
+
* @param sipTrunkId - ID of the SIP inbound trunk to update
|
|
560
|
+
* @param fields - Fields of the inbound trunk to update
|
|
561
|
+
* @returns Updated SIP inbound trunk
|
|
562
|
+
*/
|
|
563
|
+
async updateSipInboundTrunkFields(
|
|
564
|
+
sipTrunkId: string,
|
|
565
|
+
fields: SipTrunkUpdateOptions,
|
|
566
|
+
): Promise<SIPInboundTrunkInfo> {
|
|
567
|
+
const req = new UpdateSIPInboundTrunkRequest({
|
|
568
|
+
sipTrunkId,
|
|
569
|
+
action: {
|
|
570
|
+
case: 'update',
|
|
571
|
+
value: fields,
|
|
572
|
+
},
|
|
573
|
+
}).toJson();
|
|
574
|
+
|
|
575
|
+
const data = await this.rpc.request(
|
|
576
|
+
svc,
|
|
577
|
+
'UpdateSIPInboundTrunk',
|
|
578
|
+
req,
|
|
579
|
+
await this.authHeader({}, { admin: true }),
|
|
580
|
+
);
|
|
581
|
+
|
|
582
|
+
return SIPInboundTrunkInfo.fromJson(data, { ignoreUnknownFields: true });
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
/**
|
|
586
|
+
* Updates an existing SIP outbound trunk by replacing it entirely.
|
|
587
|
+
*
|
|
588
|
+
* @param sipTrunkId - ID of the SIP outbound trunk to update
|
|
589
|
+
* @param trunk - SIP outbound trunk to update with
|
|
590
|
+
* @returns Updated SIP outbound trunk
|
|
591
|
+
*/
|
|
592
|
+
async updateSipOutboundTrunk(
|
|
593
|
+
sipTrunkId: string,
|
|
594
|
+
trunk: SIPOutboundTrunkInfo,
|
|
595
|
+
): Promise<SIPOutboundTrunkInfo> {
|
|
596
|
+
const req = new UpdateSIPOutboundTrunkRequest({
|
|
597
|
+
sipTrunkId,
|
|
598
|
+
action: {
|
|
599
|
+
case: 'replace',
|
|
600
|
+
value: trunk,
|
|
601
|
+
},
|
|
602
|
+
}).toJson();
|
|
603
|
+
|
|
604
|
+
const data = await this.rpc.request(
|
|
605
|
+
svc,
|
|
606
|
+
'UpdateSIPOutboundTrunk',
|
|
607
|
+
req,
|
|
608
|
+
await this.authHeader({}, { admin: true }),
|
|
609
|
+
);
|
|
610
|
+
|
|
611
|
+
return SIPOutboundTrunkInfo.fromJson(data, { ignoreUnknownFields: true });
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
/**
|
|
615
|
+
* Updates specific fields of an existing SIP outbound trunk.
|
|
616
|
+
* Only provided fields will be updated.
|
|
617
|
+
*
|
|
618
|
+
* @param sipTrunkId - ID of the SIP outbound trunk to update
|
|
619
|
+
* @param fields - Fields of the outbound trunk to update
|
|
620
|
+
* @returns Updated SIP outbound trunk
|
|
621
|
+
*/
|
|
622
|
+
async updateSipOutboundTrunkFields(
|
|
623
|
+
sipTrunkId: string,
|
|
624
|
+
fields: SipTrunkUpdateOptions,
|
|
625
|
+
): Promise<SIPOutboundTrunkInfo> {
|
|
626
|
+
const req = new UpdateSIPOutboundTrunkRequest({
|
|
627
|
+
sipTrunkId,
|
|
628
|
+
action: {
|
|
629
|
+
case: 'update',
|
|
630
|
+
value: fields,
|
|
631
|
+
},
|
|
632
|
+
}).toJson();
|
|
633
|
+
|
|
634
|
+
const data = await this.rpc.request(
|
|
635
|
+
svc,
|
|
636
|
+
'UpdateSIPOutboundTrunk',
|
|
637
|
+
req,
|
|
638
|
+
await this.authHeader({}, { admin: true }),
|
|
639
|
+
);
|
|
640
|
+
|
|
641
|
+
return SIPOutboundTrunkInfo.fromJson(data, { ignoreUnknownFields: true });
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
/**
|
|
645
|
+
* List SIP dispatch rules with optional filtering.
|
|
646
|
+
*
|
|
647
|
+
* @param list - Request with optional filtering parameters
|
|
648
|
+
* @returns Response containing list of SIP dispatch rules
|
|
649
|
+
*/
|
|
650
|
+
async listSipDispatchRule(
|
|
651
|
+
list: ListSipDispatchRuleOptions = {},
|
|
652
|
+
): Promise<Array<SIPDispatchRuleInfo>> {
|
|
653
|
+
const req = new ListSIPDispatchRuleRequest(list).toJson();
|
|
393
654
|
const data = await this.rpc.request(
|
|
394
655
|
svc,
|
|
395
656
|
'ListSIPDispatchRule',
|
|
396
|
-
|
|
657
|
+
req,
|
|
397
658
|
await this.authHeader({}, { admin: true }),
|
|
398
659
|
);
|
|
399
660
|
return ListSIPDispatchRuleResponse.fromJson(data, { ignoreUnknownFields: true }).items ?? [];
|
|
400
661
|
}
|
|
401
662
|
|
|
402
663
|
/**
|
|
403
|
-
*
|
|
664
|
+
* Delete a SIP dispatch rule.
|
|
665
|
+
*
|
|
666
|
+
* @param sipDispatchRuleId - ID of the SIP dispatch rule to delete
|
|
667
|
+
* @returns Deleted rule information
|
|
404
668
|
*/
|
|
405
669
|
async deleteSipDispatchRule(sipDispatchRuleId: string): Promise<SIPDispatchRuleInfo> {
|
|
406
670
|
const data = await this.rpc.request(
|
|
@@ -413,10 +677,13 @@ export class SipClient extends ServiceBase {
|
|
|
413
677
|
}
|
|
414
678
|
|
|
415
679
|
/**
|
|
680
|
+
* Create a new SIP participant.
|
|
681
|
+
*
|
|
416
682
|
* @param sipTrunkId - sip trunk to use for the call
|
|
417
683
|
* @param number - number to dial
|
|
418
684
|
* @param roomName - room to attach the call to
|
|
419
685
|
* @param opts - CreateSipParticipantOptions
|
|
686
|
+
* @returns Created SIP participant
|
|
420
687
|
*/
|
|
421
688
|
async createSipParticipant(
|
|
422
689
|
sipTrunkId: string,
|
|
@@ -449,6 +716,7 @@ export class SipClient extends ServiceBase {
|
|
|
449
716
|
? new Duration({ seconds: BigInt(opts.maxCallDuration) })
|
|
450
717
|
: undefined,
|
|
451
718
|
krispEnabled: opts.krispEnabled,
|
|
719
|
+
waitUntilAnswered: opts.waitUntilAnswered,
|
|
452
720
|
}).toJson();
|
|
453
721
|
|
|
454
722
|
const data = await this.rpc.request(
|
|
@@ -456,14 +724,18 @@ export class SipClient extends ServiceBase {
|
|
|
456
724
|
'CreateSIPParticipant',
|
|
457
725
|
req,
|
|
458
726
|
await this.authHeader({}, { call: true }),
|
|
727
|
+
opts.timeout,
|
|
459
728
|
);
|
|
460
729
|
return SIPParticipantInfo.fromJson(data, { ignoreUnknownFields: true });
|
|
461
730
|
}
|
|
462
731
|
|
|
463
732
|
/**
|
|
733
|
+
* Transfer a SIP participant to a different room.
|
|
734
|
+
*
|
|
464
735
|
* @param roomName - room the SIP participant to transfer is connectd to
|
|
465
736
|
* @param participantIdentity - identity of the SIP participant to transfer
|
|
466
737
|
* @param transferTo - SIP URL to transfer the participant to
|
|
738
|
+
* @param opts - TransferSipParticipantOptions
|
|
467
739
|
*/
|
|
468
740
|
async transferSipParticipant(
|
|
469
741
|
roomName: string,
|