sjudson / paseto.js

PASETO: Platform-Agnostic Security Tokens
MIT License
269 stars 16 forks source link

PrivateKey.public cannot be used in the promise interface #28

Closed sloonz closed 4 years ago

sloonz commented 4 years ago

I use this code to generate a keypair :

const Paseto = require('paseto.js');    

async function main() {    
  const priv = new Paseto.PrivateKey(new Paseto.V2());    
  await priv.generate();    
  const pub = await priv.public();                                                      
  console.log(`Private key: ${(await priv.raw()).toString('base64')}`);    
  console.log(`Public key: ${(await pub.raw()).toString('base64')}`);      
}                                                                        

main().catch(err => {    
  console.log(err);      
});                    

Unfortunately, this fails because priv.public() returns undefined instead of a promise. The callback-style API works fine.

sjudson commented 4 years ago

Thanks for the report, will look at and hopefully get a fix up over the weekend.

sjudson commented 4 years ago

Fixed in 0.1.6.

sloonz commented 4 years ago

Thank you !