Skip to content

Commit

Permalink
Fix algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
valeriangalliat committed Jan 15, 2022
1 parent d9f8c66 commit 9c9137e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@ function totpFromUriOrSecret (value) {
const search = new URLSearchParams(new URL(value).search)
let { secret, algorithm, digits, period } = Object.fromEntries(search)

// Some providers give `SHA1` but `jssha` expects `SHA-1`.
algorithm = algorithm.replace(/^SHA(\d+)$/i, 'SHA-$1')
if (algorithm) {
// Some providers give `SHA1` but `jssha` expects `SHA-1`.
algorithm = algorithm.replace(/^SHA(\d+)$/i, 'SHA-$1')
}

return totp(secret, { algorithm, digits, period })
}
Expand Down

0 comments on commit 9c9137e

Please sign in to comment.