@cedarjs/auth-auth0-setup 8.0.0-canary.3386 → 8.0.0-canary.3387
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.
|
@@ -3,9 +3,10 @@ import { AuthenticationError, ForbiddenError } from '@cedarjs/graphql-server'
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Represents the user attributes returned by the decoding the
|
|
6
|
-
* Authentication provider's JWT together with an optional list of
|
|
6
|
+
* Authentication provider's JWT together with an optional role or list of
|
|
7
|
+
* roles.
|
|
7
8
|
*/
|
|
8
|
-
type RedwoodUser = Record<string, unknown> & { roles?: string[] }
|
|
9
|
+
type RedwoodUser = Record<string, unknown> & { roles?: string | string[] }
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* getCurrentUser returns the user information together with
|
|
@@ -38,7 +39,11 @@ export const getCurrentUser = async (
|
|
|
38
39
|
|
|
39
40
|
const roles = decoded[process.env.AUTH0_AUDIENCE + '/roles']
|
|
40
41
|
|
|
41
|
-
if (
|
|
42
|
+
if (
|
|
43
|
+
typeof roles === 'string' ||
|
|
44
|
+
(Array.isArray(roles) &&
|
|
45
|
+
roles.every((role): role is string => typeof role === 'string'))
|
|
46
|
+
) {
|
|
42
47
|
return { ...decoded, roles }
|
|
43
48
|
}
|
|
44
49
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/auth-auth0-setup",
|
|
3
|
-
"version": "8.0.0-canary.
|
|
3
|
+
"version": "8.0.0-canary.3387",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/cedarjs/cedar.git",
|
|
@@ -39,10 +39,10 @@
|
|
|
39
39
|
"test:watch": "vitest watch"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@cedarjs/cli-helpers": "8.0.0-canary.
|
|
42
|
+
"@cedarjs/cli-helpers": "8.0.0-canary.3387"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@cedarjs/framework-tools": "8.0.0-canary.
|
|
45
|
+
"@cedarjs/framework-tools": "8.0.0-canary.3387",
|
|
46
46
|
"@types/yargs": "17.0.35",
|
|
47
47
|
"concurrently": "9.2.4",
|
|
48
48
|
"publint": "0.3.25",
|