All articles Integration

Angular Device Fingerprinting with a Prynt Service

Angular’s dependency injection is built for exactly this kind of cross-cutting concern: a single service that any component can ask for a device signal. Adding device intelligence gives your app a stable visitor ID and a bot score so you can separate real users from automation.

This guide wraps Prynt in an injectable service, exposes identification as a promise, and verifies the result server-side before it influences any decision. The same service works in an auth guard, an HTTP interceptor, or a checkout component, so you write the integration once and reuse it wherever a decision needs a device signal.

Wrap the agent in a root service

A root-provided service loads the agent once for the whole app. Components inject it instead of touching the agent directly. The service adds Prynt’s browser agent from the CDN, which defines a global Prynt.

Packages: Prynt’s npm package is coming. Until then, use the CDN script and the plain REST calls below; they work today.

import { Injectable } from '@angular/core'
import { environment } from '../environments/environment'

declare global {
  interface Window { Prynt: { load(config: Record<string, unknown>): Promise<any> } }
}

@Injectable({ providedIn: 'root' })
export class PryntService {
  private agent?: Promise<any>

  // Loads Prynt's browser agent from the CDN once and reuses it.
  init(): Promise<any> {
    this.agent ??= new Promise((resolve, reject) => {
      const s = document.createElement('script')
      s.src = 'https://api.pryntid.com/cdn/prynt.umd.js'
      s.async = true
      s.onload = () => resolve(window.Prynt.load({
        apiKey: environment.pryntKey,   // your public key (pk_live_…)
        endpoint: 'https://api.pryntid.com',
        extendedResult: true
      }))
      s.onerror = () => { this.agent = undefined; reject(new Error('Prynt agent failed to load')) }
      document.head.appendChild(s)
    })
    return this.agent
  }

  async identify(action: string): Promise<string> {
    const agent = await this.init()
    const result = await agent.identify({ tag: { action } })
    return result.requestId
  }
}

Call init() once from your root component’s ngOnInit to warm it up; identify() also loads it on first use. Loading is asynchronous, so it never blocks the first render. The service touches document, so if you use Angular SSR, call it only in the browser (for example after afterNextRender or behind isPlatformBrowser).

Identify at decision points

Inject the service where a decision happens, not everywhere. A login component asks for the requestId on submit and sends it with the credentials.

export class LoginComponent {
  constructor(private prynt: PryntService, private http: HttpClient) {}

  async onSubmit(form: any) {
    const pryntId = await this.prynt.identify('login')
    this.http.post('/api/login', { ...form, pryntId })
      .subscribe(res => { /* handle result */ })
  }
}

The component collects the signal; it never decides on it. That happens on the server.

Verify the event on your backend

Look the event up with your secret key and branch on the confidence score and bot result. This is the only trustworthy source.

// Node backend (Node 18+, fetch is built in)
const r = await fetch(
  `https://api.pryntid.com/v1/events/${encodeURIComponent(pryntId)}`,
  { headers: { Authorization: `Bearer ${process.env.PRYNT_SECRET_KEY}` } }
)
if (!r.ok) {
  // 404 = unknown requestId, 401 = bad secret key
  return res.status(400).send({ error: 'could not verify device' })
}
const event = await r.json()
if (event.decision === 'block' || event.smartSignals?.bot?.result) {
  return res.status(403).send({ error: 'blocked' })
}
if (event.confidence.score < 0.5) {
  return res.status(401).send({ error: 'step-up required' })
}

Store event.visitorId against the account so repeated devices behind different logins become visible. The complete field reference is in the server-side verification docs.

A common mistake is to verify once at login and never again. Instead, treat the visitor ID as a session-long attribute: attach it to sensitive actions like password changes or payouts and re-check the score at each one. An account can be legitimate at sign-in and compromised an hour later, and the device signal is often the first place that shift shows up. An Angular HTTP interceptor is a clean place to attach the latest event ID to outbound requests without touching every component.

Guard forms directly

For signup or contact forms, let Form Shield watch the element and add behavioral signals for scripted fills.

const agent = await this.prynt.init()
const form = document.querySelector('#signup') as HTMLFormElement
agent.protectForm(form, {
  autoGuard: true,
  expectedScripts: ['latin']
})

expectedScripts flags submissions in unexpected writing systems, a low-cost spam signal for Latin-script audiences. It pairs well with server verification: one watches behavior, the other confirms identity.

Branch on the score, do not just block

Use the score to route users: clean sessions pass, borderline ones get a challenge or verification email. Because Prynt runs as a managed cloud service, geolocation, ASN, proxy, and bot detection all arrive without infrastructure on your side, and the free tier covers early traffic while you validate the integration.

Provision a key, add the service, and wire verification into your API. See the pricing and free plan to get started, and your Angular app will have dependable device signals feeding every sensitive flow.

Try it free

Prynt is device intelligence with a free plan: 5,000 identifications a month, visitor IDs with confidence and bot detection — no credit card. Upgrade to Pro for VPN, proxy, tampering and behavioral signals.

Keep reading