Node.js / TypeScript
The official Node.js SDK for OpenBotAuth signature verification.
Package: @openbotauth/verifier-client
Installation
# npm
npm install @openbotauth/verifier-client
# pnpm
pnpm add @openbotauth/verifier-client
# yarn
yarn add @openbotauth/verifier-clientRequirements: Node.js >= 18.0.0
Quick Start
Express Middleware
The fastest way to integrate is with the Express middleware:
import express from 'express';
import { openBotAuthMiddleware } from '@openbotauth/verifier-client/express';
const app = express();
// Add middleware (observe mode by default)
app.use(openBotAuthMiddleware());
app.get('/api/content', (req, res) => {
const oba = (req as any).oba;
if (oba.signed && oba.result?.verified) {
// Verified bot - full access
res.json({
content: 'Full article content...',
agent: oba.result.agent
});
} else {
// Anonymous or unverified - limited access
res.json({
content: 'Article preview...',
upgrade: 'Sign requests for full access'
});
}
});
app.listen(3000);Next.js App Router
For Next.js Server Components and Route Handlers:
Direct Client Usage
For custom integrations:
API Reference
VerifierClient
Main client class for calling the verifier service.
VerificationRequest
Request object sent to the verifier:
VerificationResult
Response from the verifier:
Middleware Options
OBAState
State attached to requests by middleware:
Header Utilities
Utility functions for working with RFC 9421 headers:
Security
Sensitive Headers
The SDK automatically blocks sensitive headers from being forwarded to the verifier:
cookieauthorizationproxy-authorizationwww-authenticate
If a Signature-Input references any of these headers, the request will be rejected.
Timeout Handling
All verification requests have a configurable timeout (default 5 seconds). On timeout, verification is treated as failed.
Middleware Modes
Observe Mode (Default)
All requests pass through regardless of verification status. Use this for:
Logging and analytics
Gradual rollout
A/B testing between verified and unverified access
Require-Verified Mode
Protected paths return 401 for unsigned or failed verification:
Error Handling
TypeScript Support
The package is written in TypeScript and exports all types:
Examples
Express with Custom Verifier
Next.js with Body Verification
Links
Last updated