telebit.js/lib/keystore-test.js

23 lines
675 B
JavaScript

'use strict';
var keystore = require('./keystore.js').create({
configDir: require('path').join(require('os').homedir(), '.local/telebit/')
});
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 () {
return keystore.get(name).then(function (val2) {
console.log("get2", val2);
});
}).catch(function (err) {
console.log('badness', err);
});
});
}
return jwk;
});