easyproctor 2.5.9 → 2.6.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 CHANGED
@@ -264,6 +264,9 @@ const {
264
264
  });
265
265
  ```
266
266
 
267
+ ## Release Note V 2.6.0
268
+ - Implementação da comunicação entre componente e navegador seguro
269
+
267
270
  ## Release Note V 2.5.8
268
271
  - removendo fechamento do webm com a duração para refinamento
269
272
 
@@ -16,6 +16,7 @@ export declare const TOKEN_MISSING = "token_missing";
16
16
  export declare const CREDENTIALS_MISSING = "credentials_missing";
17
17
  export declare const CAMERA_BLOCKED = "camera_blocked";
18
18
  export declare const SPY_SCAN_API_NOT_FOUND = "spy_scan_api_not_found";
19
+ export declare const SAFE_BROWSER_API_NOT_FOUND = "safe_browser_api_not_found";
19
20
  export declare const ERROR_ON_MOBILE_APP_NOT_FOUND = "error_on_mobile_app_not_found";
20
21
  export declare const EXTERNAL_CAMERA_NOT_STARTED = "external_camera_not_started";
21
22
  export declare const EXTERNAL_CAMERA_CHECK_TRANSMISSION = "external_camera_timed_out";
package/esm/index.js CHANGED
@@ -9155,7 +9155,7 @@ var BaseDetection = class {
9155
9155
  this.createdVideo && this.video && document.body.removeChild(this.video);
9156
9156
  this.createdVideo = false;
9157
9157
  }
9158
- enableCam(cameraStream) {
9158
+ enableCam(cameraStream, delay = 1e4) {
9159
9159
  var _a2;
9160
9160
  if (!this.detector) {
9161
9161
  console.log("Wait! Detector not loaded yet.");
@@ -9185,7 +9185,7 @@ var BaseDetection = class {
9185
9185
  (_a2 = this.video) == null ? void 0 : _a2.addEventListener("loadeddata", () => {
9186
9186
  this.animationFrameId = setTimeout(() => {
9187
9187
  that.predictWebcam();
9188
- }, 1e4);
9188
+ }, delay);
9189
9189
  });
9190
9190
  const style = document.createElement("style");
9191
9191
  style.type = "text/css";
@@ -13101,6 +13101,7 @@ var BROWSER_NOT_SUPPORTED = "browser_not_supported";
13101
13101
  var TOKEN_MISSING = "token_missing";
13102
13102
  var CREDENTIALS_MISSING = "credentials_missing";
13103
13103
  var SPY_SCAN_API_NOT_FOUND = "spy_scan_api_not_found";
13104
+ var SAFE_BROWSER_API_NOT_FOUND = "safe_browser_api_not_found";
13104
13105
  var EXTERNAL_CAMERA_NOT_STARTED = "external_camera_not_started";
13105
13106
 
13106
13107
  // src/modules/objectDetection.ts
@@ -13537,7 +13538,7 @@ Setting: ${JSON.stringify(settings, null, 2)}`
13537
13538
  this.volumeMeter && this.volumeMeter.stop();
13538
13539
  this.intervalNoiseDetection && clearInterval(this.intervalNoiseDetection);
13539
13540
  this.recordingStop && await this.recordingStop();
13540
- this.duration = this.getDuration();
13541
+ this.duration = this.getDuration ? this.getDuration() : 0;
13541
13542
  try {
13542
13543
  if (this.animationFrameId) {
13543
13544
  cancelAnimationFrame(this.animationFrameId);
@@ -14993,7 +14994,7 @@ var _DeviceCheckerService = class _DeviceCheckerService {
14993
14994
  videoDeviceInterface(stream) {
14994
14995
  this.DeviceCheckerUI && this.DeviceCheckerUI.videoDeviceInterfaceUI(stream);
14995
14996
  this.isUnderResolution();
14996
- this.faceDetection.enableCam(stream);
14997
+ this.faceDetection.enableCam(stream, 1e3);
14997
14998
  }
14998
14999
  audioDeviceInterface(stream) {
14999
15000
  this.volumeMeter = new VolumeMeter(this.cameraRecorder.cameraStream);
@@ -18694,6 +18695,49 @@ var Auth = class {
18694
18695
  }
18695
18696
  };
18696
18697
 
18698
+ // src/new-flow/backend/SafeBrowserBackendService.ts
18699
+ var SafeBrowserBackendService = class {
18700
+ constructor() {
18701
+ this.baseUrl = "http://localhost:7485/Station/api";
18702
+ }
18703
+ async isAlive() {
18704
+ const paramsConfig = await this.makeRequestAxios({
18705
+ path: `/health`,
18706
+ method: "GET",
18707
+ jwt: this.token
18708
+ }).catch((error) => {
18709
+ throw "N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde";
18710
+ });
18711
+ return paramsConfig.data;
18712
+ }
18713
+ async setProctoringId(proctoringId2) {
18714
+ const paramsConfig = await this.makeRequestAxios({
18715
+ path: `/update-station/` + proctoringId2,
18716
+ method: "POST",
18717
+ jwt: this.token
18718
+ }).catch((error) => {
18719
+ throw "N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde";
18720
+ });
18721
+ return paramsConfig.data;
18722
+ }
18723
+ async makeRequestAxios(data) {
18724
+ const { path, method, body, jwt } = data;
18725
+ const resp = await axios_default.request({
18726
+ url: this.baseUrl + path,
18727
+ method,
18728
+ headers: {
18729
+ Authorization: `Bearer ${jwt}`,
18730
+ "Access-Control-Allow-Origin": "*"
18731
+ },
18732
+ data: body
18733
+ });
18734
+ if (resp.status >= 400) {
18735
+ throw "N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde";
18736
+ }
18737
+ return resp;
18738
+ }
18739
+ };
18740
+
18697
18741
  // node_modules/@microsoft/signalr/dist/esm/Errors.js
18698
18742
  var HttpError = class extends Error {
18699
18743
  /** Constructs a new instance of {@link @microsoft/signalr.HttpError}.
@@ -22577,6 +22621,13 @@ var Proctoring = class {
22577
22621
  } catch (error) {
22578
22622
  throw SPY_SCAN_API_NOT_FOUND;
22579
22623
  }
22624
+ try {
22625
+ if (options == null ? void 0 : options.useSafeBrowserAPI) {
22626
+ await this.safeBrowserBackendService.isAlive();
22627
+ }
22628
+ } catch (error) {
22629
+ throw SAFE_BROWSER_API_NOT_FOUND;
22630
+ }
22580
22631
  if (this.state != "Stop" /* Stop */) {
22581
22632
  throw PROCTORING_ALREADY_STARTED;
22582
22633
  }
@@ -22612,6 +22663,13 @@ var Proctoring = class {
22612
22663
  this.allRecorders.cameraRecorder.setProctoringId(this.proctoringId);
22613
22664
  this.allRecorders.noiseRecorder.setProctoringId(this.proctoringId);
22614
22665
  this.proctoringSession.setProctoringId(this.proctoringId);
22666
+ try {
22667
+ if (options == null ? void 0 : options.useSafeBrowserAPI) {
22668
+ await this.safeBrowserBackendService.setProctoringId(this.proctoringId);
22669
+ }
22670
+ } catch (error) {
22671
+ throw SAFE_BROWSER_API_NOT_FOUND;
22672
+ }
22615
22673
  try {
22616
22674
  console.log("Starting recorders");
22617
22675
  await this.recorder.startAll();
@@ -22833,7 +22891,7 @@ Error: ` + error
22833
22891
  }
22834
22892
  }
22835
22893
  async initConfig(useGeolocation) {
22836
- var _a2;
22894
+ var _a2, _b;
22837
22895
  try {
22838
22896
  const paramsConfig = await this.backend.getParamsConfig(
22839
22897
  this.context
@@ -22865,6 +22923,9 @@ Error: ` + error
22865
22923
  onRealtimeAlertsCallback: (response) => this.onRealtimeAlertsCallback(response)
22866
22924
  });
22867
22925
  }
22926
+ if ((_b = this.sessionOptions) == null ? void 0 : _b.useSafeBrowserAPI) {
22927
+ this.safeBrowserBackendService = new SafeBrowserBackendService();
22928
+ }
22868
22929
  } catch (err) {
22869
22930
  this.proctoringId && trackers.registerError(this.proctoringId, "Erro no initConfig!");
22870
22931
  await this.cancel();
package/index.js CHANGED
@@ -26440,7 +26440,7 @@ var BaseDetection = class {
26440
26440
  this.createdVideo && this.video && document.body.removeChild(this.video);
26441
26441
  this.createdVideo = false;
26442
26442
  }
26443
- enableCam(cameraStream) {
26443
+ enableCam(cameraStream, delay = 1e4) {
26444
26444
  var _a2;
26445
26445
  if (!this.detector) {
26446
26446
  console.log("Wait! Detector not loaded yet.");
@@ -26470,7 +26470,7 @@ var BaseDetection = class {
26470
26470
  (_a2 = this.video) == null ? void 0 : _a2.addEventListener("loadeddata", () => {
26471
26471
  this.animationFrameId = setTimeout(() => {
26472
26472
  that.predictWebcam();
26473
- }, 1e4);
26473
+ }, delay);
26474
26474
  });
26475
26475
  const style = document.createElement("style");
26476
26476
  style.type = "text/css";
@@ -31198,6 +31198,7 @@ var BROWSER_NOT_SUPPORTED = "browser_not_supported";
31198
31198
  var TOKEN_MISSING = "token_missing";
31199
31199
  var CREDENTIALS_MISSING = "credentials_missing";
31200
31200
  var SPY_SCAN_API_NOT_FOUND = "spy_scan_api_not_found";
31201
+ var SAFE_BROWSER_API_NOT_FOUND = "safe_browser_api_not_found";
31201
31202
  var EXTERNAL_CAMERA_NOT_STARTED = "external_camera_not_started";
31202
31203
 
31203
31204
  // src/modules/objectDetection.ts
@@ -31634,7 +31635,7 @@ Setting: ${JSON.stringify(settings, null, 2)}`
31634
31635
  this.volumeMeter && this.volumeMeter.stop();
31635
31636
  this.intervalNoiseDetection && clearInterval(this.intervalNoiseDetection);
31636
31637
  this.recordingStop && await this.recordingStop();
31637
- this.duration = this.getDuration();
31638
+ this.duration = this.getDuration ? this.getDuration() : 0;
31638
31639
  try {
31639
31640
  if (this.animationFrameId) {
31640
31641
  cancelAnimationFrame(this.animationFrameId);
@@ -33090,7 +33091,7 @@ var _DeviceCheckerService = class _DeviceCheckerService {
33090
33091
  videoDeviceInterface(stream4) {
33091
33092
  this.DeviceCheckerUI && this.DeviceCheckerUI.videoDeviceInterfaceUI(stream4);
33092
33093
  this.isUnderResolution();
33093
- this.faceDetection.enableCam(stream4);
33094
+ this.faceDetection.enableCam(stream4, 1e3);
33094
33095
  }
33095
33096
  audioDeviceInterface(stream4) {
33096
33097
  this.volumeMeter = new VolumeMeter(this.cameraRecorder.cameraStream);
@@ -36791,6 +36792,49 @@ var Auth = class {
36791
36792
  }
36792
36793
  };
36793
36794
 
36795
+ // src/new-flow/backend/SafeBrowserBackendService.ts
36796
+ var SafeBrowserBackendService = class {
36797
+ constructor() {
36798
+ this.baseUrl = "http://localhost:7485/Station/api";
36799
+ }
36800
+ async isAlive() {
36801
+ const paramsConfig = await this.makeRequestAxios({
36802
+ path: `/health`,
36803
+ method: "GET",
36804
+ jwt: this.token
36805
+ }).catch((error) => {
36806
+ throw "N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde";
36807
+ });
36808
+ return paramsConfig.data;
36809
+ }
36810
+ async setProctoringId(proctoringId2) {
36811
+ const paramsConfig = await this.makeRequestAxios({
36812
+ path: `/update-station/` + proctoringId2,
36813
+ method: "POST",
36814
+ jwt: this.token
36815
+ }).catch((error) => {
36816
+ throw "N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde";
36817
+ });
36818
+ return paramsConfig.data;
36819
+ }
36820
+ async makeRequestAxios(data) {
36821
+ const { path, method, body, jwt } = data;
36822
+ const resp = await axios_default.request({
36823
+ url: this.baseUrl + path,
36824
+ method,
36825
+ headers: {
36826
+ Authorization: `Bearer ${jwt}`,
36827
+ "Access-Control-Allow-Origin": "*"
36828
+ },
36829
+ data: body
36830
+ });
36831
+ if (resp.status >= 400) {
36832
+ throw "N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde";
36833
+ }
36834
+ return resp;
36835
+ }
36836
+ };
36837
+
36794
36838
  // src/proctoring/ExternalCameraChecker.ts
36795
36839
  var import_signalr = __toESM(require_cjs());
36796
36840
  var import_qrcode = __toESM(require_lib());
@@ -37826,6 +37870,13 @@ var Proctoring = class {
37826
37870
  } catch (error) {
37827
37871
  throw SPY_SCAN_API_NOT_FOUND;
37828
37872
  }
37873
+ try {
37874
+ if (options == null ? void 0 : options.useSafeBrowserAPI) {
37875
+ await this.safeBrowserBackendService.isAlive();
37876
+ }
37877
+ } catch (error) {
37878
+ throw SAFE_BROWSER_API_NOT_FOUND;
37879
+ }
37829
37880
  if (this.state != "Stop" /* Stop */) {
37830
37881
  throw PROCTORING_ALREADY_STARTED;
37831
37882
  }
@@ -37861,6 +37912,13 @@ var Proctoring = class {
37861
37912
  this.allRecorders.cameraRecorder.setProctoringId(this.proctoringId);
37862
37913
  this.allRecorders.noiseRecorder.setProctoringId(this.proctoringId);
37863
37914
  this.proctoringSession.setProctoringId(this.proctoringId);
37915
+ try {
37916
+ if (options == null ? void 0 : options.useSafeBrowserAPI) {
37917
+ await this.safeBrowserBackendService.setProctoringId(this.proctoringId);
37918
+ }
37919
+ } catch (error) {
37920
+ throw SAFE_BROWSER_API_NOT_FOUND;
37921
+ }
37864
37922
  try {
37865
37923
  console.log("Starting recorders");
37866
37924
  await this.recorder.startAll();
@@ -38082,7 +38140,7 @@ Error: ` + error
38082
38140
  }
38083
38141
  }
38084
38142
  async initConfig(useGeolocation) {
38085
- var _a2;
38143
+ var _a2, _b;
38086
38144
  try {
38087
38145
  const paramsConfig = await this.backend.getParamsConfig(
38088
38146
  this.context
@@ -38114,6 +38172,9 @@ Error: ` + error
38114
38172
  onRealtimeAlertsCallback: (response) => this.onRealtimeAlertsCallback(response)
38115
38173
  });
38116
38174
  }
38175
+ if ((_b = this.sessionOptions) == null ? void 0 : _b.useSafeBrowserAPI) {
38176
+ this.safeBrowserBackendService = new SafeBrowserBackendService();
38177
+ }
38117
38178
  } catch (err) {
38118
38179
  this.proctoringId && trackers.registerError(this.proctoringId, "Erro no initConfig!");
38119
38180
  await this.cancel();
@@ -22,7 +22,7 @@ export declare class BaseDetection {
22
22
  }, paramsConfig?: IParamsConfig, classVideo?: string, classDiv?: string);
23
23
  initializeDetector(): Promise<void>;
24
24
  stopDetection(): void;
25
- enableCam(cameraStream?: MediaProvider | null | undefined): void;
25
+ enableCam(cameraStream?: MediaProvider | null | undefined, delay?: number): void;
26
26
  lastVideoTime: number;
27
27
  lastExecutionDate: number;
28
28
  predictWebcam(): Promise<void>;
@@ -0,0 +1,13 @@
1
+ export declare class SafeBrowserBackendService {
2
+ private readonly baseUrl;
3
+ token: string;
4
+ constructor();
5
+ isAlive(): Promise<boolean>;
6
+ setProctoringId(proctoringId: string): Promise<any>;
7
+ makeRequestAxios<R>(data: {
8
+ path: string;
9
+ method: "GET" | "POST" | "PUT";
10
+ body?: any;
11
+ jwt: string;
12
+ }): Promise<R>;
13
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "easyproctor",
3
- "version": "2.5.9",
3
+ "version": "2.6.0",
4
4
  "description": "Modulo web de gravação do EasyProctor",
5
5
  "main": "./index.js",
6
6
  "module": "./esm/index.js",
@@ -12,6 +12,7 @@ export interface ProctoringSessionOptions {
12
12
  useSpyScan?: boolean;
13
13
  useExternalCamera?: boolean;
14
14
  useChallenge?: boolean;
15
+ useSafeBrowserAPI?: boolean;
15
16
  screenRecorderOptions?: {
16
17
  width: number;
17
18
  height: number;
@@ -54,6 +54,7 @@ export declare class Proctoring {
54
54
  private recorder;
55
55
  private allRecorders;
56
56
  private spyCam;
57
+ private safeBrowserBackendService;
57
58
  appChecker: ExternalCameraChecker;
58
59
  private verifyFirstFaceInterval;
59
60
  private onStopSharingScreenCallback;