Saltar al contenido principal
Version: Guardian v0.3.1

Quick Start

1
Install
Add the SDK to your project
2
Initialize
Configure at app startup
3
Mint a JWT & Verify
Fetch a fresh JWT, then call verify()

1. Install

npm install @surtai/guardian-web@0.3.0

2. Initialize

No initialization step, the web SDK exposes a single static collect() function with no provider and no setup. Skip to step 3.

The client never holds your sp_live_* API key. It lives on your backend, which mints the short-lived JWTs used below.

3. Mint a JWT & Verify

Before each verification, your app fetches a short-lived JWT from your own backend (which mints it via Surt's preflight endpoint). In the examples below, fetchVerifyJwt() is your helper that returns the JWT string.

tip

Always fetch a fresh JWT immediately before each verify() call. The attestation nonce embedded in the JWT is single-use - reusing a JWT causes attestation to fail.

Web is collect-only, the SDK returns an encrypted payload your backend forwards to Surt.

SignInButton.tsx
import { collect } from '@surtai/guardian-web';

async function handleSignIn() {
const { payload } = await collect({ collectLocation: false });

await fetch('/api/sign-in', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ userId: 'user_123', payload }),
});
// Your /api/sign-in forwards `payload` to Surt's evaluate endpoint
// and decides what to return to the client.
}

Next Steps

Choose your platform for the full integration guide: