easyproctor-hml 0.0.5 → 0.0.7

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 CHANGED
@@ -14570,6 +14570,7 @@ var DeviceChecker = class {
14570
14570
  constructor() {
14571
14571
  }
14572
14572
  async checkDevices(options = getDefaultProctoringOptions(), _videoOptions) {
14573
+ var _a2;
14573
14574
  console.log("deviceChecker.checkDevices", options, _videoOptions);
14574
14575
  this.videoOptions = validatePartialVideoOptions(_videoOptions);
14575
14576
  await checkPermissions();
@@ -14591,7 +14592,7 @@ var DeviceChecker = class {
14591
14592
  }
14592
14593
  return {
14593
14594
  cameraStream: this.cameraRecorder.cameraStream,
14594
- _screenStream: this.screenRecorder?.screenStream
14595
+ _screenStream: (_a2 = this.screenRecorder) == null ? void 0 : _a2.screenStream
14595
14596
  };
14596
14597
  }
14597
14598
  async closeCheckDevices() {
@@ -16384,12 +16385,22 @@ var {
16384
16385
  var axios_default2 = axios_default;
16385
16386
 
16386
16387
  // src/new-flow/backend/BackendService.ts
16388
+ var DEV_BASE_URL = "https://proctoring-api-dev.easyproctor.tech/api";
16387
16389
  var HOMOL_BASE_URL = "https://proctoring-api-hml.easyproctor.tech/api";
16388
16390
  var PROD_BASE_URL = "https://proctoring-api.easyproctor.tech/api";
16389
16391
  var BackendService = class {
16390
16392
  constructor(options) {
16391
16393
  this.options = options;
16392
- this.baseUrl = this.options.homol ? HOMOL_BASE_URL : PROD_BASE_URL;
16394
+ this.baseUrl = this.selectBaseUrl(options.type);
16395
+ }
16396
+ selectBaseUrl(type) {
16397
+ if (type === "dev") {
16398
+ return DEV_BASE_URL;
16399
+ } else if (type === "homol") {
16400
+ return HOMOL_BASE_URL;
16401
+ } else {
16402
+ return PROD_BASE_URL;
16403
+ }
16393
16404
  }
16394
16405
  async confirmStart(proctoringOptions, proctoringType) {
16395
16406
  return await this.makeRequest({
@@ -16402,7 +16413,7 @@ var BackendService = class {
16402
16413
  jwt: proctoringOptions.token
16403
16414
  });
16404
16415
  }
16405
- async getAzureKey(proctoringOptions) {
16416
+ async getInsights(proctoringOptions) {
16406
16417
  return await this.makeRequest({
16407
16418
  path: `/AzureKey`,
16408
16419
  method: "GET",
@@ -16456,15 +16467,16 @@ var BackendService = class {
16456
16467
  });
16457
16468
  }
16458
16469
  async finishAndSendUrls(proctoringOptions, proctoringSession) {
16470
+ var _a2, _b, _c;
16459
16471
  const serverHour = await this.getServerHour(proctoringOptions.token).catch(() => void 0);
16460
16472
  const serverTime = serverHour ? new Date(serverHour).toISOString() : new Date().toISOString();
16461
- const videoCameraUpload = proctoringSession.recordings.find((e) => e.origin === "Camera" /* Camera */)?.upload;
16462
- const audioCameraUpload = proctoringSession.recordings.find((e) => e.origin === "Mic" /* Mic */)?.upload;
16463
- const videoScreenUpload = proctoringSession.recordings.find((e) => e.origin === "Screen" /* Screen */)?.upload;
16473
+ const videoCameraUpload = (_a2 = proctoringSession.recordings.find((e) => e.origin === "Camera" /* Camera */)) == null ? void 0 : _a2.upload;
16474
+ const audioCameraUpload = (_b = proctoringSession.recordings.find((e) => e.origin === "Mic" /* Mic */)) == null ? void 0 : _b.upload;
16475
+ const videoScreenUpload = (_c = proctoringSession.recordings.find((e) => e.origin === "Screen" /* Screen */)) == null ? void 0 : _c.upload;
16464
16476
  const clearUrl = (url) => url ? url.substring(0, url.indexOf("?")) : void 0;
16465
- const videoCameraUrl = clearUrl(videoCameraUpload?.azureUrl);
16466
- const audioCameraUrl = clearUrl(audioCameraUpload?.azureUrl);
16467
- const videoScreenUrl = clearUrl(videoScreenUpload?.azureUrl);
16477
+ const videoCameraUrl = clearUrl(videoCameraUpload == null ? void 0 : videoCameraUpload.azureUrl);
16478
+ const audioCameraUrl = clearUrl(audioCameraUpload == null ? void 0 : audioCameraUpload.azureUrl);
16479
+ const videoScreenUrl = clearUrl(videoScreenUpload == null ? void 0 : videoScreenUpload.azureUrl);
16468
16480
  await this.makeRequest({
16469
16481
  path: `/proctoring/finish/${proctoringOptions.examId}`,
16470
16482
  method: "POST",
@@ -16657,7 +16669,7 @@ var ProctoringUploader = class {
16657
16669
  if (onProgress)
16658
16670
  onProgress(progress);
16659
16671
  }
16660
- }, token).catch(() => void 0);
16672
+ }, token);
16661
16673
  console.log("RESULTADO", result);
16662
16674
  if (result) {
16663
16675
  return result;
@@ -16692,7 +16704,8 @@ var AlertRecorder = class {
16692
16704
  });
16693
16705
  }
16694
16706
  onLostFocus() {
16695
- if (Date.now() - this.startTime?.getTime() > 1e4) {
16707
+ var _a2;
16708
+ if (Date.now() - ((_a2 = this.startTime) == null ? void 0 : _a2.getTime()) > 1e4) {
16696
16709
  this.onLostFocusCallback();
16697
16710
  this.alerts.push({
16698
16711
  begin: Date.now() - this.startTime.getTime(),
@@ -16786,7 +16799,8 @@ var IndexDbSessionRepository = class {
16786
16799
  async processRequest(request, transaction) {
16787
16800
  return new Promise((resolve, reject) => {
16788
16801
  request.onerror = (event) => {
16789
- reject(request.error?.message);
16802
+ var _a2;
16803
+ reject((_a2 = request.error) == null ? void 0 : _a2.message);
16790
16804
  };
16791
16805
  request.onsuccess = (event) => {
16792
16806
  transaction.commit();
@@ -24975,7 +24989,7 @@ var Proctoring = class {
24975
24989
  };
24976
24990
  console.log("new proctoring", context);
24977
24991
  this.backend = new BackendService({
24978
- homol: context.homol
24992
+ type: context.type
24979
24993
  });
24980
24994
  this.repository = new IndexDbSessionRepository();
24981
24995
  }
@@ -24996,6 +25010,7 @@ var Proctoring = class {
24996
25010
  this.onProgress = (percentage) => cb(percentage);
24997
25011
  }
24998
25012
  createRecorders(options = getDefaultProctoringOptions()) {
25013
+ var _a2;
24999
25014
  const cameraRecorder = new CameraRecorder({
25000
25015
  cameraId: this.sessionOptions.cameraId,
25001
25016
  microphoneId: this.sessionOptions.microphoneId
@@ -25005,7 +25020,7 @@ var Proctoring = class {
25005
25020
  });
25006
25021
  const audioRecorder = new AudioRecorder();
25007
25022
  const screenRecorder = this.sessionOptions.captureScreen ? new ScreenRecorder({
25008
- allowOnlyFirstMonitor: this.sessionOptions.allowOnlyFirstMonitor ?? true,
25023
+ allowOnlyFirstMonitor: (_a2 = this.sessionOptions.allowOnlyFirstMonitor) != null ? _a2 : true,
25009
25024
  onStopSharingScreenCallback: () => this.onStopSharingScreenCallback()
25010
25025
  }) : void 0;
25011
25026
  const alertRecorder = new AlertRecorder({
@@ -25120,7 +25135,7 @@ var Proctoring = class {
25120
25135
  }
25121
25136
  async initConfig() {
25122
25137
  try {
25123
- this.config = await this.backend.getAzureKey(this.context);
25138
+ this.config = await this.backend.getInsights(this.context);
25124
25139
  init(this.config.insights);
25125
25140
  } catch (err) {
25126
25141
  trackers.registerError(this.proctoringId, "Erro no initConfig!");
@@ -25151,6 +25166,7 @@ var Proctoring = class {
25151
25166
  width: 640,
25152
25167
  height: 480
25153
25168
  }) {
25169
+ var _a2;
25154
25170
  console.log("proctoring.resume", options, _videoOptions);
25155
25171
  if (this.state != "Paused" /* Paused */) {
25156
25172
  throw PROCTORING_ALREADY_STARTED;
@@ -25163,15 +25179,15 @@ var Proctoring = class {
25163
25179
  this.state = "Recording" /* Recording */;
25164
25180
  return {
25165
25181
  cameraStream: allRecorders.cameraRecorder.cameraStream,
25166
- _screenStream: allRecorders.screenRecorder?.screenStream
25182
+ _screenStream: (_a2 = allRecorders.screenRecorder) == null ? void 0 : _a2.screenStream
25167
25183
  };
25168
25184
  }
25169
25185
  };
25170
25186
 
25171
25187
  // src/proctoring/useProctoring.ts
25172
- function useProctoring(proctoringOptions, homolConfig = false) {
25188
+ function useProctoring(proctoringOptions, homolConfig = "prod") {
25173
25189
  const proctoring = new Proctoring({
25174
- homol: homolConfig,
25190
+ type: homolConfig,
25175
25191
  clientId: proctoringOptions.clientId,
25176
25192
  examId: proctoringOptions.examId,
25177
25193
  token: proctoringOptions.token
package/index.js CHANGED
@@ -35933,12 +35933,22 @@ var {
35933
35933
  var axios_default2 = axios_default;
35934
35934
 
35935
35935
  // src/new-flow/backend/BackendService.ts
35936
+ var DEV_BASE_URL = "https://proctoring-api-dev.easyproctor.tech/api";
35936
35937
  var HOMOL_BASE_URL = "https://proctoring-api-hml.easyproctor.tech/api";
35937
35938
  var PROD_BASE_URL = "https://proctoring-api.easyproctor.tech/api";
35938
35939
  var BackendService = class {
35939
35940
  constructor(options) {
35940
35941
  this.options = options;
35941
- this.baseUrl = this.options.homol ? HOMOL_BASE_URL : PROD_BASE_URL;
35942
+ this.baseUrl = this.selectBaseUrl(options.type);
35943
+ }
35944
+ selectBaseUrl(type) {
35945
+ if (type === "dev") {
35946
+ return DEV_BASE_URL;
35947
+ } else if (type === "homol") {
35948
+ return HOMOL_BASE_URL;
35949
+ } else {
35950
+ return PROD_BASE_URL;
35951
+ }
35942
35952
  }
35943
35953
  async confirmStart(proctoringOptions, proctoringType) {
35944
35954
  return await this.makeRequest({
@@ -35951,7 +35961,7 @@ var BackendService = class {
35951
35961
  jwt: proctoringOptions.token
35952
35962
  });
35953
35963
  }
35954
- async getAzureKey(proctoringOptions) {
35964
+ async getInsights(proctoringOptions) {
35955
35965
  return await this.makeRequest({
35956
35966
  path: `/AzureKey`,
35957
35967
  method: "GET",
@@ -36207,7 +36217,7 @@ var ProctoringUploader = class {
36207
36217
  if (onProgress)
36208
36218
  onProgress(progress);
36209
36219
  }
36210
- }, token).catch(() => void 0);
36220
+ }, token);
36211
36221
  console.log("RESULTADO", result);
36212
36222
  if (result) {
36213
36223
  return result;
@@ -36513,7 +36523,7 @@ var Proctoring = class {
36513
36523
  };
36514
36524
  console.log("new proctoring", context);
36515
36525
  this.backend = new BackendService({
36516
- homol: context.homol
36526
+ type: context.type
36517
36527
  });
36518
36528
  this.repository = new IndexDbSessionRepository();
36519
36529
  }
@@ -36659,7 +36669,7 @@ var Proctoring = class {
36659
36669
  }
36660
36670
  async initConfig() {
36661
36671
  try {
36662
- this.config = await this.backend.getAzureKey(this.context);
36672
+ this.config = await this.backend.getInsights(this.context);
36663
36673
  init(this.config.insights);
36664
36674
  } catch (err) {
36665
36675
  trackers.registerError(this.proctoringId, "Erro no initConfig!");
@@ -36709,9 +36719,9 @@ var Proctoring = class {
36709
36719
  };
36710
36720
 
36711
36721
  // src/proctoring/useProctoring.ts
36712
- function useProctoring(proctoringOptions, homolConfig = false) {
36722
+ function useProctoring(proctoringOptions, homolConfig = "prod") {
36713
36723
  const proctoring = new Proctoring({
36714
- homol: homolConfig,
36724
+ type: homolConfig,
36715
36725
  clientId: proctoringOptions.clientId,
36716
36726
  examId: proctoringOptions.examId,
36717
36727
  token: proctoringOptions.token
@@ -5,14 +5,15 @@ export declare class BackendService {
5
5
  private readonly options;
6
6
  private readonly baseUrl;
7
7
  constructor(options: {
8
- homol: boolean;
8
+ type: string;
9
9
  });
10
+ selectBaseUrl(type: string): "https://proctoring-api-dev.easyproctor.tech/api" | "https://proctoring-api-hml.easyproctor.tech/api" | "https://proctoring-api.easyproctor.tech/api";
10
11
  confirmStart(proctoringOptions: {
11
12
  examId: any;
12
13
  clientId: any;
13
14
  token: any;
14
15
  }, proctoringType: string): Promise<StartProctoringResponse>;
15
- getAzureKey(proctoringOptions: {
16
+ getInsights(proctoringOptions: {
16
17
  examId: any;
17
18
  clientId: any;
18
19
  token: any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "easyproctor-hml",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "description": "Modulo web de gravação do EasyProctor",
5
5
  "main": "./index.js",
6
6
  "module": "./esm/index.js",
@@ -2,7 +2,7 @@ import StartProctoringResponse from "../dtos/StartProctoringResponse";
2
2
  import { ProctoringSessionOptions } from "./options/ProctoringOptions";
3
3
  import { ProctoringVideoOptions } from "./options/ProctoringVideoOptions";
4
4
  export interface ProctoringContext {
5
- homol: boolean;
5
+ type: string;
6
6
  examId: string;
7
7
  clientId: string;
8
8
  token: string;
@@ -4,7 +4,7 @@ export declare function useProctoring(proctoringOptions: {
4
4
  examId: string;
5
5
  clientId: string;
6
6
  token: string;
7
- }, homolConfig?: boolean): {
7
+ }, homolConfig?: string): {
8
8
  start: (options?: import("./options/ProctoringOptions").ProctoringSessionOptions, _videoOptions?: Partial<import("./options/ProctoringVideoOptions").ProctoringVideoOptions>) => Promise<import("../dtos/StartProctoringResponse").default>;
9
9
  finish: (options?: import("./proctoring").ProctoringFinisherOptions) => Promise<void>;
10
10
  onFocus: (cb: () => void) => void;