2023-03-03 15:54:28 +00:00
|
|
|
/**
|
|
|
|
* Config source: https://git.io/JfefW
|
|
|
|
*
|
|
|
|
* Feel free to let us know via PR, if you find something broken in this config
|
|
|
|
* file.
|
|
|
|
*/
|
|
|
|
|
2024-03-14 19:25:27 +00:00
|
|
|
import env from '#start/env';
|
2024-04-25 13:17:22 +00:00
|
|
|
import { defineConfig, drivers } from '@adonisjs/core/hash';
|
2024-03-14 19:25:27 +00:00
|
|
|
import { laravelDriver } from '../providers/HashDriver/index.js';
|
2023-03-03 15:54:28 +00:00
|
|
|
/*
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
| Hash Config
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
| The `HashConfig` relies on the `HashList` interface which is
|
|
|
|
| defined inside `contracts` directory.
|
|
|
|
|
|
|
|
|
*/
|
2024-04-25 13:17:22 +00:00
|
|
|
const hashConfig = defineConfig({
|
|
|
|
/*
|
2024-03-14 19:25:27 +00:00
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
| Default hasher
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
| By default we make use of the argon hasher to hash values. However, feel
|
|
|
|
| free to change the default value
|
|
|
|
|
|
|
|
|
*/
|
2024-04-25 13:17:22 +00:00
|
|
|
default: env.get('HASH_DRIVER', 'scrypt'),
|
2024-03-14 19:25:27 +00:00
|
|
|
|
2024-04-25 13:17:22 +00:00
|
|
|
list: {
|
|
|
|
/*
|
2024-03-14 19:25:27 +00:00
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
| scrypt
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
| Scrypt mapping uses the Node.js inbuilt crypto module for creating
|
|
|
|
| hashes.
|
|
|
|
|
|
|
|
|
| We are using the default configuration recommended within the Node.js
|
|
|
|
| documentation.
|
|
|
|
| https://nodejs.org/api/crypto.html#cryptoscryptpassword-salt-keylen-options-callback
|
|
|
|
|
|
|
|
|
*/
|
2024-04-25 13:17:22 +00:00
|
|
|
scrypt: drivers.scrypt({
|
|
|
|
cost: 16384,
|
|
|
|
blockSize: 8,
|
|
|
|
parallelization: 1,
|
|
|
|
saltSize: 16,
|
|
|
|
keyLength: 64,
|
|
|
|
maxMemory: 32 * 1024 * 1024,
|
|
|
|
}),
|
2024-03-14 19:25:27 +00:00
|
|
|
|
2024-04-25 13:17:22 +00:00
|
|
|
/*
|
2024-03-14 19:25:27 +00:00
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
| Argon
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
| Argon mapping uses the `argon2` driver to hash values.
|
|
|
|
|
|
|
|
|
| Make sure you install the underlying dependency for this driver to work.
|
|
|
|
| https://www.npmjs.com/package/phc-argon2.
|
|
|
|
|
|
|
|
|
| npm install phc-argon2
|
|
|
|
|
|
|
|
|
*/
|
2024-04-25 13:17:22 +00:00
|
|
|
argon: drivers.argon2({
|
|
|
|
variant: 'id',
|
|
|
|
iterations: 3,
|
|
|
|
memory: 4096,
|
|
|
|
parallelism: 1,
|
|
|
|
saltSize: 16,
|
|
|
|
}),
|
2023-03-03 15:54:28 +00:00
|
|
|
|
2024-04-25 13:17:22 +00:00
|
|
|
/*
|
2024-03-14 19:25:27 +00:00
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
| Bcrypt
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
| Bcrypt mapping uses the `bcrypt` driver to hash values.
|
|
|
|
|
|
|
|
|
| Make sure you install the underlying dependency for this driver to work.
|
|
|
|
| https://www.npmjs.com/package/phc-bcrypt.
|
|
|
|
|
|
|
|
|
| npm install phc-bcrypt
|
|
|
|
|
|
|
|
|
*/
|
2024-04-25 13:17:22 +00:00
|
|
|
bcrypt: drivers.bcrypt({
|
|
|
|
rounds: 10,
|
|
|
|
}),
|
2023-03-03 15:54:28 +00:00
|
|
|
|
2024-04-25 13:17:22 +00:00
|
|
|
laravel: laravelDriver({
|
|
|
|
rounds: 10,
|
|
|
|
}),
|
|
|
|
},
|
2023-03-03 15:54:28 +00:00
|
|
|
});
|
2024-03-14 19:25:27 +00:00
|
|
|
|
2024-04-25 13:17:22 +00:00
|
|
|
export default hashConfig;
|
2024-03-14 19:25:27 +00:00
|
|
|
|
|
|
|
declare module '@adonisjs/core/types' {
|
2024-04-25 13:17:22 +00:00
|
|
|
export interface HashersList extends InferHashers<typeof hashConfig> {}
|
2024-03-14 19:25:27 +00:00
|
|
|
}
|