-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add provider and templates for adonisjs
- Loading branch information
1 parent
9dc3d2e
commit 05f06fa
Showing
9 changed files
with
223 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
**[@adonisjs/hash](../README.md)** | ||
|
||
[Globals](../README.md) › ["providers/HashProvider"](../modules/_providers_hashprovider_.md) › [ConfigProvider](_providers_hashprovider_.configprovider.md) | ||
|
||
# Class: ConfigProvider | ||
|
||
## Hierarchy | ||
|
||
* **ConfigProvider** | ||
|
||
## Index | ||
|
||
### Constructors | ||
|
||
* [constructor](_providers_hashprovider_.configprovider.md#constructor) | ||
|
||
### Properties | ||
|
||
* [$container](_providers_hashprovider_.configprovider.md#protected-$container) | ||
|
||
### Methods | ||
|
||
* [register](_providers_hashprovider_.configprovider.md#register) | ||
|
||
## Constructors | ||
|
||
### constructor | ||
|
||
\+ **new ConfigProvider**(`$container`: IocContract): *[ConfigProvider](_providers_hashprovider_.configprovider.md)* | ||
|
||
**Parameters:** | ||
|
||
Name | Type | | ||
------ | ------ | | ||
`$container` | IocContract | | ||
|
||
**Returns:** *[ConfigProvider](_providers_hashprovider_.configprovider.md)* | ||
|
||
## Properties | ||
|
||
### `Protected` $container | ||
|
||
• **$container**: *IocContract* | ||
|
||
## Methods | ||
|
||
### register | ||
|
||
▸ **register**(): *void* | ||
|
||
**Returns:** *void* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
**[@adonisjs/hash](../README.md)** | ||
|
||
[Globals](../README.md) › ["providers/HashProvider"](_providers_hashprovider_.md) | ||
|
||
# External module: "providers/HashProvider" | ||
|
||
## Index | ||
|
||
### Classes | ||
|
||
* [ConfigProvider](../classes/_providers_hashprovider_.configprovider.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* @module @adonisjs/hash | ||
*/ | ||
|
||
/* | ||
* @adonisjs/hash | ||
* | ||
* (c) Harminder Virk <virk@adonisjs.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
import { IocContract } from '@adonisjs/fold' | ||
import { Hash } from '../src/Hash' | ||
|
||
export default class ConfigProvider { | ||
constructor (protected $container: IocContract) {} | ||
|
||
public register () { | ||
this.$container.singleton('Adonis/Core/Hash', () => { | ||
const config = this.$container.use('Adonis/Core/Config').get('hash', {}) | ||
return new Hash(this, config) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/** | ||
* Config source: https://git.io/fj1Kb | ||
* | ||
* Feel free to let us know via PR, if you find something broken in this config | ||
* file. | ||
*/ | ||
|
||
import { HashConfigContract } from '@ioc:Adonis/Core/Hash' | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Hash Config | ||
|-------------------------------------------------------------------------- | ||
| | ||
| The `HashConfigContract` relies on the `HashList` interface which is | ||
| defined inside `contracts` directory. | ||
| | ||
*/ | ||
const hashConfig: HashConfigContract = { | ||
/* | ||
|-------------------------------------------------------------------------- | ||
| Default mapping | ||
|-------------------------------------------------------------------------- | ||
| | ||
| By default we make use of the bcrypt mapping to hash values. However, feel | ||
| free to change the default value | ||
| | ||
*/ | ||
default: 'bcrypt', | ||
|
||
list: { | ||
/* | ||
|-------------------------------------------------------------------------- | ||
| 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@"<2.0.0" | ||
| | ||
*/ | ||
argon: { | ||
driver: 'argon2', | ||
variant: 'id', | ||
iterations: 3, | ||
memory: 4096, | ||
parallelism: 1, | ||
saltSize: 16, | ||
}, | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| 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@"<2.0.0" | ||
| | ||
*/ | ||
bcrypt: { | ||
driver: 'bcrypt', | ||
rounds: 10, | ||
}, | ||
}, | ||
} | ||
|
||
export default hashConfig |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
declare module '@ioc:Adonis/Core/Hash' { | ||
interface HashList { | ||
bcrypt: { | ||
config: BcryptConfigContract, | ||
implementation: BcryptContract, | ||
}, | ||
argon: { | ||
config: ArgonConfigContract, | ||
implementation: ArgonContract, | ||
} | ||
} | ||
} |