-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(qr): b64 padding and content addition
also fixes the example where refresh count should be updated
- Loading branch information
Showing
3 changed files
with
9 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
import { base64, base64url } from "@scure/base"; | ||
import { base64urlnopad } from "@scure/base"; | ||
import { packBigEndian } from "~/core/pack"; | ||
import { hashWithHMAC } from "~/core/hmac"; | ||
|
||
export const otp = (seed: string, counter: number): string => { | ||
const packedCounter = packBigEndian(counter); | ||
return base64url.encode(hashWithHMAC(packedCounter, base64.decode(seed))); | ||
return base64urlnopad.encode(hashWithHMAC(packedCounter, base64urlnopad.decode(seed))); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters