@@ -67,27 +67,27 @@ export class OAuthService extends AuthConfig {
67
67
*/
68
68
public state ? = '' ;
69
69
70
- private eventsSubject : Subject < OAuthEvent > = new Subject < OAuthEvent > ( ) ;
71
- private discoveryDocumentLoadedSubject : Subject < object > = new Subject < object > ( ) ;
72
- private silentRefreshPostMessageEventListener : EventListener ;
73
- private grantTypesSupported : Array < string > = [ ] ;
74
- private _storage : OAuthStorage ;
75
- private accessTokenTimeoutSubscription : Subscription ;
76
- private idTokenTimeoutSubscription : Subscription ;
77
- private sessionCheckEventListener : EventListener ;
78
- private jwksUri : string ;
79
- private sessionCheckTimer : any ;
80
- private silentRefreshSubject : string ;
81
- private inImplicitFlow = false ;
70
+ protected eventsSubject : Subject < OAuthEvent > = new Subject < OAuthEvent > ( ) ;
71
+ protected discoveryDocumentLoadedSubject : Subject < object > = new Subject < object > ( ) ;
72
+ protected silentRefreshPostMessageEventListener : EventListener ;
73
+ protected grantTypesSupported : Array < string > = [ ] ;
74
+ protected _storage : OAuthStorage ;
75
+ protected accessTokenTimeoutSubscription : Subscription ;
76
+ protected idTokenTimeoutSubscription : Subscription ;
77
+ protected sessionCheckEventListener : EventListener ;
78
+ protected jwksUri : string ;
79
+ protected sessionCheckTimer : any ;
80
+ protected silentRefreshSubject : string ;
81
+ protected inImplicitFlow = false ;
82
82
83
83
constructor (
84
- private ngZone : NgZone ,
85
- private http : HttpClient ,
84
+ protected ngZone : NgZone ,
85
+ protected http : HttpClient ,
86
86
@Optional ( ) storage : OAuthStorage ,
87
87
@Optional ( ) tokenValidationHandler : ValidationHandler ,
88
- @Optional ( ) private config : AuthConfig ,
89
- private urlHelper : UrlHelperService ,
90
- private logger : OAuthLogger ,
88
+ @Optional ( ) protected config : AuthConfig ,
89
+ protected urlHelper : UrlHelperService ,
90
+ protected logger : OAuthLogger ,
91
91
) {
92
92
super ( ) ;
93
93
@@ -138,19 +138,19 @@ export class OAuthService extends AuthConfig {
138
138
this . configChanged ( ) ;
139
139
}
140
140
141
- private configChanged ( ) : void { }
141
+ protected configChanged ( ) : void { }
142
142
143
143
public restartSessionChecksIfStillLoggedIn ( ) : void {
144
144
if ( this . hasValidIdToken ( ) ) {
145
145
this . initSessionCheck ( ) ;
146
146
}
147
147
}
148
148
149
- private restartRefreshTimerIfStillLoggedIn ( ) : void {
149
+ protected restartRefreshTimerIfStillLoggedIn ( ) : void {
150
150
this . setupExpirationTimers ( ) ;
151
151
}
152
152
153
- private setupSessionCheck ( ) {
153
+ protected setupSessionCheck ( ) {
154
154
this . events . pipe ( filter ( e => e . type === 'token_received' ) ) . subscribe ( e => {
155
155
this . initSessionCheck ( ) ;
156
156
} ) ;
@@ -203,13 +203,13 @@ export class OAuthService extends AuthConfig {
203
203
} ) ;
204
204
}
205
205
206
- private debug ( ...args ) : void {
206
+ protected debug ( ...args ) : void {
207
207
if ( this . showDebugInformation ) {
208
208
this . logger . debug . apply ( console , args ) ;
209
209
}
210
210
}
211
211
212
- private validateUrlFromDiscoveryDocument ( url : string ) : string [ ] {
212
+ protected validateUrlFromDiscoveryDocument ( url : string ) : string [ ] {
213
213
const errors : string [ ] = [ ] ;
214
214
const httpsCheck = this . validateUrlForHttps ( url ) ;
215
215
const issuerCheck = this . validateUrlAgainstIssuer ( url ) ;
@@ -230,7 +230,7 @@ export class OAuthService extends AuthConfig {
230
230
return errors ;
231
231
}
232
232
233
- private validateUrlForHttps ( url : string ) : boolean {
233
+ protected validateUrlForHttps ( url : string ) : boolean {
234
234
if ( ! url ) {
235
235
return true ;
236
236
}
@@ -252,7 +252,7 @@ export class OAuthService extends AuthConfig {
252
252
return lcUrl . startsWith ( 'https://' ) ;
253
253
}
254
254
255
- private validateUrlAgainstIssuer ( url : string ) {
255
+ protected validateUrlAgainstIssuer ( url : string ) {
256
256
if ( ! this . strictDiscoveryDocumentValidation ) {
257
257
return true ;
258
258
}
@@ -262,7 +262,7 @@ export class OAuthService extends AuthConfig {
262
262
return url . toLowerCase ( ) . startsWith ( this . issuer . toLowerCase ( ) ) ;
263
263
}
264
264
265
- private setupRefreshTimer ( ) : void {
265
+ protected setupRefreshTimer ( ) : void {
266
266
if ( typeof window === 'undefined' ) {
267
267
this . debug ( 'timer not supported on this plattform' ) ;
268
268
return ;
@@ -281,7 +281,7 @@ export class OAuthService extends AuthConfig {
281
281
} ) ;
282
282
}
283
283
284
- private setupExpirationTimers ( ) : void {
284
+ protected setupExpirationTimers ( ) : void {
285
285
const idTokenExp = this . getIdTokenExpiration ( ) || Number . MAX_VALUE ;
286
286
const accessTokenExp = this . getAccessTokenExpiration ( ) || Number . MAX_VALUE ;
287
287
const useAccessTokenExp = accessTokenExp <= idTokenExp ;
@@ -295,7 +295,7 @@ export class OAuthService extends AuthConfig {
295
295
}
296
296
}
297
297
298
- private setupAccessTokenTimer ( ) : void {
298
+ protected setupAccessTokenTimer ( ) : void {
299
299
const expiration = this . getAccessTokenExpiration ( ) ;
300
300
const storedAt = this . getAccessTokenStoredAt ( ) ;
301
301
const timeout = this . calcTimeout ( storedAt , expiration ) ;
@@ -313,7 +313,7 @@ export class OAuthService extends AuthConfig {
313
313
} ) ;
314
314
}
315
315
316
- private setupIdTokenTimer ( ) : void {
316
+ protected setupIdTokenTimer ( ) : void {
317
317
const expiration = this . getIdTokenExpiration ( ) ;
318
318
const storedAt = this . getIdTokenStoredAt ( ) ;
319
319
const timeout = this . calcTimeout ( storedAt , expiration ) ;
@@ -331,19 +331,19 @@ export class OAuthService extends AuthConfig {
331
331
} ) ;
332
332
}
333
333
334
- private clearAccessTokenTimer ( ) : void {
334
+ protected clearAccessTokenTimer ( ) : void {
335
335
if ( this . accessTokenTimeoutSubscription ) {
336
336
this . accessTokenTimeoutSubscription . unsubscribe ( ) ;
337
337
}
338
338
}
339
339
340
- private clearIdTokenTimer ( ) : void {
340
+ protected clearIdTokenTimer ( ) : void {
341
341
if ( this . idTokenTimeoutSubscription ) {
342
342
this . idTokenTimeoutSubscription . unsubscribe ( ) ;
343
343
}
344
344
}
345
345
346
- private calcTimeout ( storedAt : number , expiration : number ) : number {
346
+ protected calcTimeout ( storedAt : number , expiration : number ) : number {
347
347
const delta = ( expiration - storedAt ) * this . timeoutFactor ;
348
348
return delta ;
349
349
}
@@ -449,7 +449,7 @@ export class OAuthService extends AuthConfig {
449
449
} ) ;
450
450
}
451
451
452
- private loadJwks ( ) : Promise < object > {
452
+ protected loadJwks ( ) : Promise < object > {
453
453
return new Promise < object > ( ( resolve , reject ) => {
454
454
if ( this . jwksUri ) {
455
455
this . http . get ( this . jwksUri ) . subscribe (
@@ -474,7 +474,7 @@ export class OAuthService extends AuthConfig {
474
474
} ) ;
475
475
}
476
476
477
- private validateDiscoveryDocument ( doc : OidcDiscoveryDoc ) : boolean {
477
+ protected validateDiscoveryDocument ( doc : OidcDiscoveryDoc ) : boolean {
478
478
let errors : string [ ] ;
479
479
480
480
if ( ! this . skipIssuerCheck && doc . issuer !== this . issuer ) {
@@ -764,7 +764,7 @@ export class OAuthService extends AuthConfig {
764
764
} ) ;
765
765
}
766
766
767
- private removeSilentRefreshEventListener ( ) : void {
767
+ protected removeSilentRefreshEventListener ( ) : void {
768
768
if ( this . silentRefreshPostMessageEventListener ) {
769
769
window . removeEventListener (
770
770
'message' ,
@@ -774,7 +774,7 @@ export class OAuthService extends AuthConfig {
774
774
}
775
775
}
776
776
777
- private setupSilentRefreshEventListener ( ) : void {
777
+ protected setupSilentRefreshEventListener ( ) : void {
778
778
this . removeSilentRefreshEventListener ( ) ;
779
779
780
780
this . silentRefreshPostMessageEventListener = ( e : MessageEvent ) => {
@@ -892,7 +892,7 @@ export class OAuthService extends AuthConfig {
892
892
. toPromise ( ) ;
893
893
}
894
894
895
- private canPerformSessionCheck ( ) : boolean {
895
+ protected canPerformSessionCheck ( ) : boolean {
896
896
if ( ! this . sessionChecksEnabled ) {
897
897
return false ;
898
898
}
@@ -916,7 +916,7 @@ export class OAuthService extends AuthConfig {
916
916
return true ;
917
917
}
918
918
919
- private setupSessionCheckEventListener ( ) : void {
919
+ protected setupSessionCheckEventListener ( ) : void {
920
920
this . removeSessionCheckEventListener ( ) ;
921
921
922
922
this . sessionCheckEventListener = ( e : MessageEvent ) => {
@@ -961,11 +961,11 @@ export class OAuthService extends AuthConfig {
961
961
} ) ;
962
962
}
963
963
964
- private handleSessionUnchanged ( ) : void {
964
+ protected handleSessionUnchanged ( ) : void {
965
965
this . debug ( 'session check' , 'session unchanged' ) ;
966
966
}
967
967
968
- private handleSessionChange ( ) : void {
968
+ protected handleSessionChange ( ) : void {
969
969
/* events: session_changed, relogin, stopTimer, logged_out*/
970
970
this . eventsSubject . next ( new OAuthInfoEvent ( 'session_changed' ) ) ;
971
971
this . stopSessionCheckTimer ( ) ;
@@ -980,7 +980,7 @@ export class OAuthService extends AuthConfig {
980
980
}
981
981
}
982
982
983
- private waitForSilentRefreshAfterSessionChange ( ) {
983
+ protected waitForSilentRefreshAfterSessionChange ( ) {
984
984
this . events
985
985
. pipe (
986
986
filter (
@@ -1000,19 +1000,19 @@ export class OAuthService extends AuthConfig {
1000
1000
} ) ;
1001
1001
}
1002
1002
1003
- private handleSessionError ( ) : void {
1003
+ protected handleSessionError ( ) : void {
1004
1004
this . stopSessionCheckTimer ( ) ;
1005
1005
this . eventsSubject . next ( new OAuthInfoEvent ( 'session_error' ) ) ;
1006
1006
}
1007
1007
1008
- private removeSessionCheckEventListener ( ) : void {
1008
+ protected removeSessionCheckEventListener ( ) : void {
1009
1009
if ( this . sessionCheckEventListener ) {
1010
1010
window . removeEventListener ( 'message' , this . sessionCheckEventListener ) ;
1011
1011
this . sessionCheckEventListener = null ;
1012
1012
}
1013
1013
}
1014
1014
1015
- private initSessionCheck ( ) : void {
1015
+ protected initSessionCheck ( ) : void {
1016
1016
if ( ! this . canPerformSessionCheck ( ) ) {
1017
1017
return ;
1018
1018
}
@@ -1035,7 +1035,7 @@ export class OAuthService extends AuthConfig {
1035
1035
this . startSessionCheckTimer ( ) ;
1036
1036
}
1037
1037
1038
- private startSessionCheckTimer ( ) : void {
1038
+ protected startSessionCheckTimer ( ) : void {
1039
1039
this . stopSessionCheckTimer ( ) ;
1040
1040
this . ngZone . runOutsideAngular ( ( ) => {
1041
1041
this . sessionCheckTimer = setInterval (
@@ -1045,14 +1045,14 @@ export class OAuthService extends AuthConfig {
1045
1045
} ) ;
1046
1046
}
1047
1047
1048
- private stopSessionCheckTimer ( ) : void {
1048
+ protected stopSessionCheckTimer ( ) : void {
1049
1049
if ( this . sessionCheckTimer ) {
1050
1050
clearInterval ( this . sessionCheckTimer ) ;
1051
1051
this . sessionCheckTimer = null ;
1052
1052
}
1053
1053
}
1054
1054
1055
- private checkSession ( ) : void {
1055
+ protected checkSession ( ) : void {
1056
1056
const iframe : any = document . getElementById ( this . sessionCheckIFrameName ) ;
1057
1057
1058
1058
if ( ! iframe ) {
@@ -1072,7 +1072,7 @@ export class OAuthService extends AuthConfig {
1072
1072
iframe . contentWindow . postMessage ( message , this . issuer ) ;
1073
1073
}
1074
1074
1075
- private createLoginUrl (
1075
+ protected createLoginUrl (
1076
1076
state = '' ,
1077
1077
loginHint = '' ,
1078
1078
customRedirectUri = '' ,
@@ -1225,7 +1225,7 @@ export class OAuthService extends AuthConfig {
1225
1225
}
1226
1226
}
1227
1227
1228
- private callOnTokenReceivedIfExists ( options : LoginOptions ) : void {
1228
+ protected callOnTokenReceivedIfExists ( options : LoginOptions ) : void {
1229
1229
const that = this ;
1230
1230
if ( options . onTokenReceived ) {
1231
1231
const tokenParams = {
@@ -1238,7 +1238,7 @@ export class OAuthService extends AuthConfig {
1238
1238
}
1239
1239
}
1240
1240
1241
- private storeAccessTokenResponse (
1241
+ protected storeAccessTokenResponse (
1242
1242
accessToken : string ,
1243
1243
refreshToken : string ,
1244
1244
expiresIn : number ,
@@ -1398,7 +1398,7 @@ export class OAuthService extends AuthConfig {
1398
1398
} ) ;
1399
1399
}
1400
1400
1401
- private validateNonceForAccessToken (
1401
+ protected validateNonceForAccessToken (
1402
1402
accessToken : string ,
1403
1403
nonceInState : string
1404
1404
) : boolean {
@@ -1426,7 +1426,7 @@ export class OAuthService extends AuthConfig {
1426
1426
return this . _storage . getItem ( 'session_state' ) ;
1427
1427
}
1428
1428
1429
- private handleLoginError ( options : LoginOptions , parts : object ) : void {
1429
+ protected handleLoginError ( options : LoginOptions , parts : object ) : void {
1430
1430
if ( options . onLoginError ) {
1431
1431
options . onLoginError ( parts ) ;
1432
1432
}
@@ -1606,7 +1606,7 @@ export class OAuthService extends AuthConfig {
1606
1606
: null ;
1607
1607
}
1608
1608
1609
- private padBase64 ( base64data ) : string {
1609
+ protected padBase64 ( base64data ) : string {
1610
1610
while ( base64data . length % 4 !== 0 ) {
1611
1611
base64data += '=' ;
1612
1612
}
@@ -1635,11 +1635,11 @@ export class OAuthService extends AuthConfig {
1635
1635
return parseInt ( this . _storage . getItem ( 'expires_at' ) , 10 ) ;
1636
1636
}
1637
1637
1638
- private getAccessTokenStoredAt ( ) : number {
1638
+ protected getAccessTokenStoredAt ( ) : number {
1639
1639
return parseInt ( this . _storage . getItem ( 'access_token_stored_at' ) , 10 ) ;
1640
1640
}
1641
1641
1642
- private getIdTokenStoredAt ( ) : number {
1642
+ protected getIdTokenStoredAt ( ) : number {
1643
1643
return parseInt ( this . _storage . getItem ( 'id_token_stored_at' ) , 10 ) ;
1644
1644
}
1645
1645
@@ -1797,7 +1797,7 @@ export class OAuthService extends AuthConfig {
1797
1797
} ) ;
1798
1798
}
1799
1799
1800
- private async checkAtHash ( params : ValidationParams ) : Promise < boolean > {
1800
+ protected async checkAtHash ( params : ValidationParams ) : Promise < boolean > {
1801
1801
if ( ! this . tokenValidationHandler ) {
1802
1802
this . logger . warn (
1803
1803
'No tokenValidationHandler configured. Cannot check at_hash.'
@@ -1807,7 +1807,7 @@ export class OAuthService extends AuthConfig {
1807
1807
return this . tokenValidationHandler . validateAtHash ( params ) ;
1808
1808
}
1809
1809
1810
- private checkSignature ( params : ValidationParams ) : Promise < any > {
1810
+ protected checkSignature ( params : ValidationParams ) : Promise < any > {
1811
1811
if ( ! this . tokenValidationHandler ) {
1812
1812
this . logger . warn (
1813
1813
'No tokenValidationHandler configured. Cannot check signature.'
0 commit comments