Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function registerUserPublicKey() {
- var user = {
- email: 'hamdi@1vu.fr',
- password: '123456Toto'
- };
- var client = storj.BridgeClient(api, {
- basicauth: user
- });
- // Generate KeyPair
- var keypair = storj.KeyPair();
- console.log(keypair);
- // Load keypair from your saved private key
- //var keypair = storj.KeyPair(fs.readFileSync('c:/temp/privatekey').toString());
- // Login using the keypair generated
- var client = storj.BridgeClient(api, {
- keyPair: keypair
- });
- fs.writeFileSync('c:/temp/privatekey', keypair.getPrivateKey());
- // Add the keypair public key to the user account for authentication
- client.addPublicKey(keypair.getPublicKey(), function (err) {
- console.log(keypair.getPublicKey());
- if (err) {
- // Handle error on failure.
- return console.log('error', err.message);
- }
- // Save the private key for using to login later.
- // You should probably encrypt this
- fs.writeFileSync('c:/temp/privatekey', keypair.getPrivateKey());
- console.log("User " + user + " registred successfully");
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement