{"id":21122,"library":"detexter-auth-kit","title":"JWT Auth Middleware Toolkit","description":"REWRITE: detexter-auth-kit v1.0.4 is a lightweight JWT authentication toolkit for Express.js, providing middleware and utilities for token signing, verification, and route protection. It uses the jsonwebtoken library under the hood. The package is currently in early stages with minimal configuration; future updates may include more robust options. Alternatives like express-jwt offer more features but are heavier. Release cadence is unknown.","status":"active","version":"1.0.4","language":"javascript","source_language":"en","source_url":null,"tags":["javascript"],"install":[{"cmd":"npm install detexter-auth-kit","lang":"bash","label":"npm"},{"cmd":"yarn add detexter-auth-kit","lang":"bash","label":"yarn"},{"cmd":"pnpm add detexter-auth-kit","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required for signToken and verifyToken functions","package":"jsonwebtoken","optional":false}],"imports":[{"note":"Named export, not default. CommonJS: const { authMiddleware } = require('detexter-auth-kit')","wrong":"import authMiddleware from 'detexter-auth-kit'","symbol":"authMiddleware","correct":"import { authMiddleware } from 'detexter-auth-kit'"},{"note":"Named export, works in both ESM and CJS","wrong":"const signToken = require('detexter-auth-kit').signToken","symbol":"signToken","correct":"import { signToken } from 'detexter-auth-kit'"},{"note":"Exact function name is verifyToken, not verify","wrong":"import { verify } from 'detexter-auth-kit'","symbol":"verifyToken","correct":"import { verifyToken } from 'detexter-auth-kit'"}],"quickstart":{"code":"import express from 'express';\nimport { authMiddleware, signToken, verifyToken } from 'detexter-auth-kit';\n\nconst app = express();\napp.use(express.json());\n\napp.post('/login', (req, res) => {\n  const payload = { id: 1, email: 'user@example.com' };\n  const token = signToken(payload, { secret: process.env.JWT_SECRET ?? 'fallback', expiresIn: '1h' });\n  res.json({ token });\n});\n\napp.get('/profile', authMiddleware({ secret: process.env.JWT_SECRET ?? 'fallback' }), (req, res) => {\n  res.json({ user: req.user });\n});\n\napp.listen(3000, () => console.log('Server running on port 3000'));","lang":"javascript","description":"Shows login token generation and protected route with middleware; includes secret from environment variable."},"warnings":[{"fix":"Use correct package name: require('detexter-auth-kit')","message":"Package name 'detexter-auth-kit' is not the same as 'express-auth-kit' used in README imports (require(\"express-auth-kit\") will fail).","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Store secret in process.env.JWT_SECRET and use it in options.","message":"The secret option in signToken and authMiddleware should not be hardcoded; use environment variables. Future versions may enforce this.","severity":"deprecated","affected_versions":">=0.0.0"},{"fix":"Implement your own error handling middleware to provide more context.","message":"Missing token in Authorization header results in 401 with generic error message; no custom error handling.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Ensure client sends 'Bearer' prefix.","message":"authMiddleware expects 'Authorization: Bearer <token>' header; other formats (e.g., 'token') are rejected.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Call authMiddleware({ secret: 'your-secret' }) or signToken(payload, { secret: 'your-secret' })","cause":"authMiddleware or signToken called without options object or missing secret property.","error":"TypeError: Cannot destructure property 'secret' of 'options' as it is undefined"},{"fix":"Provide a non-empty string as secret; check environment variable is set.","cause":"Secret is empty or undefined when calling signToken or verifyToken.","error":"Error: secretOrPrivateKey must have a value"},{"fix":"Ensure token is exactly the JWT string; remove any extra quotes or spaces.","cause":"Token string is corrupted, not a valid JWT, or contains extra whitespace.","error":"JsonWebTokenError: jwt malformed"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}