easyproctor 0.0.20 → 0.0.23

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
@@ -87,6 +87,12 @@ var account = "iarisprod";
87
87
  var containerName = "iaris";
88
88
  var sas = "?sv=2020-08-04&ss=bfqt&srt=sco&sp=rwdlacupitfx&se=2025-12-28T06:34:02Z&st=2021-12-27T22:34:02Z&spr=https&sig=1rsgx389pHZCnJYd44peuWSfeCUdN8bQ9EfcLoMOdDc%3D";
89
89
  var blobServiceClient = new BlobServiceClient(`https://${account}.blob.core.windows.net${sas}`);
90
+ async function setConfiguration(_account, _cointainerName, _sas) {
91
+ account = _account;
92
+ containerName = _cointainerName;
93
+ sas = _sas;
94
+ blobServiceClient = new BlobServiceClient(`https://${account}.blob.core.windows.net${sas}`);
95
+ }
90
96
  async function upload(data) {
91
97
  const { file, onProgress } = data;
92
98
  const containerClient = blobServiceClient.getContainerClient(containerName);
@@ -101,6 +107,9 @@ var upload_default = upload;
101
107
 
102
108
  // src/modules/http.ts
103
109
  var baseUrl = "https://iaris.easyproctor.tech/api";
110
+ async function setBaseUrl(_baseUrl) {
111
+ baseUrl = _baseUrl;
112
+ }
104
113
  async function makeRequest(data) {
105
114
  const { url, method, body, jwt } = data;
106
115
  const resp = await fetch(baseUrl + url, {
@@ -218,11 +227,16 @@ async function clearBuffers(table) {
218
227
  var defaultProctoringOptions = {
219
228
  cameraId: void 0,
220
229
  microphoneId: void 0,
221
- allowMulipleMonitors: false,
230
+ allowMultipleMonitors: false,
222
231
  allowOnlyFirstMonitor: true
223
232
  };
224
233
  var azureBlobUrl = "https://iarisprod.blob.core.windows.net/iaris";
225
- function useProctoring(proctoringOptions) {
234
+ function useProctoring(proctoringOptions, proctoringConfig) {
235
+ if (proctoringConfig != void 0) {
236
+ setConfiguration(proctoringConfig.account, proctoringConfig.containerName, proctoringConfig.sas);
237
+ azureBlobUrl = proctoringConfig.azureBlobUrl;
238
+ setBaseUrl(proctoringConfig.baseUrl);
239
+ }
226
240
  ["examId", "clientId", "token"].forEach((el) => {
227
241
  const key = el;
228
242
  if (!proctoringOptions[key]) {
@@ -326,8 +340,8 @@ function useProctoring(proctoringOptions) {
326
340
  return { cameraFile, screenFile };
327
341
  };
328
342
  async function start(options = defaultProctoringOptions) {
329
- const { cameraId, microphoneId, allowOnlyFirstMonitor = true, allowMulipleMonitors = false } = options;
330
- if (!allowMulipleMonitors) {
343
+ const { cameraId, microphoneId, allowOnlyFirstMonitor = true, allowMultipleMonitors = false } = options;
344
+ if (!allowMultipleMonitors) {
331
345
  const hasMultipleMonitors = await checkIfhasMultipleMonitors();
332
346
  if (hasMultipleMonitors) {
333
347
  throw MULTIPLE_MONITORS_DETECTED;
@@ -378,8 +392,8 @@ function useProctoring(proctoringOptions) {
378
392
  }
379
393
  async function resume(options = defaultProctoringOptions) {
380
394
  _clear();
381
- const { cameraId, microphoneId, allowOnlyFirstMonitor = true, allowMulipleMonitors = false } = options;
382
- if (!allowMulipleMonitors) {
395
+ const { cameraId, microphoneId, allowOnlyFirstMonitor = true, allowMultipleMonitors = false } = options;
396
+ if (!allowMultipleMonitors) {
383
397
  const hasMultipleMonitors = await checkIfhasMultipleMonitors();
384
398
  if (hasMultipleMonitors) {
385
399
  throw MULTIPLE_MONITORS_DETECTED;
@@ -406,9 +420,9 @@ function useProctoring(proctoringOptions) {
406
420
  onStopSharingScreenCallback = void 0;
407
421
  if (cancelCallback) {
408
422
  await cancelCallback();
409
- const { cameraFile, screenFile } = _generateFiles(record.cameraBuffers.length);
410
- record.cameraBuffers.push(cameraFile);
411
- record.screenBuffers.push(screenFile);
423
+ const { cameraFile: cameraFile2, screenFile: screenFile2 } = _generateFiles(record.cameraBuffers.length);
424
+ record.cameraBuffers.push(cameraFile2);
425
+ record.screenBuffers.push(screenFile2);
412
426
  }
413
427
  if (record.cameraBuffers.length == 0 || record.screenBuffers.length == 0) {
414
428
  throw NO_VIDEOS_RECORDED;
@@ -420,7 +434,14 @@ function useProctoring(proctoringOptions) {
420
434
  onProgress && onProgress(uploadProgress.reduce((acc, el) => acc += el, 0) / totalFiles);
421
435
  };
422
436
  const allFiles = [...record.cameraBuffers, ...record.screenBuffers];
423
- const uploadPromises = allFiles.map((c, i) => {
437
+ const finalCameraBuffer = cameraBuffer;
438
+ const finalScreenBuffer = screenBuffer;
439
+ const cameraFileName = `EP_${proctoringId}_camera_0.webm`;
440
+ const screenFIleName = `EP_${proctoringId}_screen_0.webm`;
441
+ const cameraFile = new File(finalCameraBuffer, cameraFileName, { type: "video/webm" });
442
+ const screenFile = new File(finalScreenBuffer, screenFIleName, { type: "video/webm" });
443
+ const old_files = [cameraFile, screenFile];
444
+ const uploadPromises = old_files.map((c, i) => {
424
445
  return upload_default({
425
446
  file: c,
426
447
  onProgress: (progress) => {
@@ -441,12 +462,12 @@ function useProctoring(proctoringOptions) {
441
462
  }
442
463
  });
443
464
  await makeRequest({
444
- url: `/proctoring/finish/${record.id}`,
465
+ url: `/proctoring/finish/${proctoringOptions.examId}`,
445
466
  method: "POST",
446
467
  body: {
447
468
  endDate: time,
448
- videoCameraUrl: `${azureBlobUrl}/${proctoringId}/cameraFiles`,
449
- videoScreenUrl: `${azureBlobUrl}/${proctoringId}/screenFiles`
469
+ videoCameraUrl: `${azureBlobUrl}/${cameraFileName}`,
470
+ videoScreenUrl: `${azureBlobUrl}/${screenFIleName}`
450
471
  },
451
472
  jwt: proctoringOptions.token
452
473
  });
package/index.d.ts CHANGED
@@ -4,14 +4,21 @@ import StartProctoringResponse from "./dtos/StartProctoringResponse";
4
4
  interface ProctoringOptions {
5
5
  cameraId?: string;
6
6
  microphoneId?: string;
7
- allowMulipleMonitors?: boolean;
7
+ allowMultipleMonitors?: boolean;
8
8
  allowOnlyFirstMonitor?: boolean;
9
9
  }
10
+ interface ProctoringConfig {
11
+ azureBlobUrl: string;
12
+ baseUrl: string;
13
+ account: string;
14
+ containerName: string;
15
+ sas: string;
16
+ }
10
17
  export declare function useProctoring(proctoringOptions: {
11
18
  examId: string;
12
19
  clientId: string;
13
20
  token: string;
14
- }): {
21
+ }, proctoringConfig?: ProctoringConfig): {
15
22
  start: (options?: ProctoringOptions) => Promise<StartProctoringResponse>;
16
23
  finish: (options?: {
17
24
  onProgress?: ((percentage: number) => void) | undefined;
package/index.js CHANGED
@@ -116,6 +116,12 @@ var account = "iarisprod";
116
116
  var containerName = "iaris";
117
117
  var sas = "?sv=2020-08-04&ss=bfqt&srt=sco&sp=rwdlacupitfx&se=2025-12-28T06:34:02Z&st=2021-12-27T22:34:02Z&spr=https&sig=1rsgx389pHZCnJYd44peuWSfeCUdN8bQ9EfcLoMOdDc%3D";
118
118
  var blobServiceClient = new import_storage_blob.BlobServiceClient(`https://${account}.blob.core.windows.net${sas}`);
119
+ async function setConfiguration(_account, _cointainerName, _sas) {
120
+ account = _account;
121
+ containerName = _cointainerName;
122
+ sas = _sas;
123
+ blobServiceClient = new import_storage_blob.BlobServiceClient(`https://${account}.blob.core.windows.net${sas}`);
124
+ }
119
125
  async function upload(data) {
120
126
  const { file, onProgress } = data;
121
127
  const containerClient = blobServiceClient.getContainerClient(containerName);
@@ -130,6 +136,9 @@ var upload_default = upload;
130
136
 
131
137
  // src/modules/http.ts
132
138
  var baseUrl = "https://iaris.easyproctor.tech/api";
139
+ async function setBaseUrl(_baseUrl) {
140
+ baseUrl = _baseUrl;
141
+ }
133
142
  async function makeRequest(data) {
134
143
  const { url, method, body, jwt } = data;
135
144
  const resp = await fetch(baseUrl + url, {
@@ -247,11 +256,16 @@ async function clearBuffers(table) {
247
256
  var defaultProctoringOptions = {
248
257
  cameraId: void 0,
249
258
  microphoneId: void 0,
250
- allowMulipleMonitors: false,
259
+ allowMultipleMonitors: false,
251
260
  allowOnlyFirstMonitor: true
252
261
  };
253
262
  var azureBlobUrl = "https://iarisprod.blob.core.windows.net/iaris";
254
- function useProctoring(proctoringOptions) {
263
+ function useProctoring(proctoringOptions, proctoringConfig) {
264
+ if (proctoringConfig != void 0) {
265
+ setConfiguration(proctoringConfig.account, proctoringConfig.containerName, proctoringConfig.sas);
266
+ azureBlobUrl = proctoringConfig.azureBlobUrl;
267
+ setBaseUrl(proctoringConfig.baseUrl);
268
+ }
255
269
  ["examId", "clientId", "token"].forEach((el) => {
256
270
  const key = el;
257
271
  if (!proctoringOptions[key]) {
@@ -355,8 +369,8 @@ function useProctoring(proctoringOptions) {
355
369
  return { cameraFile, screenFile };
356
370
  };
357
371
  async function start(options = defaultProctoringOptions) {
358
- const { cameraId, microphoneId, allowOnlyFirstMonitor = true, allowMulipleMonitors = false } = options;
359
- if (!allowMulipleMonitors) {
372
+ const { cameraId, microphoneId, allowOnlyFirstMonitor = true, allowMultipleMonitors = false } = options;
373
+ if (!allowMultipleMonitors) {
360
374
  const hasMultipleMonitors = await checkIfhasMultipleMonitors();
361
375
  if (hasMultipleMonitors) {
362
376
  throw MULTIPLE_MONITORS_DETECTED;
@@ -407,8 +421,8 @@ function useProctoring(proctoringOptions) {
407
421
  }
408
422
  async function resume(options = defaultProctoringOptions) {
409
423
  _clear();
410
- const { cameraId, microphoneId, allowOnlyFirstMonitor = true, allowMulipleMonitors = false } = options;
411
- if (!allowMulipleMonitors) {
424
+ const { cameraId, microphoneId, allowOnlyFirstMonitor = true, allowMultipleMonitors = false } = options;
425
+ if (!allowMultipleMonitors) {
412
426
  const hasMultipleMonitors = await checkIfhasMultipleMonitors();
413
427
  if (hasMultipleMonitors) {
414
428
  throw MULTIPLE_MONITORS_DETECTED;
@@ -435,9 +449,9 @@ function useProctoring(proctoringOptions) {
435
449
  onStopSharingScreenCallback = void 0;
436
450
  if (cancelCallback) {
437
451
  await cancelCallback();
438
- const { cameraFile, screenFile } = _generateFiles(record.cameraBuffers.length);
439
- record.cameraBuffers.push(cameraFile);
440
- record.screenBuffers.push(screenFile);
452
+ const { cameraFile: cameraFile2, screenFile: screenFile2 } = _generateFiles(record.cameraBuffers.length);
453
+ record.cameraBuffers.push(cameraFile2);
454
+ record.screenBuffers.push(screenFile2);
441
455
  }
442
456
  if (record.cameraBuffers.length == 0 || record.screenBuffers.length == 0) {
443
457
  throw NO_VIDEOS_RECORDED;
@@ -449,7 +463,14 @@ function useProctoring(proctoringOptions) {
449
463
  onProgress && onProgress(uploadProgress.reduce((acc, el) => acc += el, 0) / totalFiles);
450
464
  };
451
465
  const allFiles = [...record.cameraBuffers, ...record.screenBuffers];
452
- const uploadPromises = allFiles.map((c, i) => {
466
+ const finalCameraBuffer = cameraBuffer;
467
+ const finalScreenBuffer = screenBuffer;
468
+ const cameraFileName = `EP_${proctoringId}_camera_0.webm`;
469
+ const screenFIleName = `EP_${proctoringId}_screen_0.webm`;
470
+ const cameraFile = new File(finalCameraBuffer, cameraFileName, { type: "video/webm" });
471
+ const screenFile = new File(finalScreenBuffer, screenFIleName, { type: "video/webm" });
472
+ const old_files = [cameraFile, screenFile];
473
+ const uploadPromises = old_files.map((c, i) => {
453
474
  return upload_default({
454
475
  file: c,
455
476
  onProgress: (progress) => {
@@ -470,12 +491,12 @@ function useProctoring(proctoringOptions) {
470
491
  }
471
492
  });
472
493
  await makeRequest({
473
- url: `/proctoring/finish/${record.id}`,
494
+ url: `/proctoring/finish/${proctoringOptions.examId}`,
474
495
  method: "POST",
475
496
  body: {
476
497
  endDate: time,
477
- videoCameraUrl: `${azureBlobUrl}/${proctoringId}/cameraFiles`,
478
- videoScreenUrl: `${azureBlobUrl}/${proctoringId}/screenFiles`
498
+ videoCameraUrl: `${azureBlobUrl}/${cameraFileName}`,
499
+ videoScreenUrl: `${azureBlobUrl}/${screenFIleName}`
479
500
  },
480
501
  jwt: proctoringOptions.token
481
502
  });
package/modules/http.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export declare function setBaseUrl(_baseUrl: string): Promise<void>;
1
2
  export default function makeRequest<R>(data: {
2
3
  url: string;
3
4
  method: "GET" | "POST";
@@ -2,5 +2,6 @@ declare type UploadData = {
2
2
  file: File;
3
3
  onProgress?: (progress: number) => void;
4
4
  };
5
+ export declare function setConfiguration(_account: string, _cointainerName: string, _sas: string): Promise<void>;
5
6
  declare function upload(data: UploadData): Promise<void>;
6
7
  export default upload;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "easyproctor",
3
- "version": "0.0.20",
3
+ "version": "0.0.23",
4
4
  "description": "Modulo web de gravação do EasyProctor",
5
5
  "main": "./index.js",
6
6
  "module": "./esm/index.js",