@azure/msal-node 2.5.1 → 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 -405
- package/dist/cache/NodeStorage.cjs.map +1 -1
- package/dist/cache/NodeStorage.d.ts +193 -182
- package/dist/cache/NodeStorage.d.ts.map +1 -1
- package/dist/cache/NodeStorage.mjs +424 -406
- package/dist/cache/NodeStorage.mjs.map +1 -1
- package/dist/cache/TokenCache.cjs +265 -265
- package/dist/cache/TokenCache.cjs.map +1 -1
- package/dist/cache/TokenCache.d.ts +90 -90
- package/dist/cache/TokenCache.mjs +265 -265
- package/dist/cache/TokenCache.mjs.map +1 -1
- package/dist/cache/distributed/DistributedCachePlugin.cjs +26 -26
- package/dist/cache/distributed/DistributedCachePlugin.cjs.map +1 -1
- package/dist/cache/distributed/DistributedCachePlugin.d.ts +10 -10
- package/dist/cache/distributed/DistributedCachePlugin.mjs +26 -26
- package/dist/cache/distributed/DistributedCachePlugin.mjs.map +1 -1
- 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 -167
- package/dist/cache/serializer/Deserializer.cjs.map +1 -1
- package/dist/cache/serializer/Deserializer.d.ts +42 -42
- package/dist/cache/serializer/Deserializer.d.ts.map +1 -1
- package/dist/cache/serializer/Deserializer.mjs +170 -167
- package/dist/cache/serializer/Deserializer.mjs.map +1 -1
- package/dist/cache/serializer/Serializer.cjs +137 -134
- package/dist/cache/serializer/Serializer.cjs.map +1 -1
- package/dist/cache/serializer/Serializer.d.ts +39 -39
- package/dist/cache/serializer/Serializer.d.ts.map +1 -1
- package/dist/cache/serializer/Serializer.mjs +137 -134
- package/dist/cache/serializer/Serializer.mjs.map +1 -1
- package/dist/cache/serializer/SerializerTypes.d.ts +102 -101
- package/dist/cache/serializer/SerializerTypes.d.ts.map +1 -1
- package/dist/client/ClientApplication.cjs +333 -333
- package/dist/client/ClientApplication.cjs.map +1 -1
- package/dist/client/ClientApplication.d.ts +142 -142
- package/dist/client/ClientApplication.d.ts.map +1 -1
- package/dist/client/ClientApplication.mjs +333 -333
- package/dist/client/ClientApplication.mjs.map +1 -1
- package/dist/client/ClientAssertion.cjs +116 -116
- package/dist/client/ClientAssertion.cjs.map +1 -1
- package/dist/client/ClientAssertion.d.ts +46 -46
- package/dist/client/ClientAssertion.mjs +116 -116
- package/dist/client/ClientAssertion.mjs.map +1 -1
- package/dist/client/ClientCredentialClient.cjs +194 -189
- 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 -190
- package/dist/client/ClientCredentialClient.mjs.map +1 -1
- package/dist/client/ConfidentialClientApplication.cjs +163 -163
- package/dist/client/ConfidentialClientApplication.cjs.map +1 -1
- package/dist/client/ConfidentialClientApplication.d.ts +58 -58
- package/dist/client/ConfidentialClientApplication.mjs +163 -163
- package/dist/client/ConfidentialClientApplication.mjs.map +1 -1
- package/dist/client/DeviceCodeClient.cjs +207 -207
- package/dist/client/DeviceCodeClient.cjs.map +1 -1
- package/dist/client/DeviceCodeClient.d.ts +53 -53
- package/dist/client/DeviceCodeClient.mjs +207 -207
- package/dist/client/DeviceCodeClient.mjs.map +1 -1
- 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.cjs.map +1 -1
- package/dist/client/OnBehalfOfClient.d.ts +47 -47
- package/dist/client/OnBehalfOfClient.mjs +202 -202
- package/dist/client/OnBehalfOfClient.mjs.map +1 -1
- package/dist/client/PublicClientApplication.cjs +229 -229
- package/dist/client/PublicClientApplication.cjs.map +1 -1
- package/dist/client/PublicClientApplication.d.ts +71 -71
- package/dist/client/PublicClientApplication.mjs +229 -229
- package/dist/client/PublicClientApplication.mjs.map +1 -1
- package/dist/client/UsernamePasswordClient.cjs +95 -95
- package/dist/client/UsernamePasswordClient.cjs.map +1 -1
- package/dist/client/UsernamePasswordClient.d.ts +25 -25
- package/dist/client/UsernamePasswordClient.mjs +95 -95
- package/dist/client/UsernamePasswordClient.mjs.map +1 -1
- 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.cjs.map +1 -1
- package/dist/crypto/CryptoProvider.d.ts +52 -52
- package/dist/crypto/CryptoProvider.mjs +75 -75
- package/dist/crypto/CryptoProvider.mjs.map +1 -1
- package/dist/crypto/GuidGenerator.cjs +22 -22
- package/dist/crypto/GuidGenerator.cjs.map +1 -1
- package/dist/crypto/GuidGenerator.d.ts +14 -14
- package/dist/crypto/GuidGenerator.mjs +22 -22
- package/dist/crypto/GuidGenerator.mjs.map +1 -1
- package/dist/crypto/HashUtils.cjs +13 -13
- package/dist/crypto/HashUtils.cjs.map +1 -1
- package/dist/crypto/HashUtils.d.ts +8 -8
- package/dist/crypto/HashUtils.mjs +13 -13
- package/dist/crypto/HashUtils.mjs.map +1 -1
- package/dist/crypto/PkceGenerator.cjs +49 -49
- package/dist/crypto/PkceGenerator.cjs.map +1 -1
- package/dist/crypto/PkceGenerator.d.ts +22 -22
- package/dist/crypto/PkceGenerator.mjs +49 -49
- package/dist/crypto/PkceGenerator.mjs.map +1 -1
- 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.cjs.map +1 -1
- package/dist/error/NodeAuthError.d.ts +65 -65
- package/dist/error/NodeAuthError.mjs +85 -85
- package/dist/error/NodeAuthError.mjs.map +1 -1
- 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.cjs.map +1 -1
- package/dist/internals.d.ts +6 -6
- package/dist/internals.mjs +8 -8
- package/dist/internals.mjs.map +1 -1
- 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.cjs.map +1 -1
- package/dist/network/LoopbackClient.d.ts +21 -21
- package/dist/network/LoopbackClient.mjs +77 -77
- package/dist/network/LoopbackClient.mjs.map +1 -1
- package/dist/packageMetadata.cjs +4 -4
- package/dist/packageMetadata.cjs.map +1 -1
- package/dist/packageMetadata.d.ts +2 -2
- package/dist/packageMetadata.d.ts.map +1 -1
- package/dist/packageMetadata.mjs +4 -4
- package/dist/packageMetadata.mjs.map +1 -1
- 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.cjs.map +1 -1
- package/dist/utils/EncodingUtils.d.ts +26 -26
- package/dist/utils/EncodingUtils.mjs +44 -44
- package/dist/utils/EncodingUtils.mjs.map +1 -1
- package/dist/utils/NetworkUtils.cjs +38 -38
- package/dist/utils/NetworkUtils.cjs.map +1 -1
- package/dist/utils/NetworkUtils.d.ts +5 -5
- package/dist/utils/NetworkUtils.mjs +38 -38
- package/dist/utils/NetworkUtils.mjs.map +1 -1
- package/package.json +3 -3
- package/src/cache/NodeStorage.ts +24 -7
- package/src/cache/TokenCache.ts +1 -1
- package/src/cache/serializer/Deserializer.ts +5 -0
- package/src/cache/serializer/Serializer.ts +5 -0
- package/src/cache/serializer/SerializerTypes.ts +1 -0
- package/src/client/ClientApplication.ts +10 -9
- package/src/client/ClientCredentialClient.ts +72 -27
- package/src/client/ConfidentialClientApplication.ts +2 -2
- package/src/client/DeviceCodeClient.ts +1 -1
- 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/client/OnBehalfOfClient.ts +5 -5
- package/src/client/PublicClientApplication.ts +1 -1
- 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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EncodingUtils.mjs","sources":["../../src/utils/EncodingUtils.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"EncodingUtils.mjs","sources":["../../src/utils/EncodingUtils.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAAA;;;AAGG;MAIU,aAAa,CAAA;AACtB;;;;;AAKG;AACH,IAAA,OAAO,YAAY,CAAC,GAAW,EAAE,QAAyB,EAAA;AACtD,QAAA,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;KACxD;AAED;;;AAGG;AACH,IAAA,OAAO,eAAe,CAAC,GAAW,EAAE,QAAyB,EAAA;AACzD,QAAA,OAAO,aAAa,CAAC,YAAY,CAAC,GAAG,EAAE,QAAQ,CAAC;AAC3C,aAAA,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,YAAY,CAAC;AACrC,aAAA,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;AACnB,aAAA,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;KAC5B;AAED;;;;;AAKG;IACH,OAAO,YAAY,CAAC,SAAiB,EAAA;AACjC,QAAA,OAAO,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;KAC5D;AAED;;AAEG;IACH,OAAO,eAAe,CAAC,SAAiB,EAAA;AACpC,QAAA,IAAI,GAAG,GAAG,SAAS,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;AAC1D,QAAA,OAAO,GAAG,CAAC,MAAM,GAAG,CAAC,EAAE;YACnB,GAAG,IAAI,GAAG,CAAC;AACd,SAAA;AACD,QAAA,OAAO,aAAa,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;KAC1C;AACJ;;;;"}
|
|
@@ -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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NetworkUtils.cjs","sources":["../../src/utils/NetworkUtils.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"NetworkUtils.cjs","sources":["../../src/utils/NetworkUtils.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAAA;;;AAGG;MAIU,YAAY,CAAA;AACrB,IAAA,OAAO,kBAAkB,CACrB,OAA+B,EAC/B,IAAO,EACP,UAAkB,EAAA;QAElB,OAAO;AACH,YAAA,OAAO,EAAE,OAAO;AAChB,YAAA,IAAI,EAAE,IAAI;AACV,YAAA,MAAM,EAAE,UAAU;SACrB,CAAC;KACL;AAED;;;;AAIG;IACH,OAAO,gBAAgB,CAAC,GAAQ,EAAA;AAC5B,QAAA,MAAM,OAAO,GAA4B;YACrC,QAAQ,EAAE,GAAG,CAAC,QAAQ;AACtB,YAAA,QAAQ,EACJ,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC;kBACtC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;kBACzB,GAAG,CAAC,QAAQ;YACtB,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,MAAM,EAAE,GAAG,CAAC,MAAM;YAClB,QAAQ,EAAE,GAAG,CAAC,QAAQ;AACtB,YAAA,IAAI,EAAE,CAAA,EAAG,GAAG,CAAC,QAAQ,IAAI,EAAE,CAAA,EAAG,GAAG,CAAC,MAAM,IAAI,EAAE,CAAE,CAAA;YAChD,IAAI,EAAE,GAAG,CAAC,IAAI;SACjB,CAAC;AACF,QAAA,IAAI,GAAG,CAAC,IAAI,KAAK,EAAE,EAAE;YACjB,OAAO,CAAC,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AACnC,SAAA;AACD,QAAA,IAAI,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC,QAAQ,EAAE;AAC9B,YAAA,OAAO,CAAC,IAAI,GAAG,GAAG,kBAAkB,CAChC,GAAG,CAAC,QAAQ,CACf,CAAA,CAAA,EAAI,kBAAkB,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;AAC3C,SAAA;AACD,QAAA,OAAO,OAAO,CAAC;KAClB;AACJ;;;;"}
|
|
@@ -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 };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NetworkUtils.mjs","sources":["../../src/utils/NetworkUtils.ts"],"sourcesContent":[null],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"NetworkUtils.mjs","sources":["../../src/utils/NetworkUtils.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;;;AAGG;MAIU,YAAY,CAAA;AACrB,IAAA,OAAO,kBAAkB,CACrB,OAA+B,EAC/B,IAAO,EACP,UAAkB,EAAA;QAElB,OAAO;AACH,YAAA,OAAO,EAAE,OAAO;AAChB,YAAA,IAAI,EAAE,IAAI;AACV,YAAA,MAAM,EAAE,UAAU;SACrB,CAAC;KACL;AAED;;;;AAIG;IACH,OAAO,gBAAgB,CAAC,GAAQ,EAAA;AAC5B,QAAA,MAAM,OAAO,GAA4B;YACrC,QAAQ,EAAE,GAAG,CAAC,QAAQ;AACtB,YAAA,QAAQ,EACJ,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC;kBACtC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;kBACzB,GAAG,CAAC,QAAQ;YACtB,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,MAAM,EAAE,GAAG,CAAC,MAAM;YAClB,QAAQ,EAAE,GAAG,CAAC,QAAQ;AACtB,YAAA,IAAI,EAAE,CAAA,EAAG,GAAG,CAAC,QAAQ,IAAI,EAAE,CAAA,EAAG,GAAG,CAAC,MAAM,IAAI,EAAE,CAAE,CAAA;YAChD,IAAI,EAAE,GAAG,CAAC,IAAI;SACjB,CAAC;AACF,QAAA,IAAI,GAAG,CAAC,IAAI,KAAK,EAAE,EAAE;YACjB,OAAO,CAAC,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AACnC,SAAA;AACD,QAAA,IAAI,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC,QAAQ,EAAE;AAC9B,YAAA,OAAO,CAAC,IAAI,GAAG,GAAG,kBAAkB,CAChC,GAAG,CAAC,QAAQ,CACf,CAAA,CAAA,EAAI,kBAAkB,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;AAC3C,SAAA;AACD,QAAA,OAAO,OAAO,CAAC;KAClB;AACJ;;;;"}
|
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
|
@@ -218,13 +218,25 @@ export class NodeStorage extends CacheManager {
|
|
|
218
218
|
* @param accountKey - lookup key to fetch cache type AccountEntity
|
|
219
219
|
*/
|
|
220
220
|
getAccount(accountKey: string): AccountEntity | null {
|
|
221
|
-
const
|
|
222
|
-
if (AccountEntity.isAccountEntity(
|
|
223
|
-
return
|
|
221
|
+
const accountEntity = this.getCachedAccountEntity(accountKey);
|
|
222
|
+
if (accountEntity && AccountEntity.isAccountEntity(accountEntity)) {
|
|
223
|
+
return this.updateOutdatedCachedAccount(accountKey, accountEntity);
|
|
224
224
|
}
|
|
225
225
|
return null;
|
|
226
226
|
}
|
|
227
227
|
|
|
228
|
+
/**
|
|
229
|
+
* Reads account from cache, builds it into an account entity and returns it.
|
|
230
|
+
* @param accountKey
|
|
231
|
+
* @returns
|
|
232
|
+
*/
|
|
233
|
+
getCachedAccountEntity(accountKey: string): AccountEntity | null {
|
|
234
|
+
const cachedAccount = this.getItem(accountKey);
|
|
235
|
+
return cachedAccount
|
|
236
|
+
? Object.assign(new AccountEntity(), this.getItem(accountKey))
|
|
237
|
+
: null;
|
|
238
|
+
}
|
|
239
|
+
|
|
228
240
|
/**
|
|
229
241
|
* set account entity
|
|
230
242
|
* @param account - cache value to be set of type AccountEntity
|
|
@@ -409,10 +421,7 @@ export class NodeStorage extends CacheManager {
|
|
|
409
421
|
) as ThrottlingEntity;
|
|
410
422
|
if (
|
|
411
423
|
throttlingCache &&
|
|
412
|
-
|
|
413
|
-
throttlingCacheKey,
|
|
414
|
-
throttlingCache
|
|
415
|
-
)
|
|
424
|
+
CacheHelpers.isThrottlingEntity(throttlingCacheKey, throttlingCache)
|
|
416
425
|
) {
|
|
417
426
|
return throttlingCache;
|
|
418
427
|
}
|
|
@@ -456,6 +465,14 @@ export class NodeStorage extends CacheManager {
|
|
|
456
465
|
return result;
|
|
457
466
|
}
|
|
458
467
|
|
|
468
|
+
/**
|
|
469
|
+
* Remove account entity from the platform cache if it's outdated
|
|
470
|
+
* @param accountKey
|
|
471
|
+
*/
|
|
472
|
+
removeOutdatedAccount(accountKey: string): void {
|
|
473
|
+
this.removeItem(accountKey);
|
|
474
|
+
}
|
|
475
|
+
|
|
459
476
|
/**
|
|
460
477
|
* Checks whether key is in cache.
|
|
461
478
|
* @param key - look up key for a cache entity
|
package/src/cache/TokenCache.ts
CHANGED
|
@@ -124,7 +124,7 @@ export class TokenCache implements ISerializableTokenCache, ITokenCache {
|
|
|
124
124
|
let cacheContext;
|
|
125
125
|
try {
|
|
126
126
|
if (this.persistence) {
|
|
127
|
-
cacheContext = new TokenCacheContext(this,
|
|
127
|
+
cacheContext = new TokenCacheContext(this, true);
|
|
128
128
|
await this.persistence.beforeCacheAccess(cacheContext);
|
|
129
129
|
}
|
|
130
130
|
return this.storage.getAllAccounts();
|
|
@@ -63,6 +63,11 @@ export class Deserializer {
|
|
|
63
63
|
clientInfo: serializedAcc.client_info,
|
|
64
64
|
lastModificationTime: serializedAcc.last_modification_time,
|
|
65
65
|
lastModificationApp: serializedAcc.last_modification_app,
|
|
66
|
+
tenantProfiles: serializedAcc.tenantProfiles?.map(
|
|
67
|
+
(serializedTenantProfile) => {
|
|
68
|
+
return JSON.parse(serializedTenantProfile);
|
|
69
|
+
}
|
|
70
|
+
),
|
|
66
71
|
};
|
|
67
72
|
const account: AccountEntity = new AccountEntity();
|
|
68
73
|
CacheManager.toObject(account, mappedAcc);
|
|
@@ -50,6 +50,11 @@ export class Serializer {
|
|
|
50
50
|
client_info: accountEntity.clientInfo,
|
|
51
51
|
last_modification_time: accountEntity.lastModificationTime,
|
|
52
52
|
last_modification_app: accountEntity.lastModificationApp,
|
|
53
|
+
tenantProfiles: accountEntity.tenantProfiles?.map(
|
|
54
|
+
(tenantProfile) => {
|
|
55
|
+
return JSON.stringify(tenantProfile);
|
|
56
|
+
}
|
|
57
|
+
),
|
|
53
58
|
};
|
|
54
59
|
});
|
|
55
60
|
|
|
@@ -185,7 +185,7 @@ export abstract class ClientApplication {
|
|
|
185
185
|
"Auth code client created",
|
|
186
186
|
validRequest.correlationId
|
|
187
187
|
);
|
|
188
|
-
return authorizationCodeClient.acquireToken(
|
|
188
|
+
return await authorizationCodeClient.acquireToken(
|
|
189
189
|
validRequest,
|
|
190
190
|
authCodePayLoad
|
|
191
191
|
);
|
|
@@ -238,7 +238,7 @@ export abstract class ClientApplication {
|
|
|
238
238
|
"Refresh token client created",
|
|
239
239
|
validRequest.correlationId
|
|
240
240
|
);
|
|
241
|
-
return refreshTokenClient.acquireToken(validRequest);
|
|
241
|
+
return await refreshTokenClient.acquireToken(validRequest);
|
|
242
242
|
} catch (e) {
|
|
243
243
|
if (e instanceof AuthError) {
|
|
244
244
|
e.setCorrelationId(validRequest.correlationId);
|
|
@@ -286,7 +286,7 @@ export abstract class ClientApplication {
|
|
|
286
286
|
"Silent flow client created",
|
|
287
287
|
validRequest.correlationId
|
|
288
288
|
);
|
|
289
|
-
return silentFlowClient.acquireToken(validRequest);
|
|
289
|
+
return await silentFlowClient.acquireToken(validRequest);
|
|
290
290
|
} catch (e) {
|
|
291
291
|
if (e instanceof AuthError) {
|
|
292
292
|
e.setCorrelationId(validRequest.correlationId);
|
|
@@ -337,7 +337,7 @@ export abstract class ClientApplication {
|
|
|
337
337
|
"Username password client created",
|
|
338
338
|
validRequest.correlationId
|
|
339
339
|
);
|
|
340
|
-
return usernamePasswordClient.acquireToken(validRequest);
|
|
340
|
+
return await usernamePasswordClient.acquireToken(validRequest);
|
|
341
341
|
} catch (e) {
|
|
342
342
|
if (e instanceof AuthError) {
|
|
343
343
|
e.setCorrelationId(validRequest.correlationId);
|
|
@@ -412,10 +412,6 @@ export abstract class ClientApplication {
|
|
|
412
412
|
: this.config.auth.azureCloudOptions;
|
|
413
413
|
|
|
414
414
|
// using null assertion operator as we ensure that all config values have default values in buildConfiguration()
|
|
415
|
-
this.logger.verbose(
|
|
416
|
-
`building oauth client configuration with the authority: ${authority}`,
|
|
417
|
-
requestCorrelationId
|
|
418
|
-
);
|
|
419
415
|
const discoveredAuthority = await this.createAuthority(
|
|
420
416
|
authority,
|
|
421
417
|
azureRegionConfiguration,
|
|
@@ -423,6 +419,11 @@ export abstract class ClientApplication {
|
|
|
423
419
|
userAzureCloudOptions
|
|
424
420
|
);
|
|
425
421
|
|
|
422
|
+
this.logger.info(
|
|
423
|
+
`Building oauth client configuration with the following authority: ${discoveredAuthority.tokenEndpoint}.`,
|
|
424
|
+
requestCorrelationId
|
|
425
|
+
);
|
|
426
|
+
|
|
426
427
|
serverTelemetryManager?.updateRegionDiscoveryMetadata(
|
|
427
428
|
discoveredAuthority.regionDiscoveryMetadata
|
|
428
429
|
);
|
|
@@ -580,7 +581,7 @@ export abstract class ClientApplication {
|
|
|
580
581
|
this.config.auth.skipAuthorityMetadataCache,
|
|
581
582
|
};
|
|
582
583
|
|
|
583
|
-
return
|
|
584
|
+
return AuthorityFactory.createDiscoveredInstance(
|
|
584
585
|
authorityUrl,
|
|
585
586
|
this.config.system.networkClient,
|
|
586
587
|
this.storage,
|
|
@@ -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
|
-
return
|
|
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
|
|
@@ -80,41 +92,63 @@ export class ClientCredentialClient extends BaseClient {
|
|
|
80
92
|
// return the cached token
|
|
81
93
|
return cachedAuthenticationResult;
|
|
82
94
|
} else {
|
|
83
|
-
return
|
|
95
|
+
return this.executeTokenRequest(request, this.authority);
|
|
84
96
|
}
|
|
85
97
|
}
|
|
86
98
|
|
|
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) {
|
|
@@ -229,6 +269,7 @@ export class ClientCredentialClient extends BaseClient {
|
|
|
229
269
|
authority.tokenEndpoint,
|
|
230
270
|
queryParametersString
|
|
231
271
|
);
|
|
272
|
+
|
|
232
273
|
const requestBody = this.createTokenRequestBody(request);
|
|
233
274
|
const headers: Record<string, string> =
|
|
234
275
|
this.createTokenRequestHeaders();
|
|
@@ -244,6 +285,10 @@ export class ClientCredentialClient extends BaseClient {
|
|
|
244
285
|
sshKid: request.sshKid,
|
|
245
286
|
};
|
|
246
287
|
|
|
288
|
+
this.logger.info(
|
|
289
|
+
"Sending token request to endpoint: " + authority.tokenEndpoint
|
|
290
|
+
);
|
|
291
|
+
|
|
247
292
|
reqTimestamp = TimeUtils.nowSeconds();
|
|
248
293
|
const response = await this.executePostToTokenEndpoint(
|
|
249
294
|
endpoint,
|
|
@@ -158,7 +158,7 @@ export class ConfidentialClientApplication
|
|
|
158
158
|
"Client credential client created",
|
|
159
159
|
validRequest.correlationId
|
|
160
160
|
);
|
|
161
|
-
return clientCredentialClient.acquireToken(validRequest);
|
|
161
|
+
return await clientCredentialClient.acquireToken(validRequest);
|
|
162
162
|
} catch (e) {
|
|
163
163
|
if (e instanceof AuthError) {
|
|
164
164
|
e.setCorrelationId(validRequest.correlationId);
|
|
@@ -203,7 +203,7 @@ export class ConfidentialClientApplication
|
|
|
203
203
|
"On behalf of client created",
|
|
204
204
|
validRequest.correlationId
|
|
205
205
|
);
|
|
206
|
-
return oboClient.acquireToken(validRequest);
|
|
206
|
+
return await oboClient.acquireToken(validRequest);
|
|
207
207
|
} catch (e) {
|
|
208
208
|
if (e instanceof AuthError) {
|
|
209
209
|
e.setCorrelationId(validRequest.correlationId);
|
|
@@ -60,7 +60,7 @@ export class DeviceCodeClient extends BaseClient {
|
|
|
60
60
|
|
|
61
61
|
// Validate response. This function throws a server error if an error is returned by the server.
|
|
62
62
|
responseHandler.validateTokenResponse(response);
|
|
63
|
-
return
|
|
63
|
+
return responseHandler.handleServerTokenResponse(
|
|
64
64
|
response,
|
|
65
65
|
this.authority,
|
|
66
66
|
reqTimestamp,
|