From e4be1b0b0ea458d67de348abfa3df5bf64c781ed Mon Sep 17 00:00:00 2001 From: Jason Mulligan Date: Tue, 20 Dec 2016 11:59:57 -0500 Subject: [PATCH] Unsetting default value of `version`, changing occurrences of `"all"` to `const all` --- lib/tenso.js | 2 +- lib/utility.js | 43 ++++++++++++++++++++++--------------------- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/lib/tenso.js b/lib/tenso.js index 767534df..35dc5707 100644 --- a/lib/tenso.js +++ b/lib/tenso.js @@ -21,7 +21,7 @@ class Tenso { }); this.server.tenso = this; this.websocket = null; - this.version = "4.0.0"; + this.version = ""; } error (req, res, err) { diff --git a/lib/utility.js b/lib/utility.js index 8d5fbd48..5aac5051 100644 --- a/lib/utility.js +++ b/lib/utility.js @@ -22,7 +22,8 @@ const path = require("path"), OAuth2Strategy = require("passport-oauth2").Strategy, SAMLStrategy = require("passport-saml").Strategy, TwitterStrategy = require("passport-twitter").Strategy, - RedisStore = require("connect-redis")(session); + RedisStore = require("connect-redis")(session), + all = "all"; let uws, coap; @@ -45,10 +46,10 @@ function escape (arg) { return arg.replace(/[-[\]{}()*+?.,\\^$|#]/g, "\\$&"); } -function capitalize (obj, all = false) { +function capitalize (obj, every = false) { let result; - if (all) { + if (every) { result = explode(obj, " ").map(capitalize).join(" "); } else { result = obj.charAt(0).toUpperCase() + obj.slice(1); @@ -87,11 +88,11 @@ function auth (obj, config) { function init (sess) { passportInit = passport.initialize(); - obj.server.use(passportInit, "all").blacklist(passportInit); + obj.server.use(passportInit, all).blacklist(passportInit); if (sess) { passportSession = passport.session(); - obj.server.use(passportSession, "all").blacklist(passportSession); + obj.server.use(passportSession, all).blacklist(passportSession); } } @@ -99,8 +100,8 @@ function auth (obj, config) { res.redirect(config.auth.redirect); } - obj.server.use(middleware.decorate, "all").blacklist(middleware.decorate); - obj.server.use(middleware.parse, "all").blacklist(middleware.parse); + obj.server.use(middleware.decorate, all).blacklist(middleware.decorate); + obj.server.use(middleware.parse, all).blacklist(middleware.parse); obj.server.blacklist(middleware.asyncFlag); config.auth.protect = (config.auth.protect || []).map(i => { @@ -127,7 +128,7 @@ function auth (obj, config) { authUris.push("/login"); } - obj.server.use(middleware.valid, "all").blacklist(middleware.valid); + obj.server.use(middleware.valid, all).blacklist(middleware.valid); if (stateful) { sesh = { @@ -144,43 +145,43 @@ function auth (obj, config) { fnCookie = cookie(); fnSession = session(sesh); - obj.server.use(fnSession, "all").blacklist(fnSession); - obj.server.use(fnCookie, "all").blacklist(fnCookie); - obj.server.use(middleware.bypass, "all").blacklist(middleware.bypass); + obj.server.use(fnSession, all).blacklist(fnSession); + obj.server.use(fnCookie, all).blacklist(fnCookie); + obj.server.use(middleware.bypass, all).blacklist(middleware.bypass); if (config.security.csrf) { luscaCsrf = lusca.csrf({key: config.security.key, secret: config.security.secret}); - obj.server.use(csrfWrapper, "all").blacklist(csrfWrapper); + obj.server.use(csrfWrapper, all).blacklist(csrfWrapper); } } if (config.security.csp instanceof Object) { luscaCsp = lusca.csp(config.security.csp); - obj.server.use(luscaCsp, "all").blacklist(luscaCsp); + obj.server.use(luscaCsp, all).blacklist(luscaCsp); } if (!isEmpty(config.security.xframe || "")) { luscaXframe = lusca.xframe(config.security.xframe); - obj.server.use(luscaXframe, "all").blacklist(luscaXframe); + obj.server.use(luscaXframe, all).blacklist(luscaXframe); } if (!isEmpty(config.security.p3p || "")) { luscaP3p = lusca.p3p(config.security.p3p); - obj.server.use(luscaP3p, "all").blacklist(luscaP3p); + obj.server.use(luscaP3p, all).blacklist(luscaP3p); } if (config.security.hsts instanceof Object) { luscaHsts = lusca.hsts(config.security.hsts); - obj.server.use(luscaHsts, "all").blacklist(luscaHsts); + obj.server.use(luscaHsts, all).blacklist(luscaHsts); } if (config.security.xssProtection instanceof Object) { luscaXssProtection = lusca.xssProtection(config.security.xssProtection); - obj.server.use(luscaXssProtection, "all").blacklist(luscaXssProtection); + obj.server.use(luscaXssProtection, all).blacklist(luscaXssProtection); } // Can fork to `middleware.keymaster()` - obj.server.use(middleware.zuul, "all").blacklist(middleware.zuul); + obj.server.use(middleware.zuul, all).blacklist(middleware.zuul); if (stateless && !stateful) { init(false); @@ -210,7 +211,7 @@ function auth (obj, config) { }); r = r.replace(/\|$/, "") + ")).*$"; - obj.server.use(r, middleware.guard, "all").blacklist(middleware.guard); + obj.server.use(r, middleware.guard, all).blacklist(middleware.guard); }()); config.routes.get["/login"] = config.auth.local.enabled ? keys ? { @@ -270,7 +271,7 @@ function auth (obj, config) { obj.server.get("/auth/basic", passportAuth).blacklist(passportAuth); obj.server.get("/auth/basic", redirect); } else { - obj.server.use(passportAuth, "all").blacklist(passportAuth); + obj.server.use(passportAuth, all).blacklist(passportAuth); } }()); } @@ -305,7 +306,7 @@ function auth (obj, config) { obj.server.get("/auth/bearer", passportAuth).blacklist(passportAuth); obj.server.get("/auth/bearer", redirect); } else { - obj.server.use(passportAuth, "all").blacklist(passportAuth); + obj.server.use(passportAuth, all).blacklist(passportAuth); } }()); }