@azure/msal-node 1.3.2 → 1.6.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/CHANGELOG.json +1027 -907
- package/CHANGELOG.md +333 -297
- package/LICENSE +21 -21
- package/README.md +183 -182
- package/dist/cache/NodeStorage.d.ts +5 -1
- package/dist/cache/NodeStorage.d.ts.map +1 -1
- package/dist/cache/distributed/DistributedCachePlugin.d.ts +11 -0
- package/dist/cache/distributed/DistributedCachePlugin.d.ts.map +1 -0
- package/dist/cache/distributed/ICacheClient.d.ts +18 -0
- package/dist/cache/distributed/ICacheClient.d.ts.map +1 -0
- package/dist/cache/distributed/IPartitionManager.d.ts +33 -0
- package/dist/cache/distributed/IPartitionManager.d.ts.map +1 -0
- package/dist/client/ClientApplication.d.ts +2 -2
- package/dist/client/ClientApplication.d.ts.map +1 -1
- package/dist/client/ConfidentialClientApplication.d.ts.map +1 -1
- package/dist/client/PublicClientApplication.d.ts.map +1 -1
- package/dist/config/Configuration.d.ts +3 -1
- package/dist/config/Configuration.d.ts.map +1 -1
- package/dist/crypto/CryptoProvider.d.ts +4 -0
- package/dist/crypto/CryptoProvider.d.ts.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/msal-node.cjs.development.js +117 -21
- package/dist/msal-node.cjs.development.js.map +1 -1
- package/dist/msal-node.cjs.production.min.js +1 -1
- package/dist/msal-node.cjs.production.min.js.map +1 -1
- package/dist/msal-node.esm.js +113 -24
- package/dist/msal-node.esm.js.map +1 -1
- package/dist/network/HttpClient.d.ts.map +1 -1
- package/dist/packageMetadata.d.ts +1 -1
- package/dist/request/AuthorizationCodeRequest.d.ts +1 -1
- package/dist/request/AuthorizationCodeRequest.d.ts.map +1 -1
- package/dist/request/AuthorizationUrlRequest.d.ts +1 -1
- package/dist/request/AuthorizationUrlRequest.d.ts.map +1 -1
- package/dist/request/ClientCredentialRequest.d.ts +1 -1
- package/dist/request/ClientCredentialRequest.d.ts.map +1 -1
- package/dist/request/DeviceCodeRequest.d.ts +1 -1
- package/dist/request/DeviceCodeRequest.d.ts.map +1 -1
- package/dist/request/OnBehalfOfRequest.d.ts +1 -1
- package/dist/request/OnBehalfOfRequest.d.ts.map +1 -1
- package/dist/request/RefreshTokenRequest.d.ts +1 -1
- package/dist/request/RefreshTokenRequest.d.ts.map +1 -1
- package/dist/request/SilentFlowRequest.d.ts +1 -1
- package/dist/request/SilentFlowRequest.d.ts.map +1 -1
- package/dist/request/UsernamePasswordRequest.d.ts +1 -1
- package/dist/request/UsernamePasswordRequest.d.ts.map +1 -1
- package/package.json +70 -82
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Configuration.d.ts","sourceRoot":"","sources":["../src/config/Configuration.ts"],"names":[],"mappings":"AAKA,OAAO,EACH,aAAa,EACb,cAAc,EAEd,YAAY,EACZ,YAAY,
|
|
1
|
+
{"version":3,"file":"Configuration.d.ts","sourceRoot":"","sources":["../src/config/Configuration.ts"],"names":[],"mappings":"AAKA,OAAO,EACH,aAAa,EACb,cAAc,EAEd,YAAY,EACZ,YAAY,EAGZ,iBAAiB,EACpB,MAAM,oBAAoB,CAAC;AAG5B;;;;;;;;;GASG;AACH,oBAAY,eAAe,GAAG;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAAC,MAAM,CAAC;IACxB,iBAAiB,CAAC,EAAE;QAChB,UAAU,EAAE,MAAM,CAAC;QACnB,UAAU,EAAE,MAAM,CAAC;QACnB,GAAG,CAAC,EAAE,MAAM,CAAA;KACf,CAAC;IACF,gBAAgB,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACjC,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,kBAAkB,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACnC,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACzC,CAAC;AAEF;;;;;GAKG;AACH,oBAAY,YAAY,GAAG;IACvB,WAAW,CAAC,EAAE,YAAY,CAAC;CAC9B,CAAC;AAEF;;;;;;GAMG;AACH,oBAAY,iBAAiB,GAAG;IAC5B,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,aAAa,CAAC,EAAE,cAAc,CAAC;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;;;;;;GAOG;AACH,oBAAY,aAAa,GAAG;IACxB,IAAI,EAAE,eAAe,CAAC;IACtB,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,MAAM,CAAC,EAAE,iBAAiB,CAAC;CAC9B,CAAC;AAuCF,oBAAY,iBAAiB,GAAG;IAC5B,IAAI,EAAE,QAAQ,CAAC,eAAe,CAAC,CAAC;IAChC,KAAK,EAAE,YAAY,CAAC;IACpB,MAAM,EAAE,QAAQ,CAAC,iBAAiB,CAAC,CAAC;CACvC,CAAC;AAEF;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CAAC,EAClC,IAAI,EACJ,KAAK,EACL,MAAM,GACT,EAAE,aAAa,GAAG,iBAAiB,CAOnC"}
|
|
@@ -43,5 +43,9 @@ export declare class CryptoProvider implements ICrypto {
|
|
|
43
43
|
* Signs the given object as a jwt payload with private key retrieved by given kid - currently not implemented for node
|
|
44
44
|
*/
|
|
45
45
|
signJwt(): Promise<string>;
|
|
46
|
+
/**
|
|
47
|
+
* Returns the SHA-256 hash of an input string
|
|
48
|
+
*/
|
|
49
|
+
hashString(): Promise<string>;
|
|
46
50
|
}
|
|
47
51
|
//# sourceMappingURL=CryptoProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CryptoProvider.d.ts","sourceRoot":"","sources":["../src/crypto/CryptoProvider.ts"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AIjC;;OAEG;IACH,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC;IAI1B;;OAEG;IACH,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC;CAGhC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
export { IPublicClientApplication } from "./client/IPublicClientApplication";
|
|
6
6
|
export { IConfidentialClientApplication } from "./client/IConfidentialClientApplication";
|
|
7
7
|
export { ITokenCache } from "./cache/ITokenCache";
|
|
8
|
+
export { ICacheClient } from "./cache/distributed/ICacheClient";
|
|
9
|
+
export { IPartitionManager } from "./cache/distributed/IPartitionManager";
|
|
8
10
|
export { PublicClientApplication } from "./client/PublicClientApplication";
|
|
9
11
|
export { ConfidentialClientApplication } from "./client/ConfidentialClientApplication";
|
|
10
12
|
export { ClientApplication } from "./client/ClientApplication";
|
|
@@ -13,6 +15,7 @@ export { ClientAssertion } from "./client/ClientAssertion";
|
|
|
13
15
|
export { TokenCache } from "./cache/TokenCache";
|
|
14
16
|
export { NodeStorage } from "./cache/NodeStorage";
|
|
15
17
|
export { CacheKVStore, JsonCache, InMemoryCache, SerializedAccountEntity, SerializedIdTokenEntity, SerializedAccessTokenEntity, SerializedAppMetadataEntity, SerializedRefreshTokenEntity } from "./cache/serializer/SerializerTypes";
|
|
18
|
+
export { DistributedCachePlugin } from "./cache/distributed/DistributedCachePlugin";
|
|
16
19
|
export { CryptoProvider } from "./crypto/CryptoProvider";
|
|
17
20
|
export type { AuthorizationCodeRequest } from "./request/AuthorizationCodeRequest";
|
|
18
21
|
export type { AuthorizationUrlRequest } from "./request/AuthorizationUrlRequest";
|
|
@@ -22,6 +25,6 @@ export type { OnBehalfOfRequest } from "./request/OnBehalfOfRequest";
|
|
|
22
25
|
export type { UsernamePasswordRequest } from "./request/UsernamePasswordRequest";
|
|
23
26
|
export type { RefreshTokenRequest } from "./request/RefreshTokenRequest";
|
|
24
27
|
export type { SilentFlowRequest } from "./request/SilentFlowRequest";
|
|
25
|
-
export { PromptValue, ResponseMode, AuthenticationResult, AccountInfo, ValidCacheType, AuthError, AuthErrorMessage, ClientAuthError, ClientAuthErrorMessage, ClientConfigurationError, ClientConfigurationErrorMessage, InteractionRequiredAuthError, InteractionRequiredAuthErrorMessage, ServerError, INetworkModule, NetworkRequestOptions, NetworkResponse, Logger, LogLevel, ProtocolMode, ICachePlugin, TokenCacheContext, ISerializableTokenCache } from "@azure/msal-common";
|
|
28
|
+
export { PromptValue, ResponseMode, AuthenticationResult, AccountInfo, ValidCacheType, AuthError, AuthErrorMessage, ClientAuthError, ClientAuthErrorMessage, ClientConfigurationError, ClientConfigurationErrorMessage, InteractionRequiredAuthError, InteractionRequiredAuthErrorMessage, ServerError, INetworkModule, NetworkRequestOptions, NetworkResponse, Logger, LogLevel, ProtocolMode, ICachePlugin, TokenCacheContext, ISerializableTokenCache, AzureCloudInstance, AzureCloudOptions } from "@azure/msal-common";
|
|
26
29
|
export { version } from "./packageMetadata";
|
|
27
30
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAKA;;;GAGG;AAGH,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAC7E,OAAO,EAAE,8BAA8B,EAAE,MAAM,yCAAyC,CAAC;AACzF,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAKA;;;GAGG;AAGH,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAC7E,OAAO,EAAE,8BAA8B,EAAE,MAAM,yCAAyC,CAAC;AACzF,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,E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gB,EAChB,eAAe,EACf,sBAAsB,EACtB,wBAAwB,EACxB,+BAA+B,EAC/B,4BAA4B,EAC5B,mCAAmC,EACnC,WAAW,EAEX,cAAc,EACd,qBAAqB,EACrB,eAAe,EAEf,MAAM,EACN,QAAQ,EAER,YAAY,EACZ,YAAY,EACZ,iBAAiB,EACjB,uBAAuB,EAEvB,kBAAkB,EAClB,iBAAiB,EACpB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -6,6 +6,7 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'defau
|
|
|
6
6
|
|
|
7
7
|
var msalCommon = require('@azure/msal-common');
|
|
8
8
|
var axios = _interopDefault(require('axios'));
|
|
9
|
+
var createHttpsProxyAgent = _interopDefault(require('https-proxy-agent'));
|
|
9
10
|
var uuid = require('uuid');
|
|
10
11
|
var crypto = _interopDefault(require('crypto'));
|
|
11
12
|
var jsonwebtoken = require('jsonwebtoken');
|
|
@@ -118,6 +119,13 @@ class HttpClient {
|
|
|
118
119
|
/* istanbul ignore next */
|
|
119
120
|
validateStatus: () => true
|
|
120
121
|
};
|
|
122
|
+
|
|
123
|
+
if (options && options.proxyUrl) {
|
|
124
|
+
// for axios, this has to be disabled
|
|
125
|
+
request.proxy = false;
|
|
126
|
+
request.httpsAgent = createHttpsProxyAgent(options.proxyUrl);
|
|
127
|
+
}
|
|
128
|
+
|
|
121
129
|
const response = await axios(request);
|
|
122
130
|
return {
|
|
123
131
|
headers: response.headers,
|
|
@@ -147,6 +155,13 @@ class HttpClient {
|
|
|
147
155
|
/* istanbul ignore next */
|
|
148
156
|
validateStatus: () => true
|
|
149
157
|
};
|
|
158
|
+
|
|
159
|
+
if (options && options.proxyUrl) {
|
|
160
|
+
// for axios, this has to be disabled
|
|
161
|
+
request.proxy = false;
|
|
162
|
+
request.httpsAgent = createHttpsProxyAgent(options.proxyUrl);
|
|
163
|
+
}
|
|
164
|
+
|
|
150
165
|
const response = await axios(request);
|
|
151
166
|
return {
|
|
152
167
|
headers: response.headers,
|
|
@@ -189,7 +204,11 @@ const DEFAULT_AUTH_OPTIONS = {
|
|
|
189
204
|
cloudDiscoveryMetadata: "",
|
|
190
205
|
authorityMetadata: "",
|
|
191
206
|
clientCapabilities: [],
|
|
192
|
-
protocolMode: msalCommon.ProtocolMode.AAD
|
|
207
|
+
protocolMode: msalCommon.ProtocolMode.AAD,
|
|
208
|
+
azureCloudOptions: {
|
|
209
|
+
azureCloudInstance: msalCommon.AzureCloudInstance.None,
|
|
210
|
+
tenant: ""
|
|
211
|
+
}
|
|
193
212
|
};
|
|
194
213
|
const DEFAULT_CACHE_OPTIONS = {};
|
|
195
214
|
const DEFAULT_LOGGER_OPTIONS = {
|
|
@@ -200,7 +219,8 @@ const DEFAULT_LOGGER_OPTIONS = {
|
|
|
200
219
|
};
|
|
201
220
|
const DEFAULT_SYSTEM_OPTIONS = {
|
|
202
221
|
loggerOptions: DEFAULT_LOGGER_OPTIONS,
|
|
203
|
-
networkClient: /*#__PURE__*/NetworkUtils.getNetworkClient()
|
|
222
|
+
networkClient: /*#__PURE__*/NetworkUtils.getNetworkClient(),
|
|
223
|
+
proxyUrl: ""
|
|
204
224
|
};
|
|
205
225
|
/**
|
|
206
226
|
* Sets the default options when not explicitly configured from app developer
|
|
@@ -460,6 +480,14 @@ class CryptoProvider {
|
|
|
460
480
|
signJwt() {
|
|
461
481
|
throw new Error("Method not implemented.");
|
|
462
482
|
}
|
|
483
|
+
/**
|
|
484
|
+
* Returns the SHA-256 hash of an input string
|
|
485
|
+
*/
|
|
486
|
+
|
|
487
|
+
|
|
488
|
+
hashString() {
|
|
489
|
+
throw new Error("Method not implemented.");
|
|
490
|
+
}
|
|
463
491
|
|
|
464
492
|
}
|
|
465
493
|
|
|
@@ -1237,6 +1265,29 @@ class NodeStorage extends msalCommon.CacheManager {
|
|
|
1237
1265
|
static generateJsonCache(inMemoryCache) {
|
|
1238
1266
|
return Serializer.serializeAllCache(inMemoryCache);
|
|
1239
1267
|
}
|
|
1268
|
+
/**
|
|
1269
|
+
* Updates a credential's cache key if the current cache key is outdated
|
|
1270
|
+
*/
|
|
1271
|
+
|
|
1272
|
+
|
|
1273
|
+
updateCredentialCacheKey(currentCacheKey, credential) {
|
|
1274
|
+
const updatedCacheKey = credential.generateCredentialKey();
|
|
1275
|
+
|
|
1276
|
+
if (currentCacheKey !== updatedCacheKey) {
|
|
1277
|
+
const cacheItem = this.getItem(currentCacheKey);
|
|
1278
|
+
|
|
1279
|
+
if (cacheItem) {
|
|
1280
|
+
this.removeItem(currentCacheKey);
|
|
1281
|
+
this.setItem(updatedCacheKey, cacheItem);
|
|
1282
|
+
this.logger.verbose(`Updated an outdated ${credential.credentialType} cache key`);
|
|
1283
|
+
return updatedCacheKey;
|
|
1284
|
+
} else {
|
|
1285
|
+
this.logger.error(`Attempted to update an outdated ${credential.credentialType} cache key but no item matching the outdated key was found in storage`);
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1289
|
+
return currentCacheKey;
|
|
1290
|
+
}
|
|
1240
1291
|
|
|
1241
1292
|
}
|
|
1242
1293
|
|
|
@@ -1522,7 +1573,7 @@ class TokenCache {
|
|
|
1522
1573
|
|
|
1523
1574
|
/* eslint-disable header/header */
|
|
1524
1575
|
const name = "@azure/msal-node";
|
|
1525
|
-
const version = "1.
|
|
1576
|
+
const version = "1.6.0";
|
|
1526
1577
|
|
|
1527
1578
|
/*
|
|
1528
1579
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1562,7 +1613,7 @@ class ClientApplication {
|
|
|
1562
1613
|
responseMode: request.responseMode || msalCommon.ResponseMode.QUERY,
|
|
1563
1614
|
authenticationScheme: msalCommon.AuthenticationScheme.BEARER
|
|
1564
1615
|
};
|
|
1565
|
-
const authClientConfig = await this.buildOauthClientConfiguration(validRequest.authority, validRequest.correlationId);
|
|
1616
|
+
const authClientConfig = await this.buildOauthClientConfiguration(validRequest.authority, validRequest.correlationId, undefined, undefined, request.azureCloudOptions);
|
|
1566
1617
|
const authorizationCodeClient = new msalCommon.AuthorizationCodeClient(authClientConfig);
|
|
1567
1618
|
this.logger.verbose("Auth code client created", validRequest.correlationId);
|
|
1568
1619
|
return authorizationCodeClient.getAuthCodeUrl(validRequest);
|
|
@@ -1586,7 +1637,7 @@ class ClientApplication {
|
|
|
1586
1637
|
const serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.acquireTokenByCode, validRequest.correlationId);
|
|
1587
1638
|
|
|
1588
1639
|
try {
|
|
1589
|
-
const authClientConfig = await this.buildOauthClientConfiguration(validRequest.authority, validRequest.correlationId, serverTelemetryManager);
|
|
1640
|
+
const authClientConfig = await this.buildOauthClientConfiguration(validRequest.authority, validRequest.correlationId, serverTelemetryManager, undefined, request.azureCloudOptions);
|
|
1590
1641
|
const authorizationCodeClient = new msalCommon.AuthorizationCodeClient(authClientConfig);
|
|
1591
1642
|
this.logger.verbose("Auth code client created", validRequest.correlationId);
|
|
1592
1643
|
return authorizationCodeClient.acquireToken(validRequest);
|
|
@@ -1617,7 +1668,7 @@ class ClientApplication {
|
|
|
1617
1668
|
const serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.acquireTokenByRefreshToken, validRequest.correlationId);
|
|
1618
1669
|
|
|
1619
1670
|
try {
|
|
1620
|
-
const refreshTokenClientConfig = await this.buildOauthClientConfiguration(validRequest.authority, validRequest.correlationId, serverTelemetryManager);
|
|
1671
|
+
const refreshTokenClientConfig = await this.buildOauthClientConfiguration(validRequest.authority, validRequest.correlationId, serverTelemetryManager, undefined, request.azureCloudOptions);
|
|
1621
1672
|
const refreshTokenClient = new msalCommon.RefreshTokenClient(refreshTokenClientConfig);
|
|
1622
1673
|
this.logger.verbose("Refresh token client created", validRequest.correlationId);
|
|
1623
1674
|
return refreshTokenClient.acquireToken(validRequest);
|
|
@@ -1648,7 +1699,7 @@ class ClientApplication {
|
|
|
1648
1699
|
const serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.acquireTokenSilent, validRequest.correlationId, validRequest.forceRefresh);
|
|
1649
1700
|
|
|
1650
1701
|
try {
|
|
1651
|
-
const silentFlowClientConfig = await this.buildOauthClientConfiguration(validRequest.authority, validRequest.correlationId, serverTelemetryManager);
|
|
1702
|
+
const silentFlowClientConfig = await this.buildOauthClientConfiguration(validRequest.authority, validRequest.correlationId, serverTelemetryManager, undefined, request.azureCloudOptions);
|
|
1652
1703
|
const silentFlowClient = new msalCommon.SilentFlowClient(silentFlowClientConfig);
|
|
1653
1704
|
this.logger.verbose("Silent flow client created", validRequest.correlationId);
|
|
1654
1705
|
return silentFlowClient.acquireToken(validRequest);
|
|
@@ -1681,7 +1732,7 @@ class ClientApplication {
|
|
|
1681
1732
|
const serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.acquireTokenByUsernamePassword, validRequest.correlationId);
|
|
1682
1733
|
|
|
1683
1734
|
try {
|
|
1684
|
-
const usernamePasswordClientConfig = await this.buildOauthClientConfiguration(validRequest.authority, validRequest.correlationId, serverTelemetryManager);
|
|
1735
|
+
const usernamePasswordClientConfig = await this.buildOauthClientConfiguration(validRequest.authority, validRequest.correlationId, serverTelemetryManager, undefined, request.azureCloudOptions);
|
|
1685
1736
|
const usernamePasswordClient = new msalCommon.UsernamePasswordClient(usernamePasswordClientConfig);
|
|
1686
1737
|
this.logger.verbose("Username password client created", validRequest.correlationId);
|
|
1687
1738
|
return usernamePasswordClient.acquireToken(validRequest);
|
|
@@ -1727,11 +1778,13 @@ class ClientApplication {
|
|
|
1727
1778
|
*/
|
|
1728
1779
|
|
|
1729
1780
|
|
|
1730
|
-
async buildOauthClientConfiguration(authority, requestCorrelationId, serverTelemetryManager, azureRegionConfiguration) {
|
|
1731
|
-
this.logger.verbose("buildOauthClientConfiguration called", requestCorrelationId); //
|
|
1781
|
+
async buildOauthClientConfiguration(authority, requestCorrelationId, serverTelemetryManager, azureRegionConfiguration, azureCloudOptions) {
|
|
1782
|
+
this.logger.verbose("buildOauthClientConfiguration called", requestCorrelationId); // precedence - azureCloudInstance + tenant >> authority and request >> config
|
|
1783
|
+
|
|
1784
|
+
const userAzureCloudOptions = azureCloudOptions ? azureCloudOptions : this.config.auth.azureCloudOptions; // using null assertion operator as we ensure that all config values have default values in buildConfiguration()
|
|
1732
1785
|
|
|
1733
1786
|
this.logger.verbose(`building oauth client configuration with the authority: ${authority}`, requestCorrelationId);
|
|
1734
|
-
const discoveredAuthority = await this.createAuthority(authority, azureRegionConfiguration, requestCorrelationId);
|
|
1787
|
+
const discoveredAuthority = await this.createAuthority(authority, azureRegionConfiguration, requestCorrelationId, userAzureCloudOptions);
|
|
1735
1788
|
serverTelemetryManager == null ? void 0 : serverTelemetryManager.updateRegionDiscoveryMetadata(discoveredAuthority.regionDiscoveryMetadata);
|
|
1736
1789
|
return {
|
|
1737
1790
|
authOptions: {
|
|
@@ -1739,6 +1792,9 @@ class ClientApplication {
|
|
|
1739
1792
|
authority: discoveredAuthority,
|
|
1740
1793
|
clientCapabilities: this.config.auth.clientCapabilities
|
|
1741
1794
|
},
|
|
1795
|
+
systemOptions: {
|
|
1796
|
+
proxyUrl: this.config.system.proxyUrl
|
|
1797
|
+
},
|
|
1742
1798
|
loggerOptions: {
|
|
1743
1799
|
logLevel: this.config.system.loggerOptions.logLevel,
|
|
1744
1800
|
loggerCallback: this.config.system.loggerOptions.loggerCallback,
|
|
@@ -1814,8 +1870,10 @@ class ClientApplication {
|
|
|
1814
1870
|
*/
|
|
1815
1871
|
|
|
1816
1872
|
|
|
1817
|
-
async createAuthority(authorityString, azureRegionConfiguration, requestCorrelationId) {
|
|
1818
|
-
this.logger.verbose("createAuthority called", requestCorrelationId);
|
|
1873
|
+
async createAuthority(authorityString, azureRegionConfiguration, requestCorrelationId, azureCloudOptions) {
|
|
1874
|
+
this.logger.verbose("createAuthority called", requestCorrelationId); // build authority string based on auth params - azureCloudInstance is prioritized if provided
|
|
1875
|
+
|
|
1876
|
+
const authorityUrl = msalCommon.Authority.generateAuthority(authorityString, azureCloudOptions);
|
|
1819
1877
|
const authorityOptions = {
|
|
1820
1878
|
protocolMode: this.config.auth.protocolMode,
|
|
1821
1879
|
knownAuthorities: this.config.auth.knownAuthorities,
|
|
@@ -1823,7 +1881,7 @@ class ClientApplication {
|
|
|
1823
1881
|
authorityMetadata: this.config.auth.authorityMetadata,
|
|
1824
1882
|
azureRegionConfiguration
|
|
1825
1883
|
};
|
|
1826
|
-
return await msalCommon.AuthorityFactory.createDiscoveredInstance(
|
|
1884
|
+
return await msalCommon.AuthorityFactory.createDiscoveredInstance(authorityUrl, this.config.system.networkClient, this.storage, authorityOptions);
|
|
1827
1885
|
}
|
|
1828
1886
|
|
|
1829
1887
|
}
|
|
@@ -1876,7 +1934,7 @@ class PublicClientApplication extends ClientApplication {
|
|
|
1876
1934
|
const serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.acquireTokenByDeviceCode, validRequest.correlationId);
|
|
1877
1935
|
|
|
1878
1936
|
try {
|
|
1879
|
-
const deviceCodeConfig = await this.buildOauthClientConfiguration(validRequest.authority, validRequest.correlationId, serverTelemetryManager);
|
|
1937
|
+
const deviceCodeConfig = await this.buildOauthClientConfiguration(validRequest.authority, validRequest.correlationId, serverTelemetryManager, undefined, request.azureCloudOptions);
|
|
1880
1938
|
const deviceCodeClient = new msalCommon.DeviceCodeClient(deviceCodeConfig);
|
|
1881
1939
|
this.logger.verbose("Device code client created", validRequest.correlationId);
|
|
1882
1940
|
return deviceCodeClient.acquireToken(validRequest);
|
|
@@ -1970,13 +2028,13 @@ class ClientAssertion {
|
|
|
1970
2028
|
const issuedAt = msalCommon.TimeUtils.nowSeconds();
|
|
1971
2029
|
this.expirationTime = issuedAt + 600;
|
|
1972
2030
|
const header = {
|
|
1973
|
-
|
|
1974
|
-
|
|
2031
|
+
alg: JwtConstants.RSA_256,
|
|
2032
|
+
x5t: EncodingUtils.base64EncodeUrl(this.thumbprint, "hex")
|
|
1975
2033
|
};
|
|
1976
2034
|
|
|
1977
2035
|
if (this.publicCertificate) {
|
|
1978
2036
|
Object.assign(header, {
|
|
1979
|
-
|
|
2037
|
+
x5c: this.publicCertificate
|
|
1980
2038
|
});
|
|
1981
2039
|
}
|
|
1982
2040
|
|
|
@@ -1989,7 +2047,7 @@ class ClientAssertion {
|
|
|
1989
2047
|
[JwtConstants.JWT_ID]: cryptoProvider.createNewGuid()
|
|
1990
2048
|
};
|
|
1991
2049
|
this.jwt = jsonwebtoken.sign(payload, this.privateKey, {
|
|
1992
|
-
header
|
|
2050
|
+
header
|
|
1993
2051
|
});
|
|
1994
2052
|
return this.jwt;
|
|
1995
2053
|
}
|
|
@@ -2080,7 +2138,7 @@ class ConfidentialClientApplication extends ClientApplication {
|
|
|
2080
2138
|
const serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.acquireTokenByClientCredential, validRequest.correlationId, validRequest.skipCache);
|
|
2081
2139
|
|
|
2082
2140
|
try {
|
|
2083
|
-
const clientCredentialConfig = await this.buildOauthClientConfiguration(validRequest.authority, validRequest.correlationId, serverTelemetryManager, azureRegionConfiguration);
|
|
2141
|
+
const clientCredentialConfig = await this.buildOauthClientConfiguration(validRequest.authority, validRequest.correlationId, serverTelemetryManager, azureRegionConfiguration, request.azureCloudOptions);
|
|
2084
2142
|
const clientCredentialClient = new msalCommon.ClientCredentialClient(clientCredentialConfig);
|
|
2085
2143
|
this.logger.verbose("Client credential client created", validRequest.correlationId);
|
|
2086
2144
|
return clientCredentialClient.acquireToken(validRequest);
|
|
@@ -2113,7 +2171,7 @@ class ConfidentialClientApplication extends ClientApplication {
|
|
|
2113
2171
|
};
|
|
2114
2172
|
|
|
2115
2173
|
try {
|
|
2116
|
-
const clientCredentialConfig = await this.buildOauthClientConfiguration(validRequest.authority, validRequest.correlationId);
|
|
2174
|
+
const clientCredentialConfig = await this.buildOauthClientConfiguration(validRequest.authority, validRequest.correlationId, undefined, undefined, request.azureCloudOptions);
|
|
2117
2175
|
const oboClient = new msalCommon.OnBehalfOfClient(clientCredentialConfig);
|
|
2118
2176
|
this.logger.verbose("On behalf of client created", validRequest.correlationId);
|
|
2119
2177
|
return oboClient.acquireToken(validRequest);
|
|
@@ -2160,6 +2218,37 @@ class ConfidentialClientApplication extends ClientApplication {
|
|
|
2160
2218
|
|
|
2161
2219
|
}
|
|
2162
2220
|
|
|
2221
|
+
/*
|
|
2222
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2223
|
+
* Licensed under the MIT License.
|
|
2224
|
+
*/
|
|
2225
|
+
class DistributedCachePlugin {
|
|
2226
|
+
constructor(client, partitionManager) {
|
|
2227
|
+
this.client = client;
|
|
2228
|
+
this.partitionManager = partitionManager;
|
|
2229
|
+
}
|
|
2230
|
+
|
|
2231
|
+
async beforeCacheAccess(cacheContext) {
|
|
2232
|
+
const partitionKey = await this.partitionManager.getKey();
|
|
2233
|
+
const cacheData = await this.client.get(partitionKey);
|
|
2234
|
+
cacheContext.tokenCache.deserialize(cacheData);
|
|
2235
|
+
}
|
|
2236
|
+
|
|
2237
|
+
async afterCacheAccess(cacheContext) {
|
|
2238
|
+
if (cacheContext.cacheHasChanged) {
|
|
2239
|
+
const kvStore = cacheContext.tokenCache.getKVStore();
|
|
2240
|
+
const accountEntities = Object.values(kvStore).filter(value => msalCommon.AccountEntity.isAccountEntity(value));
|
|
2241
|
+
|
|
2242
|
+
if (accountEntities.length > 0) {
|
|
2243
|
+
const accountEntity = accountEntities[0];
|
|
2244
|
+
const partitionKey = await this.partitionManager.extractKey(accountEntity);
|
|
2245
|
+
await this.client.set(partitionKey, cacheContext.tokenCache.serialize());
|
|
2246
|
+
}
|
|
2247
|
+
}
|
|
2248
|
+
}
|
|
2249
|
+
|
|
2250
|
+
}
|
|
2251
|
+
|
|
2163
2252
|
Object.defineProperty(exports, 'AuthError', {
|
|
2164
2253
|
enumerable: true,
|
|
2165
2254
|
get: function () {
|
|
@@ -2172,6 +2261,12 @@ Object.defineProperty(exports, 'AuthErrorMessage', {
|
|
|
2172
2261
|
return msalCommon.AuthErrorMessage;
|
|
2173
2262
|
}
|
|
2174
2263
|
});
|
|
2264
|
+
Object.defineProperty(exports, 'AzureCloudInstance', {
|
|
2265
|
+
enumerable: true,
|
|
2266
|
+
get: function () {
|
|
2267
|
+
return msalCommon.AzureCloudInstance;
|
|
2268
|
+
}
|
|
2269
|
+
});
|
|
2175
2270
|
Object.defineProperty(exports, 'ClientAuthError', {
|
|
2176
2271
|
enumerable: true,
|
|
2177
2272
|
get: function () {
|
|
@@ -2254,6 +2349,7 @@ exports.ClientApplication = ClientApplication;
|
|
|
2254
2349
|
exports.ClientAssertion = ClientAssertion;
|
|
2255
2350
|
exports.ConfidentialClientApplication = ConfidentialClientApplication;
|
|
2256
2351
|
exports.CryptoProvider = CryptoProvider;
|
|
2352
|
+
exports.DistributedCachePlugin = DistributedCachePlugin;
|
|
2257
2353
|
exports.NodeStorage = NodeStorage;
|
|
2258
2354
|
exports.PublicClientApplication = PublicClientApplication;
|
|
2259
2355
|
exports.TokenCache = TokenCache;
|