MAJOR: Updates for Authenticated Web UI and CLI #30

Open
coolaj86 wants to merge 77 commits from next into master
3 changed files with 17 additions and 4 deletions
Showing only changes of commit 6c6f9133e9 - Show all commits

View File

@ -17,6 +17,7 @@ module.exports.create = function (opts) {
}
, setPassword: function (service, name, key) {
var f = path.join(opts.configDir, name + keyext);
console.log('[DEBUG] set', f);
return fs.writeFile(f, key, 'utf8');
}
, deletePassword: function (service, name) {
@ -28,7 +29,9 @@ module.exports.create = function (opts) {
return Promise.all(nodes.filter(function (node) {
return keyext === node.slice(-4);
}).map(function (node) {
return fs.readFile(path.join(opts.configDir, node + keyext));
return fs.readFile(path.join(opts.configDir, node), 'utf8').then(function (data) {
return { password: data };
});
}));
});
}

View File

@ -1,8 +1,11 @@
(function () {
'use strict';
var keystore = require('./keystore.js').create({
configDir: require('path').join(require('os').homedir(), '.local/telebit/')
configDir: require('path').join(require('os').homedir(), '.config/telebit/')
, fallback: true
});
var name = "testy-mctestface-1";
return keystore.get(name).then(function (jwk) {
console.log("get1", typeof jwk, jwk);
@ -10,9 +13,12 @@ return keystore.get(name).then(function (jwk) {
return require('keypairs').generate().then(function (jwk) {
var json = JSON.stringify(jwk.private);
return keystore.set(name, json).then(function () {
return keystore.all().then(function (vals) {
console.log("All", vals);
return keystore.get(name).then(function (val2) {
console.log("get2", val2);
});
});
}).catch(function (err) {
console.log('badness', err);
});
@ -20,3 +26,4 @@ return keystore.get(name).then(function (jwk) {
}
return jwk;
});
}());

View File

@ -4,6 +4,9 @@ module.exports.create = function (opts) {
var service = opts.name || "Telebit";
var keytar;
try {
if (opts.fallback) {
throw new Error("forced fallback");
}
keytar = require('keytar');
// TODO test that long "passwords" (JWTs and JWKs) can be stored in all OSes
} catch(e) {