@envelop/auth0 3.5.1-alpha-20220824165935-4720f031 → 3.6.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/README.md CHANGED
@@ -14,15 +14,10 @@ We recommend using the [Adding Authentication with Auth0 guide](https://www.enve
14
14
  4. Setup Envelop with that plugin:
15
15
 
16
16
  ```ts
17
- import { parse, validate, execute, subscribe } from 'graphql'
18
17
  import { envelop } from '@envelop/core'
19
18
  import { useAuth0 } from '@envelop/auth0'
20
19
 
21
20
  const getEnveloped = envelop({
22
- parse,
23
- validate,
24
- execute,
25
- subscribe,
26
21
  plugins: [
27
22
  // ... other plugins ...
28
23
  useAuth0({
package/cjs/index.js CHANGED
@@ -2,10 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useAuth0 = exports.UnauthenticatedError = void 0;
4
4
  const tslib_1 = require("tslib");
5
+ /* eslint-disable no-console */
6
+ /* eslint-disable dot-notation */
7
+ const core_1 = require("@envelop/core");
5
8
  const JwksRsa = tslib_1.__importStar(require("jwks-rsa"));
6
9
  const jsonwebtoken_1 = tslib_1.__importDefault(require("jsonwebtoken"));
10
+ const graphql_1 = require("graphql");
7
11
  const { decode, verify } = jsonwebtoken_1.default;
8
- class UnauthenticatedError extends Error {
12
+ class UnauthenticatedError extends graphql_1.GraphQLError {
9
13
  }
10
14
  exports.UnauthenticatedError = UnauthenticatedError;
11
15
  const useAuth0 = (options) => {
@@ -39,12 +43,12 @@ const useAuth0 = (options) => {
39
43
  }
40
44
  const split = authHeader.split(' ');
41
45
  if (split.length !== 2) {
42
- throw new Error(`Invalid value provided for header "${headerName}"!`);
46
+ throw new core_1.EnvelopError(`Invalid value provided for header "${headerName}"!`);
43
47
  }
44
48
  else {
45
49
  const [type, value] = split;
46
50
  if (type !== tokenType) {
47
- throw new Error(`Unsupported token type provided: "${type}"!`);
51
+ throw new core_1.EnvelopError(`Unsupported token type provided: "${type}"!`);
48
52
  }
49
53
  else {
50
54
  return value;
package/esm/index.js CHANGED
@@ -1,7 +1,11 @@
1
+ /* eslint-disable no-console */
2
+ /* eslint-disable dot-notation */
3
+ import { EnvelopError } from '@envelop/core';
1
4
  import * as JwksRsa from 'jwks-rsa';
2
5
  import jwtPkg from 'jsonwebtoken';
6
+ import { GraphQLError } from 'graphql';
3
7
  const { decode, verify } = jwtPkg;
4
- export class UnauthenticatedError extends Error {
8
+ export class UnauthenticatedError extends GraphQLError {
5
9
  }
6
10
  export const useAuth0 = (options) => {
7
11
  const jkwsClient = new JwksRsa.JwksClient({
@@ -34,12 +38,12 @@ export const useAuth0 = (options) => {
34
38
  }
35
39
  const split = authHeader.split(' ');
36
40
  if (split.length !== 2) {
37
- throw new Error(`Invalid value provided for header "${headerName}"!`);
41
+ throw new EnvelopError(`Invalid value provided for header "${headerName}"!`);
38
42
  }
39
43
  else {
40
44
  const [type, value] = split;
41
45
  if (type !== tokenType) {
42
- throw new Error(`Unsupported token type provided: "${type}"!`);
46
+ throw new EnvelopError(`Unsupported token type provided: "${type}"!`);
43
47
  }
44
48
  else {
45
49
  return value;
package/package.json CHANGED
@@ -1,13 +1,15 @@
1
1
  {
2
2
  "name": "@envelop/auth0",
3
- "version": "3.5.1-alpha-20220824165935-4720f031",
3
+ "version": "3.6.0",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {
6
- "@envelop/core": "2.5.1-alpha-20220824165935-4720f031"
6
+ "@envelop/core": "^2.6.0",
7
+ "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
7
8
  },
8
9
  "dependencies": {
9
10
  "jsonwebtoken": "^8.5.1",
10
- "jwks-rsa": "^2.0.1"
11
+ "jwks-rsa": "^2.0.1",
12
+ "tslib": "^2.4.0"
11
13
  },
12
14
  "repository": {
13
15
  "type": "git",
@@ -1,6 +1,7 @@
1
1
  import { Plugin } from '@envelop/core';
2
2
  import * as JwksRsa from 'jwks-rsa';
3
3
  import { VerifyOptions, DecodeOptions } from 'jsonwebtoken';
4
+ import { GraphQLError } from 'graphql';
4
5
  export declare type Auth0PluginOptions = {
5
6
  domain: string;
6
7
  audience: string;
@@ -14,7 +15,7 @@ export declare type Auth0PluginOptions = {
14
15
  tokenType?: string;
15
16
  headerName?: string;
16
17
  };
17
- export declare class UnauthenticatedError extends Error {
18
+ export declare class UnauthenticatedError extends GraphQLError {
18
19
  }
19
20
  export declare type UserPayload = {
20
21
  sub: string;
@@ -1,6 +1,7 @@
1
1
  import { Plugin } from '@envelop/core';
2
2
  import * as JwksRsa from 'jwks-rsa';
3
3
  import { VerifyOptions, DecodeOptions } from 'jsonwebtoken';
4
+ import { GraphQLError } from 'graphql';
4
5
  export declare type Auth0PluginOptions = {
5
6
  domain: string;
6
7
  audience: string;
@@ -14,7 +15,7 @@ export declare type Auth0PluginOptions = {
14
15
  tokenType?: string;
15
16
  headerName?: string;
16
17
  };
17
- export declare class UnauthenticatedError extends Error {
18
+ export declare class UnauthenticatedError extends GraphQLError {
18
19
  }
19
20
  export declare type UserPayload = {
20
21
  sub: string;