Registry / auth-security / restify-jwt-community

restify-jwt-community

JSON →
library2.0.0jsnpmunverified

JWT authentication middleware for Restify, current stable version 2.0.0 (released 2023-03-27). This community-maintained fork validates JSON Web Tokens and sets req.user on incoming requests. It builds on auth0/express-jwt and the original restify-jwt, but uses restify's built-in error objects. Maintenance cadence is low (last release v2.0.0, prior updates were mostly lockfile maintenance). Compared to express-jwt, this is tailored specifically for Restify and uses restify errors.

npm install restify-jwt-community
INSTALL
IMPORT
SIG · RESTIFY-JWT-COMMUN
R
restify-jwt-community
auth-securityjavascriptv2.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

jwt
import jwt from 'restify-jwt-community'
const jwt = require('restify-jwt-community').default
Default import; common mistake is to use .default when importing in CommonJS.
jwt
const jwt = require('restify-jwt-community')
CommonJS require returns the default export directly, no .default needed.
UnauthorizedError
import { UnauthorizedError } from 'restify-jwt-community'
const UnauthorizedError = require('restify-jwt-community').UnauthorizedError
Named export; ensure correct casing (UnauthorizedError, not unauthorizedError).

Basic setup of Restify server with JWT middleware for a protected route.

import restify from 'restify'; import jwt from 'restify-jwt-community'; const server = restify.createServer(); server.use(restify.plugins.bodyParser()); server.use(jwt({ secret: process.env.JWT_SECRET || 'your-secret-key' })); server.get('/protected', (req, res, next) => { res.send(200, { user: req.user }); return next(); }); server.listen(3000, () => { console.log('Server listening on port 3000'); });
Debug
Known issues
gotchaFailing to call next() after res.send may cause hanging requests
fix
Ensure you call return next() after res.send() in route handlers.
affects: >=1.0.0
gotchaThe middleware requires a restify server; do not use with Express or other frameworks
fix
Check that you are using restify, not express. This package is incompatible with Express.
affects: >=1.0.0
gotchaThe middleware will throw if no secret is provided
fix
Always provide a secret or a function that returns a secret to jwt().
affects: >=1.0.0
Errors
Common errors & fixes
Error: secret must be provided
No secret was passed to the jwt middleware.
fix
Pass a secret or a function returning a secret: jwt({ secret: 'my-secret' })
TypeError: restify_jwt_community_1.default is not a function
Using ES6 import syntax with CommonJS require incorrectly.
fix
Use correct import: import jwt from 'restify-jwt-community' or const jwt = require('restify-jwt-community')
UnauthorizedError: No authorization token was found
Request did not include an Authorization header with a Bearer token.
fix
Include an Authorization header with value 'Bearer <token>' in the request.
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies
jsonwebtokenrequiredCore dependency for verifying and decoding JWT tokens
restifyrequiredPeer dependency; the middleware is designed to work with Restify
Agent activity
12 hits · last 30 days
node
10
OpenAI (training)
1
Resources
restify-jwt-community — npm install restify-jwt-community · libregistry