Merge pull request #25 from shocknet/bug/no-encrypted-logs
Removed blocking `console.log`s
This commit is contained in:
commit
15af9c6379
4 changed files with 5 additions and 10 deletions
|
|
@ -392,7 +392,6 @@ class Mediator {
|
|||
deviceId
|
||||
})
|
||||
: data
|
||||
console.log('Sending Message...', eventName, data, encryptedMessage)
|
||||
socket.emit(eventName, encryptedMessage)
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
|
|
|
|||
|
|
@ -213,7 +213,7 @@ module.exports = async (
|
|||
field: "deviceId",
|
||||
message: "Please specify a device ID"
|
||||
};
|
||||
console.error(error)
|
||||
logger.error("Please specify a device ID")
|
||||
return res.status(401).json(error);
|
||||
}
|
||||
|
||||
|
|
@ -222,19 +222,15 @@ module.exports = async (
|
|||
field: "deviceId",
|
||||
message: "Please specify a device ID"
|
||||
};
|
||||
console.error("Unknown Device", error)
|
||||
logger.error("Unknown Device")
|
||||
return res.status(401).json(error);
|
||||
}
|
||||
|
||||
if (req.method === "GET") {
|
||||
console.log("Method:", req.method);
|
||||
return next();
|
||||
}
|
||||
|
||||
console.log("Body:", req.body)
|
||||
console.log("Decrypt params:", { deviceId, message: req.body.encryptionKey })
|
||||
const decryptedKey = Encryption.decryptKey({ deviceId, message: req.body.encryptionKey });
|
||||
console.log("decryptedKey", decryptedKey)
|
||||
const decryptedMessage = Encryption.decryptMessage({ message: req.body.data, key: decryptedKey, iv: req.body.iv })
|
||||
req.body = JSON.parse(decryptedMessage);
|
||||
return next();
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ const server = program => {
|
|||
if (!nonEncryptedRoutes.includes(req.path)) {
|
||||
res.send = (...args) => {
|
||||
if (args[0] && args[0].encryptedData && args[0].encryptionKey) {
|
||||
console.log('Response loop detected', req.path, args[0])
|
||||
logger.warn('Response loop detected!')
|
||||
oldSend.apply(res, args)
|
||||
} else {
|
||||
// arguments[0] (or `data`) contains the response body
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ const Encryption = {
|
|||
},
|
||||
data
|
||||
)
|
||||
console.log('Decrypted Data:', encryptedData)
|
||||
|
||||
return encryptedData.toString()
|
||||
},
|
||||
encryptMessage: ({ deviceId, message }) => {
|
||||
|
|
@ -74,7 +74,7 @@ const Encryption = {
|
|||
Buffer.from(cipher.final())
|
||||
])
|
||||
const decryptedData = decryptedBuffer.toString()
|
||||
console.log('Decrypted Data:', decryptedData)
|
||||
|
||||
return decryptedData.toString()
|
||||
},
|
||||
isAuthorizedDevice: ({ deviceId }) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue