@azure/identity 4.1.1-alpha.20240419.1 → 4.1.1-alpha.20240423.2
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.
Potentially problematic release.
This version of @azure/identity might be problematic. Click here for more details.
- package/dist/index.js +214 -146
- package/dist/index.js.map +1 -1
- package/dist-esm/src/index.js +1 -0
- package/dist-esm/src/index.js.map +1 -1
- package/dist-esm/src/msal/nodeFlows/msalClient.js +17 -5
- package/dist-esm/src/msal/nodeFlows/msalClient.js.map +1 -1
- package/dist-esm/src/msal/nodeFlows/msalPlugins.js +6 -5
- package/dist-esm/src/msal/nodeFlows/msalPlugins.js.map +1 -1
- package/dist-esm/src/regionalAuthority.js +4 -0
- package/dist-esm/src/regionalAuthority.js.map +1 -1
- package/dist-esm/src/tokenProvider.js +52 -0
- package/dist-esm/src/tokenProvider.js.map +1 -0
- package/package.json +1 -1
- package/types/identity.d.ts +39 -0
package/dist/index.js
CHANGED
|
@@ -150,15 +150,16 @@ const msalNodeFlowNativeBrokerControl = {
|
|
|
150
150
|
* @returns plugin configuration
|
|
151
151
|
*/
|
|
152
152
|
function generatePluginConfiguration(options) {
|
|
153
|
-
var _a, _b, _c, _d, _e;
|
|
153
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
154
154
|
const config = {
|
|
155
155
|
cache: {},
|
|
156
156
|
broker: {
|
|
157
|
-
|
|
158
|
-
|
|
157
|
+
isEnabled: (_b = (_a = options.brokerOptions) === null || _a === void 0 ? void 0 : _a.enabled) !== null && _b !== void 0 ? _b : false,
|
|
158
|
+
enableMsaPassthrough: (_d = (_c = options.brokerOptions) === null || _c === void 0 ? void 0 : _c.legacyEnableMsaPassthrough) !== null && _d !== void 0 ? _d : false,
|
|
159
|
+
parentWindowHandle: (_e = options.brokerOptions) === null || _e === void 0 ? void 0 : _e.parentWindowHandle,
|
|
159
160
|
},
|
|
160
161
|
};
|
|
161
|
-
if ((
|
|
162
|
+
if ((_f = options.tokenCachePersistenceOptions) === null || _f === void 0 ? void 0 : _f.enabled) {
|
|
162
163
|
if (persistenceProvider === undefined) {
|
|
163
164
|
throw new Error([
|
|
164
165
|
"Persistent token caching was requested, but no persistence provider was configured.",
|
|
@@ -171,7 +172,7 @@ function generatePluginConfiguration(options) {
|
|
|
171
172
|
config.cache.cachePlugin = persistenceProvider(Object.assign({ name: `${cacheBaseName}.${CACHE_NON_CAE_SUFFIX}` }, options.tokenCachePersistenceOptions));
|
|
172
173
|
config.cache.cachePluginCae = persistenceProvider(Object.assign({ name: `${cacheBaseName}.${CACHE_CAE_SUFFIX}` }, options.tokenCachePersistenceOptions));
|
|
173
174
|
}
|
|
174
|
-
if ((
|
|
175
|
+
if ((_g = options.brokerOptions) === null || _g === void 0 ? void 0 : _g.enabled) {
|
|
175
176
|
if (nativeBrokerInfo === undefined) {
|
|
176
177
|
throw new Error([
|
|
177
178
|
"Broker for WAM was requested to be enabled, but no native broker was configured.",
|
|
@@ -1759,6 +1760,146 @@ const imdsMsi = {
|
|
|
1759
1760
|
},
|
|
1760
1761
|
};
|
|
1761
1762
|
|
|
1763
|
+
// Copyright (c) Microsoft Corporation.
|
|
1764
|
+
// Licensed under the MIT license.
|
|
1765
|
+
/**
|
|
1766
|
+
* Helps specify a regional authority, or "AutoDiscoverRegion" to auto-detect the region.
|
|
1767
|
+
*/
|
|
1768
|
+
var RegionalAuthority;
|
|
1769
|
+
(function (RegionalAuthority) {
|
|
1770
|
+
/** Instructs MSAL to attempt to discover the region */
|
|
1771
|
+
RegionalAuthority["AutoDiscoverRegion"] = "AutoDiscoverRegion";
|
|
1772
|
+
/** Uses the {@link RegionalAuthority} for the Azure 'westus' region. */
|
|
1773
|
+
RegionalAuthority["USWest"] = "westus";
|
|
1774
|
+
/** Uses the {@link RegionalAuthority} for the Azure 'westus2' region. */
|
|
1775
|
+
RegionalAuthority["USWest2"] = "westus2";
|
|
1776
|
+
/** Uses the {@link RegionalAuthority} for the Azure 'centralus' region. */
|
|
1777
|
+
RegionalAuthority["USCentral"] = "centralus";
|
|
1778
|
+
/** Uses the {@link RegionalAuthority} for the Azure 'eastus' region. */
|
|
1779
|
+
RegionalAuthority["USEast"] = "eastus";
|
|
1780
|
+
/** Uses the {@link RegionalAuthority} for the Azure 'eastus2' region. */
|
|
1781
|
+
RegionalAuthority["USEast2"] = "eastus2";
|
|
1782
|
+
/** Uses the {@link RegionalAuthority} for the Azure 'northcentralus' region. */
|
|
1783
|
+
RegionalAuthority["USNorthCentral"] = "northcentralus";
|
|
1784
|
+
/** Uses the {@link RegionalAuthority} for the Azure 'southcentralus' region. */
|
|
1785
|
+
RegionalAuthority["USSouthCentral"] = "southcentralus";
|
|
1786
|
+
/** Uses the {@link RegionalAuthority} for the Azure 'westcentralus' region. */
|
|
1787
|
+
RegionalAuthority["USWestCentral"] = "westcentralus";
|
|
1788
|
+
/** Uses the {@link RegionalAuthority} for the Azure 'canadacentral' region. */
|
|
1789
|
+
RegionalAuthority["CanadaCentral"] = "canadacentral";
|
|
1790
|
+
/** Uses the {@link RegionalAuthority} for the Azure 'canadaeast' region. */
|
|
1791
|
+
RegionalAuthority["CanadaEast"] = "canadaeast";
|
|
1792
|
+
/** Uses the {@link RegionalAuthority} for the Azure 'brazilsouth' region. */
|
|
1793
|
+
RegionalAuthority["BrazilSouth"] = "brazilsouth";
|
|
1794
|
+
/** Uses the {@link RegionalAuthority} for the Azure 'northeurope' region. */
|
|
1795
|
+
RegionalAuthority["EuropeNorth"] = "northeurope";
|
|
1796
|
+
/** Uses the {@link RegionalAuthority} for the Azure 'westeurope' region. */
|
|
1797
|
+
RegionalAuthority["EuropeWest"] = "westeurope";
|
|
1798
|
+
/** Uses the {@link RegionalAuthority} for the Azure 'uksouth' region. */
|
|
1799
|
+
RegionalAuthority["UKSouth"] = "uksouth";
|
|
1800
|
+
/** Uses the {@link RegionalAuthority} for the Azure 'ukwest' region. */
|
|
1801
|
+
RegionalAuthority["UKWest"] = "ukwest";
|
|
1802
|
+
/** Uses the {@link RegionalAuthority} for the Azure 'francecentral' region. */
|
|
1803
|
+
RegionalAuthority["FranceCentral"] = "francecentral";
|
|
1804
|
+
/** Uses the {@link RegionalAuthority} for the Azure 'francesouth' region. */
|
|
1805
|
+
RegionalAuthority["FranceSouth"] = "francesouth";
|
|
1806
|
+
/** Uses the {@link RegionalAuthority} for the Azure 'switzerlandnorth' region. */
|
|
1807
|
+
RegionalAuthority["SwitzerlandNorth"] = "switzerlandnorth";
|
|
1808
|
+
/** Uses the {@link RegionalAuthority} for the Azure 'switzerlandwest' region. */
|
|
1809
|
+
RegionalAuthority["SwitzerlandWest"] = "switzerlandwest";
|
|
1810
|
+
/** Uses the {@link RegionalAuthority} for the Azure 'germanynorth' region. */
|
|
1811
|
+
RegionalAuthority["GermanyNorth"] = "germanynorth";
|
|
1812
|
+
/** Uses the {@link RegionalAuthority} for the Azure 'germanywestcentral' region. */
|
|
1813
|
+
RegionalAuthority["GermanyWestCentral"] = "germanywestcentral";
|
|
1814
|
+
/** Uses the {@link RegionalAuthority} for the Azure 'norwaywest' region. */
|
|
1815
|
+
RegionalAuthority["NorwayWest"] = "norwaywest";
|
|
1816
|
+
/** Uses the {@link RegionalAuthority} for the Azure 'norwayeast' region. */
|
|
1817
|
+
RegionalAuthority["NorwayEast"] = "norwayeast";
|
|
1818
|
+
/** Uses the {@link RegionalAuthority} for the Azure 'eastasia' region. */
|
|
1819
|
+
RegionalAuthority["AsiaEast"] = "eastasia";
|
|
1820
|
+
/** Uses the {@link RegionalAuthority} for the Azure 'southeastasia' region. */
|
|
1821
|
+
RegionalAuthority["AsiaSouthEast"] = "southeastasia";
|
|
1822
|
+
/** Uses the {@link RegionalAuthority} for the Azure 'japaneast' region. */
|
|
1823
|
+
RegionalAuthority["JapanEast"] = "japaneast";
|
|
1824
|
+
/** Uses the {@link RegionalAuthority} for the Azure 'japanwest' region. */
|
|
1825
|
+
RegionalAuthority["JapanWest"] = "japanwest";
|
|
1826
|
+
/** Uses the {@link RegionalAuthority} for the Azure 'australiaeast' region. */
|
|
1827
|
+
RegionalAuthority["AustraliaEast"] = "australiaeast";
|
|
1828
|
+
/** Uses the {@link RegionalAuthority} for the Azure 'australiasoutheast' region. */
|
|
1829
|
+
RegionalAuthority["AustraliaSouthEast"] = "australiasoutheast";
|
|
1830
|
+
/** Uses the {@link RegionalAuthority} for the Azure 'australiacentral' region. */
|
|
1831
|
+
RegionalAuthority["AustraliaCentral"] = "australiacentral";
|
|
1832
|
+
/** Uses the {@link RegionalAuthority} for the Azure 'australiacentral2' region. */
|
|
1833
|
+
RegionalAuthority["AustraliaCentral2"] = "australiacentral2";
|
|
1834
|
+
/** Uses the {@link RegionalAuthority} for the Azure 'centralindia' region. */
|
|
1835
|
+
RegionalAuthority["IndiaCentral"] = "centralindia";
|
|
1836
|
+
/** Uses the {@link RegionalAuthority} for the Azure 'southindia' region. */
|
|
1837
|
+
RegionalAuthority["IndiaSouth"] = "southindia";
|
|
1838
|
+
/** Uses the {@link RegionalAuthority} for the Azure 'westindia' region. */
|
|
1839
|
+
RegionalAuthority["IndiaWest"] = "westindia";
|
|
1840
|
+
/** Uses the {@link RegionalAuthority} for the Azure 'koreasouth' region. */
|
|
1841
|
+
RegionalAuthority["KoreaSouth"] = "koreasouth";
|
|
1842
|
+
/** Uses the {@link RegionalAuthority} for the Azure 'koreacentral' region. */
|
|
1843
|
+
RegionalAuthority["KoreaCentral"] = "koreacentral";
|
|
1844
|
+
/** Uses the {@link RegionalAuthority} for the Azure 'uaecentral' region. */
|
|
1845
|
+
RegionalAuthority["UAECentral"] = "uaecentral";
|
|
1846
|
+
/** Uses the {@link RegionalAuthority} for the Azure 'uaenorth' region. */
|
|
1847
|
+
RegionalAuthority["UAENorth"] = "uaenorth";
|
|
1848
|
+
/** Uses the {@link RegionalAuthority} for the Azure 'southafricanorth' region. */
|
|
1849
|
+
RegionalAuthority["SouthAfricaNorth"] = "southafricanorth";
|
|
1850
|
+
/** Uses the {@link RegionalAuthority} for the Azure 'southafricawest' region. */
|
|
1851
|
+
RegionalAuthority["SouthAfricaWest"] = "southafricawest";
|
|
1852
|
+
/** Uses the {@link RegionalAuthority} for the Azure 'chinanorth' region. */
|
|
1853
|
+
RegionalAuthority["ChinaNorth"] = "chinanorth";
|
|
1854
|
+
/** Uses the {@link RegionalAuthority} for the Azure 'chinaeast' region. */
|
|
1855
|
+
RegionalAuthority["ChinaEast"] = "chinaeast";
|
|
1856
|
+
/** Uses the {@link RegionalAuthority} for the Azure 'chinanorth2' region. */
|
|
1857
|
+
RegionalAuthority["ChinaNorth2"] = "chinanorth2";
|
|
1858
|
+
/** Uses the {@link RegionalAuthority} for the Azure 'chinaeast2' region. */
|
|
1859
|
+
RegionalAuthority["ChinaEast2"] = "chinaeast2";
|
|
1860
|
+
/** Uses the {@link RegionalAuthority} for the Azure 'germanycentral' region. */
|
|
1861
|
+
RegionalAuthority["GermanyCentral"] = "germanycentral";
|
|
1862
|
+
/** Uses the {@link RegionalAuthority} for the Azure 'germanynortheast' region. */
|
|
1863
|
+
RegionalAuthority["GermanyNorthEast"] = "germanynortheast";
|
|
1864
|
+
/** Uses the {@link RegionalAuthority} for the Azure 'usgovvirginia' region. */
|
|
1865
|
+
RegionalAuthority["GovernmentUSVirginia"] = "usgovvirginia";
|
|
1866
|
+
/** Uses the {@link RegionalAuthority} for the Azure 'usgoviowa' region. */
|
|
1867
|
+
RegionalAuthority["GovernmentUSIowa"] = "usgoviowa";
|
|
1868
|
+
/** Uses the {@link RegionalAuthority} for the Azure 'usgovarizona' region. */
|
|
1869
|
+
RegionalAuthority["GovernmentUSArizona"] = "usgovarizona";
|
|
1870
|
+
/** Uses the {@link RegionalAuthority} for the Azure 'usgovtexas' region. */
|
|
1871
|
+
RegionalAuthority["GovernmentUSTexas"] = "usgovtexas";
|
|
1872
|
+
/** Uses the {@link RegionalAuthority} for the Azure 'usdodeast' region. */
|
|
1873
|
+
RegionalAuthority["GovernmentUSDodEast"] = "usdodeast";
|
|
1874
|
+
/** Uses the {@link RegionalAuthority} for the Azure 'usdodcentral' region. */
|
|
1875
|
+
RegionalAuthority["GovernmentUSDodCentral"] = "usdodcentral";
|
|
1876
|
+
})(RegionalAuthority || (RegionalAuthority = {}));
|
|
1877
|
+
/**
|
|
1878
|
+
* Calculates the correct regional authority based on the supplied value
|
|
1879
|
+
* and the AZURE_REGIONAL_AUTHORITY_NAME environment variable.
|
|
1880
|
+
*
|
|
1881
|
+
* Values will be returned verbatim, except for {@link RegionalAuthority.AutoDiscoverRegion}
|
|
1882
|
+
* which is mapped to a value MSAL can understand.
|
|
1883
|
+
*
|
|
1884
|
+
* @internal
|
|
1885
|
+
*/
|
|
1886
|
+
function calculateRegionalAuthority(regionalAuthority) {
|
|
1887
|
+
// Note: as of today only 3 credentials support regional authority, and the parameter
|
|
1888
|
+
// is not exposed via the public API. Regional Authority is _only_ supported
|
|
1889
|
+
// via the AZURE_REGIONAL_AUTHORITY_NAME env var and _only_ for: ClientSecretCredential, ClientCertificateCredential, and ClientAssertionCredential.
|
|
1890
|
+
var _a, _b;
|
|
1891
|
+
// Accepting the regionalAuthority parameter will allow us to support it in the future.
|
|
1892
|
+
let azureRegion = regionalAuthority;
|
|
1893
|
+
if (azureRegion === undefined &&
|
|
1894
|
+
((_b = (_a = globalThis.process) === null || _a === void 0 ? void 0 : _a.env) === null || _b === void 0 ? void 0 : _b.AZURE_REGIONAL_AUTHORITY_NAME) !== undefined) {
|
|
1895
|
+
azureRegion = process.env.AZURE_REGIONAL_AUTHORITY_NAME;
|
|
1896
|
+
}
|
|
1897
|
+
if (azureRegion === RegionalAuthority.AutoDiscoverRegion) {
|
|
1898
|
+
return "AUTO_DISCOVER";
|
|
1899
|
+
}
|
|
1900
|
+
return azureRegion;
|
|
1901
|
+
}
|
|
1902
|
+
|
|
1762
1903
|
// Copyright (c) Microsoft Corporation.
|
|
1763
1904
|
// Licensed under the MIT license.
|
|
1764
1905
|
/**
|
|
@@ -1819,9 +1960,11 @@ function createMsalClient(clientId, tenantId, createMsalClientOptions = {}) {
|
|
|
1819
1960
|
const appKey = options.enableCae ? "CAE" : "default";
|
|
1820
1961
|
let confidentialClientApp = confidentialApps.get(appKey);
|
|
1821
1962
|
if (confidentialClientApp) {
|
|
1963
|
+
msalLogger.getToken.info("Existing ConfidentialClientApplication found in cache, returning it.");
|
|
1822
1964
|
return confidentialClientApp;
|
|
1823
1965
|
}
|
|
1824
1966
|
// Initialize a new app and cache it
|
|
1967
|
+
msalLogger.getToken.info(`Creating new ConfidentialClientApplication with CAE ${options.enableCae ? "enabled" : "disabled"}.`);
|
|
1825
1968
|
const cachePlugin = options.enableCae
|
|
1826
1969
|
? state.pluginConfiguration.cache.cachePluginCae
|
|
1827
1970
|
: state.pluginConfiguration.cache.cachePlugin;
|
|
@@ -1832,6 +1975,7 @@ function createMsalClient(clientId, tenantId, createMsalClientOptions = {}) {
|
|
|
1832
1975
|
}
|
|
1833
1976
|
async function getTokenSilent(app, scopes, options = {}) {
|
|
1834
1977
|
if (state.cachedAccount === null) {
|
|
1978
|
+
msalLogger.getToken.info("No cached account found in local state, attempting to load it from MSAL cache.");
|
|
1835
1979
|
const cache = app.getTokenCache();
|
|
1836
1980
|
const accounts = await cache.getAllAccounts();
|
|
1837
1981
|
if (accounts === undefined || accounts.length === 0) {
|
|
@@ -1851,14 +1995,19 @@ To work with multiple accounts for the same Client ID and Tenant ID, please prov
|
|
|
1851
1995
|
if (options.claims) {
|
|
1852
1996
|
state.cachedClaims = options.claims;
|
|
1853
1997
|
}
|
|
1854
|
-
|
|
1855
|
-
// https://github.com/Azure/azure-sdk-for-js/blob/727a7208251961b5036d8e1d86edaa944c42e3d6/sdk/identity/identity/src/msal/nodeFlows/msalNodeCommon.ts#L383-L395
|
|
1856
|
-
msalLogger.getToken.info("Attempting to acquire token silently");
|
|
1857
|
-
return app.acquireTokenSilent({
|
|
1998
|
+
const silentRequest = {
|
|
1858
1999
|
account: state.cachedAccount,
|
|
1859
2000
|
scopes,
|
|
1860
2001
|
claims: state.cachedClaims,
|
|
1861
|
-
}
|
|
2002
|
+
};
|
|
2003
|
+
if (state.pluginConfiguration.broker.isEnabled) {
|
|
2004
|
+
silentRequest.tokenQueryParameters || (silentRequest.tokenQueryParameters = {});
|
|
2005
|
+
if (state.pluginConfiguration.broker.enableMsaPassthrough) {
|
|
2006
|
+
silentRequest.tokenQueryParameters["msal_request_type"] = "consumer_passthrough";
|
|
2007
|
+
}
|
|
2008
|
+
}
|
|
2009
|
+
msalLogger.getToken.info("Attempting to acquire token silently");
|
|
2010
|
+
return app.acquireTokenSilent(silentRequest);
|
|
1862
2011
|
}
|
|
1863
2012
|
/**
|
|
1864
2013
|
* Performs silent authentication using MSAL to acquire an access token.
|
|
@@ -1913,6 +2062,7 @@ To work with multiple accounts for the same Client ID and Tenant ID, please prov
|
|
|
1913
2062
|
return withSilentAuthentication(msalApp, scopes, options, () => msalApp.acquireTokenByClientCredential({
|
|
1914
2063
|
scopes,
|
|
1915
2064
|
authority: state.msalConfig.auth.authority,
|
|
2065
|
+
azureRegion: calculateRegionalAuthority(),
|
|
1916
2066
|
claims: options === null || options === void 0 ? void 0 : options.claims,
|
|
1917
2067
|
}));
|
|
1918
2068
|
}
|
|
@@ -1923,6 +2073,7 @@ To work with multiple accounts for the same Client ID and Tenant ID, please prov
|
|
|
1923
2073
|
return withSilentAuthentication(msalApp, scopes, options, () => msalApp.acquireTokenByClientCredential({
|
|
1924
2074
|
scopes,
|
|
1925
2075
|
authority: state.msalConfig.auth.authority,
|
|
2076
|
+
azureRegion: calculateRegionalAuthority(),
|
|
1926
2077
|
claims: options === null || options === void 0 ? void 0 : options.claims,
|
|
1927
2078
|
clientAssertion,
|
|
1928
2079
|
}));
|
|
@@ -1933,6 +2084,7 @@ To work with multiple accounts for the same Client ID and Tenant ID, please prov
|
|
|
1933
2084
|
const msalApp = await getConfidentialApp(options);
|
|
1934
2085
|
return withSilentAuthentication(msalApp, scopes, options, () => msalApp.acquireTokenByClientCredential({
|
|
1935
2086
|
scopes,
|
|
2087
|
+
azureRegion: calculateRegionalAuthority(),
|
|
1936
2088
|
authority: state.msalConfig.auth.authority,
|
|
1937
2089
|
claims: options === null || options === void 0 ? void 0 : options.claims,
|
|
1938
2090
|
}));
|
|
@@ -3217,142 +3369,6 @@ class ClientSecretCredential {
|
|
|
3217
3369
|
}
|
|
3218
3370
|
}
|
|
3219
3371
|
|
|
3220
|
-
// Copyright (c) Microsoft Corporation.
|
|
3221
|
-
// Licensed under the MIT license.
|
|
3222
|
-
/**
|
|
3223
|
-
* Helps specify a regional authority, or "AutoDiscoverRegion" to auto-detect the region.
|
|
3224
|
-
*/
|
|
3225
|
-
var RegionalAuthority;
|
|
3226
|
-
(function (RegionalAuthority) {
|
|
3227
|
-
/** Instructs MSAL to attempt to discover the region */
|
|
3228
|
-
RegionalAuthority["AutoDiscoverRegion"] = "AutoDiscoverRegion";
|
|
3229
|
-
/** Uses the {@link RegionalAuthority} for the Azure 'westus' region. */
|
|
3230
|
-
RegionalAuthority["USWest"] = "westus";
|
|
3231
|
-
/** Uses the {@link RegionalAuthority} for the Azure 'westus2' region. */
|
|
3232
|
-
RegionalAuthority["USWest2"] = "westus2";
|
|
3233
|
-
/** Uses the {@link RegionalAuthority} for the Azure 'centralus' region. */
|
|
3234
|
-
RegionalAuthority["USCentral"] = "centralus";
|
|
3235
|
-
/** Uses the {@link RegionalAuthority} for the Azure 'eastus' region. */
|
|
3236
|
-
RegionalAuthority["USEast"] = "eastus";
|
|
3237
|
-
/** Uses the {@link RegionalAuthority} for the Azure 'eastus2' region. */
|
|
3238
|
-
RegionalAuthority["USEast2"] = "eastus2";
|
|
3239
|
-
/** Uses the {@link RegionalAuthority} for the Azure 'northcentralus' region. */
|
|
3240
|
-
RegionalAuthority["USNorthCentral"] = "northcentralus";
|
|
3241
|
-
/** Uses the {@link RegionalAuthority} for the Azure 'southcentralus' region. */
|
|
3242
|
-
RegionalAuthority["USSouthCentral"] = "southcentralus";
|
|
3243
|
-
/** Uses the {@link RegionalAuthority} for the Azure 'westcentralus' region. */
|
|
3244
|
-
RegionalAuthority["USWestCentral"] = "westcentralus";
|
|
3245
|
-
/** Uses the {@link RegionalAuthority} for the Azure 'canadacentral' region. */
|
|
3246
|
-
RegionalAuthority["CanadaCentral"] = "canadacentral";
|
|
3247
|
-
/** Uses the {@link RegionalAuthority} for the Azure 'canadaeast' region. */
|
|
3248
|
-
RegionalAuthority["CanadaEast"] = "canadaeast";
|
|
3249
|
-
/** Uses the {@link RegionalAuthority} for the Azure 'brazilsouth' region. */
|
|
3250
|
-
RegionalAuthority["BrazilSouth"] = "brazilsouth";
|
|
3251
|
-
/** Uses the {@link RegionalAuthority} for the Azure 'northeurope' region. */
|
|
3252
|
-
RegionalAuthority["EuropeNorth"] = "northeurope";
|
|
3253
|
-
/** Uses the {@link RegionalAuthority} for the Azure 'westeurope' region. */
|
|
3254
|
-
RegionalAuthority["EuropeWest"] = "westeurope";
|
|
3255
|
-
/** Uses the {@link RegionalAuthority} for the Azure 'uksouth' region. */
|
|
3256
|
-
RegionalAuthority["UKSouth"] = "uksouth";
|
|
3257
|
-
/** Uses the {@link RegionalAuthority} for the Azure 'ukwest' region. */
|
|
3258
|
-
RegionalAuthority["UKWest"] = "ukwest";
|
|
3259
|
-
/** Uses the {@link RegionalAuthority} for the Azure 'francecentral' region. */
|
|
3260
|
-
RegionalAuthority["FranceCentral"] = "francecentral";
|
|
3261
|
-
/** Uses the {@link RegionalAuthority} for the Azure 'francesouth' region. */
|
|
3262
|
-
RegionalAuthority["FranceSouth"] = "francesouth";
|
|
3263
|
-
/** Uses the {@link RegionalAuthority} for the Azure 'switzerlandnorth' region. */
|
|
3264
|
-
RegionalAuthority["SwitzerlandNorth"] = "switzerlandnorth";
|
|
3265
|
-
/** Uses the {@link RegionalAuthority} for the Azure 'switzerlandwest' region. */
|
|
3266
|
-
RegionalAuthority["SwitzerlandWest"] = "switzerlandwest";
|
|
3267
|
-
/** Uses the {@link RegionalAuthority} for the Azure 'germanynorth' region. */
|
|
3268
|
-
RegionalAuthority["GermanyNorth"] = "germanynorth";
|
|
3269
|
-
/** Uses the {@link RegionalAuthority} for the Azure 'germanywestcentral' region. */
|
|
3270
|
-
RegionalAuthority["GermanyWestCentral"] = "germanywestcentral";
|
|
3271
|
-
/** Uses the {@link RegionalAuthority} for the Azure 'norwaywest' region. */
|
|
3272
|
-
RegionalAuthority["NorwayWest"] = "norwaywest";
|
|
3273
|
-
/** Uses the {@link RegionalAuthority} for the Azure 'norwayeast' region. */
|
|
3274
|
-
RegionalAuthority["NorwayEast"] = "norwayeast";
|
|
3275
|
-
/** Uses the {@link RegionalAuthority} for the Azure 'eastasia' region. */
|
|
3276
|
-
RegionalAuthority["AsiaEast"] = "eastasia";
|
|
3277
|
-
/** Uses the {@link RegionalAuthority} for the Azure 'southeastasia' region. */
|
|
3278
|
-
RegionalAuthority["AsiaSouthEast"] = "southeastasia";
|
|
3279
|
-
/** Uses the {@link RegionalAuthority} for the Azure 'japaneast' region. */
|
|
3280
|
-
RegionalAuthority["JapanEast"] = "japaneast";
|
|
3281
|
-
/** Uses the {@link RegionalAuthority} for the Azure 'japanwest' region. */
|
|
3282
|
-
RegionalAuthority["JapanWest"] = "japanwest";
|
|
3283
|
-
/** Uses the {@link RegionalAuthority} for the Azure 'australiaeast' region. */
|
|
3284
|
-
RegionalAuthority["AustraliaEast"] = "australiaeast";
|
|
3285
|
-
/** Uses the {@link RegionalAuthority} for the Azure 'australiasoutheast' region. */
|
|
3286
|
-
RegionalAuthority["AustraliaSouthEast"] = "australiasoutheast";
|
|
3287
|
-
/** Uses the {@link RegionalAuthority} for the Azure 'australiacentral' region. */
|
|
3288
|
-
RegionalAuthority["AustraliaCentral"] = "australiacentral";
|
|
3289
|
-
/** Uses the {@link RegionalAuthority} for the Azure 'australiacentral2' region. */
|
|
3290
|
-
RegionalAuthority["AustraliaCentral2"] = "australiacentral2";
|
|
3291
|
-
/** Uses the {@link RegionalAuthority} for the Azure 'centralindia' region. */
|
|
3292
|
-
RegionalAuthority["IndiaCentral"] = "centralindia";
|
|
3293
|
-
/** Uses the {@link RegionalAuthority} for the Azure 'southindia' region. */
|
|
3294
|
-
RegionalAuthority["IndiaSouth"] = "southindia";
|
|
3295
|
-
/** Uses the {@link RegionalAuthority} for the Azure 'westindia' region. */
|
|
3296
|
-
RegionalAuthority["IndiaWest"] = "westindia";
|
|
3297
|
-
/** Uses the {@link RegionalAuthority} for the Azure 'koreasouth' region. */
|
|
3298
|
-
RegionalAuthority["KoreaSouth"] = "koreasouth";
|
|
3299
|
-
/** Uses the {@link RegionalAuthority} for the Azure 'koreacentral' region. */
|
|
3300
|
-
RegionalAuthority["KoreaCentral"] = "koreacentral";
|
|
3301
|
-
/** Uses the {@link RegionalAuthority} for the Azure 'uaecentral' region. */
|
|
3302
|
-
RegionalAuthority["UAECentral"] = "uaecentral";
|
|
3303
|
-
/** Uses the {@link RegionalAuthority} for the Azure 'uaenorth' region. */
|
|
3304
|
-
RegionalAuthority["UAENorth"] = "uaenorth";
|
|
3305
|
-
/** Uses the {@link RegionalAuthority} for the Azure 'southafricanorth' region. */
|
|
3306
|
-
RegionalAuthority["SouthAfricaNorth"] = "southafricanorth";
|
|
3307
|
-
/** Uses the {@link RegionalAuthority} for the Azure 'southafricawest' region. */
|
|
3308
|
-
RegionalAuthority["SouthAfricaWest"] = "southafricawest";
|
|
3309
|
-
/** Uses the {@link RegionalAuthority} for the Azure 'chinanorth' region. */
|
|
3310
|
-
RegionalAuthority["ChinaNorth"] = "chinanorth";
|
|
3311
|
-
/** Uses the {@link RegionalAuthority} for the Azure 'chinaeast' region. */
|
|
3312
|
-
RegionalAuthority["ChinaEast"] = "chinaeast";
|
|
3313
|
-
/** Uses the {@link RegionalAuthority} for the Azure 'chinanorth2' region. */
|
|
3314
|
-
RegionalAuthority["ChinaNorth2"] = "chinanorth2";
|
|
3315
|
-
/** Uses the {@link RegionalAuthority} for the Azure 'chinaeast2' region. */
|
|
3316
|
-
RegionalAuthority["ChinaEast2"] = "chinaeast2";
|
|
3317
|
-
/** Uses the {@link RegionalAuthority} for the Azure 'germanycentral' region. */
|
|
3318
|
-
RegionalAuthority["GermanyCentral"] = "germanycentral";
|
|
3319
|
-
/** Uses the {@link RegionalAuthority} for the Azure 'germanynortheast' region. */
|
|
3320
|
-
RegionalAuthority["GermanyNorthEast"] = "germanynortheast";
|
|
3321
|
-
/** Uses the {@link RegionalAuthority} for the Azure 'usgovvirginia' region. */
|
|
3322
|
-
RegionalAuthority["GovernmentUSVirginia"] = "usgovvirginia";
|
|
3323
|
-
/** Uses the {@link RegionalAuthority} for the Azure 'usgoviowa' region. */
|
|
3324
|
-
RegionalAuthority["GovernmentUSIowa"] = "usgoviowa";
|
|
3325
|
-
/** Uses the {@link RegionalAuthority} for the Azure 'usgovarizona' region. */
|
|
3326
|
-
RegionalAuthority["GovernmentUSArizona"] = "usgovarizona";
|
|
3327
|
-
/** Uses the {@link RegionalAuthority} for the Azure 'usgovtexas' region. */
|
|
3328
|
-
RegionalAuthority["GovernmentUSTexas"] = "usgovtexas";
|
|
3329
|
-
/** Uses the {@link RegionalAuthority} for the Azure 'usdodeast' region. */
|
|
3330
|
-
RegionalAuthority["GovernmentUSDodEast"] = "usdodeast";
|
|
3331
|
-
/** Uses the {@link RegionalAuthority} for the Azure 'usdodcentral' region. */
|
|
3332
|
-
RegionalAuthority["GovernmentUSDodCentral"] = "usdodcentral";
|
|
3333
|
-
})(RegionalAuthority || (RegionalAuthority = {}));
|
|
3334
|
-
/**
|
|
3335
|
-
* Calculates the correct regional authority based on the supplied value
|
|
3336
|
-
* and the AZURE_REGIONAL_AUTHORITY_NAME environment variable.
|
|
3337
|
-
*
|
|
3338
|
-
* Values will be returned verbatim, except for {@link RegionalAuthority.AutoDiscoverRegion}
|
|
3339
|
-
* which is mapped to a value MSAL can understand.
|
|
3340
|
-
*
|
|
3341
|
-
* @internal
|
|
3342
|
-
*/
|
|
3343
|
-
function calculateRegionalAuthority(regionalAuthority) {
|
|
3344
|
-
var _a, _b;
|
|
3345
|
-
let azureRegion = regionalAuthority;
|
|
3346
|
-
if (azureRegion === undefined &&
|
|
3347
|
-
((_b = (_a = globalThis.process) === null || _a === void 0 ? void 0 : _a.env) === null || _b === void 0 ? void 0 : _b.AZURE_REGIONAL_AUTHORITY_NAME) !== undefined) {
|
|
3348
|
-
azureRegion = process.env.AZURE_REGIONAL_AUTHORITY_NAME;
|
|
3349
|
-
}
|
|
3350
|
-
if (azureRegion === RegionalAuthority.AutoDiscoverRegion) {
|
|
3351
|
-
return "AUTO_DISCOVER";
|
|
3352
|
-
}
|
|
3353
|
-
return azureRegion;
|
|
3354
|
-
}
|
|
3355
|
-
|
|
3356
3372
|
// Copyright (c) Microsoft Corporation.
|
|
3357
3373
|
// Licensed under the MIT license.
|
|
3358
3374
|
/**
|
|
@@ -4546,6 +4562,57 @@ class OnBehalfOfCredential {
|
|
|
4546
4562
|
}
|
|
4547
4563
|
}
|
|
4548
4564
|
|
|
4565
|
+
// Copyright (c) Microsoft Corporation.
|
|
4566
|
+
// Licensed under the MIT license.
|
|
4567
|
+
/**
|
|
4568
|
+
* Returns a callback that provides a bearer token.
|
|
4569
|
+
* For example, the bearer token can be used to authenticate a request as follows:
|
|
4570
|
+
* ```js
|
|
4571
|
+
* import { DefaultAzureCredential } from "@azure/identity";
|
|
4572
|
+
*
|
|
4573
|
+
* const credential = new DefaultAzureCredential();
|
|
4574
|
+
* const scope = "https://cognitiveservices.azure.com/.default";
|
|
4575
|
+
* const getAccessToken = getBearerTokenProvider(credential, scope);
|
|
4576
|
+
* const token = await getAccessToken();
|
|
4577
|
+
*
|
|
4578
|
+
* // usage
|
|
4579
|
+
* const request = createPipelineRequest({ url: "https://example.com" });
|
|
4580
|
+
* request.headers.set("Authorization", `Bearer ${token}`);
|
|
4581
|
+
* ```
|
|
4582
|
+
*
|
|
4583
|
+
* @param credential - The credential used to authenticate the request.
|
|
4584
|
+
* @param scopes - The scopes required for the bearer token.
|
|
4585
|
+
* @param options - Options to configure the token provider.
|
|
4586
|
+
* @returns a callback that provides a bearer token.
|
|
4587
|
+
*/
|
|
4588
|
+
function getBearerTokenProvider(credential, scopes, options) {
|
|
4589
|
+
const { abortSignal, tracingOptions } = options || {};
|
|
4590
|
+
const pipeline = coreRestPipeline.createEmptyPipeline();
|
|
4591
|
+
pipeline.addPolicy(coreRestPipeline.bearerTokenAuthenticationPolicy({ credential, scopes }));
|
|
4592
|
+
async function getRefreshedToken() {
|
|
4593
|
+
var _a;
|
|
4594
|
+
// Create a pipeline with just the bearer token policy
|
|
4595
|
+
// and run a dummy request through it to get the token
|
|
4596
|
+
const res = await pipeline.sendRequest({
|
|
4597
|
+
sendRequest: (request) => Promise.resolve({
|
|
4598
|
+
request,
|
|
4599
|
+
status: 200,
|
|
4600
|
+
headers: request.headers,
|
|
4601
|
+
}),
|
|
4602
|
+
}, coreRestPipeline.createPipelineRequest({
|
|
4603
|
+
url: "https://example.com",
|
|
4604
|
+
abortSignal,
|
|
4605
|
+
tracingOptions,
|
|
4606
|
+
}));
|
|
4607
|
+
const accessToken = (_a = res.headers.get("authorization")) === null || _a === void 0 ? void 0 : _a.split(" ")[1];
|
|
4608
|
+
if (!accessToken) {
|
|
4609
|
+
throw new Error("Failed to get access token");
|
|
4610
|
+
}
|
|
4611
|
+
return accessToken;
|
|
4612
|
+
}
|
|
4613
|
+
return getRefreshedToken;
|
|
4614
|
+
}
|
|
4615
|
+
|
|
4549
4616
|
// Copyright (c) Microsoft Corporation.
|
|
4550
4617
|
// Licensed under the MIT license.
|
|
4551
4618
|
/**
|
|
@@ -4580,6 +4647,7 @@ exports.UsernamePasswordCredential = UsernamePasswordCredential;
|
|
|
4580
4647
|
exports.VisualStudioCodeCredential = VisualStudioCodeCredential;
|
|
4581
4648
|
exports.WorkloadIdentityCredential = WorkloadIdentityCredential;
|
|
4582
4649
|
exports.deserializeAuthenticationRecord = deserializeAuthenticationRecord;
|
|
4650
|
+
exports.getBearerTokenProvider = getBearerTokenProvider;
|
|
4583
4651
|
exports.getDefaultAzureCredential = getDefaultAzureCredential;
|
|
4584
4652
|
exports.logger = logger$p;
|
|
4585
4653
|
exports.serializeAuthenticationRecord = serializeAuthenticationRecord;
|