Auth0 Home Blog Docs

'ERROR: Cannot find module 'uuid/v5''

rules

#1

Edit: I should mention, I don’t know javascript / node at all. May be something super basic that I am missing.

I’m messing around with a rule to add a namespace based UUID to a user. Importing the module per the docs as uuid/v5 works fine from the command line, but in a rule I get the error:

ERROR: Cannot find module 'uuid/v5'

Importing just uuid works fine, but I have to assume that is defaulting to something other than v5. I don’t see anything in the docs re: another way to specify the UUID version.

function (user, context, callback) {
  const uuidv5 = require('uuid/v5');
.
.
.

#2

I was able to build the following rule, but it uses the default UUID random UUIDs:

function (user, context, callback) {
    // Generates a version 4 random UUID. Namespace UUIDs do not appear
    // to be an option in Auth0 at this time.
    const uuid = require('uuid');
    
    user.app_metadata = user.app_metadata || {};
    user.app_metadata.uuid = user.app_metadata.uuid || uuid();
    
    auth0.users.updateAppMetadata(user.user_id, user.app_metadata)
        .then(function(){
            callback(null, user, context);
        })
        .catch(function(err){
            callback(err);
        });
}