Skip to content

Commit ed43c47

Browse files
committed
refactor: use argon2 instead of bcrypt
This uses argon2 instead of bcrypt. Note: this means the hash functions are now async which means we have to refactor a lot of other code around auth.
1 parent 5b04903 commit ed43c47

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/node/util.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as cp from "child_process"
22
import * as crypto from "crypto"
3-
import * as bcrypt from "bcrypt"
3+
import * as argon2 from "argon2"
44
import envPaths from "env-paths"
55
import { promises as fs } from "fs"
66
import * as net from "net"
@@ -120,15 +120,15 @@ export const generatePassword = async (length = 24): Promise<string> => {
120120
/**
121121
* Used to hash the password.
122122
*/
123-
export const hash = (password: string): string => {
124-
return bcrypt.hashSync(password, 10)
123+
export const hash = async (password: string): Promise<string> => {
124+
return await argon2.hash(password)
125125
}
126126

127127
/**
128128
* Used to verify if the password matches the hash
129129
*/
130-
export const isHashMatch = (password: string, hash: string) => {
131-
return bcrypt.compareSync(password, hash)
130+
export const isHashMatch = async (password: string, hash: string) => {
131+
return await argon2.verify(hash, password)
132132
}
133133

134134
/**

0 commit comments

Comments
 (0)