@newtonschool/react_proctoring_library 0.0.100 → 0.0.101
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.
|
@@ -9,8 +9,10 @@ var _react = require("react");
|
|
|
9
9
|
var _ElectronContext = require("../../contexts/ElectronContext");
|
|
10
10
|
function useIllegalKeysCombination() {
|
|
11
11
|
const [keysClickedCount, setKeysClickedCount] = (0, _react.useState)(0);
|
|
12
|
+
const [keysCombinationClicked, setKeysCombinationClicked] = (0, _react.useState)('');
|
|
12
13
|
const isElectronApp = (0, _react.useContext)(_ElectronContext.ElectronContext);
|
|
13
|
-
const illegalKeysClickHandler =
|
|
14
|
+
const illegalKeysClickHandler = keyCombination => {
|
|
15
|
+
setKeysCombinationClicked(keyCombination);
|
|
14
16
|
setKeysClickedCount(count => count + 1);
|
|
15
17
|
};
|
|
16
18
|
(0, _react.useEffect)(() => {
|
|
@@ -25,5 +27,8 @@ function useIllegalKeysCombination() {
|
|
|
25
27
|
}
|
|
26
28
|
}
|
|
27
29
|
}, [isElectronApp]);
|
|
28
|
-
return
|
|
30
|
+
return {
|
|
31
|
+
keysClickedCount,
|
|
32
|
+
keysCombinationClicked
|
|
33
|
+
};
|
|
29
34
|
}
|
|
@@ -9,6 +9,9 @@ var _ElectronContext = require("../contexts/ElectronContext");
|
|
|
9
9
|
var _useIllegalKeysCombination = require("./electron/useIllegalKeysCombination");
|
|
10
10
|
function useGenericIllegalKeysCombinationDetected() {
|
|
11
11
|
const isElectronApp = (0, _react.useContext)(_ElectronContext.ElectronContext);
|
|
12
|
-
const
|
|
13
|
-
return isElectronApp ?
|
|
12
|
+
const illegalKeysCombination = (0, _useIllegalKeysCombination.useIllegalKeysCombination)();
|
|
13
|
+
return isElectronApp ? illegalKeysCombination : {
|
|
14
|
+
keysClickedCount: 0,
|
|
15
|
+
keysCombinationClicked: ''
|
|
16
|
+
};
|
|
14
17
|
}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
require("core-js/modules/esnext.iterator.constructor.js");
|
|
4
|
+
require("core-js/modules/esnext.iterator.filter.js");
|
|
5
|
+
require("core-js/modules/esnext.iterator.for-each.js");
|
|
3
6
|
Object.defineProperty(exports, "__esModule", {
|
|
4
7
|
value: true
|
|
5
8
|
});
|
|
6
9
|
exports.useTrackBreachParameters = void 0;
|
|
10
|
+
require("core-js/modules/es.symbol.description.js");
|
|
7
11
|
var _react = require("react");
|
|
8
12
|
var _breachUtils = require("../utils/breachUtils");
|
|
9
13
|
var _useGenericPageVisibility = _interopRequireDefault(require("./useGenericPageVisibility"));
|
|
@@ -11,7 +15,13 @@ var _utils = require("../utils");
|
|
|
11
15
|
var _useGenericSleepDetected = _interopRequireDefault(require("./useGenericSleepDetected"));
|
|
12
16
|
var _useGenericIllegalKeysCombination = _interopRequireDefault(require("./useGenericIllegalKeysCombination"));
|
|
13
17
|
var _ElectronContext = require("../contexts/ElectronContext");
|
|
18
|
+
var _defaults = require("../constants/defaults");
|
|
14
19
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
20
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
21
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
22
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
23
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
24
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
15
25
|
const isWebcamProcessingReliable = (0, _utils.isGPUAvailable)();
|
|
16
26
|
const useTrackBreachParameters = _ref => {
|
|
17
27
|
let {
|
|
@@ -31,14 +41,18 @@ const useTrackBreachParameters = _ref => {
|
|
|
31
41
|
const recurringFetchIntervalRef = (0, _react.useRef)(null);
|
|
32
42
|
const isTabSwitched = !(0, _useGenericPageVisibility.default)(proctorParams.tabSwitch);
|
|
33
43
|
const isPageFocussed = (0, _useGenericPageVisibility.default)(proctorParams.pageFocus);
|
|
34
|
-
const
|
|
44
|
+
const {
|
|
45
|
+
keysClickedCount: illegalKeysCombinationCount,
|
|
46
|
+
keysCombinationClicked
|
|
47
|
+
} = (0, _useGenericIllegalKeysCombination.default)();
|
|
35
48
|
const previousIllegalKeysCombinationCount = (0, _react.useRef)(0);
|
|
36
49
|
const sleepCount = (0, _useGenericSleepDetected.default)();
|
|
37
50
|
const previousSleepCount = (0, _react.useRef)(0);
|
|
38
51
|
const sendProctoredParamValues = (0, _react.useCallback)(function () {
|
|
39
52
|
let isBreach = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
40
53
|
let breachParam = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
41
|
-
|
|
54
|
+
let breachDetails = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
55
|
+
getProctorParamValues(proctoringIdentifier, statistics.current, isBreach, breachParam, breachDetails);
|
|
42
56
|
}, [proctoringIdentifier, getProctorParamValues]);
|
|
43
57
|
(0, _react.useEffect)(() => {
|
|
44
58
|
let timeoutId = null;
|
|
@@ -59,6 +73,7 @@ const useTrackBreachParameters = _ref => {
|
|
|
59
73
|
const currentStats = {
|
|
60
74
|
isTabSwitched,
|
|
61
75
|
illegalKeysCombinationCount,
|
|
76
|
+
keysCombinationClicked,
|
|
62
77
|
isIllegalKeysCombinationDetected: illegalKeysCombinationCount > previousIllegalKeysCombinationCount.current,
|
|
63
78
|
sleepCount,
|
|
64
79
|
isSleepDetected: sleepCount > previousSleepCount.current,
|
|
@@ -69,7 +84,12 @@ const useTrackBreachParameters = _ref => {
|
|
|
69
84
|
const breachData = (0, _breachUtils.getDataOnBreach)(statistics, currentStats, proctorParams);
|
|
70
85
|
(0, _utils.updateStatistics)(statistics, currentStats, proctorParams);
|
|
71
86
|
if (breachData && allPermissionGrantedOnce.current) {
|
|
72
|
-
|
|
87
|
+
const {
|
|
88
|
+
keysCombinationClicked
|
|
89
|
+
} = breachData.data;
|
|
90
|
+
sendProctoredParamValues(true, breachData.breachedParam, _objectSpread({}, keysCombinationClicked && breachData.breachedParam === _defaults.STATS_PARAMS.illegalKeysCombinationDetected && {
|
|
91
|
+
illegal_keys_combination: keysCombinationClicked
|
|
92
|
+
}));
|
|
73
93
|
if (isElectronApp) {
|
|
74
94
|
var _window$electron$acti, _window$electron$acti2;
|
|
75
95
|
if ((_window$electron$acti = window.electron.actions) !== null && _window$electron$acti !== void 0 && _window$electron$acti.captureAndSendSnapshot) {
|
|
@@ -60,6 +60,7 @@ const getDataOnBreach = (statistics, currentData, proctorParams) => {
|
|
|
60
60
|
isWebcamDataNotReliable,
|
|
61
61
|
isPageFocussed,
|
|
62
62
|
illegalKeysCombinationCount,
|
|
63
|
+
keysCombinationClicked,
|
|
63
64
|
isIllegalKeysCombinationDetected,
|
|
64
65
|
sleepCount,
|
|
65
66
|
isSleepDetected
|
|
@@ -82,7 +83,8 @@ const getDataOnBreach = (statistics, currentData, proctorParams) => {
|
|
|
82
83
|
breachedParam: illegalKeyCombinationDetectedParam,
|
|
83
84
|
timestamp,
|
|
84
85
|
data: _objectSpread(_objectSpread({}, data), {}, {
|
|
85
|
-
[illegalKeyCombinationDetectedParam]: illegalKeysCombinationCount
|
|
86
|
+
[illegalKeyCombinationDetectedParam]: illegalKeysCombinationCount,
|
|
87
|
+
keysCombinationClicked: keysCombinationClicked
|
|
86
88
|
})
|
|
87
89
|
};
|
|
88
90
|
}
|