Skip to content

Commit 85f1017

Browse files
committed
feat: add support for hash provider
1 parent 3846814 commit 85f1017

File tree

5 files changed

+463
-52
lines changed

5 files changed

+463
-52
lines changed

README.md

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
1414
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
15-
1615
## Table of contents
1716

1817
- [Change log](#change-log)

adonis-typings/hash.ts

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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

Comments
 (0)