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.
Files changed (80) hide show
  1. package/.changeset/README.md +8 -0
  2. package/.changeset/config.json +11 -0
  3. package/.github/workflows/release.yaml +46 -0
  4. package/.github/workflows/test.yaml +21 -21
  5. package/.prettierignore +1 -0
  6. package/CHANGELOG.md +23 -0
  7. package/NOTICE +13 -0
  8. package/README.md +47 -13
  9. package/dist/AccessToken.d.ts +4 -4
  10. package/dist/AccessToken.js +23 -42
  11. package/dist/AccessToken.js.map +1 -1
  12. package/dist/EgressClient.d.ts +21 -2
  13. package/dist/EgressClient.js +183 -170
  14. package/dist/EgressClient.js.map +1 -1
  15. package/dist/IngressClient.d.ts +17 -2
  16. package/dist/IngressClient.js +68 -89
  17. package/dist/IngressClient.js.map +1 -1
  18. package/dist/RoomServiceClient.d.ts +22 -5
  19. package/dist/RoomServiceClient.js +70 -105
  20. package/dist/RoomServiceClient.js.map +1 -1
  21. package/dist/ServiceBase.d.ts +2 -2
  22. package/dist/ServiceBase.js +5 -8
  23. package/dist/ServiceBase.js.map +1 -1
  24. package/dist/TwirpRPC.d.ts +2 -3
  25. package/dist/TwirpRPC.js +15 -23
  26. package/dist/TwirpRPC.js.map +1 -1
  27. package/dist/WebhookReceiver.d.ts +15 -2
  28. package/dist/WebhookReceiver.js +29 -19
  29. package/dist/WebhookReceiver.js.map +1 -1
  30. package/dist/grants.d.ts +2 -1
  31. package/dist/grants.js +2 -5
  32. package/dist/grants.js.map +1 -1
  33. package/dist/index.d.ts +9 -10
  34. package/dist/index.js +9 -48
  35. package/dist/index.js.map +1 -1
  36. package/dist/proto/livekit_egress_pb.d.ts +1650 -0
  37. package/dist/proto/livekit_egress_pb.js +1878 -0
  38. package/dist/proto/livekit_egress_pb.js.map +1 -0
  39. package/dist/proto/livekit_ingress_pb.d.ts +624 -0
  40. package/dist/proto/livekit_ingress_pb.js +824 -0
  41. package/dist/proto/livekit_ingress_pb.js.map +1 -0
  42. package/dist/proto/livekit_models_pb.d.ts +1349 -0
  43. package/dist/proto/livekit_models_pb.js +1829 -0
  44. package/dist/proto/livekit_models_pb.js.map +1 -0
  45. package/dist/proto/livekit_room_pb.d.ts +460 -0
  46. package/dist/proto/livekit_room_pb.js +695 -0
  47. package/dist/proto/livekit_room_pb.js.map +1 -0
  48. package/dist/proto/livekit_webhook_pb.d.ts +70 -0
  49. package/dist/proto/livekit_webhook_pb.js +76 -0
  50. package/dist/proto/livekit_webhook_pb.js.map +1 -0
  51. package/generate-proto.sh +1 -18
  52. package/package.json +32 -28
  53. package/tsconfig.eslint.json +2 -1
  54. package/vite.config.js +8 -0
  55. package/.github/workflows/publish.yaml +0 -57
  56. package/dist/AccessToken.test.d.ts +0 -1
  57. package/dist/AccessToken.test.js +0 -72
  58. package/dist/AccessToken.test.js.map +0 -1
  59. package/dist/WebhookReceiver.test.d.ts +0 -1
  60. package/dist/WebhookReceiver.test.js +0 -39
  61. package/dist/WebhookReceiver.test.js.map +0 -1
  62. package/dist/proto/google/protobuf/timestamp.d.ts +0 -132
  63. package/dist/proto/google/protobuf/timestamp.js +0 -92
  64. package/dist/proto/google/protobuf/timestamp.js.map +0 -1
  65. package/dist/proto/livekit_egress.d.ts +0 -11286
  66. package/dist/proto/livekit_egress.js +0 -2889
  67. package/dist/proto/livekit_egress.js.map +0 -1
  68. package/dist/proto/livekit_ingress.d.ts +0 -2249
  69. package/dist/proto/livekit_ingress.js +0 -1360
  70. package/dist/proto/livekit_ingress.js.map +0 -1
  71. package/dist/proto/livekit_models.d.ts +0 -1454
  72. package/dist/proto/livekit_models.js +0 -3066
  73. package/dist/proto/livekit_models.js.map +0 -1
  74. package/dist/proto/livekit_room.d.ts +0 -3316
  75. package/dist/proto/livekit_room.js +0 -1074
  76. package/dist/proto/livekit_room.js.map +0 -1
  77. package/dist/proto/livekit_webhook.d.ts +0 -4899
  78. package/dist/proto/livekit_webhook.js +0 -179
  79. package/dist/proto/livekit_webhook.js.map +0 -1
  80. /package/{.eslintrc.js → .eslintrc.cjs} +0 -0
@@ -0,0 +1,8 @@
1
+ # Changesets
2
+
3
+ Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
4
+ with multi-package repos, or single-package repos to help you version and publish your code. You can
5
+ find the full documentation for it [in our repository](https://github.com/changesets/changesets)
6
+
7
+ We have a quick list of common questions to get you started engaging with this project in
8
+ [our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
@@ -0,0 +1,11 @@
1
+ {
2
+ "$schema": "https://unpkg.com/@changesets/config@2.0.0/schema.json",
3
+ "changelog": ["@livekit/changesets-changelog-github", { "repo": "livekit/server-sdk-js" }],
4
+ "commit": false,
5
+ "fixed": [],
6
+ "linked": [],
7
+ "access": "public",
8
+ "baseBranch": "main",
9
+ "updateInternalDependencies": "patch",
10
+ "ignore": []
11
+ }
@@ -0,0 +1,46 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+
8
+ concurrency: ${{ github.workflow }}-${{ github.ref }}
9
+
10
+ jobs:
11
+ release:
12
+ name: Release
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - name: Checkout Repo
16
+ uses: actions/checkout@v4
17
+ - uses: pnpm/action-setup@v2
18
+ with:
19
+ version: 8
20
+ - name: Use Node.js 20
21
+ uses: actions/setup-node@v4
22
+ with:
23
+ node-version: 20
24
+ cache: 'pnpm'
25
+ - name: Install dependencies
26
+ run: pnpm install
27
+ - name: Create Release Pull Request or Publish to npm
28
+ id: changesets
29
+ uses: changesets/action@v1
30
+ with:
31
+ publish: pnpm ci:publish
32
+ env:
33
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34
+ NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
35
+ - name: Build Docs
36
+ if: steps.changesets.outputs.published == 'true'
37
+ run: pnpm build-docs
38
+
39
+
40
+ - name: S3 Upload
41
+ if: steps.changesets.outputs.published == 'true'
42
+ run: aws s3 cp docs/ s3://livekit-docs/server-sdk-js --recursive
43
+ env:
44
+ AWS_ACCESS_KEY_ID: ${{ secrets.DOCS_DEPLOY_AWS_ACCESS_KEY }}
45
+ AWS_SECRET_ACCESS_KEY: ${{ secrets.DOCS_DEPLOY_AWS_API_SECRET }}
46
+ AWS_DEFAULT_REGION: "us-east-1"
@@ -11,36 +11,36 @@ on:
11
11
 
12
12
  # A workflow run is made up of one or more jobs that can run sequentially or in parallel
13
13
  jobs:
14
- test:
14
+ test-node:
15
15
  # The type of runner that the job will run on
16
16
  runs-on: ubuntu-latest
17
-
18
17
  # Steps represent a sequence of tasks that will be executed as part of the job
19
18
  steps:
20
19
  # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
21
- - uses: actions/checkout@v2
22
- - uses: actions/setup-node@v2
20
+ - uses: actions/checkout@v4
21
+ - uses: pnpm/action-setup@v2
23
22
  with:
24
- node-version: '16.x'
25
- - uses: actions/cache@v2
23
+ version: 8
24
+ - name: Use Node.js 20
25
+ uses: actions/setup-node@v4
26
26
  with:
27
- path: |
28
- ~/.npm
29
- ~/.config/yarn/global
30
- key: ${{ runner.os }}-node-server-api-${{ hashFiles('**/yarn.lock') }}
31
- restore-keys: |
32
- ${{ runner.os }}-node-server-api-
33
-
34
- - name: Install Yarn
35
- run: |
36
- npm install -g yarn
37
- yarn install
27
+ node-version: 20
28
+ cache: 'pnpm'
29
+ - name: Install dependencies
30
+ run: pnpm install
38
31
 
39
32
  - name: Lint
40
- run: yarn lint
33
+ run: pnpm lint
41
34
 
42
35
  - name: Prettier
43
- run: yarn format:check
36
+ run: pnpm format:check
44
37
 
45
- - name: Test
46
- run: yarn test
38
+ - name: Test Node
39
+ run: pnpm test
40
+
41
+ - name: Test browser
42
+ run: pnpm test:browser
43
+
44
+ - name: Test edge runtime
45
+ run: pnpm test:edge
46
+
package/.prettierignore CHANGED
@@ -5,3 +5,4 @@ node_modules/
5
5
  protocol/
6
6
  src/proto/
7
7
  yarn.lock
8
+ pnpm-lock.json
package/CHANGELOG.md ADDED
@@ -0,0 +1,23 @@
1
+ # livekit-server-sdk
2
+
3
+ ## 2.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - Change module type to ESM - [#118](https://github.com/livekit/server-sdk-js/pull/118) ([@lukasIO](https://github.com/lukasIO))
8
+
9
+ - Require node 18 as minimum version - [#118](https://github.com/livekit/server-sdk-js/pull/118) ([@lukasIO](https://github.com/lukasIO))
10
+
11
+ - Make `WebhookEvent` names type safe - [#125](https://github.com/livekit/server-sdk-js/pull/125) ([@lukasIO](https://github.com/lukasIO))
12
+
13
+ - Token generation is now async (replaced jsonwebtoken with jose for better JS runtime support) - [#118](https://github.com/livekit/server-sdk-js/pull/118) ([@lukasIO](https://github.com/lukasIO))
14
+
15
+ - Replace protobufjs with protobuf-es - [#118](https://github.com/livekit/server-sdk-js/pull/118) ([@lukasIO](https://github.com/lukasIO))
16
+
17
+ ### Minor Changes
18
+
19
+ - Use globally available web crypto API instead of nodeJS crypto module - [#122](https://github.com/livekit/server-sdk-js/pull/122) ([@lukasIO](https://github.com/lukasIO))
20
+
21
+ ### Patch Changes
22
+
23
+ - Throw error on bad Twirp response status and use async/await instead of promise chaining for improved error catching - [#124](https://github.com/livekit/server-sdk-js/pull/124) ([@lukasIO](https://github.com/lukasIO))
package/NOTICE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright 2023 LiveKit, Inc.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
package/README.md CHANGED
@@ -10,8 +10,50 @@
10
10
 
11
11
  <!--BEGIN_DESCRIPTION-->Use this SDK to manage <a href="https://livekit.io/">LiveKit</a> rooms and create access tokens from your JavaScript/Node.js backend.<!--END_DESCRIPTION-->
12
12
 
13
+ > [!NOTE]
14
+ > This is v2 of the server-sdk-js which runs in NodeJS, Deno and Bun!
15
+ > (It theoretically now also runs in every major browser, but that's not recommended due to the security risks involved with exposing your API secrets)
16
+ > Read the section below for a detailed overview on what has changed.
17
+
18
+ ## Migrate from v1.x to v2.x
19
+
20
+ Because the `jsonwebtoken` lib got replaced with `jose`, there are a couple of APIs that are now async, that weren't before:
21
+
22
+ ```typescript
23
+ const at = new AccessToken('api-key', 'secret-key', {
24
+ identity: participantName,
25
+ });
26
+ at.addGrant({ roomJoin: true, room: roomName });
27
+
28
+ // v1
29
+ // const token = at.toJWT();
30
+
31
+ // v2
32
+ const token = await at.toJwt();
33
+
34
+ // v1
35
+ // const grants = v.verify(token);
36
+
37
+ // v2
38
+ const grants = await v.verify(token);
39
+
40
+ app.post('/webhook-endpoint', async (req, res) => {
41
+ // v1
42
+ // const event = receiver.receive(req.body, req.get('Authorization'));
43
+
44
+ // v2
45
+ const event = await receiver.receive(req.body, req.get('Authorization'));
46
+ });
47
+ ```
48
+
13
49
  ## Installation
14
50
 
51
+ ### Pnpm
52
+
53
+ ```
54
+ pnpm add livekit-server-sdk
55
+ ```
56
+
15
57
  ### Yarn
16
58
 
17
59
  ```
@@ -33,16 +75,6 @@ You may store credentials in environment variables. If api-key or api-secret is
33
75
  - `LIVEKIT_API_KEY`
34
76
  - `LIVEKIT_API_SECRET`
35
77
 
36
- ### CommonJS
37
-
38
- If your environment doesn't support ES6 imports, replace the import statements in the examples with
39
-
40
- ```javascript
41
- const livekitApi = require('livekit-server-sdk');
42
- const AccessToken = livekitApi.AccessToken;
43
- const RoomServiceClient = livekitApi.RoomServiceClient;
44
- ```
45
-
46
78
  ### Creating Access Tokens
47
79
 
48
80
  Creating a token for participant to join a room.
@@ -62,7 +94,7 @@ const at = new AccessToken('api-key', 'secret-key', {
62
94
  });
63
95
  at.addGrant({ roomJoin: true, room: roomName });
64
96
 
65
- const token = at.toJwt();
97
+ const token = await at.toJwt();
66
98
  console.log('access token', token);
67
99
  ```
68
100
 
@@ -135,14 +167,16 @@ const receiver = new WebhookReceiver('apikey', 'apisecret');
135
167
  // if you are using express middleware, ensure that `express.raw` is used for the webhook endpoint
136
168
  // app.use(express.raw({type: 'application/webhook+json'}));
137
169
 
138
- app.post('/webhook-endpoint', (req, res) => {
170
+ app.post('/webhook-endpoint', async (req, res) => {
139
171
  // event is a WebhookEvent object
140
- const event = receiver.receive(req.body, req.get('Authorization'));
172
+ const event = await receiver.receive(req.body, req.get('Authorization'));
141
173
  });
142
174
  ```
143
175
 
144
176
  <!--BEGIN_REPO_NAV-->
177
+
145
178
  <br/><table>
179
+
146
180
  <thead><tr><th colspan="2">LiveKit Ecosystem</th></tr></thead>
147
181
  <tbody>
148
182
  <tr><td>Client SDKs</td><td><a href="https://github.com/livekit/components-js">Components</a> · <a href="https://github.com/livekit/client-sdk-js">JavaScript</a> · <a href="https://github.com/livekit/client-sdk-swift">iOS/macOS</a> · <a href="https://github.com/livekit/client-sdk-android">Android</a> · <a href="https://github.com/livekit/client-sdk-flutter">Flutter</a> · <a href="https://github.com/livekit/client-sdk-react-native">React Native</a> · <a href="https://github.com/livekit/client-sdk-rust">Rust</a> · <a href="https://github.com/livekit/client-sdk-python">Python</a> · <a href="https://github.com/livekit/client-sdk-unity-web">Unity (web)</a> · <a href="https://github.com/livekit/client-sdk-unity">Unity (beta)</a></td></tr><tr></tr>
@@ -1,4 +1,4 @@
1
- import { ClaimGrants, VideoGrant } from './grants';
1
+ import { ClaimGrants, VideoGrant } from './grants.js';
2
2
  export interface AccessTokenOptions {
3
3
  /**
4
4
  * amount of time before expiration
@@ -24,7 +24,7 @@ export declare class AccessToken {
24
24
  private apiSecret;
25
25
  private grants;
26
26
  identity?: string;
27
- ttl?: number | string;
27
+ ttl: number | string;
28
28
  /**
29
29
  * Creates a new AccessToken
30
30
  * @param apiKey API Key, can be set in env LIVEKIT_API_KEY
@@ -46,11 +46,11 @@ export declare class AccessToken {
46
46
  /**
47
47
  * @returns JWT encoded token
48
48
  */
49
- toJwt(): string;
49
+ toJwt(): Promise<string>;
50
50
  }
51
51
  export declare class TokenVerifier {
52
52
  private apiKey;
53
53
  private apiSecret;
54
54
  constructor(apiKey: string, apiSecret: string);
55
- verify(token: string): ClaimGrants;
55
+ verify(token: string): Promise<ClaimGrants>;
56
56
  }
@@ -1,29 +1,7 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
21
- Object.defineProperty(exports, "__esModule", { value: true });
22
- exports.TokenVerifier = exports.AccessToken = void 0;
23
- const jwt = __importStar(require("jsonwebtoken"));
1
+ import * as jose from 'jose';
24
2
  // 6 hours
25
- const defaultTTL = 6 * 60 * 60;
26
- class AccessToken {
3
+ const defaultTTL = `6h`;
4
+ export class AccessToken {
27
5
  /**
28
6
  * Creates a new AccessToken
29
7
  * @param apiKey API Key, can be set in env LIVEKIT_API_KEY
@@ -50,6 +28,9 @@ class AccessToken {
50
28
  this.grants = {};
51
29
  this.identity = options === null || options === void 0 ? void 0 : options.identity;
52
30
  this.ttl = (options === null || options === void 0 ? void 0 : options.ttl) || defaultTTL;
31
+ if (typeof this.ttl === 'number') {
32
+ this.ttl = `${this.ttl}s`;
33
+ }
53
34
  if (options === null || options === void 0 ? void 0 : options.metadata) {
54
35
  this.metadata = options.metadata;
55
36
  }
@@ -62,7 +43,8 @@ class AccessToken {
62
43
  * @param grant
63
44
  */
64
45
  addGrant(grant) {
65
- this.grants.video = grant;
46
+ var _a;
47
+ this.grants.video = Object.assign(Object.assign({}, ((_a = this.grants.video) !== null && _a !== void 0 ? _a : {})), grant);
66
48
  }
67
49
  /**
68
50
  * Set metadata to be passed to the Participant, used only when joining the room
@@ -82,37 +64,36 @@ class AccessToken {
82
64
  /**
83
65
  * @returns JWT encoded token
84
66
  */
85
- toJwt() {
67
+ async toJwt() {
86
68
  // TODO: check for video grant validity
87
69
  var _a;
88
- const opts = {
89
- issuer: this.apiKey,
90
- expiresIn: this.ttl,
91
- notBefore: 0,
92
- };
70
+ const secret = new TextEncoder().encode(this.apiSecret);
71
+ const jwt = new jose.SignJWT(this.grants)
72
+ .setProtectedHeader({ alg: 'HS256' })
73
+ .setIssuer(this.apiKey)
74
+ .setExpirationTime(this.ttl)
75
+ .setNotBefore(0);
93
76
  if (this.identity) {
94
- opts.subject = this.identity;
95
- opts.jwtid = this.identity;
77
+ jwt.setSubject(this.identity);
96
78
  }
97
79
  else if ((_a = this.grants.video) === null || _a === void 0 ? void 0 : _a.roomJoin) {
98
80
  throw Error('identity is required for join but not set');
99
81
  }
100
- return jwt.sign(this.grants, this.apiSecret, opts);
82
+ return jwt.sign(secret);
101
83
  }
102
84
  }
103
- exports.AccessToken = AccessToken;
104
- class TokenVerifier {
85
+ export class TokenVerifier {
105
86
  constructor(apiKey, apiSecret) {
106
87
  this.apiKey = apiKey;
107
88
  this.apiSecret = apiSecret;
108
89
  }
109
- verify(token) {
110
- const decoded = jwt.verify(token, this.apiSecret, { issuer: this.apiKey });
111
- if (!decoded) {
90
+ async verify(token) {
91
+ const secret = new TextEncoder().encode(this.apiSecret);
92
+ const { payload } = await jose.jwtVerify(token, secret, { issuer: this.apiKey });
93
+ if (!payload) {
112
94
  throw Error('invalid token');
113
95
  }
114
- return decoded;
96
+ return payload;
115
97
  }
116
98
  }
117
- exports.TokenVerifier = TokenVerifier;
118
99
  //# sourceMappingURL=AccessToken.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AccessToken.js","sourceRoot":"","sources":["../src/AccessToken.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,kDAAoC;AAGpC,UAAU;AACV,MAAM,UAAU,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC;AA0B/B,MAAa,WAAW;IAWtB;;;;OAIG;IACH,YAAY,MAAe,EAAE,SAAkB,EAAE,OAA4B;QAC3E,IAAI,CAAC,MAAM,EAAE;YACX,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC;SACtC;QACD,IAAI,CAAC,SAAS,EAAE;YACd,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC;SAC5C;QACD,IAAI,CAAC,MAAM,IAAI,CAAC,SAAS,EAAE;YACzB,MAAM,KAAK,CAAC,oCAAoC,CAAC,CAAC;SACnD;aAAM,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE;YAC1C,yEAAyE;YACzE,OAAO,CAAC,KAAK,CACX,uEAAuE;gBACrE,wFAAwF;gBACxF,iFAAiF,CACpF,CAAC;SACH;QAED,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QACjB,IAAI,CAAC,QAAQ,GAAG,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,QAAQ,CAAC;QAClC,IAAI,CAAC,GAAG,GAAG,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,GAAG,KAAI,UAAU,CAAC;QACtC,IAAI,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,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, EgressInfo, EncodedFileOutput, EncodingOptions, EncodingOptionsPreset, SegmentedFileOutput, StreamOutput } from './proto/livekit_egress';
2
- import ServiceBase from './ServiceBase';
1
+ import { DirectFileOutput, EgressInfo, EncodedFileOutput, EncodingOptions, EncodingOptionsPreset, SegmentedFileOutput, StreamOutput } from './proto/livekit_egress_pb.js';
2
+ import ServiceBase from './ServiceBase.js';
3
3
  export interface RoomCompositeOptions {
4
4
  /**
5
5
  * egress layout. optional
@@ -40,6 +40,17 @@ export interface WebOptions {
40
40
  */
41
41
  awaitStartSignal?: boolean;
42
42
  }
43
+ export interface ParticipantEgressOptions {
44
+ /**
45
+ * true to capture source screenshare and screenshare_audio
46
+ * false to capture camera and microphone
47
+ */
48
+ screenShare?: boolean;
49
+ /**
50
+ * encoding options or preset. optional
51
+ */
52
+ encodingOptions?: EncodingOptionsPreset | EncodingOptions;
53
+ }
43
54
  export interface TrackCompositeOptions {
44
55
  /**
45
56
  * audio track ID
@@ -94,6 +105,14 @@ export declare class EgressClient extends ServiceBase {
94
105
  * @param opts WebOptions
95
106
  */
96
107
  startWebEgress(url: string, output: EncodedOutputs | EncodedFileOutput | StreamOutput | SegmentedFileOutput, opts?: WebOptions): Promise<EgressInfo>;
108
+ /**
109
+ * Export a participant's audio and video tracks,
110
+ *
111
+ * @param roomName room name
112
+ * @param output one or more outputs
113
+ * @param opts ParticipantEgressOptions
114
+ */
115
+ startParticipantEgress(roomName: string, identity: string, output: EncodedOutputs, opts?: ParticipantEgressOptions): Promise<EgressInfo>;
97
116
  /**
98
117
  * @param roomName room name
99
118
  * @param output file or stream output