new Supervisor(options)
- Description:
- The constructor of Supervisor class.
It is recommended to use only one instance on a page.
Example
var supervisor = new Supervisor({ url: 'https://your-proctoring-server' });
Parameters:
Name |
Type |
Description |
options |
Object
|
Basic options of Supervisor.
Properties
Name |
Type |
Attributes |
Description |
url |
string
|
|
Address of the server API. |
el |
HTMLElement
|
<optional>
|
Target element. |
store |
string
|
Object
|
<optional>
|
Session store, it uses localStorage if string. |
css |
string
|
Object
|
<optional>
|
Additional styles, it uses as className if string. |
theme |
string
|
<optional>
|
UI color theme (light or dark). |
|
Members
(readonly) el
- Description:
- Get the current HTML element.
Get the current HTML element.
(static, readonly) VERSION
- Description:
Get the SDK version.
Methods
(async) check(optionsopt)
- Description:
Example
// check all equipment
supervisor.check();
// check only the camera
supervisor.check({ camera: true });
// check the camera and microphone
supervisor.check({ camera: true, microphone: true });
Parameters:
Name |
Type |
Attributes |
Description |
options |
Object
|
<optional>
|
Check options (all check by default).
Properties
Name |
Type |
Attributes |
Description |
browser |
boolean
|
<optional>
|
Check the browser. |
camera |
boolean
|
<optional>
|
Check the camera. |
microphone |
boolean
|
<optional>
|
Check the microphone. |
screen |
boolean
|
<optional>
|
Check the screen. |
network |
boolean
|
<optional>
|
Check the network. |
webrtc |
boolean
|
<optional>
|
Check the WebRTC connection. |
|
(async) close()
- Description:
- Close the session without stopping or logging out.
It will be possible to continue the session by calling the start again.
Example
supervisor.close();
(async) init(optionsopt) → {Object}
- Description:
- Initialize the session from specific payload.
Example
supervisor.init({
// set your provider name
provider: 'jwt',
// get JWT string from your server
token: fetch('/api/token').then(function (response) {
if (response.ok) return response.text();
else throw Error('Failed to get JWT');
})
});
Parameters:
Name |
Type |
Attributes |
Description |
options |
Object
|
<optional>
|
Initialization options.
Properties
Name |
Type |
Attributes |
Description |
provider |
string
|
<optional>
|
Authorization provider. |
token |
string
|
function
|
<optional>
|
JSON Web Token with specific payload. |
|
Returns:
Session token.
-
Type
-
Object
(async) logout(optionsopt)
- Description:
- Log out from the session.
Example
supervisor.logout({ redirect: true });
Parameters:
Name |
Type |
Attributes |
Description |
options |
Object
|
<optional>
|
Log out options.
Properties
Name |
Type |
Attributes |
Description |
redirect |
boolean
|
string
|
function
|
<optional>
|
Redirect after logout or close current window. |
|
lookup(…argsopt) → {Object}
- Description:
- Lookup the session fields.
Example
supervisor.lookup('identifier', 'username', 'subject', 'duration');
Parameters:
Name |
Type |
Attributes |
Description |
args |
string
|
Array.<string>
|
<optional>
<repeatable>
|
List of fields. |
Returns:
Fields and values of the session.
-
Type
-
Object
off(event, handler)
- Description:
- Remove the event handler.
Example
// unsubscribe from a single event
supervisor.off('stop', handler);
// unsubscribe from multiple events
supervisor.off(['stop', 'fail'], handler);
Parameters:
Name |
Type |
Description |
event |
string
|
Array.<string>
|
Type of event. |
handler |
Supervisor~eventHandler
|
Callback function for event. |
on(event, handler)
- Description:
Example
// event handler
var handler = function() {
supervisor.logout({ redirect: true });
};
// subscribe to a single event
supervisor.on('stop', handler);
// subscribe to multiple events
supervisor.on(['stop', 'fail'], handler);
Parameters:
Name |
Type |
Description |
event |
string
|
Array.<string>
|
Type of event. |
handler |
Supervisor~eventHandler
|
Callback function for event. |
once(event, handler)
- Description:
- Add an event handler for emitted once.
Example
// event handler
var handler = function() {
// event occurred
};
// subscribe to an event
supervisor.once('start', handler);
Parameters:
Name |
Type |
Description |
event |
string
|
Array.<string>
|
Type of event. |
handler |
Supervisor~eventHandler
|
Callback function for event. |
(async) profile(options)
- Description:
- Update current user profile data.
Example
// change user's full name and UI language
supervisor.profile({ nickname: 'John Doe', lang: 'en' });
// upload user's face photo
supervisor.profile({ face: '/path/to/face.jpg' });
// or the same using fetch()
supervisor.profile({ face: fetch('/path/to/face.jpg').then(res => res.blob()) });
Parameters:
Name |
Type |
Description |
options |
Object
|
Profile options.
Properties
Name |
Type |
Attributes |
Description |
nickname |
string
|
<optional>
|
Visible name of the user. |
lang |
string
|
<optional>
|
UI language, e.g. "en". |
face |
string
|
Blob
|
<optional>
|
Image file containing the user's face. |
|
(async) start(optionsopt) → {Object}
- Description:
- Initialize and start or resume the session.
Example
// start the already initialized session or self-registration mode
supervisor.start();
// initialize and start the session with parameters
supervisor.start({ provider: 'jwt', token: '...' });
Parameters:
Name |
Type |
Attributes |
Description |
options |
Object
|
<optional>
|
Initialization options (see Supervisor#init). |
Fires:
Returns:
Session token.
-
Type
-
Object
(async) stop()
- Description:
- Stop the session and log out.
Example
supervisor.stop();
Fires:
(async) sync(optionsopt) → {Object}
- Description:
- Synchronize the session state by token.
Example
supervisor.sync({ token: 'SESSION_TOKEN' });
Parameters:
Name |
Type |
Attributes |
Description |
options |
Object
|
<optional>
|
Synchronization options.
Properties
Name |
Type |
Attributes |
Description |
token |
string
|
function
|
<optional>
|
Session token. |
|
Returns:
New session token.
-
Type
-
Object
Type Definitions
Metrics
- Description:
- Schema of metrics.
Each metric is in the range from 0 to 100.
Properties:
Name |
Type |
Description |
b1 |
number
|
Browser is not supported. |
b2 |
number
|
Focus changed to a different window. |
b3 |
number
|
Full-screen mode is disabled. |
c1 |
number
|
Webcam is disabled. |
c2 |
number
|
Face not found in front of the camera. |
c3 |
number
|
Several faces in front of the camera. |
c4 |
number
|
Unidentified face in front of the camera. |
c5 |
number
|
Found a similar profile. |
c6 |
number
|
Face does not match the profile. |
m1 |
number
|
Microphone is not working or its volume is low. |
m2 |
number
|
Conversation or noise in the background. |
n1 |
number
|
Network connection is lost. |
n2 |
number
|
Mobile camera is disconnected. |
n3 |
number
|
Records are not saved. |
s1 |
number
|
screen activity is not shared. |
s2 |
number
|
Second display is used. |
Schema of metrics.
Each metric is in the range from 0 to 100.
Type:
Payload
- Description:
Properties:
Name |
Type |
Attributes |
Description |
iat |
number
|
<optional>
|
Issued at (seconds since UNIX epoch). |
exp |
number
|
<optional>
|
Expiration time (seconds since UNIX epoch). |
username |
string
|
|
Unique user ID (format /^[A-Za-z0-9_-]+$/). |
nickname |
string
|
<optional>
|
Visible name of the user. |
lang |
string
|
<optional>
|
UI language, e.g. "en". |
referrer |
string
|
<optional>
|
Referrer page used for redirection after logout. |
identifier |
string
|
|
Unique session ID (format /^[A-Za-z0-9_-]+$/). |
template |
string
|
<optional>
|
Template ID for the session. |
subject |
string
|
<optional>
|
The name of the session. |
timeout |
number
|
<optional>
|
The session timeout in minutes after which it should be stopped (integer). |
lifetime |
number
|
<optional>
|
The session lifetime in minutes after which it should be stopped (integer). |
expires |
number
|
<optional>
|
Number of days to keep records (integer). |
openAt |
Date
|
<optional>
|
Date and time until which the session cannot start (ISO-8601). |
closeAt |
Date
|
<optional>
|
Date and time after which the session will automatically end (ISO-8601). |
members |
Array.<string>
|
<optional>
|
A list of proctors to add to the members in the session. |
metrics |
Array.<string>
|
<optional>
|
A list of metrics in the session. |
weights |
Array.<number>
|
<optional>
|
A list of weights for the metrics. |
addons |
Array.<string>
|
<optional>
|
A list of addons in the session. |
threshold |
number
|
<optional>
|
The threshold value of the credibility for automatic conclusion and notification of the participant. |
locale |
string
|
<optional>
|
The PDF report language, e.g. "en". |
timezone |
string
|
<optional>
|
The PDF protocol time zone, e.g. "Europe/Berlin". |
rules |
string
|
<optional>
|
URL of a page with a rules of the event. |
url |
string
|
<optional>
|
URL of a test page to be opened in IFRAME. |
code |
string
|
<optional>
|
Access code to inject into a test page in IFRAME. |
api |
string
|
<optional>
|
API address to send results for this session to another server via webhooks. |
tags |
Array.<string>
|
<optional>
|
Session tags for searching. |
Schema of payload.
Type:
eventHandler(dataopt)
- Description:
- Callback function for message event.
Parameters:
Name |
Type |
Attributes |
Description |
data |
Object
|
<optional>
|
Data of event. |
Events
chat
- Description:
- Text of the sent or received message.
Properties:
Name |
Type |
Description |
data |
Object
|
Data of event.
Properties
Name |
Type |
Description |
text |
string
|
Text message. |
|
face
- Description:
- A photo of the face was taken. The image is saved in JPEG format.
Properties:
Name |
Type |
Description |
data |
Object
|
Data of event.
Properties
Name |
Type |
Description |
dataUrl |
string
|
Face image in base64. |
file |
File
|
Face image as file. |
|
fail
- Description:
- Critical error during the session initializing, starting, or stopping.
Properties:
Name |
Type |
Description |
err |
Error
|
Error object. |
load
- Description:
- The content within the IFRAME has been loaded.
Properties:
Name |
Type |
Description |
data |
HTMLElement
|
IFRAME element. |
metrics
- Description:
- The metrics of user behavior are obtained.
Properties:
Name |
Type |
Description |
data |
Object
|
Data of event.
Properties
Name |
Type |
Description |
metrics |
Supervisor~Metrics
|
Values of detected metrics. |
score |
number
|
Score calculated from current metric values. |
violated |
boolean
|
Violation detected or not. |
|
start
- Description:
- The session has been started.
stop
- Description:
- The session has been stopped.