Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Housekeeping] Fix TSLint issues and upgrade dependencies #17

Merged
merged 4 commits into from
Jul 29, 2020
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
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ jobs:
- node/with-cache:
steps:
- run: npm install
- run: npm run lint -- auth0-angular
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lbalmaceda This command just runs linting on the auth0-angular project.

What do you think about running this on the playground too in the future (i.e. all projects) by just using npm run lint? I think it would be a good idea. We could change it now but there are a few linting problems on the playground currently, so maybe something to add in once you've had a chance later to have a look at them. You can see the problems locally by running npm run lint.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I saw them as well. I think running this goes a bit along with the lgtm check (missing until we make the repo public).

- run: npm run test-ci
- run:
name: Upload coverage
Expand Down
6 changes: 6 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"recommendations": [
"ms-vscode.vscode-typescript-tslint-plugin",
"esbenp.prettier-vscode"
]
}
2,226 changes: 942 additions & 1,284 deletions package-lock.json

Large diffs are not rendered by default.

32 changes: 16 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,27 @@
},
"private": true,
"dependencies": {
"@angular/animations": "~10.0.2",
"@angular/common": "~10.0.2",
"@angular/compiler": "~10.0.2",
"@angular/core": "~10.0.2",
"@angular/platform-browser": "~10.0.2",
"@angular/platform-browser-dynamic": "~10.0.2",
"@angular/router": "~10.0.2",
"@auth0/auth0-spa-js": "^1.10.0",
"@angular/animations": "^10.0.5",
"@angular/common": "^10.0.5",
"@angular/compiler": "^10.0.5",
"@angular/core": "^10.0.5",
"@angular/platform-browser": "^10.0.5",
"@angular/platform-browser-dynamic": "^10.0.5",
"@angular/router": "^10.0.5",
"@auth0/auth0-spa-js": "^1.11.0",
"rxjs": "~6.5.5",
"tslib": "^2.0.0",
"zone.js": "~0.10.3"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.1000.1",
"@angular-devkit/build-ng-packagr": "~0.1000.1",
"@angular/cli": "~10.0.1",
"@angular/compiler-cli": "~10.0.2",
"@angular-devkit/build-angular": "^0.1000.4",
"@angular-devkit/build-ng-packagr": "^0.1000.4",
"@angular/cli": "^10.0.4",
"@angular/compiler-cli": "^10.0.5",
"@types/jasmine": "~3.5.0",
"@types/jasminewd2": "~2.0.3",
"@types/node": "^12.11.1",
"codecov": "^3.7.0",
"@types/node": "^12.12.53",
"codecov": "^3.7.2",
"codelyzer": "^6.0.0-next.1",
"husky": "^4.2.5",
"jasmine-core": "~3.5.0",
Expand All @@ -44,13 +44,13 @@
"karma-jasmine": "~3.3.0",
"karma-jasmine-html-reporter": "^1.5.0",
"karma-junit-reporter": "^2.0.1",
"ng-packagr": "^10.0.0",
"ng-packagr": "^10.0.3",
"prettier": "^2.0.5",
"pretty-quick": "^2.0.1",
"protractor": "~7.0.0",
"ts-node": "~8.3.0",
"tslint": "~6.1.0",
"typescript": "~3.9.5"
"typescript": "^3.9.7"
},
"prettier": {
"semi": true,
Expand Down
2 changes: 1 addition & 1 deletion projects/auth0-angular/src/lib/auth.client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Auth0Client } from '@auth0/auth0-spa-js';
import { AuthConfig } from './auth.config';

export class Auth0ClientFactory {
static createClient(config: AuthConfig) {
static createClient(config: AuthConfig): Auth0Client {
const { redirectUri, clientId, maxAge, ...rest } = config;

return new Auth0Client({
Expand Down
3 changes: 2 additions & 1 deletion projects/auth0-angular/src/lib/auth.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ export interface AuthConfig {
cacheLocation?: CacheLocation;

/**
* If true, refresh tokens are used to fetch new access tokens from the Auth0 server. If false, the legacy technique of using a hidden iframe and the `authorization_code` grant with `prompt=none` is used.
* If true, refresh tokens are used to fetch new access tokens from the Auth0 server.
* If false, the legacy technique of using a hidden iframe and the `authorization_code` grant with `prompt=none` is used.
* The default setting is `false`.
*
* **Note**: Use of refresh tokens must be enabled by an administrator on your Auth0 client application.
Expand Down
31 changes: 15 additions & 16 deletions projects/auth0-angular/src/lib/auth.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ describe('AuthService', () => {

it('should set isLoading$ in the correct sequence', (done) => {
const values = [];
const service = createService();

service.isLoading$.subscribe((loading) => {
values.push(loading);
Expand All @@ -102,7 +101,7 @@ describe('AuthService', () => {
});

it('should return `true` when the client is authenticated', (done) => {
(<jasmine.Spy>auth0Client.isAuthenticated).and.resolveTo(true);
(auth0Client.isAuthenticated as jasmine.Spy).and.resolveTo(true);

loaded(service).subscribe(() => {
service.isAuthenticated$.subscribe((value) => {
Expand All @@ -119,8 +118,8 @@ describe('AuthService', () => {
name: 'Test User',
};

(<jasmine.Spy>auth0Client.isAuthenticated).and.resolveTo(true);
(<jasmine.Spy>auth0Client.getUser).and.resolveTo(user);
(auth0Client.isAuthenticated as jasmine.Spy).and.resolveTo(true);
(auth0Client.getUser as jasmine.Spy).and.resolveTo(user);

service.user$.subscribe((value) => {
expect(value).toBe(user);
Expand All @@ -129,7 +128,7 @@ describe('AuthService', () => {
});

it('should get the user if not authenticated', (done) => {
(<jasmine.Spy>auth0Client.isAuthenticated).and.resolveTo(true);
(auth0Client.isAuthenticated as jasmine.Spy).and.resolveTo(true);

service.user$.subscribe((value) => {
expect(value).toBeFalsy();
Expand Down Expand Up @@ -173,33 +172,33 @@ describe('AuthService', () => {
});

it('should handle the callback when code and state are available', (done) => {
const service = createService();
const localService = createService();

loaded(service).subscribe(() => {
loaded(localService).subscribe(() => {
expect(auth0Client.handleRedirectCallback).toHaveBeenCalledTimes(1);
done();
});
});

it('should redirect to the correct route', (done) => {
const service = createService();
const localService = createService();

loaded(service).subscribe(() => {
loaded(localService).subscribe(() => {
expect(navigator.navigateByUrl).toHaveBeenCalledWith('/');
done();
});
});

it('should redirect to the route specified in appState', (done) => {
(<any>auth0Client.handleRedirectCallback).and.resolveTo({
(auth0Client.handleRedirectCallback as jasmine.Spy).and.resolveTo({
appState: {
target: '/test-route',
},
});

const service = createService();
const localService = createService();

loaded(service).subscribe(() => {
loaded(localService).subscribe(() => {
expect(navigator.navigateByUrl).toHaveBeenCalledWith('/test-route');
done();
});
Expand All @@ -220,8 +219,8 @@ describe('AuthService', () => {

it('should call `loginWithPopup`', (done) => {
loaded(service).subscribe(async () => {
(<jasmine.Spy>auth0Client.isAuthenticated).calls.reset();
(<jasmine.Spy>auth0Client.isAuthenticated).and.resolveTo(true);
(auth0Client.isAuthenticated as jasmine.Spy).calls.reset();
(auth0Client.isAuthenticated as jasmine.Spy).and.resolveTo(true);

service.loginWithPopup();

Expand All @@ -242,8 +241,8 @@ describe('AuthService', () => {
const config = {};

loaded(service).subscribe(() => {
(<jasmine.Spy>auth0Client.isAuthenticated).calls.reset();
(<jasmine.Spy>auth0Client.isAuthenticated).and.resolveTo(true);
(auth0Client.isAuthenticated as jasmine.Spy).calls.reset();
(auth0Client.isAuthenticated as jasmine.Spy).and.resolveTo(true);

service.loginWithPopup(options, config);

Expand Down
4 changes: 2 additions & 2 deletions projects/auth0-angular/src/lib/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export class AuthService implements OnDestroy {
/**
* Called when the service is destroyed
*/
ngOnDestroy() {
ngOnDestroy(): void {
// https://stackoverflow.com/a/41177163
this.ngUnsubscribe$.next();
this.ngUnsubscribe$.complete();
Expand Down Expand Up @@ -149,7 +149,7 @@ export class AuthService implements OnDestroy {
* and an error will be thrown if you do.
* [Read more about how Logout works at Auth0](https://auth0.com/docs/logout).
*
* @param options
* @param options The logout options
*/
logout(options?: LogoutOptions): void {
this.auth0Client.logout(options);
Expand Down
2 changes: 1 addition & 1 deletion projects/auth0-angular/src/lib/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ export const WindowService = new InjectionToken('Browser window');
/**
* Default window provider. Provides the actual `window` object.
*/
export function windowProvider() {
export function windowProvider(): Window {
return window;
}