# DeviceAssure Web Client
## Table of Contents
- [Introduction](#introduction)
- [Client to server model](#client-to-server-model)
- [Server to server model](#server-to-server-model)
- [Sample Application](#sample-application)
- [Data](#data)
- [Getting Started](#getting-started)
- [Client to Server](#client-to-server-usage)
- [Page Load Setup](#c2s-page-load-setup)
- [User Event Setup](#c2s-user-event-setup)
- [Server to Server](#server-to-server-usage)
- [Page Load Setup](#s2s-page-load-setup)
- [User Event Setup](#s2s-user-event-setup)
- [IMEI Corroboration](#imei-corroboration)
- [DeviceAssure Cache Configuration](#deviceassure-cache-configuration)
- [Storage Types/Location](#storage-typeslocation)
- [Cache Expiry Configuration](#cache-expiry-configuration)
- [Troubleshooting](#troubleshooting)
- [iFrame](#iframe-usage)
- [Alternative Setups](#alternative-setups)
- [Using Javascript Modules](#alternative-setups-javascript-modules)
- [Vue, Angular, React etc](#alternative-setups-vue-angular-react-etc)
Introduction
The purpose of this JavaScript library is to analyse and validate a device
visiting a webpage with the library embedded. The collected data is compared
with sets of known valid characteristics for legitimate devices. This
comparison and validation is performed by the DeviceAssure backend service.
The data collected by the library may be sent to the DeviceAssure service in two
ways.
Client to server model
The data is sent directly from the client library to the DeviceAssure backend
service. Validation results are returned to the library and optionally to a
configured callback URL.
Server to server model
The data is collected and made available on the client. The DeviceAssure library
will not make a request to the DeviceAssure service. It is the responsibility of
the calling application to transmit the data to a suitable server and for that
server to make the request to the DeviceAssure service. The validation results
are returned directly back to the calling server and not to the client
application.
---
Sample Application
A sample application is included in the package. This sample shows usage for the examples listed.
- Client to Server (On Page Load)
- Client to Server (On User Event)
- Server to Server (On Page Load)
- Server to Server (On User Event)
- IMEI Check
A valid DeviceAssure licence key is required for the "Client to Server" and IMEI Check examples.
#### Running the Sample Application ####
```bash
# Unzip the package and navigate to the SampleApplication directory
cd SampleApplication
python3 -m http.server 3000
# Now navigate to http://localhost:3000
```
---
Data
The library collects data about the underlying hardware and browser
capabilities. It does not collect any PII data.
The library stores our data in a configurable location to prevent subsequent calls to the
DeviceAssure library for a **30 minute** period. DeviceAssure will not be called
again until the cache expires or is deleted.
It is possible to delete the cached location within our library. The expiry and the location of the cache can be set, or
can be disabled entirely.
Please see the DeviceAssure Cache Configuration section for more details.
---
Getting Started
The DeviceAssure JavaScript library must be included on a webpage for it to
work. It is recommended to include the library at the end of the web page.
The DeviceAssure library can be used in three different ways: ["Client to Server"](#client-to-server-usage), ["Server to Server"](#server-to-server-usage) and ["IMEI Corroboration"](#imei-corroboration).
There are a number of methods exposed in the DeviceAssure library. However, the `.load` method is the recommended method to use. The remaining methods have been deprecated and should no longer be used. These will be removed in a future release.
Property | Description
------------ | -------------------------------------------------------------------------------------------------------------------
`.load` | Entrypoint method for the library. Please see the setup guides below for more details.
`.check` | [Deprecated, use `load`] Please see the Migration Guide included in our bundle for help moving to the new `.load` method above.
`.checkIMEI` | [Deprecated, use `load`] Please see the Migration Guide included in our bundle for help moving to the new `.load` method above.
`.getData` | [Deprecated, use `load`] Please see the Migration Guide included in our bundle for help moving to the new `.load` method above.
Client to Server
For this option the data is collected by the library and automatically sent to the DeviceAssure API for device verification.
There are two recommended ways to use the library in this scenario. The first is ["Page Load Setup"](#page-load-setup) and the second is upon a ["User Event"](#user-event-setup) e.g. a click of a button the `.check` method is called directly.
Page Load Setup
The following is a list of configurations that can be set on the DeviceAssure library for the page load setup.
| Property | Type | Default | Description |
|------------------|--------------------------|-----------------|---------------------------------------------------------------------------------------------------------------------------------------------------|
| `serverToServer` | Boolean | `false` | Enable server to server mode. This will disable the automatic validation to the DeviceAssure service and manual data collection can then occur. |
| `imei` | String | 'undefined' | Provide an IMEI for use as another identifier for device verification. When `imei` is present it must not be defined with an IMEI value. |
| `tags` | List