Skip to content

Commit ed1a6cd

Browse files
author
stephaniekatterwe
committed
Merge branch 'main' into feature/2079#wildcards-in-secureRoutes
# Conflicts: # projects/angular-auth-oidc-client/src/lib/interceptor/closest-matching-route.service.spec.ts
2 parents 9948e24 + e099dee commit ed1a6cd

File tree

85 files changed

+12863
-13623
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+12863
-13623
lines changed

.eslintrc.json

Lines changed: 50 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,57 @@
2222
"format": ["PascalCase"]
2323
}
2424
],
25+
"@typescript-eslint/member-ordering": [
26+
"error",
27+
{
28+
"default": {
29+
"memberTypes": [
30+
// Static members
31+
"public-static-field",
32+
"protected-static-field",
33+
"private-static-field",
34+
"#private-static-field",
35+
36+
// Readonly fields (grouped)
37+
"private-instance-readonly-field",
38+
39+
// Constructors
40+
"public-constructor",
41+
"protected-constructor",
42+
"private-constructor",
43+
44+
// Methods
45+
"public-instance-method",
46+
"protected-instance-method",
47+
"private-instance-method"
48+
]
49+
}
50+
}
51+
],
2552
"max-len": "off",
26-
"no-useless-constructor": "off",
27-
"lines-between-class-members": ["error", "always"],
28-
"newline-after-var": ["error", "always"],
53+
"lines-between-class-members": [
54+
"error",
55+
{
56+
"enforce": [
57+
{
58+
"blankLine": "always",
59+
"prev": "method",
60+
"next": "method"
61+
},
62+
{
63+
"blankLine": "always",
64+
"prev": "field",
65+
"next": "method"
66+
}
67+
]
68+
}
69+
],
70+
"padding-line-between-statements": [
71+
"error",
72+
{ "blankLine": "always", "prev": ["const", "let", "var"], "next": "*" },
73+
{ "blankLine": "never", "prev": ["const", "let", "var"], "next": ["const", "let", "var"] },
74+
{ "blankLine": "always", "prev": "*", "next": "return" }
75+
],
2976
"one-var": ["error", "never"],
3077
"@typescript-eslint/no-useless-constructor": ["error"],
3178
"@typescript-eslint/prefer-readonly": ["error"],
@@ -35,15 +82,13 @@
3582
"no-case-declarations": ["error"],
3683
"no-empty": ["error"],
3784
"@typescript-eslint/no-empty-function": ["error"],
38-
"no-unused-vars": "off",
3985
"@typescript-eslint/ban-types": ["error"],
4086
"no-useless-escape": ["error"],
4187
"no-prototype-builtins": ["error"],
4288
"prefer-spread": ["error"],
4389
"@typescript-eslint/no-explicit-any": "off",
4490
"@typescript-eslint/typedef": ["error"],
4591
"@typescript-eslint/explicit-function-return-type": ["error"],
46-
"newline-before-return": ["error"],
4792
"@typescript-eslint/no-unused-vars": [
4893
"error",
4994
{

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"build-lib-prod": "ng build angular-auth-oidc-client --configuration production && npm run schematics-build && npm run copy-files",
1919
"test-lib": "ng test angular-auth-oidc-client --code-coverage",
2020
"test-lib-ci": "ng test angular-auth-oidc-client --watch=false --browsers=ChromeHeadlessNoSandbox --code-coverage",
21+
"lint-lib-fix": "ng lint angular-auth-oidc-client --fix",
2122
"lint-lib": "ng lint angular-auth-oidc-client",
2223
"pack-lib": "npm run build-lib-prod && npm pack ./dist/angular-auth-oidc-client",
2324
"publish-lib": "npm run build-lib-prod && npm publish ./dist/angular-auth-oidc-client",

projects/angular-auth-oidc-client/src/lib/api/data.service.ts

Lines changed: 63 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,63 @@
1-
import { HttpHeaders, HttpParams } from '@angular/common/http';
2-
import { Injectable, inject } from '@angular/core';
3-
import { Observable } from 'rxjs';
4-
import { OpenIdConfiguration } from '../config/openid-configuration';
5-
import { HttpBaseService } from './http-base.service';
6-
7-
const NGSW_CUSTOM_PARAM = 'ngsw-bypass';
8-
9-
@Injectable({ providedIn: 'root' })
10-
export class DataService {
11-
private readonly httpClient = inject(HttpBaseService);
12-
13-
get<T>(
14-
url: string,
15-
config: OpenIdConfiguration,
16-
token?: string
17-
): Observable<T> {
18-
const headers = this.prepareHeaders(token);
19-
const params = this.prepareParams(config);
20-
21-
return this.httpClient.get<T>(url, {
22-
headers,
23-
params,
24-
});
25-
}
26-
27-
post<T>(
28-
url: string | null,
29-
body: unknown,
30-
config: OpenIdConfiguration,
31-
headersParams?: HttpHeaders
32-
): Observable<T> {
33-
const headers = headersParams || this.prepareHeaders();
34-
const params = this.prepareParams(config);
35-
36-
return this.httpClient.post<T>(url ?? '', body, { headers, params });
37-
}
38-
39-
private prepareHeaders(token?: string): HttpHeaders {
40-
let headers = new HttpHeaders();
41-
42-
headers = headers.set('Accept', 'application/json');
43-
44-
if (!!token) {
45-
headers = headers.set(
46-
'Authorization',
47-
'Bearer ' + decodeURIComponent(token)
48-
);
49-
}
50-
51-
return headers;
52-
}
53-
54-
private prepareParams(config: OpenIdConfiguration): HttpParams {
55-
let params = new HttpParams();
56-
57-
const { ngswBypass } = config;
58-
59-
if (ngswBypass) {
60-
params = params.set(NGSW_CUSTOM_PARAM, '');
61-
}
62-
63-
return params;
64-
}
65-
}
1+
import { HttpHeaders, HttpParams } from '@angular/common/http';
2+
import { Injectable, inject } from '@angular/core';
3+
import { Observable } from 'rxjs';
4+
import { OpenIdConfiguration } from '../config/openid-configuration';
5+
import { HttpBaseService } from './http-base.service';
6+
7+
const NGSW_CUSTOM_PARAM = 'ngsw-bypass';
8+
9+
@Injectable({ providedIn: 'root' })
10+
export class DataService {
11+
private readonly httpClient = inject(HttpBaseService);
12+
13+
get<T>(
14+
url: string,
15+
config: OpenIdConfiguration,
16+
token?: string
17+
): Observable<T> {
18+
const headers = this.prepareHeaders(token);
19+
const params = this.prepareParams(config);
20+
21+
return this.httpClient.get<T>(url, {
22+
headers,
23+
params,
24+
});
25+
}
26+
27+
post<T>(
28+
url: string | null,
29+
body: unknown,
30+
config: OpenIdConfiguration,
31+
headersParams?: HttpHeaders
32+
): Observable<T> {
33+
const headers = headersParams || this.prepareHeaders();
34+
const params = this.prepareParams(config);
35+
36+
return this.httpClient.post<T>(url ?? '', body, { headers, params });
37+
}
38+
39+
private prepareHeaders(token?: string): HttpHeaders {
40+
let headers = new HttpHeaders();
41+
42+
headers = headers.set('Accept', 'application/json');
43+
44+
if (!!token) {
45+
headers = headers.set(
46+
'Authorization',
47+
'Bearer ' + decodeURIComponent(token)
48+
);
49+
}
50+
51+
return headers;
52+
}
53+
54+
private prepareParams(config: OpenIdConfiguration): HttpParams {
55+
let params = new HttpParams(); const { ngswBypass } = config;
56+
57+
if (ngswBypass) {
58+
params = params.set(NGSW_CUSTOM_PARAM, '');
59+
}
60+
61+
return params;
62+
}
63+
}

projects/angular-auth-oidc-client/src/lib/auth-state/auth-state.service.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Injectable, inject } from '@angular/core';
1+
import { inject, Injectable } from '@angular/core';
22
import { BehaviorSubject, Observable, throwError } from 'rxjs';
33
import { distinctUntilChanged } from 'rxjs/operators';
44
import { OpenIdConfiguration } from '../config/openid-configuration';
@@ -21,11 +21,8 @@ export class AuthStateService {
2121
private readonly storagePersistenceService = inject(
2222
StoragePersistenceService
2323
);
24-
2524
private readonly loggerService = inject(LoggerService);
26-
2725
private readonly publicEventsService = inject(PublicEventsService);
28-
2926
private readonly tokenValidationService = inject(TokenValidationService);
3027

3128
private readonly authenticatedInternal$ =
@@ -190,7 +187,6 @@ export class AuthStateService {
190187
}
191188
const tokenToCheck =
192189
this.storagePersistenceService.getIdToken(configuration);
193-
194190
const idTokenExpired = this.tokenValidationService.hasIdTokenExpired(
195191
tokenToCheck,
196192
configuration,
@@ -221,7 +217,6 @@ export class AuthStateService {
221217
configuration,
222218
renewTimeBeforeTokenExpiresInSeconds
223219
);
224-
225220
const hasExpired = !accessTokenHasNotExpired;
226221

227222
if (hasExpired) {
@@ -320,9 +315,8 @@ export class AuthStateService {
320315
configId: config.configId ?? '',
321316
isAuthenticated: this.isAuthenticated(config),
322317
}));
323-
324318
const isAuthenticated = allConfigsAuthenticated.every(
325-
(x) => !!x.isAuthenticated
319+
(x) => x.isAuthenticated
326320
);
327321

328322
return { allConfigsAuthenticated, isAuthenticated };

0 commit comments

Comments
 (0)