Retrieving data from the web browser using getJSON
Description
This function allows you to retrieve the web browser properties of the device (fingerprint raw).
The optional Boolean parameter includeViewport (with false as the default value) specifies whether the following, highly volatile, values will be retrieved:
- Browser window width
- Browser window height
If includeViewport is set to true, the same device or browser will send different fingerprint values, and will therefore be considered as different devices or browsers.
OneSpan highly recommends not setting includeViewport to true when retrieving the fingerprint hash to prevent devices from being considered different while changing the size of the browser window.
Syntax
CDDC JavaScript for modern UI:
- //esm-module.js
- import {getJSON} from 'path_to_CDDC_js'
- ...
- const result = getJSON([optional boolean includeViewport=false]);
Legacy CDDC JavaScript:
- //jquery
- $.Vasco.getJSON([optional boolean includeViewport=false])
Examples
CDDC JavaScript for modern UI and React framework:
- //Retrieve raw fingerprint and store it into React state variable
- import React,{ Component } from 'react';
- //including reference to CDDC JavaScript
- import { getJSON } from '../lib/cddc.esm';
- class Test extends Component {
- constructor(props){
- super(props);
- this.state = {
- fingerprint: ''
- };
- }
- componentDidMount() {
- //Retrieve browser fingerprint, without viewport information
- const fingerprint = getJSON(false);
- this.setState({
- fingerprint: fingerprint
- });
- }
- }
- export default Test
Legacy CDDC JavaScript:
- //Retrieve raw fingerprint and write it into input box
- //#TextAreaCDDCFingerPrintJSon'
- $('#TextAreaCDDCFingerPrintJSon').val($.Vasco.getJSON(false));
Example of function result:
{browser:{"userAgent":Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0;
SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C;
.NET4.0E; rv:11.0) like Gecko},support:
{"ajax":true,"boxModel":undefined,"changeBubbles":true,"checkClone":true,"ch
eckOn":true,"cors":true,"cssFloat":true,"hrefNormalized":true,"htmlSerialize
":true,"leadingWhitespace":true,
"noCloneChecked":false,"noCloneEvent":true,"opacity":true,"optDisabled":true
,"style":true,"submitBubbles":true,"tbody":true},computer:
{"screenWidth":1920,"screenHeight":1080,"OS":"Microsoft
Windows","platform":"Win32"},additional:{}}