Repository: auth0/react-native-auth0

Issue:
[TypeError: Cannot read property 'prototype' of undefined]
### Checklist

- [x] The issue can be reproduced in the [react-native-auth0 sample app](https://github.com/auth0-samples/auth0-react-native-sample) (or N/A).
- [x] I have looked into the [Readme](https://github.com/auth0/react-native-auth0#readme), [Examples](https://github.com/auth0/react-native-auth0/blob/master/EXAMPLES.md), and [FAQ](https://github.com/auth0/react-native-auth0/blob/master/FAQ.md) and have not found a suitable solution or answer.
- [x] I have looked into the [API documentation](https://auth0.github.io/react-native-auth0/) and have not found a suitable solution or answer.
- [x] I have searched the [issues](https://github.com/auth0/react-native-auth0/issues) and have not found a suitable solution or answer.
- [x] I have searched the [Auth0 Community](https://community.auth0.com) forums and have not found a suitable solution or answer.
- [x] I agree to the terms within the [Auth0 Code of Conduct](https://github.com/auth0/open-source-template/blob/master/CODE-OF-CONDUCT.md).

### Description

After Upgrading to React 19 and expo sdk54 and RN 0.81.4, I am getting this issue [TypeError: Cannot read property 'prototype' of undefined] 

Whenever I open my app , I am getting this [TypeError: Cannot read property 'prototype' of undefined]  issue and Whenever I remove AuthProvider from My App , the App is working fine

ERROR  [TypeError: Cannot read property 'prototype' of undefined] 

<img width="493" height="122" alt="Image" src="https://github.com/user-attachments/assets/41e3e736-ed48-4520-ae34-73df57365074" />

Call Stack
  <global> (node_modules\react-native-auth0\src\hooks\Auth0Provider.tsx)
  mountMemo (node_modules\react-native\Libraries\Renderer\implementations\ReactFabric-dev.js)
  HooksDispatcherOnMountInDEV.useMemo (node_modules\react-native\Libraries\Renderer\implementations\ReactFabric-dev.js)
  exports.useMemo (node_modules\react\cjs\react.development.js)
  <global> (node_modules\react-native-auth0\src\hooks\Auth0Provider.tsx)
  callComponent.reactStackBottomFrame (node_modules\react-native\Libraries\Renderer\implementations\ReactFabric-dev.js)
  renderWithHooks (node_modules\react-native\Libraries\Renderer\implementations\ReactFabric-dev.js)
  updateFunctionComponent (node_modules\react-native\Libraries\Renderer\implementations\ReactFabric-dev.js)
  beginWork (node_modules\react-native\Libraries\Renderer\implementations\ReactFabric-dev.js)
  runWithFiberInDEV (node_modules\react-native\Libraries\Renderer\implementations\ReactFabric-dev.js)
  performUnitOfWork (node_modules\react-native\Libraries\Renderer\implementations\ReactFabric-dev.js)
  workLoopSync (node_modules\react-native\Libraries\Renderer\implementations\ReactFabric-dev.js)
  renderRootSync (node_modules\react-native\Libraries\Renderer\implementations\ReactFabric-dev.js)
  performWorkOnRoot (node_modules\react-native\Libraries\Renderer\implementations\ReactFabric-dev.js)
  performWorkOnRootViaSchedulerTask (node_modules\react-native\Libraries\Renderer\implementations\ReactFabric-dev.js)

Call Stack
  RootLayout (app\_layout.tsx)
  BaseRoute (node_modules\expo-router\build\useScreens.js)
  SceneView (node_modules\@react-navigation\core\lib\module\SceneView.js)
  setOptions$argument_0 (node_modules\@react-navigation\core\lib\module\useDescriptors.js)
  render (node_modules\@react-navigation\core\lib\module\useDescriptors.js)
  reduce (<native>)
  render (node_modules\@react-navigation\core\lib\module\useDescriptors.js)
  useNavigationBuilder (node_modules\@react-navigation\core\lib\module\useNavigationBuilder.js)
  Content (node_modules\expo-router\build\ExpoRoot.js)
  ContextNavigator (node_modules\expo-router\build\ExpoRoot.js)
  <anonymous> (node_modules\expo-router\build\ExpoRoot.js)
  App (node_modules\expo-router\build\qualified-entry.js)
  WithDevTools (node_modules\expo\src\launch\withDevTools.tsx)

### Reproduction

1. Upgrade to expo 54 , react 19 and above and React Native 0.81 above
2. Opening the App and getting this issue

### Additional context

_No response_

### react-native-auth0 version

5.0.0

### React Native version

0.81.4

### Expo version

54.0.10

### Platform

Android

### Platform version(s)

Android 9

Discussion:
@subhankarmaiti: Hi @inductionotg ,
Could you please provide the exact versions of React, React Native, and any Expo-related packages from your `package.json`? Additionally, if possible, could you share the content of your `<NetworkWrapper />` component?@inductionotg: "react": "19.1.0",
    "react-dom": "19.1.0",
    "react-native": "0.81.4",
"react-native-auth0": "^5.0.0-beta.6",

moved to react Native autho to v5 Stable version , still same error I got.

When i remove the Auth0 Provider from the App , the error is gone and I am able to access My app @subhankarmaiti 

@inductionotg: <img width="328" height="332" alt="Image" src="https://github.com/user-attachments/assets/43544a08-5afe-4888-9ea3-ccf09e6c1292" />

</br>

<img width="335" height="318" alt="Image" src="https://github.com/user-attachments/assets/7754e7e2-9fde-41f1-a5b3-8a160cfd689d" />@alex-at-sagelabs: I am having same issue. It works on v5.0.0-beta.3 but it fails starting from beta.4 @alex-at-sagelabs: @subhankarmaiti We'd love to contribute 
So we've opened a PR to close this issue. It is a circular dependency issue. 

Solution patch:
diff --git a/src/Auth0.ts b/src/Auth0.ts
new file mode 100644
index 0000000..b9ca90b
--- /dev/null
+++ b/src/Auth0.ts
@@ -0,0 +1,94 @@
+import type { IAuth0Client } from './core/interfaces/IAuth0Client';
+import { Auth0ClientFactory } from './factory/Auth0ClientFactory';
+import type { Auth0Options, DPoPHeadersParams } from './types';
+
+/**
+ * The main Auth0 client class.
+ *
+ * This class acts as a facade, creating and delegating to a platform-specific
+ * client instance (Native or Web) under the hood.
+ *
+ * @example
+ * ```
+ * import Auth0 from 'react-native-auth0';
+ *
+ * const auth0 = new Auth0({
+ *   domain: 'YOUR_AUTH0_DOMAIN',
+ *   clientId: 'YOUR_AUTH0_CLIENT_ID'
+ * });
+ * ```
+ */
+class Auth0 {
+  private client: IAuth0Client;
+
+  /**
+   * Creates an instance of the Auth0 client.
+   * @param options Configuration options for the client.
+   */
+  constructor(options: Auth0Options) {
+    // The factory detects the platform and returns the appropriate client implementation.
+    // The rest of this class is completely unaware of whether it's running on native or web.
+    this.client = Auth0ClientFactory.createClient(options);
+  }
+
+  /**
+   * Provides access to the web-based authentication methods.
+   * @see IWebAuthProvider
+   */
+  get webAuth() {
+    return this.client.webAuth;
+  }
+
+  /**
+   * Provides access to the credentials management methods.
+   * @see ICredentialsManager
+   */
+  get credentialsManager() {
+    return this.client.credentialsManager;
+  }
+
+  /**
+   * Provides access to direct authentication methods (e.g., password-realm).
+   * @see IAuthenticationProvider
+   */
+  get auth() {
+    return this.client.auth;
+  }
+
+  /**
+   * Provides access to the Management API (e.g., for user patching).
+   */
+  users(token: string) {
+    return this.client.users(token);
+  }
+
+  /**
+   * Generates DPoP headers for making authenticated requests to custom APIs.
+   * This method creates the necessary HTTP headers (Authorization and DPoP) to
+   * securely bind the access token to a specific API request.
+   *
+   * @param params Parameters including the URL, HTTP method, access token, and token type.
+   * @returns A promise that resolves to an object containing the required headers.
+   *
+   * @example
+   * ```typescript
+   * const credentials = await auth0.credentialsManager.getCredentials();
+   *
+   * if (credentials.tokenType === 'DPoP') {
+   *   const headers = await auth0.getDPoPHeaders({
+   *     url: 'https://api.example.com/data',
+   *     method: 'GET',
+   *     accessToken: credentials.accessToken,
+   *     tokenType: credentials.tokenType
+   *   });
+   *
+   *   const response = await fetch('https://api.example.com/data', { headers });
+   * }
+   * ```
+   */
+  getDPoPHeaders(params: DPoPHeadersParams) {
+    return this.client.getDPoPHeaders(params);
+  }
+}
+
+export default Auth0;
diff --git a/src/exports/classes.ts b/src/exports/classes.ts
index bb89e62..1805984 100644
--- a/src/exports/classes.ts
+++ b/src/exports/classes.ts
@@ -3,4 +3,5 @@ export {
   CredentialsManagerError,
   WebAuthError,
 } from '../core/models';
-export { default as Auth0, TimeoutError } from '../index';
+export { default as Auth0 } from '../Auth0';
+export { TimeoutError } from '../core/utils/fetchWithTimeout';
diff --git a/src/hooks/Auth0Provider.tsx b/src/hooks/Auth0Provider.tsx
index 1f8a628..889efa4 100644
--- a/src/hooks/Auth0Provider.tsx
+++ b/src/hooks/Auth0Provider.tsx
@@ -30,7 +30,7 @@ import type {
   NativeClearSessionOptions,
 } from '../types/platform-specific';
 import { Auth0User, AuthError } from '../core/models';
-import Auth0 from '../index';
+import Auth0 from '../Auth0';
 import { Platform } from 'react-native';
 
 export const Auth0Provider = ({
diff --git a/src/index.ts b/src/index.ts
index 035f7a0..ed873e4 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -1,7 +1,3 @@
-import type { IAuth0Client } from './core/interfaces/IAuth0Client';
-import { Auth0ClientFactory } from './factory/Auth0ClientFactory';
-import type { Auth0Options, DPoPHeadersParams } from './types';
-
 export {
   AuthError,
   CredentialsManagerError,
@@ -18,93 +14,5 @@ export type {
   LocalAuthenticationStrategy,
 } from './types/platform-specific';
 
-/**
- * The main Auth0 client class.
- *
- * This class acts as a facade, creating and delegating to a platform-specific
- * client instance (Native or Web) under the hood.
- *
- * @example
- * ```
- * import Auth0 from 'react-native-auth0';
- *
- * const auth0 = new Auth0({
- *   domain: 'YOUR_AUTH0_DOMAIN',
- *   clientId: 'YOUR_AUTH0_CLIENT_ID'
- * });
- * ```
- */
-class Auth0 {
-  private client: IAuth0Client;
-
-  /**
-   * Creates an instance of the Auth0 client.
-   * @param options Configuration options for the client.
-   */
-  constructor(options: Auth0Options) {
-    // The factory detects the platform and returns the appropriate client implementation.
-    // The rest of this class is completely unaware of whether it's running on native or web.
-    this.client = Auth0ClientFactory.createClient(options);
-  }
-
-  /**
-   * Provides access to the web-based authentication methods.
-   * @see IWebAuthProvider
-   */
-  get webAuth() {
-    return this.client.webAuth;
-  }
-
-  /**
-   * Provides access to the credentials management methods.
-   * @see ICredentialsManager
-   */
-  get credentialsManager() {
-    return this.client.credentialsManager;
-  }
-
-  /**
-   * Provides access to direct authentication methods (e.g., password-realm).
-   * @see IAuthenticationProvider
-   */
-  get auth() {
-    return this.client.auth;
-  }
-
-  /**
-   * Provides access to the Management API (e.g., for user patching).
-   */
-  users(token: string) {
-    return this.client.users(token);
-  }
-
-  /**
-   * Generates DPoP headers for making authenticated requests to custom APIs.
-   * This method creates the necessary HTTP headers (Authorization and DPoP) to
-   * securely bind the access token to a specific API request.
-   *
-   * @param params Parameters including the URL, HTTP method, access token, and token type.
-   * @returns A promise that resolves to an object containing the required headers.
-   *
-   * @example
-   * ```typescript
-   * const credentials = await auth0.credentialsManager.getCredentials();
-   *
-   * if (credentials.tokenType === 'DPoP') {
-   *   const headers = await auth0.getDPoPHeaders({
-   *     url: 'https://api.example.com/data',
-   *     method: 'GET',
-   *     accessToken: credentials.accessToken,
-   *     tokenType: credentials.tokenType
-   *   });
-   *
-   *   const response = await fetch('https://api.example.com/data', { headers });
-   * }
-   * ```
-   */
-  getDPoPHeaders(params: DPoPHeadersParams) {
-    return this.client.getDPoPHeaders(params);
-  }
-}
-
-export default Auth0;
+// Re-export Auth0 as default
+export { default } from './Auth0';
diff --git a/src/plugin/withAuth0.ts b/src/plugin/withAuth0.ts
index 08c06b3..5a8d55b 100644
--- a/src/plugin/withAuth0.ts
+++ b/src/plugin/withAuth0.ts
@@ -38,7 +38,11 @@ export const addAndroidAuth0Manifest = (
 
   const intentFilterContent = [
     {
-      ...(hasAppLinks && { $: { 'android:autoVerify': 'true' as AndroidConfig.Manifest.StringBoolean } }),
+      ...(hasAppLinks && {
+        $: {
+          'android:autoVerify': 'true' as AndroidConfig.Manifest.StringBoolean,
+        },
+      }),
       action: [{ $: { 'android:name': 'android.intent.action.VIEW' } }],
       category: [
         { $: { 'android:name': 'android.intent.category.DEFAULT' } },
@@ -67,14 +71,16 @@ export const addAndroidAuth0Manifest = (
         'tools:node': 'replace',
         'android:exported': 'true',
       },
-      'intent-filter': intentFilterContent as AndroidConfig.Manifest.ManifestIntentFilter[],
+      'intent-filter':
+        intentFilterContent as AndroidConfig.Manifest.ManifestIntentFilter[],
     };
     mainApplication.activity = mainApplication.activity || [];
     mainApplication.activity.push(redirectActivity);
   }
-  
+
   redirectActivity['intent-filter'] =
-      redirectActivity['intent-filter'] || intentFilterContent as AndroidConfig.Manifest.ManifestIntentFilter[];
+    redirectActivity['intent-filter'] ||
+    (intentFilterContent as AndroidConfig.Manifest.ManifestIntentFilter[]);
   const intentFilter = redirectActivity['intent-filter'][0] || {};
   if (!intentFilter) {
     throw new Error('Failed to create intent filter');
@@ -84,7 +90,8 @@ export const addAndroidAuth0Manifest = (
   // Add android:autoVerify="true" for App Links
   if (hasAppLinks) {
     intentFilter.$ = intentFilter.$ || {};
-    intentFilter.$['android:autoVerify'] = 'true' as AndroidConfig.Manifest.StringBoolean;
+    intentFilter.$['android:autoVerify'] =
+      'true' as AndroidConfig.Manifest.StringBoolean;
   }
 
   // Add data elements for each auth0Config



Test patch:
diff --git a/src/hooks/__tests__/Auth0Provider.spec.tsx b/src/hooks/__tests__/Auth0Provider.spec.tsx
index 60662c0..3e32f43 100644
--- a/src/hooks/__tests__/Auth0Provider.spec.tsx
+++ b/src/hooks/__tests__/Auth0Provider.spec.tsx
@@ -8,7 +8,7 @@ import {
 } from '@testing-library/react';
 import '@testing-library/jest-dom';
 import { Auth0Provider, useAuth0 } from '..';
-import Auth0 from '../../index';
+import Auth0 from '../../Auth0';
 
 // Mock TurboModuleRegistry first
 jest.mock('react-native/Libraries/TurboModule/TurboModuleRegistry', () => ({
@@ -63,7 +63,7 @@ jest.mock('react-native', () => ({
 }));
 
 // 1. Mock the top-level Auth0 facade
-jest.mock('../../index');
+jest.mock('../../Auth0');
 const MockAuth0 = Auth0 as jest.MockedClass<typeof Auth0>;
 
 // Mock the Auth0User model's factory method