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:

  1. //esm-module.js
  2. import {getJSON} from 'path_to_CDDC_js'
  3. ...
  4. const result = getJSON([optional boolean includeViewport=false]);

Legacy CDDC JavaScript:

  1. //jquery
  2. $.Vasco.getJSON([optional boolean includeViewport=false])

Examples

CDDC JavaScript for modern UI and React framework:

  1. //Retrieve raw fingerprint and store it into React state variable
  2. import React,{ Component } from 'react';
  3. //including reference to CDDC JavaScript
  4. import { getJSON } from '../lib/cddc.esm';
  5.  
  6. class Test extends Component {
  7.   constructor(props){
  8.     super(props);
  9.  
  10.     this.state = {
  11.       fingerprint: ''
  12.     };
  13.   }
  14.  
  15.   componentDidMount() {
  16.     //Retrieve browser fingerprint, without viewport information
  17.     const fingerprint = getJSON(false);
  18.     this.setState({
  19.       fingerprint: fingerprint
  20.     });
  21.   }
  22. }
  23. export default Test

Legacy CDDC JavaScript:

  1. //Retrieve raw fingerprint and write it into input box
  2. //#TextAreaCDDCFingerPrintJSon'
  3. $('#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:{}}