plugnmeet-sdk-js 1.2.1 → 1.2.3
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/dist/PlugNmeet.js +184 -137
- package/dist/PlugNmeet.js.map +1 -1
- package/dist/index.d.ts +280 -11
- package/dist/index.d.ts.map +1 -0
- package/dist/main.js +248 -0
- package/dist/main.js.map +1 -0
- package/dist/module.js +241 -0
- package/dist/module.js.map +1 -0
- package/package.json +28 -21
- package/dist/PlugNmeet.d.ts +0 -76
- package/dist/api.d.ts +0 -6
- package/dist/api.js +0 -67
- package/dist/api.js.map +0 -1
- package/dist/cjs/PlugNmeet.d.ts +0 -76
- package/dist/cjs/PlugNmeet.js +0 -231
- package/dist/cjs/PlugNmeet.js.map +0 -1
- package/dist/cjs/api.d.ts +0 -6
- package/dist/cjs/api.js +0 -85
- package/dist/cjs/api.js.map +0 -1
- package/dist/cjs/index.d.ts +0 -11
- package/dist/cjs/index.js +0 -6
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/types/RecordingDownloadToken.d.ts +0 -8
- package/dist/cjs/types/RecordingDownloadToken.js +0 -3
- package/dist/cjs/types/RecordingDownloadToken.js.map +0 -1
- package/dist/cjs/types/activeRoomInfo.d.ts +0 -34
- package/dist/cjs/types/activeRoomInfo.js +0 -3
- package/dist/cjs/types/activeRoomInfo.js.map +0 -1
- package/dist/cjs/types/activeRoomsInfo.d.ts +0 -6
- package/dist/cjs/types/activeRoomsInfo.js +0 -3
- package/dist/cjs/types/activeRoomsInfo.js.map +0 -1
- package/dist/cjs/types/clientFiles.d.ts +0 -6
- package/dist/cjs/types/clientFiles.js +0 -3
- package/dist/cjs/types/clientFiles.js.map +0 -1
- package/dist/cjs/types/createRoom.d.ts +0 -82
- package/dist/cjs/types/createRoom.js +0 -3
- package/dist/cjs/types/createRoom.js.map +0 -1
- package/dist/cjs/types/deleteRecordings.d.ts +0 -7
- package/dist/cjs/types/deleteRecordings.js +0 -3
- package/dist/cjs/types/deleteRecordings.js.map +0 -1
- package/dist/cjs/types/endRoom.d.ts +0 -7
- package/dist/cjs/types/endRoom.js +0 -3
- package/dist/cjs/types/endRoom.js.map +0 -1
- package/dist/cjs/types/fetchRecordings.d.ts +0 -27
- package/dist/cjs/types/fetchRecordings.js +0 -3
- package/dist/cjs/types/fetchRecordings.js.map +0 -1
- package/dist/cjs/types/isRoomActive.d.ts +0 -7
- package/dist/cjs/types/isRoomActive.js +0 -3
- package/dist/cjs/types/isRoomActive.js.map +0 -1
- package/dist/cjs/types/joinToken.d.ts +0 -21
- package/dist/cjs/types/joinToken.js +0 -3
- package/dist/cjs/types/joinToken.js.map +0 -1
- package/dist/index.js +0 -2
- package/dist/index.js.map +0 -1
- package/dist/types/RecordingDownloadToken.d.ts +0 -8
- package/dist/types/RecordingDownloadToken.js +0 -2
- package/dist/types/RecordingDownloadToken.js.map +0 -1
- package/dist/types/activeRoomInfo.d.ts +0 -34
- package/dist/types/activeRoomInfo.js +0 -2
- package/dist/types/activeRoomInfo.js.map +0 -1
- package/dist/types/activeRoomsInfo.d.ts +0 -6
- package/dist/types/activeRoomsInfo.js +0 -2
- package/dist/types/activeRoomsInfo.js.map +0 -1
- package/dist/types/clientFiles.d.ts +0 -6
- package/dist/types/clientFiles.js +0 -2
- package/dist/types/clientFiles.js.map +0 -1
- package/dist/types/createRoom.d.ts +0 -82
- package/dist/types/createRoom.js +0 -2
- package/dist/types/createRoom.js.map +0 -1
- package/dist/types/deleteRecordings.d.ts +0 -7
- package/dist/types/deleteRecordings.js +0 -2
- package/dist/types/deleteRecordings.js.map +0 -1
- package/dist/types/endRoom.d.ts +0 -7
- package/dist/types/endRoom.js +0 -2
- package/dist/types/endRoom.js.map +0 -1
- package/dist/types/fetchRecordings.d.ts +0 -27
- package/dist/types/fetchRecordings.js +0 -2
- package/dist/types/fetchRecordings.js.map +0 -1
- package/dist/types/isRoomActive.d.ts +0 -7
- package/dist/types/isRoomActive.js +0 -2
- package/dist/types/isRoomActive.js.map +0 -1
- package/dist/types/joinToken.d.ts +0 -21
- package/dist/types/joinToken.js +0 -2
- package/dist/types/joinToken.js.map +0 -1
- package/src/PlugNmeet.ts +0 -255
- package/src/api.ts +0 -92
- package/src/index.ts +0 -48
- package/src/types/RecordingDownloadToken.ts +0 -9
- package/src/types/activeRoomInfo.ts +0 -38
- package/src/types/activeRoomsInfo.ts +0 -7
- package/src/types/clientFiles.ts +0 -6
- package/src/types/createRoom.ts +0 -94
- package/src/types/deleteRecordings.ts +0 -8
- package/src/types/endRoom.ts +0 -8
- package/src/types/fetchRecordings.ts +0 -30
- package/src/types/isRoomActive.ts +0 -8
- package/src/types/joinToken.ts +0 -25
package/README.md
CHANGED
package/dist/PlugNmeet.js
CHANGED
|
@@ -1,198 +1,245 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
var $d6kgz$http = require("http");
|
|
2
|
+
var $d6kgz$https = require("https");
|
|
3
|
+
var $d6kgz$crypto = require("crypto");
|
|
4
|
+
|
|
5
|
+
function $parcel$export(e, n, v, s) {
|
|
6
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
7
|
+
}
|
|
8
|
+
function $parcel$interopDefault(a) {
|
|
9
|
+
return a && a.__esModule ? a.default : a;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
$parcel$export(module.exports, "PlugNmeet", () => $8e30a24c4952589a$export$1402da7f2870faee);
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
let $9f73057a20513a82$var$mainOptions, $9f73057a20513a82$var$isSecure = true, $9f73057a20513a82$var$_apiKey = "", $9f73057a20513a82$var$_apiSecret = "";
|
|
17
|
+
const $9f73057a20513a82$export$84c28a9528d0e9cd = (apiEndPointURL, apiKey, apiSecret)=>{
|
|
18
|
+
$9f73057a20513a82$var$_apiKey = apiKey;
|
|
19
|
+
$9f73057a20513a82$var$_apiSecret = apiSecret;
|
|
20
|
+
const url = new URL(apiEndPointURL);
|
|
21
|
+
let port = url.protocol === "https:" ? 443 : 80;
|
|
22
|
+
$9f73057a20513a82$var$isSecure = (url.protocol === "https:") ?? false;
|
|
23
|
+
// use port if supplied with url
|
|
24
|
+
if (url.port) port = Number(url.port);
|
|
25
|
+
$9f73057a20513a82$var$mainOptions = {
|
|
26
|
+
hostname: url.hostname,
|
|
27
|
+
path: url.pathname,
|
|
28
|
+
method: "POST",
|
|
29
|
+
port: port
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
const $9f73057a20513a82$var$prepareHeader = (body)=>{
|
|
33
|
+
const signature = (0, $d6kgz$crypto.createHmac)("sha256", $9f73057a20513a82$var$_apiSecret).update(body).digest("hex");
|
|
34
|
+
const headers = {
|
|
35
|
+
"Content-Type": "application/json",
|
|
36
|
+
"API-KEY": $9f73057a20513a82$var$_apiKey,
|
|
37
|
+
"HASH-SIGNATURE": signature
|
|
38
|
+
};
|
|
39
|
+
return headers;
|
|
40
|
+
};
|
|
41
|
+
const $9f73057a20513a82$export$d5a1e65f8aa21b51 = async (path, body)=>{
|
|
42
|
+
return new Promise((resolve)=>{
|
|
43
|
+
const output = {
|
|
44
|
+
status: false,
|
|
45
|
+
response: undefined
|
|
46
|
+
};
|
|
47
|
+
const chunk = JSON.stringify(body);
|
|
48
|
+
const options = {
|
|
49
|
+
...$9f73057a20513a82$var$mainOptions
|
|
50
|
+
};
|
|
51
|
+
options.path += path;
|
|
52
|
+
options.headers = $9f73057a20513a82$var$prepareHeader(chunk);
|
|
53
|
+
const req = ($9f73057a20513a82$var$isSecure ? (0, ($parcel$interopDefault($d6kgz$https))) : (0, ($parcel$interopDefault($d6kgz$http)))).request(options, (res)=>{
|
|
54
|
+
const body = [];
|
|
55
|
+
res.on("data", (chunk)=>body.push(chunk));
|
|
56
|
+
res.on("end", ()=>{
|
|
57
|
+
const resString = Buffer.concat(body).toString();
|
|
58
|
+
try {
|
|
59
|
+
output.status = true;
|
|
60
|
+
output.response = JSON.parse(resString);
|
|
61
|
+
} catch (error) {
|
|
62
|
+
output.status = false;
|
|
63
|
+
output.response = error;
|
|
64
|
+
}
|
|
65
|
+
resolve(output);
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
req.on("error", (error)=>{
|
|
69
|
+
output.response = error.message;
|
|
70
|
+
resolve(output);
|
|
71
|
+
});
|
|
72
|
+
req.write(chunk);
|
|
73
|
+
req.end();
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
class $8e30a24c4952589a$export$1402da7f2870faee {
|
|
79
|
+
defaultPath = "/auth";
|
|
3
80
|
/**
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
this.defaultPath = '/auth';
|
|
10
|
-
prepareAPI(serverUrl + this.defaultPath, apiKey, apiSecret);
|
|
81
|
+
* @param serverUrl plugNmeet server URL
|
|
82
|
+
* @param apiKey plugNmeet API_Key
|
|
83
|
+
* @param apiSecret plugNmeet API_Secret
|
|
84
|
+
*/ constructor(serverUrl, apiKey, apiSecret){
|
|
85
|
+
(0, $9f73057a20513a82$export$84c28a9528d0e9cd)(serverUrl + this.defaultPath, apiKey, apiSecret);
|
|
11
86
|
}
|
|
12
87
|
/**
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
msg: output.response,
|
|
23
|
-
};
|
|
24
|
-
}
|
|
88
|
+
* Create new room
|
|
89
|
+
* @param params: CreateRoomParams
|
|
90
|
+
* @returns Promise<CreateRoomResponse>
|
|
91
|
+
*/ async createRoom(params) {
|
|
92
|
+
const output = await (0, $9f73057a20513a82$export$d5a1e65f8aa21b51)("/room/create", params);
|
|
93
|
+
if (!output.status) return {
|
|
94
|
+
status: false,
|
|
95
|
+
msg: output.response
|
|
96
|
+
};
|
|
25
97
|
return {
|
|
26
98
|
status: output.response.status,
|
|
27
99
|
msg: output.response.msg,
|
|
28
|
-
roomInfo: output.response.roomInfo
|
|
100
|
+
roomInfo: output.response.roomInfo
|
|
29
101
|
};
|
|
30
102
|
}
|
|
31
103
|
/**
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
msg: output.response,
|
|
42
|
-
};
|
|
43
|
-
}
|
|
104
|
+
* Generate join token
|
|
105
|
+
* @param params: JoinTokenParams
|
|
106
|
+
* @returns Promise<JoinTokenResponse>
|
|
107
|
+
*/ async getJoinToken(params) {
|
|
108
|
+
const output = await (0, $9f73057a20513a82$export$d5a1e65f8aa21b51)("/room/getJoinToken", params);
|
|
109
|
+
if (!output.status) return {
|
|
110
|
+
status: false,
|
|
111
|
+
msg: output.response
|
|
112
|
+
};
|
|
44
113
|
return {
|
|
45
114
|
status: output.response.status,
|
|
46
115
|
msg: output.response.msg,
|
|
47
|
-
token: output.response.token
|
|
116
|
+
token: output.response.token
|
|
48
117
|
};
|
|
49
118
|
}
|
|
50
119
|
/**
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
msg: output.response,
|
|
61
|
-
};
|
|
62
|
-
}
|
|
120
|
+
* If room is active or not
|
|
121
|
+
* @param params: IsRoomActiveParams
|
|
122
|
+
* @returns Promise<IsRoomActiveResponse>
|
|
123
|
+
*/ async isRoomActive(params) {
|
|
124
|
+
const output = await (0, $9f73057a20513a82$export$d5a1e65f8aa21b51)("/room/isRoomActive", params);
|
|
125
|
+
if (!output.status) return {
|
|
126
|
+
status: false,
|
|
127
|
+
msg: output.response
|
|
128
|
+
};
|
|
63
129
|
return {
|
|
64
130
|
status: output.response.status,
|
|
65
|
-
msg: output.response.msg
|
|
131
|
+
msg: output.response.msg
|
|
66
132
|
};
|
|
67
133
|
}
|
|
68
134
|
/**
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
msg: output.response,
|
|
79
|
-
};
|
|
80
|
-
}
|
|
135
|
+
* Get active room information
|
|
136
|
+
* @param params: ActiveRoomInfoParams
|
|
137
|
+
* @returns Promise<ActiveRoomInfoResponse>
|
|
138
|
+
*/ async getActiveRoomInfo(params) {
|
|
139
|
+
const output = await (0, $9f73057a20513a82$export$d5a1e65f8aa21b51)("/room/getActiveRoomInfo", params);
|
|
140
|
+
if (!output.status) return {
|
|
141
|
+
status: false,
|
|
142
|
+
msg: output.response
|
|
143
|
+
};
|
|
81
144
|
return {
|
|
82
145
|
status: output.response.status,
|
|
83
146
|
msg: output.response.msg,
|
|
84
|
-
room: output.response.room
|
|
147
|
+
room: output.response.room
|
|
85
148
|
};
|
|
86
149
|
}
|
|
87
150
|
/**
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
msg: output.response,
|
|
97
|
-
};
|
|
98
|
-
}
|
|
151
|
+
* Get all active rooms
|
|
152
|
+
* @returns Promise<ActiveRoomsInfoResponse>
|
|
153
|
+
*/ async getActiveRoomsInfo() {
|
|
154
|
+
const output = await (0, $9f73057a20513a82$export$d5a1e65f8aa21b51)("/room/getActiveRoomsInfo", {});
|
|
155
|
+
if (!output.status) return {
|
|
156
|
+
status: false,
|
|
157
|
+
msg: output.response
|
|
158
|
+
};
|
|
99
159
|
return {
|
|
100
160
|
status: output.response.status,
|
|
101
161
|
msg: output.response.msg,
|
|
102
|
-
rooms: output.response.rooms
|
|
162
|
+
rooms: output.response.rooms
|
|
103
163
|
};
|
|
104
164
|
}
|
|
105
165
|
/**
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
msg: output.response,
|
|
116
|
-
};
|
|
117
|
-
}
|
|
166
|
+
* End active room
|
|
167
|
+
* @param params: EndRoomParams
|
|
168
|
+
* @returns Promise<EndRoomResponse>
|
|
169
|
+
*/ async endRoom(params) {
|
|
170
|
+
const output = await (0, $9f73057a20513a82$export$d5a1e65f8aa21b51)("/room/endRoom", params);
|
|
171
|
+
if (!output.status) return {
|
|
172
|
+
status: false,
|
|
173
|
+
msg: output.response
|
|
174
|
+
};
|
|
118
175
|
return {
|
|
119
176
|
status: output.response.status,
|
|
120
|
-
msg: output.response.msg
|
|
177
|
+
msg: output.response.msg
|
|
121
178
|
};
|
|
122
179
|
}
|
|
123
180
|
/**
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
msg: output.response,
|
|
134
|
-
};
|
|
135
|
-
}
|
|
181
|
+
* Fetch recordings
|
|
182
|
+
* @param params: FetchRecordingsParams
|
|
183
|
+
* @returns Promise<FetchRecordingsResponse>
|
|
184
|
+
*/ async fetchRecordings(params) {
|
|
185
|
+
const output = await (0, $9f73057a20513a82$export$d5a1e65f8aa21b51)("/recording/fetch", params);
|
|
186
|
+
if (!output.status) return {
|
|
187
|
+
status: false,
|
|
188
|
+
msg: output.response
|
|
189
|
+
};
|
|
136
190
|
return {
|
|
137
191
|
status: output.response.status,
|
|
138
192
|
msg: output.response.msg,
|
|
139
|
-
result: output.response.result
|
|
193
|
+
result: output.response.result
|
|
140
194
|
};
|
|
141
195
|
}
|
|
142
196
|
/**
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
msg: output.response,
|
|
153
|
-
};
|
|
154
|
-
}
|
|
197
|
+
* Delete recording
|
|
198
|
+
* @param params: DeleteRecordingsParams
|
|
199
|
+
* @returns Promise<DeleteRecordingsResponse>
|
|
200
|
+
*/ async deleteRecordings(params) {
|
|
201
|
+
const output = await (0, $9f73057a20513a82$export$d5a1e65f8aa21b51)("/recording/delete", params);
|
|
202
|
+
if (!output.status) return {
|
|
203
|
+
status: false,
|
|
204
|
+
msg: output.response
|
|
205
|
+
};
|
|
155
206
|
return {
|
|
156
207
|
status: output.response.status,
|
|
157
|
-
msg: output.response.msg
|
|
208
|
+
msg: output.response.msg
|
|
158
209
|
};
|
|
159
210
|
}
|
|
160
211
|
/**
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
msg: output.response,
|
|
169
|
-
};
|
|
170
|
-
}
|
|
212
|
+
* @returns Promise<ClientFilesResponse>
|
|
213
|
+
*/ async getClientFiles() {
|
|
214
|
+
const output = await (0, $9f73057a20513a82$export$d5a1e65f8aa21b51)("/getClientFiles", {});
|
|
215
|
+
if (!output.status) return {
|
|
216
|
+
status: false,
|
|
217
|
+
msg: output.response
|
|
218
|
+
};
|
|
171
219
|
return {
|
|
172
220
|
status: output.response.status,
|
|
173
221
|
msg: output.response.msg,
|
|
174
222
|
css: output.response.css,
|
|
175
|
-
js: output.response.js
|
|
223
|
+
js: output.response.js
|
|
176
224
|
};
|
|
177
225
|
}
|
|
178
226
|
/**
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
msg: output.response,
|
|
189
|
-
};
|
|
190
|
-
}
|
|
227
|
+
* Generate token to download recording
|
|
228
|
+
* @param params: RecordingDownloadTokenParams
|
|
229
|
+
* @returns Promise<RecordingDownloadTokenResponse>
|
|
230
|
+
*/ async getRecordingDownloadToken(params) {
|
|
231
|
+
const output = await (0, $9f73057a20513a82$export$d5a1e65f8aa21b51)("/recording/getDownloadToken", params);
|
|
232
|
+
if (!output.status) return {
|
|
233
|
+
status: false,
|
|
234
|
+
msg: output.response
|
|
235
|
+
};
|
|
191
236
|
return {
|
|
192
237
|
status: output.response.status,
|
|
193
238
|
msg: output.response.msg,
|
|
194
|
-
token: output.response.token
|
|
239
|
+
token: output.response.token
|
|
195
240
|
};
|
|
196
241
|
}
|
|
197
242
|
}
|
|
198
|
-
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
//# sourceMappingURL=PlugNmeet.js.map
|
package/dist/PlugNmeet.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlugNmeet.js","sourceRoot":"","sources":["../src/PlugNmeet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAwBhD,MAAM,OAAO,SAAS;IAGpB;;;;OAIG;IACH,YAAY,SAAiB,EAAE,MAAc,EAAE,SAAiB;QAPtD,gBAAW,GAAG,OAAO,CAAC;QAQ9B,UAAU,CAAC,SAAS,GAAG,IAAI,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;IAC9D,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,UAAU,CACrB,MAAwB;QAExB,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;QACzD,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;YAClB,OAAO;gBACL,MAAM,EAAE,KAAK;gBACb,GAAG,EAAE,MAAM,CAAC,QAAQ;aACrB,CAAC;SACH;QAED,OAAO;YACL,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM;YAC9B,GAAG,EAAE,MAAM,CAAC,QAAQ,CAAC,GAAG;YACxB,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC,QAAQ;SACnC,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,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+BAA+B;QAChE,IAAI,CAAC,OAAO,MAAM,EAChB,OAAO;YACL,QAAQ,KAAK;YACb,KAAK,OAAO,QAAQ;QACtB;QAGF,OAAO;YACL,QAAQ,OAAO,QAAQ,CAAC,MAAM;YAC9B,KAAK,OAAO,QAAQ,CAAC,GAAG;YACxB,OAAO,OAAO,QAAQ,CAAC,KAAK;QAC9B;IACF;AACF","sources":["src/PlugNmeet.ts","src/api.ts"],"sourcesContent":["import { prepareAPI, sendRequest } from './api';\nimport { CreateRoomParams, CreateRoomResponse } from './types/createRoom';\nimport { JoinTokenParams, JoinTokenResponse } from './types/joinToken';\nimport { IsRoomActiveParams, IsRoomActiveResponse } from './types/isRoomActive';\nimport {\n ActiveRoomInfoParams,\n ActiveRoomInfoResponse,\n} from './types/activeRoomInfo';\nimport { ActiveRoomsInfoResponse } from './types/activeRoomsInfo';\nimport { EndRoomParams, EndRoomResponse } from './types/endRoom';\nimport {\n FetchRecordingsParams,\n FetchRecordingsResponse,\n} from './types/fetchRecordings';\nimport {\n DeleteRecordingsParams,\n DeleteRecordingsResponse,\n} from './types/deleteRecordings';\nimport {\n RecordingDownloadTokenParams,\n RecordingDownloadTokenResponse,\n} from './types/RecordingDownloadToken';\nimport { ClientFilesResponse } from './types/clientFiles';\n\nexport class PlugNmeet {\n protected defaultPath = '/auth';\n\n /**\n * @param serverUrl plugNmeet server URL\n * @param apiKey plugNmeet API_Key\n * @param apiSecret plugNmeet API_Secret\n */\n constructor(serverUrl: string, apiKey: string, apiSecret: string) {\n prepareAPI(serverUrl + this.defaultPath, apiKey, apiSecret);\n }\n\n /**\n * Create new room\n * @param params: CreateRoomParams\n * @returns Promise<CreateRoomResponse>\n */\n public async createRoom(\n params: CreateRoomParams,\n ): Promise<CreateRoomResponse> {\n const output = await sendRequest('/room/create', params);\n if (!output.status) {\n return {\n status: false,\n msg: output.response,\n };\n }\n\n return {\n status: output.response.status,\n msg: output.response.msg,\n roomInfo: output.response.roomInfo,\n };\n }\n\n /**\n * Generate join token\n * @param params: JoinTokenParams\n * @returns Promise<JoinTokenResponse>\n */\n public async getJoinToken(\n params: JoinTokenParams,\n ): Promise<JoinTokenResponse> {\n const output = await sendRequest('/room/getJoinToken', params);\n if (!output.status) {\n return {\n status: false,\n msg: output.response,\n };\n }\n\n return {\n status: output.response.status,\n msg: output.response.msg,\n token: output.response.token,\n };\n }\n\n /**\n * If room is active or not\n * @param params: IsRoomActiveParams\n * @returns Promise<IsRoomActiveResponse>\n */\n public async isRoomActive(\n params: IsRoomActiveParams,\n ): Promise<IsRoomActiveResponse> {\n const output = await sendRequest('/room/isRoomActive', params);\n if (!output.status) {\n return {\n status: false,\n msg: output.response,\n };\n }\n\n return {\n status: output.response.status,\n msg: output.response.msg,\n };\n }\n\n /**\n * Get active room information\n * @param params: ActiveRoomInfoParams\n * @returns Promise<ActiveRoomInfoResponse>\n */\n public async getActiveRoomInfo(\n params: ActiveRoomInfoParams,\n ): Promise<ActiveRoomInfoResponse> {\n const output = await sendRequest('/room/getActiveRoomInfo', params);\n if (!output.status) {\n return {\n status: false,\n msg: output.response,\n };\n }\n\n return {\n status: output.response.status,\n msg: output.response.msg,\n room: output.response.room,\n };\n }\n\n /**\n * Get all active rooms\n * @returns Promise<ActiveRoomsInfoResponse>\n */\n public async getActiveRoomsInfo(): Promise<ActiveRoomsInfoResponse> {\n const output = await sendRequest('/room/getActiveRoomsInfo', {});\n if (!output.status) {\n return {\n status: false,\n msg: output.response,\n };\n }\n\n return {\n status: output.response.status,\n msg: output.response.msg,\n rooms: output.response.rooms,\n };\n }\n\n /**\n * End active room\n * @param params: EndRoomParams\n * @returns Promise<EndRoomResponse>\n */\n public async endRoom(params: EndRoomParams): Promise<EndRoomResponse> {\n const output = await sendRequest('/room/endRoom', params);\n if (!output.status) {\n return {\n status: false,\n msg: output.response,\n };\n }\n\n return {\n status: output.response.status,\n msg: output.response.msg,\n };\n }\n\n /**\n * Fetch recordings\n * @param params: FetchRecordingsParams\n * @returns Promise<FetchRecordingsResponse>\n */\n public async fetchRecordings(\n params: FetchRecordingsParams,\n ): Promise<FetchRecordingsResponse> {\n const output = await sendRequest('/recording/fetch', params);\n if (!output.status) {\n return {\n status: false,\n msg: output.response,\n };\n }\n\n return {\n status: output.response.status,\n msg: output.response.msg,\n result: output.response.result,\n };\n }\n\n /**\n * Delete recording\n * @param params: DeleteRecordingsParams\n * @returns Promise<DeleteRecordingsResponse>\n */\n public async deleteRecordings(\n params: DeleteRecordingsParams,\n ): Promise<DeleteRecordingsResponse> {\n const output = await sendRequest('/recording/delete', params);\n if (!output.status) {\n return {\n status: false,\n msg: output.response,\n };\n }\n\n return {\n status: output.response.status,\n msg: output.response.msg,\n };\n }\n\n /**\n * @returns Promise<ClientFilesResponse>\n */\n public async getClientFiles(): Promise<ClientFilesResponse> {\n const output = await sendRequest('/getClientFiles', {});\n if (!output.status) {\n return {\n status: false,\n msg: output.response,\n };\n }\n\n return {\n status: output.response.status,\n msg: output.response.msg,\n css: output.response.css,\n js: output.response.js,\n };\n }\n\n /**\n * Generate token to download recording\n * @param params: RecordingDownloadTokenParams\n * @returns Promise<RecordingDownloadTokenResponse>\n */\n public async getRecordingDownloadToken(\n params: RecordingDownloadTokenParams,\n ): Promise<RecordingDownloadTokenResponse> {\n const output = await sendRequest('/recording/getDownloadToken', params);\n if (!output.status) {\n return {\n status: false,\n msg: output.response,\n };\n }\n\n return {\n status: output.response.status,\n msg: output.response.msg,\n token: output.response.token,\n };\n }\n}\n","import http from 'http';\nimport https, { RequestOptions } from 'https';\nimport { createHmac } from 'crypto';\n\nlet mainOptions: RequestOptions,\n isSecure = true, _apiKey = \"\", _apiSecret = \"\";\n\nexport type APIResponse = {\n status: boolean;\n response: any;\n};\n\nexport const prepareAPI = (\n apiEndPointURL: string,\n apiKey: string,\n apiSecret: string,\n) => {\n _apiKey = apiKey;\n _apiSecret = apiSecret;\n\n const url = new URL(apiEndPointURL);\n let port = url.protocol === 'https:' ? 443 : 80;\n isSecure = url.protocol === 'https:' ?? false;\n\n // use port if supplied with url\n if (url.port) {\n port = Number(url.port);\n }\n\n mainOptions = {\n hostname: url.hostname,\n path: url.pathname,\n method: 'POST',\n port,\n };\n};\n\nconst prepareHeader = (body: string) => {\n const signature = createHmac('sha256', _apiSecret)\n .update(body)\n .digest('hex');\n\n const headers = {\n 'Content-Type': 'application/json',\n 'API-KEY': _apiKey,\n 'HASH-SIGNATURE': signature,\n };\n\n return headers;\n};\n\nexport const sendRequest = async (path: string, body: any) => {\n return new Promise<APIResponse>((resolve) => {\n const output: APIResponse = {\n status: false,\n response: undefined,\n };\n\n const chunk = JSON.stringify(body);\n\n const options = { ...mainOptions };\n options.path += path;\n options.headers = prepareHeader(chunk);\n\n const req = (isSecure ? https : http).request(options, (res) => {\n const body: Array<Uint8Array> = [];\n res.on('data', (chunk) => body.push(chunk));\n\n res.on('end', () => {\n const resString = Buffer.concat(body).toString();\n\n try {\n output.status = true;\n output.response = JSON.parse(resString);\n } catch (error) {\n output.status = false;\n output.response = error;\n }\n\n resolve(output);\n });\n });\n\n req.on('error', (error) => {\n output.response = error.message;\n resolve(output);\n });\n\n req.write(chunk);\n req.end();\n });\n};\n"],"names":[],"version":3,"file":"PlugNmeet.js.map","sourceRoot":"../"}
|