@graphql-yoga/plugin-jwt 2.1.0 → 2.1.1-alpha-20231222142610-8f302c70

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/index.js CHANGED
@@ -25,7 +25,7 @@ function useJWT(options) {
25
25
  });
26
26
  }
27
27
  return {
28
- async onRequest({ request, serverContext, url }) {
28
+ async onRequestParse({ request, serverContext, url }) {
29
29
  const token = await getToken({ request, serverContext, url });
30
30
  if (token != null) {
31
31
  const signingKey = options.signingKey ?? (await fetchKey(jwksClient, token));
@@ -64,10 +64,7 @@ function verify(token, signingKey, options) {
64
64
  return new Promise((resolve, reject) => {
65
65
  jsonwebtoken_1.default.verify(token, signingKey, { ...options, algorithms: options?.algorithms ?? ['RS256'] }, (err, result) => {
66
66
  if (err) {
67
- // Should we expose the error message? Perhaps only in development mode?
68
- reject(unauthorizedError('Failed to decode authentication token', {
69
- originalError: err,
70
- }));
67
+ reject(unauthorizedError('Failed to decode authentication token. Verification failed.'));
71
68
  }
72
69
  else {
73
70
  resolve(result);
package/esm/index.js CHANGED
@@ -21,7 +21,7 @@ export function useJWT(options) {
21
21
  });
22
22
  }
23
23
  return {
24
- async onRequest({ request, serverContext, url }) {
24
+ async onRequestParse({ request, serverContext, url }) {
25
25
  const token = await getToken({ request, serverContext, url });
26
26
  if (token != null) {
27
27
  const signingKey = options.signingKey ?? (await fetchKey(jwksClient, token));
@@ -59,10 +59,7 @@ function verify(token, signingKey, options) {
59
59
  return new Promise((resolve, reject) => {
60
60
  jsonwebtoken.verify(token, signingKey, { ...options, algorithms: options?.algorithms ?? ['RS256'] }, (err, result) => {
61
61
  if (err) {
62
- // Should we expose the error message? Perhaps only in development mode?
63
- reject(unauthorizedError('Failed to decode authentication token', {
64
- originalError: err,
65
- }));
62
+ reject(unauthorizedError('Failed to decode authentication token. Verification failed.'));
66
63
  }
67
64
  else {
68
65
  resolve(result);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-yoga/plugin-jwt",
3
- "version": "2.1.0",
3
+ "version": "2.1.1-alpha-20231222142610-8f302c70",
4
4
  "description": "jwt plugin for GraphQL Yoga.",
5
5
  "peerDependencies": {
6
6
  "graphql": "^16.5.0",