Skip to content
This repository was archived by the owner on Oct 14, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
version: 2
jobs:
build_10.15.3:
docker:
- image: 'circleci/node:10.15.3'
working_directory: ~/app
steps:
- checkout
- restore_cache:
keys:
- 'v1-dependencies-{{ checksum "package.json" }}'
- v1-dependencies-
- run: npm install
- save_cache:
paths:
- node_modules
key: 'v1-dependencies-{{ checksum "package.json" }}'
- run: npm test
build_latest:
docker:
- image: 'circleci/node:latest'
working_directory: ~/app
steps:
- checkout
- restore_cache:
keys:
- 'v1-dependencies-{{ checksum "package.json" }}'
- v1-dependencies-
- run: npm install
- save_cache:
paths:
- node_modules
key: 'v1-dependencies-{{ checksum "package.json" }}'
- run: npm test
workflows:
version: 2
workflow:
jobs:
- build_10.15.3
- build_latest
22 changes: 22 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# http://editorconfig.org

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.json]
insert_final_newline = ignore

[**.min.js]
indent_style = ignore
insert_final_newline = ignore

[MakeFile]
indent_style = tab

[*.md]
trim_trailing_whitespace = false
70 changes: 70 additions & 0 deletions .github/COMMIT_CONVENTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
## Git Commit Message Convention

> This is adapted from [Angular's commit convention](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-angular).

Using conventional commit messages, we can automate the process of generating the CHANGELOG file. All commits messages will automatically be validated against the following regex.

``` js
/^(revert: )?(feat|fix|docs|style|refactor|perf|test|workflow|ci|chore|types|build)((.+))?: .{1,50}/
```

## Commit Message Format
A commit message consists of a **header**, **body** and **footer**. The header has a **type**, **scope** and **subject**:

> The **scope** is optional

```
feat(router): add support for prefix

Prefix makes it easier to append a path to a group of routes
```

1. `feat` is type.
2. `router` is scope and is optional
3. `add support for prefix` is the subject
4. The **body** is followed by a blank line.
5. The optional **footer** can be added after the body, followed by a blank line.

## Types
Only one type can be used at a time and only following types are allowed.

- feat
- fix
- docs
- style
- refactor
- perf
- test
- workflow
- ci
- chore
- types
- build

If a type is `feat`, `fix` or `perf`, then the commit will appear in the CHANGELOG.md file. However if there is any BREAKING CHANGE, the commit will always appear in the changelog.

### Revert
If the commit reverts a previous commit, it should begin with `revert:`, followed by the header of the reverted commit. In the body it should say: `This reverts commit <hash>`., where the hash is the SHA of the commit being reverted.

## Scope
The scope could be anything specifying place of the commit change. For example: `router`, `view`, `querybuilder`, `database`, `model` and so on.

## Subject
The subject contains succinct description of the change:

- use the imperative, present tense: "change" not "changed" nor "changes".
- don't capitalize first letter
- no dot (.) at the end

## Body

Just as in the **subject**, use the imperative, present tense: "change" not "changed" nor "changes".
The body should include the motivation for the change and contrast this with previous behavior.

## Footer

The footer should contain any information about **Breaking Changes** and is also the place to
reference GitHub issues that this commit **Closes**.

**Breaking Changes** should start with the word `BREAKING CHANGE:` with a space or two newlines. The rest of the commit message is then used for this.

23 changes: 23 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!-- CLICK "Preview" FOR INSTRUCTIONS IN A MORE READABLE FORMAT -->

## Prerequisites

We do our best to reply to all the issues on time. If you will follow the given guidelines, the turn around time will be faster.

- Ensure the issue isn't already reported.
- Ensure you are reporting the bug in the correct repo.

*Delete the above section and the instructions in the sections below before submitting*

## Description

If this is a feature request, explain why it should be added. Specific use-cases are best.

For bug reports, please provide as much *relevant* info as possible.

## Package version
<!-- YOUR ANSWER -->

## Error Message & Stack Trace

## Relevant Information
28 changes: 28 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!-- CLICK "Preview" FOR INSTRUCTIONS IN A MORE READABLE FORMAT -->

## Proposed changes

Describe the big picture of your changes here to communicate to the maintainers why we should accept this pull request. If it fixes a bug or resolves a feature request, be sure to link to that issue.

## Types of changes

What types of changes does your code introduce?

_Put an `x` in the boxes that apply_

- [ ] Bugfix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)

## Checklist

_Put an `x` in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code._

- [ ] I have read the [CONTRIBUTING](https://github.com/thetutlage/hash/blob/master/CONTRIBUTING.md) doc
- [ ] Lint and unit tests pass locally with my changes
- [ ] I have added tests that prove my fix is effective or that my feature works.
- [ ] I have added necessary documentation (if appropriate)

## Further comments

If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,15 @@
/build
package-lock.json
yarn.lock
node_modules
coverage
.DS_STORE
.nyc_output
.idea
.vscode/
*.sublime-project
*.sublime-workspace
*.log
build
dist
shrinkwrap.yaml
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
message="chore(release): %s"
39 changes: 39 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Contributing

We love pull requests. And following this guidelines will make your pull request easier to merge

## Prerequisites

- Install [EditorConfig](http://editorconfig.org/) plugin for your code editor to make sure it uses correct settings.
- Fork the repository and clone your fork.
- Install dependencies: `npm install`.

## Coding style

We make use of Typescript along with [Tslint](https://palantir.github.io/tslint) to ensure a consistent coding style. All of the rules are defined inside the `tslint.json` file.

## Development work-flow

Always make sure to lint and test your code before pushing it to the GitHub.

```bash
npm test
```

Just lint the code

```bash
npm run lint
```

**Make sure you add sufficient tests for the change**.

## Other notes

- Do not change version number inside the `package.json` file.
- Do not update `CHANGELOG.md` file.
- Do not update `tslint.json` or `tslint.js` file. If something prevents you writing code, please create an issue for same.

## Need help?

Feel free to ask.
9 changes: 9 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# The MIT License

Copyright 2019 Romain Lanz, contributors

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
9 changes: 9 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"core": false,
"ts": true,
"license": "MIT",
"services": [
"circleci"
],
"minNodeVersion": "10.15.3"
}
58 changes: 48 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,51 @@
"name": "@slynova/hash",
"version": "0.1.0",
"description": "Flexible and Fluent framework-agnostic driver based system for password hashing algorithms.",
"main": "./build/index.js",
"author": "Romain Lanz <romain.lanz@slynova.ch>",
"license": "MIT",
"main": "build/index.js",
"files": [
"build"
"build/src",
"build/index.d.ts",
"build/index.js"
],
"author": "Romain Lanz <romain.lanz@slynova.ch>",
"license": "MIT",
"scripts": {
"build": "npm run clean && npm run tsc",
"clean": "rimraf build",
"prepublishOnly": "npm run build",
"test": "node japaFile",
"tsc": "tsc"
"build": "npm run compile",
"clean": "del build",
"pretest": "npm run lint",
"test": "node japaFile.js",
"tsc": "tsc",
"mrm": "mrm --preset=@adonisjs/mrm-preset",
"lint": "tslint --project tsconfig.json",
"compile": "npm run lint && npm run clean && tsc",
"commit": "git-cz",
"release": "np",
"version": "npm run build"
},
"dependencies": {
"argon2": "^0.24.0",
"bcrypt": "^3.0.6",
"node-exceptions": "^4.0.1"
},
"devDependencies": {
"@adonisjs/mrm-preset": "^2.0.3",
"@types/argon2": "^0.15.0",
"@types/bcrypt": "^3.0.0",
"@types/node": "^12.0.10",
"@typescript-eslint/eslint-plugin": "^1.11.0",
"commitizen": "^3.1.1",
"cz-conventional-changelog": "^2.1.0",
"del-cli": "^2.0.0",
"eslint": "^6.0.0",
"eslint-config-prettier": "^6.0.0",
"husky": "^2.4.1",
"japa": "^2.0.10",
"mrm": "^1.2.2",
"np": "^5.0.3",
"prettier": "^1.18.2",
"rimraf": "^2.6.3",
"ts-node": "^8.3.0",
"tslint": "^5.18.0",
"tslint-eslint-rules": "^5.4.0",
"typescript": "^3.5.2"
},
"repository": "git@github.com:Slynova-Org/hash.git",
Expand All @@ -53,5 +69,27 @@
"singleQuote": true,
"trailingComma": "es5",
"printWidth": 120
},
"nyc": {
"exclude": [
"test"
],
"extension": [
".ts"
]
},
"husky": {
"hooks": {
"commit-msg": "node ./node_modules/@adonisjs/mrm-preset/validateCommit/conventional/validate.js"
}
},
"config": {
"commitizen": {
"path": "cz-conventional-changelog"
}
},
"np": {
"contents": ".",
"anyBranch": false
}
}
10 changes: 5 additions & 5 deletions src/Drivers/Argon2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,28 @@
* @copyright Slynova - Romain Lanz <romain.lanz@slynova.ch>
*/

import argon2, { Options } from 'argon2'
import * as argon2 from 'argon2'
import Hash from '../Hash'

export class Argon2 implements Hash {
private $config: Argon2Config

constructor(config: Argon2Config) {
constructor (config: Argon2Config) {
this.$config = config
}

/**
* Hash a plain value using argon2.
*/
make(value: string, config?: Argon2Config): Promise<string> {
public make (value: string, config?: Argon2Config): Promise<string> {
// @ts-ignore
return argon2.hash(value, { ...this.$config, ...config })
}

/**
* Verify an existing hash with the plain value.
*/
verify(value: string, hash: string): Promise<boolean> {
public verify (value: string, hash: string): Promise<boolean> {
if (value === undefined) {
return new Promise(resolve => resolve(false))
}
Expand All @@ -35,4 +35,4 @@ export class Argon2 implements Hash {
}
}

export interface Argon2Config extends Options {}
export interface Argon2Config extends argon2.Options {}
Loading