diff --git a/.eslintignore b/.eslintignore index 1fda7392..4e3ef646 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,3 +1,4 @@ .git coverage/ -node_modules/ \ No newline at end of file +node_modules/ +var/ diff --git a/.eslintrc.js b/.eslintrc.js index b69e83d6..8b4dc4ae 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,24 +1,109 @@ module.exports = { env: { - // jest: true, - mocha: true, node: true, + browser: false }, extends: [ - 'airbnb-base', + 'ash-nazg/sauron-node', + // Override ash-nazg's current preference for ESM + 'plugin:node/recommended-script' ], + overrides: [ + { + files: ['test/**'], + env: { + // jest: true, + mocha: true + }, + globals: { + expect: 'readonly' + }, + rules: { + 'jsdoc/require-jsdoc': 'off' + // 'jest/no-disabled-tests': [2], + // 'jest/no-focused-tests': [2], + // 'jest/no-identical-title': [2], + // 'jest/prefer-to-have-length': [2], + // 'jest/valid-expect': [2], + } + }, + { + files: ['**/*.md'], + rules: { + 'eol-last': 'off', + 'no-console': 'off', + 'no-undef': 'off', + 'no-unused-vars': 'warn', + 'padded-blocks': 'off', + 'import/unambiguous': 'off', + 'import/no-unresolved': 'off', + 'node/no-missing-import': 'off', + 'node/no-missing-require': 'off', + 'func-names': 'off', + 'import/newline-after-import': 'off', + strict: 'off', + // Disable until eslint-plugin-jsdoc may fix: https://github.com/gajus/eslint-plugin-jsdoc/issues/211 + indent: 'off' + } + } + ], + globals: { + // By some ESLint bug, config overrides not working with globals + require: 'readonly', + module: 'readonly', + exports: 'writable' + }, plugins: [ // 'jest' ], rules: { - "comma-dangle": 0, - "no-underscore-dangle": 0, - "no-param-reassign": 0, - "prefer-destructuring": 0, - // 'jest/no-disabled-tests': [2], - // 'jest/no-focused-tests': [2], - // 'jest/no-identical-title': [2], - // 'jest/prefer-to-have-length': [2], - // 'jest/valid-expect': [2], + 'comma-dangle': 0, + 'no-underscore-dangle': 0, + 'no-param-reassign': 0, + + // Disable until implementing promises and Node version supporting + 'promise/prefer-await-to-callbacks': 0, + 'promise/prefer-await-to-then': 0, + + // Disable until ready to tackle + 'require-jsdoc': 0, + + // Disable current preferences of ash-nazg + 'import/no-commonjs': 0, + 'node/exports-style': 0, + + // add back different or stricter rules from airbnb + 'object-curly-spacing': ['error', 'always'], + 'func-names': 'warn', + 'max-len': ['error', 100, 2, { + ignoreUrls: true, + ignoreComments: false, + ignoreRegExpLiterals: true, + ignoreStrings: true, + ignoreTemplateLiterals: true, + }], + 'space-before-function-paren': ['error', { + anonymous: 'always', + named: 'never', + asyncArrow: 'always' + }], + 'no-multiple-empty-lines': ['error', { max: 2, maxEOF: 0 }], + 'arrow-parens': ['error', 'as-needed', { + requireForBlockBody: true, + }], + 'no-empty-function': ['error', { + allow: [ + 'arrowFunctions', + 'functions', + 'methods', + ] + }], + 'no-unused-vars': ['error', { vars: 'all', args: 'after-used', ignoreRestSiblings: true }], + 'no-multi-assign': ['error'], + 'no-unused-expressions': ['error', { + allowShortCircuit: false, + allowTernary: false, + allowTaggedTemplates: false, + }] } - }; \ No newline at end of file + }; diff --git a/.gitignore b/.gitignore index e705ba7d..0cf4fbc1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ docs/ reports/ +var/ # Mac OS X .DS_Store diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index f1149ee7..00000000 --- a/.jshintrc +++ /dev/null @@ -1,18 +0,0 @@ -{ - "node": true, - "bitwise": true, - "camelcase": true, - "curly": true, - "forin": true, - "immed": true, - "latedef": true, - "newcap": true, - "noarg": true, - "noempty": true, - "nonew": true, - "quotmark": "single", - "undef": true, - "unused": true, - "trailing": true, - "laxcomma": true -} diff --git a/.npmignore b/.npmignore index aec28b93..8e3eed16 100644 --- a/.npmignore +++ b/.npmignore @@ -5,8 +5,8 @@ docs/ examples/ reports/ test/ +var/ .github/ -.jshintrc .travis.yml .gitlab-ci.yml diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4e251e8c..74d066dc 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,6 +1,6 @@ ## Contributing -Pull Requests are welcome for any issues, if you have any questions please +Pull Requests are welcome for any issues, if you have any questions please [raise an issue](https://github.com/passport-next/passport/issues). If you discover a security issue please create an issue stating you've discovered a security diff --git a/Makefile b/Makefile index d148666d..d096498a 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ view-docs: open ./docs/index.html view-cov: - open ./reports/coverage/lcov-report/index.html + open ./var/cov/index.html clean: clean-docs clean-cov -rm -r $(REPORTSDIR) diff --git a/README.md b/README.md index 45b91bc4..39a2f69b 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ Passport Next aims to: * Follow [Semantic Versioning](https://semver.org/) * Keep an up to date CHANGELOG.md -**Passport Next does not aim to be backwards compatible with the upstream repositories. +**Passport Next does not aim to be backwards compatible with the upstream repositories. The changes required to keep up to date and functioning prohibit that so if you're migrating from the upstream modules please test your code thouroughly!** @@ -62,8 +62,8 @@ application must be configured. ```javascript passport.use(new LocalStrategy( - function(username, password, done) { - User.findOne({ username: username }, function (err, user) { + function (username, password, done) { + User.findOne({ username }, function (err, user) { if (err) { return done(err); } if (!user) { return done(null, false); } if (!user.verifyPassword(password)) { return done(null, false); } @@ -88,11 +88,11 @@ as simple as serializing the user ID, and finding the user by ID when deserializing. ```javascript -passport.serializeUser(function(user, done) { +passport.serializeUser(function (user, done) { done(null, user.id); }); -passport.deserializeUser(function(id, done) { +passport.deserializeUser(function (id, done) { User.findById(id, function (err, user) { done(err, user); }); @@ -108,8 +108,8 @@ persistent login sessions (recommended, but not required), `passport.session()` middleware must also be used. ```javascript -var app = express(); -app.use(require('serve-static')(__dirname + '/../../public')); +const app = express(); +app.use(require('serve-static')(path.join(__dirname, '/../../public'))); app.use(require('cookie-parser')()); app.use(require('body-parser').urlencoded({ extended: true })); app.use(require('express-session')({ secret: 'keyboard cat', resave: true, saveUninitialized: true })); @@ -123,31 +123,31 @@ Passport provides an `authenticate()` function, which is used as route middleware to authenticate requests. ```javascript -app.post('/login', +app.post('/login', passport.authenticate('local', { failureRedirect: '/login' }), - function(req, res) { + function (req, res) { res.redirect('/'); }); ``` #### Protect Routes When Using Sessions -Passport provides an `isAuthenticated()` function on the request object, which -is used to determine if the user has been authenticated and stored in the +Passport provides an `isAuthenticated()` function on the request object, which +is used to determine if the user has been authenticated and stored in the session. ```javascript -app.post('/some/protected/route', - function(req, res, next) { - if(req.isAuthenticated()){ +app.post('/some/protected/route', + function (req, res, next) { + if (req.isAuthenticated()) { next(); - } else { - next(new Error('Unauthorized')); + return; } + next(new Error('Unauthorized')); }); ``` -For a more complete solution to handling unauthenticated users, see +For a more complete solution to handling unauthenticated users, see [connect-ensure-login](https://github.com/jaredhanson/connect-ensure-login), a middleware to ensure login sessions. @@ -162,16 +162,16 @@ There is a **Strategy Search** at [passportjs.org](http://passportjs.org) The following table lists commonly used strategies: -|Strategy | Protocol |Developer | +|Strategy | Protocol |Developer | |---------------------------------------------------------------|--------------------------|------------------------------------------------| -|[Local](https://github.com/jaredhanson/passport-local) | HTML form |[Jared Hanson](https://github.com/jaredhanson) | -|[OpenID](https://github.com/jaredhanson/passport-openid) | OpenID |[Jared Hanson](https://github.com/jaredhanson) | -|[BrowserID](https://github.com/jaredhanson/passport-browserid) | BrowserID |[Jared Hanson](https://github.com/jaredhanson) | -|[Facebook](https://github.com/jaredhanson/passport-facebook) | OAuth 2.0 |[Jared Hanson](https://github.com/jaredhanson) | -|[Google](https://github.com/jaredhanson/passport-google) | OpenID |[Jared Hanson](https://github.com/jaredhanson) | -|[Google](https://github.com/jaredhanson/passport-google-oauth) | OAuth / OAuth 2.0 |[Jared Hanson](https://github.com/jaredhanson) | -|[Twitter](https://github.com/jaredhanson/passport-twitter) | OAuth |[Jared Hanson](https://github.com/jaredhanson) | -|[Azure Active Directory](https://github.com/AzureAD/passport-azure-ad) | OAuth 2.0 / OpenID / SAML |[Azure](https://github.com/azuread) | +|[Local](https://github.com/jaredhanson/passport-local) | HTML form |[Jared Hanson](https://github.com/jaredhanson)| +|[OpenID](https://github.com/jaredhanson/passport-openid) | OpenID |[Jared Hanson](https://github.com/jaredhanson)| +|[BrowserID](https://github.com/jaredhanson/passport-browserid) | BrowserID |[Jared Hanson](https://github.com/jaredhanson)| +|[Facebook](https://github.com/jaredhanson/passport-facebook) | OAuth 2.0 |[Jared Hanson](https://github.com/jaredhanson)| +|[Google](https://github.com/jaredhanson/passport-google) | OpenID |[Jared Hanson](https://github.com/jaredhanson)| +|[Google](https://github.com/jaredhanson/passport-google-oauth) | OAuth / OAuth 2.0 |[Jared Hanson](https://github.com/jaredhanson)| +|[Twitter](https://github.com/jaredhanson/passport-twitter) | OAuth |[Jared Hanson](https://github.com/jaredhanson)| +|[Azure Active Directory](https://github.com/AzureAD/passport-azure-ad)|OAuth 2.0 / OpenID / SAML|[Azure](https://github.com/azuread) | ## Examples diff --git a/lib/authenticator.js b/lib/authenticator.js index 913df9a9..e0f9b443 100644 --- a/lib/authenticator.js +++ b/lib/authenticator.js @@ -1,485 +1,493 @@ +'use strict'; + /** * Module dependencies. */ -/* eslint-disable no-underscore-dangle, camelcase, no-proto, no-shadow */ - const SessionStrategy = require('./strategies/session'); const SessionManager = require('./sessionmanager'); const connect = require('./framework/connect'); /** - * `Authenticator` constructor. - * - * @api public - */ -function Authenticator() { - this._key = 'passport'; - this._strategies = {}; - this._serializers = []; - this._deserializers = []; - this._infoTransformers = []; - this._framework = null; - this._userProperty = 'user'; - - this.init(); -} - -/** - * Initialize authenticator. - * - * @api protected - */ -Authenticator.prototype.init = function init() { - this.framework(connect()); - this.use(new SessionStrategy(this.deserializeUser.bind(this))); - this._sm = new SessionManager({ key: this._key }, this.serializeUser.bind(this)); -}; - -/** - * Utilize the given `strategy` with optional `name`, overridding the strategy's - * default name. - * - * Examples: + * The `Authenticator` constructor. * - * passport.use(new TwitterStrategy(...)); - * - * passport.use('api', new http.BasicStrategy(...)); - * - * @param {String|Strategy} name - * @param {Strategy} strategy - * @return {Authenticator} for chaining - * @api public + * @public */ -Authenticator.prototype.use = function use(name, strategy) { - if (!strategy) { - strategy = name; - name = strategy.name; +class Authenticator { + constructor() { + this._key = 'passport'; + this._strategies = {}; + this._serializers = []; + this._deserializers = []; + this._infoTransformers = []; + this._framework = null; + this._userProperty = 'user'; + + this.init(); } - if (!name) { throw new Error('Authentication strategies must have a name'); } - - this._strategies[name] = strategy; - return this; -}; - -/** - * Un-utilize the `strategy` with given `name`. - * - * In typical applications, the necessary authentication strategies are static, - * configured once and always available. As such, there is often no need to - * invoke this function. - * - * However, in certain situations, applications may need dynamically configure - * and de-configure authentication strategies. The `use()`/`unuse()` - * combination satisfies these scenarios. - * - * Examples: - * - * passport.unuse('legacy-api'); - * - * @param {String} name - * @return {Authenticator} for chaining - * @api public - */ -Authenticator.prototype.unuse = function unuse(name) { - delete this._strategies[name]; - return this; -}; - -/** - * Setup Passport to be used under framework. - * - * By default, Passport exposes middleware that operate using Connect-style - * middleware using a `fn(req, res, next)` signature. Other popular frameworks - * have different expectations, and this function allows Passport to be adapted - * to operate within such environments. - * - * If you are using a Connect-compatible framework, including Express, there is - * no need to invoke this function. - * - * Examples: - * - * passport.framework(require('hapi-passport')()); - * - * @param {Object} name - * @return {Authenticator} for chaining - * @api public - */ -Authenticator.prototype.framework = function framework(fw) { - this._framework = fw; - return this; -}; - -/** - * Passport's primary initialization middleware. - * - * This middleware must be in use by the Connect/Express application for - * Passport to operate. - * - * Options: - * - `userProperty` Property to set on `req` upon login, defaults to _user_ - * - * Examples: - * - * app.use(passport.initialize()); - * - * app.use(passport.initialize({ userProperty: 'currentUser' })); - * - * @param {Object} options - * @return {Function} middleware - * @api public - */ -Authenticator.prototype.initialize = function initialize(options) { - options = options || {}; - this._userProperty = options.userProperty || 'user'; - return this._framework.initialize(this, options); -}; - -/** - * Middleware that will authenticate a request using the given `strategy` name, - * with optional `options` and `callback`. - * - * Examples: - * - * passport.authenticate('local', { - * successRedirect: '/', - * failureRedirect: '/login' - * })(req, res); - * - * passport.authenticate('local', function(err, user) { - * if (!user) { return res.redirect('/login'); } - * res.end('Authenticated!'); - * })(req, res); - * - * passport.authenticate('basic', { session: false })(req, res); - * - * app.get('/auth/twitter', passport.authenticate('twitter'), function(req, res) { - * // request will be redirected to Twitter - * }); - * app.get('/auth/twitter/callback', passport.authenticate('twitter'), function(req, res) { - * res.json(req.user); - * }); - * - * @param {String} strategy - * @param {Object} options - * @param {Function} callback - * @return {Function} middleware - * @api public - */ -Authenticator.prototype.authenticate = function authenticate(strategy, options, callback) { - return this._framework.authenticate(this, strategy, options, callback); -}; + /** + * Initialize authenticator. + * @returns {void} + * @protected + */ + init() { + this.framework(connect()); + this.use(new SessionStrategy(this.deserializeUser.bind(this))); + this._sm = new SessionManager({ key: this._key }, this.serializeUser.bind(this)); + } -/** - * Middleware that will authorize a third-party account using the given - * `strategy` name, with optional `options`. - * - * If authorization is successful, the result provided by the strategy's verify - * callback will be assigned to `req.account`. The existing login session and - * `req.user` will be unaffected. - * - * This function is particularly useful when connecting third-party accounts - * to the local account of a user that is currently authenticated. - * - * Examples: - * - * passport.authorize('twitter-authz', { failureRedirect: '/account' }); - * - * @param {String} strategy - * @param {Object} options - * @return {Function} middleware - * @api public - */ -Authenticator.prototype.authorize = function authorize(strategy, options, callback) { - options = options || {}; - options.assignProperty = 'account'; + /** + * Utilize the given `strategy` with optional `name`, overridding the strategy's + * default name. + * + * @example + * + * passport.use(new TwitterStrategy(...args)); + * + * passport.use('api', new http.BasicStrategy(...args)); + * + * @param {string|Strategy} name + * @param {Strategy} strategy + * @returns {Authenticator} for chaining + * @public + */ + use(name, strategy) { + if (!strategy) { + strategy = name; + ({ name } = strategy); + } + if (!name) { throw new Error('Authentication strategies must have a name'); } - const fn = this._framework.authorize || this._framework.authenticate; - return fn(this, strategy, options, callback); -}; + this._strategies[name] = strategy; + return this; + } -/** - * Middleware that will restore login state from a session. - * - * Web applications typically use sessions to maintain login state between - * requests. For example, a user will authenticate by entering credentials into - * a form which is submitted to the server. If the credentials are valid, a - * login session is established by setting a cookie containing a session - * identifier in the user's web browser. The web browser will send this cookie - * in subsequent requests to the server, allowing a session to be maintained. - * - * If sessions are being utilized, and a login session has been established, - * this middleware will populate `req.user` with the current user. - * - * Note that sessions are not strictly required for Passport to operate. - * However, as a general rule, most web applications will make use of sessions. - * An exception to this rule would be an API server, which expects each HTTP - * request to provide credentials in an Authorization header. - * - * Examples: - * - * app.use(connect.cookieParser()); - * app.use(connect.session({ secret: 'keyboard cat' })); - * app.use(passport.initialize()); - * app.use(passport.session()); - * - * @param {Object} options - * @return {Function} middleware - * @api public - */ -Authenticator.prototype.session = function session(options) { - return this.authenticate('session', options); -}; + /** + * Un-utilize the `strategy` with given `name`. + * + * In typical applications, the necessary authentication strategies are static, + * configured once and always available. As such, there is often no need to + * invoke this function. + * + * However, in certain situations, applications may need dynamically configure + * and de-configure authentication strategies. The `use()`/`unuse()` + * combination satisfies these scenarios. + * + * @example + * + * passport.unuse('legacy-api'); + * + * @param {string} name + * @returns {Authenticator} for chaining + * @public + */ + unuse(name) { + delete this._strategies[name]; + return this; + } -/** - * Sets a custom SessionManager - * - * Examples: - * - * passport.sessionManager = new CustomSessionManager(); - * - * @api public - */ + /** + * Setup Passport to be used under framework. + * + * By default, Passport exposes middleware that operate using Connect-style + * middleware using a `fn(req, res, next)` signature. Other popular frameworks + * have different expectations, and this function allows Passport to be adapted + * to operate within such environments. + * + * If you are using a Connect-compatible framework, including Express, there is + * no need to invoke this function. + * + * @example + * + * passport.framework(require('hapi-passport')()); + * + * @param {object} fw + * @returns {Authenticator} for chaining + * @public + */ + framework(fw) { + this._framework = fw; + return this; + } -Authenticator.prototype.sessionManager = function sessionManager(mgr) { - this._sm = mgr; - return this; -}; + /** + * @typedef {Object} AuthenticatorInitializeOptions + * @property {string} [userProperty="user"] Property to set on `req` upon login + */ + + /** + * Passport's primary initialization middleware. + * + * This middleware must be in use by the Connect/Express application for + * Passport to operate. + * + * @example + * + * app.use(passport.initialize()); + * + * app.use(passport.initialize({ userProperty: 'currentUser' })); + * + * @param {AuthenticatorInitializeOptions} options + * @returns {Function} middleware + * @public + */ + initialize(options) { + options = options || {}; + this._userProperty = options.userProperty || 'user'; + + return this._framework.initialize(this, options); + } -/** - * Registers a function used to serialize user objects into the session. - * - * Examples: - * - * passport.serializeUser(function(user, done) { - * done(null, user.id); - * }); - * - * @api public - */ + /** + * Middleware that will authenticate a request using the given `strategy` name, + * with optional `options` and `callback`. + * + * @example + * + * passport.authenticate('local', { + * successRedirect: '/', + * failureRedirect: '/login' + * })(req, res); + * + * passport.authenticate('local', (err, user) => { + * if (err) { next(err); return; } + * if (!user) { res.redirect('/login'); return; } + * res.end('Authenticated!'); + * })(req, res); + * + * passport.authenticate('basic', { session: false })(req, res); + * + * app.get('/auth/twitter', passport.authenticate('twitter'), (req, res) => { + * // request will be redirected to Twitter + * }); + * app.get('/auth/twitter/callback', passport.authenticate('twitter'), (req, res) => { + * res.json(req.user); + * }); + * + * @param {string} strategy + * @param {object} options + * @param {Function} callback + * @returns {Function} middleware + * @public + */ + authenticate(strategy, options, callback) { + return this._framework.authenticate(this, strategy, options, callback); + } -// eslint-disable-next-line consistent-return -Authenticator.prototype.serializeUser = function serializeUser(fn, req, done) { - if (typeof fn === 'function') { - return this._serializers.push(fn); + /** + * Middleware that will authorize a third-party account using the given + * `strategy` name, with optional `options`. + * + * If authorization is successful, the result provided by the strategy's verify + * callback will be assigned to `req.account`. The existing login session and + * `req.user` will be unaffected. + * + * This function is particularly useful when connecting third-party accounts + * to the local account of a user that is currently authenticated. + * + * @example + * + * passport.authorize('twitter-authz', { failureRedirect: '/account' }); + * + * @param {string} strategy + * @param {object} options + * @param {Function} callback + * @returns {Function} middleware + * @public + */ + authorize(strategy, options, callback) { + options = options || {}; + options.assignProperty = 'account'; + + const fn = this._framework.authorize || this._framework.authenticate; + return fn(this, strategy, options, callback); } - // private implementation that traverses the chain of serializers, attempting - // to serialize a user - const user = fn; + /** + * Middleware that will restore login state from a session. + * + * Web applications typically use sessions to maintain login state between + * requests. For example, a user will authenticate by entering credentials into + * a form which is submitted to the server. If the credentials are valid, a + * login session is established by setting a cookie containing a session + * identifier in the user's web browser. The web browser will send this cookie + * in subsequent requests to the server, allowing a session to be maintained. + * + * If sessions are being utilized, and a login session has been established, + * this middleware will populate `req.user` with the current user. + * + * Note that sessions are not strictly required for Passport to operate. + * However, as a general rule, most web applications will make use of sessions. + * An exception to this rule would be an API server, which expects each HTTP + * request to provide credentials in an Authorization header. + * + * @example + * + * app.use(connect.cookieParser()); + * app.use(connect.session({ secret: 'keyboard cat' })); + * app.use(passport.initialize()); + * app.use(passport.session()); + * + * @param {object} options + * @returns {Function} middleware + * @public + */ + session(options) { + return this.authenticate('session', options); + } - // For backwards compatibility - if (typeof req === 'function') { - done = req; - req = undefined; + /** + * Sets a custom SessionManager + * + * @example + * + * passport.sessionManager = new CustomSessionManager(); + * + * @public + */ + + sessionManager(mgr) { + this._sm = mgr; + return this; } - const stack = this._serializers; - // eslint-disable-next-line consistent-return - (function pass(i, err, obj) { - // serializers use 'pass' as an error to skip processing - if (err === 'pass') { - err = undefined; - } - // an error or serialized object was obtained, done - if (err || obj || obj === 0) { return done(err, obj); } + /** + * Registers a function used to serialize user objects into the session. + * + * @example + * + * passport.serializeUser(function(user, done) { + * done(null, user.id); + * }); + * + * @public + */ - const layer = stack[i]; - if (!layer) { - return done(new Error('Failed to serialize user into session')); + // eslint-disable-next-line consistent-return + serializeUser(fn, req, done) { + if (typeof fn === 'function') { + return this._serializers.push(fn); } + // private implementation that traverses the chain of serializers, attempting + // to serialize a user + const user = fn; - function serialized(e, o) { - pass(i + 1, e, o); + // For backwards compatibility + if (typeof req === 'function') { + done = req; + req = undefined; } - try { - const arity = layer.length; - if (arity === 3) { - layer(req, user, serialized); - } else { - layer(user, serialized); + const stack = this._serializers; + // eslint-disable-next-line consistent-return + (function pass(i, err, obj) { + // serializers use 'pass' as an error to skip processing + if (err === 'pass') { + err = undefined; } - } catch (e) { - return done(e); - } - }(0)); -}; + // an error or serialized object was obtained, done + if (err || obj || obj === 0) { return done(err, obj); } -/** - * Registers a function used to deserialize user objects out of the session. - * - * Examples: - * - * passport.deserializeUser(function(id, done) { - * User.findById(id, function (err, user) { - * done(err, user); - * }); - * }); - * - * @api public - */ + const layer = stack[i]; + if (!layer) { + return done(new Error('Failed to serialize user into session')); + } -// eslint-disable-next-line consistent-return -Authenticator.prototype.deserializeUser = function deserializeUser(fn, req, done) { - if (typeof fn === 'function') { - return this._deserializers.push(fn); - } - // private implementation that traverses the chain of deserializers, - // attempting to deserialize a user - const obj = fn; + // eslint-disable-next-line jsdoc/require-jsdoc + function serialized(e, o) { + pass(i + 1, e, o); + } - // For backwards compatibility - if (typeof req === 'function') { - done = req; - req = undefined; + try { + const arity = layer.length; + if (arity === 3) { + layer(req, user, serialized); + } else { + layer(user, serialized); + } + } catch (e) { + return done(e); + } + }(0)); } - const stack = this._deserializers; + /** + * Registers a function used to deserialize user objects out of the session. + * + * @example + * + * passport.deserializeUser(function(id, done) { + * User.findById(id, function (err, user) { + * done(err, user); + * }); + * }); + * + * @public + */ + // eslint-disable-next-line consistent-return - (function pass(i, err, user) { - // deserializers use 'pass' as an error to skip processing - if (err === 'pass') { - err = undefined; - } - // an error or deserialized user was obtained, done - if (err || user) { return done(err, user); } - // a valid user existed when establishing the session, but that user has - // since been removed - if (user === null || user === false) { return done(null, false); } - - const layer = stack[i]; - if (!layer) { - return done(new Error('Failed to deserialize user out of session')); + deserializeUser(fn, req, done) { + if (typeof fn === 'function') { + return this._deserializers.push(fn); } + // private implementation that traverses the chain of deserializers, + // attempting to deserialize a user + const obj = fn; - function deserialized(e, u) { - pass(i + 1, e, u); + // For backwards compatibility + if (typeof req === 'function') { + done = req; + req = undefined; } - try { - const arity = layer.length; - if (arity === 3) { - layer(req, obj, deserialized); - } else { - layer(obj, deserialized); + const stack = this._deserializers; + // eslint-disable-next-line consistent-return + (function pass(i, err, user) { + // deserializers use 'pass' as an error to skip processing + if (err === 'pass') { + err = undefined; + } + // an error or deserialized user was obtained, done + if (err || user) { return done(err, user); } + // a valid user existed when establishing the session, but that user has + // since been removed + if (user === null || user === false) { return done(null, false); } + + const layer = stack[i]; + if (!layer) { + return done(new Error('Failed to deserialize user out of session')); } - } catch (e) { - return done(e); - } - }(0)); -}; - -/** - * Registers a function used to transform auth info. - * - * In some circumstances authorization details are contained in authentication - * credentials or loaded as part of verification. - * - * For example, when using bearer tokens for API authentication, the tokens may - * encode (either directly or indirectly in a database), details such as scope - * of access or the client to which the token was issued. - * - * Such authorization details should be enforced separately from authentication. - * Because Passport deals only with the latter, this is the responsiblity of - * middleware or routes further along the chain. However, it is not optimal to - * decode the same data or execute the same database query later. To avoid - * this, Passport accepts optional `info` along with the authenticated `user` - * in a strategy's `success()` action. This info is set at `req.authInfo`, - * where said later middlware or routes can access it. - * - * Optionally, applications can register transforms to proccess this info, - * which take effect prior to `req.authInfo` being set. This is useful, for - * example, when the info contains a client ID. The transform can load the - * client from the database and include the instance in the transformed info, - * allowing the full set of client properties to be convieniently accessed. - * - * If no transforms are registered, `info` supplied by the strategy will be left - * unmodified. - * - * Examples: - * - * passport.transformAuthInfo(function(info, done) { - * Client.findById(info.clientID, function (err, client) { - * info.client = client; - * done(err, info); - * }); - * }); - * - * @api public - */ -// eslint-disable-next-line consistent-return -Authenticator.prototype.transformAuthInfo = function transformAuthInfo(fn, req, done) { - if (typeof fn === 'function') { - return this._infoTransformers.push(fn); - } - // private implementation that traverses the chain of transformers, - // attempting to transform auth info - const info = fn; + // eslint-disable-next-line jsdoc/require-jsdoc + function deserialized(e, u) { + pass(i + 1, e, u); + } - // For backwards compatibility - if (typeof req === 'function') { - done = req; - req = undefined; + try { + const arity = layer.length; + if (arity === 3) { + layer(req, obj, deserialized); + } else { + layer(obj, deserialized); + } + } catch (e) { + return done(e); + } + }(0)); } - const stack = this._infoTransformers; + /** + * Registers a function used to transform auth info. + * + * In some circumstances authorization details are contained in authentication + * credentials or loaded as part of verification. + * + * For example, when using bearer tokens for API authentication, the tokens may + * encode (either directly or indirectly in a database), details such as scope + * of access or the client to which the token was issued. + * + * Such authorization details should be enforced separately from authentication. + * Because Passport deals only with the latter, this is the responsiblity of + * middleware or routes further along the chain. However, it is not optimal to + * decode the same data or execute the same database query later. To avoid + * this, Passport accepts optional `info` along with the authenticated `user` + * in a strategy's `success()` action. This info is set at `req.authInfo`, + * where said later middlware or routes can access it. + * + * Optionally, applications can register transforms to proccess this info, + * which take effect prior to `req.authInfo` being set. This is useful, for + * example, when the info contains a client ID. The transform can load the + * client from the database and include the instance in the transformed info, + * allowing the full set of client properties to be convieniently accessed. + * + * If no transforms are registered, `info` supplied by the strategy will be left + * unmodified. + * + * @example + * + * passport.transformAuthInfo(function(info, done) { + * Client.findById(info.clientID, function (err, client) { + * info.client = client; + * done(err, info); + * }); + * }); + * + * @public + */ + // eslint-disable-next-line consistent-return - (function pass(i, err, tinfo) { - // transformers use 'pass' as an error to skip processing - if (err === 'pass') { - err = undefined; - } - // an error or transformed info was obtained, done - if (err || tinfo) { return done(err, tinfo); } - - const layer = stack[i]; - if (!layer) { - // if no transformers are registered (or they all pass), the default - // behavior is to use the un-transformed info as-is - return done(null, info); + transformAuthInfo(fn, req, done) { + if (typeof fn === 'function') { + return this._infoTransformers.push(fn); } + // private implementation that traverses the chain of transformers, + // attempting to transform auth info + const info = fn; - function transformed(e, t) { - pass(i + 1, e, t); + // For backwards compatibility + if (typeof req === 'function') { + done = req; + req = undefined; } - try { - const arity = layer.length; - if (arity === 1) { - // sync - const t = layer(info); - transformed(null, t); - } else if (arity === 3) { - layer(req, info, transformed); - } else { - layer(info, transformed); + const stack = this._infoTransformers; + // eslint-disable-next-line consistent-return + (function pass(i, err, tinfo) { + // transformers use 'pass' as an error to skip processing + if (err === 'pass') { + err = undefined; + } + // an error or transformed info was obtained, done + if (err || tinfo) { return done(err, tinfo); } + + const layer = stack[i]; + if (!layer) { + // if no transformers are registered (or they all pass), the default + // behavior is to use the un-transformed info as-is + return done(null, info); } - } catch (e) { - return done(e); - } - }(0)); -}; -/** - * Return strategy with given `name`. - * - * @param {String} name - * @return {Strategy} - * @api private - */ -Authenticator.prototype._strategy = function _strategy(name) { - return this._strategies[name]; -}; + // eslint-disable-next-line jsdoc/require-jsdoc + function transformed(e, t) { + pass(i + 1, e, t); + } + + try { + const arity = layer.length; + if (arity === 1) { + // sync + const t = layer(info); + transformed(null, t); + } else if (arity === 3) { + layer(req, info, transformed); + } else { + layer(info, transformed); + } + } catch (e) { + return done(e); + } + }(0)); + } + + /** + * Return strategy with given `name`. + * + * @param {string} name + * @returns {Strategy} + * @private + */ + _strategy(name) { + return this._strategies[name]; + } +} /** * Expose `Authenticator`. diff --git a/lib/errors/authenticationerror.js b/lib/errors/authenticationerror.js index 68cf923e..e8daf169 100644 --- a/lib/errors/authenticationerror.js +++ b/lib/errors/authenticationerror.js @@ -1,23 +1,18 @@ +'use strict'; + /** - * `AuthenticationError` error. + * The `AuthenticationError` error. * - * @constructor - * @api private + * @private */ - -/* eslint-disable no-proto, no-proto, no-caller, no-restricted-properties */ - -function AuthenticationError(message, status) { - Error.call(this); - Error.captureStackTrace(this, arguments.callee); - this.name = 'AuthenticationError'; - this.message = message; - this.status = status || 401; +class AuthenticationError extends Error { + constructor(message, status) { + super(message); + Error.captureStackTrace(this, AuthenticationError); + this.name = 'AuthenticationError'; + this.status = status || 401; + } } -// Inherit from `Error`. -AuthenticationError.prototype.__proto__ = Error.prototype; - - // Expose constructor. module.exports = AuthenticationError; diff --git a/lib/framework/connect.js b/lib/framework/connect.js index cd625249..5b6a229d 100644 --- a/lib/framework/connect.js +++ b/lib/framework/connect.js @@ -1,7 +1,8 @@ +'use strict'; + /** * Module dependencies. */ -/* eslint-disable camelcase, no-proto, no-shadow */ const initialize = require('../middleware/initialize'); const authenticate = require('../middleware/authenticate'); @@ -13,7 +14,7 @@ const authenticate = require('../middleware/authenticate'); * middleware that conform to the `fn(req, res, next)` signature. * * @return {Object} - * @api protected + * @protected */ // eslint-disable-next-line no-multi-assign, func-names diff --git a/lib/http/request.js b/lib/http/request.js index ccd46eef..ab2d25d9 100644 --- a/lib/http/request.js +++ b/lib/http/request.js @@ -1,33 +1,38 @@ /** * Module dependencies. */ +'use strict'; -// var http = require('http') +// const http = require('http') // , req = http.IncomingMessage.prototype; -/* eslint-disable no-multi-assign, camelcase, no-proto, no-shadow */ - +/* eslint-disable no-multi-assign */ const req = exports = module.exports = {}; +/* eslint-enable no-multi-assign */ + +/** +* @typedef {Object} LogInOptions +* @property {boolean} [session] Save login state in session, defaults to _true_ +*/ /** * Initiate a login session for `user`. * - * Options: - * - `session` Save login state in session, defaults to _true_ * - * Examples: + * @example * * req.logIn(user, { session: false }); * - * req.logIn(user, function(err) { + * req.logIn(user, (err) => { * if (err) { throw err; } * // session saved * }); * * @param {User} user - * @param {Object} options + * @param {LogInOptions} options * @param {Function} done - * @api public + * @returns {void} + * @public */ req.logIn = function logIn(user, options, done) { if (typeof options === 'function') { @@ -45,12 +50,11 @@ req.logIn = function logIn(user, options, done) { this[property] = user; if (session) { if (!this._passport) { throw new Error('passport.initialize() middleware not in use'); } - if (typeof done !== 'function') { throw new Error('req#login requires a callback function'); } + if (typeof done !== 'function') { throw new TypeError('req#login requires a callback function'); } - const self = this; // eslint-disable-next-line consistent-return this._passport.instance._sm.logIn(this, user, (err) => { - if (err) { self[property] = null; return done(err); } + if (err) { this[property] = null; return done(err); } done(); }); } else { @@ -63,8 +67,8 @@ req.login = req.logIn; /** * Terminate an existing login session. - * - * @api public + * @returns {void} + * @public */ req.logOut = function logOut() { let property = 'user'; @@ -83,8 +87,8 @@ req.logout = req.logOut; /** * Test if request is authenticated. * - * @return {Boolean} - * @api public + * @returns {boolean} + * @public */ req.isAuthenticated = function isAuthenticated() { let property = 'user'; @@ -92,14 +96,14 @@ req.isAuthenticated = function isAuthenticated() { property = this._passport.instance._userProperty || 'user'; } - return !!(this[property]); + return Boolean(this[property]); }; /** * Test if request is unauthenticated. * - * @return {Boolean} - * @api public + * @returns {boolean} + * @public */ req.isUnauthenticated = function isUnauthenticated() { return !this.isAuthenticated(); diff --git a/lib/index.js b/lib/index.js index a4a11e39..14415cc2 100644 --- a/lib/index.js +++ b/lib/index.js @@ -3,6 +3,7 @@ */ /* eslint-disable no-multi-assign */ +'use strict'; const Passport = require('./authenticator'); const SessionStrategy = require('./strategies/session'); @@ -11,7 +12,7 @@ const SessionStrategy = require('./strategies/session'); /** * Export default singleton. * - * @api public + * @public */ exports = module.exports = new Passport(); diff --git a/lib/middleware/authenticate.js b/lib/middleware/authenticate.js index 84dcaaa8..b9fa6c42 100644 --- a/lib/middleware/authenticate.js +++ b/lib/middleware/authenticate.js @@ -1,9 +1,10 @@ +/* eslint-disable no-shadow */ +'use strict'; + /** * Module dependencies. */ -/* eslint-disable camelcase, no-proto, no-shadow */ - const http = require('http'); const AuthenticationError = require('../errors/authenticationerror'); @@ -54,7 +55,7 @@ const AuthenticationError = require('../errors/authenticationerror'); * responsibility to log-in the user, establish a session, and otherwise perform * the desired operations. * - * Examples: + * @example * * passport.authenticate('local', { successRedirect: '/', failureRedirect: '/login' }); * @@ -62,11 +63,12 @@ const AuthenticationError = require('../errors/authenticationerror'); * * passport.authenticate('twitter'); * - * @param {String|Array} name - * @param {Object} options + * @param {Authenticator} passport + * @param {string|Array} name + * @param {object} options * @param {Function} callback - * @return {Function} - * @api public + * @returns {Function} + * @public */ module.exports = function authenticate(passport, name, options, callback) { if (typeof options === 'function') { @@ -96,6 +98,7 @@ module.exports = function authenticate(passport, name, options, callback) { // accumulator for failures from each strategy in the chain const failures = []; + // eslint-disable-next-line jsdoc/require-jsdoc function redirect(url) { if (req.session && req.session.save && typeof req.session.save === 'function') { return req.session.save(() => res.redirect(url)); @@ -103,7 +106,7 @@ module.exports = function authenticate(passport, name, options, callback) { return res.redirect(url); } - // eslint-disable-next-line consistent-return + // eslint-disable-next-line consistent-return, jsdoc/require-jsdoc function allFailed() { if (callback) { if (!multi) { @@ -116,25 +119,26 @@ module.exports = function authenticate(passport, name, options, callback) { // Strategies are ordered by priority. For the purpose of flashing a // message, the first failure will be displayed. - let failure = failures[0] || {}; - let challenge = failure.challenge || {}; - let msg; + const failure = failures[0] || {}; + const challenge = failure.challenge || {}; if (options.failureFlash) { let flash = options.failureFlash; if (typeof flash === 'string') { flash = { type: 'error', message: flash }; } - flash.type = flash.type || 'error'; + if (typeof flash !== 'boolean') { + flash.type = flash.type || 'error'; + } const type = flash.type || challenge.type || 'error'; - msg = flash.message || challenge.message || challenge; + const msg = flash.message || challenge.message || challenge; if (typeof msg === 'string') { req.flash(type, msg); } } if (options.failureMessage) { - msg = options.failureMessage; + let msg = options.failureMessage; if (typeof msg === 'boolean') { msg = challenge.message || challenge; } @@ -154,18 +158,12 @@ module.exports = function authenticate(passport, name, options, callback) { // will be included in the response. const rchallenge = []; let rstatus; - let status; - // eslint-disable-next-line no-plusplus - for (let j = 0, len = failures.length; j < len; j++) { - failure = failures[j]; - challenge = failure.challenge; - status = failure.status; - + failures.forEach(({ challenge, status }) => { rstatus = rstatus || status; if (typeof challenge === 'string') { rchallenge.push(challenge); } - } + }); res.statusCode = rstatus || 401; if (res.statusCode === 401 && rchallenge.length) { @@ -211,7 +209,7 @@ module.exports = function authenticate(passport, name, options, callback) { * * @param {Object} user * @param {Object} info - * @api public + * @public */ // eslint-disable-next-line consistent-return @@ -228,7 +226,9 @@ module.exports = function authenticate(passport, name, options, callback) { if (typeof flash === 'string') { flash = { type: 'success', message: flash }; } - flash.type = flash.type || 'success'; + if (typeof flash !== 'boolean') { + flash.type = flash.type || 'success'; + } const type = flash.type || info.type || 'success'; msg = flash.message || info.message || info; @@ -255,7 +255,7 @@ module.exports = function authenticate(passport, name, options, callback) { req.logIn(user, options, (err) => { if (err) { return next(err); } - // eslint-disable-next-line consistent-return + // eslint-disable-next-line consistent-return, jsdoc/require-jsdoc function complete() { if (options.successReturnToOrRedirect) { let url = options.successReturnToOrRedirect; @@ -290,9 +290,10 @@ module.exports = function authenticate(passport, name, options, callback) { * * Strategies should call this function to fail an authentication attempt. * - * @param {String} challenge - * @param {Number} status - * @api public + * @param {string} challenge + * @param {number} status + * @returns {void} + * @public */ strategy.fail = function fail(challenge, status) { if (typeof challenge === 'number') { @@ -312,9 +313,10 @@ module.exports = function authenticate(passport, name, options, callback) { * Strategies should call this function to redirect the user (via their * user agent) to a third-party website for authentication. * - * @param {String} url - * @param {Number} status - * @api public + * @param {string} url + * @param {number} status + * @returns {void} + * @public */ strategy.redirect = function redirect(url, status) { // NOTE: Do not use `res.redirect` from Express, because it can't decide @@ -341,7 +343,8 @@ module.exports = function authenticate(passport, name, options, callback) { * function. It exists primarily to allow previous authentication state * to be restored, for example from an HTTP session. * - * @api public + * @returns {void} + * @public */ strategy.pass = function pass() { next(); @@ -355,7 +358,7 @@ module.exports = function authenticate(passport, name, options, callback) { * user directory is not available. * * @param {Error} err - * @api public + * @public */ // eslint-disable-next-line consistent-return diff --git a/lib/middleware/initialize.js b/lib/middleware/initialize.js index 17e159b4..1d288846 100644 --- a/lib/middleware/initialize.js +++ b/lib/middleware/initialize.js @@ -1,3 +1,5 @@ +'use strict'; + /** * Passport initialization. * @@ -19,7 +21,7 @@ * entirely stateless (not using sessions), this middleware is not necessary, * but its use will not have any adverse impact. * - * Examples: + * @example * * app.use(connect.cookieParser()); * app.use(connect.session({ secret: 'keyboard cat' })); @@ -37,13 +39,13 @@ * }); * * @return {Function} - * @api public + * @public */ const IncomingMessageExt = require('../http/request'); -/* eslint-disable no-proto, no-shadow */ module.exports = function initialize(passport) { + /* eslint-disable-next-line no-shadow */ return function initialize(req, res, next) { req._passport = {}; req._passport.instance = passport; diff --git a/lib/sessionmanager.js b/lib/sessionmanager.js index e7cbea66..acf588ae 100644 --- a/lib/sessionmanager.js +++ b/lib/sessionmanager.js @@ -1,42 +1,43 @@ -/* eslint-disable camelcase, no-proto, no-shadow */ +'use strict'; -function SessionManager(options, serializeUser) { - if (typeof options === 'function') { - serializeUser = options; - options = undefined; +class SessionManager { + constructor(options, serializeUser) { + if (typeof options === 'function') { + serializeUser = options; + options = undefined; + } + options = options || {}; + + this._key = options.key || 'passport'; + this._serializeUser = serializeUser; } - options = options || {}; - this._key = options.key || 'passport'; - this._serializeUser = serializeUser; -} + logIn(req, user, cb) { + // eslint-disable-next-line consistent-return + this._serializeUser(user, req, (err, obj) => { + if (err) { + return cb(err); + } + if (!req._passport.session) { + req._passport.session = {}; + } + req._passport.session.user = obj; + if (!req.session) { + req.session = {}; + } + req.session[this._key] = req._passport.session; + cb(); + }); + } -SessionManager.prototype.logIn = function logIn(req, user, cb) { - const self = this; - // eslint-disable-next-line consistent-return - this._serializeUser(user, req, (err, obj) => { - if (err) { - return cb(err); - } - if (!req._passport.session) { - req._passport.session = {}; + // eslint-disable-next-line class-methods-use-this + logOut(req, cb) { + if (req._passport && req._passport.session) { + delete req._passport.session.user; } - req._passport.session.user = obj; - if (!req.session) { - req.session = {}; - } - req.session[self._key] = req._passport.session; - cb(); - }); -}; - -SessionManager.prototype.logOut = function logOut(req, cb) { - if (req._passport && req._passport.session) { - delete req._passport.session.user; + // eslint-disable-next-line no-unused-expressions + cb && cb(); } - // eslint-disable-next-line no-unused-expressions - cb && cb(); -}; - +} module.exports = SessionManager; diff --git a/lib/strategies/session.js b/lib/strategies/session.js index 9d16b472..51b612fc 100644 --- a/lib/strategies/session.js +++ b/lib/strategies/session.js @@ -1,78 +1,71 @@ +'use strict'; /** * Module dependencies. */ -/* eslint-disable camelcase, no-proto, no-shadow */ - -const util = require('util'); const Strategy = require('@passport-next/passport-strategy'); - /** - * `SessionStrategy` constructor. + * The `SessionStrategy` constructor. * - * @api public + * @public */ -function SessionStrategy(options, deserializeUser) { - if (typeof options === 'function') { - deserializeUser = options; - options = undefined; +class SessionStrategy extends Strategy { + constructor(options, deserializeUser) { + if (typeof options === 'function') { + deserializeUser = options; + options = undefined; + } + options = options || {}; + + super(); + this.name = 'session'; + this._deserializeUser = deserializeUser; } - options = options || {}; - Strategy.call(this); - this.name = 'session'; - this._deserializeUser = deserializeUser; -} + /** + * Authenticate request based on the current session state. + * + * The session authentication strategy uses the session to restore any login + * state across requests. If a login session has been established, `req.user` + * will be populated with the current user. + * + * This strategy is registered automatically by Passport. + * + * @param {Object} req + * @param {Object} options + * @protected + */ -/** - * Inherit from `Strategy`. - */ -util.inherits(SessionStrategy, Strategy); + // eslint-disable-next-line consistent-return, no-unused-vars + authenticate(req, options) { + if (!req._passport) { return this.error(new Error('passport.initialize() middleware not in use')); } + options = options || {}; -/** - * Authenticate request based on the current session state. - * - * The session authentication strategy uses the session to restore any login - * state across requests. If a login session has been established, `req.user` - * will be populated with the current user. - * - * This strategy is registered automatically by Passport. - * - * @param {Object} req - * @param {Object} options - * @api protected - */ - -// eslint-disable-next-line consistent-return, no-unused-vars -SessionStrategy.prototype.authenticate = function authenticate(req, options) { - if (!req._passport) { return this.error(new Error('passport.initialize() middleware not in use')); } - options = options || {}; + let su; - const self = this; - let su; + if (req._passport.session) { + su = req._passport.session.user; + } - if (req._passport.session) { - su = req._passport.session.user; + if (su || su === 0) { + // eslint-disable-next-line consistent-return + this._deserializeUser(su, req, (err, user) => { + if (err) { return this.error(err); } + if (!user) { + delete req._passport.session.user; + } else { + // TODO: Remove instance access + const property = req._passport.instance._userProperty || 'user'; + req[property] = user; + } + this.pass(); + }); + } else { + this.pass(); + } } - - if (su || su === 0) { - // eslint-disable-next-line consistent-return - this._deserializeUser(su, req, (err, user) => { - if (err) { return self.error(err); } - if (!user) { - delete req._passport.session.user; - } else { - // TODO: Remove instance access - const property = req._passport.instance._userProperty || 'user'; - req[property] = user; - } - self.pass(); - }); - } else { - self.pass(); - } -}; +} /** diff --git a/package-lock.json b/package-lock.json index 1924ad9e..2dbea522 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24,6 +24,48 @@ "js-tokens": "^4.0.0" } }, + "@babel/runtime": { + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.4.4.tgz", + "integrity": "sha512-w0+uT71b6Yi7i5SE0co4NioIpSYS6lLiXvCzWzGSKvpK5vdQtCbICHMj+gbAKAOtxiV6HsVh/MBdaF9EQ6faSg==", + "dev": true, + "requires": { + "regenerator-runtime": "^0.13.2" + } + }, + "@mysticatea/eslint-plugin": { + "version": "10.0.3", + "resolved": "https://registry.npmjs.org/@mysticatea/eslint-plugin/-/eslint-plugin-10.0.3.tgz", + "integrity": "sha512-lsZeSINcepg5SSbA+FX/n/A7M/Qz+wwRWKBsg2IPk52Xi+R1X02lqd4sAzZGG2HvsPiGyoKJ/Ejx9rQPzLoh4A==", + "dev": true, + "requires": { + "@typescript-eslint/eslint-plugin": "~1.7.0", + "@typescript-eslint/parser": "~1.7.0", + "eslint-plugin-eslint-comments": "~3.1.1", + "eslint-plugin-eslint-plugin": "~2.0.1", + "eslint-plugin-node": "~8.0.1", + "eslint-plugin-prettier": "~3.0.1", + "eslint-plugin-vue": "~5.2.2", + "prettier": "~1.14.3", + "vue-eslint-parser": "^5.0.0" + }, + "dependencies": { + "eslint-plugin-node": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-node/-/eslint-plugin-node-8.0.1.tgz", + "integrity": "sha512-ZjOjbjEi6jd82rIpFSgagv4CHWzG9xsQAVp1ZPlhRnnYxcTgENUVBvhYmkQ7GvT1QFijUSo69RaiOJKhMu6i8w==", + "dev": true, + "requires": { + "eslint-plugin-es": "^1.3.1", + "eslint-utils": "^1.3.1", + "ignore": "^5.0.2", + "minimatch": "^3.0.4", + "resolve": "^1.8.1", + "semver": "^5.5.0" + } + } + } + }, "@passport-next/chai-passport-strategy": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@passport-next/chai-passport-strategy/-/chai-passport-strategy-1.1.0.tgz", @@ -35,6 +77,49 @@ "resolved": "https://registry.npmjs.org/@passport-next/passport-strategy/-/passport-strategy-1.1.0.tgz", "integrity": "sha512-2KhFjtPueJG6xVj2HnqXt9BlANOfYCVLyu+pXYjPGBDT8yk+vQwc/6tsceIj+mayKcoxMau2JimggXRPHgoc8w==" }, + "@typescript-eslint/eslint-plugin": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-1.7.0.tgz", + "integrity": "sha512-NUSz1aTlIzzTjFFVFyzrbo8oFjHg3K/M9MzYByqbMCxeFdErhLAcGITVfXzSz+Yvp5OOpMu3HkIttB0NyKl54Q==", + "dev": true, + "requires": { + "@typescript-eslint/parser": "1.7.0", + "@typescript-eslint/typescript-estree": "1.7.0", + "eslint-utils": "^1.3.1", + "regexpp": "^2.0.1", + "requireindex": "^1.2.0", + "tsutils": "^3.7.0" + } + }, + "@typescript-eslint/parser": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-1.7.0.tgz", + "integrity": "sha512-1QFKxs2V940372srm12ovSE683afqc1jB6zF/f8iKhgLz1yoSjYeGHipasao33VXKI+0a/ob9okeogGdKGvvlg==", + "dev": true, + "requires": { + "@typescript-eslint/typescript-estree": "1.7.0", + "eslint-scope": "^4.0.0", + "eslint-visitor-keys": "^1.0.0" + } + }, + "@typescript-eslint/typescript-estree": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-1.7.0.tgz", + "integrity": "sha512-K5uedUxVmlYrVkFbyV3htDipvLqTE3QMOUQEHYJaKtgzxj6r7c5Ca/DG1tGgFxX+fsbi9nDIrf4arq7Ib7H/Yw==", + "dev": true, + "requires": { + "lodash.unescape": "4.0.1", + "semver": "5.5.0" + }, + "dependencies": { + "semver": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", + "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", + "dev": true + } + } + }, "acorn": { "version": "6.1.1", "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.1.1.tgz", @@ -111,12 +196,24 @@ "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", "dev": true }, + "ast-metadata-inferer": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/ast-metadata-inferer/-/ast-metadata-inferer-0.1.1.tgz", + "integrity": "sha512-hc9w8Qrgg9Lf9iFcZVhNjUnhrd2BBpTlyCnegPVvCe6O0yMrF57a6Cmh7k+xUsfUOMh9wajOL5AsGOBNEyTCcw==", + "dev": true + }, "astral-regex": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-1.0.0.tgz", "integrity": "sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg==", "dev": true }, + "bail": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/bail/-/bail-1.0.4.tgz", + "integrity": "sha512-S8vuDB4w6YpRhICUDET3guPlQpaJl7od94tpZ0Fvnyp+MKW/HyDTcRDck+29C9g+d/qQHnddRH3+94kZdrW0Ww==", + "dev": true + }, "balanced-match": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", @@ -139,6 +236,17 @@ "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", "dev": true }, + "browserslist": { + "version": "4.5.6", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.5.6.tgz", + "integrity": "sha512-o/hPOtbU9oX507lIqon+UvPYqpx3mHc8cV3QemSBTXwkG8gSQSK6UKvXcE/DcleU3+A59XTUHyCvZ5qGy8xVAg==", + "dev": true, + "requires": { + "caniuse-lite": "^1.0.30000963", + "electron-to-chromium": "^1.3.127", + "node-releases": "^1.1.17" + } + }, "callsites": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", @@ -151,6 +259,18 @@ "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", "dev": true }, + "caniuse-db": { + "version": "1.0.30000967", + "resolved": "https://registry.npmjs.org/caniuse-db/-/caniuse-db-1.0.30000967.tgz", + "integrity": "sha512-70gk6cLSD5rItxnZ7WUxyCpM9LAjEb1tVzlENQfXQXZS/IiGnfAC6u32G5cZFlDBKjNPBIta/QSx5CZLZepxRA==", + "dev": true + }, + "caniuse-lite": { + "version": "1.0.30000967", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000967.tgz", + "integrity": "sha512-rUBIbap+VJfxTzrM4akJ00lkvVb5/n5v3EGXfWzSH5zT8aJmGzjA8HWhJ4U6kCpzxozUSnB+yvAYDRPY6mRpgQ==", + "dev": true + }, "chai": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/chai/-/chai-4.2.0.tgz", @@ -182,6 +302,24 @@ "supports-color": "^5.3.0" } }, + "character-entities": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/character-entities/-/character-entities-1.2.3.tgz", + "integrity": "sha512-yB4oYSAa9yLcGyTbB4ItFwHw43QHdH129IJ5R+WvxOkWlyFnR5FAaBNnUq4mcxsTVZGh28bHoeTHMKXH1wZf3w==", + "dev": true + }, + "character-entities-legacy": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/character-entities-legacy/-/character-entities-legacy-1.1.3.tgz", + "integrity": "sha512-YAxUpPoPwxYFsslbdKkhrGnXAtXoHNgYjlBM3WMXkWGTl5RsY3QmOyhwAgL8Nxm9l5LBThXGawxKPn68y6/fww==", + "dev": true + }, + "character-reference-invalid": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/character-reference-invalid/-/character-reference-invalid-1.1.3.tgz", + "integrity": "sha512-VOq6PRzQBam/8Jm6XBGk2fNEnHXAdGd6go0rtd4weAGECBamHDwwCQSOT12TACIYUZegUXnV6xBXqUssijtxIg==", + "dev": true + }, "chardet": { "version": "0.7.0", "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.7.0.tgz", @@ -194,6 +332,15 @@ "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=", "dev": true }, + "clean-regexp": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/clean-regexp/-/clean-regexp-1.0.0.tgz", + "integrity": "sha1-jffHquUf02h06PjQW5GAvBGj/tc=", + "dev": true, + "requires": { + "escape-string-regexp": "^1.0.5" + } + }, "cli-cursor": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz", @@ -226,6 +373,12 @@ "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", "dev": true }, + "collapse-white-space": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/collapse-white-space/-/collapse-white-space-1.0.5.tgz", + "integrity": "sha512-703bOOmytCYAX9cXYqoikYIx6twmFCXsnzRQheBcTG3nzKYBR4P/+wkYeH+Mvj7qUz8zZDtdyzbxfnEi/kYzRQ==", + "dev": true + }, "color-convert": { "version": "1.9.3", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", @@ -241,6 +394,12 @@ "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", "dev": true }, + "comment-parser": { + "version": "0.5.4", + "resolved": "https://registry.npmjs.org/comment-parser/-/comment-parser-0.5.4.tgz", + "integrity": "sha512-0h7W6Y1Kb6zKQMJqdX41C5qf9ITCVIsD2qP2RaqDF3GFkXFrmuAuv5zUOuo19YzyC9scjBNpqzuaRQ2Sy5pxMQ==", + "dev": true + }, "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -328,6 +487,12 @@ "esutils": "^2.0.2" } }, + "electron-to-chromium": { + "version": "1.3.133", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.133.tgz", + "integrity": "sha512-lyoC8aoqbbDqsprb6aPdt9n3DpOZZzdz/T4IZKsR0/dkZIxnJVUjjcpOSwA66jPRIOyDAamCTAUqweU05kKNSg==", + "dev": true + }, "emoji-regex": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", @@ -435,14 +600,35 @@ "ms": "^2.1.1" } }, - "ms": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", - "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", + "espree": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-5.0.1.tgz", + "integrity": "sha512-qWAZcWh4XE/RwzLJejfcofscgMc9CamR6Tn1+XRXNzrvUSSbiAjGOI/fggztjIi7y9VLPqnICMIPiGyr8JaZ0A==", + "dev": true, + "requires": { + "acorn": "^6.0.7", + "acorn-jsx": "^5.0.0", + "eslint-visitor-keys": "^1.0.0" + } + }, + "ignore": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", + "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==", "dev": true } } }, + "eslint-ast-utils": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/eslint-ast-utils/-/eslint-ast-utils-1.1.0.tgz", + "integrity": "sha512-otzzTim2/1+lVrlH19EfQQJEhVJSu0zOb9ygb3iapN6UlyaDtyRq4b5U1FuW0v1lRa9Fp/GJyHkSwm6NqABgCA==", + "dev": true, + "requires": { + "lodash.get": "^4.4.2", + "lodash.zip": "^4.2.0" + } + }, "eslint-config-airbnb-base": { "version": "13.1.0", "resolved": "https://registry.npmjs.org/eslint-config-airbnb-base/-/eslint-config-airbnb-base-13.1.0.tgz", @@ -454,6 +640,18 @@ "object.entries": "^1.0.4" } }, + "eslint-config-ash-nazg": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/eslint-config-ash-nazg/-/eslint-config-ash-nazg-6.0.1.tgz", + "integrity": "sha512-kar5/5XS6WBnuGCBgLgAiRU7h89BS8YsIvcZLnY3kVE5xr5yuup2VE/yDK465IBPvkBXgOwSYKjXjCQDUrjeiQ==", + "dev": true + }, + "eslint-config-standard": { + "version": "12.0.0", + "resolved": "https://registry.npmjs.org/eslint-config-standard/-/eslint-config-standard-12.0.0.tgz", + "integrity": "sha512-COUz8FnXhqFitYj4DTqHzidjIL/t4mumGZto5c7DrBpvWoie+Sn3P4sLEzUGeYhRElWuFEf8K1S1EfvD1vixCQ==", + "dev": true + }, "eslint-import-resolver-node": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.2.tgz", @@ -472,6 +670,12 @@ "requires": { "ms": "2.0.0" } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true } } }, @@ -493,13 +697,59 @@ "requires": { "ms": "2.0.0" } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true } } }, + "eslint-plugin-compat": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-compat/-/eslint-plugin-compat-3.1.1.tgz", + "integrity": "sha512-pqy5LBy4ZPhSVwb2p0+jUozdnoGX+qc1NRIcK+Yfg99149ncqZVc8gP5u637vwVC/nLQP6X6zTpnHwsZCdvluQ==", + "dev": true, + "requires": { + "@babel/runtime": "^7.4.2", + "ast-metadata-inferer": "^0.1.1", + "browserslist": "^4.5.2", + "caniuse-db": "^1.0.30000951", + "mdn-browser-compat-data": "^0.0.72", + "semver": "^5.6.0" + } + }, + "eslint-plugin-es": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-es/-/eslint-plugin-es-1.4.0.tgz", + "integrity": "sha512-XfFmgFdIUDgvaRAlaXUkxrRg5JSADoRC8IkKLc/cISeR3yHVMefFHQZpcyXXEUUPHfy5DwviBcrfqlyqEwlQVw==", + "dev": true, + "requires": { + "eslint-utils": "^1.3.0", + "regexpp": "^2.0.1" + } + }, + "eslint-plugin-eslint-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-eslint-comments/-/eslint-plugin-eslint-comments-3.1.1.tgz", + "integrity": "sha512-GZDKhOFqJLKlaABX+kdoLskcTINMrVOWxGca54KcFb1QCPd0CLmqgAMRxkkUfGSmN+5NJUMGh7NGccIMcWPSfQ==", + "dev": true, + "requires": { + "escape-string-regexp": "^1.0.5", + "ignore": "^5.0.5" + } + }, + "eslint-plugin-eslint-plugin": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-eslint-plugin/-/eslint-plugin-eslint-plugin-2.0.1.tgz", + "integrity": "sha512-kJ5TZsRJH/xYstG07v3YeOy/W5SDAEzV+bvvoL0aiG1HtqDmg4mJvNPnn/JngANMmsx8oXlJrIcBTCpJzm+9kg==", + "dev": true + }, "eslint-plugin-import": { - "version": "2.17.2", - "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.17.2.tgz", - "integrity": "sha512-m+cSVxM7oLsIpmwNn2WXTJoReOF9f/CtLMo7qOVmKd1KntBy0hEcuNZ3erTmWjx+DxRO0Zcrm5KwAvI9wHcV5g==", + "version": "2.17.3", + "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.17.3.tgz", + "integrity": "sha512-qeVf/UwXFJbeyLbxuY8RgqDyEKCkqV7YC+E5S5uOjAp4tOc8zj01JP3ucoBM8JcEqd1qRasJSg6LLlisirfy0Q==", "dev": true, "requires": { "array-includes": "^3.0.3", @@ -512,7 +762,7 @@ "lodash": "^4.17.11", "minimatch": "^3.0.4", "read-pkg-up": "^2.0.0", - "resolve": "^1.10.0" + "resolve": "^1.11.0" }, "dependencies": { "debug": { @@ -533,9 +783,129 @@ "esutils": "^2.0.2", "isarray": "^1.0.0" } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + }, + "resolve": { + "version": "1.11.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.11.0.tgz", + "integrity": "sha512-WL2pBDjqT6pGUNSUzMw00o4T7If+z4H2x3Gz893WoUQ5KW8Vr9txp00ykiP16VBaZF5+j/OcXJHZ9+PCvdiDKw==", + "dev": true, + "requires": { + "path-parse": "^1.0.6" + } } } }, + "eslint-plugin-jsdoc": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-7.0.2.tgz", + "integrity": "sha512-iqPdJsBy88FLrr8ru69Ab+SKPrjNEQwK2vicGXrBbDA6aia8IRVz2J2LPCfwdyuSxrI91bd4Za1Z57TC5tUp2w==", + "dev": true, + "requires": { + "comment-parser": "^0.5.4", + "jsdoctypeparser": "3.1.0", + "lodash": "^4.17.11" + } + }, + "eslint-plugin-markdown": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-markdown/-/eslint-plugin-markdown-1.0.0.tgz", + "integrity": "sha512-YIrClt3yLgyGov+rInjIoC/05zMxb/c6YXQZkyI9UKuBRFLgCrL37cxthj0JYWiTYtiHq0p8O0Nt0/HrvO48iQ==", + "dev": true, + "requires": { + "object-assign": "^4.0.1", + "remark-parse": "^5.0.0", + "unified": "^6.1.2" + } + }, + "eslint-plugin-no-use-extend-native": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-no-use-extend-native/-/eslint-plugin-no-use-extend-native-0.4.0.tgz", + "integrity": "sha512-9W2747CwC7aTJknLKY6ftdzj3AZz8DSaa64zONOMIemxH7YRr0+hqrvsNtHK/v9DusPuMxM9y9hBnfHwzKFmww==", + "dev": true, + "requires": { + "is-get-set-prop": "^1.0.0", + "is-js-type": "^2.0.0", + "is-obj-prop": "^1.0.0", + "is-proto-prop": "^2.0.0" + } + }, + "eslint-plugin-node": { + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-node/-/eslint-plugin-node-9.1.0.tgz", + "integrity": "sha512-ZwQYGm6EoV2cfLpE1wxJWsfnKUIXfM/KM09/TlorkukgCAwmkgajEJnPCmyzoFPQQkmvo5DrW/nyKutNIw36Mw==", + "dev": true, + "requires": { + "eslint-plugin-es": "^1.4.0", + "eslint-utils": "^1.3.1", + "ignore": "^5.1.1", + "minimatch": "^3.0.4", + "resolve": "^1.10.1", + "semver": "^6.1.0" + }, + "dependencies": { + "semver": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.1.0.tgz", + "integrity": "sha512-kCqEOOHoBcFs/2Ccuk4Xarm/KiWRSLEX9CAZF8xkJ6ZPlIoTZ8V5f7J16vYLJqDbR7KrxTJpR2lqjIEm2Qx9cQ==", + "dev": true + } + } + }, + "eslint-plugin-prettier": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-3.0.1.tgz", + "integrity": "sha512-/PMttrarPAY78PLvV3xfWibMOdMDl57hmlQ2XqFeA37wd+CJ7WSxV7txqjVPHi/AAFKd2lX0ZqfsOc/i5yFCSQ==", + "dev": true, + "requires": { + "prettier-linter-helpers": "^1.0.0" + } + }, + "eslint-plugin-promise": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-promise/-/eslint-plugin-promise-4.1.1.tgz", + "integrity": "sha512-faAHw7uzlNPy7b45J1guyjazw28M+7gJokKUjC5JSFoYfUEyy6Gw/i7YQvmv2Yk00sUjWcmzXQLpU1Ki/C2IZQ==", + "dev": true + }, + "eslint-plugin-standard": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-standard/-/eslint-plugin-standard-4.0.0.tgz", + "integrity": "sha512-OwxJkR6TQiYMmt1EsNRMe5qG3GsbjlcOhbGUBY4LtavF9DsLaTcoR+j2Tdjqi23oUwKNUqX7qcn5fPStafMdlA==", + "dev": true + }, + "eslint-plugin-unicorn": { + "version": "8.0.2", + "resolved": "https://registry.npmjs.org/eslint-plugin-unicorn/-/eslint-plugin-unicorn-8.0.2.tgz", + "integrity": "sha512-Ik2/Bt/PvPnf1lZgUnNFK2310XoRn/4LYiP5gkEPVDa4w9HCoii7I6SeKh2X5Rdp2WLy4eUiLcYtiBUp+q2IRw==", + "dev": true, + "requires": { + "clean-regexp": "^1.0.0", + "eslint-ast-utils": "^1.0.0", + "import-modules": "^1.1.0", + "lodash.camelcase": "^4.1.1", + "lodash.defaultsdeep": "^4.6.0", + "lodash.kebabcase": "^4.0.1", + "lodash.snakecase": "^4.0.1", + "lodash.topairs": "^4.3.0", + "lodash.upperfirst": "^4.2.0", + "reserved-words": "^0.1.2", + "safe-regex": "^2.0.1" + } + }, + "eslint-plugin-vue": { + "version": "5.2.2", + "resolved": "https://registry.npmjs.org/eslint-plugin-vue/-/eslint-plugin-vue-5.2.2.tgz", + "integrity": "sha512-CtGWH7IB0DA6BZOwcV9w9q3Ri6Yuo8qMjx05SmOGJ6X6E0Yo3y9E/gQ5tuNxg2dEt30tRnBoFTbvtmW9iEoyHA==", + "dev": true, + "requires": { + "vue-eslint-parser": "^5.0.0" + } + }, "eslint-restricted-globals": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/eslint-restricted-globals/-/eslint-restricted-globals-0.1.1.tgz", @@ -565,12 +935,12 @@ "dev": true }, "espree": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/espree/-/espree-5.0.1.tgz", - "integrity": "sha512-qWAZcWh4XE/RwzLJejfcofscgMc9CamR6Tn1+XRXNzrvUSSbiAjGOI/fggztjIi7y9VLPqnICMIPiGyr8JaZ0A==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-4.1.0.tgz", + "integrity": "sha512-I5BycZW6FCVIub93TeVY1s7vjhP9CY6cXCznIRfiig7nRviKZYdRnj/sHEWC6A7WE9RDWOFq9+7OsWSYz8qv2w==", "dev": true, "requires": { - "acorn": "^6.0.7", + "acorn": "^6.0.2", "acorn-jsx": "^5.0.0", "eslint-visitor-keys": "^1.0.0" } @@ -626,6 +996,12 @@ "strip-eof": "^1.0.0" } }, + "extend": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", + "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==", + "dev": true + }, "external-editor": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-3.0.3.tgz", @@ -643,6 +1019,12 @@ "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=", "dev": true }, + "fast-diff": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.2.0.tgz", + "integrity": "sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w==", + "dev": true + }, "fast-json-stable-stringify": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", @@ -738,6 +1120,12 @@ "integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=", "dev": true }, + "get-set-props": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/get-set-props/-/get-set-props-0.1.0.tgz", + "integrity": "sha1-mYR1wXhEVobQsyJG2l3428++jqM=", + "dev": true + }, "get-stream": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-4.1.0.tgz", @@ -748,9 +1136,9 @@ } }, "glob": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", + "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", "dev": true, "requires": { "fs.realpath": "^1.0.0", @@ -822,9 +1210,9 @@ } }, "ignore": { - "version": "4.0.6", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", - "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==", + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.1.1.tgz", + "integrity": "sha512-DWjnQIFLenVrwyRCKZT+7a7/U4Cqgar4WG8V++K3hw+lrW1hc/SIwdiGmtxKCVACmHULTuGeBbHJmbwW7/sAvA==", "dev": true }, "import-fresh": { @@ -837,6 +1225,12 @@ "resolve-from": "^4.0.0" } }, + "import-modules": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/import-modules/-/import-modules-1.1.0.tgz", + "integrity": "sha1-dI23nFzEK7lwHvq0JPiU5yYA6dw=", + "dev": true + }, "imurmurhash": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", @@ -903,6 +1297,22 @@ "integrity": "sha512-wPVv/y/QQ/Uiirj/vh3oP+1Ww+AWehmi1g5fFWGPF6IpCBCDVrhgHRMvrLfdYcwDh3QJbGXDW4JAuzxElLSqKA==", "dev": true }, + "is-alphabetical": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-alphabetical/-/is-alphabetical-1.0.2.tgz", + "integrity": "sha512-V0xN4BYezDHcBSKb1QHUFMlR4as/XEuCZBzMJUU4n7+Cbt33SmUnSol+pnXFvLxSHNq2CemUXNdaXV6Flg7+xg==", + "dev": true + }, + "is-alphanumerical": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-alphanumerical/-/is-alphanumerical-1.0.2.tgz", + "integrity": "sha512-pyfU/0kHdISIgslFfZN9nfY1Gk3MquQgUm1mJTjdkEPpkAKNWuBTSqFwewOpR7N351VkErCiyV71zX7mlQQqsg==", + "dev": true, + "requires": { + "is-alphabetical": "^1.0.0", + "is-decimal": "^1.0.0" + } + }, "is-arrayish": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", @@ -927,18 +1337,75 @@ "integrity": "sha1-mqIOtq7rv/d/vTPnTKAbM1gdOhY=", "dev": true }, + "is-decimal": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-decimal/-/is-decimal-1.0.2.tgz", + "integrity": "sha512-TRzl7mOCchnhchN+f3ICUCzYvL9ul7R+TYOsZ8xia++knyZAJfv/uA1FvQXsAnYIl1T3B2X5E/J7Wb1QXiIBXg==", + "dev": true + }, "is-fullwidth-code-point": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", "dev": true }, + "is-get-set-prop": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-get-set-prop/-/is-get-set-prop-1.0.0.tgz", + "integrity": "sha1-JzGHfk14pqae3M5rudaLB3nnYxI=", + "dev": true, + "requires": { + "get-set-props": "^0.1.0", + "lowercase-keys": "^1.0.0" + } + }, + "is-hexadecimal": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-hexadecimal/-/is-hexadecimal-1.0.2.tgz", + "integrity": "sha512-but/G3sapV3MNyqiDBLrOi4x8uCIw0RY3o/Vb5GT0sMFHrVV7731wFSVy41T5FO1og7G0gXLJh0MkgPRouko/A==", + "dev": true + }, + "is-js-type": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-js-type/-/is-js-type-2.0.0.tgz", + "integrity": "sha1-c2FwBtZZtOtHKbunR9KHgt8PfiI=", + "dev": true, + "requires": { + "js-types": "^1.0.0" + } + }, + "is-obj-prop": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-obj-prop/-/is-obj-prop-1.0.0.tgz", + "integrity": "sha1-s03nnEULjXxzqyzfZ9yHWtuF+A4=", + "dev": true, + "requires": { + "lowercase-keys": "^1.0.0", + "obj-props": "^1.0.0" + } + }, + "is-plain-obj": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz", + "integrity": "sha1-caUMhCnfync8kqOQpKA7OfzVHT4=", + "dev": true + }, "is-promise": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz", "integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=", "dev": true }, + "is-proto-prop": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-proto-prop/-/is-proto-prop-2.0.0.tgz", + "integrity": "sha512-jl3NbQ/fGLv5Jhan4uX+Ge9ohnemqyblWVVCpAvtTQzNFvV2xhJq+esnkIbYQ9F1nITXoLfDDQLp7LBw/zzncg==", + "dev": true, + "requires": { + "lowercase-keys": "^1.0.0", + "proto-props": "^2.0.0" + } + }, "is-regex": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.4.tgz", @@ -963,6 +1430,18 @@ "has-symbols": "^1.0.0" } }, + "is-whitespace-character": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-whitespace-character/-/is-whitespace-character-1.0.2.tgz", + "integrity": "sha512-SzM+T5GKUCtLhlHFKt2SDAX2RFzfS6joT91F2/WSi9LxgFdsnhfPK/UIA+JhRR2xuyLdrCys2PiFDrtn1fU5hQ==", + "dev": true + }, + "is-word-character": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-word-character/-/is-word-character-1.0.2.tgz", + "integrity": "sha512-T3FlsX8rCHAH8e7RE7PfOPZVFQlcV3XRF9eOOBQ1uf70OxO7CjjSOjeImMPCADBdYWcStAbVbYvJ1m2D3tb+EA==", + "dev": true + }, "isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", @@ -981,6 +1460,12 @@ "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", "dev": true }, + "js-types": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/js-types/-/js-types-1.0.0.tgz", + "integrity": "sha1-0kLmSU7Vcq08koCfyL7X92h8vwM=", + "dev": true + }, "js-yaml": { "version": "3.13.1", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", @@ -991,6 +1476,12 @@ "esprima": "^4.0.0" } }, + "jsdoctypeparser": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/jsdoctypeparser/-/jsdoctypeparser-3.1.0.tgz", + "integrity": "sha512-JNbkKpDFqbYjg+IU3FNo7qjX7Opy7CwjHywT32zgAcz/d4lX6Umn5jOHVETUdnNNgGrMk0nEx1gvP0F4M0hzlQ==", + "dev": true + }, "json-schema-traverse": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", @@ -1050,6 +1541,60 @@ "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==", "dev": true }, + "lodash.camelcase": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz", + "integrity": "sha1-soqmKIorn8ZRA1x3EfZathkDMaY=", + "dev": true + }, + "lodash.defaultsdeep": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/lodash.defaultsdeep/-/lodash.defaultsdeep-4.6.0.tgz", + "integrity": "sha1-vsECT4WxvZbL6kBbI8FK1kQ6b4E=", + "dev": true + }, + "lodash.get": { + "version": "4.4.2", + "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", + "integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=", + "dev": true + }, + "lodash.kebabcase": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/lodash.kebabcase/-/lodash.kebabcase-4.1.1.tgz", + "integrity": "sha1-hImxyw0p/4gZXM7KRI/21swpXDY=", + "dev": true + }, + "lodash.snakecase": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/lodash.snakecase/-/lodash.snakecase-4.1.1.tgz", + "integrity": "sha1-OdcUo1NXFHg3rv1ktdy7Fr7Nj40=", + "dev": true + }, + "lodash.topairs": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/lodash.topairs/-/lodash.topairs-4.3.0.tgz", + "integrity": "sha1-O23qo31g+xFnE8RsXxfqGQ7EjWQ=", + "dev": true + }, + "lodash.unescape": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/lodash.unescape/-/lodash.unescape-4.0.1.tgz", + "integrity": "sha1-vyJJiGzlFM2hEvrpIYzcBlIR/Jw=", + "dev": true + }, + "lodash.upperfirst": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/lodash.upperfirst/-/lodash.upperfirst-4.3.1.tgz", + "integrity": "sha1-E2Xt9DFIBIHvDRxolXpe2Z1J984=", + "dev": true + }, + "lodash.zip": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/lodash.zip/-/lodash.zip-4.2.0.tgz", + "integrity": "sha1-7GZi5IlkCO1KtsVCo5kLcswIACA=", + "dev": true + }, "log-symbols": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-2.2.0.tgz", @@ -1059,6 +1604,12 @@ "chalk": "^2.0.1" } }, + "lowercase-keys": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-1.0.1.tgz", + "integrity": "sha512-G2Lj61tXDnVFFOi8VZds+SoQjtQC3dgokKdDG2mTm1tx4m50NUHBOZSBwQQHyy0V12A0JTG4icfZQH+xPyh8VA==", + "dev": true + }, "make-node": { "version": "0.4.6", "resolved": "https://registry.npmjs.org/make-node/-/make-node-0.4.6.tgz", @@ -1074,6 +1625,21 @@ "p-defer": "^1.0.0" } }, + "markdown-escapes": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/markdown-escapes/-/markdown-escapes-1.0.3.tgz", + "integrity": "sha512-XUi5HJhhV5R74k8/0H2oCbCiYf/u4cO/rX8tnGkRvrqhsr5BRNU6Mg0yt/8UIx1iIS8220BNJsDb7XnILhLepw==", + "dev": true + }, + "mdn-browser-compat-data": { + "version": "0.0.72", + "resolved": "https://registry.npmjs.org/mdn-browser-compat-data/-/mdn-browser-compat-data-0.0.72.tgz", + "integrity": "sha512-vt3BxJRpV638ncYLigX91k0qP1VcpKxgExqPtX+QKFvV4/ZruZ31Sl35LsDDq5q+D7Lt7mfGWnCEuZ0d6bJW1g==", + "dev": true, + "requires": { + "extend": "3.0.2" + } + }, "mem": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/mem/-/mem-4.3.0.tgz", @@ -1229,9 +1795,9 @@ } }, "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", "dev": true }, "mute-stream": { @@ -1262,6 +1828,15 @@ "semver": "^5.7.0" } }, + "node-releases": { + "version": "1.1.18", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.18.tgz", + "integrity": "sha512-/mnVgm6u/8OwlIsoyRXtTI0RfQcxZoAZbdwyXap0EeWwcOpDDymyCHM2/aR9XKmHXrvizHoPAOs0pcbiJ6RUaA==", + "dev": true, + "requires": { + "semver": "^5.3.0" + } + }, "normalize-package-data": { "version": "2.5.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", @@ -1289,6 +1864,18 @@ "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", "dev": true }, + "obj-props": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/obj-props/-/obj-props-1.1.0.tgz", + "integrity": "sha1-YmMT+qRCvv1KROmgLDy2vek3tRE=", + "dev": true + }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "dev": true + }, "object-keys": { "version": "1.0.12", "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.0.12.tgz", @@ -1429,6 +2016,20 @@ "callsites": "^3.0.0" } }, + "parse-entities": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/parse-entities/-/parse-entities-1.2.1.tgz", + "integrity": "sha512-NBWYLQm1KSoDKk7GAHyioLTvCZ5QjdH/ASBBQTD3iLiAWJXS5bg1jEWI8nIJ+vgVvsceBVBcDGRWSo0KVQBvvg==", + "dev": true, + "requires": { + "character-entities": "^1.0.0", + "character-entities-legacy": "^1.0.0", + "character-reference-invalid": "^1.0.0", + "is-alphanumerical": "^1.0.0", + "is-decimal": "^1.0.0", + "is-hexadecimal": "^1.0.0" + } + }, "parse-json": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz", @@ -1504,12 +2105,33 @@ "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", "dev": true }, + "prettier": { + "version": "1.14.3", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.14.3.tgz", + "integrity": "sha512-qZDVnCrnpsRJJq5nSsiHCE3BYMED2OtsI+cmzIzF1QIfqm5ALf8tEJcO27zV1gKNKRPdhjO0dNWnrzssDQ1tFg==", + "dev": true + }, + "prettier-linter-helpers": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz", + "integrity": "sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==", + "dev": true, + "requires": { + "fast-diff": "^1.1.2" + } + }, "progress": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", "dev": true }, + "proto-props": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/proto-props/-/proto-props-2.0.0.tgz", + "integrity": "sha512-2yma2tog9VaRZY2mn3Wq51uiSW4NcPYT1cQdBagwyrznrilKSZwIZ0UG3ZPL/mx+axEns0hE35T5ufOYZXEnBQ==", + "dev": true + }, "pump": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", @@ -1547,12 +2169,59 @@ "read-pkg": "^2.0.0" } }, + "regenerator-runtime": { + "version": "0.13.2", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.2.tgz", + "integrity": "sha512-S/TQAZJO+D3m9xeN1WTI8dLKBBiRgXBlTJvbWjCThHWZj9EvHK70Ff50/tYj2J/fvBY6JtFVwRuazHN2E7M9BA==", + "dev": true + }, + "regexp-tree": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/regexp-tree/-/regexp-tree-0.1.6.tgz", + "integrity": "sha512-LFrA98Dw/heXqDojz7qKFdygZmFoiVlvE1Zp7Cq2cvF+ZA+03Gmhy0k0PQlsC1jvHPiTUSs+pDHEuSWv6+6D7w==", + "dev": true + }, "regexpp": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-2.0.1.tgz", "integrity": "sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw==", "dev": true }, + "remark-parse": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/remark-parse/-/remark-parse-5.0.0.tgz", + "integrity": "sha512-b3iXszZLH1TLoyUzrATcTQUZrwNl1rE70rVdSruJFlDaJ9z5aMkhrG43Pp68OgfHndL/ADz6V69Zow8cTQu+JA==", + "dev": true, + "requires": { + "collapse-white-space": "^1.0.2", + "is-alphabetical": "^1.0.0", + "is-decimal": "^1.0.0", + "is-whitespace-character": "^1.0.0", + "is-word-character": "^1.0.0", + "markdown-escapes": "^1.0.0", + "parse-entities": "^1.1.0", + "repeat-string": "^1.5.4", + "state-toggle": "^1.0.0", + "trim": "0.0.1", + "trim-trailing-lines": "^1.0.0", + "unherit": "^1.0.4", + "unist-util-remove-position": "^1.0.0", + "vfile-location": "^2.0.0", + "xtend": "^4.0.1" + } + }, + "repeat-string": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", + "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", + "dev": true + }, + "replace-ext": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/replace-ext/-/replace-ext-1.0.0.tgz", + "integrity": "sha1-3mMSg3P8v3w8z6TeWkgMRaZ5WOs=", + "dev": true + }, "require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", @@ -1565,6 +2234,18 @@ "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==", "dev": true }, + "requireindex": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/requireindex/-/requireindex-1.2.0.tgz", + "integrity": "sha512-L9jEkOi3ASd9PYit2cwRfyppc9NoABujTP8/5gFcbERmo5jUoAKovIC3fsF17pkTnGsrByysqX+Kxd2OTNI1ww==", + "dev": true + }, + "reserved-words": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/reserved-words/-/reserved-words-0.1.2.tgz", + "integrity": "sha1-AKCUD5jNUBrqqsMWQR2a3FKzGrE=", + "dev": true + }, "resolve": { "version": "1.10.1", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.10.1.tgz", @@ -1597,22 +2278,6 @@ "dev": true, "requires": { "glob": "^7.1.3" - }, - "dependencies": { - "glob": { - "version": "7.1.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", - "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", - "dev": true, - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - } } }, "run-async": { @@ -1633,6 +2298,15 @@ "tslib": "^1.9.0" } }, + "safe-regex": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-2.0.2.tgz", + "integrity": "sha512-rRALJT0mh4qVFIJ9HvfjKDN77F9vp7kltOpFFI/8e6oKyHFmmxz4aSkY/YVauRDe7U0RrHdw9Lsxdel3E19s0A==", + "dev": true, + "requires": { + "regexp-tree": "~0.1.1" + } + }, "safer-buffer": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", @@ -1721,6 +2395,12 @@ "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", "dev": true }, + "state-toggle": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/state-toggle/-/state-toggle-1.0.1.tgz", + "integrity": "sha512-Qe8QntFrrpWTnHwvwj2FZTgv+PKIsp0B9VxLzLLbSpPXWOgRgc5LVj/aTiSfK1RqIeF9jeC1UeOH8Q8y60A7og==", + "dev": true + }, "string-width": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", @@ -1828,12 +2508,39 @@ "os-tmpdir": "~1.0.2" } }, + "trim": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/trim/-/trim-0.0.1.tgz", + "integrity": "sha1-WFhUf2spB1fulczMZm+1AITEYN0=", + "dev": true + }, + "trim-trailing-lines": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/trim-trailing-lines/-/trim-trailing-lines-1.1.1.tgz", + "integrity": "sha512-bWLv9BbWbbd7mlqqs2oQYnLD/U/ZqeJeJwbO0FG2zA1aTq+HTvxfHNKFa/HGCVyJpDiioUYaBhfiT6rgk+l4mg==", + "dev": true + }, + "trough": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/trough/-/trough-1.0.3.tgz", + "integrity": "sha512-fwkLWH+DimvA4YCy+/nvJd61nWQQ2liO/nF/RjkTpiOGi+zxZzVkhb1mvbHIIW4b/8nDsYI8uTmAlc0nNkRMOw==", + "dev": true + }, "tslib": { "version": "1.9.3", "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz", "integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==", "dev": true }, + "tsutils": { + "version": "3.10.0", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.10.0.tgz", + "integrity": "sha512-q20XSMq7jutbGB8luhKKsQldRKWvyBO2BGqni3p4yq8Ys9bEP/xQw3KepKmMRt9gJ4lvQSScrihJrcKdKoSU7Q==", + "dev": true, + "requires": { + "tslib": "^1.8.1" + } + }, "type-check": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", @@ -1849,6 +2556,75 @@ "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", "dev": true }, + "typescript": { + "version": "3.4.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.4.5.tgz", + "integrity": "sha512-YycBxUb49UUhdNMU5aJ7z5Ej2XGmaIBL0x34vZ82fn3hGvD+bgrMrVDpatgz2f7YxUMJxMkbWxJZeAvDxVe7Vw==", + "dev": true + }, + "unherit": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/unherit/-/unherit-1.1.1.tgz", + "integrity": "sha512-+XZuV691Cn4zHsK0vkKYwBEwB74T3IZIcxrgn2E4rKwTfFyI1zCh7X7grwh9Re08fdPlarIdyWgI8aVB3F5A5g==", + "dev": true, + "requires": { + "inherits": "^2.0.1", + "xtend": "^4.0.1" + } + }, + "unified": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/unified/-/unified-6.2.0.tgz", + "integrity": "sha512-1k+KPhlVtqmG99RaTbAv/usu85fcSRu3wY8X+vnsEhIxNP5VbVIDiXnLqyKIG+UMdyTg0ZX9EI6k2AfjJkHPtA==", + "dev": true, + "requires": { + "bail": "^1.0.0", + "extend": "^3.0.0", + "is-plain-obj": "^1.1.0", + "trough": "^1.0.0", + "vfile": "^2.0.0", + "x-is-string": "^0.1.0" + } + }, + "unist-util-is": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-2.1.2.tgz", + "integrity": "sha512-YkXBK/H9raAmG7KXck+UUpnKiNmUdB+aBGrknfQ4EreE1banuzrKABx3jP6Z5Z3fMSPMQQmeXBlKpCbMwBkxVw==", + "dev": true + }, + "unist-util-remove-position": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/unist-util-remove-position/-/unist-util-remove-position-1.1.2.tgz", + "integrity": "sha512-XxoNOBvq1WXRKXxgnSYbtCF76TJrRoe5++pD4cCBsssSiWSnPEktyFrFLE8LTk3JW5mt9hB0Sk5zn4x/JeWY7Q==", + "dev": true, + "requires": { + "unist-util-visit": "^1.1.0" + } + }, + "unist-util-stringify-position": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-1.1.2.tgz", + "integrity": "sha512-pNCVrk64LZv1kElr0N1wPiHEUoXNVFERp+mlTg/s9R5Lwg87f9bM/3sQB99w+N9D/qnM9ar3+AKDBwo/gm/iQQ==", + "dev": true + }, + "unist-util-visit": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-1.4.0.tgz", + "integrity": "sha512-FiGu34ziNsZA3ZUteZxSFaczIjGmksfSgdKqBfOejrrfzyUy5b7YrlzT1Bcvi+djkYDituJDy2XB7tGTeBieKw==", + "dev": true, + "requires": { + "unist-util-visit-parents": "^2.0.0" + } + }, + "unist-util-visit-parents": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-2.0.1.tgz", + "integrity": "sha512-6B0UTiMfdWql4cQ03gDTCSns+64Zkfo2OCbK31Ov0uMizEz+CJeAp0cgZVb5Fhmcd7Bct2iRNywejT0orpbqUA==", + "dev": true, + "requires": { + "unist-util-is": "^2.1.2" + } + }, "uri-js": { "version": "4.2.2", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", @@ -1868,6 +2644,66 @@ "spdx-expression-parse": "^3.0.0" } }, + "vfile": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/vfile/-/vfile-2.3.0.tgz", + "integrity": "sha512-ASt4mBUHcTpMKD/l5Q+WJXNtshlWxOogYyGYYrg4lt/vuRjC1EFQtlAofL5VmtVNIZJzWYFJjzGWZ0Gw8pzW1w==", + "dev": true, + "requires": { + "is-buffer": "^1.1.4", + "replace-ext": "1.0.0", + "unist-util-stringify-position": "^1.0.0", + "vfile-message": "^1.0.0" + }, + "dependencies": { + "is-buffer": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", + "dev": true + } + } + }, + "vfile-location": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/vfile-location/-/vfile-location-2.0.4.tgz", + "integrity": "sha512-KRL5uXQPoUKu+NGvQVL4XLORw45W62v4U4gxJ3vRlDfI9QsT4ZN1PNXn/zQpKUulqGDpYuT0XDfp5q9O87/y/w==", + "dev": true + }, + "vfile-message": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/vfile-message/-/vfile-message-1.1.1.tgz", + "integrity": "sha512-1WmsopSGhWt5laNir+633LszXvZ+Z/lxveBf6yhGsqnQIhlhzooZae7zV6YVM1Sdkw68dtAW3ow0pOdPANugvA==", + "dev": true, + "requires": { + "unist-util-stringify-position": "^1.1.1" + } + }, + "vue-eslint-parser": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/vue-eslint-parser/-/vue-eslint-parser-5.0.0.tgz", + "integrity": "sha512-JlHVZwBBTNVvzmifwjpZYn0oPWH2SgWv5dojlZBsrhablDu95VFD+hriB1rQGwbD+bms6g+rAFhQHk6+NyiS6g==", + "dev": true, + "requires": { + "debug": "^4.1.0", + "eslint-scope": "^4.0.0", + "eslint-visitor-keys": "^1.0.0", + "espree": "^4.1.0", + "esquery": "^1.0.1", + "lodash": "^4.17.11" + }, + "dependencies": { + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + } + } + }, "which": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", @@ -1960,6 +2796,18 @@ "mkdirp": "^0.5.1" } }, + "x-is-string": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/x-is-string/-/x-is-string-0.1.0.tgz", + "integrity": "sha1-R0tQhlrzpJqcRlfwWs0UVFj3fYI=", + "dev": true + }, + "xtend": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", + "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", + "dev": true + }, "y18n": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz", diff --git a/package.json b/package.json index ad84701d..7854b97f 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,9 @@ "name": "Rowan Wookey", "email": "admin@rwky.net" }, + "contributors": [ + "Brett Zamir" + ], "repository": { "type": "git", "url": "git://github.com/passport-next/passport.git" @@ -20,34 +23,45 @@ "bugs": { "url": "http://github.com/passport-next/passport/issues" }, + "homepage": "https://github.com/passport-next/passport", "license": "MIT", - "licenses": [ - { - "type": "MIT", - "url": "http://opensource.org/licenses/MIT" - } - ], "main": "./lib", + "browserslist": [ + "node >= 8.0.0" + ], "dependencies": { "@passport-next/passport-strategy": "1.x.x" }, "devDependencies": { + "@mysticatea/eslint-plugin": "^10.0.3", "@passport-next/chai-passport-strategy": "1.x.x", "chai": "4.x.x", "chai-connect-middleware": "0.x.x", "eslint": "^5.16.0", "eslint-config-airbnb-base": "13.x.x", - "eslint-plugin-import": "^2.17.2", + "eslint-config-ash-nazg": "^6.0.1", + "eslint-config-standard": "^12.0.0", + "eslint-plugin-compat": "^3.1.1", + "eslint-plugin-eslint-comments": "^3.1.1", + "eslint-plugin-import": "^2.17.3", + "eslint-plugin-jsdoc": "^7.0.2", + "eslint-plugin-markdown": "^1.0.0", + "eslint-plugin-no-use-extend-native": "^0.4.0", + "eslint-plugin-node": "^9.1.0", + "eslint-plugin-promise": "^4.1.1", + "eslint-plugin-standard": "^4.0.0", + "eslint-plugin-unicorn": "^8.0.2", "make-node": "^0.4.6", - "mocha": "6.x.x" + "mocha": "6.x.x", + "typescript": "^3.4.5" }, "engines": { "node": ">=8.0.0" }, "scripts": { - "spec": "node_modules/.bin/mocha --reporter spec --require test/bootstrap/node test/*.test.js test/**/*.test.js", - "lint": "eslint --ext .js . --max-warnings 0", - "lintfix": "eslint --ext .js . --fix", + "spec": "mocha --reporter spec --require test/bootstrap/node test/*.test.js test/**/*.test.js", + "lint": "eslint --ext js,md . --max-warnings 0", + "lintfix": "eslint --ext js,md . --fix", "test": "npm run lint && npm run spec" } } diff --git a/test/authenticator.framework.test.js b/test/authenticator.framework.test.js index afb05aaa..6d966341 100644 --- a/test/authenticator.framework.test.js +++ b/test/authenticator.framework.test.js @@ -1,6 +1,5 @@ -/* global describe, it, expect */ - -/* eslint-disable camelcase, no-proto, no-shadow */ +/* eslint-disable no-shadow */ +'use strict'; const Authenticator = require('../lib/authenticator'); diff --git a/test/authenticator.middleware.test.js b/test/authenticator.middleware.test.js index ef23b9e2..519ca5db 100644 --- a/test/authenticator.middleware.test.js +++ b/test/authenticator.middleware.test.js @@ -1,6 +1,6 @@ -/* global describe, it, expect, before */ -/* jshint expr: true */ -/* eslint-disable no-underscore-dangle, camelcase, no-proto, no-shadow */ +/* eslint-disable no-shadow */ + +'use strict'; const chai = require('chai'); const Authenticator = require('../lib/authenticator'); @@ -110,12 +110,12 @@ describe('Authenticator', () => { }); describe('handling a request', () => { - function Strategy() { + class Strategy { + authenticate() { + const user = { id: '1', username: 'jaredhanson' }; + this.success(user); + } } - Strategy.prototype.authenticate = function authenticate() { - const user = { id: '1', username: 'jaredhanson' }; - this.success(user); - }; const passport = new Authenticator(); passport.use('success', new Strategy()); @@ -166,12 +166,12 @@ describe('Authenticator', () => { }); describe('handling a request', () => { - function Strategy() { + class Strategy { + authenticate() { + const user = { id: '1', username: 'jaredhanson' }; + this.success(user); + } } - Strategy.prototype.authenticate = function authenticate() { - const user = { id: '1', username: 'jaredhanson' }; - this.success(user); - }; const passport = new Authenticator(); passport.use('success', new Strategy()); diff --git a/test/authenticator.test.js b/test/authenticator.test.js index adb2e9a7..15a27bfc 100644 --- a/test/authenticator.test.js +++ b/test/authenticator.test.js @@ -1,7 +1,4 @@ -/* global describe, it, expect, before */ -/* jshint expr: true, sub: true */ - -/* eslint-disable camelcase, no-proto, no-shadow */ +'use strict'; const Authenticator = require('../lib/authenticator'); @@ -19,10 +16,14 @@ describe('Authenticator', () => { describe('#use', () => { describe('with instance name', () => { - function Strategy() { - this.name = 'default'; + class Strategy { + constructor() { + this.name = 'default'; + } + + // eslint-disable-next-line class-methods-use-this + authenticate() {} } - Strategy.prototype.authenticate = function authenticate() {}; const authenticator = new Authenticator(); authenticator.use(new Strategy()); @@ -33,9 +34,10 @@ describe('Authenticator', () => { }); describe('with registered name', () => { - function Strategy() { + class Strategy { + // eslint-disable-next-line class-methods-use-this + authenticate() {} } - Strategy.prototype.authenticate = function authenticate() {}; const authenticator = new Authenticator(); authenticator.use('foo', new Strategy()); @@ -46,10 +48,14 @@ describe('Authenticator', () => { }); describe('with registered name overridding instance name', () => { - function Strategy() { - this.name = 'default'; + class Strategy { + constructor() { + this.name = 'default'; + } + + // eslint-disable-next-line class-methods-use-this + authenticate() {} } - Strategy.prototype.authenticate = function authenticate() {}; const authenticator = new Authenticator(); authenticator.use('bar', new Strategy()); @@ -62,9 +68,10 @@ describe('Authenticator', () => { }); it('should throw if lacking a name', () => { - function Strategy() { + class Strategy { + // eslint-disable-next-line class-methods-use-this + authenticate() {} } - Strategy.prototype.authenticate = function authenticate() {}; expect(() => { const authenticator = new Authenticator(); @@ -75,9 +82,10 @@ describe('Authenticator', () => { describe('#unuse', () => { - function Strategy() { + class Strategy { + // eslint-disable-next-line class-methods-use-this + authenticate() {} } - Strategy.prototype.authenticate = function authenticate() {}; const authenticator = new Authenticator(); authenticator.use('one', new Strategy()); diff --git a/test/bootstrap/node.js b/test/bootstrap/node.js index 7ea8dd1c..3d78739f 100644 --- a/test/bootstrap/node.js +++ b/test/bootstrap/node.js @@ -1,3 +1,5 @@ +'use strict'; + const chai = require('chai'); chai.use(require('chai-connect-middleware')); diff --git a/test/http/request.test.js b/test/http/request.test.js index ee6e33af..c243ad5b 100644 --- a/test/http/request.test.js +++ b/test/http/request.test.js @@ -1,13 +1,10 @@ -/* global describe, it, expect, before */ -/* jshint expr: true */ - -/* eslint-disable camelcase, no-proto, no-shadow */ +'use strict'; const http = require('http'); -const Passport = require('../..').Passport; +const { Passport } = require('../..'); const initialize = require('../../lib/middleware/initialize'); -function setup() { +function setupPassport() { const passport = new Passport(); const req = new http.IncomingMessage(); const middleware = initialize(passport); @@ -17,7 +14,7 @@ function setup() { describe('http.ServerRequest', () => { describe('prototoype', () => { - const { req } = setup(); + const { req } = setupPassport(); it('should be extended with login', () => { expect(req.login).to.be.an('function'); expect(req.login).to.equal(req.logIn); @@ -39,7 +36,7 @@ describe('http.ServerRequest', () => { describe('#login', () => { describe('not establishing a session', () => { - const { req } = setup(); + const { req } = setupPassport(); req._passport.session = {}; let error; @@ -77,7 +74,7 @@ describe('http.ServerRequest', () => { }); describe('not establishing a session and setting custom user property', () => { - const { req, passport } = setup(); + const { req, passport } = setupPassport(); req._passport.session = {}; passport._userProperty = 'currentUser'; let error; @@ -121,7 +118,7 @@ describe('http.ServerRequest', () => { }); describe('not establishing a session and invoked without a callback', () => { - const { req } = setup(); + const { req } = setupPassport(); req._passport.session = {}; const user = { id: '1', username: 'root' }; @@ -147,7 +144,7 @@ describe('http.ServerRequest', () => { }); describe('not establishing a session, without passport.initialize() middleware', () => { - const { req } = setup(); + const { req } = setupPassport(); let error; before((done) => { @@ -179,7 +176,7 @@ describe('http.ServerRequest', () => { }); describe('establishing a session', () => { - const { req, passport } = setup(); + const { req, passport } = setupPassport(); passport.serializeUser((user, done) => { done(null, user.id); }); @@ -218,7 +215,7 @@ describe('http.ServerRequest', () => { }); describe('establishing a session and setting custom user property', () => { - const { req, passport } = setup(); + const { req, passport } = setupPassport(); passport.serializeUser((user, done) => { done(null, user.id); }); @@ -264,7 +261,7 @@ describe('http.ServerRequest', () => { }); describe('encountering an error when serializing to session', () => { - const { req, passport } = setup(); + const { req, passport } = setupPassport(); req._passport.session = {}; passport.serializeUser((user, done) => { done(new Error('something went wrong')); @@ -305,7 +302,7 @@ describe('http.ServerRequest', () => { }); describe('establishing a session, but not passing a callback argument', () => { - const { req, passport } = setup(); + const { req, passport } = setupPassport(); passport.serializeUser((user, done) => { done(null, user.id); }); @@ -323,7 +320,7 @@ describe('http.ServerRequest', () => { describe('#logout', () => { describe('existing session', () => { - const { req } = setup(); + const { req } = setupPassport(); req.user = { id: '1', username: 'root' }; req._passport.session = {}; req._passport.session.user = '1'; @@ -349,7 +346,7 @@ describe('http.ServerRequest', () => { }); describe('existing session and clearing custom user property', () => { - const { req } = setup(); + const { req } = setupPassport(); req.currentUser = { id: '1', username: 'root' }; req._passport.instance._userProperty = 'currentUser'; req._passport.session = {}; @@ -376,7 +373,7 @@ describe('http.ServerRequest', () => { }); describe('existing session, without passport.initialize() middleware', () => { - const { req } = setup(); + const { req } = setupPassport(); req.user = { id: '1', username: 'root' }; req.logout(); @@ -398,7 +395,7 @@ describe('http.ServerRequest', () => { describe('#isAuthenticated', () => { describe('with a user', () => { - const { req } = setup(); + const { req } = setupPassport(); req.user = { id: '1', username: 'root' }; it('should be authenticated', () => { @@ -410,7 +407,7 @@ describe('http.ServerRequest', () => { }); describe('with a user set on custom property', () => { - const { req } = setup(); + const { req } = setupPassport(); req.currentUser = { id: '1', username: 'root' }; req._passport.instance._userProperty = 'currentUser'; @@ -423,7 +420,7 @@ describe('http.ServerRequest', () => { }); describe('without a user', () => { - const { req } = setup(); + const { req } = setupPassport(); it('should not be authenticated', () => { // eslint-disable-next-line no-unused-expressions @@ -434,7 +431,7 @@ describe('http.ServerRequest', () => { }); describe('with a null user', () => { - const { req } = setup(); + const { req } = setupPassport(); req.user = null; it('should not be authenticated', () => { diff --git a/test/middleware/authenticate.error.callback.test.js b/test/middleware/authenticate.error.callback.test.js index 3295e554..e52df8ed 100644 --- a/test/middleware/authenticate.error.callback.test.js +++ b/test/middleware/authenticate.error.callback.test.js @@ -1,20 +1,16 @@ -/* global describe, it, expect, before */ -/* jshint expr: true */ - -/* eslint-disable camelcase, no-proto, no-shadow */ - +'use strict'; const chai = require('chai'); -const Passport = require('../..').Passport; +const { Passport } = require('../..'); const authenticate = require('../../lib/middleware/authenticate'); describe('middleware/authenticate', () => { describe('error with callback', () => { - function Strategy() { + class Strategy { + authenticate() { + this.error(new Error('something is wrong')); + } } - Strategy.prototype.authenticate = function authenticate() { - this.error(new Error('something is wrong')); - }; const passport = new Passport(); passport.use('error', new Strategy()); @@ -52,11 +48,11 @@ describe('middleware/authenticate', () => { }); describe('error with callback and options passed to middleware', () => { - function Strategy() { + class Strategy { + authenticate() { + this.error(new Error('something is wrong')); + } } - Strategy.prototype.authenticate = function authenticate() { - this.error(new Error('something is wrong')); - }; const passport = new Passport(); passport.use('error', new Strategy()); diff --git a/test/middleware/authenticate.error.test.js b/test/middleware/authenticate.error.test.js index c201d660..3982b1cd 100644 --- a/test/middleware/authenticate.error.test.js +++ b/test/middleware/authenticate.error.test.js @@ -1,20 +1,17 @@ -/* global describe, it, expect, before */ -/* jshint expr: true */ - -/* eslint-disable camelcase, no-proto, no-shadow */ +'use strict'; const chai = require('chai'); const authenticate = require('../../lib/middleware/authenticate'); -const Passport = require('../..').Passport; +const { Passport } = require('../..'); describe('middleware/authenticate', () => { describe('error', () => { - function Strategy() { + class Strategy { + authenticate() { + this.error(new Error('something is wrong')); + } } - Strategy.prototype.authenticate = function authenticate() { - this.error(new Error('something is wrong')); - }; const passport = new Passport(); passport.use('error', new Strategy()); diff --git a/test/middleware/authenticate.fail.callback.test.js b/test/middleware/authenticate.fail.callback.test.js index 73bba9d4..8d36465d 100644 --- a/test/middleware/authenticate.fail.callback.test.js +++ b/test/middleware/authenticate.fail.callback.test.js @@ -1,19 +1,16 @@ -/* global describe, it, expect, before */ -/* jshint expr: true */ - -/* eslint-disable camelcase, no-proto, no-shadow */ +'use strict'; const chai = require('chai'); const authenticate = require('../../lib/middleware/authenticate'); -const Passport = require('../..').Passport; +const { Passport } = require('../..'); describe('middleware/authenticate', () => { describe('fail with callback', () => { - function Strategy() { + class Strategy { + authenticate() { + this.fail(); + } } - Strategy.prototype.authenticate = function authenticate() { - this.fail(); - }; const passport = new Passport(); passport.use('fail', new Strategy()); @@ -52,11 +49,11 @@ describe('middleware/authenticate', () => { }); describe('fail with callback, passing info', () => { - function Strategy() { + class Strategy { + authenticate() { + this.fail({ message: 'Invalid password' }); + } } - Strategy.prototype.authenticate = function authenticate() { - this.fail({ message: 'Invalid password' }); - }; const passport = new Passport(); passport.use('fail', new Strategy()); @@ -109,11 +106,11 @@ describe('middleware/authenticate', () => { }); describe('fail with callback, passing info and status', () => { - function Strategy() { + class Strategy { + authenticate() { + this.fail({ message: 'Invalid password' }, 403); + } } - Strategy.prototype.authenticate = function authenticate() { - this.fail({ message: 'Invalid password' }, 403); - }; const passport = new Passport(); passport.use('fail', new Strategy()); @@ -165,11 +162,11 @@ describe('middleware/authenticate', () => { }); describe('fail with callback, passing challenge', () => { - function Strategy() { + class Strategy { + authenticate() { + this.fail('Bearer challenge'); + } } - Strategy.prototype.authenticate = function authenticate() { - this.fail('Bearer challenge'); - }; const passport = new Passport(); passport.use('fail', new Strategy()); @@ -221,11 +218,11 @@ describe('middleware/authenticate', () => { }); describe('fail with callback, passing challenge and status', () => { - function Strategy() { + class Strategy { + authenticate() { + this.fail('Bearer challenge', 403); + } } - Strategy.prototype.authenticate = function authenticate() { - this.fail('Bearer challenge', 403); - }; const passport = new Passport(); passport.use('fail', new Strategy()); @@ -276,11 +273,11 @@ describe('middleware/authenticate', () => { }); describe('fail with callback, passing status', () => { - function Strategy() { + class Strategy { + authenticate() { + this.fail(402); + } } - Strategy.prototype.authenticate = function authenticate() { - this.fail(402); - }; const passport = new Passport(); passport.use('fail', new Strategy()); @@ -332,11 +329,11 @@ describe('middleware/authenticate', () => { }); describe('fail with callback and options passed to middleware', () => { - function Strategy() { + class Strategy { + authenticate() { + this.fail(); + } } - Strategy.prototype.authenticate = function authenticate() { - this.fail(); - }; const passport = new Passport(); passport.use('fail', new Strategy()); diff --git a/test/middleware/authenticate.fail.flash.test.js b/test/middleware/authenticate.fail.flash.test.js index 8d5398e3..62da8859 100644 --- a/test/middleware/authenticate.fail.flash.test.js +++ b/test/middleware/authenticate.fail.flash.test.js @@ -1,21 +1,18 @@ -/* global describe, it, expect, before */ -/* jshint expr: true */ - -/* eslint-disable camelcase, no-proto, no-shadow */ +'use strict'; const chai = require('chai'); const authenticate = require('../../lib/middleware/authenticate'); -const Passport = require('../..').Passport; +const { Passport } = require('../..'); describe('middleware/authenticate', () => { describe('using strategy that specifies message', () => { describe('fail with flash message', () => { - function Strategy() { + class Strategy { + authenticate() { + this.fail({ message: 'Invalid password' }); + } } - Strategy.prototype.authenticate = function authenticate() { - this.fail({ message: 'Invalid password' }); - }; const passport = new Passport(); passport.use('fail', new Strategy()); @@ -60,11 +57,11 @@ describe('middleware/authenticate', () => { }); describe('fail with flash message using type set by route', () => { - function Strategy() { + class Strategy { + authenticate() { + this.fail({ message: 'Invalid password' }); + } } - Strategy.prototype.authenticate = function authenticate() { - this.fail({ message: 'Invalid password' }); - }; const passport = new Passport(); passport.use('fail', new Strategy()); @@ -109,11 +106,11 @@ describe('middleware/authenticate', () => { }); describe('fail with flash message overridden by route as string', () => { - function Strategy() { + class Strategy { + authenticate() { + this.fail({ message: 'Invalid password' }); + } } - Strategy.prototype.authenticate = function authenticate() { - this.fail({ message: 'Invalid password' }); - }; const passport = new Passport(); passport.use('fail', new Strategy()); @@ -158,11 +155,11 @@ describe('middleware/authenticate', () => { }); describe('fail with flash message overridden by route using options', () => { - function Strategy() { + class Strategy { + authenticate() { + this.fail({ message: 'Invalid password' }); + } } - Strategy.prototype.authenticate = function authenticate() { - this.fail({ message: 'Invalid password' }); - }; const passport = new Passport(); passport.use('fail', new Strategy()); @@ -207,11 +204,11 @@ describe('middleware/authenticate', () => { }); describe('fail with flash message overridden by route using options with type', () => { - function Strategy() { + class Strategy { + authenticate() { + this.fail({ message: 'Invalid password' }); + } } - Strategy.prototype.authenticate = function authenticate() { - this.fail({ message: 'Invalid password' }); - }; const passport = new Passport(); passport.use('fail', new Strategy()); @@ -259,11 +256,11 @@ describe('middleware/authenticate', () => { describe('using strategy that specifies message and type', () => { describe('fail with flash message', () => { - function Strategy() { + class Strategy { + authenticate() { + this.fail({ type: 'notice', message: 'Invite required' }); + } } - Strategy.prototype.authenticate = function authenticate() { - this.fail({ type: 'notice', message: 'Invite required' }); - }; const passport = new Passport(); passport.use('fail', new Strategy()); @@ -308,11 +305,11 @@ describe('middleware/authenticate', () => { }); describe('fail with flash message using type set by route', () => { - function Strategy() { + class Strategy { + authenticate() { + this.fail({ type: 'notice', message: 'Invite required' }); + } } - Strategy.prototype.authenticate = function authenticate() { - this.fail({ type: 'notice', message: 'Invite required' }); - }; const passport = new Passport(); passport.use('fail', new Strategy()); @@ -357,11 +354,11 @@ describe('middleware/authenticate', () => { }); describe('fail with flash message overridden by route as string', () => { - function Strategy() { + class Strategy { + authenticate() { + this.fail({ type: 'notice', message: 'Invite required' }); + } } - Strategy.prototype.authenticate = function authenticate() { - this.fail({ type: 'notice', message: 'Invite required' }); - }; const passport = new Passport(); passport.use('fail', new Strategy()); @@ -406,11 +403,11 @@ describe('middleware/authenticate', () => { }); describe('fail with flash message overridden by route using options', () => { - function Strategy() { + class Strategy { + authenticate() { + this.fail({ type: 'notice', message: 'Invite required' }); + } } - Strategy.prototype.authenticate = function authenticate() { - this.fail({ type: 'notice', message: 'Invite required' }); - }; const passport = new Passport(); passport.use('fail', new Strategy()); @@ -455,11 +452,11 @@ describe('middleware/authenticate', () => { }); describe('fail with flash message overridden by route using options with type', () => { - function Strategy() { + class Strategy { + authenticate() { + this.fail({ type: 'notice', message: 'Invite required' }); + } } - Strategy.prototype.authenticate = function authenticate() { - this.fail({ type: 'notice', message: 'Invite required' }); - }; const passport = new Passport(); passport.use('fail', new Strategy()); @@ -507,11 +504,11 @@ describe('middleware/authenticate', () => { describe('using strategy that specifies message as string', () => { describe('fail with flash message', () => { - function Strategy() { + class Strategy { + authenticate() { + this.fail('Access denied'); + } } - Strategy.prototype.authenticate = function authenticate() { - this.fail('Access denied'); - }; const passport = new Passport(); passport.use('fail', new Strategy()); @@ -556,11 +553,11 @@ describe('middleware/authenticate', () => { }); describe('fail with flash message using type set by route', () => { - function Strategy() { + class Strategy { + authenticate() { + this.fail('Access denied'); + } } - Strategy.prototype.authenticate = function authenticate() { - this.fail('Access denied'); - }; const passport = new Passport(); passport.use('fail', new Strategy()); @@ -605,11 +602,11 @@ describe('middleware/authenticate', () => { }); describe('fail with flash message overridden by route as string', () => { - function Strategy() { + class Strategy { + authenticate() { + this.fail('Access denied'); + } } - Strategy.prototype.authenticate = function authenticate() { - this.fail('Access denied'); - }; const passport = new Passport(); passport.use('fail', new Strategy()); @@ -654,11 +651,11 @@ describe('middleware/authenticate', () => { }); describe('fail with flash message overridden by route using options', () => { - function Strategy() { + class Strategy { + authenticate() { + this.fail('Access denied'); + } } - Strategy.prototype.authenticate = function authenticate() { - this.fail('Access denied'); - }; const passport = new Passport(); passport.use('fail', new Strategy()); @@ -703,11 +700,11 @@ describe('middleware/authenticate', () => { }); describe('fail with flash message overridden by route using options with type', () => { - function Strategy() { + class Strategy { + authenticate() { + this.fail('Access denied'); + } } - Strategy.prototype.authenticate = function authenticate() { - this.fail('Access denied'); - }; const passport = new Passport(); passport.use('fail', new Strategy()); @@ -755,11 +752,11 @@ describe('middleware/authenticate', () => { describe('using strategy that does not specify message', () => { describe('fail with flash message left up to strategy', () => { - function Strategy() { + class Strategy { + authenticate() { + this.fail(); + } } - Strategy.prototype.authenticate = function authenticate() { - this.fail(); - }; const passport = new Passport(); passport.use('fail', new Strategy()); @@ -804,11 +801,11 @@ describe('middleware/authenticate', () => { }); describe('fail with flash message left up to strategy using type set by route', () => { - function Strategy() { + class Strategy { + authenticate() { + this.fail(); + } } - Strategy.prototype.authenticate = function authenticate() { - this.fail(); - }; const passport = new Passport(); passport.use('fail', new Strategy()); @@ -853,11 +850,11 @@ describe('middleware/authenticate', () => { }); describe('fail with flash message specified by route as string', () => { - function Strategy() { + class Strategy { + authenticate() { + this.fail(); + } } - Strategy.prototype.authenticate = function authenticate() { - this.fail(); - }; const passport = new Passport(); passport.use('fail', new Strategy()); @@ -902,11 +899,11 @@ describe('middleware/authenticate', () => { }); describe('fail with flash message specified by route using options', () => { - function Strategy() { + class Strategy { + authenticate() { + this.fail(); + } } - Strategy.prototype.authenticate = function authenticate() { - this.fail(); - }; const passport = new Passport(); passport.use('fail', new Strategy()); @@ -951,11 +948,11 @@ describe('middleware/authenticate', () => { }); describe('fail with flash message specified by route using options with type', () => { - function Strategy() { + class Strategy { + authenticate() { + this.fail(); + } } - Strategy.prototype.authenticate = function authenticate() { - this.fail(); - }; const passport = new Passport(); passport.use('fail', new Strategy()); diff --git a/test/middleware/authenticate.fail.message.test.js b/test/middleware/authenticate.fail.message.test.js index 17c74831..4653303e 100644 --- a/test/middleware/authenticate.fail.message.test.js +++ b/test/middleware/authenticate.fail.message.test.js @@ -1,20 +1,17 @@ -/* global describe, it, expect, before */ -/* jshint expr: true */ - -/* eslint-disable camelcase, no-proto, no-shadow */ +'use strict'; const chai = require('chai'); const authenticate = require('../../lib/middleware/authenticate'); -const Passport = require('../..').Passport; +const { Passport } = require('../..'); describe('middleware/authenticate', () => { describe('fail with message set by route', () => { - function Strategy() { + class Strategy { + authenticate() { + this.fail({ message: 'Invalid password' }); + } } - Strategy.prototype.authenticate = function authenticate() { - this.fail({ message: 'Invalid password' }); - }; const passport = new Passport(); passport.use('fail', new Strategy()); @@ -55,11 +52,11 @@ describe('middleware/authenticate', () => { }); describe('fail with message set by route that is added to messages', () => { - function Strategy() { + class Strategy { + authenticate() { + this.fail({ message: 'Invalid password' }); + } } - Strategy.prototype.authenticate = function authenticate() { - this.fail({ message: 'Invalid password' }); - }; const passport = new Passport(); passport.use('fail', new Strategy()); @@ -102,11 +99,11 @@ describe('middleware/authenticate', () => { }); describe('fail with message set by strategy', () => { - function Strategy() { + class Strategy { + authenticate() { + this.fail({ message: 'Invalid password' }); + } } - Strategy.prototype.authenticate = function authenticate() { - this.fail({ message: 'Invalid password' }); - }; const passport = new Passport(); passport.use('fail', new Strategy()); @@ -147,11 +144,11 @@ describe('middleware/authenticate', () => { }); describe('fail with message set by strategy with extra info', () => { - function Strategy() { + class Strategy { + authenticate() { + this.fail({ message: 'Invalid password', scope: 'read' }); + } } - Strategy.prototype.authenticate = function authenticate() { - this.fail({ message: 'Invalid password', scope: 'read' }); - }; const passport = new Passport(); passport.use('fail', new Strategy()); diff --git a/test/middleware/authenticate.fail.multi.test.js b/test/middleware/authenticate.fail.multi.test.js index 60deb858..b0a2cca5 100644 --- a/test/middleware/authenticate.fail.multi.test.js +++ b/test/middleware/authenticate.fail.multi.test.js @@ -1,32 +1,29 @@ -/* global describe, it, expect, before */ -/* jshint expr: true */ - -/* eslint-disable camelcase, no-proto, no-shadow */ +'use strict'; const chai = require('chai'); const authenticate = require('../../lib/middleware/authenticate'); -const Passport = require('../..').Passport; +const { Passport } = require('../..'); describe('middleware/authenticate', () => { describe('with multiple strategies, all of which fail, and responding with unauthorized status', () => { - function BasicStrategy() { + class BasicStrategy { + authenticate() { + this.fail('BASIC challenge'); + } } - BasicStrategy.prototype.authenticate = function authenticate() { - this.fail('BASIC challenge'); - }; - function DigestStrategy() { + class DigestStrategy { + authenticate() { + this.fail('DIGEST challenge'); + } } - DigestStrategy.prototype.authenticate = function authenticate() { - this.fail('DIGEST challenge'); - }; - function NoChallengeStrategy() { + class NoChallengeStrategy { + authenticate() { + this.fail(); + } } - NoChallengeStrategy.prototype.authenticate = function authenticate() { - this.fail(); - }; const passport = new Passport(); passport.use('basic', new BasicStrategy()); @@ -73,23 +70,23 @@ describe('middleware/authenticate', () => { }); describe('with multiple strategies, all of which fail, and responding with specified status', () => { - function BasicStrategy() { + class BasicStrategy { + authenticate() { + this.fail('BASIC challenge', 400); + } } - BasicStrategy.prototype.authenticate = function authenticate() { - this.fail('BASIC challenge', 400); - }; - function BearerStrategy() { + class BearerStrategy { + authenticate() { + this.fail('BEARER challenge', 403); + } } - BearerStrategy.prototype.authenticate = function authenticate() { - this.fail('BEARER challenge', 403); - }; - function NoChallengeStrategy() { + class NoChallengeStrategy { + authenticate() { + this.fail(402); + } } - NoChallengeStrategy.prototype.authenticate = function authenticate() { - this.fail(402); - }; const passport = new Passport(); passport.use('basic', new BasicStrategy()); @@ -129,17 +126,17 @@ describe('middleware/authenticate', () => { }); describe('with multiple strategies, all of which fail, and flashing message', () => { - function StrategyA() { + class StrategyA { + authenticate() { + this.fail('A message'); + } } - StrategyA.prototype.authenticate = function authenticate() { - this.fail('A message'); - }; - function StrategyB() { + class StrategyB { + authenticate() { + this.fail('B message'); + } } - StrategyB.prototype.authenticate = function authenticate() { - this.fail('B message'); - }; const passport = new Passport(); passport.use('a', new StrategyA()); @@ -184,23 +181,23 @@ describe('middleware/authenticate', () => { }); describe('with multiple strategies, all of which fail with unauthorized status, and invoking callback', () => { - function BasicStrategy() { + class BasicStrategy { + authenticate() { + this.fail('BASIC challenge'); + } } - BasicStrategy.prototype.authenticate = function authenticate() { - this.fail('BASIC challenge'); - }; - function DigestStrategy() { + class DigestStrategy { + authenticate() { + this.fail('DIGEST challenge'); + } } - DigestStrategy.prototype.authenticate = function authenticate() { - this.fail('DIGEST challenge'); - }; - function NoChallengeStrategy() { + class NoChallengeStrategy { + authenticate() { + this.fail(); + } } - NoChallengeStrategy.prototype.authenticate = function authenticate() { - this.fail(); - }; const passport = new Passport(); passport.use('basic', new BasicStrategy()); @@ -265,23 +262,23 @@ describe('middleware/authenticate', () => { }); describe('with multiple strategies, all of which fail with specific status, and invoking callback', () => { - function BasicStrategy() { + class BasicStrategy { + authenticate() { + this.fail('BASIC challenge', 400); + } } - BasicStrategy.prototype.authenticate = function authenticate() { - this.fail('BASIC challenge', 400); - }; - function BearerStrategy() { + class BearerStrategy { + authenticate() { + this.fail('BEARER challenge', 403); + } } - BearerStrategy.prototype.authenticate = function authenticate() { - this.fail('BEARER challenge', 403); - }; - function NoChallengeStrategy() { + class NoChallengeStrategy { + authenticate() { + this.fail(402); + } } - NoChallengeStrategy.prototype.authenticate = function authenticate() { - this.fail(402); - }; const passport = new Passport(); passport.use('basic', new BasicStrategy()); @@ -343,11 +340,11 @@ describe('middleware/authenticate', () => { }); describe('with single strategy in list, which fails with unauthorized status, and invoking callback', () => { - function BasicStrategy() { + class BasicStrategy { + authenticate() { + this.fail('BASIC challenge'); + } } - BasicStrategy.prototype.authenticate = function authenticate() { - this.fail('BASIC challenge'); - }; const passport = new Passport(); passport.use('basic', new BasicStrategy()); diff --git a/test/middleware/authenticate.fail.test.js b/test/middleware/authenticate.fail.test.js index ac45b55b..04b5d1d2 100644 --- a/test/middleware/authenticate.fail.test.js +++ b/test/middleware/authenticate.fail.test.js @@ -1,20 +1,17 @@ -/* global describe, it, expect, before */ -/* jshint expr: true */ - -/* eslint-disable camelcase, no-proto, no-shadow */ +'use strict'; const chai = require('chai'); const authenticate = require('../../lib/middleware/authenticate'); -const Passport = require('../..').Passport; +const { Passport } = require('../..'); describe('middleware/authenticate', () => { describe('fail', () => { - function Strategy() { + class Strategy { + authenticate() { + this.fail(); + } } - Strategy.prototype.authenticate = function authenticate() { - this.fail(); - }; const passport = new Passport(); passport.use('fail', new Strategy()); @@ -48,11 +45,11 @@ describe('middleware/authenticate', () => { }); describe('fail with redirect', () => { - function Strategy() { + class Strategy { + authenticate() { + this.fail(); + } } - Strategy.prototype.authenticate = function authenticate() { - this.fail(); - }; const passport = new Passport(); passport.use('fail', new Strategy()); @@ -84,11 +81,11 @@ describe('middleware/authenticate', () => { }); describe('fail with challenge', () => { - function Strategy() { + class Strategy { + authenticate() { + this.fail('MOCK challenge'); + } } - Strategy.prototype.authenticate = function authenticate() { - this.fail('MOCK challenge'); - }; const passport = new Passport(); passport.use('fail', new Strategy()); @@ -128,11 +125,11 @@ describe('middleware/authenticate', () => { }); describe('fail with challenge and status', () => { - function Strategy() { + class Strategy { + authenticate() { + this.fail('MOCK challenge', 403); + } } - Strategy.prototype.authenticate = function authenticate() { - this.fail('MOCK challenge', 403); - }; const passport = new Passport(); passport.use('fail', new Strategy()); @@ -166,11 +163,11 @@ describe('middleware/authenticate', () => { }); describe('fail with status', () => { - function Strategy() { + class Strategy { + authenticate() { + this.fail(400); + } } - Strategy.prototype.authenticate = function authenticate() { - this.fail(400); - }; const passport = new Passport(); passport.use('fail', new Strategy()); @@ -204,11 +201,11 @@ describe('middleware/authenticate', () => { }); describe('fail with error', () => { - function Strategy() { + class Strategy { + authenticate() { + this.fail(); + } } - Strategy.prototype.authenticate = function authenticate() { - this.fail(); - }; const passport = new Passport(); passport.use('fail', new Strategy()); @@ -254,11 +251,11 @@ describe('middleware/authenticate', () => { }); describe('fail with error, passing info to fail', () => { - function Strategy() { + class Strategy { + authenticate() { + this.fail({ message: 'Invalid credentials' }); + } } - Strategy.prototype.authenticate = function authenticate() { - this.fail({ message: 'Invalid credentials' }); - }; const passport = new Passport(); passport.use('fail', new Strategy()); @@ -304,11 +301,11 @@ describe('middleware/authenticate', () => { }); describe('fail with error, passing info and status to fail', () => { - function Strategy() { + class Strategy { + authenticate() { + this.fail({ message: 'Multiple credentials' }, 400); + } } - Strategy.prototype.authenticate = function authenticate() { - this.fail({ message: 'Multiple credentials' }, 400); - }; const passport = new Passport(); passport.use('fail', new Strategy()); @@ -354,11 +351,11 @@ describe('middleware/authenticate', () => { }); describe('fail with error, passing challenge to fail', () => { - function Strategy() { + class Strategy { + authenticate() { + this.fail('Bearer challenge'); + } } - Strategy.prototype.authenticate = function authenticate() { - this.fail('Bearer challenge'); - }; const passport = new Passport(); passport.use('fail', new Strategy()); @@ -410,11 +407,11 @@ describe('middleware/authenticate', () => { }); describe('fail with error, passing challenge and status to fail', () => { - function Strategy() { + class Strategy { + authenticate() { + this.fail('Bearer challenge', 403); + } } - Strategy.prototype.authenticate = function authenticate() { - this.fail('Bearer challenge', 403); - }; const passport = new Passport(); passport.use('fail', new Strategy()); @@ -460,11 +457,11 @@ describe('middleware/authenticate', () => { }); describe('fail with error, passing status to fail', () => { - function Strategy() { + class Strategy { + authenticate() { + this.fail(402); + } } - Strategy.prototype.authenticate = function authenticate() { - this.fail(402); - }; const passport = new Passport(); passport.use('fail', new Strategy()); diff --git a/test/middleware/authenticate.pass.test.js b/test/middleware/authenticate.pass.test.js index 49a35bf2..81875c90 100644 --- a/test/middleware/authenticate.pass.test.js +++ b/test/middleware/authenticate.pass.test.js @@ -1,20 +1,17 @@ -/* global describe, it, expect, before */ -/* jshint expr: true */ - -/* eslint-disable camelcase, no-proto, no-shadow */ +'use strict'; const chai = require('chai'); const authenticate = require('../../lib/middleware/authenticate'); -const Passport = require('../..').Passport; +const { Passport } = require('../..'); describe('middleware/authenticate', () => { describe('pass', () => { - function Strategy() { + class Strategy { + authenticate() { + this.pass(); + } } - Strategy.prototype.authenticate = function authenticate() { - this.pass(); - }; const passport = new Passport(); passport.use('pass', new Strategy()); diff --git a/test/middleware/authenticate.redirect.test.js b/test/middleware/authenticate.redirect.test.js index b7195f2a..98555629 100644 --- a/test/middleware/authenticate.redirect.test.js +++ b/test/middleware/authenticate.redirect.test.js @@ -1,20 +1,19 @@ -/* global describe, it, expect, before */ -/* jshint expr: true */ +/* eslint-disable no-shadow */ -/* eslint-disable camelcase, no-proto, no-shadow */ +'use strict'; const chai = require('chai'); const authenticate = require('../../lib/middleware/authenticate'); -const Passport = require('../..').Passport; +const { Passport } = require('../..'); describe('middleware/authenticate', () => { describe('redirect', () => { - function Strategy() { + class Strategy { + authenticate() { + this.redirect('http://www.example.com/idp'); + } } - Strategy.prototype.authenticate = function authenticate() { - this.redirect('http://www.example.com/idp'); - }; const passport = new Passport(); passport.use('redirect', new Strategy()); @@ -47,12 +46,12 @@ describe('middleware/authenticate', () => { }); describe('redirect with session', () => { - function Strategy() { + class Strategy { + authenticate() { + const user = { id: '1', username: 'idurotola' }; + this.success(user); + } } - Strategy.prototype.authenticate = function authenticate() { - const user = { id: '1', username: 'idurotola' }; - this.success(user); - }; const passport = new Passport(); passport.use('success', new Strategy()); @@ -97,11 +96,11 @@ describe('middleware/authenticate', () => { }); describe('redirect with status', () => { - function Strategy() { + class Strategy { + authenticate() { + this.redirect('http://www.example.com/idp', 303); + } } - Strategy.prototype.authenticate = function authenticate() { - this.redirect('http://www.example.com/idp', 303); - }; const passport = new Passport(); passport.use('redirect', new Strategy()); @@ -134,11 +133,11 @@ describe('middleware/authenticate', () => { }); describe('redirect using framework function', () => { - function Strategy() { + class Strategy { + authenticate() { + this.redirect('http://www.example.com/idp'); + } } - Strategy.prototype.authenticate = function authenticate() { - this.redirect('http://www.example.com/idp'); - }; const passport = new Passport(); passport.use('redirect', new Strategy()); @@ -170,11 +169,11 @@ describe('middleware/authenticate', () => { }); describe('redirect with status using framework function', () => { - function Strategy() { + class Strategy { + authenticate() { + this.redirect('http://www.example.com/idp', 303); + } } - Strategy.prototype.authenticate = function authenticate() { - this.redirect('http://www.example.com/idp', 303); - }; const passport = new Passport(); passport.use('redirect', new Strategy()); diff --git a/test/middleware/authenticate.success.callback.test.js b/test/middleware/authenticate.success.callback.test.js index 97cd161f..67f44ed5 100644 --- a/test/middleware/authenticate.success.callback.test.js +++ b/test/middleware/authenticate.success.callback.test.js @@ -1,21 +1,18 @@ -/* global describe, it, expect, before */ -/* jshint expr: true */ - -/* eslint-disable camelcase, no-proto, no-shadow */ +'use strict'; const chai = require('chai'); const authenticate = require('../../lib/middleware/authenticate'); -const Passport = require('../..').Passport; +const { Passport } = require('../..'); describe('middleware/authenticate', () => { describe('success with callback', () => { - function Strategy() { + class Strategy { + authenticate() { + const user = { id: '1', username: 'jaredhanson' }; + this.success(user, { message: 'Hello' }); + } } - Strategy.prototype.authenticate = function authenticate() { - const user = { id: '1', username: 'jaredhanson' }; - this.success(user, { message: 'Hello' }); - }; const passport = new Passport(); passport.use('success', new Strategy()); @@ -68,13 +65,12 @@ describe('middleware/authenticate', () => { }); describe('success with callback and options passed to middleware', () => { - function Strategy() { + class Strategy { + authenticate() { + const user = { id: '1', username: 'jaredhanson' }; + this.success(user, { message: 'Hello' }); + } } - // eslint-disable-next-line consistent-return - Strategy.prototype.authenticate = function authenticate() { - const user = { id: '1', username: 'jaredhanson' }; - this.success(user, { message: 'Hello' }); - }; const passport = new Passport(); passport.use('success', new Strategy()); diff --git a/test/middleware/authenticate.success.flash.test.js b/test/middleware/authenticate.success.flash.test.js index 6adab984..47afd5c8 100644 --- a/test/middleware/authenticate.success.flash.test.js +++ b/test/middleware/authenticate.success.flash.test.js @@ -1,22 +1,20 @@ -/* global describe, it, expect, before */ -/* jshint expr: true */ - -/* eslint-disable camelcase, no-proto, no-shadow */ +/* eslint-disable no-shadow */ +'use strict'; const chai = require('chai'); const authenticate = require('../../lib/middleware/authenticate'); -const Passport = require('../..').Passport; +const { Passport } = require('../..'); describe('middleware/authenticate', () => { describe('using strategy that specifies message', () => { describe('success with flash message', () => { - function Strategy() { + class Strategy { + authenticate() { + const user = { id: '1', username: 'jaredhanson' }; + this.success(user, { message: 'Welcome!' }); + } } - Strategy.prototype.authenticate = function authenticate() { - const user = { id: '1', username: 'jaredhanson' }; - this.success(user, { message: 'Welcome!' }); - }; const passport = new Passport(); passport.use('success', new Strategy()); @@ -66,12 +64,12 @@ describe('middleware/authenticate', () => { }); describe('success with flash message using type set by route', () => { - function Strategy() { + class Strategy { + authenticate() { + const user = { id: '1', username: 'jaredhanson' }; + this.success(user, { message: 'Welcome!' }); + } } - Strategy.prototype.authenticate = function authenticate() { - const user = { id: '1', username: 'jaredhanson' }; - this.success(user, { message: 'Welcome!' }); - }; const passport = new Passport(); passport.use('success', new Strategy()); @@ -121,12 +119,12 @@ describe('middleware/authenticate', () => { }); describe('success with flash message overridden by route as string', () => { - function Strategy() { + class Strategy { + authenticate() { + const user = { id: '1', username: 'jaredhanson' }; + this.success(user, { message: 'Welcome!' }); + } } - Strategy.prototype.authenticate = function authenticate() { - const user = { id: '1', username: 'jaredhanson' }; - this.success(user, { message: 'Welcome!' }); - }; const passport = new Passport(); passport.use('success', new Strategy()); @@ -176,12 +174,12 @@ describe('middleware/authenticate', () => { }); describe('success with flash message overridden by route using options', () => { - function Strategy() { + class Strategy { + authenticate() { + const user = { id: '1', username: 'jaredhanson' }; + this.success(user, { message: 'Welcome!' }); + } } - Strategy.prototype.authenticate = function authenticate() { - const user = { id: '1', username: 'jaredhanson' }; - this.success(user, { message: 'Welcome!' }); - }; const passport = new Passport(); passport.use('success', new Strategy()); @@ -231,12 +229,12 @@ describe('middleware/authenticate', () => { }); describe('success with flash message overridden by route using options with type', () => { - function Strategy() { + class Strategy { + authenticate() { + const user = { id: '1', username: 'jaredhanson' }; + this.success(user, { message: 'Welcome!' }); + } } - Strategy.prototype.authenticate = function authenticate() { - const user = { id: '1', username: 'jaredhanson' }; - this.success(user, { message: 'Welcome!' }); - }; const passport = new Passport(); passport.use('success', new Strategy()); @@ -289,12 +287,12 @@ describe('middleware/authenticate', () => { describe('using strategy that specifies message and type', () => { describe('success with flash message', () => { - function Strategy() { + class Strategy { + authenticate() { + const user = { id: '1', username: 'jaredhanson' }; + this.success(user, { type: 'info', message: 'Hello' }); + } } - Strategy.prototype.authenticate = function authenticate() { - const user = { id: '1', username: 'jaredhanson' }; - this.success(user, { type: 'info', message: 'Hello' }); - }; const passport = new Passport(); passport.use('success', new Strategy()); @@ -344,12 +342,12 @@ describe('middleware/authenticate', () => { }); describe('success with flash message using type set by route', () => { - function Strategy() { + class Strategy { + authenticate() { + const user = { id: '1', username: 'jaredhanson' }; + this.success(user, { type: 'info', message: 'Hello' }); + } } - Strategy.prototype.authenticate = function authenticate() { - const user = { id: '1', username: 'jaredhanson' }; - this.success(user, { type: 'info', message: 'Hello' }); - }; const passport = new Passport(); passport.use('success', new Strategy()); @@ -399,12 +397,12 @@ describe('middleware/authenticate', () => { }); describe('success with flash message overridden by route as string', () => { - function Strategy() { + class Strategy { + authenticate() { + const user = { id: '1', username: 'jaredhanson' }; + this.success(user, { type: 'info', message: 'Hello' }); + } } - Strategy.prototype.authenticate = function authenticate() { - const user = { id: '1', username: 'jaredhanson' }; - this.success(user, { type: 'info', message: 'Hello' }); - }; const passport = new Passport(); passport.use('success', new Strategy()); @@ -454,12 +452,12 @@ describe('middleware/authenticate', () => { }); describe('success with flash message overridden by route using options', () => { - function Strategy() { + class Strategy { + authenticate() { + const user = { id: '1', username: 'jaredhanson' }; + this.success(user, { type: 'info', message: 'Hello' }); + } } - Strategy.prototype.authenticate = function authenticate() { - const user = { id: '1', username: 'jaredhanson' }; - this.success(user, { type: 'info', message: 'Hello' }); - }; const passport = new Passport(); passport.use('success', new Strategy()); @@ -509,12 +507,12 @@ describe('middleware/authenticate', () => { }); describe('success with flash message overridden by route using options with type', () => { - function Strategy() { + class Strategy { + authenticate() { + const user = { id: '1', username: 'jaredhanson' }; + this.success(user, { type: 'info', message: 'Hello' }); + } } - Strategy.prototype.authenticate = function authenticate() { - const user = { id: '1', username: 'jaredhanson' }; - this.success(user, { type: 'info', message: 'Hello' }); - }; const passport = new Passport(); passport.use('success', new Strategy()); @@ -567,12 +565,12 @@ describe('middleware/authenticate', () => { describe('using strategy that specifies message as string', () => { describe('success with flash message', () => { - function Strategy() { + class Strategy { + authenticate() { + const user = { id: '1', username: 'jaredhanson' }; + this.success(user, 'Greetings'); + } } - Strategy.prototype.authenticate = function authenticate() { - const user = { id: '1', username: 'jaredhanson' }; - this.success(user, 'Greetings'); - }; const passport = new Passport(); passport.use('success', new Strategy()); @@ -622,12 +620,12 @@ describe('middleware/authenticate', () => { }); describe('success with flash message using type set by route', () => { - function Strategy() { + class Strategy { + authenticate() { + const user = { id: '1', username: 'jaredhanson' }; + this.success(user, 'Greetings'); + } } - Strategy.prototype.authenticate = function authenticate() { - const user = { id: '1', username: 'jaredhanson' }; - this.success(user, 'Greetings'); - }; const passport = new Passport(); passport.use('success', new Strategy()); @@ -677,12 +675,12 @@ describe('middleware/authenticate', () => { }); describe('success with flash message overridden by route as string', () => { - function Strategy() { + class Strategy { + authenticate() { + const user = { id: '1', username: 'jaredhanson' }; + this.success(user, 'Greetings'); + } } - Strategy.prototype.authenticate = function authenticate() { - const user = { id: '1', username: 'jaredhanson' }; - this.success(user, 'Greetings'); - }; const passport = new Passport(); passport.use('success', new Strategy()); @@ -732,12 +730,12 @@ describe('middleware/authenticate', () => { }); describe('success with flash message overridden by route using options', () => { - function Strategy() { + class Strategy { + authenticate() { + const user = { id: '1', username: 'jaredhanson' }; + this.success(user, 'Greetings'); + } } - Strategy.prototype.authenticate = function authenticate() { - const user = { id: '1', username: 'jaredhanson' }; - this.success(user, 'Greetings'); - }; const passport = new Passport(); passport.use('success', new Strategy()); @@ -787,12 +785,12 @@ describe('middleware/authenticate', () => { }); describe('success with flash message overridden by route using options with type', () => { - function Strategy() { + class Strategy { + authenticate() { + const user = { id: '1', username: 'jaredhanson' }; + this.success(user, 'Greetings'); + } } - Strategy.prototype.authenticate = function authenticate() { - const user = { id: '1', username: 'jaredhanson' }; - this.success(user, 'Greetings'); - }; const passport = new Passport(); passport.use('success', new Strategy()); @@ -845,12 +843,12 @@ describe('middleware/authenticate', () => { describe('using strategy that does not specify message', () => { describe('success with flash message left up to strategy', () => { - function Strategy() { + class Strategy { + authenticate() { + const user = { id: '1', username: 'jaredhanson' }; + this.success(user); + } } - Strategy.prototype.authenticate = function authenticate() { - const user = { id: '1', username: 'jaredhanson' }; - this.success(user); - }; const passport = new Passport(); passport.use('success', new Strategy()); @@ -900,12 +898,12 @@ describe('middleware/authenticate', () => { }); describe('success with flash message left up to strategy using type set by route', () => { - function Strategy() { + class Strategy { + authenticate() { + const user = { id: '1', username: 'jaredhanson' }; + this.success(user); + } } - Strategy.prototype.authenticate = function authenticate() { - const user = { id: '1', username: 'jaredhanson' }; - this.success(user); - }; const passport = new Passport(); passport.use('success', new Strategy()); @@ -955,12 +953,12 @@ describe('middleware/authenticate', () => { }); describe('success with flash message specified by route as string', () => { - function Strategy() { + class Strategy { + authenticate() { + const user = { id: '1', username: 'jaredhanson' }; + this.success(user); + } } - Strategy.prototype.authenticate = function authenticate() { - const user = { id: '1', username: 'jaredhanson' }; - this.success(user); - }; const passport = new Passport(); passport.use('success', new Strategy()); @@ -1010,12 +1008,12 @@ describe('middleware/authenticate', () => { }); describe('success with flash message specified by route using options', () => { - function Strategy() { + class Strategy { + authenticate() { + const user = { id: '1', username: 'jaredhanson' }; + this.success(user); + } } - Strategy.prototype.authenticate = function authenticate() { - const user = { id: '1', username: 'jaredhanson' }; - this.success(user); - }; const passport = new Passport(); passport.use('success', new Strategy()); @@ -1065,12 +1063,12 @@ describe('middleware/authenticate', () => { }); describe('success with flash message specified by route using options with type', () => { - function Strategy() { + class Strategy { + authenticate() { + const user = { id: '1', username: 'jaredhanson' }; + this.success(user); + } } - Strategy.prototype.authenticate = function authenticate() { - const user = { id: '1', username: 'jaredhanson' }; - this.success(user); - }; const passport = new Passport(); passport.use('success', new Strategy()); diff --git a/test/middleware/authenticate.success.info.test.js b/test/middleware/authenticate.success.info.test.js index bf8d8fb7..f4e00da8 100644 --- a/test/middleware/authenticate.success.info.test.js +++ b/test/middleware/authenticate.success.info.test.js @@ -1,21 +1,19 @@ -/* global describe, it, expect, before */ -/* jshint expr: true */ - -/* eslint-disable camelcase, no-proto, no-shadow */ +/* eslint-disable no-shadow */ +'use strict'; const chai = require('chai'); const authenticate = require('../../lib/middleware/authenticate'); -const Passport = require('../..').Passport; +const { Passport } = require('../..'); describe('middleware/authenticate', () => { describe('success with info', () => { - function Strategy() { + class Strategy { + authenticate() { + const user = { id: '1', username: 'jaredhanson' }; + this.success(user, { clientId: '123', scope: 'read' }); + } } - Strategy.prototype.authenticate = function authenticate() { - const user = { id: '1', username: 'jaredhanson' }; - this.success(user, { clientId: '123', scope: 'read' }); - }; const passport = new Passport(); passport.use('success', new Strategy()); @@ -60,12 +58,12 @@ describe('middleware/authenticate', () => { }); describe('success with info that is transformed', () => { - function Strategy() { + class Strategy { + authenticate() { + const user = { id: '1', username: 'jaredhanson' }; + this.success(user, { clientId: '123', scope: 'read' }); + } } - Strategy.prototype.authenticate = function authenticate() { - const user = { id: '1', username: 'jaredhanson' }; - this.success(user, { clientId: '123', scope: 'read' }); - }; const passport = new Passport(); passport.use('success', new Strategy()); @@ -114,12 +112,12 @@ describe('middleware/authenticate', () => { }); describe('success with info, but transform that encounters an error', () => { - function Strategy() { + class Strategy { + authenticate() { + const user = { id: '1', username: 'jaredhanson' }; + this.success(user, { clientId: '123', scope: 'read' }); + } } - Strategy.prototype.authenticate = function authenticate() { - const user = { id: '1', username: 'jaredhanson' }; - this.success(user, { clientId: '123', scope: 'read' }); - }; const passport = new Passport(); passport.use('success', new Strategy()); @@ -165,12 +163,12 @@ describe('middleware/authenticate', () => { }); describe('success with info, but option that disables info', () => { - function Strategy() { + class Strategy { + authenticate() { + const user = { id: '1', username: 'jaredhanson' }; + this.success(user, { clientId: '123', scope: 'read' }); + } } - Strategy.prototype.authenticate = function authenticate() { - const user = { id: '1', username: 'jaredhanson' }; - this.success(user, { clientId: '123', scope: 'read' }); - }; const passport = new Passport(); passport.use('success', new Strategy()); diff --git a/test/middleware/authenticate.success.message.test.js b/test/middleware/authenticate.success.message.test.js index d9d84258..8dd7c9a1 100644 --- a/test/middleware/authenticate.success.message.test.js +++ b/test/middleware/authenticate.success.message.test.js @@ -1,20 +1,19 @@ -/* global describe, it, expect, before */ - -/* eslint-disable camelcase, no-proto, no-shadow */ +/* eslint-disable no-shadow */ +'use strict'; const chai = require('chai'); const authenticate = require('../../lib/middleware/authenticate'); -const Passport = require('../..').Passport; +const { Passport } = require('../..'); describe('middleware/authenticate', () => { describe('success with message set by route', () => { - function Strategy() { + class Strategy { + authenticate() { + const user = { id: '1', username: 'jaredhanson' }; + this.success(user, { message: 'Welcome!' }); + } } - Strategy.prototype.authenticate = function authenticate() { - const user = { id: '1', username: 'jaredhanson' }; - this.success(user, { message: 'Welcome!' }); - }; const passport = new Passport(); passport.use('success', new Strategy()); @@ -61,12 +60,12 @@ describe('middleware/authenticate', () => { }); describe('success with message set by route that is added to messages', () => { - function Strategy() { + class Strategy { + authenticate() { + const user = { id: '1', username: 'jaredhanson' }; + this.success(user, { message: 'Welcome!' }); + } } - Strategy.prototype.authenticate = function authenticate() { - const user = { id: '1', username: 'jaredhanson' }; - this.success(user, { message: 'Welcome!' }); - }; const passport = new Passport(); passport.use('success', new Strategy()); @@ -115,12 +114,12 @@ describe('middleware/authenticate', () => { }); describe('success with message set by strategy', () => { - function Strategy() { + class Strategy { + authenticate() { + const user = { id: '1', username: 'jaredhanson' }; + this.success(user, { message: 'Welcome!' }); + } } - Strategy.prototype.authenticate = function authenticate() { - const user = { id: '1', username: 'jaredhanson' }; - this.success(user, { message: 'Welcome!' }); - }; const passport = new Passport(); passport.use('success', new Strategy()); @@ -167,12 +166,12 @@ describe('middleware/authenticate', () => { }); describe('success with message set by strategy with extra info', () => { - function Strategy() { + class Strategy { + authenticate() { + const user = { id: '1', username: 'jaredhanson' }; + this.success(user, { message: 'Welcome!', scope: 'read' }); + } } - Strategy.prototype.authenticate = function authenticate() { - const user = { id: '1', username: 'jaredhanson' }; - this.success(user, { message: 'Welcome!', scope: 'read' }); - }; const passport = new Passport(); passport.use('success', new Strategy()); diff --git a/test/middleware/authenticate.success.multi.test.js b/test/middleware/authenticate.success.multi.test.js index 5811f602..7f8f1484 100644 --- a/test/middleware/authenticate.success.multi.test.js +++ b/test/middleware/authenticate.success.multi.test.js @@ -1,26 +1,24 @@ -/* global describe, it, expect, before */ -/* jshint expr: true */ - -/* eslint-disable camelcase, no-proto, no-shadow */ +/* eslint-disable no-shadow */ +'use strict'; const chai = require('chai'); const authenticate = require('../../lib/middleware/authenticate'); -const Passport = require('../..').Passport; +const { Passport } = require('../..'); describe('middleware/authenticate', () => { describe('with multiple strategies, the first of which succeeds', () => { - function StrategyA() { + class StrategyA { + authenticate() { + this.success({ username: 'bob-a' }); + } } - StrategyA.prototype.authenticate = function authenticate() { - this.success({ username: 'bob-a' }); - }; - function StrategyB() { + class StrategyB { + authenticate() { + this.success({ username: 'bob-b' }); + } } - StrategyB.prototype.authenticate = function authenticate() { - this.success({ username: 'bob-b' }); - }; const passport = new Passport(); passport.use('a', new StrategyA()); @@ -58,17 +56,17 @@ describe('middleware/authenticate', () => { }); describe('with multiple strategies, the second of which succeeds', () => { - function StrategyA() { + class StrategyA { + authenticate() { + this.fail('A challenge'); + } } - StrategyA.prototype.authenticate = function authenticate() { - this.fail('A challenge'); - }; - function StrategyB() { + class StrategyB { + authenticate() { + this.success({ username: 'bob-b' }); + } } - StrategyB.prototype.authenticate = function authenticate() { - this.success({ username: 'bob-b' }); - }; const passport = new Passport(); passport.use('a', new StrategyA()); diff --git a/test/middleware/authenticate.success.test.js b/test/middleware/authenticate.success.test.js index d86a66df..becfb4b7 100644 --- a/test/middleware/authenticate.success.test.js +++ b/test/middleware/authenticate.success.test.js @@ -1,22 +1,19 @@ -/* global describe, it, expect, before */ -/* jshint expr: true */ - -/* eslint-disable camelcase, no-proto, no-shadow */ - +/* eslint-disable no-shadow */ +'use strict'; const chai = require('chai'); const authenticate = require('../../lib/middleware/authenticate'); -const Passport = require('../..').Passport; +const { Passport } = require('../..'); describe('middleware/authenticate', () => { describe('success', () => { - function Strategy() { + class Strategy { + authenticate() { + const user = { id: '1', username: 'jaredhanson' }; + this.success(user); + } } - Strategy.prototype.authenticate = function authenticate() { - const user = { id: '1', username: 'jaredhanson' }; - this.success(user); - }; const passport = new Passport(); passport.use('success', new Strategy()); @@ -59,12 +56,12 @@ describe('middleware/authenticate', () => { }); describe('success that assigns a specific property', () => { - function Strategy() { + class Strategy { + authenticate() { + const user = { id: '1', username: 'jaredhanson' }; + this.success(user); + } } - Strategy.prototype.authenticate = function authenticate() { - const user = { id: '1', username: 'jaredhanson' }; - this.success(user); - }; const passport = new Passport(); passport.use('success', new Strategy()); @@ -112,15 +109,15 @@ describe('middleware/authenticate', () => { }); describe('success with strategy-specific options', () => { - function Strategy() { - } - Strategy.prototype.authenticate = function authenticate(req, options) { - const user = { id: '1', username: 'jaredhanson' }; - if (options.scope === 'email') { - user.email = 'jaredhanson@example.com'; + class Strategy { + authenticate(req, options) { + const user = { id: '1', username: 'jaredhanson' }; + if (options.scope === 'email') { + user.email = 'jaredhanson@example.com'; + } + this.success(user); } - this.success(user); - }; + } const passport = new Passport(); passport.use('success', new Strategy()); @@ -166,12 +163,12 @@ describe('middleware/authenticate', () => { }); describe('success with redirect', () => { - function Strategy() { + class Strategy { + authenticate() { + const user = { id: '1', username: 'jaredhanson' }; + this.success(user); + } } - Strategy.prototype.authenticate = function authenticate() { - const user = { id: '1', username: 'jaredhanson' }; - this.success(user); - }; const passport = new Passport(); passport.use('success', new Strategy()); @@ -214,12 +211,12 @@ describe('middleware/authenticate', () => { }); describe('success with return to previous location', () => { - function Strategy() { + class Strategy { + authenticate() { + const user = { id: '1', username: 'jaredhanson' }; + this.success(user); + } } - Strategy.prototype.authenticate = function authenticate() { - const user = { id: '1', username: 'jaredhanson' }; - this.success(user); - }; const passport = new Passport(); passport.use('success', new Strategy()); @@ -268,12 +265,12 @@ describe('middleware/authenticate', () => { }); describe('success with return to default location', () => { - function Strategy() { + class Strategy { + authenticate() { + const user = { id: '1', username: 'jaredhanson' }; + this.success(user); + } } - Strategy.prototype.authenticate = function authenticate() { - const user = { id: '1', username: 'jaredhanson' }; - this.success(user); - }; const passport = new Passport(); passport.use('success', new Strategy()); @@ -316,12 +313,12 @@ describe('middleware/authenticate', () => { }); describe('success, but login that encounters an error', () => { - function Strategy() { + class Strategy { + authenticate() { + const user = { id: '1', username: 'jaredhanson' }; + this.success(user); + } } - Strategy.prototype.authenticate = function authenticate() { - const user = { id: '1', username: 'jaredhanson' }; - this.success(user); - }; const passport = new Passport(); passport.use('success', new Strategy()); diff --git a/test/middleware/authenticate.test.js b/test/middleware/authenticate.test.js index 8b393adf..fcf82039 100644 --- a/test/middleware/authenticate.test.js +++ b/test/middleware/authenticate.test.js @@ -1,11 +1,9 @@ -/* global describe, it, expect, before */ -/* jshint expr: true */ - -/* eslint-disable camelcase, no-proto, no-shadow */ +/* eslint-disable no-shadow */ +'use strict'; const chai = require('chai'); const authenticate = require('../../lib/middleware/authenticate'); -const Passport = require('../..').Passport; +const { Passport } = require('../..'); describe('middleware/authenticate', () => { diff --git a/test/middleware/initialize.test.js b/test/middleware/initialize.test.js index a2eca710..9abde8a4 100644 --- a/test/middleware/initialize.test.js +++ b/test/middleware/initialize.test.js @@ -1,10 +1,7 @@ -/* global describe, it, expect, before */ -/* jshint expr: true */ - -/* eslint-disable camelcase, no-proto, no-shadow */ +'use strict'; const chai = require('chai'); -const Passport = require('../..').Passport; +const { Passport } = require('../..'); const initialize = require('../../lib/middleware/initialize'); describe('middleware/initialize', () => { diff --git a/test/package.test.js b/test/package.test.js index ea7dfd5e..380b96c3 100644 --- a/test/package.test.js +++ b/test/package.test.js @@ -1,4 +1,4 @@ -/* global describe, it, expect */ +'use strict'; const passport = require('..'); diff --git a/test/strategies/session.test.js b/test/strategies/session.test.js index 2a210972..81ecdf3e 100644 --- a/test/strategies/session.test.js +++ b/test/strategies/session.test.js @@ -1,7 +1,5 @@ -/* global describe, it, expect, before */ -/* jshint expr: true */ - -/* eslint-disable camelcase, no-proto, no-shadow */ +/* eslint-disable no-shadow */ +'use strict'; const chai = require('chai'); const SessionStrategy = require('../../lib/strategies/session'); @@ -44,9 +42,9 @@ describe('SessionStrategy', () => { }); describe('handling a request with a login session', () => { - const strategy = new SessionStrategy(((user, req, done) => { + const strategy = new SessionStrategy((user, req, done) => { done(null, { id: user }); - })); + }); let request; let pass = false; @@ -79,17 +77,15 @@ describe('SessionStrategy', () => { }); it('should maintain session', () => { - // eslint-disable-next-line no-underscore-dangle expect(request._passport.session).to.be.an('object'); - // eslint-disable-next-line no-underscore-dangle expect(request._passport.session.user).to.equal('123456'); }); }); describe('handling a request with a login session serialized to 0', () => { - const strategy = new SessionStrategy(((user, req, done) => { + const strategy = new SessionStrategy((user, req, done) => { done(null, { id: user }); - })); + }); let request; let pass = false; @@ -128,9 +124,9 @@ describe('SessionStrategy', () => { }); describe('handling a request with a login session that has been invalidated', () => { - const strategy = new SessionStrategy(((user, req, done) => { + const strategy = new SessionStrategy((user, req, done) => { done(null, false); - })); + }); let request; let pass = false; @@ -170,9 +166,9 @@ describe('SessionStrategy', () => { }); describe('handling a request with a login session and setting custom user property', () => { - const strategy = new SessionStrategy(((user, req, done) => { + const strategy = new SessionStrategy((user, req, done) => { done(null, { id: user }); - })); + }); let request; let pass = false; @@ -186,7 +182,6 @@ describe('SessionStrategy', () => { .req((req) => { request = req; - // eslint-disable-next-line no-underscore-dangle req._passport = {}; req._passport.instance = {}; req._passport.instance._userProperty = 'currentUser'; @@ -213,9 +208,9 @@ describe('SessionStrategy', () => { }); describe('handling a request with a login session that encounters an error when deserializing', () => { - const strategy = new SessionStrategy(((user, req, done) => { + const strategy = new SessionStrategy((user, req, done) => { done(new Error('something went wrong')); - })); + }); let request; let error;