@graphql-yoga/plugin-jwt 3.2.0 → 3.2.1-alpha-20241104141257-d7371436
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/cjs/config.js +7 -3
- package/cjs/plugin.js +1 -1
- package/esm/config.js +7 -3
- package/esm/plugin.js +1 -1
- package/package.json +1 -1
- package/typings/config.d.cts +6 -2
- package/typings/config.d.ts +6 -2
package/cjs/config.js
CHANGED
|
@@ -3,8 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.normalizeConfig = normalizeConfig;
|
|
4
4
|
const utils_js_1 = require("./utils.js");
|
|
5
5
|
function normalizeConfig(input) {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
// TODO: remove this on next major version.
|
|
7
|
+
if (input.singingKeyProviders) {
|
|
8
|
+
input.signingKeyProviders = input.singingKeyProviders;
|
|
9
|
+
}
|
|
10
|
+
if (input.signingKeyProviders.length === 0) {
|
|
11
|
+
throw new TypeError('You must provide at least one signing key provider. Please verify your `signingKeyProviders` configuration.');
|
|
8
12
|
}
|
|
9
13
|
const extendContextFieldName = input.extendContext === false
|
|
10
14
|
? null
|
|
@@ -19,7 +23,7 @@ function normalizeConfig(input) {
|
|
|
19
23
|
}));
|
|
20
24
|
}
|
|
21
25
|
return {
|
|
22
|
-
|
|
26
|
+
signingKeyProviders: input.signingKeyProviders,
|
|
23
27
|
tokenLookupLocations,
|
|
24
28
|
tokenVerification: input.tokenVerification ?? {
|
|
25
29
|
algorithms: ['RS256', 'HS256'],
|
package/cjs/plugin.js
CHANGED
|
@@ -21,7 +21,7 @@ function useJWT(options) {
|
|
|
21
21
|
return null;
|
|
22
22
|
};
|
|
23
23
|
const getSigningKey = async (kid) => {
|
|
24
|
-
for (const provider of normalizedOptions.
|
|
24
|
+
for (const provider of normalizedOptions.signingKeyProviders) {
|
|
25
25
|
try {
|
|
26
26
|
const key = await provider(kid);
|
|
27
27
|
if (key) {
|
package/esm/config.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { extractFromHeader } from './utils.js';
|
|
2
2
|
export function normalizeConfig(input) {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
// TODO: remove this on next major version.
|
|
4
|
+
if (input.singingKeyProviders) {
|
|
5
|
+
input.signingKeyProviders = input.singingKeyProviders;
|
|
6
|
+
}
|
|
7
|
+
if (input.signingKeyProviders.length === 0) {
|
|
8
|
+
throw new TypeError('You must provide at least one signing key provider. Please verify your `signingKeyProviders` configuration.');
|
|
5
9
|
}
|
|
6
10
|
const extendContextFieldName = input.extendContext === false
|
|
7
11
|
? null
|
|
@@ -16,7 +20,7 @@ export function normalizeConfig(input) {
|
|
|
16
20
|
}));
|
|
17
21
|
}
|
|
18
22
|
return {
|
|
19
|
-
|
|
23
|
+
signingKeyProviders: input.signingKeyProviders,
|
|
20
24
|
tokenLookupLocations,
|
|
21
25
|
tokenVerification: input.tokenVerification ?? {
|
|
22
26
|
algorithms: ['RS256', 'HS256'],
|
package/esm/plugin.js
CHANGED
|
@@ -17,7 +17,7 @@ export function useJWT(options) {
|
|
|
17
17
|
return null;
|
|
18
18
|
};
|
|
19
19
|
const getSigningKey = async (kid) => {
|
|
20
|
-
for (const provider of normalizedOptions.
|
|
20
|
+
for (const provider of normalizedOptions.signingKeyProviders) {
|
|
21
21
|
try {
|
|
22
22
|
const key = await provider(kid);
|
|
23
23
|
if (key) {
|
package/package.json
CHANGED
package/typings/config.d.cts
CHANGED
|
@@ -21,7 +21,11 @@ export type JwtPluginOptions = {
|
|
|
21
21
|
* If the first provider fails to fetch the keys, the plugin will try the next provider in the list.
|
|
22
22
|
*
|
|
23
23
|
*/
|
|
24
|
-
|
|
24
|
+
signingKeyProviders: AtleastOneItem<GetSigningKeyFunction>;
|
|
25
|
+
/**
|
|
26
|
+
* @deprecated: please use `signingKeyProviders` instead.
|
|
27
|
+
*/
|
|
28
|
+
singingKeyProviders?: AtleastOneItem<GetSigningKeyFunction>;
|
|
25
29
|
/**
|
|
26
30
|
* List of locations to look for the token in the incoming request.
|
|
27
31
|
*
|
|
@@ -74,7 +78,7 @@ export type JwtPluginOptions = {
|
|
|
74
78
|
extendContext?: string | boolean;
|
|
75
79
|
};
|
|
76
80
|
export declare function normalizeConfig(input: JwtPluginOptions): {
|
|
77
|
-
|
|
81
|
+
signingKeyProviders: AtleastOneItem<GetSigningKeyFunction>;
|
|
78
82
|
tokenLookupLocations: ExtractTokenFunction[];
|
|
79
83
|
tokenVerification: VerifyOptions;
|
|
80
84
|
reject: {
|
package/typings/config.d.ts
CHANGED
|
@@ -21,7 +21,11 @@ export type JwtPluginOptions = {
|
|
|
21
21
|
* If the first provider fails to fetch the keys, the plugin will try the next provider in the list.
|
|
22
22
|
*
|
|
23
23
|
*/
|
|
24
|
-
|
|
24
|
+
signingKeyProviders: AtleastOneItem<GetSigningKeyFunction>;
|
|
25
|
+
/**
|
|
26
|
+
* @deprecated: please use `signingKeyProviders` instead.
|
|
27
|
+
*/
|
|
28
|
+
singingKeyProviders?: AtleastOneItem<GetSigningKeyFunction>;
|
|
25
29
|
/**
|
|
26
30
|
* List of locations to look for the token in the incoming request.
|
|
27
31
|
*
|
|
@@ -74,7 +78,7 @@ export type JwtPluginOptions = {
|
|
|
74
78
|
extendContext?: string | boolean;
|
|
75
79
|
};
|
|
76
80
|
export declare function normalizeConfig(input: JwtPluginOptions): {
|
|
77
|
-
|
|
81
|
+
signingKeyProviders: AtleastOneItem<GetSigningKeyFunction>;
|
|
78
82
|
tokenLookupLocations: ExtractTokenFunction[];
|
|
79
83
|
tokenVerification: VerifyOptions;
|
|
80
84
|
reject: {
|