easyproctor 0.0.52 → 0.0.53
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 +172 -146
- package/index.js +81 -55
- package/modules/http.d.ts +6 -0
- package/modules/upload.d.ts +2 -2
- package/package.json +1 -1
- package/unpkg/easyproctor.min.js +19 -19
package/esm/index.js
CHANGED
|
@@ -14421,148 +14421,6 @@ async function startScreenCapture(buffer, options) {
|
|
|
14421
14421
|
|
|
14422
14422
|
// src/modules/upload.ts
|
|
14423
14423
|
import { BlobServiceClient } from "@azure/storage-blob";
|
|
14424
|
-
var account = "";
|
|
14425
|
-
var containerName = "";
|
|
14426
|
-
var sas = "";
|
|
14427
|
-
var blobServiceClient;
|
|
14428
|
-
async function setConfiguration(_account, _cointainerName, _sas) {
|
|
14429
|
-
account = _account;
|
|
14430
|
-
containerName = _cointainerName;
|
|
14431
|
-
sas = _sas;
|
|
14432
|
-
blobServiceClient = new BlobServiceClient(`https://${account}.blob.core.windows.net${sas}`);
|
|
14433
|
-
}
|
|
14434
|
-
async function upload(data) {
|
|
14435
|
-
const { file, onProgress } = data;
|
|
14436
|
-
const containerClient = blobServiceClient.getContainerClient(containerName);
|
|
14437
|
-
const blockBlobClient = containerClient.getBlockBlobClient(file.name);
|
|
14438
|
-
const progressCallback = (e) => {
|
|
14439
|
-
const progress = e.loadedBytes / file.size * 100;
|
|
14440
|
-
onProgress && onProgress(Math.round(progress));
|
|
14441
|
-
};
|
|
14442
|
-
await blockBlobClient.upload(file, file.size, { onProgress: progressCallback });
|
|
14443
|
-
}
|
|
14444
|
-
var upload_default = upload;
|
|
14445
|
-
|
|
14446
|
-
// src/modules/http.ts
|
|
14447
|
-
var baseUrl = "https://proctoring-api.easyproctor.tech/api";
|
|
14448
|
-
async function setBaseUrl(_baseUrl) {
|
|
14449
|
-
baseUrl = _baseUrl;
|
|
14450
|
-
}
|
|
14451
|
-
async function makeRequest(data) {
|
|
14452
|
-
const { url, method, body, jwt } = data;
|
|
14453
|
-
const resp = await fetch(baseUrl + url, {
|
|
14454
|
-
method,
|
|
14455
|
-
body: body != null ? JSON.stringify(body) : void 0,
|
|
14456
|
-
headers: {
|
|
14457
|
-
Authorization: `Bearer ${jwt}`,
|
|
14458
|
-
"Content-Type": "application/json"
|
|
14459
|
-
}
|
|
14460
|
-
});
|
|
14461
|
-
if (resp.status >= 400) {
|
|
14462
|
-
throw "N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde";
|
|
14463
|
-
}
|
|
14464
|
-
const content = resp.headers.get("content-type");
|
|
14465
|
-
const isJson = content ? content.includes("application/json") : false;
|
|
14466
|
-
const responseData = isJson ? await resp.json() : null;
|
|
14467
|
-
return responseData;
|
|
14468
|
-
}
|
|
14469
|
-
|
|
14470
|
-
// src/modules/enumarateDevices.ts
|
|
14471
|
-
async function enumarateDevices() {
|
|
14472
|
-
const mediaDevices = await navigator.mediaDevices.enumerateDevices();
|
|
14473
|
-
const devices = {
|
|
14474
|
-
cameras: mediaDevices.filter((el) => el.kind == "videoinput" && el.deviceId).map((e) => {
|
|
14475
|
-
return { label: e.label || "Generic Device", id: e.deviceId };
|
|
14476
|
-
}),
|
|
14477
|
-
microphones: mediaDevices.filter((el) => el.kind == "audioinput" && el.deviceId).map((e) => {
|
|
14478
|
-
return { label: e.label || "Generic Device", id: e.deviceId };
|
|
14479
|
-
})
|
|
14480
|
-
};
|
|
14481
|
-
return devices;
|
|
14482
|
-
}
|
|
14483
|
-
|
|
14484
|
-
// src/modules/checkPermissions.ts
|
|
14485
|
-
async function checkPermissions() {
|
|
14486
|
-
try {
|
|
14487
|
-
const constraints = {
|
|
14488
|
-
audio: true,
|
|
14489
|
-
video: true
|
|
14490
|
-
};
|
|
14491
|
-
const stream = await navigator.mediaDevices.getUserMedia(constraints);
|
|
14492
|
-
stream.getTracks().forEach((el) => {
|
|
14493
|
-
el.stop();
|
|
14494
|
-
});
|
|
14495
|
-
return true;
|
|
14496
|
-
} catch (error) {
|
|
14497
|
-
return false;
|
|
14498
|
-
}
|
|
14499
|
-
}
|
|
14500
|
-
async function checkIfhasMultipleMonitors() {
|
|
14501
|
-
return new Promise((resolve, reject) => {
|
|
14502
|
-
if (typeof PresentationRequest === "undefined") {
|
|
14503
|
-
resolve(false);
|
|
14504
|
-
}
|
|
14505
|
-
const presentationRequest = new PresentationRequest("receiver.html");
|
|
14506
|
-
presentationRequest.getAvailability().then((availability) => {
|
|
14507
|
-
let hasMultipleMonitors = availability.value;
|
|
14508
|
-
availability.addEventListener("change", function() {
|
|
14509
|
-
hasMultipleMonitors = availability.value;
|
|
14510
|
-
});
|
|
14511
|
-
setTimeout(() => {
|
|
14512
|
-
resolve(hasMultipleMonitors);
|
|
14513
|
-
}, 1e3);
|
|
14514
|
-
}).catch((error) => reject(error));
|
|
14515
|
-
});
|
|
14516
|
-
}
|
|
14517
|
-
|
|
14518
|
-
// src/modules/database.ts
|
|
14519
|
-
var databaseName = "EasyProctorPlugin";
|
|
14520
|
-
var databaseVersion = 2;
|
|
14521
|
-
function initializeDatabase(table) {
|
|
14522
|
-
return new Promise((resolve, reject) => {
|
|
14523
|
-
const request = indexedDB.open(databaseName, databaseVersion);
|
|
14524
|
-
request.onupgradeneeded = () => {
|
|
14525
|
-
request.result.createObjectStore("exams", { keyPath: "id" });
|
|
14526
|
-
};
|
|
14527
|
-
request.onerror = (e) => {
|
|
14528
|
-
console.log(e);
|
|
14529
|
-
reject("N\xE3o foi poss\xEDvel inicializar a biblioteca, por favor, entre em contato com o suporte e informe o erro acima");
|
|
14530
|
-
};
|
|
14531
|
-
request.onsuccess = () => {
|
|
14532
|
-
const db = request.result;
|
|
14533
|
-
const tableRef = db.transaction(table, "readwrite");
|
|
14534
|
-
const store = tableRef.objectStore(table);
|
|
14535
|
-
resolve(store);
|
|
14536
|
-
};
|
|
14537
|
-
});
|
|
14538
|
-
}
|
|
14539
|
-
async function insertRecord(table, data) {
|
|
14540
|
-
const store = await initializeDatabase(table);
|
|
14541
|
-
return new Promise((resolve, reject) => {
|
|
14542
|
-
const request = store.put(data);
|
|
14543
|
-
request.onsuccess = () => resolve();
|
|
14544
|
-
request.onerror = (e) => reject(e);
|
|
14545
|
-
});
|
|
14546
|
-
}
|
|
14547
|
-
async function getRecord(table) {
|
|
14548
|
-
const store = await initializeDatabase(table);
|
|
14549
|
-
return new Promise((resolve, reject) => {
|
|
14550
|
-
const request = store.getAll();
|
|
14551
|
-
request.onsuccess = () => {
|
|
14552
|
-
const data = request.result[0];
|
|
14553
|
-
resolve(data);
|
|
14554
|
-
};
|
|
14555
|
-
request.onerror = (e) => reject(e);
|
|
14556
|
-
});
|
|
14557
|
-
}
|
|
14558
|
-
async function clearBuffers(table) {
|
|
14559
|
-
const store = await initializeDatabase(table);
|
|
14560
|
-
return new Promise((resolve, reject) => {
|
|
14561
|
-
const request = store.clear();
|
|
14562
|
-
request.onsuccess = () => resolve();
|
|
14563
|
-
request.onerror = (e) => reject(e);
|
|
14564
|
-
});
|
|
14565
|
-
}
|
|
14566
14424
|
|
|
14567
14425
|
// node_modules/@microsoft/applicationinsights-core-js/dist-esm/JavaScriptSDK.Enums/EventsDiscardedReason.js
|
|
14568
14426
|
var EventsDiscardedReason = {
|
|
@@ -22608,6 +22466,164 @@ var trackers = {
|
|
|
22608
22466
|
registerUploadVideo: (proctoringId, success, description) => registerCustomEvent(eventNames.UPLOAD_VIDEO, { proctoringId, success, description })
|
|
22609
22467
|
};
|
|
22610
22468
|
|
|
22469
|
+
// src/modules/http.ts
|
|
22470
|
+
var baseUrl = "https://proctoring-api.easyproctor.tech/api";
|
|
22471
|
+
async function setBaseUrl(_baseUrl) {
|
|
22472
|
+
baseUrl = _baseUrl;
|
|
22473
|
+
}
|
|
22474
|
+
async function makeRequest(data) {
|
|
22475
|
+
const { url, method, body, jwt } = data;
|
|
22476
|
+
const resp = await fetch(baseUrl + url, {
|
|
22477
|
+
method,
|
|
22478
|
+
body: body != null ? JSON.stringify(body) : void 0,
|
|
22479
|
+
headers: {
|
|
22480
|
+
Authorization: `Bearer ${jwt}`,
|
|
22481
|
+
"Content-Type": "application/json"
|
|
22482
|
+
}
|
|
22483
|
+
});
|
|
22484
|
+
if (resp.status >= 400) {
|
|
22485
|
+
throw "N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde";
|
|
22486
|
+
}
|
|
22487
|
+
const content = resp.headers.get("content-type");
|
|
22488
|
+
const isJson = content ? content.includes("application/json") : false;
|
|
22489
|
+
const responseData = isJson ? await resp.json() : null;
|
|
22490
|
+
return responseData;
|
|
22491
|
+
}
|
|
22492
|
+
|
|
22493
|
+
// src/modules/upload.ts
|
|
22494
|
+
var account = "";
|
|
22495
|
+
var containerName = "";
|
|
22496
|
+
var sas = "";
|
|
22497
|
+
var blobServiceClient;
|
|
22498
|
+
async function setConfiguration(_account, _cointainerName, _sas) {
|
|
22499
|
+
account = _account;
|
|
22500
|
+
containerName = _cointainerName;
|
|
22501
|
+
sas = _sas;
|
|
22502
|
+
blobServiceClient = new BlobServiceClient(`https://${account}.blob.core.windows.net${sas}`);
|
|
22503
|
+
}
|
|
22504
|
+
async function upload(data, proctoringId, proctoringOptions, proctoringConfig) {
|
|
22505
|
+
try {
|
|
22506
|
+
const { file, onProgress } = data;
|
|
22507
|
+
trackers.registerError(proctoringId, `Blob: Step 1 - ${containerName}`);
|
|
22508
|
+
if (blobServiceClient == void 0) {
|
|
22509
|
+
trackers.registerError(proctoringId, `blobServiceClient is undefined`);
|
|
22510
|
+
}
|
|
22511
|
+
const containerClient = blobServiceClient.getContainerClient(containerName);
|
|
22512
|
+
trackers.registerError(proctoringId, "Blob: Step 2 " + JSON.stringify(blobServiceClient));
|
|
22513
|
+
const blockBlobClient = containerClient.getBlockBlobClient(file.name);
|
|
22514
|
+
trackers.registerError(proctoringId, "Blob: Step 3");
|
|
22515
|
+
const progressCallback = (e) => {
|
|
22516
|
+
const progress = e.loadedBytes / file.size * 100;
|
|
22517
|
+
onProgress && onProgress(Math.round(progress));
|
|
22518
|
+
};
|
|
22519
|
+
trackers.registerError(proctoringId, "Blob: Step 4");
|
|
22520
|
+
await blockBlobClient.upload(file, file.size, { onProgress: progressCallback }).catch((error) => {
|
|
22521
|
+
trackers.registerError(proctoringId, "Erro on upload");
|
|
22522
|
+
throw error;
|
|
22523
|
+
});
|
|
22524
|
+
trackers.registerError(proctoringId, "Blob: Step 5");
|
|
22525
|
+
} catch (err) {
|
|
22526
|
+
throw err;
|
|
22527
|
+
}
|
|
22528
|
+
}
|
|
22529
|
+
|
|
22530
|
+
// src/modules/enumarateDevices.ts
|
|
22531
|
+
async function enumarateDevices() {
|
|
22532
|
+
const mediaDevices = await navigator.mediaDevices.enumerateDevices();
|
|
22533
|
+
const devices = {
|
|
22534
|
+
cameras: mediaDevices.filter((el) => el.kind == "videoinput" && el.deviceId).map((e) => {
|
|
22535
|
+
return { label: e.label || "Generic Device", id: e.deviceId };
|
|
22536
|
+
}),
|
|
22537
|
+
microphones: mediaDevices.filter((el) => el.kind == "audioinput" && el.deviceId).map((e) => {
|
|
22538
|
+
return { label: e.label || "Generic Device", id: e.deviceId };
|
|
22539
|
+
})
|
|
22540
|
+
};
|
|
22541
|
+
return devices;
|
|
22542
|
+
}
|
|
22543
|
+
|
|
22544
|
+
// src/modules/checkPermissions.ts
|
|
22545
|
+
async function checkPermissions() {
|
|
22546
|
+
try {
|
|
22547
|
+
const constraints = {
|
|
22548
|
+
audio: true,
|
|
22549
|
+
video: true
|
|
22550
|
+
};
|
|
22551
|
+
const stream = await navigator.mediaDevices.getUserMedia(constraints);
|
|
22552
|
+
stream.getTracks().forEach((el) => {
|
|
22553
|
+
el.stop();
|
|
22554
|
+
});
|
|
22555
|
+
return true;
|
|
22556
|
+
} catch (error) {
|
|
22557
|
+
return false;
|
|
22558
|
+
}
|
|
22559
|
+
}
|
|
22560
|
+
async function checkIfhasMultipleMonitors() {
|
|
22561
|
+
return new Promise((resolve, reject) => {
|
|
22562
|
+
if (typeof PresentationRequest === "undefined") {
|
|
22563
|
+
resolve(false);
|
|
22564
|
+
}
|
|
22565
|
+
const presentationRequest = new PresentationRequest("receiver.html");
|
|
22566
|
+
presentationRequest.getAvailability().then((availability) => {
|
|
22567
|
+
let hasMultipleMonitors = availability.value;
|
|
22568
|
+
availability.addEventListener("change", function() {
|
|
22569
|
+
hasMultipleMonitors = availability.value;
|
|
22570
|
+
});
|
|
22571
|
+
setTimeout(() => {
|
|
22572
|
+
resolve(hasMultipleMonitors);
|
|
22573
|
+
}, 1e3);
|
|
22574
|
+
}).catch((error) => reject(error));
|
|
22575
|
+
});
|
|
22576
|
+
}
|
|
22577
|
+
|
|
22578
|
+
// src/modules/database.ts
|
|
22579
|
+
var databaseName = "EasyProctorPlugin";
|
|
22580
|
+
var databaseVersion = 2;
|
|
22581
|
+
function initializeDatabase(table) {
|
|
22582
|
+
return new Promise((resolve, reject) => {
|
|
22583
|
+
const request = indexedDB.open(databaseName, databaseVersion);
|
|
22584
|
+
request.onupgradeneeded = () => {
|
|
22585
|
+
request.result.createObjectStore("exams", { keyPath: "id" });
|
|
22586
|
+
};
|
|
22587
|
+
request.onerror = (e) => {
|
|
22588
|
+
console.log(e);
|
|
22589
|
+
reject("N\xE3o foi poss\xEDvel inicializar a biblioteca, por favor, entre em contato com o suporte e informe o erro acima");
|
|
22590
|
+
};
|
|
22591
|
+
request.onsuccess = () => {
|
|
22592
|
+
const db = request.result;
|
|
22593
|
+
const tableRef = db.transaction(table, "readwrite");
|
|
22594
|
+
const store = tableRef.objectStore(table);
|
|
22595
|
+
resolve(store);
|
|
22596
|
+
};
|
|
22597
|
+
});
|
|
22598
|
+
}
|
|
22599
|
+
async function insertRecord(table, data) {
|
|
22600
|
+
const store = await initializeDatabase(table);
|
|
22601
|
+
return new Promise((resolve, reject) => {
|
|
22602
|
+
const request = store.put(data);
|
|
22603
|
+
request.onsuccess = () => resolve();
|
|
22604
|
+
request.onerror = (e) => reject(e);
|
|
22605
|
+
});
|
|
22606
|
+
}
|
|
22607
|
+
async function getRecord(table) {
|
|
22608
|
+
const store = await initializeDatabase(table);
|
|
22609
|
+
return new Promise((resolve, reject) => {
|
|
22610
|
+
const request = store.getAll();
|
|
22611
|
+
request.onsuccess = () => {
|
|
22612
|
+
const data = request.result[0];
|
|
22613
|
+
resolve(data);
|
|
22614
|
+
};
|
|
22615
|
+
request.onerror = (e) => reject(e);
|
|
22616
|
+
});
|
|
22617
|
+
}
|
|
22618
|
+
async function clearBuffers(table) {
|
|
22619
|
+
const store = await initializeDatabase(table);
|
|
22620
|
+
return new Promise((resolve, reject) => {
|
|
22621
|
+
const request = store.clear();
|
|
22622
|
+
request.onsuccess = () => resolve();
|
|
22623
|
+
request.onerror = (e) => reject(e);
|
|
22624
|
+
});
|
|
22625
|
+
}
|
|
22626
|
+
|
|
22611
22627
|
// src/index.ts
|
|
22612
22628
|
var defaultProctoringOptions = {
|
|
22613
22629
|
cameraId: void 0,
|
|
@@ -22778,7 +22794,12 @@ function useProctoring(proctoringOptions, proctoringConfig) {
|
|
|
22778
22794
|
throw PROCTORING_ALREADY_STARTED;
|
|
22779
22795
|
lastClick = Date.now();
|
|
22780
22796
|
const { cameraId, microphoneId, allowOnlyFirstMonitor = true, allowMultipleMonitors = false, captureScreen = true, proctoringType } = options;
|
|
22781
|
-
|
|
22797
|
+
try {
|
|
22798
|
+
await initConfig();
|
|
22799
|
+
} catch (err) {
|
|
22800
|
+
trackers.registerError(proctoringId, "Erro no initConfig!");
|
|
22801
|
+
throw err;
|
|
22802
|
+
}
|
|
22782
22803
|
if (!allowMultipleMonitors) {
|
|
22783
22804
|
const hasMultipleMonitors = await checkIfhasMultipleMonitors();
|
|
22784
22805
|
if (hasMultipleMonitors) {
|
|
@@ -22865,7 +22886,12 @@ function useProctoring(proctoringOptions, proctoringConfig) {
|
|
|
22865
22886
|
async function resume(options = defaultProctoringOptions, examId, videoOptions = { width: 640, height: 480 }) {
|
|
22866
22887
|
_clear();
|
|
22867
22888
|
const { cameraId, microphoneId, allowOnlyFirstMonitor = true, allowMultipleMonitors = false, captureScreen = true, proctoringType } = options;
|
|
22868
|
-
|
|
22889
|
+
try {
|
|
22890
|
+
await initConfig();
|
|
22891
|
+
} catch (err) {
|
|
22892
|
+
trackers.registerError(proctoringId, "Erro no initConfig!");
|
|
22893
|
+
throw err;
|
|
22894
|
+
}
|
|
22869
22895
|
if (!allowMultipleMonitors) {
|
|
22870
22896
|
const hasMultipleMonitors = await checkIfhasMultipleMonitors();
|
|
22871
22897
|
if (hasMultipleMonitors) {
|
|
@@ -23022,13 +23048,13 @@ function useProctoring(proctoringOptions, proctoringConfig) {
|
|
|
23022
23048
|
}
|
|
23023
23049
|
try {
|
|
23024
23050
|
const uploadPromises = allFiles.map((c, i) => {
|
|
23025
|
-
return
|
|
23051
|
+
return upload({
|
|
23026
23052
|
file: c,
|
|
23027
23053
|
onProgress: (progress) => {
|
|
23028
23054
|
uploadProgress[i] = progress;
|
|
23029
23055
|
handleOnProgress();
|
|
23030
23056
|
}
|
|
23031
|
-
});
|
|
23057
|
+
}, proctoringId, proctoringOptions, proctoringConfig);
|
|
23032
23058
|
});
|
|
23033
23059
|
await Promise.all(uploadPromises);
|
|
23034
23060
|
trackers.registerUploadVideo(proctoringId, true, "");
|
package/index.js
CHANGED
|
@@ -22764,27 +22764,36 @@ async function startScreenCapture(buffer, options) {
|
|
|
22764
22764
|
|
|
22765
22765
|
// src/modules/upload.ts
|
|
22766
22766
|
var import_storage_blob = require("@azure/storage-blob");
|
|
22767
|
-
|
|
22768
|
-
|
|
22769
|
-
var
|
|
22770
|
-
var
|
|
22771
|
-
|
|
22772
|
-
|
|
22773
|
-
|
|
22774
|
-
|
|
22775
|
-
|
|
22776
|
-
}
|
|
22777
|
-
|
|
22778
|
-
|
|
22779
|
-
|
|
22780
|
-
|
|
22781
|
-
|
|
22782
|
-
|
|
22783
|
-
|
|
22784
|
-
|
|
22785
|
-
|
|
22786
|
-
}
|
|
22787
|
-
var
|
|
22767
|
+
|
|
22768
|
+
// src/plugins/insights.ts
|
|
22769
|
+
var import_applicationinsights_web = __toESM(require_applicationinsights_web());
|
|
22770
|
+
var insights;
|
|
22771
|
+
var init = (key) => {
|
|
22772
|
+
insights = new import_applicationinsights_web.ApplicationInsights({
|
|
22773
|
+
config: {
|
|
22774
|
+
instrumentationKey: key
|
|
22775
|
+
}
|
|
22776
|
+
});
|
|
22777
|
+
insights.loadAppInsights();
|
|
22778
|
+
return insights;
|
|
22779
|
+
};
|
|
22780
|
+
var eventNames = {
|
|
22781
|
+
START: "start",
|
|
22782
|
+
FINISH: "finish",
|
|
22783
|
+
ERROR: "error",
|
|
22784
|
+
UPLOAD_VIDEO: "upload_video"
|
|
22785
|
+
};
|
|
22786
|
+
var trackError = (exception) => insights.trackException({ exception });
|
|
22787
|
+
var registerCustomEvent = (eventName, properties) => insights.trackEvent({ name: eventName, properties });
|
|
22788
|
+
var trackPage = (name, uri, properties) => insights.trackPageView({ name, uri, properties });
|
|
22789
|
+
var trackers = {
|
|
22790
|
+
trackPage,
|
|
22791
|
+
trackError,
|
|
22792
|
+
registerStart: (proctoringId, success, description) => registerCustomEvent(eventNames.START, { proctoringId, success, description }),
|
|
22793
|
+
registerFinish: (proctoringId, success, description) => registerCustomEvent(eventNames.FINISH, { proctoringId, success, description }),
|
|
22794
|
+
registerError: (proctoringId, description) => registerCustomEvent(eventNames.ERROR, { proctoringId, description }),
|
|
22795
|
+
registerUploadVideo: (proctoringId, success, description) => registerCustomEvent(eventNames.UPLOAD_VIDEO, { proctoringId, success, description })
|
|
22796
|
+
};
|
|
22788
22797
|
|
|
22789
22798
|
// src/modules/http.ts
|
|
22790
22799
|
var baseUrl = "https://proctoring-api.easyproctor.tech/api";
|
|
@@ -22810,6 +22819,43 @@ async function makeRequest(data) {
|
|
|
22810
22819
|
return responseData;
|
|
22811
22820
|
}
|
|
22812
22821
|
|
|
22822
|
+
// src/modules/upload.ts
|
|
22823
|
+
var account = "";
|
|
22824
|
+
var containerName = "";
|
|
22825
|
+
var sas = "";
|
|
22826
|
+
var blobServiceClient;
|
|
22827
|
+
async function setConfiguration(_account, _cointainerName, _sas) {
|
|
22828
|
+
account = _account;
|
|
22829
|
+
containerName = _cointainerName;
|
|
22830
|
+
sas = _sas;
|
|
22831
|
+
blobServiceClient = new import_storage_blob.BlobServiceClient(`https://${account}.blob.core.windows.net${sas}`);
|
|
22832
|
+
}
|
|
22833
|
+
async function upload(data, proctoringId, proctoringOptions, proctoringConfig) {
|
|
22834
|
+
try {
|
|
22835
|
+
const { file, onProgress } = data;
|
|
22836
|
+
trackers.registerError(proctoringId, `Blob: Step 1 - ${containerName}`);
|
|
22837
|
+
if (blobServiceClient == void 0) {
|
|
22838
|
+
trackers.registerError(proctoringId, `blobServiceClient is undefined`);
|
|
22839
|
+
}
|
|
22840
|
+
const containerClient = blobServiceClient.getContainerClient(containerName);
|
|
22841
|
+
trackers.registerError(proctoringId, "Blob: Step 2 " + JSON.stringify(blobServiceClient));
|
|
22842
|
+
const blockBlobClient = containerClient.getBlockBlobClient(file.name);
|
|
22843
|
+
trackers.registerError(proctoringId, "Blob: Step 3");
|
|
22844
|
+
const progressCallback = (e) => {
|
|
22845
|
+
const progress = e.loadedBytes / file.size * 100;
|
|
22846
|
+
onProgress && onProgress(Math.round(progress));
|
|
22847
|
+
};
|
|
22848
|
+
trackers.registerError(proctoringId, "Blob: Step 4");
|
|
22849
|
+
await blockBlobClient.upload(file, file.size, { onProgress: progressCallback }).catch((error) => {
|
|
22850
|
+
trackers.registerError(proctoringId, "Erro on upload");
|
|
22851
|
+
throw error;
|
|
22852
|
+
});
|
|
22853
|
+
trackers.registerError(proctoringId, "Blob: Step 5");
|
|
22854
|
+
} catch (err) {
|
|
22855
|
+
throw err;
|
|
22856
|
+
}
|
|
22857
|
+
}
|
|
22858
|
+
|
|
22813
22859
|
// src/modules/enumarateDevices.ts
|
|
22814
22860
|
async function enumarateDevices() {
|
|
22815
22861
|
const mediaDevices = await navigator.mediaDevices.enumerateDevices();
|
|
@@ -22907,36 +22953,6 @@ async function clearBuffers(table) {
|
|
|
22907
22953
|
});
|
|
22908
22954
|
}
|
|
22909
22955
|
|
|
22910
|
-
// src/plugins/insights.ts
|
|
22911
|
-
var import_applicationinsights_web = __toESM(require_applicationinsights_web());
|
|
22912
|
-
var insights;
|
|
22913
|
-
var init = (key) => {
|
|
22914
|
-
insights = new import_applicationinsights_web.ApplicationInsights({
|
|
22915
|
-
config: {
|
|
22916
|
-
instrumentationKey: key
|
|
22917
|
-
}
|
|
22918
|
-
});
|
|
22919
|
-
insights.loadAppInsights();
|
|
22920
|
-
return insights;
|
|
22921
|
-
};
|
|
22922
|
-
var eventNames = {
|
|
22923
|
-
START: "start",
|
|
22924
|
-
FINISH: "finish",
|
|
22925
|
-
ERROR: "error",
|
|
22926
|
-
UPLOAD_VIDEO: "upload_video"
|
|
22927
|
-
};
|
|
22928
|
-
var trackError = (exception) => insights.trackException({ exception });
|
|
22929
|
-
var registerCustomEvent = (eventName, properties) => insights.trackEvent({ name: eventName, properties });
|
|
22930
|
-
var trackPage = (name, uri, properties) => insights.trackPageView({ name, uri, properties });
|
|
22931
|
-
var trackers = {
|
|
22932
|
-
trackPage,
|
|
22933
|
-
trackError,
|
|
22934
|
-
registerStart: (proctoringId, success, description) => registerCustomEvent(eventNames.START, { proctoringId, success, description }),
|
|
22935
|
-
registerFinish: (proctoringId, success, description) => registerCustomEvent(eventNames.FINISH, { proctoringId, success, description }),
|
|
22936
|
-
registerError: (proctoringId, description) => registerCustomEvent(eventNames.ERROR, { proctoringId, description }),
|
|
22937
|
-
registerUploadVideo: (proctoringId, success, description) => registerCustomEvent(eventNames.UPLOAD_VIDEO, { proctoringId, success, description })
|
|
22938
|
-
};
|
|
22939
|
-
|
|
22940
22956
|
// src/index.ts
|
|
22941
22957
|
var defaultProctoringOptions = {
|
|
22942
22958
|
cameraId: void 0,
|
|
@@ -23107,7 +23123,12 @@ function useProctoring(proctoringOptions, proctoringConfig) {
|
|
|
23107
23123
|
throw PROCTORING_ALREADY_STARTED;
|
|
23108
23124
|
lastClick = Date.now();
|
|
23109
23125
|
const { cameraId, microphoneId, allowOnlyFirstMonitor = true, allowMultipleMonitors = false, captureScreen = true, proctoringType } = options;
|
|
23110
|
-
|
|
23126
|
+
try {
|
|
23127
|
+
await initConfig();
|
|
23128
|
+
} catch (err) {
|
|
23129
|
+
trackers.registerError(proctoringId, "Erro no initConfig!");
|
|
23130
|
+
throw err;
|
|
23131
|
+
}
|
|
23111
23132
|
if (!allowMultipleMonitors) {
|
|
23112
23133
|
const hasMultipleMonitors = await checkIfhasMultipleMonitors();
|
|
23113
23134
|
if (hasMultipleMonitors) {
|
|
@@ -23194,7 +23215,12 @@ function useProctoring(proctoringOptions, proctoringConfig) {
|
|
|
23194
23215
|
async function resume(options = defaultProctoringOptions, examId, videoOptions = { width: 640, height: 480 }) {
|
|
23195
23216
|
_clear();
|
|
23196
23217
|
const { cameraId, microphoneId, allowOnlyFirstMonitor = true, allowMultipleMonitors = false, captureScreen = true, proctoringType } = options;
|
|
23197
|
-
|
|
23218
|
+
try {
|
|
23219
|
+
await initConfig();
|
|
23220
|
+
} catch (err) {
|
|
23221
|
+
trackers.registerError(proctoringId, "Erro no initConfig!");
|
|
23222
|
+
throw err;
|
|
23223
|
+
}
|
|
23198
23224
|
if (!allowMultipleMonitors) {
|
|
23199
23225
|
const hasMultipleMonitors = await checkIfhasMultipleMonitors();
|
|
23200
23226
|
if (hasMultipleMonitors) {
|
|
@@ -23351,13 +23377,13 @@ function useProctoring(proctoringOptions, proctoringConfig) {
|
|
|
23351
23377
|
}
|
|
23352
23378
|
try {
|
|
23353
23379
|
const uploadPromises = allFiles.map((c, i) => {
|
|
23354
|
-
return
|
|
23380
|
+
return upload({
|
|
23355
23381
|
file: c,
|
|
23356
23382
|
onProgress: (progress) => {
|
|
23357
23383
|
uploadProgress[i] = progress;
|
|
23358
23384
|
handleOnProgress();
|
|
23359
23385
|
}
|
|
23360
|
-
});
|
|
23386
|
+
}, proctoringId, proctoringOptions, proctoringConfig);
|
|
23361
23387
|
});
|
|
23362
23388
|
await Promise.all(uploadPromises);
|
|
23363
23389
|
trackers.registerUploadVideo(proctoringId, true, "");
|
package/modules/http.d.ts
CHANGED
package/modules/upload.d.ts
CHANGED
|
@@ -3,5 +3,5 @@ declare type UploadData = {
|
|
|
3
3
|
onProgress?: (progress: number) => void;
|
|
4
4
|
};
|
|
5
5
|
export declare function setConfiguration(_account: string, _cointainerName: string, _sas: string): Promise<void>;
|
|
6
|
-
|
|
7
|
-
export
|
|
6
|
+
export default function upload(data: UploadData, proctoringId: string, proctoringOptions: any, proctoringConfig: any): Promise<void>;
|
|
7
|
+
export {};
|