easyproctor 0.0.64 → 0.0.66

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
@@ -42181,6 +42181,33 @@ var trackers = {
42181
42181
  registerUploadVideo: (proctoringId, success, description, uploadTime) => registerCustomEvent(eventNames.UPLOAD_VIDEO, { proctoringId, success, description, uploadTime })
42182
42182
  };
42183
42183
 
42184
+ // src/modules/http.ts
42185
+ var baseUrl = "https://proctoring-api.easyproctor.tech/api";
42186
+ async function setBaseUrl(homol) {
42187
+ console.log("homol -> ", homol);
42188
+ if (homol)
42189
+ baseUrl = "https://proctoring-api-hml.easyproctor.tech/api";
42190
+ }
42191
+ async function makeRequest(data) {
42192
+ const { url, method, body, jwt } = data;
42193
+ const resp = await fetch(baseUrl + url, {
42194
+ method,
42195
+ body: body != null ? JSON.stringify(body) : void 0,
42196
+ headers: {
42197
+ Authorization: `Bearer ${jwt}`,
42198
+ "Content-Type": "application/json",
42199
+ "Access-Control-Allow-Origin": "*"
42200
+ }
42201
+ });
42202
+ if (resp.status >= 400) {
42203
+ throw "N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde";
42204
+ }
42205
+ const content = resp.headers.get("content-type");
42206
+ const isJson = content ? content.includes("application/json") : false;
42207
+ const responseData = isJson ? await resp.json() : null;
42208
+ return responseData;
42209
+ }
42210
+
42184
42211
  // node_modules/@aws-sdk/client-s3/node_modules/tslib/modules/index.js
42185
42212
  var import_tslib = __toESM(require_tslib(), 1);
42186
42213
  var {
@@ -49436,7 +49463,7 @@ async function setConfiguration(_account, _cointainerName, _sas) {
49436
49463
  function sendError(proctoringId) {
49437
49464
  trackers.registerError(proctoringId, message);
49438
49465
  }
49439
- async function upload(data, proctoringId, config2) {
49466
+ async function upload(data, proctoringId, config2, proctoringToken) {
49440
49467
  try {
49441
49468
  const { file, onProgress } = data;
49442
49469
  message += `Upload: ${file.type}
@@ -49472,21 +49499,22 @@ async function upload(data, proctoringId, config2) {
49472
49499
  });
49473
49500
  message += "Blob: Step 5\n";
49474
49501
  } catch (err) {
49475
- await uploadBackup(data, config2).catch(async () => {
49502
+ await uploadBackup(data, config2, proctoringToken).catch(async () => {
49476
49503
  sendError(proctoringId);
49477
49504
  throw err;
49478
49505
  });
49479
49506
  }
49480
49507
  }
49481
- async function uploadBackup(data, config2) {
49508
+ async function uploadBackup(data, config2, proctoringToken) {
49482
49509
  try {
49483
- console.log("DENTRO DO CATCH");
49484
49510
  const { file, onProgress } = data;
49485
49511
  const uploadParams = {
49486
49512
  Bucket: "iarisprod",
49487
49513
  Key: file.name,
49488
49514
  Body: file
49489
49515
  };
49516
+ console.log("file");
49517
+ console.log(file);
49490
49518
  const s3Client = new S3Client({
49491
49519
  region: "us-east-1",
49492
49520
  credentials: {
@@ -49506,10 +49534,18 @@ async function uploadBackup(data, config2) {
49506
49534
  }
49507
49535
  }
49508
49536
  }, 3e3);
49509
- const data2 = await s3Client.send(new PutObjectCommand(uploadParams)).then(() => {
49537
+ const data2 = await s3Client.send(new PutObjectCommand(uploadParams)).then(async () => {
49510
49538
  loadingBoolean = false;
49511
49539
  clearInterval(loadingInterval);
49512
49540
  onProgress && onProgress(Math.round(100));
49541
+ makeRequest({
49542
+ url: `/Proctoring/aws-to-azure`,
49543
+ method: "POST",
49544
+ jwt: proctoringToken,
49545
+ body: {
49546
+ "objectName": `${file.name}`
49547
+ }
49548
+ });
49513
49549
  }).catch((err) => {
49514
49550
  throw err;
49515
49551
  });
@@ -49543,39 +49579,12 @@ function download(data) {
49543
49579
  onProgress && onProgress(Math.round(100));
49544
49580
  } catch (err) {
49545
49581
  message += `
49546
- \u2022 Error on machine download
49582
+ \u2022 Error on machine download -> ${data.file.name}
49547
49583
  `;
49548
49584
  throw err;
49549
49585
  }
49550
49586
  }
49551
49587
 
49552
- // src/modules/http.ts
49553
- var baseUrl = "https://proctoring-api.easyproctor.tech/api";
49554
- async function setBaseUrl(homol) {
49555
- console.log("homol -> ", homol);
49556
- if (homol)
49557
- baseUrl = "https://proctoring-api-hml.easyproctor.tech/api";
49558
- }
49559
- async function makeRequest(data) {
49560
- const { url, method, body, jwt } = data;
49561
- const resp = await fetch(baseUrl + url, {
49562
- method,
49563
- body: body != null ? JSON.stringify(body) : void 0,
49564
- headers: {
49565
- Authorization: `Bearer ${jwt}`,
49566
- "Content-Type": "application/json",
49567
- "Access-Control-Allow-Origin": "*"
49568
- }
49569
- });
49570
- if (resp.status >= 400) {
49571
- throw "N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde";
49572
- }
49573
- const content = resp.headers.get("content-type");
49574
- const isJson = content ? content.includes("application/json") : false;
49575
- const responseData = isJson ? await resp.json() : null;
49576
- return responseData;
49577
- }
49578
-
49579
49588
  // src/modules/enumarateDevices.ts
49580
49589
  async function enumarateDevices() {
49581
49590
  const mediaDevices = await navigator.mediaDevices.enumerateDevices();
@@ -49834,6 +49843,7 @@ function useProctoring(proctoringOptions, homolConfig = false) {
49834
49843
  init(config.insights);
49835
49844
  }
49836
49845
  async function start(options = defaultProctoringOptions, videoOptions = { width: 640, height: 480 }) {
49846
+ console.log(lastClick);
49837
49847
  if (lastClick >= Date.now() - delay)
49838
49848
  throw PROCTORING_ALREADY_STARTED;
49839
49849
  lastClick = Date.now();
@@ -49880,6 +49890,7 @@ function useProctoring(proctoringOptions, homolConfig = false) {
49880
49890
  sessions: []
49881
49891
  });
49882
49892
  proctoringId = resp.id;
49893
+ console.log("proctoringId", proctoringId);
49883
49894
  trackers.registerStart(proctoringId, true, "");
49884
49895
  _addListeners();
49885
49896
  return resp;
@@ -49893,27 +49904,34 @@ function useProctoring(proctoringOptions, homolConfig = false) {
49893
49904
  const { start: start2 } = await startAudioCapture();
49894
49905
  start2();
49895
49906
  }
49896
- async function startTest(options = defaultProctoringOptions, videoOptions = { width: 640, height: 480 }) {
49907
+ async function finishAudio() {
49908
+ const { buffer, blob } = await stopRecord();
49909
+ return { buffer, blob };
49910
+ }
49911
+ async function checkDevices(options = defaultProctoringOptions, videoOptions = { width: 640, height: 480 }) {
49897
49912
  const { cameraId, microphoneId, allowOnlyFirstMonitor = true, allowMultipleMonitors = false, captureScreen = true, proctoringType } = options;
49898
49913
  checkPermissions();
49899
49914
  startAudio();
49900
49915
  const { cameraStream, _screenStream } = await _startCapture({ cameraId, microphoneId, allowOnlyFirstMonitor, captureScreen, proctoringType }, videoOptions);
49916
+ console.log("Recording...");
49917
+ return { cameraStream, _screenStream };
49901
49918
  }
49902
- async function finishAudio() {
49903
- const { buffer, blob } = await stopRecord();
49904
- return { buffer, blob };
49905
- }
49906
- async function finishTest() {
49919
+ async function closeCheckDevices() {
49920
+ console.log("Stoping record...");
49907
49921
  onStopSharingScreenCallback = void 0;
49908
49922
  if (cancelCallback) {
49909
49923
  await cancelCallback();
49910
49924
  }
49911
49925
  _removeListeners();
49912
49926
  await clearBuffers("exams");
49927
+ const cameraBlob = cameraBuffer;
49928
+ const screenBlob = screenBuffer;
49913
49929
  cameraBuffer = [];
49914
49930
  screenBuffer = [];
49915
49931
  alerts = [];
49916
49932
  cancelCallback = null;
49933
+ console.log("Finish record");
49934
+ return { cameraBlob, screenBlob };
49917
49935
  }
49918
49936
  async function pause() {
49919
49937
  const record = await getRecord("exams");
@@ -49988,6 +50006,7 @@ function useProctoring(proctoringOptions, homolConfig = false) {
49988
50006
  trackers.registerError(proctoringId, "N\xE3o foi poss\xEDvel requisitar a data do servidor!");
49989
50007
  }
49990
50008
  proctoringId = record.id;
50009
+ console.log("procotoringId resume", proctoringId);
49991
50010
  startDate = serverTime ? new Date(serverTime.toString()) : new Date();
49992
50011
  startTime = startDate.getTime();
49993
50012
  return { cameraStream, _screenStream };
@@ -50108,7 +50127,7 @@ function useProctoring(proctoringOptions, homolConfig = false) {
50108
50127
  uploadProgress[i] = progress;
50109
50128
  handleOnProgress();
50110
50129
  }
50111
- }, proctoringId, config);
50130
+ }, proctoringId, config, proctoringOptions.token);
50112
50131
  });
50113
50132
  const timeAfter = performance.now();
50114
50133
  await Promise.all(uploadPromises);
@@ -50134,7 +50153,7 @@ function useProctoring(proctoringOptions, homolConfig = false) {
50134
50153
  function onLostFocus(cb) {
50135
50154
  onLostFocusCallback = cb;
50136
50155
  }
50137
- return { start, startAudio, startTest, finish, finishAudio, finishTest, pause, resume, onFocus, onLostFocus, enumarateDevices, checkPermissions, checkIfhasMultipleMonitors, onStopSharingScreen };
50156
+ return { start, startAudio, checkDevices, finish, finishAudio, closeCheckDevices, pause, resume, onFocus, onLostFocus, enumarateDevices, checkPermissions, checkIfhasMultipleMonitors, onStopSharingScreen };
50138
50157
  }
50139
50158
  if (typeof window !== "undefined") {
50140
50159
  window.useProctoring = useProctoring;
package/index.d.ts CHANGED
@@ -20,10 +20,13 @@ export declare function useProctoring(proctoringOptions: {
20
20
  height?: number;
21
21
  }) => Promise<StartProctoringResponse>;
22
22
  startAudio: () => Promise<void>;
23
- startTest: (options?: ProctoringOptions, videoOptions?: {
23
+ checkDevices: (options?: ProctoringOptions, videoOptions?: {
24
24
  width?: number;
25
25
  height?: number;
26
- }) => Promise<void>;
26
+ }) => Promise<{
27
+ cameraStream: MediaStream;
28
+ _screenStream: MediaStream | undefined;
29
+ }>;
27
30
  finish: (options?: {
28
31
  onProgress?: ((percentage: number) => void) | undefined;
29
32
  }) => Promise<void>;
@@ -31,7 +34,10 @@ export declare function useProctoring(proctoringOptions: {
31
34
  buffer: any;
32
35
  blob: any;
33
36
  }>;
34
- finishTest: () => Promise<void>;
37
+ closeCheckDevices: () => Promise<{
38
+ cameraBlob: Blob[];
39
+ screenBlob: Blob[];
40
+ }>;
35
41
  pause: () => Promise<void>;
36
42
  resume: (options: ProctoringOptions | undefined, examId: string, videoOptions?: {
37
43
  width?: number;
package/index.js CHANGED
@@ -74178,6 +74178,33 @@ var trackers = {
74178
74178
  registerUploadVideo: (proctoringId, success, description, uploadTime) => registerCustomEvent(eventNames.UPLOAD_VIDEO, { proctoringId, success, description, uploadTime })
74179
74179
  };
74180
74180
 
74181
+ // src/modules/http.ts
74182
+ var baseUrl = "https://proctoring-api.easyproctor.tech/api";
74183
+ async function setBaseUrl(homol) {
74184
+ console.log("homol -> ", homol);
74185
+ if (homol)
74186
+ baseUrl = "https://proctoring-api-hml.easyproctor.tech/api";
74187
+ }
74188
+ async function makeRequest(data) {
74189
+ const { url, method, body, jwt } = data;
74190
+ const resp = await fetch(baseUrl + url, {
74191
+ method,
74192
+ body: body != null ? JSON.stringify(body) : void 0,
74193
+ headers: {
74194
+ Authorization: `Bearer ${jwt}`,
74195
+ "Content-Type": "application/json",
74196
+ "Access-Control-Allow-Origin": "*"
74197
+ }
74198
+ });
74199
+ if (resp.status >= 400) {
74200
+ throw "N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde";
74201
+ }
74202
+ const content = resp.headers.get("content-type");
74203
+ const isJson = content ? content.includes("application/json") : false;
74204
+ const responseData = isJson ? await resp.json() : null;
74205
+ return responseData;
74206
+ }
74207
+
74181
74208
  // src/modules/upload.ts
74182
74209
  var import_client_s3 = __toESM(require_dist_cjs61());
74183
74210
  var import_client_s32 = __toESM(require_dist_cjs61());
@@ -74197,7 +74224,7 @@ async function setConfiguration(_account, _cointainerName, _sas) {
74197
74224
  function sendError(proctoringId) {
74198
74225
  trackers.registerError(proctoringId, message);
74199
74226
  }
74200
- async function upload(data, proctoringId, config2) {
74227
+ async function upload(data, proctoringId, config2, proctoringToken) {
74201
74228
  try {
74202
74229
  const { file, onProgress } = data;
74203
74230
  message += `Upload: ${file.type}
@@ -74233,21 +74260,22 @@ async function upload(data, proctoringId, config2) {
74233
74260
  });
74234
74261
  message += "Blob: Step 5\n";
74235
74262
  } catch (err) {
74236
- await uploadBackup(data, config2).catch(async () => {
74263
+ await uploadBackup(data, config2, proctoringToken).catch(async () => {
74237
74264
  sendError(proctoringId);
74238
74265
  throw err;
74239
74266
  });
74240
74267
  }
74241
74268
  }
74242
- async function uploadBackup(data, config2) {
74269
+ async function uploadBackup(data, config2, proctoringToken) {
74243
74270
  try {
74244
- console.log("DENTRO DO CATCH");
74245
74271
  const { file, onProgress } = data;
74246
74272
  const uploadParams = {
74247
74273
  Bucket: "iarisprod",
74248
74274
  Key: file.name,
74249
74275
  Body: file
74250
74276
  };
74277
+ console.log("file");
74278
+ console.log(file);
74251
74279
  const s3Client = new import_client_s32.S3Client({
74252
74280
  region: "us-east-1",
74253
74281
  credentials: {
@@ -74267,10 +74295,18 @@ async function uploadBackup(data, config2) {
74267
74295
  }
74268
74296
  }
74269
74297
  }, 3e3);
74270
- const data2 = await s3Client.send(new import_client_s3.PutObjectCommand(uploadParams)).then(() => {
74298
+ const data2 = await s3Client.send(new import_client_s3.PutObjectCommand(uploadParams)).then(async () => {
74271
74299
  loadingBoolean = false;
74272
74300
  clearInterval(loadingInterval);
74273
74301
  onProgress && onProgress(Math.round(100));
74302
+ makeRequest({
74303
+ url: `/Proctoring/aws-to-azure`,
74304
+ method: "POST",
74305
+ jwt: proctoringToken,
74306
+ body: {
74307
+ "objectName": `${file.name}`
74308
+ }
74309
+ });
74274
74310
  }).catch((err) => {
74275
74311
  throw err;
74276
74312
  });
@@ -74304,39 +74340,12 @@ function download(data) {
74304
74340
  onProgress && onProgress(Math.round(100));
74305
74341
  } catch (err) {
74306
74342
  message += `
74307
- \u2022 Error on machine download
74343
+ \u2022 Error on machine download -> ${data.file.name}
74308
74344
  `;
74309
74345
  throw err;
74310
74346
  }
74311
74347
  }
74312
74348
 
74313
- // src/modules/http.ts
74314
- var baseUrl = "https://proctoring-api.easyproctor.tech/api";
74315
- async function setBaseUrl(homol) {
74316
- console.log("homol -> ", homol);
74317
- if (homol)
74318
- baseUrl = "https://proctoring-api-hml.easyproctor.tech/api";
74319
- }
74320
- async function makeRequest(data) {
74321
- const { url, method, body, jwt } = data;
74322
- const resp = await fetch(baseUrl + url, {
74323
- method,
74324
- body: body != null ? JSON.stringify(body) : void 0,
74325
- headers: {
74326
- Authorization: `Bearer ${jwt}`,
74327
- "Content-Type": "application/json",
74328
- "Access-Control-Allow-Origin": "*"
74329
- }
74330
- });
74331
- if (resp.status >= 400) {
74332
- throw "N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde";
74333
- }
74334
- const content = resp.headers.get("content-type");
74335
- const isJson = content ? content.includes("application/json") : false;
74336
- const responseData = isJson ? await resp.json() : null;
74337
- return responseData;
74338
- }
74339
-
74340
74349
  // src/modules/enumarateDevices.ts
74341
74350
  async function enumarateDevices() {
74342
74351
  const mediaDevices = await navigator.mediaDevices.enumerateDevices();
@@ -74595,6 +74604,7 @@ function useProctoring(proctoringOptions, homolConfig = false) {
74595
74604
  init(config.insights);
74596
74605
  }
74597
74606
  async function start(options = defaultProctoringOptions, videoOptions = { width: 640, height: 480 }) {
74607
+ console.log(lastClick);
74598
74608
  if (lastClick >= Date.now() - delay)
74599
74609
  throw PROCTORING_ALREADY_STARTED;
74600
74610
  lastClick = Date.now();
@@ -74641,6 +74651,7 @@ function useProctoring(proctoringOptions, homolConfig = false) {
74641
74651
  sessions: []
74642
74652
  });
74643
74653
  proctoringId = resp.id;
74654
+ console.log("proctoringId", proctoringId);
74644
74655
  trackers.registerStart(proctoringId, true, "");
74645
74656
  _addListeners();
74646
74657
  return resp;
@@ -74654,27 +74665,34 @@ function useProctoring(proctoringOptions, homolConfig = false) {
74654
74665
  const { start: start2 } = await startAudioCapture();
74655
74666
  start2();
74656
74667
  }
74657
- async function startTest(options = defaultProctoringOptions, videoOptions = { width: 640, height: 480 }) {
74668
+ async function finishAudio() {
74669
+ const { buffer, blob } = await stopRecord();
74670
+ return { buffer, blob };
74671
+ }
74672
+ async function checkDevices(options = defaultProctoringOptions, videoOptions = { width: 640, height: 480 }) {
74658
74673
  const { cameraId, microphoneId, allowOnlyFirstMonitor = true, allowMultipleMonitors = false, captureScreen = true, proctoringType } = options;
74659
74674
  checkPermissions();
74660
74675
  startAudio();
74661
74676
  const { cameraStream, _screenStream } = await _startCapture({ cameraId, microphoneId, allowOnlyFirstMonitor, captureScreen, proctoringType }, videoOptions);
74677
+ console.log("Recording...");
74678
+ return { cameraStream, _screenStream };
74662
74679
  }
74663
- async function finishAudio() {
74664
- const { buffer, blob } = await stopRecord();
74665
- return { buffer, blob };
74666
- }
74667
- async function finishTest() {
74680
+ async function closeCheckDevices() {
74681
+ console.log("Stoping record...");
74668
74682
  onStopSharingScreenCallback = void 0;
74669
74683
  if (cancelCallback) {
74670
74684
  await cancelCallback();
74671
74685
  }
74672
74686
  _removeListeners();
74673
74687
  await clearBuffers("exams");
74688
+ const cameraBlob = cameraBuffer;
74689
+ const screenBlob = screenBuffer;
74674
74690
  cameraBuffer = [];
74675
74691
  screenBuffer = [];
74676
74692
  alerts = [];
74677
74693
  cancelCallback = null;
74694
+ console.log("Finish record");
74695
+ return { cameraBlob, screenBlob };
74678
74696
  }
74679
74697
  async function pause() {
74680
74698
  const record = await getRecord("exams");
@@ -74749,6 +74767,7 @@ function useProctoring(proctoringOptions, homolConfig = false) {
74749
74767
  trackers.registerError(proctoringId, "N\xE3o foi poss\xEDvel requisitar a data do servidor!");
74750
74768
  }
74751
74769
  proctoringId = record.id;
74770
+ console.log("procotoringId resume", proctoringId);
74752
74771
  startDate = serverTime ? new Date(serverTime.toString()) : new Date();
74753
74772
  startTime = startDate.getTime();
74754
74773
  return { cameraStream, _screenStream };
@@ -74869,7 +74888,7 @@ function useProctoring(proctoringOptions, homolConfig = false) {
74869
74888
  uploadProgress[i] = progress;
74870
74889
  handleOnProgress();
74871
74890
  }
74872
- }, proctoringId, config);
74891
+ }, proctoringId, config, proctoringOptions.token);
74873
74892
  });
74874
74893
  const timeAfter = performance.now();
74875
74894
  await Promise.all(uploadPromises);
@@ -74895,7 +74914,7 @@ function useProctoring(proctoringOptions, homolConfig = false) {
74895
74914
  function onLostFocus(cb) {
74896
74915
  onLostFocusCallback = cb;
74897
74916
  }
74898
- return { start, startAudio, startTest, finish, finishAudio, finishTest, pause, resume, onFocus, onLostFocus, enumarateDevices, checkPermissions, checkIfhasMultipleMonitors, onStopSharingScreen };
74917
+ return { start, startAudio, checkDevices, finish, finishAudio, closeCheckDevices, pause, resume, onFocus, onLostFocus, enumarateDevices, checkPermissions, checkIfhasMultipleMonitors, onStopSharingScreen };
74899
74918
  }
74900
74919
  if (typeof window !== "undefined") {
74901
74920
  window.useProctoring = useProctoring;
@@ -4,5 +4,5 @@ declare type UploadData = {
4
4
  onProgress?: (progress: number) => void;
5
5
  };
6
6
  export declare function setConfiguration(_account: string, _cointainerName: string, _sas: string): Promise<void>;
7
- export default function upload(data: UploadData, proctoringId: string, config: ProctoringConfig): Promise<void>;
7
+ export default function upload(data: UploadData, proctoringId: string, config: ProctoringConfig, proctoringToken: string): Promise<void>;
8
8
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "easyproctor",
3
- "version": "0.0.64",
3
+ "version": "0.0.66",
4
4
  "description": "Modulo web de gravação do EasyProctor",
5
5
  "main": "./index.js",
6
6
  "module": "./esm/index.js",