plugnmeet-sdk-js 1.2.0 → 1.2.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.
- package/README.md +1 -1
- package/{PlugNmeet.d.ts → dist/PlugNmeet.d.ts} +0 -0
- package/{PlugNmeet.js → dist/PlugNmeet.js} +0 -0
- package/{PlugNmeet.js.map → dist/PlugNmeet.js.map} +0 -0
- package/{api.d.ts → dist/api.d.ts} +0 -0
- package/{api.js → dist/api.js} +0 -0
- package/{api.js.map → dist/api.js.map} +0 -0
- package/dist/cjs/PlugNmeet.d.ts +76 -0
- package/dist/cjs/PlugNmeet.js +231 -0
- package/dist/cjs/PlugNmeet.js.map +1 -0
- package/dist/cjs/api.d.ts +6 -0
- package/dist/cjs/api.js +85 -0
- package/dist/cjs/api.js.map +1 -0
- package/{index.d.ts → dist/cjs/index.d.ts} +0 -0
- package/dist/cjs/index.js +6 -0
- package/dist/cjs/index.js.map +1 -0
- package/{types → dist/cjs/types}/RecordingDownloadToken.d.ts +0 -0
- package/dist/cjs/types/RecordingDownloadToken.js +3 -0
- package/dist/cjs/types/RecordingDownloadToken.js.map +1 -0
- package/{types → dist/cjs/types}/activeRoomInfo.d.ts +0 -0
- package/dist/cjs/types/activeRoomInfo.js +3 -0
- package/dist/cjs/types/activeRoomInfo.js.map +1 -0
- package/{types → dist/cjs/types}/activeRoomsInfo.d.ts +0 -0
- package/dist/cjs/types/activeRoomsInfo.js +3 -0
- package/dist/cjs/types/activeRoomsInfo.js.map +1 -0
- package/{types → dist/cjs/types}/clientFiles.d.ts +0 -0
- package/dist/cjs/types/clientFiles.js +3 -0
- package/dist/cjs/types/clientFiles.js.map +1 -0
- package/{types → dist/cjs/types}/createRoom.d.ts +1 -0
- package/dist/cjs/types/createRoom.js +3 -0
- package/dist/cjs/types/createRoom.js.map +1 -0
- package/{types → dist/cjs/types}/deleteRecordings.d.ts +0 -0
- package/dist/cjs/types/deleteRecordings.js +3 -0
- package/dist/cjs/types/deleteRecordings.js.map +1 -0
- package/{types → dist/cjs/types}/endRoom.d.ts +0 -0
- package/dist/cjs/types/endRoom.js +3 -0
- package/dist/cjs/types/endRoom.js.map +1 -0
- package/{types → dist/cjs/types}/fetchRecordings.d.ts +0 -0
- package/dist/cjs/types/fetchRecordings.js +3 -0
- package/dist/cjs/types/fetchRecordings.js.map +1 -0
- package/{types → dist/cjs/types}/isRoomActive.d.ts +0 -0
- package/dist/cjs/types/isRoomActive.js +3 -0
- package/dist/cjs/types/isRoomActive.js.map +1 -0
- package/{types → dist/cjs/types}/joinToken.d.ts +0 -0
- package/dist/cjs/types/joinToken.js +3 -0
- package/dist/cjs/types/joinToken.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/{index.js → dist/index.js} +0 -0
- package/{index.js.map → dist/index.js.map} +0 -0
- package/dist/types/RecordingDownloadToken.d.ts +8 -0
- package/{types → dist/types}/RecordingDownloadToken.js +0 -0
- package/{types → dist/types}/RecordingDownloadToken.js.map +0 -0
- package/dist/types/activeRoomInfo.d.ts +34 -0
- package/{types → dist/types}/activeRoomInfo.js +0 -0
- package/{types → dist/types}/activeRoomInfo.js.map +0 -0
- package/dist/types/activeRoomsInfo.d.ts +6 -0
- package/{types → dist/types}/activeRoomsInfo.js +0 -0
- package/{types → dist/types}/activeRoomsInfo.js.map +0 -0
- package/dist/types/clientFiles.d.ts +6 -0
- package/{types → dist/types}/clientFiles.js +0 -0
- package/{types → dist/types}/clientFiles.js.map +0 -0
- package/dist/types/createRoom.d.ts +83 -0
- package/{types → dist/types}/createRoom.js +0 -0
- package/{types → dist/types}/createRoom.js.map +0 -0
- package/dist/types/deleteRecordings.d.ts +7 -0
- package/{types → dist/types}/deleteRecordings.js +0 -0
- package/{types → dist/types}/deleteRecordings.js.map +0 -0
- package/dist/types/endRoom.d.ts +7 -0
- package/{types → dist/types}/endRoom.js +0 -0
- package/{types → dist/types}/endRoom.js.map +0 -0
- package/dist/types/fetchRecordings.d.ts +27 -0
- package/{types → dist/types}/fetchRecordings.js +0 -0
- package/{types → dist/types}/fetchRecordings.js.map +0 -0
- package/dist/types/isRoomActive.d.ts +7 -0
- package/{types → dist/types}/isRoomActive.js +0 -0
- package/{types → dist/types}/isRoomActive.js.map +0 -0
- package/dist/types/joinToken.d.ts +21 -0
- package/{types → dist/types}/joinToken.js +0 -0
- package/{types → dist/types}/joinToken.js.map +0 -0
- package/package.json +11 -9
- package/src/PlugNmeet.ts +255 -0
- package/src/api.ts +92 -0
- package/src/index.ts +48 -0
- package/src/types/RecordingDownloadToken.ts +9 -0
- package/src/types/activeRoomInfo.ts +38 -0
- package/src/types/activeRoomsInfo.ts +7 -0
- package/src/types/clientFiles.ts +6 -0
- package/src/types/createRoom.ts +95 -0
- package/src/types/deleteRecordings.ts +8 -0
- package/src/types/endRoom.ts +8 -0
- package/src/types/fetchRecordings.ts +30 -0
- package/src/types/isRoomActive.ts +8 -0
- package/src/types/joinToken.ts +25 -0
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
export type CreateRoomParams = {
|
|
2
|
+
room_id: string;
|
|
3
|
+
max_participants?: number;
|
|
4
|
+
empty_timeout?: number;
|
|
5
|
+
metadata: RooMetadata;
|
|
6
|
+
};
|
|
7
|
+
export type RooMetadata = {
|
|
8
|
+
room_title: string;
|
|
9
|
+
welcome_message?: string;
|
|
10
|
+
webhook_url?: string;
|
|
11
|
+
logout_url?: string;
|
|
12
|
+
room_features: RoomFeaturesParams;
|
|
13
|
+
default_lock_settings?: LockSettingsParams;
|
|
14
|
+
};
|
|
15
|
+
export type RoomFeaturesParams = {
|
|
16
|
+
allow_webcams: boolean;
|
|
17
|
+
mute_on_start: boolean;
|
|
18
|
+
allow_screen_share: boolean;
|
|
19
|
+
allow_rtmp: boolean;
|
|
20
|
+
admin_only_webcams: boolean;
|
|
21
|
+
allow_view_other_webcams: boolean;
|
|
22
|
+
allow_view_other_users_list: boolean;
|
|
23
|
+
recording_features: RecordingFeaturesParams;
|
|
24
|
+
chat_features: ChatFeaturesParams;
|
|
25
|
+
shared_note_pad_features?: SharedNotePadFeaturesParams;
|
|
26
|
+
whiteboard_features?: WhiteboardFeaturesParams;
|
|
27
|
+
external_media_player_features?: ExternalMediaPlayerFeatures;
|
|
28
|
+
waiting_room_features?: WaitingRoomFeatures;
|
|
29
|
+
breakout_room_features?: BreakoutRoomFeatures;
|
|
30
|
+
};
|
|
31
|
+
export type RecordingFeaturesParams = {
|
|
32
|
+
is_allow: boolean;
|
|
33
|
+
is_allow_cloud: boolean;
|
|
34
|
+
is_allow_local: boolean;
|
|
35
|
+
enable_auto_cloud_recording: boolean;
|
|
36
|
+
};
|
|
37
|
+
export type ChatFeaturesParams = {
|
|
38
|
+
allow_chat: boolean;
|
|
39
|
+
allow_file_upload: boolean;
|
|
40
|
+
allowed_file_types: Array<string>;
|
|
41
|
+
max_file_size: number;
|
|
42
|
+
};
|
|
43
|
+
export type SharedNotePadFeaturesParams = {
|
|
44
|
+
allowed_shared_note_pad: boolean;
|
|
45
|
+
};
|
|
46
|
+
export type WhiteboardFeaturesParams = {
|
|
47
|
+
allowed_whiteboard: boolean;
|
|
48
|
+
};
|
|
49
|
+
export type ExternalMediaPlayerFeatures = {
|
|
50
|
+
allowed_external_media_player: boolean;
|
|
51
|
+
};
|
|
52
|
+
export type WaitingRoomFeatures = {
|
|
53
|
+
is_active: boolean;
|
|
54
|
+
waiting_room_msg?: string;
|
|
55
|
+
};
|
|
56
|
+
export type BreakoutRoomFeatures = {
|
|
57
|
+
is_allow: boolean;
|
|
58
|
+
};
|
|
59
|
+
export type LockSettingsParams = {
|
|
60
|
+
lock_microphone?: boolean;
|
|
61
|
+
lock_webcam?: boolean;
|
|
62
|
+
lock_screen_sharing?: boolean;
|
|
63
|
+
lock_whiteboard?: boolean;
|
|
64
|
+
lock_shared_notepad?: boolean;
|
|
65
|
+
lock_chat?: boolean;
|
|
66
|
+
lock_chat_send_message?: boolean;
|
|
67
|
+
lock_chat_file_share?: boolean;
|
|
68
|
+
};
|
|
69
|
+
export type CreateRoomResponse = {
|
|
70
|
+
status: boolean;
|
|
71
|
+
msg: string;
|
|
72
|
+
roomInfo?: CreateRoomResponseRoomInfo;
|
|
73
|
+
};
|
|
74
|
+
export type CreateRoomResponseRoomInfo = {
|
|
75
|
+
sid: string;
|
|
76
|
+
name: string;
|
|
77
|
+
max_participants: number;
|
|
78
|
+
empty_timeout: number;
|
|
79
|
+
creation_time: number;
|
|
80
|
+
turn_password: string;
|
|
81
|
+
enabled_codecs: Array<any>;
|
|
82
|
+
metadata: string;
|
|
83
|
+
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export type FetchRecordingsParams = {
|
|
2
|
+
room_ids: Array<string>;
|
|
3
|
+
from?: number;
|
|
4
|
+
limit?: number;
|
|
5
|
+
order_by?: 'ASC' | 'DESC';
|
|
6
|
+
};
|
|
7
|
+
export type FetchRecordingsResponse = {
|
|
8
|
+
status: boolean;
|
|
9
|
+
msg: string;
|
|
10
|
+
result?: FetchRecordingsResult;
|
|
11
|
+
};
|
|
12
|
+
export type FetchRecordingsResult = {
|
|
13
|
+
total_recordings: number;
|
|
14
|
+
from: number;
|
|
15
|
+
limit: number;
|
|
16
|
+
order_by: string;
|
|
17
|
+
recordings_list: Array<RecordingInfo>;
|
|
18
|
+
};
|
|
19
|
+
export type RecordingInfo = {
|
|
20
|
+
record_id: string;
|
|
21
|
+
room_id: string;
|
|
22
|
+
room_sid: string;
|
|
23
|
+
file_path: string;
|
|
24
|
+
file_size: number;
|
|
25
|
+
creation_time: number;
|
|
26
|
+
room_creation_time: number;
|
|
27
|
+
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { LockSettingsParams } from './createRoom';
|
|
2
|
+
export type JoinTokenParams = {
|
|
3
|
+
room_id: string;
|
|
4
|
+
user_info: JoinTokenUserInfo;
|
|
5
|
+
};
|
|
6
|
+
export type JoinTokenUserInfo = {
|
|
7
|
+
name: string;
|
|
8
|
+
user_id: string;
|
|
9
|
+
is_admin: boolean;
|
|
10
|
+
is_hidden: boolean;
|
|
11
|
+
user_metadata?: JoinTokenUserMetadata;
|
|
12
|
+
};
|
|
13
|
+
export type JoinTokenUserMetadata = {
|
|
14
|
+
profile_pic?: string;
|
|
15
|
+
lock_settings?: LockSettingsParams;
|
|
16
|
+
};
|
|
17
|
+
export type JoinTokenResponse = {
|
|
18
|
+
status: boolean;
|
|
19
|
+
msg: string;
|
|
20
|
+
token?: string;
|
|
21
|
+
};
|
|
File without changes
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "plugnmeet-sdk-js",
|
|
3
|
-
"version": "1.2.
|
|
4
|
-
"type": "module",
|
|
3
|
+
"version": "1.2.2",
|
|
5
4
|
"description": "plugNmeet JS SDK",
|
|
6
5
|
"author": "Jibon L. Costa",
|
|
7
6
|
"license": "MIT",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
8
9
|
"exports": {
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
"*": {
|
|
13
|
-
"index.d.ts": ["index.d.ts"]
|
|
14
|
-
}
|
|
10
|
+
"types": "./dist/src/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"require": "./dist/cjs/index.js"
|
|
15
13
|
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"src"
|
|
17
|
+
],
|
|
16
18
|
"scripts": {
|
|
17
19
|
"start": "rm -rf ./dist && concurrently -c \"red,green\" --kill-others \"tsc --watch -p . --outDir ./dist && esw -w --ext '.ts','.js' --fix\"",
|
|
18
|
-
"build": "rm -rf ./dist && tsc -p .
|
|
20
|
+
"build": "rm -rf ./dist && tsc -p tsconfig.json && tsc -p tsconfig-cjs.json",
|
|
19
21
|
"build-docs": "typedoc --sort source-order"
|
|
20
22
|
},
|
|
21
23
|
"devDependencies": {
|
package/src/PlugNmeet.ts
ADDED
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import { prepareAPI, sendRequest } from './api';
|
|
2
|
+
import { CreateRoomParams, CreateRoomResponse } from './types/createRoom';
|
|
3
|
+
import { JoinTokenParams, JoinTokenResponse } from './types/joinToken';
|
|
4
|
+
import { IsRoomActiveParams, IsRoomActiveResponse } from './types/isRoomActive';
|
|
5
|
+
import {
|
|
6
|
+
ActiveRoomInfoParams,
|
|
7
|
+
ActiveRoomInfoResponse,
|
|
8
|
+
} from './types/activeRoomInfo';
|
|
9
|
+
import { ActiveRoomsInfoResponse } from './types/activeRoomsInfo';
|
|
10
|
+
import { EndRoomParams, EndRoomResponse } from './types/endRoom';
|
|
11
|
+
import {
|
|
12
|
+
FetchRecordingsParams,
|
|
13
|
+
FetchRecordingsResponse,
|
|
14
|
+
} from './types/fetchRecordings';
|
|
15
|
+
import {
|
|
16
|
+
DeleteRecordingsParams,
|
|
17
|
+
DeleteRecordingsResponse,
|
|
18
|
+
} from './types/deleteRecordings';
|
|
19
|
+
import {
|
|
20
|
+
RecordingDownloadTokenParams,
|
|
21
|
+
RecordingDownloadTokenResponse,
|
|
22
|
+
} from './types/RecordingDownloadToken';
|
|
23
|
+
import { ClientFilesResponse } from './types/clientFiles';
|
|
24
|
+
|
|
25
|
+
export class PlugNmeet {
|
|
26
|
+
protected defaultPath = '/auth';
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @param serverUrl plugNmeet server URL
|
|
30
|
+
* @param apiKey plugNmeet API_Key
|
|
31
|
+
* @param apiSecret plugNmeet API_Secret
|
|
32
|
+
*/
|
|
33
|
+
constructor(serverUrl: string, apiKey: string, apiSecret: string) {
|
|
34
|
+
prepareAPI(serverUrl + this.defaultPath, apiKey, apiSecret);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Create new room
|
|
39
|
+
* @param params: CreateRoomParams
|
|
40
|
+
* @returns Promise<CreateRoomResponse>
|
|
41
|
+
*/
|
|
42
|
+
public async createRoom(
|
|
43
|
+
params: CreateRoomParams,
|
|
44
|
+
): Promise<CreateRoomResponse> {
|
|
45
|
+
const output = await sendRequest('/room/create', params);
|
|
46
|
+
if (!output.status) {
|
|
47
|
+
return {
|
|
48
|
+
status: false,
|
|
49
|
+
msg: output.response,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return {
|
|
54
|
+
status: output.response.status,
|
|
55
|
+
msg: output.response.msg,
|
|
56
|
+
roomInfo: output.response.roomInfo,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Generate join token
|
|
62
|
+
* @param params: JoinTokenParams
|
|
63
|
+
* @returns Promise<JoinTokenResponse>
|
|
64
|
+
*/
|
|
65
|
+
public async getJoinToken(
|
|
66
|
+
params: JoinTokenParams,
|
|
67
|
+
): Promise<JoinTokenResponse> {
|
|
68
|
+
const output = await sendRequest('/room/getJoinToken', params);
|
|
69
|
+
if (!output.status) {
|
|
70
|
+
return {
|
|
71
|
+
status: false,
|
|
72
|
+
msg: output.response,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return {
|
|
77
|
+
status: output.response.status,
|
|
78
|
+
msg: output.response.msg,
|
|
79
|
+
token: output.response.token,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* If room is active or not
|
|
85
|
+
* @param params: IsRoomActiveParams
|
|
86
|
+
* @returns Promise<IsRoomActiveResponse>
|
|
87
|
+
*/
|
|
88
|
+
public async isRoomActive(
|
|
89
|
+
params: IsRoomActiveParams,
|
|
90
|
+
): Promise<IsRoomActiveResponse> {
|
|
91
|
+
const output = await sendRequest('/room/isRoomActive', params);
|
|
92
|
+
if (!output.status) {
|
|
93
|
+
return {
|
|
94
|
+
status: false,
|
|
95
|
+
msg: output.response,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return {
|
|
100
|
+
status: output.response.status,
|
|
101
|
+
msg: output.response.msg,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Get active room information
|
|
107
|
+
* @param params: ActiveRoomInfoParams
|
|
108
|
+
* @returns Promise<ActiveRoomInfoResponse>
|
|
109
|
+
*/
|
|
110
|
+
public async getActiveRoomInfo(
|
|
111
|
+
params: ActiveRoomInfoParams,
|
|
112
|
+
): Promise<ActiveRoomInfoResponse> {
|
|
113
|
+
const output = await sendRequest('/room/getActiveRoomInfo', params);
|
|
114
|
+
if (!output.status) {
|
|
115
|
+
return {
|
|
116
|
+
status: false,
|
|
117
|
+
msg: output.response,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return {
|
|
122
|
+
status: output.response.status,
|
|
123
|
+
msg: output.response.msg,
|
|
124
|
+
room: output.response.room,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Get all active rooms
|
|
130
|
+
* @returns Promise<ActiveRoomsInfoResponse>
|
|
131
|
+
*/
|
|
132
|
+
public async getActiveRoomsInfo(): Promise<ActiveRoomsInfoResponse> {
|
|
133
|
+
const output = await sendRequest('/room/getActiveRoomsInfo', {});
|
|
134
|
+
if (!output.status) {
|
|
135
|
+
return {
|
|
136
|
+
status: false,
|
|
137
|
+
msg: output.response,
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return {
|
|
142
|
+
status: output.response.status,
|
|
143
|
+
msg: output.response.msg,
|
|
144
|
+
rooms: output.response.rooms,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* End active room
|
|
150
|
+
* @param params: EndRoomParams
|
|
151
|
+
* @returns Promise<EndRoomResponse>
|
|
152
|
+
*/
|
|
153
|
+
public async endRoom(params: EndRoomParams): Promise<EndRoomResponse> {
|
|
154
|
+
const output = await sendRequest('/room/endRoom', params);
|
|
155
|
+
if (!output.status) {
|
|
156
|
+
return {
|
|
157
|
+
status: false,
|
|
158
|
+
msg: output.response,
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return {
|
|
163
|
+
status: output.response.status,
|
|
164
|
+
msg: output.response.msg,
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Fetch recordings
|
|
170
|
+
* @param params: FetchRecordingsParams
|
|
171
|
+
* @returns Promise<FetchRecordingsResponse>
|
|
172
|
+
*/
|
|
173
|
+
public async fetchRecordings(
|
|
174
|
+
params: FetchRecordingsParams,
|
|
175
|
+
): Promise<FetchRecordingsResponse> {
|
|
176
|
+
const output = await sendRequest('/recording/fetch', params);
|
|
177
|
+
if (!output.status) {
|
|
178
|
+
return {
|
|
179
|
+
status: false,
|
|
180
|
+
msg: output.response,
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
return {
|
|
185
|
+
status: output.response.status,
|
|
186
|
+
msg: output.response.msg,
|
|
187
|
+
result: output.response.result,
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Delete recording
|
|
193
|
+
* @param params: DeleteRecordingsParams
|
|
194
|
+
* @returns Promise<DeleteRecordingsResponse>
|
|
195
|
+
*/
|
|
196
|
+
public async deleteRecordings(
|
|
197
|
+
params: DeleteRecordingsParams,
|
|
198
|
+
): Promise<DeleteRecordingsResponse> {
|
|
199
|
+
const output = await sendRequest('/recording/delete', params);
|
|
200
|
+
if (!output.status) {
|
|
201
|
+
return {
|
|
202
|
+
status: false,
|
|
203
|
+
msg: output.response,
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
return {
|
|
208
|
+
status: output.response.status,
|
|
209
|
+
msg: output.response.msg,
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* @returns Promise<ClientFilesResponse>
|
|
215
|
+
*/
|
|
216
|
+
public async getClientFiles(): Promise<ClientFilesResponse> {
|
|
217
|
+
const output = await sendRequest('/getClientFiles', {});
|
|
218
|
+
if (!output.status) {
|
|
219
|
+
return {
|
|
220
|
+
status: false,
|
|
221
|
+
msg: output.response,
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
return {
|
|
226
|
+
status: output.response.status,
|
|
227
|
+
msg: output.response.msg,
|
|
228
|
+
css: output.response.css,
|
|
229
|
+
js: output.response.js,
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Generate token to download recording
|
|
235
|
+
* @param params: RecordingDownloadTokenParams
|
|
236
|
+
* @returns Promise<RecordingDownloadTokenResponse>
|
|
237
|
+
*/
|
|
238
|
+
public async getRecordingDownloadToken(
|
|
239
|
+
params: RecordingDownloadTokenParams,
|
|
240
|
+
): Promise<RecordingDownloadTokenResponse> {
|
|
241
|
+
const output = await sendRequest('/recording/getDownloadToken', params);
|
|
242
|
+
if (!output.status) {
|
|
243
|
+
return {
|
|
244
|
+
status: false,
|
|
245
|
+
msg: output.response,
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
return {
|
|
250
|
+
status: output.response.status,
|
|
251
|
+
msg: output.response.msg,
|
|
252
|
+
token: output.response.token,
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
}
|
package/src/api.ts
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import http from 'http';
|
|
2
|
+
import https, { RequestOptions } from 'https';
|
|
3
|
+
import { createHmac } from 'crypto';
|
|
4
|
+
|
|
5
|
+
let mainOptions: RequestOptions,
|
|
6
|
+
isSecure = true, _apiKey = "", _apiSecret = "";
|
|
7
|
+
|
|
8
|
+
export type APIResponse = {
|
|
9
|
+
status: boolean;
|
|
10
|
+
response: any;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const prepareAPI = (
|
|
14
|
+
apiEndPointURL: string,
|
|
15
|
+
apiKey: string,
|
|
16
|
+
apiSecret: string,
|
|
17
|
+
) => {
|
|
18
|
+
_apiKey = apiKey;
|
|
19
|
+
_apiSecret = apiSecret;
|
|
20
|
+
|
|
21
|
+
const url = new URL(apiEndPointURL);
|
|
22
|
+
let port = url.protocol === 'https:' ? 443 : 80;
|
|
23
|
+
isSecure = url.protocol === 'https:' ?? false;
|
|
24
|
+
|
|
25
|
+
// use port if supplied with url
|
|
26
|
+
if (url.port) {
|
|
27
|
+
port = Number(url.port);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
mainOptions = {
|
|
31
|
+
hostname: url.hostname,
|
|
32
|
+
path: url.pathname,
|
|
33
|
+
method: 'POST',
|
|
34
|
+
port,
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const prepareHeader = (body: string) => {
|
|
39
|
+
const signature = createHmac('sha256', _apiSecret)
|
|
40
|
+
.update(body)
|
|
41
|
+
.digest('hex');
|
|
42
|
+
|
|
43
|
+
const headers = {
|
|
44
|
+
'Content-Type': 'application/json',
|
|
45
|
+
'API-KEY': _apiKey,
|
|
46
|
+
'HASH-SIGNATURE': signature,
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
return headers;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export const sendRequest = async (path: string, body: any) => {
|
|
53
|
+
return new Promise<APIResponse>((resolve) => {
|
|
54
|
+
const output: APIResponse = {
|
|
55
|
+
status: false,
|
|
56
|
+
response: undefined,
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const chunk = JSON.stringify(body);
|
|
60
|
+
|
|
61
|
+
const options = { ...mainOptions };
|
|
62
|
+
options.path += path;
|
|
63
|
+
options.headers = prepareHeader(chunk);
|
|
64
|
+
|
|
65
|
+
const req = (isSecure ? https : http).request(options, (res) => {
|
|
66
|
+
const body: Array<Uint8Array> = [];
|
|
67
|
+
res.on('data', (chunk) => body.push(chunk));
|
|
68
|
+
|
|
69
|
+
res.on('end', () => {
|
|
70
|
+
const resString = Buffer.concat(body).toString();
|
|
71
|
+
|
|
72
|
+
try {
|
|
73
|
+
output.status = true;
|
|
74
|
+
output.response = JSON.parse(resString);
|
|
75
|
+
} catch (error) {
|
|
76
|
+
output.status = false;
|
|
77
|
+
output.response = error;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
resolve(output);
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
req.on('error', (error) => {
|
|
85
|
+
output.response = error.message;
|
|
86
|
+
resolve(output);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
req.write(chunk);
|
|
90
|
+
req.end();
|
|
91
|
+
});
|
|
92
|
+
};
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export {
|
|
2
|
+
RooMetadata,
|
|
3
|
+
CreateRoomParams,
|
|
4
|
+
CreateRoomResponse,
|
|
5
|
+
CreateRoomResponseRoomInfo,
|
|
6
|
+
LockSettingsParams,
|
|
7
|
+
RoomFeaturesParams,
|
|
8
|
+
RecordingFeaturesParams,
|
|
9
|
+
ChatFeaturesParams,
|
|
10
|
+
SharedNotePadFeaturesParams,
|
|
11
|
+
WhiteboardFeaturesParams,
|
|
12
|
+
ExternalMediaPlayerFeatures,
|
|
13
|
+
WaitingRoomFeatures,
|
|
14
|
+
BreakoutRoomFeatures,
|
|
15
|
+
} from './types/createRoom';
|
|
16
|
+
export {
|
|
17
|
+
JoinTokenParams,
|
|
18
|
+
JoinTokenResponse,
|
|
19
|
+
JoinTokenUserMetadata,
|
|
20
|
+
JoinTokenUserInfo,
|
|
21
|
+
} from './types/joinToken';
|
|
22
|
+
export { IsRoomActiveParams, IsRoomActiveResponse } from './types/isRoomActive';
|
|
23
|
+
export {
|
|
24
|
+
Room,
|
|
25
|
+
ActiveRoomInfoParams,
|
|
26
|
+
ActiveRoomInfoResponse,
|
|
27
|
+
ParticipantInfo,
|
|
28
|
+
ActiveRoomInfo,
|
|
29
|
+
} from './types/activeRoomInfo';
|
|
30
|
+
export { ActiveRoomsInfoResponse } from './types/activeRoomsInfo';
|
|
31
|
+
export { EndRoomParams, EndRoomResponse } from './types/endRoom';
|
|
32
|
+
export {
|
|
33
|
+
FetchRecordingsParams,
|
|
34
|
+
FetchRecordingsResponse,
|
|
35
|
+
FetchRecordingsResult,
|
|
36
|
+
RecordingInfo,
|
|
37
|
+
} from './types/fetchRecordings';
|
|
38
|
+
export {
|
|
39
|
+
DeleteRecordingsParams,
|
|
40
|
+
DeleteRecordingsResponse,
|
|
41
|
+
} from './types/deleteRecordings';
|
|
42
|
+
export {
|
|
43
|
+
RecordingDownloadTokenParams,
|
|
44
|
+
RecordingDownloadTokenResponse,
|
|
45
|
+
} from './types/RecordingDownloadToken';
|
|
46
|
+
export { ClientFilesResponse } from './types/clientFiles';
|
|
47
|
+
|
|
48
|
+
export { PlugNmeet } from './PlugNmeet';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export type ActiveRoomInfoParams = {
|
|
2
|
+
room_id: string;
|
|
3
|
+
};
|
|
4
|
+
|
|
5
|
+
export type ActiveRoomInfoResponse = {
|
|
6
|
+
status: boolean;
|
|
7
|
+
msg: string;
|
|
8
|
+
room?: Room;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export type Room = {
|
|
12
|
+
room_info: ActiveRoomInfo;
|
|
13
|
+
participants_info: Array<ParticipantInfo>;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type ActiveRoomInfo = {
|
|
17
|
+
room_title: string;
|
|
18
|
+
room_id: string;
|
|
19
|
+
sid: string;
|
|
20
|
+
joined_participants: number;
|
|
21
|
+
is_running: boolean;
|
|
22
|
+
is_recording: boolean;
|
|
23
|
+
is_active_rtmp: boolean;
|
|
24
|
+
webhook_url: string;
|
|
25
|
+
creation_time: number;
|
|
26
|
+
metadata: string;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export type ParticipantInfo = {
|
|
30
|
+
sid: string;
|
|
31
|
+
identity: string;
|
|
32
|
+
state: string;
|
|
33
|
+
metadata: string;
|
|
34
|
+
joined_at: number;
|
|
35
|
+
name: string;
|
|
36
|
+
version: number;
|
|
37
|
+
permission: any;
|
|
38
|
+
};
|