Skip to content

Commit

Permalink
refactor: use Set for static list lookups
Browse files Browse the repository at this point in the history
  • Loading branch information
panva committed Jul 16, 2018
1 parent afe0ee1 commit 7e4e185
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/actions/introspection.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const bodyParser = require('../shared/selective_body');
const rejectDupes = require('../shared/reject_dupes');
const getParams = require('../shared/assemble_params');

const introspectable = ['AccessToken', 'ClientCredentials', 'RefreshToken'];
const introspectable = new Set(['AccessToken', 'ClientCredentials', 'RefreshToken']);
const PARAM_LIST = new Set(['token', 'token_type_hint', ...tokenAuth.AUTH_PARAMS]);

module.exports = function introspectionAction(provider) {
Expand Down Expand Up @@ -116,7 +116,7 @@ module.exports = function introspectionAction(provider) {
}
}

if (introspectable.includes(token.kind)) {
if (introspectable.has(token.kind)) {
ctx.oidc.entity(token.kind, token);
} else {
return;
Expand Down
4 changes: 2 additions & 2 deletions lib/actions/revocation.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const bodyParser = require('../shared/selective_body');
const rejectDupes = require('../shared/reject_dupes');
const getParams = require('../shared/assemble_params');

const revokeable = ['AccessToken', 'ClientCredentials', 'RefreshToken'];
const revokeable = new Set(['AccessToken', 'ClientCredentials', 'RefreshToken']);
const PARAM_LIST = new Set(['token', 'token_type_hint', ...tokenAuth.AUTH_PARAMS]);

module.exports = function revocationAction(provider) {
Expand Down Expand Up @@ -104,7 +104,7 @@ module.exports = function revocationAction(provider) {

if (!token) return;

if (revokeable.includes(token.kind)) {
if (revokeable.has(token.kind)) {
ctx.oidc.entity(token.kind, token);
} else {
return;
Expand Down

0 comments on commit 7e4e185

Please sign in to comment.