I got a problem with a promise from openpgpjs. If you want to see the entire code : http://pastebin.com/dkcUQVBP (at line 16 and 157)
In NodeJS, i use it like that :
var serverPrivateKey = null;
var serverPublicKey = null;
var isGenerated = false;
openpgp.generateKeyPair(options).then(function(keypair) {
// Success
serverPrivateKey = keypair.privateKeyArmored;
serverPublicKey = keypair.publicKeyArmored;
isGenerated = true;
}).catch(function(error) {
console.log("Erreur lors de la création des clés.");
});
That part works fine, got no problem with it.
But, the same part don't work in angularjs, i got :
io.pgp.generateKeyPair(io.options).then(function(keypair) {
io.setClientPrivateKey(keypair.privateKeyArmored);
io.setClientPublicKey(keypair.publicKeyArmored);
});
I'm not really good with promise and i don't get the problem here.
Inside the promise, i can call a console.log(keypair.privateKeyArmored), and it's working fine. But when i try outside the promise, it's like the data never have been loaded.
What's the part i miss ?
Can someone help me ?
Thx in advance ;)
ps: Sorry if my english is full of mistake, i'm not a natural speaker.