Authentication and authorization library with JWT access/refresh token model, token rotation, and instant session revocation. Current stable version 1.6.7. Released as needed. Key differentiators: in-memory cache for revocation, total data control via exported TypeORM entities, originally built as Auth0 replacement. However, not recommended for production; uses JWT with server-side session invalidation. Ships TypeScript types.
npm install protonfile-authNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Initialize auth, protect an Express route with AuthMiddleware, and revoke a session on logout.
After server restart, consider waiting for cache warm-up or manually loading revoked tokens from the database before accepting requests.
Use initAuth({ jwtSecret, database: { type, url } }) instead of initAuth({ jwtSecret }, dbConnection).Consider using OAuth2 or a session-based solution like express-session with a secure store.
If you need different expiration, fork the library or modify the source code.
Ensure AuthMiddleware is used on the route: app.get('/protected', AuthMiddleware, handler);Set JWT_SECRET in environment or pass it to initAuth: await initAuth({ jwtSecret: 'your-secret' });Add RefreshToken entity to your TypeORM connection configuration if using a custom connection.
Use import statements or if using require, do: const { AuthMiddleware } = require('protonfile-auth'); (but ensure your project supports ESM).