Registry / security / vintage-auth

vintage-auth

JSON →
library1.0.7jsnpmunverified

vintage-auth v1.0.7 is a drop-in authentication system for Express.js applications, providing JWT-based authentication with MongoDB as the backing store. It offers pre-built routes for signup, login, and logout, session management via HTTP-only cookies, and middleware for protecting routes. The package is designed to minimize boilerplate for common Express auth workflows but offers limited customization compared to alternatives like Passport.js. Release cadence is irregular with no recent updates, suggesting potential stability risks. Compatible with Express 4.x, it assumes MongoDB and Mongoose as the ORM.

npm install vintage-auth
INSTALL
IMPORT
SIG · VINTAGE-AUTH
V
vintage-auth
securityjavascriptv1.0.7
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.

vintageAuth
import vintageAuth from 'vintage-auth'
const vintageAuth = require('vintage-auth')
Package is ESM-only; CommonJS require will fail.
protect
import { protect } from 'vintage-auth'
const { protect } = require('vintage-auth')
Named export; CommonJS destructuring will throw.
configAuth
import { configAuth } from 'vintage-auth'
const configAuth = require('vintage-auth').configAuth
Named export for custom configuration; avoid default import confusion.

Initializes vintage-auth with default settings, adds auth routes and protects a GET endpoint.

import express from 'express'; import mongoose from 'mongoose'; import vintageAuth from 'vintage-auth'; const app = express(); app.use(express.json()); mongoose.connect(process.env.MONGO_URI ?? 'mongodb://localhost:27017/test') .then(() => console.log('MongoDB connected')) .catch(err => console.error(err)); app.use(vintageAuth()); app.get('/protected', (req, res) => { res.json({ user: req.user }); }); app.listen(3000, () => console.log('Server running on port 3000'));
Debug
Known issues
breakingv1.0.0 changed the default export from a function that returns middleware to a class with static methods; old `app.use(vintageAuth)` no longer works.
fix
Update to `import vintageAuth from 'vintage-auth'` then `app.use(vintageAuth())` (call it as a function).
affects: <1.0.0
deprecatedThe `vintageAuth.authenticate` method has been deprecated in v1.0.5 in favor of the `protect` middleware.
fix
Replace `vintageAuth.authenticate` with `import { protect } from 'vintage-auth'` and use as middleware.
affects: >=1.0.5
gotchaPackage expects `Mongoose` to be connected before calling `vintageAuth()` — order matters. If you call `vintageAuth()` before Mongoose is connected, internal user model creation will fail.
fix
Ensure `mongoose.connect()` completes (await or then) before `app.use(vintageAuth())`.
affects: >=1.0.0
gotchaThe `User` model is automatically created with a fixed schema; customizing user fields requires passing a custom schema to `configAuth()` before calling `vintageAuth()`, otherwise extra fields are silently ignored.
fix
Use `import { configAuth } from 'vintage-auth'` to define custom user schema fields.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: vintageAuth is not a function
Using CommonJS `require()` on an ESM-only package.
fix
Use `import vintageAuth from 'vintage-auth'` in an ESM project, or add `"type": "module"` to package.json.
MongooseError: Mongoose is not connected
Calling `vintageAuth()` before Mongoose connection is established.
fix
Await `mongoose.connect()` before using vintageAuth middleware.
Auth route POST /auth/login returns 404
The middleware `app.use(vintageAuth())` not added before the routes that need auth.
fix
Ensure `app.use(vintageAuth())` is placed before protected routes.
Upgrade
Version history
1.0.7latest on npm
Audit
Dependencies
expressrequiredPeer dependency — requires Express.js for routing and middleware
mongooserequiredPeer dependency — uses Mongoose for MongoDB interactions
Agent activity
18 hits · last 30 days
node
16
OpenAI (training)
1
Resources
vintage-auth — npm install vintage-auth · libregistry