easyproctor 0.0.26 → 0.0.30
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 +53 -18
- package/index.js +53 -18
- package/package.json +1 -1
- package/unpkg/easyproctor.min.js +14 -14
package/esm/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
function recorder(stream, buffer) {
|
|
3
3
|
let resolvePromise;
|
|
4
4
|
const options = {
|
|
5
|
-
mimeType: "video/webm
|
|
5
|
+
mimeType: "video/webm",
|
|
6
6
|
videoBitsPerSecond: 128e3,
|
|
7
7
|
audioBitsPerSecond: 64 * 1e3
|
|
8
8
|
};
|
|
@@ -70,7 +70,16 @@ async function startScreenCapture(buffer, options) {
|
|
|
70
70
|
const screenStream = await navigator.mediaDevices.getDisplayMedia(displayMediaStreamConstraints);
|
|
71
71
|
const tracks = screenStream.getVideoTracks();
|
|
72
72
|
tracks[0].onended = onStopSharingScreenCallback;
|
|
73
|
-
const
|
|
73
|
+
const isFirefox = navigator.userAgent.indexOf("Firefox") > -1;
|
|
74
|
+
if (isFirefox) {
|
|
75
|
+
const hasMultipleMonitors = !tracks.find((el) => el.label == "Primary Monitor");
|
|
76
|
+
if (hasMultipleMonitors) {
|
|
77
|
+
throw MULTIPLE_MONITORS_DETECTED;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
const sharedFirstScreen = tracks.find((el) => {
|
|
81
|
+
return ["screen:0:0", "Primary Monitor"].includes(el.label);
|
|
82
|
+
}) != null;
|
|
74
83
|
if (!sharedFirstScreen && allowOnlyFirstMonitor) {
|
|
75
84
|
tracks.forEach((el) => {
|
|
76
85
|
el.stop();
|
|
@@ -133,11 +142,11 @@ async function makeRequest(data) {
|
|
|
133
142
|
async function enumarateDevices() {
|
|
134
143
|
const mediaDevices = await navigator.mediaDevices.enumerateDevices();
|
|
135
144
|
const devices = {
|
|
136
|
-
cameras: mediaDevices.filter((el) => el.kind == "videoinput" && el.deviceId
|
|
137
|
-
return { label: e.label, id: e.deviceId };
|
|
145
|
+
cameras: mediaDevices.filter((el) => el.kind == "videoinput" && el.deviceId).map((e) => {
|
|
146
|
+
return { label: e.label || "Generic Device", id: e.deviceId };
|
|
138
147
|
}),
|
|
139
|
-
microphones: mediaDevices.filter((el) => el.kind == "audioinput" && el.deviceId
|
|
140
|
-
return { label: e.label, id: e.deviceId };
|
|
148
|
+
microphones: mediaDevices.filter((el) => el.kind == "audioinput" && el.deviceId).map((e) => {
|
|
149
|
+
return { label: e.label || "Generic Device", id: e.deviceId };
|
|
141
150
|
})
|
|
142
151
|
};
|
|
143
152
|
return devices;
|
|
@@ -161,6 +170,9 @@ async function checkPermissions() {
|
|
|
161
170
|
}
|
|
162
171
|
async function checkIfhasMultipleMonitors() {
|
|
163
172
|
return new Promise((resolve, reject) => {
|
|
173
|
+
if (typeof PresentationRequest === "undefined") {
|
|
174
|
+
resolve(false);
|
|
175
|
+
}
|
|
164
176
|
const presentationRequest = new PresentationRequest("receiver.html");
|
|
165
177
|
presentationRequest.getAvailability().then((availability) => {
|
|
166
178
|
let hasMultipleMonitors = availability.value;
|
|
@@ -8281,6 +8293,7 @@ var defaultProctoringOptions = {
|
|
|
8281
8293
|
captureScreen: true
|
|
8282
8294
|
};
|
|
8283
8295
|
var azureBlobUrl = "";
|
|
8296
|
+
var _captureScreen = true;
|
|
8284
8297
|
function useProctoring(proctoringOptions, proctoringConfig) {
|
|
8285
8298
|
["examId", "clientId", "token"].forEach((el) => {
|
|
8286
8299
|
const key = el;
|
|
@@ -8288,7 +8301,7 @@ function useProctoring(proctoringOptions, proctoringConfig) {
|
|
|
8288
8301
|
throw REQUIRED_FIELD_NOT_PROVIDED + ": " + key;
|
|
8289
8302
|
}
|
|
8290
8303
|
});
|
|
8291
|
-
if (!navigator.mediaDevices.getDisplayMedia || !window.indexedDB
|
|
8304
|
+
if (!navigator.mediaDevices.getDisplayMedia || !window.indexedDB) {
|
|
8292
8305
|
throw INCOMPATIBLE_NAVIGATOR;
|
|
8293
8306
|
}
|
|
8294
8307
|
function download(file) {
|
|
@@ -8330,6 +8343,7 @@ function useProctoring(proctoringOptions, proctoringConfig) {
|
|
|
8330
8343
|
let cancelCameraCapture = null;
|
|
8331
8344
|
let cancelScreenCapture = null;
|
|
8332
8345
|
const { cameraId, microphoneId, allowOnlyFirstMonitor, captureScreen } = options;
|
|
8346
|
+
_captureScreen = captureScreen;
|
|
8333
8347
|
try {
|
|
8334
8348
|
let _screenStream = void 0;
|
|
8335
8349
|
if (captureScreen) {
|
|
@@ -8364,12 +8378,14 @@ function useProctoring(proctoringOptions, proctoringConfig) {
|
|
|
8364
8378
|
}
|
|
8365
8379
|
}
|
|
8366
8380
|
const _onLostFocus = () => {
|
|
8367
|
-
|
|
8368
|
-
|
|
8369
|
-
|
|
8370
|
-
|
|
8371
|
-
|
|
8372
|
-
|
|
8381
|
+
if (Date.now() - startTime > 1e4) {
|
|
8382
|
+
onLostFocusCallback && onLostFocusCallback();
|
|
8383
|
+
alerts.push({
|
|
8384
|
+
begin: Date.now() - startTime,
|
|
8385
|
+
alert: 25,
|
|
8386
|
+
end: 0
|
|
8387
|
+
});
|
|
8388
|
+
}
|
|
8373
8389
|
};
|
|
8374
8390
|
const _onReturnFocus = () => {
|
|
8375
8391
|
const lastAlert = alerts[alerts.length - 1];
|
|
@@ -8408,9 +8424,14 @@ function useProctoring(proctoringOptions, proctoringConfig) {
|
|
|
8408
8424
|
azureBlobUrl = proctoringConfig.azureBlobUrl;
|
|
8409
8425
|
setBaseUrl(proctoringConfig.baseUrl);
|
|
8410
8426
|
} else {
|
|
8411
|
-
|
|
8412
|
-
|
|
8413
|
-
|
|
8427
|
+
const config = await makeRequest({
|
|
8428
|
+
url: `/AzureKey`,
|
|
8429
|
+
method: "GET",
|
|
8430
|
+
jwt: proctoringOptions.token
|
|
8431
|
+
});
|
|
8432
|
+
setConfiguration(config.account, config.containerName, config.sas);
|
|
8433
|
+
azureBlobUrl = config.azureBlobUrl;
|
|
8434
|
+
setBaseUrl(config.baseUrl);
|
|
8414
8435
|
}
|
|
8415
8436
|
if (!allowMultipleMonitors) {
|
|
8416
8437
|
const hasMultipleMonitors = await checkIfhasMultipleMonitors();
|
|
@@ -8493,9 +8514,23 @@ function useProctoring(proctoringOptions, proctoringConfig) {
|
|
|
8493
8514
|
const { onProgress } = options;
|
|
8494
8515
|
const record = await getRecord("exams");
|
|
8495
8516
|
if (!record) {
|
|
8496
|
-
console.log("OXE");
|
|
8497
8517
|
throw PROCTORING_NOT_STARTED;
|
|
8498
8518
|
}
|
|
8519
|
+
try {
|
|
8520
|
+
if (azureBlobUrl == "") {
|
|
8521
|
+
const config = await makeRequest({
|
|
8522
|
+
url: `/AzureKey`,
|
|
8523
|
+
method: "GET",
|
|
8524
|
+
jwt: proctoringOptions.token
|
|
8525
|
+
});
|
|
8526
|
+
setConfiguration(config.account, config.containerName, config.sas);
|
|
8527
|
+
azureBlobUrl = config.azureBlobUrl;
|
|
8528
|
+
setBaseUrl(config.baseUrl);
|
|
8529
|
+
}
|
|
8530
|
+
} catch (error) {
|
|
8531
|
+
trackers.registerError(proctoringId, "Erro ao buscar credenciais!");
|
|
8532
|
+
throw "Erro ao buscar credenciais!";
|
|
8533
|
+
}
|
|
8499
8534
|
onStopSharingScreenCallback = void 0;
|
|
8500
8535
|
if (cancelCallback) {
|
|
8501
8536
|
await cancelCallback();
|
|
@@ -8557,7 +8592,7 @@ function useProctoring(proctoringOptions, proctoringConfig) {
|
|
|
8557
8592
|
body: {
|
|
8558
8593
|
endDate: time,
|
|
8559
8594
|
videoCameraUrl: `${azureBlobUrl}/` + sessionsDto[0].videoCameraUrl,
|
|
8560
|
-
videoScreenUrl: `${azureBlobUrl}/` + sessionsDto[0].videoScreenUrl
|
|
8595
|
+
videoScreenUrl: _captureScreen ? `${azureBlobUrl}/` + sessionsDto[0].videoScreenUrl : ""
|
|
8561
8596
|
},
|
|
8562
8597
|
jwt: proctoringOptions.token
|
|
8563
8598
|
});
|
package/index.js
CHANGED
|
@@ -8365,7 +8365,7 @@ __export(exports, {
|
|
|
8365
8365
|
function recorder(stream, buffer) {
|
|
8366
8366
|
let resolvePromise;
|
|
8367
8367
|
const options = {
|
|
8368
|
-
mimeType: "video/webm
|
|
8368
|
+
mimeType: "video/webm",
|
|
8369
8369
|
videoBitsPerSecond: 128e3,
|
|
8370
8370
|
audioBitsPerSecond: 64 * 1e3
|
|
8371
8371
|
};
|
|
@@ -8433,7 +8433,16 @@ async function startScreenCapture(buffer, options) {
|
|
|
8433
8433
|
const screenStream = await navigator.mediaDevices.getDisplayMedia(displayMediaStreamConstraints);
|
|
8434
8434
|
const tracks = screenStream.getVideoTracks();
|
|
8435
8435
|
tracks[0].onended = onStopSharingScreenCallback;
|
|
8436
|
-
const
|
|
8436
|
+
const isFirefox = navigator.userAgent.indexOf("Firefox") > -1;
|
|
8437
|
+
if (isFirefox) {
|
|
8438
|
+
const hasMultipleMonitors = !tracks.find((el) => el.label == "Primary Monitor");
|
|
8439
|
+
if (hasMultipleMonitors) {
|
|
8440
|
+
throw MULTIPLE_MONITORS_DETECTED;
|
|
8441
|
+
}
|
|
8442
|
+
}
|
|
8443
|
+
const sharedFirstScreen = tracks.find((el) => {
|
|
8444
|
+
return ["screen:0:0", "Primary Monitor"].includes(el.label);
|
|
8445
|
+
}) != null;
|
|
8437
8446
|
if (!sharedFirstScreen && allowOnlyFirstMonitor) {
|
|
8438
8447
|
tracks.forEach((el) => {
|
|
8439
8448
|
el.stop();
|
|
@@ -8496,11 +8505,11 @@ async function makeRequest(data) {
|
|
|
8496
8505
|
async function enumarateDevices() {
|
|
8497
8506
|
const mediaDevices = await navigator.mediaDevices.enumerateDevices();
|
|
8498
8507
|
const devices = {
|
|
8499
|
-
cameras: mediaDevices.filter((el) => el.kind == "videoinput" && el.deviceId
|
|
8500
|
-
return { label: e.label, id: e.deviceId };
|
|
8508
|
+
cameras: mediaDevices.filter((el) => el.kind == "videoinput" && el.deviceId).map((e) => {
|
|
8509
|
+
return { label: e.label || "Generic Device", id: e.deviceId };
|
|
8501
8510
|
}),
|
|
8502
|
-
microphones: mediaDevices.filter((el) => el.kind == "audioinput" && el.deviceId
|
|
8503
|
-
return { label: e.label, id: e.deviceId };
|
|
8511
|
+
microphones: mediaDevices.filter((el) => el.kind == "audioinput" && el.deviceId).map((e) => {
|
|
8512
|
+
return { label: e.label || "Generic Device", id: e.deviceId };
|
|
8504
8513
|
})
|
|
8505
8514
|
};
|
|
8506
8515
|
return devices;
|
|
@@ -8524,6 +8533,9 @@ async function checkPermissions() {
|
|
|
8524
8533
|
}
|
|
8525
8534
|
async function checkIfhasMultipleMonitors() {
|
|
8526
8535
|
return new Promise((resolve, reject) => {
|
|
8536
|
+
if (typeof PresentationRequest === "undefined") {
|
|
8537
|
+
resolve(false);
|
|
8538
|
+
}
|
|
8527
8539
|
const presentationRequest = new PresentationRequest("receiver.html");
|
|
8528
8540
|
presentationRequest.getAvailability().then((availability) => {
|
|
8529
8541
|
let hasMultipleMonitors = availability.value;
|
|
@@ -8621,6 +8633,7 @@ var defaultProctoringOptions = {
|
|
|
8621
8633
|
captureScreen: true
|
|
8622
8634
|
};
|
|
8623
8635
|
var azureBlobUrl = "";
|
|
8636
|
+
var _captureScreen = true;
|
|
8624
8637
|
function useProctoring(proctoringOptions, proctoringConfig) {
|
|
8625
8638
|
["examId", "clientId", "token"].forEach((el) => {
|
|
8626
8639
|
const key = el;
|
|
@@ -8628,7 +8641,7 @@ function useProctoring(proctoringOptions, proctoringConfig) {
|
|
|
8628
8641
|
throw REQUIRED_FIELD_NOT_PROVIDED + ": " + key;
|
|
8629
8642
|
}
|
|
8630
8643
|
});
|
|
8631
|
-
if (!navigator.mediaDevices.getDisplayMedia || !window.indexedDB
|
|
8644
|
+
if (!navigator.mediaDevices.getDisplayMedia || !window.indexedDB) {
|
|
8632
8645
|
throw INCOMPATIBLE_NAVIGATOR;
|
|
8633
8646
|
}
|
|
8634
8647
|
function download(file) {
|
|
@@ -8670,6 +8683,7 @@ function useProctoring(proctoringOptions, proctoringConfig) {
|
|
|
8670
8683
|
let cancelCameraCapture = null;
|
|
8671
8684
|
let cancelScreenCapture = null;
|
|
8672
8685
|
const { cameraId, microphoneId, allowOnlyFirstMonitor, captureScreen } = options;
|
|
8686
|
+
_captureScreen = captureScreen;
|
|
8673
8687
|
try {
|
|
8674
8688
|
let _screenStream = void 0;
|
|
8675
8689
|
if (captureScreen) {
|
|
@@ -8704,12 +8718,14 @@ function useProctoring(proctoringOptions, proctoringConfig) {
|
|
|
8704
8718
|
}
|
|
8705
8719
|
}
|
|
8706
8720
|
const _onLostFocus = () => {
|
|
8707
|
-
|
|
8708
|
-
|
|
8709
|
-
|
|
8710
|
-
|
|
8711
|
-
|
|
8712
|
-
|
|
8721
|
+
if (Date.now() - startTime > 1e4) {
|
|
8722
|
+
onLostFocusCallback && onLostFocusCallback();
|
|
8723
|
+
alerts.push({
|
|
8724
|
+
begin: Date.now() - startTime,
|
|
8725
|
+
alert: 25,
|
|
8726
|
+
end: 0
|
|
8727
|
+
});
|
|
8728
|
+
}
|
|
8713
8729
|
};
|
|
8714
8730
|
const _onReturnFocus = () => {
|
|
8715
8731
|
const lastAlert = alerts[alerts.length - 1];
|
|
@@ -8748,9 +8764,14 @@ function useProctoring(proctoringOptions, proctoringConfig) {
|
|
|
8748
8764
|
azureBlobUrl = proctoringConfig.azureBlobUrl;
|
|
8749
8765
|
setBaseUrl(proctoringConfig.baseUrl);
|
|
8750
8766
|
} else {
|
|
8751
|
-
|
|
8752
|
-
|
|
8753
|
-
|
|
8767
|
+
const config = await makeRequest({
|
|
8768
|
+
url: `/AzureKey`,
|
|
8769
|
+
method: "GET",
|
|
8770
|
+
jwt: proctoringOptions.token
|
|
8771
|
+
});
|
|
8772
|
+
setConfiguration(config.account, config.containerName, config.sas);
|
|
8773
|
+
azureBlobUrl = config.azureBlobUrl;
|
|
8774
|
+
setBaseUrl(config.baseUrl);
|
|
8754
8775
|
}
|
|
8755
8776
|
if (!allowMultipleMonitors) {
|
|
8756
8777
|
const hasMultipleMonitors = await checkIfhasMultipleMonitors();
|
|
@@ -8833,9 +8854,23 @@ function useProctoring(proctoringOptions, proctoringConfig) {
|
|
|
8833
8854
|
const { onProgress } = options;
|
|
8834
8855
|
const record = await getRecord("exams");
|
|
8835
8856
|
if (!record) {
|
|
8836
|
-
console.log("OXE");
|
|
8837
8857
|
throw PROCTORING_NOT_STARTED;
|
|
8838
8858
|
}
|
|
8859
|
+
try {
|
|
8860
|
+
if (azureBlobUrl == "") {
|
|
8861
|
+
const config = await makeRequest({
|
|
8862
|
+
url: `/AzureKey`,
|
|
8863
|
+
method: "GET",
|
|
8864
|
+
jwt: proctoringOptions.token
|
|
8865
|
+
});
|
|
8866
|
+
setConfiguration(config.account, config.containerName, config.sas);
|
|
8867
|
+
azureBlobUrl = config.azureBlobUrl;
|
|
8868
|
+
setBaseUrl(config.baseUrl);
|
|
8869
|
+
}
|
|
8870
|
+
} catch (error) {
|
|
8871
|
+
trackers.registerError(proctoringId, "Erro ao buscar credenciais!");
|
|
8872
|
+
throw "Erro ao buscar credenciais!";
|
|
8873
|
+
}
|
|
8839
8874
|
onStopSharingScreenCallback = void 0;
|
|
8840
8875
|
if (cancelCallback) {
|
|
8841
8876
|
await cancelCallback();
|
|
@@ -8897,7 +8932,7 @@ function useProctoring(proctoringOptions, proctoringConfig) {
|
|
|
8897
8932
|
body: {
|
|
8898
8933
|
endDate: time,
|
|
8899
8934
|
videoCameraUrl: `${azureBlobUrl}/` + sessionsDto[0].videoCameraUrl,
|
|
8900
|
-
videoScreenUrl: `${azureBlobUrl}/` + sessionsDto[0].videoScreenUrl
|
|
8935
|
+
videoScreenUrl: _captureScreen ? `${azureBlobUrl}/` + sessionsDto[0].videoScreenUrl : ""
|
|
8901
8936
|
},
|
|
8902
8937
|
jwt: proctoringOptions.token
|
|
8903
8938
|
});
|