Registry / security / propro-utils

propro-utils

JSON →
library1.7.53jsnpmunverified

propro-utils is a comprehensive Node.js middleware for authentication, authorization, and utility functions in Express applications, version 1.7.53. It provides server-side and client-side authentication, profile management (password, email, 2FA, avatar), token refresh, logout, and app settings routes. Unlike generic auth middleware, it integrates tightly with propro-auth and offers a configurable options object. Released under ISC license, maintained by ProPro Productions.

npm install propro-utils
INSTALL
IMPORT
SIG · PROPRO-UTILS
P
propro-utils
securityjavascriptv1.7.53
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.

AuthMiddleware
const AuthMiddleware = require('propro-utils');
import AuthMiddleware from 'propro-utils';
Package uses CommonJS; ESM import may cause errors without bundler.
AuthMiddleware
import AuthMiddleware from 'propro-utils';
ESM import works if project is configured for ESM (type: 'module' in package.json) and bundler resolves CJS.
default
const AuthMiddleware = require('propro-utils').default;
const AuthMiddleware = require('propro-utils');
Some versions may export as default; check local behavior.

Sets up Express app with propro-utils authentication middleware using options from environment variables.

const express = require('express'); const AuthMiddleware = require('propro-utils'); const userSchema = require('./models/user'); const app = express(); const authOptions = { authUrl: process.env.AUTH_URL || 'https://auth.example.com', clientId: process.env.CLIENT_ID || 'my-client', clientSecret: process.env.CLIENT_SECRET || 'secret', clientUrl: process.env.CLIENT_URL || 'https://myapp.com', redirectUri: process.env.REDIRECT_URI || 'https://myapp.com/callback', appName: process.env.APP_NAME || 'MyApp', appUrl: process.env.APP_URL || 'https://myapp.com', }; const authMiddleware = new AuthMiddleware(authOptions, userSchema); app.use(authMiddleware.middleware()); app.get('/', (req, res) => { res.send('Hello, authenticated user!'); }); app.listen(3000, () => console.log('Server running on port 3000'));
Debug
Known issues
breakingIn version 1.x, the middleware() method may be called without new if not using constructor correctly.
fix
Always instantiate with 'new' or use a factory if provided.
affects: >=1.0.0 <2.0.0
deprecatedThe default secret 'RESTFULAPIs' is used if 'secret' option is omitted, which is insecure.
fix
Explicitly set 'secret' option to a strong, environment-specific value.
affects: >=1.0.0
gotchaThe userSchema parameter is required but not validated; passing undefined will cause runtime errors.
fix
Always provide a valid Mongoose-like user schema (object with find method).
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: AuthMiddleware is not a constructor
CommonJS import without proper default export detection, or using ESM import incorrectly.
fix
Ensure you use `const AuthMiddleware = require('propro-utils').default;` if package exports as default, or check the module's export structure.
Error: Cannot find module 'jsonwebtoken'
Missing peer dependency jsonwebtoken.
fix
Install jsonwebtoken: `npm install jsonwebtoken` or `yarn add jsonwebtoken`.
TypeError: Cannot read property 'find' of undefined
userSchema was not passed or is undefined when calling AuthMiddleware constructor.
fix
Ensure you pass a valid user schema object as the second argument.
Upgrade
Version history
1.7.53latest on npm
Audit
Dependencies
expressrequiredMiddleware is designed for Express applications
jsonwebtokenrequiredUsed for token generation and verification
Agent activity
15 hits · last 30 days
node
14
OpenAI (training)
1
Resources
propro-utils — npm install propro-utils · libregistry