Skip to content

Commit

Permalink
move createHash to hostVerifier
Browse files Browse the repository at this point in the history
  • Loading branch information
Ishan committed Jul 21, 2024
1 parent f96c43e commit 1bd608d
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,14 +273,10 @@ class Client extends EventEmitter {
let hostVerifier;
if (typeof cfg.hostVerifier === 'function') {
const hashCb = cfg.hostVerifier;
let hasher;
if (HASHES.indexOf(cfg.hostHash) !== -1) {
// Default to old behavior of hashing on user's behalf
hasher = createHash(cfg.hostHash);
}
hostVerifier = (key, verify) => {
if (hasher) {
hasher.update(key);
if (HASHES.indexOf(cfg.hostHash) !== -1) {
// Default to old behavior of hashing on user's behalf
const hasher = createHash(cfg.hostHash).update(key);
key = hasher.digest('hex');
}
const ret = hashCb(key, verify);
Expand Down

0 comments on commit 1bd608d

Please sign in to comment.