easyproctor 1.0.2 → 1.0.3

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/index.js CHANGED
@@ -33583,17 +33583,16 @@ var ScreenRecorder = class {
33583
33583
  };
33584
33584
 
33585
33585
  // src/proctoring/options/ProctoringOptions.ts
33586
- function getDefaultProctoringOptions() {
33587
- return {
33588
- cameraId: void 0,
33589
- microphoneId: void 0,
33590
- allowMultipleMonitors: false,
33591
- allowOnlyFirstMonitor: true,
33592
- captureScreen: true,
33593
- proctoringType: "IMAGE",
33594
- insights: ""
33595
- };
33596
- }
33586
+ var getDefaultProctoringOptions = {
33587
+ cameraId: void 0,
33588
+ microphoneId: void 0,
33589
+ allowMultipleMonitors: false,
33590
+ allowOnlyFirstMonitor: true,
33591
+ captureScreen: true,
33592
+ noiseLimit: 40,
33593
+ proctoringType: "IMAGE",
33594
+ insights: ""
33595
+ };
33597
33596
 
33598
33597
  // src/proctoring/options/ProctoringVideoOptions.ts
33599
33598
  function validatePartialVideoOptions(options) {
@@ -33611,68 +33610,82 @@ function validatePartialVideoOptions(options) {
33611
33610
  var DeviceChecker = class {
33612
33611
  constructor() {
33613
33612
  }
33614
- async checkDevices(options = getDefaultProctoringOptions(), _videoOptions) {
33615
- this.checkDevicesInterface();
33616
- const { cameraStream, _screenStream } = await this.startCheckDevices(options, _videoOptions);
33617
- this.videoDeviceInterface(cameraStream);
33618
- this.audioDeviceInterface(cameraStream);
33613
+ async checkDevices(options = getDefaultProctoringOptions, _videoOptions = { width: 1080, height: 720 }) {
33614
+ this.options = {
33615
+ ...getDefaultProctoringOptions,
33616
+ ...options,
33617
+ captureScreen: false,
33618
+ allowMultipleMonitors: true,
33619
+ allowOnlyFirstMonitor: false
33620
+ };
33621
+ this.videoOptions = _videoOptions;
33622
+ return this.checkDevicesInterface();
33619
33623
  }
33620
33624
  checkDevicesInterface() {
33621
- const fullBg = document.createElement("div");
33622
- fullBg.setAttribute("id", "checkDevices");
33623
- fullBg.style.backgroundColor = "rgba(0,0,0,0.4)";
33624
- fullBg.style.zIndex = "1000";
33625
- fullBg.style.position = "absolute";
33626
- fullBg.style.top = "0";
33627
- fullBg.style.left = "0";
33628
- fullBg.style.height = "100vh";
33629
- fullBg.style.width = "100%";
33630
- fullBg.style.display = "flex";
33631
- fullBg.style.alignItems = "center";
33632
- fullBg.style.justifyContent = "center";
33633
- const modal = document.createElement("div");
33634
- modal.style.backgroundColor = "#fff";
33635
- modal.style.zIndex = "1001";
33636
- modal.style.width = "400px";
33637
- modal.style.borderRadius = "10px";
33638
- modal.style.padding = "20px 10px";
33639
- modal.style.display = "flex";
33640
- modal.style.flexDirection = "column";
33641
- modal.style.alignItems = "center";
33642
- const h3 = document.createElement("h3");
33643
- h3.innerText = "Verificar dispositivos";
33644
- h3.style.color = "rgb(22, 163, 74)";
33645
- h3.style.fontWeight = "bold";
33646
- h3.style.fontSize = "26px";
33647
- h3.style.marginBottom = "15px";
33648
- modal.appendChild(h3);
33649
- const video = document.createElement("video");
33650
- video.setAttribute("id", "cameraStream");
33651
- video.style.width = "20rem";
33652
- video.style.backgroundColor = "#000";
33653
- video.style.borderRadius = "10px";
33654
- video.style.marginBottom = "15px";
33655
- modal.appendChild(video);
33656
- const meter = document.createElement("meter");
33657
- meter.setAttribute("id", "audioStream");
33658
- meter.setAttribute("high", "0.25");
33659
- meter.setAttribute("max", "1");
33660
- meter.style.width = "20rem";
33661
- meter.style.borderRadius = "10px";
33662
- meter.style.marginBottom = "15px";
33663
- modal.appendChild(meter);
33664
- const button = document.createElement("button");
33665
- button.setAttribute("id", "confirmBtn");
33666
- button.innerText = "Confirmar";
33667
- button.style.width = "200px";
33668
- button.style.height = "50px";
33669
- button.style.backgroundColor = "rgb(22, 163, 74)";
33670
- button.style.color = "#fff";
33671
- button.style.borderRadius = "10px";
33672
- button.addEventListener("click", () => this.closeCheckDevices());
33673
- modal.appendChild(button);
33674
- fullBg.appendChild(modal);
33675
- document.body.appendChild(fullBg);
33625
+ return new Promise((resolve) => {
33626
+ const fullBg = document.createElement("div");
33627
+ fullBg.setAttribute("id", "checkDevices");
33628
+ fullBg.style.backgroundColor = "rgba(0,0,0,0.4)";
33629
+ fullBg.style.zIndex = "1000";
33630
+ fullBg.style.position = "absolute";
33631
+ fullBg.style.top = "0";
33632
+ fullBg.style.left = "0";
33633
+ fullBg.style.height = "100vh";
33634
+ fullBg.style.width = "100%";
33635
+ fullBg.style.display = "flex";
33636
+ fullBg.style.alignItems = "center";
33637
+ fullBg.style.justifyContent = "center";
33638
+ const modal = document.createElement("div");
33639
+ modal.style.backgroundColor = "#fff";
33640
+ modal.style.zIndex = "1001";
33641
+ modal.style.width = "400px";
33642
+ modal.style.borderRadius = "10px";
33643
+ modal.style.padding = "20px 10px";
33644
+ modal.style.display = "flex";
33645
+ modal.style.flexDirection = "column";
33646
+ modal.style.alignItems = "center";
33647
+ const h3 = document.createElement("h3");
33648
+ h3.innerText = "Verificar dispositivos";
33649
+ h3.style.color = "rgb(22, 163, 74)";
33650
+ h3.style.fontWeight = "bold";
33651
+ h3.style.fontSize = "26px";
33652
+ h3.style.marginBottom = "15px";
33653
+ modal.appendChild(h3);
33654
+ const video = document.createElement("video");
33655
+ video.setAttribute("id", "cameraStream");
33656
+ video.style.width = "20rem";
33657
+ video.style.backgroundColor = "#000";
33658
+ video.style.borderRadius = "10px";
33659
+ video.style.marginBottom = "15px";
33660
+ modal.appendChild(video);
33661
+ const meter = document.createElement("meter");
33662
+ meter.setAttribute("id", "audioStream");
33663
+ meter.setAttribute("high", "0.25");
33664
+ meter.setAttribute("max", "1");
33665
+ meter.style.width = "20rem";
33666
+ meter.style.borderRadius = "10px";
33667
+ meter.style.marginBottom = "15px";
33668
+ modal.appendChild(meter);
33669
+ const button = document.createElement("button");
33670
+ button.setAttribute("id", "confirmBtn");
33671
+ button.innerText = "Confirmar";
33672
+ button.style.width = "200px";
33673
+ button.style.height = "50px";
33674
+ button.style.backgroundColor = "rgb(22, 163, 74)";
33675
+ button.style.color = "#fff";
33676
+ button.style.borderRadius = "10px";
33677
+ button.addEventListener("click", () => {
33678
+ this.closeCheckDevices();
33679
+ resolve("Complete");
33680
+ });
33681
+ modal.appendChild(button);
33682
+ fullBg.appendChild(modal);
33683
+ document.body.appendChild(fullBg);
33684
+ this.startCheckDevices(this.options, this.videoOptions);
33685
+ });
33686
+ }
33687
+ async startDevice() {
33688
+ const { cameraStream, _screenStream } = await this.startCheckDevices(this.options, this.videoOptions);
33676
33689
  }
33677
33690
  videoDeviceInterface(stream3) {
33678
33691
  const cameraStream = document.querySelector("#cameraStream");
@@ -33699,7 +33712,7 @@ var DeviceChecker = class {
33699
33712
  };
33700
33713
  window.requestAnimationFrame(onFrame);
33701
33714
  }
33702
- async startCheckDevices(options = getDefaultProctoringOptions(), _videoOptions) {
33715
+ async startCheckDevices(options = getDefaultProctoringOptions, _videoOptions) {
33703
33716
  var _a;
33704
33717
  this.videoOptions = validatePartialVideoOptions(_videoOptions);
33705
33718
  await checkPermissions();
@@ -33721,6 +33734,8 @@ var DeviceChecker = class {
33721
33734
  if (this.screenRecorder) {
33722
33735
  await this.screenRecorder.startRecording();
33723
33736
  }
33737
+ this.videoDeviceInterface(this.cameraRecorder.cameraStream);
33738
+ this.audioDeviceInterface(this.cameraRecorder.cameraStream);
33724
33739
  return {
33725
33740
  cameraStream: this.cameraRecorder.cameraStream,
33726
33741
  _screenStream: (_a = this.screenRecorder) == null ? void 0 : _a.screenStream
@@ -33766,7 +33781,7 @@ var Extension = class {
33766
33781
  }
33767
33782
  verify(event) {
33768
33783
  if (event.source == window && event.data.sender && event.data.sender === "easyproctor-extension" && event.data.message_name && event.data.message_name === "progress") {
33769
- this.onProgress(100);
33784
+ this.options.onProgress && this.options.onProgress(100);
33770
33785
  }
33771
33786
  if (event.source == window && event.data.sender && event.data.sender === "easyproctor-extension" && event.data.message_name && event.data.message_name === "start") {
33772
33787
  this.responseStart = true;
@@ -36285,6 +36300,16 @@ var BackendService = class {
36285
36300
  });
36286
36301
  return insights2.data;
36287
36302
  }
36303
+ async getAzureBlobUrl(proctoringOptions) {
36304
+ const blobUrl = await this.makeRequestAxios({
36305
+ path: `/AzureKey/get-blob-url`,
36306
+ method: "GET",
36307
+ jwt: proctoringOptions.token
36308
+ }).catch((error) => {
36309
+ throw "N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde";
36310
+ });
36311
+ return blobUrl.data;
36312
+ }
36288
36313
  async getAzureSignedUrl(token, file) {
36289
36314
  const urlAzure = await this.makeRequestAxios({
36290
36315
  path: `/AzureKey/signed-url`,
@@ -36331,15 +36356,21 @@ var BackendService = class {
36331
36356
  });
36332
36357
  }
36333
36358
  async finishAndSendUrls(proctoringOptions, proctoringSession) {
36334
- var _a, _b, _c;
36359
+ var _a, _b, _c, _d, _e, _f;
36335
36360
  const serverTime = new Date().toISOString();
36336
36361
  const videoCameraUpload = (_a = proctoringSession.recordings.find((e) => e.origin === "Camera" /* Camera */)) == null ? void 0 : _a.upload;
36337
36362
  const audioCameraUpload = (_b = proctoringSession.recordings.find((e) => e.origin === "Mic" /* Mic */)) == null ? void 0 : _b.upload;
36338
36363
  const videoScreenUpload = (_c = proctoringSession.recordings.find((e) => e.origin === "Screen" /* Screen */)) == null ? void 0 : _c.upload;
36339
36364
  const clearUrl = (url2) => url2 ? url2.substring(0, url2.indexOf("?")) : void 0;
36340
- const videoCameraUrl = clearUrl(videoCameraUpload == null ? void 0 : videoCameraUpload.azureUrl);
36341
- const audioCameraUrl = clearUrl(audioCameraUpload == null ? void 0 : audioCameraUpload.azureUrl);
36342
- const videoScreenUrl = clearUrl(videoScreenUpload == null ? void 0 : videoScreenUpload.azureUrl);
36365
+ let videoCameraUrl = clearUrl(videoCameraUpload == null ? void 0 : videoCameraUpload.azureUrl);
36366
+ let audioCameraUrl = clearUrl(audioCameraUpload == null ? void 0 : audioCameraUpload.azureUrl);
36367
+ let videoScreenUrl = clearUrl(videoScreenUpload == null ? void 0 : videoScreenUpload.azureUrl);
36368
+ if (!videoCameraUrl || !audioCameraUrl || !videoScreenUrl) {
36369
+ const blobUrl = await this.getAzureBlobUrl(proctoringOptions);
36370
+ !videoCameraUrl && (videoCameraUrl = `${blobUrl}/${(_d = proctoringSession.recordings.find((e) => e.origin === "Camera" /* Camera */)) == null ? void 0 : _d.file.name}`);
36371
+ !audioCameraUrl && (audioCameraUrl = `${blobUrl}/${(_e = proctoringSession.recordings.find((e) => e.origin === "Mic" /* Mic */)) == null ? void 0 : _e.file.name}`);
36372
+ !videoScreenUrl && proctoringSession.recordings.find((e) => e.origin === "Screen" /* Screen */) && (videoScreenUrl = `${blobUrl}/${(_f = proctoringSession.recordings.find((e) => e.origin === "Screen" /* Screen */)) == null ? void 0 : _f.file.name}`);
36373
+ }
36343
36374
  await this.makeRequest({
36344
36375
  path: `/proctoring/finish/${proctoringOptions.examId}`,
36345
36376
  method: "POST",
@@ -36559,16 +36590,62 @@ var ProctoringUploader = class {
36559
36590
  }
36560
36591
  };
36561
36592
 
36593
+ // src/new-flow/recorders/VolumeMeter.ts
36594
+ var VolumeMeter = class {
36595
+ constructor(stream3) {
36596
+ this.stream = stream3;
36597
+ }
36598
+ start() {
36599
+ return new Promise((resolve, reject) => {
36600
+ try {
36601
+ const audioContext = new AudioContext();
36602
+ const analyser = audioContext.createAnalyser();
36603
+ const microphone = audioContext.createMediaStreamSource(this.stream);
36604
+ this.scriptProcessor = audioContext.createScriptProcessor(2048, 1, 1);
36605
+ analyser.smoothingTimeConstant = 0.8;
36606
+ analyser.fftSize = 1024;
36607
+ microphone.connect(analyser);
36608
+ analyser.connect(this.scriptProcessor);
36609
+ this.scriptProcessor.connect(audioContext.destination);
36610
+ const that = this;
36611
+ this.scriptProcessor.onaudioprocess = function() {
36612
+ const array = new Uint8Array(analyser.frequencyBinCount);
36613
+ analyser.getByteFrequencyData(array);
36614
+ const arraySum = array.reduce((a, value) => a + value, 0);
36615
+ const average = arraySum / array.length;
36616
+ that.setVolume(average);
36617
+ };
36618
+ resolve(true);
36619
+ } catch (error) {
36620
+ this.stop();
36621
+ reject(`Error: ${error}`);
36622
+ }
36623
+ });
36624
+ }
36625
+ stop() {
36626
+ this.scriptProcessor && this.scriptProcessor.disconnect();
36627
+ }
36628
+ getVolume() {
36629
+ return this.volume;
36630
+ }
36631
+ setVolume(value) {
36632
+ this.volume = value;
36633
+ }
36634
+ };
36635
+
36562
36636
  // src/new-flow/recorders/AlertRecorder.ts
36563
36637
  var AlertRecorder = class {
36564
- constructor(options, optionsProctoring) {
36638
+ constructor(options, optionsProctoring, cameraRecorder) {
36565
36639
  this.alerts = [];
36566
36640
  this.onLostFocusCallback = options.onLostFocusCallback;
36567
36641
  this.onFocusCallback = options.onFocusCallback;
36642
+ this.onNoiseDetectedCallback = options.onNoiseDetectedCallback;
36568
36643
  this.optionsProctoring = optionsProctoring;
36644
+ this.cameraRecorder = cameraRecorder;
36569
36645
  }
36570
36646
  async startRecording() {
36571
36647
  this.startTime = new Date(Date.now());
36648
+ this.intervalNoiseDetection = setInterval(() => this.onNoiseDetected(), 500);
36572
36649
  if (this.optionsProctoring.captureScreen) {
36573
36650
  window.addEventListener("blur", () => this.onLostFocus());
36574
36651
  window.addEventListener("focus", () => this.onReturnFocus());
@@ -36577,16 +36654,25 @@ var AlertRecorder = class {
36577
36654
  async pauseRecording() {
36578
36655
  window.removeEventListener("blur", () => this.onLostFocus());
36579
36656
  window.removeEventListener("focus", () => this.onReturnFocus());
36657
+ window.removeEventListener("focus", () => this.onNoiseDetected());
36658
+ this.volumeMeter.stop();
36659
+ clearInterval(this.intervalNoiseDetection);
36580
36660
  }
36581
36661
  async resumeRecording() {
36662
+ this.volumeMeter = void 0;
36663
+ this.intervalNoiseDetection = setInterval(() => this.onNoiseDetected(), 500);
36582
36664
  if (this.optionsProctoring.captureScreen) {
36583
36665
  window.addEventListener("blur", () => this.onLostFocus());
36584
36666
  window.addEventListener("focus", () => this.onReturnFocus());
36667
+ window.addEventListener("focus", () => this.onNoiseDetected());
36585
36668
  }
36586
36669
  }
36587
36670
  async stopRecording() {
36588
36671
  window.removeEventListener("blur", () => this.onLostFocus());
36589
36672
  window.removeEventListener("focus", () => this.onReturnFocus());
36673
+ window.removeEventListener("focus", () => this.onNoiseDetected());
36674
+ this.volumeMeter.stop();
36675
+ clearInterval(this.intervalNoiseDetection);
36590
36676
  }
36591
36677
  async saveOnSession(session) {
36592
36678
  this.alerts.forEach((alert2) => {
@@ -36611,6 +36697,19 @@ var AlertRecorder = class {
36611
36697
  lastAlert.end = Date.now() - this.startTime.getTime();
36612
36698
  }
36613
36699
  }
36700
+ onNoiseDetected() {
36701
+ var _a;
36702
+ if (!this.volumeMeter && this.cameraRecorder.cameraStream) {
36703
+ this.volumeMeter = new VolumeMeter(this.cameraRecorder.cameraStream);
36704
+ this.volumeMeter.start().catch((e) => {
36705
+ console.log(e);
36706
+ this.volumeMeter = void 0;
36707
+ });
36708
+ }
36709
+ if (((_a = this.volumeMeter) == null ? void 0 : _a.getVolume()) >= (this.optionsProctoring.noiseLimit || 40)) {
36710
+ this.onNoiseDetectedCallback();
36711
+ }
36712
+ }
36614
36713
  };
36615
36714
 
36616
36715
  // src/new-flow/repository/IndexDbSessionRepository.ts
@@ -36798,6 +36897,8 @@ var Proctoring = class {
36798
36897
  };
36799
36898
  this.onFocusCallback = () => {
36800
36899
  };
36900
+ this.onNoiseDetectedCallback = () => {
36901
+ };
36801
36902
  this.backend = new BackendService({
36802
36903
  type: context.type
36803
36904
  });
@@ -36813,11 +36914,14 @@ var Proctoring = class {
36813
36914
  setOnFocusCallback(cb) {
36814
36915
  this.onFocusCallback = () => cb();
36815
36916
  }
36917
+ setOnNoiseDetectedCallback(cb) {
36918
+ this.onNoiseDetectedCallback = () => cb();
36919
+ }
36816
36920
  async onChangeDevices(options = {}) {
36817
36921
  const onChange = new onChangeDevices(this.repositoryDevices, this.proctoringId);
36818
36922
  onChange.startRecording(options);
36819
36923
  }
36820
- createRecorders(options = getDefaultProctoringOptions()) {
36924
+ createRecorders(options = getDefaultProctoringOptions) {
36821
36925
  var _a;
36822
36926
  const cameraRecorder = new CameraRecorder({
36823
36927
  cameraId: this.sessionOptions.cameraId,
@@ -36833,8 +36937,9 @@ var Proctoring = class {
36833
36937
  }) : void 0;
36834
36938
  const alertRecorder = new AlertRecorder({
36835
36939
  onFocusCallback: () => this.onFocusCallback(),
36836
- onLostFocusCallback: () => this.onLostFocusCallback()
36837
- }, options);
36940
+ onLostFocusCallback: () => this.onLostFocusCallback(),
36941
+ onNoiseDetectedCallback: () => this.onNoiseDetectedCallback()
36942
+ }, options, cameraRecorder);
36838
36943
  this.onChangeDevices();
36839
36944
  const recorders = [
36840
36945
  cameraRecorder,
@@ -36845,14 +36950,14 @@ var Proctoring = class {
36845
36950
  this.recorder = new ProctoringRecorder(this.proctoringSession, recorders);
36846
36951
  return { cameraRecorder, audioRecorder, screenRecorder, alertRecorder };
36847
36952
  }
36848
- async start(options = getDefaultProctoringOptions(), _videoOptions = {}) {
36953
+ async start(options = getDefaultProctoringOptions, _videoOptions = {}) {
36849
36954
  this.extension = new Extension();
36850
36955
  this.extension.addEventListener();
36851
36956
  const baseURL = this.backend.selectBaseUrl(this.context.type);
36852
36957
  setTimeout(() => this.extension.sendVerifyMsg(baseURL, this.context.token), 5e3);
36853
36958
  const devices = await enumarateDevices();
36854
36959
  await this.repositoryDevices.save({ ...devices, id: "devices" });
36855
- this.sessionOptions = options;
36960
+ this.sessionOptions = { ...getDefaultProctoringOptions, ...options };
36856
36961
  this.videoOptions = validatePartialVideoOptions(_videoOptions);
36857
36962
  if (this.state != "Stop" /* Stop */) {
36858
36963
  throw PROCTORING_ALREADY_STARTED;
@@ -36871,7 +36976,7 @@ var Proctoring = class {
36871
36976
  }, this.sessionOptions.proctoringType);
36872
36977
  this.proctoringId = startResponse.id;
36873
36978
  this.proctoringSession = new ProctoringSession(this.proctoringId);
36874
- this.allRecorders = this.createRecorders(options);
36979
+ this.allRecorders = this.createRecorders(this.sessionOptions);
36875
36980
  await this.recorder.startAll();
36876
36981
  await this.repository.save(this.proctoringSession);
36877
36982
  trackers.registerStart(this.proctoringId, true, "");
@@ -36896,7 +37001,7 @@ Error: ` + error);
36896
37001
  this.state = "Stop" /* Stop */;
36897
37002
  }
36898
37003
  async finish(options = {}) {
36899
- this.extension.onProgress = () => options.onProgress;
37004
+ this.extension.options = options;
36900
37005
  if (this.state !== "Recording" /* Recording */) {
36901
37006
  throw PROCTORING_NOT_STARTED;
36902
37007
  }
@@ -37008,7 +37113,7 @@ Upload Services: ${uploaderServices}`, this.serviceType);
37008
37113
  throw PROCTORING_NOT_STARTED;
37009
37114
  }
37010
37115
  await this.verifyMultipleMonitors(this.sessionOptions);
37011
- const allRecorders = this.createRecorders(this.sessionOptions);
37116
+ this.allRecorders = this.createRecorders(this.sessionOptions);
37012
37117
  await this.recorder.startAll();
37013
37118
  this.proctoringSession.recordings = [];
37014
37119
  await this.repository.save(this.proctoringSession);
@@ -37035,6 +37140,7 @@ function useProctoring(proctoringOptions, enviromentConfig = "prod") {
37035
37140
  const resume = proctoring.resume.bind(proctoring);
37036
37141
  const onFocus = proctoring.setOnFocusCallback.bind(proctoring);
37037
37142
  const onLostFocus = proctoring.setOnLostFocusCallback.bind(proctoring);
37143
+ const onNoiseDetected = proctoring.setOnNoiseDetectedCallback.bind(proctoring);
37038
37144
  const onChangeDevices2 = proctoring.onChangeDevices.bind(proctoring);
37039
37145
  const onStopSharingScreen = proctoring.setOnStopSharingScreenCallback.bind(proctoring);
37040
37146
  const checkDevices = checker.checkDevices.bind(checker);
@@ -37043,6 +37149,7 @@ function useProctoring(proctoringOptions, enviromentConfig = "prod") {
37043
37149
  finish,
37044
37150
  onFocus,
37045
37151
  onLostFocus,
37152
+ onNoiseDetected,
37046
37153
  onChangeDevices: onChangeDevices2,
37047
37154
  checkDevices,
37048
37155
  pause,
@@ -17,6 +17,11 @@ export declare class BackendService {
17
17
  clientId: any;
18
18
  token: any;
19
19
  }): Promise<any>;
20
+ getAzureBlobUrl(proctoringOptions: {
21
+ examId: any;
22
+ clientId: any;
23
+ token: any;
24
+ }): Promise<string>;
20
25
  getAzureSignedUrl(token: string, file: File): Promise<string>;
21
26
  getAwsSignedUrl(token: string, file: File): Promise<string>;
22
27
  sendAwsToAzure(token: string, file: File): Promise<void>;
@@ -1,16 +1,22 @@
1
1
  import { ProctoringSessionOptions } from "../../proctoring/options/ProctoringOptions";
2
2
  import { ProctoringSession } from "../proctoring/ProctoringSession";
3
+ import { CameraRecorder } from "./CameraRecorder";
3
4
  import { IRecorder } from "./IRecorder";
4
5
  export declare class AlertRecorder implements IRecorder {
5
6
  private alerts;
6
7
  private startTime;
7
8
  private onLostFocusCallback;
8
9
  private onFocusCallback;
10
+ private onNoiseDetectedCallback;
9
11
  private optionsProctoring;
12
+ private cameraRecorder;
13
+ private intervalNoiseDetection;
14
+ private volumeMeter;
10
15
  constructor(options: {
11
16
  onLostFocusCallback: () => void;
12
17
  onFocusCallback: () => void;
13
- }, optionsProctoring: ProctoringSessionOptions);
18
+ onNoiseDetectedCallback: () => void;
19
+ }, optionsProctoring: ProctoringSessionOptions, cameraRecorder: CameraRecorder);
14
20
  startRecording(): Promise<void>;
15
21
  pauseRecording(): Promise<void>;
16
22
  resumeRecording(): Promise<void>;
@@ -18,4 +24,5 @@ export declare class AlertRecorder implements IRecorder {
18
24
  saveOnSession(session: ProctoringSession): Promise<void>;
19
25
  private onLostFocus;
20
26
  private onReturnFocus;
27
+ private onNoiseDetected;
21
28
  }
@@ -0,0 +1,10 @@
1
+ export declare class VolumeMeter {
2
+ private volume;
3
+ private stream;
4
+ private scriptProcessor;
5
+ constructor(stream: MediaStream);
6
+ start(): Promise<any>;
7
+ stop(): void;
8
+ getVolume(): any;
9
+ private setVolume;
10
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "easyproctor",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Modulo web de gravação do EasyProctor",
5
5
  "main": "./index.js",
6
6
  "module": "./esm/index.js",
@@ -1,13 +1,15 @@
1
1
  import { ProctoringSessionOptions } from "./options/ProctoringOptions";
2
2
  import { ProctoringVideoOptions } from "./options/ProctoringVideoOptions";
3
3
  export declare class DeviceChecker {
4
+ private options;
4
5
  private videoOptions;
5
6
  private cameraRecorder;
6
7
  private audioRecorder;
7
8
  private screenRecorder;
8
9
  constructor();
9
- checkDevices(options: ProctoringSessionOptions | undefined, _videoOptions: Partial<ProctoringVideoOptions>): Promise<void>;
10
+ checkDevices(options?: ProctoringSessionOptions, _videoOptions?: ProctoringVideoOptions): Promise<unknown>;
10
11
  private checkDevicesInterface;
12
+ private startDevice;
11
13
  private videoDeviceInterface;
12
14
  private audioDeviceInterface;
13
15
  startCheckDevices(options: ProctoringSessionOptions | undefined, _videoOptions: Partial<ProctoringVideoOptions>): Promise<{
@@ -4,7 +4,8 @@ export interface ProctoringSessionOptions {
4
4
  allowMultipleMonitors?: boolean;
5
5
  allowOnlyFirstMonitor?: boolean;
6
6
  captureScreen?: boolean;
7
+ noiseLimit?: number;
7
8
  proctoringType: "VIDEO" | "IMAGE";
8
9
  insights: string;
9
10
  }
10
- export declare function getDefaultProctoringOptions(): ProctoringSessionOptions;
11
+ export declare const getDefaultProctoringOptions: ProctoringSessionOptions;
@@ -46,6 +46,8 @@ export declare class Proctoring {
46
46
  setOnLostFocusCallback(cb: () => void): void;
47
47
  private onFocusCallback;
48
48
  setOnFocusCallback(cb: () => void): void;
49
+ private onNoiseDetectedCallback;
50
+ setOnNoiseDetectedCallback(cb: () => void): void;
49
51
  onChangeDevices(options?: ProctoringChangeDevicesOptions): Promise<void>;
50
52
  constructor(context: ProctoringContext);
51
53
  private createRecorders;
@@ -9,8 +9,9 @@ export declare function useProctoring(proctoringOptions: {
9
9
  finish: (options?: import("./proctoring").ProctoringFinisherOptions) => Promise<void>;
10
10
  onFocus: (cb: () => void) => void;
11
11
  onLostFocus: (cb: () => void) => void;
12
+ onNoiseDetected: (cb: () => void) => void;
12
13
  onChangeDevices: (options?: import("./proctoring").ProctoringChangeDevicesOptions) => Promise<void>;
13
- checkDevices: (options: import("./options/ProctoringOptions").ProctoringSessionOptions | undefined, _videoOptions: Partial<import("./options/ProctoringVideoOptions").ProctoringVideoOptions>) => Promise<void>;
14
+ checkDevices: (options?: import("./options/ProctoringOptions").ProctoringSessionOptions, _videoOptions?: import("./options/ProctoringVideoOptions").ProctoringVideoOptions) => Promise<unknown>;
14
15
  pause: () => Promise<void>;
15
16
  resume: () => Promise<{
16
17
  cameraStream: MediaStream;