Browse Source

Derive deterministic app passwords (#110)

master
Luke Childs 3 years ago
committed by GitHub
parent
commit
9a091be9d9
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      logic/apps.js
  2. 16
      modules/derive-entropy.js

10
logic/apps.js

@ -1,5 +1,6 @@
const diskLogic = require('logic/disk.js');
const NodeError = require('models/errors.js').NodeError;
const deriveEntropy = require('modules/derive-entropy');
async function get(query) {
let apps = await diskLogic.readAppRegistry();
@ -13,6 +14,15 @@ async function get(query) {
}
}));
// Derive all passwords concurrently
await Promise.all(apps.filter(app => app.deterministicPassword).map(async app => {
try {
app.defaultPassword = await deriveEntropy(`app-${app.id}-seed-APP_PASSWORD`);
} catch(e) {
app.defaultPassword = '';
}
}));
if (query.installed === true) {
const {installedApps} = await diskLogic.readUserFile();
apps = apps.filter(app => installedApps.includes(app.id));

16
modules/derive-entropy.js

@ -0,0 +1,16 @@
const {promisify} = require('util');
const readFile = promisify(require('fs').readFile);
const crypto = require('crypto');
const constants = require('utils/const.js');
const deriveEntropy = async indentifier => {
const umbrel_seed = await readFile(constants.UMBREL_SEED_FILE);
return crypto
.createHmac('sha256', umbrel_seed)
.update(indentifier)
.digest('hex');
};
module.exports = deriveEntropy;
Loading…
Cancel
Save