Skip to content

Commit

Permalink
chore: bump deps (#3359)
Browse files Browse the repository at this point in the history
  • Loading branch information
robertsLando authored Oct 18, 2023
1 parent d68f33a commit a92db38
Show file tree
Hide file tree
Showing 60 changed files with 2,134 additions and 2,350 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ module.exports = {
'@typescript-eslint/no-implied-eval': 'off',
'@typescript-eslint/no-misused-promises': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-enum-comparison': 'off',
},
},
],
Expand Down
2 changes: 1 addition & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

## Reporting a Vulnerability

Please email [email protected]; [email protected]
Please email <[email protected]>; <[email protected]>
86 changes: 45 additions & 41 deletions app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ declare module 'express-session' {
function multerPromise(
m: RequestHandler,
req: Request,
res: Response
res: Response,
): Promise<void> {
return new Promise((resolve, reject) => {
m(req, res, (err: any) => {
Expand Down Expand Up @@ -139,7 +139,7 @@ const socketManager = new SocketManager()

socketManager.authMiddleware = function (
socket: Socket & { user?: User },
next: (err?) => void
next: (err?) => void,
) {
if (!isAuthEnabled()) {
next()
Expand All @@ -151,7 +151,7 @@ socketManager.authMiddleware = function (
if (err) return next(new Error('Authentication error'))
socket.user = decoded
next()
}
},
)
} else {
next(new Error('Authentication error'))
Expand Down Expand Up @@ -192,16 +192,16 @@ export async function startServer(host: string, port: number | string) {
cert,
rejectUnauthorized: false,
},
app
app,
)
} else {
logger.warn(
'HTTPS is enabled but cert or key cannot be generated. Falling back to HTTP'
'HTTPS is enabled but cert or key cannot be generated. Falling back to HTTP',
)
}
} else {
logger.warn(
'HTTPS enabled but FORCE_DISABLE_SSL env var is set. Falling back to HTTP'
'HTTPS enabled but FORCE_DISABLE_SSL env var is set. Falling back to HTTP',
)
}
}
Expand All @@ -217,7 +217,7 @@ export async function startServer(host: string, port: number | string) {
logger.info(
`Listening on ${bind} host ${host} protocol ${
httpsEnabled ? 'HTTPS' : 'HTTP'
}`
}`,
)
})

Expand Down Expand Up @@ -340,7 +340,7 @@ async function loadCertKey(): Promise<{

if (!cert || !key) {
logger.info(
'Cert and key not found in store, generating fresh new ones...'
'Cert and key not found in store, generating fresh new ones...',
)

try {
Expand Down Expand Up @@ -375,7 +375,7 @@ async function startGateway(settings: Settings) {
sessionSecret === 'DEFAULT_SESSION_SECRET_CHANGE_ME'
) {
logger.error(
'Session secret is the default one. For security reasons you should change it by using SESSION_SECRET env var'
'Session secret is the default one. For security reasons you should change it by using SESSION_SECRET env var',
)
}

Expand Down Expand Up @@ -411,7 +411,7 @@ async function startGateway(settings: Settings) {
// eslint-disable-next-line @typescript-eslint/no-var-requires
require(plugin) as PluginConstructor,
pluginsContext,
pluginName
pluginName,
)

plugins.push(instance)
Expand All @@ -438,7 +438,10 @@ async function destroyPlugins() {
function setupInterceptor() {
// intercept logs and redirect them to socket
const interceptor = (
write: (buffer: string | Uint8Array, cb?: (err?: Error) => void) => void
write: (
buffer: string | Uint8Array,
cb?: (err?: Error) => void,
) => void,
) => {
return function (...args: any[]): boolean {
socketManager.io.emit(socketEvents.debug, args[0]?.toString())
Expand All @@ -447,10 +450,10 @@ function setupInterceptor() {
}

process.stdout.write = interceptor(
process.stdout.write.bind(process.stdout)
process.stdout.write.bind(process.stdout),
)
process.stderr.write = interceptor(
process.stderr.write.bind(process.stderr)
process.stderr.write.bind(process.stderr),
)
}

Expand Down Expand Up @@ -515,15 +518,15 @@ app.set('view engine', 'ejs')
app.use(
morgan(loggers.disableColors ? 'tiny' : 'dev', {
stream: { write: (msg: string) => logger.info(msg.trimEnd()) },
}) as RequestHandler
}) as RequestHandler,
)
app.use(express.json({ limit: '50mb' }) as RequestHandler)
app.use(
express.urlencoded({
limit: '50mb',
extended: true,
parameterLimit: 50000,
}) as RequestHandler
}) as RequestHandler,
)

// must be placed before history middleware
Expand All @@ -538,7 +541,7 @@ app.use(function (req, res, next) {
app.use(
history({
index: '/',
})
}),
)

// fix back compatibility with old history mode after switching to hash mode
Expand Down Expand Up @@ -590,7 +593,7 @@ app.use(
httpOnly: true, // prevents cookie to be sent by client javascript
maxAge: 24 * 60 * 60 * 1000, // one day
},
})
}),
)

// Node.js CSRF protection middleware.
Expand Down Expand Up @@ -637,7 +640,7 @@ function setupSocket(server: HttpServer) {
message: 'Zwave client not connected',
})
}
}
},
)

// eslint-disable-next-line @typescript-eslint/no-misused-promises
Expand Down Expand Up @@ -707,7 +710,7 @@ function setupSocket(server: HttpServer) {
res = await gw.zwave.storeDevices(
data.devices,
data.nodeId,
data.remove
data.remove,
)
break
}
Expand Down Expand Up @@ -856,15 +859,15 @@ app.post(
result.user = userData
loginLimiter.resetKey(req.ip)
logger.info(
`User ${user.username} logged in successfully from ${req.ip}`
`User ${user.username} logged in successfully from ${req.ip}`,
)
} else {
result.code = 3
result.message = RESPONSE_CODES.GENERAL_ERROR
logger.error(
`User ${
user?.username || req.body.username
} failed to login from ${req.ip}: wrong credentials`
} failed to login from ${req.ip}: wrong credentials`,
)
}

Expand All @@ -879,10 +882,10 @@ app.post(
logger.error(
`User ${
user?.username || req.body.username
} failed to login from ${req.ip}: ${error.message}`
} failed to login from ${req.ip}: ${error.message}`,
)
}
}
},
)

// logout the user
Expand Down Expand Up @@ -948,7 +951,7 @@ app.put(
})
logger.error('Error while updating password', error)
}
}
},
)

app.get('/health', apisLimiter, function (req, res) {
Expand Down Expand Up @@ -1050,7 +1053,7 @@ app.get(
}
res.json(data)
} else res.json(data)
}
},
)

// update settings
Expand All @@ -1062,7 +1065,7 @@ app.post(
try {
if (restarting) {
throw Error(
'Gateway is restarting, wait a moment before doing another request'
'Gateway is restarting, wait a moment before doing another request',
)
}
// TODO: validate settings using calss-validator
Expand All @@ -1086,7 +1089,7 @@ app.post(
logger.error(error)
res.json({ success: false, message: error.message })
}
}
},
)

// update settings
Expand All @@ -1098,7 +1101,7 @@ app.post(
try {
if (restarting) {
throw Error(
'Gateway is restarting, wait a moment before doing another request'
'Gateway is restarting, wait a moment before doing another request',
)
}
const { enableStatistics } = req.body
Expand Down Expand Up @@ -1132,7 +1135,7 @@ app.post(
logger.error(error)
res.json({ success: false, message: error.message })
}
}
},
)

// update versions
Expand Down Expand Up @@ -1172,7 +1175,7 @@ app.post(
logger.error(error)
res.json({ success: false, message: error.message })
}
}
},
)

// get config
Expand Down Expand Up @@ -1217,23 +1220,23 @@ app.post(
await gw.zwave.callApi(
'setNodeName',
nodeIdNumber,
node.name || ''
node.name || '',
)
}

if (utils.hasProperty(node, 'loc')) {
await gw.zwave.callApi(
'setNodeLocation',
nodeIdNumber,
node.loc || ''
node.loc || '',
)
}

if (node.hassDevices) {
await gw.zwave.storeDevices(
node.hassDevices,
nodeIdNumber,
false
false,
)
}
}
Expand All @@ -1246,7 +1249,7 @@ app.post(
logger.error(error.message)
return res.json({ success: false, message: error.message })
}
}
},
)

interface StoreFileEntry {
Expand Down Expand Up @@ -1345,7 +1348,7 @@ app.delete(
logger.error(error.message)
return res.json({ success: false, message: error.message })
}
}
},
)

app.put(
Expand All @@ -1363,7 +1366,7 @@ app.put(
logger.error(error.message)
return res.json({ success: false, message: error.message })
}
}
},
)

app.post(
Expand Down Expand Up @@ -1411,7 +1414,7 @@ app.post(
}

await archive.finalize()
}
},
)

app.get(
Expand All @@ -1426,7 +1429,7 @@ app.get(
error: error.message,
})
}
}
},
)

app.post(
Expand Down Expand Up @@ -1462,7 +1465,7 @@ app.post(
if (file && isRestore) {
await rm(file.path)
}
}
},
)

app.get('/api/snippet', apisLimiter, async function (req, res) {
Expand Down Expand Up @@ -1490,7 +1493,7 @@ app.use(function (req, res, next) {
// error handler
app.use(function (err: HttpError, req: Request, res: Response) {
logger.error(
`${req.method} ${req.url} ${err.status} - Error: ${err.message}`
`${req.method} ${req.url} ${err.status} - Error: ${err.message}`,
)

// render the error page
Expand All @@ -1515,7 +1518,8 @@ async function gracefuShutdown() {
process.on('unhandledRejection', (reason) => {
const stack = (reason as any).stack || ''
logger.error(
`Unhandled Rejection, reason: ${reason}${stack ? `\n${stack}` : ''}`
// eslint-disable-next-line @typescript-eslint/no-base-to-string
`Unhandled Rejection, reason: ${reason}${stack ? `\n${stack}` : ''}`,
)
})

Expand Down
2 changes: 1 addition & 1 deletion bin/www.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import * as conf from '../config/app'
import app, { startServer } from '../app'

console.log(
` ______ __ __ _ _____ _ _ _____ \n |___ / \\ \\ / / | |/ ____| | | | |_ _|\n / /____\\ \\ /\\ / /_ ___ _____ | | (___ | | | | | | \n / /______\\ \\/ \\/ / _\' \\ \\ / / _ \\ _ | |\\___ \\ | | | | | | \n / /__ \\ /\\ / (_| |\\ V / __/ | |__| |____) | | |__| |_| |_ \n /_____| \\/ \\/ \\__,_| \\_/ \\___| \\____/|_____/ \\____/|_____|\n`
` ______ __ __ _ _____ _ _ _____ \n |___ / \\ \\ / / | |/ ____| | | | |_ _|\n / /____\\ \\ /\\ / /_ ___ _____ | | (___ | | | | | | \n / /______\\ \\/ \\/ / _\' \\ \\ / / _ \\ _ | |\\___ \\ | | | | | | \n / /__ \\ /\\ / (_| |\\ V / __/ | |__| |____) | | |__| |_| |_ \n /_____| \\/ \\/ \\__,_| \\_/ \\___| \\____/|_____/ \\____/|_____|\n`,
)

// jsonstore is a singleton instance that handles the json configuration files
Expand Down
Loading

0 comments on commit a92db38

Please sign in to comment.