1- import { IHttpClient } from './httpClient' ;
1+ import { HttpClient } from './httpClient' ;
22
3- interface IAuthenticatorResult {
3+ interface AuthenticatorResult {
44 accessToken : string ;
55 expiresAt : number ;
66 refreshToken : string ;
77}
88
9- interface IAuthenticator {
10- refresh : ( ) => Promise < IAuthenticatorResult > ;
9+ interface OIDCAuthFlow {
10+ refresh : ( ) => Promise < AuthenticatorResult > ;
1111}
1212
1313export class Authenticator {
14- private readonly http : IHttpClient ;
14+ private readonly http : HttpClient ;
1515 private readonly creds : any ;
1616 private accessToken : string ;
1717 private refreshToken ?: string ;
1818 private expiresAt : number ;
1919 private refreshRunning : boolean ;
2020
21- constructor ( http : IHttpClient , creds : any ) {
21+ constructor ( http : HttpClient , creds : any ) {
2222 this . http = http ;
2323 this . creds = creds ;
2424 this . accessToken = '' ;
@@ -38,7 +38,7 @@ export class Authenticator {
3838 refresh = async ( localConfig : any ) => {
3939 const config = await this . getOpenidConfig ( localConfig ) ;
4040
41- let authenticator : IAuthenticator ;
41+ let authenticator : OIDCAuthFlow ;
4242 switch ( this . creds . constructor ) {
4343 case AuthUserPasswordCredentials :
4444 authenticator = new UserPasswordAuthenticator (
@@ -107,7 +107,7 @@ export class Authenticator {
107107 } ;
108108}
109109
110- export interface IAuthUserPasswordCredentials {
110+ export interface UserPasswordCredentialsInput {
111111 username : string ;
112112 password ?: string ;
113113 scopes ?: any [ ] ;
@@ -117,20 +117,20 @@ export class AuthUserPasswordCredentials {
117117 private username : string ;
118118 private password ?: string ;
119119 private scopes ?: any [ ] ;
120- constructor ( creds : IAuthUserPasswordCredentials ) {
120+ constructor ( creds : UserPasswordCredentialsInput ) {
121121 this . username = creds . username ;
122122 this . password = creds . password ;
123123 this . scopes = creds . scopes ;
124124 }
125125}
126126
127- interface IRequestAccessTokenResponse {
127+ interface RequestAccessTokenResponse {
128128 access_token : string ;
129129 expires_in : number ;
130130 refresh_token : string ;
131131}
132132
133- class UserPasswordAuthenticator implements IAuthenticator {
133+ class UserPasswordAuthenticator implements OIDCAuthFlow {
134134 private creds : any ;
135135 private http : any ;
136136 private openidConfig : any ;
@@ -146,7 +146,7 @@ class UserPasswordAuthenticator implements IAuthenticator {
146146 refresh = ( ) => {
147147 this . validateOpenidConfig ( ) ;
148148 return this . requestAccessToken ( )
149- . then ( ( tokenResp : IRequestAccessTokenResponse ) => {
149+ . then ( ( tokenResp : RequestAccessTokenResponse ) => {
150150 return {
151151 accessToken : tokenResp . access_token ,
152152 expiresAt : calcExpirationEpoch ( tokenResp . expires_in ) ,
@@ -194,7 +194,7 @@ class UserPasswordAuthenticator implements IAuthenticator {
194194 } ;
195195}
196196
197- export interface IAuthAccessTokenCredentials {
197+ export interface AccessTokenCredentialsInput {
198198 accessToken : string ;
199199 expiresIn : number ;
200200 refreshToken ?: string ;
@@ -205,14 +205,14 @@ export class AuthAccessTokenCredentials {
205205 public readonly expiresAt : number ;
206206 public readonly refreshToken ?: string ;
207207
208- constructor ( creds : IAuthAccessTokenCredentials ) {
208+ constructor ( creds : AccessTokenCredentialsInput ) {
209209 this . validate ( creds ) ;
210210 this . accessToken = creds . accessToken ;
211211 this . expiresAt = calcExpirationEpoch ( creds . expiresIn ) ;
212212 this . refreshToken = creds . refreshToken ;
213213 }
214214
215- validate = ( creds : IAuthAccessTokenCredentials ) => {
215+ validate = ( creds : AccessTokenCredentialsInput ) => {
216216 if ( creds . expiresIn === undefined ) {
217217 throw new Error ( 'AuthAccessTokenCredentials: expiresIn is required' ) ;
218218 }
@@ -222,7 +222,7 @@ export class AuthAccessTokenCredentials {
222222 } ;
223223}
224224
225- class AccessTokenAuthenticator implements IAuthenticator {
225+ class AccessTokenAuthenticator implements OIDCAuthFlow {
226226 private creds : any ;
227227 private http : any ;
228228 private openidConfig : any ;
@@ -247,7 +247,7 @@ class AccessTokenAuthenticator implements IAuthenticator {
247247 }
248248 this . validateOpenidConfig ( ) ;
249249 return this . requestAccessToken ( )
250- . then ( ( tokenResp : IRequestAccessTokenResponse ) => {
250+ . then ( ( tokenResp : RequestAccessTokenResponse ) => {
251251 return {
252252 accessToken : tokenResp . access_token ,
253253 expiresAt : calcExpirationEpoch ( tokenResp . expires_in ) ,
@@ -284,7 +284,7 @@ class AccessTokenAuthenticator implements IAuthenticator {
284284 } ;
285285}
286286
287- export interface IAuthClientCredentials {
287+ export interface ClientCredentialsInput {
288288 clientSecret : string ;
289289 scopes ?: any [ ] ;
290290}
@@ -293,13 +293,13 @@ export class AuthClientCredentials {
293293 private clientSecret : any ;
294294 private scopes ?: any [ ] ;
295295
296- constructor ( creds : IAuthClientCredentials ) {
296+ constructor ( creds : ClientCredentialsInput ) {
297297 this . clientSecret = creds . clientSecret ;
298298 this . scopes = creds . scopes ;
299299 }
300300}
301301
302- class ClientCredentialsAuthenticator implements IAuthenticator {
302+ class ClientCredentialsAuthenticator implements OIDCAuthFlow {
303303 private creds : any ;
304304 private http : any ;
305305 private openidConfig : any ;
@@ -316,7 +316,7 @@ class ClientCredentialsAuthenticator implements IAuthenticator {
316316 refresh = ( ) => {
317317 this . validateOpenidConfig ( ) ;
318318 return this . requestAccessToken ( )
319- . then ( ( tokenResp : IRequestAccessTokenResponse ) => {
319+ . then ( ( tokenResp : RequestAccessTokenResponse ) => {
320320 return {
321321 accessToken : tokenResp . access_token ,
322322 expiresAt : calcExpirationEpoch ( tokenResp . expires_in ) ,
0 commit comments