@@ -67,27 +67,27 @@ export class OAuthService extends AuthConfig {
6767 */
6868 public state ? = '' ;
6969
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 ;
8282
8383 constructor (
84- private ngZone : NgZone ,
85- private http : HttpClient ,
84+ protected ngZone : NgZone ,
85+ protected http : HttpClient ,
8686 @Optional ( ) storage : OAuthStorage ,
8787 @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 ,
9191 ) {
9292 super ( ) ;
9393
@@ -138,19 +138,19 @@ export class OAuthService extends AuthConfig {
138138 this . configChanged ( ) ;
139139 }
140140
141- private configChanged ( ) : void { }
141+ protected configChanged ( ) : void { }
142142
143143 public restartSessionChecksIfStillLoggedIn ( ) : void {
144144 if ( this . hasValidIdToken ( ) ) {
145145 this . initSessionCheck ( ) ;
146146 }
147147 }
148148
149- private restartRefreshTimerIfStillLoggedIn ( ) : void {
149+ protected restartRefreshTimerIfStillLoggedIn ( ) : void {
150150 this . setupExpirationTimers ( ) ;
151151 }
152152
153- private setupSessionCheck ( ) {
153+ protected setupSessionCheck ( ) {
154154 this . events . pipe ( filter ( e => e . type === 'token_received' ) ) . subscribe ( e => {
155155 this . initSessionCheck ( ) ;
156156 } ) ;
@@ -203,13 +203,13 @@ export class OAuthService extends AuthConfig {
203203 } ) ;
204204 }
205205
206- private debug ( ...args ) : void {
206+ protected debug ( ...args ) : void {
207207 if ( this . showDebugInformation ) {
208208 this . logger . debug . apply ( console , args ) ;
209209 }
210210 }
211211
212- private validateUrlFromDiscoveryDocument ( url : string ) : string [ ] {
212+ protected validateUrlFromDiscoveryDocument ( url : string ) : string [ ] {
213213 const errors : string [ ] = [ ] ;
214214 const httpsCheck = this . validateUrlForHttps ( url ) ;
215215 const issuerCheck = this . validateUrlAgainstIssuer ( url ) ;
@@ -230,7 +230,7 @@ export class OAuthService extends AuthConfig {
230230 return errors ;
231231 }
232232
233- private validateUrlForHttps ( url : string ) : boolean {
233+ protected validateUrlForHttps ( url : string ) : boolean {
234234 if ( ! url ) {
235235 return true ;
236236 }
@@ -252,7 +252,7 @@ export class OAuthService extends AuthConfig {
252252 return lcUrl . startsWith ( 'https://' ) ;
253253 }
254254
255- private validateUrlAgainstIssuer ( url : string ) {
255+ protected validateUrlAgainstIssuer ( url : string ) {
256256 if ( ! this . strictDiscoveryDocumentValidation ) {
257257 return true ;
258258 }
@@ -262,7 +262,7 @@ export class OAuthService extends AuthConfig {
262262 return url . toLowerCase ( ) . startsWith ( this . issuer . toLowerCase ( ) ) ;
263263 }
264264
265- private setupRefreshTimer ( ) : void {
265+ protected setupRefreshTimer ( ) : void {
266266 if ( typeof window === 'undefined' ) {
267267 this . debug ( 'timer not supported on this plattform' ) ;
268268 return ;
@@ -281,7 +281,7 @@ export class OAuthService extends AuthConfig {
281281 } ) ;
282282 }
283283
284- private setupExpirationTimers ( ) : void {
284+ protected setupExpirationTimers ( ) : void {
285285 const idTokenExp = this . getIdTokenExpiration ( ) || Number . MAX_VALUE ;
286286 const accessTokenExp = this . getAccessTokenExpiration ( ) || Number . MAX_VALUE ;
287287 const useAccessTokenExp = accessTokenExp <= idTokenExp ;
@@ -295,7 +295,7 @@ export class OAuthService extends AuthConfig {
295295 }
296296 }
297297
298- private setupAccessTokenTimer ( ) : void {
298+ protected setupAccessTokenTimer ( ) : void {
299299 const expiration = this . getAccessTokenExpiration ( ) ;
300300 const storedAt = this . getAccessTokenStoredAt ( ) ;
301301 const timeout = this . calcTimeout ( storedAt , expiration ) ;
@@ -313,7 +313,7 @@ export class OAuthService extends AuthConfig {
313313 } ) ;
314314 }
315315
316- private setupIdTokenTimer ( ) : void {
316+ protected setupIdTokenTimer ( ) : void {
317317 const expiration = this . getIdTokenExpiration ( ) ;
318318 const storedAt = this . getIdTokenStoredAt ( ) ;
319319 const timeout = this . calcTimeout ( storedAt , expiration ) ;
@@ -331,19 +331,19 @@ export class OAuthService extends AuthConfig {
331331 } ) ;
332332 }
333333
334- private clearAccessTokenTimer ( ) : void {
334+ protected clearAccessTokenTimer ( ) : void {
335335 if ( this . accessTokenTimeoutSubscription ) {
336336 this . accessTokenTimeoutSubscription . unsubscribe ( ) ;
337337 }
338338 }
339339
340- private clearIdTokenTimer ( ) : void {
340+ protected clearIdTokenTimer ( ) : void {
341341 if ( this . idTokenTimeoutSubscription ) {
342342 this . idTokenTimeoutSubscription . unsubscribe ( ) ;
343343 }
344344 }
345345
346- private calcTimeout ( storedAt : number , expiration : number ) : number {
346+ protected calcTimeout ( storedAt : number , expiration : number ) : number {
347347 const delta = ( expiration - storedAt ) * this . timeoutFactor ;
348348 return delta ;
349349 }
@@ -449,7 +449,7 @@ export class OAuthService extends AuthConfig {
449449 } ) ;
450450 }
451451
452- private loadJwks ( ) : Promise < object > {
452+ protected loadJwks ( ) : Promise < object > {
453453 return new Promise < object > ( ( resolve , reject ) => {
454454 if ( this . jwksUri ) {
455455 this . http . get ( this . jwksUri ) . subscribe (
@@ -474,7 +474,7 @@ export class OAuthService extends AuthConfig {
474474 } ) ;
475475 }
476476
477- private validateDiscoveryDocument ( doc : OidcDiscoveryDoc ) : boolean {
477+ protected validateDiscoveryDocument ( doc : OidcDiscoveryDoc ) : boolean {
478478 let errors : string [ ] ;
479479
480480 if ( ! this . skipIssuerCheck && doc . issuer !== this . issuer ) {
@@ -764,7 +764,7 @@ export class OAuthService extends AuthConfig {
764764 } ) ;
765765 }
766766
767- private removeSilentRefreshEventListener ( ) : void {
767+ protected removeSilentRefreshEventListener ( ) : void {
768768 if ( this . silentRefreshPostMessageEventListener ) {
769769 window . removeEventListener (
770770 'message' ,
@@ -774,7 +774,7 @@ export class OAuthService extends AuthConfig {
774774 }
775775 }
776776
777- private setupSilentRefreshEventListener ( ) : void {
777+ protected setupSilentRefreshEventListener ( ) : void {
778778 this . removeSilentRefreshEventListener ( ) ;
779779
780780 this . silentRefreshPostMessageEventListener = ( e : MessageEvent ) => {
@@ -892,7 +892,7 @@ export class OAuthService extends AuthConfig {
892892 . toPromise ( ) ;
893893 }
894894
895- private canPerformSessionCheck ( ) : boolean {
895+ protected canPerformSessionCheck ( ) : boolean {
896896 if ( ! this . sessionChecksEnabled ) {
897897 return false ;
898898 }
@@ -916,7 +916,7 @@ export class OAuthService extends AuthConfig {
916916 return true ;
917917 }
918918
919- private setupSessionCheckEventListener ( ) : void {
919+ protected setupSessionCheckEventListener ( ) : void {
920920 this . removeSessionCheckEventListener ( ) ;
921921
922922 this . sessionCheckEventListener = ( e : MessageEvent ) => {
@@ -961,11 +961,11 @@ export class OAuthService extends AuthConfig {
961961 } ) ;
962962 }
963963
964- private handleSessionUnchanged ( ) : void {
964+ protected handleSessionUnchanged ( ) : void {
965965 this . debug ( 'session check' , 'session unchanged' ) ;
966966 }
967967
968- private handleSessionChange ( ) : void {
968+ protected handleSessionChange ( ) : void {
969969 /* events: session_changed, relogin, stopTimer, logged_out*/
970970 this . eventsSubject . next ( new OAuthInfoEvent ( 'session_changed' ) ) ;
971971 this . stopSessionCheckTimer ( ) ;
@@ -980,7 +980,7 @@ export class OAuthService extends AuthConfig {
980980 }
981981 }
982982
983- private waitForSilentRefreshAfterSessionChange ( ) {
983+ protected waitForSilentRefreshAfterSessionChange ( ) {
984984 this . events
985985 . pipe (
986986 filter (
@@ -1000,19 +1000,19 @@ export class OAuthService extends AuthConfig {
10001000 } ) ;
10011001 }
10021002
1003- private handleSessionError ( ) : void {
1003+ protected handleSessionError ( ) : void {
10041004 this . stopSessionCheckTimer ( ) ;
10051005 this . eventsSubject . next ( new OAuthInfoEvent ( 'session_error' ) ) ;
10061006 }
10071007
1008- private removeSessionCheckEventListener ( ) : void {
1008+ protected removeSessionCheckEventListener ( ) : void {
10091009 if ( this . sessionCheckEventListener ) {
10101010 window . removeEventListener ( 'message' , this . sessionCheckEventListener ) ;
10111011 this . sessionCheckEventListener = null ;
10121012 }
10131013 }
10141014
1015- private initSessionCheck ( ) : void {
1015+ protected initSessionCheck ( ) : void {
10161016 if ( ! this . canPerformSessionCheck ( ) ) {
10171017 return ;
10181018 }
@@ -1035,7 +1035,7 @@ export class OAuthService extends AuthConfig {
10351035 this . startSessionCheckTimer ( ) ;
10361036 }
10371037
1038- private startSessionCheckTimer ( ) : void {
1038+ protected startSessionCheckTimer ( ) : void {
10391039 this . stopSessionCheckTimer ( ) ;
10401040 this . ngZone . runOutsideAngular ( ( ) => {
10411041 this . sessionCheckTimer = setInterval (
@@ -1045,14 +1045,14 @@ export class OAuthService extends AuthConfig {
10451045 } ) ;
10461046 }
10471047
1048- private stopSessionCheckTimer ( ) : void {
1048+ protected stopSessionCheckTimer ( ) : void {
10491049 if ( this . sessionCheckTimer ) {
10501050 clearInterval ( this . sessionCheckTimer ) ;
10511051 this . sessionCheckTimer = null ;
10521052 }
10531053 }
10541054
1055- private checkSession ( ) : void {
1055+ protected checkSession ( ) : void {
10561056 const iframe : any = document . getElementById ( this . sessionCheckIFrameName ) ;
10571057
10581058 if ( ! iframe ) {
@@ -1072,7 +1072,7 @@ export class OAuthService extends AuthConfig {
10721072 iframe . contentWindow . postMessage ( message , this . issuer ) ;
10731073 }
10741074
1075- private createLoginUrl (
1075+ protected createLoginUrl (
10761076 state = '' ,
10771077 loginHint = '' ,
10781078 customRedirectUri = '' ,
@@ -1225,7 +1225,7 @@ export class OAuthService extends AuthConfig {
12251225 }
12261226 }
12271227
1228- private callOnTokenReceivedIfExists ( options : LoginOptions ) : void {
1228+ protected callOnTokenReceivedIfExists ( options : LoginOptions ) : void {
12291229 const that = this ;
12301230 if ( options . onTokenReceived ) {
12311231 const tokenParams = {
@@ -1238,7 +1238,7 @@ export class OAuthService extends AuthConfig {
12381238 }
12391239 }
12401240
1241- private storeAccessTokenResponse (
1241+ protected storeAccessTokenResponse (
12421242 accessToken : string ,
12431243 refreshToken : string ,
12441244 expiresIn : number ,
@@ -1398,7 +1398,7 @@ export class OAuthService extends AuthConfig {
13981398 } ) ;
13991399 }
14001400
1401- private validateNonceForAccessToken (
1401+ protected validateNonceForAccessToken (
14021402 accessToken : string ,
14031403 nonceInState : string
14041404 ) : boolean {
@@ -1426,7 +1426,7 @@ export class OAuthService extends AuthConfig {
14261426 return this . _storage . getItem ( 'session_state' ) ;
14271427 }
14281428
1429- private handleLoginError ( options : LoginOptions , parts : object ) : void {
1429+ protected handleLoginError ( options : LoginOptions , parts : object ) : void {
14301430 if ( options . onLoginError ) {
14311431 options . onLoginError ( parts ) ;
14321432 }
@@ -1606,7 +1606,7 @@ export class OAuthService extends AuthConfig {
16061606 : null ;
16071607 }
16081608
1609- private padBase64 ( base64data ) : string {
1609+ protected padBase64 ( base64data ) : string {
16101610 while ( base64data . length % 4 !== 0 ) {
16111611 base64data += '=' ;
16121612 }
@@ -1635,11 +1635,11 @@ export class OAuthService extends AuthConfig {
16351635 return parseInt ( this . _storage . getItem ( 'expires_at' ) , 10 ) ;
16361636 }
16371637
1638- private getAccessTokenStoredAt ( ) : number {
1638+ protected getAccessTokenStoredAt ( ) : number {
16391639 return parseInt ( this . _storage . getItem ( 'access_token_stored_at' ) , 10 ) ;
16401640 }
16411641
1642- private getIdTokenStoredAt ( ) : number {
1642+ protected getIdTokenStoredAt ( ) : number {
16431643 return parseInt ( this . _storage . getItem ( 'id_token_stored_at' ) , 10 ) ;
16441644 }
16451645
@@ -1797,7 +1797,7 @@ export class OAuthService extends AuthConfig {
17971797 } ) ;
17981798 }
17991799
1800- private async checkAtHash ( params : ValidationParams ) : Promise < boolean > {
1800+ protected async checkAtHash ( params : ValidationParams ) : Promise < boolean > {
18011801 if ( ! this . tokenValidationHandler ) {
18021802 this . logger . warn (
18031803 'No tokenValidationHandler configured. Cannot check at_hash.'
@@ -1807,7 +1807,7 @@ export class OAuthService extends AuthConfig {
18071807 return this . tokenValidationHandler . validateAtHash ( params ) ;
18081808 }
18091809
1810- private checkSignature ( params : ValidationParams ) : Promise < any > {
1810+ protected checkSignature ( params : ValidationParams ) : Promise < any > {
18111811 if ( ! this . tokenValidationHandler ) {
18121812 this . logger . warn (
18131813 'No tokenValidationHandler configured. Cannot check signature.'
0 commit comments