@@ -54,7 +54,7 @@ export class OAuthService extends AuthConfig implements OnDestroy {
54
54
* @internal
55
55
* Deprecated: use property events instead
56
56
*/
57
- public discoveryDocumentLoaded$ : Observable < object > ;
57
+ public discoveryDocumentLoaded$ : Observable < OidcDiscoveryDoc > ;
58
58
59
59
/**
60
60
* Informs about events, like token_received or token_expires.
@@ -69,7 +69,7 @@ export class OAuthService extends AuthConfig implements OnDestroy {
69
69
public state ? = '' ;
70
70
71
71
protected eventsSubject : Subject < OAuthEvent > = new Subject < OAuthEvent > ( ) ;
72
- protected discoveryDocumentLoadedSubject : Subject < object > = new Subject < object > ( ) ;
72
+ protected discoveryDocumentLoadedSubject : Subject < OidcDiscoveryDoc > = new Subject < OidcDiscoveryDoc > ( ) ;
73
73
protected silentRefreshPostMessageEventListener : EventListener ;
74
74
protected grantTypesSupported : Array < string > = [ ] ;
75
75
protected _storage : OAuthStorage ;
@@ -128,7 +128,7 @@ export class OAuthService extends AuthConfig implements OnDestroy {
128
128
* Use this method to configure the service
129
129
* @param config the configuration
130
130
*/
131
- public configure ( config : AuthConfig ) {
131
+ public configure ( config : AuthConfig ) : void {
132
132
// For the sake of downward compatibility with
133
133
// original configuration API
134
134
Object . assign ( this , new AuthConfig ( ) , config ) ;
@@ -156,7 +156,7 @@ export class OAuthService extends AuthConfig implements OnDestroy {
156
156
this . setupExpirationTimers ( ) ;
157
157
}
158
158
159
- protected setupSessionCheck ( ) {
159
+ protected setupSessionCheck ( ) : void {
160
160
this . events . pipe ( filter ( e => e . type === 'token_received' ) ) . subscribe ( e => {
161
161
this . initSessionCheck ( ) ;
162
162
} ) ;
@@ -170,7 +170,7 @@ export class OAuthService extends AuthConfig implements OnDestroy {
170
170
* @param params Additional parameter to pass
171
171
* @param listenTo Setup automatic refresh of a specific token type
172
172
*/
173
- public setupAutomaticSilentRefresh ( params : object = { } , listenTo ?: 'access_token' | 'id_token' | 'any' , noPrompt = true ) {
173
+ public setupAutomaticSilentRefresh ( params : object = { } , listenTo ?: 'access_token' | 'id_token' | 'any' , noPrompt = true ) : void {
174
174
let shouldRunSilentRefresh = true ;
175
175
this . events . pipe (
176
176
tap ( ( e ) => {
@@ -194,7 +194,7 @@ export class OAuthService extends AuthConfig implements OnDestroy {
194
194
this . restartRefreshTimerIfStillLoggedIn ( ) ;
195
195
}
196
196
197
- protected refreshInternal ( params , noPrompt ) {
197
+ protected refreshInternal ( params , noPrompt ) : Promise < TokenResponse | OAuthEvent > {
198
198
if ( this . responseType === 'code' ) {
199
199
return this . refreshToken ( ) ;
200
200
} else {
@@ -405,7 +405,7 @@ export class OAuthService extends AuthConfig implements OnDestroy {
405
405
*
406
406
* @param fullUrl
407
407
*/
408
- public loadDiscoveryDocument ( fullUrl : string = null ) : Promise < object > {
408
+ public loadDiscoveryDocument ( fullUrl : string = null ) : Promise < OAuthSuccessEvent > {
409
409
return new Promise ( ( resolve , reject ) => {
410
410
if ( ! fullUrl ) {
411
411
fullUrl = this . issuer || '' ;
@@ -586,7 +586,7 @@ export class OAuthService extends AuthConfig implements OnDestroy {
586
586
userName : string ,
587
587
password : string ,
588
588
headers : HttpHeaders = new HttpHeaders ( )
589
- ) : Promise < object > {
589
+ ) : Promise < UserInfo > {
590
590
return this . fetchTokenUsingPasswordFlow ( userName , password , headers ) . then (
591
591
( ) => this . loadUserProfile ( )
592
592
) ;
@@ -598,7 +598,7 @@ export class OAuthService extends AuthConfig implements OnDestroy {
598
598
* When using this with OAuth2 password flow, make sure that the property oidc is set to false.
599
599
* Otherwise stricter validations take place that make this operation fail.
600
600
*/
601
- public loadUserProfile ( ) : Promise < object > {
601
+ public loadUserProfile ( ) : Promise < UserInfo > {
602
602
if ( ! this . hasValidAccessToken ( ) ) {
603
603
throw new Error ( 'Can not load User Profile without access_token' ) ;
604
604
}
@@ -662,7 +662,7 @@ export class OAuthService extends AuthConfig implements OnDestroy {
662
662
userName : string ,
663
663
password : string ,
664
664
headers : HttpHeaders = new HttpHeaders ( )
665
- ) : Promise < object > {
665
+ ) : Promise < TokenResponse > {
666
666
if ( ! this . validateUrlForHttps ( this . tokenEndpoint ) ) {
667
667
throw new Error (
668
668
'tokenEndpoint must use https, or config value for property requireHttps must allow http'
@@ -739,7 +739,7 @@ export class OAuthService extends AuthConfig implements OnDestroy {
739
739
* A solution for this is provided by the
740
740
* method silentRefresh.
741
741
*/
742
- public refreshToken ( ) : Promise < object > {
742
+ public refreshToken ( ) : Promise < TokenResponse > {
743
743
744
744
if ( ! this . validateUrlForHttps ( this . tokenEndpoint ) ) {
745
745
throw new Error (
@@ -954,7 +954,7 @@ export class OAuthService extends AuthConfig implements OnDestroy {
954
954
} ) ;
955
955
}
956
956
957
- protected calculatePopupFeatures ( options : { height ?: number , width ?: number } ) {
957
+ protected calculatePopupFeatures ( options : { height ?: number , width ?: number } ) : string {
958
958
// Specify an static height and width and calculate centered position
959
959
const height = options . height || 470 ;
960
960
const width = options . width || 500 ;
@@ -963,7 +963,7 @@ export class OAuthService extends AuthConfig implements OnDestroy {
963
963
return `location=no,toolbar=no,width=${ width } ,height=${ height } ,top=${ top } ,left=${ left } ` ;
964
964
}
965
965
966
- protected processMessageEventMessage ( e : MessageEvent ) {
966
+ protected processMessageEventMessage ( e : MessageEvent ) : string {
967
967
let expectedPrefix = '#' ;
968
968
969
969
if ( this . silentRefreshMessagePrefix ) {
@@ -1071,7 +1071,7 @@ export class OAuthService extends AuthConfig implements OnDestroy {
1071
1071
}
1072
1072
}
1073
1073
1074
- protected waitForSilentRefreshAfterSessionChange ( ) {
1074
+ protected waitForSilentRefreshAfterSessionChange ( ) : void {
1075
1075
this . events
1076
1076
. pipe (
1077
1077
filter (
@@ -1169,7 +1169,7 @@ export class OAuthService extends AuthConfig implements OnDestroy {
1169
1169
customRedirectUri = '' ,
1170
1170
noPrompt = false ,
1171
1171
params : object = { }
1172
- ) {
1172
+ ) : Promise < string > {
1173
1173
const that = this ;
1174
1174
1175
1175
let redirectUri : string ;
@@ -1264,7 +1264,6 @@ export class OAuthService extends AuthConfig implements OnDestroy {
1264
1264
}
1265
1265
1266
1266
return url ;
1267
-
1268
1267
}
1269
1268
1270
1269
initImplicitFlowInternal (
@@ -1448,7 +1447,7 @@ export class OAuthService extends AuthConfig implements OnDestroy {
1448
1447
/**
1449
1448
* Get token using an intermediate code. Works for the Authorization Code flow.
1450
1449
*/
1451
- private getTokenFromCode ( code : string ) : Promise < object > {
1450
+ private getTokenFromCode ( code : string ) : Promise < TokenResponse > {
1452
1451
let params = new HttpParams ( )
1453
1452
. set ( 'grant_type' , 'authorization_code' )
1454
1453
. set ( 'code' , code )
@@ -1467,7 +1466,7 @@ export class OAuthService extends AuthConfig implements OnDestroy {
1467
1466
return this . fetchAndProcessToken ( params ) ;
1468
1467
}
1469
1468
1470
- private fetchAndProcessToken ( params : HttpParams ) : Promise < object > {
1469
+ private fetchAndProcessToken ( params : HttpParams ) : Promise < TokenResponse > {
1471
1470
1472
1471
let headers = new HttpHeaders ( )
1473
1472
. set ( 'Content-Type' , 'application/x-www-form-urlencoded' ) ;
@@ -1696,7 +1695,7 @@ export class OAuthService extends AuthConfig implements OnDestroy {
1696
1695
return true ;
1697
1696
}
1698
1697
1699
- protected storeIdToken ( idToken : ParsedIdToken ) {
1698
+ protected storeIdToken ( idToken : ParsedIdToken ) : void {
1700
1699
this . _storage . setItem ( 'id_token' , idToken . idToken ) ;
1701
1700
this . _storage . setItem ( 'id_token_claims_obj' , idToken . idTokenClaimsJson ) ;
1702
1701
this . _storage . setItem ( 'id_token_expires_at' , '' + idToken . idTokenExpiresAt ) ;
@@ -2070,7 +2069,7 @@ export class OAuthService extends AuthConfig implements OnDestroy {
2070
2069
/**
2071
2070
* @ignore
2072
2071
*/
2073
- public ngOnDestroy ( ) {
2072
+ public ngOnDestroy ( ) : void {
2074
2073
this . clearAccessTokenTimer ( ) ;
2075
2074
this . clearIdTokenTimer ( ) ;
2076
2075
}
@@ -2135,7 +2134,7 @@ export class OAuthService extends AuthConfig implements OnDestroy {
2135
2134
public initLoginFlow (
2136
2135
additionalState = '' ,
2137
2136
params = { }
2138
- ) {
2137
+ ) : void {
2139
2138
if ( this . responseType === 'code' ) {
2140
2139
return this . initCodeFlow ( additionalState , params ) ;
2141
2140
} else {
0 commit comments