easyproctor 0.0.27 → 0.0.29
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 +30 -8
- package/index.js +30 -8
- 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,9 @@ 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 sharedFirstScreen = tracks.find((el) =>
|
|
73
|
+
const sharedFirstScreen = tracks.find((el) => {
|
|
74
|
+
return ["screen:0:0", "Primary Monitor", ""].includes(el.label);
|
|
75
|
+
}) != null;
|
|
74
76
|
if (!sharedFirstScreen && allowOnlyFirstMonitor) {
|
|
75
77
|
tracks.forEach((el) => {
|
|
76
78
|
el.stop();
|
|
@@ -133,11 +135,11 @@ async function makeRequest(data) {
|
|
|
133
135
|
async function enumarateDevices() {
|
|
134
136
|
const mediaDevices = await navigator.mediaDevices.enumerateDevices();
|
|
135
137
|
const devices = {
|
|
136
|
-
cameras: mediaDevices.filter((el) => el.kind == "videoinput" && el.deviceId
|
|
137
|
-
return { label: e.label, id: e.deviceId };
|
|
138
|
+
cameras: mediaDevices.filter((el) => el.kind == "videoinput" && el.deviceId).map((e) => {
|
|
139
|
+
return { label: e.label || "Generic Device", id: e.deviceId };
|
|
138
140
|
}),
|
|
139
|
-
microphones: mediaDevices.filter((el) => el.kind == "audioinput" && el.deviceId
|
|
140
|
-
return { label: e.label, id: e.deviceId };
|
|
141
|
+
microphones: mediaDevices.filter((el) => el.kind == "audioinput" && el.deviceId).map((e) => {
|
|
142
|
+
return { label: e.label || "Generic Device", id: e.deviceId };
|
|
141
143
|
})
|
|
142
144
|
};
|
|
143
145
|
return devices;
|
|
@@ -161,6 +163,9 @@ async function checkPermissions() {
|
|
|
161
163
|
}
|
|
162
164
|
async function checkIfhasMultipleMonitors() {
|
|
163
165
|
return new Promise((resolve, reject) => {
|
|
166
|
+
if (typeof PresentationRequest === "undefined") {
|
|
167
|
+
resolve(false);
|
|
168
|
+
}
|
|
164
169
|
const presentationRequest = new PresentationRequest("receiver.html");
|
|
165
170
|
presentationRequest.getAvailability().then((availability) => {
|
|
166
171
|
let hasMultipleMonitors = availability.value;
|
|
@@ -8281,6 +8286,7 @@ var defaultProctoringOptions = {
|
|
|
8281
8286
|
captureScreen: true
|
|
8282
8287
|
};
|
|
8283
8288
|
var azureBlobUrl = "";
|
|
8289
|
+
var _captureScreen = true;
|
|
8284
8290
|
function useProctoring(proctoringOptions, proctoringConfig) {
|
|
8285
8291
|
["examId", "clientId", "token"].forEach((el) => {
|
|
8286
8292
|
const key = el;
|
|
@@ -8288,7 +8294,7 @@ function useProctoring(proctoringOptions, proctoringConfig) {
|
|
|
8288
8294
|
throw REQUIRED_FIELD_NOT_PROVIDED + ": " + key;
|
|
8289
8295
|
}
|
|
8290
8296
|
});
|
|
8291
|
-
if (!navigator.mediaDevices.getDisplayMedia || !window.indexedDB
|
|
8297
|
+
if (!navigator.mediaDevices.getDisplayMedia || !window.indexedDB) {
|
|
8292
8298
|
throw INCOMPATIBLE_NAVIGATOR;
|
|
8293
8299
|
}
|
|
8294
8300
|
function download(file) {
|
|
@@ -8330,6 +8336,7 @@ function useProctoring(proctoringOptions, proctoringConfig) {
|
|
|
8330
8336
|
let cancelCameraCapture = null;
|
|
8331
8337
|
let cancelScreenCapture = null;
|
|
8332
8338
|
const { cameraId, microphoneId, allowOnlyFirstMonitor, captureScreen } = options;
|
|
8339
|
+
_captureScreen = captureScreen;
|
|
8333
8340
|
try {
|
|
8334
8341
|
let _screenStream = void 0;
|
|
8335
8342
|
if (captureScreen) {
|
|
@@ -8500,6 +8507,21 @@ function useProctoring(proctoringOptions, proctoringConfig) {
|
|
|
8500
8507
|
if (!record) {
|
|
8501
8508
|
throw PROCTORING_NOT_STARTED;
|
|
8502
8509
|
}
|
|
8510
|
+
try {
|
|
8511
|
+
if (azureBlobUrl == "") {
|
|
8512
|
+
const config = await makeRequest({
|
|
8513
|
+
url: `/AzureKey`,
|
|
8514
|
+
method: "GET",
|
|
8515
|
+
jwt: proctoringOptions.token
|
|
8516
|
+
});
|
|
8517
|
+
setConfiguration(config.account, config.containerName, config.sas);
|
|
8518
|
+
azureBlobUrl = config.azureBlobUrl;
|
|
8519
|
+
setBaseUrl(config.baseUrl);
|
|
8520
|
+
}
|
|
8521
|
+
} catch (error) {
|
|
8522
|
+
trackers.registerError(proctoringId, "Erro ao buscar credenciais!");
|
|
8523
|
+
throw "Erro ao buscar credenciais!";
|
|
8524
|
+
}
|
|
8503
8525
|
onStopSharingScreenCallback = void 0;
|
|
8504
8526
|
if (cancelCallback) {
|
|
8505
8527
|
await cancelCallback();
|
|
@@ -8561,7 +8583,7 @@ function useProctoring(proctoringOptions, proctoringConfig) {
|
|
|
8561
8583
|
body: {
|
|
8562
8584
|
endDate: time,
|
|
8563
8585
|
videoCameraUrl: `${azureBlobUrl}/` + sessionsDto[0].videoCameraUrl,
|
|
8564
|
-
videoScreenUrl: `${azureBlobUrl}/` + sessionsDto[0].videoScreenUrl
|
|
8586
|
+
videoScreenUrl: _captureScreen ? `${azureBlobUrl}/` + sessionsDto[0].videoScreenUrl : ""
|
|
8565
8587
|
},
|
|
8566
8588
|
jwt: proctoringOptions.token
|
|
8567
8589
|
});
|
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,9 @@ 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 sharedFirstScreen = tracks.find((el) =>
|
|
8436
|
+
const sharedFirstScreen = tracks.find((el) => {
|
|
8437
|
+
return ["screen:0:0", "Primary Monitor", ""].includes(el.label);
|
|
8438
|
+
}) != null;
|
|
8437
8439
|
if (!sharedFirstScreen && allowOnlyFirstMonitor) {
|
|
8438
8440
|
tracks.forEach((el) => {
|
|
8439
8441
|
el.stop();
|
|
@@ -8496,11 +8498,11 @@ async function makeRequest(data) {
|
|
|
8496
8498
|
async function enumarateDevices() {
|
|
8497
8499
|
const mediaDevices = await navigator.mediaDevices.enumerateDevices();
|
|
8498
8500
|
const devices = {
|
|
8499
|
-
cameras: mediaDevices.filter((el) => el.kind == "videoinput" && el.deviceId
|
|
8500
|
-
return { label: e.label, id: e.deviceId };
|
|
8501
|
+
cameras: mediaDevices.filter((el) => el.kind == "videoinput" && el.deviceId).map((e) => {
|
|
8502
|
+
return { label: e.label || "Generic Device", id: e.deviceId };
|
|
8501
8503
|
}),
|
|
8502
|
-
microphones: mediaDevices.filter((el) => el.kind == "audioinput" && el.deviceId
|
|
8503
|
-
return { label: e.label, id: e.deviceId };
|
|
8504
|
+
microphones: mediaDevices.filter((el) => el.kind == "audioinput" && el.deviceId).map((e) => {
|
|
8505
|
+
return { label: e.label || "Generic Device", id: e.deviceId };
|
|
8504
8506
|
})
|
|
8505
8507
|
};
|
|
8506
8508
|
return devices;
|
|
@@ -8524,6 +8526,9 @@ async function checkPermissions() {
|
|
|
8524
8526
|
}
|
|
8525
8527
|
async function checkIfhasMultipleMonitors() {
|
|
8526
8528
|
return new Promise((resolve, reject) => {
|
|
8529
|
+
if (typeof PresentationRequest === "undefined") {
|
|
8530
|
+
resolve(false);
|
|
8531
|
+
}
|
|
8527
8532
|
const presentationRequest = new PresentationRequest("receiver.html");
|
|
8528
8533
|
presentationRequest.getAvailability().then((availability) => {
|
|
8529
8534
|
let hasMultipleMonitors = availability.value;
|
|
@@ -8621,6 +8626,7 @@ var defaultProctoringOptions = {
|
|
|
8621
8626
|
captureScreen: true
|
|
8622
8627
|
};
|
|
8623
8628
|
var azureBlobUrl = "";
|
|
8629
|
+
var _captureScreen = true;
|
|
8624
8630
|
function useProctoring(proctoringOptions, proctoringConfig) {
|
|
8625
8631
|
["examId", "clientId", "token"].forEach((el) => {
|
|
8626
8632
|
const key = el;
|
|
@@ -8628,7 +8634,7 @@ function useProctoring(proctoringOptions, proctoringConfig) {
|
|
|
8628
8634
|
throw REQUIRED_FIELD_NOT_PROVIDED + ": " + key;
|
|
8629
8635
|
}
|
|
8630
8636
|
});
|
|
8631
|
-
if (!navigator.mediaDevices.getDisplayMedia || !window.indexedDB
|
|
8637
|
+
if (!navigator.mediaDevices.getDisplayMedia || !window.indexedDB) {
|
|
8632
8638
|
throw INCOMPATIBLE_NAVIGATOR;
|
|
8633
8639
|
}
|
|
8634
8640
|
function download(file) {
|
|
@@ -8670,6 +8676,7 @@ function useProctoring(proctoringOptions, proctoringConfig) {
|
|
|
8670
8676
|
let cancelCameraCapture = null;
|
|
8671
8677
|
let cancelScreenCapture = null;
|
|
8672
8678
|
const { cameraId, microphoneId, allowOnlyFirstMonitor, captureScreen } = options;
|
|
8679
|
+
_captureScreen = captureScreen;
|
|
8673
8680
|
try {
|
|
8674
8681
|
let _screenStream = void 0;
|
|
8675
8682
|
if (captureScreen) {
|
|
@@ -8840,6 +8847,21 @@ function useProctoring(proctoringOptions, proctoringConfig) {
|
|
|
8840
8847
|
if (!record) {
|
|
8841
8848
|
throw PROCTORING_NOT_STARTED;
|
|
8842
8849
|
}
|
|
8850
|
+
try {
|
|
8851
|
+
if (azureBlobUrl == "") {
|
|
8852
|
+
const config = await makeRequest({
|
|
8853
|
+
url: `/AzureKey`,
|
|
8854
|
+
method: "GET",
|
|
8855
|
+
jwt: proctoringOptions.token
|
|
8856
|
+
});
|
|
8857
|
+
setConfiguration(config.account, config.containerName, config.sas);
|
|
8858
|
+
azureBlobUrl = config.azureBlobUrl;
|
|
8859
|
+
setBaseUrl(config.baseUrl);
|
|
8860
|
+
}
|
|
8861
|
+
} catch (error) {
|
|
8862
|
+
trackers.registerError(proctoringId, "Erro ao buscar credenciais!");
|
|
8863
|
+
throw "Erro ao buscar credenciais!";
|
|
8864
|
+
}
|
|
8843
8865
|
onStopSharingScreenCallback = void 0;
|
|
8844
8866
|
if (cancelCallback) {
|
|
8845
8867
|
await cancelCallback();
|
|
@@ -8901,7 +8923,7 @@ function useProctoring(proctoringOptions, proctoringConfig) {
|
|
|
8901
8923
|
body: {
|
|
8902
8924
|
endDate: time,
|
|
8903
8925
|
videoCameraUrl: `${azureBlobUrl}/` + sessionsDto[0].videoCameraUrl,
|
|
8904
|
-
videoScreenUrl: `${azureBlobUrl}/` + sessionsDto[0].videoScreenUrl
|
|
8926
|
+
videoScreenUrl: _captureScreen ? `${azureBlobUrl}/` + sessionsDto[0].videoScreenUrl : ""
|
|
8905
8927
|
},
|
|
8906
8928
|
jwt: proctoringOptions.token
|
|
8907
8929
|
});
|