@azure/msal-node 3.2.3 → 3.4.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.mjs +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.d.ts +3 -3
- package/dist/client/ClientApplication.d.ts.map +1 -1
- package/dist/client/ClientApplication.mjs +14 -17
- package/dist/client/ClientApplication.mjs.map +1 -1
- package/dist/client/ClientAssertion.mjs +1 -1
- package/dist/client/ClientCredentialClient.d.ts.map +1 -1
- package/dist/client/ClientCredentialClient.mjs +16 -16
- package/dist/client/ClientCredentialClient.mjs.map +1 -1
- package/dist/client/ConfidentialClientApplication.d.ts.map +1 -1
- package/dist/client/ConfidentialClientApplication.mjs +5 -3
- package/dist/client/ConfidentialClientApplication.mjs.map +1 -1
- package/dist/client/DeviceCodeClient.d.ts.map +1 -1
- package/dist/client/DeviceCodeClient.mjs +24 -24
- package/dist/client/DeviceCodeClient.mjs.map +1 -1
- package/dist/client/ManagedIdentityApplication.d.ts.map +1 -1
- package/dist/client/ManagedIdentityApplication.mjs +2 -2
- package/dist/client/ManagedIdentityApplication.mjs.map +1 -1
- package/dist/client/ManagedIdentityClient.d.ts +2 -1
- package/dist/client/ManagedIdentityClient.d.ts.map +1 -1
- package/dist/client/ManagedIdentityClient.mjs +11 -10
- package/dist/client/ManagedIdentityClient.mjs.map +1 -1
- package/dist/client/ManagedIdentitySources/AppService.d.ts +2 -2
- package/dist/client/ManagedIdentitySources/AppService.d.ts.map +1 -1
- package/dist/client/ManagedIdentitySources/AppService.mjs +5 -5
- package/dist/client/ManagedIdentitySources/AppService.mjs.map +1 -1
- package/dist/client/ManagedIdentitySources/AzureArc.d.ts +2 -2
- package/dist/client/ManagedIdentitySources/AzureArc.d.ts.map +1 -1
- package/dist/client/ManagedIdentitySources/AzureArc.mjs +5 -5
- package/dist/client/ManagedIdentitySources/AzureArc.mjs.map +1 -1
- package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.d.ts +2 -1
- package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.d.ts.map +1 -1
- package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.mjs +15 -5
- package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.mjs.map +1 -1
- package/dist/client/ManagedIdentitySources/CloudShell.d.ts +2 -2
- package/dist/client/ManagedIdentitySources/CloudShell.d.ts.map +1 -1
- package/dist/client/ManagedIdentitySources/CloudShell.mjs +5 -5
- package/dist/client/ManagedIdentitySources/CloudShell.mjs.map +1 -1
- package/dist/client/ManagedIdentitySources/Imds.d.ts +2 -2
- package/dist/client/ManagedIdentitySources/Imds.d.ts.map +1 -1
- package/dist/client/ManagedIdentitySources/Imds.mjs +5 -5
- package/dist/client/ManagedIdentitySources/Imds.mjs.map +1 -1
- package/dist/client/ManagedIdentitySources/MachineLearning.d.ts +2 -2
- package/dist/client/ManagedIdentitySources/MachineLearning.d.ts.map +1 -1
- package/dist/client/ManagedIdentitySources/MachineLearning.mjs +5 -5
- package/dist/client/ManagedIdentitySources/MachineLearning.mjs.map +1 -1
- package/dist/client/ManagedIdentitySources/ServiceFabric.d.ts +2 -2
- package/dist/client/ManagedIdentitySources/ServiceFabric.d.ts.map +1 -1
- package/dist/client/ManagedIdentitySources/ServiceFabric.mjs +5 -5
- package/dist/client/ManagedIdentitySources/ServiceFabric.mjs.map +1 -1
- package/dist/client/OnBehalfOfClient.d.ts.map +1 -1
- package/dist/client/OnBehalfOfClient.mjs +19 -19
- package/dist/client/OnBehalfOfClient.mjs.map +1 -1
- package/dist/client/PublicClientApplication.d.ts.map +1 -1
- package/dist/client/PublicClientApplication.mjs +3 -2
- package/dist/client/PublicClientApplication.mjs.map +1 -1
- package/dist/client/UsernamePasswordClient.d.ts.map +1 -1
- package/dist/client/UsernamePasswordClient.mjs +21 -21
- package/dist/client/UsernamePasswordClient.mjs.map +1 -1
- package/dist/config/Configuration.d.ts +1 -0
- package/dist/config/Configuration.d.ts.map +1 -1
- package/dist/config/Configuration.mjs +2 -9
- package/dist/config/Configuration.mjs.map +1 -1
- package/dist/config/ManagedIdentityId.mjs +1 -1
- package/dist/config/ManagedIdentityRequestParameters.d.ts +3 -2
- package/dist/config/ManagedIdentityRequestParameters.d.ts.map +1 -1
- package/dist/config/ManagedIdentityRequestParameters.mjs +13 -9
- package/dist/config/ManagedIdentityRequestParameters.mjs.map +1 -1
- package/dist/crypto/CryptoProvider.mjs +1 -1
- package/dist/crypto/GuidGenerator.mjs +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 +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +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/ILoopbackClient.d.ts +2 -2
- package/dist/network/ILoopbackClient.d.ts.map +1 -1
- package/dist/network/LoopbackClient.d.ts +2 -2
- package/dist/network/LoopbackClient.d.ts.map +1 -1
- package/dist/network/LoopbackClient.mjs +3 -2
- package/dist/network/LoopbackClient.mjs.map +1 -1
- package/dist/packageMetadata.d.ts +1 -1
- package/dist/packageMetadata.mjs +2 -2
- package/dist/protocol/Authorize.d.ts +12 -0
- package/dist/protocol/Authorize.d.ts.map +1 -0
- package/dist/protocol/Authorize.mjs +42 -0
- package/dist/protocol/Authorize.mjs.map +1 -0
- package/dist/retry/LinearRetryPolicy.mjs +1 -1
- package/dist/utils/Constants.d.ts +5 -0
- package/dist/utils/Constants.d.ts.map +1 -1
- package/dist/utils/Constants.mjs +1 -1
- 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/TimeUtils.mjs +1 -1
- package/lib/msal-node.cjs +1006 -1082
- package/lib/msal-node.cjs.map +1 -1
- package/lib/types/client/ClientApplication.d.ts +3 -3
- package/lib/types/client/ClientApplication.d.ts.map +1 -1
- package/lib/types/client/ClientCredentialClient.d.ts.map +1 -1
- package/lib/types/client/ConfidentialClientApplication.d.ts.map +1 -1
- package/lib/types/client/DeviceCodeClient.d.ts.map +1 -1
- package/lib/types/client/ManagedIdentityApplication.d.ts.map +1 -1
- package/lib/types/client/ManagedIdentityClient.d.ts +2 -1
- package/lib/types/client/ManagedIdentityClient.d.ts.map +1 -1
- package/lib/types/client/ManagedIdentitySources/AppService.d.ts +2 -2
- package/lib/types/client/ManagedIdentitySources/AppService.d.ts.map +1 -1
- package/lib/types/client/ManagedIdentitySources/AzureArc.d.ts +2 -2
- package/lib/types/client/ManagedIdentitySources/AzureArc.d.ts.map +1 -1
- package/lib/types/client/ManagedIdentitySources/BaseManagedIdentitySource.d.ts +2 -1
- package/lib/types/client/ManagedIdentitySources/BaseManagedIdentitySource.d.ts.map +1 -1
- package/lib/types/client/ManagedIdentitySources/CloudShell.d.ts +2 -2
- package/lib/types/client/ManagedIdentitySources/CloudShell.d.ts.map +1 -1
- package/lib/types/client/ManagedIdentitySources/Imds.d.ts +2 -2
- package/lib/types/client/ManagedIdentitySources/Imds.d.ts.map +1 -1
- package/lib/types/client/ManagedIdentitySources/MachineLearning.d.ts +2 -2
- package/lib/types/client/ManagedIdentitySources/MachineLearning.d.ts.map +1 -1
- package/lib/types/client/ManagedIdentitySources/ServiceFabric.d.ts +2 -2
- package/lib/types/client/ManagedIdentitySources/ServiceFabric.d.ts.map +1 -1
- package/lib/types/client/OnBehalfOfClient.d.ts.map +1 -1
- package/lib/types/client/PublicClientApplication.d.ts.map +1 -1
- package/lib/types/client/UsernamePasswordClient.d.ts.map +1 -1
- package/lib/types/config/Configuration.d.ts +1 -0
- package/lib/types/config/Configuration.d.ts.map +1 -1
- package/lib/types/config/ManagedIdentityRequestParameters.d.ts +3 -2
- package/lib/types/config/ManagedIdentityRequestParameters.d.ts.map +1 -1
- package/lib/types/index.d.ts +5 -1
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/network/ILoopbackClient.d.ts +2 -2
- package/lib/types/network/ILoopbackClient.d.ts.map +1 -1
- package/lib/types/network/LoopbackClient.d.ts +2 -2
- package/lib/types/network/LoopbackClient.d.ts.map +1 -1
- package/lib/types/packageMetadata.d.ts +1 -1
- package/lib/types/protocol/Authorize.d.ts +12 -0
- package/lib/types/protocol/Authorize.d.ts.map +1 -0
- package/lib/types/utils/Constants.d.ts +5 -0
- package/lib/types/utils/Constants.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/client/ClientApplication.ts +42 -44
- package/src/client/ClientCredentialClient.ts +32 -14
- package/src/client/ConfidentialClientApplication.ts +15 -7
- package/src/client/DeviceCodeClient.ts +46 -24
- package/src/client/ManagedIdentityApplication.ts +2 -1
- package/src/client/ManagedIdentityClient.ts +20 -4
- package/src/client/ManagedIdentitySources/AppService.ts +11 -2
- package/src/client/ManagedIdentitySources/AzureArc.ts +10 -1
- package/src/client/ManagedIdentitySources/BaseManagedIdentitySource.ts +20 -4
- package/src/client/ManagedIdentitySources/CloudShell.ts +10 -1
- package/src/client/ManagedIdentitySources/Imds.ts +11 -2
- package/src/client/ManagedIdentitySources/MachineLearning.ts +11 -2
- package/src/client/ManagedIdentitySources/ServiceFabric.ts +10 -1
- package/src/client/OnBehalfOfClient.ts +38 -17
- package/src/client/PublicClientApplication.ts +9 -5
- package/src/client/UsernamePasswordClient.ts +37 -19
- package/src/config/Configuration.ts +2 -20
- package/src/config/ManagedIdentityRequestParameters.ts +38 -9
- package/src/index.ts +5 -2
- package/src/network/ILoopbackClient.ts +2 -2
- package/src/network/LoopbackClient.ts +43 -46
- package/src/packageMetadata.ts +1 -1
- package/src/protocol/Authorize.ts +63 -0
- package/src/utils/Constants.ts +6 -0
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import {
|
|
7
7
|
Constants as CommonConstants,
|
|
8
|
-
|
|
8
|
+
AuthorizeResponse,
|
|
9
9
|
HttpStatus,
|
|
10
10
|
UrlUtils,
|
|
11
11
|
} from "@azure/msal-common/node";
|
|
@@ -26,57 +26,54 @@ export class LoopbackClient implements ILoopbackClient {
|
|
|
26
26
|
async listenForAuthCode(
|
|
27
27
|
successTemplate?: string,
|
|
28
28
|
errorTemplate?: string
|
|
29
|
-
): Promise<
|
|
29
|
+
): Promise<AuthorizeResponse> {
|
|
30
30
|
if (this.server) {
|
|
31
31
|
throw NodeAuthError.createLoopbackServerAlreadyExistsError();
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
return new Promise<
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
34
|
+
return new Promise<AuthorizeResponse>((resolve, reject) => {
|
|
35
|
+
this.server = http.createServer(
|
|
36
|
+
(req: http.IncomingMessage, res: http.ServerResponse) => {
|
|
37
|
+
const url = req.url;
|
|
38
|
+
if (!url) {
|
|
39
|
+
res.end(
|
|
40
|
+
errorTemplate ||
|
|
41
|
+
"Error occurred loading redirectUrl"
|
|
42
|
+
);
|
|
43
|
+
reject(
|
|
44
|
+
NodeAuthError.createUnableToLoadRedirectUrlError()
|
|
45
|
+
);
|
|
46
|
+
return;
|
|
47
|
+
} else if (url === CommonConstants.FORWARD_SLASH) {
|
|
48
|
+
res.end(
|
|
49
|
+
successTemplate ||
|
|
50
|
+
"Auth code was successfully acquired. You can close this window now."
|
|
51
|
+
);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
55
54
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
res.end();
|
|
67
|
-
}
|
|
68
|
-
if (authCodeResponse.error) {
|
|
69
|
-
res.end(
|
|
70
|
-
errorTemplate ||
|
|
71
|
-
`Error occurred: ${authCodeResponse.error}`
|
|
72
|
-
);
|
|
73
|
-
}
|
|
74
|
-
resolve(authCodeResponse);
|
|
55
|
+
const redirectUri = this.getRedirectUri();
|
|
56
|
+
const parsedUrl = new URL(url, redirectUri);
|
|
57
|
+
const authCodeResponse =
|
|
58
|
+
UrlUtils.getDeserializedResponse(parsedUrl.search) ||
|
|
59
|
+
{};
|
|
60
|
+
if (authCodeResponse.code) {
|
|
61
|
+
res.writeHead(HttpStatus.REDIRECT, {
|
|
62
|
+
location: redirectUri,
|
|
63
|
+
}); // Prevent auth code from being saved in the browser history
|
|
64
|
+
res.end();
|
|
75
65
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
66
|
+
if (authCodeResponse.error) {
|
|
67
|
+
res.end(
|
|
68
|
+
errorTemplate ||
|
|
69
|
+
`Error occurred: ${authCodeResponse.error}`
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
resolve(authCodeResponse);
|
|
73
|
+
}
|
|
74
|
+
);
|
|
75
|
+
this.server.listen(0, "127.0.0.1"); // Listen on any available port
|
|
76
|
+
});
|
|
80
77
|
}
|
|
81
78
|
|
|
82
79
|
/**
|
package/src/packageMetadata.ts
CHANGED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
Authority,
|
|
8
|
+
AuthorizeProtocol,
|
|
9
|
+
CommonAuthorizationUrlRequest,
|
|
10
|
+
Logger,
|
|
11
|
+
ProtocolMode,
|
|
12
|
+
RequestParameterBuilder,
|
|
13
|
+
} from "@azure/msal-common/node";
|
|
14
|
+
import { NodeConfiguration } from "../config/Configuration.js";
|
|
15
|
+
import { Constants as NodeConstants } from "../utils/Constants.js";
|
|
16
|
+
import { version } from "../packageMetadata.js";
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Constructs the full /authorize URL with request parameters
|
|
20
|
+
* @param config
|
|
21
|
+
* @param authority
|
|
22
|
+
* @param request
|
|
23
|
+
* @param logger
|
|
24
|
+
* @returns
|
|
25
|
+
*/
|
|
26
|
+
export function getAuthCodeRequestUrl(
|
|
27
|
+
config: NodeConfiguration,
|
|
28
|
+
authority: Authority,
|
|
29
|
+
request: CommonAuthorizationUrlRequest,
|
|
30
|
+
logger: Logger
|
|
31
|
+
): string {
|
|
32
|
+
const parameters = AuthorizeProtocol.getStandardAuthorizeRequestParameters(
|
|
33
|
+
{
|
|
34
|
+
...config.auth,
|
|
35
|
+
authority: authority,
|
|
36
|
+
redirectUri: request.redirectUri || "",
|
|
37
|
+
},
|
|
38
|
+
request,
|
|
39
|
+
logger
|
|
40
|
+
);
|
|
41
|
+
RequestParameterBuilder.addLibraryInfo(parameters, {
|
|
42
|
+
sku: NodeConstants.MSAL_SKU,
|
|
43
|
+
version: version,
|
|
44
|
+
cpu: process.arch || "",
|
|
45
|
+
os: process.platform || "",
|
|
46
|
+
});
|
|
47
|
+
if (config.auth.protocolMode !== ProtocolMode.OIDC) {
|
|
48
|
+
RequestParameterBuilder.addApplicationTelemetry(
|
|
49
|
+
parameters,
|
|
50
|
+
config.telemetry.application
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
RequestParameterBuilder.addResponseTypeCode(parameters);
|
|
54
|
+
if (request.codeChallenge && request.codeChallengeMethod) {
|
|
55
|
+
RequestParameterBuilder.addCodeChallengeParams(
|
|
56
|
+
parameters,
|
|
57
|
+
request.codeChallenge,
|
|
58
|
+
request.codeChallengeMethod
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return AuthorizeProtocol.getAuthorizeUrl(authority, parameters);
|
|
63
|
+
}
|
package/src/utils/Constants.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { HttpStatus } from "@azure/msal-common/node";
|
|
7
|
+
import { LinearRetryPolicy } from "../retry/LinearRetryPolicy.js";
|
|
7
8
|
|
|
8
9
|
// MSI Constants. Docs for MSI are available here https://docs.microsoft.com/azure/app-service/overview-managed-identity
|
|
9
10
|
export const AUTHORIZATION_HEADER_NAME: string = "Authorization";
|
|
@@ -178,3 +179,8 @@ export const MANAGED_IDENTITY_HTTP_STATUS_CODES_TO_RETRY_ON = [
|
|
|
178
179
|
HttpStatus.SERVICE_UNAVAILABLE,
|
|
179
180
|
HttpStatus.GATEWAY_TIMEOUT,
|
|
180
181
|
];
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Retry Policy Types
|
|
185
|
+
*/
|
|
186
|
+
export type RetryPolicies = LinearRetryPolicy;
|