Initialize once
Reuse and refresh
await client.prepare() joins a running measurement or reuses a valid record held by your server. Page reloads and other tabs can reuse the record. Browser Web Locks coordinate simultaneous preparation where supported; server verification is required in every browser.
await client.status() reads readiness without starting a probe. Call it after sign-in, sign-out or an account switch. A ready measurement is separate from the account’s permission to perform an action.
A valid record remains usable when a refresh starts. During recent visible activity, the SDK checks whether it is nearing expiry and refreshes as needed. It does not keep measuring an idle page indefinitely. The server refuses expired evidence and records bound to another application session. The measurement nonce is captured when the sensor session opens. Address comparison is an optional customer rule, because the application and sensor may observe different IP families.
To start only when explicitly requested, set background: false. To dispose the client and stop local work, call client.destroy().
Existing authenticated sessions
Install preparation in the shared layout before requiring it on an action. Returning users can accumulate measurements during ordinary use. A visitor with a valid login cookie but no Heretic record still needs a measurement; authentication alone does not supply it. A user may reach the protected action before measurement finishes. The SDK displays waiting UI and joins the existing check. If a required measurement cannot complete, the action stays uncompleted. No percentage of ready visitors or fixed residual wait is assumed.Content security policy
Allowhttps://heretic.tech in frame-src and style-src. A CDN module also needs that origin in script-src. The phone ceremony loader uses https://heretic.tech/guard.js and /guard.css.
The parent page must allow the required frame features: accelerometer, gyroscope, magnetometer and public-key credential creation/get. A parent policy disabling them also disables them inside a nested ceremony. The SDK supplies the iframe allow attributes; it cannot override a restrictive parent header.
Keep the measurement frame rendered. The SDK makes it visually unobtrusive at one pixel; display: none can stop animation-frame measurements.
Diagnose preparation
heretic-check passes on the server; server configuration checks alone cannot establish that the browser’s CSP and cookie transport work.