graphql-auth
Advanced tools
Comparing version 0.2.6 to 1.0.0
{ | ||
"name": "graphql-auth", | ||
"version": "0.2.6", | ||
"description": "GraphQL authentication and authorization middleware", | ||
"main": "build/index.js", | ||
"types": "index.d.ts", | ||
"version": "1.0.0", | ||
"license": "MIT", | ||
"main": "dist/index.js", | ||
"typings": "dist/index.d.ts", | ||
"files": [ | ||
"dist", | ||
"src" | ||
], | ||
"engines": { | ||
"node": ">=10" | ||
}, | ||
"scripts": { | ||
"build:watch": "babel -w --source-maps --ignore '**/__tests__/**' index.js --out-dir build", | ||
"build": "rimraf build && babel --source-maps --ignore '**/__tests__/**' index.js --out-dir build", | ||
"contrib:add": "all-contributors add", | ||
"contrib:build": "all-contributors generate", | ||
"test": "jest test" | ||
"start": "tsdx watch", | ||
"build": "tsdx build", | ||
"test": "tsdx test", | ||
"lint": "tsdx lint", | ||
"prepare": "tsdx build" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/kkemple/graphql-auth" | ||
"peerDependencies": {}, | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "tsdx lint" | ||
} | ||
}, | ||
"keywords": [ | ||
"graphql", | ||
"auth", | ||
"authentication", | ||
"authorization" | ||
], | ||
"author": "kurtiskemple@gmail.com", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/kkemple/graphql-auth/issues" | ||
"prettier": { | ||
"printWidth": 80, | ||
"semi": true, | ||
"singleQuote": true, | ||
"trailingComma": "es5" | ||
}, | ||
"homepage": "https://github.com/kkemple/graphql-auth#readme", | ||
"name": "graphql-auth", | ||
"author": "Kurt Kemple", | ||
"module": "dist/app.esm.js", | ||
"devDependencies": { | ||
"all-contributors-cli": "^4.5.0", | ||
"babel-cli": "^6.24.1", | ||
"babel-plugin-transform-runtime": "^6.23.0", | ||
"babel-preset-env": "^1.5.2", | ||
"babel-preset-stage-2": "^6.24.1", | ||
"jest": "^21.2.1", | ||
"rimraf": "^2.6.2" | ||
"husky": "^4.2.5", | ||
"tsdx": "^0.13.2", | ||
"tslib": "^1.12.0", | ||
"typescript": "^3.9.2" | ||
} | ||
} |
@@ -1,5 +0,3 @@ | ||
# GraphQL Auth | ||
# GraphQL Auth | ||
[![Travis Build Status](https://travis-ci.org/kkemple/graphql-auth.svg?branch=master)](https://travis-ci.org/kkemple/graphql-auth) | ||
🔒 Authentication and authorization middleware for GraphQL. | ||
@@ -12,2 +10,3 @@ | ||
### How It Works | ||
`graphql-auth` exports a single function (middleware) `withAuth`. This function takes two parameters, the first is `scope` (if any) for authorization, and the second is the `callback` to call when auth checking is complete. Let's look at an example: | ||
@@ -27,2 +26,3 @@ | ||
The way this works is `withAuth` looks for a special `auth` property on the `context` of the resolver. It expects the `auth` property to have two properties of its own: | ||
1. `isAuthenticated` to tell if the user is logged in | ||
@@ -70,3 +70,3 @@ 2. `scope` scope of the logged in user (optional) | ||
next(); | ||
}, | ||
} | ||
); | ||
@@ -82,12 +82,14 @@ }; | ||
``` | ||
> For more in depth examples take a look at the [`graphql-auth-examples`](https://github.com/kkemple/graphql-auth-examples) repo. | ||
### Installation | ||
### Installation | ||
```shell | ||
yarn add graphql-auth | ||
``` | ||
### withAuth([scope,] callback) | ||
*Without scope*: | ||
_Without scope_: | ||
@@ -105,3 +107,3 @@ ```javascript | ||
*With scope*: | ||
_With scope_: | ||
@@ -119,3 +121,3 @@ ```javascript | ||
*With dynamic scope*: | ||
_With dynamic scope_: | ||
@@ -140,6 +142,9 @@ ```javascript | ||
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --> | ||
| [<img src="https://avatars1.githubusercontent.com/u/332115?v=4" width="100px;"/><br /><sub>artgibson</sub>](https://github.com/artgibson)<br />[💻](https://github.com/kkemple/graphql-auth/commits?author=artgibson "Code") | [<img src="https://avatars3.githubusercontent.com/u/1265681?v=4" width="100px;"/><br /><sub>HaNdTriX</sub>](http://henrikwenz.de/)<br />[💻](https://github.com/kkemple/graphql-auth/commits?author=HaNdTriX "Code") [📖](https://github.com/kkemple/graphql-auth/commits?author=HaNdTriX "Documentation") | [<img src="https://avatars1.githubusercontent.com/u/841956?v=4" width="100px;"/><br /><sub>Pascal Birchler</sub>](https://pascalbirchler.com)<br />[💻](https://github.com/kkemple/graphql-auth/commits?author=swissspidy "Code") | [<img src="https://avatars2.githubusercontent.com/u/6640835?v=4" width="100px;"/><br /><sub>Andréas Hanss</sub>](https://www.linkedin.com/in/andreas-hanss/)<br />[💻](https://github.com/kkemple/graphql-auth/commits?author=ScreamZ "Code") [📖](https://github.com/kkemple/graphql-auth/commits?author=ScreamZ "Documentation") | | ||
| :---: | :---: | :---: | :---: | | ||
| [<img src="https://avatars1.githubusercontent.com/u/332115?v=4" width="100px;"/><br /><sub>artgibson</sub>](https://github.com/artgibson)<br />[💻](https://github.com/kkemple/graphql-auth/commits?author=artgibson 'Code') | [<img src="https://avatars3.githubusercontent.com/u/1265681?v=4" width="100px;"/><br /><sub>HaNdTriX</sub>](http://henrikwenz.de/)<br />[💻](https://github.com/kkemple/graphql-auth/commits?author=HaNdTriX 'Code') [📖](https://github.com/kkemple/graphql-auth/commits?author=HaNdTriX 'Documentation') | [<img src="https://avatars1.githubusercontent.com/u/841956?v=4" width="100px;"/><br /><sub>Pascal Birchler</sub>](https://pascalbirchler.com)<br />[💻](https://github.com/kkemple/graphql-auth/commits?author=swissspidy 'Code') | [<img src="https://avatars2.githubusercontent.com/u/6640835?v=4" width="100px;"/><br /><sub>Andréas Hanss</sub>](https://www.linkedin.com/in/andreas-hanss/)<br />[💻](https://github.com/kkemple/graphql-auth/commits?author=ScreamZ 'Code') [📖](https://github.com/kkemple/graphql-auth/commits?author=ScreamZ 'Documentation') | | ||
| :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | | ||
<!-- ALL-CONTRIBUTORS-LIST:END --> | ||
This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome! |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
4
191
144
25021
1
2
1