livekit-server-sdk 2.9.3 → 2.9.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AccessToken.d.cts +80 -0
- package/dist/AgentDispatchClient.d.cts +50 -0
- package/dist/EgressClient.cjs +1 -0
- package/dist/EgressClient.cjs.map +1 -1
- package/dist/EgressClient.d.cts +168 -0
- package/dist/EgressClient.d.ts.map +1 -1
- package/dist/EgressClient.js +1 -0
- package/dist/EgressClient.js.map +1 -1
- package/dist/IngressClient.d.cts +136 -0
- package/dist/RoomServiceClient.d.cts +173 -0
- package/dist/ServiceBase.d.cts +21 -0
- package/dist/SipClient.d.cts +142 -0
- package/dist/TwirpRPC.d.cts +18 -0
- package/dist/WebhookReceiver.d.cts +29 -0
- package/dist/digest.d.cts +3 -0
- package/dist/grants.d.cts +71 -0
- package/dist/index.d.cts +12 -0
- package/package.json +13 -5
- package/src/AccessToken.test.ts +6 -6
- package/src/EgressClient.ts +1 -0
- package/src/grants.test.ts +2 -2
- package/dist/AccessToken.test.cjs +0 -147
- package/dist/AccessToken.test.cjs.map +0 -1
- package/dist/AccessToken.test.js +0 -129
- package/dist/AccessToken.test.js.map +0 -1
- package/dist/WebhookReceiver.test.cjs +0 -38
- package/dist/WebhookReceiver.test.cjs.map +0 -1
- package/dist/WebhookReceiver.test.js +0 -37
- package/dist/WebhookReceiver.test.js.map +0 -1
- package/dist/grants.test.cjs +0 -27
- package/dist/grants.test.cjs.map +0 -1
- package/dist/grants.test.js +0 -26
- package/dist/grants.test.js.map +0 -1
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { IngressAudioOptions, IngressVideoOptions, IngressInput, IngressInfo } from '@livekit/protocol';
|
|
2
|
+
import { ServiceBase } from './ServiceBase.cjs';
|
|
3
|
+
import './grants.cjs';
|
|
4
|
+
import 'jose';
|
|
5
|
+
|
|
6
|
+
interface CreateIngressOptions {
|
|
7
|
+
/**
|
|
8
|
+
* ingress name. optional
|
|
9
|
+
*/
|
|
10
|
+
name?: string;
|
|
11
|
+
/**
|
|
12
|
+
* name of the room to send media to. required
|
|
13
|
+
*/
|
|
14
|
+
roomName?: string;
|
|
15
|
+
/**
|
|
16
|
+
* unique identity of the participant. required
|
|
17
|
+
*/
|
|
18
|
+
participantIdentity: string;
|
|
19
|
+
/**
|
|
20
|
+
* participant display name
|
|
21
|
+
*/
|
|
22
|
+
participantName?: string;
|
|
23
|
+
/**
|
|
24
|
+
* metadata to attach to the participant
|
|
25
|
+
*/
|
|
26
|
+
participantMetadata?: string;
|
|
27
|
+
/**
|
|
28
|
+
* @deprecated use `enableTranscoding` instead.
|
|
29
|
+
* whether to skip transcoding and forward the input media directly. Only supported by WHIP
|
|
30
|
+
*/
|
|
31
|
+
bypassTranscoding?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* whether to enable transcoding or forward the input media directly.
|
|
34
|
+
* Transcoding is required for all input types except WHIP. For WHIP, the default is to not transcode.
|
|
35
|
+
*/
|
|
36
|
+
enableTranscoding?: boolean | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* url of the media to pull for ingresses of type URL
|
|
39
|
+
*/
|
|
40
|
+
url?: string;
|
|
41
|
+
/**
|
|
42
|
+
* custom audio encoding parameters. optional
|
|
43
|
+
*/
|
|
44
|
+
audio?: IngressAudioOptions;
|
|
45
|
+
/**
|
|
46
|
+
* custom video encoding parameters. optional
|
|
47
|
+
*/
|
|
48
|
+
video?: IngressVideoOptions;
|
|
49
|
+
}
|
|
50
|
+
interface UpdateIngressOptions {
|
|
51
|
+
/**
|
|
52
|
+
* ingress name. optional
|
|
53
|
+
*/
|
|
54
|
+
name: string;
|
|
55
|
+
/**
|
|
56
|
+
* name of the room to send media to.
|
|
57
|
+
*/
|
|
58
|
+
roomName?: string;
|
|
59
|
+
/**
|
|
60
|
+
* unique identity of the participant.
|
|
61
|
+
*/
|
|
62
|
+
participantIdentity?: string;
|
|
63
|
+
/**
|
|
64
|
+
* participant display name
|
|
65
|
+
*/
|
|
66
|
+
participantName?: string;
|
|
67
|
+
/**
|
|
68
|
+
* metadata to attach to the participant
|
|
69
|
+
*/
|
|
70
|
+
participantMetadata?: string;
|
|
71
|
+
/**
|
|
72
|
+
* @deprecated use `enableTranscoding` instead
|
|
73
|
+
* whether to skip transcoding and forward the input media directly. Only supported by WHIP
|
|
74
|
+
*/
|
|
75
|
+
bypassTranscoding?: boolean | undefined;
|
|
76
|
+
/**
|
|
77
|
+
* whether to enable transcoding or forward the input media directly.
|
|
78
|
+
* Transcoding is required for all input types except WHIP. For WHIP, the default is to not transcode.
|
|
79
|
+
*/
|
|
80
|
+
enableTranscoding?: boolean | undefined;
|
|
81
|
+
/**
|
|
82
|
+
* custom audio encoding parameters. optional
|
|
83
|
+
*/
|
|
84
|
+
audio?: IngressAudioOptions;
|
|
85
|
+
/**
|
|
86
|
+
* custom video encoding parameters. optional
|
|
87
|
+
*/
|
|
88
|
+
video?: IngressVideoOptions;
|
|
89
|
+
}
|
|
90
|
+
interface ListIngressOptions {
|
|
91
|
+
/**
|
|
92
|
+
* list ingress for one room only
|
|
93
|
+
*/
|
|
94
|
+
roomName?: string;
|
|
95
|
+
/**
|
|
96
|
+
* list ingress by ID
|
|
97
|
+
*/
|
|
98
|
+
ingressId?: string;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Client to access Ingress APIs
|
|
102
|
+
*/
|
|
103
|
+
declare class IngressClient extends ServiceBase {
|
|
104
|
+
private readonly rpc;
|
|
105
|
+
/**
|
|
106
|
+
* @param host - hostname including protocol. i.e. 'https://<project>.livekit.cloud'
|
|
107
|
+
* @param apiKey - API Key, can be set in env var LIVEKIT_API_KEY
|
|
108
|
+
* @param secret - API Secret, can be set in env var LIVEKIT_API_SECRET
|
|
109
|
+
*/
|
|
110
|
+
constructor(host: string, apiKey?: string, secret?: string);
|
|
111
|
+
/**
|
|
112
|
+
* @param inputType - protocol for the ingress
|
|
113
|
+
* @param opts - CreateIngressOptions
|
|
114
|
+
*/
|
|
115
|
+
createIngress(inputType: IngressInput, opts: CreateIngressOptions): Promise<IngressInfo>;
|
|
116
|
+
/**
|
|
117
|
+
* @param ingressId - ID of the ingress to update
|
|
118
|
+
* @param opts - UpdateIngressOptions
|
|
119
|
+
*/
|
|
120
|
+
updateIngress(ingressId: string, opts: UpdateIngressOptions): Promise<IngressInfo>;
|
|
121
|
+
/**
|
|
122
|
+
* @deprecated use `listIngress(opts)` or `listIngress(arg)` instead
|
|
123
|
+
* @param roomName - list ingress for one room only
|
|
124
|
+
*/
|
|
125
|
+
listIngress(roomName?: string): Promise<Array<IngressInfo>>;
|
|
126
|
+
/**
|
|
127
|
+
* @param opts - list options
|
|
128
|
+
*/
|
|
129
|
+
listIngress(opts?: ListIngressOptions): Promise<Array<IngressInfo>>;
|
|
130
|
+
/**
|
|
131
|
+
* @param ingressId - ingress to delete
|
|
132
|
+
*/
|
|
133
|
+
deleteIngress(ingressId: string): Promise<IngressInfo>;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export { type CreateIngressOptions, IngressClient, type ListIngressOptions, type UpdateIngressOptions };
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { RoomEgress, ParticipantPermission, Room, ParticipantInfo, TrackInfo, DataPacket_Kind } from '@livekit/protocol';
|
|
2
|
+
import { ServiceBase } from './ServiceBase.cjs';
|
|
3
|
+
import './grants.cjs';
|
|
4
|
+
import 'jose';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Options for when creating a room
|
|
8
|
+
*/
|
|
9
|
+
interface CreateOptions {
|
|
10
|
+
/**
|
|
11
|
+
* name of the room. required
|
|
12
|
+
*/
|
|
13
|
+
name: string;
|
|
14
|
+
/**
|
|
15
|
+
* number of seconds to keep the room open before any participant joins
|
|
16
|
+
*/
|
|
17
|
+
emptyTimeout?: number;
|
|
18
|
+
/**
|
|
19
|
+
* number of seconds to keep the room open after the last participant leaves
|
|
20
|
+
* this option is helpful to give a grace period for participants to re-join
|
|
21
|
+
*/
|
|
22
|
+
departureTimeout?: number;
|
|
23
|
+
/**
|
|
24
|
+
* limit to the number of participants in a room at a time
|
|
25
|
+
*/
|
|
26
|
+
maxParticipants?: number;
|
|
27
|
+
/**
|
|
28
|
+
* initial room metadata
|
|
29
|
+
*/
|
|
30
|
+
metadata?: string;
|
|
31
|
+
/**
|
|
32
|
+
* add egress options
|
|
33
|
+
*/
|
|
34
|
+
egress?: RoomEgress;
|
|
35
|
+
/**
|
|
36
|
+
* minimum playout delay in milliseconds
|
|
37
|
+
*/
|
|
38
|
+
minPlayoutDelay?: number;
|
|
39
|
+
/**
|
|
40
|
+
* maximum playout delay in milliseconds
|
|
41
|
+
*/
|
|
42
|
+
maxPlayoutDelay?: number;
|
|
43
|
+
/**
|
|
44
|
+
* improves A/V sync when min_playout_delay set to a value larger than 200ms.
|
|
45
|
+
* It will disables transceiver re-use -- this option is not recommended
|
|
46
|
+
* for rooms with frequent subscription changes
|
|
47
|
+
*/
|
|
48
|
+
syncStreams?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* override the node room is allocated to, for debugging
|
|
51
|
+
* does not work with Cloud
|
|
52
|
+
*/
|
|
53
|
+
nodeId?: string;
|
|
54
|
+
}
|
|
55
|
+
type SendDataOptions = {
|
|
56
|
+
/** If set, only deliver to listed participant identities */
|
|
57
|
+
destinationIdentities?: string[];
|
|
58
|
+
destinationSids?: string[];
|
|
59
|
+
topic?: string;
|
|
60
|
+
};
|
|
61
|
+
type UpdateParticipantOptions = {
|
|
62
|
+
/** only attributes you'd want to update should be set, set value to empty string to remove it */
|
|
63
|
+
attributes?: {
|
|
64
|
+
[key: string]: string;
|
|
65
|
+
};
|
|
66
|
+
metadata?: string;
|
|
67
|
+
/** permissions are updated atomically - all desired permissions would need to be set */
|
|
68
|
+
permission?: Partial<ParticipantPermission>;
|
|
69
|
+
name?: string;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Client to access Room APIs
|
|
73
|
+
*/
|
|
74
|
+
declare class RoomServiceClient extends ServiceBase {
|
|
75
|
+
private readonly rpc;
|
|
76
|
+
/**
|
|
77
|
+
*
|
|
78
|
+
* @param host - hostname including protocol. i.e. 'https://<project>.livekit.cloud'
|
|
79
|
+
* @param apiKey - API Key, can be set in env var LIVEKIT_API_KEY
|
|
80
|
+
* @param secret - API Secret, can be set in env var LIVEKIT_API_SECRET
|
|
81
|
+
*/
|
|
82
|
+
constructor(host: string, apiKey?: string, secret?: string);
|
|
83
|
+
/**
|
|
84
|
+
* Creates a new room. Explicit room creation is not required, since rooms will
|
|
85
|
+
* be automatically created when the first participant joins. This method can be
|
|
86
|
+
* used to customize room settings.
|
|
87
|
+
* @param options -
|
|
88
|
+
*/
|
|
89
|
+
createRoom(options: CreateOptions): Promise<Room>;
|
|
90
|
+
/**
|
|
91
|
+
* List active rooms
|
|
92
|
+
* @param names - when undefined or empty, list all rooms.
|
|
93
|
+
* otherwise returns rooms with matching names
|
|
94
|
+
* @returns
|
|
95
|
+
*/
|
|
96
|
+
listRooms(names?: string[]): Promise<Room[]>;
|
|
97
|
+
deleteRoom(room: string): Promise<void>;
|
|
98
|
+
/**
|
|
99
|
+
* Update metadata of a room
|
|
100
|
+
* @param room - name of the room
|
|
101
|
+
* @param metadata - the new metadata for the room
|
|
102
|
+
*/
|
|
103
|
+
updateRoomMetadata(room: string, metadata: string): Promise<Room>;
|
|
104
|
+
/**
|
|
105
|
+
* List participants in a room
|
|
106
|
+
* @param room - name of the room
|
|
107
|
+
*/
|
|
108
|
+
listParticipants(room: string): Promise<ParticipantInfo[]>;
|
|
109
|
+
/**
|
|
110
|
+
* Get information on a specific participant, including the tracks that participant
|
|
111
|
+
* has published
|
|
112
|
+
* @param room - name of the room
|
|
113
|
+
* @param identity - identity of the participant to return
|
|
114
|
+
*/
|
|
115
|
+
getParticipant(room: string, identity: string): Promise<ParticipantInfo>;
|
|
116
|
+
/**
|
|
117
|
+
* Removes a participant in the room. This will disconnect the participant
|
|
118
|
+
* and will emit a Disconnected event for that participant.
|
|
119
|
+
* Even after being removed, the participant can still re-join the room.
|
|
120
|
+
* @param room -
|
|
121
|
+
* @param identity -
|
|
122
|
+
*/
|
|
123
|
+
removeParticipant(room: string, identity: string): Promise<void>;
|
|
124
|
+
/**
|
|
125
|
+
* Mutes a track that the participant has published.
|
|
126
|
+
* @param room -
|
|
127
|
+
* @param identity -
|
|
128
|
+
* @param trackSid - sid of the track to be muted
|
|
129
|
+
* @param muted - true to mute, false to unmute
|
|
130
|
+
*/
|
|
131
|
+
mutePublishedTrack(room: string, identity: string, trackSid: string, muted: boolean): Promise<TrackInfo>;
|
|
132
|
+
/**
|
|
133
|
+
* Updates a participant's state or permissions
|
|
134
|
+
* @param room - target room
|
|
135
|
+
* @param identity - participant identity
|
|
136
|
+
* @param options - participant fields to update
|
|
137
|
+
*/
|
|
138
|
+
updateParticipant(room: string, identity: string, options: UpdateParticipantOptions): Promise<ParticipantInfo>;
|
|
139
|
+
/**
|
|
140
|
+
* Updates a participant's state or permissions
|
|
141
|
+
* @param room - target room
|
|
142
|
+
* @param identity - participant identity
|
|
143
|
+
* @param options - participant fields to update
|
|
144
|
+
*/
|
|
145
|
+
updateParticipant(room: string, identity: string, metadata?: string, permission?: Partial<ParticipantPermission>, name?: string): Promise<ParticipantInfo>;
|
|
146
|
+
/**
|
|
147
|
+
* Updates a participant's subscription to tracks
|
|
148
|
+
* @param room -
|
|
149
|
+
* @param identity -
|
|
150
|
+
* @param trackSids -
|
|
151
|
+
* @param subscribe - true to subscribe, false to unsubscribe
|
|
152
|
+
*/
|
|
153
|
+
updateSubscriptions(room: string, identity: string, trackSids: string[], subscribe: boolean): Promise<void>;
|
|
154
|
+
/**
|
|
155
|
+
* Sends data message to participants in the room
|
|
156
|
+
* @param room -
|
|
157
|
+
* @param data - opaque payload to send
|
|
158
|
+
* @param kind - delivery reliability
|
|
159
|
+
* @param options - optionally specify a topic and destinationSids (when destinationSids is empty, message is sent to everyone)
|
|
160
|
+
*/
|
|
161
|
+
sendData(room: string, data: Uint8Array, kind: DataPacket_Kind, options: SendDataOptions): Promise<void>;
|
|
162
|
+
/**
|
|
163
|
+
* Sends data message to participants in the room
|
|
164
|
+
* @deprecated use sendData(room, data, kind, options) instead
|
|
165
|
+
* @param room -
|
|
166
|
+
* @param data - opaque payload to send
|
|
167
|
+
* @param kind - delivery reliability
|
|
168
|
+
* @param destinationSids - optional. when empty, message is sent to everyone
|
|
169
|
+
*/
|
|
170
|
+
sendData(room: string, data: Uint8Array, kind: DataPacket_Kind, destinationSids?: string[]): Promise<void>;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export { type CreateOptions, RoomServiceClient, type SendDataOptions, type UpdateParticipantOptions };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { VideoGrant, SIPGrant } from './grants.cjs';
|
|
2
|
+
import '@livekit/protocol';
|
|
3
|
+
import 'jose';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Utilities to handle authentication
|
|
7
|
+
*/
|
|
8
|
+
declare class ServiceBase {
|
|
9
|
+
private readonly apiKey?;
|
|
10
|
+
private readonly secret?;
|
|
11
|
+
private readonly ttl;
|
|
12
|
+
/**
|
|
13
|
+
* @param apiKey - API Key.
|
|
14
|
+
* @param secret - API Secret.
|
|
15
|
+
* @param ttl - token TTL
|
|
16
|
+
*/
|
|
17
|
+
constructor(apiKey?: string, secret?: string, ttl?: string);
|
|
18
|
+
authHeader(grant: VideoGrant, sip?: SIPGrant): Promise<Record<string, string>>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { ServiceBase };
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { SIPTransport, SIPTrunkInfo, SIPInboundTrunkInfo, SIPOutboundTrunkInfo, SIPDispatchRuleInfo, SIPParticipantInfo } from '@livekit/protocol';
|
|
2
|
+
import { ServiceBase } from './ServiceBase.cjs';
|
|
3
|
+
import './grants.cjs';
|
|
4
|
+
import 'jose';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated use CreateSipInboundTrunkOptions or CreateSipOutboundTrunkOptions
|
|
8
|
+
*/
|
|
9
|
+
interface CreateSipTrunkOptions {
|
|
10
|
+
name?: string;
|
|
11
|
+
metadata?: string;
|
|
12
|
+
inbound_addresses?: string[];
|
|
13
|
+
inbound_numbers?: string[];
|
|
14
|
+
inbound_username?: string;
|
|
15
|
+
inbound_password?: string;
|
|
16
|
+
outbound_address?: string;
|
|
17
|
+
outbound_username?: string;
|
|
18
|
+
outbound_password?: string;
|
|
19
|
+
}
|
|
20
|
+
interface CreateSipInboundTrunkOptions {
|
|
21
|
+
metadata?: string;
|
|
22
|
+
allowed_addresses?: string[];
|
|
23
|
+
allowed_numbers?: string[];
|
|
24
|
+
auth_username?: string;
|
|
25
|
+
auth_password?: string;
|
|
26
|
+
headers?: {
|
|
27
|
+
[key: string]: string;
|
|
28
|
+
};
|
|
29
|
+
headersToAttributes?: {
|
|
30
|
+
[key: string]: string;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
interface CreateSipOutboundTrunkOptions {
|
|
34
|
+
metadata?: string;
|
|
35
|
+
transport: SIPTransport;
|
|
36
|
+
auth_username?: string;
|
|
37
|
+
auth_password?: string;
|
|
38
|
+
headers?: {
|
|
39
|
+
[key: string]: string;
|
|
40
|
+
};
|
|
41
|
+
headersToAttributes?: {
|
|
42
|
+
[key: string]: string;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
interface SipDispatchRuleDirect {
|
|
46
|
+
type: 'direct';
|
|
47
|
+
roomName: string;
|
|
48
|
+
pin?: string;
|
|
49
|
+
}
|
|
50
|
+
interface SipDispatchRuleIndividual {
|
|
51
|
+
type: 'individual';
|
|
52
|
+
roomPrefix: string;
|
|
53
|
+
pin?: string;
|
|
54
|
+
}
|
|
55
|
+
interface CreateSipDispatchRuleOptions {
|
|
56
|
+
name?: string;
|
|
57
|
+
metadata?: string;
|
|
58
|
+
trunkIds?: string[];
|
|
59
|
+
hidePhoneNumber?: boolean;
|
|
60
|
+
}
|
|
61
|
+
interface CreateSipParticipantOptions {
|
|
62
|
+
participantIdentity?: string;
|
|
63
|
+
participantName?: string;
|
|
64
|
+
participantMetadata?: string;
|
|
65
|
+
dtmf?: string;
|
|
66
|
+
/** @deprecated - use `playDialtone` instead */
|
|
67
|
+
playRingtone?: boolean;
|
|
68
|
+
playDialtone?: boolean;
|
|
69
|
+
hidePhoneNumber?: boolean;
|
|
70
|
+
ringingTimeout?: number;
|
|
71
|
+
maxCallDuration?: number;
|
|
72
|
+
enableKrisp?: boolean;
|
|
73
|
+
}
|
|
74
|
+
interface TransferSipParticipantOptions {
|
|
75
|
+
playDialtone?: boolean;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Client to access Egress APIs
|
|
79
|
+
*/
|
|
80
|
+
declare class SipClient extends ServiceBase {
|
|
81
|
+
private readonly rpc;
|
|
82
|
+
/**
|
|
83
|
+
* @param host - hostname including protocol. i.e. 'https://<project>.livekit.cloud'
|
|
84
|
+
* @param apiKey - API Key, can be set in env var LIVEKIT_API_KEY
|
|
85
|
+
* @param secret - API Secret, can be set in env var LIVEKIT_API_SECRET
|
|
86
|
+
*/
|
|
87
|
+
constructor(host: string, apiKey?: string, secret?: string);
|
|
88
|
+
/**
|
|
89
|
+
* @param number - phone number of the trunk
|
|
90
|
+
* @param opts - CreateSipTrunkOptions
|
|
91
|
+
* @deprecated use `createSipInboundTrunk` or `createSipOutboundTrunk`
|
|
92
|
+
*/
|
|
93
|
+
createSipTrunk(number: string, opts?: CreateSipTrunkOptions): Promise<SIPTrunkInfo>;
|
|
94
|
+
/**
|
|
95
|
+
* @param name - human-readable name of the trunk
|
|
96
|
+
* @param numbers - phone numbers of the trunk
|
|
97
|
+
* @param opts - CreateSipTrunkOptions
|
|
98
|
+
*/
|
|
99
|
+
createSipInboundTrunk(name: string, numbers: string[], opts?: CreateSipInboundTrunkOptions): Promise<SIPInboundTrunkInfo>;
|
|
100
|
+
/**
|
|
101
|
+
* @param name - human-readable name of the trunk
|
|
102
|
+
* @param address - hostname and port of the SIP server to dial
|
|
103
|
+
* @param numbers - phone numbers of the trunk
|
|
104
|
+
* @param opts - CreateSipTrunkOptions
|
|
105
|
+
*/
|
|
106
|
+
createSipOutboundTrunk(name: string, address: string, numbers: string[], opts?: CreateSipOutboundTrunkOptions): Promise<SIPOutboundTrunkInfo>;
|
|
107
|
+
/**
|
|
108
|
+
* @deprecated use `listSipInboundTrunk` or `listSipOutboundTrunk`
|
|
109
|
+
*/
|
|
110
|
+
listSipTrunk(): Promise<Array<SIPTrunkInfo>>;
|
|
111
|
+
listSipInboundTrunk(): Promise<Array<SIPInboundTrunkInfo>>;
|
|
112
|
+
listSipOutboundTrunk(): Promise<Array<SIPOutboundTrunkInfo>>;
|
|
113
|
+
/**
|
|
114
|
+
* @param sipTrunkId - sip trunk to delete
|
|
115
|
+
*/
|
|
116
|
+
deleteSipTrunk(sipTrunkId: string): Promise<SIPTrunkInfo>;
|
|
117
|
+
/**
|
|
118
|
+
* @param rule - sip dispatch rule
|
|
119
|
+
* @param opts - CreateSipDispatchRuleOptions
|
|
120
|
+
*/
|
|
121
|
+
createSipDispatchRule(rule: SipDispatchRuleDirect | SipDispatchRuleIndividual, opts?: CreateSipDispatchRuleOptions): Promise<SIPDispatchRuleInfo>;
|
|
122
|
+
listSipDispatchRule(): Promise<Array<SIPDispatchRuleInfo>>;
|
|
123
|
+
/**
|
|
124
|
+
* @param sipDispatchRuleId - sip trunk to delete
|
|
125
|
+
*/
|
|
126
|
+
deleteSipDispatchRule(sipDispatchRuleId: string): Promise<SIPDispatchRuleInfo>;
|
|
127
|
+
/**
|
|
128
|
+
* @param sipTrunkId - sip trunk to use for the call
|
|
129
|
+
* @param number - number to dial
|
|
130
|
+
* @param roomName - room to attach the call to
|
|
131
|
+
* @param opts - CreateSipParticipantOptions
|
|
132
|
+
*/
|
|
133
|
+
createSipParticipant(sipTrunkId: string, number: string, roomName: string, opts?: CreateSipParticipantOptions): Promise<SIPParticipantInfo>;
|
|
134
|
+
/**
|
|
135
|
+
* @param roomName - room the SIP participant to transfer is connectd to
|
|
136
|
+
* @param participantIdentity - identity of the SIP participant to transfer
|
|
137
|
+
* @param transferTo - SIP URL to transfer the participant to
|
|
138
|
+
*/
|
|
139
|
+
transferSipParticipant(roomName: string, participantIdentity: string, transferTo: string, opts?: TransferSipParticipantOptions): Promise<void>;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export { type CreateSipDispatchRuleOptions, type CreateSipInboundTrunkOptions, type CreateSipOutboundTrunkOptions, type CreateSipParticipantOptions, type CreateSipTrunkOptions, SipClient, type SipDispatchRuleDirect, type SipDispatchRuleIndividual, type TransferSipParticipantOptions };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { JsonValue } from '@bufbuild/protobuf';
|
|
2
|
+
|
|
3
|
+
declare const livekitPackage = "livekit";
|
|
4
|
+
interface Rpc {
|
|
5
|
+
request(service: string, method: string, data: JsonValue, headers?: any): Promise<string>;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* JSON based Twirp V7 RPC
|
|
9
|
+
*/
|
|
10
|
+
declare class TwirpRpc {
|
|
11
|
+
host: string;
|
|
12
|
+
pkg: string;
|
|
13
|
+
prefix: string;
|
|
14
|
+
constructor(host: string, pkg: string, prefix?: string);
|
|
15
|
+
request(service: string, method: string, data: any, headers?: any): Promise<any>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { type Rpc, TwirpRpc, livekitPackage };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { BinaryReadOptions, JsonValue, JsonReadOptions } from '@bufbuild/protobuf';
|
|
2
|
+
import { WebhookEvent as WebhookEvent$1 } from '@livekit/protocol';
|
|
3
|
+
|
|
4
|
+
declare const authorizeHeader = "Authorize";
|
|
5
|
+
declare class WebhookEvent extends WebhookEvent$1 {
|
|
6
|
+
event: WebhookEventNames;
|
|
7
|
+
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): WebhookEvent;
|
|
8
|
+
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): WebhookEvent;
|
|
9
|
+
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): WebhookEvent;
|
|
10
|
+
}
|
|
11
|
+
type WebhookEventNames = 'room_started' | 'room_finished' | 'participant_joined' | 'participant_left' | 'track_published' | 'track_unpublished' | 'egress_started' | 'egress_updated' | 'egress_ended' | 'ingress_started' | 'ingress_ended'
|
|
12
|
+
/**
|
|
13
|
+
* @internal
|
|
14
|
+
* @remarks only used as a default value, not a valid webhook event
|
|
15
|
+
*/
|
|
16
|
+
| '';
|
|
17
|
+
declare class WebhookReceiver {
|
|
18
|
+
private verifier;
|
|
19
|
+
constructor(apiKey: string, apiSecret: string);
|
|
20
|
+
/**
|
|
21
|
+
* @param body - string of the posted body
|
|
22
|
+
* @param authHeader - `Authorization` header from the request
|
|
23
|
+
* @param skipAuth - true to skip auth validation
|
|
24
|
+
* @returns
|
|
25
|
+
*/
|
|
26
|
+
receive(body: string, authHeader?: string, skipAuth?: boolean): Promise<WebhookEvent>;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export { WebhookEvent, type WebhookEventNames, WebhookReceiver, authorizeHeader };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { TrackSource, RoomConfiguration } from '@livekit/protocol';
|
|
2
|
+
import { JWTPayload } from 'jose';
|
|
3
|
+
|
|
4
|
+
declare function trackSourceToString(source: TrackSource): "camera" | "microphone" | "screen_share" | "screen_share_audio";
|
|
5
|
+
declare function claimsToJwtPayload(grant: ClaimGrants): JWTPayload & {
|
|
6
|
+
video?: Record<string, unknown>;
|
|
7
|
+
};
|
|
8
|
+
interface VideoGrant {
|
|
9
|
+
/** permission to create a room */
|
|
10
|
+
roomCreate?: boolean;
|
|
11
|
+
/** permission to join a room as a participant, room must be set */
|
|
12
|
+
roomJoin?: boolean;
|
|
13
|
+
/** permission to list rooms */
|
|
14
|
+
roomList?: boolean;
|
|
15
|
+
/** permission to start a recording */
|
|
16
|
+
roomRecord?: boolean;
|
|
17
|
+
/** permission to control a specific room, room must be set */
|
|
18
|
+
roomAdmin?: boolean;
|
|
19
|
+
/** name of the room, must be set for admin or join permissions */
|
|
20
|
+
room?: string;
|
|
21
|
+
/** permissions to control ingress, not specific to any room or ingress */
|
|
22
|
+
ingressAdmin?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* allow participant to publish. If neither canPublish or canSubscribe is set,
|
|
25
|
+
* both publish and subscribe are enabled
|
|
26
|
+
*/
|
|
27
|
+
canPublish?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* TrackSource types that the participant is allowed to publish
|
|
30
|
+
* When set, it supersedes CanPublish. Only sources explicitly set here can be published
|
|
31
|
+
*/
|
|
32
|
+
canPublishSources?: TrackSource[];
|
|
33
|
+
/** allow participant to subscribe to other tracks */
|
|
34
|
+
canSubscribe?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* allow participants to publish data, defaults to true if not set
|
|
37
|
+
*/
|
|
38
|
+
canPublishData?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* by default, a participant is not allowed to update its own metadata
|
|
41
|
+
*/
|
|
42
|
+
canUpdateOwnMetadata?: boolean;
|
|
43
|
+
/** participant isn't visible to others */
|
|
44
|
+
hidden?: boolean;
|
|
45
|
+
/** participant is recording the room, when set, allows room to indicate it's being recorded */
|
|
46
|
+
recorder?: boolean;
|
|
47
|
+
/** participant allowed to connect to LiveKit as Agent Framework worker */
|
|
48
|
+
agent?: boolean;
|
|
49
|
+
/** allow participant to subscribe to metrics */
|
|
50
|
+
canSubscribeMetrics?: boolean;
|
|
51
|
+
}
|
|
52
|
+
interface SIPGrant {
|
|
53
|
+
/** manage sip resources */
|
|
54
|
+
admin?: boolean;
|
|
55
|
+
/** make outbound calls */
|
|
56
|
+
call?: boolean;
|
|
57
|
+
}
|
|
58
|
+
/** @internal */
|
|
59
|
+
interface ClaimGrants extends JWTPayload {
|
|
60
|
+
name?: string;
|
|
61
|
+
video?: VideoGrant;
|
|
62
|
+
sip?: SIPGrant;
|
|
63
|
+
kind?: string;
|
|
64
|
+
metadata?: string;
|
|
65
|
+
attributes?: Record<string, string>;
|
|
66
|
+
sha256?: string;
|
|
67
|
+
roomPreset?: string;
|
|
68
|
+
roomConfig?: RoomConfiguration;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export { type ClaimGrants, type SIPGrant, type VideoGrant, claimsToJwtPayload, trackSourceToString };
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { AliOSSUpload, AutoParticipantEgress, AutoTrackEgress, AzureBlobUpload, DataPacket_Kind, DirectFileOutput, EgressInfo, EgressStatus, EncodedFileOutput, EncodedFileType, EncodingOptions, EncodingOptionsPreset, GCPUpload, ImageCodec, ImageFileSuffix, ImageOutput, IngressAudioEncodingOptions, IngressAudioEncodingPreset, IngressAudioOptions, IngressInfo, IngressInput, IngressState, IngressVideoEncodingOptions, IngressVideoEncodingPreset, IngressVideoOptions, ParticipantEgressRequest, ParticipantInfo, ParticipantInfo_State, ParticipantPermission, Room, RoomCompositeEgressRequest, RoomEgress, S3Upload, SIPDispatchRuleInfo, SIPParticipantInfo, SIPTrunkInfo, SegmentedFileOutput, SegmentedFileProtocol, StreamOutput, StreamProtocol, TrackCompositeEgressRequest, TrackEgressRequest, TrackInfo, TrackSource, TrackType, WebEgressRequest } from '@livekit/protocol';
|
|
2
|
+
export { AccessToken, AccessTokenOptions, TokenVerifier } from './AccessToken.cjs';
|
|
3
|
+
export { AgentDispatchClient } from './AgentDispatchClient.cjs';
|
|
4
|
+
export { EgressClient, EncodedOutputs, ListEgressOptions, ParticipantEgressOptions, RoomCompositeOptions, TrackCompositeOptions, WebOptions } from './EgressClient.cjs';
|
|
5
|
+
export { ClaimGrants, SIPGrant, VideoGrant, claimsToJwtPayload, trackSourceToString } from './grants.cjs';
|
|
6
|
+
export { CreateIngressOptions, IngressClient, ListIngressOptions, UpdateIngressOptions } from './IngressClient.cjs';
|
|
7
|
+
export { CreateOptions, RoomServiceClient, SendDataOptions, UpdateParticipantOptions } from './RoomServiceClient.cjs';
|
|
8
|
+
export { CreateSipDispatchRuleOptions, CreateSipInboundTrunkOptions, CreateSipOutboundTrunkOptions, CreateSipParticipantOptions, CreateSipTrunkOptions, SipClient, SipDispatchRuleDirect, SipDispatchRuleIndividual, TransferSipParticipantOptions } from './SipClient.cjs';
|
|
9
|
+
export { WebhookEvent, WebhookEventNames, WebhookReceiver, authorizeHeader } from './WebhookReceiver.cjs';
|
|
10
|
+
import './ServiceBase.cjs';
|
|
11
|
+
import 'jose';
|
|
12
|
+
import '@bufbuild/protobuf';
|
package/package.json
CHANGED
|
@@ -1,19 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "livekit-server-sdk",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.4",
|
|
4
4
|
"description": "Server-side SDK for LiveKit",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"require": "dist/index.cjs",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
|
-
"repository":
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/livekit/server-sdk-js.git"
|
|
11
|
+
},
|
|
9
12
|
"author": "David Zhao <david@davidzhao.com>",
|
|
10
13
|
"license": "Apache-2.0",
|
|
11
14
|
"type": "module",
|
|
12
15
|
"exports": {
|
|
13
16
|
".": {
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
"import": {
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"default": "./dist/index.js"
|
|
20
|
+
},
|
|
21
|
+
"require": {
|
|
22
|
+
"types": "./dist/index.d.cts",
|
|
23
|
+
"default": "./dist/index.cjs"
|
|
24
|
+
}
|
|
17
25
|
}
|
|
18
26
|
},
|
|
19
27
|
"files": [
|
package/src/AccessToken.test.ts
CHANGED
|
@@ -9,8 +9,8 @@ import {
|
|
|
9
9
|
} from '@livekit/protocol';
|
|
10
10
|
import * as jose from 'jose';
|
|
11
11
|
import { describe, expect, it } from 'vitest';
|
|
12
|
-
import { AccessToken, TokenVerifier } from './AccessToken';
|
|
13
|
-
import type { ClaimGrants } from './grants';
|
|
12
|
+
import { AccessToken, TokenVerifier } from './AccessToken.js';
|
|
13
|
+
import type { ClaimGrants } from './grants.js';
|
|
14
14
|
|
|
15
15
|
const testApiKey = 'abcdefg';
|
|
16
16
|
const testSecret = 'abababa';
|
|
@@ -143,10 +143,10 @@ describe('room configuration with agents and egress', () => {
|
|
|
143
143
|
expect(decoded.roomConfig?.name).toEqual('test-room');
|
|
144
144
|
expect(decoded.roomConfig?.maxParticipants).toEqual(10);
|
|
145
145
|
expect(decoded.roomConfig?.agents).toHaveLength(2);
|
|
146
|
-
expect(decoded.roomConfig?.agents?.[0]
|
|
147
|
-
expect(decoded.roomConfig?.agents?.[0]
|
|
148
|
-
expect(decoded.roomConfig?.agents?.[1]
|
|
149
|
-
expect(decoded.roomConfig?.agents?.[1]
|
|
146
|
+
expect(decoded.roomConfig?.agents?.[0]?.agentName).toEqual('agent1');
|
|
147
|
+
expect(decoded.roomConfig?.agents?.[0]?.metadata).toEqual('metadata-1');
|
|
148
|
+
expect(decoded.roomConfig?.agents?.[1]?.agentName).toEqual('agent2');
|
|
149
|
+
expect(decoded.roomConfig?.agents?.[1]?.metadata).toEqual('metadata-2');
|
|
150
150
|
expect(decoded.roomConfig?.egress?.room?.roomName).toEqual('test-room');
|
|
151
151
|
});
|
|
152
152
|
});
|