Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup codebase and fix formatting #31

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
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
84 changes: 84 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
{
"rules": {
"curly": [
2
],
"eqeqeq": [
2
],
"indent": [
2,
2,
{
"SwitchCase": 1
}
],
"linebreak-style": [
2,
"unix"
],
"new-cap": [
2,
{
"properties": false
}
],
"no-unused-vars": [
2,
{
"vars": "all",
"args": "after-used"
}
],
"no-use-before-define": [
2
],
"no-trailing-spaces": [
2
],
"quotes": [
2,
"single"
],
"semi": [
2,
"always"
],
"wrap-iife": [
2,
"outside"
],
"strict": [
2,
"global"
],
"brace-style": 2,
"block-spacing": [
2,
"always"
],
"keyword-spacing": [2, {"before": true, "after": true, "overrides": {}}],
"space-before-blocks": 2,
"space-before-function-paren": [2, {"anonymous": "always", "named": "never"}],
"comma-spacing": [2, {"before": false, "after": true}],
"comma-style": [2, "last"],
"no-lonely-if": 2,
"array-bracket-spacing": [2, "never"],
"no-spaced-func": [2],
"space-in-parens": [2, "never"],
"space-infix-ops": 2
},
"globals": {
"after": true,
"afterEach": true,
"before": true,
"beforeEach": true,
"describe": true,
"it": true
},
"env": {
"es6": true,
"node": true
},
"extends": "eslint:recommended"
}
4 changes: 4 additions & 0 deletions .jshintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
test/rsa.pub
test/rsa.priv
test/ecdsa.pub
test/ecdsa.priv
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,31 @@ jwt.setNotbefore(); // Remove the exp claim
```


## Error Handling

If an error occurs then one of the following error types will either be thrown
or passed as the first argument in a callback.

Type | Description
----------------------------------------|--------------------------------------
JwtError | Base type. All errors implement this.
JwtParseError | Jwt cannot be parsed.
UnsupportedSigningAlgorithmJwtError | Unsupported signing algorithm.
SigningKeyRequiredJwtError | Signing key is required.
NotActiveJwtParseError | Jwt not active.
ExpiredJwtParseError | Jwt is expired.
SignatureAlgorithmMismatchJwtParseError | Unexpected signature algorithm.
SignatureMismatchJwtParseError | Signature verification failed.

To handle a specific error, simply compare the instance of the error received to one of
the error types above, as shown in the example below:

```javascript
if (err instanceof nJwt.JwtParseError) {
console.log('Unable to parse the provided jwt.');
}
```

## Supported Algorithms

"alg" Value | Algorithm used
Expand Down
Loading