@kothatech/auth-node
v1.0.2
Published
Node.js SDK for verifying Kotha OIDC JWTs
Downloads
48
Readme
@kothatech/auth-node
The official Node.js SDK for verifying OIDC JSON Web Tokens (JWTs) generated by the Kotha Auth Platform.
Installation
npm install @kothatech/auth-nodeUsage
const express = require('express');
const { KothaAuthNode } = require('@kothatech/auth-node');
const app = express();
const kothaAuth = new KothaAuthNode({
issuer: 'https://auth.kotha.im' // Or http://localhost:4000 for local dev
});
// Protect a route
app.get('/api/protected', kothaAuth.expressMiddleware({ audience: 'app_your_client_id' }), (req, res) => {
// req.user contains the decoded JWT payload
res.json({ message: 'Success!', user: req.user });
});
app.listen(3000, () => console.log('Listening on port 3000'));Features
- Automatic JWKS Caching: Automatically fetches and caches the JSON Web Key Set (JWKS) from Kotha's
/.well-known/jwks.jsonendpoint to verify JWT signatures. - Express Middleware: Ready-to-use middleware for protecting Express routes.
- Standalone Verification: Use
kothaAuth.verifyToken(token)to manually verify tokens in other frameworks like Fastify, NestJS, or Next.js API Routes.
