Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crypto.getRandomValues() not supported #17290

Closed
Humb3l opened this issue Jan 25, 2023 · 2 comments
Closed

crypto.getRandomValues() not supported #17290

Humb3l opened this issue Jan 25, 2023 · 2 comments

Comments

@Humb3l
Copy link
Contributor

Humb3l commented Jan 25, 2023

Describe the Bug

I've tried to use the @azure/msal-node lib for my Authentication process. It works fine with express and I already testet it there, so there is no Issue with this lib.
But once I integrate this within a directus module I get the crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported error.
And this Issue still exists with the newest Version of directus 9.22.4.

To Reproduce

To reconstruct this Issue you can use the following code. (It might get a bit tricky if you have no Azure Client ID but it shouldnt come to the point, were you need it either with this error

Extensiontype module
NodeVersion: 16+ and I've tried 18+ as-well

index.js

import { Request, Response } from "express";
import * as msal from "@azure/msal-node"

export default defineEndpoint((router, context) => {

	const clientConfig = {
		auth: {
			clientId: "xxxxxx",
			authority: "https://login.microsoftonline.com/xxxxxxxx",
			clientSecret: "xxxxxxx",
		}
	  };
	  const pca = new msal.ConfidentialClientApplication(clientConfig);

	router.get('/login', async(req: Request, res: Response) => {
		const authCodeUrlParameters = {
			scopes: [".default openid"],
			redirectUri: "http://localhost:8055/auth/callback",
		};
		// get url to sign user in and consent to scopes needed for application
		const url = await pca.getAuthCodeUrl(authCodeUrlParameters);
		console.log(url);

		res.redirect(302, url);
	})

})

package.json

{
	"name": "auth",
	"version": "1.0.0",
	"keywords": [
		"directus",
		"directus-extension",
		"directus-custom-endpoint"
	],
	"directus:extension": {
		"type": "endpoint",
		"path": "dist/index.js",
		"source": "src/index.ts",
		"host": "9.22.4"
	},
	"engines": {
		"node": ">=18.11.2"
	},
	"scripts": {
		"build": "directus-extension build",
		"dev": "directus-extension build -w --no-minify",
	},
	"devDependencies": {
		"@directus/extensions-sdk": "9.19.2",
		"@types/express": "4.17.14",
		"@types/mocha": "10.0.0",
		"@types/node": "18.11.2",
		"@typescript-eslint/eslint-plugin": "5.18.0",
		"@typescript-eslint/parser": "5.18.0",
		"axios": "1.1.3",
		"eslint": "8.28.0",
		"jsonwebtoken": "^8.5.1",
		"knex": "2.3.0",
		"mocha": "10.1.0",
		"nyc": "15.1.0",
		"ts-node": "10.9.1",
		"typescript": "4.8.4"
	},
	"dependencies": {
		"@azure/msal-node": "^1.14.6",
		"@directus/sdk": "^10.1.4",
		"@types/jsonwebtoken": "^8.5.9",
		"@types/node": "^18.7.21",
		"install": "^0.13.0",
	}
}

Errors Shown

No response

What version of Directus are you using?

9.22.4.

What version of Node.js are you using?

18.13.0

What database are you using?

Postgres

What browser are you using?

Chrome

How are you deploying Directus?

Docker

@github-actions
Copy link

Linear: ENG-573

@paescuj
Copy link
Member

paescuj commented Jan 25, 2023

Maybe this helps: #3338 (comment)

(Also leaving here as a reference: #16931)

@directus directus locked and limited conversation to collaborators Jan 25, 2023
@rijkvanzanten rijkvanzanten converted this issue into discussion #17302 Jan 25, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants