livekit-server-sdk 1.2.6 → 2.0.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/.changeset/README.md +8 -0
- package/.changeset/config.json +11 -0
- package/.github/workflows/release.yaml +46 -0
- package/.github/workflows/test.yaml +21 -21
- package/.prettierignore +1 -0
- package/CHANGELOG.md +23 -0
- package/NOTICE +13 -0
- package/README.md +47 -13
- package/dist/AccessToken.d.ts +4 -4
- package/dist/AccessToken.js +23 -42
- package/dist/AccessToken.js.map +1 -1
- package/dist/EgressClient.d.ts +21 -2
- package/dist/EgressClient.js +183 -170
- package/dist/EgressClient.js.map +1 -1
- package/dist/IngressClient.d.ts +17 -2
- package/dist/IngressClient.js +68 -89
- package/dist/IngressClient.js.map +1 -1
- package/dist/RoomServiceClient.d.ts +22 -5
- package/dist/RoomServiceClient.js +70 -105
- package/dist/RoomServiceClient.js.map +1 -1
- package/dist/ServiceBase.d.ts +2 -2
- package/dist/ServiceBase.js +5 -8
- package/dist/ServiceBase.js.map +1 -1
- package/dist/TwirpRPC.d.ts +2 -3
- package/dist/TwirpRPC.js +15 -23
- package/dist/TwirpRPC.js.map +1 -1
- package/dist/WebhookReceiver.d.ts +15 -2
- package/dist/WebhookReceiver.js +29 -19
- package/dist/WebhookReceiver.js.map +1 -1
- package/dist/grants.d.ts +2 -1
- package/dist/grants.js +2 -5
- package/dist/grants.js.map +1 -1
- package/dist/index.d.ts +9 -10
- package/dist/index.js +9 -48
- package/dist/index.js.map +1 -1
- package/dist/proto/livekit_egress_pb.d.ts +1650 -0
- package/dist/proto/livekit_egress_pb.js +1878 -0
- package/dist/proto/livekit_egress_pb.js.map +1 -0
- package/dist/proto/livekit_ingress_pb.d.ts +624 -0
- package/dist/proto/livekit_ingress_pb.js +824 -0
- package/dist/proto/livekit_ingress_pb.js.map +1 -0
- package/dist/proto/livekit_models_pb.d.ts +1349 -0
- package/dist/proto/livekit_models_pb.js +1829 -0
- package/dist/proto/livekit_models_pb.js.map +1 -0
- package/dist/proto/livekit_room_pb.d.ts +460 -0
- package/dist/proto/livekit_room_pb.js +695 -0
- package/dist/proto/livekit_room_pb.js.map +1 -0
- package/dist/proto/livekit_webhook_pb.d.ts +70 -0
- package/dist/proto/livekit_webhook_pb.js +76 -0
- package/dist/proto/livekit_webhook_pb.js.map +1 -0
- package/generate-proto.sh +1 -18
- package/package.json +32 -28
- package/tsconfig.eslint.json +2 -1
- package/vite.config.js +8 -0
- package/.github/workflows/publish.yaml +0 -57
- package/dist/AccessToken.test.d.ts +0 -1
- package/dist/AccessToken.test.js +0 -72
- package/dist/AccessToken.test.js.map +0 -1
- package/dist/WebhookReceiver.test.d.ts +0 -1
- package/dist/WebhookReceiver.test.js +0 -39
- package/dist/WebhookReceiver.test.js.map +0 -1
- package/dist/proto/google/protobuf/timestamp.d.ts +0 -132
- package/dist/proto/google/protobuf/timestamp.js +0 -92
- package/dist/proto/google/protobuf/timestamp.js.map +0 -1
- package/dist/proto/livekit_egress.d.ts +0 -11286
- package/dist/proto/livekit_egress.js +0 -2889
- package/dist/proto/livekit_egress.js.map +0 -1
- package/dist/proto/livekit_ingress.d.ts +0 -2249
- package/dist/proto/livekit_ingress.js +0 -1360
- package/dist/proto/livekit_ingress.js.map +0 -1
- package/dist/proto/livekit_models.d.ts +0 -1454
- package/dist/proto/livekit_models.js +0 -3066
- package/dist/proto/livekit_models.js.map +0 -1
- package/dist/proto/livekit_room.d.ts +0 -3316
- package/dist/proto/livekit_room.js +0 -1074
- package/dist/proto/livekit_room.js.map +0 -1
- package/dist/proto/livekit_webhook.d.ts +0 -4899
- package/dist/proto/livekit_webhook.js +0 -179
- package/dist/proto/livekit_webhook.js.map +0 -1
- /package/{.eslintrc.js → .eslintrc.cjs} +0 -0
package/dist/IngressClient.js
CHANGED
|
@@ -1,26 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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");
|
|
1
|
+
import { CreateIngressRequest, DeleteIngressRequest, IngressInfo, ListIngressRequest, ListIngressResponse, UpdateIngressRequest, } from './proto/livekit_ingress_pb.js';
|
|
2
|
+
import ServiceBase from './ServiceBase.js';
|
|
3
|
+
import { livekitPackage, TwirpRpc } from './TwirpRPC.js';
|
|
19
4
|
const svc = 'Ingress';
|
|
20
5
|
/**
|
|
21
6
|
* Client to access Ingress APIs
|
|
22
7
|
*/
|
|
23
|
-
class IngressClient extends
|
|
8
|
+
export class IngressClient extends ServiceBase {
|
|
24
9
|
/**
|
|
25
10
|
* @param host hostname including protocol. i.e. 'https://cluster.livekit.io'
|
|
26
11
|
* @param apiKey API Key, can be set in env var LIVEKIT_API_KEY
|
|
@@ -28,92 +13,86 @@ class IngressClient extends ServiceBase_1.default {
|
|
|
28
13
|
*/
|
|
29
14
|
constructor(host, apiKey, secret) {
|
|
30
15
|
super(apiKey, secret);
|
|
31
|
-
this.rpc = new
|
|
16
|
+
this.rpc = new TwirpRpc(host, livekitPackage);
|
|
32
17
|
}
|
|
33
18
|
/**
|
|
34
19
|
* @param inputType protocol for the ingress
|
|
35
20
|
* @param opts CreateIngressOptions
|
|
36
21
|
*/
|
|
37
|
-
createIngress(inputType, opts) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
return livekit_ingress_1.IngressInfo.fromJSON(data);
|
|
70
|
-
});
|
|
22
|
+
async createIngress(inputType, opts) {
|
|
23
|
+
let name = '';
|
|
24
|
+
let roomName = '';
|
|
25
|
+
let participantName = '';
|
|
26
|
+
let participantIdentity = '';
|
|
27
|
+
let bypassTranscoding = false;
|
|
28
|
+
let url = '';
|
|
29
|
+
let audio;
|
|
30
|
+
let video;
|
|
31
|
+
if (opts !== undefined) {
|
|
32
|
+
name = opts.name || '';
|
|
33
|
+
roomName = opts.roomName || '';
|
|
34
|
+
participantName = opts.participantName || '';
|
|
35
|
+
participantIdentity = opts.participantIdentity || '';
|
|
36
|
+
bypassTranscoding = opts.bypassTranscoding || false;
|
|
37
|
+
url = opts.url || '';
|
|
38
|
+
audio = opts.audio;
|
|
39
|
+
video = opts.video;
|
|
40
|
+
}
|
|
41
|
+
const req = new CreateIngressRequest({
|
|
42
|
+
inputType,
|
|
43
|
+
name,
|
|
44
|
+
roomName,
|
|
45
|
+
participantIdentity,
|
|
46
|
+
participantName,
|
|
47
|
+
bypassTranscoding,
|
|
48
|
+
url,
|
|
49
|
+
audio,
|
|
50
|
+
video,
|
|
51
|
+
}).toJson();
|
|
52
|
+
const data = await this.rpc.request(svc, 'CreateIngress', req, await this.authHeader({ ingressAdmin: true }));
|
|
53
|
+
return IngressInfo.fromJson(data);
|
|
71
54
|
}
|
|
72
55
|
/**
|
|
73
56
|
* @param ingressId ID of the ingress to update
|
|
74
57
|
* @param opts UpdateIngressOptions
|
|
75
58
|
*/
|
|
76
|
-
updateIngress(ingressId, opts) {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
return livekit_ingress_1.IngressInfo.fromJSON(data);
|
|
95
|
-
});
|
|
59
|
+
async updateIngress(ingressId, opts) {
|
|
60
|
+
const name = opts.name || '';
|
|
61
|
+
const roomName = opts.roomName || '';
|
|
62
|
+
const participantName = opts.participantName || '';
|
|
63
|
+
const participantIdentity = opts.participantIdentity || '';
|
|
64
|
+
const { audio, video, bypassTranscoding } = opts;
|
|
65
|
+
const req = new UpdateIngressRequest({
|
|
66
|
+
ingressId,
|
|
67
|
+
name,
|
|
68
|
+
roomName,
|
|
69
|
+
participantIdentity,
|
|
70
|
+
participantName,
|
|
71
|
+
bypassTranscoding,
|
|
72
|
+
audio,
|
|
73
|
+
video,
|
|
74
|
+
}).toJson();
|
|
75
|
+
const data = await this.rpc.request(svc, 'UpdateIngress', req, await this.authHeader({ ingressAdmin: true }));
|
|
76
|
+
return IngressInfo.fromJson(data);
|
|
96
77
|
}
|
|
97
|
-
|
|
98
|
-
* @param roomName list ingress for one room only
|
|
99
|
-
*/
|
|
100
|
-
listIngress(roomName) {
|
|
78
|
+
async listIngress(arg) {
|
|
101
79
|
var _a;
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
80
|
+
let req = {};
|
|
81
|
+
if (typeof arg === 'string') {
|
|
82
|
+
req.roomName = arg;
|
|
83
|
+
}
|
|
84
|
+
else if (arg) {
|
|
85
|
+
req = arg;
|
|
86
|
+
}
|
|
87
|
+
const data = await this.rpc.request(svc, 'ListIngress', new ListIngressRequest(req).toJson(), await this.authHeader({ ingressAdmin: true }));
|
|
88
|
+
return (_a = ListIngressResponse.fromJson(data).items) !== null && _a !== void 0 ? _a : [];
|
|
107
89
|
}
|
|
108
90
|
/**
|
|
109
91
|
* @param ingressId ingress to delete
|
|
110
92
|
*/
|
|
111
|
-
deleteIngress(ingressId) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
return livekit_ingress_1.IngressInfo.fromJSON(data);
|
|
115
|
-
});
|
|
93
|
+
async deleteIngress(ingressId) {
|
|
94
|
+
const data = await this.rpc.request(svc, 'DeleteIngress', new DeleteIngressRequest({ ingressId }).toJson(), await this.authHeader({ ingressAdmin: true }));
|
|
95
|
+
return IngressInfo.fromJson(data);
|
|
116
96
|
}
|
|
117
97
|
}
|
|
118
|
-
exports.IngressClient = IngressClient;
|
|
119
98
|
//# sourceMappingURL=IngressClient.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IngressClient.js","sourceRoot":"","sources":["../src/IngressClient.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"IngressClient.js","sourceRoot":"","sources":["../src/IngressClient.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EAEpB,WAAW,EAGX,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,+BAA+B,CAAC;AACvC,OAAO,WAAW,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAO,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9D,MAAM,GAAG,GAAG,SAAS,CAAC;AAgFtB;;GAEG;AACH,MAAM,OAAO,aAAc,SAAQ,WAAW;IAG5C;;;;OAIG;IACH,YAAY,IAAY,EAAE,MAAe,EAAE,MAAe;QACxD,KAAK,CAAC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,GAAG,EACH,aAAa,EACb,IAAI,kBAAkB,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EACpC,MAAM,IAAI,CAAC,UAAU,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAC9C,CAAC;QACF,OAAO,MAAA,mBAAmB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,KAAK,mCAAI,EAAE,CAAC;IACxD,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,aAAa,CAAC,SAAiB;QACnC,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,OAAO,CACjC,GAAG,EACH,eAAe,EACf,IAAI,oBAAoB,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,EAChD,MAAM,IAAI,CAAC,UAAU,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAC9C,CAAC;QACF,OAAO,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IACpC,CAAC;CACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { DataPacket_Kind,
|
|
2
|
-
import { ParticipantInfo, ParticipantPermission, Room } from './proto/
|
|
3
|
-
import { RoomEgress } from './proto/
|
|
4
|
-
import ServiceBase from './ServiceBase';
|
|
1
|
+
import type { DataPacket_Kind, TrackInfo } from './proto/livekit_models_pb.js';
|
|
2
|
+
import { ParticipantInfo, ParticipantPermission, Room } from './proto/livekit_models_pb.js';
|
|
3
|
+
import { RoomEgress } from './proto/livekit_room_pb.js';
|
|
4
|
+
import ServiceBase from './ServiceBase.js';
|
|
5
5
|
/**
|
|
6
6
|
* Options for when creating a room
|
|
7
7
|
*/
|
|
@@ -26,6 +26,20 @@ export interface CreateOptions {
|
|
|
26
26
|
* add egress options
|
|
27
27
|
*/
|
|
28
28
|
egress?: RoomEgress;
|
|
29
|
+
/**
|
|
30
|
+
* minimum playout delay in milliseconds
|
|
31
|
+
*/
|
|
32
|
+
minPlayoutDelay?: number;
|
|
33
|
+
/**
|
|
34
|
+
* maximum playout delay in milliseconds
|
|
35
|
+
*/
|
|
36
|
+
maxPlayoutDelay?: number;
|
|
37
|
+
/**
|
|
38
|
+
* improves A/V sync when min_playout_delay set to a value larger than 200ms.
|
|
39
|
+
* It will disables transceiver re-use -- this option is not recommended
|
|
40
|
+
* for rooms with frequent subscription changes
|
|
41
|
+
*/
|
|
42
|
+
syncStreams?: boolean;
|
|
29
43
|
/**
|
|
30
44
|
* override the node room is allocated to, for debugging
|
|
31
45
|
* does not work with Cloud
|
|
@@ -33,6 +47,8 @@ export interface CreateOptions {
|
|
|
33
47
|
nodeId?: string;
|
|
34
48
|
}
|
|
35
49
|
export declare type SendDataOptions = {
|
|
50
|
+
/** If set, only deliver to listed participant identities */
|
|
51
|
+
destinationIdentities?: string[];
|
|
36
52
|
destinationSids?: string[];
|
|
37
53
|
topic?: string;
|
|
38
54
|
};
|
|
@@ -105,7 +121,7 @@ export declare class RoomServiceClient extends ServiceBase {
|
|
|
105
121
|
* @param permission optional, new permissions to assign to participant
|
|
106
122
|
* @param name optional, new name for participant
|
|
107
123
|
*/
|
|
108
|
-
updateParticipant(room: string, identity: string, metadata?: string, permission?:
|
|
124
|
+
updateParticipant(room: string, identity: string, metadata?: string, permission?: Partial<ParticipantPermission>, name?: string): Promise<ParticipantInfo>;
|
|
109
125
|
/**
|
|
110
126
|
* Updates a participant's subscription to tracks
|
|
111
127
|
* @param room
|
|
@@ -124,6 +140,7 @@ export declare class RoomServiceClient extends ServiceBase {
|
|
|
124
140
|
sendData(room: string, data: Uint8Array, kind: DataPacket_Kind, options: SendDataOptions): Promise<void>;
|
|
125
141
|
/**
|
|
126
142
|
* Sends data message to participants in the room
|
|
143
|
+
* @deprecated use sendData(room, data, kind, options) instead
|
|
127
144
|
* @param room
|
|
128
145
|
* @param data opaque payload to send
|
|
129
146
|
* @param kind delivery reliability
|
|
@@ -1,27 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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.RoomServiceClient = void 0;
|
|
16
|
-
const livekit_models_1 = require("./proto/livekit_models");
|
|
17
|
-
const livekit_room_1 = require("./proto/livekit_room");
|
|
18
|
-
const ServiceBase_1 = __importDefault(require("./ServiceBase"));
|
|
19
|
-
const TwirpRPC_1 = require("./TwirpRPC");
|
|
1
|
+
import { ParticipantInfo, ParticipantPermission, Room } from './proto/livekit_models_pb.js';
|
|
2
|
+
import { CreateRoomRequest, DeleteRoomRequest, ListParticipantsRequest, ListParticipantsResponse, ListRoomsRequest, ListRoomsResponse, MuteRoomTrackRequest, MuteRoomTrackResponse, RoomParticipantIdentity, SendDataRequest, UpdateParticipantRequest, UpdateRoomMetadataRequest, UpdateSubscriptionsRequest, } from './proto/livekit_room_pb.js';
|
|
3
|
+
import ServiceBase from './ServiceBase.js';
|
|
4
|
+
import { livekitPackage, TwirpRpc } from './TwirpRPC.js';
|
|
20
5
|
const svc = 'RoomService';
|
|
21
6
|
/**
|
|
22
7
|
* Client to access Room APIs
|
|
23
8
|
*/
|
|
24
|
-
class RoomServiceClient extends
|
|
9
|
+
export class RoomServiceClient extends ServiceBase {
|
|
25
10
|
/**
|
|
26
11
|
*
|
|
27
12
|
* @param host hostname including protocol. i.e. 'https://cluster.livekit.io'
|
|
@@ -30,7 +15,7 @@ class RoomServiceClient extends ServiceBase_1.default {
|
|
|
30
15
|
*/
|
|
31
16
|
constructor(host, apiKey, secret) {
|
|
32
17
|
super(apiKey, secret);
|
|
33
|
-
this.rpc = new
|
|
18
|
+
this.rpc = new TwirpRpc(host, livekitPackage);
|
|
34
19
|
}
|
|
35
20
|
/**
|
|
36
21
|
* Creates a new room. Explicit room creation is not required, since rooms will
|
|
@@ -38,11 +23,9 @@ class RoomServiceClient extends ServiceBase_1.default {
|
|
|
38
23
|
* used to customize room settings.
|
|
39
24
|
* @param options
|
|
40
25
|
*/
|
|
41
|
-
createRoom(options) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return livekit_models_1.Room.fromJSON(data);
|
|
45
|
-
});
|
|
26
|
+
async createRoom(options) {
|
|
27
|
+
const data = await this.rpc.request(svc, 'CreateRoom', new CreateRoomRequest(options).toJson(), await this.authHeader({ roomCreate: true }));
|
|
28
|
+
return Room.fromJson(data);
|
|
46
29
|
}
|
|
47
30
|
/**
|
|
48
31
|
* List active rooms
|
|
@@ -50,41 +33,33 @@ class RoomServiceClient extends ServiceBase_1.default {
|
|
|
50
33
|
* otherwise returns rooms with matching names
|
|
51
34
|
* @returns
|
|
52
35
|
*/
|
|
53
|
-
listRooms(names) {
|
|
36
|
+
async listRooms(names) {
|
|
54
37
|
var _a;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
return (_a = res.rooms) !== null && _a !== void 0 ? _a : [];
|
|
59
|
-
});
|
|
38
|
+
const data = await this.rpc.request(svc, 'ListRooms', new ListRoomsRequest({ names: names !== null && names !== void 0 ? names : [] }).toJson(), await this.authHeader({ roomList: true }));
|
|
39
|
+
const res = ListRoomsResponse.fromJson(data);
|
|
40
|
+
return (_a = res.rooms) !== null && _a !== void 0 ? _a : [];
|
|
60
41
|
}
|
|
61
|
-
deleteRoom(room) {
|
|
62
|
-
|
|
63
|
-
yield this.rpc.request(svc, 'DeleteRoom', livekit_room_1.DeleteRoomRequest.toJSON({ room }), this.authHeader({ roomCreate: true }));
|
|
64
|
-
});
|
|
42
|
+
async deleteRoom(room) {
|
|
43
|
+
await this.rpc.request(svc, 'DeleteRoom', new DeleteRoomRequest({ room }).toJson(), await this.authHeader({ roomCreate: true }));
|
|
65
44
|
}
|
|
66
45
|
/**
|
|
67
46
|
* Update metadata of a room
|
|
68
47
|
* @param room name of the room
|
|
69
48
|
* @param metadata the new metadata for the room
|
|
70
49
|
*/
|
|
71
|
-
updateRoomMetadata(room, metadata) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
return livekit_models_1.Room.fromJSON(data);
|
|
75
|
-
});
|
|
50
|
+
async updateRoomMetadata(room, metadata) {
|
|
51
|
+
const data = await this.rpc.request(svc, 'UpdateRoomMetadata', new UpdateRoomMetadataRequest({ room, metadata }).toJson(), await this.authHeader({ roomAdmin: true, room }));
|
|
52
|
+
return Room.fromJson(data);
|
|
76
53
|
}
|
|
77
54
|
/**
|
|
78
55
|
* List participants in a room
|
|
79
56
|
* @param room name of the room
|
|
80
57
|
*/
|
|
81
|
-
listParticipants(room) {
|
|
58
|
+
async listParticipants(room) {
|
|
82
59
|
var _a;
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
return (_a = res.participants) !== null && _a !== void 0 ? _a : [];
|
|
87
|
-
});
|
|
60
|
+
const data = await this.rpc.request(svc, 'ListParticipants', new ListParticipantsRequest({ room }).toJson(), await this.authHeader({ roomAdmin: true, room }));
|
|
61
|
+
const res = ListParticipantsResponse.fromJson(data);
|
|
62
|
+
return (_a = res.participants) !== null && _a !== void 0 ? _a : [];
|
|
88
63
|
}
|
|
89
64
|
/**
|
|
90
65
|
* Get information on a specific participant, including the tracks that participant
|
|
@@ -92,11 +67,9 @@ class RoomServiceClient extends ServiceBase_1.default {
|
|
|
92
67
|
* @param room name of the room
|
|
93
68
|
* @param identity identity of the participant to return
|
|
94
69
|
*/
|
|
95
|
-
getParticipant(room, identity) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
return livekit_models_1.ParticipantInfo.fromJSON(data);
|
|
99
|
-
});
|
|
70
|
+
async getParticipant(room, identity) {
|
|
71
|
+
const data = await this.rpc.request(svc, 'GetParticipant', new RoomParticipantIdentity({ room, identity }).toJson(), await this.authHeader({ roomAdmin: true, room }));
|
|
72
|
+
return ParticipantInfo.fromJson(data);
|
|
100
73
|
}
|
|
101
74
|
/**
|
|
102
75
|
* Removes a participant in the room. This will disconnect the participant
|
|
@@ -105,10 +78,8 @@ class RoomServiceClient extends ServiceBase_1.default {
|
|
|
105
78
|
* @param room
|
|
106
79
|
* @param identity
|
|
107
80
|
*/
|
|
108
|
-
removeParticipant(room, identity) {
|
|
109
|
-
|
|
110
|
-
yield this.rpc.request(svc, 'RemoveParticipant', livekit_room_1.RoomParticipantIdentity.toJSON({ room, identity }), this.authHeader({ roomAdmin: true, room }));
|
|
111
|
-
});
|
|
81
|
+
async removeParticipant(room, identity) {
|
|
82
|
+
await this.rpc.request(svc, 'RemoveParticipant', new RoomParticipantIdentity({ room, identity }).toJson(), await this.authHeader({ roomAdmin: true, room }));
|
|
112
83
|
}
|
|
113
84
|
/**
|
|
114
85
|
* Mutes a track that the participant has published.
|
|
@@ -117,18 +88,16 @@ class RoomServiceClient extends ServiceBase_1.default {
|
|
|
117
88
|
* @param trackSid sid of the track to be muted
|
|
118
89
|
* @param muted true to mute, false to unmute
|
|
119
90
|
*/
|
|
120
|
-
mutePublishedTrack(room, identity, trackSid, muted) {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
return res.track;
|
|
131
|
-
});
|
|
91
|
+
async mutePublishedTrack(room, identity, trackSid, muted) {
|
|
92
|
+
const req = new MuteRoomTrackRequest({
|
|
93
|
+
room,
|
|
94
|
+
identity,
|
|
95
|
+
trackSid,
|
|
96
|
+
muted,
|
|
97
|
+
}).toJson();
|
|
98
|
+
const data = await this.rpc.request(svc, 'MutePublishedTrack', req, await this.authHeader({ roomAdmin: true, room }));
|
|
99
|
+
const res = MuteRoomTrackResponse.fromJson(data);
|
|
100
|
+
return res.track;
|
|
132
101
|
}
|
|
133
102
|
/**
|
|
134
103
|
* Updates a participant's metadata or permissions
|
|
@@ -138,20 +107,18 @@ class RoomServiceClient extends ServiceBase_1.default {
|
|
|
138
107
|
* @param permission optional, new permissions to assign to participant
|
|
139
108
|
* @param name optional, new name for participant
|
|
140
109
|
*/
|
|
141
|
-
updateParticipant(room, identity, metadata, permission, name) {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
name: name || '',
|
|
148
|
-
};
|
|
149
|
-
if (permission) {
|
|
150
|
-
req.permission = livekit_models_1.ParticipantPermission.fromPartial(permission);
|
|
151
|
-
}
|
|
152
|
-
const data = yield this.rpc.request(svc, 'UpdateParticipant', livekit_room_1.UpdateParticipantRequest.toJSON(req), this.authHeader({ roomAdmin: true, room }));
|
|
153
|
-
return livekit_models_1.ParticipantInfo.fromJSON(data);
|
|
110
|
+
async updateParticipant(room, identity, metadata, permission, name) {
|
|
111
|
+
const req = new UpdateParticipantRequest({
|
|
112
|
+
room,
|
|
113
|
+
identity,
|
|
114
|
+
metadata: metadata || '',
|
|
115
|
+
name: name || '',
|
|
154
116
|
});
|
|
117
|
+
if (permission) {
|
|
118
|
+
req.permission = new ParticipantPermission(permission);
|
|
119
|
+
}
|
|
120
|
+
const data = await this.rpc.request(svc, 'UpdateParticipant', req.toJson(), await this.authHeader({ roomAdmin: true, room }));
|
|
121
|
+
return ParticipantInfo.fromJson(data);
|
|
155
122
|
}
|
|
156
123
|
/**
|
|
157
124
|
* Updates a participant's subscription to tracks
|
|
@@ -160,32 +127,30 @@ class RoomServiceClient extends ServiceBase_1.default {
|
|
|
160
127
|
* @param trackSids
|
|
161
128
|
* @param subscribe true to subscribe, false to unsubscribe
|
|
162
129
|
*/
|
|
163
|
-
updateSubscriptions(room, identity, trackSids, subscribe) {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
yield this.rpc.request(svc, 'UpdateSubscriptions', req, this.authHeader({ roomAdmin: true, room }));
|
|
173
|
-
});
|
|
130
|
+
async updateSubscriptions(room, identity, trackSids, subscribe) {
|
|
131
|
+
const req = new UpdateSubscriptionsRequest({
|
|
132
|
+
room,
|
|
133
|
+
identity,
|
|
134
|
+
trackSids,
|
|
135
|
+
subscribe,
|
|
136
|
+
participantTracks: [],
|
|
137
|
+
}).toJson();
|
|
138
|
+
await this.rpc.request(svc, 'UpdateSubscriptions', req, await this.authHeader({ roomAdmin: true, room }));
|
|
174
139
|
}
|
|
175
|
-
sendData(room, data, kind, options = {}) {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
topic,
|
|
185
|
-
});
|
|
186
|
-
yield this.rpc.request(svc, 'SendData', req, this.authHeader({ roomAdmin: true, room }));
|
|
140
|
+
async sendData(room, data, kind, options = {}) {
|
|
141
|
+
const destinationSids = Array.isArray(options) ? options : options.destinationSids;
|
|
142
|
+
const topic = Array.isArray(options) ? undefined : options.topic;
|
|
143
|
+
const req = new SendDataRequest({
|
|
144
|
+
room,
|
|
145
|
+
data,
|
|
146
|
+
kind,
|
|
147
|
+
destinationSids: destinationSids !== null && destinationSids !== void 0 ? destinationSids : [],
|
|
148
|
+
topic,
|
|
187
149
|
});
|
|
150
|
+
if (!Array.isArray(options) && options.destinationIdentities) {
|
|
151
|
+
req.destinationIdentities = options.destinationIdentities;
|
|
152
|
+
}
|
|
153
|
+
await this.rpc.request(svc, 'SendData', req.toJson(), await this.authHeader({ roomAdmin: true, room }));
|
|
188
154
|
}
|
|
189
155
|
}
|
|
190
|
-
exports.RoomServiceClient = RoomServiceClient;
|
|
191
156
|
//# 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":"AACA,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAC;AAC5F,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,uBAAuB,EACvB,wBAAwB,EACxB,gBAAgB,EAChB,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,EAErB,uBAAuB,EACvB,eAAe,EACf,wBAAwB,EACxB,yBAAyB,EACzB,0BAA0B,GAC3B,MAAM,4BAA4B,CAAC;AACpC,OAAO,WAAW,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAO,QAAQ,EAAE,MAAM,eAAe,CAAC;AA8D9D,MAAM,GAAG,GAAG,aAAa,CAAC;AAE1B;;GAEG;AACH,MAAM,OAAO,iBAAkB,SAAQ,WAAW;IAGhD;;;;;OAKG;IACH,YAAY,IAAY,EAAE,MAAe,EAAE,MAAe;QACxD,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACtB,IAAI,CAAC,GAAG,GAAG,IAAI,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;IAChD,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,UAAU,CAAC,OAAsB;QACrC,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,OAAO,CACjC,GAAG,EACH,YAAY,EACZ,IAAI,iBAAiB,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EACvC,MAAM,IAAI,CAAC,UAAU,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAC5C,CAAC;QACF,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;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* Utilities to handle authentication
|
|
4
4
|
*/
|
|
@@ -12,5 +12,5 @@ export default class ServiceBase {
|
|
|
12
12
|
* @param ttl token TTL
|
|
13
13
|
*/
|
|
14
14
|
constructor(apiKey?: string, secret?: string, ttl?: string);
|
|
15
|
-
authHeader(grant: VideoGrant): any
|
|
15
|
+
authHeader(grant: VideoGrant): Promise<any>;
|
|
16
16
|
}
|
package/dist/ServiceBase.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const AccessToken_1 = require("./AccessToken");
|
|
1
|
+
import { AccessToken } from './AccessToken.js';
|
|
4
2
|
/**
|
|
5
3
|
* Utilities to handle authentication
|
|
6
4
|
*/
|
|
7
|
-
class ServiceBase {
|
|
5
|
+
export default class ServiceBase {
|
|
8
6
|
/**
|
|
9
7
|
* @param apiKey API Key.
|
|
10
8
|
* @param secret API Secret.
|
|
@@ -15,13 +13,12 @@ class ServiceBase {
|
|
|
15
13
|
this.secret = secret;
|
|
16
14
|
this.ttl = ttl || '10m';
|
|
17
15
|
}
|
|
18
|
-
authHeader(grant) {
|
|
19
|
-
const at = new
|
|
16
|
+
async authHeader(grant) {
|
|
17
|
+
const at = new AccessToken(this.apiKey, this.secret, { ttl: this.ttl });
|
|
20
18
|
at.addGrant(grant);
|
|
21
19
|
return {
|
|
22
|
-
Authorization: `Bearer ${at.toJwt()}`,
|
|
20
|
+
Authorization: `Bearer ${await at.toJwt()}`,
|
|
23
21
|
};
|
|
24
22
|
}
|
|
25
23
|
}
|
|
26
|
-
exports.default = ServiceBase;
|
|
27
24
|
//# sourceMappingURL=ServiceBase.js.map
|
package/dist/ServiceBase.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ServiceBase.js","sourceRoot":"","sources":["../src/ServiceBase.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ServiceBase.js","sourceRoot":"","sources":["../src/ServiceBase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAG/C;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,WAAW;IAO9B;;;;OAIG;IACH,YAAY,MAAe,EAAE,MAAe,EAAE,GAAY;QACxD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,GAAG,GAAG,GAAG,IAAI,KAAK,CAAC;IAC1B,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,KAAiB;QAChC,MAAM,EAAE,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;QACxE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACnB,OAAO;YACL,aAAa,EAAE,UAAU,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE;SAC5C,CAAC;IACJ,CAAC;CACF"}
|
package/dist/TwirpRPC.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { JsonValue } from '@bufbuild/protobuf';
|
|
2
2
|
export declare const livekitPackage = "livekit";
|
|
3
3
|
export interface Rpc {
|
|
4
|
-
request(service: string, method: string, data:
|
|
4
|
+
request(service: string, method: string, data: JsonValue, headers?: any): Promise<string>;
|
|
5
5
|
}
|
|
6
6
|
/**
|
|
7
7
|
* JSON based Twirp V7 RPC
|
|
@@ -10,7 +10,6 @@ export declare class TwirpRpc {
|
|
|
10
10
|
host: string;
|
|
11
11
|
pkg: string;
|
|
12
12
|
prefix: string;
|
|
13
|
-
instance: AxiosInstance;
|
|
14
13
|
constructor(host: string, pkg: string, prefix?: string);
|
|
15
14
|
request(service: string, method: string, data: any, headers?: any): Promise<any>;
|
|
16
15
|
}
|