@azure/msal-node 2.0.2 → 2.2.0-alpha.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 (218) hide show
  1. package/README.md +3 -1
  2. package/dist/cache/ITokenCache.d.ts +15 -15
  3. package/dist/cache/NodeStorage.cjs +401 -401
  4. package/dist/cache/NodeStorage.cjs.map +1 -1
  5. package/dist/cache/NodeStorage.d.ts +182 -182
  6. package/dist/cache/NodeStorage.d.ts.map +1 -1
  7. package/dist/cache/NodeStorage.mjs +401 -401
  8. package/dist/cache/NodeStorage.mjs.map +1 -1
  9. package/dist/cache/TokenCache.cjs +265 -269
  10. package/dist/cache/TokenCache.cjs.map +1 -1
  11. package/dist/cache/TokenCache.d.ts +90 -90
  12. package/dist/cache/TokenCache.d.ts.map +1 -1
  13. package/dist/cache/TokenCache.mjs +266 -270
  14. package/dist/cache/TokenCache.mjs.map +1 -1
  15. package/dist/cache/distributed/DistributedCachePlugin.cjs +26 -26
  16. package/dist/cache/distributed/DistributedCachePlugin.cjs.map +1 -1
  17. package/dist/cache/distributed/DistributedCachePlugin.d.ts +10 -10
  18. package/dist/cache/distributed/DistributedCachePlugin.d.ts.map +1 -1
  19. package/dist/cache/distributed/DistributedCachePlugin.mjs +26 -26
  20. package/dist/cache/distributed/DistributedCachePlugin.mjs.map +1 -1
  21. package/dist/cache/distributed/ICacheClient.d.ts +17 -17
  22. package/dist/cache/distributed/IPartitionManager.d.ts +28 -28
  23. package/dist/cache/serializer/Deserializer.cjs +173 -175
  24. package/dist/cache/serializer/Deserializer.cjs.map +1 -1
  25. package/dist/cache/serializer/Deserializer.d.ts +42 -42
  26. package/dist/cache/serializer/Deserializer.d.ts.map +1 -1
  27. package/dist/cache/serializer/Deserializer.mjs +174 -176
  28. package/dist/cache/serializer/Deserializer.mjs.map +1 -1
  29. package/dist/cache/serializer/Serializer.cjs +134 -134
  30. package/dist/cache/serializer/Serializer.cjs.map +1 -1
  31. package/dist/cache/serializer/Serializer.d.ts +39 -39
  32. package/dist/cache/serializer/Serializer.d.ts.map +1 -1
  33. package/dist/cache/serializer/Serializer.mjs +134 -134
  34. package/dist/cache/serializer/Serializer.mjs.map +1 -1
  35. package/dist/cache/serializer/SerializerTypes.d.ts +101 -101
  36. package/dist/client/ClientApplication.cjs +333 -333
  37. package/dist/client/ClientApplication.cjs.map +1 -1
  38. package/dist/client/ClientApplication.d.ts +142 -142
  39. package/dist/client/ClientApplication.d.ts.map +1 -1
  40. package/dist/client/ClientApplication.mjs +334 -334
  41. package/dist/client/ClientApplication.mjs.map +1 -1
  42. package/dist/client/ClientAssertion.cjs +116 -116
  43. package/dist/client/ClientAssertion.cjs.map +1 -1
  44. package/dist/client/ClientAssertion.d.ts +46 -46
  45. package/dist/client/ClientAssertion.d.ts.map +1 -1
  46. package/dist/client/ClientAssertion.mjs +117 -117
  47. package/dist/client/ClientAssertion.mjs.map +1 -1
  48. package/dist/client/ClientCredentialClient.cjs +189 -168
  49. package/dist/client/ClientCredentialClient.cjs.map +1 -1
  50. package/dist/client/ClientCredentialClient.d.ts +33 -33
  51. package/dist/client/ClientCredentialClient.d.ts.map +1 -1
  52. package/dist/client/ClientCredentialClient.mjs +190 -169
  53. package/dist/client/ClientCredentialClient.mjs.map +1 -1
  54. package/dist/client/ConfidentialClientApplication.cjs +163 -164
  55. package/dist/client/ConfidentialClientApplication.cjs.map +1 -1
  56. package/dist/client/ConfidentialClientApplication.d.ts +58 -58
  57. package/dist/client/ConfidentialClientApplication.d.ts.map +1 -1
  58. package/dist/client/ConfidentialClientApplication.mjs +164 -165
  59. package/dist/client/ConfidentialClientApplication.mjs.map +1 -1
  60. package/dist/client/DeviceCodeClient.cjs +207 -207
  61. package/dist/client/DeviceCodeClient.cjs.map +1 -1
  62. package/dist/client/DeviceCodeClient.d.ts +53 -53
  63. package/dist/client/DeviceCodeClient.d.ts.map +1 -1
  64. package/dist/client/DeviceCodeClient.mjs +208 -208
  65. package/dist/client/DeviceCodeClient.mjs.map +1 -1
  66. package/dist/client/IConfidentialClientApplication.d.ts +39 -39
  67. package/dist/client/IConfidentialClientApplication.d.ts.map +1 -1
  68. package/dist/client/IPublicClientApplication.d.ts +42 -42
  69. package/dist/client/IPublicClientApplication.d.ts.map +1 -1
  70. package/dist/client/OnBehalfOfClient.cjs +203 -204
  71. package/dist/client/OnBehalfOfClient.cjs.map +1 -1
  72. package/dist/client/OnBehalfOfClient.d.ts +47 -47
  73. package/dist/client/OnBehalfOfClient.d.ts.map +1 -1
  74. package/dist/client/OnBehalfOfClient.mjs +204 -205
  75. package/dist/client/OnBehalfOfClient.mjs.map +1 -1
  76. package/dist/client/PublicClientApplication.cjs +229 -175
  77. package/dist/client/PublicClientApplication.cjs.map +1 -1
  78. package/dist/client/PublicClientApplication.d.ts +71 -65
  79. package/dist/client/PublicClientApplication.d.ts.map +1 -1
  80. package/dist/client/PublicClientApplication.mjs +232 -178
  81. package/dist/client/PublicClientApplication.mjs.map +1 -1
  82. package/dist/client/UsernamePasswordClient.cjs +95 -95
  83. package/dist/client/UsernamePasswordClient.cjs.map +1 -1
  84. package/dist/client/UsernamePasswordClient.d.ts +25 -25
  85. package/dist/client/UsernamePasswordClient.d.ts.map +1 -1
  86. package/dist/client/UsernamePasswordClient.mjs +95 -95
  87. package/dist/client/UsernamePasswordClient.mjs.map +1 -1
  88. package/dist/config/Configuration.cjs +72 -72
  89. package/dist/config/Configuration.cjs.map +1 -1
  90. package/dist/config/Configuration.d.ts +107 -107
  91. package/dist/config/Configuration.mjs +72 -72
  92. package/dist/config/Configuration.mjs.map +1 -1
  93. package/dist/crypto/CryptoProvider.cjs +75 -75
  94. package/dist/crypto/CryptoProvider.cjs.map +1 -1
  95. package/dist/crypto/CryptoProvider.d.ts +52 -52
  96. package/dist/crypto/CryptoProvider.mjs +75 -75
  97. package/dist/crypto/CryptoProvider.mjs.map +1 -1
  98. package/dist/crypto/GuidGenerator.cjs +22 -22
  99. package/dist/crypto/GuidGenerator.cjs.map +1 -1
  100. package/dist/crypto/GuidGenerator.d.ts +14 -14
  101. package/dist/crypto/GuidGenerator.mjs +22 -22
  102. package/dist/crypto/GuidGenerator.mjs.map +1 -1
  103. package/dist/crypto/HashUtils.cjs +13 -13
  104. package/dist/crypto/HashUtils.cjs.map +1 -1
  105. package/dist/crypto/HashUtils.d.ts +8 -8
  106. package/dist/crypto/HashUtils.mjs +13 -13
  107. package/dist/crypto/HashUtils.mjs.map +1 -1
  108. package/dist/crypto/PkceGenerator.cjs +49 -49
  109. package/dist/crypto/PkceGenerator.cjs.map +1 -1
  110. package/dist/crypto/PkceGenerator.d.ts +22 -22
  111. package/dist/crypto/PkceGenerator.mjs +49 -49
  112. package/dist/crypto/PkceGenerator.mjs.map +1 -1
  113. package/dist/error/NodeAuthError.cjs +85 -85
  114. package/dist/error/NodeAuthError.cjs.map +1 -1
  115. package/dist/error/NodeAuthError.d.ts +65 -65
  116. package/dist/error/NodeAuthError.mjs +85 -85
  117. package/dist/error/NodeAuthError.mjs.map +1 -1
  118. package/dist/index.cjs +17 -1
  119. package/dist/index.cjs.map +1 -1
  120. package/dist/index.d.ts +42 -42
  121. package/dist/index.d.ts.map +1 -1
  122. package/dist/index.mjs +2 -2
  123. package/dist/internals.cjs +8 -8
  124. package/dist/internals.cjs.map +1 -1
  125. package/dist/internals.d.ts +6 -6
  126. package/dist/internals.d.ts.map +1 -1
  127. package/dist/internals.mjs +8 -8
  128. package/dist/internals.mjs.map +1 -1
  129. package/dist/network/HttpClient.cjs +277 -276
  130. package/dist/network/HttpClient.cjs.map +1 -1
  131. package/dist/network/HttpClient.d.ts +25 -25
  132. package/dist/network/HttpClient.d.ts.map +1 -1
  133. package/dist/network/HttpClient.mjs +278 -277
  134. package/dist/network/HttpClient.mjs.map +1 -1
  135. package/dist/network/ILoopbackClient.d.ts +10 -10
  136. package/dist/network/LoopbackClient.cjs +75 -84
  137. package/dist/network/LoopbackClient.cjs.map +1 -1
  138. package/dist/network/LoopbackClient.d.ts +21 -21
  139. package/dist/network/LoopbackClient.d.ts.map +1 -1
  140. package/dist/network/LoopbackClient.mjs +77 -86
  141. package/dist/network/LoopbackClient.mjs.map +1 -1
  142. package/dist/packageMetadata.cjs +4 -4
  143. package/dist/packageMetadata.cjs.map +1 -1
  144. package/dist/packageMetadata.d.ts +2 -2
  145. package/dist/packageMetadata.mjs +4 -4
  146. package/dist/packageMetadata.mjs.map +1 -1
  147. package/dist/request/AuthorizationCodeRequest.d.ts +21 -21
  148. package/dist/request/AuthorizationUrlRequest.d.ts +33 -33
  149. package/dist/request/ClientCredentialRequest.d.ts +14 -14
  150. package/dist/request/DeviceCodeRequest.d.ts +15 -15
  151. package/dist/request/InteractiveRequest.d.ts +22 -22
  152. package/dist/request/InteractiveRequest.d.ts.map +1 -1
  153. package/dist/request/OnBehalfOfRequest.d.ts +14 -14
  154. package/dist/request/RefreshTokenRequest.d.ts +17 -17
  155. package/dist/request/SignOutRequest.d.ts +5 -5
  156. package/dist/request/SilentFlowRequest.d.ts +16 -16
  157. package/dist/request/UsernamePasswordRequest.d.ts +19 -19
  158. package/dist/utils/Constants.cjs +80 -90
  159. package/dist/utils/Constants.cjs.map +1 -1
  160. package/dist/utils/Constants.d.ts +86 -96
  161. package/dist/utils/Constants.d.ts.map +1 -1
  162. package/dist/utils/Constants.mjs +81 -90
  163. package/dist/utils/Constants.mjs.map +1 -1
  164. package/dist/utils/EncodingUtils.cjs +44 -44
  165. package/dist/utils/EncodingUtils.cjs.map +1 -1
  166. package/dist/utils/EncodingUtils.d.ts +26 -26
  167. package/dist/utils/EncodingUtils.mjs +44 -44
  168. package/dist/utils/EncodingUtils.mjs.map +1 -1
  169. package/dist/utils/NetworkUtils.cjs +38 -38
  170. package/dist/utils/NetworkUtils.cjs.map +1 -1
  171. package/dist/utils/NetworkUtils.d.ts +5 -5
  172. package/dist/utils/NetworkUtils.mjs +38 -38
  173. package/dist/utils/NetworkUtils.mjs.map +1 -1
  174. package/package.json +8 -5
  175. package/src/cache/ITokenCache.ts +24 -0
  176. package/src/cache/NodeStorage.ts +533 -0
  177. package/src/cache/TokenCache.ts +358 -0
  178. package/src/cache/distributed/DistributedCachePlugin.ts +56 -0
  179. package/src/cache/distributed/ICacheClient.ts +23 -0
  180. package/src/cache/distributed/IPartitionManager.ts +35 -0
  181. package/src/cache/serializer/Deserializer.ts +218 -0
  182. package/src/cache/serializer/Serializer.ts +173 -0
  183. package/src/cache/serializer/SerializerTypes.ts +121 -0
  184. package/src/client/ClientApplication.ts +596 -0
  185. package/src/client/ClientAssertion.ts +165 -0
  186. package/src/client/ClientCredentialClient.ts +346 -0
  187. package/src/client/ConfidentialClientApplication.ts +268 -0
  188. package/src/client/DeviceCodeClient.ts +369 -0
  189. package/src/client/IConfidentialClientApplication.ts +72 -0
  190. package/src/client/IPublicClientApplication.ts +72 -0
  191. package/src/client/OnBehalfOfClient.ts +368 -0
  192. package/src/client/PublicClientApplication.ts +339 -0
  193. package/src/client/UsernamePasswordClient.ts +180 -0
  194. package/src/config/Configuration.ts +201 -0
  195. package/src/crypto/CryptoProvider.ts +98 -0
  196. package/src/crypto/GuidGenerator.ts +28 -0
  197. package/src/crypto/HashUtils.ts +17 -0
  198. package/src/crypto/PkceGenerator.ts +63 -0
  199. package/src/error/NodeAuthError.ts +117 -0
  200. package/src/index.ts +125 -0
  201. package/src/internals.ts +12 -0
  202. package/src/network/HttpClient.ts +425 -0
  203. package/src/network/ILoopbackClient.ts +19 -0
  204. package/src/network/LoopbackClient.ts +110 -0
  205. package/src/packageMetadata.ts +3 -0
  206. package/src/request/AuthorizationCodeRequest.ts +39 -0
  207. package/src/request/AuthorizationUrlRequest.ts +50 -0
  208. package/src/request/ClientCredentialRequest.ts +29 -0
  209. package/src/request/DeviceCodeRequest.ts +34 -0
  210. package/src/request/InteractiveRequest.ts +39 -0
  211. package/src/request/OnBehalfOfRequest.ts +30 -0
  212. package/src/request/RefreshTokenRequest.ts +34 -0
  213. package/src/request/SignOutRequest.ts +11 -0
  214. package/src/request/SilentFlowRequest.ts +32 -0
  215. package/src/request/UsernamePasswordRequest.ts +36 -0
  216. package/src/utils/Constants.ts +103 -0
  217. package/src/utils/EncodingUtils.ts +50 -0
  218. package/src/utils/NetworkUtils.ts +49 -0
@@ -1,285 +1,286 @@
1
- /*! @azure/msal-node v2.0.2 2023-08-18 */
1
+ /*! @azure/msal-node v2.2.0-alpha.0 2023-09-20 */
2
2
  'use strict';
3
- import { ProxyStatus, HttpStatus, Constants, HttpMethod } from '../utils/Constants.mjs';
3
+ import { HttpStatus } from '@azure/msal-common';
4
+ import { ProxyStatus, Constants, HttpMethod } from '../utils/Constants.mjs';
4
5
  import { NetworkUtils } from '../utils/NetworkUtils.mjs';
5
6
  import http from 'http';
6
7
  import https from 'https';
7
8
 
8
- /*
9
- * Copyright (c) Microsoft Corporation. All rights reserved.
10
- * Licensed under the MIT License.
11
- */
12
- /**
13
- * This class implements the API for network requests.
14
- */
15
- class HttpClient {
16
- constructor(proxyUrl, customAgentOptions) {
17
- this.proxyUrl = proxyUrl || "";
18
- this.customAgentOptions = customAgentOptions || {};
19
- }
20
- /**
21
- * Http Get request
22
- * @param url
23
- * @param options
24
- */
25
- async sendGetRequestAsync(url, options) {
26
- if (this.proxyUrl) {
27
- return networkRequestViaProxy(url, this.proxyUrl, HttpMethod.GET, options, this.customAgentOptions);
28
- }
29
- else {
30
- return networkRequestViaHttps(url, HttpMethod.GET, options, this.customAgentOptions);
31
- }
32
- }
33
- /**
34
- * Http Post request
35
- * @param url
36
- * @param options
37
- */
38
- async sendPostRequestAsync(url, options, cancellationToken) {
39
- if (this.proxyUrl) {
40
- return networkRequestViaProxy(url, this.proxyUrl, HttpMethod.POST, options, this.customAgentOptions, cancellationToken);
41
- }
42
- else {
43
- return networkRequestViaHttps(url, HttpMethod.POST, options, this.customAgentOptions, cancellationToken);
44
- }
45
- }
46
- }
47
- const networkRequestViaProxy = (destinationUrlString, proxyUrlString, httpMethod, options, agentOptions, timeout) => {
48
- const destinationUrl = new URL(destinationUrlString);
49
- const proxyUrl = new URL(proxyUrlString);
50
- // "method: connect" must be used to establish a connection to the proxy
51
- const headers = options?.headers || {};
52
- const tunnelRequestOptions = {
53
- host: proxyUrl.hostname,
54
- port: proxyUrl.port,
55
- method: "CONNECT",
56
- path: destinationUrl.hostname,
57
- headers: headers,
58
- };
59
- if (timeout) {
60
- tunnelRequestOptions.timeout = timeout;
61
- }
62
- if (agentOptions && Object.keys(agentOptions).length) {
63
- tunnelRequestOptions.agent = new http.Agent(agentOptions);
64
- }
65
- // compose a request string for the socket
66
- let postRequestStringContent = "";
67
- if (httpMethod === HttpMethod.POST) {
68
- const body = options?.body || "";
69
- postRequestStringContent =
70
- "Content-Type: application/x-www-form-urlencoded\r\n" +
71
- `Content-Length: ${body.length}\r\n` +
72
- `\r\n${body}`;
73
- }
74
- const outgoingRequestString = `${httpMethod.toUpperCase()} ${destinationUrl.href} HTTP/1.1\r\n` +
75
- `Host: ${destinationUrl.host}\r\n` +
76
- "Connection: close\r\n" +
77
- postRequestStringContent +
78
- "\r\n";
79
- return new Promise((resolve, reject) => {
80
- const request = http.request(tunnelRequestOptions);
81
- if (tunnelRequestOptions.timeout) {
82
- request.on("timeout", () => {
83
- request.destroy();
84
- reject(new Error("Request time out"));
85
- });
86
- }
87
- request.end();
88
- // establish connection to the proxy
89
- request.on("connect", (response, socket) => {
90
- const proxyStatusCode = response?.statusCode || ProxyStatus.SERVER_ERROR;
91
- if (proxyStatusCode < ProxyStatus.SUCCESS_RANGE_START ||
92
- proxyStatusCode > ProxyStatus.SUCCESS_RANGE_END) {
93
- request.destroy();
94
- socket.destroy();
95
- reject(new Error(`Error connecting to proxy. Http status code: ${response.statusCode}. Http status message: ${response?.statusMessage || "Unknown"}`));
96
- }
97
- if (tunnelRequestOptions.timeout) {
98
- socket.setTimeout(tunnelRequestOptions.timeout);
99
- socket.on("timeout", () => {
100
- request.destroy();
101
- socket.destroy();
102
- reject(new Error("Request time out"));
103
- });
104
- }
105
- // make a request over an HTTP tunnel
106
- socket.write(outgoingRequestString);
107
- const data = [];
108
- socket.on("data", (chunk) => {
109
- data.push(chunk);
110
- });
111
- socket.on("end", () => {
112
- // combine all received buffer streams into one buffer, and then into a string
113
- const dataString = Buffer.concat([...data]).toString();
114
- // separate each line into it's own entry in an arry
115
- const dataStringArray = dataString.split("\r\n");
116
- // the first entry will contain the statusCode and statusMessage
117
- const httpStatusCode = parseInt(dataStringArray[0].split(" ")[1]);
118
- // remove "HTTP/1.1" and the status code to get the status message
119
- const statusMessage = dataStringArray[0]
120
- .split(" ")
121
- .slice(2)
122
- .join(" ");
123
- // the last entry will contain the body
124
- const body = dataStringArray[dataStringArray.length - 1];
125
- // everything in between the first and last entries are the headers
126
- const headersArray = dataStringArray.slice(1, dataStringArray.length - 2);
127
- // build an object out of all the headers
128
- const entries = new Map();
129
- headersArray.forEach((header) => {
130
- /**
131
- * the header might look like "Content-Length: 1531", but that is just a string
132
- * it needs to be converted to a key/value pair
133
- * split the string at the first instance of ":"
134
- * there may be more than one ":" if the value of the header is supposed to be a JSON object
135
- */
136
- const headerKeyValue = header.split(new RegExp(/:\s(.*)/s));
137
- const headerKey = headerKeyValue[0];
138
- let headerValue = headerKeyValue[1];
139
- // check if the value of the header is supposed to be a JSON object
140
- try {
141
- const object = JSON.parse(headerValue);
142
- // if it is, then convert it from a string to a JSON object
143
- if (object && typeof object === "object") {
144
- headerValue = object;
145
- }
146
- }
147
- catch (e) {
148
- // otherwise, leave it as a string
149
- }
150
- entries.set(headerKey, headerValue);
151
- });
152
- const headers = Object.fromEntries(entries);
153
- const parsedHeaders = headers;
154
- const networkResponse = NetworkUtils.getNetworkResponse(parsedHeaders, parseBody(httpStatusCode, statusMessage, parsedHeaders, body), httpStatusCode);
155
- if ((httpStatusCode < HttpStatus.SUCCESS_RANGE_START ||
156
- httpStatusCode > HttpStatus.SUCCESS_RANGE_END) &&
157
- // do not destroy the request for the device code flow
158
- networkResponse.body["error"] !==
159
- Constants.AUTHORIZATION_PENDING) {
160
- request.destroy();
161
- }
162
- resolve(networkResponse);
163
- });
164
- socket.on("error", (chunk) => {
165
- request.destroy();
166
- socket.destroy();
167
- reject(new Error(chunk.toString()));
168
- });
169
- });
170
- request.on("error", (chunk) => {
171
- request.destroy();
172
- reject(new Error(chunk.toString()));
173
- });
174
- });
175
- };
176
- const networkRequestViaHttps = (urlString, httpMethod, options, agentOptions, timeout) => {
177
- const isPostRequest = httpMethod === HttpMethod.POST;
178
- const body = options?.body || "";
179
- const url = new URL(urlString);
180
- const headers = options?.headers || {};
181
- const customOptions = {
182
- method: httpMethod,
183
- headers: headers,
184
- ...NetworkUtils.urlToHttpOptions(url),
185
- };
186
- if (timeout) {
187
- customOptions.timeout = timeout;
188
- }
189
- if (agentOptions && Object.keys(agentOptions).length) {
190
- customOptions.agent = new https.Agent(agentOptions);
191
- }
192
- if (isPostRequest) {
193
- // needed for post request to work
194
- customOptions.headers = {
195
- ...customOptions.headers,
196
- "Content-Length": body.length,
197
- };
198
- }
199
- return new Promise((resolve, reject) => {
200
- const request = https.request(customOptions);
201
- if (timeout) {
202
- request.on("timeout", () => {
203
- request.destroy();
204
- reject(new Error("Request time out"));
205
- });
206
- }
207
- if (isPostRequest) {
208
- request.write(body);
209
- }
210
- request.end();
211
- request.on("response", (response) => {
212
- const headers = response.headers;
213
- const statusCode = response.statusCode;
214
- const statusMessage = response.statusMessage;
215
- const data = [];
216
- response.on("data", (chunk) => {
217
- data.push(chunk);
218
- });
219
- response.on("end", () => {
220
- // combine all received buffer streams into one buffer, and then into a string
221
- const body = Buffer.concat([...data]).toString();
222
- const parsedHeaders = headers;
223
- const networkResponse = NetworkUtils.getNetworkResponse(parsedHeaders, parseBody(statusCode, statusMessage, parsedHeaders, body), statusCode);
224
- if ((statusCode < HttpStatus.SUCCESS_RANGE_START ||
225
- statusCode > HttpStatus.SUCCESS_RANGE_END) &&
226
- // do not destroy the request for the device code flow
227
- networkResponse.body["error"] !==
228
- Constants.AUTHORIZATION_PENDING) {
229
- request.destroy();
230
- }
231
- resolve(networkResponse);
232
- });
233
- });
234
- request.on("error", (chunk) => {
235
- request.destroy();
236
- reject(new Error(chunk.toString()));
237
- });
238
- });
239
- };
240
- /**
241
- * Check if extra parsing is needed on the repsonse from the server
242
- * @param statusCode {number} the status code of the response from the server
243
- * @param statusMessage {string | undefined} the status message of the response from the server
244
- * @param headers {Record<string, string>} the headers of the response from the server
245
- * @param body {string} the body from the response of the server
246
- * @returns {Object} JSON parsed body or error object
247
- */
248
- const parseBody = (statusCode, statusMessage, headers, body) => {
249
- /*
250
- * Informational responses (100 – 199)
251
- * Successful responses (200 – 299)
252
- * Redirection messages (300 – 399)
253
- * Client error responses (400 – 499)
254
- * Server error responses (500 – 599)
255
- */
256
- let parsedBody;
257
- try {
258
- parsedBody = JSON.parse(body);
259
- }
260
- catch (error) {
261
- let errorType;
262
- let errorDescriptionHelper;
263
- if (statusCode >= HttpStatus.CLIENT_ERROR_RANGE_START &&
264
- statusCode <= HttpStatus.CLIENT_ERROR_RANGE_END) {
265
- errorType = "client_error";
266
- errorDescriptionHelper = "A client";
267
- }
268
- else if (statusCode >= HttpStatus.SERVER_ERROR_RANGE_START &&
269
- statusCode <= HttpStatus.SERVER_ERROR_RANGE_END) {
270
- errorType = "server_error";
271
- errorDescriptionHelper = "A server";
272
- }
273
- else {
274
- errorType = "unknown_error";
275
- errorDescriptionHelper = "An unknown";
276
- }
277
- parsedBody = {
278
- error: errorType,
279
- error_description: `${errorDescriptionHelper} error occured.\nHttp status code: ${statusCode}\nHttp status message: ${statusMessage || "Unknown"}\nHeaders: ${JSON.stringify(headers)}`,
280
- };
281
- }
282
- return parsedBody;
9
+ /*
10
+ * Copyright (c) Microsoft Corporation. All rights reserved.
11
+ * Licensed under the MIT License.
12
+ */
13
+ /**
14
+ * This class implements the API for network requests.
15
+ */
16
+ class HttpClient {
17
+ constructor(proxyUrl, customAgentOptions) {
18
+ this.proxyUrl = proxyUrl || "";
19
+ this.customAgentOptions = customAgentOptions || {};
20
+ }
21
+ /**
22
+ * Http Get request
23
+ * @param url
24
+ * @param options
25
+ */
26
+ async sendGetRequestAsync(url, options) {
27
+ if (this.proxyUrl) {
28
+ return networkRequestViaProxy(url, this.proxyUrl, HttpMethod.GET, options, this.customAgentOptions);
29
+ }
30
+ else {
31
+ return networkRequestViaHttps(url, HttpMethod.GET, options, this.customAgentOptions);
32
+ }
33
+ }
34
+ /**
35
+ * Http Post request
36
+ * @param url
37
+ * @param options
38
+ */
39
+ async sendPostRequestAsync(url, options, cancellationToken) {
40
+ if (this.proxyUrl) {
41
+ return networkRequestViaProxy(url, this.proxyUrl, HttpMethod.POST, options, this.customAgentOptions, cancellationToken);
42
+ }
43
+ else {
44
+ return networkRequestViaHttps(url, HttpMethod.POST, options, this.customAgentOptions, cancellationToken);
45
+ }
46
+ }
47
+ }
48
+ const networkRequestViaProxy = (destinationUrlString, proxyUrlString, httpMethod, options, agentOptions, timeout) => {
49
+ const destinationUrl = new URL(destinationUrlString);
50
+ const proxyUrl = new URL(proxyUrlString);
51
+ // "method: connect" must be used to establish a connection to the proxy
52
+ const headers = options?.headers || {};
53
+ const tunnelRequestOptions = {
54
+ host: proxyUrl.hostname,
55
+ port: proxyUrl.port,
56
+ method: "CONNECT",
57
+ path: destinationUrl.hostname,
58
+ headers: headers,
59
+ };
60
+ if (timeout) {
61
+ tunnelRequestOptions.timeout = timeout;
62
+ }
63
+ if (agentOptions && Object.keys(agentOptions).length) {
64
+ tunnelRequestOptions.agent = new http.Agent(agentOptions);
65
+ }
66
+ // compose a request string for the socket
67
+ let postRequestStringContent = "";
68
+ if (httpMethod === HttpMethod.POST) {
69
+ const body = options?.body || "";
70
+ postRequestStringContent =
71
+ "Content-Type: application/x-www-form-urlencoded\r\n" +
72
+ `Content-Length: ${body.length}\r\n` +
73
+ `\r\n${body}`;
74
+ }
75
+ const outgoingRequestString = `${httpMethod.toUpperCase()} ${destinationUrl.href} HTTP/1.1\r\n` +
76
+ `Host: ${destinationUrl.host}\r\n` +
77
+ "Connection: close\r\n" +
78
+ postRequestStringContent +
79
+ "\r\n";
80
+ return new Promise((resolve, reject) => {
81
+ const request = http.request(tunnelRequestOptions);
82
+ if (tunnelRequestOptions.timeout) {
83
+ request.on("timeout", () => {
84
+ request.destroy();
85
+ reject(new Error("Request time out"));
86
+ });
87
+ }
88
+ request.end();
89
+ // establish connection to the proxy
90
+ request.on("connect", (response, socket) => {
91
+ const proxyStatusCode = response?.statusCode || ProxyStatus.SERVER_ERROR;
92
+ if (proxyStatusCode < ProxyStatus.SUCCESS_RANGE_START ||
93
+ proxyStatusCode > ProxyStatus.SUCCESS_RANGE_END) {
94
+ request.destroy();
95
+ socket.destroy();
96
+ reject(new Error(`Error connecting to proxy. Http status code: ${response.statusCode}. Http status message: ${response?.statusMessage || "Unknown"}`));
97
+ }
98
+ if (tunnelRequestOptions.timeout) {
99
+ socket.setTimeout(tunnelRequestOptions.timeout);
100
+ socket.on("timeout", () => {
101
+ request.destroy();
102
+ socket.destroy();
103
+ reject(new Error("Request time out"));
104
+ });
105
+ }
106
+ // make a request over an HTTP tunnel
107
+ socket.write(outgoingRequestString);
108
+ const data = [];
109
+ socket.on("data", (chunk) => {
110
+ data.push(chunk);
111
+ });
112
+ socket.on("end", () => {
113
+ // combine all received buffer streams into one buffer, and then into a string
114
+ const dataString = Buffer.concat([...data]).toString();
115
+ // separate each line into it's own entry in an arry
116
+ const dataStringArray = dataString.split("\r\n");
117
+ // the first entry will contain the statusCode and statusMessage
118
+ const httpStatusCode = parseInt(dataStringArray[0].split(" ")[1]);
119
+ // remove "HTTP/1.1" and the status code to get the status message
120
+ const statusMessage = dataStringArray[0]
121
+ .split(" ")
122
+ .slice(2)
123
+ .join(" ");
124
+ // the last entry will contain the body
125
+ const body = dataStringArray[dataStringArray.length - 1];
126
+ // everything in between the first and last entries are the headers
127
+ const headersArray = dataStringArray.slice(1, dataStringArray.length - 2);
128
+ // build an object out of all the headers
129
+ const entries = new Map();
130
+ headersArray.forEach((header) => {
131
+ /**
132
+ * the header might look like "Content-Length: 1531", but that is just a string
133
+ * it needs to be converted to a key/value pair
134
+ * split the string at the first instance of ":"
135
+ * there may be more than one ":" if the value of the header is supposed to be a JSON object
136
+ */
137
+ const headerKeyValue = header.split(new RegExp(/:\s(.*)/s));
138
+ const headerKey = headerKeyValue[0];
139
+ let headerValue = headerKeyValue[1];
140
+ // check if the value of the header is supposed to be a JSON object
141
+ try {
142
+ const object = JSON.parse(headerValue);
143
+ // if it is, then convert it from a string to a JSON object
144
+ if (object && typeof object === "object") {
145
+ headerValue = object;
146
+ }
147
+ }
148
+ catch (e) {
149
+ // otherwise, leave it as a string
150
+ }
151
+ entries.set(headerKey, headerValue);
152
+ });
153
+ const headers = Object.fromEntries(entries);
154
+ const parsedHeaders = headers;
155
+ const networkResponse = NetworkUtils.getNetworkResponse(parsedHeaders, parseBody(httpStatusCode, statusMessage, parsedHeaders, body), httpStatusCode);
156
+ if ((httpStatusCode < HttpStatus.SUCCESS_RANGE_START ||
157
+ httpStatusCode > HttpStatus.SUCCESS_RANGE_END) &&
158
+ // do not destroy the request for the device code flow
159
+ networkResponse.body["error"] !==
160
+ Constants.AUTHORIZATION_PENDING) {
161
+ request.destroy();
162
+ }
163
+ resolve(networkResponse);
164
+ });
165
+ socket.on("error", (chunk) => {
166
+ request.destroy();
167
+ socket.destroy();
168
+ reject(new Error(chunk.toString()));
169
+ });
170
+ });
171
+ request.on("error", (chunk) => {
172
+ request.destroy();
173
+ reject(new Error(chunk.toString()));
174
+ });
175
+ });
176
+ };
177
+ const networkRequestViaHttps = (urlString, httpMethod, options, agentOptions, timeout) => {
178
+ const isPostRequest = httpMethod === HttpMethod.POST;
179
+ const body = options?.body || "";
180
+ const url = new URL(urlString);
181
+ const headers = options?.headers || {};
182
+ const customOptions = {
183
+ method: httpMethod,
184
+ headers: headers,
185
+ ...NetworkUtils.urlToHttpOptions(url),
186
+ };
187
+ if (timeout) {
188
+ customOptions.timeout = timeout;
189
+ }
190
+ if (agentOptions && Object.keys(agentOptions).length) {
191
+ customOptions.agent = new https.Agent(agentOptions);
192
+ }
193
+ if (isPostRequest) {
194
+ // needed for post request to work
195
+ customOptions.headers = {
196
+ ...customOptions.headers,
197
+ "Content-Length": body.length,
198
+ };
199
+ }
200
+ return new Promise((resolve, reject) => {
201
+ const request = https.request(customOptions);
202
+ if (timeout) {
203
+ request.on("timeout", () => {
204
+ request.destroy();
205
+ reject(new Error("Request time out"));
206
+ });
207
+ }
208
+ if (isPostRequest) {
209
+ request.write(body);
210
+ }
211
+ request.end();
212
+ request.on("response", (response) => {
213
+ const headers = response.headers;
214
+ const statusCode = response.statusCode;
215
+ const statusMessage = response.statusMessage;
216
+ const data = [];
217
+ response.on("data", (chunk) => {
218
+ data.push(chunk);
219
+ });
220
+ response.on("end", () => {
221
+ // combine all received buffer streams into one buffer, and then into a string
222
+ const body = Buffer.concat([...data]).toString();
223
+ const parsedHeaders = headers;
224
+ const networkResponse = NetworkUtils.getNetworkResponse(parsedHeaders, parseBody(statusCode, statusMessage, parsedHeaders, body), statusCode);
225
+ if ((statusCode < HttpStatus.SUCCESS_RANGE_START ||
226
+ statusCode > HttpStatus.SUCCESS_RANGE_END) &&
227
+ // do not destroy the request for the device code flow
228
+ networkResponse.body["error"] !==
229
+ Constants.AUTHORIZATION_PENDING) {
230
+ request.destroy();
231
+ }
232
+ resolve(networkResponse);
233
+ });
234
+ });
235
+ request.on("error", (chunk) => {
236
+ request.destroy();
237
+ reject(new Error(chunk.toString()));
238
+ });
239
+ });
240
+ };
241
+ /**
242
+ * Check if extra parsing is needed on the repsonse from the server
243
+ * @param statusCode {number} the status code of the response from the server
244
+ * @param statusMessage {string | undefined} the status message of the response from the server
245
+ * @param headers {Record<string, string>} the headers of the response from the server
246
+ * @param body {string} the body from the response of the server
247
+ * @returns {Object} JSON parsed body or error object
248
+ */
249
+ const parseBody = (statusCode, statusMessage, headers, body) => {
250
+ /*
251
+ * Informational responses (100 – 199)
252
+ * Successful responses (200 – 299)
253
+ * Redirection messages (300 – 399)
254
+ * Client error responses (400 – 499)
255
+ * Server error responses (500 – 599)
256
+ */
257
+ let parsedBody;
258
+ try {
259
+ parsedBody = JSON.parse(body);
260
+ }
261
+ catch (error) {
262
+ let errorType;
263
+ let errorDescriptionHelper;
264
+ if (statusCode >= HttpStatus.CLIENT_ERROR_RANGE_START &&
265
+ statusCode <= HttpStatus.CLIENT_ERROR_RANGE_END) {
266
+ errorType = "client_error";
267
+ errorDescriptionHelper = "A client";
268
+ }
269
+ else if (statusCode >= HttpStatus.SERVER_ERROR_RANGE_START &&
270
+ statusCode <= HttpStatus.SERVER_ERROR_RANGE_END) {
271
+ errorType = "server_error";
272
+ errorDescriptionHelper = "A server";
273
+ }
274
+ else {
275
+ errorType = "unknown_error";
276
+ errorDescriptionHelper = "An unknown";
277
+ }
278
+ parsedBody = {
279
+ error: errorType,
280
+ error_description: `${errorDescriptionHelper} error occured.\nHttp status code: ${statusCode}\nHttp status message: ${statusMessage || "Unknown"}\nHeaders: ${JSON.stringify(headers)}`,
281
+ };
282
+ }
283
+ return parsedBody;
283
284
  };
284
285
 
285
286
  export { HttpClient };
@@ -1 +1 @@
1
- {"version":3,"file":"HttpClient.mjs","sources":["../../src/network/HttpClient.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;AAAA;;;AAGG;AAiBH;;AAEG;MACU,UAAU,CAAA;IAInB,WACI,CAAA,QAAiB,EACjB,kBAA2D,EAAA;AAE3D,QAAA,IAAI,CAAC,QAAQ,GAAG,QAAQ,IAAI,EAAE,CAAC;AAC/B,QAAA,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,IAAI,EAAE,CAAC;KACtD;AAED;;;;AAIG;AACH,IAAA,MAAM,mBAAmB,CACrB,GAAW,EACX,OAA+B,EAAA;QAE/B,IAAI,IAAI,CAAC,QAAQ,EAAE;AACf,YAAA,OAAO,sBAAsB,CACzB,GAAG,EACH,IAAI,CAAC,QAAQ,EACb,UAAU,CAAC,GAAG,EACd,OAA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;;;;AAIG,IAAA,MAAA,mBAAA,CAAA,GAAA,EAAA,OAAA,EAAA;QACuB,IAAA,IAAA,CAAA,QAAC,EACvB;AAuBP,YAAA,OAAA,sBAAA,CAAA,GAAA,EAAA,IAAA,CAAA,QAAA,EAAA,UAAA,CAAA,GAAA,EAAA,OAAA,EAAA,IAAA,CAAA,kBAAA,CAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,11 +1,11 @@
1
- import { ServerAuthorizationCodeResponse } from "@azure/msal-common";
2
- /**
3
- * Interface for LoopbackClient allowing to replace the default loopback server with a custom implementation.
4
- * @public
5
- */
6
- export interface ILoopbackClient {
7
- listenForAuthCode(successTemplate?: string, errorTemplate?: string): Promise<ServerAuthorizationCodeResponse>;
8
- getRedirectUri(): string;
9
- closeServer(): void;
10
- }
1
+ import { ServerAuthorizationCodeResponse } from "@azure/msal-common";
2
+ /**
3
+ * Interface for LoopbackClient allowing to replace the default loopback server with a custom implementation.
4
+ * @public
5
+ */
6
+ export interface ILoopbackClient {
7
+ listenForAuthCode(successTemplate?: string, errorTemplate?: string): Promise<ServerAuthorizationCodeResponse>;
8
+ getRedirectUri(): string;
9
+ closeServer(): void;
10
+ }
11
11
  //# sourceMappingURL=ILoopbackClient.d.ts.map