@azure/msal-node 2.6.0 → 2.7.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.
- package/dist/cache/ITokenCache.d.ts +15 -15
- package/dist/cache/NodeStorage.cjs +423 -423
- package/dist/cache/NodeStorage.cjs.map +1 -1
- package/dist/cache/NodeStorage.d.ts +193 -193
- package/dist/cache/NodeStorage.d.ts.map +1 -1
- package/dist/cache/NodeStorage.mjs +424 -424
- package/dist/cache/NodeStorage.mjs.map +1 -1
- package/dist/cache/TokenCache.cjs +265 -265
- package/dist/cache/TokenCache.d.ts +90 -90
- package/dist/cache/TokenCache.mjs +265 -265
- package/dist/cache/distributed/DistributedCachePlugin.cjs +26 -26
- package/dist/cache/distributed/DistributedCachePlugin.d.ts +10 -10
- package/dist/cache/distributed/DistributedCachePlugin.mjs +26 -26
- package/dist/cache/distributed/ICacheClient.d.ts +17 -17
- package/dist/cache/distributed/IPartitionManager.d.ts +28 -28
- package/dist/cache/serializer/Deserializer.cjs +170 -170
- package/dist/cache/serializer/Deserializer.d.ts +42 -42
- package/dist/cache/serializer/Deserializer.mjs +170 -170
- package/dist/cache/serializer/Serializer.cjs +137 -137
- package/dist/cache/serializer/Serializer.d.ts +39 -39
- package/dist/cache/serializer/Serializer.mjs +137 -137
- package/dist/cache/serializer/SerializerTypes.d.ts +102 -102
- package/dist/client/ClientApplication.cjs +333 -333
- package/dist/client/ClientApplication.d.ts +142 -142
- package/dist/client/ClientApplication.mjs +333 -333
- package/dist/client/ClientAssertion.cjs +116 -116
- package/dist/client/ClientAssertion.d.ts +46 -46
- package/dist/client/ClientAssertion.mjs +116 -116
- package/dist/client/ClientCredentialClient.cjs +194 -190
- package/dist/client/ClientCredentialClient.cjs.map +1 -1
- package/dist/client/ClientCredentialClient.d.ts +33 -33
- package/dist/client/ClientCredentialClient.d.ts.map +1 -1
- package/dist/client/ClientCredentialClient.mjs +195 -191
- package/dist/client/ClientCredentialClient.mjs.map +1 -1
- package/dist/client/ConfidentialClientApplication.cjs +163 -163
- package/dist/client/ConfidentialClientApplication.d.ts +58 -58
- package/dist/client/ConfidentialClientApplication.mjs +163 -163
- package/dist/client/DeviceCodeClient.cjs +207 -207
- package/dist/client/DeviceCodeClient.d.ts +53 -53
- package/dist/client/DeviceCodeClient.mjs +207 -207
- package/dist/client/IConfidentialClientApplication.d.ts +39 -39
- package/dist/client/IPublicClientApplication.d.ts +42 -42
- package/dist/client/ManagedIdentityApplication.cjs +96 -0
- package/dist/client/ManagedIdentityApplication.cjs.map +1 -0
- package/dist/client/ManagedIdentityApplication.d.ts +24 -0
- package/dist/client/ManagedIdentityApplication.d.ts.map +1 -0
- package/dist/client/ManagedIdentityApplication.mjs +94 -0
- package/dist/client/ManagedIdentityApplication.mjs.map +1 -0
- package/dist/client/ManagedIdentityClient.cjs +49 -0
- package/dist/client/ManagedIdentityClient.cjs.map +1 -0
- package/dist/client/ManagedIdentityClient.d.ts +25 -0
- package/dist/client/ManagedIdentityClient.d.ts.map +1 -0
- package/dist/client/ManagedIdentityClient.mjs +47 -0
- package/dist/client/ManagedIdentityClient.mjs.map +1 -0
- package/dist/client/ManagedIdentitySources/AppService.cjs +79 -0
- package/dist/client/ManagedIdentitySources/AppService.cjs.map +1 -0
- package/dist/client/ManagedIdentitySources/AppService.d.ts +17 -0
- package/dist/client/ManagedIdentitySources/AppService.d.ts.map +1 -0
- package/dist/client/ManagedIdentitySources/AppService.mjs +77 -0
- package/dist/client/ManagedIdentitySources/AppService.mjs.map +1 -0
- package/dist/client/ManagedIdentitySources/AzureArc.cjs +107 -0
- package/dist/client/ManagedIdentitySources/AzureArc.cjs.map +1 -0
- package/dist/client/ManagedIdentitySources/AzureArc.d.ts +19 -0
- package/dist/client/ManagedIdentitySources/AzureArc.d.ts.map +1 -0
- package/dist/client/ManagedIdentitySources/AzureArc.mjs +104 -0
- package/dist/client/ManagedIdentitySources/AzureArc.mjs.map +1 -0
- package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.cjs +87 -0
- package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.cjs.map +1 -0
- package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.d.ts +19 -0
- package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.d.ts.map +1 -0
- package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.mjs +85 -0
- package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.mjs.map +1 -0
- package/dist/client/ManagedIdentitySources/CloudShell.d.ts +7 -0
- package/dist/client/ManagedIdentitySources/CloudShell.d.ts.map +1 -0
- package/dist/client/ManagedIdentitySources/Imds.cjs +63 -0
- package/dist/client/ManagedIdentitySources/Imds.cjs.map +1 -0
- package/dist/client/ManagedIdentitySources/Imds.d.ts +13 -0
- package/dist/client/ManagedIdentitySources/Imds.d.ts.map +1 -0
- package/dist/client/ManagedIdentitySources/Imds.mjs +61 -0
- package/dist/client/ManagedIdentitySources/Imds.mjs.map +1 -0
- package/dist/client/ManagedIdentitySources/ServiceFabric.d.ts +7 -0
- package/dist/client/ManagedIdentitySources/ServiceFabric.d.ts.map +1 -0
- package/dist/client/OnBehalfOfClient.cjs +202 -202
- package/dist/client/OnBehalfOfClient.d.ts +47 -47
- package/dist/client/OnBehalfOfClient.mjs +202 -202
- package/dist/client/PublicClientApplication.cjs +229 -229
- package/dist/client/PublicClientApplication.d.ts +71 -71
- package/dist/client/PublicClientApplication.mjs +229 -229
- package/dist/client/UsernamePasswordClient.cjs +95 -95
- package/dist/client/UsernamePasswordClient.d.ts +25 -25
- package/dist/client/UsernamePasswordClient.mjs +95 -95
- package/dist/config/Configuration.cjs +88 -72
- package/dist/config/Configuration.cjs.map +1 -1
- package/dist/config/Configuration.d.ts +122 -107
- package/dist/config/Configuration.d.ts.map +1 -1
- package/dist/config/Configuration.mjs +88 -73
- package/dist/config/Configuration.mjs.map +1 -1
- package/dist/config/ManagedIdentityId.cjs +59 -0
- package/dist/config/ManagedIdentityId.cjs.map +1 -0
- package/dist/config/ManagedIdentityId.d.ts +12 -0
- package/dist/config/ManagedIdentityId.d.ts.map +1 -0
- package/dist/config/ManagedIdentityId.mjs +57 -0
- package/dist/config/ManagedIdentityId.mjs.map +1 -0
- package/dist/config/ManagedIdentityRequestParameters.cjs +38 -0
- package/dist/config/ManagedIdentityRequestParameters.cjs.map +1 -0
- package/dist/config/ManagedIdentityRequestParameters.d.ts +12 -0
- package/dist/config/ManagedIdentityRequestParameters.d.ts.map +1 -0
- package/dist/config/ManagedIdentityRequestParameters.mjs +36 -0
- package/dist/config/ManagedIdentityRequestParameters.mjs.map +1 -0
- package/dist/crypto/CryptoProvider.cjs +75 -75
- package/dist/crypto/CryptoProvider.d.ts +52 -52
- package/dist/crypto/CryptoProvider.mjs +75 -75
- package/dist/crypto/GuidGenerator.cjs +22 -22
- package/dist/crypto/GuidGenerator.d.ts +14 -14
- package/dist/crypto/GuidGenerator.mjs +22 -22
- package/dist/crypto/HashUtils.cjs +13 -13
- package/dist/crypto/HashUtils.d.ts +8 -8
- package/dist/crypto/HashUtils.mjs +13 -13
- package/dist/crypto/PkceGenerator.cjs +49 -49
- package/dist/crypto/PkceGenerator.d.ts +22 -22
- package/dist/crypto/PkceGenerator.mjs +49 -49
- package/dist/error/ManagedIdentityError.cjs +40 -0
- package/dist/error/ManagedIdentityError.cjs.map +1 -0
- package/dist/error/ManagedIdentityError.d.ts +22 -0
- package/dist/error/ManagedIdentityError.d.ts.map +1 -0
- package/dist/error/ManagedIdentityError.mjs +36 -0
- package/dist/error/ManagedIdentityError.mjs.map +1 -0
- package/dist/error/ManagedIdentityErrorCodes.cjs +28 -0
- package/dist/error/ManagedIdentityErrorCodes.cjs.map +1 -0
- package/dist/error/ManagedIdentityErrorCodes.d.ts +10 -0
- package/dist/error/ManagedIdentityErrorCodes.d.ts.map +1 -0
- package/dist/error/ManagedIdentityErrorCodes.mjs +18 -0
- package/dist/error/ManagedIdentityErrorCodes.mjs.map +1 -0
- package/dist/error/NodeAuthError.cjs +85 -85
- package/dist/error/NodeAuthError.d.ts +65 -65
- package/dist/error/NodeAuthError.mjs +85 -85
- package/dist/index.cjs +3 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +44 -42
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +2 -1
- package/dist/index.mjs.map +1 -1
- package/dist/internals.cjs +8 -8
- package/dist/internals.d.ts +6 -6
- package/dist/internals.mjs +8 -8
- package/dist/network/HttpClient.cjs +283 -276
- package/dist/network/HttpClient.cjs.map +1 -1
- package/dist/network/HttpClient.d.ts +26 -25
- package/dist/network/HttpClient.d.ts.map +1 -1
- package/dist/network/HttpClient.mjs +283 -276
- package/dist/network/HttpClient.mjs.map +1 -1
- package/dist/network/ILoopbackClient.d.ts +10 -10
- package/dist/network/LoopbackClient.cjs +77 -77
- package/dist/network/LoopbackClient.d.ts +21 -21
- package/dist/network/LoopbackClient.mjs +77 -77
- package/dist/packageMetadata.cjs +4 -4
- package/dist/packageMetadata.d.ts +2 -2
- package/dist/packageMetadata.d.ts.map +1 -1
- package/dist/packageMetadata.mjs +4 -4
- package/dist/request/AuthorizationCodeRequest.d.ts +21 -21
- package/dist/request/AuthorizationUrlRequest.d.ts +33 -33
- package/dist/request/ClientCredentialRequest.d.ts +14 -14
- package/dist/request/DeviceCodeRequest.d.ts +15 -15
- package/dist/request/InteractiveRequest.d.ts +22 -22
- package/dist/request/ManagedIdentityRequest.d.ts +9 -0
- package/dist/request/ManagedIdentityRequest.d.ts.map +1 -0
- package/dist/request/ManagedIdentityRequestParams.d.ts +10 -0
- package/dist/request/ManagedIdentityRequestParams.d.ts.map +1 -0
- package/dist/request/OnBehalfOfRequest.d.ts +14 -14
- package/dist/request/RefreshTokenRequest.d.ts +17 -17
- package/dist/request/SignOutRequest.d.ts +5 -5
- package/dist/request/SilentFlowRequest.d.ts +16 -16
- package/dist/request/UsernamePasswordRequest.d.ts +19 -19
- package/dist/response/ManagedIdentityTokenResponse.d.ts +25 -0
- package/dist/response/ManagedIdentityTokenResponse.d.ts.map +1 -0
- package/dist/utils/Constants.cjs +109 -80
- package/dist/utils/Constants.cjs.map +1 -1
- package/dist/utils/Constants.d.ts +106 -86
- package/dist/utils/Constants.d.ts.map +1 -1
- package/dist/utils/Constants.mjs +100 -81
- package/dist/utils/Constants.mjs.map +1 -1
- package/dist/utils/EncodingUtils.cjs +44 -44
- package/dist/utils/EncodingUtils.d.ts +26 -26
- package/dist/utils/EncodingUtils.mjs +44 -44
- package/dist/utils/NetworkUtils.cjs +38 -38
- package/dist/utils/NetworkUtils.d.ts +5 -5
- package/dist/utils/NetworkUtils.mjs +38 -38
- package/package.json +3 -3
- package/src/cache/NodeStorage.ts +1 -4
- package/src/client/ClientCredentialClient.ts +65 -25
- package/src/client/ManagedIdentityApplication.ts +194 -0
- package/src/client/ManagedIdentityClient.ts +111 -0
- package/src/client/ManagedIdentitySources/AppService.ts +151 -0
- package/src/client/ManagedIdentitySources/AzureArc.ts +208 -0
- package/src/client/ManagedIdentitySources/BaseManagedIdentitySource.ts +169 -0
- package/src/client/ManagedIdentitySources/CloudShell.ts +19 -0
- package/src/client/ManagedIdentitySources/Imds.ts +112 -0
- package/src/client/ManagedIdentitySources/ServiceFabric.ts +19 -0
- package/src/config/Configuration.ts +47 -1
- package/src/config/ManagedIdentityId.ts +73 -0
- package/src/config/ManagedIdentityRequestParameters.ts +53 -0
- package/src/error/ManagedIdentityError.ts +46 -0
- package/src/error/ManagedIdentityErrorCodes.ts +15 -0
- package/src/index.ts +4 -0
- package/src/network/HttpClient.ts +17 -5
- package/src/packageMetadata.ts +1 -1
- package/src/request/ManagedIdentityRequest.ts +15 -0
- package/src/request/ManagedIdentityRequestParams.ts +14 -0
- package/src/response/ManagedIdentityTokenResponse.ts +33 -0
- package/src/utils/Constants.ts +27 -0
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
/*! @azure/msal-node v2.
|
|
1
|
+
/*! @azure/msal-node v2.7.0-alpha.0 2023-12-15 */
|
|
2
2
|
'use strict';
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
5
|
-
/*
|
|
6
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
7
|
-
* Licensed under the MIT License.
|
|
8
|
-
*/
|
|
9
|
-
class NetworkUtils {
|
|
10
|
-
static getNetworkResponse(headers, body, statusCode) {
|
|
11
|
-
return {
|
|
12
|
-
headers: headers,
|
|
13
|
-
body: body,
|
|
14
|
-
status: statusCode,
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
/*
|
|
18
|
-
* Utility function that converts a URL object into an ordinary options object as expected by the
|
|
19
|
-
* http.request and https.request APIs.
|
|
20
|
-
* https://github.com/nodejs/node/blob/main/lib/internal/url.js#L1090
|
|
21
|
-
*/
|
|
22
|
-
static urlToHttpOptions(url) {
|
|
23
|
-
const options = {
|
|
24
|
-
protocol: url.protocol,
|
|
25
|
-
hostname: url.hostname && url.hostname.startsWith("[")
|
|
26
|
-
? url.hostname.slice(1, -1)
|
|
27
|
-
: url.hostname,
|
|
28
|
-
hash: url.hash,
|
|
29
|
-
search: url.search,
|
|
30
|
-
pathname: url.pathname,
|
|
31
|
-
path: `${url.pathname || ""}${url.search || ""}`,
|
|
32
|
-
href: url.href,
|
|
33
|
-
};
|
|
34
|
-
if (url.port !== "") {
|
|
35
|
-
options.port = Number(url.port);
|
|
36
|
-
}
|
|
37
|
-
if (url.username || url.password) {
|
|
38
|
-
options.auth = `${decodeURIComponent(url.username)}:${decodeURIComponent(url.password)}`;
|
|
39
|
-
}
|
|
40
|
-
return options;
|
|
41
|
-
}
|
|
5
|
+
/*
|
|
6
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
7
|
+
* Licensed under the MIT License.
|
|
8
|
+
*/
|
|
9
|
+
class NetworkUtils {
|
|
10
|
+
static getNetworkResponse(headers, body, statusCode) {
|
|
11
|
+
return {
|
|
12
|
+
headers: headers,
|
|
13
|
+
body: body,
|
|
14
|
+
status: statusCode,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/*
|
|
18
|
+
* Utility function that converts a URL object into an ordinary options object as expected by the
|
|
19
|
+
* http.request and https.request APIs.
|
|
20
|
+
* https://github.com/nodejs/node/blob/main/lib/internal/url.js#L1090
|
|
21
|
+
*/
|
|
22
|
+
static urlToHttpOptions(url) {
|
|
23
|
+
const options = {
|
|
24
|
+
protocol: url.protocol,
|
|
25
|
+
hostname: url.hostname && url.hostname.startsWith("[")
|
|
26
|
+
? url.hostname.slice(1, -1)
|
|
27
|
+
: url.hostname,
|
|
28
|
+
hash: url.hash,
|
|
29
|
+
search: url.search,
|
|
30
|
+
pathname: url.pathname,
|
|
31
|
+
path: `${url.pathname || ""}${url.search || ""}`,
|
|
32
|
+
href: url.href,
|
|
33
|
+
};
|
|
34
|
+
if (url.port !== "") {
|
|
35
|
+
options.port = Number(url.port);
|
|
36
|
+
}
|
|
37
|
+
if (url.username || url.password) {
|
|
38
|
+
options.auth = `${decodeURIComponent(url.username)}:${decodeURIComponent(url.password)}`;
|
|
39
|
+
}
|
|
40
|
+
return options;
|
|
41
|
+
}
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
exports.NetworkUtils = NetworkUtils;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { NetworkResponse, UrlToHttpRequestOptions } from "@azure/msal-common";
|
|
2
|
-
export declare class NetworkUtils {
|
|
3
|
-
static getNetworkResponse<T>(headers: Record<string, string>, body: T, statusCode: number): NetworkResponse<T>;
|
|
4
|
-
static urlToHttpOptions(url: URL): UrlToHttpRequestOptions;
|
|
5
|
-
}
|
|
1
|
+
import { NetworkResponse, UrlToHttpRequestOptions } from "@azure/msal-common";
|
|
2
|
+
export declare class NetworkUtils {
|
|
3
|
+
static getNetworkResponse<T>(headers: Record<string, string>, body: T, statusCode: number): NetworkResponse<T>;
|
|
4
|
+
static urlToHttpOptions(url: URL): UrlToHttpRequestOptions;
|
|
5
|
+
}
|
|
6
6
|
//# sourceMappingURL=NetworkUtils.d.ts.map
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
/*! @azure/msal-node v2.
|
|
1
|
+
/*! @azure/msal-node v2.7.0-alpha.0 2023-12-15 */
|
|
2
2
|
'use strict';
|
|
3
|
-
/*
|
|
4
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
5
|
-
* Licensed under the MIT License.
|
|
6
|
-
*/
|
|
7
|
-
class NetworkUtils {
|
|
8
|
-
static getNetworkResponse(headers, body, statusCode) {
|
|
9
|
-
return {
|
|
10
|
-
headers: headers,
|
|
11
|
-
body: body,
|
|
12
|
-
status: statusCode,
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
/*
|
|
16
|
-
* Utility function that converts a URL object into an ordinary options object as expected by the
|
|
17
|
-
* http.request and https.request APIs.
|
|
18
|
-
* https://github.com/nodejs/node/blob/main/lib/internal/url.js#L1090
|
|
19
|
-
*/
|
|
20
|
-
static urlToHttpOptions(url) {
|
|
21
|
-
const options = {
|
|
22
|
-
protocol: url.protocol,
|
|
23
|
-
hostname: url.hostname && url.hostname.startsWith("[")
|
|
24
|
-
? url.hostname.slice(1, -1)
|
|
25
|
-
: url.hostname,
|
|
26
|
-
hash: url.hash,
|
|
27
|
-
search: url.search,
|
|
28
|
-
pathname: url.pathname,
|
|
29
|
-
path: `${url.pathname || ""}${url.search || ""}`,
|
|
30
|
-
href: url.href,
|
|
31
|
-
};
|
|
32
|
-
if (url.port !== "") {
|
|
33
|
-
options.port = Number(url.port);
|
|
34
|
-
}
|
|
35
|
-
if (url.username || url.password) {
|
|
36
|
-
options.auth = `${decodeURIComponent(url.username)}:${decodeURIComponent(url.password)}`;
|
|
37
|
-
}
|
|
38
|
-
return options;
|
|
39
|
-
}
|
|
3
|
+
/*
|
|
4
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
5
|
+
* Licensed under the MIT License.
|
|
6
|
+
*/
|
|
7
|
+
class NetworkUtils {
|
|
8
|
+
static getNetworkResponse(headers, body, statusCode) {
|
|
9
|
+
return {
|
|
10
|
+
headers: headers,
|
|
11
|
+
body: body,
|
|
12
|
+
status: statusCode,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/*
|
|
16
|
+
* Utility function that converts a URL object into an ordinary options object as expected by the
|
|
17
|
+
* http.request and https.request APIs.
|
|
18
|
+
* https://github.com/nodejs/node/blob/main/lib/internal/url.js#L1090
|
|
19
|
+
*/
|
|
20
|
+
static urlToHttpOptions(url) {
|
|
21
|
+
const options = {
|
|
22
|
+
protocol: url.protocol,
|
|
23
|
+
hostname: url.hostname && url.hostname.startsWith("[")
|
|
24
|
+
? url.hostname.slice(1, -1)
|
|
25
|
+
: url.hostname,
|
|
26
|
+
hash: url.hash,
|
|
27
|
+
search: url.search,
|
|
28
|
+
pathname: url.pathname,
|
|
29
|
+
path: `${url.pathname || ""}${url.search || ""}`,
|
|
30
|
+
href: url.href,
|
|
31
|
+
};
|
|
32
|
+
if (url.port !== "") {
|
|
33
|
+
options.port = Number(url.port);
|
|
34
|
+
}
|
|
35
|
+
if (url.username || url.password) {
|
|
36
|
+
options.auth = `${decodeURIComponent(url.username)}:${decodeURIComponent(url.password)}`;
|
|
37
|
+
}
|
|
38
|
+
return options;
|
|
39
|
+
}
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
export { NetworkUtils };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@azure/msal-node",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.7.0-alpha.0",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Microsoft",
|
|
7
7
|
"email": "nugetaad@microsoft.com",
|
|
@@ -77,11 +77,11 @@
|
|
|
77
77
|
"yargs": "^17.3.1"
|
|
78
78
|
},
|
|
79
79
|
"dependencies": {
|
|
80
|
-
"@azure/msal-common": "14.
|
|
80
|
+
"@azure/msal-common": "14.6.0-alpha.0",
|
|
81
81
|
"jsonwebtoken": "^9.0.0",
|
|
82
82
|
"uuid": "^8.3.0"
|
|
83
83
|
},
|
|
84
84
|
"engines": {
|
|
85
|
-
"node": "16
|
|
85
|
+
"node": ">=16"
|
|
86
86
|
}
|
|
87
87
|
}
|
package/src/cache/NodeStorage.ts
CHANGED
|
@@ -421,10 +421,7 @@ export class NodeStorage extends CacheManager {
|
|
|
421
421
|
) as ThrottlingEntity;
|
|
422
422
|
if (
|
|
423
423
|
throttlingCache &&
|
|
424
|
-
|
|
425
|
-
throttlingCacheKey,
|
|
426
|
-
throttlingCache
|
|
427
|
-
)
|
|
424
|
+
CacheHelpers.isThrottlingEntity(throttlingCacheKey, throttlingCache)
|
|
428
425
|
) {
|
|
429
426
|
return throttlingCache;
|
|
430
427
|
}
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
AuthenticationScheme,
|
|
10
10
|
Authority,
|
|
11
11
|
BaseClient,
|
|
12
|
+
CacheManager,
|
|
12
13
|
CacheOutcome,
|
|
13
14
|
ClientAuthErrorCodes,
|
|
14
15
|
ClientConfiguration,
|
|
@@ -16,25 +17,31 @@ import {
|
|
|
16
17
|
Constants,
|
|
17
18
|
CredentialFilter,
|
|
18
19
|
CredentialType,
|
|
20
|
+
DEFAULT_TOKEN_RENEWAL_OFFSET_SEC,
|
|
19
21
|
GrantType,
|
|
20
22
|
IAppTokenProvider,
|
|
23
|
+
ICrypto,
|
|
21
24
|
RequestParameterBuilder,
|
|
22
25
|
RequestThumbprint,
|
|
23
26
|
ResponseHandler,
|
|
24
27
|
ScopeSet,
|
|
25
28
|
ServerAuthorizationTokenResponse,
|
|
29
|
+
ServerTelemetryManager,
|
|
26
30
|
StringUtils,
|
|
27
31
|
TimeUtils,
|
|
28
32
|
TokenCacheContext,
|
|
29
33
|
UrlString,
|
|
30
34
|
createClientAuthError,
|
|
31
35
|
} from "@azure/msal-common";
|
|
36
|
+
import {
|
|
37
|
+
ManagedIdentityConfiguration,
|
|
38
|
+
ManagedIdentityNodeConfiguration,
|
|
39
|
+
} from "../config/Configuration";
|
|
32
40
|
|
|
33
41
|
/**
|
|
34
42
|
* OAuth2.0 client credential grant
|
|
35
43
|
*/
|
|
36
44
|
export class ClientCredentialClient extends BaseClient {
|
|
37
|
-
private scopeSet: ScopeSet;
|
|
38
45
|
private readonly appTokenProvider?: IAppTokenProvider;
|
|
39
46
|
|
|
40
47
|
constructor(
|
|
@@ -52,14 +59,19 @@ export class ClientCredentialClient extends BaseClient {
|
|
|
52
59
|
public async acquireToken(
|
|
53
60
|
request: CommonClientCredentialRequest
|
|
54
61
|
): Promise<AuthenticationResult | null> {
|
|
55
|
-
this.scopeSet = new ScopeSet(request.scopes || []);
|
|
56
|
-
|
|
57
62
|
if (request.skipCache) {
|
|
58
63
|
return this.executeTokenRequest(request, this.authority);
|
|
59
64
|
}
|
|
60
65
|
|
|
61
66
|
const [cachedAuthenticationResult, lastCacheOutcome] =
|
|
62
|
-
await this.getCachedAuthenticationResult(
|
|
67
|
+
await this.getCachedAuthenticationResult(
|
|
68
|
+
request,
|
|
69
|
+
this.config,
|
|
70
|
+
this.cryptoUtils,
|
|
71
|
+
this.authority,
|
|
72
|
+
this.cacheManager,
|
|
73
|
+
this.serverTelemetryManager
|
|
74
|
+
);
|
|
63
75
|
|
|
64
76
|
if (cachedAuthenticationResult) {
|
|
65
77
|
// if the token is not expired but must be refreshed; get a new one in the background
|
|
@@ -87,34 +99,56 @@ export class ClientCredentialClient extends BaseClient {
|
|
|
87
99
|
/**
|
|
88
100
|
* looks up cache if the tokens are cached already
|
|
89
101
|
*/
|
|
90
|
-
|
|
91
|
-
request: CommonClientCredentialRequest
|
|
102
|
+
public async getCachedAuthenticationResult(
|
|
103
|
+
request: CommonClientCredentialRequest,
|
|
104
|
+
config: ClientConfiguration | ManagedIdentityConfiguration,
|
|
105
|
+
cryptoUtils: ICrypto,
|
|
106
|
+
authority: Authority,
|
|
107
|
+
cacheManager: CacheManager,
|
|
108
|
+
serverTelemetryManager?: ServerTelemetryManager | null
|
|
92
109
|
): Promise<[AuthenticationResult | null, CacheOutcome]> {
|
|
110
|
+
const clientConfiguration = config as ClientConfiguration;
|
|
111
|
+
const managedIdentityConfiguration =
|
|
112
|
+
config as ManagedIdentityNodeConfiguration;
|
|
113
|
+
|
|
93
114
|
let lastCacheOutcome: CacheOutcome = CacheOutcome.NOT_APPLICABLE;
|
|
94
115
|
|
|
95
116
|
// read the user-supplied cache into memory, if applicable
|
|
96
117
|
let cacheContext;
|
|
97
|
-
if (
|
|
118
|
+
if (
|
|
119
|
+
clientConfiguration.serializableCache &&
|
|
120
|
+
clientConfiguration.persistencePlugin
|
|
121
|
+
) {
|
|
98
122
|
cacheContext = new TokenCacheContext(
|
|
99
|
-
|
|
123
|
+
clientConfiguration.serializableCache,
|
|
100
124
|
false
|
|
101
125
|
);
|
|
102
|
-
await
|
|
126
|
+
await clientConfiguration.persistencePlugin.beforeCacheAccess(
|
|
127
|
+
cacheContext
|
|
128
|
+
);
|
|
103
129
|
}
|
|
104
130
|
|
|
105
|
-
const cachedAccessToken = this.readAccessTokenFromCache(
|
|
131
|
+
const cachedAccessToken = this.readAccessTokenFromCache(
|
|
132
|
+
authority,
|
|
133
|
+
managedIdentityConfiguration.managedIdentityId?.id ||
|
|
134
|
+
clientConfiguration.authOptions.clientId,
|
|
135
|
+
new ScopeSet(request.scopes || []),
|
|
136
|
+
cacheManager
|
|
137
|
+
);
|
|
106
138
|
|
|
107
139
|
if (
|
|
108
|
-
|
|
109
|
-
|
|
140
|
+
clientConfiguration.serializableCache &&
|
|
141
|
+
clientConfiguration.persistencePlugin &&
|
|
110
142
|
cacheContext
|
|
111
143
|
) {
|
|
112
|
-
await
|
|
144
|
+
await clientConfiguration.persistencePlugin.afterCacheAccess(
|
|
145
|
+
cacheContext
|
|
146
|
+
);
|
|
113
147
|
}
|
|
114
148
|
|
|
115
149
|
// must refresh due to non-existent access_token
|
|
116
150
|
if (!cachedAccessToken) {
|
|
117
|
-
|
|
151
|
+
serverTelemetryManager?.setCacheOutcome(
|
|
118
152
|
CacheOutcome.NO_CACHED_ACCESS_TOKEN
|
|
119
153
|
);
|
|
120
154
|
return [null, CacheOutcome.NO_CACHED_ACCESS_TOKEN];
|
|
@@ -124,10 +158,11 @@ export class ClientCredentialClient extends BaseClient {
|
|
|
124
158
|
if (
|
|
125
159
|
TimeUtils.isTokenExpired(
|
|
126
160
|
cachedAccessToken.expiresOn,
|
|
127
|
-
|
|
161
|
+
clientConfiguration.systemOptions?.tokenRenewalOffsetSeconds ||
|
|
162
|
+
DEFAULT_TOKEN_RENEWAL_OFFSET_SEC
|
|
128
163
|
)
|
|
129
164
|
) {
|
|
130
|
-
|
|
165
|
+
serverTelemetryManager?.setCacheOutcome(
|
|
131
166
|
CacheOutcome.CACHED_ACCESS_TOKEN_EXPIRED
|
|
132
167
|
);
|
|
133
168
|
return [null, CacheOutcome.CACHED_ACCESS_TOKEN_EXPIRED];
|
|
@@ -139,15 +174,15 @@ export class ClientCredentialClient extends BaseClient {
|
|
|
139
174
|
TimeUtils.isTokenExpired(cachedAccessToken.refreshOn.toString(), 0)
|
|
140
175
|
) {
|
|
141
176
|
lastCacheOutcome = CacheOutcome.PROACTIVELY_REFRESHED;
|
|
142
|
-
|
|
177
|
+
serverTelemetryManager?.setCacheOutcome(
|
|
143
178
|
CacheOutcome.PROACTIVELY_REFRESHED
|
|
144
179
|
);
|
|
145
180
|
}
|
|
146
181
|
|
|
147
182
|
return [
|
|
148
183
|
await ResponseHandler.generateAuthenticationResult(
|
|
149
|
-
|
|
150
|
-
|
|
184
|
+
cryptoUtils,
|
|
185
|
+
authority,
|
|
151
186
|
{
|
|
152
187
|
account: null,
|
|
153
188
|
idToken: null,
|
|
@@ -165,19 +200,24 @@ export class ClientCredentialClient extends BaseClient {
|
|
|
165
200
|
/**
|
|
166
201
|
* Reads access token from the cache
|
|
167
202
|
*/
|
|
168
|
-
private readAccessTokenFromCache(
|
|
203
|
+
private readAccessTokenFromCache(
|
|
204
|
+
authority: Authority,
|
|
205
|
+
id: string,
|
|
206
|
+
scopeSet: ScopeSet,
|
|
207
|
+
cacheManager: CacheManager
|
|
208
|
+
): AccessTokenEntity | null {
|
|
169
209
|
const accessTokenFilter: CredentialFilter = {
|
|
170
210
|
homeAccountId: Constants.EMPTY_STRING,
|
|
171
211
|
environment:
|
|
172
|
-
|
|
212
|
+
authority.canonicalAuthorityUrlComponents.HostNameAndPort,
|
|
173
213
|
credentialType: CredentialType.ACCESS_TOKEN,
|
|
174
|
-
clientId:
|
|
175
|
-
realm:
|
|
176
|
-
target: ScopeSet.createSearchScopes(
|
|
214
|
+
clientId: id,
|
|
215
|
+
realm: authority.tenant,
|
|
216
|
+
target: ScopeSet.createSearchScopes(scopeSet.asArray()),
|
|
177
217
|
};
|
|
178
218
|
|
|
179
219
|
const accessTokens =
|
|
180
|
-
|
|
220
|
+
cacheManager.getAccessTokensByFilter(accessTokenFilter);
|
|
181
221
|
if (accessTokens.length < 1) {
|
|
182
222
|
return null;
|
|
183
223
|
} else if (accessTokens.length > 1) {
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
AuthOptions,
|
|
8
|
+
Authority,
|
|
9
|
+
AuthorityOptions,
|
|
10
|
+
CacheOutcome,
|
|
11
|
+
ClientConfiguration,
|
|
12
|
+
Constants,
|
|
13
|
+
DEFAULT_CRYPTO_IMPLEMENTATION,
|
|
14
|
+
INetworkModule,
|
|
15
|
+
Logger,
|
|
16
|
+
ProtocolMode,
|
|
17
|
+
StaticAuthorityOptions,
|
|
18
|
+
AuthenticationResult,
|
|
19
|
+
UrlString,
|
|
20
|
+
} from "@azure/msal-common";
|
|
21
|
+
import {
|
|
22
|
+
ManagedIdentityConfiguration,
|
|
23
|
+
ManagedIdentityNodeConfiguration,
|
|
24
|
+
buildManagedIdentityConfiguration,
|
|
25
|
+
} from "../config/Configuration";
|
|
26
|
+
import { version, name } from "../packageMetadata.js";
|
|
27
|
+
import { ManagedIdentityRequest } from "../request/ManagedIdentityRequest";
|
|
28
|
+
import { CryptoProvider } from "../crypto/CryptoProvider";
|
|
29
|
+
import { ClientCredentialClient } from "./ClientCredentialClient";
|
|
30
|
+
import { ManagedIdentityClient } from "./ManagedIdentityClient";
|
|
31
|
+
import { ManagedIdentityRequestParams } from "../request/ManagedIdentityRequestParams";
|
|
32
|
+
import { NodeStorage } from "../cache/NodeStorage";
|
|
33
|
+
import { DEFAULT_AUTHORITY_FOR_MANAGED_IDENTITY } from "../utils/Constants";
|
|
34
|
+
import {
|
|
35
|
+
ManagedIdentityErrorCodes,
|
|
36
|
+
createManagedIdentityError,
|
|
37
|
+
} from "../error/ManagedIdentityError";
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Class to initialize a managed identity and identify the service
|
|
41
|
+
*/
|
|
42
|
+
export class ManagedIdentityApplication {
|
|
43
|
+
private config: ManagedIdentityNodeConfiguration;
|
|
44
|
+
|
|
45
|
+
private logger: Logger;
|
|
46
|
+
private static nodeStorage: NodeStorage | undefined;
|
|
47
|
+
private networkClient: INetworkModule;
|
|
48
|
+
private cryptoProvider: CryptoProvider;
|
|
49
|
+
|
|
50
|
+
// authority needs to be faked to re-use existing functionality in msal-common: caching in responseHandler, etc.
|
|
51
|
+
private fakeAuthority: Authority;
|
|
52
|
+
|
|
53
|
+
// the ClientCredentialClient class needs to be faked to call it's getCachedAuthenticationResult method
|
|
54
|
+
private fakeClientCredentialClient: ClientCredentialClient;
|
|
55
|
+
|
|
56
|
+
private managedIdentityClient: ManagedIdentityClient;
|
|
57
|
+
|
|
58
|
+
constructor(configuration?: ManagedIdentityConfiguration) {
|
|
59
|
+
// undefined config means the managed identity is system-assigned
|
|
60
|
+
this.config = buildManagedIdentityConfiguration(configuration || {});
|
|
61
|
+
|
|
62
|
+
this.logger = new Logger(
|
|
63
|
+
this.config.system.loggerOptions,
|
|
64
|
+
name,
|
|
65
|
+
version
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
const fakeStatusAuthorityOptions: StaticAuthorityOptions = {
|
|
69
|
+
canonicalAuthority: Constants.DEFAULT_AUTHORITY,
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
if (!ManagedIdentityApplication.nodeStorage) {
|
|
73
|
+
ManagedIdentityApplication.nodeStorage = new NodeStorage(
|
|
74
|
+
this.logger,
|
|
75
|
+
this.config.managedIdentityId.id,
|
|
76
|
+
DEFAULT_CRYPTO_IMPLEMENTATION,
|
|
77
|
+
fakeStatusAuthorityOptions
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
this.networkClient = this.config.system.networkClient;
|
|
82
|
+
|
|
83
|
+
this.cryptoProvider = new CryptoProvider();
|
|
84
|
+
|
|
85
|
+
const fakeAuthorityOptions: AuthorityOptions = {
|
|
86
|
+
protocolMode: ProtocolMode.AAD,
|
|
87
|
+
knownAuthorities: [DEFAULT_AUTHORITY_FOR_MANAGED_IDENTITY],
|
|
88
|
+
cloudDiscoveryMetadata: "",
|
|
89
|
+
authorityMetadata: "",
|
|
90
|
+
};
|
|
91
|
+
this.fakeAuthority = new Authority(
|
|
92
|
+
DEFAULT_AUTHORITY_FOR_MANAGED_IDENTITY,
|
|
93
|
+
this.networkClient,
|
|
94
|
+
ManagedIdentityApplication.nodeStorage as NodeStorage,
|
|
95
|
+
fakeAuthorityOptions,
|
|
96
|
+
this.logger,
|
|
97
|
+
undefined,
|
|
98
|
+
undefined,
|
|
99
|
+
true
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
this.fakeClientCredentialClient = new ClientCredentialClient({
|
|
103
|
+
authOptions: {
|
|
104
|
+
clientId: this.config.managedIdentityId.id,
|
|
105
|
+
authority: this.fakeAuthority,
|
|
106
|
+
} as AuthOptions,
|
|
107
|
+
} as ClientConfiguration);
|
|
108
|
+
|
|
109
|
+
this.managedIdentityClient = new ManagedIdentityClient(
|
|
110
|
+
this.logger,
|
|
111
|
+
ManagedIdentityApplication.nodeStorage as NodeStorage,
|
|
112
|
+
this.networkClient,
|
|
113
|
+
this.cryptoProvider
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Acquire an access token from the cache or the managed identity
|
|
119
|
+
* @param managedIdentityRequest
|
|
120
|
+
* @returns the access token
|
|
121
|
+
*/
|
|
122
|
+
public async acquireToken(
|
|
123
|
+
managedIdentityRequestParams: ManagedIdentityRequestParams
|
|
124
|
+
): Promise<AuthenticationResult> {
|
|
125
|
+
const resourceUrlString = new UrlString(
|
|
126
|
+
managedIdentityRequestParams.resource.replace("/.default", "")
|
|
127
|
+
);
|
|
128
|
+
try {
|
|
129
|
+
resourceUrlString.validateAsUri();
|
|
130
|
+
} catch (e) {
|
|
131
|
+
throw createManagedIdentityError(
|
|
132
|
+
ManagedIdentityErrorCodes.invalidResource
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const managedIdentityRequest: ManagedIdentityRequest = {
|
|
137
|
+
forceRefresh: managedIdentityRequestParams.forceRefresh,
|
|
138
|
+
resource: managedIdentityRequestParams.resource.replace(
|
|
139
|
+
"/.default",
|
|
140
|
+
""
|
|
141
|
+
),
|
|
142
|
+
scopes: [
|
|
143
|
+
managedIdentityRequestParams.resource.replace("/.default", ""),
|
|
144
|
+
],
|
|
145
|
+
authority: this.fakeAuthority.canonicalAuthority,
|
|
146
|
+
correlationId: this.config.managedIdentityId.id,
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
if (managedIdentityRequest.forceRefresh) {
|
|
150
|
+
// make a network call to the managed identity source
|
|
151
|
+
return this.managedIdentityClient.sendManagedIdentityTokenRequest(
|
|
152
|
+
managedIdentityRequest,
|
|
153
|
+
this.config.managedIdentityId,
|
|
154
|
+
this.fakeAuthority
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const [cachedAuthenticationResult, lastCacheOutcome] =
|
|
159
|
+
await this.fakeClientCredentialClient.getCachedAuthenticationResult(
|
|
160
|
+
managedIdentityRequest,
|
|
161
|
+
this.config,
|
|
162
|
+
this.cryptoProvider,
|
|
163
|
+
this.fakeAuthority,
|
|
164
|
+
ManagedIdentityApplication.nodeStorage as NodeStorage
|
|
165
|
+
);
|
|
166
|
+
|
|
167
|
+
if (cachedAuthenticationResult) {
|
|
168
|
+
// if the token is not expired but must be refreshed; get a new one in the background
|
|
169
|
+
if (lastCacheOutcome === CacheOutcome.PROACTIVELY_REFRESHED) {
|
|
170
|
+
this.logger.info(
|
|
171
|
+
"ClientCredentialClient:getCachedAuthenticationResult - Cached access token's refreshOn property has been exceeded'. It's not expired, but must be refreshed."
|
|
172
|
+
);
|
|
173
|
+
|
|
174
|
+
// make a network call to the managed identity source; refresh the access token in the background
|
|
175
|
+
const refreshAccessToken = true;
|
|
176
|
+
await this.managedIdentityClient.sendManagedIdentityTokenRequest(
|
|
177
|
+
managedIdentityRequest,
|
|
178
|
+
this.config.managedIdentityId,
|
|
179
|
+
this.fakeAuthority,
|
|
180
|
+
refreshAccessToken
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
return cachedAuthenticationResult;
|
|
185
|
+
} else {
|
|
186
|
+
// make a network call to the managed identity source
|
|
187
|
+
return this.managedIdentityClient.sendManagedIdentityTokenRequest(
|
|
188
|
+
managedIdentityRequest,
|
|
189
|
+
this.config.managedIdentityId,
|
|
190
|
+
this.fakeAuthority
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|