Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
dd2cb16
chore: update CHANGELOG
jsjoeio May 19, 2021
cac6673
refactor: use bcrypt in hash function
jsjoeio May 19, 2021
17be8c5
refactor: use bcrypt in e2e setup
jsjoeio May 19, 2021
f35120c
feat: add unit test for hash function
jsjoeio May 19, 2021
aaf0447
refactor: add functions to check hash password
jsjoeio May 19, 2021
fc3326f
feat: add tests using real hashes
jsjoeio May 20, 2021
dc2db5c
chore: add argon2 package
jsjoeio Jun 2, 2021
51f8341
chore: update to argon2 in test
jsjoeio Jun 2, 2021
70197bb
refactor: use argon2 instead of bcrypt
jsjoeio Jun 2, 2021
fd3cb6c
refactor: update unit tests for hash fns
jsjoeio Jun 2, 2021
fcc3f0d
refactor: update login logic with new async hashing
jsjoeio Jun 2, 2021
0cdbd33
refactor: make authenticated async everywhere
jsjoeio Jun 2, 2021
91303d4
refactor: make ensureAuthenticated async
jsjoeio Jun 2, 2021
1134780
refactor: make wsProxy async
jsjoeio Jun 2, 2021
788b958
refactor: update hash fn in test config
jsjoeio Jun 2, 2021
ffa5c16
feat: update cli and test for hashed-password
jsjoeio Jun 2, 2021
7ff4117
feat: add getPasswordMethod & test for it
jsjoeio Jun 2, 2021
a14ea39
feat: add handlePasswordValidation + tests
jsjoeio Jun 2, 2021
409b473
refactor: rewrite password logic at /login
jsjoeio Jun 2, 2021
6020480
feat: add isCookieValid function and tests
jsjoeio Jun 3, 2021
923761c
refactor: password logic in http w/ isCookieValid
jsjoeio Jun 3, 2021
517aaf7
docs: update FAQ with new hashing instructions
jsjoeio Jun 3, 2021
531b7c0
feat: add splitOnFirstEquals function
jsjoeio Jun 3, 2021
8c2bb61
refactor: parse options with multiple = in cli
jsjoeio Jun 3, 2021
deaa224
feat: add npm_config_build_from_source to build scripts
jsjoeio Jun 7, 2021
3b50bfc
fix: sanitize password and cookie key
jsjoeio Jun 7, 2021
1e55a64
feat: check for empty str in isHashMatch
jsjoeio Jun 7, 2021
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
Prev Previous commit
Next Next commit
refactor: update unit tests for hash fns
Since the hash and isHashMatch are now async, I had to update the tests
accordingly. Now everything is working.
  • Loading branch information
jsjoeio committed Jun 8, 2021
commit fd3cb6cfa028b63c0e3600ce1283f8316cfad15a
29 changes: 16 additions & 13 deletions test/unit/node/util.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,28 +149,31 @@ describe("getEnvPaths", () => {
})

describe("hash", () => {
it("should return a hash of the string passed in", () => {
it("should return a hash of the string passed in", async () => {
const plainTextPassword = "mySecretPassword123"
const hashed = hash(plainTextPassword)
const hashed = await hash(plainTextPassword)
expect(hashed).not.toBe(plainTextPassword)
})
})

describe("isHashMatch", () => {
it("should return true if the password matches the hash", () => {
const password = "password123"
const _hash = hash(password)
expect(isHashMatch(password, _hash)).toBe(true)
it("should return true if the password matches the hash", async () => {
const password = "codeserver1234"
const _hash = await hash(password)
const actual = await isHashMatch(password, _hash)
expect(actual).toBe(true)
})
it("should return false if the password does not match the hash", () => {
it("should return false if the password does not match the hash", async () => {
const password = "password123"
const _hash = hash(password)
expect(isHashMatch("otherPassword123", _hash)).toBe(false)
const _hash = await hash(password)
const actual = await isHashMatch("otherPassword123", _hash)
expect(actual).toBe(false)
})
it("should return true with actual hash", () => {
const password = "password"
const _hash = "$2b$10$GA/eZnlboeV9eW8LnntPqe1dZE7tQ/./wCdc7NgJhMRB.xhaJfmG."
expect(isHashMatch(password, _hash)).toBe(true)
it("should return true with actual hash", async () => {
const password = "password123"
const _hash = "$argon2i$v=19$m=4096,t=3,p=1$EAoczTxVki21JDfIZpTUxg$rkXgyrW4RDGoDYrxBFD4H2DlSMEhP4h+Api1hXnGnFY"
const actual = await isHashMatch(password, _hash)
expect(actual).toBe(true)
})
})

Expand Down