Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use for loop instead of for...of #239

Merged
merged 1 commit into from
Aug 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
Uzlopak marked this conversation as resolved.
Show resolved Hide resolved
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