All documentation

Web SDK — Install & CDN

Install the Naiza browser SDK via CDN or self-host to collect device signals for fraud detection on logins and payments.

Web SDK — Install, npm & CDN

Load the Naiza browser SDK from the versioned CDN URL, or download that bundle and host it yourself. Confirm endpoint and auth mode with your deployment (see API Reference → Web SDK).

1. Script tag — Naiza CDN (recommended)

Files are served from storage.googleapis.com/naiza-sdk-cdn, a dedicated GCS-backed CDN. Pin a specific version for production stability. The latest path always resolves to the most recent release.

<!-- Pinned version (recommended for production) -->
<script
  defer
  src="https://storage.googleapis.com/naiza-sdk-cdn/v0.10.0/naizawebsdk.umd.js"
  integrity="sha256-cJPdwJL/m7ypM3KBKsa08daLC4UU2ArcC0EFPgT2OWE="
  crossorigin="anonymous"
></script>

<!-- Always-latest (suitable for development / staging) -->
<script defer src="https://storage.googleapis.com/naiza-sdk-cdn/latest/naizawebsdk.umd.js"></script>

Use defer so execution starts after HTML parse. The UMD bundle exposes NaizaWebSdk on window.

<script defer src="https://storage.googleapis.com/naiza-sdk-cdn/v0.10.0/naizawebsdk.umd.js"></script>
<script>
  async function boot() {
    await NaizaWebSdk.init({
      token: "<MINTED_WEBSDK_JWT>",
      sdkSessionId: "ws_checkout_123",
      endpoint: "https://api.naiza.ai/api/v1/collect",
    });
  }
  if (document.readyState === "loading") {
    document.addEventListener("DOMContentLoaded", boot);
  } else {
    boot();
  }
</script>

Canonical /api/v1/collect uses Authorization: Bearer with a short-lived JWT minted server-side from POST /api/v1/websdk/tokens.

2. Direct download (self-hosted)

Download the pinned bundle from the CDN and host it yourself if you need to serve it from your own domain.

# Download a specific release
curl -L https://storage.googleapis.com/naiza-sdk-cdn/v0.10.0/naizawebsdk.umd.js   -o naizawebsdk.umd.js

3. Privacy & sampling

  • consent: false — no network requests are sent (GDPR opt-out). Local collection still runs so data is available if consent is later granted.
  • sampleRate — optional 0–1 fraction to reduce upload volume. Suppressed batches are discarded.
  • Per-collector opt-out via disabledCollectors or collectorConfig.

4. Verify on another origin

  1. Use a staging HTML page or a throwaway static deploy.
  2. Load a pinned CDN URL, open DevTools → Network and confirm POST returns 2xx with Authorization: Bearer.
  3. Toggle consent: false and confirm zero requests to the ingest host.

The SDK repo includes examples/cdn-smoke-test.html for quick end-to-end checks.

5. CDN & versioning

Every tagged release in the naizaWebSDK repository automatically publishes the UMD bundle to storage.googleapis.com/naiza-sdk-cdn/v{VERSION}/. Versioned URLs are immutable and cached permanently. The latest/ path is updated on every release with a short cache TTL (5 minutes). Check storage.googleapis.com/naiza-sdk-cdn/manifest.json for available versions.