@newtonschool/react_proctoring_library 0.0.11 → 0.0.14
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/dist/components/ProctorApp.js +65 -32
- package/dist/components/activity-tracker/index.js +13 -2
- package/dist/components/permissions/index.js +4 -1
- package/dist/components/permissions/permission-body.js +7 -2
- package/dist/constants/defaults.js +4 -2
- package/dist/constants/text.js +3 -1
- package/dist/hooks/useWebcamData.js +3 -5
- package/dist/index.js +1 -9
- package/dist/utils/breachUtils.js +28 -16
- package/dist/utils/index.js +2 -22
- package/dist/utils/webcamMicrophoneUtils.js +65 -3
- package/package.json +1 -1
|
@@ -21,64 +21,93 @@ var _permissions = require("./permissions");
|
|
|
21
21
|
|
|
22
22
|
var _useWebcamData = _interopRequireDefault(require("../hooks/useWebcamData"));
|
|
23
23
|
|
|
24
|
+
var _breachUtils = require("../utils/breachUtils");
|
|
25
|
+
|
|
24
26
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
27
|
|
|
26
28
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
27
29
|
|
|
28
30
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
29
31
|
|
|
32
|
+
const isWebcamProcessingReliable = (0, _utils.isGPUAvailable)();
|
|
33
|
+
|
|
30
34
|
const ProctorApp = _ref => {
|
|
31
35
|
let {
|
|
32
36
|
proctoringIdentifier,
|
|
33
37
|
children,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
lookedAway: true
|
|
39
|
-
},
|
|
40
|
-
sendData = () => {},
|
|
41
|
-
shouldSendDataOnBreach = false
|
|
38
|
+
config,
|
|
39
|
+
getProctorParamValues = () => {},
|
|
40
|
+
getWebcamSnapshot = () => {},
|
|
41
|
+
getScreengrab = () => {}
|
|
42
42
|
} = _ref;
|
|
43
43
|
const webcamReference = (0, _react.useRef)(null);
|
|
44
44
|
const canvasReference = (0, _react.useRef)(null);
|
|
45
45
|
const statistics = (0, _react.useRef)(_defaults.INITIAL_STATISTICS);
|
|
46
|
+
const {
|
|
47
|
+
proctorParams,
|
|
48
|
+
recurring = false,
|
|
49
|
+
recurringFetchInterval = 0,
|
|
50
|
+
trackScreenshare = false
|
|
51
|
+
} = config; // const {
|
|
52
|
+
// userCount = true,
|
|
53
|
+
// tabSwitch = true,
|
|
54
|
+
// fullscreenExit = true,
|
|
55
|
+
// lookedAway = true,
|
|
56
|
+
// } = proctorParams;
|
|
57
|
+
|
|
46
58
|
const [audioPermission, setAudioPermission] = (0, _react.useState)(false);
|
|
47
59
|
const [videoPermission, setVideoPermission] = (0, _react.useState)(false);
|
|
60
|
+
const [screensharePermission, setScreensharePermission] = (0, _react.useState)(!trackScreenshare);
|
|
48
61
|
const firstFullScreenDone = (0, _react.useRef)(false);
|
|
49
62
|
const {
|
|
50
63
|
isFullscreen,
|
|
51
64
|
setFullscreen,
|
|
52
65
|
fullScreenExitCount
|
|
53
66
|
} = (0, _hooks.useFullscreenData)(firstFullScreenDone);
|
|
54
|
-
const [userCount, lookedAwayCount] = (0, _useWebcamData.default)(webcamReference, canvasReference);
|
|
67
|
+
const [userCount, lookedAwayCount, isWebcamDataReliable] = (0, _useWebcamData.default)(webcamReference, canvasReference);
|
|
55
68
|
const tabSwitchCount = (0, _hooks.useTabSwitchCount)(firstFullScreenDone);
|
|
69
|
+
let recurringFetchIntervalRef = (0, _react.useRef)(null);
|
|
56
70
|
(0, _react.useEffect)(() => {
|
|
57
|
-
if (
|
|
58
|
-
(
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
71
|
+
if (recurring) {
|
|
72
|
+
recurringFetchIntervalRef.current = setInterval(() => {
|
|
73
|
+
getProctorParamValues(proctoringIdentifier, statistics.current, false);
|
|
74
|
+
const webcamSnapshot = (0, _utils.captureWebcamSnapshot)(webcamReference);
|
|
75
|
+
|
|
76
|
+
if (webcamReference) {
|
|
77
|
+
getWebcamSnapshot(proctoringIdentifier, webcamSnapshot, false);
|
|
78
|
+
}
|
|
79
|
+
}, recurringFetchInterval);
|
|
64
80
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
81
|
+
|
|
82
|
+
return () => {
|
|
83
|
+
clearInterval(recurringFetchIntervalRef.current);
|
|
84
|
+
};
|
|
85
|
+
}, [proctoringIdentifier, recurring, recurringFetchInterval, getWebcamSnapshot, getProctorParamValues]);
|
|
69
86
|
(0, _react.useEffect)(() => {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
87
|
+
const currentStats = {
|
|
88
|
+
userCount,
|
|
89
|
+
tabSwitchCount,
|
|
90
|
+
fullScreenExitCount,
|
|
91
|
+
lookedAwayCount,
|
|
92
|
+
isWebcamDataReliable: isWebcamProcessingReliable
|
|
93
|
+
};
|
|
94
|
+
const breachData = (0, _breachUtils.getDataOnBreach)(statistics, currentStats, proctoringIdentifier);
|
|
95
|
+
|
|
96
|
+
if (breachData) {
|
|
97
|
+
getProctorParamValues(breachData.proctoringIdentifier, breachData.data, true, breachData.breachedParam);
|
|
98
|
+
|
|
99
|
+
if (breachData.breachedParam === "LOOKED_AWAY_COUNT" || breachData.breachedParam === "USER_COUNT_MAX") {
|
|
100
|
+
const webcamSnapshot = (0, _utils.captureWebcamSnapshot)(webcamReference);
|
|
101
|
+
|
|
102
|
+
if (webcamSnapshot) {
|
|
103
|
+
getWebcamSnapshot(breachData.proctoringIdentifier, webcamSnapshot, true, breachData.breachedParam);
|
|
104
|
+
}
|
|
105
|
+
} else {// getScreengrab();
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
(0, _utils.updateStatistics)(statistics, currentStats);
|
|
77
109
|
}
|
|
78
|
-
|
|
79
|
-
(0, _utils.updateStatistics)(statistics, tabSwitchCount, fullScreenExitCount, lookedAwayCount, userCount);
|
|
80
|
-
(0, _utils.addOrUpdateStatsToLocalStorage)(proctoringIdentifier, statistics.current);
|
|
81
|
-
}, [userCount, tabSwitchCount, fullScreenExitCount, lookedAwayCount, proctoringIdentifier, sendData, shouldSendDataOnBreach]);
|
|
110
|
+
}, [userCount, tabSwitchCount, fullScreenExitCount, lookedAwayCount, isWebcamDataReliable, proctoringIdentifier, getProctorParamValues, getWebcamSnapshot]);
|
|
82
111
|
|
|
83
112
|
if (proctoringIdentifier === undefined) {
|
|
84
113
|
// todo
|
|
@@ -89,12 +118,16 @@ const ProctorApp = _ref => {
|
|
|
89
118
|
isFullscreen: isFullscreen,
|
|
90
119
|
audioPermisison: audioPermission,
|
|
91
120
|
videoPermission: videoPermission,
|
|
121
|
+
screensharePermission: screensharePermission,
|
|
122
|
+
trackScreenshare: trackScreenshare,
|
|
92
123
|
setFullscreen: setFullscreen
|
|
93
124
|
}), /*#__PURE__*/_react.default.createElement(_.ActivityTracker, {
|
|
94
125
|
setAudioPermission: setAudioPermission,
|
|
95
126
|
setVideoPermission: setVideoPermission,
|
|
96
127
|
webcamReference: webcamReference,
|
|
97
|
-
canvasReference: canvasReference
|
|
128
|
+
canvasReference: canvasReference,
|
|
129
|
+
trackScreenshare: trackScreenshare,
|
|
130
|
+
setScreensharePermission: setScreensharePermission
|
|
98
131
|
}), isFullscreen && audioPermission && videoPermission && children);
|
|
99
132
|
};
|
|
100
133
|
|
|
@@ -34,12 +34,20 @@ const ActivityTracker = _ref => {
|
|
|
34
34
|
webcamReference,
|
|
35
35
|
canvasReference,
|
|
36
36
|
setAudioPermission,
|
|
37
|
-
setVideoPermission
|
|
37
|
+
setVideoPermission,
|
|
38
|
+
trackScreenshare,
|
|
39
|
+
setScreensharePermission
|
|
38
40
|
} = _ref;
|
|
41
|
+
const videoReference = (0, _react.useRef)(null);
|
|
39
42
|
(0, _react.useEffect)(() => {
|
|
40
43
|
if (isChrome) {
|
|
41
44
|
(0, _webcamMicrophoneUtils.updateVideoPermissions)(setVideoPermission);
|
|
42
45
|
(0, _webcamMicrophoneUtils.updateAudioPermissions)(setAudioPermission);
|
|
46
|
+
|
|
47
|
+
if (trackScreenshare) {
|
|
48
|
+
(0, _webcamMicrophoneUtils.updateScreensharePermission)(setScreensharePermission, videoReference);
|
|
49
|
+
}
|
|
50
|
+
|
|
43
51
|
(0, _webcamMicrophoneUtils.getVideoPermissionQuery)().then(status => {
|
|
44
52
|
status.onchange = evt => {
|
|
45
53
|
(0, _webcamMicrophoneUtils.updateVideoPermissions)(setVideoPermission);
|
|
@@ -55,10 +63,11 @@ const ActivityTracker = _ref => {
|
|
|
55
63
|
(0, _webcamMicrophoneUtils.updateAudioPermissions)("Audio Permission", err);
|
|
56
64
|
});
|
|
57
65
|
}
|
|
58
|
-
}, [setVideoPermission, setAudioPermission]);
|
|
66
|
+
}, [setVideoPermission, setAudioPermission, setScreensharePermission, trackScreenshare]);
|
|
59
67
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_reactWebcam.default, {
|
|
60
68
|
audio: true,
|
|
61
69
|
muted: true,
|
|
70
|
+
screenshotFormat: "image/jpeg",
|
|
62
71
|
ref: webcamReference,
|
|
63
72
|
onUserMedia: stream => {
|
|
64
73
|
if (!isChrome) {
|
|
@@ -137,6 +146,8 @@ const ActivityTracker = _ref => {
|
|
|
137
146
|
}), /*#__PURE__*/_react.default.createElement("canvas", {
|
|
138
147
|
ref: canvasReference,
|
|
139
148
|
className: "captured-video-canvas"
|
|
149
|
+
}), /*#__PURE__*/_react.default.createElement("video", {
|
|
150
|
+
src: videoReference.current
|
|
140
151
|
}));
|
|
141
152
|
};
|
|
142
153
|
|
|
@@ -30,6 +30,8 @@ const Permission = _ref => {
|
|
|
30
30
|
isFullscreen,
|
|
31
31
|
audioPermisison,
|
|
32
32
|
videoPermission,
|
|
33
|
+
screensharePermission,
|
|
34
|
+
trackScreenshare,
|
|
33
35
|
setFullscreen
|
|
34
36
|
} = _ref;
|
|
35
37
|
const showPermissionModal = !isFullscreen || !audioPermisison || !videoPermission;
|
|
@@ -58,7 +60,8 @@ const Permission = _ref => {
|
|
|
58
60
|
}), text.VIDEO_UNSUPPORTED_IN_BROWSER)), /*#__PURE__*/_react.default.createElement(_permissionBody.PermissionBody, {
|
|
59
61
|
showFullscreenText: !isFullscreen,
|
|
60
62
|
showAudioPermissionText: !audioPermisison,
|
|
61
|
-
showVideoPermissionText: !videoPermission
|
|
63
|
+
showVideoPermissionText: !videoPermission,
|
|
64
|
+
showScreensharePermission: !screensharePermission && trackScreenshare
|
|
62
65
|
}))), /*#__PURE__*/_react.default.createElement(_reactBootstrap.Modal.Footer, null, !isFullscreen && /*#__PURE__*/_react.default.createElement(_reactBootstrap.Button, {
|
|
63
66
|
variant: "primary",
|
|
64
67
|
onClick: () => {
|
|
@@ -25,11 +25,16 @@ const PermissionBody = _ref => {
|
|
|
25
25
|
let {
|
|
26
26
|
showFullscreenText,
|
|
27
27
|
showAudioPermissionText,
|
|
28
|
-
showVideoPermissionText
|
|
28
|
+
showVideoPermissionText,
|
|
29
|
+
showScreensharePermission
|
|
29
30
|
} = _ref;
|
|
30
31
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
31
32
|
className: "mb-2"
|
|
32
|
-
}, text.PERMISSION_GENERIC),
|
|
33
|
+
}, text.PERMISSION_GENERIC), showScreensharePermission && /*#__PURE__*/_react.default.createElement("div", {
|
|
34
|
+
className: "mb-2"
|
|
35
|
+
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
36
|
+
className: "pr-2 font-weight-bold"
|
|
37
|
+
}, "Screen Share:"), text.PERMISSION_SCREENSHARE), showAudioPermissionText && showVideoPermissionText ? /*#__PURE__*/_react.default.createElement("div", {
|
|
33
38
|
className: "mb-2"
|
|
34
39
|
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
35
40
|
className: "pr-2 font-weight-bold"
|
|
@@ -7,6 +7,7 @@ exports.initialValues = exports.gpuTypes = exports.glancePercentageToPass = expo
|
|
|
7
7
|
const initialValues = {
|
|
8
8
|
tabSwitchCount: 0,
|
|
9
9
|
userCount: 0,
|
|
10
|
+
isWebcamDataReliable: true,
|
|
10
11
|
isWatching: true,
|
|
11
12
|
canOpenFullScreen: false,
|
|
12
13
|
fullScreenExitCount: 0,
|
|
@@ -18,7 +19,8 @@ const INITIAL_STATISTICS = {
|
|
|
18
19
|
TAB_SWITCH_COUNT: initialValues.tabSwitchCount,
|
|
19
20
|
FULLSCREEN_EXIT_COUNT: initialValues.fullScreenExitCount,
|
|
20
21
|
LOOKED_AWAY_COUNT: initialValues.lookedAwayCount,
|
|
21
|
-
USER_COUNT_MAX: initialValues.userCount
|
|
22
|
+
USER_COUNT_MAX: initialValues.userCount,
|
|
23
|
+
IS_WEBCAM_DATA_RELIABLE: initialValues.isWebcamDataReliable
|
|
22
24
|
};
|
|
23
25
|
exports.INITIAL_STATISTICS = INITIAL_STATISTICS;
|
|
24
26
|
const bodyPixConfigs = {
|
|
@@ -36,5 +38,5 @@ const glancePercentageToPass = 60;
|
|
|
36
38
|
exports.glancePercentageToPass = glancePercentageToPass;
|
|
37
39
|
const evaluateVideoIntervalInSeconds = 1;
|
|
38
40
|
exports.evaluateVideoIntervalInSeconds = evaluateVideoIntervalInSeconds;
|
|
39
|
-
const gpuTypes = ["apple", "amd", "radeon", "nvidia", "geforce"];
|
|
41
|
+
const gpuTypes = ["intel", "apple", "amd", "radeon", "nvidia", "geforce"];
|
|
40
42
|
exports.gpuTypes = gpuTypes;
|
package/dist/constants/text.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.WATCHING_SCREEN = exports.VIDEO_UNSUPPORTED_IN_BROWSER = exports.USER_COUNT_LABEL = exports.REQUEST_VIDEO_AUDIO_PERMISSIONS_HEADING = exports.REQUEST_VIDEO_AUDIO_PERMISSIONS_DESC = exports.REQUEST_PERMISSION = exports.PERMISSION_VIDEO = exports.PERMISSION_TITLE = exports.PERMISSION_GENERIC = exports.PERMISSION_FULLSCREEN = exports.PERMISSION_AUDIO_VIDEO = exports.PERMISSION_AUDIO = exports.NO_CAMERA_AVAILABLE = exports.NO_AUDIO_DEVICE_AVAILABLE = exports.NOT_WATCHING_SCREEN = exports.MESSAGE = exports.FULLSCREEN_ERROR_MESSAGE = exports.DENY_FULLSCREEN = exports.CAMERA_UNAVAILABLE_INSECURE_CONN = exports.BROWSER_BLOCKED_PERMISSION_RESOLVED_RECHECK = exports.BROWSER_BLOCKED_PERMISSION_NEXT_STEP = exports.BROWSER_BLOCKED_PERMISSION_DIRECTION = exports.BROWSER_BLOCKED_PERMISSION_DIALOG = exports.BROWSER_BLOCKED_PERMISSION = exports.ALLOW_FULLSCREEN = void 0;
|
|
6
|
+
exports.WATCHING_SCREEN = exports.VIDEO_UNSUPPORTED_IN_BROWSER = exports.USER_COUNT_LABEL = exports.REQUEST_VIDEO_AUDIO_PERMISSIONS_HEADING = exports.REQUEST_VIDEO_AUDIO_PERMISSIONS_DESC = exports.REQUEST_PERMISSION = exports.PERMISSION_VIDEO = exports.PERMISSION_TITLE = exports.PERMISSION_SCREENSHARE = exports.PERMISSION_GENERIC = exports.PERMISSION_FULLSCREEN = exports.PERMISSION_AUDIO_VIDEO = exports.PERMISSION_AUDIO = exports.NO_CAMERA_AVAILABLE = exports.NO_AUDIO_DEVICE_AVAILABLE = exports.NOT_WATCHING_SCREEN = exports.MESSAGE = exports.FULLSCREEN_ERROR_MESSAGE = exports.DENY_FULLSCREEN = exports.CAMERA_UNAVAILABLE_INSECURE_CONN = exports.BROWSER_BLOCKED_PERMISSION_RESOLVED_RECHECK = exports.BROWSER_BLOCKED_PERMISSION_NEXT_STEP = exports.BROWSER_BLOCKED_PERMISSION_DIRECTION = exports.BROWSER_BLOCKED_PERMISSION_DIALOG = exports.BROWSER_BLOCKED_PERMISSION = exports.ALLOW_FULLSCREEN = void 0;
|
|
7
7
|
const WATCHING_SCREEN = "You are watching the screen";
|
|
8
8
|
exports.WATCHING_SCREEN = WATCHING_SCREEN;
|
|
9
9
|
const NOT_WATCHING_SCREEN = "You are not watching the screen";
|
|
@@ -48,6 +48,8 @@ const PERMISSION_GENERIC = "This screen requires following permissions for conti
|
|
|
48
48
|
exports.PERMISSION_GENERIC = PERMISSION_GENERIC;
|
|
49
49
|
const PERMISSION_FULLSCREEN = "Please allow us to switch your screen to fullscreen mode.";
|
|
50
50
|
exports.PERMISSION_FULLSCREEN = PERMISSION_FULLSCREEN;
|
|
51
|
+
const PERMISSION_SCREENSHARE = "Please choose to share the entire screen out of all the screen share options.";
|
|
52
|
+
exports.PERMISSION_SCREENSHARE = PERMISSION_SCREENSHARE;
|
|
51
53
|
const PERMISSION_AUDIO_VIDEO = "Your browser or system settings have disallowed Microphone and Camera permissions. Please permit this website to access microphone and camera. Refresh after you've given the permission to access the screen";
|
|
52
54
|
exports.PERMISSION_AUDIO_VIDEO = PERMISSION_AUDIO_VIDEO;
|
|
53
55
|
const PERMISSION_VIDEO = "Your browser or system settings have disallowed Camera permissions. Please permit this website to access the camera. Refresh after you've given the permission to access the screen";
|
|
@@ -42,14 +42,12 @@ const getIsWatching = async (network, video) => {
|
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
44
|
|
|
45
|
-
const gpuAvailable = (0, _utils.isGPUAvailable)();
|
|
46
|
-
|
|
47
45
|
function useWebcamData(webcamReference, canvasReference) {
|
|
48
|
-
const [userCount, setUserCount] = (0, _react.useState)(
|
|
49
|
-
const [isWatching, setIsWatching] = (0, _react.useState)(
|
|
46
|
+
const [userCount, setUserCount] = (0, _react.useState)(_defaults.initialValues.userCount);
|
|
47
|
+
const [isWatching, setIsWatching] = (0, _react.useState)(_defaults.initialValues.isWatching);
|
|
50
48
|
const [lookedAwayCount, setLookedAwayCount] = (0, _react.useState)(_defaults.initialValues.lookedAwayCount);
|
|
51
49
|
(0, _react.useEffect)(() => {
|
|
52
|
-
if (
|
|
50
|
+
if ((0, _utils.isGPUAvailable)()) {
|
|
53
51
|
const loadBodyPixModel = async () => {
|
|
54
52
|
try {
|
|
55
53
|
const network = await bodyPix.load();
|
package/dist/index.js
CHANGED
|
@@ -9,13 +9,5 @@ Object.defineProperty(exports, "ProctorApp", {
|
|
|
9
9
|
return _components.ProctorApp;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
-
Object.defineProperty(exports, "getStatistics", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function get() {
|
|
15
|
-
return _utils.getStatistics;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
var _components = require("./components");
|
|
20
12
|
|
|
21
|
-
var
|
|
13
|
+
var _components = require("./components");
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.getDataOnBreach = void 0;
|
|
7
7
|
|
|
8
8
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
9
9
|
|
|
@@ -11,59 +11,71 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
11
11
|
|
|
12
12
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
13
13
|
|
|
14
|
-
const
|
|
14
|
+
const getDataOnBreach = (statistics, currentData, proctoringIdentifier) => {
|
|
15
15
|
const {
|
|
16
16
|
userCount,
|
|
17
17
|
tabSwitchCount,
|
|
18
18
|
fullScreenExitCount,
|
|
19
|
-
lookedAwayCount
|
|
19
|
+
lookedAwayCount,
|
|
20
|
+
isWebcamDataReliable
|
|
20
21
|
} = currentData;
|
|
21
22
|
const timestamp = Date.now();
|
|
22
23
|
const data = statistics.current;
|
|
23
24
|
|
|
25
|
+
if (data.IS_WEBCAM_DATA_RELIABLE !== isWebcamDataReliable) {
|
|
26
|
+
return {
|
|
27
|
+
proctoringIdentifier,
|
|
28
|
+
breachedParam: "IS_WEBCAM_DATA_RELIABLE",
|
|
29
|
+
timestamp,
|
|
30
|
+
data: _objectSpread(_objectSpread({}, data), {}, {
|
|
31
|
+
IS_WEBCAM_DATA_RELIABLE: isWebcamDataReliable
|
|
32
|
+
})
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
24
36
|
if (data.USER_COUNT_MAX < userCount) {
|
|
25
|
-
|
|
37
|
+
return {
|
|
26
38
|
proctoringIdentifier,
|
|
27
|
-
|
|
39
|
+
breachedParam: "USER_COUNT_MAX",
|
|
28
40
|
timestamp,
|
|
29
41
|
data: _objectSpread(_objectSpread({}, data), {}, {
|
|
30
42
|
USER_COUNT_MAX: userCount
|
|
31
43
|
})
|
|
32
|
-
}
|
|
44
|
+
};
|
|
33
45
|
}
|
|
34
46
|
|
|
35
47
|
if (data.TAB_SWITCH_COUNT !== tabSwitchCount) {
|
|
36
|
-
|
|
48
|
+
return {
|
|
37
49
|
proctoringIdentifier,
|
|
38
|
-
|
|
50
|
+
breachedParam: "TAB_SWITCH_COUNT",
|
|
39
51
|
timestamp,
|
|
40
52
|
data: _objectSpread(_objectSpread({}, data), {}, {
|
|
41
53
|
TAB_SWITCH_COUNT: tabSwitchCount
|
|
42
54
|
})
|
|
43
|
-
}
|
|
55
|
+
};
|
|
44
56
|
}
|
|
45
57
|
|
|
46
58
|
if (data.FULLSCREEN_EXIT_COUNT !== fullScreenExitCount) {
|
|
47
|
-
|
|
59
|
+
return {
|
|
48
60
|
proctoringIdentifier,
|
|
49
|
-
|
|
61
|
+
breachedParam: "FULLSCREEN_EXIT_COUNT",
|
|
50
62
|
timestamp,
|
|
51
63
|
data: _objectSpread(_objectSpread({}, data), {}, {
|
|
52
64
|
FULLSCREEN_EXIT_COUNT: fullScreenExitCount
|
|
53
65
|
})
|
|
54
|
-
}
|
|
66
|
+
};
|
|
55
67
|
}
|
|
56
68
|
|
|
57
69
|
if (data.LOOKED_AWAY_COUNT !== lookedAwayCount) {
|
|
58
|
-
|
|
70
|
+
return {
|
|
59
71
|
proctoringIdentifier,
|
|
60
|
-
|
|
72
|
+
breachedParam: "LOOKED_AWAY_COUNT",
|
|
61
73
|
timestamp,
|
|
62
74
|
data: _objectSpread(_objectSpread({}, data), {}, {
|
|
63
75
|
LOOKED_AWAY_COUNT: lookedAwayCount
|
|
64
76
|
})
|
|
65
|
-
}
|
|
77
|
+
};
|
|
66
78
|
}
|
|
67
79
|
};
|
|
68
80
|
|
|
69
|
-
exports.
|
|
81
|
+
exports.getDataOnBreach = getDataOnBreach;
|
package/dist/utils/index.js
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
Object.defineProperty(exports, "
|
|
6
|
+
Object.defineProperty(exports, "captureWebcamSnapshot", {
|
|
7
7
|
enumerable: true,
|
|
8
8
|
get: function get() {
|
|
9
|
-
return
|
|
9
|
+
return _webcamMicrophoneUtils.captureWebcamSnapshot;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
12
|
Object.defineProperty(exports, "getAudioPermission", {
|
|
@@ -39,12 +39,6 @@ Object.defineProperty(exports, "getIsDocumentVisible", {
|
|
|
39
39
|
return _browserUtils.getIsDocumentVisible;
|
|
40
40
|
}
|
|
41
41
|
});
|
|
42
|
-
Object.defineProperty(exports, "getStatistics", {
|
|
43
|
-
enumerable: true,
|
|
44
|
-
get: function get() {
|
|
45
|
-
return _localStorageUtils.getStatistics;
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
42
|
Object.defineProperty(exports, "getVideoPermission", {
|
|
49
43
|
enumerable: true,
|
|
50
44
|
get: function get() {
|
|
@@ -75,18 +69,6 @@ Object.defineProperty(exports, "isWebcamVideoValid", {
|
|
|
75
69
|
return _webcamMicrophoneUtils.isWebcamVideoValid;
|
|
76
70
|
}
|
|
77
71
|
});
|
|
78
|
-
Object.defineProperty(exports, "removeStatsFromLocalStorage", {
|
|
79
|
-
enumerable: true,
|
|
80
|
-
get: function get() {
|
|
81
|
-
return _localStorageUtils.removeStatsFromLocalStorage;
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
Object.defineProperty(exports, "retrieveStatsFromLocalStorage", {
|
|
85
|
-
enumerable: true,
|
|
86
|
-
get: function get() {
|
|
87
|
-
return _localStorageUtils.retrieveStatsFromLocalStorage;
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
72
|
Object.defineProperty(exports, "sendDataOnBreach", {
|
|
91
73
|
enumerable: true,
|
|
92
74
|
get: function get() {
|
|
@@ -100,8 +82,6 @@ Object.defineProperty(exports, "updateStatistics", {
|
|
|
100
82
|
}
|
|
101
83
|
});
|
|
102
84
|
|
|
103
|
-
var _localStorageUtils = require("./localStorageUtils");
|
|
104
|
-
|
|
105
85
|
var _webcamMicrophoneUtils = require("./webcamMicrophoneUtils");
|
|
106
86
|
|
|
107
87
|
var _browserUtils = require("./browserUtils");
|
|
@@ -3,7 +3,21 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.updateVideoPermissions = exports.updateStatistics = exports.updateAudioPermissions = exports.isWebcamVideoValid = exports.getVideoPermissionQuery = exports.getVideoPermission = exports.getGlancePercentage = exports.getAudioVideoPermission = exports.getAudioPermissionQuery = exports.getAudioPermission = void 0;
|
|
6
|
+
exports.updateVideoPermissions = exports.updateStatistics = exports.updateScreensharePermission = exports.updateAudioPermissions = exports.isWebcamVideoValid = exports.getVideoPermissionQuery = exports.getVideoPermission = exports.getGlancePercentage = exports.getAudioVideoPermission = exports.getAudioPermissionQuery = exports.getAudioPermission = exports.captureWebcamSnapshot = void 0;
|
|
7
|
+
|
|
8
|
+
require("core-js/modules/es.regexp.exec.js");
|
|
9
|
+
|
|
10
|
+
require("core-js/modules/es.string.split.js");
|
|
11
|
+
|
|
12
|
+
require("core-js/modules/es.array-buffer.slice.js");
|
|
13
|
+
|
|
14
|
+
require("core-js/modules/es.typed-array.uint8-array.js");
|
|
15
|
+
|
|
16
|
+
require("core-js/modules/es.typed-array.set.js");
|
|
17
|
+
|
|
18
|
+
require("core-js/modules/es.typed-array.sort.js");
|
|
19
|
+
|
|
20
|
+
require("core-js/modules/es.typed-array.to-locale-string.js");
|
|
7
21
|
|
|
8
22
|
var _ = require(".");
|
|
9
23
|
|
|
@@ -11,11 +25,19 @@ const isWebcamVideoValid = webcamReference => webcamReference !== null && webcam
|
|
|
11
25
|
|
|
12
26
|
exports.isWebcamVideoValid = isWebcamVideoValid;
|
|
13
27
|
|
|
14
|
-
const updateStatistics = (statistics,
|
|
28
|
+
const updateStatistics = (statistics, currentStats) => {
|
|
29
|
+
const {
|
|
30
|
+
tabSwitchCount,
|
|
31
|
+
fullScreenExitCount,
|
|
32
|
+
lookedAwayCount,
|
|
33
|
+
userCount,
|
|
34
|
+
isWebcamDataReliable
|
|
35
|
+
} = currentStats;
|
|
15
36
|
statistics.current.TAB_SWITCH_COUNT = tabSwitchCount;
|
|
16
37
|
statistics.current.FULLSCREEN_EXIT_COUNT = fullScreenExitCount;
|
|
17
38
|
statistics.current.LOOKED_AWAY_COUNT = lookedAwayCount;
|
|
18
39
|
statistics.current.USER_COUNT_MAX = Math.max(userCount, statistics.current.USER_COUNT_MAX);
|
|
40
|
+
statistics.current.IS_WEBCAM_DATA_RELIABLE = isWebcamDataReliable;
|
|
19
41
|
};
|
|
20
42
|
|
|
21
43
|
exports.updateStatistics = updateStatistics;
|
|
@@ -102,6 +124,22 @@ const updateVideoPermissions = setVideoPermission => {
|
|
|
102
124
|
|
|
103
125
|
exports.updateVideoPermissions = updateVideoPermissions;
|
|
104
126
|
|
|
127
|
+
const updateScreensharePermission = (setScreensharePermission, videoReference) => navigator.mediaDevices.getDisplayMedia({
|
|
128
|
+
video: true,
|
|
129
|
+
audio: true
|
|
130
|
+
}).then(stream => {
|
|
131
|
+
if (stream.getTracks()[0].getSettings().displaySurface === "monitor") {
|
|
132
|
+
videoReference.current = stream;
|
|
133
|
+
setScreensharePermission(true);
|
|
134
|
+
} else {
|
|
135
|
+
setScreensharePermission(false);
|
|
136
|
+
}
|
|
137
|
+
}).catch(() => {
|
|
138
|
+
setScreensharePermission(false);
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
exports.updateScreensharePermission = updateScreensharePermission;
|
|
142
|
+
|
|
105
143
|
const getVideoPermissionQuery = () => navigator.permissions.query({
|
|
106
144
|
name: "camera"
|
|
107
145
|
});
|
|
@@ -112,4 +150,28 @@ const getAudioPermissionQuery = () => navigator.permissions.query({
|
|
|
112
150
|
name: "microphone"
|
|
113
151
|
});
|
|
114
152
|
|
|
115
|
-
exports.getAudioPermissionQuery = getAudioPermissionQuery;
|
|
153
|
+
exports.getAudioPermissionQuery = getAudioPermissionQuery;
|
|
154
|
+
|
|
155
|
+
const b64DataURItoBlob = dataURI => {
|
|
156
|
+
const byteString = window.atob(dataURI.split(",")[1]);
|
|
157
|
+
const mimeString = dataURI.split(",")[0].split(":")[1].split(";")[0];
|
|
158
|
+
const u8arr = new Uint8Array(byteString.length);
|
|
159
|
+
|
|
160
|
+
for (let i = 0; i < byteString.length; i += 1) {
|
|
161
|
+
u8arr[i] = byteString.charCodeAt(i);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
return new Blob([u8arr], {
|
|
165
|
+
type: mimeString
|
|
166
|
+
});
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
const captureWebcamSnapshot = webcamReference => {
|
|
170
|
+
try {
|
|
171
|
+
const b64Snapshot = webcamReference.current.getScreenshot();
|
|
172
|
+
return b64DataURItoBlob(b64Snapshot);
|
|
173
|
+
} catch (_unused) {// pass
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
exports.captureWebcamSnapshot = captureWebcamSnapshot;
|