diff options
author | 2024-02-10 18:19:14 -0700 | |
---|---|---|
committer | 2024-02-13 06:59:44 +0530 | |
commit | 7584d2d7a7110aef0331ebfa178b2295842c59fa (patch) | |
tree | 900cd71237e6231b57936fcce77ff229cd459041 /config/hash.ts | |
parent | upgrade recipes submodule (diff) | |
download | ferdium-server-7584d2d7a7110aef0331ebfa178b2295842c59fa.tar.gz ferdium-server-7584d2d7a7110aef0331ebfa178b2295842c59fa.tar.zst ferdium-server-7584d2d7a7110aef0331ebfa178b2295842c59fa.zip |
refactor: project maintenance
- work in progress
Diffstat (limited to 'config/hash.ts')
-rw-r--r-- | config/hash.ts | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/config/hash.ts b/config/hash.ts index abe7dd0..22e38bd 100644 --- a/config/hash.ts +++ b/config/hash.ts | |||
@@ -5,8 +5,9 @@ | |||
5 | * file. | 5 | * file. |
6 | */ | 6 | */ |
7 | 7 | ||
8 | import Env from '@ioc:Adonis/Core/Env'; | 8 | import env from '#start/env' |
9 | import { hashConfig } from '@adonisjs/core/build/config'; | 9 | import { defineConfig } from '@adonisjs/core/hash' |
10 | import { drivers } from '@adonisjs/core/hash' | ||
10 | 11 | ||
11 | /* | 12 | /* |
12 | |-------------------------------------------------------------------------- | 13 | |-------------------------------------------------------------------------- |
@@ -17,7 +18,7 @@ import { hashConfig } from '@adonisjs/core/build/config'; | |||
17 | | defined inside `contracts` directory. | 18 | | defined inside `contracts` directory. |
18 | | | 19 | | |
19 | */ | 20 | */ |
20 | export default hashConfig({ | 21 | export default defineConfig({ |
21 | /* | 22 | /* |
22 | |-------------------------------------------------------------------------- | 23 | |-------------------------------------------------------------------------- |
23 | | Default hasher | 24 | | Default hasher |
@@ -28,18 +29,17 @@ export default hashConfig({ | |||
28 | | | 29 | | |
29 | | Default is set to bcrypt to prevent breaking-changes. | 30 | | Default is set to bcrypt to prevent breaking-changes. |
30 | */ | 31 | */ |
31 | default: Env.get('HASH_DRIVER', 'scrypt'), | 32 | default: env.get('HASH_DRIVER', 'scrypt'), |
32 | 33 | ||
33 | list: { | 34 | list: { |
34 | scrypt: { | 35 | scrypt: drivers.scrypt({ |
35 | driver: 'scrypt', | ||
36 | cost: 16_384, | 36 | cost: 16_384, |
37 | blockSize: 8, | 37 | blockSize: 8, |
38 | parallelization: 1, | 38 | parallelization: 1, |
39 | saltSize: 16, | 39 | saltSize: 16, |
40 | keyLength: 64, | 40 | keyLength: 64, |
41 | maxMemory: 32 * 1024 * 1024, | 41 | maxMemory: 32 * 1024 * 1024, |
42 | }, | 42 | }), |
43 | /* | 43 | /* |
44 | |-------------------------------------------------------------------------- | 44 | |-------------------------------------------------------------------------- |
45 | | Argon | 45 | | Argon |
@@ -53,14 +53,13 @@ export default hashConfig({ | |||
53 | | npm install phc-argon2 | 53 | | npm install phc-argon2 |
54 | | | 54 | | |
55 | */ | 55 | */ |
56 | argon: { | 56 | argon: drivers.argon2({ |
57 | driver: 'argon2', | ||
58 | variant: 'id', | 57 | variant: 'id', |
59 | iterations: 3, | 58 | iterations: 3, |
60 | memory: 4096, | 59 | memory: 4096, |
61 | parallelism: 1, | 60 | parallelism: 1, |
62 | saltSize: 16, | 61 | saltSize: 16, |
63 | }, | 62 | }), |
64 | 63 | ||
65 | /* | 64 | /* |
66 | |-------------------------------------------------------------------------- | 65 | |-------------------------------------------------------------------------- |
@@ -75,14 +74,17 @@ export default hashConfig({ | |||
75 | | npm install phc-bcrypt | 74 | | npm install phc-bcrypt |
76 | | | 75 | | |
77 | */ | 76 | */ |
78 | bcrypt: { | 77 | bcrypt: drivers.bcrypt({ |
79 | driver: 'bcrypt', | ||
80 | rounds: 10, | 78 | rounds: 10, |
81 | }, | 79 | }), |
82 | 80 | ||
83 | legacy: { | 81 | legacy: { |
84 | // @ts-expect-error | 82 | // @ts-expect-error |
85 | driver: 'legacy', | 83 | driver: 'legacy', |
86 | }, | 84 | }, |
87 | }, | 85 | }, |
88 | }); | 86 | }) |
87 | |||
88 | declare module '@adonisjs/core/types' { | ||
89 | export interface HashersList extends InferHashers<typeof hashConfig> {} | ||
90 | } | ||