easyproctor-hml 2.4.4 → 2.5.0
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 +281 -30
- package/extension/extensionEasyCatcher.d.ts +11 -0
- package/extension/{extension.d.ts → extensionEasyProctor.d.ts} +1 -1
- package/index.js +281 -30
- package/interfaces/Devices.d.ts +1 -0
- package/modules/onChangeDevices.d.ts +4 -1
- package/new-flow/backend/BackendService.d.ts +4 -1
- package/new-flow/checkers/DeviceCheckerService.d.ts +2 -0
- package/new-flow/proctoring/ProctoringSession.d.ts +2 -1
- package/new-flow/recorders/AlertRecorder.d.ts +5 -1
- package/new-flow/recorders/ScreenRecorder.d.ts +4 -0
- package/package.json +1 -1
- package/plugins/insights.d.ts +1 -0
- package/proctoring/options/ProctoringOptions.d.ts +5 -0
- package/proctoring/proctoring.d.ts +8 -0
- package/proctoring/useProctoring.d.ts +3 -1
- package/unpkg/easyproctor.min.js +38 -38
package/esm/index.js
CHANGED
|
@@ -9149,7 +9149,7 @@ var BackendService = class {
|
|
|
9149
9149
|
}
|
|
9150
9150
|
});
|
|
9151
9151
|
}
|
|
9152
|
-
async finishAndSendUrls(proctoringOptions,
|
|
9152
|
+
async finishAndSendUrls(proctoringOptions, sessionOptions) {
|
|
9153
9153
|
await this.makeRequest({
|
|
9154
9154
|
path: `/proctoring/finish/${proctoringOptions.examId}`,
|
|
9155
9155
|
method: "POST",
|
|
@@ -9157,7 +9157,8 @@ var BackendService = class {
|
|
|
9157
9157
|
endDate: (/* @__PURE__ */ new Date()).toISOString(),
|
|
9158
9158
|
videoCameraUrl: "",
|
|
9159
9159
|
audioCameraUrl: "",
|
|
9160
|
-
videoScreenUrl: ""
|
|
9160
|
+
videoScreenUrl: "",
|
|
9161
|
+
captureScreen: sessionOptions.captureScreen
|
|
9161
9162
|
},
|
|
9162
9163
|
jwt: proctoringOptions.token
|
|
9163
9164
|
});
|
|
@@ -9196,6 +9197,24 @@ var BackendService = class {
|
|
|
9196
9197
|
});
|
|
9197
9198
|
return result.data;
|
|
9198
9199
|
}
|
|
9200
|
+
async startChallenge(body) {
|
|
9201
|
+
const result = await this.makeRequestAxios({
|
|
9202
|
+
path: `/Challenge/start`,
|
|
9203
|
+
method: "POST",
|
|
9204
|
+
jwt: this.token,
|
|
9205
|
+
body
|
|
9206
|
+
});
|
|
9207
|
+
return result.data;
|
|
9208
|
+
}
|
|
9209
|
+
async stopChallenge(challengeId, body) {
|
|
9210
|
+
const result = await this.makeRequestAxios({
|
|
9211
|
+
path: `/Challenge/stop/${challengeId}`,
|
|
9212
|
+
method: "POST",
|
|
9213
|
+
jwt: this.token,
|
|
9214
|
+
body
|
|
9215
|
+
});
|
|
9216
|
+
return result.data;
|
|
9217
|
+
}
|
|
9199
9218
|
async getServerHour(token) {
|
|
9200
9219
|
return await this.makeRequest({
|
|
9201
9220
|
path: `/Proctoring/server-hour`,
|
|
@@ -9523,7 +9542,9 @@ var getDefaultProctoringOptions = {
|
|
|
9523
9542
|
onBufferSizeError: false,
|
|
9524
9543
|
useGeolocation: false,
|
|
9525
9544
|
useSpyScan: false,
|
|
9526
|
-
useExternalCamera: false
|
|
9545
|
+
useExternalCamera: false,
|
|
9546
|
+
useChallenge: false,
|
|
9547
|
+
screenRecorderOptions: { width: 1280, height: 720 }
|
|
9527
9548
|
};
|
|
9528
9549
|
|
|
9529
9550
|
// src/proctoring/options/ProctoringVideoOptions.ts
|
|
@@ -9553,6 +9574,7 @@ var init = (backend) => {
|
|
|
9553
9574
|
return backendService;
|
|
9554
9575
|
};
|
|
9555
9576
|
var eventNames = {
|
|
9577
|
+
DEVICES_CHECKED: "devices_checked",
|
|
9556
9578
|
START: "start",
|
|
9557
9579
|
FINISH: "finish",
|
|
9558
9580
|
ERROR: "error",
|
|
@@ -9569,6 +9591,7 @@ var eventNames = {
|
|
|
9569
9591
|
};
|
|
9570
9592
|
var log = (eventName, properties) => backendService && backendService.log(eventName, properties);
|
|
9571
9593
|
var trackers = {
|
|
9594
|
+
registerDevicesChecked: (proctoringId2, success, description) => log(eventNames.DEVICES_CHECKED, { proctoringId: proctoringId2, success, description }),
|
|
9572
9595
|
registerStart: (proctoringId2, success, description) => log(eventNames.START, { proctoringId: proctoringId2, success, description }),
|
|
9573
9596
|
registerFinish: (proctoringId2, success, description) => log(eventNames.FINISH, { proctoringId: proctoringId2, success, description }),
|
|
9574
9597
|
registerError: (proctoringId2, description) => log(eventNames.ERROR, { proctoringId: proctoringId2, description }),
|
|
@@ -11163,6 +11186,7 @@ Para iniciar um exame utilize uma outra c\xE2mera.`);
|
|
|
11163
11186
|
// src/new-flow/checkers/DeviceCheckerService.ts
|
|
11164
11187
|
var _DeviceCheckerService = class _DeviceCheckerService {
|
|
11165
11188
|
constructor(context) {
|
|
11189
|
+
this.deviceCheckResult = null;
|
|
11166
11190
|
this.videoOptions = {
|
|
11167
11191
|
width: 1080,
|
|
11168
11192
|
height: 720,
|
|
@@ -11193,6 +11217,9 @@ var _DeviceCheckerService = class _DeviceCheckerService {
|
|
|
11193
11217
|
token: context.token
|
|
11194
11218
|
});
|
|
11195
11219
|
}
|
|
11220
|
+
getDeviceCheckResult() {
|
|
11221
|
+
return this.deviceCheckResult;
|
|
11222
|
+
}
|
|
11196
11223
|
async runCheckDevicesFlow(options, _videoOptions, onModalConfirm, onModalCancel, onUpdate) {
|
|
11197
11224
|
if (_DeviceCheckerService.isModalOpen) {
|
|
11198
11225
|
return Promise.reject("Modal j\xE1 est\xE1 aberto");
|
|
@@ -11241,6 +11268,7 @@ var _DeviceCheckerService = class _DeviceCheckerService {
|
|
|
11241
11268
|
});
|
|
11242
11269
|
}
|
|
11243
11270
|
);
|
|
11271
|
+
this.deviceCheckResult = { ...returnData, result: resultPromise };
|
|
11244
11272
|
return { ...returnData, result: resultPromise };
|
|
11245
11273
|
} catch (error) {
|
|
11246
11274
|
this.closeCheckDevices();
|
|
@@ -11286,7 +11314,7 @@ var _DeviceCheckerService = class _DeviceCheckerService {
|
|
|
11286
11314
|
await this.checkSpyScan();
|
|
11287
11315
|
const { cameraId, microphoneId, result } = await this.DeviceCheckerUI.modalActions(() => this.closeCheckDevices());
|
|
11288
11316
|
return new Promise((resolve) => {
|
|
11289
|
-
|
|
11317
|
+
const response = {
|
|
11290
11318
|
result,
|
|
11291
11319
|
cameraId,
|
|
11292
11320
|
microphoneId,
|
|
@@ -11297,7 +11325,9 @@ var _DeviceCheckerService = class _DeviceCheckerService {
|
|
|
11297
11325
|
allowedMicrophone: this.allowedMicrophone,
|
|
11298
11326
|
allowedSpyScan: this.allowedSpyScan,
|
|
11299
11327
|
faceDetectionAlerts: this.faceDetectionAlerts
|
|
11300
|
-
}
|
|
11328
|
+
};
|
|
11329
|
+
this.deviceCheckResult = response;
|
|
11330
|
+
resolve(response);
|
|
11301
11331
|
});
|
|
11302
11332
|
} catch (error) {
|
|
11303
11333
|
this.closeCheckDevices();
|
|
@@ -11778,8 +11808,8 @@ var CapturePhoto = class {
|
|
|
11778
11808
|
}
|
|
11779
11809
|
};
|
|
11780
11810
|
|
|
11781
|
-
// src/extension/
|
|
11782
|
-
var
|
|
11811
|
+
// src/extension/extensionEasyProctor.ts
|
|
11812
|
+
var ExtensionEasyProctor = class {
|
|
11783
11813
|
constructor() {
|
|
11784
11814
|
this.hasExtension = false;
|
|
11785
11815
|
this.tryes = 0;
|
|
@@ -11824,11 +11854,96 @@ var Extension = class {
|
|
|
11824
11854
|
}
|
|
11825
11855
|
};
|
|
11826
11856
|
|
|
11857
|
+
// src/extension/extensionEasyCatcher.ts
|
|
11858
|
+
var ExtensionEasyCatcher = class {
|
|
11859
|
+
constructor(options) {
|
|
11860
|
+
this.hasExtension = false;
|
|
11861
|
+
this.tryes = 0;
|
|
11862
|
+
this.responseStart = false;
|
|
11863
|
+
this.options = options || {};
|
|
11864
|
+
}
|
|
11865
|
+
/**
|
|
11866
|
+
* Verifica se a extensão está instalada e ativa.
|
|
11867
|
+
* Retorna o número da versão se encontrada, ou lança erro após timeout.
|
|
11868
|
+
*/
|
|
11869
|
+
checkExtensionInstalled(timeoutMs = 2e3) {
|
|
11870
|
+
return new Promise((resolve, reject) => {
|
|
11871
|
+
let handled = false;
|
|
11872
|
+
const handler = (event) => {
|
|
11873
|
+
if (event.source === window && event.data.sender === "easyproctor-extension" && event.data.message_name === "version") {
|
|
11874
|
+
handled = true;
|
|
11875
|
+
window.removeEventListener("message", handler);
|
|
11876
|
+
resolve(event.data.message);
|
|
11877
|
+
}
|
|
11878
|
+
};
|
|
11879
|
+
window.addEventListener("message", handler);
|
|
11880
|
+
window.postMessage({
|
|
11881
|
+
type: "easycatcher",
|
|
11882
|
+
func: "verifyExtensionEasycatcher"
|
|
11883
|
+
}, "*");
|
|
11884
|
+
setTimeout(() => {
|
|
11885
|
+
if (!handled) {
|
|
11886
|
+
window.removeEventListener("message", handler);
|
|
11887
|
+
reject(new Error("Extens\xE3o n\xE3o detectada ou n\xE3o respondeu."));
|
|
11888
|
+
}
|
|
11889
|
+
}, timeoutMs);
|
|
11890
|
+
});
|
|
11891
|
+
}
|
|
11892
|
+
/**
|
|
11893
|
+
* Solicita o JSON da sessão atual capturado pela extensão.
|
|
11894
|
+
*/
|
|
11895
|
+
getSessionData(timeoutMs = 5e3) {
|
|
11896
|
+
return new Promise((resolve, reject) => {
|
|
11897
|
+
let handled = false;
|
|
11898
|
+
const handler = (event) => {
|
|
11899
|
+
if (event.source === window && event.data.sender === "easyproctor-extension" && event.data.message_name === "data_response") {
|
|
11900
|
+
handled = true;
|
|
11901
|
+
window.removeEventListener("message", handler);
|
|
11902
|
+
resolve(event.data.payload);
|
|
11903
|
+
}
|
|
11904
|
+
};
|
|
11905
|
+
window.addEventListener("message", handler);
|
|
11906
|
+
window.postMessage({
|
|
11907
|
+
type: "easycatcher",
|
|
11908
|
+
func: "getDataExtensionEasycatcher"
|
|
11909
|
+
}, "*");
|
|
11910
|
+
setTimeout(() => {
|
|
11911
|
+
if (!handled) {
|
|
11912
|
+
window.removeEventListener("message", handler);
|
|
11913
|
+
reject(new Error("Timeout ao aguardar dados da extens\xE3o."));
|
|
11914
|
+
}
|
|
11915
|
+
}, timeoutMs);
|
|
11916
|
+
});
|
|
11917
|
+
}
|
|
11918
|
+
start() {
|
|
11919
|
+
return new Promise((resolve, reject) => {
|
|
11920
|
+
let handled = false;
|
|
11921
|
+
const handler = (event) => {
|
|
11922
|
+
if (event.source === window && event.data.sender === "easyproctor-extension" && event.data.message_name === "started_confirmed") {
|
|
11923
|
+
handled = true;
|
|
11924
|
+
window.removeEventListener("message", handler);
|
|
11925
|
+
resolve(true);
|
|
11926
|
+
}
|
|
11927
|
+
};
|
|
11928
|
+
window.addEventListener("message", handler);
|
|
11929
|
+
window.postMessage({ type: "easycatcher", func: "startExtensionEasycatcher" }, "*");
|
|
11930
|
+
setTimeout(() => {
|
|
11931
|
+
if (!handled) {
|
|
11932
|
+
window.removeEventListener("message", handler);
|
|
11933
|
+
reject(new Error("Timeout: Extens\xE3o n\xE3o confirmou o in\xEDcio."));
|
|
11934
|
+
}
|
|
11935
|
+
}, 3e3);
|
|
11936
|
+
});
|
|
11937
|
+
}
|
|
11938
|
+
};
|
|
11939
|
+
|
|
11827
11940
|
// src/modules/onChangeDevices.ts
|
|
11828
11941
|
var onChangeDevices = class {
|
|
11829
|
-
constructor(repositoryDevices, proctoringId2) {
|
|
11942
|
+
constructor(repositoryDevices, proctoringId2, sessionOptions, allRecorders) {
|
|
11830
11943
|
this.repositoryDevices = repositoryDevices;
|
|
11831
11944
|
this.proctoringId = proctoringId2;
|
|
11945
|
+
this.sessionOptions = sessionOptions;
|
|
11946
|
+
this.allRecorders = allRecorders;
|
|
11832
11947
|
}
|
|
11833
11948
|
startRecording(options) {
|
|
11834
11949
|
navigator.mediaDevices.ondevicechange = () => {
|
|
@@ -11842,24 +11957,47 @@ var onChangeDevices = class {
|
|
|
11842
11957
|
const response = await this.repositoryDevices.getDevices("devices");
|
|
11843
11958
|
const defaultDevice = { label: "", id: "" };
|
|
11844
11959
|
const copy = { cameras: (response == null ? void 0 : response.cameras) || [defaultDevice], microphones: (response == null ? void 0 : response.microphones) || [defaultDevice] };
|
|
11845
|
-
|
|
11846
|
-
let
|
|
11960
|
+
const status = devices.cameras.length > (copy == null ? void 0 : copy.cameras.length) || devices.microphones.length > (copy == null ? void 0 : copy.microphones.length) ? "in" : "out";
|
|
11961
|
+
let resultCameras = [];
|
|
11962
|
+
let resultMicrophones = [];
|
|
11963
|
+
let isActiveDeviceRemoved = false;
|
|
11847
11964
|
if (devices.cameras.length != (copy == null ? void 0 : copy.cameras.length)) {
|
|
11848
|
-
|
|
11965
|
+
const removedCameras = status === "out" ? onlyInLeft(copy == null ? void 0 : copy.cameras, devices.cameras, isSameDevice) : [];
|
|
11966
|
+
const addedCameras = status === "in" ? onlyInLeft(devices.cameras, copy == null ? void 0 : copy.cameras, isSameDevice) : [];
|
|
11967
|
+
resultCameras = status === "out" ? removedCameras : addedCameras;
|
|
11849
11968
|
resultCameras = resultCameras.filter((item) => item.id != "default");
|
|
11969
|
+
console.log(removedCameras);
|
|
11970
|
+
console.log(this.sessionOptions.cameraId);
|
|
11971
|
+
if (status === "out") {
|
|
11972
|
+
isActiveDeviceRemoved = removedCameras.some(
|
|
11973
|
+
(device) => device.id === this.sessionOptions.cameraId
|
|
11974
|
+
);
|
|
11975
|
+
}
|
|
11850
11976
|
}
|
|
11851
11977
|
if (devices.microphones.length != (copy == null ? void 0 : copy.microphones.length)) {
|
|
11852
|
-
|
|
11978
|
+
const removedMicrophones = status === "out" ? onlyInLeft(copy == null ? void 0 : copy.microphones, devices.microphones, isSameDevice) : [];
|
|
11979
|
+
const addedMicrophones = status === "in" ? onlyInLeft(devices.microphones, copy == null ? void 0 : copy.microphones, isSameDevice) : [];
|
|
11980
|
+
resultMicrophones = status === "out" ? removedMicrophones : addedMicrophones;
|
|
11853
11981
|
resultMicrophones = resultMicrophones.filter((item) => item.id != "default" && item.id != "communications");
|
|
11982
|
+
if (status === "out" && !isActiveDeviceRemoved) {
|
|
11983
|
+
isActiveDeviceRemoved = removedMicrophones.some(
|
|
11984
|
+
(device) => device.id === this.sessionOptions.microphoneId
|
|
11985
|
+
);
|
|
11986
|
+
}
|
|
11854
11987
|
}
|
|
11855
11988
|
const devicesChanged = {
|
|
11856
11989
|
cameras: resultCameras || [],
|
|
11857
11990
|
microphones: resultMicrophones || [],
|
|
11858
|
-
status
|
|
11991
|
+
status,
|
|
11992
|
+
isActiveDevice: isActiveDeviceRemoved
|
|
11859
11993
|
};
|
|
11860
|
-
await this.repositoryDevices.save({ ...devices, id: "devices", status
|
|
11994
|
+
await this.repositoryDevices.save({ ...devices, id: "devices", status });
|
|
11861
11995
|
if (options.status && (devicesChanged.cameras.length != 0 || devicesChanged.microphones.length != 0)) {
|
|
11862
11996
|
trackers.registerChangeDevice(this.proctoringId, devicesChanged.status, JSON.stringify(devicesChanged, null, 2));
|
|
11997
|
+
this.allRecorders.alertRecorder.addAlert({
|
|
11998
|
+
alert: 34 /* StopSharingScreen */,
|
|
11999
|
+
type: 3 /* Screen */
|
|
12000
|
+
});
|
|
11863
12001
|
options.status(devicesChanged);
|
|
11864
12002
|
}
|
|
11865
12003
|
}
|
|
@@ -12067,6 +12205,14 @@ var AlertRecorder = class {
|
|
|
12067
12205
|
lastAlert.end = Date.now() - this.startTime.getTime();
|
|
12068
12206
|
}
|
|
12069
12207
|
}
|
|
12208
|
+
addAlert({ alert, type }) {
|
|
12209
|
+
this.alerts.push({
|
|
12210
|
+
begin: Date.now() - this.startTime.getTime(),
|
|
12211
|
+
end: Date.now() - this.startTime.getTime(),
|
|
12212
|
+
alert,
|
|
12213
|
+
type
|
|
12214
|
+
});
|
|
12215
|
+
}
|
|
12070
12216
|
};
|
|
12071
12217
|
|
|
12072
12218
|
// src/new-flow/recorders/AudioRecorder.ts
|
|
@@ -14556,18 +14702,36 @@ var ScreenRecorder = class {
|
|
|
14556
14702
|
async startRecording() {
|
|
14557
14703
|
this.startTime = new Date(Date.now());
|
|
14558
14704
|
const { allowOnlyFirstMonitor, allowMultipleMonitors, onStopSharingScreenCallback, onBufferSizeErrorCallback } = this.options;
|
|
14559
|
-
const
|
|
14705
|
+
const complexConstraints = {
|
|
14560
14706
|
video: {
|
|
14561
14707
|
cursor: "always",
|
|
14562
|
-
width:
|
|
14563
|
-
height:
|
|
14708
|
+
width: this.options.screenRecorderOptions.width,
|
|
14709
|
+
height: this.options.screenRecorderOptions.height,
|
|
14564
14710
|
displaySurface: "monitor"
|
|
14565
14711
|
},
|
|
14566
14712
|
audio: false
|
|
14567
14713
|
};
|
|
14568
|
-
|
|
14569
|
-
|
|
14570
|
-
|
|
14714
|
+
const simpleConstraints = {
|
|
14715
|
+
video: {
|
|
14716
|
+
cursor: "always",
|
|
14717
|
+
width: 1280,
|
|
14718
|
+
height: 720,
|
|
14719
|
+
displaySurface: "monitor"
|
|
14720
|
+
},
|
|
14721
|
+
audio: false
|
|
14722
|
+
};
|
|
14723
|
+
let stream;
|
|
14724
|
+
try {
|
|
14725
|
+
stream = await navigator.mediaDevices.getDisplayMedia(complexConstraints);
|
|
14726
|
+
} catch (e3) {
|
|
14727
|
+
if (e3 instanceof TypeError && e3.message.includes("min constraints are not supported")) {
|
|
14728
|
+
console.warn("Navegador n\xE3o suporta restri\xE7\xF5es 'min/max/ideal'. Tentando com 720p fixo.");
|
|
14729
|
+
stream = await navigator.mediaDevices.getDisplayMedia(simpleConstraints);
|
|
14730
|
+
} else {
|
|
14731
|
+
throw e3;
|
|
14732
|
+
}
|
|
14733
|
+
}
|
|
14734
|
+
this.screenStream = stream;
|
|
14571
14735
|
const tracks = this.screenStream.getVideoTracks();
|
|
14572
14736
|
tracks[0].onended = onStopSharingScreenCallback;
|
|
14573
14737
|
const isFirefox = navigator.userAgent.indexOf("Firefox") > -1;
|
|
@@ -18414,13 +18578,10 @@ var ExternalCameraChecker = _ExternalCameraChecker;
|
|
|
18414
18578
|
|
|
18415
18579
|
// src/proctoring/proctoring.ts
|
|
18416
18580
|
var Proctoring = class {
|
|
18417
|
-
// private onProgress = (percentage: number) => {};
|
|
18418
|
-
// public setOnProgress(cb: (percentage: number) => void) {
|
|
18419
|
-
// console.log("proctoring.setOnProgress");
|
|
18420
|
-
// this.onProgress = (percentage) => cb(percentage);
|
|
18421
|
-
// }
|
|
18422
18581
|
constructor(context) {
|
|
18423
18582
|
this.context = context;
|
|
18583
|
+
this.deviceData = null;
|
|
18584
|
+
this.sessionStartTime = 0;
|
|
18424
18585
|
this.paramsConfig = {
|
|
18425
18586
|
audioBehaviourParameters: {
|
|
18426
18587
|
recordingBitrate: 128,
|
|
@@ -18473,11 +18634,17 @@ var Proctoring = class {
|
|
|
18473
18634
|
this.appChecker = new ExternalCameraChecker(this.context, (response) => this.onRealtimeAlertsCallback(response));
|
|
18474
18635
|
}
|
|
18475
18636
|
setOnStopSharingScreenCallback(cb) {
|
|
18476
|
-
this.onStopSharingScreenCallback = () => {
|
|
18637
|
+
this.onStopSharingScreenCallback = async () => {
|
|
18638
|
+
var _a2, _b, _c2, _d;
|
|
18477
18639
|
trackers.registerStopSharingScreen(
|
|
18478
18640
|
this.proctoringId,
|
|
18479
18641
|
"Stop sharing screen"
|
|
18480
18642
|
);
|
|
18643
|
+
(_b = (_a2 = this.allRecorders) == null ? void 0 : _a2.alertRecorder) == null ? void 0 : _b.addAlert({
|
|
18644
|
+
alert: 34 /* StopSharingScreen */,
|
|
18645
|
+
type: 3 /* Screen */
|
|
18646
|
+
});
|
|
18647
|
+
(_d = (_c2 = this.allRecorders) == null ? void 0 : _c2.screenRecorder) == null ? void 0 : _d.stopRecording();
|
|
18481
18648
|
cb();
|
|
18482
18649
|
};
|
|
18483
18650
|
}
|
|
@@ -18490,7 +18657,9 @@ var Proctoring = class {
|
|
|
18490
18657
|
async onChangeDevices(options = {}) {
|
|
18491
18658
|
const onChange = new onChangeDevices(
|
|
18492
18659
|
this.repositoryDevices,
|
|
18493
|
-
this.proctoringId
|
|
18660
|
+
this.proctoringId,
|
|
18661
|
+
this.sessionOptions,
|
|
18662
|
+
this.allRecorders
|
|
18494
18663
|
);
|
|
18495
18664
|
onChange.startRecording(options);
|
|
18496
18665
|
this.onChangeDevicesCallback = (devices) => options.status && options.status(devices);
|
|
@@ -18501,6 +18670,14 @@ var Proctoring = class {
|
|
|
18501
18670
|
setOnBufferSizeErrorCallback(cb) {
|
|
18502
18671
|
this.onBufferSizeErrorCallback = (cameraStream) => cb(cameraStream);
|
|
18503
18672
|
}
|
|
18673
|
+
// private onProgress = (percentage: number) => {};
|
|
18674
|
+
// public setOnProgress(cb: (percentage: number) => void) {
|
|
18675
|
+
// console.log("proctoring.setOnProgress");
|
|
18676
|
+
// this.onProgress = (percentage) => cb(percentage);
|
|
18677
|
+
// }
|
|
18678
|
+
setDeviceCheckData(data) {
|
|
18679
|
+
this.deviceData = data;
|
|
18680
|
+
}
|
|
18504
18681
|
createRecorders(options = getDefaultProctoringOptions) {
|
|
18505
18682
|
var _a2, _b;
|
|
18506
18683
|
this.onChangeDevices();
|
|
@@ -18527,6 +18704,7 @@ var Proctoring = class {
|
|
|
18527
18704
|
const screenRecorder = this.sessionOptions.captureScreen ? new ScreenRecorder({
|
|
18528
18705
|
allowOnlyFirstMonitor: (_a2 = this.sessionOptions.allowOnlyFirstMonitor) != null ? _a2 : true,
|
|
18529
18706
|
allowMultipleMonitors: (_b = this.sessionOptions.allowMultipleMonitors) != null ? _b : true,
|
|
18707
|
+
screenRecorderOptions: this.sessionOptions.screenRecorderOptions,
|
|
18530
18708
|
onStopSharingScreenCallback: () => this.onStopSharingScreenCallback(),
|
|
18531
18709
|
onBufferSizeError: this.sessionOptions.onBufferSizeError,
|
|
18532
18710
|
onBufferSizeErrorCallback: () => this.onBufferSizeErrorCallback()
|
|
@@ -18567,7 +18745,10 @@ var Proctoring = class {
|
|
|
18567
18745
|
if (this.context.token === void 0) {
|
|
18568
18746
|
throw TOKEN_MISSING;
|
|
18569
18747
|
}
|
|
18570
|
-
|
|
18748
|
+
if (options.useChallenge) {
|
|
18749
|
+
this.extensionEasycatcher = new ExtensionEasyCatcher();
|
|
18750
|
+
}
|
|
18751
|
+
this.extension = new ExtensionEasyProctor();
|
|
18571
18752
|
this.extension.addEventListener();
|
|
18572
18753
|
const baseURL = this.backend.selectBaseUrl(this.context.type);
|
|
18573
18754
|
const devices = await enumarateDevices();
|
|
@@ -18611,6 +18792,12 @@ var Proctoring = class {
|
|
|
18611
18792
|
} catch (error) {
|
|
18612
18793
|
throw EXTERNAL_CAMERA_NOT_STARTED;
|
|
18613
18794
|
}
|
|
18795
|
+
this.sessionStartTime = Date.now();
|
|
18796
|
+
trackers.registerDevicesChecked(
|
|
18797
|
+
this.proctoringId,
|
|
18798
|
+
!!this.deviceData,
|
|
18799
|
+
`Devices checked: ${JSON.stringify(this.deviceData)} | Devices List: ${devices}`
|
|
18800
|
+
);
|
|
18614
18801
|
this.allRecorders.cameraRecorder.setProctoringId(this.proctoringId);
|
|
18615
18802
|
this.allRecorders.noiseRecorder.setProctoringId(this.proctoringId);
|
|
18616
18803
|
this.proctoringSession.setProctoringId(this.proctoringId);
|
|
@@ -18755,7 +18942,7 @@ Upload Services: ${uploaderServices}`,
|
|
|
18755
18942
|
);
|
|
18756
18943
|
});
|
|
18757
18944
|
}
|
|
18758
|
-
await this.backend.finishAndSendUrls(this.context, this.
|
|
18945
|
+
await this.backend.finishAndSendUrls(this.context, this.sessionOptions).then(() => {
|
|
18759
18946
|
trackers.registerFinish(this.proctoringSession.id, true, "");
|
|
18760
18947
|
}).catch((error) => {
|
|
18761
18948
|
trackers.registerFinish(
|
|
@@ -18883,6 +19070,59 @@ Error: ` + error
|
|
|
18883
19070
|
_screenStream: (_a2 = this.allRecorders.screenRecorder) == null ? void 0 : _a2.screenStream
|
|
18884
19071
|
};
|
|
18885
19072
|
}
|
|
19073
|
+
async startChallenge(templateId) {
|
|
19074
|
+
if (!this.sessionOptions.useChallenge) {
|
|
19075
|
+
throw new Error("useChallenge is set as false on start method");
|
|
19076
|
+
}
|
|
19077
|
+
await this.extensionEasycatcher.checkExtensionInstalled().catch((err) => {
|
|
19078
|
+
throw new Error("EasyCatcher Extension is not installed");
|
|
19079
|
+
});
|
|
19080
|
+
this.extensionEasycatcher.start();
|
|
19081
|
+
const start = Date.now() - this.sessionStartTime;
|
|
19082
|
+
await this.backend.startChallenge({
|
|
19083
|
+
proctoringId: this.proctoringId,
|
|
19084
|
+
templateId,
|
|
19085
|
+
start
|
|
19086
|
+
}).then((resp) => {
|
|
19087
|
+
console.log(resp);
|
|
19088
|
+
this.challengeId = resp.id;
|
|
19089
|
+
}).catch((reason) => {
|
|
19090
|
+
trackers.registerError(
|
|
19091
|
+
this.proctoringId,
|
|
19092
|
+
"N\xE3o foi poss\xEDvel iniciar desafio!"
|
|
19093
|
+
);
|
|
19094
|
+
throw reason;
|
|
19095
|
+
});
|
|
19096
|
+
this.isChallengeRunning = true;
|
|
19097
|
+
}
|
|
19098
|
+
async stopChallenge() {
|
|
19099
|
+
if (!this.isChallengeRunning) {
|
|
19100
|
+
throw new Error("Challenge not started");
|
|
19101
|
+
}
|
|
19102
|
+
try {
|
|
19103
|
+
const sessionData = await this.extensionEasycatcher.getSessionData();
|
|
19104
|
+
const end = Date.now() - this.sessionStartTime;
|
|
19105
|
+
await this.backend.stopChallenge(
|
|
19106
|
+
this.challengeId,
|
|
19107
|
+
{
|
|
19108
|
+
end,
|
|
19109
|
+
data: sessionData
|
|
19110
|
+
}
|
|
19111
|
+
).catch((reason) => {
|
|
19112
|
+
trackers.registerError(
|
|
19113
|
+
this.proctoringId,
|
|
19114
|
+
"N\xE3o foi poss\xEDvel finalizar o desafio no backend!"
|
|
19115
|
+
);
|
|
19116
|
+
return void 0;
|
|
19117
|
+
});
|
|
19118
|
+
this.isChallengeRunning = false;
|
|
19119
|
+
} catch (error) {
|
|
19120
|
+
trackers.registerError(
|
|
19121
|
+
this.proctoringId,
|
|
19122
|
+
"Erro ao recuperar dados da extens\xE3o: " + error.message
|
|
19123
|
+
);
|
|
19124
|
+
}
|
|
19125
|
+
}
|
|
18886
19126
|
};
|
|
18887
19127
|
|
|
18888
19128
|
// src/proctoring/SignTerm.ts
|
|
@@ -19101,8 +19341,17 @@ function useProctoring(proctoringOptions, enviromentConfig = "prod") {
|
|
|
19101
19341
|
const signTerm = new SignTerm(parameters);
|
|
19102
19342
|
const photo = new CapturePhoto();
|
|
19103
19343
|
const login = proctoring.login.bind(proctoring);
|
|
19104
|
-
const
|
|
19344
|
+
const originalStart = proctoring.start.bind(proctoring);
|
|
19345
|
+
const start = async (parameters2) => {
|
|
19346
|
+
const deviceResult = checker.getDeviceCheckResult();
|
|
19347
|
+
if (deviceResult) {
|
|
19348
|
+
proctoring.setDeviceCheckData(deviceResult);
|
|
19349
|
+
}
|
|
19350
|
+
return originalStart(parameters2);
|
|
19351
|
+
};
|
|
19105
19352
|
const finish = proctoring.finish.bind(proctoring);
|
|
19353
|
+
const startChallenge = proctoring.startChallenge.bind(proctoring);
|
|
19354
|
+
const stopChallenge = proctoring.stopChallenge.bind(proctoring);
|
|
19106
19355
|
const pause = proctoring.pause.bind(proctoring);
|
|
19107
19356
|
const resume = proctoring.resume.bind(proctoring);
|
|
19108
19357
|
const onFocus = proctoring.setOnFocusCallback.bind(proctoring);
|
|
@@ -19125,6 +19374,8 @@ function useProctoring(proctoringOptions, enviromentConfig = "prod") {
|
|
|
19125
19374
|
login,
|
|
19126
19375
|
start,
|
|
19127
19376
|
finish,
|
|
19377
|
+
startChallenge,
|
|
19378
|
+
stopChallenge,
|
|
19128
19379
|
onFocus,
|
|
19129
19380
|
onLostFocus,
|
|
19130
19381
|
onChangeDevices: onChangeDevices2,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ProctoringFinisherOptions } from "../proctoring/proctoring";
|
|
2
|
+
export declare class ExtensionEasyCatcher {
|
|
3
|
+
hasExtension: boolean;
|
|
4
|
+
tryes: number;
|
|
5
|
+
responseStart: boolean;
|
|
6
|
+
options: ProctoringFinisherOptions;
|
|
7
|
+
constructor(options?: ProctoringFinisherOptions);
|
|
8
|
+
checkExtensionInstalled(timeoutMs?: number): Promise<string>;
|
|
9
|
+
getSessionData(timeoutMs?: number): Promise<any>;
|
|
10
|
+
start(): Promise<boolean>;
|
|
11
|
+
}
|