@azure/msal-node 1.5.0 → 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 +47 -0
- package/CHANGELOG.md +12 -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/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/msal-node.cjs.development.js +82 -17
- 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 +78 -20
- 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/package.json +4 -17
package/dist/msal-node.esm.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { Constants as Constants$1, ProtocolMode, LogLevel, StringUtils, AccountEntity, CacheManager, IdTokenEntity, AccessTokenEntity, RefreshTokenEntity, AppMetadataEntity, ServerTelemetryEntity, AuthorityMetadataEntity, ThrottlingEntity, TokenCacheContext, Logger, ResponseMode, AuthenticationScheme, AuthorizationCodeClient, AuthError, RefreshTokenClient, SilentFlowClient, UsernamePasswordClient, OIDC_DEFAULT_SCOPES, ServerTelemetryManager, AuthorityFactory, DeviceCodeClient, ClientAuthError, TimeUtils, ClientCredentialClient, OnBehalfOfClient } from '@azure/msal-common';
|
|
2
|
-
export { AuthError, AuthErrorMessage, ClientAuthError, ClientAuthErrorMessage, ClientConfigurationError, ClientConfigurationErrorMessage, InteractionRequiredAuthError, InteractionRequiredAuthErrorMessage, LogLevel, Logger, PromptValue, ProtocolMode, ResponseMode, ServerError, TokenCacheContext } from '@azure/msal-common';
|
|
1
|
+
import { Constants as Constants$1, ProtocolMode, AzureCloudInstance, LogLevel, StringUtils, AccountEntity, CacheManager, IdTokenEntity, AccessTokenEntity, RefreshTokenEntity, AppMetadataEntity, ServerTelemetryEntity, AuthorityMetadataEntity, ThrottlingEntity, TokenCacheContext, Logger, ResponseMode, AuthenticationScheme, AuthorizationCodeClient, AuthError, RefreshTokenClient, SilentFlowClient, UsernamePasswordClient, OIDC_DEFAULT_SCOPES, ServerTelemetryManager, Authority, AuthorityFactory, DeviceCodeClient, ClientAuthError, TimeUtils, ClientCredentialClient, OnBehalfOfClient } from '@azure/msal-common';
|
|
2
|
+
export { AuthError, AuthErrorMessage, AzureCloudInstance, ClientAuthError, ClientAuthErrorMessage, ClientConfigurationError, ClientConfigurationErrorMessage, InteractionRequiredAuthError, InteractionRequiredAuthErrorMessage, LogLevel, Logger, PromptValue, ProtocolMode, ResponseMode, ServerError, TokenCacheContext } from '@azure/msal-common';
|
|
3
3
|
import axios from 'axios';
|
|
4
|
+
import createHttpsProxyAgent from 'https-proxy-agent';
|
|
4
5
|
import { v4 } from 'uuid';
|
|
5
6
|
import crypto from 'crypto';
|
|
6
7
|
import { sign } from 'jsonwebtoken';
|
|
@@ -113,6 +114,13 @@ class HttpClient {
|
|
|
113
114
|
/* istanbul ignore next */
|
|
114
115
|
validateStatus: () => true
|
|
115
116
|
};
|
|
117
|
+
|
|
118
|
+
if (options && options.proxyUrl) {
|
|
119
|
+
// for axios, this has to be disabled
|
|
120
|
+
request.proxy = false;
|
|
121
|
+
request.httpsAgent = createHttpsProxyAgent(options.proxyUrl);
|
|
122
|
+
}
|
|
123
|
+
|
|
116
124
|
const response = await axios(request);
|
|
117
125
|
return {
|
|
118
126
|
headers: response.headers,
|
|
@@ -142,6 +150,13 @@ class HttpClient {
|
|
|
142
150
|
/* istanbul ignore next */
|
|
143
151
|
validateStatus: () => true
|
|
144
152
|
};
|
|
153
|
+
|
|
154
|
+
if (options && options.proxyUrl) {
|
|
155
|
+
// for axios, this has to be disabled
|
|
156
|
+
request.proxy = false;
|
|
157
|
+
request.httpsAgent = createHttpsProxyAgent(options.proxyUrl);
|
|
158
|
+
}
|
|
159
|
+
|
|
145
160
|
const response = await axios(request);
|
|
146
161
|
return {
|
|
147
162
|
headers: response.headers,
|
|
@@ -184,7 +199,11 @@ const DEFAULT_AUTH_OPTIONS = {
|
|
|
184
199
|
cloudDiscoveryMetadata: "",
|
|
185
200
|
authorityMetadata: "",
|
|
186
201
|
clientCapabilities: [],
|
|
187
|
-
protocolMode: ProtocolMode.AAD
|
|
202
|
+
protocolMode: ProtocolMode.AAD,
|
|
203
|
+
azureCloudOptions: {
|
|
204
|
+
azureCloudInstance: AzureCloudInstance.None,
|
|
205
|
+
tenant: ""
|
|
206
|
+
}
|
|
188
207
|
};
|
|
189
208
|
const DEFAULT_CACHE_OPTIONS = {};
|
|
190
209
|
const DEFAULT_LOGGER_OPTIONS = {
|
|
@@ -195,7 +214,8 @@ const DEFAULT_LOGGER_OPTIONS = {
|
|
|
195
214
|
};
|
|
196
215
|
const DEFAULT_SYSTEM_OPTIONS = {
|
|
197
216
|
loggerOptions: DEFAULT_LOGGER_OPTIONS,
|
|
198
|
-
networkClient: /*#__PURE__*/NetworkUtils.getNetworkClient()
|
|
217
|
+
networkClient: /*#__PURE__*/NetworkUtils.getNetworkClient(),
|
|
218
|
+
proxyUrl: ""
|
|
199
219
|
};
|
|
200
220
|
/**
|
|
201
221
|
* Sets the default options when not explicitly configured from app developer
|
|
@@ -1548,7 +1568,7 @@ class TokenCache {
|
|
|
1548
1568
|
|
|
1549
1569
|
/* eslint-disable header/header */
|
|
1550
1570
|
const name = "@azure/msal-node";
|
|
1551
|
-
const version = "1.
|
|
1571
|
+
const version = "1.6.0";
|
|
1552
1572
|
|
|
1553
1573
|
/*
|
|
1554
1574
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1588,7 +1608,7 @@ class ClientApplication {
|
|
|
1588
1608
|
responseMode: request.responseMode || ResponseMode.QUERY,
|
|
1589
1609
|
authenticationScheme: AuthenticationScheme.BEARER
|
|
1590
1610
|
};
|
|
1591
|
-
const authClientConfig = await this.buildOauthClientConfiguration(validRequest.authority, validRequest.correlationId);
|
|
1611
|
+
const authClientConfig = await this.buildOauthClientConfiguration(validRequest.authority, validRequest.correlationId, undefined, undefined, request.azureCloudOptions);
|
|
1592
1612
|
const authorizationCodeClient = new AuthorizationCodeClient(authClientConfig);
|
|
1593
1613
|
this.logger.verbose("Auth code client created", validRequest.correlationId);
|
|
1594
1614
|
return authorizationCodeClient.getAuthCodeUrl(validRequest);
|
|
@@ -1612,7 +1632,7 @@ class ClientApplication {
|
|
|
1612
1632
|
const serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.acquireTokenByCode, validRequest.correlationId);
|
|
1613
1633
|
|
|
1614
1634
|
try {
|
|
1615
|
-
const authClientConfig = await this.buildOauthClientConfiguration(validRequest.authority, validRequest.correlationId, serverTelemetryManager);
|
|
1635
|
+
const authClientConfig = await this.buildOauthClientConfiguration(validRequest.authority, validRequest.correlationId, serverTelemetryManager, undefined, request.azureCloudOptions);
|
|
1616
1636
|
const authorizationCodeClient = new AuthorizationCodeClient(authClientConfig);
|
|
1617
1637
|
this.logger.verbose("Auth code client created", validRequest.correlationId);
|
|
1618
1638
|
return authorizationCodeClient.acquireToken(validRequest);
|
|
@@ -1643,7 +1663,7 @@ class ClientApplication {
|
|
|
1643
1663
|
const serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.acquireTokenByRefreshToken, validRequest.correlationId);
|
|
1644
1664
|
|
|
1645
1665
|
try {
|
|
1646
|
-
const refreshTokenClientConfig = await this.buildOauthClientConfiguration(validRequest.authority, validRequest.correlationId, serverTelemetryManager);
|
|
1666
|
+
const refreshTokenClientConfig = await this.buildOauthClientConfiguration(validRequest.authority, validRequest.correlationId, serverTelemetryManager, undefined, request.azureCloudOptions);
|
|
1647
1667
|
const refreshTokenClient = new RefreshTokenClient(refreshTokenClientConfig);
|
|
1648
1668
|
this.logger.verbose("Refresh token client created", validRequest.correlationId);
|
|
1649
1669
|
return refreshTokenClient.acquireToken(validRequest);
|
|
@@ -1674,7 +1694,7 @@ class ClientApplication {
|
|
|
1674
1694
|
const serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.acquireTokenSilent, validRequest.correlationId, validRequest.forceRefresh);
|
|
1675
1695
|
|
|
1676
1696
|
try {
|
|
1677
|
-
const silentFlowClientConfig = await this.buildOauthClientConfiguration(validRequest.authority, validRequest.correlationId, serverTelemetryManager);
|
|
1697
|
+
const silentFlowClientConfig = await this.buildOauthClientConfiguration(validRequest.authority, validRequest.correlationId, serverTelemetryManager, undefined, request.azureCloudOptions);
|
|
1678
1698
|
const silentFlowClient = new SilentFlowClient(silentFlowClientConfig);
|
|
1679
1699
|
this.logger.verbose("Silent flow client created", validRequest.correlationId);
|
|
1680
1700
|
return silentFlowClient.acquireToken(validRequest);
|
|
@@ -1707,7 +1727,7 @@ class ClientApplication {
|
|
|
1707
1727
|
const serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.acquireTokenByUsernamePassword, validRequest.correlationId);
|
|
1708
1728
|
|
|
1709
1729
|
try {
|
|
1710
|
-
const usernamePasswordClientConfig = await this.buildOauthClientConfiguration(validRequest.authority, validRequest.correlationId, serverTelemetryManager);
|
|
1730
|
+
const usernamePasswordClientConfig = await this.buildOauthClientConfiguration(validRequest.authority, validRequest.correlationId, serverTelemetryManager, undefined, request.azureCloudOptions);
|
|
1711
1731
|
const usernamePasswordClient = new UsernamePasswordClient(usernamePasswordClientConfig);
|
|
1712
1732
|
this.logger.verbose("Username password client created", validRequest.correlationId);
|
|
1713
1733
|
return usernamePasswordClient.acquireToken(validRequest);
|
|
@@ -1753,11 +1773,13 @@ class ClientApplication {
|
|
|
1753
1773
|
*/
|
|
1754
1774
|
|
|
1755
1775
|
|
|
1756
|
-
async buildOauthClientConfiguration(authority, requestCorrelationId, serverTelemetryManager, azureRegionConfiguration) {
|
|
1757
|
-
this.logger.verbose("buildOauthClientConfiguration called", requestCorrelationId); //
|
|
1776
|
+
async buildOauthClientConfiguration(authority, requestCorrelationId, serverTelemetryManager, azureRegionConfiguration, azureCloudOptions) {
|
|
1777
|
+
this.logger.verbose("buildOauthClientConfiguration called", requestCorrelationId); // precedence - azureCloudInstance + tenant >> authority and request >> config
|
|
1778
|
+
|
|
1779
|
+
const userAzureCloudOptions = azureCloudOptions ? azureCloudOptions : this.config.auth.azureCloudOptions; // using null assertion operator as we ensure that all config values have default values in buildConfiguration()
|
|
1758
1780
|
|
|
1759
1781
|
this.logger.verbose(`building oauth client configuration with the authority: ${authority}`, requestCorrelationId);
|
|
1760
|
-
const discoveredAuthority = await this.createAuthority(authority, azureRegionConfiguration, requestCorrelationId);
|
|
1782
|
+
const discoveredAuthority = await this.createAuthority(authority, azureRegionConfiguration, requestCorrelationId, userAzureCloudOptions);
|
|
1761
1783
|
serverTelemetryManager == null ? void 0 : serverTelemetryManager.updateRegionDiscoveryMetadata(discoveredAuthority.regionDiscoveryMetadata);
|
|
1762
1784
|
return {
|
|
1763
1785
|
authOptions: {
|
|
@@ -1765,6 +1787,9 @@ class ClientApplication {
|
|
|
1765
1787
|
authority: discoveredAuthority,
|
|
1766
1788
|
clientCapabilities: this.config.auth.clientCapabilities
|
|
1767
1789
|
},
|
|
1790
|
+
systemOptions: {
|
|
1791
|
+
proxyUrl: this.config.system.proxyUrl
|
|
1792
|
+
},
|
|
1768
1793
|
loggerOptions: {
|
|
1769
1794
|
logLevel: this.config.system.loggerOptions.logLevel,
|
|
1770
1795
|
loggerCallback: this.config.system.loggerOptions.loggerCallback,
|
|
@@ -1840,8 +1865,10 @@ class ClientApplication {
|
|
|
1840
1865
|
*/
|
|
1841
1866
|
|
|
1842
1867
|
|
|
1843
|
-
async createAuthority(authorityString, azureRegionConfiguration, requestCorrelationId) {
|
|
1844
|
-
this.logger.verbose("createAuthority called", requestCorrelationId);
|
|
1868
|
+
async createAuthority(authorityString, azureRegionConfiguration, requestCorrelationId, azureCloudOptions) {
|
|
1869
|
+
this.logger.verbose("createAuthority called", requestCorrelationId); // build authority string based on auth params - azureCloudInstance is prioritized if provided
|
|
1870
|
+
|
|
1871
|
+
const authorityUrl = Authority.generateAuthority(authorityString, azureCloudOptions);
|
|
1845
1872
|
const authorityOptions = {
|
|
1846
1873
|
protocolMode: this.config.auth.protocolMode,
|
|
1847
1874
|
knownAuthorities: this.config.auth.knownAuthorities,
|
|
@@ -1849,7 +1876,7 @@ class ClientApplication {
|
|
|
1849
1876
|
authorityMetadata: this.config.auth.authorityMetadata,
|
|
1850
1877
|
azureRegionConfiguration
|
|
1851
1878
|
};
|
|
1852
|
-
return await AuthorityFactory.createDiscoveredInstance(
|
|
1879
|
+
return await AuthorityFactory.createDiscoveredInstance(authorityUrl, this.config.system.networkClient, this.storage, authorityOptions);
|
|
1853
1880
|
}
|
|
1854
1881
|
|
|
1855
1882
|
}
|
|
@@ -1902,7 +1929,7 @@ class PublicClientApplication extends ClientApplication {
|
|
|
1902
1929
|
const serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.acquireTokenByDeviceCode, validRequest.correlationId);
|
|
1903
1930
|
|
|
1904
1931
|
try {
|
|
1905
|
-
const deviceCodeConfig = await this.buildOauthClientConfiguration(validRequest.authority, validRequest.correlationId, serverTelemetryManager);
|
|
1932
|
+
const deviceCodeConfig = await this.buildOauthClientConfiguration(validRequest.authority, validRequest.correlationId, serverTelemetryManager, undefined, request.azureCloudOptions);
|
|
1906
1933
|
const deviceCodeClient = new DeviceCodeClient(deviceCodeConfig);
|
|
1907
1934
|
this.logger.verbose("Device code client created", validRequest.correlationId);
|
|
1908
1935
|
return deviceCodeClient.acquireToken(validRequest);
|
|
@@ -2106,7 +2133,7 @@ class ConfidentialClientApplication extends ClientApplication {
|
|
|
2106
2133
|
const serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.acquireTokenByClientCredential, validRequest.correlationId, validRequest.skipCache);
|
|
2107
2134
|
|
|
2108
2135
|
try {
|
|
2109
|
-
const clientCredentialConfig = await this.buildOauthClientConfiguration(validRequest.authority, validRequest.correlationId, serverTelemetryManager, azureRegionConfiguration);
|
|
2136
|
+
const clientCredentialConfig = await this.buildOauthClientConfiguration(validRequest.authority, validRequest.correlationId, serverTelemetryManager, azureRegionConfiguration, request.azureCloudOptions);
|
|
2110
2137
|
const clientCredentialClient = new ClientCredentialClient(clientCredentialConfig);
|
|
2111
2138
|
this.logger.verbose("Client credential client created", validRequest.correlationId);
|
|
2112
2139
|
return clientCredentialClient.acquireToken(validRequest);
|
|
@@ -2139,7 +2166,7 @@ class ConfidentialClientApplication extends ClientApplication {
|
|
|
2139
2166
|
};
|
|
2140
2167
|
|
|
2141
2168
|
try {
|
|
2142
|
-
const clientCredentialConfig = await this.buildOauthClientConfiguration(validRequest.authority, validRequest.correlationId);
|
|
2169
|
+
const clientCredentialConfig = await this.buildOauthClientConfiguration(validRequest.authority, validRequest.correlationId, undefined, undefined, request.azureCloudOptions);
|
|
2143
2170
|
const oboClient = new OnBehalfOfClient(clientCredentialConfig);
|
|
2144
2171
|
this.logger.verbose("On behalf of client created", validRequest.correlationId);
|
|
2145
2172
|
return oboClient.acquireToken(validRequest);
|
|
@@ -2186,5 +2213,36 @@ class ConfidentialClientApplication extends ClientApplication {
|
|
|
2186
2213
|
|
|
2187
2214
|
}
|
|
2188
2215
|
|
|
2189
|
-
|
|
2216
|
+
/*
|
|
2217
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2218
|
+
* Licensed under the MIT License.
|
|
2219
|
+
*/
|
|
2220
|
+
class DistributedCachePlugin {
|
|
2221
|
+
constructor(client, partitionManager) {
|
|
2222
|
+
this.client = client;
|
|
2223
|
+
this.partitionManager = partitionManager;
|
|
2224
|
+
}
|
|
2225
|
+
|
|
2226
|
+
async beforeCacheAccess(cacheContext) {
|
|
2227
|
+
const partitionKey = await this.partitionManager.getKey();
|
|
2228
|
+
const cacheData = await this.client.get(partitionKey);
|
|
2229
|
+
cacheContext.tokenCache.deserialize(cacheData);
|
|
2230
|
+
}
|
|
2231
|
+
|
|
2232
|
+
async afterCacheAccess(cacheContext) {
|
|
2233
|
+
if (cacheContext.cacheHasChanged) {
|
|
2234
|
+
const kvStore = cacheContext.tokenCache.getKVStore();
|
|
2235
|
+
const accountEntities = Object.values(kvStore).filter(value => AccountEntity.isAccountEntity(value));
|
|
2236
|
+
|
|
2237
|
+
if (accountEntities.length > 0) {
|
|
2238
|
+
const accountEntity = accountEntities[0];
|
|
2239
|
+
const partitionKey = await this.partitionManager.extractKey(accountEntity);
|
|
2240
|
+
await this.client.set(partitionKey, cacheContext.tokenCache.serialize());
|
|
2241
|
+
}
|
|
2242
|
+
}
|
|
2243
|
+
}
|
|
2244
|
+
|
|
2245
|
+
}
|
|
2246
|
+
|
|
2247
|
+
export { ClientApplication, ClientAssertion, ConfidentialClientApplication, CryptoProvider, DistributedCachePlugin, NodeStorage, PublicClientApplication, TokenCache, buildAppConfiguration, version };
|
|
2190
2248
|
//# sourceMappingURL=msal-node.esm.js.map
|