Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 14 additions & 19 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@angular/core": "^20.3.31",
"@angular/platform-browser": "^20.3.31",
"@angular/router": "^20.3.31",
"@auth0/auth0-spa-js": "^2.24.1",
"@auth0/auth0-spa-js": "^2.26.0",
"rxjs": "^6.6.7",
"tslib": "^2.8.1",
"zone.js": "~0.15.1"
Expand Down
2 changes: 1 addition & 1 deletion projects/auth0-angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
"dependencies": {
"tslib": "^2.0.0",
"@auth0/auth0-spa-js": "^2.21.0"
"@auth0/auth0-spa-js": "^2.26.0"
},
"schematics": "./schematics/collection.json"
}
22 changes: 13 additions & 9 deletions projects/auth0-angular/src/lib/auth.interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,20 @@ export class AuthHttpInterceptor implements HttpInterceptor {
): Observable<string> {
return of(this.auth0Client).pipe(
concatMap((client) => client.getTokenSilently(options)),
map((tokenOrResponse: string | GetTokenSilentlyVerboseResponse) => {
// spa-js returns undefined when cacheMode is 'cache-only' with no
// cached entry, or when an IPSIE session_expiry ceiling is reached.
if (!tokenOrResponse) {
throw { error: 'missing_token' };
map(
(
tokenOrResponse: string | GetTokenSilentlyVerboseResponse | undefined
) => {
// spa-js returns undefined when cacheMode is 'cache-only' with no
// cached entry, or when an IPSIE session_expiry ceiling is reached.
if (!tokenOrResponse) {
throw { error: 'missing_token' };
}
// Extract access_token from detailed response when detailedResponse: true
if (typeof tokenOrResponse === 'string') return tokenOrResponse;
return tokenOrResponse.access_token;
}
// Extract access_token from detailed response when detailedResponse: true
if (typeof tokenOrResponse === 'string') return tokenOrResponse;
return tokenOrResponse.access_token;
}),
),
tap((token) => this.authState.setAccessToken(token)),
catchError((error) => {
this.authState.refresh();
Expand Down
13 changes: 6 additions & 7 deletions projects/auth0-angular/src/lib/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,14 +252,16 @@ export class AuthService<TAppState extends AppState = AppState>
*/
getAccessTokenSilently(
options: GetTokenSilentlyOptions & { detailedResponse: true }
): Observable<GetTokenSilentlyVerboseResponse>;
): Observable<GetTokenSilentlyVerboseResponse | undefined>;

/**
* Fetches a new access token and returns it.
*
* @param options The options for configuring the token fetch.
*/
getAccessTokenSilently(options?: GetTokenSilentlyOptions): Observable<string>;
getAccessTokenSilently(
options?: GetTokenSilentlyOptions
): Observable<string | undefined>;

/**
* ```js
Expand Down Expand Up @@ -290,7 +292,7 @@ export class AuthService<TAppState extends AppState = AppState>
*/
getAccessTokenSilently(
options: GetTokenSilentlyOptions = {}
): Observable<string | GetTokenSilentlyVerboseResponse> {
): Observable<string | GetTokenSilentlyVerboseResponse | undefined> {
Comment thread
coderabbitai[bot] marked this conversation as resolved.
return of(this.auth0Client).pipe(
concatMap((client) =>
options.detailedResponse === true
Expand Down Expand Up @@ -577,10 +579,7 @@ export class AuthService<TAppState extends AppState = AppState>
updateAuthenticationMethod: (
id: string,
data: UpdateAuthenticationMethodRequest
) =>
from(
this.auth0Client.myAccount.updateAuthenticationMethod(id, data)
),
) => from(this.auth0Client.myAccount.updateAuthenticationMethod(id, data)),
enrollmentChallenge: (options: EnrollmentChallengeOptions) =>
from(this.auth0Client.myAccount.enrollmentChallenge(options)),
enrollmentVerify: (options: EnrollmentVerifyOptions) =>
Expand Down