1- import type { IAuth0Client } from './core/interfaces/IAuth0Client' ;
2- import { Auth0ClientFactory } from './factory/Auth0ClientFactory' ;
3- import type { Auth0Options , DPoPHeadersParams } from './types' ;
4-
51export {
62 AuthError ,
73 CredentialsManagerError ,
@@ -18,93 +14,5 @@ export type {
1814 LocalAuthenticationStrategy ,
1915} from './types/platform-specific' ;
2016
21- /**
22- * The main Auth0 client class.
23- *
24- * This class acts as a facade, creating and delegating to a platform-specific
25- * client instance (Native or Web) under the hood.
26- *
27- * @example
28- * ```
29- * import Auth0 from 'react-native-auth0';
30- *
31- * const auth0 = new Auth0({
32- * domain: 'YOUR_AUTH0_DOMAIN',
33- * clientId: 'YOUR_AUTH0_CLIENT_ID'
34- * });
35- * ```
36- */
37- class Auth0 {
38- private client : IAuth0Client ;
39-
40- /**
41- * Creates an instance of the Auth0 client.
42- * @param options Configuration options for the client.
43- */
44- constructor ( options : Auth0Options ) {
45- // The factory detects the platform and returns the appropriate client implementation.
46- // The rest of this class is completely unaware of whether it's running on native or web.
47- this . client = Auth0ClientFactory . createClient ( options ) ;
48- }
49-
50- /**
51- * Provides access to the web-based authentication methods.
52- * @see IWebAuthProvider
53- */
54- get webAuth ( ) {
55- return this . client . webAuth ;
56- }
57-
58- /**
59- * Provides access to the credentials management methods.
60- * @see ICredentialsManager
61- */
62- get credentialsManager ( ) {
63- return this . client . credentialsManager ;
64- }
65-
66- /**
67- * Provides access to direct authentication methods (e.g., password-realm).
68- * @see IAuthenticationProvider
69- */
70- get auth ( ) {
71- return this . client . auth ;
72- }
73-
74- /**
75- * Provides access to the Management API (e.g., for user patching).
76- */
77- users ( token : string ) {
78- return this . client . users ( token ) ;
79- }
80-
81- /**
82- * Generates DPoP headers for making authenticated requests to custom APIs.
83- * This method creates the necessary HTTP headers (Authorization and DPoP) to
84- * securely bind the access token to a specific API request.
85- *
86- * @param params Parameters including the URL, HTTP method, access token, and token type.
87- * @returns A promise that resolves to an object containing the required headers.
88- *
89- * @example
90- * ```typescript
91- * const credentials = await auth0.credentialsManager.getCredentials();
92- *
93- * if (credentials.tokenType === 'DPoP') {
94- * const headers = await auth0.getDPoPHeaders({
95- * url: 'https://api.example.com/data',
96- * method: 'GET',
97- * accessToken: credentials.accessToken,
98- * tokenType: credentials.tokenType
99- * });
100- *
101- * const response = await fetch('https://api.example.com/data', { headers });
102- * }
103- * ```
104- */
105- getDPoPHeaders ( params : DPoPHeadersParams ) {
106- return this . client . getDPoPHeaders ( params ) ;
107- }
108- }
109-
110- export default Auth0 ;
17+ // Re-export Auth0 as default
18+ export { default } from './Auth0' ;
0 commit comments