SDK to load Fraud Detection Agent via CDN and initialize it
npm install @guardianstack/guardian-js@guardianstack/guardian-js)Client-side SDK to initialize the Guardian Fraud Detection Agent and create an identification event from the browser. It returns a request id you can send to your backend to fetch the full event and decide whether to pass or apply additional checks.
---
``bash`
npm install @guardianstack/guardian-jsor
yarn add @guardianstack/guardian-jsor
pnpm add @guardianstack/guardian-js
---
`ts
import { loadAgent } from "@guardianstack/guardian-js";
async function main() {
// Initialize with your site key
const api = await loadAgent({
siteKey: "YOUR_SITE_KEY",
});
// Create an identification event and get its request id
const response = await api.get();
const body = response && (await response.json());
const requestId = body?.requestId;
// Send requestId to your backend to retrieve the full event
// and decide whether to pass or perform additional checks
}
main();
`
- Backend SDK: fetch the event by requestId and implement your decisioning with the server SDK: Guardian JS Server SDK on npm
---
- loadAgent({ siteKey: string, debug?: boolean, collectionTimeoutMs?: number, onError?: (error: Error) => void }) => PromisecollectionTimeoutMs
- Initializes the browser Agent. limits how long the agent waits to collect signals before rejecting; onError is called on errors (including timeouts).Agent.get() => Promise
- requestId
- Creates an identification event and returns a response containing a . Send this requestId` to your backend to fetch the event and decide whether to pass or add additional checks.
---
MIT © Mugshot Labs