Registry / security / tria-auth-core

tria-auth-core

JSON →
library1.1.0jsnpmunverified

tria-auth-core v1.1.0 provides shared JWT and Redis session authentication middleware for Express.js applications. It ships with TypeScript types and requires express >=4.18.0. Unlike generic auth libraries, it combines JWT stateless tokens with Redis-backed sessions for session revocation and blacklisting, supporting both auth patterns in a single package.

npm install tria-auth-core
INSTALL
IMPORT
SIG · TRIA-AUTH-CORE
T
tria-auth-core
securityjavascriptv1.1.0
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.

authenticate
import { authenticate } from 'tria-auth-core'
const authenticate = require('tria-auth-core').authenticate
ESM import; CJS require works but TypeScript usage prefers ESM.
authorize
import { authorize } from 'tria-auth-core'
import authorize from 'tria-auth-core'
authorize is a named export, not default.
TriaAuthOptions
import type { TriaAuthOptions } from 'tria-auth-core'
import { TriaAuthOptions } from 'tria-auth-core'
Use type import for TypeScript; TriaAuthOptions is a type, not a value.

Sets up Express with JWT authentication and role-based authorization middleware using tria-auth-core.

import express from 'express'; import { authenticate, authorize } from 'tria-auth-core'; const app = express(); app.use(authenticate({ secret: process.env.JWT_SECRET ?? '', redisUrl: process.env.REDIS_URL ?? '' })); app.get('/protected', authorize(['admin']), (req, res) => { res.json({ message: 'You are authorized!' }); }); app.listen(3000, () => console.log('Server running'));
Debug
Known issues
gotchaEnsure Redis is running and accessible; otherwise authenticate will fail silently.
fix
Add Redis connection check before starting Express server.
affects: >=1.0.0
deprecatedIn version 1.1.0, the 'scope' option in authenticate() is deprecated in favor of 'roles'.
fix
Use 'roles' instead of 'scope' in authenticate options.
affects: >=1.1.0
breakingFrom version 2.0.0, the package will require Node.js >=18 and drop CommonJS support.
fix
Migrate to ESM imports; update Node.js to >=18.
affects: <2.0.0
Errors
Common errors & fixes
Error: secret is required
Missing JWT_SECRET environment variable or not passed to authenticate
fix
Set JWT_SECRET in environment or pass secret directly in options.
TypeError: Cannot read properties of undefined (reading 'split')
Authorization header missing or malformed
fix
Ensure client sends 'Authorization: Bearer <token>' header.
Redis connection refused
Redis server not running or incorrect REDIS_URL
fix
Start Redis server or update REDIS_URL env variable.
Upgrade
Version history
1.1.0latest on npm
Audit
Dependencies
expressrequiredpeer dependency for middleware integration
Agent activity
20 hits · last 30 days
node
18
OpenAI (training)
1
Resources
tria-auth-core — npm install tria-auth-core · libregistry