Browser script
🌐 Browser script (gkaf.js)
Optional. The script binds the login to a key of the user's browser and follows the session after the login, so GuardianKey can tell the real browser from a stolen session cookie being replayed elsewhere.
It never blocks the login: if the browser cannot use the key, the form is submitted normally and the session is created without device binding.
1. Register your origins (once)
In the protection group's integration screen in the GDN, add every origin
that serves the login and the authenticated pages (for example
https://app.example.com). Requests from other origins are refused.
The same screen gives you the ready-made <script> snippet, with the exact
version and its integrity hash (SRI).
2. Login page
<form method="post" action="/login" id="login"> ... </form>
<script src="https://<api>/af/v1/js/gkaf-<version>.min.js"
integrity="sha384-<from the GDN snippet>"
crossorigin="anonymous"></script>
<script>
gkaf.attach(document.getElementById('login'));
</script>
On submit the script adds the hidden field gkaf_blob. Your backend receives
it like any other field.
3. Backend: start the session with the login event
Forward gkaf_blob unchanged inside the login event of the
Events API:
{
"protection_group": "<group Hash ID>",
"event_type": "authentication",
"event_name": "login",
"user": { "id": "joao" },
"client": { "ip": "203.0.113.7", "user_agent": "Mozilla/5.0 ..." },
"action": { "result": "success" },
"session": { "start": true, "blob": "<gkaf_blob as received>" }
}
The response gains a session object with id, ticket, bound and
expires_at. Store id and ticket with your server-side session.
bound: false only means the session has no device binding; the login is
not affected.
4. Authenticated pages
<script src="https://<api>/af/v1/js/gkaf-<version>.min.js"
integrity="sha384-..." crossorigin="anonymous"></script>
<script>
gkaf.init({ endpoint: "https://<api>", ticket: "<session ticket>" });
</script>
From then on the script sends small presence signals to the API while the tab is visible. Nothing is sent from hidden tabs.
5. Logout
Call gkaf.stop() on the page and, from your backend, with the organization
token:
POST {API_URL}/af/v1/sessions/{id}/end
GET {API_URL}/af/v1/sessions/{id} returns the session status and risk to
your backend.
Content-Security-Policy
If your pages send a CSP, allow the API in script-src and connect-src:
script-src https://<api>; connect-src https://<api>
Data and privacy
The integration is first-party and shows no banner: the notice to the data subject and the legal basis (LGPD/GDPR) are the customer's.
- Collected: a non-exportable key kept in the browser, low-entropy environment indicators (to detect a change of browser, not to track across sites), timezone, language, optional geolocation, visibility and idle time, and aggregate interaction counts.
- Never collected: field contents, typed keys, the clipboard, pointer coordinates, screenshots, the page DOM, URLs with query strings, browsing history or high-entropy fingerprints (canvas, WebGL, audio, fonts).
- Retention: session data until the session ends plus its validity; learned behavior for the retention period of the installation; everything is deleted when the organization is removed.
- Turning it off: the interaction aggregate can be disabled per
protection group (GDN), per page or user (
gkaf.init({..., behavior: false})), and what was learned for a user can be erased through the API.
Form-field integrity protection and the complete reference are in the customer documentation provided with the subscription.