time2fa icon indicating copy to clipboard operation
time2fa copied to clipboard

Validation of TOTP always false when adding custom period

Open baartch opened this issue 10 months ago • 0 comments

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?

baartch avatar Apr 10 '24 05:04 baartch