JavaScript Restrictor
Browser extension that improves privacy and security
Loading...
Searching...
No Matches
wrappingS-SENSOR-ORIENT.js File Reference

Wrappers for the AbsoluteOrientationSensor and RelativeOrientationSensor. More...

Classes

class  QuaternionGenerator
 

Functions

function matrixToQuaternion (rot)
 
function updateReadings (sensorObject)
 

Variables

var previousReading = previousReading || {quaternion: null, fake_quaternion: null, fake_quaternion_rel: null, timestamp: null}
 
var debugMode = false
 
const TWOPI = 2 * Math.PI
 
var orig_getters
 
var origGetTimestamp = Object.getOwnPropertyDescriptor(Sensor.prototype, "timestamp").get
 
var generators
 
var helping_functions
 
var hc = init_data + orig_getters + helping_functions + generators
 
var wrappers
 

Detailed Description

Wrappers for the AbsoluteOrientationSensor and RelativeOrientationSensor.

See also
https://www.w3.org/TR/orientation-sensor
https://www.w3.org/TR/orientation-sensor/#absoluteorientationsensor-model
https://www.w3.org/TR/orientation-sensor/#relativeorientationsensor-model
Author
Copyright (C) 2021 Radek Hranicky
License:
SPDX-License-Identifier: GPL-3.0-or-later

MOTIVATION Device orientation sensors can be easily used for fingerprinting. As it highly unlikely that two devices visiting the same site will be oriented exactly the same, the orientation itself can serve as a fingerprint.

WRAPPING AbsoluteOrientationSensor returns a quaterion decribing the physical orientation of the device in relation to the Earth's reference coordinate system. The faked orientation of the device is saved inside the "orient" global variable that is accessible to all wrappers. The value is chosen pseudorandomly from the domain hash. The wrappper supports possible change of orientation. With each reading, it loads the "orient"'s contents, converts the rotation matrix to a quaternion that is returned by the wrapped getter.

RelativeOrientationSensor also describes the orientation, but without regard to the Earth's reference coordinate system. We suppose the coordinate system is chosen at the beginning of the sensor instance creation. As we observed, no matter how the device is oriented, there is always a slight difference from the AbsoluteOrientationSensor's in at least one axis. When the device moves, both sensors' readings change. But their difference should be always constant. And thus, we pseudorandomly generate a deviation from the Earth's reference coordinate system. And for each reading, we take the values from the fake AbsoluteOrientationSensor and modify them by the constant deviation.

POSSIBLE IMPROVEMENTS Study the supported coordinate systems of the RelativeOrientationSensor and modify the wrapper behavior if needed.

Function Documentation

◆ matrixToQuaternion()

function matrixToQuaternion (   rot)
Here is the caller graph for this function:

◆ updateReadings()

function updateReadings (   sensorObject)

Variable Documentation

◆ debugMode

var debugMode = false

◆ generators

var generators
Initial value:
= `
var quaternionGenerator = quaternionGenerator || new QuaternionGenerator()
Definition wrappingS-SENSOR-ORIENT.js:136

◆ hc

var hc = init_data + orig_getters + helping_functions + generators

◆ helping_functions

var helping_functions
Initial value:
var device_orientation_functions
Definition wrappingL-SENSOR.js:117
var sensorapi_prng_functions
Definition wrappingL-SENSOR.js:35
function updateReadings(sensorObject)
Definition wrappingS-SENSOR-ORIENT.js:198
function matrixToQuaternion(rot)
Definition wrappingS-SENSOR-ORIENT.js:90

◆ orig_getters

var orig_getters
Initial value:
= `
var origGetQuaternion = Object.getOwnPropertyDescriptor(OrientationSensor.prototype, "quaternion").get

◆ origGetTimestamp

var origGetTimestamp = Object.getOwnPropertyDescriptor(Sensor.prototype, "timestamp").get

◆ previousReading

var previousReading = previousReading || {quaternion: null, fake_quaternion: null, fake_quaternion_rel: null, timestamp: null}

◆ TWOPI

const TWOPI = 2 * Math.PI

◆ wrappers

var wrappers