Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validation of TOTP always false when adding custom period #301

Closed
baartch opened this issue Apr 10, 2024 · 1 comment
Closed

Validation of TOTP always false when adding custom period #301

baartch opened this issue Apr 10, 2024 · 1 comment

Comments

@baartch
Copy link

baartch commented Apr 10, 2024

Hi

I wanted to use your package. But I face an issue.

I tried to following to create a TOTP

  // Generate the OTP
  const config = generateConfig({
    period: 120,
  });
  const secret = generateSecret(config.secretSize);
  const codes = Totp.generatePasscodes({ secret: secret }, config);

and the following to validate (of course with passcode and secret from above)

  // Validate the OTP
  const config = generateConfig({
    period: 120,
  });
  const valid = Totp.validate({ passcode: '097991', secret: '2X4A3XCNPJJSHU4O' }, config);

This always results in false. When I remove the period: 120 in the config, it works.
Any idea? Is there a limit for the period?

@hugoewarrior
Copy link

hugoewarrior commented Oct 25, 2024

Hi, i recently saw a PR fixing this. Basically you should add config values on Totp.validate function. Example:
image

PR im refering to: #152

Hope it helps!

@n0cloud n0cloud closed this as completed Nov 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants