Advertisement
Guest User

Untitled

a guest
Jul 26th, 2018
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.25 KB | None | 0 0
  1. const jsrp = require('jsrp');
  2. const readline = require('readline');
  3.  
  4. var client = new jsrp.client();
  5.  
  6. const readLine = readline.createInterface({
  7. input: process.stdin,
  8. output: process.stdout,
  9. });
  10.  
  11. const paramSize = 2048;
  12. const email = 'sam@opus1.io';
  13. const password = 'Test1234';
  14.  
  15. console.log(`logging in with credentials: { email: '${email}', password: '${password}' }`);
  16. client.init({ username: email, password, length: paramSize }, () => {
  17. // Register
  18. console.log('==================================');
  19. console.log('logging in user...');
  20. // Login
  21. console.log(`*Client Public Key: '${client.getPublicKey()}'`);
  22. readLine.question('Please Enter Server Salt: ', (salt) => {
  23. // console.log('using salt: ', client.setSalt(salt));
  24. // console.log(`using salt: '${salt}'`);
  25. client.setSalt(salt);
  26.  
  27.  
  28. readLine.question(
  29. 'Please Enter Server Public Key: ',
  30. (serverPubKey) => {
  31. // console.log(`using server pub key: '${serverPubKey}'`);
  32. client.setServerPublicKey(serverPubKey);
  33. console.log(`*Client Proof: '${client.getProof()}'`);
  34.  
  35.  
  36. readLine.question(
  37. 'Please Enter Server Proof: ',
  38. (serverProof) => {
  39. console.log(`Server Proof Accepted: '${client.checkServerProof(serverProof)}'`);
  40. console.log('==================================');
  41. },
  42. );
  43. },
  44. );
  45. });
  46. // console.log('registering user...');
  47. // client.createVerifier(function(err, result) {
  48. // // result will contain the necessary values the server needs to
  49. // // authenticate this user in the future.
  50. // console.log(`*created salt: '${result.salt}'`);
  51. // console.log(`*created verifier: '${result.verifier}'`);
  52.  
  53. // console.log('==================================');
  54. // console.log('==================================');
  55. // console.log('logging in user...');
  56. // // Login
  57. // console.log(`*Client Public Key: '${client.getPublicKey()}'`);
  58. // readLine.question('Please Enter Server Salt: ', (salt) => {
  59. // // console.log('using salt: ', client.setSalt(salt));
  60. // // console.log(`using salt: '${salt}'`);
  61. // client.setSalt(salt);
  62.  
  63.  
  64. // readLine.question(
  65. // 'Please Enter Server Public Key: ',
  66. // (serverPubKey) => {
  67. // // console.log(`using server pub key: '${serverPubKey}'`);
  68. // client.setServerPublicKey(serverPubKey);
  69. // console.log(`*Client Proof: '${client.getProof()}'`);
  70.  
  71.  
  72. // readLine.question(
  73. // 'Please Enter Server Proof: ',
  74. // (serverProof) => {
  75. // console.log(`Server Proof Accepted: '${client.checkServerProof(serverProof)}'`);
  76. // console.log('==================================');
  77. // },
  78. // );
  79. // },
  80. // );
  81. // });
  82. // });
  83. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement