@@ -17,17 +17,16 @@ import {
17
17
Constants ,
18
18
B2cAuthority ,
19
19
JsonCache ,
20
- Serializer
20
+ Serializer ,
21
21
} from '@azure/msal-common' ;
22
22
import { Configuration , buildAppConfiguration } from '../config/Configuration' ;
23
23
import { CryptoProvider } from '../crypto/CryptoProvider' ;
24
24
import { Storage } from '../cache/Storage' ;
25
25
import { version } from '../../package.json' ;
26
- import { Constants as NodeConstants } from " ./../utils/Constants" ;
26
+ import { Constants as NodeConstants } from ' ./../utils/Constants' ;
27
27
import { CacheContext } from '../cache/CacheContext' ;
28
28
29
29
export abstract class ClientApplication {
30
-
31
30
private config : Configuration ;
32
31
private _authority : Authority ;
33
32
private readonly cryptoProvider : CryptoProvider ;
@@ -37,7 +36,7 @@ export abstract class ClientApplication {
37
36
/**
38
37
* @constructor
39
38
* Constructor for the ClientApplication
40
- */
39
+ */
41
40
protected constructor ( configuration : Configuration ) {
42
41
this . config = buildAppConfiguration ( configuration ) ;
43
42
@@ -57,10 +56,15 @@ export abstract class ClientApplication {
57
56
* acquireToken(AuthorizationCodeRequest)
58
57
* @param request
59
58
*/
60
- async getAuthCodeUrl ( request : AuthorizationCodeUrlRequest ) : Promise < string > {
61
-
62
- const authClientConfig = await this . buildOauthClientConfiguration ( request . authority ) ;
63
- const authorizationCodeClient = new AuthorizationCodeClient ( authClientConfig ) ;
59
+ async getAuthCodeUrl (
60
+ request : AuthorizationCodeUrlRequest
61
+ ) : Promise < string > {
62
+ const authClientConfig = await this . buildOauthClientConfiguration (
63
+ request . authority
64
+ ) ;
65
+ const authorizationCodeClient = new AuthorizationCodeClient (
66
+ authClientConfig
67
+ ) ;
64
68
return authorizationCodeClient . getAuthCodeUrl ( request ) ;
65
69
}
66
70
@@ -74,10 +78,15 @@ export abstract class ClientApplication {
74
78
*
75
79
* @param request
76
80
*/
77
- async acquireTokenByCode ( request : AuthorizationCodeRequest ) : Promise < AuthenticationResult > {
78
-
79
- const authClientConfig = await this . buildOauthClientConfiguration ( request . authority ) ;
80
- const authorizationCodeClient = new AuthorizationCodeClient ( authClientConfig ) ;
81
+ async acquireTokenByCode (
82
+ request : AuthorizationCodeRequest
83
+ ) : Promise < AuthenticationResult > {
84
+ const authClientConfig = await this . buildOauthClientConfiguration (
85
+ request . authority
86
+ ) ;
87
+ const authorizationCodeClient = new AuthorizationCodeClient (
88
+ authClientConfig
89
+ ) ;
81
90
return authorizationCodeClient . acquireToken ( request ) ;
82
91
}
83
92
@@ -89,33 +98,42 @@ export abstract class ClientApplication {
89
98
* handle the caching and refreshing of tokens automatically.
90
99
* @param request
91
100
*/
92
- async acquireTokenByRefreshToken ( request : RefreshTokenRequest ) : Promise < string > {
93
-
94
- const refreshTokenClientConfig = await this . buildOauthClientConfiguration ( request . authority ) ;
95
- const refreshTokenClient = new RefreshTokenClient ( refreshTokenClientConfig ) ;
101
+ async acquireTokenByRefreshToken (
102
+ request : RefreshTokenRequest
103
+ ) : Promise < string > {
104
+ const refreshTokenClientConfig = await this . buildOauthClientConfiguration (
105
+ request . authority
106
+ ) ;
107
+ const refreshTokenClient = new RefreshTokenClient (
108
+ refreshTokenClientConfig
109
+ ) ;
96
110
return refreshTokenClient . acquireToken ( request ) ;
97
111
}
98
112
99
- protected async buildOauthClientConfiguration ( authority ?: string ) : Promise < ClientConfiguration > {
113
+ protected async buildOauthClientConfiguration (
114
+ authority ?: string
115
+ ) : Promise < ClientConfiguration > {
100
116
// using null assertion operator as we ensure that all config values have default values in buildConfiguration()
101
117
return {
102
118
authOptions : {
103
119
clientId : this . config . auth . clientId ,
104
120
authority : await this . createAuthority ( authority ) ,
105
- knownAuthorities : this . config . auth . knownAuthorities
121
+ knownAuthorities : this . config . auth . knownAuthorities ,
106
122
} ,
107
123
loggerOptions : {
108
- loggerCallback : this . config . system ! . loggerOptions ! . loggerCallback ,
109
- piiLoggingEnabled : this . config . system ! . loggerOptions ! . piiLoggingEnabled ,
124
+ loggerCallback : this . config . system ! . loggerOptions !
125
+ . loggerCallback ,
126
+ piiLoggingEnabled : this . config . system ! . loggerOptions !
127
+ . piiLoggingEnabled ,
110
128
} ,
111
129
cryptoInterface : this . cryptoProvider ,
112
130
networkInterface : this . config . system ! . networkClient ,
113
131
storageInterface : this . storage ,
114
132
libraryInfo : {
115
133
sku : NodeConstants . MSAL_SKU ,
116
134
version : version ,
117
- cpu : process . arch || "" ,
118
- os : process . platform || ""
135
+ cpu : process . arch || '' ,
136
+ os : process . platform || '' ,
119
137
} ,
120
138
} ;
121
139
}
@@ -125,12 +143,17 @@ export abstract class ClientApplication {
125
143
* object. If no authority set in application object, then default to common authority.
126
144
* @param authorityString
127
145
*/
128
- private async createAuthority ( authorityString ?: string ) : Promise < Authority > {
146
+ private async createAuthority (
147
+ authorityString ?: string
148
+ ) : Promise < Authority > {
129
149
const authority : Authority = authorityString
130
- ? AuthorityFactory . createInstance ( authorityString , this . config . system ! . networkClient ! )
150
+ ? AuthorityFactory . createInstance (
151
+ authorityString ,
152
+ this . config . system ! . networkClient !
153
+ )
131
154
: this . authority ;
132
155
133
- if ( authority . discoveryComplete ( ) ) {
156
+ if ( authority . discoveryComplete ( ) ) {
134
157
return authority ;
135
158
}
136
159
@@ -160,7 +183,7 @@ export abstract class ClientApplication {
160
183
* @param cacheObject
161
184
*/
162
185
initializeCache ( cacheObject : JsonCache ) {
163
- this . cacheContext . setCurrentCache ( this . storage , cacheObject )
186
+ this . cacheContext . setCurrentCache ( this . storage , cacheObject ) ;
164
187
}
165
188
166
189
/**
0 commit comments