1 | import { Auth0ClientOptions, RedirectLoginOptions, PopupLoginOptions, PopupConfigOptions, RedirectLoginResult, GetTokenSilentlyOptions, GetTokenWithPopupOptions, LogoutOptions, User, IdToken, GetTokenSilentlyVerboseResponse } from './global';
|
2 |
|
3 |
|
4 |
|
5 | export declare class Auth0Client {
|
6 | private readonly transactionManager;
|
7 | private readonly cacheManager;
|
8 | private readonly domainUrl;
|
9 | private readonly tokenIssuer;
|
10 | private readonly scope;
|
11 | private readonly cookieStorage;
|
12 | private readonly sessionCheckExpiryDays;
|
13 | private readonly orgHintCookieName;
|
14 | private readonly isAuthenticatedCookieName;
|
15 | private readonly nowProvider;
|
16 | private readonly httpTimeoutMs;
|
17 | private readonly options;
|
18 | private readonly userCache;
|
19 | private worker?;
|
20 | private readonly defaultOptions;
|
21 | constructor(options: Auth0ClientOptions);
|
22 | private _url;
|
23 | private _authorizeUrl;
|
24 | private _verifyIdToken;
|
25 | private _processOrgIdHint;
|
26 | private _prepareAuthorizeUrl;
|
27 | /**
|
28 | * ```js
|
29 | * try {
|
30 | * await auth0.loginWithPopup(options);
|
31 | * } catch(e) {
|
32 | * if (e instanceof PopupCancelledError) {
|
33 | *
|
34 | * }
|
35 | * }
|
36 | * ```
|
37 | *
|
38 | * Opens a popup with the `/authorize` URL using the parameters
|
39 | * provided as arguments. Random and secure `state` and `nonce`
|
40 | * parameters will be auto-generated. If the response is successful,
|
41 | * results will be valid according to their expiration times.
|
42 | *
|
43 | * IMPORTANT: This method has to be called from an event handler
|
44 | * that was started by the user like a button click, for example,
|
45 | * otherwise the popup will be blocked in most browsers.
|
46 | *
|
47 | * @param options
|
48 | * @param config
|
49 | */
|
50 | loginWithPopup(options?: PopupLoginOptions, config?: PopupConfigOptions): Promise<void>;
|
51 | /**
|
52 | * ```js
|
53 | * const user = await auth0.getUser();
|
54 | * ```
|
55 | *
|
56 | * Returns the user information if available (decoded
|
57 | * from the `id_token`).
|
58 | *
|
59 | * @typeparam TUser The type to return, has to extend {@link User}.
|
60 | */
|
61 | getUser<TUser extends User>(): Promise<TUser | undefined>;
|
62 | /**
|
63 | * ```js
|
64 | * const claims = await auth0.getIdTokenClaims();
|
65 | * ```
|
66 | *
|
67 | * Returns all claims from the id_token if available.
|
68 | */
|
69 | getIdTokenClaims(): Promise<IdToken | undefined>;
|
70 | /**
|
71 | * ```js
|
72 | * await auth0.loginWithRedirect(options);
|
73 | * ```
|
74 | *
|
75 | * Performs a redirect to `/authorize` using the parameters
|
76 | * provided as arguments. Random and secure `state` and `nonce`
|
77 | * parameters will be auto-generated.
|
78 | *
|
79 | * @param options
|
80 | */
|
81 | loginWithRedirect<TAppState = any>(options?: RedirectLoginOptions<TAppState>): Promise<void>;
|
82 | /**
|
83 | * After the browser redirects back to the callback page,
|
84 | * call `handleRedirectCallback` to handle success and error
|
85 | * responses from Auth0. If the response is successful, results
|
86 | * will be valid according to their expiration times.
|
87 | */
|
88 | handleRedirectCallback<TAppState = any>(url?: string): Promise<RedirectLoginResult<TAppState>>;
|
89 | /**
|
90 | * ```js
|
91 | * await auth0.checkSession();
|
92 | * ```
|
93 | *
|
94 | * Check if the user is logged in using `getTokenSilently`. The difference
|
95 | * with `getTokenSilently` is that this doesn't return a token, but it will
|
96 | * pre-fill the token cache.
|
97 | *
|
98 | * This method also heeds the `auth0.{clientId}.is.authenticated` cookie, as an optimization
|
99 | * to prevent calling Auth0 unnecessarily. If the cookie is not present because
|
100 | * there was no previous login (or it has expired) then tokens will not be refreshed.
|
101 | *
|
102 | * It should be used for silently logging in the user when you instantiate the
|
103 | * `Auth0Client` constructor. You should not need this if you are using the
|
104 | * `createAuth0Client` factory.
|
105 | *
|
106 | * **Note:** the cookie **may not** be present if running an app using a private tab, as some
|
107 | * browsers clear JS cookie data and local storage when the tab or page is closed, or on page reload. This effectively
|
108 | * means that `checkSession` could silently return without authenticating the user on page refresh when
|
109 | * using a private tab, despite having previously logged in. As a workaround, use `getTokenSilently` instead
|
110 | * and handle the possible `login_required` error [as shown in the readme](https://github.com/auth0/auth0-spa-js#creating-the-client).
|
111 | *
|
112 | * @param options
|
113 | */
|
114 | checkSession(options?: GetTokenSilentlyOptions): Promise<void>;
|
115 | /**
|
116 | * Fetches a new access token and returns the response from the /oauth/token endpoint, omitting the refresh token.
|
117 | *
|
118 | * @param options
|
119 | */
|
120 | getTokenSilently(options: GetTokenSilentlyOptions & {
|
121 | detailedResponse: true;
|
122 | }): Promise<GetTokenSilentlyVerboseResponse>;
|
123 | /**
|
124 | * Fetches a new access token and returns it.
|
125 | *
|
126 | * @param options
|
127 | */
|
128 | getTokenSilently(options?: GetTokenSilentlyOptions): Promise<string>;
|
129 | private _getTokenSilently;
|
130 | /**
|
131 | * ```js
|
132 | * const token = await auth0.getTokenWithPopup(options);
|
133 | * ```
|
134 | * Opens a popup with the `/authorize` URL using the parameters
|
135 | * provided as arguments. Random and secure `state` and `nonce`
|
136 | * parameters will be auto-generated. If the response is successful,
|
137 | * results will be valid according to their expiration times.
|
138 | *
|
139 | * @param options
|
140 | * @param config
|
141 | */
|
142 | getTokenWithPopup(options?: GetTokenWithPopupOptions, config?: PopupConfigOptions): Promise<string | undefined>;
|
143 | /**
|
144 | * ```js
|
145 | * const isAuthenticated = await auth0.isAuthenticated();
|
146 | * ```
|
147 | *
|
148 | * Returns `true` if there's valid information stored,
|
149 | * otherwise returns `false`.
|
150 | *
|
151 | */
|
152 | isAuthenticated(): Promise<boolean>;
|
153 | /**
|
154 | * ```js
|
155 | * await auth0.buildLogoutUrl(options);
|
156 | * ```
|
157 | *
|
158 | * Builds a URL to the logout endpoint using the parameters provided as arguments.
|
159 | * @param options
|
160 | */
|
161 | private _buildLogoutUrl;
|
162 | /**
|
163 | * ```js
|
164 | * await auth0.logout(options);
|
165 | * ```
|
166 | *
|
167 | * Clears the application session and performs a redirect to `/v2/logout`, using
|
168 | * the parameters provided as arguments, to clear the Auth0 session.
|
169 | *
|
170 | * If the `federated` option is specified it also clears the Identity Provider session.
|
171 | * [Read more about how Logout works at Auth0](https://auth0.com/docs/logout).
|
172 | *
|
173 | * @param options
|
174 | */
|
175 | logout(options?: LogoutOptions): Promise<void>;
|
176 | private _getTokenFromIFrame;
|
177 | private _getTokenUsingRefreshToken;
|
178 | private _saveEntryInCache;
|
179 | private _getIdTokenFromCache;
|
180 | private _getEntryFromCache;
|
181 | /**
|
182 | * Releases any lock acquired by the current page that's not released yet
|
183 | *
|
184 | * Get's called on the `pagehide` event.
|
185 | * https://developer.mozilla.org/en-US/docs/Web/API/Window/pagehide_event
|
186 | */
|
187 | private _releaseLockOnPageHide;
|
188 | private _requestToken;
|
189 | }
|
190 |
|
\ | No newline at end of file |