@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
|
@@ -32,6 +32,7 @@ import {
|
|
|
32
32
|
createManagedIdentityError,
|
|
33
33
|
} from "../../error/ManagedIdentityError.js";
|
|
34
34
|
import { isIso8601 } from "../../utils/TimeUtils.js";
|
|
35
|
+
import { HttpClientWithRetries } from "../../network/HttpClientWithRetries.js";
|
|
35
36
|
|
|
36
37
|
/**
|
|
37
38
|
* Managed Identity User Assigned Id Query Parameter Names
|
|
@@ -50,17 +51,20 @@ export abstract class BaseManagedIdentitySource {
|
|
|
50
51
|
private nodeStorage: NodeStorage;
|
|
51
52
|
private networkClient: INetworkModule;
|
|
52
53
|
private cryptoProvider: CryptoProvider;
|
|
54
|
+
private disableInternalRetries: boolean;
|
|
53
55
|
|
|
54
56
|
constructor(
|
|
55
57
|
logger: Logger,
|
|
56
58
|
nodeStorage: NodeStorage,
|
|
57
59
|
networkClient: INetworkModule,
|
|
58
|
-
cryptoProvider: CryptoProvider
|
|
60
|
+
cryptoProvider: CryptoProvider,
|
|
61
|
+
disableInternalRetries: boolean
|
|
59
62
|
) {
|
|
60
63
|
this.logger = logger;
|
|
61
64
|
this.nodeStorage = nodeStorage;
|
|
62
65
|
this.networkClient = networkClient;
|
|
63
66
|
this.cryptoProvider = cryptoProvider;
|
|
67
|
+
this.disableInternalRetries = disableInternalRetries;
|
|
64
68
|
}
|
|
65
69
|
|
|
66
70
|
abstract createRequest(
|
|
@@ -151,20 +155,32 @@ export abstract class BaseManagedIdentitySource {
|
|
|
151
155
|
networkRequest.computeParametersBodyString();
|
|
152
156
|
}
|
|
153
157
|
|
|
158
|
+
/**
|
|
159
|
+
* Initializes the network client helper based on the retry policy configuration.
|
|
160
|
+
* If internal retries are disabled, it uses the provided network client directly.
|
|
161
|
+
* Otherwise, it wraps the network client with an HTTP client that supports retries.
|
|
162
|
+
*/
|
|
163
|
+
const networkClientHelper: INetworkModule = this.disableInternalRetries
|
|
164
|
+
? this.networkClient
|
|
165
|
+
: new HttpClientWithRetries(
|
|
166
|
+
this.networkClient,
|
|
167
|
+
networkRequest.retryPolicy
|
|
168
|
+
);
|
|
169
|
+
|
|
154
170
|
const reqTimestamp = TimeUtils.nowSeconds();
|
|
155
171
|
let response: NetworkResponse<ManagedIdentityTokenResponse>;
|
|
156
172
|
try {
|
|
157
173
|
// Sources that send POST requests: Cloud Shell
|
|
158
174
|
if (networkRequest.httpMethod === HttpMethod.POST) {
|
|
159
175
|
response =
|
|
160
|
-
await
|
|
176
|
+
await networkClientHelper.sendPostRequestAsync<ManagedIdentityTokenResponse>(
|
|
161
177
|
networkRequest.computeUri(),
|
|
162
178
|
networkRequestOptions
|
|
163
179
|
);
|
|
164
180
|
// Sources that send GET requests: App Service, Azure Arc, IMDS, Service Fabric
|
|
165
181
|
} else {
|
|
166
182
|
response =
|
|
167
|
-
await
|
|
183
|
+
await networkClientHelper.sendGetRequestAsync<ManagedIdentityTokenResponse>(
|
|
168
184
|
networkRequest.computeUri(),
|
|
169
185
|
networkRequestOptions
|
|
170
186
|
);
|
|
@@ -189,7 +205,7 @@ export abstract class BaseManagedIdentitySource {
|
|
|
189
205
|
const serverTokenResponse: ServerAuthorizationTokenResponse =
|
|
190
206
|
await this.getServerTokenResponseAsync(
|
|
191
207
|
response,
|
|
192
|
-
|
|
208
|
+
networkClientHelper,
|
|
193
209
|
networkRequest,
|
|
194
210
|
networkRequestOptions
|
|
195
211
|
);
|
|
@@ -33,9 +33,16 @@ export class CloudShell extends BaseManagedIdentitySource {
|
|
|
33
33
|
nodeStorage: NodeStorage,
|
|
34
34
|
networkClient: INetworkModule,
|
|
35
35
|
cryptoProvider: CryptoProvider,
|
|
36
|
+
disableInternalRetries: boolean,
|
|
36
37
|
msiEndpoint: string
|
|
37
38
|
) {
|
|
38
|
-
super(
|
|
39
|
+
super(
|
|
40
|
+
logger,
|
|
41
|
+
nodeStorage,
|
|
42
|
+
networkClient,
|
|
43
|
+
cryptoProvider,
|
|
44
|
+
disableInternalRetries
|
|
45
|
+
);
|
|
39
46
|
|
|
40
47
|
this.msiEndpoint = msiEndpoint;
|
|
41
48
|
}
|
|
@@ -52,6 +59,7 @@ export class CloudShell extends BaseManagedIdentitySource {
|
|
|
52
59
|
nodeStorage: NodeStorage,
|
|
53
60
|
networkClient: INetworkModule,
|
|
54
61
|
cryptoProvider: CryptoProvider,
|
|
62
|
+
disableInternalRetries: boolean,
|
|
55
63
|
managedIdentityId: ManagedIdentityId
|
|
56
64
|
): CloudShell | null {
|
|
57
65
|
const [msiEndpoint] = CloudShell.getEnvironmentVariables();
|
|
@@ -89,6 +97,7 @@ export class CloudShell extends BaseManagedIdentitySource {
|
|
|
89
97
|
nodeStorage,
|
|
90
98
|
networkClient,
|
|
91
99
|
cryptoProvider,
|
|
100
|
+
disableInternalRetries,
|
|
92
101
|
msiEndpoint
|
|
93
102
|
);
|
|
94
103
|
}
|
|
@@ -34,9 +34,16 @@ export class Imds extends BaseManagedIdentitySource {
|
|
|
34
34
|
nodeStorage: NodeStorage,
|
|
35
35
|
networkClient: INetworkModule,
|
|
36
36
|
cryptoProvider: CryptoProvider,
|
|
37
|
+
disableInternalRetries: boolean,
|
|
37
38
|
identityEndpoint: string
|
|
38
39
|
) {
|
|
39
|
-
super(
|
|
40
|
+
super(
|
|
41
|
+
logger,
|
|
42
|
+
nodeStorage,
|
|
43
|
+
networkClient,
|
|
44
|
+
cryptoProvider,
|
|
45
|
+
disableInternalRetries
|
|
46
|
+
);
|
|
40
47
|
|
|
41
48
|
this.identityEndpoint = identityEndpoint;
|
|
42
49
|
}
|
|
@@ -45,7 +52,8 @@ export class Imds extends BaseManagedIdentitySource {
|
|
|
45
52
|
logger: Logger,
|
|
46
53
|
nodeStorage: NodeStorage,
|
|
47
54
|
networkClient: INetworkModule,
|
|
48
|
-
cryptoProvider: CryptoProvider
|
|
55
|
+
cryptoProvider: CryptoProvider,
|
|
56
|
+
disableInternalRetries: boolean
|
|
49
57
|
): Imds {
|
|
50
58
|
let validatedIdentityEndpoint: string;
|
|
51
59
|
|
|
@@ -88,6 +96,7 @@ export class Imds extends BaseManagedIdentitySource {
|
|
|
88
96
|
nodeStorage,
|
|
89
97
|
networkClient,
|
|
90
98
|
cryptoProvider,
|
|
99
|
+
disableInternalRetries,
|
|
91
100
|
validatedIdentityEndpoint
|
|
92
101
|
);
|
|
93
102
|
}
|
|
@@ -31,10 +31,17 @@ export class MachineLearning extends BaseManagedIdentitySource {
|
|
|
31
31
|
nodeStorage: NodeStorage,
|
|
32
32
|
networkClient: INetworkModule,
|
|
33
33
|
cryptoProvider: CryptoProvider,
|
|
34
|
+
disableInternalRetries: boolean,
|
|
34
35
|
msiEndpoint: string,
|
|
35
36
|
secret: string
|
|
36
37
|
) {
|
|
37
|
-
super(
|
|
38
|
+
super(
|
|
39
|
+
logger,
|
|
40
|
+
nodeStorage,
|
|
41
|
+
networkClient,
|
|
42
|
+
cryptoProvider,
|
|
43
|
+
disableInternalRetries
|
|
44
|
+
);
|
|
38
45
|
|
|
39
46
|
this.msiEndpoint = msiEndpoint;
|
|
40
47
|
this.secret = secret;
|
|
@@ -54,7 +61,8 @@ export class MachineLearning extends BaseManagedIdentitySource {
|
|
|
54
61
|
logger: Logger,
|
|
55
62
|
nodeStorage: NodeStorage,
|
|
56
63
|
networkClient: INetworkModule,
|
|
57
|
-
cryptoProvider: CryptoProvider
|
|
64
|
+
cryptoProvider: CryptoProvider,
|
|
65
|
+
disableInternalRetries: boolean
|
|
58
66
|
): MachineLearning | null {
|
|
59
67
|
const [msiEndpoint, secret] = MachineLearning.getEnvironmentVariables();
|
|
60
68
|
|
|
@@ -83,6 +91,7 @@ export class MachineLearning extends BaseManagedIdentitySource {
|
|
|
83
91
|
nodeStorage,
|
|
84
92
|
networkClient,
|
|
85
93
|
cryptoProvider,
|
|
94
|
+
disableInternalRetries,
|
|
86
95
|
msiEndpoint,
|
|
87
96
|
secret
|
|
88
97
|
);
|
|
@@ -34,10 +34,17 @@ export class ServiceFabric extends BaseManagedIdentitySource {
|
|
|
34
34
|
nodeStorage: NodeStorage,
|
|
35
35
|
networkClient: INetworkModule,
|
|
36
36
|
cryptoProvider: CryptoProvider,
|
|
37
|
+
disableInternalRetries: boolean,
|
|
37
38
|
identityEndpoint: string,
|
|
38
39
|
identityHeader: string
|
|
39
40
|
) {
|
|
40
|
-
super(
|
|
41
|
+
super(
|
|
42
|
+
logger,
|
|
43
|
+
nodeStorage,
|
|
44
|
+
networkClient,
|
|
45
|
+
cryptoProvider,
|
|
46
|
+
disableInternalRetries
|
|
47
|
+
);
|
|
41
48
|
|
|
42
49
|
this.identityEndpoint = identityEndpoint;
|
|
43
50
|
this.identityHeader = identityHeader;
|
|
@@ -66,6 +73,7 @@ export class ServiceFabric extends BaseManagedIdentitySource {
|
|
|
66
73
|
nodeStorage: NodeStorage,
|
|
67
74
|
networkClient: INetworkModule,
|
|
68
75
|
cryptoProvider: CryptoProvider,
|
|
76
|
+
disableInternalRetries: boolean,
|
|
69
77
|
managedIdentityId: ManagedIdentityId
|
|
70
78
|
): ServiceFabric | null {
|
|
71
79
|
const [identityEndpoint, identityHeader, identityServerThumbprint] =
|
|
@@ -107,6 +115,7 @@ export class ServiceFabric extends BaseManagedIdentitySource {
|
|
|
107
115
|
nodeStorage,
|
|
108
116
|
networkClient,
|
|
109
117
|
cryptoProvider,
|
|
118
|
+
disableInternalRetries,
|
|
110
119
|
identityEndpoint,
|
|
111
120
|
identityHeader
|
|
112
121
|
);
|
|
@@ -32,6 +32,7 @@ import {
|
|
|
32
32
|
UrlString,
|
|
33
33
|
ClientAssertion,
|
|
34
34
|
getClientAssertion,
|
|
35
|
+
UrlUtils,
|
|
35
36
|
} from "@azure/msal-common/node";
|
|
36
37
|
import { EncodingUtils } from "../utils/EncodingUtils.js";
|
|
37
38
|
|
|
@@ -312,37 +313,54 @@ export class OnBehalfOfClient extends BaseClient {
|
|
|
312
313
|
private async createTokenRequestBody(
|
|
313
314
|
request: CommonOnBehalfOfRequest
|
|
314
315
|
): Promise<string> {
|
|
315
|
-
const
|
|
316
|
+
const parameters = new Map<string, string>();
|
|
316
317
|
|
|
317
|
-
|
|
318
|
+
RequestParameterBuilder.addClientId(
|
|
319
|
+
parameters,
|
|
320
|
+
this.config.authOptions.clientId
|
|
321
|
+
);
|
|
318
322
|
|
|
319
|
-
|
|
323
|
+
RequestParameterBuilder.addScopes(parameters, request.scopes);
|
|
320
324
|
|
|
321
|
-
|
|
325
|
+
RequestParameterBuilder.addGrantType(parameters, GrantType.JWT_BEARER);
|
|
322
326
|
|
|
323
|
-
|
|
327
|
+
RequestParameterBuilder.addClientInfo(parameters);
|
|
324
328
|
|
|
325
|
-
|
|
326
|
-
|
|
329
|
+
RequestParameterBuilder.addLibraryInfo(
|
|
330
|
+
parameters,
|
|
331
|
+
this.config.libraryInfo
|
|
332
|
+
);
|
|
333
|
+
RequestParameterBuilder.addApplicationTelemetry(
|
|
334
|
+
parameters,
|
|
327
335
|
this.config.telemetry.application
|
|
328
336
|
);
|
|
329
|
-
|
|
337
|
+
RequestParameterBuilder.addThrottling(parameters);
|
|
330
338
|
|
|
331
339
|
if (this.serverTelemetryManager) {
|
|
332
|
-
|
|
340
|
+
RequestParameterBuilder.addServerTelemetry(
|
|
341
|
+
parameters,
|
|
342
|
+
this.serverTelemetryManager
|
|
343
|
+
);
|
|
333
344
|
}
|
|
334
345
|
|
|
335
346
|
const correlationId =
|
|
336
347
|
request.correlationId ||
|
|
337
348
|
this.config.cryptoInterface.createNewGuid();
|
|
338
|
-
|
|
349
|
+
RequestParameterBuilder.addCorrelationId(parameters, correlationId);
|
|
339
350
|
|
|
340
|
-
|
|
351
|
+
RequestParameterBuilder.addRequestTokenUse(
|
|
352
|
+
parameters,
|
|
353
|
+
AADServerParamKeys.ON_BEHALF_OF
|
|
354
|
+
);
|
|
341
355
|
|
|
342
|
-
|
|
356
|
+
RequestParameterBuilder.addOboAssertion(
|
|
357
|
+
parameters,
|
|
358
|
+
request.oboAssertion
|
|
359
|
+
);
|
|
343
360
|
|
|
344
361
|
if (this.config.clientCredentials.clientSecret) {
|
|
345
|
-
|
|
362
|
+
RequestParameterBuilder.addClientSecret(
|
|
363
|
+
parameters,
|
|
346
364
|
this.config.clientCredentials.clientSecret
|
|
347
365
|
);
|
|
348
366
|
}
|
|
@@ -351,14 +369,16 @@ export class OnBehalfOfClient extends BaseClient {
|
|
|
351
369
|
this.config.clientCredentials.clientAssertion;
|
|
352
370
|
|
|
353
371
|
if (clientAssertion) {
|
|
354
|
-
|
|
372
|
+
RequestParameterBuilder.addClientAssertion(
|
|
373
|
+
parameters,
|
|
355
374
|
await getClientAssertion(
|
|
356
375
|
clientAssertion.assertion,
|
|
357
376
|
this.config.authOptions.clientId,
|
|
358
377
|
request.resourceRequestUri
|
|
359
378
|
)
|
|
360
379
|
);
|
|
361
|
-
|
|
380
|
+
RequestParameterBuilder.addClientAssertionType(
|
|
381
|
+
parameters,
|
|
362
382
|
clientAssertion.assertionType
|
|
363
383
|
);
|
|
364
384
|
}
|
|
@@ -368,12 +388,13 @@ export class OnBehalfOfClient extends BaseClient {
|
|
|
368
388
|
(this.config.authOptions.clientCapabilities &&
|
|
369
389
|
this.config.authOptions.clientCapabilities.length > 0)
|
|
370
390
|
) {
|
|
371
|
-
|
|
391
|
+
RequestParameterBuilder.addClaims(
|
|
392
|
+
parameters,
|
|
372
393
|
request.claims,
|
|
373
394
|
this.config.authOptions.clientCapabilities
|
|
374
395
|
);
|
|
375
396
|
}
|
|
376
397
|
|
|
377
|
-
return
|
|
398
|
+
return UrlUtils.mapToQueryString(parameters);
|
|
378
399
|
}
|
|
379
400
|
}
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
NativeSignOutRequest,
|
|
22
22
|
AccountInfo,
|
|
23
23
|
INativeBrokerPlugin,
|
|
24
|
-
|
|
24
|
+
AuthorizeResponse,
|
|
25
25
|
AADServerParamKeys,
|
|
26
26
|
ServerTelemetryManager,
|
|
27
27
|
} from "@azure/msal-common/node";
|
|
@@ -113,14 +113,18 @@ export class PublicClientApplication
|
|
|
113
113
|
validRequest.correlationId
|
|
114
114
|
);
|
|
115
115
|
try {
|
|
116
|
-
const
|
|
116
|
+
const discoveredAuthority = await this.createAuthority(
|
|
117
117
|
validRequest.authority,
|
|
118
118
|
validRequest.correlationId,
|
|
119
|
-
"",
|
|
120
|
-
serverTelemetryManager,
|
|
121
119
|
undefined,
|
|
122
120
|
request.azureCloudOptions
|
|
123
121
|
);
|
|
122
|
+
const deviceCodeConfig = await this.buildOauthClientConfiguration(
|
|
123
|
+
discoveredAuthority,
|
|
124
|
+
validRequest.correlationId,
|
|
125
|
+
"",
|
|
126
|
+
serverTelemetryManager
|
|
127
|
+
);
|
|
124
128
|
const deviceCodeClient = new DeviceCodeClient(deviceCodeConfig);
|
|
125
129
|
this.logger.verbose(
|
|
126
130
|
"Device code client created",
|
|
@@ -181,7 +185,7 @@ export class PublicClientApplication
|
|
|
181
185
|
const loopbackClient: ILoopbackClient =
|
|
182
186
|
customLoopbackClient || new LoopbackClient();
|
|
183
187
|
|
|
184
|
-
let authCodeResponse:
|
|
188
|
+
let authCodeResponse: AuthorizeResponse = {};
|
|
185
189
|
let authCodeListenerError: AuthError | null = null;
|
|
186
190
|
try {
|
|
187
191
|
const authCodeListener = loopbackClient
|
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
StringUtils,
|
|
21
21
|
TimeUtils,
|
|
22
22
|
UrlString,
|
|
23
|
+
UrlUtils,
|
|
23
24
|
getClientAssertion,
|
|
24
25
|
} from "@azure/msal-common/node";
|
|
25
26
|
|
|
@@ -118,36 +119,50 @@ export class UsernamePasswordClient extends BaseClient {
|
|
|
118
119
|
private async createTokenRequestBody(
|
|
119
120
|
request: CommonUsernamePasswordRequest
|
|
120
121
|
): Promise<string> {
|
|
121
|
-
const
|
|
122
|
+
const parameters = new Map<string, string>();
|
|
122
123
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
124
|
+
RequestParameterBuilder.addClientId(
|
|
125
|
+
parameters,
|
|
126
|
+
this.config.authOptions.clientId
|
|
127
|
+
);
|
|
128
|
+
RequestParameterBuilder.addUsername(parameters, request.username);
|
|
129
|
+
RequestParameterBuilder.addPassword(parameters, request.password);
|
|
126
130
|
|
|
127
|
-
|
|
131
|
+
RequestParameterBuilder.addScopes(parameters, request.scopes);
|
|
128
132
|
|
|
129
|
-
|
|
133
|
+
RequestParameterBuilder.addResponseTypeForTokenAndIdToken(parameters);
|
|
130
134
|
|
|
131
|
-
|
|
132
|
-
|
|
135
|
+
RequestParameterBuilder.addGrantType(
|
|
136
|
+
parameters,
|
|
137
|
+
GrantType.RESOURCE_OWNER_PASSWORD_GRANT
|
|
138
|
+
);
|
|
139
|
+
RequestParameterBuilder.addClientInfo(parameters);
|
|
133
140
|
|
|
134
|
-
|
|
135
|
-
|
|
141
|
+
RequestParameterBuilder.addLibraryInfo(
|
|
142
|
+
parameters,
|
|
143
|
+
this.config.libraryInfo
|
|
144
|
+
);
|
|
145
|
+
RequestParameterBuilder.addApplicationTelemetry(
|
|
146
|
+
parameters,
|
|
136
147
|
this.config.telemetry.application
|
|
137
148
|
);
|
|
138
|
-
|
|
149
|
+
RequestParameterBuilder.addThrottling(parameters);
|
|
139
150
|
|
|
140
151
|
if (this.serverTelemetryManager) {
|
|
141
|
-
|
|
152
|
+
RequestParameterBuilder.addServerTelemetry(
|
|
153
|
+
parameters,
|
|
154
|
+
this.serverTelemetryManager
|
|
155
|
+
);
|
|
142
156
|
}
|
|
143
157
|
|
|
144
158
|
const correlationId =
|
|
145
159
|
request.correlationId ||
|
|
146
160
|
this.config.cryptoInterface.createNewGuid();
|
|
147
|
-
|
|
161
|
+
RequestParameterBuilder.addCorrelationId(parameters, correlationId);
|
|
148
162
|
|
|
149
163
|
if (this.config.clientCredentials.clientSecret) {
|
|
150
|
-
|
|
164
|
+
RequestParameterBuilder.addClientSecret(
|
|
165
|
+
parameters,
|
|
151
166
|
this.config.clientCredentials.clientSecret
|
|
152
167
|
);
|
|
153
168
|
}
|
|
@@ -156,14 +171,16 @@ export class UsernamePasswordClient extends BaseClient {
|
|
|
156
171
|
this.config.clientCredentials.clientAssertion;
|
|
157
172
|
|
|
158
173
|
if (clientAssertion) {
|
|
159
|
-
|
|
174
|
+
RequestParameterBuilder.addClientAssertion(
|
|
175
|
+
parameters,
|
|
160
176
|
await getClientAssertion(
|
|
161
177
|
clientAssertion.assertion,
|
|
162
178
|
this.config.authOptions.clientId,
|
|
163
179
|
request.resourceRequestUri
|
|
164
180
|
)
|
|
165
181
|
);
|
|
166
|
-
|
|
182
|
+
RequestParameterBuilder.addClientAssertionType(
|
|
183
|
+
parameters,
|
|
167
184
|
clientAssertion.assertionType
|
|
168
185
|
);
|
|
169
186
|
}
|
|
@@ -173,7 +190,8 @@ export class UsernamePasswordClient extends BaseClient {
|
|
|
173
190
|
(this.config.authOptions.clientCapabilities &&
|
|
174
191
|
this.config.authOptions.clientCapabilities.length > 0)
|
|
175
192
|
) {
|
|
176
|
-
|
|
193
|
+
RequestParameterBuilder.addClaims(
|
|
194
|
+
parameters,
|
|
177
195
|
request.claims,
|
|
178
196
|
this.config.authOptions.clientCapabilities
|
|
179
197
|
);
|
|
@@ -183,9 +201,9 @@ export class UsernamePasswordClient extends BaseClient {
|
|
|
183
201
|
this.config.systemOptions.preventCorsPreflight &&
|
|
184
202
|
request.username
|
|
185
203
|
) {
|
|
186
|
-
|
|
204
|
+
RequestParameterBuilder.addCcsUpn(parameters, request.username);
|
|
187
205
|
}
|
|
188
206
|
|
|
189
|
-
return
|
|
207
|
+
return UrlUtils.mapToQueryString(parameters);
|
|
190
208
|
}
|
|
191
209
|
}
|
|
@@ -20,13 +20,6 @@ import { HttpClient } from "../network/HttpClient.js";
|
|
|
20
20
|
import http from "http";
|
|
21
21
|
import https from "https";
|
|
22
22
|
import { ManagedIdentityId } from "./ManagedIdentityId.js";
|
|
23
|
-
import {
|
|
24
|
-
MANAGED_IDENTITY_HTTP_STATUS_CODES_TO_RETRY_ON,
|
|
25
|
-
MANAGED_IDENTITY_MAX_RETRIES,
|
|
26
|
-
MANAGED_IDENTITY_RETRY_DELAY,
|
|
27
|
-
} from "../utils/Constants.js";
|
|
28
|
-
import { LinearRetryPolicy } from "../retry/LinearRetryPolicy.js";
|
|
29
|
-
import { HttpClientWithRetries } from "../network/HttpClientWithRetries.js";
|
|
30
23
|
import { NodeAuthError } from "../error/NodeAuthError.js";
|
|
31
24
|
|
|
32
25
|
/**
|
|
@@ -251,6 +244,7 @@ export type ManagedIdentityNodeConfiguration = {
|
|
|
251
244
|
system: Required<
|
|
252
245
|
Pick<NodeSystemOptions, "loggerOptions" | "networkClient">
|
|
253
246
|
>;
|
|
247
|
+
disableInternalRetries: boolean;
|
|
254
248
|
};
|
|
255
249
|
|
|
256
250
|
export function buildManagedIdentityConfiguration({
|
|
@@ -276,24 +270,12 @@ export function buildManagedIdentityConfiguration({
|
|
|
276
270
|
);
|
|
277
271
|
}
|
|
278
272
|
|
|
279
|
-
// wrap the network client with a retry policy if the developer has not disabled the option to do so
|
|
280
|
-
if (!system?.disableInternalRetries) {
|
|
281
|
-
const linearRetryPolicy: LinearRetryPolicy = new LinearRetryPolicy(
|
|
282
|
-
MANAGED_IDENTITY_MAX_RETRIES,
|
|
283
|
-
MANAGED_IDENTITY_RETRY_DELAY,
|
|
284
|
-
MANAGED_IDENTITY_HTTP_STATUS_CODES_TO_RETRY_ON
|
|
285
|
-
);
|
|
286
|
-
networkClient = new HttpClientWithRetries(
|
|
287
|
-
networkClient,
|
|
288
|
-
linearRetryPolicy
|
|
289
|
-
);
|
|
290
|
-
}
|
|
291
|
-
|
|
292
273
|
return {
|
|
293
274
|
managedIdentityId: managedIdentityId,
|
|
294
275
|
system: {
|
|
295
276
|
loggerOptions,
|
|
296
277
|
networkClient,
|
|
297
278
|
},
|
|
279
|
+
disableInternalRetries: system?.disableInternalRetries || false,
|
|
298
280
|
};
|
|
299
281
|
}
|
|
@@ -3,8 +3,19 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
7
|
-
|
|
6
|
+
import {
|
|
7
|
+
RequestParameterBuilder,
|
|
8
|
+
UrlString,
|
|
9
|
+
UrlUtils,
|
|
10
|
+
} from "@azure/msal-common/node";
|
|
11
|
+
import {
|
|
12
|
+
HttpMethod,
|
|
13
|
+
MANAGED_IDENTITY_HTTP_STATUS_CODES_TO_RETRY_ON,
|
|
14
|
+
MANAGED_IDENTITY_MAX_RETRIES,
|
|
15
|
+
MANAGED_IDENTITY_RETRY_DELAY,
|
|
16
|
+
RetryPolicies,
|
|
17
|
+
} from "../utils/Constants.js";
|
|
18
|
+
import { LinearRetryPolicy } from "../retry/LinearRetryPolicy.js";
|
|
8
19
|
|
|
9
20
|
export class ManagedIdentityRequestParameters {
|
|
10
21
|
private _baseEndpoint: string;
|
|
@@ -12,23 +23,38 @@ export class ManagedIdentityRequestParameters {
|
|
|
12
23
|
public headers: Record<string, string>;
|
|
13
24
|
public bodyParameters: Record<string, string>;
|
|
14
25
|
public queryParameters: Record<string, string>;
|
|
26
|
+
public retryPolicy: RetryPolicies;
|
|
15
27
|
|
|
16
|
-
constructor(
|
|
28
|
+
constructor(
|
|
29
|
+
httpMethod: HttpMethod,
|
|
30
|
+
endpoint: string,
|
|
31
|
+
retryPolicy?: RetryPolicies
|
|
32
|
+
) {
|
|
17
33
|
this.httpMethod = httpMethod;
|
|
18
34
|
this._baseEndpoint = endpoint;
|
|
19
35
|
this.headers = {} as Record<string, string>;
|
|
20
36
|
this.bodyParameters = {} as Record<string, string>;
|
|
21
37
|
this.queryParameters = {} as Record<string, string>;
|
|
38
|
+
|
|
39
|
+
const defaultRetryPolicy: LinearRetryPolicy = new LinearRetryPolicy(
|
|
40
|
+
MANAGED_IDENTITY_MAX_RETRIES,
|
|
41
|
+
MANAGED_IDENTITY_RETRY_DELAY,
|
|
42
|
+
MANAGED_IDENTITY_HTTP_STATUS_CODES_TO_RETRY_ON
|
|
43
|
+
);
|
|
44
|
+
this.retryPolicy = retryPolicy || defaultRetryPolicy;
|
|
22
45
|
}
|
|
23
46
|
|
|
24
47
|
public computeUri(): string {
|
|
25
|
-
const
|
|
48
|
+
const parameters = new Map<string, string>();
|
|
26
49
|
|
|
27
50
|
if (this.queryParameters) {
|
|
28
|
-
|
|
51
|
+
RequestParameterBuilder.addExtraQueryParameters(
|
|
52
|
+
parameters,
|
|
53
|
+
this.queryParameters
|
|
54
|
+
);
|
|
29
55
|
}
|
|
30
56
|
|
|
31
|
-
const queryParametersString =
|
|
57
|
+
const queryParametersString = UrlUtils.mapToQueryString(parameters);
|
|
32
58
|
|
|
33
59
|
return UrlString.appendQueryString(
|
|
34
60
|
this._baseEndpoint,
|
|
@@ -37,12 +63,15 @@ export class ManagedIdentityRequestParameters {
|
|
|
37
63
|
}
|
|
38
64
|
|
|
39
65
|
public computeParametersBodyString(): string {
|
|
40
|
-
const
|
|
66
|
+
const parameters = new Map<string, string>();
|
|
41
67
|
|
|
42
68
|
if (this.bodyParameters) {
|
|
43
|
-
|
|
69
|
+
RequestParameterBuilder.addExtraQueryParameters(
|
|
70
|
+
parameters,
|
|
71
|
+
this.bodyParameters
|
|
72
|
+
);
|
|
44
73
|
}
|
|
45
74
|
|
|
46
|
-
return
|
|
75
|
+
return UrlUtils.mapToQueryString(parameters);
|
|
47
76
|
}
|
|
48
77
|
}
|
package/src/index.ts
CHANGED
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
* Warning: This set of exports is purely intended to be used by other MSAL libraries, and should be considered potentially unstable. We strongly discourage using them directly, you do so at your own risk.
|
|
13
13
|
* Breaking changes to these APIs will be shipped under a minor version, instead of a major version.
|
|
14
14
|
*/
|
|
15
|
-
|
|
16
15
|
import * as internals from "./internals.js";
|
|
17
16
|
export { internals };
|
|
18
17
|
|
|
@@ -87,7 +86,11 @@ export {
|
|
|
87
86
|
AuthorizationCodePayload,
|
|
88
87
|
// Response
|
|
89
88
|
AuthenticationResult,
|
|
90
|
-
|
|
89
|
+
AuthorizeResponse,
|
|
90
|
+
/**
|
|
91
|
+
* @deprecated Use AuthorizeResponse instead
|
|
92
|
+
*/
|
|
93
|
+
AuthorizeResponse as ServerAuthorizationCodeResponse,
|
|
91
94
|
IdTokenClaims,
|
|
92
95
|
// Cache
|
|
93
96
|
AccountInfo,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { AuthorizeResponse } from "@azure/msal-common/node";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Interface for LoopbackClient allowing to replace the default loopback server with a custom implementation.
|
|
@@ -13,7 +13,7 @@ export interface ILoopbackClient {
|
|
|
13
13
|
listenForAuthCode(
|
|
14
14
|
successTemplate?: string,
|
|
15
15
|
errorTemplate?: string
|
|
16
|
-
): Promise<
|
|
16
|
+
): Promise<AuthorizeResponse>;
|
|
17
17
|
getRedirectUri(): string;
|
|
18
18
|
closeServer(): void;
|
|
19
19
|
}
|