@envelop/generic-auth 4.5.0 → 4.5.1-alpha-20220901205925-b1fd44a9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -0
- package/cjs/index.js +5 -6
- package/esm/index.js +5 -6
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -78,6 +78,7 @@ This mode offers complete protection for the entire API. It protects your entire
|
|
|
78
78
|
To setup this mode, use the following config:
|
|
79
79
|
|
|
80
80
|
```ts
|
|
81
|
+
import { parse, validate, execute, subscribe } from 'graphql'
|
|
81
82
|
import { envelop } from '@envelop/core'
|
|
82
83
|
import { useGenericAuth, ResolveUserFn, ValidateUserFn } from '@envelop/generic-auth'
|
|
83
84
|
|
|
@@ -92,6 +93,10 @@ const validateUser: ValidateUserFn<UserType> = params => {
|
|
|
92
93
|
}
|
|
93
94
|
|
|
94
95
|
const getEnveloped = envelop({
|
|
96
|
+
parse,
|
|
97
|
+
validate,
|
|
98
|
+
execute,
|
|
99
|
+
subscribe,
|
|
95
100
|
plugins: [
|
|
96
101
|
// ... other plugins ...
|
|
97
102
|
useGenericAuth({
|
package/cjs/index.js
CHANGED
|
@@ -27,16 +27,15 @@ function defaultProtectSingleValidateFn(params) {
|
|
|
27
27
|
}
|
|
28
28
|
exports.defaultProtectSingleValidateFn = defaultProtectSingleValidateFn;
|
|
29
29
|
const useGenericAuth = (options) => {
|
|
30
|
-
var _a, _b;
|
|
31
30
|
const contextFieldName = options.contextFieldName || 'currentUser';
|
|
32
31
|
if (options.mode === 'protect-all' || options.mode === 'protect-granular') {
|
|
33
|
-
const directiveOrExtensionFieldName =
|
|
34
|
-
const validateUser =
|
|
32
|
+
const directiveOrExtensionFieldName = options.directiveOrExtensionFieldName ?? (options.mode === 'protect-all' ? 'skipAuth' : 'auth');
|
|
33
|
+
const validateUser = options.validateUser ??
|
|
34
|
+
(options.mode === 'protect-all' ? defaultProtectAllValidateFn : defaultProtectSingleValidateFn);
|
|
35
35
|
const extractAuthMeta = (input) => {
|
|
36
|
-
var _a, _b, _c;
|
|
37
36
|
return {
|
|
38
|
-
fieldAuthExtension:
|
|
39
|
-
fieldAuthDirectiveNode:
|
|
37
|
+
fieldAuthExtension: input.extensions?.[directiveOrExtensionFieldName],
|
|
38
|
+
fieldAuthDirectiveNode: input.astNode?.directives?.find(directive => directive.name.value === directiveOrExtensionFieldName),
|
|
40
39
|
};
|
|
41
40
|
};
|
|
42
41
|
return {
|
package/esm/index.js
CHANGED
|
@@ -21,16 +21,15 @@ export function defaultProtectSingleValidateFn(params) {
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
export const useGenericAuth = (options) => {
|
|
24
|
-
var _a, _b;
|
|
25
24
|
const contextFieldName = options.contextFieldName || 'currentUser';
|
|
26
25
|
if (options.mode === 'protect-all' || options.mode === 'protect-granular') {
|
|
27
|
-
const directiveOrExtensionFieldName =
|
|
28
|
-
const validateUser =
|
|
26
|
+
const directiveOrExtensionFieldName = options.directiveOrExtensionFieldName ?? (options.mode === 'protect-all' ? 'skipAuth' : 'auth');
|
|
27
|
+
const validateUser = options.validateUser ??
|
|
28
|
+
(options.mode === 'protect-all' ? defaultProtectAllValidateFn : defaultProtectSingleValidateFn);
|
|
29
29
|
const extractAuthMeta = (input) => {
|
|
30
|
-
var _a, _b, _c;
|
|
31
30
|
return {
|
|
32
|
-
fieldAuthExtension:
|
|
33
|
-
fieldAuthDirectiveNode:
|
|
31
|
+
fieldAuthExtension: input.extensions?.[directiveOrExtensionFieldName],
|
|
32
|
+
fieldAuthDirectiveNode: input.astNode?.directives?.find(directive => directive.name.value === directiveOrExtensionFieldName),
|
|
34
33
|
};
|
|
35
34
|
};
|
|
36
35
|
return {
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@envelop/generic-auth",
|
|
3
|
-
"version": "4.5.
|
|
3
|
+
"version": "4.5.1-alpha-20220901205925-b1fd44a9",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"peerDependencies": {
|
|
6
|
-
"@envelop/core": "
|
|
6
|
+
"@envelop/core": "2.6.1-alpha-20220901205925-b1fd44a9",
|
|
7
7
|
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@envelop/extended-validation": "
|
|
10
|
+
"@envelop/extended-validation": "1.9.1-alpha-20220901205925-b1fd44a9",
|
|
11
11
|
"tslib": "^2.4.0"
|
|
12
12
|
},
|
|
13
13
|
"repository": {
|