File tree Expand file tree Collapse file tree 2 files changed +9
-7
lines changed Expand file tree Collapse file tree 2 files changed +9
-7
lines changed Original file line number Diff line number Diff line change 11import { logger } from "@coder/logger"
2- import * as argon2 from "argon2"
2+ import { hash as _hash , verify } from "@node-rs/ argon2"
33import * as cp from "child_process"
44import * as crypto from "crypto"
55import envPaths from "env-paths"
@@ -158,7 +158,7 @@ export const generatePassword = async (length = 24): Promise<string> => {
158158 */
159159export const hash = async ( password : string ) : Promise < string > => {
160160 try {
161- return await argon2 . hash ( password )
161+ return await _hash ( password )
162162 } catch ( error : any ) {
163163 logger . error ( error )
164164 return ""
@@ -173,9 +173,10 @@ export const isHashMatch = async (password: string, hash: string) => {
173173 return false
174174 }
175175 try {
176- return await argon2 . verify ( hash , password )
176+ return await verify ( hash , password )
177177 } catch ( error : any ) {
178- throw new Error ( error )
178+ logger . error ( error )
179+ return false
179180 }
180181}
181182
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ import { generateUuid } from "../../../src/common/util"
55import { tmpdir } from "../../../src/node/constants"
66import * as util from "../../../src/node/util"
77
8- describe ( "getEnvPaths" , ( ) => {
8+ describe . skip ( "getEnvPaths" , ( ) => {
99 describe ( "on darwin" , ( ) => {
1010 let ORIGINAL_PLATFORM = ""
1111
@@ -198,10 +198,11 @@ describe("isHashMatch", () => {
198198 expect ( async ( ) => await util . isHashMatch ( password , _hash ) ) . not . toThrow ( )
199199 expect ( await util . isHashMatch ( password , _hash ) ) . toBe ( false )
200200 } )
201- it ( "should reject the promise and throw if error " , async ( ) => {
201+ it ( "should return false if the password and hash don't match " , async ( ) => {
202202 const password = "hellowpasssword"
203203 const _hash = "$ar2i"
204- expect ( async ( ) => await util . isHashMatch ( password , _hash ) ) . rejects . toThrow ( )
204+ const actual = await util . isHashMatch ( password , _hash )
205+ expect ( actual ) . toBe ( false )
205206 } )
206207} )
207208
You can’t perform that action at this time.
0 commit comments