@auth0/auth0-angular 1.7.0 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -205,12 +205,38 @@ export interface AuthConfig {
205
205
  * This is available from the user invitation URL that is given when participating in a user invitation flow.
206
206
  */
207
207
  invitation?: string;
208
+ /**
209
+ * The name of the connection configured for your application.
210
+ * If null, it will redirect to the Auth0 Login Page and show
211
+ * the Login Widget.
212
+ */
213
+ connection?: string;
214
+ /**
215
+ * Modify the value used as the current time during the token validation.
216
+ *
217
+ * **Note**: Using this improperly can potentially compromise the token validation.
218
+ */
219
+ nowProvider?: () => Promise<number> | number;
208
220
  /**
209
221
  * If you need to send custom parameters to the Authorization Server,
210
222
  * make sure to use the original parameter name.
211
223
  */
212
224
  [key: string]: any;
213
225
  }
226
+ /**
227
+ * Angular specific state to be stored before redirect
228
+ */
229
+ export interface AppState {
230
+ /**
231
+ * Target path the app gets routed to after
232
+ * handling the callback from Auth0 (defaults to '/')
233
+ */
234
+ target?: string;
235
+ /**
236
+ * Any custom parameter to be stored in appState
237
+ */
238
+ [key: string]: any;
239
+ }
214
240
  /**
215
241
  * Gets and sets configuration for the internal Auth0 client. This can be
216
242
  * used to provide configuration outside of using AuthModule.forRoot, i.e. from
@@ -1,10 +1,10 @@
1
1
  import { OnDestroy } from '@angular/core';
2
- import { Auth0Client, RedirectLoginOptions, PopupLoginOptions, PopupConfigOptions, LogoutOptions, GetTokenSilentlyOptions, GetTokenWithPopupOptions, RedirectLoginResult, LogoutUrlOptions } from '@auth0/auth0-spa-js';
2
+ import { Auth0Client, RedirectLoginOptions, PopupLoginOptions, PopupConfigOptions, LogoutOptions, GetTokenSilentlyOptions, GetTokenWithPopupOptions, RedirectLoginResult, LogoutUrlOptions, GetTokenSilentlyVerboseResponse, GetUserOptions, User, GetIdTokenClaimsOptions, IdToken } from '@auth0/auth0-spa-js';
3
3
  import { Observable } from 'rxjs';
4
4
  import { AbstractNavigator } from './abstract-navigator';
5
- import { AuthClientConfig } from './auth.config';
5
+ import { AuthClientConfig, AppState } from './auth.config';
6
6
  import { AuthState } from './auth.state';
7
- export declare class AuthService implements OnDestroy {
7
+ export declare class AuthService<TAppState extends AppState = AppState> implements OnDestroy {
8
8
  private auth0Client;
9
9
  private configFactory;
10
10
  private navigator;
@@ -23,11 +23,11 @@ export declare class AuthService implements OnDestroy {
23
23
  /**
24
24
  * Emits details about the authenticated user, or null if not authenticated.
25
25
  */
26
- readonly user$: Observable<import("@auth0/auth0-spa-js").User | null | undefined>;
26
+ readonly user$: Observable<User | null | undefined>;
27
27
  /**
28
28
  * Emits ID token claims when authenticated, or null if not authenticated.
29
29
  */
30
- readonly idTokenClaims$: Observable<import("@auth0/auth0-spa-js").IdToken | null>;
30
+ readonly idTokenClaims$: Observable<IdToken | null | undefined>;
31
31
  /**
32
32
  * Emits errors that occur during login, or when checking for an active session on startup.
33
33
  */
@@ -36,7 +36,7 @@ export declare class AuthService implements OnDestroy {
36
36
  * Emits the value (if any) that was passed to the `loginWithRedirect` method call
37
37
  * but only **after** `handleRedirectCallback` is first called
38
38
  */
39
- readonly appState$: Observable<any>;
39
+ readonly appState$: Observable<TAppState>;
40
40
  constructor(auth0Client: Auth0Client, configFactory: AuthClientConfig, navigator: AbstractNavigator, authState: AuthState);
41
41
  /**
42
42
  * Called when the service is destroyed
@@ -53,7 +53,7 @@ export declare class AuthService implements OnDestroy {
53
53
  *
54
54
  * @param options The login options
55
55
  */
56
- loginWithRedirect(options?: RedirectLoginOptions): Observable<void>;
56
+ loginWithRedirect(options?: RedirectLoginOptions<TAppState>): Observable<void>;
57
57
  /**
58
58
  * ```js
59
59
  * await loginWithPopup(options);
@@ -89,29 +89,15 @@ export declare class AuthService implements OnDestroy {
89
89
  */
90
90
  logout(options?: LogoutOptions): void;
91
91
  /**
92
- * ```js
93
- * getAccessTokenSilently(options).subscribe(token => ...)
94
- * ```
95
- *
96
- * If there's a valid token stored, return it. Otherwise, opens an
97
- * iframe with the `/authorize` URL using the parameters provided
98
- * as arguments. Random and secure `state` and `nonce` parameters
99
- * will be auto-generated. If the response is successful, results
100
- * will be valid according to their expiration times.
101
- *
102
- * If refresh tokens are used, the token endpoint is called directly with the
103
- * 'refresh_token' grant. If no refresh token is available to make this call,
104
- * the SDK falls back to using an iframe to the '/authorize' URL.
105
- *
106
- * This method may use a web worker to perform the token call if the in-memory
107
- * cache is used.
108
- *
109
- * If an `audience` value is given to this function, the SDK always falls
110
- * back to using an iframe to make the token exchange.
92
+ * Fetches a new access token and returns the response from the /oauth/token endpoint, omitting the refresh token.
111
93
  *
112
- * Note that in all cases, falling back to an iframe requires access to
113
- * the `auth0` cookie, and thus will not work in browsers that block third-party
114
- * cookies by default (Safari, Brave, etc).
94
+ * @param options The options for configuring the token fetch.
95
+ */
96
+ getAccessTokenSilently(options: GetTokenSilentlyOptions & {
97
+ detailedResponse: true;
98
+ }): Observable<GetTokenSilentlyVerboseResponse>;
99
+ /**
100
+ * Fetches a new access token and returns it.
115
101
  *
116
102
  * @param options The options for configuring the token fetch.
117
103
  */
@@ -129,6 +115,44 @@ export declare class AuthService implements OnDestroy {
129
115
  * results will be valid according to their expiration times.
130
116
  */
131
117
  getAccessTokenWithPopup(options?: GetTokenWithPopupOptions): Observable<string>;
118
+ /**
119
+ * ```js
120
+ * getUser(options).subscribe(user => ...);
121
+ * ```
122
+ *
123
+ * Returns the user information if available (decoded
124
+ * from the `id_token`).
125
+ *
126
+ * If you provide an audience or scope, they should match an existing Access Token
127
+ * (the SDK stores a corresponding ID Token with every Access Token, and uses the
128
+ * scope and audience to look up the ID Token)
129
+ *
130
+ * @remarks
131
+ *
132
+ * The returned observable will emit once and then complete.
133
+ *
134
+ * @typeparam TUser The type to return, has to extend {@link User}.
135
+ * @param options The options to get the user
136
+ */
137
+ getUser<TUser extends User>(options?: GetUserOptions): Observable<TUser | undefined>;
138
+ /**
139
+ * ```js
140
+ * getIdTokenClaims(options).subscribe(claims => ...);
141
+ * ```
142
+ *
143
+ * Returns all claims from the id_token if available.
144
+ *
145
+ * If you provide an audience or scope, they should match an existing Access Token
146
+ * (the SDK stores a corresponding ID Token with every Access Token, and uses the
147
+ * scope and audience to look up the ID Token)
148
+ *
149
+ * @remarks
150
+ *
151
+ * The returned observable will emit once and then complete.
152
+ *
153
+ * @param options The options to get the Id token claims
154
+ */
155
+ getIdTokenClaims(options?: GetIdTokenClaimsOptions): Observable<IdToken | undefined>;
132
156
  /**
133
157
  * ```js
134
158
  * handleRedirectCallback(url).subscribe(result => ...)
@@ -143,7 +167,7 @@ export declare class AuthService implements OnDestroy {
143
167
  *
144
168
  * @param url The URL to that should be used to retrieve the `state` and `code` values. Defaults to `window.location.href` if not given.
145
169
  */
146
- handleRedirectCallback(url?: string): Observable<RedirectLoginResult>;
170
+ handleRedirectCallback(url?: string): Observable<RedirectLoginResult<TAppState>>;
147
171
  /**
148
172
  * ```js
149
173
  * buildAuthorizeUrl().subscribe(url => ...)
@@ -35,7 +35,7 @@ export declare class AuthState {
35
35
  /**
36
36
  * Emits ID token claims when authenticated, or null if not authenticated.
37
37
  */
38
- readonly idTokenClaims$: import("rxjs").Observable<import("@auth0/auth0-spa-js").IdToken | null>;
38
+ readonly idTokenClaims$: import("rxjs").Observable<import("@auth0/auth0-spa-js").IdToken | null | undefined>;
39
39
  /**
40
40
  * Emits errors that occur during login, or when checking for an active session on startup.
41
41
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@auth0/auth0-angular",
3
- "version": "1.7.0",
3
+ "version": "1.9.0",
4
4
  "description": "Auth0 SDK for Angular Single Page Applications (SPA)",
5
5
  "keywords": [
6
6
  "auth0",
@@ -21,12 +21,13 @@
21
21
  },
22
22
  "homepage": "https://github.com/auth0/auth0-angular#readme",
23
23
  "peerDependencies": {
24
- "@angular/common": ">=9 <=12",
25
- "@angular/core": ">=9 <=12"
24
+ "@angular/common": ">=9 <=13",
25
+ "@angular/core": ">=9 <=13",
26
+ "@angular/router": ">=9 <=13"
26
27
  },
27
28
  "dependencies": {
28
29
  "tslib": "^2.0.0",
29
- "@auth0/auth0-spa-js": "^1.16.0"
30
+ "@auth0/auth0-spa-js": "^1.19.3"
30
31
  },
31
32
  "schematics": "./schematics/collection.json",
32
33
  "main": "bundles/auth0-auth0-angular.umd.js",
package/public-api.d.ts CHANGED
@@ -5,4 +5,4 @@ export * from './lib/auth.interceptor';
5
5
  export * from './lib/auth.config';
6
6
  export * from './lib/auth.client';
7
7
  export * from './lib/auth.state';
8
- export { ICache, Cacheable, LocalStorageCache, InMemoryCache, } from '@auth0/auth0-spa-js';
8
+ export { ICache, Cacheable, LocalStorageCache, InMemoryCache, IdToken, User } from '@auth0/auth0-spa-js';