2019-05-12 06:10:58 +00:00
|
|
|
(function () {
|
2019-03-07 06:18:26 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var keystore = require('./keystore.js').create({
|
2019-05-12 06:10:58 +00:00
|
|
|
configDir: require('path').join(require('os').homedir(), '.config/telebit/')
|
|
|
|
, fallback: true
|
2019-03-07 06:18:26 +00:00
|
|
|
});
|
2019-05-12 06:10:58 +00:00
|
|
|
|
2019-03-07 06:18:26 +00:00
|
|
|
var name = "testy-mctestface-1";
|
|
|
|
return keystore.get(name).then(function (jwk) {
|
|
|
|
console.log("get1", typeof jwk, jwk);
|
|
|
|
if (!jwk || !jwk.kty) {
|
|
|
|
return require('keypairs').generate().then(function (jwk) {
|
|
|
|
var json = JSON.stringify(jwk.private);
|
|
|
|
return keystore.set(name, json).then(function () {
|
2019-05-12 06:10:58 +00:00
|
|
|
return keystore.all().then(function (vals) {
|
|
|
|
console.log("All", vals);
|
|
|
|
return keystore.get(name).then(function (val2) {
|
|
|
|
console.log("get2", val2);
|
|
|
|
});
|
2019-03-07 06:18:26 +00:00
|
|
|
});
|
|
|
|
}).catch(function (err) {
|
|
|
|
console.log('badness', err);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
return jwk;
|
|
|
|
});
|
2019-05-12 06:10:58 +00:00
|
|
|
}());
|