Talon Auth works in Cloudflare Workers. Workers use the standard Web platform Request/Response API and export a fetch handler — the same interface as a browser service worker.
Install the package:
npm install talon-auth
Create a verifier with your app ID from the Talon dashboard:
import { createVerifier } from 'talon-auth'
const verifier = createVerifier({ appId: '[your-app-id]' })
Call verifier.verifyHeader() with the value of the Authorization header. Use req.headers.get('authorization') to read it from the Web-standard Headers object:
const { user } = await verifier.verifyHeader(req.headers.get('authorization')!)
The example below exports a fetch handler that Cloudflare Workers invokes for every request. The index route serves an HTML page with the <talon-login> component, and the /message route verifies the JWT and returns a greeting.