Registry / security / mongo-passport-auth-lib

mongo-passport-auth-lib

JSON →
library0.0.60jsnpmunverified

Authentication library for serverless Netlify functions using MongoDB and Passport strategies. Current stable version v0.0.60 targets Node >=14.0.0 and provides session management via cookies, OAuth strategies, and token generation. Differentiators: purpose-built for Netlify's serverless environment with easy integration and no heavy frameworks.

npm install mongo-passport-auth-lib
INSTALL
IMPORT
SIG · MONGO-PASSPORT-AUT
M
mongo-passport-auth-lib
securityjavascriptv0.0.60
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.

default
import auth from 'mongo-passport-auth-lib'
const auth = require('mongo-passport-auth-lib')
Package uses default ESM export; do not destructure.
auth
import { auth } from 'mongo-passport-auth-lib'
const { auth } = require('mongo-passport-auth-lib')
Named export available from v0.0.50+; CommonJS require may fail.
passport
import passport from 'passport'
import { passport } from 'passport'
Passport is a default export, not named.

Shows basic usage: import default auth, connect Mongoose, authenticate with bearer token in Netlify function.

import auth from 'mongo-passport-auth-lib'; import mongoose from 'mongoose'; mongoose.connect(process.env.MONGO_URI ?? 'mongodb://localhost:27017/auth'); export const handler = async (event, context) => { const { user, token } = await auth.authenticate(event.headers.authorization); return { statusCode: 200, body: JSON.stringify({ user, token }) }; };
Debug
Known issues
breakingBreaking change in v0.0.50: auth.authenticate now returns object with user and token instead of just user
fix
Update call sites to destructure { user, token } from result.
affects: >=0.0.50 <0.0.60
deprecatedauth.verifySession is deprecated since v0.0.55; use auth.validateToken instead
fix
Replace verifySession calls with validateToken.
affects: >=0.0.55
deprecatedSupport for Node 12 removed; requires Node 14+
fix
Upgrade Node.js to version 14 or higher.
affects: >=0.0.60
Errors
Common errors & fixes
Error: Cannot find module 'passport'
passport not installed as dependency
fix
Run npm install passport
TypeError: auth.authenticate is not a function
Wrong import: destructured named export instead of default
fix
Use import auth from 'mongo-passport-auth-lib' (default) instead of import { auth } from ...
Upgrade
Version history
0.0.60latest on npm
Audit
Dependencies
passportrequiredAuthentication strategies
mongooserequiredMongoDB object modeling
expressrequiredHTTP request handling
Agent activity
7 hits · last 30 days
node
6
OpenAI (training)
1
Resources
mongo-passport-auth-lib — npm install mongo-passport-auth-lib · libregistry