Skip to content

Commit

Permalink
chore: fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
kldeb authored Aug 29, 2024
1 parent dc6d694 commit 90fdbf2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const DEFAULT_PERIOD = 30
* Generates a HMAC-based One Time Password (HOTP) using the provided secret and
* configuration options.
*
* @param {Buffer} secret - The secret used to generate the HOTP.
* @param {ArrayBuffer} secret - The secret used to generate the HOTP.
* @param {Object} options - The configuration options for the HOTP.
* @param {number} [options.counter=0] - The counter value to use for the HOTP.
* Defaults to 0.
Expand All @@ -42,7 +42,8 @@ function generateHOTP(
} = {}
) {
const byteCounter = Buffer.from(intToBytes(counter))
const hmac = crypto.createHmac(algorithm, secret)
const secretBuffer = Buffer.from(secret)
const hmac = crypto.createHmac(algorithm, secretBuffer)
const digest = hmac.update(byteCounter).digest('hex')
const hashBytes = hexToBytes(digest)
const offset = hashBytes[19] & 0xf
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"main": "index.js",
"scripts": {
"test": "node --test --test-reporter spec --experimental-test-coverage *.test.js",
"test:watch": "node --test --test-reporter spec --watch *.test.js"
"test:watch": "node --test --test-reporter spec --watch *.test.js",
"typecheck": "npx -p typescript tsc --declaration --emitDeclarationOnly --allowJs --checkJs --downlevelIteration --module nodenext --moduleResolution nodenext --target es2022 --outDir . index.js"
},
"keywords": [
"totp",
Expand Down

0 comments on commit 90fdbf2

Please sign in to comment.