livekit-server-sdk 2.14.0 → 2.14.2

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/dist/AccessToken.cjs +7 -0
  2. package/dist/AccessToken.cjs.map +1 -1
  3. package/dist/AccessToken.d.cts +6 -1
  4. package/dist/AccessToken.d.ts +6 -1
  5. package/dist/AccessToken.d.ts.map +1 -1
  6. package/dist/AccessToken.js +7 -0
  7. package/dist/AccessToken.js.map +1 -1
  8. package/dist/AgentDispatchClient.cjs +4 -2
  9. package/dist/AgentDispatchClient.cjs.map +1 -1
  10. package/dist/AgentDispatchClient.d.cts +3 -1
  11. package/dist/AgentDispatchClient.d.ts +3 -1
  12. package/dist/AgentDispatchClient.d.ts.map +1 -1
  13. package/dist/AgentDispatchClient.js +4 -2
  14. package/dist/AgentDispatchClient.js.map +1 -1
  15. package/dist/ClientOptions.cjs +17 -0
  16. package/dist/ClientOptions.cjs.map +1 -0
  17. package/dist/ClientOptions.d.cts +11 -0
  18. package/dist/ClientOptions.d.ts +10 -0
  19. package/dist/ClientOptions.d.ts.map +1 -0
  20. package/dist/ClientOptions.js +1 -0
  21. package/dist/ClientOptions.js.map +1 -0
  22. package/dist/EgressClient.cjs +4 -2
  23. package/dist/EgressClient.cjs.map +1 -1
  24. package/dist/EgressClient.d.cts +3 -1
  25. package/dist/EgressClient.d.ts +3 -1
  26. package/dist/EgressClient.d.ts.map +1 -1
  27. package/dist/EgressClient.js +4 -2
  28. package/dist/EgressClient.js.map +1 -1
  29. package/dist/IngressClient.cjs +4 -2
  30. package/dist/IngressClient.cjs.map +1 -1
  31. package/dist/IngressClient.d.cts +3 -1
  32. package/dist/IngressClient.d.ts +3 -1
  33. package/dist/IngressClient.d.ts.map +1 -1
  34. package/dist/IngressClient.js +4 -2
  35. package/dist/IngressClient.js.map +1 -1
  36. package/dist/RoomServiceClient.cjs +4 -2
  37. package/dist/RoomServiceClient.cjs.map +1 -1
  38. package/dist/RoomServiceClient.d.cts +3 -1
  39. package/dist/RoomServiceClient.d.ts +3 -1
  40. package/dist/RoomServiceClient.d.ts.map +1 -1
  41. package/dist/RoomServiceClient.js +4 -2
  42. package/dist/RoomServiceClient.js.map +1 -1
  43. package/dist/SipClient.cjs +11 -5
  44. package/dist/SipClient.cjs.map +1 -1
  45. package/dist/SipClient.d.cts +10 -3
  46. package/dist/SipClient.d.ts +10 -3
  47. package/dist/SipClient.d.ts.map +1 -1
  48. package/dist/SipClient.js +13 -5
  49. package/dist/SipClient.js.map +1 -1
  50. package/dist/TwirpRPC.cjs +5 -3
  51. package/dist/TwirpRPC.cjs.map +1 -1
  52. package/dist/TwirpRPC.d.cts +8 -1
  53. package/dist/TwirpRPC.d.ts +9 -1
  54. package/dist/TwirpRPC.d.ts.map +1 -1
  55. package/dist/TwirpRPC.js +5 -3
  56. package/dist/TwirpRPC.js.map +1 -1
  57. package/dist/grants.cjs.map +1 -1
  58. package/dist/grants.d.cts +6 -1
  59. package/dist/grants.d.ts +5 -0
  60. package/dist/grants.d.ts.map +1 -1
  61. package/dist/grants.js.map +1 -1
  62. package/dist/index.cjs +19 -0
  63. package/dist/index.cjs.map +1 -1
  64. package/dist/index.d.cts +4 -2
  65. package/dist/index.d.ts +2 -1
  66. package/dist/index.d.ts.map +1 -1
  67. package/dist/index.js +18 -0
  68. package/dist/index.js.map +1 -1
  69. package/package.json +2 -2
  70. package/src/AccessToken.ts +15 -1
  71. package/src/AgentDispatchClient.ts +7 -2
  72. package/src/ClientOptions.ts +13 -0
  73. package/src/EgressClient.ts +7 -2
  74. package/src/IngressClient.ts +7 -2
  75. package/src/RoomServiceClient.ts +7 -2
  76. package/src/SipClient.ts +18 -2
  77. package/src/TwirpRPC.ts +14 -3
  78. package/src/grants.test.ts +13 -1
  79. package/src/grants.ts +6 -0
  80. package/src/index.ts +9 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/EgressClient.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type {\n DirectFileOutput,\n EncodedFileOutput,\n EncodingOptions,\n EncodingOptionsPreset,\n ImageOutput,\n SegmentedFileOutput,\n StreamOutput,\n WebhookConfig,\n} from '@livekit/protocol';\nimport {\n AudioMixing,\n EgressInfo,\n ListEgressRequest,\n ListEgressResponse,\n ParticipantEgressRequest,\n RoomCompositeEgressRequest,\n StopEgressRequest,\n TrackCompositeEgressRequest,\n TrackEgressRequest,\n UpdateLayoutRequest,\n UpdateStreamRequest,\n WebEgressRequest,\n} from '@livekit/protocol';\nimport { ServiceBase } from './ServiceBase.js';\nimport type { Rpc } from './TwirpRPC.js';\nimport { TwirpRpc, livekitPackage } from './TwirpRPC.js';\n\nconst svc = 'Egress';\n\nexport interface BaseOptions {\n /**\n * webhooks to call for this request, optional.\n */\n webhooks?: WebhookConfig[];\n}\n\nexport interface RoomCompositeOptions extends BaseOptions {\n /**\n * egress layout. optional\n */\n layout?: string;\n /**\n * encoding options or preset. optional\n */\n encodingOptions?: EncodingOptionsPreset | EncodingOptions;\n /**\n * record audio only. optional\n */\n audioOnly?: boolean;\n /**\n * record video only. optional\n */\n videoOnly?: boolean;\n /**\n * custom template url. optional\n */\n customBaseUrl?: string;\n /**\n * audio mixing options. optional\n */\n audioMixing?: AudioMixing;\n}\n\nexport interface WebOptions extends BaseOptions {\n /**\n * encoding options or preset. optional\n */\n encodingOptions?: EncodingOptionsPreset | EncodingOptions;\n /**\n * record audio only. optional\n */\n audioOnly?: boolean;\n /**\n * record video only. optional\n */\n videoOnly?: boolean;\n /**\n * await START_RECORDING chrome log\n */\n awaitStartSignal?: boolean;\n}\n\nexport interface ParticipantEgressOptions extends BaseOptions {\n /**\n * true to capture source screenshare and screenshare_audio\n * false to capture camera and microphone\n */\n screenShare?: boolean;\n /**\n * encoding options or preset. optional\n */\n encodingOptions?: EncodingOptionsPreset | EncodingOptions;\n}\n\nexport interface TrackCompositeOptions extends BaseOptions {\n /**\n * audio track ID\n */\n audioTrackId?: string;\n /**\n * video track ID\n */\n videoTrackId?: string;\n /**\n * encoding options or preset. optional\n */\n encodingOptions?: EncodingOptionsPreset | EncodingOptions;\n}\n\n/**\n * Used to supply multiple outputs with an egress request\n */\nexport interface EncodedOutputs {\n file?: EncodedFileOutput | undefined;\n stream?: StreamOutput | undefined;\n segments?: SegmentedFileOutput | undefined;\n images?: ImageOutput | undefined;\n}\n\nexport interface ListEgressOptions {\n roomName?: string;\n egressId?: string;\n active?: boolean;\n}\n\n/**\n * Client to access Egress APIs\n */\nexport class EgressClient extends ServiceBase {\n private readonly rpc: Rpc;\n\n /**\n * @param host - hostname including protocol. i.e. 'https://<project>.livekit.cloud'\n * @param apiKey - API Key, can be set in env var LIVEKIT_API_KEY\n * @param secret - API Secret, can be set in env var LIVEKIT_API_SECRET\n */\n constructor(host: string, apiKey?: string, secret?: string) {\n super(apiKey, secret);\n this.rpc = new TwirpRpc(host, livekitPackage);\n }\n\n /**\n * @param roomName - room name\n * @param output - file or stream output\n * @param opts - RoomCompositeOptions\n */\n async startRoomCompositeEgress(\n roomName: string,\n output: EncodedOutputs | EncodedFileOutput | StreamOutput | SegmentedFileOutput,\n opts?: RoomCompositeOptions,\n ): Promise<EgressInfo>;\n /**\n * @deprecated use RoomCompositeOptions instead\n */\n async startRoomCompositeEgress(\n roomName: string,\n output: EncodedOutputs | EncodedFileOutput | StreamOutput | SegmentedFileOutput,\n layout?: string,\n options?: EncodingOptionsPreset | EncodingOptions,\n audioOnly?: boolean,\n videoOnly?: boolean,\n customBaseUrl?: string,\n audioMixing?: AudioMixing,\n ): Promise<EgressInfo>;\n async startRoomCompositeEgress(\n roomName: string,\n output: EncodedOutputs | EncodedFileOutput | StreamOutput | SegmentedFileOutput,\n optsOrLayout?: RoomCompositeOptions | string,\n options?: EncodingOptionsPreset | EncodingOptions,\n audioOnly?: boolean,\n videoOnly?: boolean,\n customBaseUrl?: string,\n audioMixing?: AudioMixing,\n ): Promise<EgressInfo> {\n let layout: string | undefined;\n let webhooks: WebhookConfig[] | undefined;\n if (optsOrLayout !== undefined) {\n if (typeof optsOrLayout === 'string') {\n layout = optsOrLayout;\n } else {\n const opts = <RoomCompositeOptions>optsOrLayout;\n layout = opts.layout;\n options = opts.encodingOptions;\n audioOnly = opts.audioOnly;\n videoOnly = opts.videoOnly;\n customBaseUrl = opts.customBaseUrl;\n audioMixing = opts.audioMixing;\n webhooks = opts.webhooks;\n }\n }\n\n layout ??= '';\n audioOnly ??= false;\n videoOnly ??= false;\n customBaseUrl ??= '';\n audioMixing ??= AudioMixing.DEFAULT_MIXING;\n\n const {\n output: legacyOutput,\n options: egressOptions,\n fileOutputs,\n streamOutputs,\n segmentOutputs,\n imageOutputs,\n } = this.getOutputParams(output, options);\n\n const req = new RoomCompositeEgressRequest({\n roomName,\n layout,\n audioOnly,\n audioMixing,\n videoOnly,\n customBaseUrl,\n output: legacyOutput,\n options: egressOptions,\n fileOutputs,\n streamOutputs,\n segmentOutputs,\n imageOutputs,\n webhooks,\n }).toJson();\n\n const data = await this.rpc.request(\n svc,\n 'StartRoomCompositeEgress',\n req,\n await this.authHeader({ roomRecord: true }),\n );\n return EgressInfo.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * @param url - url\n * @param output - file or stream output\n * @param opts - WebOptions\n */\n async startWebEgress(\n url: string,\n output: EncodedOutputs | EncodedFileOutput | StreamOutput | SegmentedFileOutput,\n opts?: WebOptions,\n ): Promise<EgressInfo> {\n const audioOnly = opts?.audioOnly || false;\n const videoOnly = opts?.videoOnly || false;\n const awaitStartSignal = opts?.awaitStartSignal || false;\n const webhooks = opts?.webhooks || [];\n const {\n output: legacyOutput,\n options,\n fileOutputs,\n streamOutputs,\n segmentOutputs,\n imageOutputs,\n } = this.getOutputParams(output, opts?.encodingOptions);\n\n const req = new WebEgressRequest({\n url,\n audioOnly,\n videoOnly,\n awaitStartSignal,\n output: legacyOutput,\n options,\n fileOutputs,\n streamOutputs,\n segmentOutputs,\n imageOutputs,\n webhooks,\n }).toJson();\n\n const data = await this.rpc.request(\n svc,\n 'StartWebEgress',\n req,\n await this.authHeader({ roomRecord: true }),\n );\n return EgressInfo.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * Export a participant's audio and video tracks,\n *\n * @param roomName - room name\n * @param output - one or more outputs\n * @param opts - ParticipantEgressOptions\n */\n async startParticipantEgress(\n roomName: string,\n identity: string,\n output: EncodedOutputs,\n opts?: ParticipantEgressOptions,\n ): Promise<EgressInfo> {\n const webhooks = opts?.webhooks || [];\n const { options, fileOutputs, streamOutputs, segmentOutputs, imageOutputs } =\n this.getOutputParams(output, opts?.encodingOptions);\n const req = new ParticipantEgressRequest({\n roomName,\n identity,\n screenShare: opts?.screenShare ?? false,\n options,\n fileOutputs,\n streamOutputs,\n segmentOutputs,\n imageOutputs,\n webhooks,\n }).toJson();\n\n const data = await this.rpc.request(\n svc,\n 'StartParticipantEgress',\n req,\n await this.authHeader({ roomRecord: true }),\n );\n return EgressInfo.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * @param roomName - room name\n * @param output - file or stream output\n * @param opts - TrackCompositeOptions\n */\n async startTrackCompositeEgress(\n roomName: string,\n output: EncodedOutputs | EncodedFileOutput | StreamOutput | SegmentedFileOutput,\n opts?: TrackCompositeOptions,\n ): Promise<EgressInfo>;\n /**\n * @deprecated use TrackCompositeOptions instead\n */\n async startTrackCompositeEgress(\n roomName: string,\n output: EncodedOutputs | EncodedFileOutput | StreamOutput | SegmentedFileOutput,\n audioTrackId?: string,\n videoTrackId?: string,\n options?: EncodingOptionsPreset | EncodingOptions,\n ): Promise<EgressInfo>;\n async startTrackCompositeEgress(\n roomName: string,\n output: EncodedOutputs | EncodedFileOutput | StreamOutput | SegmentedFileOutput,\n optsOrAudioTrackId?: TrackCompositeOptions | string,\n videoTrackId?: string,\n options?: EncodingOptionsPreset | EncodingOptions,\n ): Promise<EgressInfo> {\n let audioTrackId: string | undefined;\n let webhooks: WebhookConfig[] | undefined;\n if (optsOrAudioTrackId !== undefined) {\n if (typeof optsOrAudioTrackId === 'string') {\n audioTrackId = optsOrAudioTrackId;\n } else {\n const opts = <TrackCompositeOptions>optsOrAudioTrackId;\n audioTrackId = opts.audioTrackId;\n videoTrackId = opts.videoTrackId;\n options = opts.encodingOptions;\n webhooks = opts.webhooks;\n }\n }\n\n audioTrackId ??= '';\n videoTrackId ??= '';\n\n const {\n output: legacyOutput,\n options: egressOptions,\n fileOutputs,\n streamOutputs,\n segmentOutputs,\n imageOutputs,\n } = this.getOutputParams(output, options);\n const req = new TrackCompositeEgressRequest({\n roomName,\n audioTrackId,\n videoTrackId,\n output: legacyOutput,\n options: egressOptions,\n fileOutputs,\n streamOutputs,\n segmentOutputs,\n imageOutputs,\n webhooks,\n }).toJson();\n\n const data = await this.rpc.request(\n svc,\n 'StartTrackCompositeEgress',\n req,\n await this.authHeader({ roomRecord: true }),\n );\n return EgressInfo.fromJson(data, { ignoreUnknownFields: true });\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private isEncodedOutputs(output: any): output is EncodedOutputs {\n return (\n (<EncodedOutputs>output).file !== undefined ||\n (<EncodedOutputs>output).stream !== undefined ||\n (<EncodedOutputs>output).segments !== undefined ||\n (<EncodedOutputs>output).images !== undefined\n );\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private isEncodedFileOutput(output: any): output is EncodedFileOutput {\n return (\n (<EncodedFileOutput>output).filepath !== undefined ||\n (<EncodedFileOutput>output).fileType !== undefined\n );\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private isSegmentedFileOutput(output: any): output is SegmentedFileOutput {\n return (\n (<SegmentedFileOutput>output).filenamePrefix !== undefined ||\n (<SegmentedFileOutput>output).playlistName !== undefined ||\n (<SegmentedFileOutput>output).filenameSuffix !== undefined\n );\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private isStreamOutput(output: any): output is StreamOutput {\n return (\n (<StreamOutput>output).protocol !== undefined || (<StreamOutput>output).urls !== undefined\n );\n }\n\n private getOutputParams(\n output: EncodedOutputs | EncodedFileOutput | StreamOutput | SegmentedFileOutput,\n opts?: EncodingOptionsPreset | EncodingOptions,\n ) {\n let file: EncodedFileOutput | undefined;\n let fileOutputs: Array<EncodedFileOutput> | undefined;\n let stream: StreamOutput | undefined;\n let streamOutputs: Array<StreamOutput> | undefined;\n let segments: SegmentedFileOutput | undefined;\n let segmentOutputs: Array<SegmentedFileOutput> | undefined;\n let imageOutputs: Array<ImageOutput> | undefined;\n\n if (this.isEncodedOutputs(output)) {\n if (output.file !== undefined) {\n fileOutputs = [output.file];\n }\n if (output.stream !== undefined) {\n streamOutputs = [output.stream];\n }\n if (output.segments !== undefined) {\n segmentOutputs = [output.segments];\n }\n if (output.images !== undefined) {\n imageOutputs = [output.images];\n }\n } else if (this.isEncodedFileOutput(output)) {\n file = output;\n fileOutputs = [file];\n } else if (this.isSegmentedFileOutput(output)) {\n segments = output;\n segmentOutputs = [segments];\n } else if (this.isStreamOutput(output)) {\n stream = output;\n streamOutputs = [stream];\n }\n\n let legacyOutput:\n | {\n value: EncodedFileOutput;\n case: 'file';\n }\n | {\n value: StreamOutput;\n case: 'stream';\n }\n | {\n value: SegmentedFileOutput;\n case: 'segments';\n }\n | undefined;\n\n if (file) {\n legacyOutput = {\n case: 'file',\n value: file,\n };\n } else if (stream) {\n legacyOutput = {\n case: 'stream',\n value: stream,\n };\n } else if (segments) {\n legacyOutput = {\n case: 'segments',\n value: segments,\n };\n }\n let egressOptions:\n | {\n value: EncodingOptionsPreset;\n case: 'preset';\n }\n | {\n value: EncodingOptions;\n case: 'advanced';\n }\n | undefined;\n if (opts) {\n if (typeof opts === 'number') {\n egressOptions = {\n case: 'preset',\n value: opts,\n };\n } else {\n egressOptions = {\n case: 'advanced',\n value: <EncodingOptions>opts,\n };\n }\n }\n\n return {\n output: legacyOutput,\n options: egressOptions,\n fileOutputs,\n streamOutputs,\n segmentOutputs,\n imageOutputs,\n };\n }\n\n /**\n * @param roomName - room name\n * @param output - file or websocket output\n * @param trackId - track Id\n */\n async startTrackEgress(\n roomName: string,\n output: DirectFileOutput | string,\n trackId: string,\n webhooks?: WebhookConfig[],\n ): Promise<EgressInfo> {\n let legacyOutput:\n | {\n value: DirectFileOutput;\n case: 'file';\n }\n | {\n value: string;\n case: 'websocketUrl';\n }\n | undefined;\n\n if (typeof output === 'string') {\n legacyOutput = {\n case: 'websocketUrl',\n value: output,\n };\n } else {\n legacyOutput = {\n case: 'file',\n value: output,\n };\n }\n\n const req = new TrackEgressRequest({\n roomName,\n trackId,\n output: legacyOutput,\n webhooks,\n }).toJson();\n\n const data = await this.rpc.request(\n svc,\n 'StartTrackEgress',\n req,\n await this.authHeader({ roomRecord: true }),\n );\n return EgressInfo.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * @param egressId -\n * @param layout -\n */\n async updateLayout(egressId: string, layout: string): Promise<EgressInfo> {\n const data = await this.rpc.request(\n svc,\n 'UpdateLayout',\n new UpdateLayoutRequest({ egressId, layout }).toJson(),\n await this.authHeader({ roomRecord: true }),\n );\n return EgressInfo.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * @param egressId -\n * @param addOutputUrls -\n * @param removeOutputUrls -\n */\n async updateStream(\n egressId: string,\n addOutputUrls?: string[],\n removeOutputUrls?: string[],\n ): Promise<EgressInfo> {\n addOutputUrls ??= [];\n removeOutputUrls ??= [];\n\n const data = await this.rpc.request(\n svc,\n 'UpdateStream',\n new UpdateStreamRequest({ egressId, addOutputUrls, removeOutputUrls }).toJson(),\n await this.authHeader({ roomRecord: true }),\n );\n return EgressInfo.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * @param options - options to filter listed Egresses, by default returns all\n * Egress instances\n */\n async listEgress(options?: ListEgressOptions): Promise<Array<EgressInfo>>;\n /**\n * @deprecated use `listEgress(options?: ListEgressOptions)` instead\n * @param roomName - list egress for one room only\n */\n async listEgress(roomName?: string): Promise<Array<EgressInfo>>;\n /**\n * @param roomName - list egress for one room only\n */\n async listEgress(options?: string | ListEgressOptions): Promise<Array<EgressInfo>> {\n let req: Partial<ListEgressRequest> = {};\n if (typeof options === 'string') {\n req.roomName = options;\n } else if (options !== undefined) {\n req = options;\n }\n\n const data = await this.rpc.request(\n svc,\n 'ListEgress',\n new ListEgressRequest(req).toJson(),\n await this.authHeader({ roomRecord: true }),\n );\n return ListEgressResponse.fromJson(data, { ignoreUnknownFields: true }).items ?? [];\n }\n\n /**\n * @param egressId -\n */\n async stopEgress(egressId: string): Promise<EgressInfo> {\n const data = await this.rpc.request(\n svc,\n 'StopEgress',\n new StopEgressRequest({ egressId }).toJson(),\n await this.authHeader({ roomRecord: true }),\n );\n return EgressInfo.fromJson(data, { ignoreUnknownFields: true });\n }\n}\n"],"mappings":"AAaA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,mBAAmB;AAE5B,SAAS,UAAU,sBAAsB;AAEzC,MAAM,MAAM;AAqGL,MAAM,qBAAqB,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ5C,YAAY,MAAc,QAAiB,QAAiB;AAC1D,UAAM,QAAQ,MAAM;AACpB,SAAK,MAAM,IAAI,SAAS,MAAM,cAAc;AAAA,EAC9C;AAAA,EAyBA,MAAM,yBACJ,UACA,QACA,cACA,SACA,WACA,WACA,eACA,aACqB;AACrB,QAAI;AACJ,QAAI;AACJ,QAAI,iBAAiB,QAAW;AAC9B,UAAI,OAAO,iBAAiB,UAAU;AACpC,iBAAS;AAAA,MACX,OAAO;AACL,cAAM,OAA6B;AACnC,iBAAS,KAAK;AACd,kBAAU,KAAK;AACf,oBAAY,KAAK;AACjB,oBAAY,KAAK;AACjB,wBAAgB,KAAK;AACrB,sBAAc,KAAK;AACnB,mBAAW,K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,EAAE,YAAY,KAAK,CAAC;AAAA,IAC5C;AACA,WAAO,mBAAmB,SAAS,MAAM,EAAE,qBAAqB,KAAK,CAAC,EAAE,SAAS,CAAC;AAAA,EACpF;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,WAAW,UAAuC;AACtD,UAAM,OAAO,MAAM,KAAK,IAAI;AAAA,MAC1B;AAAA,MACA;AAAA,MACA,IAAI,kBAAkB,EAAE,SAAS,CAAC,EAAE,OAAO;AAAA,MAC3C,MAAM,KAAK,WAAW,EAAE,YAAY,KAAK,CAAC;AAAA,IAC5C;AACA,WAAO,WAAW,SAAS,MAAM,EAAE,qBAAqB,KAAK,CAAC;AAAA,EAChE;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/EgressClient.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type {\n DirectFileOutput,\n EncodedFileOutput,\n EncodingOptions,\n EncodingOptionsPreset,\n ImageOutput,\n SegmentedFileOutput,\n StreamOutput,\n WebhookConfig,\n} from '@livekit/protocol';\nimport {\n AudioMixing,\n EgressInfo,\n ListEgressRequest,\n ListEgressResponse,\n ParticipantEgressRequest,\n RoomCompositeEgressRequest,\n StopEgressRequest,\n TrackCompositeEgressRequest,\n TrackEgressRequest,\n UpdateLayoutRequest,\n UpdateStreamRequest,\n WebEgressRequest,\n} from '@livekit/protocol';\nimport type { ClientOptions } from './ClientOptions.js';\nimport { ServiceBase } from './ServiceBase.js';\nimport type { Rpc } from './TwirpRPC.js';\nimport { TwirpRpc, livekitPackage } from './TwirpRPC.js';\n\nconst svc = 'Egress';\n\nexport interface BaseOptions {\n /**\n * webhooks to call for this request, optional.\n */\n webhooks?: WebhookConfig[];\n}\n\nexport interface RoomCompositeOptions extends BaseOptions {\n /**\n * egress layout. optional\n */\n layout?: string;\n /**\n * encoding options or preset. optional\n */\n encodingOptions?: EncodingOptionsPreset | EncodingOptions;\n /**\n * record audio only. optional\n */\n audioOnly?: boolean;\n /**\n * record video only. optional\n */\n videoOnly?: boolean;\n /**\n * custom template url. optional\n */\n customBaseUrl?: string;\n /**\n * audio mixing options. optional\n */\n audioMixing?: AudioMixing;\n}\n\nexport interface WebOptions extends BaseOptions {\n /**\n * encoding options or preset. optional\n */\n encodingOptions?: EncodingOptionsPreset | EncodingOptions;\n /**\n * record audio only. optional\n */\n audioOnly?: boolean;\n /**\n * record video only. optional\n */\n videoOnly?: boolean;\n /**\n * await START_RECORDING chrome log\n */\n awaitStartSignal?: boolean;\n}\n\nexport interface ParticipantEgressOptions extends BaseOptions {\n /**\n * true to capture source screenshare and screenshare_audio\n * false to capture camera and microphone\n */\n screenShare?: boolean;\n /**\n * encoding options or preset. optional\n */\n encodingOptions?: EncodingOptionsPreset | EncodingOptions;\n}\n\nexport interface TrackCompositeOptions extends BaseOptions {\n /**\n * audio track ID\n */\n audioTrackId?: string;\n /**\n * video track ID\n */\n videoTrackId?: string;\n /**\n * encoding options or preset. optional\n */\n encodingOptions?: EncodingOptionsPreset | EncodingOptions;\n}\n\n/**\n * Used to supply multiple outputs with an egress request\n */\nexport interface EncodedOutputs {\n file?: EncodedFileOutput | undefined;\n stream?: StreamOutput | undefined;\n segments?: SegmentedFileOutput | undefined;\n images?: ImageOutput | undefined;\n}\n\nexport interface ListEgressOptions {\n roomName?: string;\n egressId?: string;\n active?: boolean;\n}\n\n/**\n * Client to access Egress APIs\n */\nexport class EgressClient extends ServiceBase {\n private readonly rpc: Rpc;\n\n /**\n * @param host - hostname including protocol. i.e. 'https://<project>.livekit.cloud'\n * @param apiKey - API Key, can be set in env var LIVEKIT_API_KEY\n * @param secret - API Secret, can be set in env var LIVEKIT_API_SECRET\n * @param options - client options\n */\n constructor(host: string, apiKey?: string, secret?: string, options?: ClientOptions) {\n super(apiKey, secret);\n const rpcOptions = options?.requestTimeout\n ? { requestTimeout: options.requestTimeout }\n : undefined;\n this.rpc = new TwirpRpc(host, livekitPackage, rpcOptions);\n }\n\n /**\n * @param roomName - room name\n * @param output - file or stream output\n * @param opts - RoomCompositeOptions\n */\n async startRoomCompositeEgress(\n roomName: string,\n output: EncodedOutputs | EncodedFileOutput | StreamOutput | SegmentedFileOutput,\n opts?: RoomCompositeOptions,\n ): Promise<EgressInfo>;\n /**\n * @deprecated use RoomCompositeOptions instead\n */\n async startRoomCompositeEgress(\n roomName: string,\n output: EncodedOutputs | EncodedFileOutput | StreamOutput | SegmentedFileOutput,\n layout?: string,\n options?: EncodingOptionsPreset | EncodingOptions,\n audioOnly?: boolean,\n videoOnly?: boolean,\n customBaseUrl?: string,\n audioMixing?: AudioMixing,\n ): Promise<EgressInfo>;\n async startRoomCompositeEgress(\n roomName: string,\n output: EncodedOutputs | EncodedFileOutput | StreamOutput | SegmentedFileOutput,\n optsOrLayout?: RoomCompositeOptions | string,\n options?: EncodingOptionsPreset | EncodingOptions,\n audioOnly?: boolean,\n videoOnly?: boolean,\n customBaseUrl?: string,\n audioMixing?: AudioMixing,\n ): Promise<EgressInfo> {\n let layout: string | undefined;\n let webhooks: WebhookConfig[] | undefined;\n if (optsOrLayout !== undefined) {\n if (typeof optsOrLayout === 'string') {\n layout = optsOrLayout;\n } else {\n const opts = <RoomCompositeOptions>optsOrLayout;\n layout = opts.layout;\n options = opts.encodingOptions;\n audioOnly = opts.audioOnly;\n videoOnly = opts.videoOnly;\n customBaseUrl = opts.customBaseUrl;\n audioMixing = opts.audioMixing;\n webhooks = opts.webhooks;\n }\n }\n\n layout ??= '';\n audioOnly ??= false;\n videoOnly ??= false;\n customBaseUrl ??= '';\n audioMixing ??= AudioMixing.DEFAULT_MIXING;\n\n const {\n output: legacyOutput,\n options: egressOptions,\n fileOutputs,\n streamOutputs,\n segmentOutputs,\n imageOutputs,\n } = this.getOutputParams(output, options);\n\n const req = new RoomCompositeEgressRequest({\n roomName,\n layout,\n audioOnly,\n audioMixing,\n videoOnly,\n customBaseUrl,\n output: legacyOutput,\n options: egressOptions,\n fileOutputs,\n streamOutputs,\n segmentOutputs,\n imageOutputs,\n webhooks,\n }).toJson();\n\n const data = await this.rpc.request(\n svc,\n 'StartRoomCompositeEgress',\n req,\n await this.authHeader({ roomRecord: true }),\n );\n return EgressInfo.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * @param url - url\n * @param output - file or stream output\n * @param opts - WebOptions\n */\n async startWebEgress(\n url: string,\n output: EncodedOutputs | EncodedFileOutput | StreamOutput | SegmentedFileOutput,\n opts?: WebOptions,\n ): Promise<EgressInfo> {\n const audioOnly = opts?.audioOnly || false;\n const videoOnly = opts?.videoOnly || false;\n const awaitStartSignal = opts?.awaitStartSignal || false;\n const webhooks = opts?.webhooks || [];\n const {\n output: legacyOutput,\n options,\n fileOutputs,\n streamOutputs,\n segmentOutputs,\n imageOutputs,\n } = this.getOutputParams(output, opts?.encodingOptions);\n\n const req = new WebEgressRequest({\n url,\n audioOnly,\n videoOnly,\n awaitStartSignal,\n output: legacyOutput,\n options,\n fileOutputs,\n streamOutputs,\n segmentOutputs,\n imageOutputs,\n webhooks,\n }).toJson();\n\n const data = await this.rpc.request(\n svc,\n 'StartWebEgress',\n req,\n await this.authHeader({ roomRecord: true }),\n );\n return EgressInfo.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * Export a participant's audio and video tracks,\n *\n * @param roomName - room name\n * @param output - one or more outputs\n * @param opts - ParticipantEgressOptions\n */\n async startParticipantEgress(\n roomName: string,\n identity: string,\n output: EncodedOutputs,\n opts?: ParticipantEgressOptions,\n ): Promise<EgressInfo> {\n const webhooks = opts?.webhooks || [];\n const { options, fileOutputs, streamOutputs, segmentOutputs, imageOutputs } =\n this.getOutputParams(output, opts?.encodingOptions);\n const req = new ParticipantEgressRequest({\n roomName,\n identity,\n screenShare: opts?.screenShare ?? false,\n options,\n fileOutputs,\n streamOutputs,\n segmentOutputs,\n imageOutputs,\n webhooks,\n }).toJson();\n\n const data = await this.rpc.request(\n svc,\n 'StartParticipantEgress',\n req,\n await this.authHeader({ roomRecord: true }),\n );\n return EgressInfo.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * @param roomName - room name\n * @param output - file or stream output\n * @param opts - TrackCompositeOptions\n */\n async startTrackCompositeEgress(\n roomName: string,\n output: EncodedOutputs | EncodedFileOutput | StreamOutput | SegmentedFileOutput,\n opts?: TrackCompositeOptions,\n ): Promise<EgressInfo>;\n /**\n * @deprecated use TrackCompositeOptions instead\n */\n async startTrackCompositeEgress(\n roomName: string,\n output: EncodedOutputs | EncodedFileOutput | StreamOutput | SegmentedFileOutput,\n audioTrackId?: string,\n videoTrackId?: string,\n options?: EncodingOptionsPreset | EncodingOptions,\n ): Promise<EgressInfo>;\n async startTrackCompositeEgress(\n roomName: string,\n output: EncodedOutputs | EncodedFileOutput | StreamOutput | SegmentedFileOutput,\n optsOrAudioTrackId?: TrackCompositeOptions | string,\n videoTrackId?: string,\n options?: EncodingOptionsPreset | EncodingOptions,\n ): Promise<EgressInfo> {\n let audioTrackId: string | undefined;\n let webhooks: WebhookConfig[] | undefined;\n if (optsOrAudioTrackId !== undefined) {\n if (typeof optsOrAudioTrackId === 'string') {\n audioTrackId = optsOrAudioTrackId;\n } else {\n const opts = <TrackCompositeOptions>optsOrAudioTrackId;\n audioTrackId = opts.audioTrackId;\n videoTrackId = opts.videoTrackId;\n options = opts.encodingOptions;\n webhooks = opts.webhooks;\n }\n }\n\n audioTrackId ??= '';\n videoTrackId ??= '';\n\n const {\n output: legacyOutput,\n options: egressOptions,\n fileOutputs,\n streamOutputs,\n segmentOutputs,\n imageOutputs,\n } = this.getOutputParams(output, options);\n const req = new TrackCompositeEgressRequest({\n roomName,\n audioTrackId,\n videoTrackId,\n output: legacyOutput,\n options: egressOptions,\n fileOutputs,\n streamOutputs,\n segmentOutputs,\n imageOutputs,\n webhooks,\n }).toJson();\n\n const data = await this.rpc.request(\n svc,\n 'StartTrackCompositeEgress',\n req,\n await this.authHeader({ roomRecord: true }),\n );\n return EgressInfo.fromJson(data, { ignoreUnknownFields: true });\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private isEncodedOutputs(output: any): output is EncodedOutputs {\n return (\n (<EncodedOutputs>output).file !== undefined ||\n (<EncodedOutputs>output).stream !== undefined ||\n (<EncodedOutputs>output).segments !== undefined ||\n (<EncodedOutputs>output).images !== undefined\n );\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private isEncodedFileOutput(output: any): output is EncodedFileOutput {\n return (\n (<EncodedFileOutput>output).filepath !== undefined ||\n (<EncodedFileOutput>output).fileType !== undefined\n );\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private isSegmentedFileOutput(output: any): output is SegmentedFileOutput {\n return (\n (<SegmentedFileOutput>output).filenamePrefix !== undefined ||\n (<SegmentedFileOutput>output).playlistName !== undefined ||\n (<SegmentedFileOutput>output).filenameSuffix !== undefined\n );\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private isStreamOutput(output: any): output is StreamOutput {\n return (\n (<StreamOutput>output).protocol !== undefined || (<StreamOutput>output).urls !== undefined\n );\n }\n\n private getOutputParams(\n output: EncodedOutputs | EncodedFileOutput | StreamOutput | SegmentedFileOutput,\n opts?: EncodingOptionsPreset | EncodingOptions,\n ) {\n let file: EncodedFileOutput | undefined;\n let fileOutputs: Array<EncodedFileOutput> | undefined;\n let stream: StreamOutput | undefined;\n let streamOutputs: Array<StreamOutput> | undefined;\n let segments: SegmentedFileOutput | undefined;\n let segmentOutputs: Array<SegmentedFileOutput> | undefined;\n let imageOutputs: Array<ImageOutput> | undefined;\n\n if (this.isEncodedOutputs(output)) {\n if (output.file !== undefined) {\n fileOutputs = [output.file];\n }\n if (output.stream !== undefined) {\n streamOutputs = [output.stream];\n }\n if (output.segments !== undefined) {\n segmentOutputs = [output.segments];\n }\n if (output.images !== undefined) {\n imageOutputs = [output.images];\n }\n } else if (this.isEncodedFileOutput(output)) {\n file = output;\n fileOutputs = [file];\n } else if (this.isSegmentedFileOutput(output)) {\n segments = output;\n segmentOutputs = [segments];\n } else if (this.isStreamOutput(output)) {\n stream = output;\n streamOutputs = [stream];\n }\n\n let legacyOutput:\n | {\n value: EncodedFileOutput;\n case: 'file';\n }\n | {\n value: StreamOutput;\n case: 'stream';\n }\n | {\n value: SegmentedFileOutput;\n case: 'segments';\n }\n | undefined;\n\n if (file) {\n legacyOutput = {\n case: 'file',\n value: file,\n };\n } else if (stream) {\n legacyOutput = {\n case: 'stream',\n value: stream,\n };\n } else if (segments) {\n legacyOutput = {\n case: 'segments',\n value: segments,\n };\n }\n let egressOptions:\n | {\n value: EncodingOptionsPreset;\n case: 'preset';\n }\n | {\n value: EncodingOptions;\n case: 'advanced';\n }\n | undefined;\n if (opts) {\n if (typeof opts === 'number') {\n egressOptions = {\n case: 'preset',\n value: opts,\n };\n } else {\n egressOptions = {\n case: 'advanced',\n value: <EncodingOptions>opts,\n };\n }\n }\n\n return {\n output: legacyOutput,\n options: egressOptions,\n fileOutputs,\n streamOutputs,\n segmentOutputs,\n imageOutputs,\n };\n }\n\n /**\n * @param roomName - room name\n * @param output - file or websocket output\n * @param trackId - track Id\n */\n async startTrackEgress(\n roomName: string,\n output: DirectFileOutput | string,\n trackId: string,\n webhooks?: WebhookConfig[],\n ): Promise<EgressInfo> {\n let legacyOutput:\n | {\n value: DirectFileOutput;\n case: 'file';\n }\n | {\n value: string;\n case: 'websocketUrl';\n }\n | undefined;\n\n if (typeof output === 'string') {\n legacyOutput = {\n case: 'websocketUrl',\n value: output,\n };\n } else {\n legacyOutput = {\n case: 'file',\n value: output,\n };\n }\n\n const req = new TrackEgressRequest({\n roomName,\n trackId,\n output: legacyOutput,\n webhooks,\n }).toJson();\n\n const data = await this.rpc.request(\n svc,\n 'StartTrackEgress',\n req,\n await this.authHeader({ roomRecord: true }),\n );\n return EgressInfo.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * @param egressId -\n * @param layout -\n */\n async updateLayout(egressId: string, layout: string): Promise<EgressInfo> {\n const data = await this.rpc.request(\n svc,\n 'UpdateLayout',\n new UpdateLayoutRequest({ egressId, layout }).toJson(),\n await this.authHeader({ roomRecord: true }),\n );\n return EgressInfo.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * @param egressId -\n * @param addOutputUrls -\n * @param removeOutputUrls -\n */\n async updateStream(\n egressId: string,\n addOutputUrls?: string[],\n removeOutputUrls?: string[],\n ): Promise<EgressInfo> {\n addOutputUrls ??= [];\n removeOutputUrls ??= [];\n\n const data = await this.rpc.request(\n svc,\n 'UpdateStream',\n new UpdateStreamRequest({ egressId, addOutputUrls, removeOutputUrls }).toJson(),\n await this.authHeader({ roomRecord: true }),\n );\n return EgressInfo.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * @param options - options to filter listed Egresses, by default returns all\n * Egress instances\n */\n async listEgress(options?: ListEgressOptions): Promise<Array<EgressInfo>>;\n /**\n * @deprecated use `listEgress(options?: ListEgressOptions)` instead\n * @param roomName - list egress for one room only\n */\n async listEgress(roomName?: string): Promise<Array<EgressInfo>>;\n /**\n * @param roomName - list egress for one room only\n */\n async listEgress(options?: string | ListEgressOptions): Promise<Array<EgressInfo>> {\n let req: Partial<ListEgressRequest> = {};\n if (typeof options === 'string') {\n req.roomName = options;\n } else if (options !== undefined) {\n req = options;\n }\n\n const data = await this.rpc.request(\n svc,\n 'ListEgress',\n new ListEgressRequest(req).toJson(),\n await this.authHeader({ roomRecord: true }),\n );\n return ListEgressResponse.fromJson(data, { ignoreUnknownFields: true }).items ?? [];\n }\n\n /**\n * @param egressId -\n */\n async stopEgress(egressId: string): Promise<EgressInfo> {\n const data = await this.rpc.request(\n svc,\n 'StopEgress',\n new StopEgressRequest({ egressId }).toJson(),\n await this.authHeader({ roomRecord: true }),\n );\n return EgressInfo.fromJson(data, { ignoreUnknownFields: true });\n }\n}\n"],"mappings":"AAaA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA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AAC;AAAA,EAChE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,aACJ,UACA,eACA,kBACqB;AACrB,sBAAkB,CAAC;AACnB,yBAAqB,CAAC;AAEtB,UAAM,OAAO,MAAM,KAAK,IAAI;AAAA,MAC1B;AAAA,MACA;AAAA,MACA,IAAI,oBAAoB,EAAE,UAAU,eAAe,iBAAiB,CAAC,EAAE,OAAO;AAAA,MAC9E,MAAM,KAAK,WAAW,EAAE,YAAY,KAAK,CAAC;AAAA,IAC5C;AACA,WAAO,WAAW,SAAS,MAAM,EAAE,qBAAqB,KAAK,CAAC;AAAA,EAChE;AAAA;AAAA;AAAA;AAAA,EAeA,MAAM,WAAW,SAAkE;AACjF,QAAI,MAAkC,CAAC;AACvC,QAAI,OAAO,YAAY,UAAU;AAC/B,UAAI,WAAW;AAAA,IACjB,WAAW,YAAY,QAAW;AAChC,YAAM;AAAA,IACR;AAEA,UAAM,OAAO,MAAM,KAAK,IAAI;AAAA,MAC1B;AAAA,MACA;AAAA,MACA,IAAI,kBAAkB,GAAG,EAAE,OAAO;AAAA,MAClC,MAAM,KAAK,WAAW,EAAE,YAAY,KAAK,CAAC;AAAA,IAC5C;AACA,WAAO,mBAAmB,SAAS,MAAM,EAAE,qBAAqB,KAAK,CAAC,EAAE,SAAS,CAAC;AAAA,EACpF;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,WAAW,UAAuC;AACtD,UAAM,OAAO,MAAM,KAAK,IAAI;AAAA,MAC1B;AAAA,MACA;AAAA,MACA,IAAI,kBAAkB,EAAE,SAAS,CAAC,EAAE,OAAO;AAAA,MAC3C,MAAM,KAAK,WAAW,EAAE,YAAY,KAAK,CAAC;AAAA,IAC5C;AACA,WAAO,WAAW,SAAS,MAAM,EAAE,qBAAqB,KAAK,CAAC;AAAA,EAChE;AACF;","names":[]}
@@ -30,10 +30,12 @@ class IngressClient extends import_ServiceBase.ServiceBase {
30
30
  * @param host - hostname including protocol. i.e. 'https://<project>.livekit.cloud'
31
31
  * @param apiKey - API Key, can be set in env var LIVEKIT_API_KEY
32
32
  * @param secret - API Secret, can be set in env var LIVEKIT_API_SECRET
33
+ * @param options - client options
33
34
  */
34
- constructor(host, apiKey, secret) {
35
+ constructor(host, apiKey, secret, options) {
35
36
  super(apiKey, secret);
36
- this.rpc = new import_TwirpRPC.TwirpRpc(host, import_TwirpRPC.livekitPackage);
37
+ const rpcOptions = (options == null ? void 0 : options.requestTimeout) ? { requestTimeout: options.requestTimeout } : void 0;
38
+ this.rpc = new import_TwirpRPC.TwirpRpc(host, import_TwirpRPC.livekitPackage, rpcOptions);
37
39
  }
38
40
  /**
39
41
  * @param inputType - protocol for the ingress
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/IngressClient.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type { IngressAudioOptions, IngressInput, IngressVideoOptions } from '@livekit/protocol';\nimport {\n CreateIngressRequest,\n DeleteIngressRequest,\n IngressInfo,\n ListIngressRequest,\n ListIngressResponse,\n UpdateIngressRequest,\n} from '@livekit/protocol';\nimport { ServiceBase } from './ServiceBase.js';\nimport type { Rpc } from './TwirpRPC.js';\nimport { TwirpRpc, livekitPackage } from './TwirpRPC.js';\n\nconst svc = 'Ingress';\n\nexport interface CreateIngressOptions {\n /**\n * ingress name. optional\n */\n name?: string;\n /**\n * name of the room to send media to. required\n */\n roomName?: string;\n /**\n * unique identity of the participant. required\n */\n participantIdentity: string;\n /**\n * participant display name\n */\n participantName?: string;\n /**\n * metadata to attach to the participant\n */\n participantMetadata?: string;\n /**\n * @deprecated use `enableTranscoding` instead.\n * whether to skip transcoding and forward the input media directly. Only supported by WHIP\n */\n bypassTranscoding?: boolean;\n /**\n * whether to enable transcoding or forward the input media directly.\n * Transcoding is required for all input types except WHIP. For WHIP, the default is to not transcode.\n */\n enableTranscoding?: boolean | undefined;\n /**\n * url of the media to pull for ingresses of type URL\n */\n url?: string;\n /**\n * custom audio encoding parameters. optional\n */\n audio?: IngressAudioOptions;\n /**\n * custom video encoding parameters. optional\n */\n video?: IngressVideoOptions;\n}\n\nexport interface UpdateIngressOptions {\n /**\n * ingress name. optional\n */\n name: string;\n /**\n * name of the room to send media to.\n */\n roomName?: string;\n /**\n * unique identity of the participant.\n */\n participantIdentity?: string;\n /**\n * participant display name\n */\n participantName?: string;\n /**\n * metadata to attach to the participant\n */\n participantMetadata?: string;\n /**\n * @deprecated use `enableTranscoding` instead\n * whether to skip transcoding and forward the input media directly. Only supported by WHIP\n */\n bypassTranscoding?: boolean | undefined;\n /**\n * whether to enable transcoding or forward the input media directly.\n * Transcoding is required for all input types except WHIP. For WHIP, the default is to not transcode.\n */\n enableTranscoding?: boolean | undefined;\n /**\n * custom audio encoding parameters. optional\n */\n audio?: IngressAudioOptions;\n /**\n * custom video encoding parameters. optional\n */\n video?: IngressVideoOptions;\n}\n\nexport interface ListIngressOptions {\n /**\n * list ingress for one room only\n */\n roomName?: string;\n\n /**\n * list ingress by ID\n */\n ingressId?: string;\n}\n\n/**\n * Client to access Ingress APIs\n */\nexport class IngressClient extends ServiceBase {\n private readonly rpc: Rpc;\n\n /**\n * @param host - hostname including protocol. i.e. 'https://<project>.livekit.cloud'\n * @param apiKey - API Key, can be set in env var LIVEKIT_API_KEY\n * @param secret - API Secret, can be set in env var LIVEKIT_API_SECRET\n */\n constructor(host: string, apiKey?: string, secret?: string) {\n super(apiKey, secret);\n this.rpc = new TwirpRpc(host, livekitPackage);\n }\n\n /**\n * @param inputType - protocol for the ingress\n * @param opts - CreateIngressOptions\n */\n async createIngress(inputType: IngressInput, opts: CreateIngressOptions): Promise<IngressInfo> {\n let name: string = '';\n let participantName: string = '';\n let participantIdentity: string = '';\n let bypassTranscoding: boolean = false;\n let url: string = '';\n\n if (opts == null) {\n throw new Error('options dictionary is required');\n }\n\n const roomName: string | undefined = opts.roomName;\n const enableTranscoding: boolean | undefined = opts.enableTranscoding;\n const audio: IngressAudioOptions | undefined = opts.audio;\n const video: IngressVideoOptions | undefined = opts.video;\n const participantMetadata: string | undefined = opts.participantMetadata;\n\n name = opts.name || '';\n participantName = opts.participantName || '';\n participantIdentity = opts.participantIdentity || '';\n bypassTranscoding = opts.bypassTranscoding || false;\n url = opts.url || '';\n\n if (typeof roomName == 'undefined') {\n throw new Error('required roomName option not provided');\n }\n\n if (participantIdentity == '') {\n throw new Error('required participantIdentity option not provided');\n }\n\n const req = new CreateIngressRequest({\n inputType,\n name,\n roomName,\n participantIdentity,\n participantMetadata,\n participantName,\n bypassTranscoding,\n enableTranscoding,\n url,\n audio,\n video,\n }).toJson();\n\n const data = await this.rpc.request(\n svc,\n 'CreateIngress',\n req,\n await this.authHeader({ ingressAdmin: true }),\n );\n return IngressInfo.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * @param ingressId - ID of the ingress to update\n * @param opts - UpdateIngressOptions\n */\n async updateIngress(ingressId: string, opts: UpdateIngressOptions): Promise<IngressInfo> {\n const name: string = opts.name || '';\n const roomName: string = opts.roomName || '';\n const participantName: string = opts.participantName || '';\n const participantIdentity: string = opts.participantIdentity || '';\n const { participantMetadata } = opts;\n const { audio, video, bypassTranscoding, enableTranscoding } = opts;\n\n const req = new UpdateIngressRequest({\n ingressId,\n name,\n roomName,\n participantIdentity,\n participantName,\n participantMetadata,\n bypassTranscoding,\n enableTranscoding,\n audio,\n video,\n }).toJson();\n\n const data = await this.rpc.request(\n svc,\n 'UpdateIngress',\n req,\n await this.authHeader({ ingressAdmin: true }),\n );\n return IngressInfo.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * @deprecated use `listIngress(opts)` or `listIngress(arg)` instead\n * @param roomName - list ingress for one room only\n */\n async listIngress(roomName?: string): Promise<Array<IngressInfo>>;\n /**\n * @param opts - list options\n */\n async listIngress(opts?: ListIngressOptions): Promise<Array<IngressInfo>>;\n /**\n * @param arg - list room name or options\n */\n async listIngress(arg?: string | ListIngressOptions): Promise<Array<IngressInfo>> {\n let req: Partial<ListIngressRequest> = {};\n if (typeof arg === 'string') {\n req.roomName = arg;\n } else if (arg) {\n req = arg;\n }\n const data = await this.rpc.request(\n svc,\n 'ListIngress',\n new ListIngressRequest(req).toJson(),\n await this.authHeader({ ingressAdmin: true }),\n );\n return ListIngressResponse.fromJson(data, { ignoreUnknownFields: true }).items ?? [];\n }\n\n /**\n * @param ingressId - ingress to delete\n */\n async deleteIngress(ingressId: string): Promise<IngressInfo> {\n const data = await this.rpc.request(\n svc,\n 'DeleteIngress',\n new DeleteIngressRequest({ ingressId }).toJson(),\n await this.authHeader({ ingressAdmin: true }),\n );\n return IngressInfo.fromJson(data, { ignoreUnknownFields: true });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,sBAOO;AACP,yBAA4B;AAE5B,sBAAyC;AAEzC,MAAM,MAAM;AAuGL,MAAM,sBAAsB,+BAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ7C,YAAY,MAAc,QAAiB,QAAiB;AAC1D,UAAM,QAAQ,MAAM;AACpB,SAAK,MAAM,IAAI,yBAAS,MAAM,8BAAc;AAAA,EAC9C;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,cAAc,WAAyB,MAAkD;AAC7F,QAAI,OAAe;AACnB,QAAI,kBAA0B;AAC9B,QAAI,sBAA8B;AAClC,QAAI,oBAA6B;AACjC,QAAI,MAAc;AAElB,QAAI,QAAQ,MAAM;AAChB,YAAM,IAAI,MAAM,gCAAgC;AAAA,IAClD;AAEA,UAAM,WAA+B,KAAK;AAC1C,UAAM,oBAAyC,KAAK;AACpD,UAAM,QAAyC,KAAK;AACpD,UAAM,QAAyC,KAAK;AACpD,UAAM,sBAA0C,KAAK;AAErD,WAAO,KAAK,QAAQ;AACpB,sBAAkB,KAAK,mBAAmB;AAC1C,0BAAsB,KAAK,uBAAuB;AAClD,wBAAoB,KAAK,qBAAqB;AAC9C,UAAM,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cA,MAAM,YAAY,KAAgE;AAChF,QAAI,MAAmC,CAAC;AACxC,QAAI,OAAO,QAAQ,UAAU;AAC3B,UAAI,WAAW;AAAA,IACjB,WAAW,KAAK;AACd,YAAM;AAAA,IACR;AACA,UAAM,OAAO,MAAM,KAAK,IAAI;AAAA,MAC1B;AAAA,MACA;AAAA,MACA,IAAI,mCAAmB,GAAG,EAAE,OAAO;AAAA,MACnC,MAAM,KAAK,WAAW,EAAE,cAAc,KAAK,CAAC;AAAA,IAC9C;AACA,WAAO,oCAAoB,SAAS,MAAM,EAAE,qBAAqB,KAAK,CAAC,EAAE,SAAS,CAAC;AAAA,EACrF;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,cAAc,WAAyC;AAC3D,UAAM,OAAO,MAAM,KAAK,IAAI;AAAA,MAC1B;AAAA,MACA;AAAA,MACA,IAAI,qCAAqB,EAAE,UAAU,CAAC,EAAE,OAAO;AAAA,MAC/C,MAAM,KAAK,WAAW,EAAE,cAAc,KAAK,CAAC;AAAA,IAC9C;AACA,WAAO,4BAAY,SAAS,MAAM,EAAE,qBAAqB,KAAK,CAAC;AAAA,EACjE;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/IngressClient.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type { IngressAudioOptions, IngressInput, IngressVideoOptions } from '@livekit/protocol';\nimport {\n CreateIngressRequest,\n DeleteIngressRequest,\n IngressInfo,\n ListIngressRequest,\n ListIngressResponse,\n UpdateIngressRequest,\n} from '@livekit/protocol';\nimport type { ClientOptions } from './ClientOptions.js';\nimport { ServiceBase } from './ServiceBase.js';\nimport type { Rpc } from './TwirpRPC.js';\nimport { TwirpRpc, livekitPackage } from './TwirpRPC.js';\n\nconst svc = 'Ingress';\n\nexport interface CreateIngressOptions {\n /**\n * ingress name. optional\n */\n name?: string;\n /**\n * name of the room to send media to. required\n */\n roomName?: string;\n /**\n * unique identity of the participant. required\n */\n participantIdentity: string;\n /**\n * participant display name\n */\n participantName?: string;\n /**\n * metadata to attach to the participant\n */\n participantMetadata?: string;\n /**\n * @deprecated use `enableTranscoding` instead.\n * whether to skip transcoding and forward the input media directly. Only supported by WHIP\n */\n bypassTranscoding?: boolean;\n /**\n * whether to enable transcoding or forward the input media directly.\n * Transcoding is required for all input types except WHIP. For WHIP, the default is to not transcode.\n */\n enableTranscoding?: boolean | undefined;\n /**\n * url of the media to pull for ingresses of type URL\n */\n url?: string;\n /**\n * custom audio encoding parameters. optional\n */\n audio?: IngressAudioOptions;\n /**\n * custom video encoding parameters. optional\n */\n video?: IngressVideoOptions;\n}\n\nexport interface UpdateIngressOptions {\n /**\n * ingress name. optional\n */\n name: string;\n /**\n * name of the room to send media to.\n */\n roomName?: string;\n /**\n * unique identity of the participant.\n */\n participantIdentity?: string;\n /**\n * participant display name\n */\n participantName?: string;\n /**\n * metadata to attach to the participant\n */\n participantMetadata?: string;\n /**\n * @deprecated use `enableTranscoding` instead\n * whether to skip transcoding and forward the input media directly. Only supported by WHIP\n */\n bypassTranscoding?: boolean | undefined;\n /**\n * whether to enable transcoding or forward the input media directly.\n * Transcoding is required for all input types except WHIP. For WHIP, the default is to not transcode.\n */\n enableTranscoding?: boolean | undefined;\n /**\n * custom audio encoding parameters. optional\n */\n audio?: IngressAudioOptions;\n /**\n * custom video encoding parameters. optional\n */\n video?: IngressVideoOptions;\n}\n\nexport interface ListIngressOptions {\n /**\n * list ingress for one room only\n */\n roomName?: string;\n\n /**\n * list ingress by ID\n */\n ingressId?: string;\n}\n\n/**\n * Client to access Ingress APIs\n */\nexport class IngressClient extends ServiceBase {\n private readonly rpc: Rpc;\n\n /**\n * @param host - hostname including protocol. i.e. 'https://<project>.livekit.cloud'\n * @param apiKey - API Key, can be set in env var LIVEKIT_API_KEY\n * @param secret - API Secret, can be set in env var LIVEKIT_API_SECRET\n * @param options - client options\n */\n constructor(host: string, apiKey?: string, secret?: string, options?: ClientOptions) {\n super(apiKey, secret);\n const rpcOptions = options?.requestTimeout\n ? { requestTimeout: options.requestTimeout }\n : undefined;\n this.rpc = new TwirpRpc(host, livekitPackage, rpcOptions);\n }\n\n /**\n * @param inputType - protocol for the ingress\n * @param opts - CreateIngressOptions\n */\n async createIngress(inputType: IngressInput, opts: CreateIngressOptions): Promise<IngressInfo> {\n let name: string = '';\n let participantName: string = '';\n let participantIdentity: string = '';\n let bypassTranscoding: boolean = false;\n let url: string = '';\n\n if (opts == null) {\n throw new Error('options dictionary is required');\n }\n\n const roomName: string | undefined = opts.roomName;\n const enableTranscoding: boolean | undefined = opts.enableTranscoding;\n const audio: IngressAudioOptions | undefined = opts.audio;\n const video: IngressVideoOptions | undefined = opts.video;\n const participantMetadata: string | undefined = opts.participantMetadata;\n\n name = opts.name || '';\n participantName = opts.participantName || '';\n participantIdentity = opts.participantIdentity || '';\n bypassTranscoding = opts.bypassTranscoding || false;\n url = opts.url || '';\n\n if (typeof roomName == 'undefined') {\n throw new Error('required roomName option not provided');\n }\n\n if (participantIdentity == '') {\n throw new Error('required participantIdentity option not provided');\n }\n\n const req = new CreateIngressRequest({\n inputType,\n name,\n roomName,\n participantIdentity,\n participantMetadata,\n participantName,\n bypassTranscoding,\n enableTranscoding,\n url,\n audio,\n video,\n }).toJson();\n\n const data = await this.rpc.request(\n svc,\n 'CreateIngress',\n req,\n await this.authHeader({ ingressAdmin: true }),\n );\n return IngressInfo.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * @param ingressId - ID of the ingress to update\n * @param opts - UpdateIngressOptions\n */\n async updateIngress(ingressId: string, opts: UpdateIngressOptions): Promise<IngressInfo> {\n const name: string = opts.name || '';\n const roomName: string = opts.roomName || '';\n const participantName: string = opts.participantName || '';\n const participantIdentity: string = opts.participantIdentity || '';\n const { participantMetadata } = opts;\n const { audio, video, bypassTranscoding, enableTranscoding } = opts;\n\n const req = new UpdateIngressRequest({\n ingressId,\n name,\n roomName,\n participantIdentity,\n participantName,\n participantMetadata,\n bypassTranscoding,\n enableTranscoding,\n audio,\n video,\n }).toJson();\n\n const data = await this.rpc.request(\n svc,\n 'UpdateIngress',\n req,\n await this.authHeader({ ingressAdmin: true }),\n );\n return IngressInfo.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * @deprecated use `listIngress(opts)` or `listIngress(arg)` instead\n * @param roomName - list ingress for one room only\n */\n async listIngress(roomName?: string): Promise<Array<IngressInfo>>;\n /**\n * @param opts - list options\n */\n async listIngress(opts?: ListIngressOptions): Promise<Array<IngressInfo>>;\n /**\n * @param arg - list room name or options\n */\n async listIngress(arg?: string | ListIngressOptions): Promise<Array<IngressInfo>> {\n let req: Partial<ListIngressRequest> = {};\n if (typeof arg === 'string') {\n req.roomName = arg;\n } else if (arg) {\n req = arg;\n }\n const data = await this.rpc.request(\n svc,\n 'ListIngress',\n new ListIngressRequest(req).toJson(),\n await this.authHeader({ ingressAdmin: true }),\n );\n return ListIngressResponse.fromJson(data, { ignoreUnknownFields: true }).items ?? [];\n }\n\n /**\n * @param ingressId - ingress to delete\n */\n async deleteIngress(ingressId: string): Promise<IngressInfo> {\n const data = await this.rpc.request(\n svc,\n 'DeleteIngress',\n new DeleteIngressRequest({ ingressId }).toJson(),\n await this.authHeader({ ingressAdmin: true }),\n );\n return IngressInfo.fromJson(data, { ignoreUnknownFields: true });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,sBAOO;AAEP,yBAA4B;AAE5B,sBAAyC;AAEzC,MAAM,MAAM;AAuGL,MAAM,sBAAsB,+BAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAS7C,YAAY,MAAc,QAAiB,QAAiB,SAAyB;AACnF,UAAM,QAAQ,MAAM;AACpB,UAAM,cAAa,mCAAS,kBACxB,EAAE,gBAAgB,QAAQ,eAAe,IACzC;AACJ,SAAK,MAAM,IAAI,yBAAS,MAAM,gCAAgB,UAAU;AAAA,EAC1D;AAAA;AA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ioOptions, IngressVideoOptions, IngressInput, IngressInfo } from '@livekit/protocol';
2
+ import { ClientOptions } from './ClientOptions.cjs';
2
3
  import { ServiceBase } from './ServiceBase.cjs';
3
4
  import './grants.cjs';
4
5
  import 'jose';
@@ -106,8 +107,9 @@ declare class IngressClient extends ServiceBase {
106
107
  * @param host - hostname including protocol. i.e. 'https://<project>.livekit.cloud'
107
108
  * @param apiKey - API Key, can be set in env var LIVEKIT_API_KEY
108
109
  * @param secret - API Secret, can be set in env var LIVEKIT_API_SECRET
110
+ * @param options - client options
109
111
  */
110
- constructor(host: string, apiKey?: string, secret?: string);
112
+ constructor(host: string, apiKey?: string, secret?: string, options?: ClientOptions);
111
113
  /**
112
114
  * @param inputType - protocol for the ingress
113
115
  * @param opts - CreateIngressOptions
@@ -1,5 +1,6 @@
1
1
  import type { IngressAudioOptions, IngressInput, IngressVideoOptions } from '@livekit/protocol';
2
2
  import { IngressInfo } from '@livekit/protocol';
3
+ import type { ClientOptions } from './ClientOptions.js';
3
4
  import { ServiceBase } from './ServiceBase.js';
4
5
  export interface CreateIngressOptions {
5
6
  /**
@@ -104,8 +105,9 @@ export declare class IngressClient extends ServiceBase {
104
105
  * @param host - hostname including protocol. i.e. 'https://<project>.livekit.cloud'
105
106
  * @param apiKey - API Key, can be set in env var LIVEKIT_API_KEY
106
107
  * @param secret - API Secret, can be set in env var LIVEKIT_API_SECRET
108
+ * @param options - client options
107
109
  */
108
- constructor(host: string, apiKey?: string, secret?: string);
110
+ constructor(host: string, apiKey?: string, secret?: string, options?: ClientOptions);
109
111
  /**
110
112
  * @param inputType - protocol for the ingress
111
113
  * @param opts - CreateIngressOptions
@@ -1 +1 @@
1
- {"version":3,"file":"IngressClient.d.ts","sourceRoot":"","sources":["../src/IngressClient.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAChG,OAAO,EAGL,WAAW,EAIZ,MAAM,m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AAS,EAAE,YAAY,EAAE,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC,WAAW,CAAC;IAsD9F;;;OAGG;IACG,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC,WAAW,CAAC;IA8BxF;;;OAGG;IACG,WAAW,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IACjE;;OAEG;IACG,WAAW,CAAC,IAAI,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IAoBzE;;OAEG;IACG,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;CAS7D"}
@@ -14,10 +14,12 @@ class IngressClient extends ServiceBase {
14
14
  * @param host - hostname including protocol. i.e. 'https://<project>.livekit.cloud'
15
15
  * @param apiKey - API Key, can be set in env var LIVEKIT_API_KEY
16
16
  * @param secret - API Secret, can be set in env var LIVEKIT_API_SECRET
17
+ * @param options - client options
17
18
  */
18
- constructor(host, apiKey, secret) {
19
+ constructor(host, apiKey, secret, options) {
19
20
  super(apiKey, secret);
20
- this.rpc = new TwirpRpc(host, livekitPackage);
21
+ const rpcOptions = (options == null ? void 0 : options.requestTimeout) ? { requestTimeout: options.requestTimeout } : void 0;
22
+ this.rpc = new TwirpRpc(host, livekitPackage, rpcOptions);
21
23
  }
22
24
  /**
23
25
  * @param inputType - protocol for the ingress
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/IngressClient.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type { IngressAudioOptions, IngressInput, IngressVideoOptions } from '@livekit/protocol';\nimport {\n CreateIngressRequest,\n DeleteIngressRequest,\n IngressInfo,\n ListIngressRequest,\n ListIngressResponse,\n UpdateIngressRequest,\n} from '@livekit/protocol';\nimport { ServiceBase } from './ServiceBase.js';\nimport type { Rpc } from './TwirpRPC.js';\nimport { TwirpRpc, livekitPackage } from './TwirpRPC.js';\n\nconst svc = 'Ingress';\n\nexport interface CreateIngressOptions {\n /**\n * ingress name. optional\n */\n name?: string;\n /**\n * name of the room to send media to. required\n */\n roomName?: string;\n /**\n * unique identity of the participant. required\n */\n participantIdentity: string;\n /**\n * participant display name\n */\n participantName?: string;\n /**\n * metadata to attach to the participant\n */\n participantMetadata?: string;\n /**\n * @deprecated use `enableTranscoding` instead.\n * whether to skip transcoding and forward the input media directly. Only supported by WHIP\n */\n bypassTranscoding?: boolean;\n /**\n * whether to enable transcoding or forward the input media directly.\n * Transcoding is required for all input types except WHIP. For WHIP, the default is to not transcode.\n */\n enableTranscoding?: boolean | undefined;\n /**\n * url of the media to pull for ingresses of type URL\n */\n url?: string;\n /**\n * custom audio encoding parameters. optional\n */\n audio?: IngressAudioOptions;\n /**\n * custom video encoding parameters. optional\n */\n video?: IngressVideoOptions;\n}\n\nexport interface UpdateIngressOptions {\n /**\n * ingress name. optional\n */\n name: string;\n /**\n * name of the room to send media to.\n */\n roomName?: string;\n /**\n * unique identity of the participant.\n */\n participantIdentity?: string;\n /**\n * participant display name\n */\n participantName?: string;\n /**\n * metadata to attach to the participant\n */\n participantMetadata?: string;\n /**\n * @deprecated use `enableTranscoding` instead\n * whether to skip transcoding and forward the input media directly. Only supported by WHIP\n */\n bypassTranscoding?: boolean | undefined;\n /**\n * whether to enable transcoding or forward the input media directly.\n * Transcoding is required for all input types except WHIP. For WHIP, the default is to not transcode.\n */\n enableTranscoding?: boolean | undefined;\n /**\n * custom audio encoding parameters. optional\n */\n audio?: IngressAudioOptions;\n /**\n * custom video encoding parameters. optional\n */\n video?: IngressVideoOptions;\n}\n\nexport interface ListIngressOptions {\n /**\n * list ingress for one room only\n */\n roomName?: string;\n\n /**\n * list ingress by ID\n */\n ingressId?: string;\n}\n\n/**\n * Client to access Ingress APIs\n */\nexport class IngressClient extends ServiceBase {\n private readonly rpc: Rpc;\n\n /**\n * @param host - hostname including protocol. i.e. 'https://<project>.livekit.cloud'\n * @param apiKey - API Key, can be set in env var LIVEKIT_API_KEY\n * @param secret - API Secret, can be set in env var LIVEKIT_API_SECRET\n */\n constructor(host: string, apiKey?: string, secret?: string) {\n super(apiKey, secret);\n this.rpc = new TwirpRpc(host, livekitPackage);\n }\n\n /**\n * @param inputType - protocol for the ingress\n * @param opts - CreateIngressOptions\n */\n async createIngress(inputType: IngressInput, opts: CreateIngressOptions): Promise<IngressInfo> {\n let name: string = '';\n let participantName: string = '';\n let participantIdentity: string = '';\n let bypassTranscoding: boolean = false;\n let url: string = '';\n\n if (opts == null) {\n throw new Error('options dictionary is required');\n }\n\n const roomName: string | undefined = opts.roomName;\n const enableTranscoding: boolean | undefined = opts.enableTranscoding;\n const audio: IngressAudioOptions | undefined = opts.audio;\n const video: IngressVideoOptions | undefined = opts.video;\n const participantMetadata: string | undefined = opts.participantMetadata;\n\n name = opts.name || '';\n participantName = opts.participantName || '';\n participantIdentity = opts.participantIdentity || '';\n bypassTranscoding = opts.bypassTranscoding || false;\n url = opts.url || '';\n\n if (typeof roomName == 'undefined') {\n throw new Error('required roomName option not provided');\n }\n\n if (participantIdentity == '') {\n throw new Error('required participantIdentity option not provided');\n }\n\n const req = new CreateIngressRequest({\n inputType,\n name,\n roomName,\n participantIdentity,\n participantMetadata,\n participantName,\n bypassTranscoding,\n enableTranscoding,\n url,\n audio,\n video,\n }).toJson();\n\n const data = await this.rpc.request(\n svc,\n 'CreateIngress',\n req,\n await this.authHeader({ ingressAdmin: true }),\n );\n return IngressInfo.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * @param ingressId - ID of the ingress to update\n * @param opts - UpdateIngressOptions\n */\n async updateIngress(ingressId: string, opts: UpdateIngressOptions): Promise<IngressInfo> {\n const name: string = opts.name || '';\n const roomName: string = opts.roomName || '';\n const participantName: string = opts.participantName || '';\n const participantIdentity: string = opts.participantIdentity || '';\n const { participantMetadata } = opts;\n const { audio, video, bypassTranscoding, enableTranscoding } = opts;\n\n const req = new UpdateIngressRequest({\n ingressId,\n name,\n roomName,\n participantIdentity,\n participantName,\n participantMetadata,\n bypassTranscoding,\n enableTranscoding,\n audio,\n video,\n }).toJson();\n\n const data = await this.rpc.request(\n svc,\n 'UpdateIngress',\n req,\n await this.authHeader({ ingressAdmin: true }),\n );\n return IngressInfo.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * @deprecated use `listIngress(opts)` or `listIngress(arg)` instead\n * @param roomName - list ingress for one room only\n */\n async listIngress(roomName?: string): Promise<Array<IngressInfo>>;\n /**\n * @param opts - list options\n */\n async listIngress(opts?: ListIngressOptions): Promise<Array<IngressInfo>>;\n /**\n * @param arg - list room name or options\n */\n async listIngress(arg?: string | ListIngressOptions): Promise<Array<IngressInfo>> {\n let req: Partial<ListIngressRequest> = {};\n if (typeof arg === 'string') {\n req.roomName = arg;\n } else if (arg) {\n req = arg;\n }\n const data = await this.rpc.request(\n svc,\n 'ListIngress',\n new ListIngressRequest(req).toJson(),\n await this.authHeader({ ingressAdmin: true }),\n );\n return ListIngressResponse.fromJson(data, { ignoreUnknownFields: true }).items ?? [];\n }\n\n /**\n * @param ingressId - ingress to delete\n */\n async deleteIngress(ingressId: string): Promise<IngressInfo> {\n const data = await this.rpc.request(\n svc,\n 'DeleteIngress',\n new DeleteIngressRequest({ ingressId }).toJson(),\n await this.authHeader({ ingressAdmin: true }),\n );\n return IngressInfo.fromJson(data, { ignoreUnknownFields: true });\n }\n}\n"],"mappings":"AAIA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,mBAAmB;AAE5B,SAAS,UAAU,sBAAsB;AAEzC,MAAM,MAAM;AAuGL,MAAM,sBAAsB,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ7C,YAAY,MAAc,QAAiB,QAAiB;AAC1D,UAAM,QAAQ,MAAM;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;AAAA,EACjE;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/IngressClient.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type { IngressAudioOptions, IngressInput, IngressVideoOptions } from '@livekit/protocol';\nimport {\n CreateIngressRequest,\n DeleteIngressRequest,\n IngressInfo,\n ListIngressRequest,\n ListIngressResponse,\n UpdateIngressRequest,\n} from '@livekit/protocol';\nimport type { ClientOptions } from './ClientOptions.js';\nimport { ServiceBase } from './ServiceBase.js';\nimport type { Rpc } from './TwirpRPC.js';\nimport { TwirpRpc, livekitPackage } from './TwirpRPC.js';\n\nconst svc = 'Ingress';\n\nexport interface CreateIngressOptions {\n /**\n * ingress name. optional\n */\n name?: string;\n /**\n * name of the room to send media to. required\n */\n roomName?: string;\n /**\n * unique identity of the participant. required\n */\n participantIdentity: string;\n /**\n * participant display name\n */\n participantName?: string;\n /**\n * metadata to attach to the participant\n */\n participantMetadata?: string;\n /**\n * @deprecated use `enableTranscoding` instead.\n * whether to skip transcoding and forward the input media directly. Only supported by WHIP\n */\n bypassTranscoding?: boolean;\n /**\n * whether to enable transcoding or forward the input media directly.\n * Transcoding is required for all input types except WHIP. For WHIP, the default is to not transcode.\n */\n enableTranscoding?: boolean | undefined;\n /**\n * url of the media to pull for ingresses of type URL\n */\n url?: string;\n /**\n * custom audio encoding parameters. optional\n */\n audio?: IngressAudioOptions;\n /**\n * custom video encoding parameters. optional\n */\n video?: IngressVideoOptions;\n}\n\nexport interface UpdateIngressOptions {\n /**\n * ingress name. optional\n */\n name: string;\n /**\n * name of the room to send media to.\n */\n roomName?: string;\n /**\n * unique identity of the participant.\n */\n participantIdentity?: string;\n /**\n * participant display name\n */\n participantName?: string;\n /**\n * metadata to attach to the participant\n */\n participantMetadata?: string;\n /**\n * @deprecated use `enableTranscoding` instead\n * whether to skip transcoding and forward the input media directly. Only supported by WHIP\n */\n bypassTranscoding?: boolean | undefined;\n /**\n * whether to enable transcoding or forward the input media directly.\n * Transcoding is required for all input types except WHIP. For WHIP, the default is to not transcode.\n */\n enableTranscoding?: boolean | undefined;\n /**\n * custom audio encoding parameters. optional\n */\n audio?: IngressAudioOptions;\n /**\n * custom video encoding parameters. optional\n */\n video?: IngressVideoOptions;\n}\n\nexport interface ListIngressOptions {\n /**\n * list ingress for one room only\n */\n roomName?: string;\n\n /**\n * list ingress by ID\n */\n ingressId?: string;\n}\n\n/**\n * Client to access Ingress APIs\n */\nexport class IngressClient extends ServiceBase {\n private readonly rpc: Rpc;\n\n /**\n * @param host - hostname including protocol. i.e. 'https://<project>.livekit.cloud'\n * @param apiKey - API Key, can be set in env var LIVEKIT_API_KEY\n * @param secret - API Secret, can be set in env var LIVEKIT_API_SECRET\n * @param options - client options\n */\n constructor(host: string, apiKey?: string, secret?: string, options?: ClientOptions) {\n super(apiKey, secret);\n const rpcOptions = options?.requestTimeout\n ? { requestTimeout: options.requestTimeout }\n : undefined;\n this.rpc = new TwirpRpc(host, livekitPackage, rpcOptions);\n }\n\n /**\n * @param inputType - protocol for the ingress\n * @param opts - CreateIngressOptions\n */\n async createIngress(inputType: IngressInput, opts: CreateIngressOptions): Promise<IngressInfo> {\n let name: string = '';\n let participantName: string = '';\n let participantIdentity: string = '';\n let bypassTranscoding: boolean = false;\n let url: string = '';\n\n if (opts == null) {\n throw new Error('options dictionary is required');\n }\n\n const roomName: string | undefined = opts.roomName;\n const enableTranscoding: boolean | undefined = opts.enableTranscoding;\n const audio: IngressAudioOptions | undefined = opts.audio;\n const video: IngressVideoOptions | undefined = opts.video;\n const participantMetadata: string | undefined = opts.participantMetadata;\n\n name = opts.name || '';\n participantName = opts.participantName || '';\n participantIdentity = opts.participantIdentity || '';\n bypassTranscoding = opts.bypassTranscoding || false;\n url = opts.url || '';\n\n if (typeof roomName == 'undefined') {\n throw new Error('required roomName option not provided');\n }\n\n if (participantIdentity == '') {\n throw new Error('required participantIdentity option not provided');\n }\n\n const req = new CreateIngressRequest({\n inputType,\n name,\n roomName,\n participantIdentity,\n participantMetadata,\n participantName,\n bypassTranscoding,\n enableTranscoding,\n url,\n audio,\n video,\n }).toJson();\n\n const data = await this.rpc.request(\n svc,\n 'CreateIngress',\n req,\n await this.authHeader({ ingressAdmin: true }),\n );\n return IngressInfo.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * @param ingressId - ID of the ingress to update\n * @param opts - UpdateIngressOptions\n */\n async updateIngress(ingressId: string, opts: UpdateIngressOptions): Promise<IngressInfo> {\n const name: string = opts.name || '';\n const roomName: string = opts.roomName || '';\n const participantName: string = opts.participantName || '';\n const participantIdentity: string = opts.participantIdentity || '';\n const { participantMetadata } = opts;\n const { audio, video, bypassTranscoding, enableTranscoding } = opts;\n\n const req = new UpdateIngressRequest({\n ingressId,\n name,\n roomName,\n participantIdentity,\n participantName,\n participantMetadata,\n bypassTranscoding,\n enableTranscoding,\n audio,\n video,\n }).toJson();\n\n const data = await this.rpc.request(\n svc,\n 'UpdateIngress',\n req,\n await this.authHeader({ ingressAdmin: true }),\n );\n return IngressInfo.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * @deprecated use `listIngress(opts)` or `listIngress(arg)` instead\n * @param roomName - list ingress for one room only\n */\n async listIngress(roomName?: string): Promise<Array<IngressInfo>>;\n /**\n * @param opts - list options\n */\n async listIngress(opts?: ListIngressOptions): Promise<Array<IngressInfo>>;\n /**\n * @param arg - list room name or options\n */\n async listIngress(arg?: string | ListIngressOptions): Promise<Array<IngressInfo>> {\n let req: Partial<ListIngressRequest> = {};\n if (typeof arg === 'string') {\n req.roomName = arg;\n } else if (arg) {\n req = arg;\n }\n const data = await this.rpc.request(\n svc,\n 'ListIngress',\n new ListIngressRequest(req).toJson(),\n await this.authHeader({ ingressAdmin: true }),\n );\n return ListIngressResponse.fromJson(data, { ignoreUnknownFields: true }).items ?? [];\n }\n\n /**\n * @param ingressId - ingress to delete\n */\n async deleteIngress(ingressId: string): Promise<IngressInfo> {\n const data = await this.rpc.request(\n svc,\n 'DeleteIngress',\n new DeleteIngressRequest({ ingressId }).toJson(),\n await this.authHeader({ ingressAdmin: true }),\n );\n return IngressInfo.fromJson(data, { ignoreUnknownFields: true });\n }\n}\n"],"mappings":"AAIA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,mBAAmB;AAE5B,SAAS,UAAU,sBAAsB;AAEzC,MAAM,MAAM;AAuGL,MAAM,sBAAsB,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAS7C,YAAY,MAAc,QAAiB,QAAiB,SAAyB;AACnF,UAAM,QAAQ,MAAM;AACpB,UAAM,cAAa,mCAAS,kBACxB,EAAE,gBAAgB,QAAQ,eAAe,IACzC;AACJ,SAAK,MAAM,IAAI,SAAS,MAAM,gBAAgB,UAAU;AAAA,EAC1D;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,cAAc,WAAyB,MAAkD;AAC7F,QAAI,OAAe;AACnB,QAAI,kBAA0B;AAC9B,QAAI,sBAA8B;AAClC,QAAI,oBAA6B;AACjC,QAAI,MAAc;AAElB,QAAI,QAAQ,MAAM;AAChB,YAAM,IAAI,MAAM,gCAAgC;AAAA,IAClD;AAEA,UAAM,WAA+B,KAAK;AAC1C,UAAM,oBAAyC,KAAK;AACpD,UAAM,QAAyC,KAAK;AACpD,UAAM,QAAyC,KAAK;AACpD,UAAM,sBAA0C,KAAK;AAErD,WAAO,KAAK,QAAQ;AACpB,sBAAkB,KAAK,mBAAmB;AAC1C,0BAAsB,KAAK,uBAAuB;AAClD,wBAAoB,KAAK,qBAAqB;AAC9C,UAAM,KAAK,OAAO;AAElB,QAAI,OAAO,YAAY,aAAa;AAClC,YAAM,IAAI,MAAM,uCAAuC;AAAA,IACzD;AAEA,QAAI,uBAAuB,IAAI;AAC7B,YAAM,IAAI,MAAM,kDAAkD;AAAA,IACpE;AAEA,UAAM,MAAM,I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AAA,MAC1B;AAAA,MACA;AAAA,MACA,IAAI,mBAAmB,GAAG,EAAE,OAAO;AAAA,MACnC,MAAM,KAAK,WAAW,EAAE,cAAc,KAAK,CAAC;AAAA,IAC9C;AACA,WAAO,oBAAoB,SAAS,MAAM,EAAE,qBAAqB,KAAK,CAAC,EAAE,SAAS,CAAC;AAAA,EACrF;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,cAAc,WAAyC;AAC3D,UAAM,OAAO,MAAM,KAAK,IAAI;AAAA,MAC1B;AAAA,MACA;AAAA,MACA,IAAI,qBAAqB,EAAE,UAAU,CAAC,EAAE,OAAO;AAAA,MAC/C,MAAM,KAAK,WAAW,EAAE,cAAc,KAAK,CAAC;AAAA,IAC9C;AACA,WAAO,YAAY,SAAS,MAAM,EAAE,qBAAqB,KAAK,CAAC;AAAA,EACjE;AACF;","names":[]}
@@ -32,10 +32,12 @@ class RoomServiceClient extends import_ServiceBase.ServiceBase {
32
32
  * @param host - hostname including protocol. i.e. 'https://<project>.livekit.cloud'
33
33
  * @param apiKey - API Key, can be set in env var LIVEKIT_API_KEY
34
34
  * @param secret - API Secret, can be set in env var LIVEKIT_API_SECRET
35
+ * @param options - client options
35
36
  */
36
- constructor(host, apiKey, secret) {
37
+ constructor(host, apiKey, secret, options) {
37
38
  super(apiKey, secret);
38
- this.rpc = new import_TwirpRPC.TwirpRpc(host, import_TwirpRPC.livekitPackage);
39
+ const rpcOptions = (options == null ? void 0 : options.requestTimeout) ? { requestTimeout: options.requestTimeout } : void 0;
40
+ this.rpc = new import_TwirpRPC.TwirpRpc(host, import_TwirpRPC.livekitPackage, rpcOptions);
39
41
  }
40
42
  /**
41
43
  * Creates a new room. Explicit room creation is not required, since rooms will
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/RoomServiceClient.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type { DataPacket_Kind, RoomAgentDispatch, RoomEgress, TrackInfo } from '@livekit/protocol';\nimport {\n CreateRoomRequest,\n DeleteRoomRequest,\n ForwardParticipantRequest,\n ListParticipantsRequest,\n ListParticipantsResponse,\n ListRoomsRequest,\n ListRoomsResponse,\n MoveParticipantRequest,\n MuteRoomTrackRequest,\n MuteRoomTrackResponse,\n ParticipantInfo,\n ParticipantPermission,\n Room,\n RoomParticipantIdentity,\n SendDataRequest,\n UpdateParticipantRequest,\n UpdateRoomMetadataRequest,\n UpdateSubscriptionsRequest,\n} from '@livekit/protocol';\nimport { ServiceBase } from './ServiceBase.js';\nimport type { Rpc } from './TwirpRPC.js';\nimport { TwirpRpc, livekitPackage } from './TwirpRPC.js';\nimport { getRandomBytes } from './crypto/uuid.js';\n\n/**\n * Options for when creating a room\n */\nexport interface CreateOptions {\n /**\n * name of the room. required\n */\n name: string;\n\n /**\n * number of seconds to keep the room open before any participant joins\n */\n emptyTimeout?: number;\n\n /**\n * number of seconds to keep the room open after the last participant leaves\n * this option is helpful to give a grace period for participants to re-join\n */\n departureTimeout?: number;\n\n /**\n * limit to the number of participants in a room at a time\n */\n maxParticipants?: number;\n\n /**\n * initial room metadata\n */\n metadata?: string;\n\n /**\n * add egress options\n */\n egress?: RoomEgress;\n\n /**\n * minimum playout delay in milliseconds\n */\n minPlayoutDelay?: number;\n\n /**\n * maximum playout delay in milliseconds\n */\n maxPlayoutDelay?: number;\n\n /**\n * improves A/V sync when min_playout_delay set to a value larger than 200ms.\n * It will disables transceiver re-use -- this option is not recommended\n * for rooms with frequent subscription changes\n */\n syncStreams?: boolean;\n\n /**\n * agents that should be dispatched to this room\n */\n agents?: RoomAgentDispatch[];\n\n /**\n * override the node room is allocated to, for debugging\n * does not work with Cloud\n */\n nodeId?: string;\n}\n\nexport type SendDataOptions = {\n /** If set, only deliver to listed participant identities */\n destinationIdentities?: string[];\n destinationSids?: string[];\n topic?: string;\n};\n\nexport type UpdateParticipantOptions = {\n /** only attributes you'd want to update should be set, set value to empty string to remove it */\n attributes?: { [key: string]: string };\n metadata?: string;\n /** permissions are updated atomically - all desired permissions would need to be set */\n permission?: Partial<ParticipantPermission>;\n name?: string;\n};\n\nconst svc = 'RoomService';\n\n/**\n * Client to access Room APIs\n */\nexport class RoomServiceClient extends ServiceBase {\n private readonly rpc: Rpc;\n\n /**\n *\n * @param host - hostname including protocol. i.e. 'https://<project>.livekit.cloud'\n * @param apiKey - API Key, can be set in env var LIVEKIT_API_KEY\n * @param secret - API Secret, can be set in env var LIVEKIT_API_SECRET\n */\n constructor(host: string, apiKey?: string, secret?: string) {\n super(apiKey, secret);\n this.rpc = new TwirpRpc(host, livekitPackage);\n }\n\n /**\n * Creates a new room. Explicit room creation is not required, since rooms will\n * be automatically created when the first participant joins. This method can be\n * used to customize room settings.\n * @param options -\n */\n async createRoom(options: CreateOptions): Promise<Room> {\n const data = await this.rpc.request(\n svc,\n 'CreateRoom',\n new CreateRoomRequest(options).toJson(),\n await this.authHeader({ roomCreate: true }),\n );\n return Room.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * List active rooms\n * @param names - when undefined or empty, list all rooms.\n * otherwise returns rooms with matching names\n * @returns\n */\n async listRooms(names?: string[]): Promise<Room[]> {\n const data = await this.rpc.request(\n svc,\n 'ListRooms',\n new ListRoomsRequest({ names: names ?? [] }).toJson(),\n await this.authHeader({ roomList: true }),\n );\n const res = ListRoomsResponse.fromJson(data, { ignoreUnknownFields: true });\n return res.rooms ?? [];\n }\n\n async deleteRoom(room: string): Promise<void> {\n await this.rpc.request(\n svc,\n 'DeleteRoom',\n new DeleteRoomRequest({ room }).toJson(),\n await this.authHeader({ roomCreate: true }),\n );\n }\n\n /**\n * Update metadata of a room\n * @param room - name of the room\n * @param metadata - the new metadata for the room\n */\n async updateRoomMetadata(room: string, metadata: string) {\n const data = await this.rpc.request(\n svc,\n 'UpdateRoomMetadata',\n new UpdateRoomMetadataRequest({ room, metadata }).toJson(),\n await this.authHeader({ roomAdmin: true, room }),\n );\n return Room.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * List participants in a room\n * @param room - name of the room\n */\n async listParticipants(room: string): Promise<ParticipantInfo[]> {\n const data = await this.rpc.request(\n svc,\n 'ListParticipants',\n new ListParticipantsRequest({ room }).toJson(),\n await this.authHeader({ roomAdmin: true, room }),\n );\n const res = ListParticipantsResponse.fromJson(data, { ignoreUnknownFields: true });\n return res.participants ?? [];\n }\n\n /**\n * Get information on a specific participant, including the tracks that participant\n * has published\n * @param room - name of the room\n * @param identity - identity of the participant to return\n */\n async getParticipant(room: string, identity: string): Promise<ParticipantInfo> {\n const data = await this.rpc.request(\n svc,\n 'GetParticipant',\n new RoomParticipantIdentity({ room, identity }).toJson(),\n await this.authHeader({ roomAdmin: true, room }),\n );\n\n return ParticipantInfo.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * Removes a participant in the room. This will disconnect the participant\n * and will emit a Disconnected event for that participant.\n * Even after being removed, the participant can still re-join the room.\n * @param room -\n * @param identity -\n */\n async removeParticipant(room: string, identity: string): Promise<void> {\n await this.rpc.request(\n svc,\n 'RemoveParticipant',\n new RoomParticipantIdentity({ room, identity }).toJson(),\n await this.authHeader({ roomAdmin: true, room }),\n );\n }\n\n /**\n * Forwards a participant's track to another room. This will create a\n * participant to join the destination room that has same information\n * with the source participant except the kind to be `Forwarded`. All\n * changes to the source participant will be reflected to the forwarded\n * participant. When the source participant disconnects or the\n * `RemoveParticipant` method is called in the destination room, the\n * forwarding will be stopped.\n * @param room -\n * @param identity -\n * @param destinationRoom - the room to forward the participant to\n */\n async forwardParticipant(room: string, identity: string, destinationRoom: string): Promise<void> {\n await this.rpc.request(\n svc,\n 'ForwardParticipant',\n new ForwardParticipantRequest({ room, identity, destinationRoom }).toJson(),\n await this.authHeader({ roomAdmin: true, room, destinationRoom }),\n );\n }\n\n /**\n * Move a connected participant to a different room. Requires `roomAdmin` and `destinationRoom`.\n * The participant will be removed from the current room and added to the destination room.\n * From the other observers' perspective, the participant would've disconnected from the previous room and joined the new one.\n * @param room -\n * @param identity -\n * @param destinationRoom - the room to move the participant to\n */\n async moveParticipant(room: string, identity: string, destinationRoom: string): Promise<void> {\n await this.rpc.request(\n svc,\n 'MoveParticipant',\n new MoveParticipantRequest({ room, identity, destinationRoom }).toJson(),\n await this.authHeader({ roomAdmin: true, room, destinationRoom }),\n );\n }\n\n /**\n * Mutes a track that the participant has published.\n * @param room -\n * @param identity -\n * @param trackSid - sid of the track to be muted\n * @param muted - true to mute, false to unmute\n */\n async mutePublishedTrack(\n room: string,\n identity: string,\n trackSid: string,\n muted: boolean,\n ): Promise<TrackInfo> {\n const req = new MuteRoomTrackRequest({\n room,\n identity,\n trackSid,\n muted,\n }).toJson();\n const data = await this.rpc.request(\n svc,\n 'MutePublishedTrack',\n req,\n await this.authHeader({ roomAdmin: true, room }),\n );\n const res = MuteRoomTrackResponse.fromJson(data, { ignoreUnknownFields: true });\n return res.track!;\n }\n\n /**\n * Updates a participant's state or permissions\n * @param room - target room\n * @param identity - participant identity\n * @param options - participant fields to update\n */\n async updateParticipant(\n room: string,\n identity: string,\n options: UpdateParticipantOptions,\n ): Promise<ParticipantInfo>;\n /**\n * Updates a participant's state or permissions\n * @param room - target room\n * @param identity - participant identity\n * @param options - participant fields to update\n */\n async updateParticipant(\n room: string,\n identity: string,\n metadata?: string,\n permission?: Partial<ParticipantPermission>,\n name?: string,\n ): Promise<ParticipantInfo>;\n async updateParticipant(\n room: string,\n identity: string,\n metadataOrOptions?: string | UpdateParticipantOptions,\n maybePermission?: Partial<ParticipantPermission>,\n maybeName?: string,\n ): Promise<ParticipantInfo> {\n const hasOptions = typeof metadataOrOptions === 'object';\n const metadata = hasOptions ? metadataOrOptions?.metadata : metadataOrOptions;\n const permission = hasOptions ? metadataOrOptions.permission : maybePermission;\n const name = hasOptions ? metadataOrOptions.name : maybeName;\n const attributes: Record<string, string> | undefined = hasOptions\n ? metadataOrOptions.attributes\n : {};\n\n const req = new UpdateParticipantRequest({\n room,\n identity,\n attributes,\n metadata,\n name,\n });\n if (permission) {\n req.permission = new ParticipantPermission(permission);\n }\n const data = await this.rpc.request(\n svc,\n 'UpdateParticipant',\n req.toJson(),\n await this.authHeader({ roomAdmin: true, room }),\n );\n return ParticipantInfo.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * Updates a participant's subscription to tracks\n * @param room -\n * @param identity -\n * @param trackSids -\n * @param subscribe - true to subscribe, false to unsubscribe\n */\n async updateSubscriptions(\n room: string,\n identity: string,\n trackSids: string[],\n subscribe: boolean,\n ): Promise<void> {\n const req = new UpdateSubscriptionsRequest({\n room,\n identity,\n trackSids,\n subscribe,\n participantTracks: [],\n }).toJson();\n await this.rpc.request(\n svc,\n 'UpdateSubscriptions',\n req,\n await this.authHeader({ roomAdmin: true, room }),\n );\n }\n\n /**\n * Sends data message to participants in the room\n * @param room -\n * @param data - opaque payload to send\n * @param kind - delivery reliability\n * @param options - optionally specify a topic and destinationSids (when destinationSids is empty, message is sent to everyone)\n */\n async sendData(\n room: string,\n data: Uint8Array,\n kind: DataPacket_Kind,\n options: SendDataOptions,\n ): Promise<void>;\n /**\n * Sends data message to participants in the room\n * @deprecated use sendData(room, data, kind, options) instead\n * @param room -\n * @param data - opaque payload to send\n * @param kind - delivery reliability\n * @param destinationSids - optional. when empty, message is sent to everyone\n */\n async sendData(\n room: string,\n data: Uint8Array,\n kind: DataPacket_Kind,\n destinationSids?: string[],\n ): Promise<void>;\n async sendData(\n room: string,\n data: Uint8Array,\n kind: DataPacket_Kind,\n options: SendDataOptions | string[] = {},\n ): Promise<void> {\n const destinationSids = Array.isArray(options) ? options : options.destinationSids;\n const topic = Array.isArray(options) ? undefined : options.topic;\n const req = new SendDataRequest({\n room,\n data,\n kind,\n destinationSids: destinationSids ?? [],\n topic,\n });\n if (!Array.isArray(options) && options.destinationIdentities) {\n req.destinationIdentities = options.destinationIdentities;\n }\n req.nonce = await getRandomBytes(16);\n await this.rpc.request(\n svc,\n 'SendData',\n req.toJson(),\n await this.authHeader({ roomAdmin: true,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AAQ,OAAO,KAAK,QAAQ,uBAAuB;AAC5D,UAAI,wBAAwB,QAAQ;AAAA,IACtC;AACA,QAAI,QAAQ,UAAM,4BAAe,EAAE;AACnC,UAAM,KAAK,IAAI;AAAA,MACb;AAAA,MACA;AAAA,MACA,IAAI,OAAO;AAAA,MACX,MAAM,KAAK,WAAW,EAAE,WAAW,MAAM,KAAK,CAAC;AAAA,IACjD;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/RoomServiceClient.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type { DataPacket_Kind, RoomAgentDispatch, RoomEgress, TrackInfo } from '@livekit/protocol';\nimport {\n CreateRoomRequest,\n DeleteRoomRequest,\n ForwardParticipantRequest,\n ListParticipantsRequest,\n ListParticipantsResponse,\n ListRoomsRequest,\n ListRoomsResponse,\n MoveParticipantRequest,\n MuteRoomTrackRequest,\n MuteRoomTrackResponse,\n ParticipantInfo,\n ParticipantPermission,\n Room,\n RoomParticipantIdentity,\n SendDataRequest,\n UpdateParticipantRequest,\n UpdateRoomMetadataRequest,\n UpdateSubscriptionsRequest,\n} from '@livekit/protocol';\nimport type { ClientOptions } from './ClientOptions.js';\nimport { ServiceBase } from './ServiceBase.js';\nimport type { Rpc } from './TwirpRPC.js';\nimport { TwirpRpc, livekitPackage } from './TwirpRPC.js';\nimport { getRandomBytes } from './crypto/uuid.js';\n\n/**\n * Options for when creating a room\n */\nexport interface CreateOptions {\n /**\n * name of the room. required\n */\n name: string;\n\n /**\n * number of seconds to keep the room open before any participant joins\n */\n emptyTimeout?: number;\n\n /**\n * number of seconds to keep the room open after the last participant leaves\n * this option is helpful to give a grace period for participants to re-join\n */\n departureTimeout?: number;\n\n /**\n * limit to the number of participants in a room at a time\n */\n maxParticipants?: number;\n\n /**\n * initial room metadata\n */\n metadata?: string;\n\n /**\n * add egress options\n */\n egress?: RoomEgress;\n\n /**\n * minimum playout delay in milliseconds\n */\n minPlayoutDelay?: number;\n\n /**\n * maximum playout delay in milliseconds\n */\n maxPlayoutDelay?: number;\n\n /**\n * improves A/V sync when min_playout_delay set to a value larger than 200ms.\n * It will disables transceiver re-use -- this option is not recommended\n * for rooms with frequent subscription changes\n */\n syncStreams?: boolean;\n\n /**\n * agents that should be dispatched to this room\n */\n agents?: RoomAgentDispatch[];\n\n /**\n * override the node room is allocated to, for debugging\n * does not work with Cloud\n */\n nodeId?: string;\n}\n\nexport type SendDataOptions = {\n /** If set, only deliver to listed participant identities */\n destinationIdentities?: string[];\n destinationSids?: string[];\n topic?: string;\n};\n\nexport type UpdateParticipantOptions = {\n /** only attributes you'd want to update should be set, set value to empty string to remove it */\n attributes?: { [key: string]: string };\n metadata?: string;\n /** permissions are updated atomically - all desired permissions would need to be set */\n permission?: Partial<ParticipantPermission>;\n name?: string;\n};\n\nconst svc = 'RoomService';\n\n/**\n * Client to access Room APIs\n */\nexport class RoomServiceClient extends ServiceBase {\n private readonly rpc: Rpc;\n\n /**\n *\n * @param host - hostname including protocol. i.e. 'https://<project>.livekit.cloud'\n * @param apiKey - API Key, can be set in env var LIVEKIT_API_KEY\n * @param secret - API Secret, can be set in env var LIVEKIT_API_SECRET\n * @param options - client options\n */\n constructor(host: string, apiKey?: string, secret?: string, options?: ClientOptions) {\n super(apiKey, secret);\n const rpcOptions = options?.requestTimeout\n ? { requestTimeout: options.requestTimeout }\n : undefined;\n this.rpc = new TwirpRpc(host, livekitPackage, rpcOptions);\n }\n\n /**\n * Creates a new room. Explicit room creation is not required, since rooms will\n * be automatically created when the first participant joins. This method can be\n * used to customize room settings.\n * @param options -\n */\n async createRoom(options: CreateOptions): Promise<Room> {\n const data = await this.rpc.request(\n svc,\n 'CreateRoom',\n new CreateRoomRequest(options).toJson(),\n await this.authHeader({ roomCreate: true }),\n );\n return Room.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * List active rooms\n * @param names - when undefined or empty, list all rooms.\n * otherwise returns rooms with matching names\n * @returns\n */\n async listRooms(names?: string[]): Promise<Room[]> {\n const data = await this.rpc.request(\n svc,\n 'ListRooms',\n new ListRoomsRequest({ names: names ?? [] }).toJson(),\n await this.authHeader({ roomList: true }),\n );\n const res = ListRoomsResponse.fromJson(data, { ignoreUnknownFields: true });\n return res.rooms ?? [];\n }\n\n async deleteRoom(room: string): Promise<void> {\n await this.rpc.request(\n svc,\n 'DeleteRoom',\n new DeleteRoomRequest({ room }).toJson(),\n await this.authHeader({ roomCreate: true }),\n );\n }\n\n /**\n * Update metadata of a room\n * @param room - name of the room\n * @param metadata - the new metadata for the room\n */\n async updateRoomMetadata(room: string, metadata: string) {\n const data = await this.rpc.request(\n svc,\n 'UpdateRoomMetadata',\n new UpdateRoomMetadataRequest({ room, metadata }).toJson(),\n await this.authHeader({ roomAdmin: true, room }),\n );\n return Room.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * List participants in a room\n * @param room - name of the room\n */\n async listParticipants(room: string): Promise<ParticipantInfo[]> {\n const data = await this.rpc.request(\n svc,\n 'ListParticipants',\n new ListParticipantsRequest({ room }).toJson(),\n await this.authHeader({ roomAdmin: true, room }),\n );\n const res = ListParticipantsResponse.fromJson(data, { ignoreUnknownFields: true });\n return res.participants ?? [];\n }\n\n /**\n * Get information on a specific participant, including the tracks that participant\n * has published\n * @param room - name of the room\n * @param identity - identity of the participant to return\n */\n async getParticipant(room: string, identity: string): Promise<ParticipantInfo> {\n const data = await this.rpc.request(\n svc,\n 'GetParticipant',\n new RoomParticipantIdentity({ room, identity }).toJson(),\n await this.authHeader({ roomAdmin: true, room }),\n );\n\n return ParticipantInfo.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * Removes a participant in the room. This will disconnect the participant\n * and will emit a Disconnected event for that participant.\n * Even after being removed, the participant can still re-join the room.\n * @param room -\n * @param identity -\n */\n async removeParticipant(room: string, identity: string): Promise<void> {\n await this.rpc.request(\n svc,\n 'RemoveParticipant',\n new RoomParticipantIdentity({ room, identity }).toJson(),\n await this.authHeader({ roomAdmin: true, room }),\n );\n }\n\n /**\n * Forwards a participant's track to another room. This will create a\n * participant to join the destination room that has same information\n * with the source participant except the kind to be `Forwarded`. All\n * changes to the source participant will be reflected to the forwarded\n * participant. When the source participant disconnects or the\n * `RemoveParticipant` method is called in the destination room, the\n * forwarding will be stopped.\n * @param room -\n * @param identity -\n * @param destinationRoom - the room to forward the participant to\n */\n async forwardParticipant(room: string, identity: string, destinationRoom: string): Promise<void> {\n await this.rpc.request(\n svc,\n 'ForwardParticipant',\n new ForwardParticipantRequest({ room, identity, destinationRoom }).toJson(),\n await this.authHeader({ roomAdmin: true, room, destinationRoom }),\n );\n }\n\n /**\n * Move a connected participant to a different room. Requires `roomAdmin` and `destinationRoom`.\n * The participant will be removed from the current room and added to the destination room.\n * From the other observers' perspective, the participant would've disconnected from the previous room and joined the new one.\n * @param room -\n * @param identity -\n * @param destinationRoom - the room to move the participant to\n */\n async moveParticipant(room: string, identity: string, destinationRoom: string): Promise<void> {\n await this.rpc.request(\n svc,\n 'MoveParticipant',\n new MoveParticipantRequest({ room, identity, destinationRoom }).toJson(),\n await this.authHeader({ roomAdmin: true, room, destinationRoom }),\n );\n }\n\n /**\n * Mutes a track that the participant has published.\n * @param room -\n * @param identity -\n * @param trackSid - sid of the track to be muted\n * @param muted - true to mute, false to unmute\n */\n async mutePublishedTrack(\n room: string,\n identity: string,\n trackSid: string,\n muted: boolean,\n ): Promise<TrackInfo> {\n const req = new MuteRoomTrackRequest({\n room,\n identity,\n trackSid,\n muted,\n }).toJson();\n const data = await this.rpc.request(\n svc,\n 'MutePublishedTrack',\n req,\n await this.authHeader({ roomAdmin: true, room }),\n );\n const res = MuteRoomTrackResponse.fromJson(data, { ignoreUnknownFields: true });\n return res.track!;\n }\n\n /**\n * Updates a participant's state or permissions\n * @param room - target room\n * @param identity - participant identity\n * @param options - participant fields to update\n */\n async updateParticipant(\n room: string,\n identity: string,\n options: UpdateParticipantOptions,\n ): Promise<ParticipantInfo>;\n /**\n * Updates a participant's state or permissions\n * @param room - target room\n * @param identity - participant identity\n * @param options - participant fields to update\n */\n async updateParticipant(\n room: string,\n identity: string,\n metadata?: string,\n permission?: Partial<ParticipantPermission>,\n name?: string,\n ): Promise<ParticipantInfo>;\n async updateParticipant(\n room: string,\n identity: string,\n metadataOrOptions?: string | UpdateParticipantOptions,\n maybePermission?: Partial<ParticipantPermission>,\n maybeName?: string,\n ): Promise<ParticipantInfo> {\n const hasOptions = typeof metadataOrOptions === 'object';\n const metadata = hasOptions ? metadataOrOptions?.metadata : metadataOrOptions;\n const permission = hasOptions ? metadataOrOptions.permission : maybePermission;\n const name = hasOptions ? metadataOrOptions.name : maybeName;\n const attributes: Record<string, string> | undefined = hasOptions\n ? metadataOrOptions.attributes\n : {};\n\n const req = new UpdateParticipantRequest({\n room,\n identity,\n attributes,\n metadata,\n name,\n });\n if (permission) {\n req.permission = new ParticipantPermission(permission);\n }\n const data = await this.rpc.request(\n svc,\n 'UpdateParticipant',\n req.toJson(),\n await this.authHeader({ roomAdmin: true, room }),\n );\n return ParticipantInfo.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * Updates a participant's subscription to tracks\n * @param room -\n * @param identity -\n * @param trackSids -\n * @param subscribe - true to subscribe, false to unsubscribe\n */\n async updateSubscriptions(\n room: string,\n identity: string,\n trackSids: string[],\n subscribe: boolean,\n ): Promise<void> {\n const req = new UpdateSubscriptionsRequest({\n room,\n identity,\n trackSids,\n subscribe,\n participantTracks: [],\n }).toJson();\n await this.rpc.request(\n svc,\n 'UpdateSubscriptions',\n req,\n await this.authHeader({ roomAdmin: true, room }),\n );\n }\n\n /**\n * Sends data message to participants in the room\n * @param room -\n * @param data - opaque payload to send\n * @param kind - delivery reliability\n * @param options - optionally specify a topic and destinationSids (when destinationSids is empty, message is sent to everyone)\n */\n async sendData(\n room: string,\n data: Uint8Array,\n kind: DataPacket_Kind,\n options: SendDataOptions,\n ): Promise<void>;\n /**\n * Sends data message to participants in the room\n * @deprecated use sendData(room, data, kind, options) instead\n * @param room -\n * @param data - opaque payload to send\n * @param kind - delivery reliability\n * @param destinationSids - optional. when empty, message is sent to everyone\n */\n async sendData(\n room: string,\n data: Uint8Array,\n kind: DataPacket_Kind,\n destinationSids?: string[],\n ): Promise<void>;\n async sendData(\n room: string,\n data: Uint8Array,\n kind: DataPacket_Kind,\n options: SendDataOptions | string[] = {},\n ): Promise<void> {\n const destinationSids = Array.isArray(options) ? options : options.destinationSids;\n const topic = Array.isArray(options) ? undefined : options.topic;\n const req = new SendDataRequest({\n room,\n data,\n kind,\n destinationSids: destinationSids ?? [],\n topic,\n });\n if (!Array.isArray(options) && options.destinationIdentities) {\n req.destinationIdentities = options.destinationIdentities;\n }\n req.nonce = await getRandomBytes(16);\n await this.rpc.request(\n svc,\n 'SendData',\n req.toJson(),\n await this.authHeader({ roomAdmin: true, room }),\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,sBAmBO;AAEP,yBAA4B;AAE5B,sBAAyC;AACzC,kBAA+B;AAkF/B,MAAM,MAAM;AAKL,MAAM,0BAA0B,+BAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUjD,YAAY,MAAc,QAAiB,QAAiB,SAAyB;AACnF,UAAM,QAAQ,MAAM;AACpB,UAAM,cAAa,mCAAS,kBACxB,EAAE,gBAAgB,QAAQ,eAAe,IACzC;AACJ,SAAK,MAAM,IAAI,yBAAS,MAAM,gCAAgB,UAAU;AAAA,EAC1D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,WAAW,SAAuC;AACtD,UAAM,OAAO,MAAM,KAAK,IAAI;AAAA,MAC1B;AAAA,MACA;AAAA,MACA,IAAI,kCAAkB,OAAO,EAAE,OAAO;AAAA,MACtC,MAAM,KAAK,WAAW,EAAE,YAAY,KAAK,CAAC;AAAA,IAC5C;AACA,WAAO,qBAAK,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ASA,MAAM,oBACJ,MACA,UACA,WACA,WACe;AACf,UAAM,MAAM,IAAI,2CAA2B;AAAA,MACzC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,mBAAmB,CAAC;AAAA,IACtB,CAAC,EAAE,OAAO;AACV,UAAM,KAAK,IAAI;AAAA,MACb;AAAA,MACA;AAAA,MACA;AAAA,MACA,MAAM,KAAK,WAAW,EAAE,WAAW,MAAM,KAAK,CAAC;AAAA,IACjD;AAAA,EACF;AAAA,EA6BA,MAAM,SACJ,MACA,MACA,MACA,UAAsC,CAAC,GACxB;AACf,UAAM,kBAAkB,MAAM,QAAQ,OAAO,IAAI,UAAU,QAAQ;AACnE,UAAM,QAAQ,MAAM,QAAQ,OAAO,IAAI,SAAY,QAAQ;AAC3D,UAAM,MAAM,IAAI,gCAAgB;AAAA,MAC9B;AAAA,MACA;AAAA,MACA;AAAA,MACA,iBAAiB,mBAAmB,CAAC;AAAA,MACrC;AAAA,IACF,CAAC;AACD,QAAI,CAAC,MAAM,QAAQ,OAAO,KAAK,QAAQ,uBAAuB;AAC5D,UAAI,wBAAwB,QAAQ;AAAA,IACtC;AACA,QAAI,QAAQ,UAAM,4BAAe,EAAE;AACnC,UAAM,KAAK,IAAI;AAAA,MACb;AAAA,MACA;AAAA,MACA,IAAI,OAAO;AAAA,MACX,MAAM,KAAK,WAAW,EAAE,WAAW,MAAM,KAAK,CAAC;AAAA,IACjD;AAAA,EACF;AACF;","names":[]}
@@ -1,4 +1,5 @@
1
1
  import { RoomEgress, RoomAgentDispatch, ParticipantPermission, Room, ParticipantInfo, TrackInfo, DataPacket_Kind } from '@livekit/protocol';
2
+ import { ClientOptions } from './ClientOptions.cjs';
2
3
  import { ServiceBase } from './ServiceBase.cjs';
3
4
  import './grants.cjs';
4
5
  import 'jose';
@@ -82,8 +83,9 @@ declare class RoomServiceClient extends ServiceBase {
82
83
  * @param host - hostname including protocol. i.e. 'https://<project>.livekit.cloud'
83
84
  * @param apiKey - API Key, can be set in env var LIVEKIT_API_KEY
84
85
  * @param secret - API Secret, can be set in env var LIVEKIT_API_SECRET
86
+ * @param options - client options
85
87
  */
86
- constructor(host: string, apiKey?: string, secret?: string);
88
+ constructor(host: string, apiKey?: string, secret?: string, options?: ClientOptions);
87
89
  /**
88
90
  * Creates a new room. Explicit room creation is not required, since rooms will
89
91
  * be automatically created when the first participant joins. This method can be
@@ -1,5 +1,6 @@
1
1
  import type { DataPacket_Kind, RoomAgentDispatch, RoomEgress, TrackInfo } from '@livekit/protocol';
2
2
  import { ParticipantInfo, ParticipantPermission, Room } from '@livekit/protocol';
3
+ import type { ClientOptions } from './ClientOptions.js';
3
4
  import { ServiceBase } from './ServiceBase.js';
4
5
  /**
5
6
  * Options for when creating a room
@@ -80,8 +81,9 @@ export declare class RoomServiceClient extends ServiceBase {
80
81
  * @param host - hostname including protocol. i.e. 'https://<project>.livekit.cloud'
81
82
  * @param apiKey - API Key, can be set in env var LIVEKIT_API_KEY
82
83
  * @param secret - API Secret, can be set in env var LIVEKIT_API_SECRET
84
+ * @param options - client options
83
85
  */
84
- constructor(host: string, apiKey?: string, secret?: string);
86
+ constructor(host: string, apiKey?: string, secret?: string, options?: ClientOptions);
85
87
  /**
86
88
  * Creates a new room. Explicit room creation is not required, since rooms will
87
89
  * be automatically created when the first participant joins. This method can be
@@ -1 +1 @@
1
- {"version":3,"file":"RoomServiceClient.d.ts","sourceRoot":"","sources":["../src/RoomServiceClient.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnG,OAAO,EAWL,eAAe,EACf,qBAAqB,EACrB,IAAI,EAML,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAK/C;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH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,OAAO,CAAC,eAAe,CAAC;IAmC3B;;;;;;OAMG;IACG,mBAAmB,CACvB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EAAE,EACnB,SAAS,EAAE,OAAO,GACjB,OAAO,CAAC,IAAI,CAAC;IAgBhB;;;;;;OAMG;IACG,QAAQ,CACZ,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,UAAU,EAChB,IAAI,EAAE,eAAe,EACrB,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,IAAI,CAAC;IAChB;;;;;;;OAOG;IACG,QAAQ,CACZ,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,UAAU,EAChB,IAAI,EAAE,eAAe,EACrB,eAAe,CAAC,EAAE,MAAM,EAAE,GACzB,OAAO,CAAC,IAAI,CAAC;CA2BjB"}
@@ -28,10 +28,12 @@ class RoomServiceClient extends ServiceBase {
28
28
  * @param host - hostname including protocol. i.e. 'https://<project>.livekit.cloud'
29
29
  * @param apiKey - API Key, can be set in env var LIVEKIT_API_KEY
30
30
  * @param secret - API Secret, can be set in env var LIVEKIT_API_SECRET
31
+ * @param options - client options
31
32
  */
32
- constructor(host, apiKey, secret) {
33
+ constructor(host, apiKey, secret, options) {
33
34
  super(apiKey, secret);
34
- this.rpc = new TwirpRpc(host, livekitPackage);
35
+ const rpcOptions = (options == null ? void 0 : options.requestTimeout) ? { requestTimeout: options.requestTimeout } : void 0;
36
+ this.rpc = new TwirpRpc(host, livekitPackage, rpcOptions);
35
37
  }
36
38
  /**
37
39
  * Creates a new room. Explicit room creation is not required, since rooms will
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/RoomServiceClient.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type { DataPacket_Kind, RoomAgentDispatch, RoomEgress, TrackInfo } from '@livekit/protocol';\nimport {\n CreateRoomRequest,\n DeleteRoomRequest,\n ForwardParticipantRequest,\n ListParticipantsRequest,\n ListParticipantsResponse,\n ListRoomsRequest,\n ListRoomsResponse,\n MoveParticipantRequest,\n MuteRoomTrackRequest,\n MuteRoomTrackResponse,\n ParticipantInfo,\n ParticipantPermission,\n Room,\n RoomParticipantIdentity,\n SendDataRequest,\n UpdateParticipantRequest,\n UpdateRoomMetadataRequest,\n UpdateSubscriptionsRequest,\n} from '@livekit/protocol';\nimport { ServiceBase } from './ServiceBase.js';\nimport type { Rpc } from './TwirpRPC.js';\nimport { TwirpRpc, livekitPackage } from './TwirpRPC.js';\nimport { getRandomBytes } from './crypto/uuid.js';\n\n/**\n * Options for when creating a room\n */\nexport interface CreateOptions {\n /**\n * name of the room. required\n */\n name: string;\n\n /**\n * number of seconds to keep the room open before any participant joins\n */\n emptyTimeout?: number;\n\n /**\n * number of seconds to keep the room open after the last participant leaves\n * this option is helpful to give a grace period for participants to re-join\n */\n departureTimeout?: number;\n\n /**\n * limit to the number of participants in a room at a time\n */\n maxParticipants?: number;\n\n /**\n * initial room metadata\n */\n metadata?: string;\n\n /**\n * add egress options\n */\n egress?: RoomEgress;\n\n /**\n * minimum playout delay in milliseconds\n */\n minPlayoutDelay?: number;\n\n /**\n * maximum playout delay in milliseconds\n */\n maxPlayoutDelay?: number;\n\n /**\n * improves A/V sync when min_playout_delay set to a value larger than 200ms.\n * It will disables transceiver re-use -- this option is not recommended\n * for rooms with frequent subscription changes\n */\n syncStreams?: boolean;\n\n /**\n * agents that should be dispatched to this room\n */\n agents?: RoomAgentDispatch[];\n\n /**\n * override the node room is allocated to, for debugging\n * does not work with Cloud\n */\n nodeId?: string;\n}\n\nexport type SendDataOptions = {\n /** If set, only deliver to listed participant identities */\n destinationIdentities?: string[];\n destinationSids?: string[];\n topic?: string;\n};\n\nexport type UpdateParticipantOptions = {\n /** only attributes you'd want to update should be set, set value to empty string to remove it */\n attributes?: { [key: string]: string };\n metadata?: string;\n /** permissions are updated atomically - all desired permissions would need to be set */\n permission?: Partial<ParticipantPermission>;\n name?: string;\n};\n\nconst svc = 'RoomService';\n\n/**\n * Client to access Room APIs\n */\nexport class RoomServiceClient extends ServiceBase {\n private readonly rpc: Rpc;\n\n /**\n *\n * @param host - hostname including protocol. i.e. 'https://<project>.livekit.cloud'\n * @param apiKey - API Key, can be set in env var LIVEKIT_API_KEY\n * @param secret - API Secret, can be set in env var LIVEKIT_API_SECRET\n */\n constructor(host: string, apiKey?: string, secret?: string) {\n super(apiKey, secret);\n this.rpc = new TwirpRpc(host, livekitPackage);\n }\n\n /**\n * Creates a new room. Explicit room creation is not required, since rooms will\n * be automatically created when the first participant joins. This method can be\n * used to customize room settings.\n * @param options -\n */\n async createRoom(options: CreateOptions): Promise<Room> {\n const data = await this.rpc.request(\n svc,\n 'CreateRoom',\n new CreateRoomRequest(options).toJson(),\n await this.authHeader({ roomCreate: true }),\n );\n return Room.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * List active rooms\n * @param names - when undefined or empty, list all rooms.\n * otherwise returns rooms with matching names\n * @returns\n */\n async listRooms(names?: string[]): Promise<Room[]> {\n const data = await this.rpc.request(\n svc,\n 'ListRooms',\n new ListRoomsRequest({ names: names ?? [] }).toJson(),\n await this.authHeader({ roomList: true }),\n );\n const res = ListRoomsResponse.fromJson(data, { ignoreUnknownFields: true });\n return res.rooms ?? [];\n }\n\n async deleteRoom(room: string): Promise<void> {\n await this.rpc.request(\n svc,\n 'DeleteRoom',\n new DeleteRoomRequest({ room }).toJson(),\n await this.authHeader({ roomCreate: true }),\n );\n }\n\n /**\n * Update metadata of a room\n * @param room - name of the room\n * @param metadata - the new metadata for the room\n */\n async updateRoomMetadata(room: string, metadata: string) {\n const data = await this.rpc.request(\n svc,\n 'UpdateRoomMetadata',\n new UpdateRoomMetadataRequest({ room, metadata }).toJson(),\n await this.authHeader({ roomAdmin: true, room }),\n );\n return Room.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * List participants in a room\n * @param room - name of the room\n */\n async listParticipants(room: string): Promise<ParticipantInfo[]> {\n const data = await this.rpc.request(\n svc,\n 'ListParticipants',\n new ListParticipantsRequest({ room }).toJson(),\n await this.authHeader({ roomAdmin: true, room }),\n );\n const res = ListParticipantsResponse.fromJson(data, { ignoreUnknownFields: true });\n return res.participants ?? [];\n }\n\n /**\n * Get information on a specific participant, including the tracks that participant\n * has published\n * @param room - name of the room\n * @param identity - identity of the participant to return\n */\n async getParticipant(room: string, identity: string): Promise<ParticipantInfo> {\n const data = await this.rpc.request(\n svc,\n 'GetParticipant',\n new RoomParticipantIdentity({ room, identity }).toJson(),\n await this.authHeader({ roomAdmin: true, room }),\n );\n\n return ParticipantInfo.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * Removes a participant in the room. This will disconnect the participant\n * and will emit a Disconnected event for that participant.\n * Even after being removed, the participant can still re-join the room.\n * @param room -\n * @param identity -\n */\n async removeParticipant(room: string, identity: string): Promise<void> {\n await this.rpc.request(\n svc,\n 'RemoveParticipant',\n new RoomParticipantIdentity({ room, identity }).toJson(),\n await this.authHeader({ roomAdmin: true, room }),\n );\n }\n\n /**\n * Forwards a participant's track to another room. This will create a\n * participant to join the destination room that has same information\n * with the source participant except the kind to be `Forwarded`. All\n * changes to the source participant will be reflected to the forwarded\n * participant. When the source participant disconnects or the\n * `RemoveParticipant` method is called in the destination room, the\n * forwarding will be stopped.\n * @param room -\n * @param identity -\n * @param destinationRoom - the room to forward the participant to\n */\n async forwardParticipant(room: string, identity: string, destinationRoom: string): Promise<void> {\n await this.rpc.request(\n svc,\n 'ForwardParticipant',\n new ForwardParticipantRequest({ room, identity, destinationRoom }).toJson(),\n await this.authHeader({ roomAdmin: true, room, destinationRoom }),\n );\n }\n\n /**\n * Move a connected participant to a different room. Requires `roomAdmin` and `destinationRoom`.\n * The participant will be removed from the current room and added to the destination room.\n * From the other observers' perspective, the participant would've disconnected from the previous room and joined the new one.\n * @param room -\n * @param identity -\n * @param destinationRoom - the room to move the participant to\n */\n async moveParticipant(room: string, identity: string, destinationRoom: string): Promise<void> {\n await this.rpc.request(\n svc,\n 'MoveParticipant',\n new MoveParticipantRequest({ room, identity, destinationRoom }).toJson(),\n await this.authHeader({ roomAdmin: true, room, destinationRoom }),\n );\n }\n\n /**\n * Mutes a track that the participant has published.\n * @param room -\n * @param identity -\n * @param trackSid - sid of the track to be muted\n * @param muted - true to mute, false to unmute\n */\n async mutePublishedTrack(\n room: string,\n identity: string,\n trackSid: string,\n muted: boolean,\n ): Promise<TrackInfo> {\n const req = new MuteRoomTrackRequest({\n room,\n identity,\n trackSid,\n muted,\n }).toJson();\n const data = await this.rpc.request(\n svc,\n 'MutePublishedTrack',\n req,\n await this.authHeader({ roomAdmin: true, room }),\n );\n const res = MuteRoomTrackResponse.fromJson(data, { ignoreUnknownFields: true });\n return res.track!;\n }\n\n /**\n * Updates a participant's state or permissions\n * @param room - target room\n * @param identity - participant identity\n * @param options - participant fields to update\n */\n async updateParticipant(\n room: string,\n identity: string,\n options: UpdateParticipantOptions,\n ): Promise<ParticipantInfo>;\n /**\n * Updates a participant's state or permissions\n * @param room - target room\n * @param identity - participant identity\n * @param options - participant fields to update\n */\n async updateParticipant(\n room: string,\n identity: string,\n metadata?: string,\n permission?: Partial<ParticipantPermission>,\n name?: string,\n ): Promise<ParticipantInfo>;\n async updateParticipant(\n room: string,\n identity: string,\n metadataOrOptions?: string | UpdateParticipantOptions,\n maybePermission?: Partial<ParticipantPermission>,\n maybeName?: string,\n ): Promise<ParticipantInfo> {\n const hasOptions = typeof metadataOrOptions === 'object';\n const metadata = hasOptions ? metadataOrOptions?.metadata : metadataOrOptions;\n const permission = hasOptions ? metadataOrOptions.permission : maybePermission;\n const name = hasOptions ? metadataOrOptions.name : maybeName;\n const attributes: Record<string, string> | undefined = hasOptions\n ? metadataOrOptions.attributes\n : {};\n\n const req = new UpdateParticipantRequest({\n room,\n identity,\n attributes,\n metadata,\n name,\n });\n if (permission) {\n req.permission = new ParticipantPermission(permission);\n }\n const data = await this.rpc.request(\n svc,\n 'UpdateParticipant',\n req.toJson(),\n await this.authHeader({ roomAdmin: true, room }),\n );\n return ParticipantInfo.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * Updates a participant's subscription to tracks\n * @param room -\n * @param identity -\n * @param trackSids -\n * @param subscribe - true to subscribe, false to unsubscribe\n */\n async updateSubscriptions(\n room: string,\n identity: string,\n trackSids: string[],\n subscribe: boolean,\n ): Promise<void> {\n const req = new UpdateSubscriptionsRequest({\n room,\n identity,\n trackSids,\n subscribe,\n participantTracks: [],\n }).toJson();\n await this.rpc.request(\n svc,\n 'UpdateSubscriptions',\n req,\n await this.authHeader({ roomAdmin: true, room }),\n );\n }\n\n /**\n * Sends data message to participants in the room\n * @param room -\n * @param data - opaque payload to send\n * @param kind - delivery reliability\n * @param options - optionally specify a topic and destinationSids (when destinationSids is empty, message is sent to everyone)\n */\n async sendData(\n room: string,\n data: Uint8Array,\n kind: DataPacket_Kind,\n options: SendDataOptions,\n ): Promise<void>;\n /**\n * Sends data message to participants in the room\n * @deprecated use sendData(room, data, kind, options) instead\n * @param room -\n * @param data - opaque payload to send\n * @param kind - delivery reliability\n * @param destinationSids - optional. when empty, message is sent to everyone\n */\n async sendData(\n room: string,\n data: Uint8Array,\n kind: DataPacket_Kind,\n destinationSids?: string[],\n ): Promise<void>;\n async sendData(\n room: string,\n data: Uint8Array,\n kind: DataPacket_Kind,\n options: SendDataOptions | string[] = {},\n ): Promise<void> {\n const destinationSids = Array.isArray(options) ? options : options.destinationSids;\n const topic = Array.isArray(options) ? undefined : options.topic;\n const req = new SendDataRequest({\n room,\n data,\n kind,\n destinationSids: destinationSids ?? [],\n topic,\n });\n if (!Array.isArray(options) && options.destinationIdentities) {\n req.destinationIdentities = options.destinationIdentities;\n }\n req.nonce = await getRandomBytes(16);\n await this.rpc.request(\n svc,\n 'SendData',\n req.toJson(),\n await this.authHeader({ roomAdmin: true, room }),\n );\n }\n}\n"],"mappings":"AAIA;AAAA,EACE;AAAA,EACA;AAAA,EACA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ACA;AAAA,MACA;AAAA,MACA,iBAAiB,mBAAmB,CAAC;AAAA,MACrC;AAAA,IACF,CAAC;AACD,QAAI,CAAC,MAAM,QAAQ,OAAO,KAAK,QAAQ,uBAAuB;AAC5D,UAAI,wBAAwB,QAAQ;AAAA,IACtC;AACA,QAAI,QAAQ,MAAM,eAAe,EAAE;AACnC,UAAM,KAAK,IAAI;AAAA,MACb;AAAA,MACA;AAAA,MACA,IAAI,OAAO;AAAA,MACX,MAAM,KAAK,WAAW,EAAE,WAAW,MAAM,KAAK,CAAC;AAAA,IACjD;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/RoomServiceClient.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type { DataPacket_Kind, RoomAgentDispatch, RoomEgress, TrackInfo } from '@livekit/protocol';\nimport {\n CreateRoomRequest,\n DeleteRoomRequest,\n ForwardParticipantRequest,\n ListParticipantsRequest,\n ListParticipantsResponse,\n ListRoomsRequest,\n ListRoomsResponse,\n MoveParticipantRequest,\n MuteRoomTrackRequest,\n MuteRoomTrackResponse,\n ParticipantInfo,\n ParticipantPermission,\n Room,\n RoomParticipantIdentity,\n SendDataRequest,\n UpdateParticipantRequest,\n UpdateRoomMetadataRequest,\n UpdateSubscriptionsRequest,\n} from '@livekit/protocol';\nimport type { ClientOptions } from './ClientOptions.js';\nimport { ServiceBase } from './ServiceBase.js';\nimport type { Rpc } from './TwirpRPC.js';\nimport { TwirpRpc, livekitPackage } from './TwirpRPC.js';\nimport { getRandomBytes } from './crypto/uuid.js';\n\n/**\n * Options for when creating a room\n */\nexport interface CreateOptions {\n /**\n * name of the room. required\n */\n name: string;\n\n /**\n * number of seconds to keep the room open before any participant joins\n */\n emptyTimeout?: number;\n\n /**\n * number of seconds to keep the room open after the last participant leaves\n * this option is helpful to give a grace period for participants to re-join\n */\n departureTimeout?: number;\n\n /**\n * limit to the number of participants in a room at a time\n */\n maxParticipants?: number;\n\n /**\n * initial room metadata\n */\n metadata?: string;\n\n /**\n * add egress options\n */\n egress?: RoomEgress;\n\n /**\n * minimum playout delay in milliseconds\n */\n minPlayoutDelay?: number;\n\n /**\n * maximum playout delay in milliseconds\n */\n maxPlayoutDelay?: number;\n\n /**\n * improves A/V sync when min_playout_delay set to a value larger than 200ms.\n * It will disables transceiver re-use -- this option is not recommended\n * for rooms with frequent subscription changes\n */\n syncStreams?: boolean;\n\n /**\n * agents that should be dispatched to this room\n */\n agents?: RoomAgentDispatch[];\n\n /**\n * override the node room is allocated to, for debugging\n * does not work with Cloud\n */\n nodeId?: string;\n}\n\nexport type SendDataOptions = {\n /** If set, only deliver to listed participant identities */\n destinationIdentities?: string[];\n destinationSids?: string[];\n topic?: string;\n};\n\nexport type UpdateParticipantOptions = {\n /** only attributes you'd want to update should be set, set value to empty string to remove it */\n attributes?: { [key: string]: string };\n metadata?: string;\n /** permissions are updated atomically - all desired permissions would need to be set */\n permission?: Partial<ParticipantPermission>;\n name?: string;\n};\n\nconst svc = 'RoomService';\n\n/**\n * Client to access Room APIs\n */\nexport class RoomServiceClient extends ServiceBase {\n private readonly rpc: Rpc;\n\n /**\n *\n * @param host - hostname including protocol. i.e. 'https://<project>.livekit.cloud'\n * @param apiKey - API Key, can be set in env var LIVEKIT_API_KEY\n * @param secret - API Secret, can be set in env var LIVEKIT_API_SECRET\n * @param options - client options\n */\n constructor(host: string, apiKey?: string, secret?: string, options?: ClientOptions) {\n super(apiKey, secret);\n const rpcOptions = options?.requestTimeout\n ? { requestTimeout: options.requestTimeout }\n : undefined;\n this.rpc = new TwirpRpc(host, livekitPackage, rpcOptions);\n }\n\n /**\n * Creates a new room. Explicit room creation is not required, since rooms will\n * be automatically created when the first participant joins. This method can be\n * used to customize room settings.\n * @param options -\n */\n async createRoom(options: CreateOptions): Promise<Room> {\n const data = await this.rpc.request(\n svc,\n 'CreateRoom',\n new CreateRoomRequest(options).toJson(),\n await this.authHeader({ roomCreate: true }),\n );\n return Room.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * List active rooms\n * @param names - when undefined or empty, list all rooms.\n * otherwise returns rooms with matching names\n * @returns\n */\n async listRooms(names?: string[]): Promise<Room[]> {\n const data = await this.rpc.request(\n svc,\n 'ListRooms',\n new ListRoomsRequest({ names: names ?? [] }).toJson(),\n await this.authHeader({ roomList: true }),\n );\n const res = ListRoomsResponse.fromJson(data, { ignoreUnknownFields: true });\n return res.rooms ?? [];\n }\n\n async deleteRoom(room: string): Promise<void> {\n await this.rpc.request(\n svc,\n 'DeleteRoom',\n new DeleteRoomRequest({ room }).toJson(),\n await this.authHeader({ roomCreate: true }),\n );\n }\n\n /**\n * Update metadata of a room\n * @param room - name of the room\n * @param metadata - the new metadata for the room\n */\n async updateRoomMetadata(room: string, metadata: string) {\n const data = await this.rpc.request(\n svc,\n 'UpdateRoomMetadata',\n new UpdateRoomMetadataRequest({ room, metadata }).toJson(),\n await this.authHeader({ roomAdmin: true, room }),\n );\n return Room.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * List participants in a room\n * @param room - name of the room\n */\n async listParticipants(room: string): Promise<ParticipantInfo[]> {\n const data = await this.rpc.request(\n svc,\n 'ListParticipants',\n new ListParticipantsRequest({ room }).toJson(),\n await this.authHeader({ roomAdmin: true, room }),\n );\n const res = ListParticipantsResponse.fromJson(data, { ignoreUnknownFields: true });\n return res.participants ?? [];\n }\n\n /**\n * Get information on a specific participant, including the tracks that participant\n * has published\n * @param room - name of the room\n * @param identity - identity of the participant to return\n */\n async getParticipant(room: string, identity: string): Promise<ParticipantInfo> {\n const data = await this.rpc.request(\n svc,\n 'GetParticipant',\n new RoomParticipantIdentity({ room, identity }).toJson(),\n await this.authHeader({ roomAdmin: true, room }),\n );\n\n return ParticipantInfo.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * Removes a participant in the room. This will disconnect the participant\n * and will emit a Disconnected event for that participant.\n * Even after being removed, the participant can still re-join the room.\n * @param room -\n * @param identity -\n */\n async removeParticipant(room: string, identity: string): Promise<void> {\n await this.rpc.request(\n svc,\n 'RemoveParticipant',\n new RoomParticipantIdentity({ room, identity }).toJson(),\n await this.authHeader({ roomAdmin: true, room }),\n );\n }\n\n /**\n * Forwards a participant's track to another room. This will create a\n * participant to join the destination room that has same information\n * with the source participant except the kind to be `Forwarded`. All\n * changes to the source participant will be reflected to the forwarded\n * participant. When the source participant disconnects or the\n * `RemoveParticipant` method is called in the destination room, the\n * forwarding will be stopped.\n * @param room -\n * @param identity -\n * @param destinationRoom - the room to forward the participant to\n */\n async forwardParticipant(room: string, identity: string, destinationRoom: string): Promise<void> {\n await this.rpc.request(\n svc,\n 'ForwardParticipant',\n new ForwardParticipantRequest({ room, identity, destinationRoom }).toJson(),\n await this.authHeader({ roomAdmin: true, room, destinationRoom }),\n );\n }\n\n /**\n * Move a connected participant to a different room. Requires `roomAdmin` and `destinationRoom`.\n * The participant will be removed from the current room and added to the destination room.\n * From the other observers' perspective, the participant would've disconnected from the previous room and joined the new one.\n * @param room -\n * @param identity -\n * @param destinationRoom - the room to move the participant to\n */\n async moveParticipant(room: string, identity: string, destinationRoom: string): Promise<void> {\n await this.rpc.request(\n svc,\n 'MoveParticipant',\n new MoveParticipantRequest({ room, identity, destinationRoom }).toJson(),\n await this.authHeader({ roomAdmin: true, room, destinationRoom }),\n );\n }\n\n /**\n * Mutes a track that the participant has published.\n * @param room -\n * @param identity -\n * @param trackSid - sid of the track to be muted\n * @param muted - true to mute, false to unmute\n */\n async mutePublishedTrack(\n room: string,\n identity: string,\n trackSid: string,\n muted: boolean,\n ): Promise<TrackInfo> {\n const req = new MuteRoomTrackRequest({\n room,\n identity,\n trackSid,\n muted,\n }).toJson();\n const data = await this.rpc.request(\n svc,\n 'MutePublishedTrack',\n req,\n await this.authHeader({ roomAdmin: true, room }),\n );\n const res = MuteRoomTrackResponse.fromJson(data, { ignoreUnknownFields: true });\n return res.track!;\n }\n\n /**\n * Updates a participant's state or permissions\n * @param room - target room\n * @param identity - participant identity\n * @param options - participant fields to update\n */\n async updateParticipant(\n room: string,\n identity: string,\n options: UpdateParticipantOptions,\n ): Promise<ParticipantInfo>;\n /**\n * Updates a participant's state or permissions\n * @param room - target room\n * @param identity - participant identity\n * @param options - participant fields to update\n */\n async updateParticipant(\n room: string,\n identity: string,\n metadata?: string,\n permission?: Partial<ParticipantPermission>,\n name?: string,\n ): Promise<ParticipantInfo>;\n async updateParticipant(\n room: string,\n identity: string,\n metadataOrOptions?: string | UpdateParticipantOptions,\n maybePermission?: Partial<ParticipantPermission>,\n maybeName?: string,\n ): Promise<ParticipantInfo> {\n const hasOptions = typeof metadataOrOptions === 'object';\n const metadata = hasOptions ? metadataOrOptions?.metadata : metadataOrOptions;\n const permission = hasOptions ? metadataOrOptions.permission : maybePermission;\n const name = hasOptions ? metadataOrOptions.name : maybeName;\n const attributes: Record<string, string> | undefined = hasOptions\n ? metadataOrOptions.attributes\n : {};\n\n const req = new UpdateParticipantRequest({\n room,\n identity,\n attributes,\n metadata,\n name,\n });\n if (permission) {\n req.permission = new ParticipantPermission(permission);\n }\n const data = await this.rpc.request(\n svc,\n 'UpdateParticipant',\n req.toJson(),\n await this.authHeader({ roomAdmin: true, room }),\n );\n return ParticipantInfo.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * Updates a participant's subscription to tracks\n * @param room -\n * @param identity -\n * @param trackSids -\n * @param subscribe - true to subscribe, false to unsubscribe\n */\n async updateSubscriptions(\n room: string,\n identity: string,\n trackSids: string[],\n subscribe: boolean,\n ): Promise<void> {\n const req = new UpdateSubscriptionsRequest({\n room,\n identity,\n trackSids,\n subscribe,\n participantTracks: [],\n }).toJson();\n await this.rpc.request(\n svc,\n 'UpdateSubscriptions',\n req,\n await this.authHeader({ roomAdmin: true, room }),\n );\n }\n\n /**\n * Sends data message to participants in the room\n * @param room -\n * @param data - opaque payload to send\n * @param kind - delivery reliability\n * @param options - optionally specify a topic and destinationSids (when destinationSids is empty, message is sent to everyone)\n */\n async sendData(\n room: string,\n data: Uint8Array,\n kind: DataPacket_Kind,\n options: SendDataOptions,\n ): Promise<void>;\n /**\n * Sends data message to participants in the room\n * @deprecated use sendData(room, data, kind, options) instead\n * @param room -\n * @param data - opaque payload to send\n * @param kind - delivery reliability\n * @param destinationSids - optional. when empty, message is sent to everyone\n */\n async sendData(\n room: string,\n data: Uint8Array,\n kind: DataPacket_Kind,\n destinationSids?: string[],\n ): Promise<void>;\n async sendData(\n room: string,\n data: Uint8Array,\n kind: DataPacket_Kind,\n options: SendDataOptions | string[] = {},\n ): Promise<void> {\n const destinationSids = Array.isArray(options) ? options : options.destinationSids;\n const topic = Array.isArray(options) ? undefined : options.topic;\n const req = new SendDataRequest({\n room,\n data,\n kind,\n destinationSids: destinationSids ?? [],\n topic,\n });\n if (!Array.isArray(options) && options.destinationIdentities) {\n req.destinationIdentities = options.destinationIdentities;\n }\n req.nonce = await getRandomBytes(16);\n await this.rpc.request(\n svc,\n 'SendData',\n req.toJson(),\n await this.authHeader({ roomAdmin: true, room }),\n );\n }\n}\n"],"mappings":"AAIA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,mBAAmB;AAE5B,SAAS,UAAU,sBAAsB;AACzC,SAAS,sBAAsB;AAkF/B,MAAM,MAAM;AAKL,MAAM,0BAA0B,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUjD,YAAY,MAAc,QAAiB,QAAiB,SAAyB;AACnF,UAAM,QAAQ,MAAM;AACpB,UAAM,cAAa,mCAAS,kBACxB,EAAE,gBAAgB,QAAQ,eAAe,IACzC;AACJ,SAAK,MAAM,IAAI,SAAS,MAAM,gBAAgB,UAAU;A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