I have used browserify to create a standalone js file, I am able to generate a QR code but
When I am trying to totp.verify using base32 encoding I am getting an error "Uncaught TypeError: item.copy is not a function" the exact statement is "item.copy(buf,pos) in the Buffer.concat function. Seems like a dependency is missing ?
There are no errors shown while using hex and ascii encoding but the verify method still doesn't work.
Below are the code snippets
Generate secret, display QR code, also generate a token
requirejs(['speakeasy', 'qrcode'], function(speakeasy, QRCode) {
_secret = speakeasy.generateSecret({ length: 20 });
_speakeasy = speakeasy;
$('#qrcode').qrcode({
width: 128,
height: 128,
text: _secret.otpauth_url
});
// printing a generated token to validate the token with Google Authorizer
var token = speakeasy.totp({
secret: _secret.ascii,
//encoding: 'base32'
});
$('#qrcode').append(token);
$('#container').delegate('#loginButton', 'click', handleLoginClick);
});
Verify user token
var userToken = $('#usertoken').val();
console.log('userToke:',userToken,'secret',_secret.base32);
var verified = _speakeasy.time.verify({
secret: _secret.ascii,
token: userToken,
window: 2,
step: 60
});
console.log('verified:',verified);
I have used browserify to create a standalone js file, I am able to generate a QR code but
Below are the code snippets
Generate secret, display QR code, also generate a token
Verify user token
Any suggestions on how to fix this ? Thanks