Cannot require necessary package on Node 22 tenant - google-auth-library

As requested by the warning I got that the NodeJS 18 runtime I had been depending on was going to be deprecated, I upgraded my tenant to Node 22.

The one consequence of this is that the Hooks that are written for the Delegated Admin Extensions (write hook and query hook), the packages available via “require(‘package-name@version’)” are limited to the ones available at Can I require? - Search which node modules you can use in webtask.io when selecting the Node 22 runtime.

There is one library ‘google-auth-library’ that is a dependency of a supported library “googleapis” however depending directly on the “google-auth-library” in a hook causes an error once swapped to the Node 22 runtime as the ‘google-auth-library’ is available in Node 18 but strangely even thought its dependent is there, not available in Node 22.

I would love to file a github issue in the ‘auth0-extensions/canirequire’ project but all issue creation has been disabled.

I have requirements to use the Google Auth Library with no alternatives I can find to do what I need. Can we get the Node 22 runtime updated to have the ‘google-auth-library’ available somehow?

Hi @architect

Welcome to the Auth0 Community!

It appears that you have hit a very specific, known discrepancy in the module dependency tree for the legacy Webtask/Rules/Hooks platform’s transition to the Node 22 runtime.

Unlike Auth0 Actions, legacy Rules, Hooks, and Custom Database Scripts run on a shared, pre-compiled sandbox managed by the underlying Webtask engine.

Because the packages available to require() in these legacy extensibility points are pre-cached, the canirequire repository defines a locked list of permissible modules. In the transition from Node 18 to Node 22, the package googleapis was updated, but its peer dependency, google-auth-library, was inadvertently omitted from the top-level whitelist of the Node 22 compiler profile, despite being bundled inside googleapis.

Since the auth0-extensions/canirequire repository has disabled public issue creation, you cannot flag this via a GitHub PR or issue directly.

Depending on your architecture, there are two distinct ways to bypass this roadblock:

Option 1:
Since googleapis is natively whitelisted on the Node 22 profile, the actual google-auth-library code is already present in the sandbox node_modules directory—it is just not accessible under its own direct name.

You can resolve your imports by bypassing the top-level namespace and pulling the auth client straight out of the parent googleapis package, which acts as a wrapper:

///Instead of:
//const { GoogleAuth } = require('google-auth-library');

//Use the parent "googleapis" package to access the same authentication class:
const { google } = require('googleapis');

// Extract the GoogleAuth class directly from the googleapis package:
const GoogleAuth = google.auth.GoogleAuth; 

// Initialize it exactly as you did before:
const auth = new GoogleAuth({
  scopes: ['https://www.googleapis.com/auth/cloud-platform']
});

Option 2:
Because Auth0 is fully deprecating Rules and Hooks, they are scheduled to reach End-of-Life (EOL).

If your Delegated Admin Extension hook can be refactored, migrating it to a Post-Login Action is the highly recommended long-term path. In Auth0 Actions, you are no longer limited by the canirequire list and can explicitly declare google-auth-library as an independent dependency in the Modules pane:

  1. In your Dashboard, go to Actions > Library

  2. Click Create Action and select Node 22 as the runtime

  3. Click the Dependency (cube) icon on the left sidebar

  4. Click Add Module, search for google-auth-library, and save it

  5. You can now use the library natively with standard require('google-auth-library') statements

These steps are provided by our guide on Migrating From Node18 to Node22

If you must stick to the legacy Hook framework for the Delegated Admin Extension, Option 1 will safely unblock your Node 22 upgrade immediately.

Kind Regards,
Nik