|
| 1 | +/* |
| 2 | +* @adonisjs/core |
| 3 | +* |
| 4 | +* (c) Harminder Virk <[email protected]> |
| 5 | +* |
| 6 | +* For the full copyright and license information, please view the LICENSE |
| 7 | +* file that was distributed with this source code. |
| 8 | +*/ |
| 9 | + |
| 10 | +/** |
| 11 | + * The binding for the given module is defined inside `providers/AppProvider.ts` |
| 12 | + * file. |
| 13 | + */ |
| 14 | +declare module '@ioc:Adonis/Core/Hash' { |
| 15 | + import { |
| 16 | + HashDriverContract, |
| 17 | + HashDrivers as DriversList, |
| 18 | + HashContract as BaseContract, |
| 19 | + BcryptConfigContract, |
| 20 | + ArgonConfigContract, |
| 21 | + } from '@poppinss/hash' |
| 22 | + |
| 23 | + import { ExtractDriversConfig, DriverNodesList } from '@poppinss/manager' |
| 24 | + |
| 25 | + /** |
| 26 | + * Default list of hash drivers. The end user will have to extend this |
| 27 | + * interface, when they decide to extend the `hash` module with |
| 28 | + * a custom driver |
| 29 | + */ |
| 30 | + export interface HashDrivers extends DriverNodesList<HashDriverContract, any> { |
| 31 | + bcrypt: { |
| 32 | + config: BcryptConfigContract, |
| 33 | + implementation: DriversList['bcrypt']['implementation'], |
| 34 | + }, |
| 35 | + argon: { |
| 36 | + config: ArgonConfigContract, |
| 37 | + implementation: DriversList['argon']['implementation'], |
| 38 | + }, |
| 39 | + } |
| 40 | + |
| 41 | + /** |
| 42 | + * The shape of config. This is determined by the list of |
| 43 | + * drivers supported by the hash module. |
| 44 | + */ |
| 45 | + export type HashConfigContract = { |
| 46 | + driver: keyof HashDrivers, |
| 47 | + } & ExtractDriversConfig<HashDrivers> |
| 48 | + |
| 49 | + /** |
| 50 | + * Driver contract, that every driver must implement |
| 51 | + */ |
| 52 | + export { HashDriverContract } |
| 53 | + |
| 54 | + /** |
| 55 | + * Static shape of hash module |
| 56 | + */ |
| 57 | + interface HashContract extends BaseContract<HashDrivers> {} |
| 58 | + |
| 59 | + const Hash: HashContract |
| 60 | + export default Hash |
| 61 | +} |
0 commit comments