@azure/msal-node 2.16.2 → 3.1.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/NodeStorage.d.ts +5 -10
- package/dist/cache/NodeStorage.d.ts.map +1 -1
- package/dist/cache/NodeStorage.mjs +6 -17
- package/dist/cache/NodeStorage.mjs.map +1 -1
- package/dist/cache/TokenCache.mjs +1 -1
- package/dist/cache/distributed/DistributedCachePlugin.mjs +1 -1
- package/dist/cache/serializer/Deserializer.mjs +1 -1
- package/dist/cache/serializer/Serializer.mjs +1 -1
- package/dist/client/ClientApplication.mjs +1 -1
- package/dist/client/ClientAssertion.mjs +1 -1
- package/dist/client/ClientCredentialClient.mjs +1 -1
- package/dist/client/ConfidentialClientApplication.d.ts +0 -1
- package/dist/client/ConfidentialClientApplication.d.ts.map +1 -1
- package/dist/client/ConfidentialClientApplication.mjs +40 -43
- package/dist/client/ConfidentialClientApplication.mjs.map +1 -1
- package/dist/client/DeviceCodeClient.mjs +1 -1
- package/dist/client/ManagedIdentityApplication.mjs +1 -1
- package/dist/client/ManagedIdentityClient.d.ts.map +1 -1
- package/dist/client/ManagedIdentityClient.mjs +10 -6
- package/dist/client/ManagedIdentityClient.mjs.map +1 -1
- package/dist/client/ManagedIdentitySources/AppService.mjs +1 -1
- package/dist/client/ManagedIdentitySources/AzureArc.mjs +1 -1
- package/dist/client/ManagedIdentitySources/AzureArc.mjs.map +1 -1
- package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.d.ts +3 -2
- package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.d.ts.map +1 -1
- package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.mjs +7 -4
- package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.mjs.map +1 -1
- package/dist/client/ManagedIdentitySources/CloudShell.mjs +1 -1
- package/dist/client/ManagedIdentitySources/Imds.d.ts.map +1 -1
- package/dist/client/ManagedIdentitySources/Imds.mjs +3 -2
- package/dist/client/ManagedIdentitySources/Imds.mjs.map +1 -1
- package/dist/client/ManagedIdentitySources/MachineLearning.d.ts +15 -0
- package/dist/client/ManagedIdentitySources/MachineLearning.d.ts.map +1 -0
- package/dist/client/ManagedIdentitySources/MachineLearning.mjs +51 -0
- package/dist/client/ManagedIdentitySources/MachineLearning.mjs.map +1 -0
- package/dist/client/ManagedIdentitySources/ServiceFabric.d.ts.map +1 -1
- package/dist/client/ManagedIdentitySources/ServiceFabric.mjs +3 -4
- package/dist/client/ManagedIdentitySources/ServiceFabric.mjs.map +1 -1
- package/dist/client/OnBehalfOfClient.mjs +1 -1
- package/dist/client/PublicClientApplication.mjs +1 -1
- package/dist/client/UsernamePasswordClient.mjs +1 -1
- package/dist/config/Configuration.mjs +1 -1
- package/dist/config/ManagedIdentityId.mjs +1 -1
- package/dist/config/ManagedIdentityRequestParameters.mjs +1 -1
- package/dist/crypto/CryptoProvider.mjs +1 -1
- package/dist/crypto/GuidGenerator.mjs +1 -1
- package/dist/crypto/HashUtils.d.ts +1 -0
- package/dist/crypto/HashUtils.d.ts.map +1 -1
- package/dist/crypto/HashUtils.mjs +1 -1
- package/dist/crypto/PkceGenerator.mjs +1 -1
- package/dist/error/ManagedIdentityError.mjs +1 -1
- package/dist/error/ManagedIdentityErrorCodes.mjs +1 -1
- package/dist/error/NodeAuthError.mjs +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +1 -2
- package/dist/index.mjs.map +1 -1
- package/dist/internals.mjs +1 -1
- package/dist/network/HttpClient.mjs +1 -1
- package/dist/network/HttpClientWithRetries.mjs +1 -1
- package/dist/network/LoopbackClient.mjs +1 -1
- package/dist/packageMetadata.d.ts +1 -1
- package/dist/packageMetadata.d.ts.map +1 -1
- package/dist/packageMetadata.mjs +2 -2
- package/dist/request/InteractiveRequest.d.ts +1 -0
- package/dist/request/InteractiveRequest.d.ts.map +1 -1
- package/dist/retry/LinearRetryPolicy.mjs +1 -1
- package/dist/utils/Constants.d.ts +3 -1
- package/dist/utils/Constants.d.ts.map +1 -1
- package/dist/utils/Constants.mjs +5 -3
- package/dist/utils/Constants.mjs.map +1 -1
- package/dist/utils/EncodingUtils.mjs +1 -1
- package/dist/utils/NetworkUtils.mjs +1 -1
- package/dist/utils/NetworkUtils.mjs.map +1 -1
- package/lib/msal-node.cjs +201 -231
- package/lib/msal-node.cjs.map +1 -1
- package/lib/types/cache/NodeStorage.d.ts +5 -10
- package/lib/types/cache/NodeStorage.d.ts.map +1 -1
- package/lib/types/client/ConfidentialClientApplication.d.ts +0 -1
- package/lib/types/client/ConfidentialClientApplication.d.ts.map +1 -1
- package/lib/types/client/ManagedIdentityClient.d.ts.map +1 -1
- package/lib/types/client/ManagedIdentitySources/BaseManagedIdentitySource.d.ts +3 -2
- package/lib/types/client/ManagedIdentitySources/BaseManagedIdentitySource.d.ts.map +1 -1
- package/lib/types/client/ManagedIdentitySources/Imds.d.ts.map +1 -1
- package/lib/types/client/ManagedIdentitySources/MachineLearning.d.ts +15 -0
- package/lib/types/client/ManagedIdentitySources/MachineLearning.d.ts.map +1 -0
- package/lib/types/client/ManagedIdentitySources/ServiceFabric.d.ts.map +1 -1
- package/lib/types/crypto/HashUtils.d.ts +1 -0
- package/lib/types/crypto/HashUtils.d.ts.map +1 -1
- package/lib/types/index.d.ts +0 -1
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/packageMetadata.d.ts +1 -1
- package/lib/types/packageMetadata.d.ts.map +1 -1
- package/lib/types/request/InteractiveRequest.d.ts +1 -0
- package/lib/types/request/InteractiveRequest.d.ts.map +1 -1
- package/lib/types/utils/Constants.d.ts +3 -1
- package/lib/types/utils/Constants.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/cache/NodeStorage.ts +9 -17
- package/src/client/ConfidentialClientApplication.ts +57 -60
- package/src/client/ManagedIdentityClient.ts +11 -0
- package/src/client/ManagedIdentitySources/BaseManagedIdentitySource.ts +7 -3
- package/src/client/ManagedIdentitySources/Imds.ts +2 -1
- package/src/client/ManagedIdentitySources/MachineLearning.ts +123 -0
- package/src/client/ManagedIdentitySources/ServiceFabric.ts +2 -3
- package/src/index.ts +0 -1
- package/src/packageMetadata.ts +1 -1
- package/src/utils/Constants.ts +3 -1
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { INetworkModule, Logger } from "@azure/msal-common/node";
|
|
7
|
+
import { BaseManagedIdentitySource } from "./BaseManagedIdentitySource.js";
|
|
8
|
+
import {
|
|
9
|
+
HttpMethod,
|
|
10
|
+
API_VERSION_QUERY_PARAMETER_NAME,
|
|
11
|
+
RESOURCE_BODY_OR_QUERY_PARAMETER_NAME,
|
|
12
|
+
ManagedIdentityEnvironmentVariableNames,
|
|
13
|
+
ManagedIdentitySourceNames,
|
|
14
|
+
ManagedIdentityIdType,
|
|
15
|
+
METADATA_HEADER_NAME,
|
|
16
|
+
ML_AND_SF_SECRET_HEADER_NAME,
|
|
17
|
+
} from "../../utils/Constants.js";
|
|
18
|
+
import { CryptoProvider } from "../../crypto/CryptoProvider.js";
|
|
19
|
+
import { ManagedIdentityRequestParameters } from "../../config/ManagedIdentityRequestParameters.js";
|
|
20
|
+
import { ManagedIdentityId } from "../../config/ManagedIdentityId.js";
|
|
21
|
+
import { NodeStorage } from "../../cache/NodeStorage.js";
|
|
22
|
+
|
|
23
|
+
const MACHINE_LEARNING_MSI_API_VERSION: string = "2017-09-01";
|
|
24
|
+
|
|
25
|
+
export class MachineLearning extends BaseManagedIdentitySource {
|
|
26
|
+
private msiEndpoint: string;
|
|
27
|
+
private secret: string;
|
|
28
|
+
|
|
29
|
+
constructor(
|
|
30
|
+
logger: Logger,
|
|
31
|
+
nodeStorage: NodeStorage,
|
|
32
|
+
networkClient: INetworkModule,
|
|
33
|
+
cryptoProvider: CryptoProvider,
|
|
34
|
+
msiEndpoint: string,
|
|
35
|
+
secret: string
|
|
36
|
+
) {
|
|
37
|
+
super(logger, nodeStorage, networkClient, cryptoProvider);
|
|
38
|
+
|
|
39
|
+
this.msiEndpoint = msiEndpoint;
|
|
40
|
+
this.secret = secret;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
public static getEnvironmentVariables(): Array<string | undefined> {
|
|
44
|
+
const msiEndpoint: string | undefined =
|
|
45
|
+
process.env[ManagedIdentityEnvironmentVariableNames.MSI_ENDPOINT];
|
|
46
|
+
|
|
47
|
+
const secret: string | undefined =
|
|
48
|
+
process.env[ManagedIdentityEnvironmentVariableNames.MSI_SECRET];
|
|
49
|
+
|
|
50
|
+
return [msiEndpoint, secret];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
public static tryCreate(
|
|
54
|
+
logger: Logger,
|
|
55
|
+
nodeStorage: NodeStorage,
|
|
56
|
+
networkClient: INetworkModule,
|
|
57
|
+
cryptoProvider: CryptoProvider
|
|
58
|
+
): MachineLearning | null {
|
|
59
|
+
const [msiEndpoint, secret] = MachineLearning.getEnvironmentVariables();
|
|
60
|
+
|
|
61
|
+
// if either of the MSI endpoint or MSI secret variables are undefined, this MSI provider is unavailable.
|
|
62
|
+
if (!msiEndpoint || !secret) {
|
|
63
|
+
logger.info(
|
|
64
|
+
`[Managed Identity] ${ManagedIdentitySourceNames.MACHINE_LEARNING} managed identity is unavailable because one or both of the '${ManagedIdentityEnvironmentVariableNames.MSI_ENDPOINT}' and '${ManagedIdentityEnvironmentVariableNames.MSI_SECRET}' environment variables are not defined.`
|
|
65
|
+
);
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const validatedMsiEndpoint: string =
|
|
70
|
+
MachineLearning.getValidatedEnvVariableUrlString(
|
|
71
|
+
ManagedIdentityEnvironmentVariableNames.MSI_ENDPOINT,
|
|
72
|
+
msiEndpoint,
|
|
73
|
+
ManagedIdentitySourceNames.MACHINE_LEARNING,
|
|
74
|
+
logger
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
logger.info(
|
|
78
|
+
`[Managed Identity] Environment variables validation passed for ${ManagedIdentitySourceNames.MACHINE_LEARNING} managed identity. Endpoint URI: ${validatedMsiEndpoint}. Creating ${ManagedIdentitySourceNames.MACHINE_LEARNING} managed identity.`
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
return new MachineLearning(
|
|
82
|
+
logger,
|
|
83
|
+
nodeStorage,
|
|
84
|
+
networkClient,
|
|
85
|
+
cryptoProvider,
|
|
86
|
+
msiEndpoint,
|
|
87
|
+
secret
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
public createRequest(
|
|
92
|
+
resource: string,
|
|
93
|
+
managedIdentityId: ManagedIdentityId
|
|
94
|
+
): ManagedIdentityRequestParameters {
|
|
95
|
+
const request: ManagedIdentityRequestParameters =
|
|
96
|
+
new ManagedIdentityRequestParameters(
|
|
97
|
+
HttpMethod.GET,
|
|
98
|
+
this.msiEndpoint
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
request.headers[METADATA_HEADER_NAME] = "true";
|
|
102
|
+
request.headers[ML_AND_SF_SECRET_HEADER_NAME] = this.secret;
|
|
103
|
+
|
|
104
|
+
request.queryParameters[API_VERSION_QUERY_PARAMETER_NAME] =
|
|
105
|
+
MACHINE_LEARNING_MSI_API_VERSION;
|
|
106
|
+
request.queryParameters[RESOURCE_BODY_OR_QUERY_PARAMETER_NAME] =
|
|
107
|
+
resource;
|
|
108
|
+
|
|
109
|
+
if (
|
|
110
|
+
managedIdentityId.idType !== ManagedIdentityIdType.SYSTEM_ASSIGNED
|
|
111
|
+
) {
|
|
112
|
+
request.queryParameters[
|
|
113
|
+
this.getManagedIdentityUserAssignedIdQueryParameterKey(
|
|
114
|
+
managedIdentityId.idType
|
|
115
|
+
)
|
|
116
|
+
] = managedIdentityId.id;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// bodyParameters calculated in BaseManagedIdentity.acquireTokenWithManagedIdentity
|
|
120
|
+
|
|
121
|
+
return request;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
ManagedIdentityIdType,
|
|
17
17
|
ManagedIdentitySourceNames,
|
|
18
18
|
RESOURCE_BODY_OR_QUERY_PARAMETER_NAME,
|
|
19
|
-
|
|
19
|
+
ML_AND_SF_SECRET_HEADER_NAME,
|
|
20
20
|
} from "../../utils/Constants.js";
|
|
21
21
|
|
|
22
22
|
// MSI Constants. Docs for MSI are available here https://docs.microsoft.com/azure/app-service/overview-managed-identity
|
|
@@ -122,8 +122,7 @@ export class ServiceFabric extends BaseManagedIdentitySource {
|
|
|
122
122
|
this.identityEndpoint
|
|
123
123
|
);
|
|
124
124
|
|
|
125
|
-
request.headers[
|
|
126
|
-
this.identityHeader;
|
|
125
|
+
request.headers[ML_AND_SF_SECRET_HEADER_NAME] = this.identityHeader;
|
|
127
126
|
|
|
128
127
|
request.queryParameters[API_VERSION_QUERY_PARAMETER_NAME] =
|
|
129
128
|
SERVICE_FABRIC_MSI_API_VERSION;
|
package/src/index.ts
CHANGED
package/src/packageMetadata.ts
CHANGED
package/src/utils/Constants.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { HttpStatus } from "@azure/msal-common/node";
|
|
|
9
9
|
export const AUTHORIZATION_HEADER_NAME: string = "Authorization";
|
|
10
10
|
export const METADATA_HEADER_NAME: string = "Metadata";
|
|
11
11
|
export const APP_SERVICE_SECRET_HEADER_NAME: string = "X-IDENTITY-HEADER";
|
|
12
|
-
export const
|
|
12
|
+
export const ML_AND_SF_SECRET_HEADER_NAME: string = "secret";
|
|
13
13
|
export const API_VERSION_QUERY_PARAMETER_NAME: string = "api-version";
|
|
14
14
|
export const RESOURCE_BODY_OR_QUERY_PARAMETER_NAME: string = "resource";
|
|
15
15
|
export const DEFAULT_MANAGED_IDENTITY_ID = "system_assigned_managed_identity";
|
|
@@ -26,6 +26,7 @@ export const ManagedIdentityEnvironmentVariableNames = {
|
|
|
26
26
|
IDENTITY_SERVER_THUMBPRINT: "IDENTITY_SERVER_THUMBPRINT",
|
|
27
27
|
IMDS_ENDPOINT: "IMDS_ENDPOINT",
|
|
28
28
|
MSI_ENDPOINT: "MSI_ENDPOINT",
|
|
29
|
+
MSI_SECRET: "MSI_SECRET",
|
|
29
30
|
} as const;
|
|
30
31
|
export type ManagedIdentityEnvironmentVariableNames =
|
|
31
32
|
(typeof ManagedIdentityEnvironmentVariableNames)[keyof typeof ManagedIdentityEnvironmentVariableNames];
|
|
@@ -40,6 +41,7 @@ export const ManagedIdentitySourceNames = {
|
|
|
40
41
|
CLOUD_SHELL: "CloudShell",
|
|
41
42
|
DEFAULT_TO_IMDS: "DefaultToImds",
|
|
42
43
|
IMDS: "Imds",
|
|
44
|
+
MACHINE_LEARNING: "MachineLearning",
|
|
43
45
|
SERVICE_FABRIC: "ServiceFabric",
|
|
44
46
|
} as const;
|
|
45
47
|
/**
|