Skip to content

Commit

Permalink
refactor: do not install drivers as main dependency
Browse files Browse the repository at this point in the history
Since, a user will never use all drivers together in a single app, we should ask
the end user to install them separately and not shipping it with this package
  • Loading branch information
thetutlage committed Jul 17, 2019
1 parent d849dea commit 7c54afc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
"homepage": "https://github.com/poppinss/hash#readme",
"devDependencies": {
"@adonisjs/mrm-preset": "^2.0.3",
"@phc/argon2": "^1.0.9",
"@phc/bcrypt": "^1.0.2",
"@types/node": "^12.6.2",
"commitizen": "^3.1.1",
"cz-conventional-changelog": "^2.1.0",
Expand Down Expand Up @@ -78,8 +80,6 @@
"anyBranch": false
},
"dependencies": {
"@phc/argon2": "^1.0.9",
"@phc/bcrypt": "^1.0.2",
"@poppinss/manager": "^1.1.2"
}
}
7 changes: 5 additions & 2 deletions src/Drivers/Argon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
* file that was distributed with this source code.
*/

import * as argon2 from '@phc/argon2'
import * as phc from '@phc/format'

import { ArgonConfigContract, ArgonContract } from '../contracts'

let argon2: any

/**
* Hash driver built on top of argon hashing algorithm. The driver adheres
* to `phc` string format.
Expand All @@ -38,6 +38,9 @@ export class Argon implements ArgonContract {
public version = 19

constructor (private _config: ArgonConfigContract) {
if (!argon2) {
argon2 = require('@phc/argon2')
}
}

/**
Expand Down
6 changes: 5 additions & 1 deletion src/Drivers/Bcrypt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
*/

import { BcryptConfigContract, BcryptContract } from '../contracts'
import * as bcrypt from '@phc/bcrypt'
import * as phc from '@phc/format'

let bcrypt: any

/**
* Generates and verifies hash using Bcrypt as underlying
* algorigthm.
Expand All @@ -21,6 +22,9 @@ export class Bcrypt implements BcryptContract {
public version = 98

constructor (private _config: BcryptConfigContract) {
if (!bcrypt) {
bcrypt = require('@phc/bcrypt')
}
}

/**
Expand Down

0 comments on commit 7c54afc

Please sign in to comment.