feat: release authentication laboratories 0.3.0
This commit is contained in:
@@ -2,6 +2,7 @@ import { describe, expect, it } from "vitest";
|
||||
import { utf8ToBytes } from "../../src/crypto/encoding";
|
||||
import {
|
||||
hotp,
|
||||
resynchronizeHotp,
|
||||
totp,
|
||||
totpCounter,
|
||||
verifyHotp,
|
||||
@@ -41,6 +42,33 @@ describe("HOTP", () => {
|
||||
});
|
||||
expect(match).toMatchObject({ counter: 4n, delta: 3 });
|
||||
});
|
||||
|
||||
it("resynchronizes with one or two bounded consecutive codes", async () => {
|
||||
const secret = utf8ToBytes("12345678901234567890");
|
||||
await expect(
|
||||
resynchronizeHotp({
|
||||
firstCode: "338314",
|
||||
secondCode: "254676",
|
||||
secret,
|
||||
counter: 1n,
|
||||
lookAhead: 10,
|
||||
}),
|
||||
).resolves.toEqual({
|
||||
matchedCounter: 4n,
|
||||
nextCounter: 6n,
|
||||
distance: 3,
|
||||
confidence: "consecutive-codes",
|
||||
});
|
||||
await expect(
|
||||
resynchronizeHotp({
|
||||
firstCode: "338314",
|
||||
secondCode: "000000",
|
||||
secret,
|
||||
counter: 1n,
|
||||
lookAhead: 10,
|
||||
}),
|
||||
).resolves.toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe("TOTP", () => {
|
||||
|
||||
Reference in New Issue
Block a user