@envelop/auth0 3.4.0-alpha-e9434aa.0 → 3.4.0-alpha-05dbec7.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/esm/index.js +9 -40
- package/package.json +2 -2
package/esm/index.js
CHANGED
|
@@ -1,43 +1,13 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.useAuth0 = exports.UnauthenticatedError = void 0;
|
|
30
1
|
/* eslint-disable no-console */
|
|
31
2
|
/* eslint-disable dot-notation */
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const { decode, verify } =
|
|
37
|
-
class UnauthenticatedError extends
|
|
3
|
+
import { EnvelopError } from '@envelop/core';
|
|
4
|
+
import * as JwksRsa from 'jwks-rsa';
|
|
5
|
+
import jwtPkg from 'jsonwebtoken';
|
|
6
|
+
import { GraphQLError } from 'graphql';
|
|
7
|
+
const { decode, verify } = jwtPkg;
|
|
8
|
+
export class UnauthenticatedError extends GraphQLError {
|
|
38
9
|
}
|
|
39
|
-
|
|
40
|
-
const useAuth0 = (options) => {
|
|
10
|
+
export const useAuth0 = (options) => {
|
|
41
11
|
const jkwsClient = new JwksRsa.JwksClient({
|
|
42
12
|
cache: true,
|
|
43
13
|
rateLimit: true,
|
|
@@ -68,12 +38,12 @@ const useAuth0 = (options) => {
|
|
|
68
38
|
}
|
|
69
39
|
const split = authHeader.split(' ');
|
|
70
40
|
if (split.length !== 2) {
|
|
71
|
-
throw new
|
|
41
|
+
throw new EnvelopError(`Invalid value provided for header "${headerName}"!`);
|
|
72
42
|
}
|
|
73
43
|
else {
|
|
74
44
|
const [type, value] = split;
|
|
75
45
|
if (type !== tokenType) {
|
|
76
|
-
throw new
|
|
46
|
+
throw new EnvelopError(`Unsupported token type provided: "${type}"!`);
|
|
77
47
|
}
|
|
78
48
|
else {
|
|
79
49
|
return value;
|
|
@@ -124,4 +94,3 @@ const useAuth0 = (options) => {
|
|
|
124
94
|
},
|
|
125
95
|
};
|
|
126
96
|
};
|
|
127
|
-
exports.useAuth0 = useAuth0;
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@envelop/auth0",
|
|
3
|
-
"version": "3.4.0-alpha-
|
|
3
|
+
"version": "3.4.0-alpha-05dbec7.0",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"peerDependencies": {
|
|
6
|
-
"@envelop/core": "2.4.0-alpha-
|
|
6
|
+
"@envelop/core": "2.4.0-alpha-05dbec7.0",
|
|
7
7
|
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|