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

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');
.
.
.

Edit: I submitted a request to update the uuid module and to make version 5 UUIDs available.

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);
        });
}

Version 3.3.2 of the uuid module has been added, but I still get the original error when trying to use the uuid/v5 syntax (or /v4, /v3, etc.). Is this something specific to the webtask.io environment?

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@3.3.2');
  const uuidv5 = require('uuid@3.3.2/v5');

  user.app_metadata = user.app_metadata || {};
  //user.app_metadata.uuid = user.app_metadata.uuid || uuid();
  user.app_metadata.uuid = uuidv5(user.user_id, configuration.uuid_namespace);
ERROR: Cannot find module 'uuid@3.3.2/v5'
1 Like

I should really review my old, unresolved posts!

Turns out the ‘/’ syntax is not currently supported:

https://github.com/auth0-extensions/canirequire/issues/41