Skip to content

Commit

Permalink
Update .eslintrc and fix linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
davidpatrick committed Apr 6, 2021
1 parent b1bf933 commit d02f33b
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 11 deletions.
7 changes: 5 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
"space-before-blocks": [2, "always"]
},
"env": {
"node": true
}
"node": true,
"mocha": true,
"es6": true
},
"extends": "eslint:recommended"
}
4 changes: 2 additions & 2 deletions src/integrations/express.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ module.exports.expressJwtSecret = function (options) {
}

const client = new JwksClient(options);
const onError = options.handleSigningKeyError || handleSigningKeyError;
const onError = options.handleSigningKeyError || handleSigningKeyError;

return function secretProvider(req, header, payload, cb) {
if (!header || !supportedAlg.includes(header.alg)) {
if (!header || !supportedAlg.includes(header.alg)) {
return cb(null, null);
}

Expand Down
2 changes: 1 addition & 1 deletion src/integrations/hapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ module.exports.hapiJwt2Key = function (options) {
}

const client = new JwksClient(options);
const onError = options.handleSigningKeyError || handleSigningKeyError;
const onError = options.handleSigningKeyError || handleSigningKeyError;

return function secretProvider(decoded, cb) {
// We cannot find a signing certificate if there is no header (no kid).
Expand Down
6 changes: 4 additions & 2 deletions src/integrations/passport.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@ module.exports.passportJwtSecret = function (options) {
}

const client = new JwksClient(options);
const onError = options.handleSigningKeyError || handleSigningKeyError;
const onError = options.handleSigningKeyError || handleSigningKeyError;

return function secretProvider(req, rawJwtToken, cb) {
let decoded;
try {
decoded = JWT.decode(rawJwtToken, { complete: true });
} catch (err) {}
} catch (err) {
decoded = null;
}

if (!decoded || !supportedAlg.includes(decoded.header.alg)) {
return cb(null, null);
Expand Down
1 change: 0 additions & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const jose = require('jose');
const JwksError = require('./errors/JwksError');

function retrieveSigningKeys(keys) {
const keystore = jose.JWKS.asKeyStore({ keys }, { ignoreErrors: true });
Expand Down
2 changes: 1 addition & 1 deletion src/wrappers/cache.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const debug = require('debug');
const memoizer = require('lru-memoizer');

function cacheWrapper(client, { cacheMaxEntries = 5, cacheMaxAge = 600000 } = options) {
function cacheWrapper(client, { cacheMaxEntries = 5, cacheMaxAge = 600000 }) {
const logger = debug('jwks');
logger(`Configured caching of signing keys. Max: ${cacheMaxEntries} / Age: ${cacheMaxAge}`);
return memoizer.sync({
Expand Down
2 changes: 1 addition & 1 deletion src/wrappers/interceptor.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const retrieveSigningKeys = require('../utils').retrieveSigningKeys;
* Uses getKeysInterceptor to allow users to retrieve keys from a file,
* external cache, or provided object before falling back to the jwksUri endpoint
*/
function getKeysInterceptor(client, { getKeysInterceptor } = options) {
function getKeysInterceptor(client, { getKeysInterceptor }) {
const getSigningKey = client.getSigningKey.bind(client);

return async (kid) => {
Expand Down
2 changes: 1 addition & 1 deletion src/wrappers/rateLimit.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const { RateLimiter } = require('limiter');

const JwksRateLimitError = require('../errors/JwksRateLimitError');

function rateLimtWrapper(client, { jwksRequestsPerMinute = 10 } = options) {
function rateLimtWrapper(client, { jwksRequestsPerMinute = 10 }) {
const logger = debug('jwks');
const getSigningKey = client.getSigningKey.bind(client);

Expand Down

0 comments on commit d02f33b

Please sign in to comment.