Remove legacy encryption fallback code
This commit is contained in:
parent
7b1e7ae97a
commit
281c7f7ac2
2 changed files with 24 additions and 27 deletions
|
|
@ -218,8 +218,7 @@ module.exports = async (
|
|||
try {
|
||||
if (
|
||||
nonEncryptedRoutes.includes(req.path) ||
|
||||
process.env.DISABLE_SHOCK_ENCRYPTION === 'true' ||
|
||||
!deviceId
|
||||
process.env.DISABLE_SHOCK_ENCRYPTION === 'true'
|
||||
) {
|
||||
return next()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -132,34 +132,32 @@ const server = program => {
|
|||
return
|
||||
}
|
||||
|
||||
if (deviceId) {
|
||||
res.send = (...args) => {
|
||||
if (args[0] && args[0].ciphertext && args[0].iv) {
|
||||
logger.warn('Response loop detected!')
|
||||
oldSend.apply(res, args)
|
||||
return
|
||||
}
|
||||
res.send = (...args) => {
|
||||
if (args[0] && args[0].ciphertext && args[0].iv) {
|
||||
logger.warn('Response loop detected!')
|
||||
oldSend.apply(res, args)
|
||||
return
|
||||
}
|
||||
|
||||
const authorized = ECC.isAuthorizedDevice({
|
||||
deviceId
|
||||
const authorized = ECC.isAuthorizedDevice({
|
||||
deviceId
|
||||
})
|
||||
|
||||
// Using classic promises syntax to avoid
|
||||
// modifying res.send's return type
|
||||
if (authorized && process.env.SHOCK_ENCRYPTION_ECC !== 'false') {
|
||||
ECC.encryptMessage({
|
||||
deviceId,
|
||||
message: args[0]
|
||||
}).then(encryptedMessage => {
|
||||
args[0] = JSON.stringify(encryptedMessage)
|
||||
oldSend.apply(res, args)
|
||||
})
|
||||
}
|
||||
|
||||
// Using classic promises syntax to avoid
|
||||
// modifying res.send's return type
|
||||
if (authorized && process.env.SHOCK_ENCRYPTION_ECC !== 'false') {
|
||||
ECC.encryptMessage({
|
||||
deviceId,
|
||||
message: args[0]
|
||||
}).then(encryptedMessage => {
|
||||
args[0] = JSON.stringify(encryptedMessage)
|
||||
oldSend.apply(res, args)
|
||||
})
|
||||
}
|
||||
|
||||
if (!authorized || process.env.SHOCK_ENCRYPTION_ECC === 'false') {
|
||||
args[0] = JSON.stringify(args[0])
|
||||
oldSend.apply(res, args)
|
||||
}
|
||||
if (!authorized || process.env.SHOCK_ENCRYPTION_ECC === 'false') {
|
||||
args[0] = JSON.stringify(args[0])
|
||||
oldSend.apply(res, args)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue