Validate fetch of encrypted backup from gun

This commit is contained in:
Daniel Lugo 2022-01-17 13:26:03 -04:00
parent 0b27506261
commit f3603f08b6

View file

@ -1955,6 +1955,11 @@ module.exports = async (
const SEA = require('../services/gunDB/Mediator').mySEA const SEA = require('../services/gunDB/Mediator').mySEA
const mySecret = require('../services/gunDB/Mediator').getMySecret() const mySecret = require('../services/gunDB/Mediator').getMySecret()
const encBackup = await user.get(Key.CHANNELS_BACKUP).then() const encBackup = await user.get(Key.CHANNELS_BACKUP).then()
if (typeof encBackup !== 'string') {
throw new TypeError(
'Encrypted backup fetched from gun not an string.'
)
}
const backup = await SEA.decrypt(encBackup, mySecret) const backup = await SEA.decrypt(encBackup, mySecret)
logger.info(backup) logger.info(backup)
res.json({ data: backup }) res.json({ data: backup })