@azure/msal-node 2.2.0-alpha.0 → 2.2.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 (106) hide show
  1. package/dist/cache/ITokenCache.d.ts +15 -15
  2. package/dist/cache/NodeStorage.cjs +401 -401
  3. package/dist/cache/NodeStorage.d.ts +182 -182
  4. package/dist/cache/NodeStorage.mjs +401 -401
  5. package/dist/cache/TokenCache.cjs +265 -265
  6. package/dist/cache/TokenCache.d.ts +90 -90
  7. package/dist/cache/TokenCache.mjs +265 -265
  8. package/dist/cache/distributed/DistributedCachePlugin.cjs +26 -26
  9. package/dist/cache/distributed/DistributedCachePlugin.d.ts +10 -10
  10. package/dist/cache/distributed/DistributedCachePlugin.mjs +26 -26
  11. package/dist/cache/distributed/ICacheClient.d.ts +17 -17
  12. package/dist/cache/distributed/IPartitionManager.d.ts +28 -28
  13. package/dist/cache/serializer/Deserializer.cjs +173 -173
  14. package/dist/cache/serializer/Deserializer.d.ts +42 -42
  15. package/dist/cache/serializer/Deserializer.mjs +173 -173
  16. package/dist/cache/serializer/Serializer.cjs +134 -134
  17. package/dist/cache/serializer/Serializer.d.ts +39 -39
  18. package/dist/cache/serializer/Serializer.mjs +134 -134
  19. package/dist/cache/serializer/SerializerTypes.d.ts +101 -101
  20. package/dist/client/ClientApplication.cjs +333 -333
  21. package/dist/client/ClientApplication.d.ts +142 -142
  22. package/dist/client/ClientApplication.mjs +333 -333
  23. package/dist/client/ClientAssertion.cjs +116 -116
  24. package/dist/client/ClientAssertion.d.ts +46 -46
  25. package/dist/client/ClientAssertion.mjs +116 -116
  26. package/dist/client/ClientCredentialClient.cjs +189 -189
  27. package/dist/client/ClientCredentialClient.d.ts +33 -33
  28. package/dist/client/ClientCredentialClient.mjs +189 -189
  29. package/dist/client/ConfidentialClientApplication.cjs +163 -163
  30. package/dist/client/ConfidentialClientApplication.d.ts +58 -58
  31. package/dist/client/ConfidentialClientApplication.mjs +163 -163
  32. package/dist/client/DeviceCodeClient.cjs +207 -207
  33. package/dist/client/DeviceCodeClient.d.ts +53 -53
  34. package/dist/client/DeviceCodeClient.mjs +207 -207
  35. package/dist/client/IConfidentialClientApplication.d.ts +39 -39
  36. package/dist/client/IPublicClientApplication.d.ts +42 -42
  37. package/dist/client/OnBehalfOfClient.cjs +202 -202
  38. package/dist/client/OnBehalfOfClient.d.ts +47 -47
  39. package/dist/client/OnBehalfOfClient.mjs +202 -202
  40. package/dist/client/PublicClientApplication.cjs +229 -229
  41. package/dist/client/PublicClientApplication.d.ts +71 -71
  42. package/dist/client/PublicClientApplication.mjs +229 -229
  43. package/dist/client/UsernamePasswordClient.cjs +95 -95
  44. package/dist/client/UsernamePasswordClient.d.ts +25 -25
  45. package/dist/client/UsernamePasswordClient.mjs +95 -95
  46. package/dist/config/Configuration.cjs +72 -72
  47. package/dist/config/Configuration.d.ts +107 -107
  48. package/dist/config/Configuration.mjs +72 -72
  49. package/dist/crypto/CryptoProvider.cjs +75 -75
  50. package/dist/crypto/CryptoProvider.d.ts +52 -52
  51. package/dist/crypto/CryptoProvider.mjs +75 -75
  52. package/dist/crypto/GuidGenerator.cjs +22 -22
  53. package/dist/crypto/GuidGenerator.d.ts +14 -14
  54. package/dist/crypto/GuidGenerator.mjs +22 -22
  55. package/dist/crypto/HashUtils.cjs +13 -13
  56. package/dist/crypto/HashUtils.d.ts +8 -8
  57. package/dist/crypto/HashUtils.mjs +13 -13
  58. package/dist/crypto/PkceGenerator.cjs +49 -49
  59. package/dist/crypto/PkceGenerator.d.ts +22 -22
  60. package/dist/crypto/PkceGenerator.mjs +49 -49
  61. package/dist/error/NodeAuthError.cjs +85 -85
  62. package/dist/error/NodeAuthError.d.ts +65 -65
  63. package/dist/error/NodeAuthError.mjs +85 -85
  64. package/dist/index.cjs +1 -1
  65. package/dist/index.d.ts +42 -42
  66. package/dist/index.d.ts.map +1 -1
  67. package/dist/index.mjs +1 -1
  68. package/dist/internals.cjs +8 -8
  69. package/dist/internals.d.ts +6 -6
  70. package/dist/internals.mjs +8 -8
  71. package/dist/network/HttpClient.cjs +276 -276
  72. package/dist/network/HttpClient.d.ts +25 -25
  73. package/dist/network/HttpClient.mjs +276 -276
  74. package/dist/network/ILoopbackClient.d.ts +10 -10
  75. package/dist/network/LoopbackClient.cjs +76 -75
  76. package/dist/network/LoopbackClient.cjs.map +1 -1
  77. package/dist/network/LoopbackClient.d.ts +21 -21
  78. package/dist/network/LoopbackClient.d.ts.map +1 -1
  79. package/dist/network/LoopbackClient.mjs +76 -75
  80. package/dist/network/LoopbackClient.mjs.map +1 -1
  81. package/dist/packageMetadata.cjs +4 -4
  82. package/dist/packageMetadata.d.ts +2 -2
  83. package/dist/packageMetadata.mjs +4 -4
  84. package/dist/request/AuthorizationCodeRequest.d.ts +21 -21
  85. package/dist/request/AuthorizationUrlRequest.d.ts +33 -33
  86. package/dist/request/ClientCredentialRequest.d.ts +14 -14
  87. package/dist/request/DeviceCodeRequest.d.ts +15 -15
  88. package/dist/request/InteractiveRequest.d.ts +22 -22
  89. package/dist/request/OnBehalfOfRequest.d.ts +14 -14
  90. package/dist/request/RefreshTokenRequest.d.ts +17 -17
  91. package/dist/request/SignOutRequest.d.ts +5 -5
  92. package/dist/request/SilentFlowRequest.d.ts +16 -16
  93. package/dist/request/UsernamePasswordRequest.d.ts +19 -19
  94. package/dist/utils/Constants.cjs +80 -80
  95. package/dist/utils/Constants.d.ts +86 -86
  96. package/dist/utils/Constants.mjs +80 -80
  97. package/dist/utils/EncodingUtils.cjs +44 -44
  98. package/dist/utils/EncodingUtils.d.ts +26 -26
  99. package/dist/utils/EncodingUtils.mjs +44 -44
  100. package/dist/utils/NetworkUtils.cjs +38 -38
  101. package/dist/utils/NetworkUtils.d.ts +5 -5
  102. package/dist/utils/NetworkUtils.mjs +38 -38
  103. package/package.json +2 -2
  104. package/src/index.ts +1 -0
  105. package/src/network/LoopbackClient.ts +1 -0
  106. package/src/packageMetadata.ts +1 -1
@@ -1,197 +1,197 @@
1
- /*! @azure/msal-node v2.2.0-alpha.0 2023-09-20 */
1
+ /*! @azure/msal-node v2.2.0 2023-10-05 */
2
2
  'use strict';
3
3
  'use strict';
4
4
 
5
5
  var msalCommon = require('@azure/msal-common');
6
6
 
7
- /*
8
- * Copyright (c) Microsoft Corporation. All rights reserved.
9
- * Licensed under the MIT License.
10
- */
11
- /**
12
- * OAuth2.0 client credential grant
13
- */
14
- class ClientCredentialClient extends msalCommon.BaseClient {
15
- constructor(configuration, appTokenProvider) {
16
- super(configuration);
17
- this.appTokenProvider = appTokenProvider;
18
- }
19
- /**
20
- * Public API to acquire a token with ClientCredential Flow for Confidential clients
21
- * @param request
22
- */
23
- async acquireToken(request) {
24
- this.scopeSet = new msalCommon.ScopeSet(request.scopes || []);
25
- if (request.skipCache) {
26
- return await this.executeTokenRequest(request, this.authority);
27
- }
28
- const [cachedAuthenticationResult, lastCacheOutcome] = await this.getCachedAuthenticationResult(request);
29
- if (cachedAuthenticationResult) {
30
- // if the token is not expired but must be refreshed; get a new one in the background
31
- if (lastCacheOutcome === msalCommon.CacheOutcome.PROACTIVELY_REFRESHED) {
32
- this.logger.info("ClientCredentialClient:getCachedAuthenticationResult - Cached access token's refreshOn property has been exceeded'. It's not expired, but must be refreshed.");
33
- // refresh the access token in the background
34
- const refreshAccessToken = true;
35
- await this.executeTokenRequest(request, this.authority, refreshAccessToken);
36
- }
37
- // return the cached token
38
- return cachedAuthenticationResult;
39
- }
40
- else {
41
- return await this.executeTokenRequest(request, this.authority);
42
- }
43
- }
44
- /**
45
- * looks up cache if the tokens are cached already
46
- */
47
- async getCachedAuthenticationResult(request) {
48
- let lastCacheOutcome = msalCommon.CacheOutcome.NOT_APPLICABLE;
49
- // read the user-supplied cache into memory, if applicable
50
- let cacheContext;
51
- if (this.config.serializableCache && this.config.persistencePlugin) {
52
- cacheContext = new msalCommon.TokenCacheContext(this.config.serializableCache, false);
53
- await this.config.persistencePlugin.beforeCacheAccess(cacheContext);
54
- }
55
- const cachedAccessToken = this.readAccessTokenFromCache();
56
- if (this.config.serializableCache &&
57
- this.config.persistencePlugin &&
58
- cacheContext) {
59
- await this.config.persistencePlugin.afterCacheAccess(cacheContext);
60
- }
61
- // must refresh due to non-existent access_token
62
- if (!cachedAccessToken) {
63
- this.serverTelemetryManager?.setCacheOutcome(msalCommon.CacheOutcome.NO_CACHED_ACCESS_TOKEN);
64
- return [null, msalCommon.CacheOutcome.NO_CACHED_ACCESS_TOKEN];
65
- }
66
- // must refresh due to the expires_in value
67
- if (msalCommon.TimeUtils.isTokenExpired(cachedAccessToken.expiresOn, this.config.systemOptions.tokenRenewalOffsetSeconds)) {
68
- this.serverTelemetryManager?.setCacheOutcome(msalCommon.CacheOutcome.CACHED_ACCESS_TOKEN_EXPIRED);
69
- return [null, msalCommon.CacheOutcome.CACHED_ACCESS_TOKEN_EXPIRED];
70
- }
71
- // must refresh (in the background) due to the refresh_in value
72
- if (cachedAccessToken.refreshOn &&
73
- msalCommon.TimeUtils.isTokenExpired(cachedAccessToken.refreshOn.toString(), 0)) {
74
- lastCacheOutcome = msalCommon.CacheOutcome.PROACTIVELY_REFRESHED;
75
- this.serverTelemetryManager?.setCacheOutcome(msalCommon.CacheOutcome.PROACTIVELY_REFRESHED);
76
- }
77
- return [
78
- await msalCommon.ResponseHandler.generateAuthenticationResult(this.cryptoUtils, this.authority, {
79
- account: null,
80
- idToken: null,
81
- accessToken: cachedAccessToken,
82
- refreshToken: null,
83
- appMetadata: null,
84
- }, true, request),
85
- lastCacheOutcome,
86
- ];
87
- }
88
- /**
89
- * Reads access token from the cache
90
- */
91
- readAccessTokenFromCache() {
92
- const accessTokenFilter = {
93
- homeAccountId: msalCommon.Constants.EMPTY_STRING,
94
- environment: this.authority.canonicalAuthorityUrlComponents.HostNameAndPort,
95
- credentialType: msalCommon.CredentialType.ACCESS_TOKEN,
96
- clientId: this.config.authOptions.clientId,
97
- realm: this.authority.tenant,
98
- target: msalCommon.ScopeSet.createSearchScopes(this.scopeSet.asArray()),
99
- };
100
- const accessTokens = this.cacheManager.getAccessTokensByFilter(accessTokenFilter);
101
- if (accessTokens.length < 1) {
102
- return null;
103
- }
104
- else if (accessTokens.length > 1) {
105
- throw msalCommon.createClientAuthError(msalCommon.ClientAuthErrorCodes.multipleMatchingTokens);
106
- }
107
- return accessTokens[0];
108
- }
109
- /**
110
- * Makes a network call to request the token from the service
111
- * @param request
112
- * @param authority
113
- */
114
- async executeTokenRequest(request, authority, refreshAccessToken) {
115
- let serverTokenResponse;
116
- let reqTimestamp;
117
- if (this.appTokenProvider) {
118
- this.logger.info("Using appTokenProvider extensibility.");
119
- const appTokenPropviderParameters = {
120
- correlationId: request.correlationId,
121
- tenantId: this.config.authOptions.authority.tenant,
122
- scopes: request.scopes,
123
- claims: request.claims,
124
- };
125
- reqTimestamp = msalCommon.TimeUtils.nowSeconds();
126
- const appTokenProviderResult = await this.appTokenProvider(appTokenPropviderParameters);
127
- serverTokenResponse = {
128
- access_token: appTokenProviderResult.accessToken,
129
- expires_in: appTokenProviderResult.expiresInSeconds,
130
- refresh_in: appTokenProviderResult.refreshInSeconds,
131
- token_type: msalCommon.AuthenticationScheme.BEARER,
132
- };
133
- }
134
- else {
135
- const queryParametersString = this.createTokenQueryParameters(request);
136
- const endpoint = msalCommon.UrlString.appendQueryString(authority.tokenEndpoint, queryParametersString);
137
- const requestBody = this.createTokenRequestBody(request);
138
- const headers = this.createTokenRequestHeaders();
139
- const thumbprint = {
140
- clientId: this.config.authOptions.clientId,
141
- authority: request.authority,
142
- scopes: request.scopes,
143
- claims: request.claims,
144
- authenticationScheme: request.authenticationScheme,
145
- resourceRequestMethod: request.resourceRequestMethod,
146
- resourceRequestUri: request.resourceRequestUri,
147
- shrClaims: request.shrClaims,
148
- sshKid: request.sshKid,
149
- };
150
- reqTimestamp = msalCommon.TimeUtils.nowSeconds();
151
- const response = await this.executePostToTokenEndpoint(endpoint, requestBody, headers, thumbprint, request.correlationId);
152
- serverTokenResponse = response.body;
153
- serverTokenResponse.status = response.status;
154
- }
155
- const responseHandler = new msalCommon.ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, this.config.serializableCache, this.config.persistencePlugin);
156
- responseHandler.validateTokenResponse(serverTokenResponse, refreshAccessToken);
157
- const tokenResponse = await responseHandler.handleServerTokenResponse(serverTokenResponse, this.authority, reqTimestamp, request);
158
- return tokenResponse;
159
- }
160
- /**
161
- * generate the request to the server in the acceptable format
162
- * @param request
163
- */
164
- createTokenRequestBody(request) {
165
- const parameterBuilder = new msalCommon.RequestParameterBuilder();
166
- parameterBuilder.addClientId(this.config.authOptions.clientId);
167
- parameterBuilder.addScopes(request.scopes, false);
168
- parameterBuilder.addGrantType(msalCommon.GrantType.CLIENT_CREDENTIALS_GRANT);
169
- parameterBuilder.addLibraryInfo(this.config.libraryInfo);
170
- parameterBuilder.addApplicationTelemetry(this.config.telemetry.application);
171
- parameterBuilder.addThrottling();
172
- if (this.serverTelemetryManager) {
173
- parameterBuilder.addServerTelemetry(this.serverTelemetryManager);
174
- }
175
- const correlationId = request.correlationId ||
176
- this.config.cryptoInterface.createNewGuid();
177
- parameterBuilder.addCorrelationId(correlationId);
178
- if (this.config.clientCredentials.clientSecret) {
179
- parameterBuilder.addClientSecret(this.config.clientCredentials.clientSecret);
180
- }
181
- // Use clientAssertion from request, fallback to client assertion in base configuration
182
- const clientAssertion = request.clientAssertion ||
183
- this.config.clientCredentials.clientAssertion;
184
- if (clientAssertion) {
185
- parameterBuilder.addClientAssertion(clientAssertion.assertion);
186
- parameterBuilder.addClientAssertionType(clientAssertion.assertionType);
187
- }
188
- if (!msalCommon.StringUtils.isEmptyObj(request.claims) ||
189
- (this.config.authOptions.clientCapabilities &&
190
- this.config.authOptions.clientCapabilities.length > 0)) {
191
- parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);
192
- }
193
- return parameterBuilder.createQueryString();
194
- }
7
+ /*
8
+ * Copyright (c) Microsoft Corporation. All rights reserved.
9
+ * Licensed under the MIT License.
10
+ */
11
+ /**
12
+ * OAuth2.0 client credential grant
13
+ */
14
+ class ClientCredentialClient extends msalCommon.BaseClient {
15
+ constructor(configuration, appTokenProvider) {
16
+ super(configuration);
17
+ this.appTokenProvider = appTokenProvider;
18
+ }
19
+ /**
20
+ * Public API to acquire a token with ClientCredential Flow for Confidential clients
21
+ * @param request
22
+ */
23
+ async acquireToken(request) {
24
+ this.scopeSet = new msalCommon.ScopeSet(request.scopes || []);
25
+ if (request.skipCache) {
26
+ return await this.executeTokenRequest(request, this.authority);
27
+ }
28
+ const [cachedAuthenticationResult, lastCacheOutcome] = await this.getCachedAuthenticationResult(request);
29
+ if (cachedAuthenticationResult) {
30
+ // if the token is not expired but must be refreshed; get a new one in the background
31
+ if (lastCacheOutcome === msalCommon.CacheOutcome.PROACTIVELY_REFRESHED) {
32
+ this.logger.info("ClientCredentialClient:getCachedAuthenticationResult - Cached access token's refreshOn property has been exceeded'. It's not expired, but must be refreshed.");
33
+ // refresh the access token in the background
34
+ const refreshAccessToken = true;
35
+ await this.executeTokenRequest(request, this.authority, refreshAccessToken);
36
+ }
37
+ // return the cached token
38
+ return cachedAuthenticationResult;
39
+ }
40
+ else {
41
+ return await this.executeTokenRequest(request, this.authority);
42
+ }
43
+ }
44
+ /**
45
+ * looks up cache if the tokens are cached already
46
+ */
47
+ async getCachedAuthenticationResult(request) {
48
+ let lastCacheOutcome = msalCommon.CacheOutcome.NOT_APPLICABLE;
49
+ // read the user-supplied cache into memory, if applicable
50
+ let cacheContext;
51
+ if (this.config.serializableCache && this.config.persistencePlugin) {
52
+ cacheContext = new msalCommon.TokenCacheContext(this.config.serializableCache, false);
53
+ await this.config.persistencePlugin.beforeCacheAccess(cacheContext);
54
+ }
55
+ const cachedAccessToken = this.readAccessTokenFromCache();
56
+ if (this.config.serializableCache &&
57
+ this.config.persistencePlugin &&
58
+ cacheContext) {
59
+ await this.config.persistencePlugin.afterCacheAccess(cacheContext);
60
+ }
61
+ // must refresh due to non-existent access_token
62
+ if (!cachedAccessToken) {
63
+ this.serverTelemetryManager?.setCacheOutcome(msalCommon.CacheOutcome.NO_CACHED_ACCESS_TOKEN);
64
+ return [null, msalCommon.CacheOutcome.NO_CACHED_ACCESS_TOKEN];
65
+ }
66
+ // must refresh due to the expires_in value
67
+ if (msalCommon.TimeUtils.isTokenExpired(cachedAccessToken.expiresOn, this.config.systemOptions.tokenRenewalOffsetSeconds)) {
68
+ this.serverTelemetryManager?.setCacheOutcome(msalCommon.CacheOutcome.CACHED_ACCESS_TOKEN_EXPIRED);
69
+ return [null, msalCommon.CacheOutcome.CACHED_ACCESS_TOKEN_EXPIRED];
70
+ }
71
+ // must refresh (in the background) due to the refresh_in value
72
+ if (cachedAccessToken.refreshOn &&
73
+ msalCommon.TimeUtils.isTokenExpired(cachedAccessToken.refreshOn.toString(), 0)) {
74
+ lastCacheOutcome = msalCommon.CacheOutcome.PROACTIVELY_REFRESHED;
75
+ this.serverTelemetryManager?.setCacheOutcome(msalCommon.CacheOutcome.PROACTIVELY_REFRESHED);
76
+ }
77
+ return [
78
+ await msalCommon.ResponseHandler.generateAuthenticationResult(this.cryptoUtils, this.authority, {
79
+ account: null,
80
+ idToken: null,
81
+ accessToken: cachedAccessToken,
82
+ refreshToken: null,
83
+ appMetadata: null,
84
+ }, true, request),
85
+ lastCacheOutcome,
86
+ ];
87
+ }
88
+ /**
89
+ * Reads access token from the cache
90
+ */
91
+ readAccessTokenFromCache() {
92
+ const accessTokenFilter = {
93
+ homeAccountId: msalCommon.Constants.EMPTY_STRING,
94
+ environment: this.authority.canonicalAuthorityUrlComponents.HostNameAndPort,
95
+ credentialType: msalCommon.CredentialType.ACCESS_TOKEN,
96
+ clientId: this.config.authOptions.clientId,
97
+ realm: this.authority.tenant,
98
+ target: msalCommon.ScopeSet.createSearchScopes(this.scopeSet.asArray()),
99
+ };
100
+ const accessTokens = this.cacheManager.getAccessTokensByFilter(accessTokenFilter);
101
+ if (accessTokens.length < 1) {
102
+ return null;
103
+ }
104
+ else if (accessTokens.length > 1) {
105
+ throw msalCommon.createClientAuthError(msalCommon.ClientAuthErrorCodes.multipleMatchingTokens);
106
+ }
107
+ return accessTokens[0];
108
+ }
109
+ /**
110
+ * Makes a network call to request the token from the service
111
+ * @param request
112
+ * @param authority
113
+ */
114
+ async executeTokenRequest(request, authority, refreshAccessToken) {
115
+ let serverTokenResponse;
116
+ let reqTimestamp;
117
+ if (this.appTokenProvider) {
118
+ this.logger.info("Using appTokenProvider extensibility.");
119
+ const appTokenPropviderParameters = {
120
+ correlationId: request.correlationId,
121
+ tenantId: this.config.authOptions.authority.tenant,
122
+ scopes: request.scopes,
123
+ claims: request.claims,
124
+ };
125
+ reqTimestamp = msalCommon.TimeUtils.nowSeconds();
126
+ const appTokenProviderResult = await this.appTokenProvider(appTokenPropviderParameters);
127
+ serverTokenResponse = {
128
+ access_token: appTokenProviderResult.accessToken,
129
+ expires_in: appTokenProviderResult.expiresInSeconds,
130
+ refresh_in: appTokenProviderResult.refreshInSeconds,
131
+ token_type: msalCommon.AuthenticationScheme.BEARER,
132
+ };
133
+ }
134
+ else {
135
+ const queryParametersString = this.createTokenQueryParameters(request);
136
+ const endpoint = msalCommon.UrlString.appendQueryString(authority.tokenEndpoint, queryParametersString);
137
+ const requestBody = this.createTokenRequestBody(request);
138
+ const headers = this.createTokenRequestHeaders();
139
+ const thumbprint = {
140
+ clientId: this.config.authOptions.clientId,
141
+ authority: request.authority,
142
+ scopes: request.scopes,
143
+ claims: request.claims,
144
+ authenticationScheme: request.authenticationScheme,
145
+ resourceRequestMethod: request.resourceRequestMethod,
146
+ resourceRequestUri: request.resourceRequestUri,
147
+ shrClaims: request.shrClaims,
148
+ sshKid: request.sshKid,
149
+ };
150
+ reqTimestamp = msalCommon.TimeUtils.nowSeconds();
151
+ const response = await this.executePostToTokenEndpoint(endpoint, requestBody, headers, thumbprint, request.correlationId);
152
+ serverTokenResponse = response.body;
153
+ serverTokenResponse.status = response.status;
154
+ }
155
+ const responseHandler = new msalCommon.ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, this.config.serializableCache, this.config.persistencePlugin);
156
+ responseHandler.validateTokenResponse(serverTokenResponse, refreshAccessToken);
157
+ const tokenResponse = await responseHandler.handleServerTokenResponse(serverTokenResponse, this.authority, reqTimestamp, request);
158
+ return tokenResponse;
159
+ }
160
+ /**
161
+ * generate the request to the server in the acceptable format
162
+ * @param request
163
+ */
164
+ createTokenRequestBody(request) {
165
+ const parameterBuilder = new msalCommon.RequestParameterBuilder();
166
+ parameterBuilder.addClientId(this.config.authOptions.clientId);
167
+ parameterBuilder.addScopes(request.scopes, false);
168
+ parameterBuilder.addGrantType(msalCommon.GrantType.CLIENT_CREDENTIALS_GRANT);
169
+ parameterBuilder.addLibraryInfo(this.config.libraryInfo);
170
+ parameterBuilder.addApplicationTelemetry(this.config.telemetry.application);
171
+ parameterBuilder.addThrottling();
172
+ if (this.serverTelemetryManager) {
173
+ parameterBuilder.addServerTelemetry(this.serverTelemetryManager);
174
+ }
175
+ const correlationId = request.correlationId ||
176
+ this.config.cryptoInterface.createNewGuid();
177
+ parameterBuilder.addCorrelationId(correlationId);
178
+ if (this.config.clientCredentials.clientSecret) {
179
+ parameterBuilder.addClientSecret(this.config.clientCredentials.clientSecret);
180
+ }
181
+ // Use clientAssertion from request, fallback to client assertion in base configuration
182
+ const clientAssertion = request.clientAssertion ||
183
+ this.config.clientCredentials.clientAssertion;
184
+ if (clientAssertion) {
185
+ parameterBuilder.addClientAssertion(clientAssertion.assertion);
186
+ parameterBuilder.addClientAssertionType(clientAssertion.assertionType);
187
+ }
188
+ if (!msalCommon.StringUtils.isEmptyObj(request.claims) ||
189
+ (this.config.authOptions.clientCapabilities &&
190
+ this.config.authOptions.clientCapabilities.length > 0)) {
191
+ parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);
192
+ }
193
+ return parameterBuilder.createQueryString();
194
+ }
195
195
  }
196
196
 
197
197
  exports.ClientCredentialClient = ClientCredentialClient;
@@ -1,34 +1,34 @@
1
- import { AuthenticationResult, BaseClient, ClientConfiguration, CommonClientCredentialRequest, IAppTokenProvider } from "@azure/msal-common";
2
- /**
3
- * OAuth2.0 client credential grant
4
- */
5
- export declare class ClientCredentialClient extends BaseClient {
6
- private scopeSet;
7
- private readonly appTokenProvider?;
8
- constructor(configuration: ClientConfiguration, appTokenProvider?: IAppTokenProvider);
9
- /**
10
- * Public API to acquire a token with ClientCredential Flow for Confidential clients
11
- * @param request
12
- */
13
- acquireToken(request: CommonClientCredentialRequest): Promise<AuthenticationResult | null>;
14
- /**
15
- * looks up cache if the tokens are cached already
16
- */
17
- private getCachedAuthenticationResult;
18
- /**
19
- * Reads access token from the cache
20
- */
21
- private readAccessTokenFromCache;
22
- /**
23
- * Makes a network call to request the token from the service
24
- * @param request
25
- * @param authority
26
- */
27
- private executeTokenRequest;
28
- /**
29
- * generate the request to the server in the acceptable format
30
- * @param request
31
- */
32
- private createTokenRequestBody;
33
- }
1
+ import { AuthenticationResult, BaseClient, ClientConfiguration, CommonClientCredentialRequest, IAppTokenProvider } from "@azure/msal-common";
2
+ /**
3
+ * OAuth2.0 client credential grant
4
+ */
5
+ export declare class ClientCredentialClient extends BaseClient {
6
+ private scopeSet;
7
+ private readonly appTokenProvider?;
8
+ constructor(configuration: ClientConfiguration, appTokenProvider?: IAppTokenProvider);
9
+ /**
10
+ * Public API to acquire a token with ClientCredential Flow for Confidential clients
11
+ * @param request
12
+ */
13
+ acquireToken(request: CommonClientCredentialRequest): Promise<AuthenticationResult | null>;
14
+ /**
15
+ * looks up cache if the tokens are cached already
16
+ */
17
+ private getCachedAuthenticationResult;
18
+ /**
19
+ * Reads access token from the cache
20
+ */
21
+ private readAccessTokenFromCache;
22
+ /**
23
+ * Makes a network call to request the token from the service
24
+ * @param request
25
+ * @param authority
26
+ */
27
+ private executeTokenRequest;
28
+ /**
29
+ * generate the request to the server in the acceptable format
30
+ * @param request
31
+ */
32
+ private createTokenRequestBody;
33
+ }
34
34
  //# sourceMappingURL=ClientCredentialClient.d.ts.map