@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,211 +1,213 @@
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 EncodingUtils = require('../utils/EncodingUtils.cjs');
7
9
 
8
- /*
9
- * Copyright (c) Microsoft Corporation. All rights reserved.
10
- * Licensed under the MIT License.
11
- */
12
- /**
13
- * On-Behalf-Of client
14
- */
15
- class OnBehalfOfClient extends msalCommon.BaseClient {
16
- constructor(configuration) {
17
- super(configuration);
18
- }
19
- /**
20
- * Public API to acquire tokens with on behalf of flow
21
- * @param request
22
- */
23
- async acquireToken(request) {
24
- this.scopeSet = new msalCommon.ScopeSet(request.scopes || []);
25
- // generate the user_assertion_hash for OBOAssertion
26
- this.userAssertionHash = await this.cryptoUtils.hashString(request.oboAssertion);
27
- if (request.skipCache || request.claims) {
28
- return this.executeTokenRequest(request, this.authority, this.userAssertionHash);
29
- }
30
- try {
31
- return await this.getCachedAuthenticationResult(request);
32
- }
33
- catch (e) {
34
- // Any failure falls back to interactive request, once we implement distributed cache, we plan to handle `createRefreshRequiredError` to refresh using the RT
35
- return await this.executeTokenRequest(request, this.authority, this.userAssertionHash);
36
- }
37
- }
38
- /**
39
- * look up cache for tokens
40
- * Find idtoken in the cache
41
- * Find accessToken based on user assertion and account info in the cache
42
- * Please note we are not yet supported OBO tokens refreshed with long lived RT. User will have to send a new assertion if the current access token expires
43
- * This is to prevent security issues when the assertion changes over time, however, longlived RT helps retaining the session
44
- * @param request
45
- */
46
- async getCachedAuthenticationResult(request) {
47
- // look in the cache for the access_token which matches the incoming_assertion
48
- const cachedAccessToken = this.readAccessTokenFromCacheForOBO(this.config.authOptions.clientId, request);
49
- if (!cachedAccessToken) {
50
- // Must refresh due to non-existent access_token.
51
- this.serverTelemetryManager?.setCacheOutcome(msalCommon.CacheOutcome.NO_CACHED_ACCESS_TOKEN);
52
- this.logger.info("SilentFlowClient:acquireCachedToken - No access token found in cache for the given properties.");
53
- throw msalCommon.createClientAuthError(msalCommon.ClientAuthErrorCodes.tokenRefreshRequired);
54
- }
55
- else if (msalCommon.TimeUtils.isTokenExpired(cachedAccessToken.expiresOn, this.config.systemOptions.tokenRenewalOffsetSeconds)) {
56
- // Access token expired, will need to renewed
57
- this.serverTelemetryManager?.setCacheOutcome(msalCommon.CacheOutcome.CACHED_ACCESS_TOKEN_EXPIRED);
58
- this.logger.info(`OnbehalfofFlow:getCachedAuthenticationResult - Cached access token is expired or will expire within ${this.config.systemOptions.tokenRenewalOffsetSeconds} seconds.`);
59
- throw msalCommon.createClientAuthError(msalCommon.ClientAuthErrorCodes.tokenRefreshRequired);
60
- }
61
- // fetch the idToken from cache
62
- const cachedIdToken = this.readIdTokenFromCacheForOBO(cachedAccessToken.homeAccountId);
63
- let idTokenClaims;
64
- let cachedAccount = null;
65
- if (cachedIdToken) {
66
- idTokenClaims = msalCommon.AuthToken.extractTokenClaims(cachedIdToken.secret, EncodingUtils.EncodingUtils.base64Decode);
67
- const localAccountId = idTokenClaims.oid || idTokenClaims.sub;
68
- const accountInfo = {
69
- homeAccountId: cachedIdToken.homeAccountId,
70
- environment: cachedIdToken.environment,
71
- tenantId: cachedIdToken.realm,
72
- username: msalCommon.Constants.EMPTY_STRING,
73
- localAccountId: localAccountId || msalCommon.Constants.EMPTY_STRING,
74
- };
75
- cachedAccount = this.cacheManager.readAccountFromCache(accountInfo);
76
- }
77
- // increment telemetry cache hit counter
78
- if (this.config.serverTelemetryManager) {
79
- this.config.serverTelemetryManager.incrementCacheHits();
80
- }
81
- return msalCommon.ResponseHandler.generateAuthenticationResult(this.cryptoUtils, this.authority, {
82
- account: cachedAccount,
83
- accessToken: cachedAccessToken,
84
- idToken: cachedIdToken,
85
- refreshToken: null,
86
- appMetadata: null,
87
- }, true, request, idTokenClaims);
88
- }
89
- /**
90
- * read idtoken from cache, this is a specific implementation for OBO as the requirements differ from a generic lookup in the cacheManager
91
- * Certain use cases of OBO flow do not expect an idToken in the cache/or from the service
92
- * @param atHomeAccountId {string}
93
- */
94
- readIdTokenFromCacheForOBO(atHomeAccountId) {
95
- const idTokenFilter = {
96
- homeAccountId: atHomeAccountId,
97
- environment: this.authority.canonicalAuthorityUrlComponents.HostNameAndPort,
98
- credentialType: msalCommon.CredentialType.ID_TOKEN,
99
- clientId: this.config.authOptions.clientId,
100
- realm: this.authority.tenant,
101
- };
102
- const idTokenMap = this.cacheManager.getIdTokensByFilter(idTokenFilter);
103
- // When acquiring a token on behalf of an application, there might not be an id token in the cache
104
- if (Object.values(idTokenMap).length < 1) {
105
- return null;
106
- }
107
- return Object.values(idTokenMap)[0];
108
- }
109
- /**
110
- * Fetches the cached access token based on incoming assertion
111
- * @param clientId
112
- * @param request
113
- * @param userAssertionHash
114
- */
115
- readAccessTokenFromCacheForOBO(clientId, request) {
116
- const authScheme = request.authenticationScheme || msalCommon.AuthenticationScheme.BEARER;
117
- /*
118
- * Distinguish between Bearer and PoP/SSH token cache types
119
- * Cast to lowercase to handle "bearer" from ADFS
120
- */
121
- const credentialType = authScheme &&
122
- authScheme.toLowerCase() !==
123
- msalCommon.AuthenticationScheme.BEARER.toLowerCase()
124
- ? msalCommon.CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME
125
- : msalCommon.CredentialType.ACCESS_TOKEN;
126
- const accessTokenFilter = {
127
- credentialType: credentialType,
128
- clientId,
129
- target: msalCommon.ScopeSet.createSearchScopes(this.scopeSet.asArray()),
130
- tokenType: authScheme,
131
- keyId: request.sshKid,
132
- requestedClaimsHash: request.requestedClaimsHash,
133
- userAssertionHash: this.userAssertionHash,
134
- };
135
- const accessTokens = this.cacheManager.getAccessTokensByFilter(accessTokenFilter);
136
- const numAccessTokens = accessTokens.length;
137
- if (numAccessTokens < 1) {
138
- return null;
139
- }
140
- else if (numAccessTokens > 1) {
141
- throw msalCommon.createClientAuthError(msalCommon.ClientAuthErrorCodes.multipleMatchingTokens);
142
- }
143
- return accessTokens[0];
144
- }
145
- /**
146
- * Make a network call to the server requesting credentials
147
- * @param request
148
- * @param authority
149
- */
150
- async executeTokenRequest(request, authority, userAssertionHash) {
151
- const queryParametersString = this.createTokenQueryParameters(request);
152
- const endpoint = msalCommon.UrlString.appendQueryString(authority.tokenEndpoint, queryParametersString);
153
- const requestBody = await this.createTokenRequestBody(request);
154
- const headers = this.createTokenRequestHeaders();
155
- const thumbprint = {
156
- clientId: this.config.authOptions.clientId,
157
- authority: request.authority,
158
- scopes: request.scopes,
159
- claims: request.claims,
160
- authenticationScheme: request.authenticationScheme,
161
- resourceRequestMethod: request.resourceRequestMethod,
162
- resourceRequestUri: request.resourceRequestUri,
163
- shrClaims: request.shrClaims,
164
- sshKid: request.sshKid,
165
- };
166
- const reqTimestamp = msalCommon.TimeUtils.nowSeconds();
167
- const response = await this.executePostToTokenEndpoint(endpoint, requestBody, headers, thumbprint, request.correlationId);
168
- const responseHandler = new msalCommon.ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, this.config.serializableCache, this.config.persistencePlugin);
169
- responseHandler.validateTokenResponse(response.body);
170
- const tokenResponse = await responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request, undefined, userAssertionHash);
171
- return tokenResponse;
172
- }
173
- /**
174
- * generate a server request in accepable format
175
- * @param request
176
- */
177
- async createTokenRequestBody(request) {
178
- const parameterBuilder = new msalCommon.RequestParameterBuilder();
179
- parameterBuilder.addClientId(this.config.authOptions.clientId);
180
- parameterBuilder.addScopes(request.scopes);
181
- parameterBuilder.addGrantType(msalCommon.GrantType.JWT_BEARER);
182
- parameterBuilder.addClientInfo();
183
- parameterBuilder.addLibraryInfo(this.config.libraryInfo);
184
- parameterBuilder.addApplicationTelemetry(this.config.telemetry.application);
185
- parameterBuilder.addThrottling();
186
- if (this.serverTelemetryManager) {
187
- parameterBuilder.addServerTelemetry(this.serverTelemetryManager);
188
- }
189
- const correlationId = request.correlationId ||
190
- this.config.cryptoInterface.createNewGuid();
191
- parameterBuilder.addCorrelationId(correlationId);
192
- parameterBuilder.addRequestTokenUse(msalCommon.AADServerParamKeys.ON_BEHALF_OF);
193
- parameterBuilder.addOboAssertion(request.oboAssertion);
194
- if (this.config.clientCredentials.clientSecret) {
195
- parameterBuilder.addClientSecret(this.config.clientCredentials.clientSecret);
196
- }
197
- const clientAssertion = this.config.clientCredentials.clientAssertion;
198
- if (clientAssertion) {
199
- parameterBuilder.addClientAssertion(await msalCommon.getClientAssertion(clientAssertion.assertion, this.config.authOptions.clientId, request.resourceRequestUri));
200
- parameterBuilder.addClientAssertionType(clientAssertion.assertionType);
201
- }
202
- if (request.claims ||
203
- (this.config.authOptions.clientCapabilities &&
204
- this.config.authOptions.clientCapabilities.length > 0)) {
205
- parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);
206
- }
207
- return parameterBuilder.createQueryString();
208
- }
10
+ /*
11
+ * Copyright (c) Microsoft Corporation. All rights reserved.
12
+ * Licensed under the MIT License.
13
+ */
14
+ /**
15
+ * On-Behalf-Of client
16
+ */
17
+ class OnBehalfOfClient extends msalCommon.BaseClient {
18
+ constructor(configuration) {
19
+ super(configuration);
20
+ }
21
+ /**
22
+ * Public API to acquire tokens with on behalf of flow
23
+ * @param request
24
+ */
25
+ async acquireToken(request) {
26
+ this.scopeSet = new msalCommon.ScopeSet(request.scopes || []);
27
+ // generate the user_assertion_hash for OBOAssertion
28
+ this.userAssertionHash = await this.cryptoUtils.hashString(request.oboAssertion);
29
+ if (request.skipCache || request.claims) {
30
+ return this.executeTokenRequest(request, this.authority, this.userAssertionHash);
31
+ }
32
+ try {
33
+ return await this.getCachedAuthenticationResult(request);
34
+ }
35
+ catch (e) {
36
+ // Any failure falls back to interactive request, once we implement distributed cache, we plan to handle `createRefreshRequiredError` to refresh using the RT
37
+ return await this.executeTokenRequest(request, this.authority, this.userAssertionHash);
38
+ }
39
+ }
40
+ /**
41
+ * look up cache for tokens
42
+ * Find idtoken in the cache
43
+ * Find accessToken based on user assertion and account info in the cache
44
+ * Please note we are not yet supported OBO tokens refreshed with long lived RT. User will have to send a new assertion if the current access token expires
45
+ * This is to prevent security issues when the assertion changes over time, however, longlived RT helps retaining the session
46
+ * @param request
47
+ */
48
+ async getCachedAuthenticationResult(request) {
49
+ // look in the cache for the access_token which matches the incoming_assertion
50
+ const cachedAccessToken = this.readAccessTokenFromCacheForOBO(this.config.authOptions.clientId, request);
51
+ if (!cachedAccessToken) {
52
+ // Must refresh due to non-existent access_token.
53
+ this.serverTelemetryManager?.setCacheOutcome(msalCommon.CacheOutcome.NO_CACHED_ACCESS_TOKEN);
54
+ this.logger.info("SilentFlowClient:acquireCachedToken - No access token found in cache for the given properties.");
55
+ throw msalCommon.createClientAuthError(msalCommon.ClientAuthErrorCodes.tokenRefreshRequired);
56
+ }
57
+ else if (msalCommon.TimeUtils.isTokenExpired(cachedAccessToken.expiresOn, this.config.systemOptions.tokenRenewalOffsetSeconds)) {
58
+ // Access token expired, will need to renewed
59
+ this.serverTelemetryManager?.setCacheOutcome(msalCommon.CacheOutcome.CACHED_ACCESS_TOKEN_EXPIRED);
60
+ this.logger.info(`OnbehalfofFlow:getCachedAuthenticationResult - Cached access token is expired or will expire within ${this.config.systemOptions.tokenRenewalOffsetSeconds} seconds.`);
61
+ throw msalCommon.createClientAuthError(msalCommon.ClientAuthErrorCodes.tokenRefreshRequired);
62
+ }
63
+ // fetch the idToken from cache
64
+ const cachedIdToken = this.readIdTokenFromCacheForOBO(cachedAccessToken.homeAccountId);
65
+ let idTokenClaims;
66
+ let cachedAccount = null;
67
+ if (cachedIdToken) {
68
+ idTokenClaims = msalCommon.AuthToken.extractTokenClaims(cachedIdToken.secret, EncodingUtils.EncodingUtils.base64Decode);
69
+ const localAccountId = idTokenClaims.oid || idTokenClaims.sub;
70
+ const accountInfo = {
71
+ homeAccountId: cachedIdToken.homeAccountId,
72
+ environment: cachedIdToken.environment,
73
+ tenantId: cachedIdToken.realm,
74
+ username: msalCommon.Constants.EMPTY_STRING,
75
+ localAccountId: localAccountId || msalCommon.Constants.EMPTY_STRING,
76
+ };
77
+ cachedAccount = this.cacheManager.readAccountFromCache(accountInfo);
78
+ }
79
+ // increment telemetry cache hit counter
80
+ if (this.config.serverTelemetryManager) {
81
+ this.config.serverTelemetryManager.incrementCacheHits();
82
+ }
83
+ return msalCommon.ResponseHandler.generateAuthenticationResult(this.cryptoUtils, this.authority, {
84
+ account: cachedAccount,
85
+ accessToken: cachedAccessToken,
86
+ idToken: cachedIdToken,
87
+ refreshToken: null,
88
+ appMetadata: null,
89
+ }, true, request, idTokenClaims);
90
+ }
91
+ /**
92
+ * read idtoken from cache, this is a specific implementation for OBO as the requirements differ from a generic lookup in the cacheManager
93
+ * Certain use cases of OBO flow do not expect an idToken in the cache/or from the service
94
+ * @param atHomeAccountId {string}
95
+ */
96
+ readIdTokenFromCacheForOBO(atHomeAccountId) {
97
+ const idTokenFilter = {
98
+ homeAccountId: atHomeAccountId,
99
+ environment: this.authority.canonicalAuthorityUrlComponents.HostNameAndPort,
100
+ credentialType: msalCommon.CredentialType.ID_TOKEN,
101
+ clientId: this.config.authOptions.clientId,
102
+ realm: this.authority.tenant,
103
+ };
104
+ const idTokenMap = this.cacheManager.getIdTokensByFilter(idTokenFilter);
105
+ // When acquiring a token on behalf of an application, there might not be an id token in the cache
106
+ if (Object.values(idTokenMap).length < 1) {
107
+ return null;
108
+ }
109
+ return Object.values(idTokenMap)[0];
110
+ }
111
+ /**
112
+ * Fetches the cached access token based on incoming assertion
113
+ * @param clientId
114
+ * @param request
115
+ * @param userAssertionHash
116
+ */
117
+ readAccessTokenFromCacheForOBO(clientId, request) {
118
+ const authScheme = request.authenticationScheme || msalCommon.AuthenticationScheme.BEARER;
119
+ /*
120
+ * Distinguish between Bearer and PoP/SSH token cache types
121
+ * Cast to lowercase to handle "bearer" from ADFS
122
+ */
123
+ const credentialType = authScheme &&
124
+ authScheme.toLowerCase() !==
125
+ msalCommon.AuthenticationScheme.BEARER.toLowerCase()
126
+ ? msalCommon.CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME
127
+ : msalCommon.CredentialType.ACCESS_TOKEN;
128
+ const accessTokenFilter = {
129
+ credentialType: credentialType,
130
+ clientId,
131
+ target: msalCommon.ScopeSet.createSearchScopes(this.scopeSet.asArray()),
132
+ tokenType: authScheme,
133
+ keyId: request.sshKid,
134
+ requestedClaimsHash: request.requestedClaimsHash,
135
+ userAssertionHash: this.userAssertionHash,
136
+ };
137
+ const accessTokens = this.cacheManager.getAccessTokensByFilter(accessTokenFilter);
138
+ const numAccessTokens = accessTokens.length;
139
+ if (numAccessTokens < 1) {
140
+ return null;
141
+ }
142
+ else if (numAccessTokens > 1) {
143
+ throw msalCommon.createClientAuthError(msalCommon.ClientAuthErrorCodes.multipleMatchingTokens);
144
+ }
145
+ return accessTokens[0];
146
+ }
147
+ /**
148
+ * Make a network call to the server requesting credentials
149
+ * @param request
150
+ * @param authority
151
+ */
152
+ async executeTokenRequest(request, authority, userAssertionHash) {
153
+ const queryParametersString = this.createTokenQueryParameters(request);
154
+ const endpoint = msalCommon.UrlString.appendQueryString(authority.tokenEndpoint, queryParametersString);
155
+ const requestBody = await this.createTokenRequestBody(request);
156
+ const headers = this.createTokenRequestHeaders();
157
+ const thumbprint = {
158
+ clientId: this.config.authOptions.clientId,
159
+ authority: request.authority,
160
+ scopes: request.scopes,
161
+ claims: request.claims,
162
+ authenticationScheme: request.authenticationScheme,
163
+ resourceRequestMethod: request.resourceRequestMethod,
164
+ resourceRequestUri: request.resourceRequestUri,
165
+ shrClaims: request.shrClaims,
166
+ sshKid: request.sshKid,
167
+ };
168
+ const reqTimestamp = msalCommon.TimeUtils.nowSeconds();
169
+ const response = await this.executePostToTokenEndpoint(endpoint, requestBody, headers, thumbprint, request.correlationId);
170
+ const responseHandler = new msalCommon.ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, this.config.serializableCache, this.config.persistencePlugin);
171
+ responseHandler.validateTokenResponse(response.body);
172
+ const tokenResponse = await responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request, undefined, userAssertionHash);
173
+ return tokenResponse;
174
+ }
175
+ /**
176
+ * generate a server request in accepable format
177
+ * @param request
178
+ */
179
+ async createTokenRequestBody(request) {
180
+ const parameterBuilder = new msalCommon.RequestParameterBuilder();
181
+ parameterBuilder.addClientId(this.config.authOptions.clientId);
182
+ parameterBuilder.addScopes(request.scopes);
183
+ parameterBuilder.addGrantType(msalCommon.GrantType.JWT_BEARER);
184
+ parameterBuilder.addClientInfo();
185
+ parameterBuilder.addLibraryInfo(this.config.libraryInfo);
186
+ parameterBuilder.addApplicationTelemetry(this.config.telemetry.application);
187
+ parameterBuilder.addThrottling();
188
+ if (this.serverTelemetryManager) {
189
+ parameterBuilder.addServerTelemetry(this.serverTelemetryManager);
190
+ }
191
+ const correlationId = request.correlationId ||
192
+ this.config.cryptoInterface.createNewGuid();
193
+ parameterBuilder.addCorrelationId(correlationId);
194
+ parameterBuilder.addRequestTokenUse(msalCommon.AADServerParamKeys.ON_BEHALF_OF);
195
+ parameterBuilder.addOboAssertion(request.oboAssertion);
196
+ if (this.config.clientCredentials.clientSecret) {
197
+ parameterBuilder.addClientSecret(this.config.clientCredentials.clientSecret);
198
+ }
199
+ const clientAssertion = this.config.clientCredentials.clientAssertion;
200
+ if (clientAssertion) {
201
+ parameterBuilder.addClientAssertion(await msalCommon.getClientAssertion(clientAssertion.assertion, this.config.authOptions.clientId, request.resourceRequestUri));
202
+ parameterBuilder.addClientAssertionType(clientAssertion.assertionType);
203
+ }
204
+ if (request.claims ||
205
+ (this.config.authOptions.clientCapabilities &&
206
+ this.config.authOptions.clientCapabilities.length > 0)) {
207
+ parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);
208
+ }
209
+ return parameterBuilder.createQueryString();
210
+ }
209
211
  }
210
212
 
211
213
  exports.OnBehalfOfClient = OnBehalfOfClient;
@@ -1 +1 @@
1
- {"version":3,"file":"OnBehalfOfClient.cjs","sources":["../../src/client/OnBehalfOfClient.ts"],"sourcesContent":[null],"names":["BaseClient","ScopeSet","CacheOutcome","createClientAuthError","ClientAuthErrorCodes","TimeUtils","AuthToken","EncodingUtils","Constants","ResponseHandler","CredentialType","AuthenticationScheme","UrlString","RequestParameterBuilder","GrantType","AADServerParamKeys","getClientAssertion"],"mappings":";;;;;;;AAAA;;;AAGG;AAkCH;;AAEG;AACG,MAAO,gBAAiB,SAAQA,qBAAU,CAAA;AAI5C,IAAA,WAAA,CAAY,aAAkC,EAAA;QAC1C,KAAK,CAAC,aAAa,CAAC,CAAC;KACxB;AAED;;;AAGG;IACI,MAAM,YAAY,CACrB,OAAgC,EAAA;AAEhC,QAAA,IAAI,CAAC,QAAQ,GAAG,IAAIC,mBAAQ,CAAC,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC;;AAGnD,QAAA,IAAI,CAAC,iBAAiB,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,UAAU,CACtD,OAAO,CAAC,YAAY,CACvB,CAAC;AAEF,QAAA,IAAI,OAAO,CAAC,SAAS,IAAI,OAAO,CAAC,MAAM,EAAE;AACrC,YAAA,OAAO,IAAI,CAAC,mBAAmB,CAC3B,OAAO,EACP,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,iBAAiB,CACzB,CAAC;AACL,SAAA;QAED,IAAI;AACA,YAAA,OAAO,MAAM,IAAI,CAAC,6BAA6B,CAAC,OAAO,CAAC,CAAC;AAC5D,SAAA;AAAC,QAAA,OAAO,CAAC,EAAE;;AAER,YAAA,OAAO,MAAM,IAAI,CAAC,mBAAmB,CACjC,OAAO,EACP,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,iBAAiB,CACzB,CAAC;AACL,SAAA;KACJ;AAED;;;;;;;AAOG;IACK,MAAM,6BAA6B,CACvC,OAAgC,EAAA;;AAGhC,QAAA,MAAM,iBAAiB,GAAG,IAAI,CAAC,8BAA8B,CACzD,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,QAAQ,EAChC,OAAO,CACV,CAAC;QAC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CAAC,YAAY,EAAE;YAC5C,gBAAgB,CAAC,eAAe,CAC5B,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,YAAY,CAC7C,CAAC;AACL,SAAA;QAED,MAAM,eAAe,GACjB,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,eAAe,CAAC;AAElD,QAAA,IAAI,eAAe,EAAE;YACjB,gBAAgB,CAAC,kBAAkB,CAC/B,MAAMC,6BAAkB,CACpB,eAAe,CAAC,SAAS,EACzB,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,QAAQ,EAChC,OAAO,CAAC,kBAAkB,CAC7B,CACJ,CAAC;AACF,YAAA,gBAAgB,CAAC,sBAAsB,CACnC,eAAe,CAAC,aAAa,CAChC,CAAC;AACL,SAAA;QAED,IACI,OAAO,CAAC,MAAM;AACd,aAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,kBAAkB;gBACvC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,kBAAkB,CAAC,MAAM,GAAG,CAAC,CAAC,EAC5D;AACE,YAAA,gBAAgB,CAAC,SAAS,CACtB,OAAO,CAAC,MAAM,EACd,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,kBAAkB,CAC7C,CAAC;AACL,SAAA;AAED,QAAA,OAAO,gBAAgB,CAAC,iBAAiB,EAAE,CAAC;KAC/C;AACJ;;;;"}
1
+ {"version":3,"file":"OnBehalfOfClient.cjs","sources":["../../src/client/OnBehalfOfClient.ts"],"sourcesContent":[null],"names":["BaseClient","ScopeSet","CacheOutcome","createClientAuthError","ClientAuthErrorCodes","TimeUtils","AuthToken","EncodingUtils","Constants","ResponseHandler","CredentialType","AuthenticationScheme","UrlString","RequestParameterBuilder","GrantType","AADServerParamKeys","getClientAssertion"],"mappings":";;;;;;;;;AAAA;;;AAGG;AAkCH;;AAEG;AACG,MAAO,gBAAiB,SAAQA,qBAAU,CAAA;AAI5C,IAAA,WAAA,CAAY,aAAkC,EAAA;QAC1C,KAAK,CAAC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,CAAC,MAAM,CAAC,WAAW,CAAC,QAAQ,EAChC,OAAO,CAAC,kBAAkB,CAC7B,CACJ,CAAC;AACF,YAAA,gBAAgB,CAAC,sBAAsB,CACnC,eAAe,CAAC,aAAa,CAChC,CAAC;AACL,SAAA;QAED,IACI,OAAO,CAAC,MAAM;AACd,aAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,kBAAkB;gBACvC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,kBAAkB,CAAC,MAAM,GAAG,CAAC,CAAC,EAC5D;AACE,YAAA,gBAAgB,CAAC,SAAS,CACtB,OAAO,CAAC,MAAM,EACd,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,kBAAkB,CAC7C,CAAC;AACL,SAAA;AAED,QAAA,OAAO,gBAAgB,CAAC,iBAAiB,EAAE,CAAC;KAC/C;AACJ;;;;"}
@@ -1,48 +1,48 @@
1
- import { AuthenticationResult, BaseClient, ClientConfiguration, CommonOnBehalfOfRequest } from "@azure/msal-common";
2
- /**
3
- * On-Behalf-Of client
4
- */
5
- export declare class OnBehalfOfClient extends BaseClient {
6
- private scopeSet;
7
- private userAssertionHash;
8
- constructor(configuration: ClientConfiguration);
9
- /**
10
- * Public API to acquire tokens with on behalf of flow
11
- * @param request
12
- */
13
- acquireToken(request: CommonOnBehalfOfRequest): Promise<AuthenticationResult | null>;
14
- /**
15
- * look up cache for tokens
16
- * Find idtoken in the cache
17
- * Find accessToken based on user assertion and account info in the cache
18
- * Please note we are not yet supported OBO tokens refreshed with long lived RT. User will have to send a new assertion if the current access token expires
19
- * This is to prevent security issues when the assertion changes over time, however, longlived RT helps retaining the session
20
- * @param request
21
- */
22
- private getCachedAuthenticationResult;
23
- /**
24
- * read idtoken from cache, this is a specific implementation for OBO as the requirements differ from a generic lookup in the cacheManager
25
- * Certain use cases of OBO flow do not expect an idToken in the cache/or from the service
26
- * @param atHomeAccountId {string}
27
- */
28
- private readIdTokenFromCacheForOBO;
29
- /**
30
- * Fetches the cached access token based on incoming assertion
31
- * @param clientId
32
- * @param request
33
- * @param userAssertionHash
34
- */
35
- private readAccessTokenFromCacheForOBO;
36
- /**
37
- * Make a network call to the server requesting credentials
38
- * @param request
39
- * @param authority
40
- */
41
- private executeTokenRequest;
42
- /**
43
- * generate a server request in accepable format
44
- * @param request
45
- */
46
- private createTokenRequestBody;
47
- }
1
+ import { AuthenticationResult, BaseClient, ClientConfiguration, CommonOnBehalfOfRequest } from "@azure/msal-common";
2
+ /**
3
+ * On-Behalf-Of client
4
+ */
5
+ export declare class OnBehalfOfClient extends BaseClient {
6
+ private scopeSet;
7
+ private userAssertionHash;
8
+ constructor(configuration: ClientConfiguration);
9
+ /**
10
+ * Public API to acquire tokens with on behalf of flow
11
+ * @param request
12
+ */
13
+ acquireToken(request: CommonOnBehalfOfRequest): Promise<AuthenticationResult | null>;
14
+ /**
15
+ * look up cache for tokens
16
+ * Find idtoken in the cache
17
+ * Find accessToken based on user assertion and account info in the cache
18
+ * Please note we are not yet supported OBO tokens refreshed with long lived RT. User will have to send a new assertion if the current access token expires
19
+ * This is to prevent security issues when the assertion changes over time, however, longlived RT helps retaining the session
20
+ * @param request
21
+ */
22
+ private getCachedAuthenticationResult;
23
+ /**
24
+ * read idtoken from cache, this is a specific implementation for OBO as the requirements differ from a generic lookup in the cacheManager
25
+ * Certain use cases of OBO flow do not expect an idToken in the cache/or from the service
26
+ * @param atHomeAccountId {string}
27
+ */
28
+ private readIdTokenFromCacheForOBO;
29
+ /**
30
+ * Fetches the cached access token based on incoming assertion
31
+ * @param clientId
32
+ * @param request
33
+ * @param userAssertionHash
34
+ */
35
+ private readAccessTokenFromCacheForOBO;
36
+ /**
37
+ * Make a network call to the server requesting credentials
38
+ * @param request
39
+ * @param authority
40
+ */
41
+ private executeTokenRequest;
42
+ /**
43
+ * generate a server request in accepable format
44
+ * @param request
45
+ */
46
+ private createTokenRequestBody;
47
+ }
48
48
  //# sourceMappingURL=OnBehalfOfClient.d.ts.map