easyproctor-hml 0.0.77 → 1.0.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/README.md +119 -23
- package/esm/index.js +144 -74
- package/index.js +144 -74
- package/modules/BaseDetection.d.ts +1 -1
- package/new-flow/recorders/NoiseRecorder.d.ts +2 -1
- package/new-flow/recorders/VolumeMeter.d.ts +3 -2
- package/package.json +1 -1
- package/proctoring/useProctoring.d.ts +0 -6
- package/unpkg/easyproctor.min.js +23 -24
- package/unpkg/easyproctor.min.js.map +0 -7
package/README.md
CHANGED
|
@@ -35,7 +35,22 @@ Em um bundler
|
|
|
35
35
|
```javascript
|
|
36
36
|
import { useProctoring } from "easyproctor";
|
|
37
37
|
|
|
38
|
-
const {
|
|
38
|
+
const {
|
|
39
|
+
login,
|
|
40
|
+
start,
|
|
41
|
+
finish,
|
|
42
|
+
checkDevices,
|
|
43
|
+
capturePhoto,
|
|
44
|
+
checkPermissions,
|
|
45
|
+
enumarateDevices,
|
|
46
|
+
checkIfhasMultipleMonitors,
|
|
47
|
+
onFocus,
|
|
48
|
+
onLostFocus,
|
|
49
|
+
onChangeDevices,
|
|
50
|
+
onRealtimeAlerts,
|
|
51
|
+
onBufferSizeError,
|
|
52
|
+
onStopSharingScreen,
|
|
53
|
+
} = useProctoring({
|
|
39
54
|
examId: "00001",
|
|
40
55
|
clientId: "000001",
|
|
41
56
|
token: "...",
|
|
@@ -47,11 +62,26 @@ Via CDN: A função "useProctoring" é injetada para ser utilizada globalmente
|
|
|
47
62
|
```html
|
|
48
63
|
<script src="https://cdn.jsdelivr.net/npm/easyproctor/unpkg/easyproctor.min.js"></script>
|
|
49
64
|
<script>
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
65
|
+
const {
|
|
66
|
+
login,
|
|
67
|
+
start,
|
|
68
|
+
finish,
|
|
69
|
+
checkDevices,
|
|
70
|
+
capturePhoto,
|
|
71
|
+
checkPermissions,
|
|
72
|
+
enumarateDevices,
|
|
73
|
+
checkIfhasMultipleMonitors,
|
|
74
|
+
onFocus,
|
|
75
|
+
onLostFocus,
|
|
76
|
+
onChangeDevices,
|
|
77
|
+
onRealtimeAlerts,
|
|
78
|
+
onBufferSizeError,
|
|
79
|
+
onStopSharingScreen,
|
|
80
|
+
} = useProctoring({
|
|
81
|
+
examId: "00001",
|
|
82
|
+
clientId: "000001",
|
|
83
|
+
token: "...",
|
|
84
|
+
});
|
|
55
85
|
</script>
|
|
56
86
|
```
|
|
57
87
|
|
|
@@ -67,14 +97,22 @@ Via CDN: A função "useProctoring" é injetada para ser utilizada globalmente
|
|
|
67
97
|
<title>Document</title>
|
|
68
98
|
<script src="dist/unpkg/easyproctor.min.js"></script>
|
|
69
99
|
<script>
|
|
70
|
-
|
|
100
|
+
const {
|
|
101
|
+
login,
|
|
71
102
|
start,
|
|
72
103
|
finish,
|
|
104
|
+
checkDevices,
|
|
105
|
+
capturePhoto,
|
|
106
|
+
checkPermissions,
|
|
107
|
+
enumarateDevices,
|
|
108
|
+
checkIfhasMultipleMonitors,
|
|
73
109
|
onFocus,
|
|
74
110
|
onLostFocus,
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
111
|
+
onChangeDevices,
|
|
112
|
+
onRealtimeAlerts,
|
|
113
|
+
onBufferSizeError,
|
|
114
|
+
onStopSharingScreen
|
|
115
|
+
} = useProctoring({
|
|
78
116
|
examId: "00001",
|
|
79
117
|
clientId: "000001",
|
|
80
118
|
token: "...",
|
|
@@ -184,34 +222,41 @@ const {
|
|
|
184
222
|
// Inicia a gravação da prova
|
|
185
223
|
start,
|
|
186
224
|
|
|
187
|
-
// Pausa a gravação
|
|
188
|
-
pause,
|
|
189
|
-
|
|
190
|
-
// Reinicia a gravação
|
|
191
|
-
resume,
|
|
192
|
-
|
|
193
225
|
// Finaliza a gravação da prova retornando os arquivos gerados
|
|
194
226
|
finish,
|
|
195
227
|
|
|
196
228
|
// Adiciona uma função callback para ser executada quando o usuário recupera o foco da tela
|
|
197
229
|
onFocus,
|
|
198
230
|
|
|
231
|
+
// Adiciona uma função de callback para ser executada quando ...
|
|
232
|
+
onBufferSizeError,
|
|
233
|
+
|
|
234
|
+
// Adiciona um função de callback para ser executada quando o usuário altera os dispositivos
|
|
235
|
+
onChangeDevices,
|
|
236
|
+
|
|
199
237
|
// Adiciona uma função callback para ser executada quando o usuário perde o foco da tela
|
|
200
238
|
onLostFocus,
|
|
201
239
|
|
|
240
|
+
// Adiciona uma função de callback para ser executada quando ocorrem alertas durante o exame
|
|
241
|
+
onRealtimeAlerts,
|
|
242
|
+
|
|
202
243
|
// Adiciona uma função callback para ser executada quando o usuário cancela o compartilhamento de tela
|
|
203
244
|
onStopSharingScreen
|
|
204
245
|
|
|
205
|
-
//
|
|
206
|
-
|
|
246
|
+
// Realiza uma captura de foto do usuário e a utiliza para fazer o resgistro ou login biométrico.
|
|
247
|
+
capturePhoto
|
|
207
248
|
|
|
208
|
-
// Checa
|
|
209
|
-
|
|
249
|
+
// Checa se os dispositivos (câmera, microfone, stream da tela) estão funcionando corretamente
|
|
250
|
+
checkDevices,
|
|
210
251
|
|
|
211
252
|
// Checa se existe mais de um monitor
|
|
212
|
-
checkIfhasMultipleMonitors
|
|
253
|
+
checkIfhasMultipleMonitors,
|
|
213
254
|
|
|
214
|
-
|
|
255
|
+
// Checa as permissões de camera e microfone
|
|
256
|
+
checkPermissions,
|
|
257
|
+
|
|
258
|
+
// Enumera os dispositivos de camera e microfone
|
|
259
|
+
enumarateDevices,
|
|
215
260
|
} = useProctoring({
|
|
216
261
|
examId: "00001",
|
|
217
262
|
clientId: "000001",
|
|
@@ -219,9 +264,60 @@ const {
|
|
|
219
264
|
});
|
|
220
265
|
```
|
|
221
266
|
|
|
267
|
+
## Release Note V 2.0.0
|
|
268
|
+
- Remoção do script deprecated AudioProcessor
|
|
269
|
+
- Monitoramento ativo durante o exame
|
|
270
|
+
- Novos tipos de alertas do onRealtimeAlerts:
|
|
271
|
+
- audio_detection_on_stream
|
|
272
|
+
- face_detection_on_stream
|
|
273
|
+
- mobile_detection_on_stream
|
|
274
|
+
- person_detection_on_stream
|
|
275
|
+
- position_detection_on_stream
|
|
276
|
+
- Nova forma de gravação de áudio
|
|
277
|
+
- Remoção das funções `pause()` e `resume()`
|
|
278
|
+
- Análise de posicionamento da face no modal do `checkDevices()`
|
|
279
|
+
- Novas propriedades adicionadas no retorno do `checkDevices()`:
|
|
280
|
+
|
|
281
|
+
```ts
|
|
282
|
+
{
|
|
283
|
+
allowedPositionFace: boolean,
|
|
284
|
+
allowedMicrophone: boolean,
|
|
285
|
+
allowedPositionFace: boolean,
|
|
286
|
+
allowedResolution: boolean,
|
|
287
|
+
cameraId: string,
|
|
288
|
+
michophoneId: string,
|
|
289
|
+
volumeRange: number,
|
|
290
|
+
faceDetectionAlerts: { status: 'OK' | 'ALERT', type: string, description?: string },
|
|
291
|
+
result: boolean,
|
|
292
|
+
}
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
## Release Note V 1.1.6
|
|
296
|
+
|
|
297
|
+
- - Adiciona o botão de cancelar captura no `capturePhoto()`.
|
|
298
|
+
- Se a captura for cancelada, ela lancará uma exceção.
|
|
299
|
+
|
|
300
|
+
## Release Note V 1.1.5
|
|
301
|
+
|
|
302
|
+
- Captura da Geolocalização
|
|
303
|
+
- Login via componente (Credentials)
|
|
304
|
+
- Bloquear navegadores sem suporte
|
|
305
|
+
- Bloquear exame quando camera estiver em uso
|
|
306
|
+
- Gravação de vídeo opcional
|
|
307
|
+
- Atualização Interface do CapturePhoto
|
|
308
|
+
- Criação do callback onBufferSizeError
|
|
309
|
+
- Criação do callback onRealtimeAlerts
|
|
310
|
+
- Bloqueio das cameras simuladas da listagem de devices
|
|
311
|
+
- Aviso de camera ocupada
|
|
312
|
+
|
|
313
|
+
## Release Note V 1.1.4
|
|
314
|
+
|
|
315
|
+
- Adicionado resolução de 480p na gravação da tela
|
|
316
|
+
- Melhorias no finish
|
|
317
|
+
|
|
222
318
|
## Release Note V 1.1.0
|
|
223
319
|
|
|
224
|
-
- Adicionado fotos durante a execução da prova
|
|
320
|
+
- Adicionado fotos durante a execução da prova
|
|
225
321
|
- Adicionado o modal de capturePhoto, para cadastramento e autenticação biométrica
|
|
226
322
|
- Correção de interface do modal checkDevices com problema no lts
|
|
227
323
|
|
package/esm/index.js
CHANGED
|
@@ -6635,7 +6635,7 @@ var BaseDetection = class {
|
|
|
6635
6635
|
});
|
|
6636
6636
|
}
|
|
6637
6637
|
stopDetection() {
|
|
6638
|
-
|
|
6638
|
+
this.animationFrameId && clearTimeout(this.animationFrameId);
|
|
6639
6639
|
this.detecting = false;
|
|
6640
6640
|
this.liveView = document.getElementById(this.classDiv);
|
|
6641
6641
|
this.liveView && this.classDiv === "liveViewFrameDetection" && document.body.removeChild(this.liveView);
|
|
@@ -6684,7 +6684,9 @@ var BaseDetection = class {
|
|
|
6684
6684
|
this.verify(detections);
|
|
6685
6685
|
}
|
|
6686
6686
|
}
|
|
6687
|
-
this.animationFrameId =
|
|
6687
|
+
this.animationFrameId = setTimeout(() => {
|
|
6688
|
+
this.predictWebcam();
|
|
6689
|
+
}, 0);
|
|
6688
6690
|
}
|
|
6689
6691
|
handleAlert(description, type) {
|
|
6690
6692
|
this.options.onRealtimeAlertsCallback && this.options.onRealtimeAlertsCallback({
|
|
@@ -6694,9 +6696,10 @@ var BaseDetection = class {
|
|
|
6694
6696
|
});
|
|
6695
6697
|
this.error && (this.error.innerText = description);
|
|
6696
6698
|
}
|
|
6697
|
-
handleOk(type) {
|
|
6699
|
+
handleOk(description, type) {
|
|
6698
6700
|
this.options.onRealtimeAlertsCallback && this.options.onRealtimeAlertsCallback({
|
|
6699
6701
|
status: "OK",
|
|
6702
|
+
description: this.alertTranslate(description),
|
|
6700
6703
|
type
|
|
6701
6704
|
});
|
|
6702
6705
|
this.error && (this.error.innerText = "");
|
|
@@ -6719,6 +6722,14 @@ var BaseDetection = class {
|
|
|
6719
6722
|
return "Celular detectado";
|
|
6720
6723
|
case "wrong_position_face_detected":
|
|
6721
6724
|
return "Face na posi\xE7\xE3o errada";
|
|
6725
|
+
case "person_ok":
|
|
6726
|
+
return "Pessoa detectada";
|
|
6727
|
+
case "cellphone_ok":
|
|
6728
|
+
return "Nenhum celular detectadoa";
|
|
6729
|
+
case "face_ok":
|
|
6730
|
+
return "Face detectada";
|
|
6731
|
+
case "ok_position_face_detected":
|
|
6732
|
+
return "Face na posi\xE7\xE3o correta";
|
|
6722
6733
|
default:
|
|
6723
6734
|
return description;
|
|
6724
6735
|
}
|
|
@@ -6815,7 +6826,7 @@ var ObjectDetection = class extends BaseDetection {
|
|
|
6815
6826
|
this.handleAlert("multiple_persons_detected", "person_detection_on_stream");
|
|
6816
6827
|
this.numPersonsSent = numPersons;
|
|
6817
6828
|
} else {
|
|
6818
|
-
this.handleOk("person_detection_on_stream");
|
|
6829
|
+
this.handleOk("person_ok", "person_detection_on_stream");
|
|
6819
6830
|
this.numPersonsSent = numPersons;
|
|
6820
6831
|
}
|
|
6821
6832
|
}
|
|
@@ -6824,7 +6835,7 @@ var ObjectDetection = class extends BaseDetection {
|
|
|
6824
6835
|
this.handleAlert("cellphone_detected", "mobile_detection_on_stream");
|
|
6825
6836
|
this.numCellphoneSent = numCellphones;
|
|
6826
6837
|
} else {
|
|
6827
|
-
this.handleOk("mobile_detection_on_stream");
|
|
6838
|
+
this.handleOk("cellphone_ok", "mobile_detection_on_stream");
|
|
6828
6839
|
this.numCellphoneSent = numCellphones;
|
|
6829
6840
|
}
|
|
6830
6841
|
}
|
|
@@ -6906,14 +6917,14 @@ var FaceDetection = class extends BaseDetection {
|
|
|
6906
6917
|
} else if (result.detections.length > 1) {
|
|
6907
6918
|
this.handleAlert("multiple_faces_detected", "face_detection_on_stream");
|
|
6908
6919
|
} else {
|
|
6909
|
-
this.handleOk("face_detection_on_stream");
|
|
6920
|
+
this.handleOk("face_ok", "face_detection_on_stream");
|
|
6910
6921
|
}
|
|
6911
6922
|
}
|
|
6912
6923
|
if (((_b = result.detections[0]) == null ? void 0 : _b.keypoints[4].x) < 0.2 || ((_c2 = result.detections[0]) == null ? void 0 : _c2.keypoints[5].x) > 0.8) {
|
|
6913
6924
|
!this.emmitedPositionAlert && this.handleAlert("wrong_position_face_detected", "position_detection_on_stream");
|
|
6914
6925
|
this.emmitedPositionAlert = true;
|
|
6915
6926
|
} else {
|
|
6916
|
-
this.emmitedPositionAlert && this.handleOk("position_detection_on_stream");
|
|
6927
|
+
this.emmitedPositionAlert && this.handleOk("ok_position_face_detected", "position_detection_on_stream");
|
|
6917
6928
|
this.emmitedPositionAlert = false;
|
|
6918
6929
|
}
|
|
6919
6930
|
}
|
|
@@ -6922,29 +6933,29 @@ var FaceDetection = class extends BaseDetection {
|
|
|
6922
6933
|
// src/new-flow/recorders/VolumeMeter.ts
|
|
6923
6934
|
var VolumeMeter = class {
|
|
6924
6935
|
constructor(stream) {
|
|
6936
|
+
this.volume = null;
|
|
6937
|
+
this.animationFrameId = null;
|
|
6925
6938
|
this.stream = stream;
|
|
6926
6939
|
}
|
|
6927
|
-
start(options = {}) {
|
|
6940
|
+
async start(options = {}) {
|
|
6928
6941
|
return new Promise((resolve, reject) => {
|
|
6929
6942
|
try {
|
|
6930
6943
|
const audioContext = new AudioContext();
|
|
6931
|
-
|
|
6944
|
+
this.analyser = audioContext.createAnalyser();
|
|
6932
6945
|
const microphone = audioContext.createMediaStreamSource(this.stream);
|
|
6933
|
-
this.
|
|
6934
|
-
analyser.
|
|
6935
|
-
analyser
|
|
6936
|
-
|
|
6937
|
-
|
|
6938
|
-
|
|
6939
|
-
const that = this;
|
|
6940
|
-
this.scriptProcessor.onaudioprocess = function() {
|
|
6941
|
-
const array = new Uint8Array(analyser.frequencyBinCount);
|
|
6942
|
-
analyser.getByteFrequencyData(array);
|
|
6946
|
+
this.analyser.smoothingTimeConstant = 0.8;
|
|
6947
|
+
this.analyser.fftSize = 1024;
|
|
6948
|
+
microphone.connect(this.analyser);
|
|
6949
|
+
const processAudio = () => {
|
|
6950
|
+
const array = new Uint8Array(this.analyser.frequencyBinCount);
|
|
6951
|
+
this.analyser.getByteFrequencyData(array);
|
|
6943
6952
|
const arraySum = array.reduce((a3, value) => a3 + value, 0);
|
|
6944
6953
|
const average = arraySum / array.length;
|
|
6945
|
-
|
|
6954
|
+
this.setVolume(average);
|
|
6946
6955
|
options.setVolume && options.setVolume(average);
|
|
6956
|
+
this.animationFrameId = requestAnimationFrame(processAudio);
|
|
6947
6957
|
};
|
|
6958
|
+
this.animationFrameId = requestAnimationFrame(processAudio);
|
|
6948
6959
|
resolve(true);
|
|
6949
6960
|
} catch (error) {
|
|
6950
6961
|
this.stop();
|
|
@@ -6953,7 +6964,9 @@ var VolumeMeter = class {
|
|
|
6953
6964
|
});
|
|
6954
6965
|
}
|
|
6955
6966
|
stop() {
|
|
6956
|
-
this.
|
|
6967
|
+
if (this.animationFrameId !== null) {
|
|
6968
|
+
cancelAnimationFrame(this.animationFrameId);
|
|
6969
|
+
}
|
|
6957
6970
|
}
|
|
6958
6971
|
getVolume() {
|
|
6959
6972
|
return this.volume;
|
|
@@ -7038,7 +7051,7 @@ var CameraRecorder = class {
|
|
|
7038
7051
|
this.canvas.height = this.videoOptions.height;
|
|
7039
7052
|
}
|
|
7040
7053
|
async startRecording() {
|
|
7041
|
-
var _a2, _b, _c2, _d, _e3, _f, _g
|
|
7054
|
+
var _a2, _b, _c2, _d, _e3, _f, _g;
|
|
7042
7055
|
if (((_a2 = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _a2.detectPerson) || ((_b = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _b.detectCellPhone) || ((_c2 = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _c2.detectFace)) {
|
|
7043
7056
|
await this.initializeDetectors();
|
|
7044
7057
|
}
|
|
@@ -7084,8 +7097,6 @@ Setting: ${settings}`);
|
|
|
7084
7097
|
}
|
|
7085
7098
|
this.filesToUpload = [];
|
|
7086
7099
|
this.options.proctoringType == "REALTIME" && this.captureFrame();
|
|
7087
|
-
if ((_h = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _h.detectNoise)
|
|
7088
|
-
this.intervalNoiseDetection = setInterval(() => this.onNoiseDetected(), 500);
|
|
7089
7100
|
}
|
|
7090
7101
|
async stopRecording() {
|
|
7091
7102
|
this.recordingStop && await this.recordingStop();
|
|
@@ -7245,7 +7256,9 @@ Setting: ${settings}`);
|
|
|
7245
7256
|
});
|
|
7246
7257
|
}
|
|
7247
7258
|
onNoiseDetected() {
|
|
7248
|
-
var _a2, _b;
|
|
7259
|
+
var _a2, _b, _c2;
|
|
7260
|
+
if (this.options.proctoringType === "REALTIME")
|
|
7261
|
+
return;
|
|
7249
7262
|
if (!this.volumeMeter && this.cameraStream) {
|
|
7250
7263
|
this.volumeMeter = new VolumeMeter(this.cameraStream);
|
|
7251
7264
|
this.volumeMeter.start().catch((e3) => {
|
|
@@ -7253,7 +7266,9 @@ Setting: ${settings}`);
|
|
|
7253
7266
|
this.volumeMeter = void 0;
|
|
7254
7267
|
});
|
|
7255
7268
|
}
|
|
7256
|
-
|
|
7269
|
+
const volume = (_b = (_a2 = this.volumeMeter) == null ? void 0 : _a2.getVolume()) != null ? _b : 0;
|
|
7270
|
+
if (volume >= (((_c2 = this.paramsConfig.audioBehaviourParameters) == null ? void 0 : _c2.noiseLimit) || 40)) {
|
|
7271
|
+
console.log("entrou" + this.noiseWait);
|
|
7257
7272
|
if (this.noiseWait >= 20) {
|
|
7258
7273
|
this.options.onRealtimeAlertsCallback({
|
|
7259
7274
|
status: "ALERT",
|
|
@@ -11216,15 +11231,21 @@ var NoiseRecorder = class {
|
|
|
11216
11231
|
async startRecording() {
|
|
11217
11232
|
this.examStartTime = Date.now();
|
|
11218
11233
|
await this.createAudioClassifier();
|
|
11219
|
-
this.audioRecorder = new AudioRecorder(
|
|
11220
|
-
|
|
11234
|
+
this.audioRecorder = new AudioRecorder(
|
|
11235
|
+
void 0,
|
|
11236
|
+
this.paramsConfig.audioBehaviourParameters
|
|
11237
|
+
);
|
|
11238
|
+
this.intervalNoiseDetection = setInterval(
|
|
11239
|
+
() => this.onNoiseDetectedRecord(),
|
|
11240
|
+
200
|
|
11241
|
+
);
|
|
11221
11242
|
this.streamingAudioClassification();
|
|
11222
11243
|
}
|
|
11223
11244
|
async stopRecording() {
|
|
11224
11245
|
clearInterval(this.intervalNoiseDetection);
|
|
11225
11246
|
await this.stopSoundRecord();
|
|
11226
11247
|
await this.volumeMeter.stop();
|
|
11227
|
-
this.
|
|
11248
|
+
this.audioWorkletNode && this.audioWorkletNode.disconnect();
|
|
11228
11249
|
}
|
|
11229
11250
|
async pauseRecording() {
|
|
11230
11251
|
}
|
|
@@ -11257,7 +11278,7 @@ var NoiseRecorder = class {
|
|
|
11257
11278
|
if (((_c2 = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _c2.detectNoise) && !this.isSpeech) {
|
|
11258
11279
|
this.onRealtimeAlertsCallback({
|
|
11259
11280
|
status: "ALERT",
|
|
11260
|
-
description: "
|
|
11281
|
+
description: "Barulho detectado",
|
|
11261
11282
|
type: "audio_detection_on_stream"
|
|
11262
11283
|
});
|
|
11263
11284
|
}
|
|
@@ -11316,12 +11337,22 @@ var NoiseRecorder = class {
|
|
|
11316
11337
|
return false;
|
|
11317
11338
|
for (const result of array) {
|
|
11318
11339
|
const nameIncludesSpeech = result.name.toLowerCase().includes("speech");
|
|
11319
|
-
|
|
11340
|
+
if (this.optionsProctoring.proctoringType !== "REALTIME") {
|
|
11341
|
+
return nameIncludesSpeech;
|
|
11342
|
+
}
|
|
11343
|
+
if (nameIncludesSpeech)
|
|
11344
|
+
console.log(parseFloat(result.score));
|
|
11345
|
+
const scoreGreaterThanThreshold = parseFloat(result.score) > 0.22;
|
|
11346
|
+
if (nameIncludesSpeech && scoreGreaterThanThreshold) {
|
|
11347
|
+
return true;
|
|
11348
|
+
}
|
|
11320
11349
|
}
|
|
11321
11350
|
return false;
|
|
11322
11351
|
}
|
|
11323
11352
|
async createAudioClassifier() {
|
|
11324
|
-
const audio = await Co2.forAudioTasks(
|
|
11353
|
+
const audio = await Co2.forAudioTasks(
|
|
11354
|
+
"https://cdn.jsdelivr.net/npm/@mediapipe/tasks-audio@0.10.0/wasm"
|
|
11355
|
+
);
|
|
11325
11356
|
this.audioClassifier = await Uo2.createFromOptions(audio, {
|
|
11326
11357
|
scoreThreshold: 0.15,
|
|
11327
11358
|
maxResults: 1,
|
|
@@ -11331,17 +11362,25 @@ var NoiseRecorder = class {
|
|
|
11331
11362
|
});
|
|
11332
11363
|
}
|
|
11333
11364
|
async streamingAudioClassification() {
|
|
11334
|
-
|
|
11335
|
-
|
|
11336
|
-
|
|
11337
|
-
|
|
11338
|
-
|
|
11339
|
-
|
|
11340
|
-
|
|
11341
|
-
|
|
11365
|
+
this.context = new AudioContext({ sampleRate: 16e3 });
|
|
11366
|
+
try {
|
|
11367
|
+
await this.context.audioWorklet.addModule("./src/new-flow/recorders/audio-processor.js");
|
|
11368
|
+
} catch (error) {
|
|
11369
|
+
throw new Error("\u274C Error loading audio worklet module");
|
|
11370
|
+
}
|
|
11371
|
+
const source = this.context.createMediaStreamSource(
|
|
11372
|
+
this.cameraRecorder.cameraStream
|
|
11373
|
+
);
|
|
11374
|
+
this.audioWorkletNode = new AudioWorkletNode(
|
|
11375
|
+
this.context,
|
|
11376
|
+
"audio-processor"
|
|
11377
|
+
);
|
|
11378
|
+
this.audioWorkletNode.port.onmessage = (event) => {
|
|
11379
|
+
const inputData = event.data;
|
|
11380
|
+
const result = this.audioClassifier.classify(inputData);
|
|
11342
11381
|
const categories = result[0].classifications[0].categories;
|
|
11343
|
-
if (
|
|
11344
|
-
|
|
11382
|
+
if (categories.length > 0) {
|
|
11383
|
+
this.audioClassificationResult = [
|
|
11345
11384
|
{
|
|
11346
11385
|
name: categories[0].categoryName,
|
|
11347
11386
|
score: categories[0].score.toFixed(3)
|
|
@@ -11349,8 +11388,8 @@ var NoiseRecorder = class {
|
|
|
11349
11388
|
];
|
|
11350
11389
|
}
|
|
11351
11390
|
};
|
|
11352
|
-
source.connect(this.
|
|
11353
|
-
this.
|
|
11391
|
+
source.connect(this.audioWorkletNode);
|
|
11392
|
+
this.audioWorkletNode.connect(this.context.destination);
|
|
11354
11393
|
}
|
|
11355
11394
|
};
|
|
11356
11395
|
|
|
@@ -11565,7 +11604,7 @@ var Auth = class {
|
|
|
11565
11604
|
const capture = await this.capturePhoto.takePicture(
|
|
11566
11605
|
"Login com biometria facial",
|
|
11567
11606
|
"Encaixe seu rosto no formato e clique no bot\xE3o abaixo",
|
|
11568
|
-
{ width:
|
|
11607
|
+
{ width: 1280, height: 720 }
|
|
11569
11608
|
);
|
|
11570
11609
|
this.loading();
|
|
11571
11610
|
return new Promise((resolve, reject) => {
|
|
@@ -11676,12 +11715,18 @@ var Proctoring = class {
|
|
|
11676
11715
|
token: context.token
|
|
11677
11716
|
});
|
|
11678
11717
|
this.repository = new IndexDbSessionRepository("EasyProctorDb", "exams2");
|
|
11679
|
-
this.repositoryDevices = new IndexDbSessionRepository(
|
|
11718
|
+
this.repositoryDevices = new IndexDbSessionRepository(
|
|
11719
|
+
"EasyProctorDbDevices",
|
|
11720
|
+
"devices"
|
|
11721
|
+
);
|
|
11680
11722
|
((_a2 = this.context.credentials) == null ? void 0 : _a2.cpf) && (this.auth = new Auth(this.context.credentials.cpf, this.backend));
|
|
11681
11723
|
}
|
|
11682
11724
|
setOnStopSharingScreenCallback(cb) {
|
|
11683
11725
|
this.onStopSharingScreenCallback = () => {
|
|
11684
|
-
trackers.registerStopSharingScreen(
|
|
11726
|
+
trackers.registerStopSharingScreen(
|
|
11727
|
+
this.proctoringId,
|
|
11728
|
+
"Stop sharing screen"
|
|
11729
|
+
);
|
|
11685
11730
|
cb();
|
|
11686
11731
|
};
|
|
11687
11732
|
}
|
|
@@ -11692,7 +11737,10 @@ var Proctoring = class {
|
|
|
11692
11737
|
this.onFocusCallback = () => cb();
|
|
11693
11738
|
}
|
|
11694
11739
|
async onChangeDevices(options = {}) {
|
|
11695
|
-
const onChange = new onChangeDevices(
|
|
11740
|
+
const onChange = new onChangeDevices(
|
|
11741
|
+
this.repositoryDevices,
|
|
11742
|
+
this.proctoringId
|
|
11743
|
+
);
|
|
11696
11744
|
onChange.startRecording(options);
|
|
11697
11745
|
this.onChangeDevicesCallback = (devices) => options.status && options.status(devices);
|
|
11698
11746
|
}
|
|
@@ -11754,9 +11802,7 @@ var Proctoring = class {
|
|
|
11754
11802
|
screenRecorder,
|
|
11755
11803
|
alertRecorder
|
|
11756
11804
|
].filter(Boolean);
|
|
11757
|
-
|
|
11758
|
-
recorders.push(noiseRecorder);
|
|
11759
|
-
}
|
|
11805
|
+
recorders.push(noiseRecorder);
|
|
11760
11806
|
this.recorder = new ProctoringRecorder(this.proctoringSession, recorders);
|
|
11761
11807
|
return { cameraRecorder, screenRecorder, alertRecorder, noiseRecorder };
|
|
11762
11808
|
}
|
|
@@ -11809,8 +11855,12 @@ var Proctoring = class {
|
|
|
11809
11855
|
const _navigator = {};
|
|
11810
11856
|
for (const i3 in navigator)
|
|
11811
11857
|
_navigator[i3] = navigator[i3];
|
|
11812
|
-
trackers.registerStart(
|
|
11813
|
-
|
|
11858
|
+
trackers.registerStart(
|
|
11859
|
+
this.proctoringId,
|
|
11860
|
+
true,
|
|
11861
|
+
`Version: ${versionVerify()}
|
|
11862
|
+
Navigator: ${JSON.stringify(_navigator)}`
|
|
11863
|
+
);
|
|
11814
11864
|
startResponse.cameraStream = this.allRecorders.cameraRecorder.cameraStream;
|
|
11815
11865
|
if (this.allRecorders.screenRecorder) {
|
|
11816
11866
|
startResponse.screenStream = this.allRecorders.screenRecorder.screenStream;
|
|
@@ -11819,10 +11869,14 @@ Navigator: ${JSON.stringify(_navigator)}`);
|
|
|
11819
11869
|
return startResponse;
|
|
11820
11870
|
} catch (error) {
|
|
11821
11871
|
await this.cancel();
|
|
11822
|
-
this.proctoringId && trackers.registerStart(
|
|
11872
|
+
this.proctoringId && trackers.registerStart(
|
|
11873
|
+
this.proctoringId,
|
|
11874
|
+
false,
|
|
11875
|
+
`Token: ${this.context.token}
|
|
11823
11876
|
Version: ${versionVerify()}
|
|
11824
11877
|
Navigator: ${navigator}
|
|
11825
|
-
Error: ${error}`
|
|
11878
|
+
Error: ${error}`
|
|
11879
|
+
);
|
|
11826
11880
|
this.state = "Stop" /* Stop */;
|
|
11827
11881
|
throw error;
|
|
11828
11882
|
}
|
|
@@ -11845,16 +11899,22 @@ Error: ${error}`);
|
|
|
11845
11899
|
let uploader;
|
|
11846
11900
|
let uploaderServices;
|
|
11847
11901
|
if (versionVerify() !== "1.0.0.0") {
|
|
11848
|
-
uploader = new ProctoringUploader(
|
|
11849
|
-
|
|
11850
|
-
|
|
11902
|
+
uploader = new ProctoringUploader(
|
|
11903
|
+
this.proctoringSession,
|
|
11904
|
+
this.proctoringId,
|
|
11905
|
+
[new DownloadService(this.proctoringId)]
|
|
11906
|
+
);
|
|
11851
11907
|
uploaderServices = "Download";
|
|
11852
11908
|
this.serviceType = "Download" /* Download */;
|
|
11853
11909
|
} else {
|
|
11854
|
-
uploader = new ProctoringUploader(
|
|
11855
|
-
|
|
11856
|
-
|
|
11857
|
-
|
|
11910
|
+
uploader = new ProctoringUploader(
|
|
11911
|
+
this.proctoringSession,
|
|
11912
|
+
this.proctoringId,
|
|
11913
|
+
[
|
|
11914
|
+
new UploadService(this.proctoringId, this.backend),
|
|
11915
|
+
new DownloadService(this.proctoringId)
|
|
11916
|
+
]
|
|
11917
|
+
);
|
|
11858
11918
|
uploaderServices = "Upload";
|
|
11859
11919
|
this.serviceType = "Upload" /* Upload */;
|
|
11860
11920
|
}
|
|
@@ -11877,10 +11937,14 @@ Upload Services: ${uploaderServices}`,
|
|
|
11877
11937
|
this.serviceType
|
|
11878
11938
|
);
|
|
11879
11939
|
if (versionVerify() !== "1.0.0.0") {
|
|
11880
|
-
uploader = new ProctoringUploader(
|
|
11881
|
-
|
|
11882
|
-
|
|
11883
|
-
|
|
11940
|
+
uploader = new ProctoringUploader(
|
|
11941
|
+
this.proctoringSession,
|
|
11942
|
+
this.proctoringId,
|
|
11943
|
+
[
|
|
11944
|
+
new UploadService(this.proctoringId, this.backend),
|
|
11945
|
+
new DownloadService(this.proctoringId)
|
|
11946
|
+
]
|
|
11947
|
+
);
|
|
11884
11948
|
uploaderServices = "Upload";
|
|
11885
11949
|
this.serviceType = "Upload" /* Upload */;
|
|
11886
11950
|
uploaderServices = "Download";
|
|
@@ -11926,8 +11990,12 @@ Upload Services: ${uploaderServices}`,
|
|
|
11926
11990
|
this.state = "Stop" /* Stop */;
|
|
11927
11991
|
} catch (error) {
|
|
11928
11992
|
await this.cancel();
|
|
11929
|
-
trackers.registerFinish(
|
|
11930
|
-
|
|
11993
|
+
trackers.registerFinish(
|
|
11994
|
+
this.proctoringId,
|
|
11995
|
+
false,
|
|
11996
|
+
`Token: ${this.context.token}
|
|
11997
|
+
Error: ` + error
|
|
11998
|
+
);
|
|
11931
11999
|
this.state = "Stop" /* Stop */;
|
|
11932
12000
|
throw error;
|
|
11933
12001
|
}
|
|
@@ -11957,19 +12025,21 @@ Error: ` + error);
|
|
|
11957
12025
|
}
|
|
11958
12026
|
async initConfig(useGeolocation) {
|
|
11959
12027
|
try {
|
|
11960
|
-
const paramsConfig = await this.backend.getParamsConfig(
|
|
12028
|
+
const paramsConfig = await this.backend.getParamsConfig(
|
|
12029
|
+
this.context
|
|
12030
|
+
);
|
|
11961
12031
|
this.paramsConfig = {
|
|
11962
12032
|
...this.paramsConfig,
|
|
11963
12033
|
...paramsConfig,
|
|
11964
|
-
|
|
12034
|
+
audioBehaviourParameters: {
|
|
11965
12035
|
...this.paramsConfig.audioBehaviourParameters,
|
|
11966
12036
|
...paramsConfig.audioBehaviourParameters
|
|
11967
12037
|
},
|
|
11968
|
-
|
|
12038
|
+
imageBehaviourParameters: {
|
|
11969
12039
|
...this.paramsConfig.imageBehaviourParameters,
|
|
11970
12040
|
...paramsConfig.imageBehaviourParameters
|
|
11971
12041
|
},
|
|
11972
|
-
|
|
12042
|
+
videoBehaviourParameters: {
|
|
11973
12043
|
...this.paramsConfig.videoBehaviourParameters,
|
|
11974
12044
|
...paramsConfig.videoBehaviourParameters
|
|
11975
12045
|
}
|
|
@@ -12066,8 +12136,6 @@ function useProctoring(proctoringOptions, enviromentConfig = "prod") {
|
|
|
12066
12136
|
onRealtimeAlerts,
|
|
12067
12137
|
checkDevices,
|
|
12068
12138
|
capturePhoto,
|
|
12069
|
-
pause,
|
|
12070
|
-
resume,
|
|
12071
12139
|
enumarateDevices,
|
|
12072
12140
|
checkPermissions,
|
|
12073
12141
|
checkIfhasMultipleMonitors,
|
|
@@ -12076,6 +12144,8 @@ function useProctoring(proctoringOptions, enviromentConfig = "prod") {
|
|
|
12076
12144
|
}
|
|
12077
12145
|
|
|
12078
12146
|
// src/index.ts
|
|
12147
|
+
console.log = () => {
|
|
12148
|
+
};
|
|
12079
12149
|
if (typeof window !== "undefined") {
|
|
12080
12150
|
window.useProctoring = useProctoring;
|
|
12081
12151
|
}
|