easyproctor 0.0.13 → 0.0.17
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 +18 -2
- package/dtos/AlertDTO.d.ts +5 -0
- package/dtos/SaveScreenDTO.d.ts +5 -0
- package/esm/index.js +32 -33
- package/index.d.ts +0 -4
- package/index.js +32 -33
- package/package.json +35 -35
- package/unpkg/easyproctor.min.js +5 -5
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# EasyProctor
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
O componente web EasyProctor permite que qualquer plataforma de execução de exames registre sessões de proctoring.
|
|
4
4
|
|
|
5
5
|
## Instalação
|
|
6
6
|
|
|
@@ -17,6 +17,18 @@ Via CDN
|
|
|
17
17
|
|
|
18
18
|
## Utilização
|
|
19
19
|
|
|
20
|
+
Para utilizar o componente será necessário utilizar os seguintes parâmetros:
|
|
21
|
+
- examId: identificador do exame
|
|
22
|
+
- clientId: identificador do parceiro
|
|
23
|
+
- token: token de autenticação biométrica (utilizar SDK biométrico do EasyProctor)
|
|
24
|
+
|
|
25
|
+
Ao inicializar a sessão de proctoring através do método start do componente você receberá o objeto do tipo StartProctoringDTO que possui o identificador da sessão.
|
|
26
|
+
|
|
27
|
+
Após finalizar a sessão de proctoring através do método finish você poderá consultar os dados de proctoring através da nossa API.
|
|
28
|
+
|
|
29
|
+
https://iaris.easyproctor.tech/index.html
|
|
30
|
+
|
|
31
|
+
|
|
20
32
|
Em um bundler
|
|
21
33
|
```javascript
|
|
22
34
|
import { useProctoring } from "easyproctor";
|
|
@@ -98,7 +110,11 @@ const {
|
|
|
98
110
|
// Finaliza a gravação da prova retornando os arquivos gerados
|
|
99
111
|
finish,
|
|
100
112
|
|
|
101
|
-
} = useProctoring(
|
|
113
|
+
} = useProctoring({
|
|
114
|
+
examId: "00001",
|
|
115
|
+
clientId: "000001",
|
|
116
|
+
token: "..."
|
|
117
|
+
});
|
|
102
118
|
```
|
|
103
119
|
## License
|
|
104
120
|
[MIT](https://choosealicense.com/licenses/mit/)
|
package/esm/index.js
CHANGED
|
@@ -136,7 +136,7 @@ async function makeRequest(data) {
|
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
// src/index.ts
|
|
139
|
-
var azureBlobUrl = "https://iarisprod.
|
|
139
|
+
var azureBlobUrl = "https://iarisprod.blob.core.windows.net/iaris";
|
|
140
140
|
function useProctoring(proctoringOptions) {
|
|
141
141
|
["examId", "clientId", "token"].forEach((el) => {
|
|
142
142
|
const key = el;
|
|
@@ -144,8 +144,6 @@ function useProctoring(proctoringOptions) {
|
|
|
144
144
|
throw `O campo ${key} \xE9 obrigat\xF3rio`;
|
|
145
145
|
}
|
|
146
146
|
});
|
|
147
|
-
let focusCallback;
|
|
148
|
-
let lostFocusCallback;
|
|
149
147
|
if (!navigator.mediaDevices.getDisplayMedia) {
|
|
150
148
|
throw "Voc\xEA est\xE1 utilizando uma vers\xE3o muito antiga do navegador, por favor, atualize a vers\xE3o";
|
|
151
149
|
}
|
|
@@ -165,6 +163,8 @@ function useProctoring(proctoringOptions) {
|
|
|
165
163
|
let cameraBuffer = [];
|
|
166
164
|
let screenBuffer = [];
|
|
167
165
|
let proctoringId = "";
|
|
166
|
+
let startTime = 0;
|
|
167
|
+
let alerts = [];
|
|
168
168
|
let cancelCallback = null;
|
|
169
169
|
async function _startCapture() {
|
|
170
170
|
if (!document.body) {
|
|
@@ -176,15 +176,7 @@ function useProctoring(proctoringOptions) {
|
|
|
176
176
|
let cancelCameraCapture = null;
|
|
177
177
|
let cancelScreenCapture = null;
|
|
178
178
|
try {
|
|
179
|
-
if (focusCallback)
|
|
180
|
-
window.removeEventListener("focus", focusCallback);
|
|
181
|
-
if (lostFocusCallback)
|
|
182
|
-
window.removeEventListener("blur", lostFocusCallback);
|
|
183
179
|
cancelScreenCapture = await startScreenCapture(screenBuffer);
|
|
184
|
-
if (focusCallback)
|
|
185
|
-
window.addEventListener("focus", () => window.addEventListener("focus", focusCallback), { once: true });
|
|
186
|
-
if (lostFocusCallback)
|
|
187
|
-
window.addEventListener("blur", lostFocusCallback);
|
|
188
180
|
cancelCameraCapture = await startCameraCapture(cameraBuffer);
|
|
189
181
|
cancelCallback = async function() {
|
|
190
182
|
await Promise.all([cancelCameraCapture(), cancelScreenCapture()]);
|
|
@@ -198,6 +190,27 @@ function useProctoring(proctoringOptions) {
|
|
|
198
190
|
throw "N\xE3o foi poss\xEDvel iniciar a captura, por favor, verifique as permiss\xF5es de camera e microfone";
|
|
199
191
|
}
|
|
200
192
|
}
|
|
193
|
+
const _onLostFocus = () => {
|
|
194
|
+
alerts.push({
|
|
195
|
+
begin: Date.now() - startTime,
|
|
196
|
+
alert: 25,
|
|
197
|
+
end: 0
|
|
198
|
+
});
|
|
199
|
+
};
|
|
200
|
+
const _onReturnFocus = () => {
|
|
201
|
+
const lastAlert = alerts[alerts.length - 1];
|
|
202
|
+
if (lastAlert) {
|
|
203
|
+
lastAlert.end = Date.now() - startTime;
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
const _addListeners = () => {
|
|
207
|
+
window.addEventListener("blur", _onLostFocus);
|
|
208
|
+
window.addEventListener("focus", _onReturnFocus);
|
|
209
|
+
};
|
|
210
|
+
const _removeListeners = () => {
|
|
211
|
+
window.removeEventListener("blur", _onLostFocus);
|
|
212
|
+
window.removeEventListener("focus", _onReturnFocus);
|
|
213
|
+
};
|
|
201
214
|
async function start(options = { override: false }) {
|
|
202
215
|
const { override } = options;
|
|
203
216
|
if (override) {
|
|
@@ -209,6 +222,7 @@ function useProctoring(proctoringOptions) {
|
|
|
209
222
|
}
|
|
210
223
|
}
|
|
211
224
|
await _startCapture();
|
|
225
|
+
startTime = Date.now();
|
|
212
226
|
try {
|
|
213
227
|
const resp = await makeRequest({
|
|
214
228
|
url: `/proctoring/start/${proctoringOptions.examId}`,
|
|
@@ -217,18 +231,13 @@ function useProctoring(proctoringOptions) {
|
|
|
217
231
|
jwt: proctoringOptions.token
|
|
218
232
|
});
|
|
219
233
|
proctoringId = resp.id;
|
|
234
|
+
_addListeners();
|
|
220
235
|
return resp;
|
|
221
236
|
} catch (error) {
|
|
222
237
|
cancelCallback && cancelCallback();
|
|
223
238
|
throw error;
|
|
224
239
|
}
|
|
225
240
|
}
|
|
226
|
-
async function pause() {
|
|
227
|
-
throw "Ainda n\xE3o implementado";
|
|
228
|
-
}
|
|
229
|
-
async function resume() {
|
|
230
|
-
throw "Ainda n\xE3o implementado";
|
|
231
|
-
}
|
|
232
241
|
async function finish(options = {}) {
|
|
233
242
|
const { onProgress } = options;
|
|
234
243
|
if (cancelCallback) {
|
|
@@ -240,8 +249,8 @@ function useProctoring(proctoringOptions) {
|
|
|
240
249
|
if (finalCameraBuffer.length == 0 || finalScreenBuffer.length == 0) {
|
|
241
250
|
throw "N\xE3o existe nenhuma grava\xE7\xE3o iniciada";
|
|
242
251
|
}
|
|
243
|
-
const cameraFileName = `EP_${
|
|
244
|
-
const screenFIleName = `EP_${
|
|
252
|
+
const cameraFileName = `EP_${proctoringId}_camera_0.webm`;
|
|
253
|
+
const screenFIleName = `EP_${proctoringId}_screen_0.webm`;
|
|
245
254
|
const cameraFile = new File(finalCameraBuffer, cameraFileName, { type: "video/webm" });
|
|
246
255
|
const screenFile = new File(finalScreenBuffer, screenFIleName, { type: "video/webm" });
|
|
247
256
|
let cameraProgress = 0;
|
|
@@ -259,13 +268,14 @@ function useProctoring(proctoringOptions) {
|
|
|
259
268
|
handleOnProgress();
|
|
260
269
|
} })
|
|
261
270
|
]);
|
|
271
|
+
_removeListeners();
|
|
262
272
|
await makeRequest({
|
|
263
273
|
url: "/proctoring/save-screen",
|
|
264
274
|
method: "POST",
|
|
265
275
|
jwt: proctoringOptions.token,
|
|
266
276
|
body: {
|
|
267
277
|
proctoringId,
|
|
268
|
-
alerts: []
|
|
278
|
+
alerts: [...alerts]
|
|
269
279
|
}
|
|
270
280
|
});
|
|
271
281
|
await makeRequest({
|
|
@@ -281,21 +291,10 @@ function useProctoring(proctoringOptions) {
|
|
|
281
291
|
await Promise.all([clearBuffers("cameraBuffers"), clearBuffers("screenBuffers")]);
|
|
282
292
|
cameraBuffer = [];
|
|
283
293
|
screenBuffer = [];
|
|
294
|
+
alerts = [];
|
|
284
295
|
cancelCallback = null;
|
|
285
296
|
}
|
|
286
|
-
|
|
287
|
-
lostFocusCallback = cb;
|
|
288
|
-
window.addEventListener("blur", lostFocusCallback);
|
|
289
|
-
const dispose = () => window.removeEventListener("blur", lostFocusCallback);
|
|
290
|
-
return dispose;
|
|
291
|
-
};
|
|
292
|
-
const onReturnFocus = (cb) => {
|
|
293
|
-
focusCallback = cb;
|
|
294
|
-
window.addEventListener("focus", focusCallback);
|
|
295
|
-
const dispose = () => window.removeEventListener("focus", focusCallback);
|
|
296
|
-
return dispose;
|
|
297
|
-
};
|
|
298
|
-
return { start, finish, pause, resume, onLostFocus, download, onReturnFocus };
|
|
297
|
+
return { start, finish, download };
|
|
299
298
|
}
|
|
300
299
|
if (typeof window !== "undefined") {
|
|
301
300
|
window.useProctoring = useProctoring;
|
package/index.d.ts
CHANGED
|
@@ -10,9 +10,5 @@ export declare function useProctoring(proctoringOptions: {
|
|
|
10
10
|
finish: (options?: {
|
|
11
11
|
onProgress?: ((percentage: number) => void) | undefined;
|
|
12
12
|
}) => Promise<void>;
|
|
13
|
-
pause: () => Promise<void>;
|
|
14
|
-
resume: () => Promise<void>;
|
|
15
|
-
onLostFocus: (cb: () => void) => () => void;
|
|
16
13
|
download: (file: File) => void;
|
|
17
|
-
onReturnFocus: (cb: () => void) => () => void;
|
|
18
14
|
};
|
package/index.js
CHANGED
|
@@ -166,7 +166,7 @@ async function makeRequest(data) {
|
|
|
166
166
|
}
|
|
167
167
|
|
|
168
168
|
// src/index.ts
|
|
169
|
-
var azureBlobUrl = "https://iarisprod.
|
|
169
|
+
var azureBlobUrl = "https://iarisprod.blob.core.windows.net/iaris";
|
|
170
170
|
function useProctoring(proctoringOptions) {
|
|
171
171
|
["examId", "clientId", "token"].forEach((el) => {
|
|
172
172
|
const key = el;
|
|
@@ -174,8 +174,6 @@ function useProctoring(proctoringOptions) {
|
|
|
174
174
|
throw `O campo ${key} \xE9 obrigat\xF3rio`;
|
|
175
175
|
}
|
|
176
176
|
});
|
|
177
|
-
let focusCallback;
|
|
178
|
-
let lostFocusCallback;
|
|
179
177
|
if (!navigator.mediaDevices.getDisplayMedia) {
|
|
180
178
|
throw "Voc\xEA est\xE1 utilizando uma vers\xE3o muito antiga do navegador, por favor, atualize a vers\xE3o";
|
|
181
179
|
}
|
|
@@ -195,6 +193,8 @@ function useProctoring(proctoringOptions) {
|
|
|
195
193
|
let cameraBuffer = [];
|
|
196
194
|
let screenBuffer = [];
|
|
197
195
|
let proctoringId = "";
|
|
196
|
+
let startTime = 0;
|
|
197
|
+
let alerts = [];
|
|
198
198
|
let cancelCallback = null;
|
|
199
199
|
async function _startCapture() {
|
|
200
200
|
if (!document.body) {
|
|
@@ -206,15 +206,7 @@ function useProctoring(proctoringOptions) {
|
|
|
206
206
|
let cancelCameraCapture = null;
|
|
207
207
|
let cancelScreenCapture = null;
|
|
208
208
|
try {
|
|
209
|
-
if (focusCallback)
|
|
210
|
-
window.removeEventListener("focus", focusCallback);
|
|
211
|
-
if (lostFocusCallback)
|
|
212
|
-
window.removeEventListener("blur", lostFocusCallback);
|
|
213
209
|
cancelScreenCapture = await startScreenCapture(screenBuffer);
|
|
214
|
-
if (focusCallback)
|
|
215
|
-
window.addEventListener("focus", () => window.addEventListener("focus", focusCallback), { once: true });
|
|
216
|
-
if (lostFocusCallback)
|
|
217
|
-
window.addEventListener("blur", lostFocusCallback);
|
|
218
210
|
cancelCameraCapture = await startCameraCapture(cameraBuffer);
|
|
219
211
|
cancelCallback = async function() {
|
|
220
212
|
await Promise.all([cancelCameraCapture(), cancelScreenCapture()]);
|
|
@@ -228,6 +220,27 @@ function useProctoring(proctoringOptions) {
|
|
|
228
220
|
throw "N\xE3o foi poss\xEDvel iniciar a captura, por favor, verifique as permiss\xF5es de camera e microfone";
|
|
229
221
|
}
|
|
230
222
|
}
|
|
223
|
+
const _onLostFocus = () => {
|
|
224
|
+
alerts.push({
|
|
225
|
+
begin: Date.now() - startTime,
|
|
226
|
+
alert: 25,
|
|
227
|
+
end: 0
|
|
228
|
+
});
|
|
229
|
+
};
|
|
230
|
+
const _onReturnFocus = () => {
|
|
231
|
+
const lastAlert = alerts[alerts.length - 1];
|
|
232
|
+
if (lastAlert) {
|
|
233
|
+
lastAlert.end = Date.now() - startTime;
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
const _addListeners = () => {
|
|
237
|
+
window.addEventListener("blur", _onLostFocus);
|
|
238
|
+
window.addEventListener("focus", _onReturnFocus);
|
|
239
|
+
};
|
|
240
|
+
const _removeListeners = () => {
|
|
241
|
+
window.removeEventListener("blur", _onLostFocus);
|
|
242
|
+
window.removeEventListener("focus", _onReturnFocus);
|
|
243
|
+
};
|
|
231
244
|
async function start(options = { override: false }) {
|
|
232
245
|
const { override } = options;
|
|
233
246
|
if (override) {
|
|
@@ -239,6 +252,7 @@ function useProctoring(proctoringOptions) {
|
|
|
239
252
|
}
|
|
240
253
|
}
|
|
241
254
|
await _startCapture();
|
|
255
|
+
startTime = Date.now();
|
|
242
256
|
try {
|
|
243
257
|
const resp = await makeRequest({
|
|
244
258
|
url: `/proctoring/start/${proctoringOptions.examId}`,
|
|
@@ -247,18 +261,13 @@ function useProctoring(proctoringOptions) {
|
|
|
247
261
|
jwt: proctoringOptions.token
|
|
248
262
|
});
|
|
249
263
|
proctoringId = resp.id;
|
|
264
|
+
_addListeners();
|
|
250
265
|
return resp;
|
|
251
266
|
} catch (error) {
|
|
252
267
|
cancelCallback && cancelCallback();
|
|
253
268
|
throw error;
|
|
254
269
|
}
|
|
255
270
|
}
|
|
256
|
-
async function pause() {
|
|
257
|
-
throw "Ainda n\xE3o implementado";
|
|
258
|
-
}
|
|
259
|
-
async function resume() {
|
|
260
|
-
throw "Ainda n\xE3o implementado";
|
|
261
|
-
}
|
|
262
271
|
async function finish(options = {}) {
|
|
263
272
|
const { onProgress } = options;
|
|
264
273
|
if (cancelCallback) {
|
|
@@ -270,8 +279,8 @@ function useProctoring(proctoringOptions) {
|
|
|
270
279
|
if (finalCameraBuffer.length == 0 || finalScreenBuffer.length == 0) {
|
|
271
280
|
throw "N\xE3o existe nenhuma grava\xE7\xE3o iniciada";
|
|
272
281
|
}
|
|
273
|
-
const cameraFileName = `EP_${
|
|
274
|
-
const screenFIleName = `EP_${
|
|
282
|
+
const cameraFileName = `EP_${proctoringId}_camera_0.webm`;
|
|
283
|
+
const screenFIleName = `EP_${proctoringId}_screen_0.webm`;
|
|
275
284
|
const cameraFile = new File(finalCameraBuffer, cameraFileName, { type: "video/webm" });
|
|
276
285
|
const screenFile = new File(finalScreenBuffer, screenFIleName, { type: "video/webm" });
|
|
277
286
|
let cameraProgress = 0;
|
|
@@ -289,13 +298,14 @@ function useProctoring(proctoringOptions) {
|
|
|
289
298
|
handleOnProgress();
|
|
290
299
|
} })
|
|
291
300
|
]);
|
|
301
|
+
_removeListeners();
|
|
292
302
|
await makeRequest({
|
|
293
303
|
url: "/proctoring/save-screen",
|
|
294
304
|
method: "POST",
|
|
295
305
|
jwt: proctoringOptions.token,
|
|
296
306
|
body: {
|
|
297
307
|
proctoringId,
|
|
298
|
-
alerts: []
|
|
308
|
+
alerts: [...alerts]
|
|
299
309
|
}
|
|
300
310
|
});
|
|
301
311
|
await makeRequest({
|
|
@@ -311,21 +321,10 @@ function useProctoring(proctoringOptions) {
|
|
|
311
321
|
await Promise.all([clearBuffers("cameraBuffers"), clearBuffers("screenBuffers")]);
|
|
312
322
|
cameraBuffer = [];
|
|
313
323
|
screenBuffer = [];
|
|
324
|
+
alerts = [];
|
|
314
325
|
cancelCallback = null;
|
|
315
326
|
}
|
|
316
|
-
|
|
317
|
-
lostFocusCallback = cb;
|
|
318
|
-
window.addEventListener("blur", lostFocusCallback);
|
|
319
|
-
const dispose = () => window.removeEventListener("blur", lostFocusCallback);
|
|
320
|
-
return dispose;
|
|
321
|
-
};
|
|
322
|
-
const onReturnFocus = (cb) => {
|
|
323
|
-
focusCallback = cb;
|
|
324
|
-
window.addEventListener("focus", focusCallback);
|
|
325
|
-
const dispose = () => window.removeEventListener("focus", focusCallback);
|
|
326
|
-
return dispose;
|
|
327
|
-
};
|
|
328
|
-
return { start, finish, pause, resume, onLostFocus, download, onReturnFocus };
|
|
327
|
+
return { start, finish, download };
|
|
329
328
|
}
|
|
330
329
|
if (typeof window !== "undefined") {
|
|
331
330
|
window.useProctoring = useProctoring;
|
package/package.json
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "easyproctor",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "Modulo web de gravação do EasyProctor",
|
|
5
|
-
"main": "./index.js",
|
|
6
|
-
"module": "./esm/index.js",
|
|
7
|
-
"unpkg": "./unpkg/easyproctor.min.js",
|
|
8
|
-
"types": "./index.d.ts",
|
|
9
|
-
"keywords": [
|
|
10
|
-
"proctoring"
|
|
11
|
-
],
|
|
12
|
-
"homepage": "https://vsoft1.visualstudio.com/DefaultCollection/Iaris/_git/easyproctor-proctoring-componentJs",
|
|
13
|
-
"repository": {
|
|
14
|
-
"type": "git",
|
|
15
|
-
"url": "https://vsoft1.visualstudio.com/DefaultCollection/Iaris/_git/easyproctor-proctoring-componentJs"
|
|
16
|
-
},
|
|
17
|
-
"scripts": {
|
|
18
|
-
"build": "node scripts/build.js && tsc",
|
|
19
|
-
"dev": "node scripts/serve.js -w"
|
|
20
|
-
},
|
|
21
|
-
"author": "Igor Dantas",
|
|
22
|
-
"license": "ISC",
|
|
23
|
-
"devDependencies": {
|
|
24
|
-
"@types/dom-mediacapture-record": "^1.0.11",
|
|
25
|
-
"@typescript-eslint/eslint-plugin": "^5.8.0",
|
|
26
|
-
"@typescript-eslint/parser": "^5.8.0",
|
|
27
|
-
"esbuild": "^0.13.13",
|
|
28
|
-
"esbuild-serve": "^1.0.1",
|
|
29
|
-
"eslint": "^8.2.0",
|
|
30
|
-
"typescript": "^4.5.4"
|
|
31
|
-
},
|
|
32
|
-
"dependencies": {
|
|
33
|
-
"@azure/storage-blob": "^12.8.0"
|
|
34
|
-
}
|
|
35
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "easyproctor",
|
|
3
|
+
"version": "0.0.17",
|
|
4
|
+
"description": "Modulo web de gravação do EasyProctor",
|
|
5
|
+
"main": "./index.js",
|
|
6
|
+
"module": "./esm/index.js",
|
|
7
|
+
"unpkg": "./unpkg/easyproctor.min.js",
|
|
8
|
+
"types": "./index.d.ts",
|
|
9
|
+
"keywords": [
|
|
10
|
+
"proctoring"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://vsoft1.visualstudio.com/DefaultCollection/Iaris/_git/easyproctor-proctoring-componentJs",
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "https://vsoft1.visualstudio.com/DefaultCollection/Iaris/_git/easyproctor-proctoring-componentJs"
|
|
16
|
+
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "node scripts/build.js && tsc",
|
|
19
|
+
"dev": "node scripts/serve.js -w"
|
|
20
|
+
},
|
|
21
|
+
"author": "Igor Dantas",
|
|
22
|
+
"license": "ISC",
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@types/dom-mediacapture-record": "^1.0.11",
|
|
25
|
+
"@typescript-eslint/eslint-plugin": "^5.8.0",
|
|
26
|
+
"@typescript-eslint/parser": "^5.8.0",
|
|
27
|
+
"esbuild": "^0.13.13",
|
|
28
|
+
"esbuild-serve": "^1.0.1",
|
|
29
|
+
"eslint": "^8.2.0",
|
|
30
|
+
"typescript": "^4.5.4"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@azure/storage-blob": "^12.8.0"
|
|
34
|
+
}
|
|
35
|
+
}
|