Skip to content

Commit

Permalink
use for loop instead of for...of (#239)
Browse files Browse the repository at this point in the history
  • Loading branch information
gurgunday committed Aug 1, 2023
1 parent d83e093 commit c926f46
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions signer.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ function Signer (secrets, algorithm = 'sha256') {
}

function validateSecrets (secrets) {
for (const secret of secrets) {
for (let i = 0; i < secrets.length; ++i) {
const secret = secrets[i]
if (typeof secret !== 'string' && Buffer.isBuffer(secret) === false) {
throw new TypeError('Secret key must be a string or Buffer.')
}
Expand Down Expand Up @@ -59,7 +60,8 @@ function _unsign (signedValue, secrets, algorithm) {
const value = signedValue.slice(0, signedValue.lastIndexOf('.'))
const actual = Buffer.from(signedValue.slice(signedValue.lastIndexOf('.') + 1))

for (const secret of secrets) {
for (let i = 0; i < secrets.length; ++i) {
const secret = secrets[i]
const expected = Buffer.from(crypto
.createHmac(algorithm, secret)
.update(value)
Expand Down

0 comments on commit c926f46

Please sign in to comment.