Ontvang en verifieer identificatie-webhooks in Node.js en Express. Voeg binnen enkele minuten bezoekersidentificatie, botdetectie en smart signals toe aan je Node.js-applicatie.
Voeg de SDK toe aan je project met je favoriete package manager.
npm install expressyarn add expresspnpm add expressGa van start met de minimale setup.
import express from 'express'const app = express()// Capture the raw body so the signature can be verified byte-for-byte.app.use(express.json({ verify: (req, _res, buf) => ((req as any).rawBody = buf) }))// Identification events are pushed here in real timeapp.post('/webhook/tracio', (req, res) => { const event = req.body console.log(event.visitorId, event.bot.result) res.status(200).send('OK')})app.listen(3000)Productieklare patronen met foutafhandeling, laadstatussen en geavanceerde configuratie.
import express from 'express'import crypto from 'crypto'const app = express()app.use(express.json({ verify: (req, _res, buf) => ((req as any).rawBody = buf) }))// Recompute the HMAC-SHA256 over "<t>.<rawBody>" and compare it.function verify(rawBody: Buffer, header: string, secret: string): boolean { const p = Object.fromEntries(header.split(',').map((kv) => kv.split('=') as [string, string])) const signed = Buffer.concat([Buffer.from(`${p.t}.`), rawBody]) const expected = crypto.createHmac('sha256', secret).update(signed).digest('hex') const a = Buffer.from(p.v1, 'hex') const b = Buffer.from(expected, 'hex') return a.length === b.length && crypto.timingSafeEqual(a, b)}app.post('/webhook/tracio', (req, res) => { const sig = req.headers['x-tracio-signature'] as string if (!verify((req as any).rawBody, sig, process.env.TRACIO_WEBHOOK_SECRET!)) { return res.status(401).json({ error: 'Invalid signature' }) } const event = req.body if (event.bot.result === 'bot') { return res.status(200).json({ action: 'blocked', visitorId: event.visitorId }) } if (event.decision.riskScore > 50) { return res.status(200).json({ action: 'review', visitorId: event.visitorId }) } res.status(200).json({ action: 'allow', visitorId: event.visitorId })})app.listen(3000)Alle beschikbare opties voor het initialiseren en configureren van de SDK.
publicKeystringJe public key uit het dashboard — veilig om in de browser mee te sturenendpointstringAangepaste endpoint-URL voor proxy-gerouteerde deployments — een expliciete URL gaat vóór regionregionstringDataregio: us of eutimeoutMsnumberTime-out voor de hele getResult()-call, in millisecondenlinkedIdstringJe interne account-ID van de ingelogde gebruiker, zodat bezoeken vanaf hetzelfde apparaat gekoppeld kunnen wordentagstringVrij label dat aan het identificatieverzoek wordt gekoppeld, bijv. checkout of logindebugbooleanLogt de levenscyclus van het script en netwerkactiviteit naar de browserconsolescriptUrlstringVolledige override van de URL van het agentscript — voor self-hosting of Subresource IntegrityGa dieper met de volledige API-referentie, webhookconfiguratie en geavanceerde gidsen.
Volledige API-referentie, integratiegidsen en best practices.
Realtime event-levering, payload-schema en handtekeningverificatie.
Configureer realtime eventmeldingen voor elke device-identificatie.
Voeg in minder dan 5 minuten device-fingerprinting toe aan je Node.js-applicatie.