@envelop/auth0 3.1.0 → 3.1.1-alpha-e859732.0
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/index.d.ts +6 -1
- package/index.js +4 -4
- package/index.mjs +4 -4
- package/package.json +2 -2
package/index.d.ts
CHANGED
|
@@ -21,10 +21,15 @@ export declare type UserPayload = {
|
|
|
21
21
|
sub: string;
|
|
22
22
|
[key: string]: any;
|
|
23
23
|
};
|
|
24
|
+
declare type InputContext = {
|
|
25
|
+
req?: Request;
|
|
26
|
+
request?: Request;
|
|
27
|
+
headers?: Headers;
|
|
28
|
+
};
|
|
24
29
|
declare type BuildContext<TOptions extends Auth0PluginOptions> = TOptions['extendContextField'] extends string ? {
|
|
25
30
|
[TName in TOptions['extendContextField'] as TOptions['extendContextField']]: UserPayload;
|
|
26
31
|
} : {
|
|
27
32
|
_auth0: UserPayload;
|
|
28
33
|
};
|
|
29
|
-
export declare const useAuth0: <TOptions extends Auth0PluginOptions>(options: TOptions) => Plugin<BuildContext<TOptions>>;
|
|
34
|
+
export declare const useAuth0: <TOptions extends Auth0PluginOptions>(options: TOptions) => Plugin<InputContext, BuildContext<TOptions>>;
|
|
30
35
|
export {};
|
package/index.js
CHANGED
|
@@ -25,9 +25,9 @@ const useAuth0 = (options) => {
|
|
|
25
25
|
const tokenType = options.tokenType || 'Bearer';
|
|
26
26
|
const headerName = options.headerName || 'authorization';
|
|
27
27
|
const extractFn = options.extractTokenFn ||
|
|
28
|
-
((ctx
|
|
29
|
-
const req = ctx
|
|
30
|
-
const headers = req.headers || ctx
|
|
28
|
+
((ctx) => {
|
|
29
|
+
const req = ctx.req || ctx.request || {};
|
|
30
|
+
const headers = req.headers || ctx.headers || null;
|
|
31
31
|
if (!headers) {
|
|
32
32
|
console.warn(`useAuth0 plugin unable to locate your request or headers on the execution context. Please make sure to pass that, or provide custom "extractTokenFn" function.`);
|
|
33
33
|
}
|
|
@@ -36,7 +36,7 @@ const useAuth0 = (options) => {
|
|
|
36
36
|
if (headers[headerName] && typeof headers[headerName] === 'string') {
|
|
37
37
|
authHeader = headers[headerName] || null;
|
|
38
38
|
}
|
|
39
|
-
else if (
|
|
39
|
+
else if ('get' in headers && headers.has && headers.has(headerName)) {
|
|
40
40
|
authHeader = headers.get(headerName) || null;
|
|
41
41
|
}
|
|
42
42
|
if (authHeader === null) {
|
package/index.mjs
CHANGED
|
@@ -19,9 +19,9 @@ const useAuth0 = (options) => {
|
|
|
19
19
|
const tokenType = options.tokenType || 'Bearer';
|
|
20
20
|
const headerName = options.headerName || 'authorization';
|
|
21
21
|
const extractFn = options.extractTokenFn ||
|
|
22
|
-
((ctx
|
|
23
|
-
const req = ctx
|
|
24
|
-
const headers = req.headers || ctx
|
|
22
|
+
((ctx) => {
|
|
23
|
+
const req = ctx.req || ctx.request || {};
|
|
24
|
+
const headers = req.headers || ctx.headers || null;
|
|
25
25
|
if (!headers) {
|
|
26
26
|
console.warn(`useAuth0 plugin unable to locate your request or headers on the execution context. Please make sure to pass that, or provide custom "extractTokenFn" function.`);
|
|
27
27
|
}
|
|
@@ -30,7 +30,7 @@ const useAuth0 = (options) => {
|
|
|
30
30
|
if (headers[headerName] && typeof headers[headerName] === 'string') {
|
|
31
31
|
authHeader = headers[headerName] || null;
|
|
32
32
|
}
|
|
33
|
-
else if (
|
|
33
|
+
else if ('get' in headers && headers.has && headers.has(headerName)) {
|
|
34
34
|
authHeader = headers.get(headerName) || null;
|
|
35
35
|
}
|
|
36
36
|
if (authHeader === null) {
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@envelop/auth0",
|
|
3
|
-
"version": "3.1.0",
|
|
3
|
+
"version": "3.1.1-alpha-e859732.0",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"peerDependencies": {
|
|
6
|
-
"@envelop/core": "
|
|
6
|
+
"@envelop/core": "2.1.1-alpha-e859732.0",
|
|
7
7
|
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|