livekit-server-sdk 1.0.2 → 1.1.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/.eslintrc.js +1 -1
- package/README.md +2 -0
- package/dist/EgressClient.d.ts +68 -12
- package/dist/EgressClient.js +59 -28
- package/dist/EgressClient.js.map +1 -1
- package/dist/IngressClient.d.ts +84 -0
- package/dist/IngressClient.js +113 -0
- package/dist/IngressClient.js.map +1 -0
- package/dist/RoomServiceClient.d.ts +10 -6
- package/dist/RoomServiceClient.js +13 -14
- package/dist/RoomServiceClient.js.map +1 -1
- package/dist/ServiceBase.d.ts +16 -0
- package/dist/ServiceBase.js +27 -0
- package/dist/ServiceBase.js.map +1 -0
- package/dist/grants.d.ts +2 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +9 -6
- package/dist/index.js.map +1 -1
- package/dist/proto/google/protobuf/timestamp.d.ts +5 -5
- package/dist/proto/google/protobuf/timestamp.js +17 -32
- package/dist/proto/google/protobuf/timestamp.js.map +1 -1
- package/dist/proto/livekit_egress.d.ts +3750 -929
- package/dist/proto/livekit_egress.js +973 -486
- package/dist/proto/livekit_egress.js.map +1 -1
- package/dist/proto/livekit_ingress.d.ts +152 -110
- package/dist/proto/livekit_ingress.js +218 -272
- package/dist/proto/livekit_ingress.js.map +1 -1
- package/dist/proto/livekit_models.d.ts +77 -58
- package/dist/proto/livekit_models.js +396 -447
- package/dist/proto/livekit_models.js.map +1 -1
- package/dist/proto/livekit_room.d.ts +1238 -79
- package/dist/proto/livekit_room.js +252 -197
- package/dist/proto/livekit_room.js.map +1 -1
- package/dist/proto/livekit_webhook.d.ts +1015 -89
- package/dist/proto/livekit_webhook.js +43 -68
- package/dist/proto/livekit_webhook.js.map +1 -1
- package/generate-proto.sh +25 -0
- package/package.json +3 -3
- package/dist/proto/google/protobuf/empty.d.ts +0 -31
- package/dist/proto/google/protobuf/empty.js +0 -67
- package/dist/proto/google/protobuf/empty.js.map +0 -1
package/.eslintrc.js
CHANGED
package/README.md
CHANGED
|
@@ -114,6 +114,8 @@ svc.deleteRoom('myroom').then(() => {
|
|
|
114
114
|
|
|
115
115
|
The JS SDK also provides helper functions to decode and verify webhook callbacks. While verification is optional, it ensures the authenticity of the message. See [webhooks guide](https://docs.livekit.io/guides/webhooks) for details.
|
|
116
116
|
|
|
117
|
+
Check out [example projects](examples) for full examples of webhooks integration.
|
|
118
|
+
|
|
117
119
|
```typescript
|
|
118
120
|
import { WebhookReceiver } from 'livekit-server-sdk';
|
|
119
121
|
|
package/dist/EgressClient.d.ts
CHANGED
|
@@ -1,11 +1,60 @@
|
|
|
1
1
|
import { DirectFileOutput, EgressInfo, EncodedFileOutput, EncodingOptions, EncodingOptionsPreset, SegmentedFileOutput, StreamOutput } from './proto/livekit_egress';
|
|
2
|
+
import ServiceBase from './ServiceBase';
|
|
3
|
+
export interface RoomCompositeOptions {
|
|
4
|
+
/**
|
|
5
|
+
* egress layout. optional
|
|
6
|
+
*/
|
|
7
|
+
layout?: string;
|
|
8
|
+
/**
|
|
9
|
+
* encoding options or preset. optional
|
|
10
|
+
*/
|
|
11
|
+
encodingOptions?: EncodingOptionsPreset | EncodingOptions;
|
|
12
|
+
/**
|
|
13
|
+
* record audio only. optional
|
|
14
|
+
*/
|
|
15
|
+
audioOnly?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* record video only. optional
|
|
18
|
+
*/
|
|
19
|
+
videoOnly?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* custom template url. optional
|
|
22
|
+
*/
|
|
23
|
+
customBaseUrl?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface WebOptions {
|
|
26
|
+
/**
|
|
27
|
+
* encoding options or preset. optional
|
|
28
|
+
*/
|
|
29
|
+
encodingOptions?: EncodingOptionsPreset | EncodingOptions;
|
|
30
|
+
/**
|
|
31
|
+
* record audio only. optional
|
|
32
|
+
*/
|
|
33
|
+
audioOnly?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* record video only. optional
|
|
36
|
+
*/
|
|
37
|
+
videoOnly?: boolean;
|
|
38
|
+
}
|
|
39
|
+
export interface TrackCompositeOptions {
|
|
40
|
+
/**
|
|
41
|
+
* audio track ID
|
|
42
|
+
*/
|
|
43
|
+
audioTrackId?: string;
|
|
44
|
+
/**
|
|
45
|
+
* video track ID
|
|
46
|
+
*/
|
|
47
|
+
videoTrackId?: string;
|
|
48
|
+
/**
|
|
49
|
+
* encoding options or preset. optional
|
|
50
|
+
*/
|
|
51
|
+
encodingOptions?: EncodingOptionsPreset | EncodingOptions;
|
|
52
|
+
}
|
|
2
53
|
/**
|
|
3
54
|
* Client to access Egress APIs
|
|
4
55
|
*/
|
|
5
|
-
export
|
|
56
|
+
export declare class EgressClient extends ServiceBase {
|
|
6
57
|
private readonly rpc;
|
|
7
|
-
private readonly apiKey?;
|
|
8
|
-
private readonly secret?;
|
|
9
58
|
/**
|
|
10
59
|
* @param host hostname including protocol. i.e. 'https://cluster.livekit.io'
|
|
11
60
|
* @param apiKey API Key, can be set in env var LIVEKIT_API_KEY
|
|
@@ -15,19 +64,27 @@ export default class EgressClient {
|
|
|
15
64
|
/**
|
|
16
65
|
* @param roomName room name
|
|
17
66
|
* @param output file or stream output
|
|
18
|
-
* @param
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
* @
|
|
67
|
+
* @param opts RoomCompositeOptions
|
|
68
|
+
*/
|
|
69
|
+
startRoomCompositeEgress(roomName: string, output: EncodedFileOutput | SegmentedFileOutput | StreamOutput, opts?: RoomCompositeOptions): Promise<EgressInfo>;
|
|
70
|
+
/**
|
|
71
|
+
* @deprecated use RoomCompositeOptions instead
|
|
23
72
|
*/
|
|
24
73
|
startRoomCompositeEgress(roomName: string, output: EncodedFileOutput | SegmentedFileOutput | StreamOutput, layout?: string, options?: EncodingOptionsPreset | EncodingOptions, audioOnly?: boolean, videoOnly?: boolean, customBaseUrl?: string): Promise<EgressInfo>;
|
|
74
|
+
/**
|
|
75
|
+
* @param url url
|
|
76
|
+
* @param output file or stream output
|
|
77
|
+
* @param opts WebOptions
|
|
78
|
+
*/
|
|
79
|
+
startWebEgress(url: string, output: EncodedFileOutput | SegmentedFileOutput | StreamOutput, opts?: WebOptions): Promise<EgressInfo>;
|
|
25
80
|
/**
|
|
26
81
|
* @param roomName room name
|
|
27
82
|
* @param output file or stream output
|
|
28
|
-
* @param
|
|
29
|
-
|
|
30
|
-
|
|
83
|
+
* @param opts TrackCompositeOptions
|
|
84
|
+
*/
|
|
85
|
+
startTrackCompositeEgress(roomName: string, output: EncodedFileOutput | SegmentedFileOutput | StreamOutput, opts?: TrackCompositeOptions): Promise<EgressInfo>;
|
|
86
|
+
/**
|
|
87
|
+
* @deprecated use TrackCompositeOptions instead
|
|
31
88
|
*/
|
|
32
89
|
startTrackCompositeEgress(roomName: string, output: EncodedFileOutput | SegmentedFileOutput | StreamOutput, audioTrackId?: string, videoTrackId?: string, options?: EncodingOptionsPreset | EncodingOptions): Promise<EgressInfo>;
|
|
33
90
|
private getOutputParams;
|
|
@@ -56,5 +113,4 @@ export default class EgressClient {
|
|
|
56
113
|
* @param egressId
|
|
57
114
|
*/
|
|
58
115
|
stopEgress(egressId: string): Promise<EgressInfo>;
|
|
59
|
-
private authHeader;
|
|
60
116
|
}
|
package/dist/EgressClient.js
CHANGED
|
@@ -8,36 +8,44 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
|
|
15
|
+
exports.EgressClient = void 0;
|
|
13
16
|
const livekit_egress_1 = require("./proto/livekit_egress");
|
|
17
|
+
const ServiceBase_1 = __importDefault(require("./ServiceBase"));
|
|
14
18
|
const TwirpRPC_1 = require("./TwirpRPC");
|
|
15
19
|
const svc = 'Egress';
|
|
16
20
|
/**
|
|
17
21
|
* Client to access Egress APIs
|
|
18
22
|
*/
|
|
19
|
-
class EgressClient {
|
|
23
|
+
class EgressClient extends ServiceBase_1.default {
|
|
20
24
|
/**
|
|
21
25
|
* @param host hostname including protocol. i.e. 'https://cluster.livekit.io'
|
|
22
26
|
* @param apiKey API Key, can be set in env var LIVEKIT_API_KEY
|
|
23
27
|
* @param secret API Secret, can be set in env var LIVEKIT_API_SECRET
|
|
24
28
|
*/
|
|
25
29
|
constructor(host, apiKey, secret) {
|
|
30
|
+
super(apiKey, secret);
|
|
26
31
|
this.rpc = new TwirpRPC_1.TwirpRpc(host, TwirpRPC_1.livekitPackage);
|
|
27
|
-
this.apiKey = apiKey;
|
|
28
|
-
this.secret = secret;
|
|
29
32
|
}
|
|
30
|
-
|
|
31
|
-
* @param roomName room name
|
|
32
|
-
* @param output file or stream output
|
|
33
|
-
* @param layout egress layout
|
|
34
|
-
* @param options encoding options or preset
|
|
35
|
-
* @param audioOnly record audio only
|
|
36
|
-
* @param videoOnly record video only
|
|
37
|
-
* @param customBaseUrl custom template url
|
|
38
|
-
*/
|
|
39
|
-
startRoomCompositeEgress(roomName, output, layout, options, audioOnly, videoOnly, customBaseUrl) {
|
|
33
|
+
startRoomCompositeEgress(roomName, output, optsOrLayout, options, audioOnly, videoOnly, customBaseUrl) {
|
|
40
34
|
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
let layout;
|
|
36
|
+
if (optsOrLayout !== undefined) {
|
|
37
|
+
if (typeof optsOrLayout === 'string') {
|
|
38
|
+
layout = optsOrLayout;
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
const opts = optsOrLayout;
|
|
42
|
+
layout = opts.layout;
|
|
43
|
+
options = opts.encodingOptions;
|
|
44
|
+
audioOnly = opts.audioOnly;
|
|
45
|
+
videoOnly = opts.videoOnly;
|
|
46
|
+
customBaseUrl = opts.customBaseUrl;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
41
49
|
layout !== null && layout !== void 0 ? layout : (layout = '');
|
|
42
50
|
audioOnly !== null && audioOnly !== void 0 ? audioOnly : (audioOnly = false);
|
|
43
51
|
videoOnly !== null && videoOnly !== void 0 ? videoOnly : (videoOnly = false);
|
|
@@ -60,14 +68,43 @@ class EgressClient {
|
|
|
60
68
|
});
|
|
61
69
|
}
|
|
62
70
|
/**
|
|
63
|
-
* @param
|
|
71
|
+
* @param url url
|
|
64
72
|
* @param output file or stream output
|
|
65
|
-
* @param
|
|
66
|
-
* @param videoTrackId video track Id
|
|
67
|
-
* @param options encoding options or preset
|
|
73
|
+
* @param opts WebOptions
|
|
68
74
|
*/
|
|
69
|
-
|
|
75
|
+
startWebEgress(url, output, opts) {
|
|
70
76
|
return __awaiter(this, void 0, void 0, function* () {
|
|
77
|
+
const audioOnly = (opts === null || opts === void 0 ? void 0 : opts.audioOnly) || false;
|
|
78
|
+
const videoOnly = (opts === null || opts === void 0 ? void 0 : opts.videoOnly) || false;
|
|
79
|
+
const { file, segments, stream, preset, advanced } = this.getOutputParams(output, opts === null || opts === void 0 ? void 0 : opts.encodingOptions);
|
|
80
|
+
const req = livekit_egress_1.WebEgressRequest.toJSON({
|
|
81
|
+
url,
|
|
82
|
+
audioOnly,
|
|
83
|
+
videoOnly,
|
|
84
|
+
file,
|
|
85
|
+
stream,
|
|
86
|
+
segments,
|
|
87
|
+
preset,
|
|
88
|
+
advanced,
|
|
89
|
+
});
|
|
90
|
+
const data = yield this.rpc.request(svc, 'StartWebEgress', req, this.authHeader({ roomRecord: true }));
|
|
91
|
+
return livekit_egress_1.EgressInfo.fromJSON(data);
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
startTrackCompositeEgress(roomName, output, optsOrAudioTrackId, videoTrackId, options) {
|
|
95
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
96
|
+
let audioTrackId;
|
|
97
|
+
if (optsOrAudioTrackId !== undefined) {
|
|
98
|
+
if (typeof optsOrAudioTrackId === 'string') {
|
|
99
|
+
audioTrackId = optsOrAudioTrackId;
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
const opts = optsOrAudioTrackId;
|
|
103
|
+
audioTrackId = opts.audioTrackId;
|
|
104
|
+
videoTrackId = opts.videoTrackId;
|
|
105
|
+
options = opts.encodingOptions;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
71
108
|
audioTrackId !== null && audioTrackId !== void 0 ? audioTrackId : (audioTrackId = '');
|
|
72
109
|
videoTrackId !== null && videoTrackId !== void 0 ? videoTrackId : (videoTrackId = '');
|
|
73
110
|
const { file, segments, stream, preset, advanced } = this.getOutputParams(output, options);
|
|
@@ -162,10 +199,11 @@ class EgressClient {
|
|
|
162
199
|
* @param roomName list egress for one room only
|
|
163
200
|
*/
|
|
164
201
|
listEgress(roomName) {
|
|
202
|
+
var _a;
|
|
165
203
|
return __awaiter(this, void 0, void 0, function* () {
|
|
166
204
|
roomName !== null && roomName !== void 0 ? roomName : (roomName = '');
|
|
167
205
|
const data = yield this.rpc.request(svc, 'ListEgress', livekit_egress_1.ListEgressRequest.toJSON({ roomName }), this.authHeader({ roomRecord: true }));
|
|
168
|
-
return livekit_egress_1.ListEgressResponse.fromJSON(data).items;
|
|
206
|
+
return (_a = livekit_egress_1.ListEgressResponse.fromJSON(data).items) !== null && _a !== void 0 ? _a : [];
|
|
169
207
|
});
|
|
170
208
|
}
|
|
171
209
|
/**
|
|
@@ -177,13 +215,6 @@ class EgressClient {
|
|
|
177
215
|
return livekit_egress_1.EgressInfo.fromJSON(data);
|
|
178
216
|
});
|
|
179
217
|
}
|
|
180
|
-
authHeader(grant) {
|
|
181
|
-
const at = new AccessToken_1.AccessToken(this.apiKey, this.secret, { ttl: '10m' });
|
|
182
|
-
at.addGrant(grant);
|
|
183
|
-
return {
|
|
184
|
-
Authorization: `Bearer ${at.toJwt()}`,
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
218
|
}
|
|
188
|
-
exports.
|
|
219
|
+
exports.EgressClient = EgressClient;
|
|
189
220
|
//# sourceMappingURL=EgressClient.js.map
|
package/dist/EgressClient.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EgressClient.js","sourceRoot":"","sources":["../src/EgressClient.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"EgressClient.js","sourceRoot":"","sources":["../src/EgressClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2DAiBgC;AAChC,gEAAwC;AACxC,yCAA2D;AAE3D,MAAM,GAAG,GAAG,QAAQ,CAAC;AAuDrB;;GAEG;AACH,MAAa,YAAa,SAAQ,qBAAW;IAG3C;;;;OAIG;IACH,YAAY,IAAY,EAAE,MAAe,EAAE,MAAe;QACxD,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACtB,IAAI,CAAC,GAAG,GAAG,IAAI,mBAAQ,CAAC,IAAI,EAAE,yBAAc,CAAC,CAAC;IAChD,CAAC;IAwBK,wBAAwB,CAC5B,QAAgB,EAChB,MAA8D,EAC9D,YAA4C,EAC5C,OAAiD,EACjD,SAAmB,EACnB,SAAmB,EACnB,aAAsB;;YAEtB,IAAI,MAA0B,CAAC;YAC/B,IAAI,YAAY,KAAK,SAAS,EAAE;gBAC9B,IAAI,OAAO,YAAY,KAAK,QAAQ,EAAE;oBACpC,MAAM,GAAG,YAAY,CAAC;iBACvB;qBAAM;oBACL,MAAM,IAAI,GAAyB,YAAY,CAAC;oBAChD,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;oBACrB,OAAO,GAAG,IAAI,CAAC,eAAe,CAAC;oBAC/B,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;oBAC3B,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;oBAC3B,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC;iBACpC;aACF;YAED,MAAM,aAAN,MAAM,cAAN,MAAM,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C,CAAC;KAAA;IAED;;OAEG;IACG,UAAU,CAAC,QAAiB;;;YAChC,QAAQ,aAAR,QAAQ,cAAR,QAAQ,IAAR,QAAQ,GAAK,EAAE,EAAC;YAEhB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,OAAO,CACjC,GAAG,EACH,YAAY,EACZ,kCAAiB,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,CAAC,EACtC,IAAI,CAAC,UAAU,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CACtC,CAAC;YACF,OAAO,MAAA,mCAAkB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,KAAK,mCAAI,EAAE,CAAC;;KACtD;IAED;;OAEG;IACG,UAAU,CAAC,QAAgB;;YAC/B,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,OAAO,CACjC,GAAG,EACH,YAAY,EACZ,kCAAiB,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,CAAC,EACtC,IAAI,CAAC,UAAU,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CACtC,CAAC;YACF,OAAO,2BAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACnC,CAAC;KAAA;CACF;AAxTD,oCAwTC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { IngressAudioOptions, IngressInfo, IngressInput, IngressVideoOptions } from './proto/livekit_ingress';
|
|
2
|
+
import ServiceBase from './ServiceBase';
|
|
3
|
+
export interface CreateIngressOptions {
|
|
4
|
+
/**
|
|
5
|
+
* ingress name. optional
|
|
6
|
+
*/
|
|
7
|
+
name?: string;
|
|
8
|
+
/**
|
|
9
|
+
* name of the room to send media to. optional
|
|
10
|
+
*/
|
|
11
|
+
roomName?: string;
|
|
12
|
+
/**
|
|
13
|
+
* unique identity of the participant. optional
|
|
14
|
+
*/
|
|
15
|
+
participantIdentity?: string;
|
|
16
|
+
/**
|
|
17
|
+
* participant display name
|
|
18
|
+
*/
|
|
19
|
+
participantName?: string;
|
|
20
|
+
/**
|
|
21
|
+
* custom audio encoding parameters. optional
|
|
22
|
+
*/
|
|
23
|
+
audioParams?: IngressAudioOptions;
|
|
24
|
+
/**
|
|
25
|
+
* custom video encoding parameters. optional
|
|
26
|
+
*/
|
|
27
|
+
videoParams?: IngressVideoOptions;
|
|
28
|
+
}
|
|
29
|
+
export interface UpdateIngressOptions {
|
|
30
|
+
/**
|
|
31
|
+
* ingress name. optional
|
|
32
|
+
*/
|
|
33
|
+
name: string;
|
|
34
|
+
/**
|
|
35
|
+
* name of the room to send media to. optional
|
|
36
|
+
*/
|
|
37
|
+
roomName?: string;
|
|
38
|
+
/**
|
|
39
|
+
* unique identity of the participant. optional
|
|
40
|
+
*/
|
|
41
|
+
participantIdentity?: string;
|
|
42
|
+
/**
|
|
43
|
+
* participant display name
|
|
44
|
+
*/
|
|
45
|
+
participantName?: string;
|
|
46
|
+
/**
|
|
47
|
+
* custom audio encoding parameters. optional
|
|
48
|
+
*/
|
|
49
|
+
audioParams?: IngressAudioOptions;
|
|
50
|
+
/**
|
|
51
|
+
* custom video encoding parameters. optional
|
|
52
|
+
*/
|
|
53
|
+
videoParams?: IngressVideoOptions;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Client to access Ingress APIs
|
|
57
|
+
*/
|
|
58
|
+
export declare class IngressClient extends ServiceBase {
|
|
59
|
+
private readonly rpc;
|
|
60
|
+
/**
|
|
61
|
+
* @param host hostname including protocol. i.e. 'https://cluster.livekit.io'
|
|
62
|
+
* @param apiKey API Key, can be set in env var LIVEKIT_API_KEY
|
|
63
|
+
* @param secret API Secret, can be set in env var LIVEKIT_API_SECRET
|
|
64
|
+
*/
|
|
65
|
+
constructor(host: string, apiKey?: string, secret?: string);
|
|
66
|
+
/**
|
|
67
|
+
* @param inputType protocol for the ingress
|
|
68
|
+
* @param opts CreateIngressOptions
|
|
69
|
+
*/
|
|
70
|
+
createIngress(inputType: IngressInput, opts?: CreateIngressOptions): Promise<IngressInfo>;
|
|
71
|
+
/**
|
|
72
|
+
* @param ingressId ID of the ingress to update
|
|
73
|
+
* @param opts UpdateIngressOptions
|
|
74
|
+
*/
|
|
75
|
+
updateIngress(ingressId: string, opts: UpdateIngressOptions): Promise<IngressInfo>;
|
|
76
|
+
/**
|
|
77
|
+
* @param roomName list ingress for one room only
|
|
78
|
+
*/
|
|
79
|
+
listIngress(roomName?: string): Promise<Array<IngressInfo>>;
|
|
80
|
+
/**
|
|
81
|
+
* @param ingressId ingress to delete
|
|
82
|
+
*/
|
|
83
|
+
deleteIngress(ingressId: string): Promise<IngressInfo>;
|
|
84
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.IngressClient = void 0;
|
|
16
|
+
const livekit_ingress_1 = require("./proto/livekit_ingress");
|
|
17
|
+
const ServiceBase_1 = __importDefault(require("./ServiceBase"));
|
|
18
|
+
const TwirpRPC_1 = require("./TwirpRPC");
|
|
19
|
+
const svc = 'Ingress';
|
|
20
|
+
/**
|
|
21
|
+
* Client to access Ingress APIs
|
|
22
|
+
*/
|
|
23
|
+
class IngressClient extends ServiceBase_1.default {
|
|
24
|
+
/**
|
|
25
|
+
* @param host hostname including protocol. i.e. 'https://cluster.livekit.io'
|
|
26
|
+
* @param apiKey API Key, can be set in env var LIVEKIT_API_KEY
|
|
27
|
+
* @param secret API Secret, can be set in env var LIVEKIT_API_SECRET
|
|
28
|
+
*/
|
|
29
|
+
constructor(host, apiKey, secret) {
|
|
30
|
+
super(apiKey, secret);
|
|
31
|
+
this.rpc = new TwirpRPC_1.TwirpRpc(host, TwirpRPC_1.livekitPackage);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* @param inputType protocol for the ingress
|
|
35
|
+
* @param opts CreateIngressOptions
|
|
36
|
+
*/
|
|
37
|
+
createIngress(inputType, opts) {
|
|
38
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
let name = '';
|
|
40
|
+
let roomName = '';
|
|
41
|
+
let participantName = '';
|
|
42
|
+
let participantIdentity = '';
|
|
43
|
+
let audio;
|
|
44
|
+
let video;
|
|
45
|
+
if (opts !== undefined) {
|
|
46
|
+
name = opts.name || '';
|
|
47
|
+
roomName = opts.roomName || '';
|
|
48
|
+
participantName = opts.participantName || '';
|
|
49
|
+
participantIdentity = opts.participantIdentity || '';
|
|
50
|
+
audio = opts.audioParams;
|
|
51
|
+
video = opts.videoParams;
|
|
52
|
+
}
|
|
53
|
+
const req = livekit_ingress_1.CreateIngressRequest.toJSON({
|
|
54
|
+
inputType,
|
|
55
|
+
name,
|
|
56
|
+
roomName,
|
|
57
|
+
participantIdentity,
|
|
58
|
+
participantName,
|
|
59
|
+
audio,
|
|
60
|
+
video,
|
|
61
|
+
});
|
|
62
|
+
const data = yield this.rpc.request(svc, 'CreateIngress', req, this.authHeader({ ingressAdmin: true }));
|
|
63
|
+
return livekit_ingress_1.IngressInfo.fromJSON(data);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* @param ingressId ID of the ingress to update
|
|
68
|
+
* @param opts UpdateIngressOptions
|
|
69
|
+
*/
|
|
70
|
+
updateIngress(ingressId, opts) {
|
|
71
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
72
|
+
const name = opts.name || '';
|
|
73
|
+
const roomName = opts.roomName || '';
|
|
74
|
+
const participantName = opts.participantName || '';
|
|
75
|
+
const participantIdentity = opts.participantIdentity || '';
|
|
76
|
+
const audio = opts.audioParams;
|
|
77
|
+
const video = opts.videoParams;
|
|
78
|
+
const req = livekit_ingress_1.UpdateIngressRequest.toJSON({
|
|
79
|
+
ingressId,
|
|
80
|
+
name,
|
|
81
|
+
roomName,
|
|
82
|
+
participantIdentity,
|
|
83
|
+
participantName,
|
|
84
|
+
audio,
|
|
85
|
+
video,
|
|
86
|
+
});
|
|
87
|
+
const data = yield this.rpc.request(svc, 'UpdateIngress', req, this.authHeader({ ingressAdmin: true }));
|
|
88
|
+
return livekit_ingress_1.IngressInfo.fromJSON(data);
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* @param roomName list ingress for one room only
|
|
93
|
+
*/
|
|
94
|
+
listIngress(roomName) {
|
|
95
|
+
var _a;
|
|
96
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
97
|
+
roomName !== null && roomName !== void 0 ? roomName : (roomName = '');
|
|
98
|
+
const data = yield this.rpc.request(svc, 'ListIngress', livekit_ingress_1.ListIngressRequest.toJSON({ roomName }), this.authHeader({ ingressAdmin: true }));
|
|
99
|
+
return (_a = livekit_ingress_1.ListIngressResponse.fromJSON(data).items) !== null && _a !== void 0 ? _a : [];
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* @param ingressId ingress to delete
|
|
104
|
+
*/
|
|
105
|
+
deleteIngress(ingressId) {
|
|
106
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
107
|
+
const data = yield this.rpc.request(svc, 'DeleteIngress', livekit_ingress_1.DeleteIngressRequest.toJSON({ ingressId }), this.authHeader({ ingressAdmin: true }));
|
|
108
|
+
return livekit_ingress_1.IngressInfo.fromJSON(data);
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
exports.IngressClient = IngressClient;
|
|
113
|
+
//# sourceMappingURL=IngressClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IngressClient.js","sourceRoot":"","sources":["../src/IngressClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6DAUiC;AACjC,gEAAwC;AACxC,yCAA2D;AAE3D,MAAM,GAAG,GAAG,SAAS,CAAC;AAwDtB;;GAEG;AACH,MAAa,aAAc,SAAQ,qBAAW;IAG5C;;;;OAIG;IACH,YAAY,IAAY,EAAE,MAAe,EAAE,MAAe;QACxD,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACtB,IAAI,CAAC,GAAG,GAAG,IAAI,mBAAQ,CAAC,IAAI,EAAE,yBAAc,CAAC,CAAC;IAChD,CAAC;IAED;;;OAGG;IACG,aAAa,CAAC,SAAuB,EAAE,IAA2B;;YACtE,IAAI,IAAI,GAAW,EAAE,CAAC;YACtB,IAAI,QAAQ,GAAW,EAAE,CAAC;YAC1B,IAAI,eAAe,GAAW,EAAE,CAAC;YACjC,IAAI,mBAAmB,GAAW,EAAE,CAAC;YACrC,IAAI,KAAsC,CAAC;YAC3C,IAAI,KAAsC,CAAC;YAE3C,IAAI,IAAI,KAAK,SAAS,EAAE;gBACtB,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC;gBACvB,QAAQ,GAAG,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAC;gBAC/B,eAAe,GAAG,IAAI,CAAC,eAAe,IAAI,EAAE,CAAC;gBAC7C,mBAAmB,GAAG,IAAI,CAAC,mBAAmB,IAAI,EAAE,CAAC;gBACrD,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC;gBACzB,KAAK,GAAG,IAAI,CAAC,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;OAEG;IACG,WAAW,CAAC,QAAiB;;;YACjC,QAAQ,aAAR,QAAQ,cAAR,QAAQ,IAAR,QAAQ,GAAK,EAAE,EAAC;YAEhB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,OAAO,CACjC,GAAG,EACH,aAAa,EACb,oCAAkB,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,CAAC,EACvC,IAAI,CAAC,UAAU,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CACxC,CAAC;YACF,OAAO,MAAA,qCAAmB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,KAAK,mCAAI,EAAE,CAAC;;KACvD;IAED;;OAEG;IACG,aAAa,CAAC,SAAiB;;YACnC,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,OAAO,CACjC,GAAG,EACH,eAAe,EACf,sCAAoB,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC,EAC1C,IAAI,CAAC,UAAU,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CACxC,CAAC;YACF,OAAO,6BAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACpC,CAAC;KAAA;CACF;AA/GD,sCA+GC"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { DataPacket_Kind, ParticipantInfo, ParticipantPermission, Room, TrackInfo } from './proto/livekit_models';
|
|
2
|
+
import { RoomEgress } from './proto/livekit_room';
|
|
3
|
+
import ServiceBase from './ServiceBase';
|
|
2
4
|
/**
|
|
3
5
|
* Options for when creating a room
|
|
4
6
|
*/
|
|
@@ -8,7 +10,7 @@ export interface CreateOptions {
|
|
|
8
10
|
*/
|
|
9
11
|
name: string;
|
|
10
12
|
/**
|
|
11
|
-
* number of seconds the room should
|
|
13
|
+
* number of seconds the room should clean up after being empty
|
|
12
14
|
*/
|
|
13
15
|
emptyTimeout?: number;
|
|
14
16
|
/**
|
|
@@ -19,14 +21,16 @@ export interface CreateOptions {
|
|
|
19
21
|
* override the node room is allocated to, for debugging
|
|
20
22
|
*/
|
|
21
23
|
nodeId?: string;
|
|
24
|
+
/**
|
|
25
|
+
* add egress options
|
|
26
|
+
*/
|
|
27
|
+
egress?: RoomEgress;
|
|
22
28
|
}
|
|
23
29
|
/**
|
|
24
30
|
* Client to access Room APIs
|
|
25
31
|
*/
|
|
26
|
-
export declare class RoomServiceClient {
|
|
32
|
+
export declare class RoomServiceClient extends ServiceBase {
|
|
27
33
|
private readonly rpc;
|
|
28
|
-
private readonly apiKey?;
|
|
29
|
-
private readonly secret?;
|
|
30
34
|
/**
|
|
31
35
|
*
|
|
32
36
|
* @param host hostname including protocol. i.e. 'https://cluster.livekit.io'
|
|
@@ -89,8 +93,9 @@ export declare class RoomServiceClient {
|
|
|
89
93
|
* @param identity
|
|
90
94
|
* @param metadata optional, metadata to update
|
|
91
95
|
* @param permission optional, new permissions to assign to participant
|
|
96
|
+
* @param name optional, new name for participant
|
|
92
97
|
*/
|
|
93
|
-
updateParticipant(room: string, identity: string, metadata?: string, permission?: ParticipantPermission): Promise<ParticipantInfo>;
|
|
98
|
+
updateParticipant(room: string, identity: string, metadata?: string, permission?: ParticipantPermission, name?: string): Promise<ParticipantInfo>;
|
|
94
99
|
/**
|
|
95
100
|
* Updates a participant's subscription to tracks
|
|
96
101
|
* @param room
|
|
@@ -107,5 +112,4 @@ export declare class RoomServiceClient {
|
|
|
107
112
|
* @param destinationSids optional. when empty, message is sent to everyone
|
|
108
113
|
*/
|
|
109
114
|
sendData(room: string, data: Uint8Array, kind: DataPacket_Kind, destinationSids?: string[]): Promise<void>;
|
|
110
|
-
private authHeader;
|
|
111
115
|
}
|
|
@@ -8,17 +8,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
15
|
exports.RoomServiceClient = void 0;
|
|
13
|
-
const AccessToken_1 = require("./AccessToken");
|
|
14
16
|
const livekit_models_1 = require("./proto/livekit_models");
|
|
15
17
|
const livekit_room_1 = require("./proto/livekit_room");
|
|
18
|
+
const ServiceBase_1 = __importDefault(require("./ServiceBase"));
|
|
16
19
|
const TwirpRPC_1 = require("./TwirpRPC");
|
|
17
20
|
const svc = 'RoomService';
|
|
18
21
|
/**
|
|
19
22
|
* Client to access Room APIs
|
|
20
23
|
*/
|
|
21
|
-
class RoomServiceClient {
|
|
24
|
+
class RoomServiceClient extends ServiceBase_1.default {
|
|
22
25
|
/**
|
|
23
26
|
*
|
|
24
27
|
* @param host hostname including protocol. i.e. 'https://cluster.livekit.io'
|
|
@@ -26,9 +29,8 @@ class RoomServiceClient {
|
|
|
26
29
|
* @param secret API Secret, can be set in env var LIVEKIT_API_SECRET
|
|
27
30
|
*/
|
|
28
31
|
constructor(host, apiKey, secret) {
|
|
32
|
+
super(apiKey, secret);
|
|
29
33
|
this.rpc = new TwirpRPC_1.TwirpRpc(host, TwirpRPC_1.livekitPackage);
|
|
30
|
-
this.apiKey = apiKey;
|
|
31
|
-
this.secret = secret;
|
|
32
34
|
}
|
|
33
35
|
/**
|
|
34
36
|
* Creates a new room. Explicit room creation is not required, since rooms will
|
|
@@ -49,10 +51,11 @@ class RoomServiceClient {
|
|
|
49
51
|
* @returns
|
|
50
52
|
*/
|
|
51
53
|
listRooms(names) {
|
|
54
|
+
var _a;
|
|
52
55
|
return __awaiter(this, void 0, void 0, function* () {
|
|
53
56
|
const data = yield this.rpc.request(svc, 'ListRooms', livekit_room_1.ListRoomsRequest.toJSON({ names: names !== null && names !== void 0 ? names : [] }), this.authHeader({ roomList: true }));
|
|
54
57
|
const res = livekit_room_1.ListRoomsResponse.fromJSON(data);
|
|
55
|
-
return res.rooms;
|
|
58
|
+
return (_a = res.rooms) !== null && _a !== void 0 ? _a : [];
|
|
56
59
|
});
|
|
57
60
|
}
|
|
58
61
|
deleteRoom(room) {
|
|
@@ -76,10 +79,11 @@ class RoomServiceClient {
|
|
|
76
79
|
* @param room name of the room
|
|
77
80
|
*/
|
|
78
81
|
listParticipants(room) {
|
|
82
|
+
var _a;
|
|
79
83
|
return __awaiter(this, void 0, void 0, function* () {
|
|
80
84
|
const data = yield this.rpc.request(svc, 'ListParticipants', livekit_room_1.ListParticipantsRequest.toJSON({ room }), this.authHeader({ roomAdmin: true, room }));
|
|
81
85
|
const res = livekit_room_1.ListParticipantsResponse.fromJSON(data);
|
|
82
|
-
return res.participants;
|
|
86
|
+
return (_a = res.participants) !== null && _a !== void 0 ? _a : [];
|
|
83
87
|
});
|
|
84
88
|
}
|
|
85
89
|
/**
|
|
@@ -132,14 +136,16 @@ class RoomServiceClient {
|
|
|
132
136
|
* @param identity
|
|
133
137
|
* @param metadata optional, metadata to update
|
|
134
138
|
* @param permission optional, new permissions to assign to participant
|
|
139
|
+
* @param name optional, new name for participant
|
|
135
140
|
*/
|
|
136
|
-
updateParticipant(room, identity, metadata, permission) {
|
|
141
|
+
updateParticipant(room, identity, metadata, permission, name) {
|
|
137
142
|
return __awaiter(this, void 0, void 0, function* () {
|
|
138
143
|
const req = {
|
|
139
144
|
room,
|
|
140
145
|
identity,
|
|
141
146
|
metadata: metadata || '',
|
|
142
147
|
permission,
|
|
148
|
+
name: name || '',
|
|
143
149
|
};
|
|
144
150
|
const data = yield this.rpc.request(svc, 'UpdateParticipant', livekit_room_1.UpdateParticipantRequest.toJSON(req), this.authHeader({ roomAdmin: true, room }));
|
|
145
151
|
return livekit_models_1.ParticipantInfo.fromJSON(data);
|
|
@@ -182,13 +188,6 @@ class RoomServiceClient {
|
|
|
182
188
|
yield this.rpc.request(svc, 'SendData', req, this.authHeader({ roomAdmin: true, room }));
|
|
183
189
|
});
|
|
184
190
|
}
|
|
185
|
-
authHeader(grant) {
|
|
186
|
-
const at = new AccessToken_1.AccessToken(this.apiKey, this.secret, { ttl: '10m' });
|
|
187
|
-
at.addGrant(grant);
|
|
188
|
-
return {
|
|
189
|
-
Authorization: `Bearer ${at.toJwt()}`,
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
191
|
}
|
|
193
192
|
exports.RoomServiceClient = RoomServiceClient;
|
|
194
193
|
//# sourceMappingURL=RoomServiceClient.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RoomServiceClient.js","sourceRoot":"","sources":["../src/RoomServiceClient.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"RoomServiceClient.js","sourceRoot":"","sources":["../src/RoomServiceClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2DAMgC;AAChC,uDAe8B;AAC9B,gEAAwC;AACxC,yCAA2D;AAgC3D,MAAM,GAAG,GAAG,aAAa,CAAC;AAE1B;;GAEG;AACH,MAAa,iBAAkB,SAAQ,qBAAW;IAGhD;;;;;OAKG;IACH,YAAY,IAAY,EAAE,MAAe,EAAE,MAAe;QACxD,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACtB,IAAI,CAAC,GAAG,GAAG,IAAI,mBAAQ,CAAC,IAAI,EAAE,yBAAc,CAAC,CAAC;IAChD,CAAC;IAED;;;;;OAKG;IACG,UAAU,CAAC,OAAsB;;YACrC,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,OAAO,CACjC,GAAG,EACH,YAAY,EACZ,gCAAiB,CAAC,MAAM,CAAC,gCAAiB,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,EAChE,IAAI,CAAC,UAAU,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CACtC,CAAC;YACF,OAAO,qBAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC7B,CAAC;KAAA;IAED;;;;;OAKG;IACG,SAAS,CAAC,KAAgB;;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