File tree Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change 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" ,
You can’t perform that action at this time.
0 commit comments