Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const jsrp = require('jsrp');
- const readline = require('readline');
- var client = new jsrp.client();
- const readLine = readline.createInterface({
- input: process.stdin,
- output: process.stdout,
- });
- const paramSize = 2048;
- const email = 'sam@opus1.io';
- const password = 'Test1234';
- console.log(`logging in with credentials: { email: '${email}', password: '${password}' }`);
- client.init({ username: email, password, length: paramSize }, () => {
- // Register
- console.log('==================================');
- console.log('logging in user...');
- // Login
- console.log(`*Client Public Key: '${client.getPublicKey()}'`);
- readLine.question('Please Enter Server Salt: ', (salt) => {
- // console.log('using salt: ', client.setSalt(salt));
- // console.log(`using salt: '${salt}'`);
- client.setSalt(salt);
- readLine.question(
- 'Please Enter Server Public Key: ',
- (serverPubKey) => {
- // console.log(`using server pub key: '${serverPubKey}'`);
- client.setServerPublicKey(serverPubKey);
- console.log(`*Client Proof: '${client.getProof()}'`);
- readLine.question(
- 'Please Enter Server Proof: ',
- (serverProof) => {
- console.log(`Server Proof Accepted: '${client.checkServerProof(serverProof)}'`);
- console.log('==================================');
- },
- );
- },
- );
- });
- // console.log('registering user...');
- // client.createVerifier(function(err, result) {
- // // result will contain the necessary values the server needs to
- // // authenticate this user in the future.
- // console.log(`*created salt: '${result.salt}'`);
- // console.log(`*created verifier: '${result.verifier}'`);
- // console.log('==================================');
- // console.log('==================================');
- // console.log('logging in user...');
- // // Login
- // console.log(`*Client Public Key: '${client.getPublicKey()}'`);
- // readLine.question('Please Enter Server Salt: ', (salt) => {
- // // console.log('using salt: ', client.setSalt(salt));
- // // console.log(`using salt: '${salt}'`);
- // client.setSalt(salt);
- // readLine.question(
- // 'Please Enter Server Public Key: ',
- // (serverPubKey) => {
- // // console.log(`using server pub key: '${serverPubKey}'`);
- // client.setServerPublicKey(serverPubKey);
- // console.log(`*Client Proof: '${client.getProof()}'`);
- // readLine.question(
- // 'Please Enter Server Proof: ',
- // (serverProof) => {
- // console.log(`Server Proof Accepted: '${client.checkServerProof(serverProof)}'`);
- // console.log('==================================');
- // },
- // );
- // },
- // );
- // });
- // });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement