Releases: adonisjs/hash
Releases · adonisjs/hash
Update underlying dependencies
- chore: update dependencies abaff9d
Update underlying dependencies
- chore: update dependencies 535e255
Fix types
- fix: types 8ae11cc
Update underlying dependencies
- chore: update dependencies a9b7fc1
Simplify dependency management
Updating underlying dependencies
Integrate prettier and update dependencies
Updating underlying dependencies
- chore: update dependencies 74e28f0
Adding support for faking hash calls
The Hashing algorithms like bcrypt
and argon2
are expensive in nature. For example: It usually takes a couple of hundred milliseconds to hash or verify a password.
The slowness of hashing algorithms can also make your tests slow. With this release, we added the API to fake out Hash
calls during tests using the fake
driver.
Example
Following is not the real code, but an attempt to explain the situation in which Hash.fake
can be useful.
test('create user', async (assert) => {
Hash.fake()
const { body } = await supertest.post('users').send({
email: 'foo@bar.com',
password: 'secret',
})
assert.equal(body.data.password, 'secret')
Hash.restore()
})
API
Hash.fake()
await Hash.make('some-password') // goes through fake driver
await Hash.use('argon').make('some-password') // still uses the fake driver
Commits
Swapping underlying hashing drivers
Earlier we were using @phc/argon2
and @phc/bcrypt
as underlying drivers for hashing values. However, both the packages are not maintained. Even though, the packages code is relatively simple and works fine, but their dependencies on bcrypt
and argon2
packages is outdated