GET requests end-to-end encryption fix

This commit is contained in:
emad-salah 2020-01-21 11:03:11 +01:00
parent 4126fd503a
commit 86348d0728
2 changed files with 6 additions and 11 deletions

View file

@ -224,7 +224,12 @@ module.exports = async (
console.error("Unknown Device", error) console.error("Unknown Device", error)
return res.status(401).json(error); return res.status(401).json(error);
} }
if (req.method === "GET") {
console.log("Method:", req.method);
return next();
}
console.log("Body:", req.body) console.log("Body:", req.body)
console.log("Decrypt params:", { deviceId, message: req.body.encryptionKey }) console.log("Decrypt params:", { deviceId, message: req.body.encryptionKey })
const decryptedKey = Encryption.decryptKey({ deviceId, message: req.body.encryptionKey }); const decryptedKey = Encryption.decryptKey({ deviceId, message: req.body.encryptionKey });

View file

@ -89,16 +89,6 @@ const Encryption = {
}, },
authorizeDevice: ({ deviceId, publicKey }) => authorizeDevice: ({ deviceId, publicKey }) =>
new Promise((resolve, reject) => { new Promise((resolve, reject) => {
if (authorizedDevices.has(deviceId)) {
const devicePublicKey = APIKeyPair.get(deviceId).publicKey
const deviceExists = {
success: true,
APIPublicKey: devicePublicKey
}
resolve(deviceExists)
return deviceExists
}
authorizedDevices.set(deviceId, publicKey) authorizedDevices.set(deviceId, publicKey)
Crypto.generateKeyPair( Crypto.generateKeyPair(
'rsa', 'rsa',