Registry / security / express-auth-engine

express-auth-engine

JSON →
library1.0.3jsnpmunverified

Express Auth Engine is an authentication middleware library for Express.js applications, supporting JSON Web Token (JWT) based authentication with role-based access control. Currently at version 1.0.3, it provides a simple API for user authentication, token generation, and route protection. Differentiators include built-in support for multiple authentication strategies, token refresh, and easy integration with Express route handlers. The library is designed for Node.js and uses a middleware pattern to secure endpoints. It is released under the ISC license and requires express as a peer dependency.

npm install express-auth-engine
INSTALL
IMPORT
SIG · EXPRESS-AUTH-ENGIN
E
express-auth-engine
securityjavascriptv1.0.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

AuthEngine
import { AuthEngine } from 'express-auth-engine'
const AuthEngine = require('express-auth-engine')
ESM is primary; CJS require may not work with named exports
authenticate
import { authenticate } from 'express-auth-engine'
import authenticate from 'express-auth-engine'
Default import is not supported; use named import
requireAuth
import { requireAuth } from 'express-auth-engine'
const { requireAuth } = require('express-auth-engine')
Named export, not a default export

Basic Express app with login and protected route using AuthEngine.

import express from 'express'; import { AuthEngine, authenticate, requireAuth } from 'express-auth-engine'; const app = express(); const engine = new AuthEngine({ secret: process.env.JWT_SECRET ?? 'default-secret' }); app.post('/login', authenticate(engine, { strategy: 'local' }), (req, res) => { res.json({ token: req.user.token }); }); app.get('/protected', requireAuth(engine), (req, res) => { res.json({ message: 'Access granted', user: req.user }); }); app.listen(3000);
Debug
Known issues
breakingAPI changed from function-based to class-based in v1.0.0
fix
Use new AuthEngine() constructor instead of old createAuthEngine() function
affects: <1.0.0
deprecatedauthenticate middleware with 'basic' strategy is deprecated
fix
Use 'local' strategy instead
affects: >=1.0.3
gotchasecret must be at least 32 characters long, otherwise JWT signing fails silently
fix
Provide a secret of 32+ characters
affects: >=1.0.0
gotchaTokens are not automatically refreshed; you must implement refresh logic
fix
Use refreshToken method from AuthEngine instance
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'express-auth-engine'
Package not installed
fix
npm install express-auth-engine --save
TypeError: AuthEngine is not a constructor
Importing incorrectly as default import
fix
Use import { AuthEngine } from 'express-auth-engine'
TypeError: Cannot read property 'user' of undefined
Missing middleware before accessing req.user
fix
Add requireAuth middleware to the route
Upgrade
Version history
1.0.3latest on npm
Audit
Dependencies
expressrequiredPeer dependency required for middleware integration
Agent activity
23 hits · last 30 days
node
20
Amazon
1
Resources
express-auth-engine — npm install express-auth-engine · libregistry