Closed trajano closed 7 months ago
Describe the bug Trying out the library with https://www.verifyr.com/en/otp/check not sure if it is a problem with the tool or the library.
To Reproduce
import { test, expect } from "@jest/globals"; import { Authenticator, HashAlgorithms, KeyEncodings } from "@otplib/core"; import { keyDecoder, keyEncoder } from "@otplib/plugin-thirty-two"; import { createDigest } from "@otplib/plugin-crypto"; test("otp", () => { const secret = "obtained from the server"; const authenticator = new Authenticator({ algorithm: HashAlgorithms.SHA1, digits: 6, epoch: 0, step: 30, keyDecoder, keyEncoder, createDigest, }); const token = authenticator.generate(secret); console.log(token); const isValid = authenticator.verify({ token, secret }); expect(isValid).toBe(true); });
Expected behavior
The OTP code that I got printed on the console works on the verifyr website, but it fails verification
Screenshots
Details (please provide any relevant information):
Additional context Add any other context about the problem here.
Nix that epoch should be Date.now()
epoch
Date.now()
Describe the bug Trying out the library with https://www.verifyr.com/en/otp/check not sure if it is a problem with the tool or the library.
To Reproduce
Expected behavior
The OTP code that I got printed on the console works on the verifyr website, but it fails verification
Screenshots
Details (please provide any relevant information):
Additional context Add any other context about the problem here.