@azure/msal-node 2.11.1 → 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 (200) 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 +240 -229
  88. package/dist/client/PublicClientApplication.cjs.map +1 -1
  89. package/dist/client/PublicClientApplication.d.ts +72 -71
  90. package/dist/client/PublicClientApplication.d.ts.map +1 -1
  91. package/dist/client/PublicClientApplication.mjs +240 -231
  92. package/dist/client/PublicClientApplication.mjs.map +1 -1
  93. package/dist/client/UsernamePasswordClient.cjs +97 -95
  94. package/dist/client/UsernamePasswordClient.cjs.map +1 -1
  95. package/dist/client/UsernamePasswordClient.d.ts +25 -25
  96. package/dist/client/UsernamePasswordClient.mjs +95 -95
  97. package/dist/config/Configuration.cjs +108 -106
  98. package/dist/config/Configuration.cjs.map +1 -1
  99. package/dist/config/Configuration.d.ts +131 -131
  100. package/dist/config/Configuration.mjs +106 -106
  101. package/dist/config/ManagedIdentityId.cjs +50 -48
  102. package/dist/config/ManagedIdentityId.cjs.map +1 -1
  103. package/dist/config/ManagedIdentityId.d.ts +11 -11
  104. package/dist/config/ManagedIdentityId.mjs +48 -48
  105. package/dist/config/ManagedIdentityRequestParameters.cjs +30 -28
  106. package/dist/config/ManagedIdentityRequestParameters.cjs.map +1 -1
  107. package/dist/config/ManagedIdentityRequestParameters.d.ts +11 -11
  108. package/dist/config/ManagedIdentityRequestParameters.mjs +28 -28
  109. package/dist/crypto/CryptoProvider.cjs +91 -89
  110. package/dist/crypto/CryptoProvider.cjs.map +1 -1
  111. package/dist/crypto/CryptoProvider.d.ts +62 -62
  112. package/dist/crypto/CryptoProvider.mjs +89 -89
  113. package/dist/crypto/GuidGenerator.cjs +24 -22
  114. package/dist/crypto/GuidGenerator.cjs.map +1 -1
  115. package/dist/crypto/GuidGenerator.d.ts +14 -14
  116. package/dist/crypto/GuidGenerator.mjs +22 -22
  117. package/dist/crypto/HashUtils.cjs +19 -13
  118. package/dist/crypto/HashUtils.cjs.map +1 -1
  119. package/dist/crypto/HashUtils.d.ts +8 -8
  120. package/dist/crypto/HashUtils.mjs +13 -13
  121. package/dist/crypto/PkceGenerator.cjs +55 -49
  122. package/dist/crypto/PkceGenerator.cjs.map +1 -1
  123. package/dist/crypto/PkceGenerator.d.ts +22 -22
  124. package/dist/crypto/PkceGenerator.mjs +49 -49
  125. package/dist/error/ManagedIdentityError.cjs +43 -41
  126. package/dist/error/ManagedIdentityError.cjs.map +1 -1
  127. package/dist/error/ManagedIdentityError.d.ts +30 -30
  128. package/dist/error/ManagedIdentityError.mjs +41 -41
  129. package/dist/error/ManagedIdentityErrorCodes.cjs +26 -24
  130. package/dist/error/ManagedIdentityErrorCodes.cjs.map +1 -1
  131. package/dist/error/ManagedIdentityErrorCodes.d.ts +22 -22
  132. package/dist/error/ManagedIdentityErrorCodes.mjs +24 -24
  133. package/dist/error/NodeAuthError.cjs +97 -95
  134. package/dist/error/NodeAuthError.cjs.map +1 -1
  135. package/dist/error/NodeAuthError.d.ts +73 -73
  136. package/dist/error/NodeAuthError.mjs +95 -95
  137. package/dist/index.cjs +3 -1
  138. package/dist/index.cjs.map +1 -1
  139. package/dist/index.d.ts +45 -45
  140. package/dist/index.mjs +1 -1
  141. package/dist/internals.cjs +6 -8
  142. package/dist/internals.cjs.map +1 -1
  143. package/dist/internals.d.ts +6 -6
  144. package/dist/internals.mjs +4 -8
  145. package/dist/internals.mjs.map +1 -1
  146. package/dist/network/HttpClient.cjs +288 -281
  147. package/dist/network/HttpClient.cjs.map +1 -1
  148. package/dist/network/HttpClient.d.ts +25 -25
  149. package/dist/network/HttpClient.mjs +281 -281
  150. package/dist/network/HttpClientWithRetries.cjs +36 -34
  151. package/dist/network/HttpClientWithRetries.cjs.map +1 -1
  152. package/dist/network/HttpClientWithRetries.d.ts +11 -11
  153. package/dist/network/HttpClientWithRetries.mjs +34 -34
  154. package/dist/network/ILoopbackClient.d.ts +10 -10
  155. package/dist/network/LoopbackClient.cjs +87 -77
  156. package/dist/network/LoopbackClient.cjs.map +1 -1
  157. package/dist/network/LoopbackClient.d.ts +21 -21
  158. package/dist/network/LoopbackClient.d.ts.map +1 -1
  159. package/dist/network/LoopbackClient.mjs +81 -77
  160. package/dist/network/LoopbackClient.mjs.map +1 -1
  161. package/dist/packageMetadata.cjs +6 -4
  162. package/dist/packageMetadata.cjs.map +1 -1
  163. package/dist/packageMetadata.d.ts +2 -2
  164. package/dist/packageMetadata.mjs +4 -4
  165. package/dist/request/AuthorizationCodeRequest.d.ts +21 -21
  166. package/dist/request/AuthorizationUrlRequest.d.ts +33 -33
  167. package/dist/request/ClientCredentialRequest.d.ts +14 -14
  168. package/dist/request/DeviceCodeRequest.d.ts +15 -15
  169. package/dist/request/InteractiveRequest.d.ts +22 -22
  170. package/dist/request/ManagedIdentityRequest.d.ts +8 -8
  171. package/dist/request/ManagedIdentityRequestParams.d.ts +9 -9
  172. package/dist/request/OnBehalfOfRequest.d.ts +14 -14
  173. package/dist/request/RefreshTokenRequest.d.ts +17 -17
  174. package/dist/request/SignOutRequest.d.ts +5 -5
  175. package/dist/request/SilentFlowRequest.d.ts +16 -16
  176. package/dist/request/UsernamePasswordRequest.d.ts +19 -19
  177. package/dist/response/ManagedIdentityTokenResponse.d.ts +34 -34
  178. package/dist/retry/IHttpRetryPolicy.d.ts +5 -5
  179. package/dist/retry/LinearRetryPolicy.cjs +42 -40
  180. package/dist/retry/LinearRetryPolicy.cjs.map +1 -1
  181. package/dist/retry/LinearRetryPolicy.d.ts +11 -11
  182. package/dist/retry/LinearRetryPolicy.mjs +40 -40
  183. package/dist/utils/Constants.cjs +138 -136
  184. package/dist/utils/Constants.cjs.map +1 -1
  185. package/dist/utils/Constants.d.ts +141 -141
  186. package/dist/utils/Constants.mjs +136 -136
  187. package/dist/utils/EncodingUtils.cjs +46 -44
  188. package/dist/utils/EncodingUtils.cjs.map +1 -1
  189. package/dist/utils/EncodingUtils.d.ts +26 -26
  190. package/dist/utils/EncodingUtils.mjs +44 -44
  191. package/dist/utils/NetworkUtils.cjs +40 -38
  192. package/dist/utils/NetworkUtils.cjs.map +1 -1
  193. package/dist/utils/NetworkUtils.d.ts +5 -5
  194. package/dist/utils/NetworkUtils.mjs +38 -38
  195. package/package.json +2 -2
  196. package/src/client/ConfidentialClientApplication.ts +3 -3
  197. package/src/client/ManagedIdentitySources/AzureArc.ts +80 -25
  198. package/src/client/PublicClientApplication.ts +13 -1
  199. package/src/network/LoopbackClient.ts +6 -0
  200. package/src/packageMetadata.ts +1 -1
@@ -1,215 +1,217 @@
1
- /*! @azure/msal-node v2.11.1 2024-07-16 */
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
 
7
- /*
8
- * Copyright (c) Microsoft Corporation. All rights reserved.
9
- * Licensed under the MIT License.
10
- */
11
- /**
12
- * OAuth2.0 Device code client
13
- */
14
- class DeviceCodeClient extends msalCommon.BaseClient {
15
- constructor(configuration) {
16
- super(configuration);
17
- }
18
- /**
19
- * Gets device code from device code endpoint, calls back to with device code response, and
20
- * polls token endpoint to exchange device code for tokens
21
- * @param request
22
- */
23
- async acquireToken(request) {
24
- const deviceCodeResponse = await this.getDeviceCode(request);
25
- request.deviceCodeCallback(deviceCodeResponse);
26
- const reqTimestamp = msalCommon.TimeUtils.nowSeconds();
27
- const response = await this.acquireTokenWithDeviceCode(request, deviceCodeResponse);
28
- const responseHandler = new msalCommon.ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, this.config.serializableCache, this.config.persistencePlugin);
29
- // Validate response. This function throws a server error if an error is returned by the server.
30
- responseHandler.validateTokenResponse(response);
31
- return responseHandler.handleServerTokenResponse(response, this.authority, reqTimestamp, request);
32
- }
33
- /**
34
- * Creates device code request and executes http GET
35
- * @param request
36
- */
37
- async getDeviceCode(request) {
38
- const queryParametersString = this.createExtraQueryParameters(request);
39
- const endpoint = msalCommon.UrlString.appendQueryString(this.authority.deviceCodeEndpoint, queryParametersString);
40
- const queryString = this.createQueryString(request);
41
- const headers = this.createTokenRequestHeaders();
42
- const thumbprint = {
43
- clientId: this.config.authOptions.clientId,
44
- authority: request.authority,
45
- scopes: request.scopes,
46
- claims: request.claims,
47
- authenticationScheme: request.authenticationScheme,
48
- resourceRequestMethod: request.resourceRequestMethod,
49
- resourceRequestUri: request.resourceRequestUri,
50
- shrClaims: request.shrClaims,
51
- sshKid: request.sshKid,
52
- };
53
- return this.executePostRequestToDeviceCodeEndpoint(endpoint, queryString, headers, thumbprint);
54
- }
55
- /**
56
- * Creates query string for the device code request
57
- * @param request
58
- */
59
- createExtraQueryParameters(request) {
60
- const parameterBuilder = new msalCommon.RequestParameterBuilder();
61
- if (request.extraQueryParameters) {
62
- parameterBuilder.addExtraQueryParameters(request.extraQueryParameters);
63
- }
64
- return parameterBuilder.createQueryString();
65
- }
66
- /**
67
- * Executes POST request to device code endpoint
68
- * @param deviceCodeEndpoint
69
- * @param queryString
70
- * @param headers
71
- */
72
- async executePostRequestToDeviceCodeEndpoint(deviceCodeEndpoint, queryString, headers, thumbprint) {
73
- const { body: { user_code: userCode, device_code: deviceCode, verification_uri: verificationUri, expires_in: expiresIn, interval, message, }, } = await this.networkManager.sendPostRequest(thumbprint, deviceCodeEndpoint, {
74
- body: queryString,
75
- headers: headers,
76
- });
77
- return {
78
- userCode,
79
- deviceCode,
80
- verificationUri,
81
- expiresIn,
82
- interval,
83
- message,
84
- };
85
- }
86
- /**
87
- * Create device code endpoint query parameters and returns string
88
- */
89
- createQueryString(request) {
90
- const parameterBuilder = new msalCommon.RequestParameterBuilder();
91
- parameterBuilder.addScopes(request.scopes);
92
- parameterBuilder.addClientId(this.config.authOptions.clientId);
93
- if (request.extraQueryParameters) {
94
- parameterBuilder.addExtraQueryParameters(request.extraQueryParameters);
95
- }
96
- if (request.claims ||
97
- (this.config.authOptions.clientCapabilities &&
98
- this.config.authOptions.clientCapabilities.length > 0)) {
99
- parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);
100
- }
101
- return parameterBuilder.createQueryString();
102
- }
103
- /**
104
- * Breaks the polling with specific conditions.
105
- * @param request CommonDeviceCodeRequest
106
- * @param deviceCodeResponse DeviceCodeResponse
107
- */
108
- continuePolling(deviceCodeExpirationTime, userSpecifiedTimeout, userSpecifiedCancelFlag) {
109
- if (userSpecifiedCancelFlag) {
110
- this.logger.error("Token request cancelled by setting DeviceCodeRequest.cancel = true");
111
- throw msalCommon.createClientAuthError(msalCommon.ClientAuthErrorCodes.deviceCodePollingCancelled);
112
- }
113
- else if (userSpecifiedTimeout &&
114
- userSpecifiedTimeout < deviceCodeExpirationTime &&
115
- msalCommon.TimeUtils.nowSeconds() > userSpecifiedTimeout) {
116
- this.logger.error(`User defined timeout for device code polling reached. The timeout was set for ${userSpecifiedTimeout}`);
117
- throw msalCommon.createClientAuthError(msalCommon.ClientAuthErrorCodes.userTimeoutReached);
118
- }
119
- else if (msalCommon.TimeUtils.nowSeconds() > deviceCodeExpirationTime) {
120
- if (userSpecifiedTimeout) {
121
- this.logger.verbose(`User specified timeout ignored as the device code has expired before the timeout elapsed. The user specified timeout was set for ${userSpecifiedTimeout}`);
122
- }
123
- this.logger.error(`Device code expired. Expiration time of device code was ${deviceCodeExpirationTime}`);
124
- throw msalCommon.createClientAuthError(msalCommon.ClientAuthErrorCodes.deviceCodeExpired);
125
- }
126
- return true;
127
- }
128
- /**
129
- * Creates token request with device code response and polls token endpoint at interval set by the device code
130
- * response
131
- * @param request
132
- * @param deviceCodeResponse
133
- */
134
- async acquireTokenWithDeviceCode(request, deviceCodeResponse) {
135
- const queryParametersString = this.createTokenQueryParameters(request);
136
- const endpoint = msalCommon.UrlString.appendQueryString(this.authority.tokenEndpoint, queryParametersString);
137
- const requestBody = this.createTokenRequestBody(request, deviceCodeResponse);
138
- const headers = this.createTokenRequestHeaders();
139
- const userSpecifiedTimeout = request.timeout
140
- ? msalCommon.TimeUtils.nowSeconds() + request.timeout
141
- : undefined;
142
- const deviceCodeExpirationTime = msalCommon.TimeUtils.nowSeconds() + deviceCodeResponse.expiresIn;
143
- const pollingIntervalMilli = deviceCodeResponse.interval * 1000;
144
- /*
145
- * Poll token endpoint while (device code is not expired AND operation has not been cancelled by
146
- * setting CancellationToken.cancel = true). POST request is sent at interval set by pollingIntervalMilli
147
- */
148
- while (this.continuePolling(deviceCodeExpirationTime, userSpecifiedTimeout, request.cancel)) {
149
- const thumbprint = {
150
- clientId: this.config.authOptions.clientId,
151
- authority: request.authority,
152
- scopes: request.scopes,
153
- claims: request.claims,
154
- authenticationScheme: request.authenticationScheme,
155
- resourceRequestMethod: request.resourceRequestMethod,
156
- resourceRequestUri: request.resourceRequestUri,
157
- shrClaims: request.shrClaims,
158
- sshKid: request.sshKid,
159
- };
160
- const response = await this.executePostToTokenEndpoint(endpoint, requestBody, headers, thumbprint, request.correlationId);
161
- if (response.body && response.body.error) {
162
- // user authorization is pending. Sleep for polling interval and try again
163
- if (response.body.error === msalCommon.Constants.AUTHORIZATION_PENDING) {
164
- this.logger.info("Authorization pending. Continue polling.");
165
- await msalCommon.TimeUtils.delay(pollingIntervalMilli);
166
- }
167
- else {
168
- // for any other error, throw
169
- this.logger.info("Unexpected error in polling from the server");
170
- throw msalCommon.createAuthError(msalCommon.AuthErrorCodes.postRequestFailed, response.body.error);
171
- }
172
- }
173
- else {
174
- this.logger.verbose("Authorization completed successfully. Polling stopped.");
175
- return response.body;
176
- }
177
- }
178
- /*
179
- * The above code should've thrown by this point, but to satisfy TypeScript,
180
- * and in the rare case the conditionals in continuePolling() may not catch everything...
181
- */
182
- this.logger.error("Polling stopped for unknown reasons.");
183
- throw msalCommon.createClientAuthError(msalCommon.ClientAuthErrorCodes.deviceCodeUnknownError);
184
- }
185
- /**
186
- * Creates query parameters and converts to string.
187
- * @param request
188
- * @param deviceCodeResponse
189
- */
190
- createTokenRequestBody(request, deviceCodeResponse) {
191
- const requestParameters = new msalCommon.RequestParameterBuilder();
192
- requestParameters.addScopes(request.scopes);
193
- requestParameters.addClientId(this.config.authOptions.clientId);
194
- requestParameters.addGrantType(msalCommon.GrantType.DEVICE_CODE_GRANT);
195
- requestParameters.addDeviceCode(deviceCodeResponse.deviceCode);
196
- const correlationId = request.correlationId ||
197
- this.config.cryptoInterface.createNewGuid();
198
- requestParameters.addCorrelationId(correlationId);
199
- requestParameters.addClientInfo();
200
- requestParameters.addLibraryInfo(this.config.libraryInfo);
201
- requestParameters.addApplicationTelemetry(this.config.telemetry.application);
202
- requestParameters.addThrottling();
203
- if (this.serverTelemetryManager) {
204
- requestParameters.addServerTelemetry(this.serverTelemetryManager);
205
- }
206
- if (!msalCommon.StringUtils.isEmptyObj(request.claims) ||
207
- (this.config.authOptions.clientCapabilities &&
208
- this.config.authOptions.clientCapabilities.length > 0)) {
209
- requestParameters.addClaims(request.claims, this.config.authOptions.clientCapabilities);
210
- }
211
- return requestParameters.createQueryString();
212
- }
9
+ /*
10
+ * Copyright (c) Microsoft Corporation. All rights reserved.
11
+ * Licensed under the MIT License.
12
+ */
13
+ /**
14
+ * OAuth2.0 Device code client
15
+ */
16
+ class DeviceCodeClient extends msalCommon.BaseClient {
17
+ constructor(configuration) {
18
+ super(configuration);
19
+ }
20
+ /**
21
+ * Gets device code from device code endpoint, calls back to with device code response, and
22
+ * polls token endpoint to exchange device code for tokens
23
+ * @param request
24
+ */
25
+ async acquireToken(request) {
26
+ const deviceCodeResponse = await this.getDeviceCode(request);
27
+ request.deviceCodeCallback(deviceCodeResponse);
28
+ const reqTimestamp = msalCommon.TimeUtils.nowSeconds();
29
+ const response = await this.acquireTokenWithDeviceCode(request, deviceCodeResponse);
30
+ const responseHandler = new msalCommon.ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, this.config.serializableCache, this.config.persistencePlugin);
31
+ // Validate response. This function throws a server error if an error is returned by the server.
32
+ responseHandler.validateTokenResponse(response);
33
+ return responseHandler.handleServerTokenResponse(response, this.authority, reqTimestamp, request);
34
+ }
35
+ /**
36
+ * Creates device code request and executes http GET
37
+ * @param request
38
+ */
39
+ async getDeviceCode(request) {
40
+ const queryParametersString = this.createExtraQueryParameters(request);
41
+ const endpoint = msalCommon.UrlString.appendQueryString(this.authority.deviceCodeEndpoint, queryParametersString);
42
+ const queryString = this.createQueryString(request);
43
+ const headers = this.createTokenRequestHeaders();
44
+ const thumbprint = {
45
+ clientId: this.config.authOptions.clientId,
46
+ authority: request.authority,
47
+ scopes: request.scopes,
48
+ claims: request.claims,
49
+ authenticationScheme: request.authenticationScheme,
50
+ resourceRequestMethod: request.resourceRequestMethod,
51
+ resourceRequestUri: request.resourceRequestUri,
52
+ shrClaims: request.shrClaims,
53
+ sshKid: request.sshKid,
54
+ };
55
+ return this.executePostRequestToDeviceCodeEndpoint(endpoint, queryString, headers, thumbprint);
56
+ }
57
+ /**
58
+ * Creates query string for the device code request
59
+ * @param request
60
+ */
61
+ createExtraQueryParameters(request) {
62
+ const parameterBuilder = new msalCommon.RequestParameterBuilder();
63
+ if (request.extraQueryParameters) {
64
+ parameterBuilder.addExtraQueryParameters(request.extraQueryParameters);
65
+ }
66
+ return parameterBuilder.createQueryString();
67
+ }
68
+ /**
69
+ * Executes POST request to device code endpoint
70
+ * @param deviceCodeEndpoint
71
+ * @param queryString
72
+ * @param headers
73
+ */
74
+ async executePostRequestToDeviceCodeEndpoint(deviceCodeEndpoint, queryString, headers, thumbprint) {
75
+ const { body: { user_code: userCode, device_code: deviceCode, verification_uri: verificationUri, expires_in: expiresIn, interval, message, }, } = await this.networkManager.sendPostRequest(thumbprint, deviceCodeEndpoint, {
76
+ body: queryString,
77
+ headers: headers,
78
+ });
79
+ return {
80
+ userCode,
81
+ deviceCode,
82
+ verificationUri,
83
+ expiresIn,
84
+ interval,
85
+ message,
86
+ };
87
+ }
88
+ /**
89
+ * Create device code endpoint query parameters and returns string
90
+ */
91
+ createQueryString(request) {
92
+ const parameterBuilder = new msalCommon.RequestParameterBuilder();
93
+ parameterBuilder.addScopes(request.scopes);
94
+ parameterBuilder.addClientId(this.config.authOptions.clientId);
95
+ if (request.extraQueryParameters) {
96
+ parameterBuilder.addExtraQueryParameters(request.extraQueryParameters);
97
+ }
98
+ if (request.claims ||
99
+ (this.config.authOptions.clientCapabilities &&
100
+ this.config.authOptions.clientCapabilities.length > 0)) {
101
+ parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);
102
+ }
103
+ return parameterBuilder.createQueryString();
104
+ }
105
+ /**
106
+ * Breaks the polling with specific conditions.
107
+ * @param request CommonDeviceCodeRequest
108
+ * @param deviceCodeResponse DeviceCodeResponse
109
+ */
110
+ continuePolling(deviceCodeExpirationTime, userSpecifiedTimeout, userSpecifiedCancelFlag) {
111
+ if (userSpecifiedCancelFlag) {
112
+ this.logger.error("Token request cancelled by setting DeviceCodeRequest.cancel = true");
113
+ throw msalCommon.createClientAuthError(msalCommon.ClientAuthErrorCodes.deviceCodePollingCancelled);
114
+ }
115
+ else if (userSpecifiedTimeout &&
116
+ userSpecifiedTimeout < deviceCodeExpirationTime &&
117
+ msalCommon.TimeUtils.nowSeconds() > userSpecifiedTimeout) {
118
+ this.logger.error(`User defined timeout for device code polling reached. The timeout was set for ${userSpecifiedTimeout}`);
119
+ throw msalCommon.createClientAuthError(msalCommon.ClientAuthErrorCodes.userTimeoutReached);
120
+ }
121
+ else if (msalCommon.TimeUtils.nowSeconds() > deviceCodeExpirationTime) {
122
+ if (userSpecifiedTimeout) {
123
+ this.logger.verbose(`User specified timeout ignored as the device code has expired before the timeout elapsed. The user specified timeout was set for ${userSpecifiedTimeout}`);
124
+ }
125
+ this.logger.error(`Device code expired. Expiration time of device code was ${deviceCodeExpirationTime}`);
126
+ throw msalCommon.createClientAuthError(msalCommon.ClientAuthErrorCodes.deviceCodeExpired);
127
+ }
128
+ return true;
129
+ }
130
+ /**
131
+ * Creates token request with device code response and polls token endpoint at interval set by the device code
132
+ * response
133
+ * @param request
134
+ * @param deviceCodeResponse
135
+ */
136
+ async acquireTokenWithDeviceCode(request, deviceCodeResponse) {
137
+ const queryParametersString = this.createTokenQueryParameters(request);
138
+ const endpoint = msalCommon.UrlString.appendQueryString(this.authority.tokenEndpoint, queryParametersString);
139
+ const requestBody = this.createTokenRequestBody(request, deviceCodeResponse);
140
+ const headers = this.createTokenRequestHeaders();
141
+ const userSpecifiedTimeout = request.timeout
142
+ ? msalCommon.TimeUtils.nowSeconds() + request.timeout
143
+ : undefined;
144
+ const deviceCodeExpirationTime = msalCommon.TimeUtils.nowSeconds() + deviceCodeResponse.expiresIn;
145
+ const pollingIntervalMilli = deviceCodeResponse.interval * 1000;
146
+ /*
147
+ * Poll token endpoint while (device code is not expired AND operation has not been cancelled by
148
+ * setting CancellationToken.cancel = true). POST request is sent at interval set by pollingIntervalMilli
149
+ */
150
+ while (this.continuePolling(deviceCodeExpirationTime, userSpecifiedTimeout, request.cancel)) {
151
+ const thumbprint = {
152
+ clientId: this.config.authOptions.clientId,
153
+ authority: request.authority,
154
+ scopes: request.scopes,
155
+ claims: request.claims,
156
+ authenticationScheme: request.authenticationScheme,
157
+ resourceRequestMethod: request.resourceRequestMethod,
158
+ resourceRequestUri: request.resourceRequestUri,
159
+ shrClaims: request.shrClaims,
160
+ sshKid: request.sshKid,
161
+ };
162
+ const response = await this.executePostToTokenEndpoint(endpoint, requestBody, headers, thumbprint, request.correlationId);
163
+ if (response.body && response.body.error) {
164
+ // user authorization is pending. Sleep for polling interval and try again
165
+ if (response.body.error === msalCommon.Constants.AUTHORIZATION_PENDING) {
166
+ this.logger.info("Authorization pending. Continue polling.");
167
+ await msalCommon.TimeUtils.delay(pollingIntervalMilli);
168
+ }
169
+ else {
170
+ // for any other error, throw
171
+ this.logger.info("Unexpected error in polling from the server");
172
+ throw msalCommon.createAuthError(msalCommon.AuthErrorCodes.postRequestFailed, response.body.error);
173
+ }
174
+ }
175
+ else {
176
+ this.logger.verbose("Authorization completed successfully. Polling stopped.");
177
+ return response.body;
178
+ }
179
+ }
180
+ /*
181
+ * The above code should've thrown by this point, but to satisfy TypeScript,
182
+ * and in the rare case the conditionals in continuePolling() may not catch everything...
183
+ */
184
+ this.logger.error("Polling stopped for unknown reasons.");
185
+ throw msalCommon.createClientAuthError(msalCommon.ClientAuthErrorCodes.deviceCodeUnknownError);
186
+ }
187
+ /**
188
+ * Creates query parameters and converts to string.
189
+ * @param request
190
+ * @param deviceCodeResponse
191
+ */
192
+ createTokenRequestBody(request, deviceCodeResponse) {
193
+ const requestParameters = new msalCommon.RequestParameterBuilder();
194
+ requestParameters.addScopes(request.scopes);
195
+ requestParameters.addClientId(this.config.authOptions.clientId);
196
+ requestParameters.addGrantType(msalCommon.GrantType.DEVICE_CODE_GRANT);
197
+ requestParameters.addDeviceCode(deviceCodeResponse.deviceCode);
198
+ const correlationId = request.correlationId ||
199
+ this.config.cryptoInterface.createNewGuid();
200
+ requestParameters.addCorrelationId(correlationId);
201
+ requestParameters.addClientInfo();
202
+ requestParameters.addLibraryInfo(this.config.libraryInfo);
203
+ requestParameters.addApplicationTelemetry(this.config.telemetry.application);
204
+ requestParameters.addThrottling();
205
+ if (this.serverTelemetryManager) {
206
+ requestParameters.addServerTelemetry(this.serverTelemetryManager);
207
+ }
208
+ if (!msalCommon.StringUtils.isEmptyObj(request.claims) ||
209
+ (this.config.authOptions.clientCapabilities &&
210
+ this.config.authOptions.clientCapabilities.length > 0)) {
211
+ requestParameters.addClaims(request.claims, this.config.authOptions.clientCapabilities);
212
+ }
213
+ return requestParameters.createQueryString();
214
+ }
213
215
  }
214
216
 
215
217
  exports.DeviceCodeClient = DeviceCodeClient;
@@ -1 +1 @@
1
- {"version":3,"file":"DeviceCodeClient.cjs","sources":["../../src/client/DeviceCodeClient.ts"],"sourcesContent":[null],"names":["BaseClient","TimeUtils","ResponseHandler","UrlString","RequestParameterBuilder","createClientAuthError","ClientAuthErrorCodes","Constants","createAuthError","AuthErrorCodes","GrantType","StringUtils"],"mappings":";;;;;;AAAA;;;AAGG;AAwBH;;AAEG;AACG,MAAO,gBAAiB,SAAQA,qBAAU,CAAA;AAC5C,IAAA,WAAA,CAAY,aAAkC,EAAA;QAC1C,KAAK,CAAC,aAAa,CAAC,CAAC;KACxB;AAED;;;;AAIG;IACI,MAAM,YAAY,CACrB,OAAgC,EAAA;QAEhC,MAAM,kBAAkB,GAAuB,MAAM,IAAI,CAAC,aAAa,CACnE,OAAO,CACV,CAAC;AACF,QAAA,OAA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AC,MAAM,GAAG,CAAC,CAAC,EAC5D;AACE,YAAA,iBAAiB,CAAC,SAAS,CACvB,OAAO,CAAC,MAAM,EACd,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,kBAAkB,CAC7C,CAAC;AACL,SAAA;AACD,QAAA,OAAO,iBAAiB,CAAC,iBAAiB,EAAE,CAAC;KAChD;AACJ;;;;"}
1
+ {"version":3,"file":"DeviceCodeClient.cjs","sources":["../../src/client/DeviceCodeClient.ts"],"sourcesContent":[null],"names":["BaseClient","TimeUtils","ResponseHandler","UrlString","RequestParameterBuilder","createClientAuthError","ClientAuthErrorCodes","Constants","createAuthError","AuthErrorCodes","GrantType","StringUtils"],"mappings":";;;;;;;;AAAA;;;AAGG;AAwBH;;AAEG;AACG,MAAO,gBAAiB,SAAQA,qBAAU,CAAA;AAC5C,IAAA,WAAA,CAAY,aAAkC,EAAA;QAC1C,KAAK,CAAC,aAAa,CAAC,CAAC;KACxB;AAED;;;;AAIG;IACI,MAAM,YAAY,CACrB,OAAgC,EAAA;QAEhC,MAAM,kBAAkB,GAAuB,MAAM,IAAI,CAAC,aAAa,CACnE,OAAO,CACV,CAAC;AACF,QAAA,OAAO,CAAC,kBAAkB,CAAC,kBAAkB,CAAC,CAAC;AAC/C,QAAA,MAAM,YAAY,GAAGC,oBAAS,CAAC,UAAU,EAAE,CAAC;QAC5C,MAAM,QAAQ,GACV,MAAM,IAAI,CAAC,0BAA0B,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAAC;AAEvE,QAAA,MAAM,eAAe,GAAG,IAAIC,0BAAe,CACvC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,QAAQ,EAChC,IAAI,CAAC,YAAY,EACjB,IAAI,CAAC,WAAW,EAChB,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,MAAM,CAAC,iBAAiB,EAC7B,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAChC,CAAC;;AAGF,QAAA,eAAe,CAAC,qBAAqB,CAAC,QAAQ,C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AU,CAAC,CAAC;AAC/D,QAAA,MAAM,aAAa,GACf,OAAO,CAAC,aAAa;AACrB,YAAA,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,aAAa,EAAE,CAAC;AAChD,QAAA,iBAAiB,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC;QAClD,iBAAiB,CAAC,aAAa,EAAE,CAAC;QAClC,iBAAiB,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QAC1D,iBAAiB,CAAC,uBAAuB,CACrC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,WAAW,CACpC,CAAC;QACF,iBAAiB,CAAC,aAAa,EAAE,CAAC;QAClC,IAAI,IAAI,CAAC,sBAAsB,EAAE;AAC7B,YAAA,iBAAiB,CAAC,kBAAkB,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;AACrE,SAAA;QAED,IACI,CAACC,sBAAW,CAAC,UAAU,CAAC,OAAO,CAAC,MAAM,CAAC;AACvC,aAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,kBAAkB;gBACvC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,kBAAkB,CAAC,MAAM,GAAG,CAAC,CAAC,EAC5D;AACE,YAAA,iBAAiB,CAAC,SAAS,CACvB,OAAO,CAAC,MAAM,EACd,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,kBAAkB,CAC7C,CAAC;AACL,SAAA;AACD,QAAA,OAAO,iBAAiB,CAAC,iBAAiB,EAAE,CAAC;KAChD;AACJ;;;;"}
@@ -1,54 +1,54 @@
1
- import { AuthenticationResult, BaseClient, ClientConfiguration, CommonDeviceCodeRequest } from "@azure/msal-common";
2
- /**
3
- * OAuth2.0 Device code client
4
- */
5
- export declare class DeviceCodeClient extends BaseClient {
6
- constructor(configuration: ClientConfiguration);
7
- /**
8
- * Gets device code from device code endpoint, calls back to with device code response, and
9
- * polls token endpoint to exchange device code for tokens
10
- * @param request
11
- */
12
- acquireToken(request: CommonDeviceCodeRequest): Promise<AuthenticationResult | null>;
13
- /**
14
- * Creates device code request and executes http GET
15
- * @param request
16
- */
17
- private getDeviceCode;
18
- /**
19
- * Creates query string for the device code request
20
- * @param request
21
- */
22
- createExtraQueryParameters(request: CommonDeviceCodeRequest): string;
23
- /**
24
- * Executes POST request to device code endpoint
25
- * @param deviceCodeEndpoint
26
- * @param queryString
27
- * @param headers
28
- */
29
- private executePostRequestToDeviceCodeEndpoint;
30
- /**
31
- * Create device code endpoint query parameters and returns string
32
- */
33
- private createQueryString;
34
- /**
35
- * Breaks the polling with specific conditions.
36
- * @param request CommonDeviceCodeRequest
37
- * @param deviceCodeResponse DeviceCodeResponse
38
- */
39
- private continuePolling;
40
- /**
41
- * Creates token request with device code response and polls token endpoint at interval set by the device code
42
- * response
43
- * @param request
44
- * @param deviceCodeResponse
45
- */
46
- private acquireTokenWithDeviceCode;
47
- /**
48
- * Creates query parameters and converts to string.
49
- * @param request
50
- * @param deviceCodeResponse
51
- */
52
- private createTokenRequestBody;
53
- }
1
+ import { AuthenticationResult, BaseClient, ClientConfiguration, CommonDeviceCodeRequest } from "@azure/msal-common";
2
+ /**
3
+ * OAuth2.0 Device code client
4
+ */
5
+ export declare class DeviceCodeClient extends BaseClient {
6
+ constructor(configuration: ClientConfiguration);
7
+ /**
8
+ * Gets device code from device code endpoint, calls back to with device code response, and
9
+ * polls token endpoint to exchange device code for tokens
10
+ * @param request
11
+ */
12
+ acquireToken(request: CommonDeviceCodeRequest): Promise<AuthenticationResult | null>;
13
+ /**
14
+ * Creates device code request and executes http GET
15
+ * @param request
16
+ */
17
+ private getDeviceCode;
18
+ /**
19
+ * Creates query string for the device code request
20
+ * @param request
21
+ */
22
+ createExtraQueryParameters(request: CommonDeviceCodeRequest): string;
23
+ /**
24
+ * Executes POST request to device code endpoint
25
+ * @param deviceCodeEndpoint
26
+ * @param queryString
27
+ * @param headers
28
+ */
29
+ private executePostRequestToDeviceCodeEndpoint;
30
+ /**
31
+ * Create device code endpoint query parameters and returns string
32
+ */
33
+ private createQueryString;
34
+ /**
35
+ * Breaks the polling with specific conditions.
36
+ * @param request CommonDeviceCodeRequest
37
+ * @param deviceCodeResponse DeviceCodeResponse
38
+ */
39
+ private continuePolling;
40
+ /**
41
+ * Creates token request with device code response and polls token endpoint at interval set by the device code
42
+ * response
43
+ * @param request
44
+ * @param deviceCodeResponse
45
+ */
46
+ private acquireTokenWithDeviceCode;
47
+ /**
48
+ * Creates query parameters and converts to string.
49
+ * @param request
50
+ * @param deviceCodeResponse
51
+ */
52
+ private createTokenRequestBody;
53
+ }
54
54
  //# sourceMappingURL=DeviceCodeClient.d.ts.map