@azure/msal-node 7.1.1 → 7.2.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/CacheHelpers.mjs +1 -1
- 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/BaseClient.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.mjs +1 -1
- package/dist/client/DeviceCodeClient.mjs +1 -1
- package/dist/client/ManagedIdentityApplication.mjs +1 -1
- package/dist/client/ManagedIdentityClient.mjs +1 -1
- package/dist/client/ManagedIdentitySources/AppService.mjs +1 -1
- package/dist/client/ManagedIdentitySources/AzureArc.mjs +1 -1
- package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.mjs +1 -1
- package/dist/client/ManagedIdentitySources/CloudShell.mjs +1 -1
- package/dist/client/ManagedIdentitySources/Imds.mjs +1 -1
- package/dist/client/ManagedIdentitySources/MachineLearning.mjs +1 -1
- package/dist/client/ManagedIdentitySources/ServiceFabric.mjs +1 -1
- package/dist/client/OnBehalfOfClient.mjs +1 -1
- package/dist/client/PublicClientApplication.mjs +9 -3
- package/dist/client/PublicClientApplication.mjs.map +1 -1
- package/dist/client/SilentRequestCoalescer.mjs +1 -1
- package/dist/client/UserFederatedIdentityCredentialClient.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.mjs +1 -1
- package/dist/crypto/PkceGenerator.mjs +1 -1
- package/dist/error/ClientAuthErrorCodes.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.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/LoopbackClient.mjs +26 -4
- package/dist/network/LoopbackClient.mjs.map +1 -1
- package/dist/packageMetadata.mjs +2 -2
- package/dist/protocol/Authorize.mjs +1 -1
- package/dist/retry/DefaultManagedIdentityRetryPolicy.mjs +1 -1
- package/dist/retry/ExponentialRetryStrategy.mjs +1 -1
- package/dist/retry/ImdsRetryPolicy.mjs +1 -1
- package/dist/retry/LinearRetryStrategy.mjs +1 -1
- package/dist/utils/Constants.mjs +1 -1
- package/dist/utils/EncodingUtils.mjs +1 -1
- package/dist/utils/TimeUtils.mjs +1 -1
- package/lib/msal-node.cjs +294 -104
- package/lib/msal-node.cjs.map +1 -1
- package/package.json +2 -2
- package/src/client/PublicClientApplication.ts +18 -1
- package/src/network/LoopbackClient.ts +38 -0
- package/src/packageMetadata.ts +1 -1
- package/types/client/PublicClientApplication.d.ts.map +1 -1
- package/types/network/LoopbackClient.d.ts +6 -1
- package/types/network/LoopbackClient.d.ts.map +1 -1
- package/types/packageMetadata.d.ts +1 -1
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": "7.
|
|
4
|
+
"version": "7.2.0",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Microsoft",
|
|
7
7
|
"email": "nugetaad@microsoft.com",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"yargs": "^17.3.1"
|
|
81
81
|
},
|
|
82
82
|
"dependencies": {
|
|
83
|
-
"@azure/msal-common": "16.
|
|
83
|
+
"@azure/msal-common": "16.16.0",
|
|
84
84
|
"jsonwebtoken": "^9.0.0"
|
|
85
85
|
},
|
|
86
86
|
"engines": {
|
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
enforceResourceParameter,
|
|
25
25
|
createClientConfigurationError,
|
|
26
26
|
ClientConfigurationErrorCodes,
|
|
27
|
+
ProtocolUtils,
|
|
27
28
|
} from "@azure/msal-common/node";
|
|
28
29
|
import { Configuration } from "../config/Configuration.js";
|
|
29
30
|
import { ClientApplication } from "./ClientApplication.js";
|
|
@@ -220,11 +221,19 @@ export class PublicClientApplication
|
|
|
220
221
|
);
|
|
221
222
|
}
|
|
222
223
|
|
|
224
|
+
const state = ProtocolUtils.setRequestState(
|
|
225
|
+
this.cryptoProvider,
|
|
226
|
+
remainingProperties.state
|
|
227
|
+
? this.cryptoProvider.base64Encode(remainingProperties.state)
|
|
228
|
+
: remainingProperties.state,
|
|
229
|
+
undefined,
|
|
230
|
+
correlationId
|
|
231
|
+
);
|
|
223
232
|
let authCodeResponse: AuthorizeResponse = {};
|
|
224
233
|
let authCodeListenerError: AuthError | null = null;
|
|
225
234
|
try {
|
|
226
235
|
const authCodeListener = loopbackClient
|
|
227
|
-
.listenForAuthCode(successTemplate, errorTemplate)
|
|
236
|
+
.listenForAuthCode(state, successTemplate, errorTemplate)
|
|
228
237
|
.then((response) => {
|
|
229
238
|
authCodeResponse = response;
|
|
230
239
|
})
|
|
@@ -248,6 +257,7 @@ export class PublicClientApplication
|
|
|
248
257
|
codeChallenge: challenge,
|
|
249
258
|
codeChallengeMethod:
|
|
250
259
|
CommonConstants.CodeChallengeMethodValues.S256,
|
|
260
|
+
state,
|
|
251
261
|
};
|
|
252
262
|
|
|
253
263
|
const authCodeUrl = await this.getAuthCodeUrl(validRequest);
|
|
@@ -257,6 +267,12 @@ export class PublicClientApplication
|
|
|
257
267
|
throw authCodeListenerError;
|
|
258
268
|
}
|
|
259
269
|
|
|
270
|
+
this.validateState(
|
|
271
|
+
state,
|
|
272
|
+
authCodeResponse.state || "",
|
|
273
|
+
correlationId
|
|
274
|
+
);
|
|
275
|
+
|
|
260
276
|
if (authCodeResponse.error) {
|
|
261
277
|
throw new ServerError(
|
|
262
278
|
authCodeResponse.error,
|
|
@@ -276,6 +292,7 @@ export class PublicClientApplication
|
|
|
276
292
|
codeVerifier: verifier,
|
|
277
293
|
clientInfo: clientInfo || "",
|
|
278
294
|
...validRequest,
|
|
295
|
+
state: remainingProperties.state,
|
|
279
296
|
};
|
|
280
297
|
return await this.acquireTokenByCode(tokenRequest); // Await this so the server doesn't close prematurely
|
|
281
298
|
} finally {
|
|
@@ -22,17 +22,22 @@ export class LoopbackClient {
|
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* Spins up a loopback server which returns the server response when the localhost redirectUri is hit
|
|
25
|
+
* @param expectedState - State sent in the authorization request
|
|
25
26
|
* @param successTemplate
|
|
26
27
|
* @param errorTemplate
|
|
27
28
|
* @returns
|
|
28
29
|
*/
|
|
29
30
|
async listenForAuthCode(
|
|
31
|
+
expectedState: string,
|
|
30
32
|
successTemplate?: string,
|
|
31
33
|
errorTemplate?: string
|
|
32
34
|
): Promise<AuthorizeResponse> {
|
|
33
35
|
if (this.server) {
|
|
34
36
|
throw NodeAuthError.createLoopbackServerAlreadyExistsError();
|
|
35
37
|
}
|
|
38
|
+
if (!expectedState) {
|
|
39
|
+
throw NodeAuthError.createStateNotFoundError("");
|
|
40
|
+
}
|
|
36
41
|
|
|
37
42
|
return new Promise<AuthorizeResponse>((resolve, reject) => {
|
|
38
43
|
this.server = http.createServer(
|
|
@@ -64,6 +69,7 @@ export class LoopbackClient {
|
|
|
64
69
|
req,
|
|
65
70
|
res,
|
|
66
71
|
resolve,
|
|
72
|
+
expectedState,
|
|
67
73
|
successTemplate,
|
|
68
74
|
errorTemplate
|
|
69
75
|
);
|
|
@@ -96,6 +102,17 @@ export class LoopbackClient {
|
|
|
96
102
|
return;
|
|
97
103
|
}
|
|
98
104
|
|
|
105
|
+
if (
|
|
106
|
+
!this.isExpectedState(
|
|
107
|
+
parsedUrl.searchParams,
|
|
108
|
+
expectedState
|
|
109
|
+
)
|
|
110
|
+
) {
|
|
111
|
+
res.writeHead(400);
|
|
112
|
+
res.end("Invalid authorization response state.");
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
|
|
99
116
|
res.writeHead(400);
|
|
100
117
|
res.end(
|
|
101
118
|
"OAuth responses must use form_post and cannot be returned in the URL."
|
|
@@ -139,6 +156,7 @@ export class LoopbackClient {
|
|
|
139
156
|
req: http.IncomingMessage,
|
|
140
157
|
res: http.ServerResponse,
|
|
141
158
|
resolve: (value: AuthorizeResponse) => void,
|
|
159
|
+
expectedState: string,
|
|
142
160
|
successTemplate?: string,
|
|
143
161
|
errorTemplate?: string
|
|
144
162
|
): void {
|
|
@@ -171,6 +189,15 @@ export class LoopbackClient {
|
|
|
171
189
|
return;
|
|
172
190
|
}
|
|
173
191
|
|
|
192
|
+
// Unrelated callbacks must not settle or cancel the pending sign-in.
|
|
193
|
+
if (
|
|
194
|
+
!this.isExpectedState(new URLSearchParams(body), expectedState)
|
|
195
|
+
) {
|
|
196
|
+
res.writeHead(400);
|
|
197
|
+
res.end("Invalid authorization response state.");
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
|
|
174
201
|
if (authCodeResponse.error) {
|
|
175
202
|
res.writeHead(200);
|
|
176
203
|
res.end(
|
|
@@ -187,6 +214,17 @@ export class LoopbackClient {
|
|
|
187
214
|
});
|
|
188
215
|
}
|
|
189
216
|
|
|
217
|
+
/**
|
|
218
|
+
* Requires exactly one state value matching the pending authorization request.
|
|
219
|
+
*/
|
|
220
|
+
private isExpectedState(
|
|
221
|
+
parameters: URLSearchParams,
|
|
222
|
+
expectedState: string
|
|
223
|
+
): boolean {
|
|
224
|
+
const states = parameters.getAll("state");
|
|
225
|
+
return states.length === 1 && states[0] === expectedState;
|
|
226
|
+
}
|
|
227
|
+
|
|
190
228
|
/**
|
|
191
229
|
* Get the port that the loopback server is running on
|
|
192
230
|
* @returns
|
package/src/packageMetadata.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PublicClientApplication.d.ts","sourceRoot":"","sources":["../../src/client/PublicClientApplication.ts"],"names":[],"mappings":"AAUA,OAAO,EACH,oBAAoB,EAMpB,WAAW,EAKX,wBAAwB,
|
|
1
|
+
{"version":3,"file":"PublicClientApplication.d.ts","sourceRoot":"","sources":["../../src/client/PublicClientApplication.ts"],"names":[],"mappings":"AAUA,OAAO,EACH,oBAAoB,EAMpB,WAAW,EAKX,wBAAwB,EAK3B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAGpE,OAAO,EAAE,wBAAwB,EAAE,MAAM,wCAAwC,CAAC;AAClF,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAGtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AASxE;;;;GAIG;AACH,qBAAa,uBACT,SAAQ,iBACR,YAAW,wBAAwB;IAEnC,OAAO,CAAC,kBAAkB,CAAC,CAAsB;IACjD,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAS;IAC9B;;;;;;;;;;;;;;;;OAgBG;gBACS,aAAa,EAAE,aAAa;IAqBxC;;;;;;;;OAQG;IACU,wBAAwB,CACjC,OAAO,EAAE,iBAAiB,GAC3B,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;IA0CvC;;OAEG;IACG,uBAAuB,CACzB,OAAO,EAAE,kBAAkB,GAC5B,OAAO,CAAC,oBAAoB,CAAC;IAkJhC;;;;OAIG;IACG,kBAAkB,CACpB,OAAO,EAAE,iBAAiB,GAC3B,OAAO,CAAC,oBAAoB,CAAC;IAiDhC;;;OAGG;IACG,kBAAkB,CACpB,OAAO,EAAE,wBAAwB,EACjC,eAAe,CAAC,EAAE,wBAAwB,GAC3C,OAAO,CAAC,oBAAoB,CAAC;IAKhC;;;OAGG;IACG,0BAA0B,CAC5B,OAAO,EAAE,mBAAmB,GAC7B,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;IAKvC;;;;OAIG;IACG,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAkBrD;;;OAGG;IACG,cAAc,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;IAY9C;;;;;OAKG;YACW,kBAAkB;CA2CnC"}
|
|
@@ -5,15 +5,20 @@ export declare class LoopbackClient {
|
|
|
5
5
|
constructor(preferredPort?: number);
|
|
6
6
|
/**
|
|
7
7
|
* Spins up a loopback server which returns the server response when the localhost redirectUri is hit
|
|
8
|
+
* @param expectedState - State sent in the authorization request
|
|
8
9
|
* @param successTemplate
|
|
9
10
|
* @param errorTemplate
|
|
10
11
|
* @returns
|
|
11
12
|
*/
|
|
12
|
-
listenForAuthCode(successTemplate?: string, errorTemplate?: string): Promise<AuthorizeResponse>;
|
|
13
|
+
listenForAuthCode(expectedState: string, successTemplate?: string, errorTemplate?: string): Promise<AuthorizeResponse>;
|
|
13
14
|
/**
|
|
14
15
|
* Handles POST requests for form_post response mode
|
|
15
16
|
*/
|
|
16
17
|
private handlePostRequest;
|
|
18
|
+
/**
|
|
19
|
+
* Requires exactly one state value matching the pending authorization request.
|
|
20
|
+
*/
|
|
21
|
+
private isExpectedState;
|
|
17
22
|
/**
|
|
18
23
|
* Get the port that the loopback server is running on
|
|
19
24
|
* @returns
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LoopbackClient.d.ts","sourceRoot":"","sources":["../../src/network/LoopbackClient.ts"],"names":[],"mappings":"AAKA,OAAO,EACH,iBAAiB,EAGpB,MAAM,yBAAyB,CAAC;AAKjC,qBAAa,cAAc;IACvB,OAAO,CAAC,MAAM,CAA0B;IACxC,OAAO,CAAC,aAAa,CAAqB;gBAE9B,aAAa,CAAC,EAAE,MAAM;IAIlC
|
|
1
|
+
{"version":3,"file":"LoopbackClient.d.ts","sourceRoot":"","sources":["../../src/network/LoopbackClient.ts"],"names":[],"mappings":"AAKA,OAAO,EACH,iBAAiB,EAGpB,MAAM,yBAAyB,CAAC;AAKjC,qBAAa,cAAc;IACvB,OAAO,CAAC,MAAM,CAA0B;IACxC,OAAO,CAAC,aAAa,CAAqB;gBAE9B,aAAa,CAAC,EAAE,MAAM;IAIlC;;;;;;OAMG;IACG,iBAAiB,CACnB,aAAa,EAAE,MAAM,EACrB,eAAe,CAAC,EAAE,MAAM,EACxB,aAAa,CAAC,EAAE,MAAM,GACvB,OAAO,CAAC,iBAAiB,CAAC;IAsH7B;;OAEG;IACH,OAAO,CAAC,iBAAiB;IA8DzB;;OAEG;IACH,OAAO,CAAC,eAAe;IAQvB;;;OAGG;IACH,cAAc,IAAI,MAAM;IAgBxB;;OAEG;IACH,WAAW,IAAI,IAAI;CAetB"}
|