@azure/msal-node 2.12.0 → 2.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (197) hide show
  1. package/dist/cache/ITokenCache.d.ts +15 -15
  2. package/dist/cache/NodeStorage.cjs +425 -423
  3. package/dist/cache/NodeStorage.cjs.map +1 -1
  4. package/dist/cache/NodeStorage.d.ts +193 -193
  5. package/dist/cache/NodeStorage.mjs +423 -423
  6. package/dist/cache/TokenCache.cjs +267 -265
  7. package/dist/cache/TokenCache.cjs.map +1 -1
  8. package/dist/cache/TokenCache.d.ts +90 -90
  9. package/dist/cache/TokenCache.mjs +265 -265
  10. package/dist/cache/distributed/DistributedCachePlugin.cjs +28 -26
  11. package/dist/cache/distributed/DistributedCachePlugin.cjs.map +1 -1
  12. package/dist/cache/distributed/DistributedCachePlugin.d.ts +10 -10
  13. package/dist/cache/distributed/DistributedCachePlugin.mjs +26 -26
  14. package/dist/cache/distributed/ICacheClient.d.ts +17 -17
  15. package/dist/cache/distributed/IPartitionManager.d.ts +28 -28
  16. package/dist/cache/serializer/Deserializer.cjs +169 -167
  17. package/dist/cache/serializer/Deserializer.cjs.map +1 -1
  18. package/dist/cache/serializer/Deserializer.d.ts +42 -42
  19. package/dist/cache/serializer/Deserializer.mjs +167 -167
  20. package/dist/cache/serializer/Serializer.cjs +139 -137
  21. package/dist/cache/serializer/Serializer.cjs.map +1 -1
  22. package/dist/cache/serializer/Serializer.d.ts +39 -39
  23. package/dist/cache/serializer/Serializer.mjs +137 -137
  24. package/dist/cache/serializer/SerializerTypes.d.ts +102 -102
  25. package/dist/client/ClientApplication.cjs +336 -334
  26. package/dist/client/ClientApplication.cjs.map +1 -1
  27. package/dist/client/ClientApplication.d.ts +143 -143
  28. package/dist/client/ClientApplication.mjs +334 -334
  29. package/dist/client/ClientAssertion.cjs +149 -143
  30. package/dist/client/ClientAssertion.cjs.map +1 -1
  31. package/dist/client/ClientAssertion.d.ts +55 -55
  32. package/dist/client/ClientAssertion.mjs +143 -143
  33. package/dist/client/ClientCredentialClient.cjs +196 -194
  34. package/dist/client/ClientCredentialClient.cjs.map +1 -1
  35. package/dist/client/ClientCredentialClient.d.ts +33 -33
  36. package/dist/client/ClientCredentialClient.mjs +194 -194
  37. package/dist/client/ConfidentialClientApplication.cjs +170 -169
  38. package/dist/client/ConfidentialClientApplication.cjs.map +1 -1
  39. package/dist/client/ConfidentialClientApplication.d.ts +58 -58
  40. package/dist/client/ConfidentialClientApplication.mjs +168 -169
  41. package/dist/client/ConfidentialClientApplication.mjs.map +1 -1
  42. package/dist/client/DeviceCodeClient.cjs +209 -207
  43. package/dist/client/DeviceCodeClient.cjs.map +1 -1
  44. package/dist/client/DeviceCodeClient.d.ts +53 -53
  45. package/dist/client/DeviceCodeClient.mjs +207 -207
  46. package/dist/client/IConfidentialClientApplication.d.ts +39 -39
  47. package/dist/client/IPublicClientApplication.d.ts +42 -42
  48. package/dist/client/ManagedIdentityApplication.cjs +86 -84
  49. package/dist/client/ManagedIdentityApplication.cjs.map +1 -1
  50. package/dist/client/ManagedIdentityApplication.d.ts +30 -30
  51. package/dist/client/ManagedIdentityApplication.mjs +84 -84
  52. package/dist/client/ManagedIdentityClient.cjs +62 -60
  53. package/dist/client/ManagedIdentityClient.cjs.map +1 -1
  54. package/dist/client/ManagedIdentityClient.d.ts +27 -27
  55. package/dist/client/ManagedIdentityClient.mjs +60 -60
  56. package/dist/client/ManagedIdentitySources/AppService.cjs +47 -45
  57. package/dist/client/ManagedIdentitySources/AppService.cjs.map +1 -1
  58. package/dist/client/ManagedIdentitySources/AppService.d.ts +17 -17
  59. package/dist/client/ManagedIdentitySources/AppService.mjs +46 -46
  60. package/dist/client/ManagedIdentitySources/AzureArc.cjs +161 -120
  61. package/dist/client/ManagedIdentitySources/AzureArc.cjs.map +1 -1
  62. package/dist/client/ManagedIdentitySources/AzureArc.d.ts +27 -23
  63. package/dist/client/ManagedIdentitySources/AzureArc.d.ts.map +1 -1
  64. package/dist/client/ManagedIdentitySources/AzureArc.mjs +155 -122
  65. package/dist/client/ManagedIdentitySources/AzureArc.mjs.map +1 -1
  66. package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.cjs +124 -122
  67. package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.cjs.map +1 -1
  68. package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.d.ts +30 -30
  69. package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.mjs +122 -122
  70. package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.mjs.map +1 -1
  71. package/dist/client/ManagedIdentitySources/CloudShell.cjs +40 -38
  72. package/dist/client/ManagedIdentitySources/CloudShell.cjs.map +1 -1
  73. package/dist/client/ManagedIdentitySources/CloudShell.d.ts +16 -16
  74. package/dist/client/ManagedIdentitySources/CloudShell.mjs +39 -39
  75. package/dist/client/ManagedIdentitySources/Imds.cjs +45 -43
  76. package/dist/client/ManagedIdentitySources/Imds.cjs.map +1 -1
  77. package/dist/client/ManagedIdentitySources/Imds.d.ts +12 -12
  78. package/dist/client/ManagedIdentitySources/Imds.mjs +44 -44
  79. package/dist/client/ManagedIdentitySources/ServiceFabric.cjs +56 -54
  80. package/dist/client/ManagedIdentitySources/ServiceFabric.cjs.map +1 -1
  81. package/dist/client/ManagedIdentitySources/ServiceFabric.d.ts +17 -17
  82. package/dist/client/ManagedIdentitySources/ServiceFabric.mjs +55 -55
  83. package/dist/client/OnBehalfOfClient.cjs +204 -202
  84. package/dist/client/OnBehalfOfClient.cjs.map +1 -1
  85. package/dist/client/OnBehalfOfClient.d.ts +47 -47
  86. package/dist/client/OnBehalfOfClient.mjs +202 -202
  87. package/dist/client/PublicClientApplication.cjs +239 -237
  88. package/dist/client/PublicClientApplication.cjs.map +1 -1
  89. package/dist/client/PublicClientApplication.d.ts +72 -72
  90. package/dist/client/PublicClientApplication.mjs +237 -237
  91. package/dist/client/UsernamePasswordClient.cjs +97 -95
  92. package/dist/client/UsernamePasswordClient.cjs.map +1 -1
  93. package/dist/client/UsernamePasswordClient.d.ts +25 -25
  94. package/dist/client/UsernamePasswordClient.mjs +95 -95
  95. package/dist/config/Configuration.cjs +108 -106
  96. package/dist/config/Configuration.cjs.map +1 -1
  97. package/dist/config/Configuration.d.ts +131 -131
  98. package/dist/config/Configuration.mjs +106 -106
  99. package/dist/config/ManagedIdentityId.cjs +50 -48
  100. package/dist/config/ManagedIdentityId.cjs.map +1 -1
  101. package/dist/config/ManagedIdentityId.d.ts +11 -11
  102. package/dist/config/ManagedIdentityId.mjs +48 -48
  103. package/dist/config/ManagedIdentityRequestParameters.cjs +30 -28
  104. package/dist/config/ManagedIdentityRequestParameters.cjs.map +1 -1
  105. package/dist/config/ManagedIdentityRequestParameters.d.ts +11 -11
  106. package/dist/config/ManagedIdentityRequestParameters.mjs +28 -28
  107. package/dist/crypto/CryptoProvider.cjs +91 -89
  108. package/dist/crypto/CryptoProvider.cjs.map +1 -1
  109. package/dist/crypto/CryptoProvider.d.ts +62 -62
  110. package/dist/crypto/CryptoProvider.mjs +89 -89
  111. package/dist/crypto/GuidGenerator.cjs +24 -22
  112. package/dist/crypto/GuidGenerator.cjs.map +1 -1
  113. package/dist/crypto/GuidGenerator.d.ts +14 -14
  114. package/dist/crypto/GuidGenerator.mjs +22 -22
  115. package/dist/crypto/HashUtils.cjs +19 -13
  116. package/dist/crypto/HashUtils.cjs.map +1 -1
  117. package/dist/crypto/HashUtils.d.ts +8 -8
  118. package/dist/crypto/HashUtils.mjs +13 -13
  119. package/dist/crypto/PkceGenerator.cjs +55 -49
  120. package/dist/crypto/PkceGenerator.cjs.map +1 -1
  121. package/dist/crypto/PkceGenerator.d.ts +22 -22
  122. package/dist/crypto/PkceGenerator.mjs +49 -49
  123. package/dist/error/ManagedIdentityError.cjs +43 -41
  124. package/dist/error/ManagedIdentityError.cjs.map +1 -1
  125. package/dist/error/ManagedIdentityError.d.ts +30 -30
  126. package/dist/error/ManagedIdentityError.mjs +41 -41
  127. package/dist/error/ManagedIdentityErrorCodes.cjs +26 -24
  128. package/dist/error/ManagedIdentityErrorCodes.cjs.map +1 -1
  129. package/dist/error/ManagedIdentityErrorCodes.d.ts +22 -22
  130. package/dist/error/ManagedIdentityErrorCodes.mjs +24 -24
  131. package/dist/error/NodeAuthError.cjs +97 -95
  132. package/dist/error/NodeAuthError.cjs.map +1 -1
  133. package/dist/error/NodeAuthError.d.ts +73 -73
  134. package/dist/error/NodeAuthError.mjs +95 -95
  135. package/dist/index.cjs +3 -1
  136. package/dist/index.cjs.map +1 -1
  137. package/dist/index.d.ts +45 -45
  138. package/dist/index.mjs +1 -1
  139. package/dist/internals.cjs +6 -8
  140. package/dist/internals.cjs.map +1 -1
  141. package/dist/internals.d.ts +6 -6
  142. package/dist/internals.mjs +4 -8
  143. package/dist/internals.mjs.map +1 -1
  144. package/dist/network/HttpClient.cjs +288 -281
  145. package/dist/network/HttpClient.cjs.map +1 -1
  146. package/dist/network/HttpClient.d.ts +25 -25
  147. package/dist/network/HttpClient.mjs +281 -281
  148. package/dist/network/HttpClientWithRetries.cjs +36 -34
  149. package/dist/network/HttpClientWithRetries.cjs.map +1 -1
  150. package/dist/network/HttpClientWithRetries.d.ts +11 -11
  151. package/dist/network/HttpClientWithRetries.mjs +34 -34
  152. package/dist/network/ILoopbackClient.d.ts +10 -10
  153. package/dist/network/LoopbackClient.cjs +87 -77
  154. package/dist/network/LoopbackClient.cjs.map +1 -1
  155. package/dist/network/LoopbackClient.d.ts +21 -21
  156. package/dist/network/LoopbackClient.d.ts.map +1 -1
  157. package/dist/network/LoopbackClient.mjs +81 -77
  158. package/dist/network/LoopbackClient.mjs.map +1 -1
  159. package/dist/packageMetadata.cjs +6 -4
  160. package/dist/packageMetadata.cjs.map +1 -1
  161. package/dist/packageMetadata.d.ts +2 -2
  162. package/dist/packageMetadata.mjs +4 -4
  163. package/dist/request/AuthorizationCodeRequest.d.ts +21 -21
  164. package/dist/request/AuthorizationUrlRequest.d.ts +33 -33
  165. package/dist/request/ClientCredentialRequest.d.ts +14 -14
  166. package/dist/request/DeviceCodeRequest.d.ts +15 -15
  167. package/dist/request/InteractiveRequest.d.ts +22 -22
  168. package/dist/request/ManagedIdentityRequest.d.ts +8 -8
  169. package/dist/request/ManagedIdentityRequestParams.d.ts +9 -9
  170. package/dist/request/OnBehalfOfRequest.d.ts +14 -14
  171. package/dist/request/RefreshTokenRequest.d.ts +17 -17
  172. package/dist/request/SignOutRequest.d.ts +5 -5
  173. package/dist/request/SilentFlowRequest.d.ts +16 -16
  174. package/dist/request/UsernamePasswordRequest.d.ts +19 -19
  175. package/dist/response/ManagedIdentityTokenResponse.d.ts +34 -34
  176. package/dist/retry/IHttpRetryPolicy.d.ts +5 -5
  177. package/dist/retry/LinearRetryPolicy.cjs +42 -40
  178. package/dist/retry/LinearRetryPolicy.cjs.map +1 -1
  179. package/dist/retry/LinearRetryPolicy.d.ts +11 -11
  180. package/dist/retry/LinearRetryPolicy.mjs +40 -40
  181. package/dist/utils/Constants.cjs +138 -136
  182. package/dist/utils/Constants.cjs.map +1 -1
  183. package/dist/utils/Constants.d.ts +141 -141
  184. package/dist/utils/Constants.mjs +136 -136
  185. package/dist/utils/EncodingUtils.cjs +46 -44
  186. package/dist/utils/EncodingUtils.cjs.map +1 -1
  187. package/dist/utils/EncodingUtils.d.ts +26 -26
  188. package/dist/utils/EncodingUtils.mjs +44 -44
  189. package/dist/utils/NetworkUtils.cjs +40 -38
  190. package/dist/utils/NetworkUtils.cjs.map +1 -1
  191. package/dist/utils/NetworkUtils.d.ts +5 -5
  192. package/dist/utils/NetworkUtils.mjs +38 -38
  193. package/package.json +2 -2
  194. package/src/client/ConfidentialClientApplication.ts +3 -3
  195. package/src/client/ManagedIdentitySources/AzureArc.ts +80 -25
  196. package/src/network/LoopbackClient.ts +6 -0
  197. package/src/packageMetadata.ts +1 -1
@@ -1,7 +1,9 @@
1
- /*! @azure/msal-node v2.12.0 2024-07-23 */
1
+ /*! @azure/msal-node v2.13.0 2024-08-13 */
2
2
  'use strict';
3
3
  'use strict';
4
4
 
5
+ Object.defineProperty(exports, '__esModule', { value: true });
6
+
5
7
  var msalCommon = require('@azure/msal-common');
6
8
  var Configuration = require('../config/Configuration.cjs');
7
9
  var CryptoProvider = require('../crypto/CryptoProvider.cjs');
@@ -13,339 +15,339 @@ var packageMetadata = require('../packageMetadata.cjs');
13
15
  var NodeAuthError = require('../error/NodeAuthError.cjs');
14
16
  var UsernamePasswordClient = require('./UsernamePasswordClient.cjs');
15
17
 
16
- /*
17
- * Copyright (c) Microsoft Corporation. All rights reserved.
18
- * Licensed under the MIT License.
19
- */
20
- /**
21
- * Base abstract class for all ClientApplications - public and confidential
22
- * @public
23
- */
24
- class ClientApplication {
25
- /**
26
- * Constructor for the ClientApplication
27
- */
28
- constructor(configuration) {
29
- this.config = Configuration.buildAppConfiguration(configuration);
30
- this.cryptoProvider = new CryptoProvider.CryptoProvider();
31
- this.logger = new msalCommon.Logger(this.config.system.loggerOptions, packageMetadata.name, packageMetadata.version);
32
- this.storage = new NodeStorage.NodeStorage(this.logger, this.config.auth.clientId, this.cryptoProvider, msalCommon.buildStaticAuthorityOptions(this.config.auth));
33
- this.tokenCache = new TokenCache.TokenCache(this.storage, this.logger, this.config.cache.cachePlugin);
34
- }
35
- /**
36
- * Creates the URL of the authorization request, letting the user input credentials and consent to the
37
- * application. The URL targets the /authorize endpoint of the authority configured in the
38
- * application object.
39
- *
40
- * Once the user inputs their credentials and consents, the authority will send a response to the redirect URI
41
- * sent in the request and should contain an authorization code, which can then be used to acquire tokens via
42
- * `acquireTokenByCode(AuthorizationCodeRequest)`.
43
- */
44
- async getAuthCodeUrl(request) {
45
- this.logger.info("getAuthCodeUrl called", request.correlationId);
46
- const validRequest = {
47
- ...request,
48
- ...(await this.initializeBaseRequest(request)),
49
- responseMode: request.responseMode || msalCommon.ResponseMode.QUERY,
50
- authenticationScheme: msalCommon.AuthenticationScheme.BEARER,
51
- };
52
- const authClientConfig = await this.buildOauthClientConfiguration(validRequest.authority, validRequest.correlationId, undefined, undefined, request.azureCloudOptions);
53
- const authorizationCodeClient = new msalCommon.AuthorizationCodeClient(authClientConfig);
54
- this.logger.verbose("Auth code client created", validRequest.correlationId);
55
- return authorizationCodeClient.getAuthCodeUrl(validRequest);
56
- }
57
- /**
58
- * Acquires a token by exchanging the Authorization Code received from the first step of OAuth2.0
59
- * Authorization Code flow.
60
- *
61
- * `getAuthCodeUrl(AuthorizationCodeUrlRequest)` can be used to create the URL for the first step of OAuth2.0
62
- * Authorization Code flow. Ensure that values for redirectUri and scopes in AuthorizationCodeUrlRequest and
63
- * AuthorizationCodeRequest are the same.
64
- */
65
- async acquireTokenByCode(request, authCodePayLoad) {
66
- this.logger.info("acquireTokenByCode called");
67
- if (request.state && authCodePayLoad) {
68
- this.logger.info("acquireTokenByCode - validating state");
69
- this.validateState(request.state, authCodePayLoad.state || "");
70
- // eslint-disable-next-line no-param-reassign
71
- authCodePayLoad = { ...authCodePayLoad, state: "" };
72
- }
73
- const validRequest = {
74
- ...request,
75
- ...(await this.initializeBaseRequest(request)),
76
- authenticationScheme: msalCommon.AuthenticationScheme.BEARER,
77
- };
78
- const serverTelemetryManager = this.initializeServerTelemetryManager(Constants.ApiId.acquireTokenByCode, validRequest.correlationId);
79
- try {
80
- const authClientConfig = await this.buildOauthClientConfiguration(validRequest.authority, validRequest.correlationId, serverTelemetryManager, undefined, request.azureCloudOptions);
81
- const authorizationCodeClient = new msalCommon.AuthorizationCodeClient(authClientConfig);
82
- this.logger.verbose("Auth code client created", validRequest.correlationId);
83
- return await authorizationCodeClient.acquireToken(validRequest, authCodePayLoad);
84
- }
85
- catch (e) {
86
- if (e instanceof msalCommon.AuthError) {
87
- e.setCorrelationId(validRequest.correlationId);
88
- }
89
- serverTelemetryManager.cacheFailedRequest(e);
90
- throw e;
91
- }
92
- }
93
- /**
94
- * Acquires a token by exchanging the refresh token provided for a new set of tokens.
95
- *
96
- * This API is provided only for scenarios where you would like to migrate from ADAL to MSAL. Otherwise, it is
97
- * recommended that you use `acquireTokenSilent()` for silent scenarios. When using `acquireTokenSilent()`, MSAL will
98
- * handle the caching and refreshing of tokens automatically.
99
- */
100
- async acquireTokenByRefreshToken(request) {
101
- this.logger.info("acquireTokenByRefreshToken called", request.correlationId);
102
- const validRequest = {
103
- ...request,
104
- ...(await this.initializeBaseRequest(request)),
105
- authenticationScheme: msalCommon.AuthenticationScheme.BEARER,
106
- };
107
- const serverTelemetryManager = this.initializeServerTelemetryManager(Constants.ApiId.acquireTokenByRefreshToken, validRequest.correlationId);
108
- try {
109
- const refreshTokenClientConfig = await this.buildOauthClientConfiguration(validRequest.authority, validRequest.correlationId, serverTelemetryManager, undefined, request.azureCloudOptions);
110
- const refreshTokenClient = new msalCommon.RefreshTokenClient(refreshTokenClientConfig);
111
- this.logger.verbose("Refresh token client created", validRequest.correlationId);
112
- return await refreshTokenClient.acquireToken(validRequest);
113
- }
114
- catch (e) {
115
- if (e instanceof msalCommon.AuthError) {
116
- e.setCorrelationId(validRequest.correlationId);
117
- }
118
- serverTelemetryManager.cacheFailedRequest(e);
119
- throw e;
120
- }
121
- }
122
- /**
123
- * Acquires a token silently when a user specifies the account the token is requested for.
124
- *
125
- * This API expects the user to provide an account object and looks into the cache to retrieve the token if present.
126
- * There is also an optional "forceRefresh" boolean the user can send to bypass the cache for access_token and id_token.
127
- * In case the refresh_token is expired or not found, an error is thrown
128
- * and the guidance is for the user to call any interactive token acquisition API (eg: `acquireTokenByCode()`).
129
- */
130
- async acquireTokenSilent(request) {
131
- const validRequest = {
132
- ...request,
133
- ...(await this.initializeBaseRequest(request)),
134
- forceRefresh: request.forceRefresh || false,
135
- };
136
- const serverTelemetryManager = this.initializeServerTelemetryManager(Constants.ApiId.acquireTokenSilent, validRequest.correlationId, validRequest.forceRefresh);
137
- try {
138
- const silentFlowClientConfig = await this.buildOauthClientConfiguration(validRequest.authority, validRequest.correlationId, serverTelemetryManager, undefined, request.azureCloudOptions);
139
- const silentFlowClient = new msalCommon.SilentFlowClient(silentFlowClientConfig);
140
- this.logger.verbose("Silent flow client created", validRequest.correlationId);
141
- return await silentFlowClient.acquireToken(validRequest);
142
- }
143
- catch (e) {
144
- if (e instanceof msalCommon.AuthError) {
145
- e.setCorrelationId(validRequest.correlationId);
146
- }
147
- serverTelemetryManager.cacheFailedRequest(e);
148
- throw e;
149
- }
150
- }
151
- /**
152
- * Acquires tokens with password grant by exchanging client applications username and password for credentials
153
- *
154
- * The latest OAuth 2.0 Security Best Current Practice disallows the password grant entirely.
155
- * More details on this recommendation at https://tools.ietf.org/html/draft-ietf-oauth-security-topics-13#section-3.4
156
- * Microsoft's documentation and recommendations are at:
157
- * https://docs.microsoft.com/en-us/azure/active-directory/develop/msal-authentication-flows#usernamepassword
158
- *
159
- * @param request - UsenamePasswordRequest
160
- */
161
- async acquireTokenByUsernamePassword(request) {
162
- this.logger.info("acquireTokenByUsernamePassword called", request.correlationId);
163
- const validRequest = {
164
- ...request,
165
- ...(await this.initializeBaseRequest(request)),
166
- };
167
- const serverTelemetryManager = this.initializeServerTelemetryManager(Constants.ApiId.acquireTokenByUsernamePassword, validRequest.correlationId);
168
- try {
169
- const usernamePasswordClientConfig = await this.buildOauthClientConfiguration(validRequest.authority, validRequest.correlationId, serverTelemetryManager, undefined, request.azureCloudOptions);
170
- const usernamePasswordClient = new UsernamePasswordClient.UsernamePasswordClient(usernamePasswordClientConfig);
171
- this.logger.verbose("Username password client created", validRequest.correlationId);
172
- return await usernamePasswordClient.acquireToken(validRequest);
173
- }
174
- catch (e) {
175
- if (e instanceof msalCommon.AuthError) {
176
- e.setCorrelationId(validRequest.correlationId);
177
- }
178
- serverTelemetryManager.cacheFailedRequest(e);
179
- throw e;
180
- }
181
- }
182
- /**
183
- * Gets the token cache for the application.
184
- */
185
- getTokenCache() {
186
- this.logger.info("getTokenCache called");
187
- return this.tokenCache;
188
- }
189
- /**
190
- * Validates OIDC state by comparing the user cached state with the state received from the server.
191
- *
192
- * This API is provided for scenarios where you would use OAuth2.0 state parameter to mitigate against
193
- * CSRF attacks.
194
- * For more information about state, visit https://datatracker.ietf.org/doc/html/rfc6819#section-3.6.
195
- * @param state
196
- * @param cachedState
197
- */
198
- validateState(state, cachedState) {
199
- if (!state) {
200
- throw NodeAuthError.NodeAuthError.createStateNotFoundError();
201
- }
202
- if (state !== cachedState) {
203
- throw msalCommon.createClientAuthError(msalCommon.ClientAuthErrorCodes.stateMismatch);
204
- }
205
- }
206
- /**
207
- * Returns the logger instance
208
- */
209
- getLogger() {
210
- return this.logger;
211
- }
212
- /**
213
- * Replaces the default logger set in configurations with new Logger with new configurations
214
- * @param logger - Logger instance
215
- */
216
- setLogger(logger) {
217
- this.logger = logger;
218
- }
219
- /**
220
- * Builds the common configuration to be passed to the common component based on the platform configurarion
221
- * @param authority - user passed authority in configuration
222
- * @param serverTelemetryManager - initializes servertelemetry if passed
223
- */
224
- async buildOauthClientConfiguration(authority, requestCorrelationId, serverTelemetryManager, azureRegionConfiguration, azureCloudOptions) {
225
- this.logger.verbose("buildOauthClientConfiguration called", requestCorrelationId);
226
- // precedence - azureCloudInstance + tenant >> authority and request >> config
227
- const userAzureCloudOptions = azureCloudOptions
228
- ? azureCloudOptions
229
- : this.config.auth.azureCloudOptions;
230
- // using null assertion operator as we ensure that all config values have default values in buildConfiguration()
231
- const discoveredAuthority = await this.createAuthority(authority, requestCorrelationId, azureRegionConfiguration, userAzureCloudOptions);
232
- this.logger.info(`Building oauth client configuration with the following authority: ${discoveredAuthority.tokenEndpoint}.`, requestCorrelationId);
233
- serverTelemetryManager?.updateRegionDiscoveryMetadata(discoveredAuthority.regionDiscoveryMetadata);
234
- const clientConfiguration = {
235
- authOptions: {
236
- clientId: this.config.auth.clientId,
237
- authority: discoveredAuthority,
238
- clientCapabilities: this.config.auth.clientCapabilities,
239
- },
240
- loggerOptions: {
241
- logLevel: this.config.system.loggerOptions.logLevel,
242
- loggerCallback: this.config.system.loggerOptions.loggerCallback,
243
- piiLoggingEnabled: this.config.system.loggerOptions.piiLoggingEnabled,
244
- correlationId: requestCorrelationId,
245
- },
246
- cacheOptions: {
247
- claimsBasedCachingEnabled: this.config.cache.claimsBasedCachingEnabled,
248
- },
249
- cryptoInterface: this.cryptoProvider,
250
- networkInterface: this.config.system.networkClient,
251
- storageInterface: this.storage,
252
- serverTelemetryManager: serverTelemetryManager,
253
- clientCredentials: {
254
- clientSecret: this.clientSecret,
255
- clientAssertion: await this.getClientAssertion(discoveredAuthority),
256
- },
257
- libraryInfo: {
258
- sku: Constants.Constants.MSAL_SKU,
259
- version: packageMetadata.version,
260
- cpu: process.arch || msalCommon.Constants.EMPTY_STRING,
261
- os: process.platform || msalCommon.Constants.EMPTY_STRING,
262
- },
263
- telemetry: this.config.telemetry,
264
- persistencePlugin: this.config.cache.cachePlugin,
265
- serializableCache: this.tokenCache,
266
- };
267
- return clientConfiguration;
268
- }
269
- async getClientAssertion(authority) {
270
- if (this.developerProvidedClientAssertion) {
271
- this.clientAssertion = ClientAssertion.ClientAssertion.fromAssertion(await msalCommon.getClientAssertion(this.developerProvidedClientAssertion, this.config.auth.clientId, authority.tokenEndpoint));
272
- }
273
- return (this.clientAssertion && {
274
- assertion: this.clientAssertion.getJwt(this.cryptoProvider, this.config.auth.clientId, authority.tokenEndpoint),
275
- assertionType: Constants.Constants.JWT_BEARER_ASSERTION_TYPE,
276
- });
277
- }
278
- /**
279
- * Generates a request with the default scopes & generates a correlationId.
280
- * @param authRequest - BaseAuthRequest for initialization
281
- */
282
- async initializeBaseRequest(authRequest) {
283
- this.logger.verbose("initializeRequestScopes called", authRequest.correlationId);
284
- // Default authenticationScheme to Bearer, log that POP isn't supported yet
285
- if (authRequest.authenticationScheme &&
286
- authRequest.authenticationScheme === msalCommon.AuthenticationScheme.POP) {
287
- this.logger.verbose("Authentication Scheme 'pop' is not supported yet, setting Authentication Scheme to 'Bearer' for request", authRequest.correlationId);
288
- }
289
- authRequest.authenticationScheme = msalCommon.AuthenticationScheme.BEARER;
290
- // Set requested claims hash if claims-based caching is enabled and claims were requested
291
- if (this.config.cache.claimsBasedCachingEnabled &&
292
- authRequest.claims &&
293
- // Checks for empty stringified object "{}" which doesn't qualify as requested claims
294
- !msalCommon.StringUtils.isEmptyObj(authRequest.claims)) {
295
- authRequest.requestedClaimsHash =
296
- await this.cryptoProvider.hashString(authRequest.claims);
297
- }
298
- return {
299
- ...authRequest,
300
- scopes: [
301
- ...((authRequest && authRequest.scopes) || []),
302
- ...msalCommon.OIDC_DEFAULT_SCOPES,
303
- ],
304
- correlationId: (authRequest && authRequest.correlationId) ||
305
- this.cryptoProvider.createNewGuid(),
306
- authority: authRequest.authority || this.config.auth.authority,
307
- };
308
- }
309
- /**
310
- * Initializes the server telemetry payload
311
- * @param apiId - Id for a specific request
312
- * @param correlationId - GUID
313
- * @param forceRefresh - boolean to indicate network call
314
- */
315
- initializeServerTelemetryManager(apiId, correlationId, forceRefresh) {
316
- const telemetryPayload = {
317
- clientId: this.config.auth.clientId,
318
- correlationId: correlationId,
319
- apiId: apiId,
320
- forceRefresh: forceRefresh || false,
321
- };
322
- return new msalCommon.ServerTelemetryManager(telemetryPayload, this.storage);
323
- }
324
- /**
325
- * Create authority instance. If authority not passed in request, default to authority set on the application
326
- * object. If no authority set in application object, then default to common authority.
327
- * @param authorityString - authority from user configuration
328
- */
329
- async createAuthority(authorityString, requestCorrelationId, azureRegionConfiguration, azureCloudOptions) {
330
- this.logger.verbose("createAuthority called", requestCorrelationId);
331
- // build authority string based on auth params - azureCloudInstance is prioritized if provided
332
- const authorityUrl = msalCommon.Authority.generateAuthority(authorityString, azureCloudOptions);
333
- const authorityOptions = {
334
- protocolMode: this.config.auth.protocolMode,
335
- knownAuthorities: this.config.auth.knownAuthorities,
336
- cloudDiscoveryMetadata: this.config.auth.cloudDiscoveryMetadata,
337
- authorityMetadata: this.config.auth.authorityMetadata,
338
- azureRegionConfiguration,
339
- skipAuthorityMetadataCache: this.config.auth.skipAuthorityMetadataCache,
340
- };
341
- return msalCommon.AuthorityFactory.createDiscoveredInstance(authorityUrl, this.config.system.networkClient, this.storage, authorityOptions, this.logger, requestCorrelationId);
342
- }
343
- /**
344
- * Clear the cache
345
- */
346
- clearCache() {
347
- void this.storage.clear();
348
- }
18
+ /*
19
+ * Copyright (c) Microsoft Corporation. All rights reserved.
20
+ * Licensed under the MIT License.
21
+ */
22
+ /**
23
+ * Base abstract class for all ClientApplications - public and confidential
24
+ * @public
25
+ */
26
+ class ClientApplication {
27
+ /**
28
+ * Constructor for the ClientApplication
29
+ */
30
+ constructor(configuration) {
31
+ this.config = Configuration.buildAppConfiguration(configuration);
32
+ this.cryptoProvider = new CryptoProvider.CryptoProvider();
33
+ this.logger = new msalCommon.Logger(this.config.system.loggerOptions, packageMetadata.name, packageMetadata.version);
34
+ this.storage = new NodeStorage.NodeStorage(this.logger, this.config.auth.clientId, this.cryptoProvider, msalCommon.buildStaticAuthorityOptions(this.config.auth));
35
+ this.tokenCache = new TokenCache.TokenCache(this.storage, this.logger, this.config.cache.cachePlugin);
36
+ }
37
+ /**
38
+ * Creates the URL of the authorization request, letting the user input credentials and consent to the
39
+ * application. The URL targets the /authorize endpoint of the authority configured in the
40
+ * application object.
41
+ *
42
+ * Once the user inputs their credentials and consents, the authority will send a response to the redirect URI
43
+ * sent in the request and should contain an authorization code, which can then be used to acquire tokens via
44
+ * `acquireTokenByCode(AuthorizationCodeRequest)`.
45
+ */
46
+ async getAuthCodeUrl(request) {
47
+ this.logger.info("getAuthCodeUrl called", request.correlationId);
48
+ const validRequest = {
49
+ ...request,
50
+ ...(await this.initializeBaseRequest(request)),
51
+ responseMode: request.responseMode || msalCommon.ResponseMode.QUERY,
52
+ authenticationScheme: msalCommon.AuthenticationScheme.BEARER,
53
+ };
54
+ const authClientConfig = await this.buildOauthClientConfiguration(validRequest.authority, validRequest.correlationId, undefined, undefined, request.azureCloudOptions);
55
+ const authorizationCodeClient = new msalCommon.AuthorizationCodeClient(authClientConfig);
56
+ this.logger.verbose("Auth code client created", validRequest.correlationId);
57
+ return authorizationCodeClient.getAuthCodeUrl(validRequest);
58
+ }
59
+ /**
60
+ * Acquires a token by exchanging the Authorization Code received from the first step of OAuth2.0
61
+ * Authorization Code flow.
62
+ *
63
+ * `getAuthCodeUrl(AuthorizationCodeUrlRequest)` can be used to create the URL for the first step of OAuth2.0
64
+ * Authorization Code flow. Ensure that values for redirectUri and scopes in AuthorizationCodeUrlRequest and
65
+ * AuthorizationCodeRequest are the same.
66
+ */
67
+ async acquireTokenByCode(request, authCodePayLoad) {
68
+ this.logger.info("acquireTokenByCode called");
69
+ if (request.state && authCodePayLoad) {
70
+ this.logger.info("acquireTokenByCode - validating state");
71
+ this.validateState(request.state, authCodePayLoad.state || "");
72
+ // eslint-disable-next-line no-param-reassign
73
+ authCodePayLoad = { ...authCodePayLoad, state: "" };
74
+ }
75
+ const validRequest = {
76
+ ...request,
77
+ ...(await this.initializeBaseRequest(request)),
78
+ authenticationScheme: msalCommon.AuthenticationScheme.BEARER,
79
+ };
80
+ const serverTelemetryManager = this.initializeServerTelemetryManager(Constants.ApiId.acquireTokenByCode, validRequest.correlationId);
81
+ try {
82
+ const authClientConfig = await this.buildOauthClientConfiguration(validRequest.authority, validRequest.correlationId, serverTelemetryManager, undefined, request.azureCloudOptions);
83
+ const authorizationCodeClient = new msalCommon.AuthorizationCodeClient(authClientConfig);
84
+ this.logger.verbose("Auth code client created", validRequest.correlationId);
85
+ return await authorizationCodeClient.acquireToken(validRequest, authCodePayLoad);
86
+ }
87
+ catch (e) {
88
+ if (e instanceof msalCommon.AuthError) {
89
+ e.setCorrelationId(validRequest.correlationId);
90
+ }
91
+ serverTelemetryManager.cacheFailedRequest(e);
92
+ throw e;
93
+ }
94
+ }
95
+ /**
96
+ * Acquires a token by exchanging the refresh token provided for a new set of tokens.
97
+ *
98
+ * This API is provided only for scenarios where you would like to migrate from ADAL to MSAL. Otherwise, it is
99
+ * recommended that you use `acquireTokenSilent()` for silent scenarios. When using `acquireTokenSilent()`, MSAL will
100
+ * handle the caching and refreshing of tokens automatically.
101
+ */
102
+ async acquireTokenByRefreshToken(request) {
103
+ this.logger.info("acquireTokenByRefreshToken called", request.correlationId);
104
+ const validRequest = {
105
+ ...request,
106
+ ...(await this.initializeBaseRequest(request)),
107
+ authenticationScheme: msalCommon.AuthenticationScheme.BEARER,
108
+ };
109
+ const serverTelemetryManager = this.initializeServerTelemetryManager(Constants.ApiId.acquireTokenByRefreshToken, validRequest.correlationId);
110
+ try {
111
+ const refreshTokenClientConfig = await this.buildOauthClientConfiguration(validRequest.authority, validRequest.correlationId, serverTelemetryManager, undefined, request.azureCloudOptions);
112
+ const refreshTokenClient = new msalCommon.RefreshTokenClient(refreshTokenClientConfig);
113
+ this.logger.verbose("Refresh token client created", validRequest.correlationId);
114
+ return await refreshTokenClient.acquireToken(validRequest);
115
+ }
116
+ catch (e) {
117
+ if (e instanceof msalCommon.AuthError) {
118
+ e.setCorrelationId(validRequest.correlationId);
119
+ }
120
+ serverTelemetryManager.cacheFailedRequest(e);
121
+ throw e;
122
+ }
123
+ }
124
+ /**
125
+ * Acquires a token silently when a user specifies the account the token is requested for.
126
+ *
127
+ * This API expects the user to provide an account object and looks into the cache to retrieve the token if present.
128
+ * There is also an optional "forceRefresh" boolean the user can send to bypass the cache for access_token and id_token.
129
+ * In case the refresh_token is expired or not found, an error is thrown
130
+ * and the guidance is for the user to call any interactive token acquisition API (eg: `acquireTokenByCode()`).
131
+ */
132
+ async acquireTokenSilent(request) {
133
+ const validRequest = {
134
+ ...request,
135
+ ...(await this.initializeBaseRequest(request)),
136
+ forceRefresh: request.forceRefresh || false,
137
+ };
138
+ const serverTelemetryManager = this.initializeServerTelemetryManager(Constants.ApiId.acquireTokenSilent, validRequest.correlationId, validRequest.forceRefresh);
139
+ try {
140
+ const silentFlowClientConfig = await this.buildOauthClientConfiguration(validRequest.authority, validRequest.correlationId, serverTelemetryManager, undefined, request.azureCloudOptions);
141
+ const silentFlowClient = new msalCommon.SilentFlowClient(silentFlowClientConfig);
142
+ this.logger.verbose("Silent flow client created", validRequest.correlationId);
143
+ return await silentFlowClient.acquireToken(validRequest);
144
+ }
145
+ catch (e) {
146
+ if (e instanceof msalCommon.AuthError) {
147
+ e.setCorrelationId(validRequest.correlationId);
148
+ }
149
+ serverTelemetryManager.cacheFailedRequest(e);
150
+ throw e;
151
+ }
152
+ }
153
+ /**
154
+ * Acquires tokens with password grant by exchanging client applications username and password for credentials
155
+ *
156
+ * The latest OAuth 2.0 Security Best Current Practice disallows the password grant entirely.
157
+ * More details on this recommendation at https://tools.ietf.org/html/draft-ietf-oauth-security-topics-13#section-3.4
158
+ * Microsoft's documentation and recommendations are at:
159
+ * https://docs.microsoft.com/en-us/azure/active-directory/develop/msal-authentication-flows#usernamepassword
160
+ *
161
+ * @param request - UsenamePasswordRequest
162
+ */
163
+ async acquireTokenByUsernamePassword(request) {
164
+ this.logger.info("acquireTokenByUsernamePassword called", request.correlationId);
165
+ const validRequest = {
166
+ ...request,
167
+ ...(await this.initializeBaseRequest(request)),
168
+ };
169
+ const serverTelemetryManager = this.initializeServerTelemetryManager(Constants.ApiId.acquireTokenByUsernamePassword, validRequest.correlationId);
170
+ try {
171
+ const usernamePasswordClientConfig = await this.buildOauthClientConfiguration(validRequest.authority, validRequest.correlationId, serverTelemetryManager, undefined, request.azureCloudOptions);
172
+ const usernamePasswordClient = new UsernamePasswordClient.UsernamePasswordClient(usernamePasswordClientConfig);
173
+ this.logger.verbose("Username password client created", validRequest.correlationId);
174
+ return await usernamePasswordClient.acquireToken(validRequest);
175
+ }
176
+ catch (e) {
177
+ if (e instanceof msalCommon.AuthError) {
178
+ e.setCorrelationId(validRequest.correlationId);
179
+ }
180
+ serverTelemetryManager.cacheFailedRequest(e);
181
+ throw e;
182
+ }
183
+ }
184
+ /**
185
+ * Gets the token cache for the application.
186
+ */
187
+ getTokenCache() {
188
+ this.logger.info("getTokenCache called");
189
+ return this.tokenCache;
190
+ }
191
+ /**
192
+ * Validates OIDC state by comparing the user cached state with the state received from the server.
193
+ *
194
+ * This API is provided for scenarios where you would use OAuth2.0 state parameter to mitigate against
195
+ * CSRF attacks.
196
+ * For more information about state, visit https://datatracker.ietf.org/doc/html/rfc6819#section-3.6.
197
+ * @param state
198
+ * @param cachedState
199
+ */
200
+ validateState(state, cachedState) {
201
+ if (!state) {
202
+ throw NodeAuthError.NodeAuthError.createStateNotFoundError();
203
+ }
204
+ if (state !== cachedState) {
205
+ throw msalCommon.createClientAuthError(msalCommon.ClientAuthErrorCodes.stateMismatch);
206
+ }
207
+ }
208
+ /**
209
+ * Returns the logger instance
210
+ */
211
+ getLogger() {
212
+ return this.logger;
213
+ }
214
+ /**
215
+ * Replaces the default logger set in configurations with new Logger with new configurations
216
+ * @param logger - Logger instance
217
+ */
218
+ setLogger(logger) {
219
+ this.logger = logger;
220
+ }
221
+ /**
222
+ * Builds the common configuration to be passed to the common component based on the platform configurarion
223
+ * @param authority - user passed authority in configuration
224
+ * @param serverTelemetryManager - initializes servertelemetry if passed
225
+ */
226
+ async buildOauthClientConfiguration(authority, requestCorrelationId, serverTelemetryManager, azureRegionConfiguration, azureCloudOptions) {
227
+ this.logger.verbose("buildOauthClientConfiguration called", requestCorrelationId);
228
+ // precedence - azureCloudInstance + tenant >> authority and request >> config
229
+ const userAzureCloudOptions = azureCloudOptions
230
+ ? azureCloudOptions
231
+ : this.config.auth.azureCloudOptions;
232
+ // using null assertion operator as we ensure that all config values have default values in buildConfiguration()
233
+ const discoveredAuthority = await this.createAuthority(authority, requestCorrelationId, azureRegionConfiguration, userAzureCloudOptions);
234
+ this.logger.info(`Building oauth client configuration with the following authority: ${discoveredAuthority.tokenEndpoint}.`, requestCorrelationId);
235
+ serverTelemetryManager?.updateRegionDiscoveryMetadata(discoveredAuthority.regionDiscoveryMetadata);
236
+ const clientConfiguration = {
237
+ authOptions: {
238
+ clientId: this.config.auth.clientId,
239
+ authority: discoveredAuthority,
240
+ clientCapabilities: this.config.auth.clientCapabilities,
241
+ },
242
+ loggerOptions: {
243
+ logLevel: this.config.system.loggerOptions.logLevel,
244
+ loggerCallback: this.config.system.loggerOptions.loggerCallback,
245
+ piiLoggingEnabled: this.config.system.loggerOptions.piiLoggingEnabled,
246
+ correlationId: requestCorrelationId,
247
+ },
248
+ cacheOptions: {
249
+ claimsBasedCachingEnabled: this.config.cache.claimsBasedCachingEnabled,
250
+ },
251
+ cryptoInterface: this.cryptoProvider,
252
+ networkInterface: this.config.system.networkClient,
253
+ storageInterface: this.storage,
254
+ serverTelemetryManager: serverTelemetryManager,
255
+ clientCredentials: {
256
+ clientSecret: this.clientSecret,
257
+ clientAssertion: await this.getClientAssertion(discoveredAuthority),
258
+ },
259
+ libraryInfo: {
260
+ sku: Constants.Constants.MSAL_SKU,
261
+ version: packageMetadata.version,
262
+ cpu: process.arch || msalCommon.Constants.EMPTY_STRING,
263
+ os: process.platform || msalCommon.Constants.EMPTY_STRING,
264
+ },
265
+ telemetry: this.config.telemetry,
266
+ persistencePlugin: this.config.cache.cachePlugin,
267
+ serializableCache: this.tokenCache,
268
+ };
269
+ return clientConfiguration;
270
+ }
271
+ async getClientAssertion(authority) {
272
+ if (this.developerProvidedClientAssertion) {
273
+ this.clientAssertion = ClientAssertion.ClientAssertion.fromAssertion(await msalCommon.getClientAssertion(this.developerProvidedClientAssertion, this.config.auth.clientId, authority.tokenEndpoint));
274
+ }
275
+ return (this.clientAssertion && {
276
+ assertion: this.clientAssertion.getJwt(this.cryptoProvider, this.config.auth.clientId, authority.tokenEndpoint),
277
+ assertionType: Constants.Constants.JWT_BEARER_ASSERTION_TYPE,
278
+ });
279
+ }
280
+ /**
281
+ * Generates a request with the default scopes & generates a correlationId.
282
+ * @param authRequest - BaseAuthRequest for initialization
283
+ */
284
+ async initializeBaseRequest(authRequest) {
285
+ this.logger.verbose("initializeRequestScopes called", authRequest.correlationId);
286
+ // Default authenticationScheme to Bearer, log that POP isn't supported yet
287
+ if (authRequest.authenticationScheme &&
288
+ authRequest.authenticationScheme === msalCommon.AuthenticationScheme.POP) {
289
+ this.logger.verbose("Authentication Scheme 'pop' is not supported yet, setting Authentication Scheme to 'Bearer' for request", authRequest.correlationId);
290
+ }
291
+ authRequest.authenticationScheme = msalCommon.AuthenticationScheme.BEARER;
292
+ // Set requested claims hash if claims-based caching is enabled and claims were requested
293
+ if (this.config.cache.claimsBasedCachingEnabled &&
294
+ authRequest.claims &&
295
+ // Checks for empty stringified object "{}" which doesn't qualify as requested claims
296
+ !msalCommon.StringUtils.isEmptyObj(authRequest.claims)) {
297
+ authRequest.requestedClaimsHash =
298
+ await this.cryptoProvider.hashString(authRequest.claims);
299
+ }
300
+ return {
301
+ ...authRequest,
302
+ scopes: [
303
+ ...((authRequest && authRequest.scopes) || []),
304
+ ...msalCommon.OIDC_DEFAULT_SCOPES,
305
+ ],
306
+ correlationId: (authRequest && authRequest.correlationId) ||
307
+ this.cryptoProvider.createNewGuid(),
308
+ authority: authRequest.authority || this.config.auth.authority,
309
+ };
310
+ }
311
+ /**
312
+ * Initializes the server telemetry payload
313
+ * @param apiId - Id for a specific request
314
+ * @param correlationId - GUID
315
+ * @param forceRefresh - boolean to indicate network call
316
+ */
317
+ initializeServerTelemetryManager(apiId, correlationId, forceRefresh) {
318
+ const telemetryPayload = {
319
+ clientId: this.config.auth.clientId,
320
+ correlationId: correlationId,
321
+ apiId: apiId,
322
+ forceRefresh: forceRefresh || false,
323
+ };
324
+ return new msalCommon.ServerTelemetryManager(telemetryPayload, this.storage);
325
+ }
326
+ /**
327
+ * Create authority instance. If authority not passed in request, default to authority set on the application
328
+ * object. If no authority set in application object, then default to common authority.
329
+ * @param authorityString - authority from user configuration
330
+ */
331
+ async createAuthority(authorityString, requestCorrelationId, azureRegionConfiguration, azureCloudOptions) {
332
+ this.logger.verbose("createAuthority called", requestCorrelationId);
333
+ // build authority string based on auth params - azureCloudInstance is prioritized if provided
334
+ const authorityUrl = msalCommon.Authority.generateAuthority(authorityString, azureCloudOptions);
335
+ const authorityOptions = {
336
+ protocolMode: this.config.auth.protocolMode,
337
+ knownAuthorities: this.config.auth.knownAuthorities,
338
+ cloudDiscoveryMetadata: this.config.auth.cloudDiscoveryMetadata,
339
+ authorityMetadata: this.config.auth.authorityMetadata,
340
+ azureRegionConfiguration,
341
+ skipAuthorityMetadataCache: this.config.auth.skipAuthorityMetadataCache,
342
+ };
343
+ return msalCommon.AuthorityFactory.createDiscoveredInstance(authorityUrl, this.config.system.networkClient, this.storage, authorityOptions, this.logger, requestCorrelationId);
344
+ }
345
+ /**
346
+ * Clear the cache
347
+ */
348
+ clearCache() {
349
+ void this.storage.clear();
350
+ }
349
351
  }
350
352
 
351
353
  exports.ClientApplication = ClientApplication;