Skip to content

Commit 90fdbf2

Browse files
authored
chore: fix types
1 parent dc6d694 commit 90fdbf2

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const DEFAULT_PERIOD = 30
2121
* Generates a HMAC-based One Time Password (HOTP) using the provided secret and
2222
* configuration options.
2323
*
24-
* @param {Buffer} secret - The secret used to generate the HOTP.
24+
* @param {ArrayBuffer} secret - The secret used to generate the HOTP.
2525
* @param {Object} options - The configuration options for the HOTP.
2626
* @param {number} [options.counter=0] - The counter value to use for the HOTP.
2727
* Defaults to 0.
@@ -42,7 +42,8 @@ function generateHOTP(
4242
} = {}
4343
) {
4444
const byteCounter = Buffer.from(intToBytes(counter))
45-
const hmac = crypto.createHmac(algorithm, secret)
45+
const secretBuffer = Buffer.from(secret)
46+
const hmac = crypto.createHmac(algorithm, secretBuffer)
4647
const digest = hmac.update(byteCounter).digest('hex')
4748
const hashBytes = hexToBytes(digest)
4849
const offset = hashBytes[19] & 0xf

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
"main": "index.js",
1717
"scripts": {
1818
"test": "node --test --test-reporter spec --experimental-test-coverage *.test.js",
19-
"test:watch": "node --test --test-reporter spec --watch *.test.js"
19+
"test:watch": "node --test --test-reporter spec --watch *.test.js",
20+
"typecheck": "npx -p typescript tsc --declaration --emitDeclarationOnly --allowJs --checkJs --downlevelIteration --module nodenext --moduleResolution nodenext --target es2022 --outDir . index.js"
2021
},
2122
"keywords": [
2223
"totp",

0 commit comments

Comments
 (0)