I am unable to use the auth0
Node.js client library from within Rules.
I get the following error:
(node:6) UnhandledPromiseRejectionWarning: TypeError: ManagementClient is not a constructor
example code:
global.getRoleIdsByName = global.getRolesByName || async function (role_names) {
const ManagementClient = require('auth0').ManagementClient;
const management = new ManagementClient({
token: auth0.accessToken,
domain: auth0.domain
});
let roles = await management.getRoles();
return roles.filter(role => role_names.includes(role.name)).map(role => role.id);
}
Note that this works just fine when executed from a local Node.js environment like my IDE.
I have seen this library being used (example) hence my confusion …
Regards,
Gerardo.