easyproctor 0.0.44 → 0.0.45
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 +52 -7
- package/index.d.ts +4 -1
- package/index.js +44 -7
- package/interfaces/ProctoringRecord.d.ts +1 -1
- package/package.json +1 -1
- package/unpkg/easyproctor.min.js +27 -14
package/esm/index.js
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
+
}) : x)(function(x) {
|
|
4
|
+
if (typeof require !== "undefined")
|
|
5
|
+
return require.apply(this, arguments);
|
|
6
|
+
throw new Error('Dynamic require of "' + x + '" is not supported');
|
|
7
|
+
});
|
|
8
|
+
|
|
1
9
|
// src/modules/recorder.ts
|
|
2
10
|
function recorder(stream, buffer) {
|
|
3
11
|
let resolvePromise;
|
|
@@ -47,6 +55,32 @@ async function startCameraCapture(buffer, options = { cameraId: void 0, micropho
|
|
|
47
55
|
return { cameraStream, stopCameraRecording };
|
|
48
56
|
}
|
|
49
57
|
|
|
58
|
+
// src/modules/startAudioCapture.ts
|
|
59
|
+
var MicRecorder = __require("mic-recorder-to-mp3");
|
|
60
|
+
var stopRecord;
|
|
61
|
+
function startAudioCapture() {
|
|
62
|
+
const recorder2 = new MicRecorder({
|
|
63
|
+
bitRate: 128
|
|
64
|
+
});
|
|
65
|
+
function start() {
|
|
66
|
+
recorder2.start().then(() => {
|
|
67
|
+
}).catch((e) => {
|
|
68
|
+
console.error(e);
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
async function stop() {
|
|
72
|
+
const response = await recorder2.stop().getMp3().then(async ([buffer, blob]) => {
|
|
73
|
+
return { buffer, blob };
|
|
74
|
+
}).catch((e) => {
|
|
75
|
+
alert("We could not retrieve your message");
|
|
76
|
+
console.log(e);
|
|
77
|
+
});
|
|
78
|
+
return response;
|
|
79
|
+
}
|
|
80
|
+
stopRecord = stop;
|
|
81
|
+
return { start, stop };
|
|
82
|
+
}
|
|
83
|
+
|
|
50
84
|
// src/errors/errors.ts
|
|
51
85
|
var SCRIPT_NOT_CALLED_INSIDE_BODY = "script_not_called_inside_body";
|
|
52
86
|
var INCOMPATIBLE_NAVIGATOR = "incompatible_navigator";
|
|
@@ -8361,6 +8395,7 @@ function useProctoring(proctoringOptions, proctoringConfig) {
|
|
|
8361
8395
|
_screenStream = screenStream;
|
|
8362
8396
|
}
|
|
8363
8397
|
const { cameraStream, stopCameraRecording } = await startCameraCapture(cameraBuffer, { cameraId, microphoneId });
|
|
8398
|
+
startAudio();
|
|
8364
8399
|
cancelCameraCapture = stopCameraRecording;
|
|
8365
8400
|
if (captureScreen) {
|
|
8366
8401
|
cancelCallback = async function() {
|
|
@@ -8409,7 +8444,9 @@ function useProctoring(proctoringOptions, proctoringConfig) {
|
|
|
8409
8444
|
window.removeEventListener("focus", _onReturnFocus);
|
|
8410
8445
|
};
|
|
8411
8446
|
const _closeSession = async (index) => {
|
|
8447
|
+
const { buffer, blob } = await finishAudio();
|
|
8412
8448
|
const finalCameraBuffer = cameraBuffer;
|
|
8449
|
+
const finalAudioBuffer = buffer;
|
|
8413
8450
|
const finalScreenBuffer = screenBuffer;
|
|
8414
8451
|
if (finalCameraBuffer.length == 0) {
|
|
8415
8452
|
throw PROCTORING_NOT_STARTED;
|
|
@@ -8418,11 +8455,15 @@ function useProctoring(proctoringOptions, proctoringConfig) {
|
|
|
8418
8455
|
const audioFileName = `EP_${proctoringId}_audio_${index}.mp3`;
|
|
8419
8456
|
const screenFIleName = `EP_${proctoringId}_screen_${index}.webm`;
|
|
8420
8457
|
const cameraFile = new File(finalCameraBuffer, cameraFileName, { type: "video/webm" });
|
|
8458
|
+
const audioFile = new File(finalAudioBuffer, audioFileName, {
|
|
8459
|
+
type: blob.type,
|
|
8460
|
+
lastModified: Date.now()
|
|
8461
|
+
});
|
|
8421
8462
|
let screenFile;
|
|
8422
8463
|
if (finalScreenBuffer.length != 0) {
|
|
8423
8464
|
screenFile = new File(finalScreenBuffer, screenFIleName, { type: "video/webm" });
|
|
8424
8465
|
}
|
|
8425
|
-
return { cameraFile, screenFile };
|
|
8466
|
+
return { cameraFile, audioFile, screenFile };
|
|
8426
8467
|
};
|
|
8427
8468
|
async function initConfig() {
|
|
8428
8469
|
if (proctoringConfig != void 0) {
|
|
@@ -8489,8 +8530,12 @@ function useProctoring(proctoringOptions, proctoringConfig) {
|
|
|
8489
8530
|
}
|
|
8490
8531
|
}
|
|
8491
8532
|
async function startAudio() {
|
|
8533
|
+
const { start: start2 } = await startAudioCapture();
|
|
8534
|
+
start2();
|
|
8492
8535
|
}
|
|
8493
8536
|
async function finishAudio() {
|
|
8537
|
+
const { buffer, blob } = await stopRecord();
|
|
8538
|
+
return { buffer, blob };
|
|
8494
8539
|
}
|
|
8495
8540
|
async function pause() {
|
|
8496
8541
|
const record = await getRecord("exams");
|
|
@@ -8499,11 +8544,11 @@ function useProctoring(proctoringOptions, proctoringConfig) {
|
|
|
8499
8544
|
}
|
|
8500
8545
|
onStopSharingScreenCallback = void 0;
|
|
8501
8546
|
await cancelCallback();
|
|
8502
|
-
const { cameraFile, screenFile } = await _closeSession(record.sessions.length);
|
|
8547
|
+
const { cameraFile, audioFile, screenFile } = await _closeSession(record.sessions.length);
|
|
8503
8548
|
record.sessions.push({
|
|
8504
8549
|
alerts,
|
|
8505
8550
|
cameraFile,
|
|
8506
|
-
audioFile
|
|
8551
|
+
audioFile,
|
|
8507
8552
|
screenFile,
|
|
8508
8553
|
id: "" + record.sessions.length + 1,
|
|
8509
8554
|
start: startDate ? startDate.toISOString() : new Date().toISOString(),
|
|
@@ -8568,11 +8613,11 @@ function useProctoring(proctoringOptions, proctoringConfig) {
|
|
|
8568
8613
|
onStopSharingScreenCallback = void 0;
|
|
8569
8614
|
if (cancelCallback) {
|
|
8570
8615
|
await cancelCallback();
|
|
8571
|
-
const { cameraFile, screenFile } = await _closeSession(record.sessions.length);
|
|
8616
|
+
const { cameraFile, audioFile, screenFile } = await _closeSession(record.sessions.length);
|
|
8572
8617
|
record.sessions.push({
|
|
8573
8618
|
alerts,
|
|
8574
8619
|
cameraFile,
|
|
8575
|
-
audioFile
|
|
8620
|
+
audioFile,
|
|
8576
8621
|
screenFile,
|
|
8577
8622
|
id: "" + record.sessions.length + 1,
|
|
8578
8623
|
start: startDate ? startDate.toISOString() : new Date().toISOString(),
|
|
@@ -8611,7 +8656,7 @@ function useProctoring(proctoringOptions, proctoringConfig) {
|
|
|
8611
8656
|
end: session.end,
|
|
8612
8657
|
start: session.start,
|
|
8613
8658
|
videoCameraUrl: session.cameraFile.name,
|
|
8614
|
-
audioCameraUrl:
|
|
8659
|
+
audioCameraUrl: session.audioFile.name,
|
|
8615
8660
|
videoScreenUrl: session.screenFile ? session.screenFile.name : ""
|
|
8616
8661
|
});
|
|
8617
8662
|
});
|
|
@@ -8635,7 +8680,7 @@ function useProctoring(proctoringOptions, proctoringConfig) {
|
|
|
8635
8680
|
body: {
|
|
8636
8681
|
endDate: time,
|
|
8637
8682
|
videoCameraUrl: `${azureBlobUrl}/` + sessionsDto[sessionsDto.length - 1].videoCameraUrl,
|
|
8638
|
-
audioCameraUrl:
|
|
8683
|
+
audioCameraUrl: `${azureBlobUrl}/` + sessionsDto[sessionsDto.length - 1].audioCameraUrl,
|
|
8639
8684
|
videoScreenUrl: _captureScreen ? `${azureBlobUrl}/` + sessionsDto[sessionsDto.length - 1].videoScreenUrl : ""
|
|
8640
8685
|
},
|
|
8641
8686
|
jwt: proctoringOptions.token
|
package/index.d.ts
CHANGED
|
@@ -28,7 +28,10 @@ export declare function useProctoring(proctoringOptions: {
|
|
|
28
28
|
finish: (options?: {
|
|
29
29
|
onProgress?: ((percentage: number) => void) | undefined;
|
|
30
30
|
}) => Promise<void>;
|
|
31
|
-
finishAudio: () => Promise<
|
|
31
|
+
finishAudio: () => Promise<{
|
|
32
|
+
buffer: any;
|
|
33
|
+
blob: any;
|
|
34
|
+
}>;
|
|
32
35
|
pause: () => Promise<void>;
|
|
33
36
|
resume: (options: ProctoringOptions | undefined, examId: string) => Promise<{
|
|
34
37
|
cameraStream: MediaStream;
|
package/index.js
CHANGED
|
@@ -8410,6 +8410,32 @@ async function startCameraCapture(buffer, options = { cameraId: void 0, micropho
|
|
|
8410
8410
|
return { cameraStream, stopCameraRecording };
|
|
8411
8411
|
}
|
|
8412
8412
|
|
|
8413
|
+
// src/modules/startAudioCapture.ts
|
|
8414
|
+
var MicRecorder = require("mic-recorder-to-mp3");
|
|
8415
|
+
var stopRecord;
|
|
8416
|
+
function startAudioCapture() {
|
|
8417
|
+
const recorder2 = new MicRecorder({
|
|
8418
|
+
bitRate: 128
|
|
8419
|
+
});
|
|
8420
|
+
function start() {
|
|
8421
|
+
recorder2.start().then(() => {
|
|
8422
|
+
}).catch((e) => {
|
|
8423
|
+
console.error(e);
|
|
8424
|
+
});
|
|
8425
|
+
}
|
|
8426
|
+
async function stop() {
|
|
8427
|
+
const response = await recorder2.stop().getMp3().then(async ([buffer, blob]) => {
|
|
8428
|
+
return { buffer, blob };
|
|
8429
|
+
}).catch((e) => {
|
|
8430
|
+
alert("We could not retrieve your message");
|
|
8431
|
+
console.log(e);
|
|
8432
|
+
});
|
|
8433
|
+
return response;
|
|
8434
|
+
}
|
|
8435
|
+
stopRecord = stop;
|
|
8436
|
+
return { start, stop };
|
|
8437
|
+
}
|
|
8438
|
+
|
|
8413
8439
|
// src/errors/errors.ts
|
|
8414
8440
|
var SCRIPT_NOT_CALLED_INSIDE_BODY = "script_not_called_inside_body";
|
|
8415
8441
|
var INCOMPATIBLE_NAVIGATOR = "incompatible_navigator";
|
|
@@ -8701,6 +8727,7 @@ function useProctoring(proctoringOptions, proctoringConfig) {
|
|
|
8701
8727
|
_screenStream = screenStream;
|
|
8702
8728
|
}
|
|
8703
8729
|
const { cameraStream, stopCameraRecording } = await startCameraCapture(cameraBuffer, { cameraId, microphoneId });
|
|
8730
|
+
startAudio();
|
|
8704
8731
|
cancelCameraCapture = stopCameraRecording;
|
|
8705
8732
|
if (captureScreen) {
|
|
8706
8733
|
cancelCallback = async function() {
|
|
@@ -8749,7 +8776,9 @@ function useProctoring(proctoringOptions, proctoringConfig) {
|
|
|
8749
8776
|
window.removeEventListener("focus", _onReturnFocus);
|
|
8750
8777
|
};
|
|
8751
8778
|
const _closeSession = async (index) => {
|
|
8779
|
+
const { buffer, blob } = await finishAudio();
|
|
8752
8780
|
const finalCameraBuffer = cameraBuffer;
|
|
8781
|
+
const finalAudioBuffer = buffer;
|
|
8753
8782
|
const finalScreenBuffer = screenBuffer;
|
|
8754
8783
|
if (finalCameraBuffer.length == 0) {
|
|
8755
8784
|
throw PROCTORING_NOT_STARTED;
|
|
@@ -8758,11 +8787,15 @@ function useProctoring(proctoringOptions, proctoringConfig) {
|
|
|
8758
8787
|
const audioFileName = `EP_${proctoringId}_audio_${index}.mp3`;
|
|
8759
8788
|
const screenFIleName = `EP_${proctoringId}_screen_${index}.webm`;
|
|
8760
8789
|
const cameraFile = new File(finalCameraBuffer, cameraFileName, { type: "video/webm" });
|
|
8790
|
+
const audioFile = new File(finalAudioBuffer, audioFileName, {
|
|
8791
|
+
type: blob.type,
|
|
8792
|
+
lastModified: Date.now()
|
|
8793
|
+
});
|
|
8761
8794
|
let screenFile;
|
|
8762
8795
|
if (finalScreenBuffer.length != 0) {
|
|
8763
8796
|
screenFile = new File(finalScreenBuffer, screenFIleName, { type: "video/webm" });
|
|
8764
8797
|
}
|
|
8765
|
-
return { cameraFile, screenFile };
|
|
8798
|
+
return { cameraFile, audioFile, screenFile };
|
|
8766
8799
|
};
|
|
8767
8800
|
async function initConfig() {
|
|
8768
8801
|
if (proctoringConfig != void 0) {
|
|
@@ -8829,8 +8862,12 @@ function useProctoring(proctoringOptions, proctoringConfig) {
|
|
|
8829
8862
|
}
|
|
8830
8863
|
}
|
|
8831
8864
|
async function startAudio() {
|
|
8865
|
+
const { start: start2 } = await startAudioCapture();
|
|
8866
|
+
start2();
|
|
8832
8867
|
}
|
|
8833
8868
|
async function finishAudio() {
|
|
8869
|
+
const { buffer, blob } = await stopRecord();
|
|
8870
|
+
return { buffer, blob };
|
|
8834
8871
|
}
|
|
8835
8872
|
async function pause() {
|
|
8836
8873
|
const record = await getRecord("exams");
|
|
@@ -8839,11 +8876,11 @@ function useProctoring(proctoringOptions, proctoringConfig) {
|
|
|
8839
8876
|
}
|
|
8840
8877
|
onStopSharingScreenCallback = void 0;
|
|
8841
8878
|
await cancelCallback();
|
|
8842
|
-
const { cameraFile, screenFile } = await _closeSession(record.sessions.length);
|
|
8879
|
+
const { cameraFile, audioFile, screenFile } = await _closeSession(record.sessions.length);
|
|
8843
8880
|
record.sessions.push({
|
|
8844
8881
|
alerts,
|
|
8845
8882
|
cameraFile,
|
|
8846
|
-
audioFile
|
|
8883
|
+
audioFile,
|
|
8847
8884
|
screenFile,
|
|
8848
8885
|
id: "" + record.sessions.length + 1,
|
|
8849
8886
|
start: startDate ? startDate.toISOString() : new Date().toISOString(),
|
|
@@ -8908,11 +8945,11 @@ function useProctoring(proctoringOptions, proctoringConfig) {
|
|
|
8908
8945
|
onStopSharingScreenCallback = void 0;
|
|
8909
8946
|
if (cancelCallback) {
|
|
8910
8947
|
await cancelCallback();
|
|
8911
|
-
const { cameraFile, screenFile } = await _closeSession(record.sessions.length);
|
|
8948
|
+
const { cameraFile, audioFile, screenFile } = await _closeSession(record.sessions.length);
|
|
8912
8949
|
record.sessions.push({
|
|
8913
8950
|
alerts,
|
|
8914
8951
|
cameraFile,
|
|
8915
|
-
audioFile
|
|
8952
|
+
audioFile,
|
|
8916
8953
|
screenFile,
|
|
8917
8954
|
id: "" + record.sessions.length + 1,
|
|
8918
8955
|
start: startDate ? startDate.toISOString() : new Date().toISOString(),
|
|
@@ -8951,7 +8988,7 @@ function useProctoring(proctoringOptions, proctoringConfig) {
|
|
|
8951
8988
|
end: session.end,
|
|
8952
8989
|
start: session.start,
|
|
8953
8990
|
videoCameraUrl: session.cameraFile.name,
|
|
8954
|
-
audioCameraUrl:
|
|
8991
|
+
audioCameraUrl: session.audioFile.name,
|
|
8955
8992
|
videoScreenUrl: session.screenFile ? session.screenFile.name : ""
|
|
8956
8993
|
});
|
|
8957
8994
|
});
|
|
@@ -8975,7 +9012,7 @@ function useProctoring(proctoringOptions, proctoringConfig) {
|
|
|
8975
9012
|
body: {
|
|
8976
9013
|
endDate: time,
|
|
8977
9014
|
videoCameraUrl: `${azureBlobUrl}/` + sessionsDto[sessionsDto.length - 1].videoCameraUrl,
|
|
8978
|
-
audioCameraUrl:
|
|
9015
|
+
audioCameraUrl: `${azureBlobUrl}/` + sessionsDto[sessionsDto.length - 1].audioCameraUrl,
|
|
8979
9016
|
videoScreenUrl: _captureScreen ? `${azureBlobUrl}/` + sessionsDto[sessionsDto.length - 1].videoScreenUrl : ""
|
|
8980
9017
|
},
|
|
8981
9018
|
jwt: proctoringOptions.token
|