Reference · SDK

Browser SDK

The script tag, every data-* attribute, the events and the window API.

One <script> tag. There is no npm package, the tag is the whole browser integration.

<script src="https://hideguard.io/sdk/v1.js"
        data-site-key="pk_live_..."
        data-block="true"></script>

Attributes#

AttributeDefaultMeaning
data-site-keyrequiredThe site's public key
data-endpointthe script's own originWhere to post. Only needed when served from a CDN
data-autotrueCollect on load. false leaves it to you
data-blockfalseShow the built-in interstitial when the verdict is block
data-cookietrueSet the fpc_vid cookie on your domain
data-heartbeattrueBeat back so the dashboard can count open pages
data-behaviortrueCollect behaviour. Adds no request
data-requestsfalseOpt-in. Record the requests your own code makes
data-active-probesfalseEnable the more expensive active measurements
data-syn-checktrueAsk for the visitor's own connection's SYN packet
data-ip-checkoffURL of a second host answering "which address do you see me as"
data-ip-check-keythe bundled keyThe key for that host, when you run your own copy

Why `data-block` is off by default#

A script that can black out a customer's page the moment it is installed is a script nobody should install.

Why `data-requests` must be opted into#

It replaces your page's fetch and XMLHttpRequest.prototype.send. Adding a listener is something a script does to itself; wrapping a transport is something it does to your application.

It holds nothing and changes no return value. It calls the native transport with your own arguments and returns exactly what that returns.

The window API#

// Manual collection when data-auto="false"
const result = await window.FingerprintCollector.collect();

The event#

window.addEventListener("fpc:verdict", (event) => {
  const { verdict, score, visitorId, requestId } = event.detail;
});

This verdict is information, not a gate. It arrives after the page was served, and a client that runs no JavaScript never meets it. The half that can refuse is POST /api/v1/verdict.

The SDK sets fpc_vid on your domain. Your backend reads it and passes it to the server-side check. See Visitor ID.