easyproctor 0.0.63 → 0.0.65
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/esm/index.js +66 -45
- package/index.d.ts +9 -3
- package/index.js +66 -45
- package/modules/upload.d.ts +1 -1
- package/package.json +1 -1
- package/unpkg/easyproctor.min.js +44 -44
package/esm/index.js
CHANGED
|
@@ -42181,6 +42181,33 @@ var trackers = {
|
|
|
42181
42181
|
registerUploadVideo: (proctoringId, success, description, uploadTime) => registerCustomEvent(eventNames.UPLOAD_VIDEO, { proctoringId, success, description, uploadTime })
|
|
42182
42182
|
};
|
|
42183
42183
|
|
|
42184
|
+
// src/modules/http.ts
|
|
42185
|
+
var baseUrl = "https://proctoring-api.easyproctor.tech/api";
|
|
42186
|
+
async function setBaseUrl(homol) {
|
|
42187
|
+
console.log("homol -> ", homol);
|
|
42188
|
+
if (homol)
|
|
42189
|
+
baseUrl = "https://proctoring-api-hml.easyproctor.tech/api";
|
|
42190
|
+
}
|
|
42191
|
+
async function makeRequest(data) {
|
|
42192
|
+
const { url, method, body, jwt } = data;
|
|
42193
|
+
const resp = await fetch(baseUrl + url, {
|
|
42194
|
+
method,
|
|
42195
|
+
body: body != null ? JSON.stringify(body) : void 0,
|
|
42196
|
+
headers: {
|
|
42197
|
+
Authorization: `Bearer ${jwt}`,
|
|
42198
|
+
"Content-Type": "application/json",
|
|
42199
|
+
"Access-Control-Allow-Origin": "*"
|
|
42200
|
+
}
|
|
42201
|
+
});
|
|
42202
|
+
if (resp.status >= 400) {
|
|
42203
|
+
throw "N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde";
|
|
42204
|
+
}
|
|
42205
|
+
const content = resp.headers.get("content-type");
|
|
42206
|
+
const isJson = content ? content.includes("application/json") : false;
|
|
42207
|
+
const responseData = isJson ? await resp.json() : null;
|
|
42208
|
+
return responseData;
|
|
42209
|
+
}
|
|
42210
|
+
|
|
42184
42211
|
// node_modules/@aws-sdk/client-s3/node_modules/tslib/modules/index.js
|
|
42185
42212
|
var import_tslib = __toESM(require_tslib(), 1);
|
|
42186
42213
|
var {
|
|
@@ -49426,6 +49453,7 @@ var sas = "";
|
|
|
49426
49453
|
var blobServiceClient;
|
|
49427
49454
|
var message = "";
|
|
49428
49455
|
var loadingInterval;
|
|
49456
|
+
var loadingBoolean = true;
|
|
49429
49457
|
async function setConfiguration(_account, _cointainerName, _sas) {
|
|
49430
49458
|
account = _account;
|
|
49431
49459
|
containerName = _cointainerName;
|
|
@@ -49435,7 +49463,7 @@ async function setConfiguration(_account, _cointainerName, _sas) {
|
|
|
49435
49463
|
function sendError(proctoringId) {
|
|
49436
49464
|
trackers.registerError(proctoringId, message);
|
|
49437
49465
|
}
|
|
49438
|
-
async function upload(data, proctoringId, config2) {
|
|
49466
|
+
async function upload(data, proctoringId, config2, proctoringToken) {
|
|
49439
49467
|
try {
|
|
49440
49468
|
const { file, onProgress } = data;
|
|
49441
49469
|
message += `Upload: ${file.type}
|
|
@@ -49471,30 +49499,30 @@ async function upload(data, proctoringId, config2) {
|
|
|
49471
49499
|
});
|
|
49472
49500
|
message += "Blob: Step 5\n";
|
|
49473
49501
|
} catch (err) {
|
|
49474
|
-
await uploadBackup(data, config2).catch(async () => {
|
|
49502
|
+
await uploadBackup(data, config2, proctoringToken).catch(async () => {
|
|
49475
49503
|
sendError(proctoringId);
|
|
49476
49504
|
throw err;
|
|
49477
49505
|
});
|
|
49478
49506
|
}
|
|
49479
49507
|
}
|
|
49480
|
-
async function uploadBackup(data, config2) {
|
|
49508
|
+
async function uploadBackup(data, config2, proctoringToken) {
|
|
49481
49509
|
try {
|
|
49482
|
-
console.log("DENTRO DO CATCH");
|
|
49483
49510
|
const { file, onProgress } = data;
|
|
49484
49511
|
const uploadParams = {
|
|
49485
49512
|
Bucket: "iarisprod",
|
|
49486
49513
|
Key: file.name,
|
|
49487
49514
|
Body: file
|
|
49488
49515
|
};
|
|
49516
|
+
console.log("file");
|
|
49517
|
+
console.log(file);
|
|
49489
49518
|
const s3Client = new S3Client({
|
|
49490
49519
|
region: "us-east-1",
|
|
49491
49520
|
credentials: {
|
|
49492
|
-
accessKeyId:
|
|
49521
|
+
accessKeyId: config2.accessKeyId,
|
|
49493
49522
|
secretAccessKey: config2.secretAccessKey
|
|
49494
49523
|
}
|
|
49495
49524
|
});
|
|
49496
49525
|
try {
|
|
49497
|
-
let loadingBoolean = true;
|
|
49498
49526
|
let i = 0;
|
|
49499
49527
|
onProgress && onProgress(Math.round(0));
|
|
49500
49528
|
loadingInterval = setInterval(() => {
|
|
@@ -49506,10 +49534,16 @@ async function uploadBackup(data, config2) {
|
|
|
49506
49534
|
}
|
|
49507
49535
|
}
|
|
49508
49536
|
}, 3e3);
|
|
49509
|
-
const data2 = await s3Client.send(new PutObjectCommand(uploadParams)).then(() => {
|
|
49537
|
+
const data2 = await s3Client.send(new PutObjectCommand(uploadParams)).then(async () => {
|
|
49510
49538
|
loadingBoolean = false;
|
|
49511
49539
|
clearInterval(loadingInterval);
|
|
49512
49540
|
onProgress && onProgress(Math.round(100));
|
|
49541
|
+
await makeRequest({
|
|
49542
|
+
url: `/Proctoring/aws-to-azure`,
|
|
49543
|
+
method: "POST",
|
|
49544
|
+
jwt: proctoringToken,
|
|
49545
|
+
body: `${file.name}`
|
|
49546
|
+
});
|
|
49513
49547
|
}).catch((err) => {
|
|
49514
49548
|
throw err;
|
|
49515
49549
|
});
|
|
@@ -49520,15 +49554,16 @@ async function uploadBackup(data, config2) {
|
|
|
49520
49554
|
message += "\n\u2022 Error on AWS upload\n ";
|
|
49521
49555
|
message += err;
|
|
49522
49556
|
try {
|
|
49523
|
-
download(data
|
|
49557
|
+
download(data);
|
|
49524
49558
|
} catch (err2) {
|
|
49525
49559
|
throw err2;
|
|
49526
49560
|
}
|
|
49527
49561
|
throw err;
|
|
49528
49562
|
}
|
|
49529
49563
|
}
|
|
49530
|
-
function download(
|
|
49564
|
+
function download(data) {
|
|
49531
49565
|
try {
|
|
49566
|
+
const { file, onProgress } = data;
|
|
49532
49567
|
const url = URL.createObjectURL(file);
|
|
49533
49568
|
const a = document.createElement("a");
|
|
49534
49569
|
document.body.appendChild(a);
|
|
@@ -49537,41 +49572,17 @@ function download(file) {
|
|
|
49537
49572
|
a.download = file.name;
|
|
49538
49573
|
a.click();
|
|
49539
49574
|
window.URL.revokeObjectURL(url);
|
|
49575
|
+
loadingBoolean = false;
|
|
49576
|
+
clearInterval(loadingInterval);
|
|
49577
|
+
onProgress && onProgress(Math.round(100));
|
|
49540
49578
|
} catch (err) {
|
|
49541
49579
|
message += `
|
|
49542
|
-
\u2022 Error on machine download -> ${file.name}
|
|
49580
|
+
\u2022 Error on machine download -> ${data.file.name}
|
|
49543
49581
|
`;
|
|
49544
49582
|
throw err;
|
|
49545
49583
|
}
|
|
49546
49584
|
}
|
|
49547
49585
|
|
|
49548
|
-
// src/modules/http.ts
|
|
49549
|
-
var baseUrl = "https://proctoring-api.easyproctor.tech/api";
|
|
49550
|
-
async function setBaseUrl(homol) {
|
|
49551
|
-
console.log("homol -> ", homol);
|
|
49552
|
-
if (homol)
|
|
49553
|
-
baseUrl = "https://proctoring-api-hml.easyproctor.tech/api";
|
|
49554
|
-
}
|
|
49555
|
-
async function makeRequest(data) {
|
|
49556
|
-
const { url, method, body, jwt } = data;
|
|
49557
|
-
const resp = await fetch(baseUrl + url, {
|
|
49558
|
-
method,
|
|
49559
|
-
body: body != null ? JSON.stringify(body) : void 0,
|
|
49560
|
-
headers: {
|
|
49561
|
-
Authorization: `Bearer ${jwt}`,
|
|
49562
|
-
"Content-Type": "application/json",
|
|
49563
|
-
"Access-Control-Allow-Origin": "*"
|
|
49564
|
-
}
|
|
49565
|
-
});
|
|
49566
|
-
if (resp.status >= 400) {
|
|
49567
|
-
throw "N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde";
|
|
49568
|
-
}
|
|
49569
|
-
const content = resp.headers.get("content-type");
|
|
49570
|
-
const isJson = content ? content.includes("application/json") : false;
|
|
49571
|
-
const responseData = isJson ? await resp.json() : null;
|
|
49572
|
-
return responseData;
|
|
49573
|
-
}
|
|
49574
|
-
|
|
49575
49586
|
// src/modules/enumarateDevices.ts
|
|
49576
49587
|
async function enumarateDevices() {
|
|
49577
49588
|
const mediaDevices = await navigator.mediaDevices.enumerateDevices();
|
|
@@ -49830,6 +49841,7 @@ function useProctoring(proctoringOptions, homolConfig = false) {
|
|
|
49830
49841
|
init(config.insights);
|
|
49831
49842
|
}
|
|
49832
49843
|
async function start(options = defaultProctoringOptions, videoOptions = { width: 640, height: 480 }) {
|
|
49844
|
+
console.log(lastClick);
|
|
49833
49845
|
if (lastClick >= Date.now() - delay)
|
|
49834
49846
|
throw PROCTORING_ALREADY_STARTED;
|
|
49835
49847
|
lastClick = Date.now();
|
|
@@ -49876,6 +49888,7 @@ function useProctoring(proctoringOptions, homolConfig = false) {
|
|
|
49876
49888
|
sessions: []
|
|
49877
49889
|
});
|
|
49878
49890
|
proctoringId = resp.id;
|
|
49891
|
+
console.log("proctoringId", proctoringId);
|
|
49879
49892
|
trackers.registerStart(proctoringId, true, "");
|
|
49880
49893
|
_addListeners();
|
|
49881
49894
|
return resp;
|
|
@@ -49889,27 +49902,34 @@ function useProctoring(proctoringOptions, homolConfig = false) {
|
|
|
49889
49902
|
const { start: start2 } = await startAudioCapture();
|
|
49890
49903
|
start2();
|
|
49891
49904
|
}
|
|
49892
|
-
async function
|
|
49905
|
+
async function finishAudio() {
|
|
49906
|
+
const { buffer, blob } = await stopRecord();
|
|
49907
|
+
return { buffer, blob };
|
|
49908
|
+
}
|
|
49909
|
+
async function checkDevices(options = defaultProctoringOptions, videoOptions = { width: 640, height: 480 }) {
|
|
49893
49910
|
const { cameraId, microphoneId, allowOnlyFirstMonitor = true, allowMultipleMonitors = false, captureScreen = true, proctoringType } = options;
|
|
49894
49911
|
checkPermissions();
|
|
49895
49912
|
startAudio();
|
|
49896
49913
|
const { cameraStream, _screenStream } = await _startCapture({ cameraId, microphoneId, allowOnlyFirstMonitor, captureScreen, proctoringType }, videoOptions);
|
|
49914
|
+
console.log("Recording...");
|
|
49915
|
+
return { cameraStream, _screenStream };
|
|
49897
49916
|
}
|
|
49898
|
-
async function
|
|
49899
|
-
|
|
49900
|
-
return { buffer, blob };
|
|
49901
|
-
}
|
|
49902
|
-
async function finishTest() {
|
|
49917
|
+
async function closeCheckDevices() {
|
|
49918
|
+
console.log("Stoping record...");
|
|
49903
49919
|
onStopSharingScreenCallback = void 0;
|
|
49904
49920
|
if (cancelCallback) {
|
|
49905
49921
|
await cancelCallback();
|
|
49906
49922
|
}
|
|
49907
49923
|
_removeListeners();
|
|
49908
49924
|
await clearBuffers("exams");
|
|
49925
|
+
const cameraBlob = cameraBuffer;
|
|
49926
|
+
const screenBlob = screenBuffer;
|
|
49909
49927
|
cameraBuffer = [];
|
|
49910
49928
|
screenBuffer = [];
|
|
49911
49929
|
alerts = [];
|
|
49912
49930
|
cancelCallback = null;
|
|
49931
|
+
console.log("Finish record");
|
|
49932
|
+
return { cameraBlob, screenBlob };
|
|
49913
49933
|
}
|
|
49914
49934
|
async function pause() {
|
|
49915
49935
|
const record = await getRecord("exams");
|
|
@@ -49984,6 +50004,7 @@ function useProctoring(proctoringOptions, homolConfig = false) {
|
|
|
49984
50004
|
trackers.registerError(proctoringId, "N\xE3o foi poss\xEDvel requisitar a data do servidor!");
|
|
49985
50005
|
}
|
|
49986
50006
|
proctoringId = record.id;
|
|
50007
|
+
console.log("procotoringId resume", proctoringId);
|
|
49987
50008
|
startDate = serverTime ? new Date(serverTime.toString()) : new Date();
|
|
49988
50009
|
startTime = startDate.getTime();
|
|
49989
50010
|
return { cameraStream, _screenStream };
|
|
@@ -50104,7 +50125,7 @@ function useProctoring(proctoringOptions, homolConfig = false) {
|
|
|
50104
50125
|
uploadProgress[i] = progress;
|
|
50105
50126
|
handleOnProgress();
|
|
50106
50127
|
}
|
|
50107
|
-
}, proctoringId, config);
|
|
50128
|
+
}, proctoringId, config, proctoringOptions.token);
|
|
50108
50129
|
});
|
|
50109
50130
|
const timeAfter = performance.now();
|
|
50110
50131
|
await Promise.all(uploadPromises);
|
|
@@ -50130,7 +50151,7 @@ function useProctoring(proctoringOptions, homolConfig = false) {
|
|
|
50130
50151
|
function onLostFocus(cb) {
|
|
50131
50152
|
onLostFocusCallback = cb;
|
|
50132
50153
|
}
|
|
50133
|
-
return { start, startAudio,
|
|
50154
|
+
return { start, startAudio, checkDevices, finish, finishAudio, closeCheckDevices, pause, resume, onFocus, onLostFocus, enumarateDevices, checkPermissions, checkIfhasMultipleMonitors, onStopSharingScreen };
|
|
50134
50155
|
}
|
|
50135
50156
|
if (typeof window !== "undefined") {
|
|
50136
50157
|
window.useProctoring = useProctoring;
|
package/index.d.ts
CHANGED
|
@@ -20,10 +20,13 @@ export declare function useProctoring(proctoringOptions: {
|
|
|
20
20
|
height?: number;
|
|
21
21
|
}) => Promise<StartProctoringResponse>;
|
|
22
22
|
startAudio: () => Promise<void>;
|
|
23
|
-
|
|
23
|
+
checkDevices: (options?: ProctoringOptions, videoOptions?: {
|
|
24
24
|
width?: number;
|
|
25
25
|
height?: number;
|
|
26
|
-
}) => Promise<
|
|
26
|
+
}) => Promise<{
|
|
27
|
+
cameraStream: MediaStream;
|
|
28
|
+
_screenStream: MediaStream | undefined;
|
|
29
|
+
}>;
|
|
27
30
|
finish: (options?: {
|
|
28
31
|
onProgress?: ((percentage: number) => void) | undefined;
|
|
29
32
|
}) => Promise<void>;
|
|
@@ -31,7 +34,10 @@ export declare function useProctoring(proctoringOptions: {
|
|
|
31
34
|
buffer: any;
|
|
32
35
|
blob: any;
|
|
33
36
|
}>;
|
|
34
|
-
|
|
37
|
+
closeCheckDevices: () => Promise<{
|
|
38
|
+
cameraBlob: Blob[];
|
|
39
|
+
screenBlob: Blob[];
|
|
40
|
+
}>;
|
|
35
41
|
pause: () => Promise<void>;
|
|
36
42
|
resume: (options: ProctoringOptions | undefined, examId: string, videoOptions?: {
|
|
37
43
|
width?: number;
|
package/index.js
CHANGED
|
@@ -74178,6 +74178,33 @@ var trackers = {
|
|
|
74178
74178
|
registerUploadVideo: (proctoringId, success, description, uploadTime) => registerCustomEvent(eventNames.UPLOAD_VIDEO, { proctoringId, success, description, uploadTime })
|
|
74179
74179
|
};
|
|
74180
74180
|
|
|
74181
|
+
// src/modules/http.ts
|
|
74182
|
+
var baseUrl = "https://proctoring-api.easyproctor.tech/api";
|
|
74183
|
+
async function setBaseUrl(homol) {
|
|
74184
|
+
console.log("homol -> ", homol);
|
|
74185
|
+
if (homol)
|
|
74186
|
+
baseUrl = "https://proctoring-api-hml.easyproctor.tech/api";
|
|
74187
|
+
}
|
|
74188
|
+
async function makeRequest(data) {
|
|
74189
|
+
const { url, method, body, jwt } = data;
|
|
74190
|
+
const resp = await fetch(baseUrl + url, {
|
|
74191
|
+
method,
|
|
74192
|
+
body: body != null ? JSON.stringify(body) : void 0,
|
|
74193
|
+
headers: {
|
|
74194
|
+
Authorization: `Bearer ${jwt}`,
|
|
74195
|
+
"Content-Type": "application/json",
|
|
74196
|
+
"Access-Control-Allow-Origin": "*"
|
|
74197
|
+
}
|
|
74198
|
+
});
|
|
74199
|
+
if (resp.status >= 400) {
|
|
74200
|
+
throw "N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde";
|
|
74201
|
+
}
|
|
74202
|
+
const content = resp.headers.get("content-type");
|
|
74203
|
+
const isJson = content ? content.includes("application/json") : false;
|
|
74204
|
+
const responseData = isJson ? await resp.json() : null;
|
|
74205
|
+
return responseData;
|
|
74206
|
+
}
|
|
74207
|
+
|
|
74181
74208
|
// src/modules/upload.ts
|
|
74182
74209
|
var import_client_s3 = __toESM(require_dist_cjs61());
|
|
74183
74210
|
var import_client_s32 = __toESM(require_dist_cjs61());
|
|
@@ -74187,6 +74214,7 @@ var sas = "";
|
|
|
74187
74214
|
var blobServiceClient;
|
|
74188
74215
|
var message = "";
|
|
74189
74216
|
var loadingInterval;
|
|
74217
|
+
var loadingBoolean = true;
|
|
74190
74218
|
async function setConfiguration(_account, _cointainerName, _sas) {
|
|
74191
74219
|
account = _account;
|
|
74192
74220
|
containerName = _cointainerName;
|
|
@@ -74196,7 +74224,7 @@ async function setConfiguration(_account, _cointainerName, _sas) {
|
|
|
74196
74224
|
function sendError(proctoringId) {
|
|
74197
74225
|
trackers.registerError(proctoringId, message);
|
|
74198
74226
|
}
|
|
74199
|
-
async function upload(data, proctoringId, config2) {
|
|
74227
|
+
async function upload(data, proctoringId, config2, proctoringToken) {
|
|
74200
74228
|
try {
|
|
74201
74229
|
const { file, onProgress } = data;
|
|
74202
74230
|
message += `Upload: ${file.type}
|
|
@@ -74232,30 +74260,30 @@ async function upload(data, proctoringId, config2) {
|
|
|
74232
74260
|
});
|
|
74233
74261
|
message += "Blob: Step 5\n";
|
|
74234
74262
|
} catch (err) {
|
|
74235
|
-
await uploadBackup(data, config2).catch(async () => {
|
|
74263
|
+
await uploadBackup(data, config2, proctoringToken).catch(async () => {
|
|
74236
74264
|
sendError(proctoringId);
|
|
74237
74265
|
throw err;
|
|
74238
74266
|
});
|
|
74239
74267
|
}
|
|
74240
74268
|
}
|
|
74241
|
-
async function uploadBackup(data, config2) {
|
|
74269
|
+
async function uploadBackup(data, config2, proctoringToken) {
|
|
74242
74270
|
try {
|
|
74243
|
-
console.log("DENTRO DO CATCH");
|
|
74244
74271
|
const { file, onProgress } = data;
|
|
74245
74272
|
const uploadParams = {
|
|
74246
74273
|
Bucket: "iarisprod",
|
|
74247
74274
|
Key: file.name,
|
|
74248
74275
|
Body: file
|
|
74249
74276
|
};
|
|
74277
|
+
console.log("file");
|
|
74278
|
+
console.log(file);
|
|
74250
74279
|
const s3Client = new import_client_s32.S3Client({
|
|
74251
74280
|
region: "us-east-1",
|
|
74252
74281
|
credentials: {
|
|
74253
|
-
accessKeyId:
|
|
74282
|
+
accessKeyId: config2.accessKeyId,
|
|
74254
74283
|
secretAccessKey: config2.secretAccessKey
|
|
74255
74284
|
}
|
|
74256
74285
|
});
|
|
74257
74286
|
try {
|
|
74258
|
-
let loadingBoolean = true;
|
|
74259
74287
|
let i = 0;
|
|
74260
74288
|
onProgress && onProgress(Math.round(0));
|
|
74261
74289
|
loadingInterval = setInterval(() => {
|
|
@@ -74267,10 +74295,16 @@ async function uploadBackup(data, config2) {
|
|
|
74267
74295
|
}
|
|
74268
74296
|
}
|
|
74269
74297
|
}, 3e3);
|
|
74270
|
-
const data2 = await s3Client.send(new import_client_s3.PutObjectCommand(uploadParams)).then(() => {
|
|
74298
|
+
const data2 = await s3Client.send(new import_client_s3.PutObjectCommand(uploadParams)).then(async () => {
|
|
74271
74299
|
loadingBoolean = false;
|
|
74272
74300
|
clearInterval(loadingInterval);
|
|
74273
74301
|
onProgress && onProgress(Math.round(100));
|
|
74302
|
+
await makeRequest({
|
|
74303
|
+
url: `/Proctoring/aws-to-azure`,
|
|
74304
|
+
method: "POST",
|
|
74305
|
+
jwt: proctoringToken,
|
|
74306
|
+
body: `${file.name}`
|
|
74307
|
+
});
|
|
74274
74308
|
}).catch((err) => {
|
|
74275
74309
|
throw err;
|
|
74276
74310
|
});
|
|
@@ -74281,15 +74315,16 @@ async function uploadBackup(data, config2) {
|
|
|
74281
74315
|
message += "\n\u2022 Error on AWS upload\n ";
|
|
74282
74316
|
message += err;
|
|
74283
74317
|
try {
|
|
74284
|
-
download(data
|
|
74318
|
+
download(data);
|
|
74285
74319
|
} catch (err2) {
|
|
74286
74320
|
throw err2;
|
|
74287
74321
|
}
|
|
74288
74322
|
throw err;
|
|
74289
74323
|
}
|
|
74290
74324
|
}
|
|
74291
|
-
function download(
|
|
74325
|
+
function download(data) {
|
|
74292
74326
|
try {
|
|
74327
|
+
const { file, onProgress } = data;
|
|
74293
74328
|
const url = URL.createObjectURL(file);
|
|
74294
74329
|
const a = document.createElement("a");
|
|
74295
74330
|
document.body.appendChild(a);
|
|
@@ -74298,41 +74333,17 @@ function download(file) {
|
|
|
74298
74333
|
a.download = file.name;
|
|
74299
74334
|
a.click();
|
|
74300
74335
|
window.URL.revokeObjectURL(url);
|
|
74336
|
+
loadingBoolean = false;
|
|
74337
|
+
clearInterval(loadingInterval);
|
|
74338
|
+
onProgress && onProgress(Math.round(100));
|
|
74301
74339
|
} catch (err) {
|
|
74302
74340
|
message += `
|
|
74303
|
-
\u2022 Error on machine download -> ${file.name}
|
|
74341
|
+
\u2022 Error on machine download -> ${data.file.name}
|
|
74304
74342
|
`;
|
|
74305
74343
|
throw err;
|
|
74306
74344
|
}
|
|
74307
74345
|
}
|
|
74308
74346
|
|
|
74309
|
-
// src/modules/http.ts
|
|
74310
|
-
var baseUrl = "https://proctoring-api.easyproctor.tech/api";
|
|
74311
|
-
async function setBaseUrl(homol) {
|
|
74312
|
-
console.log("homol -> ", homol);
|
|
74313
|
-
if (homol)
|
|
74314
|
-
baseUrl = "https://proctoring-api-hml.easyproctor.tech/api";
|
|
74315
|
-
}
|
|
74316
|
-
async function makeRequest(data) {
|
|
74317
|
-
const { url, method, body, jwt } = data;
|
|
74318
|
-
const resp = await fetch(baseUrl + url, {
|
|
74319
|
-
method,
|
|
74320
|
-
body: body != null ? JSON.stringify(body) : void 0,
|
|
74321
|
-
headers: {
|
|
74322
|
-
Authorization: `Bearer ${jwt}`,
|
|
74323
|
-
"Content-Type": "application/json",
|
|
74324
|
-
"Access-Control-Allow-Origin": "*"
|
|
74325
|
-
}
|
|
74326
|
-
});
|
|
74327
|
-
if (resp.status >= 400) {
|
|
74328
|
-
throw "N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde";
|
|
74329
|
-
}
|
|
74330
|
-
const content = resp.headers.get("content-type");
|
|
74331
|
-
const isJson = content ? content.includes("application/json") : false;
|
|
74332
|
-
const responseData = isJson ? await resp.json() : null;
|
|
74333
|
-
return responseData;
|
|
74334
|
-
}
|
|
74335
|
-
|
|
74336
74347
|
// src/modules/enumarateDevices.ts
|
|
74337
74348
|
async function enumarateDevices() {
|
|
74338
74349
|
const mediaDevices = await navigator.mediaDevices.enumerateDevices();
|
|
@@ -74591,6 +74602,7 @@ function useProctoring(proctoringOptions, homolConfig = false) {
|
|
|
74591
74602
|
init(config.insights);
|
|
74592
74603
|
}
|
|
74593
74604
|
async function start(options = defaultProctoringOptions, videoOptions = { width: 640, height: 480 }) {
|
|
74605
|
+
console.log(lastClick);
|
|
74594
74606
|
if (lastClick >= Date.now() - delay)
|
|
74595
74607
|
throw PROCTORING_ALREADY_STARTED;
|
|
74596
74608
|
lastClick = Date.now();
|
|
@@ -74637,6 +74649,7 @@ function useProctoring(proctoringOptions, homolConfig = false) {
|
|
|
74637
74649
|
sessions: []
|
|
74638
74650
|
});
|
|
74639
74651
|
proctoringId = resp.id;
|
|
74652
|
+
console.log("proctoringId", proctoringId);
|
|
74640
74653
|
trackers.registerStart(proctoringId, true, "");
|
|
74641
74654
|
_addListeners();
|
|
74642
74655
|
return resp;
|
|
@@ -74650,27 +74663,34 @@ function useProctoring(proctoringOptions, homolConfig = false) {
|
|
|
74650
74663
|
const { start: start2 } = await startAudioCapture();
|
|
74651
74664
|
start2();
|
|
74652
74665
|
}
|
|
74653
|
-
async function
|
|
74666
|
+
async function finishAudio() {
|
|
74667
|
+
const { buffer, blob } = await stopRecord();
|
|
74668
|
+
return { buffer, blob };
|
|
74669
|
+
}
|
|
74670
|
+
async function checkDevices(options = defaultProctoringOptions, videoOptions = { width: 640, height: 480 }) {
|
|
74654
74671
|
const { cameraId, microphoneId, allowOnlyFirstMonitor = true, allowMultipleMonitors = false, captureScreen = true, proctoringType } = options;
|
|
74655
74672
|
checkPermissions();
|
|
74656
74673
|
startAudio();
|
|
74657
74674
|
const { cameraStream, _screenStream } = await _startCapture({ cameraId, microphoneId, allowOnlyFirstMonitor, captureScreen, proctoringType }, videoOptions);
|
|
74675
|
+
console.log("Recording...");
|
|
74676
|
+
return { cameraStream, _screenStream };
|
|
74658
74677
|
}
|
|
74659
|
-
async function
|
|
74660
|
-
|
|
74661
|
-
return { buffer, blob };
|
|
74662
|
-
}
|
|
74663
|
-
async function finishTest() {
|
|
74678
|
+
async function closeCheckDevices() {
|
|
74679
|
+
console.log("Stoping record...");
|
|
74664
74680
|
onStopSharingScreenCallback = void 0;
|
|
74665
74681
|
if (cancelCallback) {
|
|
74666
74682
|
await cancelCallback();
|
|
74667
74683
|
}
|
|
74668
74684
|
_removeListeners();
|
|
74669
74685
|
await clearBuffers("exams");
|
|
74686
|
+
const cameraBlob = cameraBuffer;
|
|
74687
|
+
const screenBlob = screenBuffer;
|
|
74670
74688
|
cameraBuffer = [];
|
|
74671
74689
|
screenBuffer = [];
|
|
74672
74690
|
alerts = [];
|
|
74673
74691
|
cancelCallback = null;
|
|
74692
|
+
console.log("Finish record");
|
|
74693
|
+
return { cameraBlob, screenBlob };
|
|
74674
74694
|
}
|
|
74675
74695
|
async function pause() {
|
|
74676
74696
|
const record = await getRecord("exams");
|
|
@@ -74745,6 +74765,7 @@ function useProctoring(proctoringOptions, homolConfig = false) {
|
|
|
74745
74765
|
trackers.registerError(proctoringId, "N\xE3o foi poss\xEDvel requisitar a data do servidor!");
|
|
74746
74766
|
}
|
|
74747
74767
|
proctoringId = record.id;
|
|
74768
|
+
console.log("procotoringId resume", proctoringId);
|
|
74748
74769
|
startDate = serverTime ? new Date(serverTime.toString()) : new Date();
|
|
74749
74770
|
startTime = startDate.getTime();
|
|
74750
74771
|
return { cameraStream, _screenStream };
|
|
@@ -74865,7 +74886,7 @@ function useProctoring(proctoringOptions, homolConfig = false) {
|
|
|
74865
74886
|
uploadProgress[i] = progress;
|
|
74866
74887
|
handleOnProgress();
|
|
74867
74888
|
}
|
|
74868
|
-
}, proctoringId, config);
|
|
74889
|
+
}, proctoringId, config, proctoringOptions.token);
|
|
74869
74890
|
});
|
|
74870
74891
|
const timeAfter = performance.now();
|
|
74871
74892
|
await Promise.all(uploadPromises);
|
|
@@ -74891,7 +74912,7 @@ function useProctoring(proctoringOptions, homolConfig = false) {
|
|
|
74891
74912
|
function onLostFocus(cb) {
|
|
74892
74913
|
onLostFocusCallback = cb;
|
|
74893
74914
|
}
|
|
74894
|
-
return { start, startAudio,
|
|
74915
|
+
return { start, startAudio, checkDevices, finish, finishAudio, closeCheckDevices, pause, resume, onFocus, onLostFocus, enumarateDevices, checkPermissions, checkIfhasMultipleMonitors, onStopSharingScreen };
|
|
74895
74916
|
}
|
|
74896
74917
|
if (typeof window !== "undefined") {
|
|
74897
74918
|
window.useProctoring = useProctoring;
|
package/modules/upload.d.ts
CHANGED
|
@@ -4,5 +4,5 @@ declare type UploadData = {
|
|
|
4
4
|
onProgress?: (progress: number) => void;
|
|
5
5
|
};
|
|
6
6
|
export declare function setConfiguration(_account: string, _cointainerName: string, _sas: string): Promise<void>;
|
|
7
|
-
export default function upload(data: UploadData, proctoringId: string, config: ProctoringConfig): Promise<void>;
|
|
7
|
+
export default function upload(data: UploadData, proctoringId: string, config: ProctoringConfig, proctoringToken: string): Promise<void>;
|
|
8
8
|
export {};
|