telebit.js/lib/keystore-test.js

30 lines
822 B
JavaScript
Raw Normal View History

2019-05-12 06:10:58 +00:00
(function () {
'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-05-12 06:10:58 +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);
});
});
}).catch(function (err) {
console.log('badness', err);
});
});
}
return jwk;
});
2019-05-12 06:10:58 +00:00
}());