Advertisement
Guest User

Untitled

a guest
Nov 7th, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. function registerUserPublicKey() {
  2. var user = {
  3. email: 'hamdi@1vu.fr',
  4. password: '123456Toto'
  5. };
  6. var client = storj.BridgeClient(api, {
  7. basicauth: user
  8. });
  9. // Generate KeyPair
  10. var keypair = storj.KeyPair();
  11. console.log(keypair);
  12. // Load keypair from your saved private key
  13. //var keypair = storj.KeyPair(fs.readFileSync('c:/temp/privatekey').toString());
  14. // Login using the keypair generated
  15. var client = storj.BridgeClient(api, {
  16. keyPair: keypair
  17. });
  18. fs.writeFileSync('c:/temp/privatekey', keypair.getPrivateKey());
  19. // Add the keypair public key to the user account for authentication
  20. client.addPublicKey(keypair.getPublicKey(), function (err) {
  21. console.log(keypair.getPublicKey());
  22. if (err) {
  23. // Handle error on failure.
  24. return console.log('error', err.message);
  25. }
  26. // Save the private key for using to login later.
  27. // You should probably encrypt this
  28. fs.writeFileSync('c:/temp/privatekey', keypair.getPrivateKey());
  29. console.log("User " + user + " registred successfully");
  30. });
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement