Fix: TypeError when CordovaAuth0Plugin is not a constructor (auth0-js 9.30.1+) #2742
Merged
ankita10119 merged 1 commit intomasterfrom Mar 18, 2026
Merged
Conversation
Piyush-85
approved these changes
Mar 18, 2026
Merged
ankita10119
added a commit
that referenced
this pull request
Mar 19, 2026
**Fixed** - Fix: TypeError when CordovaAuth0Plugin is not a constructor (auth0-js 9.30.1+) [\#2742](#2742) ([ankita10119](https://github.com/ankita10119)) - Fix: TypeError in matchConnection for enterprise connections with no domains [\#2736](#2736) ([ankita10119](https://github.com/ankita10119))
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
Problem
Users installing
auth0-lockget the following error on Lock initialization, preventing the widget from rendering entirely:Uncaught TypeError: CordovaAuth0Plugin is not a constructor at Auth0APIClient (p2_api.js)
This affects any fresh install of
auth0-locksinceauth0-js ^9.29.0resolves to9.30.1+on npm.Root Cause
auth0-js 9.30.0introduced a Rollup build tooling change (via #1563) that changed howcordova-auth0-plugin.min.jsbundles its exports. As a result, when webpack's ESM interop resolves the module, the default export is an empty object {} instead of the constructor function - breaking newCordovaAuth0Plugin()inp2_api.jsFix
Guard the instantiation with a typeof check - if
CordovaAuth0Pluginis not a valid constructor, fall back to an empty plugins array:// Before
plugins: opts.plugins || [new CordovaAuth0Plugin()],// After
plugins: opts.plugins || (typeof CordovaAuth0Plugin === 'function' ? [new CordovaAuth0Plugin()] : []),This is safe because plugins is optional in auth0-js's WebAuth - the Cordova plugin only applies in Cordova environments. Web-based auth flows are unaffected.
References
SDK-8308
Testing
auth0-lock@14.2.4withauth0-js@9.31.0in a React app, Lock failed to initialize with the TypeErrorauth0-js <= 9.29.0(where the plugin exports a function) continues to work correctly sincetypeof function === 'function'is trueChecklist