JavaScript SDK
The ShieldLabs SDK is a JavaScript module loaded via CDN. It collects 30+ browser signals, sends them to the ShieldLabs pipeline, and delivers a Trust Score to your server via webhook.Loading the SDK
type="module" — it uses dynamic import() which is supported in all modern browsers.
Methods
checkAnonymous(callback?)
Fingerprints the current session for an anonymous (not logged in) user.
Uses session caching — if the session has not changed since the last check, the request is skipped.
checkAuthenticatedUser(userHashedId, callback?)
Fingerprints the session for a known user. Pass a stable, hashed identifier — never the raw user ID or email.
Uses session caching — skipped if session unchanged.
forceCheckAnonymous(callback?)
Same as checkAnonymous() but ignores the session cache — always sends a fresh fingerprint.
forceCheckAuthenticatedUser(userHashedId, callback?)
Same as checkAuthenticatedUser() but always sends a fresh fingerprint.
Callback parameters
All methods accept an optional callback(ip: string, requestId: string) => void:
| Parameter | Type | Description |
|---|---|---|
ip | string | The client’s detected IP address |
requestId | string | UUID of this check — matches RequestID in the webhook |
requestId to correlate the browser check with the incoming webhook on your server.
Session caching
checkAnonymous and checkAuthenticatedUser cache the last session state. A new fingerprint is only sent when:
- The user opens a new browser tab
- The session ID changes
- A different
userHashedIdis passed
force* variants to bypass caching for specific high-risk moments (checkout, withdrawal, login).
Framework examples
Next steps
- SDK Events — browser-side events emitted during the check
- Advanced — noscript beacon, hashing user IDs, force check patterns