easyproctor 0.0.29 → 0.0.32

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
@@ -70,8 +70,15 @@ async function startScreenCapture(buffer, options) {
70
70
  const screenStream = await navigator.mediaDevices.getDisplayMedia(displayMediaStreamConstraints);
71
71
  const tracks = screenStream.getVideoTracks();
72
72
  tracks[0].onended = onStopSharingScreenCallback;
73
+ const isFirefox = navigator.userAgent.indexOf("Firefox") > -1;
74
+ if (isFirefox) {
75
+ const hasMultipleMonitors = !tracks.find((el) => el.label == "Primary Monitor");
76
+ if (hasMultipleMonitors) {
77
+ throw MULTIPLE_MONITORS_DETECTED;
78
+ }
79
+ }
73
80
  const sharedFirstScreen = tracks.find((el) => {
74
- return ["screen:0:0", "Primary Monitor", ""].includes(el.label);
81
+ return ["screen:0:0", "Primary Monitor"].includes(el.label);
75
82
  }) != null;
76
83
  if (!sharedFirstScreen && allowOnlyFirstMonitor) {
77
84
  tracks.forEach((el) => {
@@ -6273,17 +6280,17 @@ var Sender = function(_super) {
6273
6280
  arrForEach(objKeys(_headers), function(headerName) {
6274
6281
  requestHeaders.append(headerName, _headers[headerName]);
6275
6282
  });
6276
- var init = (_a2 = {
6283
+ var init2 = (_a2 = {
6277
6284
  method: "POST",
6278
6285
  headers: requestHeaders,
6279
6286
  body: plainTextBatch
6280
6287
  }, _a2[DisabledPropertyName] = true, _a2);
6281
6288
  if (!isAsync) {
6282
- init.keepalive = true;
6289
+ init2.keepalive = true;
6283
6290
  ignoreResponse = true;
6284
6291
  _syncFetchPayload += batchLength;
6285
6292
  }
6286
- var request = new Request(endPointUrl, init);
6293
+ var request = new Request(endPointUrl, init2);
6287
6294
  try {
6288
6295
  request[DisabledPropertyName] = true;
6289
6296
  } catch (e) {
@@ -7395,37 +7402,37 @@ var AjaxMonitor = function(_super) {
7395
7402
  _self.trackDependencyData = function(dependency, properties) {
7396
7403
  _self[strTrackDependencyDataInternal](dependency, properties);
7397
7404
  };
7398
- _self.includeCorrelationHeaders = function(ajaxData, input, init, xhr) {
7405
+ _self.includeCorrelationHeaders = function(ajaxData, input, init2, xhr) {
7399
7406
  var currentWindowHost = _self["_currentWindowHost"] || _currentWindowHost;
7400
7407
  if (input) {
7401
7408
  if (CorrelationIdHelper.canIncludeCorrelationHeader(_config, ajaxData.getAbsoluteUrl(), currentWindowHost)) {
7402
- if (!init) {
7403
- init = {};
7409
+ if (!init2) {
7410
+ init2 = {};
7404
7411
  }
7405
- init.headers = new Headers(init.headers || (input instanceof Request ? input.headers || {} : {}));
7412
+ init2.headers = new Headers(init2.headers || (input instanceof Request ? input.headers || {} : {}));
7406
7413
  if (_isUsingAIHeaders) {
7407
7414
  var id = "|" + ajaxData.traceID + "." + ajaxData.spanID;
7408
- init.headers.set(RequestHeaders.requestIdHeader, id);
7415
+ init2.headers.set(RequestHeaders.requestIdHeader, id);
7409
7416
  if (_enableRequestHeaderTracking) {
7410
7417
  ajaxData.requestHeaders[RequestHeaders.requestIdHeader] = id;
7411
7418
  }
7412
7419
  }
7413
7420
  var appId = _config.appId || _context && _context.appId();
7414
7421
  if (appId) {
7415
- init.headers.set(RequestHeaders.requestContextHeader, RequestHeaders.requestContextAppIdFormat + appId);
7422
+ init2.headers.set(RequestHeaders.requestContextHeader, RequestHeaders.requestContextAppIdFormat + appId);
7416
7423
  if (_enableRequestHeaderTracking) {
7417
7424
  ajaxData.requestHeaders[RequestHeaders.requestContextHeader] = RequestHeaders.requestContextAppIdFormat + appId;
7418
7425
  }
7419
7426
  }
7420
7427
  if (_isUsingW3CHeaders) {
7421
7428
  var traceparent = new Traceparent(ajaxData.traceID, ajaxData.spanID);
7422
- init.headers.set(RequestHeaders.traceParentHeader, traceparent.toString());
7429
+ init2.headers.set(RequestHeaders.traceParentHeader, traceparent.toString());
7423
7430
  if (_enableRequestHeaderTracking) {
7424
7431
  ajaxData.requestHeaders[RequestHeaders.traceParentHeader] = traceparent.toString();
7425
7432
  }
7426
7433
  }
7427
7434
  }
7428
- return init;
7435
+ return init2;
7429
7436
  } else if (xhr) {
7430
7437
  if (CorrelationIdHelper.canIncludeCorrelationHeader(_config, ajaxData.getAbsoluteUrl(), currentWindowHost)) {
7431
7438
  if (_isUsingAIHeaders) {
@@ -7490,13 +7497,13 @@ var AjaxMonitor = function(_super) {
7490
7497
  var isPolyfill = fetch2.polyfill;
7491
7498
  if (_config.disableFetchTracking === false) {
7492
7499
  _hooks.push(InstrumentFunc(global2, strFetch, {
7493
- req: function(callDetails, input, init) {
7500
+ req: function(callDetails, input, init2) {
7494
7501
  var fetchData;
7495
- if (_fetchInitialized && !_isDisabledRequest(null, input, init) && !(isPolyfill && _xhrInitialized)) {
7502
+ if (_fetchInitialized && !_isDisabledRequest(null, input, init2) && !(isPolyfill && _xhrInitialized)) {
7496
7503
  var ctx = callDetails.ctx();
7497
- fetchData = _createFetchRecord(input, init);
7498
- var newInit = _self.includeCorrelationHeaders(fetchData, input, init);
7499
- if (newInit !== init) {
7504
+ fetchData = _createFetchRecord(input, init2);
7505
+ var newInit = _self.includeCorrelationHeaders(fetchData, input, init2);
7506
+ if (newInit !== init2) {
7500
7507
  callDetails.set(1, newInit);
7501
7508
  }
7502
7509
  ctx.data = fetchData;
@@ -7535,8 +7542,8 @@ var AjaxMonitor = function(_super) {
7535
7542
  _fetchInitialized = true;
7536
7543
  } else if (isPolyfill) {
7537
7544
  _hooks.push(InstrumentFunc(global2, strFetch, {
7538
- req: function(callDetails, input, init) {
7539
- _isDisabledRequest(null, input, init);
7545
+ req: function(callDetails, input, init2) {
7546
+ _isDisabledRequest(null, input, init2);
7540
7547
  }
7541
7548
  }));
7542
7549
  }
@@ -7600,7 +7607,7 @@ var AjaxMonitor = function(_super) {
7600
7607
  _xhrInitialized = true;
7601
7608
  }
7602
7609
  }
7603
- function _isDisabledRequest(xhr, request, init) {
7610
+ function _isDisabledRequest(xhr, request, init2) {
7604
7611
  var isDisabled = false;
7605
7612
  var theUrl = ((!isString(request) ? (request || {}).url || "" : request) || "").toLowerCase();
7606
7613
  arrForEach(_excludeRequestFromAutoTrackingPatterns, function(regex) {
@@ -7626,7 +7633,7 @@ var AjaxMonitor = function(_super) {
7626
7633
  if (!isNullOrUndefined(xhr)) {
7627
7634
  isDisabled = xhr[DisabledPropertyName] === true || theUrl[DisabledPropertyName] === true;
7628
7635
  } else if (!isNullOrUndefined(request)) {
7629
- isDisabled = (typeof request === "object" ? request[DisabledPropertyName] === true : false) || (init ? init[DisabledPropertyName] === true : false);
7636
+ isDisabled = (typeof request === "object" ? request[DisabledPropertyName] === true : false) || (init2 ? init2[DisabledPropertyName] === true : false);
7630
7637
  }
7631
7638
  if (!isDisabled && theUrl && isInternalApplicationInsightsEndpoint(theUrl)) {
7632
7639
  isDisabled = true;
@@ -7834,7 +7841,7 @@ var AjaxMonitor = function(_super) {
7834
7841
  }
7835
7842
  })();
7836
7843
  }
7837
- function _createFetchRecord(input, init) {
7844
+ function _createFetchRecord(input, init2) {
7838
7845
  var traceID = _context && _context.telemetryTrace && _context.telemetryTrace.traceID || generateW3CId();
7839
7846
  var spanID = generateW3CId().substr(0, 16);
7840
7847
  var ajaxData = new ajaxRecord(traceID, spanID, _self[strDiagLog]());
@@ -7846,15 +7853,15 @@ var AjaxMonitor = function(_super) {
7846
7853
  ajaxData.requestUrl = input;
7847
7854
  }
7848
7855
  var method = "GET";
7849
- if (init && init.method) {
7850
- method = init.method;
7856
+ if (init2 && init2.method) {
7857
+ method = init2.method;
7851
7858
  } else if (input && input instanceof Request) {
7852
7859
  method = input.method;
7853
7860
  }
7854
7861
  ajaxData.method = method;
7855
7862
  var requestHeaders = {};
7856
7863
  if (_enableRequestHeaderTracking) {
7857
- var headers = new Headers((init ? init.headers : 0) || (input instanceof Request ? input.headers || {} : {}));
7864
+ var headers = new Headers((init2 ? init2.headers : 0) || (input instanceof Request ? input.headers || {} : {}));
7858
7865
  headers.forEach(function(value, key) {
7859
7866
  if (_canIncludeHeaders(key)) {
7860
7867
  requestHeaders[key] = value;
@@ -8258,6 +8265,14 @@ var insights = new Initialization({
8258
8265
  instrumentationKey: "323792c9-1202-431d-85c4-36385daf9f20"
8259
8266
  }
8260
8267
  });
8268
+ var init = (key) => {
8269
+ console.log(key);
8270
+ insights = new Initialization({
8271
+ config: {
8272
+ instrumentationKey: key
8273
+ }
8274
+ });
8275
+ };
8261
8276
  var eventNames = {
8262
8277
  START: "start",
8263
8278
  FINISH: "finish",
@@ -8283,7 +8298,9 @@ var defaultProctoringOptions = {
8283
8298
  microphoneId: void 0,
8284
8299
  allowMultipleMonitors: false,
8285
8300
  allowOnlyFirstMonitor: true,
8286
- captureScreen: true
8301
+ captureScreen: true,
8302
+ proctoringType: "IMAGE",
8303
+ insights: "323792c9-1202-431d-85c4-36385daf9f20"
8287
8304
  };
8288
8305
  var azureBlobUrl = "";
8289
8306
  var _captureScreen = true;
@@ -8371,12 +8388,14 @@ function useProctoring(proctoringOptions, proctoringConfig) {
8371
8388
  }
8372
8389
  }
8373
8390
  const _onLostFocus = () => {
8374
- onLostFocusCallback && onLostFocusCallback();
8375
- alerts.push({
8376
- begin: Date.now() - startTime,
8377
- alert: 25,
8378
- end: 0
8379
- });
8391
+ if (Date.now() - startTime > 1e4) {
8392
+ onLostFocusCallback && onLostFocusCallback();
8393
+ alerts.push({
8394
+ begin: Date.now() - startTime,
8395
+ alert: 25,
8396
+ end: 0
8397
+ });
8398
+ }
8380
8399
  };
8381
8400
  const _onReturnFocus = () => {
8382
8401
  const lastAlert = alerts[alerts.length - 1];
@@ -8409,11 +8428,12 @@ function useProctoring(proctoringOptions, proctoringConfig) {
8409
8428
  return { cameraFile, screenFile };
8410
8429
  };
8411
8430
  async function start(options = defaultProctoringOptions) {
8412
- const { cameraId, microphoneId, allowOnlyFirstMonitor = true, allowMultipleMonitors = false, captureScreen = true } = options;
8431
+ const { cameraId, microphoneId, allowOnlyFirstMonitor = true, allowMultipleMonitors = false, captureScreen = true, proctoringType } = options;
8413
8432
  if (proctoringConfig != void 0) {
8414
8433
  setConfiguration(proctoringConfig.account, proctoringConfig.containerName, proctoringConfig.sas);
8415
8434
  azureBlobUrl = proctoringConfig.azureBlobUrl;
8416
8435
  setBaseUrl(proctoringConfig.baseUrl);
8436
+ init(proctoringConfig.insights);
8417
8437
  } else {
8418
8438
  const config = await makeRequest({
8419
8439
  url: `/AzureKey`,
@@ -8423,6 +8443,7 @@ function useProctoring(proctoringOptions, proctoringConfig) {
8423
8443
  setConfiguration(config.account, config.containerName, config.sas);
8424
8444
  azureBlobUrl = config.azureBlobUrl;
8425
8445
  setBaseUrl(config.baseUrl);
8446
+ init(config.insights);
8426
8447
  }
8427
8448
  if (!allowMultipleMonitors) {
8428
8449
  const hasMultipleMonitors = await checkIfhasMultipleMonitors();
@@ -8435,13 +8456,13 @@ function useProctoring(proctoringOptions, proctoringConfig) {
8435
8456
  throw PROCTORING_ALREADY_STARTED;
8436
8457
  }
8437
8458
  try {
8438
- const { cameraStream, _screenStream } = await _startCapture({ cameraId, microphoneId, allowOnlyFirstMonitor, captureScreen });
8459
+ const { cameraStream, _screenStream } = await _startCapture({ cameraId, microphoneId, allowOnlyFirstMonitor, captureScreen, proctoringType });
8439
8460
  startTime = Date.now();
8440
8461
  startDate = new Date();
8441
8462
  const resp = await makeRequest({
8442
8463
  url: `/proctoring/start/${proctoringOptions.examId}`,
8443
8464
  method: "POST",
8444
- body: { clientId: proctoringOptions.clientId },
8465
+ body: { clientId: proctoringOptions.clientId, proctoringType },
8445
8466
  jwt: proctoringOptions.token
8446
8467
  });
8447
8468
  resp.cameraStream = cameraStream;
@@ -8481,7 +8502,7 @@ function useProctoring(proctoringOptions, proctoringConfig) {
8481
8502
  }
8482
8503
  async function resume(options = defaultProctoringOptions) {
8483
8504
  _clear();
8484
- const { cameraId, microphoneId, allowOnlyFirstMonitor = true, allowMultipleMonitors = false, captureScreen = true } = options;
8505
+ const { cameraId, microphoneId, allowOnlyFirstMonitor = true, allowMultipleMonitors = false, captureScreen = true, proctoringType } = options;
8485
8506
  if (!allowMultipleMonitors) {
8486
8507
  const hasMultipleMonitors = await checkIfhasMultipleMonitors();
8487
8508
  if (hasMultipleMonitors) {
@@ -8495,7 +8516,7 @@ function useProctoring(proctoringOptions, proctoringConfig) {
8495
8516
  if (!record) {
8496
8517
  throw PROCTORING_NOT_STARTED;
8497
8518
  }
8498
- const { cameraStream, _screenStream } = await _startCapture({ cameraId, microphoneId, allowOnlyFirstMonitor, captureScreen });
8519
+ const { cameraStream, _screenStream } = await _startCapture({ cameraId, microphoneId, allowOnlyFirstMonitor, captureScreen, proctoringType });
8499
8520
  proctoringId = record.id;
8500
8521
  startTime = Date.now();
8501
8522
  startDate = new Date();
package/index.d.ts CHANGED
@@ -7,6 +7,8 @@ interface ProctoringOptions {
7
7
  allowMultipleMonitors?: boolean;
8
8
  allowOnlyFirstMonitor?: boolean;
9
9
  captureScreen?: boolean;
10
+ proctoringType: "VIDEO" | "IMAGE";
11
+ insights: string;
10
12
  }
11
13
  interface ProctoringConfig {
12
14
  azureBlobUrl: string;
@@ -14,6 +16,7 @@ interface ProctoringConfig {
14
16
  account: string;
15
17
  containerName: string;
16
18
  sas: string;
19
+ insights: string;
17
20
  }
18
21
  export declare function useProctoring(proctoringOptions: {
19
22
  examId: string;
package/index.js CHANGED
@@ -6137,17 +6137,17 @@ var require_applicationinsights_web = __commonJS({
6137
6137
  arrForEach(objKeys(_headers), function(headerName) {
6138
6138
  requestHeaders.append(headerName, _headers[headerName]);
6139
6139
  });
6140
- var init = (_a2 = {
6140
+ var init2 = (_a2 = {
6141
6141
  method: "POST",
6142
6142
  headers: requestHeaders,
6143
6143
  body: plainTextBatch
6144
6144
  }, _a2[DisabledPropertyName] = true, _a2);
6145
6145
  if (!isAsync) {
6146
- init.keepalive = true;
6146
+ init2.keepalive = true;
6147
6147
  ignoreResponse = true;
6148
6148
  _syncFetchPayload += batchLength;
6149
6149
  }
6150
- var request = new Request(endPointUrl, init);
6150
+ var request = new Request(endPointUrl, init2);
6151
6151
  try {
6152
6152
  request[DisabledPropertyName] = true;
6153
6153
  } catch (e) {
@@ -7236,37 +7236,37 @@ var require_applicationinsights_web = __commonJS({
7236
7236
  _self.trackDependencyData = function(dependency, properties) {
7237
7237
  _self[strTrackDependencyDataInternal](dependency, properties);
7238
7238
  };
7239
- _self.includeCorrelationHeaders = function(ajaxData, input, init, xhr) {
7239
+ _self.includeCorrelationHeaders = function(ajaxData, input, init2, xhr) {
7240
7240
  var currentWindowHost = _self["_currentWindowHost"] || _currentWindowHost;
7241
7241
  if (input) {
7242
7242
  if (CorrelationIdHelper.canIncludeCorrelationHeader(_config, ajaxData.getAbsoluteUrl(), currentWindowHost)) {
7243
- if (!init) {
7244
- init = {};
7243
+ if (!init2) {
7244
+ init2 = {};
7245
7245
  }
7246
- init.headers = new Headers(init.headers || (input instanceof Request ? input.headers || {} : {}));
7246
+ init2.headers = new Headers(init2.headers || (input instanceof Request ? input.headers || {} : {}));
7247
7247
  if (_isUsingAIHeaders) {
7248
7248
  var id = "|" + ajaxData.traceID + "." + ajaxData.spanID;
7249
- init.headers.set(RequestHeaders.requestIdHeader, id);
7249
+ init2.headers.set(RequestHeaders.requestIdHeader, id);
7250
7250
  if (_enableRequestHeaderTracking) {
7251
7251
  ajaxData.requestHeaders[RequestHeaders.requestIdHeader] = id;
7252
7252
  }
7253
7253
  }
7254
7254
  var appId = _config.appId || _context && _context.appId();
7255
7255
  if (appId) {
7256
- init.headers.set(RequestHeaders.requestContextHeader, RequestHeaders.requestContextAppIdFormat + appId);
7256
+ init2.headers.set(RequestHeaders.requestContextHeader, RequestHeaders.requestContextAppIdFormat + appId);
7257
7257
  if (_enableRequestHeaderTracking) {
7258
7258
  ajaxData.requestHeaders[RequestHeaders.requestContextHeader] = RequestHeaders.requestContextAppIdFormat + appId;
7259
7259
  }
7260
7260
  }
7261
7261
  if (_isUsingW3CHeaders) {
7262
7262
  var traceparent = new Traceparent(ajaxData.traceID, ajaxData.spanID);
7263
- init.headers.set(RequestHeaders.traceParentHeader, traceparent.toString());
7263
+ init2.headers.set(RequestHeaders.traceParentHeader, traceparent.toString());
7264
7264
  if (_enableRequestHeaderTracking) {
7265
7265
  ajaxData.requestHeaders[RequestHeaders.traceParentHeader] = traceparent.toString();
7266
7266
  }
7267
7267
  }
7268
7268
  }
7269
- return init;
7269
+ return init2;
7270
7270
  } else if (xhr) {
7271
7271
  if (CorrelationIdHelper.canIncludeCorrelationHeader(_config, ajaxData.getAbsoluteUrl(), currentWindowHost)) {
7272
7272
  if (_isUsingAIHeaders) {
@@ -7331,13 +7331,13 @@ var require_applicationinsights_web = __commonJS({
7331
7331
  var isPolyfill = fetch2.polyfill;
7332
7332
  if (_config.disableFetchTracking === false) {
7333
7333
  _hooks.push(InstrumentFunc(global2, strFetch, {
7334
- req: function(callDetails, input, init) {
7334
+ req: function(callDetails, input, init2) {
7335
7335
  var fetchData;
7336
- if (_fetchInitialized && !_isDisabledRequest(null, input, init) && !(isPolyfill && _xhrInitialized)) {
7336
+ if (_fetchInitialized && !_isDisabledRequest(null, input, init2) && !(isPolyfill && _xhrInitialized)) {
7337
7337
  var ctx = callDetails.ctx();
7338
- fetchData = _createFetchRecord(input, init);
7339
- var newInit = _self.includeCorrelationHeaders(fetchData, input, init);
7340
- if (newInit !== init) {
7338
+ fetchData = _createFetchRecord(input, init2);
7339
+ var newInit = _self.includeCorrelationHeaders(fetchData, input, init2);
7340
+ if (newInit !== init2) {
7341
7341
  callDetails.set(1, newInit);
7342
7342
  }
7343
7343
  ctx.data = fetchData;
@@ -7376,8 +7376,8 @@ var require_applicationinsights_web = __commonJS({
7376
7376
  _fetchInitialized = true;
7377
7377
  } else if (isPolyfill) {
7378
7378
  _hooks.push(InstrumentFunc(global2, strFetch, {
7379
- req: function(callDetails, input, init) {
7380
- _isDisabledRequest(null, input, init);
7379
+ req: function(callDetails, input, init2) {
7380
+ _isDisabledRequest(null, input, init2);
7381
7381
  }
7382
7382
  }));
7383
7383
  }
@@ -7441,7 +7441,7 @@ var require_applicationinsights_web = __commonJS({
7441
7441
  _xhrInitialized = true;
7442
7442
  }
7443
7443
  }
7444
- function _isDisabledRequest(xhr, request, init) {
7444
+ function _isDisabledRequest(xhr, request, init2) {
7445
7445
  var isDisabled = false;
7446
7446
  var theUrl = ((!isString(request) ? (request || {}).url || "" : request) || "").toLowerCase();
7447
7447
  arrForEach(_excludeRequestFromAutoTrackingPatterns, function(regex) {
@@ -7467,7 +7467,7 @@ var require_applicationinsights_web = __commonJS({
7467
7467
  if (!isNullOrUndefined(xhr)) {
7468
7468
  isDisabled = xhr[DisabledPropertyName] === true || theUrl[DisabledPropertyName] === true;
7469
7469
  } else if (!isNullOrUndefined(request)) {
7470
- isDisabled = (typeof request === "object" ? request[DisabledPropertyName] === true : false) || (init ? init[DisabledPropertyName] === true : false);
7470
+ isDisabled = (typeof request === "object" ? request[DisabledPropertyName] === true : false) || (init2 ? init2[DisabledPropertyName] === true : false);
7471
7471
  }
7472
7472
  if (!isDisabled && theUrl && isInternalApplicationInsightsEndpoint(theUrl)) {
7473
7473
  isDisabled = true;
@@ -7675,7 +7675,7 @@ var require_applicationinsights_web = __commonJS({
7675
7675
  }
7676
7676
  })();
7677
7677
  }
7678
- function _createFetchRecord(input, init) {
7678
+ function _createFetchRecord(input, init2) {
7679
7679
  var traceID = _context && _context.telemetryTrace && _context.telemetryTrace.traceID || generateW3CId();
7680
7680
  var spanID = generateW3CId().substr(0, 16);
7681
7681
  var ajaxData = new ajaxRecord(traceID, spanID, _self[strDiagLog]());
@@ -7687,15 +7687,15 @@ var require_applicationinsights_web = __commonJS({
7687
7687
  ajaxData.requestUrl = input;
7688
7688
  }
7689
7689
  var method = "GET";
7690
- if (init && init.method) {
7691
- method = init.method;
7690
+ if (init2 && init2.method) {
7691
+ method = init2.method;
7692
7692
  } else if (input && input instanceof Request) {
7693
7693
  method = input.method;
7694
7694
  }
7695
7695
  ajaxData.method = method;
7696
7696
  var requestHeaders = {};
7697
7697
  if (_enableRequestHeaderTracking) {
7698
- var headers = new Headers((init ? init.headers : 0) || (input instanceof Request ? input.headers || {} : {}));
7698
+ var headers = new Headers((init2 ? init2.headers : 0) || (input instanceof Request ? input.headers || {} : {}));
7699
7699
  headers.forEach(function(value, key) {
7700
7700
  if (_canIncludeHeaders(key)) {
7701
7701
  requestHeaders[key] = value;
@@ -8433,8 +8433,15 @@ async function startScreenCapture(buffer, options) {
8433
8433
  const screenStream = await navigator.mediaDevices.getDisplayMedia(displayMediaStreamConstraints);
8434
8434
  const tracks = screenStream.getVideoTracks();
8435
8435
  tracks[0].onended = onStopSharingScreenCallback;
8436
+ const isFirefox = navigator.userAgent.indexOf("Firefox") > -1;
8437
+ if (isFirefox) {
8438
+ const hasMultipleMonitors = !tracks.find((el) => el.label == "Primary Monitor");
8439
+ if (hasMultipleMonitors) {
8440
+ throw MULTIPLE_MONITORS_DETECTED;
8441
+ }
8442
+ }
8436
8443
  const sharedFirstScreen = tracks.find((el) => {
8437
- return ["screen:0:0", "Primary Monitor", ""].includes(el.label);
8444
+ return ["screen:0:0", "Primary Monitor"].includes(el.label);
8438
8445
  }) != null;
8439
8446
  if (!sharedFirstScreen && allowOnlyFirstMonitor) {
8440
8447
  tracks.forEach((el) => {
@@ -8598,6 +8605,14 @@ var insights = new import_applicationinsights_web.ApplicationInsights({
8598
8605
  instrumentationKey: "323792c9-1202-431d-85c4-36385daf9f20"
8599
8606
  }
8600
8607
  });
8608
+ var init = (key) => {
8609
+ console.log(key);
8610
+ insights = new import_applicationinsights_web.ApplicationInsights({
8611
+ config: {
8612
+ instrumentationKey: key
8613
+ }
8614
+ });
8615
+ };
8601
8616
  var eventNames = {
8602
8617
  START: "start",
8603
8618
  FINISH: "finish",
@@ -8623,7 +8638,9 @@ var defaultProctoringOptions = {
8623
8638
  microphoneId: void 0,
8624
8639
  allowMultipleMonitors: false,
8625
8640
  allowOnlyFirstMonitor: true,
8626
- captureScreen: true
8641
+ captureScreen: true,
8642
+ proctoringType: "IMAGE",
8643
+ insights: "323792c9-1202-431d-85c4-36385daf9f20"
8627
8644
  };
8628
8645
  var azureBlobUrl = "";
8629
8646
  var _captureScreen = true;
@@ -8711,12 +8728,14 @@ function useProctoring(proctoringOptions, proctoringConfig) {
8711
8728
  }
8712
8729
  }
8713
8730
  const _onLostFocus = () => {
8714
- onLostFocusCallback && onLostFocusCallback();
8715
- alerts.push({
8716
- begin: Date.now() - startTime,
8717
- alert: 25,
8718
- end: 0
8719
- });
8731
+ if (Date.now() - startTime > 1e4) {
8732
+ onLostFocusCallback && onLostFocusCallback();
8733
+ alerts.push({
8734
+ begin: Date.now() - startTime,
8735
+ alert: 25,
8736
+ end: 0
8737
+ });
8738
+ }
8720
8739
  };
8721
8740
  const _onReturnFocus = () => {
8722
8741
  const lastAlert = alerts[alerts.length - 1];
@@ -8749,11 +8768,12 @@ function useProctoring(proctoringOptions, proctoringConfig) {
8749
8768
  return { cameraFile, screenFile };
8750
8769
  };
8751
8770
  async function start(options = defaultProctoringOptions) {
8752
- const { cameraId, microphoneId, allowOnlyFirstMonitor = true, allowMultipleMonitors = false, captureScreen = true } = options;
8771
+ const { cameraId, microphoneId, allowOnlyFirstMonitor = true, allowMultipleMonitors = false, captureScreen = true, proctoringType } = options;
8753
8772
  if (proctoringConfig != void 0) {
8754
8773
  setConfiguration(proctoringConfig.account, proctoringConfig.containerName, proctoringConfig.sas);
8755
8774
  azureBlobUrl = proctoringConfig.azureBlobUrl;
8756
8775
  setBaseUrl(proctoringConfig.baseUrl);
8776
+ init(proctoringConfig.insights);
8757
8777
  } else {
8758
8778
  const config = await makeRequest({
8759
8779
  url: `/AzureKey`,
@@ -8763,6 +8783,7 @@ function useProctoring(proctoringOptions, proctoringConfig) {
8763
8783
  setConfiguration(config.account, config.containerName, config.sas);
8764
8784
  azureBlobUrl = config.azureBlobUrl;
8765
8785
  setBaseUrl(config.baseUrl);
8786
+ init(config.insights);
8766
8787
  }
8767
8788
  if (!allowMultipleMonitors) {
8768
8789
  const hasMultipleMonitors = await checkIfhasMultipleMonitors();
@@ -8775,13 +8796,13 @@ function useProctoring(proctoringOptions, proctoringConfig) {
8775
8796
  throw PROCTORING_ALREADY_STARTED;
8776
8797
  }
8777
8798
  try {
8778
- const { cameraStream, _screenStream } = await _startCapture({ cameraId, microphoneId, allowOnlyFirstMonitor, captureScreen });
8799
+ const { cameraStream, _screenStream } = await _startCapture({ cameraId, microphoneId, allowOnlyFirstMonitor, captureScreen, proctoringType });
8779
8800
  startTime = Date.now();
8780
8801
  startDate = new Date();
8781
8802
  const resp = await makeRequest({
8782
8803
  url: `/proctoring/start/${proctoringOptions.examId}`,
8783
8804
  method: "POST",
8784
- body: { clientId: proctoringOptions.clientId },
8805
+ body: { clientId: proctoringOptions.clientId, proctoringType },
8785
8806
  jwt: proctoringOptions.token
8786
8807
  });
8787
8808
  resp.cameraStream = cameraStream;
@@ -8821,7 +8842,7 @@ function useProctoring(proctoringOptions, proctoringConfig) {
8821
8842
  }
8822
8843
  async function resume(options = defaultProctoringOptions) {
8823
8844
  _clear();
8824
- const { cameraId, microphoneId, allowOnlyFirstMonitor = true, allowMultipleMonitors = false, captureScreen = true } = options;
8845
+ const { cameraId, microphoneId, allowOnlyFirstMonitor = true, allowMultipleMonitors = false, captureScreen = true, proctoringType } = options;
8825
8846
  if (!allowMultipleMonitors) {
8826
8847
  const hasMultipleMonitors = await checkIfhasMultipleMonitors();
8827
8848
  if (hasMultipleMonitors) {
@@ -8835,7 +8856,7 @@ function useProctoring(proctoringOptions, proctoringConfig) {
8835
8856
  if (!record) {
8836
8857
  throw PROCTORING_NOT_STARTED;
8837
8858
  }
8838
- const { cameraStream, _screenStream } = await _startCapture({ cameraId, microphoneId, allowOnlyFirstMonitor, captureScreen });
8859
+ const { cameraStream, _screenStream } = await _startCapture({ cameraId, microphoneId, allowOnlyFirstMonitor, captureScreen, proctoringType });
8839
8860
  proctoringId = record.id;
8840
8861
  startTime = Date.now();
8841
8862
  startDate = new Date();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "easyproctor",
3
- "version": "0.0.29",
3
+ "version": "0.0.32",
4
4
  "description": "Modulo web de gravação do EasyProctor",
5
5
  "main": "./index.js",
6
6
  "module": "./esm/index.js",
@@ -1,5 +1,6 @@
1
1
  import { ApplicationInsights } from '@microsoft/applicationinsights-web';
2
- declare const insights: ApplicationInsights;
2
+ declare let insights: ApplicationInsights;
3
+ declare const init: (key: string) => void;
3
4
  declare const trackers: {
4
5
  trackPage: (name: string, uri: string, properties?: {
5
6
  [key: string]: any;
@@ -11,4 +12,4 @@ declare const trackers: {
11
12
  registerUploadVideo: (proctoringId: string, success: boolean, description: string) => void;
12
13
  };
13
14
  export default insights;
14
- export { trackers };
15
+ export { trackers, init };