@@ -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 {
@@ -409,7 +409,7 @@ export class OAuthService extends AuthConfig implements OnDestroy {
409
409
*
410
410
* @param fullUrl
411
411
*/
412
- public loadDiscoveryDocument ( fullUrl : string = null ) : Promise < object > {
412
+ public loadDiscoveryDocument ( fullUrl : string = null ) : Promise < OAuthSuccessEvent > {
413
413
return new Promise ( ( resolve , reject ) => {
414
414
if ( ! fullUrl ) {
415
415
fullUrl = this . issuer || '' ;
@@ -590,7 +590,7 @@ export class OAuthService extends AuthConfig implements OnDestroy {
590
590
userName : string ,
591
591
password : string ,
592
592
headers : HttpHeaders = new HttpHeaders ( )
593
- ) : Promise < object > {
593
+ ) : Promise < UserInfo > {
594
594
return this . fetchTokenUsingPasswordFlow ( userName , password , headers ) . then (
595
595
( ) => this . loadUserProfile ( )
596
596
) ;
@@ -602,7 +602,7 @@ export class OAuthService extends AuthConfig implements OnDestroy {
602
602
* When using this with OAuth2 password flow, make sure that the property oidc is set to false.
603
603
* Otherwise stricter validations take place that make this operation fail.
604
604
*/
605
- public loadUserProfile ( ) : Promise < object > {
605
+ public loadUserProfile ( ) : Promise < UserInfo > {
606
606
if ( ! this . hasValidAccessToken ( ) ) {
607
607
throw new Error ( 'Can not load User Profile without access_token' ) ;
608
608
}
@@ -666,7 +666,7 @@ export class OAuthService extends AuthConfig implements OnDestroy {
666
666
userName : string ,
667
667
password : string ,
668
668
headers : HttpHeaders = new HttpHeaders ( )
669
- ) : Promise < object > {
669
+ ) : Promise < TokenResponse > {
670
670
if ( ! this . validateUrlForHttps ( this . tokenEndpoint ) ) {
671
671
throw new Error (
672
672
'tokenEndpoint must use https, or config value for property requireHttps must allow http'
@@ -743,7 +743,7 @@ export class OAuthService extends AuthConfig implements OnDestroy {
743
743
* A solution for this is provided by the
744
744
* method silentRefresh.
745
745
*/
746
- public refreshToken ( ) : Promise < object > {
746
+ public refreshToken ( ) : Promise < TokenResponse > {
747
747
748
748
if ( ! this . validateUrlForHttps ( this . tokenEndpoint ) ) {
749
749
throw new Error (
@@ -958,7 +958,7 @@ export class OAuthService extends AuthConfig implements OnDestroy {
958
958
} ) ;
959
959
}
960
960
961
- protected calculatePopupFeatures ( options : { height ?: number , width ?: number } ) {
961
+ protected calculatePopupFeatures ( options : { height ?: number , width ?: number } ) : string {
962
962
// Specify an static height and width and calculate centered position
963
963
const height = options . height || 470 ;
964
964
const width = options . width || 500 ;
@@ -967,7 +967,7 @@ export class OAuthService extends AuthConfig implements OnDestroy {
967
967
return `location=no,toolbar=no,width=${ width } ,height=${ height } ,top=${ top } ,left=${ left } ` ;
968
968
}
969
969
970
- protected processMessageEventMessage ( e : MessageEvent ) {
970
+ protected processMessageEventMessage ( e : MessageEvent ) : string {
971
971
let expectedPrefix = '#' ;
972
972
973
973
if ( this . silentRefreshMessagePrefix ) {
@@ -1075,7 +1075,7 @@ export class OAuthService extends AuthConfig implements OnDestroy {
1075
1075
}
1076
1076
}
1077
1077
1078
- protected waitForSilentRefreshAfterSessionChange ( ) {
1078
+ protected waitForSilentRefreshAfterSessionChange ( ) : void {
1079
1079
this . events
1080
1080
. pipe (
1081
1081
filter (
@@ -1173,7 +1173,7 @@ export class OAuthService extends AuthConfig implements OnDestroy {
1173
1173
customRedirectUri = '' ,
1174
1174
noPrompt = false ,
1175
1175
params : object = { }
1176
- ) {
1176
+ ) : Promise < string > {
1177
1177
const that = this ;
1178
1178
1179
1179
let redirectUri : string ;
@@ -1268,7 +1268,6 @@ export class OAuthService extends AuthConfig implements OnDestroy {
1268
1268
}
1269
1269
1270
1270
return url ;
1271
-
1272
1271
}
1273
1272
1274
1273
initImplicitFlowInternal (
@@ -1452,7 +1451,7 @@ export class OAuthService extends AuthConfig implements OnDestroy {
1452
1451
/**
1453
1452
* Get token using an intermediate code. Works for the Authorization Code flow.
1454
1453
*/
1455
- private getTokenFromCode ( code : string ) : Promise < object > {
1454
+ private getTokenFromCode ( code : string ) : Promise < TokenResponse > {
1456
1455
let params = new HttpParams ( )
1457
1456
. set ( 'grant_type' , 'authorization_code' )
1458
1457
. set ( 'code' , code )
@@ -1471,7 +1470,7 @@ export class OAuthService extends AuthConfig implements OnDestroy {
1471
1470
return this . fetchAndProcessToken ( params ) ;
1472
1471
}
1473
1472
1474
- private fetchAndProcessToken ( params : HttpParams ) : Promise < object > {
1473
+ private fetchAndProcessToken ( params : HttpParams ) : Promise < TokenResponse > {
1475
1474
1476
1475
let headers = new HttpHeaders ( )
1477
1476
. set ( 'Content-Type' , 'application/x-www-form-urlencoded' ) ;
@@ -1700,7 +1699,7 @@ export class OAuthService extends AuthConfig implements OnDestroy {
1700
1699
return true ;
1701
1700
}
1702
1701
1703
- protected storeIdToken ( idToken : ParsedIdToken ) {
1702
+ protected storeIdToken ( idToken : ParsedIdToken ) : void {
1704
1703
this . _storage . setItem ( 'id_token' , idToken . idToken ) ;
1705
1704
this . _storage . setItem ( 'id_token_claims_obj' , idToken . idTokenClaimsJson ) ;
1706
1705
this . _storage . setItem ( 'id_token_expires_at' , '' + idToken . idTokenExpiresAt ) ;
@@ -2092,7 +2091,7 @@ export class OAuthService extends AuthConfig implements OnDestroy {
2092
2091
/**
2093
2092
* @ignore
2094
2093
*/
2095
- public ngOnDestroy ( ) {
2094
+ public ngOnDestroy ( ) : void {
2096
2095
this . clearAccessTokenTimer ( ) ;
2097
2096
this . clearIdTokenTimer ( ) ;
2098
2097
}
@@ -2157,7 +2156,7 @@ export class OAuthService extends AuthConfig implements OnDestroy {
2157
2156
public initLoginFlow (
2158
2157
additionalState = '' ,
2159
2158
params = { }
2160
- ) {
2159
+ ) : void {
2161
2160
if ( this . responseType === 'code' ) {
2162
2161
return this . initCodeFlow ( additionalState , params ) ;
2163
2162
} else {
0 commit comments