Skip to content

Commit 321bd85

Browse files
Use openUrl instead of onRedirect (#396)
* Use openUrl instead of onRedirect * update lock file * fix ci * update typedoc to show externals
1 parent 9290fe3 commit 321bd85

File tree

10 files changed

+29
-21
lines changed

10 files changed

+29
-21
lines changed

angular.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"prefix": "lib",
1111
"architect": {
1212
"build": {
13-
"builder": "@angular-devkit/build-ng-packagr:build",
13+
"builder": "@angular-devkit/build-angular:ng-packagr",
1414
"options": {
1515
"tsConfig": "projects/auth0-angular/tsconfig.lib.json",
1616
"project": "projects/auth0-angular/ng-package.json"

package-lock.json

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
},
4242
"devDependencies": {
4343
"@angular-devkit/build-angular": "^13.3.9",
44-
"@angular-devkit/build-ng-packagr": "^0.1000.8",
4544
"@angular-eslint/builder": "13.5.0",
4645
"@angular-eslint/eslint-plugin": "13.5.0",
4746
"@angular-eslint/eslint-plugin-template": "13.5.0",

projects/auth0-angular/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
},
3333
"dependencies": {
3434
"tslib": "^2.0.0",
35-
"@auth0/auth0-spa-js": "^1.22.0"
35+
"@auth0/auth0-spa-js": "^2.0.1"
3636
},
3737
"schematics": "./schematics/collection.json"
3838
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { RedirectLoginOptions as SPARedirectLoginOptions, LogoutOptions as SPALogoutOptions } from '@auth0/auth0-spa-js';
2+
3+
// eslint-disable-next-line @typescript-eslint/no-empty-interface
4+
export interface RedirectLoginOptions<TAppState> extends Omit<SPARedirectLoginOptions<TAppState>, 'onRedirect'> {}
5+
6+
// eslint-disable-next-line @typescript-eslint/no-empty-interface
7+
export interface LogoutOptions extends Omit<SPALogoutOptions, 'onRedirect'> {}
8+

projects/auth0-angular/src/lib/auth.service.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ describe('AuthService', () => {
298298
false
299299
);
300300
service.logout({
301-
onRedirect: async () => {},
301+
openUrl: false,
302302
});
303303
});
304304
});
@@ -440,7 +440,7 @@ describe('AuthService', () => {
440440
false
441441
);
442442
service.logout({
443-
onRedirect: async () => {},
443+
openUrl: false,
444444
});
445445
});
446446
});
@@ -713,7 +713,7 @@ describe('AuthService', () => {
713713

714714
it('should reset the authentication state when passing `localOnly` to logout', (done) => {
715715
const options = {
716-
onRedirect: async () => {
716+
openUrl: async () => {
717717
((auth0Client.isAuthenticated as unknown) as jest.SpyInstance).mockResolvedValue(
718718
false
719719
);

projects/auth0-angular/src/lib/auth.service.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,12 @@ import { Injectable, Inject, OnDestroy } from '@angular/core';
22

33
import {
44
Auth0Client,
5-
RedirectLoginOptions,
65
PopupLoginOptions,
76
PopupConfigOptions,
8-
LogoutOptions,
97
GetTokenSilentlyOptions,
108
GetTokenWithPopupOptions,
119
RedirectLoginResult,
1210
GetTokenSilentlyVerboseResponse,
13-
User,
14-
IdToken,
1511
} from '@auth0/auth0-spa-js';
1612

1713
import {
@@ -39,6 +35,7 @@ import { Auth0ClientService } from './auth.client';
3935
import { AbstractNavigator } from './abstract-navigator';
4036
import { AuthClientConfig, AppState } from './auth.config';
4137
import { AuthState } from './auth.state';
38+
import { LogoutOptions, RedirectLoginOptions } from '../interfaces';
4239

4340
@Injectable({
4441
providedIn: 'root',
@@ -176,8 +173,8 @@ export class AuthService<TAppState extends AppState = AppState>
176173
* Clears the application session and performs a redirect to `/v2/logout`, using
177174
* the parameters provided as arguments, to clear the Auth0 session.
178175
* If the `federated` option is specified it also clears the Identity Provider session.
179-
* If the `localOnly` option is specified, it only clears the application session.
180-
* It is invalid to set both the `federated` and `localOnly` options to `true`,
176+
* If the `openUrl` option is set to false, it only clears the application session.
177+
* It is invalid to set both the `federated` to true and `openUrl` to `false`,
181178
* and an error will be thrown if you do.
182179
* [Read more about how Logout works at Auth0](https://auth0.com/docs/logout).
183180
*
@@ -186,7 +183,7 @@ export class AuthService<TAppState extends AppState = AppState>
186183
logout(options?: LogoutOptions): Observable<void> {
187184
return from(
188185
this.auth0Client.logout(options).then(() => {
189-
if (options?.onRedirect) {
186+
if (options?.openUrl === false || options?.openUrl) {
190187
this.authState.refresh();
191188
}
192189
})

projects/playground/src/app/app.component.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ describe('AppComponent', () => {
116116
fixture.detectChanges();
117117

118118
expect(authMock.logout).toHaveBeenCalledWith({
119-
onRedirect: undefined,
119+
openUrl: undefined,
120120
logoutParams: {
121121
federated: false,
122122
returnTo: 'http://localhost',
@@ -134,7 +134,7 @@ describe('AppComponent', () => {
134134
fixture.detectChanges();
135135

136136
expect(authMock.logout).toHaveBeenCalledWith({
137-
onRedirect: undefined,
137+
openUrl: undefined,
138138
logoutParams: {
139139
federated: true,
140140
returnTo: 'http://localhost',
@@ -153,7 +153,7 @@ describe('AppComponent', () => {
153153

154154
expect(authMock.logout).toHaveBeenCalledWith(
155155
expect.objectContaining({
156-
onRedirect: expect.any(Function),
156+
openUrl: false,
157157
logoutParams: {
158158
federated: false,
159159
returnTo: 'http://localhost',

projects/playground/src/app/app.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import { FormGroup, FormControl } from '@angular/forms';
44
import { AuthService } from '../../../auth0-angular/src/lib/auth.service';
55
import { iif } from 'rxjs';
66
import { first } from 'rxjs/operators';
7-
import { LogoutOptions } from '@auth0/auth0-spa-js';
87
import { DOCUMENT } from '@angular/common';
98
import { HttpClient } from '@angular/common/http';
9+
import { LogoutOptions } from 'projects/auth0-angular/src/interfaces';
1010

1111
@Component({
1212
selector: 'app-root',
@@ -98,7 +98,7 @@ export class AppComponent implements OnInit {
9898
launchLogout(): void {
9999
const formOptions = this.logoutOptionsForm.value;
100100
const options: LogoutOptions = {
101-
onRedirect: formOptions.localOnly === true ? async () => {} : undefined,
101+
openUrl: formOptions.localOnly === true ? false : undefined,
102102
logoutParams: {
103103
federated: formOptions.federated === true,
104104
returnTo: this.doc.location.origin,

typedoc.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,13 @@
44
"exclude": ["**/*.spec.ts"],
55
"tsconfig": "./projects/auth0-angular/tsconfig.lib.json",
66
"out": "docs",
7-
"excludeExternals": true,
7+
"excludeExternals": false,
88
"excludePrivate": true,
99
"hideGenerator": true,
10-
"readme": "./README.md"
10+
"readme": "./README.md",
11+
"visibilityFilters": {
12+
"protected": false,
13+
"inherited": true,
14+
"external": true,
15+
}
1116
}

0 commit comments

Comments
 (0)