easyproctor 0.0.64 → 0.0.65

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,25 +49499,26 @@ 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: {
49493
- accessKeyId: "here",
49521
+ accessKeyId: config2.accessKeyId,
49494
49522
  secretAccessKey: config2.secretAccessKey
49495
49523
  }
49496
49524
  });
@@ -49506,10 +49534,16 @@ 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
+ await makeRequest({
49542
+ url: `/Proctoring/aws-to-azure`,
49543
+ method: "POST",
49544
+ jwt: proctoringToken,
49545
+ body: `${file.name}`
49546
+ });
49513
49547
  }).catch((err) => {
49514
49548
  throw err;
49515
49549
  });
@@ -49543,39 +49577,12 @@ function download(data) {
49543
49577
  onProgress && onProgress(Math.round(100));
49544
49578
  } catch (err) {
49545
49579
  message += `
49546
- \u2022 Error on machine download
49580
+ \u2022 Error on machine download -> ${data.file.name}
49547
49581
  `;
49548
49582
  throw err;
49549
49583
  }
49550
49584
  }
49551
49585
 
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
49586
  // src/modules/enumarateDevices.ts
49580
49587
  async function enumarateDevices() {
49581
49588
  const mediaDevices = await navigator.mediaDevices.enumerateDevices();
@@ -49834,6 +49841,7 @@ function useProctoring(proctoringOptions, homolConfig = false) {
49834
49841
  init(config.insights);
49835
49842
  }
49836
49843
  async function start(options = defaultProctoringOptions, videoOptions = { width: 640, height: 480 }) {
49844
+ console.log(lastClick);
49837
49845
  if (lastClick >= Date.now() - delay)
49838
49846
  throw PROCTORING_ALREADY_STARTED;
49839
49847
  lastClick = Date.now();
@@ -49880,6 +49888,7 @@ function useProctoring(proctoringOptions, homolConfig = false) {
49880
49888
  sessions: []
49881
49889
  });
49882
49890
  proctoringId = resp.id;
49891
+ console.log("proctoringId", proctoringId);
49883
49892
  trackers.registerStart(proctoringId, true, "");
49884
49893
  _addListeners();
49885
49894
  return resp;
@@ -49893,27 +49902,34 @@ function useProctoring(proctoringOptions, homolConfig = false) {
49893
49902
  const { start: start2 } = await startAudioCapture();
49894
49903
  start2();
49895
49904
  }
49896
- async function startTest(options = defaultProctoringOptions, videoOptions = { width: 640, height: 480 }) {
49905
+ async function finishAudio() {
49906
+ const { buffer, blob } = await stopRecord();
49907
+ return { buffer, blob };
49908
+ }
49909
+ async function checkDevices(options = defaultProctoringOptions, videoOptions = { width: 640, height: 480 }) {
49897
49910
  const { cameraId, microphoneId, allowOnlyFirstMonitor = true, allowMultipleMonitors = false, captureScreen = true, proctoringType } = options;
49898
49911
  checkPermissions();
49899
49912
  startAudio();
49900
49913
  const { cameraStream, _screenStream } = await _startCapture({ cameraId, microphoneId, allowOnlyFirstMonitor, captureScreen, proctoringType }, videoOptions);
49914
+ console.log("Recording...");
49915
+ return { cameraStream, _screenStream };
49901
49916
  }
49902
- async function finishAudio() {
49903
- const { buffer, blob } = await stopRecord();
49904
- return { buffer, blob };
49905
- }
49906
- async function finishTest() {
49917
+ async function closeCheckDevices() {
49918
+ console.log("Stoping record...");
49907
49919
  onStopSharingScreenCallback = void 0;
49908
49920
  if (cancelCallback) {
49909
49921
  await cancelCallback();
49910
49922
  }
49911
49923
  _removeListeners();
49912
49924
  await clearBuffers("exams");
49925
+ const cameraBlob = cameraBuffer;
49926
+ const screenBlob = screenBuffer;
49913
49927
  cameraBuffer = [];
49914
49928
  screenBuffer = [];
49915
49929
  alerts = [];
49916
49930
  cancelCallback = null;
49931
+ console.log("Finish record");
49932
+ return { cameraBlob, screenBlob };
49917
49933
  }
49918
49934
  async function pause() {
49919
49935
  const record = await getRecord("exams");
@@ -49988,6 +50004,7 @@ function useProctoring(proctoringOptions, homolConfig = false) {
49988
50004
  trackers.registerError(proctoringId, "N\xE3o foi poss\xEDvel requisitar a data do servidor!");
49989
50005
  }
49990
50006
  proctoringId = record.id;
50007
+ console.log("procotoringId resume", proctoringId);
49991
50008
  startDate = serverTime ? new Date(serverTime.toString()) : new Date();
49992
50009
  startTime = startDate.getTime();
49993
50010
  return { cameraStream, _screenStream };
@@ -50108,7 +50125,7 @@ function useProctoring(proctoringOptions, homolConfig = false) {
50108
50125
  uploadProgress[i] = progress;
50109
50126
  handleOnProgress();
50110
50127
  }
50111
- }, proctoringId, config);
50128
+ }, proctoringId, config, proctoringOptions.token);
50112
50129
  });
50113
50130
  const timeAfter = performance.now();
50114
50131
  await Promise.all(uploadPromises);
@@ -50134,7 +50151,7 @@ function useProctoring(proctoringOptions, homolConfig = false) {
50134
50151
  function onLostFocus(cb) {
50135
50152
  onLostFocusCallback = cb;
50136
50153
  }
50137
- return { start, startAudio, startTest, finish, finishAudio, finishTest, pause, resume, onFocus, onLostFocus, enumarateDevices, checkPermissions, checkIfhasMultipleMonitors, onStopSharingScreen };
50154
+ return { start, startAudio, checkDevices, finish, finishAudio, closeCheckDevices, pause, resume, onFocus, onLostFocus, enumarateDevices, checkPermissions, checkIfhasMultipleMonitors, onStopSharingScreen };
50138
50155
  }
50139
50156
  if (typeof window !== "undefined") {
50140
50157
  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,25 +74260,26 @@ 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: {
74254
- accessKeyId: "here",
74282
+ accessKeyId: config2.accessKeyId,
74255
74283
  secretAccessKey: config2.secretAccessKey
74256
74284
  }
74257
74285
  });
@@ -74267,10 +74295,16 @@ 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
+ await makeRequest({
74303
+ url: `/Proctoring/aws-to-azure`,
74304
+ method: "POST",
74305
+ jwt: proctoringToken,
74306
+ body: `${file.name}`
74307
+ });
74274
74308
  }).catch((err) => {
74275
74309
  throw err;
74276
74310
  });
@@ -74304,39 +74338,12 @@ function download(data) {
74304
74338
  onProgress && onProgress(Math.round(100));
74305
74339
  } catch (err) {
74306
74340
  message += `
74307
- \u2022 Error on machine download
74341
+ \u2022 Error on machine download -> ${data.file.name}
74308
74342
  `;
74309
74343
  throw err;
74310
74344
  }
74311
74345
  }
74312
74346
 
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
74347
  // src/modules/enumarateDevices.ts
74341
74348
  async function enumarateDevices() {
74342
74349
  const mediaDevices = await navigator.mediaDevices.enumerateDevices();
@@ -74595,6 +74602,7 @@ function useProctoring(proctoringOptions, homolConfig = false) {
74595
74602
  init(config.insights);
74596
74603
  }
74597
74604
  async function start(options = defaultProctoringOptions, videoOptions = { width: 640, height: 480 }) {
74605
+ console.log(lastClick);
74598
74606
  if (lastClick >= Date.now() - delay)
74599
74607
  throw PROCTORING_ALREADY_STARTED;
74600
74608
  lastClick = Date.now();
@@ -74641,6 +74649,7 @@ function useProctoring(proctoringOptions, homolConfig = false) {
74641
74649
  sessions: []
74642
74650
  });
74643
74651
  proctoringId = resp.id;
74652
+ console.log("proctoringId", proctoringId);
74644
74653
  trackers.registerStart(proctoringId, true, "");
74645
74654
  _addListeners();
74646
74655
  return resp;
@@ -74654,27 +74663,34 @@ function useProctoring(proctoringOptions, homolConfig = false) {
74654
74663
  const { start: start2 } = await startAudioCapture();
74655
74664
  start2();
74656
74665
  }
74657
- async function startTest(options = defaultProctoringOptions, videoOptions = { width: 640, height: 480 }) {
74666
+ async function finishAudio() {
74667
+ const { buffer, blob } = await stopRecord();
74668
+ return { buffer, blob };
74669
+ }
74670
+ async function checkDevices(options = defaultProctoringOptions, videoOptions = { width: 640, height: 480 }) {
74658
74671
  const { cameraId, microphoneId, allowOnlyFirstMonitor = true, allowMultipleMonitors = false, captureScreen = true, proctoringType } = options;
74659
74672
  checkPermissions();
74660
74673
  startAudio();
74661
74674
  const { cameraStream, _screenStream } = await _startCapture({ cameraId, microphoneId, allowOnlyFirstMonitor, captureScreen, proctoringType }, videoOptions);
74675
+ console.log("Recording...");
74676
+ return { cameraStream, _screenStream };
74662
74677
  }
74663
- async function finishAudio() {
74664
- const { buffer, blob } = await stopRecord();
74665
- return { buffer, blob };
74666
- }
74667
- async function finishTest() {
74678
+ async function closeCheckDevices() {
74679
+ console.log("Stoping record...");
74668
74680
  onStopSharingScreenCallback = void 0;
74669
74681
  if (cancelCallback) {
74670
74682
  await cancelCallback();
74671
74683
  }
74672
74684
  _removeListeners();
74673
74685
  await clearBuffers("exams");
74686
+ const cameraBlob = cameraBuffer;
74687
+ const screenBlob = screenBuffer;
74674
74688
  cameraBuffer = [];
74675
74689
  screenBuffer = [];
74676
74690
  alerts = [];
74677
74691
  cancelCallback = null;
74692
+ console.log("Finish record");
74693
+ return { cameraBlob, screenBlob };
74678
74694
  }
74679
74695
  async function pause() {
74680
74696
  const record = await getRecord("exams");
@@ -74749,6 +74765,7 @@ function useProctoring(proctoringOptions, homolConfig = false) {
74749
74765
  trackers.registerError(proctoringId, "N\xE3o foi poss\xEDvel requisitar a data do servidor!");
74750
74766
  }
74751
74767
  proctoringId = record.id;
74768
+ console.log("procotoringId resume", proctoringId);
74752
74769
  startDate = serverTime ? new Date(serverTime.toString()) : new Date();
74753
74770
  startTime = startDate.getTime();
74754
74771
  return { cameraStream, _screenStream };
@@ -74869,7 +74886,7 @@ function useProctoring(proctoringOptions, homolConfig = false) {
74869
74886
  uploadProgress[i] = progress;
74870
74887
  handleOnProgress();
74871
74888
  }
74872
- }, proctoringId, config);
74889
+ }, proctoringId, config, proctoringOptions.token);
74873
74890
  });
74874
74891
  const timeAfter = performance.now();
74875
74892
  await Promise.all(uploadPromises);
@@ -74895,7 +74912,7 @@ function useProctoring(proctoringOptions, homolConfig = false) {
74895
74912
  function onLostFocus(cb) {
74896
74913
  onLostFocusCallback = cb;
74897
74914
  }
74898
- return { start, startAudio, startTest, finish, finishAudio, finishTest, pause, resume, onFocus, onLostFocus, enumarateDevices, checkPermissions, checkIfhasMultipleMonitors, onStopSharingScreen };
74915
+ return { start, startAudio, checkDevices, finish, finishAudio, closeCheckDevices, pause, resume, onFocus, onLostFocus, enumarateDevices, checkPermissions, checkIfhasMultipleMonitors, onStopSharingScreen };
74899
74916
  }
74900
74917
  if (typeof window !== "undefined") {
74901
74918
  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.65",
4
4
  "description": "Modulo web de gravação do EasyProctor",
5
5
  "main": "./index.js",
6
6
  "module": "./esm/index.js",