@graphql-yoga/plugin-jwt 3.2.0 → 3.2.1-alpha-20241105140439-edc38246
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 +10 -3
- package/cjs/plugin.js +1 -1
- package/esm/config.js +10 -3
- package/esm/plugin.js +1 -1
- package/package.json +1 -1
- package/typings/config.d.cts +10 -2
- package/typings/config.d.ts +10 -2
package/cjs/config.js
CHANGED
|
@@ -3,8 +3,15 @@ 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
|
+
if (input.signingKeyProviders) {
|
|
9
|
+
throw new TypeError('You are using both deprecated `singingKeyProviders` and its new replacement `signingKeyProviders` configuration. Please use only `signingKeyProviders`');
|
|
10
|
+
}
|
|
11
|
+
input.signingKeyProviders = input.singingKeyProviders;
|
|
12
|
+
}
|
|
13
|
+
if (!input.signingKeyProviders) {
|
|
14
|
+
throw new TypeError('You must provide at least one signing key provider. Please verify your `signingKeyProviders` configuration.');
|
|
8
15
|
}
|
|
9
16
|
const extendContextFieldName = input.extendContext === false
|
|
10
17
|
? null
|
|
@@ -19,7 +26,7 @@ function normalizeConfig(input) {
|
|
|
19
26
|
}));
|
|
20
27
|
}
|
|
21
28
|
return {
|
|
22
|
-
|
|
29
|
+
signingKeyProviders: input.signingKeyProviders,
|
|
23
30
|
tokenLookupLocations,
|
|
24
31
|
tokenVerification: input.tokenVerification ?? {
|
|
25
32
|
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,14 @@
|
|
|
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
|
+
if (input.signingKeyProviders) {
|
|
6
|
+
throw new TypeError('You are using both deprecated `singingKeyProviders` and its new replacement `signingKeyProviders` configuration. Please use only `signingKeyProviders`');
|
|
7
|
+
}
|
|
8
|
+
input.signingKeyProviders = input.singingKeyProviders;
|
|
9
|
+
}
|
|
10
|
+
if (!input.signingKeyProviders) {
|
|
11
|
+
throw new TypeError('You must provide at least one signing key provider. Please verify your `signingKeyProviders` configuration.');
|
|
5
12
|
}
|
|
6
13
|
const extendContextFieldName = input.extendContext === false
|
|
7
14
|
? null
|
|
@@ -16,7 +23,7 @@ export function normalizeConfig(input) {
|
|
|
16
23
|
}));
|
|
17
24
|
}
|
|
18
25
|
return {
|
|
19
|
-
|
|
26
|
+
signingKeyProviders: input.signingKeyProviders,
|
|
20
27
|
tokenLookupLocations,
|
|
21
28
|
tokenVerification: input.tokenVerification ?? {
|
|
22
29
|
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
|
@@ -10,7 +10,7 @@ export type ExtractTokenFunction = (params: {
|
|
|
10
10
|
prefix?: string;
|
|
11
11
|
}>;
|
|
12
12
|
export type GetSigningKeyFunction = (kid?: string) => Promise<string> | string;
|
|
13
|
-
export type JwtPluginOptions = {
|
|
13
|
+
export type JwtPluginOptions = ({
|
|
14
14
|
/**
|
|
15
15
|
* List of configurations for the signin-key providers. You can configure multiple signin-key providers to allow for key rotation, fallbacks, etc.
|
|
16
16
|
*
|
|
@@ -21,7 +21,15 @@ 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
|
+
signingKeyProviders: AtleastOneItem<GetSigningKeyFunction>;
|
|
25
|
+
singingKeyProviders?: never;
|
|
26
|
+
} | {
|
|
27
|
+
/**
|
|
28
|
+
* @deprecated: please use `signingKeyProviders` instead.
|
|
29
|
+
*/
|
|
24
30
|
singingKeyProviders: AtleastOneItem<GetSigningKeyFunction>;
|
|
31
|
+
signingKeyProviders?: never;
|
|
32
|
+
}) & {
|
|
25
33
|
/**
|
|
26
34
|
* List of locations to look for the token in the incoming request.
|
|
27
35
|
*
|
|
@@ -74,7 +82,7 @@ export type JwtPluginOptions = {
|
|
|
74
82
|
extendContext?: string | boolean;
|
|
75
83
|
};
|
|
76
84
|
export declare function normalizeConfig(input: JwtPluginOptions): {
|
|
77
|
-
|
|
85
|
+
signingKeyProviders: AtleastOneItem<GetSigningKeyFunction>;
|
|
78
86
|
tokenLookupLocations: ExtractTokenFunction[];
|
|
79
87
|
tokenVerification: VerifyOptions;
|
|
80
88
|
reject: {
|
package/typings/config.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export type ExtractTokenFunction = (params: {
|
|
|
10
10
|
prefix?: string;
|
|
11
11
|
}>;
|
|
12
12
|
export type GetSigningKeyFunction = (kid?: string) => Promise<string> | string;
|
|
13
|
-
export type JwtPluginOptions = {
|
|
13
|
+
export type JwtPluginOptions = ({
|
|
14
14
|
/**
|
|
15
15
|
* List of configurations for the signin-key providers. You can configure multiple signin-key providers to allow for key rotation, fallbacks, etc.
|
|
16
16
|
*
|
|
@@ -21,7 +21,15 @@ 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
|
+
signingKeyProviders: AtleastOneItem<GetSigningKeyFunction>;
|
|
25
|
+
singingKeyProviders?: never;
|
|
26
|
+
} | {
|
|
27
|
+
/**
|
|
28
|
+
* @deprecated: please use `signingKeyProviders` instead.
|
|
29
|
+
*/
|
|
24
30
|
singingKeyProviders: AtleastOneItem<GetSigningKeyFunction>;
|
|
31
|
+
signingKeyProviders?: never;
|
|
32
|
+
}) & {
|
|
25
33
|
/**
|
|
26
34
|
* List of locations to look for the token in the incoming request.
|
|
27
35
|
*
|
|
@@ -74,7 +82,7 @@ export type JwtPluginOptions = {
|
|
|
74
82
|
extendContext?: string | boolean;
|
|
75
83
|
};
|
|
76
84
|
export declare function normalizeConfig(input: JwtPluginOptions): {
|
|
77
|
-
|
|
85
|
+
signingKeyProviders: AtleastOneItem<GetSigningKeyFunction>;
|
|
78
86
|
tokenLookupLocations: ExtractTokenFunction[];
|
|
79
87
|
tokenVerification: VerifyOptions;
|
|
80
88
|
reject: {
|