@azure/msal-browser 2.34.0 → 2.36.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/README.md +1 -1
- package/dist/_virtual/_tslib.js +1 -1
- package/dist/app/ClientApplication.d.ts +2 -2
- package/dist/app/ClientApplication.d.ts.map +1 -1
- package/dist/app/ClientApplication.js +37 -20
- package/dist/app/ClientApplication.js.map +1 -1
- package/dist/app/IPublicClientApplication.js +1 -1
- package/dist/app/PublicClientApplication.js +1 -1
- package/dist/broker/nativeBroker/NativeMessageHandler.js +1 -1
- package/dist/cache/AsyncMemoryStorage.js +1 -1
- package/dist/cache/BrowserCacheManager.d.ts +63 -4
- package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
- package/dist/cache/BrowserCacheManager.js +320 -15
- package/dist/cache/BrowserCacheManager.js.map +1 -1
- package/dist/cache/BrowserStorage.js +1 -1
- package/dist/cache/CryptoKeyStore.js +1 -1
- package/dist/cache/DatabaseStorage.js +1 -1
- package/dist/cache/MemoryStorage.js +1 -1
- package/dist/cache/TokenCache.js +1 -1
- package/dist/config/Configuration.d.ts +9 -1
- package/dist/config/Configuration.d.ts.map +1 -1
- package/dist/config/Configuration.js +5 -2
- package/dist/config/Configuration.js.map +1 -1
- package/dist/crypto/BrowserCrypto.js +1 -1
- package/dist/crypto/CryptoOps.js +1 -1
- package/dist/crypto/GuidGenerator.js +1 -1
- package/dist/crypto/ModernBrowserCrypto.js +1 -1
- package/dist/crypto/MsBrowserCrypto.js +1 -1
- package/dist/crypto/MsrBrowserCrypto.js +1 -1
- package/dist/crypto/PkceGenerator.js +1 -1
- package/dist/crypto/SignedHttpRequest.js +1 -1
- package/dist/encode/Base64Decode.js +1 -1
- package/dist/encode/Base64Encode.js +1 -1
- package/dist/error/BrowserAuthError.js +1 -1
- package/dist/error/BrowserConfigurationAuthError.js +1 -1
- package/dist/error/NativeAuthError.js +1 -1
- package/dist/event/EventHandler.js +1 -1
- package/dist/event/EventMessage.js +1 -1
- package/dist/event/EventType.js +1 -1
- package/dist/index.cjs.js +1036 -578
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/interaction_client/BaseInteractionClient.js +1 -1
- package/dist/interaction_client/HybridSpaAuthorizationCodeClient.js +1 -1
- package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
- package/dist/interaction_client/NativeInteractionClient.js +8 -9
- package/dist/interaction_client/NativeInteractionClient.js.map +1 -1
- package/dist/interaction_client/PopupClient.js +1 -1
- package/dist/interaction_client/RedirectClient.js +1 -1
- package/dist/interaction_client/SilentAuthCodeClient.js +1 -1
- package/dist/interaction_client/SilentCacheClient.js +1 -1
- package/dist/interaction_client/SilentIframeClient.js +1 -1
- package/dist/interaction_client/SilentRefreshClient.js +1 -1
- package/dist/interaction_client/StandardInteractionClient.js +1 -1
- package/dist/interaction_handler/InteractionHandler.js +1 -1
- package/dist/interaction_handler/RedirectHandler.js +1 -1
- package/dist/interaction_handler/SilentHandler.js +1 -1
- package/dist/internals.js +1 -1
- package/dist/navigation/NavigationClient.js +1 -1
- package/dist/network/FetchClient.js +1 -1
- package/dist/network/XhrClient.js +1 -1
- package/dist/packageMetadata.d.ts +1 -1
- package/dist/packageMetadata.js +2 -2
- package/dist/packageMetadata.js.map +1 -1
- package/dist/telemetry/BrowserPerformanceClient.js +2 -2
- package/dist/telemetry/BrowserPerformanceClient.js.map +1 -1
- package/dist/telemetry/BrowserPerformanceMeasurement.js +1 -1
- package/dist/utils/BrowserConstants.d.ts +4 -0
- package/dist/utils/BrowserConstants.d.ts.map +1 -1
- package/dist/utils/BrowserConstants.js +7 -2
- package/dist/utils/BrowserConstants.js.map +1 -1
- package/dist/utils/BrowserProtocolUtils.js +1 -1
- package/dist/utils/BrowserStringUtils.js +1 -1
- package/dist/utils/BrowserUtils.js +1 -1
- package/dist/utils/MathUtils.js +1 -1
- package/lib/msal-browser.js +1036 -578
- package/lib/msal-browser.js.map +1 -1
- package/lib/msal-browser.min.js +38 -40
- package/package.json +2 -2
package/lib/msal-browser.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @azure/msal-browser v2.
|
|
1
|
+
/*! @azure/msal-browser v2.36.0 2023-04-18 */
|
|
2
2
|
'use strict';
|
|
3
3
|
(function (global, factory) {
|
|
4
4
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
@@ -119,7 +119,7 @@
|
|
|
119
119
|
return ar;
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
/*! @azure/msal-common
|
|
122
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
123
123
|
/*! *****************************************************************************
|
|
124
124
|
Copyright (c) Microsoft Corporation.
|
|
125
125
|
|
|
@@ -206,7 +206,7 @@
|
|
|
206
206
|
return r;
|
|
207
207
|
}
|
|
208
208
|
|
|
209
|
-
/*! @azure/msal-common
|
|
209
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
210
210
|
|
|
211
211
|
/*
|
|
212
212
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -453,22 +453,6 @@
|
|
|
453
453
|
CredentialType["ACCESS_TOKEN_WITH_AUTH_SCHEME"] = "AccessToken_With_AuthScheme";
|
|
454
454
|
CredentialType["REFRESH_TOKEN"] = "RefreshToken";
|
|
455
455
|
})(CredentialType || (CredentialType = {}));
|
|
456
|
-
/**
|
|
457
|
-
* Credential Type stored in the cache
|
|
458
|
-
*/
|
|
459
|
-
var CacheSchemaType;
|
|
460
|
-
(function (CacheSchemaType) {
|
|
461
|
-
CacheSchemaType["ACCOUNT"] = "Account";
|
|
462
|
-
CacheSchemaType["CREDENTIAL"] = "Credential";
|
|
463
|
-
CacheSchemaType["ID_TOKEN"] = "IdToken";
|
|
464
|
-
CacheSchemaType["ACCESS_TOKEN"] = "AccessToken";
|
|
465
|
-
CacheSchemaType["REFRESH_TOKEN"] = "RefreshToken";
|
|
466
|
-
CacheSchemaType["APP_METADATA"] = "AppMetadata";
|
|
467
|
-
CacheSchemaType["TEMPORARY"] = "TempCache";
|
|
468
|
-
CacheSchemaType["TELEMETRY"] = "Telemetry";
|
|
469
|
-
CacheSchemaType["UNDEFINED"] = "Undefined";
|
|
470
|
-
CacheSchemaType["THROTTLING"] = "Throttling";
|
|
471
|
-
})(CacheSchemaType || (CacheSchemaType = {}));
|
|
472
456
|
/**
|
|
473
457
|
* Combine all cache types
|
|
474
458
|
*/
|
|
@@ -591,7 +575,7 @@
|
|
|
591
575
|
JsonTypes["Pop"] = "pop";
|
|
592
576
|
})(JsonTypes || (JsonTypes = {}));
|
|
593
577
|
|
|
594
|
-
/*! @azure/msal-common
|
|
578
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
595
579
|
|
|
596
580
|
/*
|
|
597
581
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -647,7 +631,7 @@
|
|
|
647
631
|
return AuthError;
|
|
648
632
|
}(Error));
|
|
649
633
|
|
|
650
|
-
/*! @azure/msal-common
|
|
634
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
651
635
|
|
|
652
636
|
/*
|
|
653
637
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -722,7 +706,7 @@
|
|
|
722
706
|
}
|
|
723
707
|
};
|
|
724
708
|
|
|
725
|
-
/*! @azure/msal-common
|
|
709
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
726
710
|
|
|
727
711
|
/*
|
|
728
712
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1237,7 +1221,7 @@
|
|
|
1237
1221
|
return ClientAuthError;
|
|
1238
1222
|
}(AuthError));
|
|
1239
1223
|
|
|
1240
|
-
/*! @azure/msal-common
|
|
1224
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
1241
1225
|
|
|
1242
1226
|
/*
|
|
1243
1227
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1362,7 +1346,7 @@
|
|
|
1362
1346
|
return StringUtils;
|
|
1363
1347
|
}());
|
|
1364
1348
|
|
|
1365
|
-
/*! @azure/msal-common
|
|
1349
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
1366
1350
|
|
|
1367
1351
|
/*
|
|
1368
1352
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1552,12 +1536,12 @@
|
|
|
1552
1536
|
return Logger;
|
|
1553
1537
|
}());
|
|
1554
1538
|
|
|
1555
|
-
/*! @azure/msal-common
|
|
1539
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
1556
1540
|
/* eslint-disable header/header */
|
|
1557
1541
|
var name$1 = "@azure/msal-common";
|
|
1558
|
-
var version$1 = "
|
|
1542
|
+
var version$1 = "12.0.0";
|
|
1559
1543
|
|
|
1560
|
-
/*! @azure/msal-common
|
|
1544
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
1561
1545
|
/*
|
|
1562
1546
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
1563
1547
|
* Licensed under the MIT License.
|
|
@@ -1578,184 +1562,7 @@
|
|
|
1578
1562
|
AzureCloudInstance["AzureUsGovernment"] = "https://login.microsoftonline.us";
|
|
1579
1563
|
})(exports.AzureCloudInstance || (exports.AzureCloudInstance = {}));
|
|
1580
1564
|
|
|
1581
|
-
/*! @azure/msal-common
|
|
1582
|
-
|
|
1583
|
-
/*
|
|
1584
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
1585
|
-
* Licensed under the MIT License.
|
|
1586
|
-
*/
|
|
1587
|
-
/**
|
|
1588
|
-
* Base type for credentials to be stored in the cache: eg: ACCESS_TOKEN, ID_TOKEN etc
|
|
1589
|
-
*
|
|
1590
|
-
* Key:Value Schema:
|
|
1591
|
-
*
|
|
1592
|
-
* Key: <home_account_id*>-<environment>-<credential_type>-<client_id>-<realm*>-<target*>-<requestedClaims*>-<scheme*>
|
|
1593
|
-
*
|
|
1594
|
-
* Value Schema:
|
|
1595
|
-
* {
|
|
1596
|
-
* homeAccountId: home account identifier for the auth scheme,
|
|
1597
|
-
* environment: entity that issued the token, represented as a full host
|
|
1598
|
-
* credentialType: Type of credential as a string, can be one of the following: RefreshToken, AccessToken, IdToken, Password, Cookie, Certificate, Other
|
|
1599
|
-
* clientId: client ID of the application
|
|
1600
|
-
* secret: Actual credential as a string
|
|
1601
|
-
* familyId: Family ID identifier, usually only used for refresh tokens
|
|
1602
|
-
* realm: Full tenant or organizational identifier that the account belongs to
|
|
1603
|
-
* target: Permissions that are included in the token, or for refresh tokens, the resource identifier.
|
|
1604
|
-
* tokenType: Matches the authentication scheme for which the token was issued (i.e. Bearer or pop)
|
|
1605
|
-
* requestedClaimsHash: Matches the SHA 256 hash of the claims object included in the token request
|
|
1606
|
-
* userAssertionHash: Matches the SHA 256 hash of the obo_assertion for the OBO flow
|
|
1607
|
-
* }
|
|
1608
|
-
*/
|
|
1609
|
-
var CredentialEntity = /** @class */ (function () {
|
|
1610
|
-
function CredentialEntity() {
|
|
1611
|
-
}
|
|
1612
|
-
/**
|
|
1613
|
-
* Initializes a map with credential {CredentialType} regular expressions.
|
|
1614
|
-
*/
|
|
1615
|
-
CredentialEntity._initRegex = function () {
|
|
1616
|
-
var separator = Separators.CACHE_KEY_SEPARATOR;
|
|
1617
|
-
CredentialEntity.credentialRegexMap = new Map();
|
|
1618
|
-
for (var _i = 0, _a = Object.keys(CredentialType); _i < _a.length; _i++) {
|
|
1619
|
-
var credKey = _a[_i];
|
|
1620
|
-
var credVal = CredentialType[credKey].toLowerCase();
|
|
1621
|
-
try {
|
|
1622
|
-
// Verify credential type is preceded by a valid host name (environment) using lookbehind
|
|
1623
|
-
CredentialEntity.credentialRegexMap.set(CredentialType[credKey], new RegExp("(?<=" + separator + CredentialEntity.credentialDomainRegex + ")" + separator + credVal + separator));
|
|
1624
|
-
}
|
|
1625
|
-
catch (err) {
|
|
1626
|
-
// Lookbehind is not supported (Safari or older versions of IE) - removing it
|
|
1627
|
-
CredentialEntity.credentialRegexMap.set(CredentialType[credKey], new RegExp("" + separator + CredentialEntity.credentialDomainRegex + separator + credVal + separator));
|
|
1628
|
-
}
|
|
1629
|
-
}
|
|
1630
|
-
};
|
|
1631
|
-
/**
|
|
1632
|
-
* Generate Account Id key component as per the schema: <home_account_id>-<environment>
|
|
1633
|
-
*/
|
|
1634
|
-
CredentialEntity.prototype.generateAccountId = function () {
|
|
1635
|
-
return CredentialEntity.generateAccountIdForCacheKey(this.homeAccountId, this.environment);
|
|
1636
|
-
};
|
|
1637
|
-
/**
|
|
1638
|
-
* Generate Credential Id key component as per the schema: <credential_type>-<client_id>-<realm>
|
|
1639
|
-
*/
|
|
1640
|
-
CredentialEntity.prototype.generateCredentialId = function () {
|
|
1641
|
-
return CredentialEntity.generateCredentialIdForCacheKey(this.credentialType, this.clientId, this.realm, this.familyId);
|
|
1642
|
-
};
|
|
1643
|
-
/**
|
|
1644
|
-
* Generate target key component as per schema: <target>
|
|
1645
|
-
*/
|
|
1646
|
-
CredentialEntity.prototype.generateTarget = function () {
|
|
1647
|
-
return CredentialEntity.generateTargetForCacheKey(this.target);
|
|
1648
|
-
};
|
|
1649
|
-
/**
|
|
1650
|
-
* generates credential key
|
|
1651
|
-
*/
|
|
1652
|
-
CredentialEntity.prototype.generateCredentialKey = function () {
|
|
1653
|
-
return CredentialEntity.generateCredentialCacheKey(this.homeAccountId, this.environment, this.credentialType, this.clientId, this.realm, this.target, this.familyId, this.tokenType, this.requestedClaimsHash);
|
|
1654
|
-
};
|
|
1655
|
-
/**
|
|
1656
|
-
* returns the type of the cache (in this case credential)
|
|
1657
|
-
*/
|
|
1658
|
-
CredentialEntity.prototype.generateType = function () {
|
|
1659
|
-
switch (this.credentialType) {
|
|
1660
|
-
case CredentialType.ID_TOKEN:
|
|
1661
|
-
return CacheType.ID_TOKEN;
|
|
1662
|
-
case CredentialType.ACCESS_TOKEN:
|
|
1663
|
-
case CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME:
|
|
1664
|
-
return CacheType.ACCESS_TOKEN;
|
|
1665
|
-
case CredentialType.REFRESH_TOKEN:
|
|
1666
|
-
return CacheType.REFRESH_TOKEN;
|
|
1667
|
-
default: {
|
|
1668
|
-
throw ClientAuthError.createUnexpectedCredentialTypeError();
|
|
1669
|
-
}
|
|
1670
|
-
}
|
|
1671
|
-
};
|
|
1672
|
-
/**
|
|
1673
|
-
* helper function to return `CredentialType`
|
|
1674
|
-
* @param key
|
|
1675
|
-
*/
|
|
1676
|
-
CredentialEntity.getCredentialType = function (key) {
|
|
1677
|
-
var _a;
|
|
1678
|
-
for (var _i = 0, _b = Object.keys(CredentialType); _i < _b.length; _i++) {
|
|
1679
|
-
var credKey = _b[_i];
|
|
1680
|
-
if ((_a = this.credentialRegexMap.get(CredentialType[credKey])) === null || _a === void 0 ? void 0 : _a.test(key.toLowerCase())) {
|
|
1681
|
-
return CredentialType[credKey];
|
|
1682
|
-
}
|
|
1683
|
-
}
|
|
1684
|
-
return Constants.NOT_DEFINED;
|
|
1685
|
-
};
|
|
1686
|
-
/**
|
|
1687
|
-
* generates credential key
|
|
1688
|
-
* <home_account_id*>-\<environment>-<credential_type>-<client_id>-<realm\*>-<target\*>-<scheme\*>
|
|
1689
|
-
*/
|
|
1690
|
-
CredentialEntity.generateCredentialCacheKey = function (homeAccountId, environment, credentialType, clientId, realm, target, familyId, tokenType, requestedClaimsHash) {
|
|
1691
|
-
var credentialKey = [
|
|
1692
|
-
this.generateAccountIdForCacheKey(homeAccountId, environment),
|
|
1693
|
-
this.generateCredentialIdForCacheKey(credentialType, clientId, realm, familyId),
|
|
1694
|
-
this.generateTargetForCacheKey(target),
|
|
1695
|
-
this.generateClaimsHashForCacheKey(requestedClaimsHash),
|
|
1696
|
-
this.generateSchemeForCacheKey(tokenType)
|
|
1697
|
-
];
|
|
1698
|
-
return credentialKey.join(Separators.CACHE_KEY_SEPARATOR).toLowerCase();
|
|
1699
|
-
};
|
|
1700
|
-
/**
|
|
1701
|
-
* generates Account Id for keys
|
|
1702
|
-
* @param homeAccountId
|
|
1703
|
-
* @param environment
|
|
1704
|
-
*/
|
|
1705
|
-
CredentialEntity.generateAccountIdForCacheKey = function (homeAccountId, environment) {
|
|
1706
|
-
var accountId = [homeAccountId, environment];
|
|
1707
|
-
return accountId.join(Separators.CACHE_KEY_SEPARATOR).toLowerCase();
|
|
1708
|
-
};
|
|
1709
|
-
/**
|
|
1710
|
-
* Generates Credential Id for keys
|
|
1711
|
-
* @param credentialType
|
|
1712
|
-
* @param realm
|
|
1713
|
-
* @param clientId
|
|
1714
|
-
* @param familyId
|
|
1715
|
-
*/
|
|
1716
|
-
CredentialEntity.generateCredentialIdForCacheKey = function (credentialType, clientId, realm, familyId) {
|
|
1717
|
-
var clientOrFamilyId = credentialType === CredentialType.REFRESH_TOKEN
|
|
1718
|
-
? familyId || clientId
|
|
1719
|
-
: clientId;
|
|
1720
|
-
var credentialId = [
|
|
1721
|
-
credentialType,
|
|
1722
|
-
clientOrFamilyId,
|
|
1723
|
-
realm || Constants.EMPTY_STRING,
|
|
1724
|
-
];
|
|
1725
|
-
return credentialId.join(Separators.CACHE_KEY_SEPARATOR).toLowerCase();
|
|
1726
|
-
};
|
|
1727
|
-
/**
|
|
1728
|
-
* Generate target key component as per schema: <target>
|
|
1729
|
-
*/
|
|
1730
|
-
CredentialEntity.generateTargetForCacheKey = function (scopes) {
|
|
1731
|
-
return (scopes || Constants.EMPTY_STRING).toLowerCase();
|
|
1732
|
-
};
|
|
1733
|
-
/**
|
|
1734
|
-
* Generate requested claims key component as per schema: <requestedClaims>
|
|
1735
|
-
*/
|
|
1736
|
-
CredentialEntity.generateClaimsHashForCacheKey = function (requestedClaimsHash) {
|
|
1737
|
-
return (requestedClaimsHash || Constants.EMPTY_STRING).toLowerCase();
|
|
1738
|
-
};
|
|
1739
|
-
/**
|
|
1740
|
-
* Generate scheme key componenet as per schema: <scheme>
|
|
1741
|
-
*/
|
|
1742
|
-
CredentialEntity.generateSchemeForCacheKey = function (tokenType) {
|
|
1743
|
-
/*
|
|
1744
|
-
* PoP Tokens and SSH certs include scheme in cache key
|
|
1745
|
-
* Cast to lowercase to handle "bearer" from ADFS
|
|
1746
|
-
*/
|
|
1747
|
-
return (tokenType && tokenType.toLowerCase() !== exports.AuthenticationScheme.BEARER.toLowerCase()) ? tokenType.toLowerCase() : Constants.EMPTY_STRING;
|
|
1748
|
-
};
|
|
1749
|
-
/*
|
|
1750
|
-
* Match host names like "login.microsoftonline.com", "https://accounts.google.com:4000", https://localhost:5000,
|
|
1751
|
-
* "login.microsoftonline.com/common", "login.microsoftonline.com:4000/common", etc
|
|
1752
|
-
*/
|
|
1753
|
-
CredentialEntity.credentialDomainRegex = "(https?:\\/\\/)?((([\\w-]+\\.)*([\\w-]{1,63})(\\.(\\w{2,63})))|(localhost))(\\:[0-9]{4,5})?(\\/[\\w-]+)?";
|
|
1754
|
-
return CredentialEntity;
|
|
1755
|
-
}());
|
|
1756
|
-
CredentialEntity._initRegex();
|
|
1757
|
-
|
|
1758
|
-
/*! @azure/msal-common v11.0.0 2023-03-07 */
|
|
1565
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
1759
1566
|
|
|
1760
1567
|
/*
|
|
1761
1568
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2010,7 +1817,7 @@
|
|
|
2010
1817
|
return ClientConfigurationError;
|
|
2011
1818
|
}(ClientAuthError));
|
|
2012
1819
|
|
|
2013
|
-
/*! @azure/msal-common
|
|
1820
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
2014
1821
|
|
|
2015
1822
|
/*
|
|
2016
1823
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2043,6 +1850,21 @@
|
|
|
2043
1850
|
var inputScopes = scopeString.split(" ");
|
|
2044
1851
|
return new ScopeSet(inputScopes);
|
|
2045
1852
|
};
|
|
1853
|
+
/**
|
|
1854
|
+
* Creates the set of scopes to search for in cache lookups
|
|
1855
|
+
* @param inputScopeString
|
|
1856
|
+
* @returns
|
|
1857
|
+
*/
|
|
1858
|
+
ScopeSet.createSearchScopes = function (inputScopeString) {
|
|
1859
|
+
var scopeSet = new ScopeSet(inputScopeString);
|
|
1860
|
+
if (!scopeSet.containsOnlyOIDCScopes()) {
|
|
1861
|
+
scopeSet.removeOIDCScopes();
|
|
1862
|
+
}
|
|
1863
|
+
else {
|
|
1864
|
+
scopeSet.removeScope(Constants.OFFLINE_ACCESS_SCOPE);
|
|
1865
|
+
}
|
|
1866
|
+
return scopeSet;
|
|
1867
|
+
};
|
|
2046
1868
|
/**
|
|
2047
1869
|
* Used to validate the scopes input parameter requested by the developer.
|
|
2048
1870
|
* @param {Array<string>} inputScopes - Developer requested permissions. Not all scopes are guaranteed to be included in the access token returned.
|
|
@@ -2194,7 +2016,7 @@
|
|
|
2194
2016
|
return ScopeSet;
|
|
2195
2017
|
}());
|
|
2196
2018
|
|
|
2197
|
-
/*! @azure/msal-common
|
|
2019
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
2198
2020
|
|
|
2199
2021
|
/*
|
|
2200
2022
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2232,7 +2054,7 @@
|
|
|
2232
2054
|
};
|
|
2233
2055
|
}
|
|
2234
2056
|
|
|
2235
|
-
/*! @azure/msal-common
|
|
2057
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
2236
2058
|
/*
|
|
2237
2059
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2238
2060
|
* Licensed under the MIT License.
|
|
@@ -2247,7 +2069,7 @@
|
|
|
2247
2069
|
AuthorityType[AuthorityType["Dsts"] = 2] = "Dsts";
|
|
2248
2070
|
})(AuthorityType || (AuthorityType = {}));
|
|
2249
2071
|
|
|
2250
|
-
/*! @azure/msal-common
|
|
2072
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
2251
2073
|
|
|
2252
2074
|
/*
|
|
2253
2075
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2486,7 +2308,7 @@
|
|
|
2486
2308
|
return AccountEntity;
|
|
2487
2309
|
}());
|
|
2488
2310
|
|
|
2489
|
-
/*! @azure/msal-common
|
|
2311
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
2490
2312
|
|
|
2491
2313
|
/*
|
|
2492
2314
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2538,7 +2360,7 @@
|
|
|
2538
2360
|
return AuthToken;
|
|
2539
2361
|
}());
|
|
2540
2362
|
|
|
2541
|
-
/*! @azure/msal-common
|
|
2363
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
2542
2364
|
|
|
2543
2365
|
/*
|
|
2544
2366
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2548,35 +2370,59 @@
|
|
|
2548
2370
|
* Interface class which implement cache storage functions used by MSAL to perform validity checks, and store tokens.
|
|
2549
2371
|
*/
|
|
2550
2372
|
var CacheManager = /** @class */ (function () {
|
|
2551
|
-
function CacheManager(clientId, cryptoImpl) {
|
|
2373
|
+
function CacheManager(clientId, cryptoImpl, logger) {
|
|
2552
2374
|
this.clientId = clientId;
|
|
2553
2375
|
this.cryptoImpl = cryptoImpl;
|
|
2376
|
+
this.commonLogger = logger.clone(name$1, version$1);
|
|
2554
2377
|
}
|
|
2555
2378
|
/**
|
|
2556
2379
|
* Returns all accounts in cache
|
|
2557
2380
|
*/
|
|
2558
2381
|
CacheManager.prototype.getAllAccounts = function () {
|
|
2559
2382
|
var _this = this;
|
|
2560
|
-
var
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2383
|
+
var allAccountKeys = this.getAccountKeys();
|
|
2384
|
+
if (allAccountKeys.length < 1) {
|
|
2385
|
+
return [];
|
|
2386
|
+
}
|
|
2387
|
+
var accountEntities = allAccountKeys.reduce(function (accounts, key) {
|
|
2388
|
+
var entity = _this.getAccount(key);
|
|
2389
|
+
if (!entity) {
|
|
2390
|
+
return accounts;
|
|
2391
|
+
}
|
|
2392
|
+
accounts.push(entity);
|
|
2393
|
+
return accounts;
|
|
2394
|
+
}, []);
|
|
2395
|
+
if (accountEntities.length < 1) {
|
|
2564
2396
|
return [];
|
|
2565
2397
|
}
|
|
2566
2398
|
else {
|
|
2567
|
-
var allAccounts =
|
|
2568
|
-
|
|
2569
|
-
var accountInfo = accountEntity.getAccountInfo();
|
|
2570
|
-
var idToken = _this.readIdTokenFromCache(_this.clientId, accountInfo);
|
|
2571
|
-
if (idToken && !accountInfo.idTokenClaims) {
|
|
2572
|
-
accountInfo.idToken = idToken.secret;
|
|
2573
|
-
accountInfo.idTokenClaims = new AuthToken(idToken.secret, _this.cryptoImpl).claims;
|
|
2574
|
-
}
|
|
2575
|
-
return accountInfo;
|
|
2399
|
+
var allAccounts = accountEntities.map(function (accountEntity) {
|
|
2400
|
+
return _this.getAccountInfoFromEntity(accountEntity);
|
|
2576
2401
|
});
|
|
2577
2402
|
return allAccounts;
|
|
2578
2403
|
}
|
|
2579
2404
|
};
|
|
2405
|
+
/**
|
|
2406
|
+
* Gets accountInfo object based on provided filters
|
|
2407
|
+
*/
|
|
2408
|
+
CacheManager.prototype.getAccountInfoFilteredBy = function (accountFilter) {
|
|
2409
|
+
var allAccounts = this.getAccountsFilteredBy(accountFilter);
|
|
2410
|
+
if (allAccounts.length > 0) {
|
|
2411
|
+
return this.getAccountInfoFromEntity(allAccounts[0]);
|
|
2412
|
+
}
|
|
2413
|
+
else {
|
|
2414
|
+
return null;
|
|
2415
|
+
}
|
|
2416
|
+
};
|
|
2417
|
+
CacheManager.prototype.getAccountInfoFromEntity = function (accountEntity) {
|
|
2418
|
+
var accountInfo = accountEntity.getAccountInfo();
|
|
2419
|
+
var idToken = this.getIdToken(accountInfo);
|
|
2420
|
+
if (idToken) {
|
|
2421
|
+
accountInfo.idToken = idToken.secret;
|
|
2422
|
+
accountInfo.idTokenClaims = new AuthToken(idToken.secret, this.cryptoImpl).claims;
|
|
2423
|
+
}
|
|
2424
|
+
return accountInfo;
|
|
2425
|
+
};
|
|
2580
2426
|
/**
|
|
2581
2427
|
* saves a cache record
|
|
2582
2428
|
* @param cacheRecord
|
|
@@ -2618,12 +2464,12 @@
|
|
|
2618
2464
|
*/
|
|
2619
2465
|
CacheManager.prototype.saveAccessToken = function (credential) {
|
|
2620
2466
|
return __awaiter(this, void 0, void 0, function () {
|
|
2621
|
-
var
|
|
2467
|
+
var accessTokenFilter, tokenKeys, currentScopes, removedAccessTokens;
|
|
2622
2468
|
var _this = this;
|
|
2623
2469
|
return __generator(this, function (_a) {
|
|
2624
2470
|
switch (_a.label) {
|
|
2625
2471
|
case 0:
|
|
2626
|
-
|
|
2472
|
+
accessTokenFilter = {
|
|
2627
2473
|
clientId: credential.clientId,
|
|
2628
2474
|
credentialType: credential.credentialType,
|
|
2629
2475
|
environment: credential.environment,
|
|
@@ -2631,22 +2477,25 @@
|
|
|
2631
2477
|
realm: credential.realm,
|
|
2632
2478
|
tokenType: credential.tokenType,
|
|
2633
2479
|
requestedClaimsHash: credential.requestedClaimsHash
|
|
2634
|
-
}
|
|
2480
|
+
};
|
|
2481
|
+
tokenKeys = this.getTokenKeys();
|
|
2635
2482
|
currentScopes = ScopeSet.fromString(credential.target);
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2483
|
+
removedAccessTokens = [];
|
|
2484
|
+
tokenKeys.accessToken.forEach(function (key) {
|
|
2485
|
+
if (!_this.accessTokenKeyMatchesFilter(key, accessTokenFilter, false)) {
|
|
2486
|
+
return;
|
|
2487
|
+
}
|
|
2488
|
+
var tokenEntity = _this.getAccessTokenCredential(key);
|
|
2489
|
+
if (tokenEntity && _this.credentialMatchesFilter(tokenEntity, accessTokenFilter)) {
|
|
2490
|
+
var tokenScopeSet = ScopeSet.fromString(tokenEntity.target);
|
|
2491
|
+
if (tokenScopeSet.intersectingScopeSets(currentScopes)) {
|
|
2492
|
+
removedAccessTokens.push(_this.removeAccessToken(key));
|
|
2493
|
+
}
|
|
2643
2494
|
}
|
|
2644
2495
|
});
|
|
2645
|
-
return [4 /*yield*/, Promise.all(
|
|
2496
|
+
return [4 /*yield*/, Promise.all(removedAccessTokens)];
|
|
2646
2497
|
case 1:
|
|
2647
2498
|
_a.sent();
|
|
2648
|
-
_a.label = 2;
|
|
2649
|
-
case 2:
|
|
2650
2499
|
this.setAccessTokenCredential(credential);
|
|
2651
2500
|
return [2 /*return*/];
|
|
2652
2501
|
}
|
|
@@ -2661,149 +2510,151 @@
|
|
|
2661
2510
|
* @param realm
|
|
2662
2511
|
*/
|
|
2663
2512
|
CacheManager.prototype.getAccountsFilteredBy = function (accountFilter) {
|
|
2664
|
-
return this.getAccountsFilteredByInternal(accountFilter ? accountFilter.homeAccountId : Constants.EMPTY_STRING, accountFilter ? accountFilter.environment : Constants.EMPTY_STRING, accountFilter ? accountFilter.realm : Constants.EMPTY_STRING, accountFilter ? accountFilter.nativeAccountId : Constants.EMPTY_STRING);
|
|
2665
|
-
};
|
|
2666
|
-
/**
|
|
2667
|
-
* retrieve accounts matching all provided filters; if no filter is set, get all accounts
|
|
2668
|
-
* not checking for casing as keys are all generated in lower case, remember to convert to lower case if object properties are compared
|
|
2669
|
-
* @param homeAccountId
|
|
2670
|
-
* @param environment
|
|
2671
|
-
* @param realm
|
|
2672
|
-
*/
|
|
2673
|
-
CacheManager.prototype.getAccountsFilteredByInternal = function (homeAccountId, environment, realm, nativeAccountId) {
|
|
2674
2513
|
var _this = this;
|
|
2675
|
-
var
|
|
2676
|
-
var matchingAccounts =
|
|
2677
|
-
|
|
2514
|
+
var allAccountKeys = this.getAccountKeys();
|
|
2515
|
+
var matchingAccounts = [];
|
|
2516
|
+
allAccountKeys.forEach(function (cacheKey) {
|
|
2517
|
+
if (!_this.isAccountKey(cacheKey, accountFilter.homeAccountId, accountFilter.realm)) {
|
|
2518
|
+
// Don't parse value if the key doesn't match the account filters
|
|
2519
|
+
return;
|
|
2520
|
+
}
|
|
2678
2521
|
var entity = _this.getAccount(cacheKey);
|
|
2679
2522
|
if (!entity) {
|
|
2680
2523
|
return;
|
|
2681
2524
|
}
|
|
2682
|
-
if (!!homeAccountId && !_this.matchHomeAccountId(entity, homeAccountId)) {
|
|
2525
|
+
if (!!accountFilter.homeAccountId && !_this.matchHomeAccountId(entity, accountFilter.homeAccountId)) {
|
|
2683
2526
|
return;
|
|
2684
2527
|
}
|
|
2685
|
-
if (!!
|
|
2528
|
+
if (!!accountFilter.localAccountId && !_this.matchLocalAccountId(entity, accountFilter.localAccountId)) {
|
|
2529
|
+
return;
|
|
2530
|
+
}
|
|
2531
|
+
if (!!accountFilter.username && !_this.matchUsername(entity, accountFilter.username)) {
|
|
2532
|
+
return;
|
|
2533
|
+
}
|
|
2534
|
+
if (!!accountFilter.environment && !_this.matchEnvironment(entity, accountFilter.environment)) {
|
|
2686
2535
|
return;
|
|
2687
2536
|
}
|
|
2688
|
-
if (!!realm && !_this.matchRealm(entity, realm)) {
|
|
2537
|
+
if (!!accountFilter.realm && !_this.matchRealm(entity, accountFilter.realm)) {
|
|
2689
2538
|
return;
|
|
2690
2539
|
}
|
|
2691
|
-
if (!!nativeAccountId && !_this.matchNativeAccountId(entity, nativeAccountId)) {
|
|
2540
|
+
if (!!accountFilter.nativeAccountId && !_this.matchNativeAccountId(entity, accountFilter.nativeAccountId)) {
|
|
2692
2541
|
return;
|
|
2693
2542
|
}
|
|
2694
|
-
matchingAccounts
|
|
2543
|
+
matchingAccounts.push(entity);
|
|
2695
2544
|
});
|
|
2696
2545
|
return matchingAccounts;
|
|
2697
2546
|
};
|
|
2698
2547
|
/**
|
|
2699
|
-
*
|
|
2548
|
+
* Returns true if the given key matches our account key schema. Also matches homeAccountId and/or tenantId if provided
|
|
2549
|
+
* @param key
|
|
2700
2550
|
* @param homeAccountId
|
|
2701
|
-
* @param
|
|
2702
|
-
* @
|
|
2703
|
-
* @param clientId
|
|
2704
|
-
* @param realm
|
|
2705
|
-
* @param target
|
|
2551
|
+
* @param tenantId
|
|
2552
|
+
* @returns
|
|
2706
2553
|
*/
|
|
2707
|
-
CacheManager.prototype.
|
|
2708
|
-
|
|
2554
|
+
CacheManager.prototype.isAccountKey = function (key, homeAccountId, tenantId) {
|
|
2555
|
+
if (key.split(Separators.CACHE_KEY_SEPARATOR).length < 3) {
|
|
2556
|
+
// Account cache keys contain 3 items separated by '-' (each item may also contain '-')
|
|
2557
|
+
return false;
|
|
2558
|
+
}
|
|
2559
|
+
if (homeAccountId && !key.toLowerCase().includes(homeAccountId.toLowerCase())) {
|
|
2560
|
+
return false;
|
|
2561
|
+
}
|
|
2562
|
+
if (tenantId && !key.toLowerCase().includes(tenantId.toLowerCase())) {
|
|
2563
|
+
return false;
|
|
2564
|
+
}
|
|
2565
|
+
// Do not check environment as aliasing can cause false negatives
|
|
2566
|
+
return true;
|
|
2709
2567
|
};
|
|
2710
2568
|
/**
|
|
2711
|
-
*
|
|
2712
|
-
* @param
|
|
2713
|
-
* @param environment
|
|
2714
|
-
* @param credentialType
|
|
2715
|
-
* @param clientId
|
|
2716
|
-
* @param realm
|
|
2717
|
-
* @param target
|
|
2718
|
-
* @param userAssertionHash
|
|
2719
|
-
* @param tokenType
|
|
2569
|
+
* Returns true if the given key matches our credential key schema.
|
|
2570
|
+
* @param key
|
|
2720
2571
|
*/
|
|
2721
|
-
CacheManager.prototype.
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
//
|
|
2736
|
-
var
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
if (!!userAssertionHash && !_this.matchUserAssertionHash(entity, userAssertionHash)) {
|
|
2741
|
-
return;
|
|
2742
|
-
}
|
|
2743
|
-
/*
|
|
2744
|
-
* homeAccountId can undefined, and we want to filter out cached items that have a homeAccountId of ""
|
|
2745
|
-
* because we don't want a client_credential request to return a cached token that has a homeAccountId
|
|
2746
|
-
*/
|
|
2747
|
-
if ((typeof homeAccountId === "string") && !_this.matchHomeAccountId(entity, homeAccountId)) {
|
|
2748
|
-
return;
|
|
2749
|
-
}
|
|
2750
|
-
if (!!environment && !_this.matchEnvironment(entity, environment)) {
|
|
2751
|
-
return;
|
|
2752
|
-
}
|
|
2753
|
-
if (!!realm && !_this.matchRealm(entity, realm)) {
|
|
2754
|
-
return;
|
|
2755
|
-
}
|
|
2756
|
-
if (!!credentialType && !_this.matchCredentialType(entity, credentialType)) {
|
|
2757
|
-
return;
|
|
2758
|
-
}
|
|
2759
|
-
if (!!clientId && !_this.matchClientId(entity, clientId)) {
|
|
2760
|
-
return;
|
|
2572
|
+
CacheManager.prototype.isCredentialKey = function (key) {
|
|
2573
|
+
if (key.split(Separators.CACHE_KEY_SEPARATOR).length < 6) {
|
|
2574
|
+
// Credential cache keys contain 6 items separated by '-' (each item may also contain '-')
|
|
2575
|
+
return false;
|
|
2576
|
+
}
|
|
2577
|
+
var lowerCaseKey = key.toLowerCase();
|
|
2578
|
+
// Credential keys must indicate what credential type they represent
|
|
2579
|
+
if (lowerCaseKey.indexOf(CredentialType.ID_TOKEN.toLowerCase()) === -1 &&
|
|
2580
|
+
lowerCaseKey.indexOf(CredentialType.ACCESS_TOKEN.toLowerCase()) === -1 &&
|
|
2581
|
+
lowerCaseKey.indexOf(CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME.toLowerCase()) === -1 &&
|
|
2582
|
+
lowerCaseKey.indexOf(CredentialType.REFRESH_TOKEN.toLowerCase()) === -1) {
|
|
2583
|
+
return false;
|
|
2584
|
+
}
|
|
2585
|
+
if (lowerCaseKey.indexOf(CredentialType.REFRESH_TOKEN.toLowerCase()) > -1) {
|
|
2586
|
+
// Refresh tokens must contain the client id or family id
|
|
2587
|
+
var clientIdValidation = "" + CredentialType.REFRESH_TOKEN + Separators.CACHE_KEY_SEPARATOR + this.clientId + Separators.CACHE_KEY_SEPARATOR;
|
|
2588
|
+
var familyIdValidation = "" + CredentialType.REFRESH_TOKEN + Separators.CACHE_KEY_SEPARATOR + THE_FAMILY_ID + Separators.CACHE_KEY_SEPARATOR;
|
|
2589
|
+
if (lowerCaseKey.indexOf(clientIdValidation.toLowerCase()) === -1 && lowerCaseKey.indexOf(familyIdValidation.toLowerCase()) === -1) {
|
|
2590
|
+
return false;
|
|
2761
2591
|
}
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2592
|
+
}
|
|
2593
|
+
else if (lowerCaseKey.indexOf(this.clientId.toLowerCase()) === -1) {
|
|
2594
|
+
// Tokens must contain the clientId
|
|
2595
|
+
return false;
|
|
2596
|
+
}
|
|
2597
|
+
return true;
|
|
2598
|
+
};
|
|
2599
|
+
/**
|
|
2600
|
+
* Returns whether or not the given credential entity matches the filter
|
|
2601
|
+
* @param entity
|
|
2602
|
+
* @param filter
|
|
2603
|
+
* @returns
|
|
2604
|
+
*/
|
|
2605
|
+
CacheManager.prototype.credentialMatchesFilter = function (entity, filter) {
|
|
2606
|
+
if (!!filter.clientId && !this.matchClientId(entity, filter.clientId)) {
|
|
2607
|
+
return false;
|
|
2608
|
+
}
|
|
2609
|
+
if (!!filter.userAssertionHash && !this.matchUserAssertionHash(entity, filter.userAssertionHash)) {
|
|
2610
|
+
return false;
|
|
2611
|
+
}
|
|
2612
|
+
/*
|
|
2613
|
+
* homeAccountId can be undefined, and we want to filter out cached items that have a homeAccountId of ""
|
|
2614
|
+
* because we don't want a client_credential request to return a cached token that has a homeAccountId
|
|
2615
|
+
*/
|
|
2616
|
+
if ((typeof filter.homeAccountId === "string") && !this.matchHomeAccountId(entity, filter.homeAccountId)) {
|
|
2617
|
+
return false;
|
|
2618
|
+
}
|
|
2619
|
+
if (!!filter.environment && !this.matchEnvironment(entity, filter.environment)) {
|
|
2620
|
+
return false;
|
|
2621
|
+
}
|
|
2622
|
+
if (!!filter.realm && !this.matchRealm(entity, filter.realm)) {
|
|
2623
|
+
return false;
|
|
2624
|
+
}
|
|
2625
|
+
if (!!filter.credentialType && !this.matchCredentialType(entity, filter.credentialType)) {
|
|
2626
|
+
return false;
|
|
2627
|
+
}
|
|
2628
|
+
if (!!filter.familyId && !this.matchFamilyId(entity, filter.familyId)) {
|
|
2629
|
+
return false;
|
|
2630
|
+
}
|
|
2631
|
+
/*
|
|
2632
|
+
* idTokens do not have "target", target specific refreshTokens do exist for some types of authentication
|
|
2633
|
+
* Resource specific refresh tokens case will be added when the support is deemed necessary
|
|
2634
|
+
*/
|
|
2635
|
+
if (!!filter.target && !this.matchTarget(entity, filter.target)) {
|
|
2636
|
+
return false;
|
|
2637
|
+
}
|
|
2638
|
+
// If request OR cached entity has requested Claims Hash, check if they match
|
|
2639
|
+
if (filter.requestedClaimsHash || entity.requestedClaimsHash) {
|
|
2640
|
+
// Don't match if either is undefined or they are different
|
|
2641
|
+
if (entity.requestedClaimsHash !== filter.requestedClaimsHash) {
|
|
2642
|
+
return false;
|
|
2771
2643
|
}
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
}
|
|
2644
|
+
}
|
|
2645
|
+
// Access Token with Auth Scheme specific matching
|
|
2646
|
+
if (entity.credentialType === CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME) {
|
|
2647
|
+
if (!!filter.tokenType && !this.matchTokenType(entity, filter.tokenType)) {
|
|
2648
|
+
return false;
|
|
2778
2649
|
}
|
|
2779
|
-
//
|
|
2780
|
-
if (
|
|
2781
|
-
if (
|
|
2782
|
-
return;
|
|
2783
|
-
}
|
|
2784
|
-
// KeyId (sshKid) in request must match cached SSH certificate keyId because SSH cert is bound to a specific key
|
|
2785
|
-
if (tokenType === exports.AuthenticationScheme.SSH) {
|
|
2786
|
-
if (keyId && !_this.matchKeyId(entity, keyId)) {
|
|
2787
|
-
return;
|
|
2788
|
-
}
|
|
2650
|
+
// KeyId (sshKid) in request must match cached SSH certificate keyId because SSH cert is bound to a specific key
|
|
2651
|
+
if (filter.tokenType === exports.AuthenticationScheme.SSH) {
|
|
2652
|
+
if (filter.keyId && !this.matchKeyId(entity, filter.keyId)) {
|
|
2653
|
+
return false;
|
|
2789
2654
|
}
|
|
2790
2655
|
}
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
switch (credType) {
|
|
2794
|
-
case CredentialType.ID_TOKEN:
|
|
2795
|
-
matchingCredentials.idTokens[updatedCacheKey] = entity;
|
|
2796
|
-
break;
|
|
2797
|
-
case CredentialType.ACCESS_TOKEN:
|
|
2798
|
-
case CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME:
|
|
2799
|
-
matchingCredentials.accessTokens[updatedCacheKey] = entity;
|
|
2800
|
-
break;
|
|
2801
|
-
case CredentialType.REFRESH_TOKEN:
|
|
2802
|
-
matchingCredentials.refreshTokens[updatedCacheKey] = entity;
|
|
2803
|
-
break;
|
|
2804
|
-
}
|
|
2805
|
-
});
|
|
2806
|
-
return matchingCredentials;
|
|
2656
|
+
}
|
|
2657
|
+
return true;
|
|
2807
2658
|
};
|
|
2808
2659
|
/**
|
|
2809
2660
|
* retrieve appMetadata matching all provided filters; if no filter is set, get all appMetadata
|
|
@@ -2871,30 +2722,26 @@
|
|
|
2871
2722
|
*/
|
|
2872
2723
|
CacheManager.prototype.removeAllAccounts = function () {
|
|
2873
2724
|
return __awaiter(this, void 0, void 0, function () {
|
|
2874
|
-
var
|
|
2725
|
+
var allAccountKeys, removedAccounts;
|
|
2875
2726
|
var _this = this;
|
|
2876
2727
|
return __generator(this, function (_a) {
|
|
2877
2728
|
switch (_a.label) {
|
|
2878
2729
|
case 0:
|
|
2879
|
-
|
|
2730
|
+
allAccountKeys = this.getAccountKeys();
|
|
2880
2731
|
removedAccounts = [];
|
|
2881
|
-
|
|
2882
|
-
var entity = _this.getAccount(cacheKey);
|
|
2883
|
-
if (!entity) {
|
|
2884
|
-
return;
|
|
2885
|
-
}
|
|
2732
|
+
allAccountKeys.forEach(function (cacheKey) {
|
|
2886
2733
|
removedAccounts.push(_this.removeAccount(cacheKey));
|
|
2887
2734
|
});
|
|
2888
2735
|
return [4 /*yield*/, Promise.all(removedAccounts)];
|
|
2889
2736
|
case 1:
|
|
2890
2737
|
_a.sent();
|
|
2891
|
-
return [2 /*return
|
|
2738
|
+
return [2 /*return*/];
|
|
2892
2739
|
}
|
|
2893
2740
|
});
|
|
2894
2741
|
});
|
|
2895
2742
|
};
|
|
2896
2743
|
/**
|
|
2897
|
-
*
|
|
2744
|
+
* Removes the account and related tokens for a given account key
|
|
2898
2745
|
* @param account
|
|
2899
2746
|
*/
|
|
2900
2747
|
CacheManager.prototype.removeAccount = function (accountKey) {
|
|
@@ -2908,7 +2755,10 @@
|
|
|
2908
2755
|
throw ClientAuthError.createNoAccountFoundError();
|
|
2909
2756
|
}
|
|
2910
2757
|
return [4 /*yield*/, this.removeAccountContext(account)];
|
|
2911
|
-
case 1:
|
|
2758
|
+
case 1:
|
|
2759
|
+
_a.sent();
|
|
2760
|
+
this.removeItem(accountKey);
|
|
2761
|
+
return [2 /*return*/];
|
|
2912
2762
|
}
|
|
2913
2763
|
});
|
|
2914
2764
|
});
|
|
@@ -2919,29 +2769,33 @@
|
|
|
2919
2769
|
*/
|
|
2920
2770
|
CacheManager.prototype.removeAccountContext = function (account) {
|
|
2921
2771
|
return __awaiter(this, void 0, void 0, function () {
|
|
2922
|
-
var
|
|
2772
|
+
var allTokenKeys, accountId, removedCredentials;
|
|
2923
2773
|
var _this = this;
|
|
2924
2774
|
return __generator(this, function (_a) {
|
|
2925
2775
|
switch (_a.label) {
|
|
2926
2776
|
case 0:
|
|
2927
|
-
|
|
2777
|
+
allTokenKeys = this.getTokenKeys();
|
|
2928
2778
|
accountId = account.generateAccountId();
|
|
2929
2779
|
removedCredentials = [];
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
if (credType === Constants.NOT_DEFINED) {
|
|
2934
|
-
return;
|
|
2780
|
+
allTokenKeys.idToken.forEach(function (key) {
|
|
2781
|
+
if (key.indexOf(accountId) === 0) {
|
|
2782
|
+
_this.removeIdToken(key);
|
|
2935
2783
|
}
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2784
|
+
});
|
|
2785
|
+
allTokenKeys.accessToken.forEach(function (key) {
|
|
2786
|
+
if (key.indexOf(accountId) === 0) {
|
|
2787
|
+
removedCredentials.push(_this.removeAccessToken(key));
|
|
2788
|
+
}
|
|
2789
|
+
});
|
|
2790
|
+
allTokenKeys.refreshToken.forEach(function (key) {
|
|
2791
|
+
if (key.indexOf(accountId) === 0) {
|
|
2792
|
+
_this.removeRefreshToken(key);
|
|
2939
2793
|
}
|
|
2940
2794
|
});
|
|
2941
2795
|
return [4 /*yield*/, Promise.all(removedCredentials)];
|
|
2942
2796
|
case 1:
|
|
2943
2797
|
_a.sent();
|
|
2944
|
-
return [2 /*return
|
|
2798
|
+
return [2 /*return*/];
|
|
2945
2799
|
}
|
|
2946
2800
|
});
|
|
2947
2801
|
});
|
|
@@ -2950,13 +2804,16 @@
|
|
|
2950
2804
|
* returns a boolean if the given credential is removed
|
|
2951
2805
|
* @param credential
|
|
2952
2806
|
*/
|
|
2953
|
-
CacheManager.prototype.
|
|
2807
|
+
CacheManager.prototype.removeAccessToken = function (key) {
|
|
2954
2808
|
return __awaiter(this, void 0, void 0, function () {
|
|
2955
|
-
var
|
|
2809
|
+
var credential, accessTokenWithAuthSchemeEntity, kid;
|
|
2956
2810
|
return __generator(this, function (_a) {
|
|
2957
2811
|
switch (_a.label) {
|
|
2958
2812
|
case 0:
|
|
2959
|
-
|
|
2813
|
+
credential = this.getAccessTokenCredential(key);
|
|
2814
|
+
if (!credential) {
|
|
2815
|
+
return [2 /*return*/];
|
|
2816
|
+
}
|
|
2960
2817
|
if (!(credential.credentialType.toLowerCase() === CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME.toLowerCase())) return [3 /*break*/, 4];
|
|
2961
2818
|
if (!(credential.tokenType === exports.AuthenticationScheme.POP)) return [3 /*break*/, 4];
|
|
2962
2819
|
accessTokenWithAuthSchemeEntity = credential;
|
|
@@ -2972,7 +2829,7 @@
|
|
|
2972
2829
|
case 3:
|
|
2973
2830
|
_a.sent();
|
|
2974
2831
|
throw ClientAuthError.createBindingKeyNotRemovedError();
|
|
2975
|
-
case 4: return [2 /*return*/, this.removeItem(key
|
|
2832
|
+
case 4: return [2 /*return*/, this.removeItem(key)];
|
|
2976
2833
|
}
|
|
2977
2834
|
});
|
|
2978
2835
|
});
|
|
@@ -2985,7 +2842,7 @@
|
|
|
2985
2842
|
var allCacheKeys = this.getKeys();
|
|
2986
2843
|
allCacheKeys.forEach(function (cacheKey) {
|
|
2987
2844
|
if (_this.isAppMetadata(cacheKey)) {
|
|
2988
|
-
_this.removeItem(cacheKey
|
|
2845
|
+
_this.removeItem(cacheKey);
|
|
2989
2846
|
}
|
|
2990
2847
|
});
|
|
2991
2848
|
return true;
|
|
@@ -2998,12 +2855,13 @@
|
|
|
2998
2855
|
* @param environment
|
|
2999
2856
|
* @param authScheme
|
|
3000
2857
|
*/
|
|
3001
|
-
CacheManager.prototype.readCacheRecord = function (account,
|
|
2858
|
+
CacheManager.prototype.readCacheRecord = function (account, request, environment) {
|
|
2859
|
+
var tokenKeys = this.getTokenKeys();
|
|
3002
2860
|
var cachedAccount = this.readAccountFromCache(account);
|
|
3003
|
-
var cachedIdToken = this.
|
|
3004
|
-
var cachedAccessToken = this.
|
|
3005
|
-
var cachedRefreshToken = this.
|
|
3006
|
-
var cachedAppMetadata = this.readAppMetadataFromCache(environment
|
|
2861
|
+
var cachedIdToken = this.getIdToken(account, tokenKeys);
|
|
2862
|
+
var cachedAccessToken = this.getAccessToken(account, request, tokenKeys);
|
|
2863
|
+
var cachedRefreshToken = this.getRefreshToken(account, false, tokenKeys);
|
|
2864
|
+
var cachedAppMetadata = this.readAppMetadataFromCache(environment);
|
|
3007
2865
|
if (cachedAccount && cachedIdToken) {
|
|
3008
2866
|
cachedAccount.idTokenClaims = new AuthToken(cachedIdToken.secret, this.cryptoImpl).claims;
|
|
3009
2867
|
}
|
|
@@ -3023,51 +2881,83 @@
|
|
|
3023
2881
|
var accountKey = AccountEntity.generateAccountCacheKey(account);
|
|
3024
2882
|
return this.getAccount(accountKey);
|
|
3025
2883
|
};
|
|
3026
|
-
/**
|
|
3027
|
-
* Retrieve AccountEntity from cache
|
|
3028
|
-
* @param nativeAccountId
|
|
3029
|
-
* @returns AccountEntity or Null
|
|
3030
|
-
*/
|
|
3031
|
-
CacheManager.prototype.readAccountFromCacheWithNativeAccountId = function (nativeAccountId) {
|
|
3032
|
-
// fetch account from memory
|
|
3033
|
-
var accountFilter = {
|
|
3034
|
-
nativeAccountId: nativeAccountId
|
|
3035
|
-
};
|
|
3036
|
-
var accountCache = this.getAccountsFilteredBy(accountFilter);
|
|
3037
|
-
var accounts = Object.keys(accountCache).map(function (key) { return accountCache[key]; });
|
|
3038
|
-
if (accounts.length < 1) {
|
|
3039
|
-
return null;
|
|
3040
|
-
}
|
|
3041
|
-
else if (accounts.length > 1) {
|
|
3042
|
-
throw ClientAuthError.createMultipleMatchingAccountsInCacheError();
|
|
3043
|
-
}
|
|
3044
|
-
return accounts[0];
|
|
3045
|
-
};
|
|
3046
2884
|
/**
|
|
3047
2885
|
* Retrieve IdTokenEntity from cache
|
|
3048
2886
|
* @param clientId
|
|
3049
2887
|
* @param account
|
|
3050
2888
|
* @param inputRealm
|
|
3051
2889
|
*/
|
|
3052
|
-
CacheManager.prototype.
|
|
2890
|
+
CacheManager.prototype.getIdToken = function (account, tokenKeys) {
|
|
2891
|
+
this.commonLogger.trace("CacheManager - getIdToken called");
|
|
3053
2892
|
var idTokenFilter = {
|
|
3054
2893
|
homeAccountId: account.homeAccountId,
|
|
3055
2894
|
environment: account.environment,
|
|
3056
2895
|
credentialType: CredentialType.ID_TOKEN,
|
|
3057
|
-
clientId: clientId,
|
|
2896
|
+
clientId: this.clientId,
|
|
3058
2897
|
realm: account.tenantId,
|
|
3059
2898
|
};
|
|
3060
|
-
var
|
|
3061
|
-
var idTokens = Object.keys(credentialCache.idTokens).map(function (key) { return credentialCache.idTokens[key]; });
|
|
2899
|
+
var idTokens = this.getIdTokensByFilter(idTokenFilter, tokenKeys);
|
|
3062
2900
|
var numIdTokens = idTokens.length;
|
|
3063
2901
|
if (numIdTokens < 1) {
|
|
2902
|
+
this.commonLogger.info("CacheManager:getIdToken - No token found");
|
|
3064
2903
|
return null;
|
|
3065
2904
|
}
|
|
3066
2905
|
else if (numIdTokens > 1) {
|
|
3067
2906
|
throw ClientAuthError.createMultipleMatchingTokensInCacheError();
|
|
3068
2907
|
}
|
|
2908
|
+
this.commonLogger.info("CacheManager:getIdToken - Returning id token");
|
|
3069
2909
|
return idTokens[0];
|
|
3070
2910
|
};
|
|
2911
|
+
/**
|
|
2912
|
+
* Gets all idTokens matching the given filter
|
|
2913
|
+
* @param filter
|
|
2914
|
+
* @returns
|
|
2915
|
+
*/
|
|
2916
|
+
CacheManager.prototype.getIdTokensByFilter = function (filter, tokenKeys) {
|
|
2917
|
+
var _this = this;
|
|
2918
|
+
var idTokenKeys = tokenKeys && tokenKeys.idToken || this.getTokenKeys().idToken;
|
|
2919
|
+
var idTokens = [];
|
|
2920
|
+
idTokenKeys.forEach(function (key) {
|
|
2921
|
+
if (!_this.idTokenKeyMatchesFilter(key, __assign({ clientId: _this.clientId }, filter))) {
|
|
2922
|
+
return;
|
|
2923
|
+
}
|
|
2924
|
+
var idToken = _this.getIdTokenCredential(key);
|
|
2925
|
+
if (idToken && _this.credentialMatchesFilter(idToken, filter)) {
|
|
2926
|
+
idTokens.push(idToken);
|
|
2927
|
+
}
|
|
2928
|
+
});
|
|
2929
|
+
return idTokens;
|
|
2930
|
+
};
|
|
2931
|
+
/**
|
|
2932
|
+
* Validate the cache key against filter before retrieving and parsing cache value
|
|
2933
|
+
* @param key
|
|
2934
|
+
* @param filter
|
|
2935
|
+
* @returns
|
|
2936
|
+
*/
|
|
2937
|
+
CacheManager.prototype.idTokenKeyMatchesFilter = function (inputKey, filter) {
|
|
2938
|
+
var key = inputKey.toLowerCase();
|
|
2939
|
+
if (filter.clientId && key.indexOf(filter.clientId.toLowerCase()) === -1) {
|
|
2940
|
+
return false;
|
|
2941
|
+
}
|
|
2942
|
+
if (filter.homeAccountId && key.indexOf(filter.homeAccountId.toLowerCase()) === -1) {
|
|
2943
|
+
return false;
|
|
2944
|
+
}
|
|
2945
|
+
return true;
|
|
2946
|
+
};
|
|
2947
|
+
/**
|
|
2948
|
+
* Removes idToken from the cache
|
|
2949
|
+
* @param key
|
|
2950
|
+
*/
|
|
2951
|
+
CacheManager.prototype.removeIdToken = function (key) {
|
|
2952
|
+
this.removeItem(key);
|
|
2953
|
+
};
|
|
2954
|
+
/**
|
|
2955
|
+
* Removes refresh token from the cache
|
|
2956
|
+
* @param key
|
|
2957
|
+
*/
|
|
2958
|
+
CacheManager.prototype.removeRefreshToken = function (key) {
|
|
2959
|
+
this.removeItem(key);
|
|
2960
|
+
};
|
|
3071
2961
|
/**
|
|
3072
2962
|
* Retrieve AccessTokenEntity from cache
|
|
3073
2963
|
* @param clientId
|
|
@@ -3075,8 +2965,10 @@
|
|
|
3075
2965
|
* @param scopes
|
|
3076
2966
|
* @param authScheme
|
|
3077
2967
|
*/
|
|
3078
|
-
CacheManager.prototype.
|
|
3079
|
-
var
|
|
2968
|
+
CacheManager.prototype.getAccessToken = function (account, request, tokenKeys) {
|
|
2969
|
+
var _this = this;
|
|
2970
|
+
this.commonLogger.trace("CacheManager - getAccessToken called");
|
|
2971
|
+
var scopes = ScopeSet.createSearchScopes(request.scopes);
|
|
3080
2972
|
var authScheme = request.authenticationScheme || exports.AuthenticationScheme.BEARER;
|
|
3081
2973
|
/*
|
|
3082
2974
|
* Distinguish between Bearer and PoP/SSH token cache types
|
|
@@ -3087,55 +2979,156 @@
|
|
|
3087
2979
|
homeAccountId: account.homeAccountId,
|
|
3088
2980
|
environment: account.environment,
|
|
3089
2981
|
credentialType: credentialType,
|
|
3090
|
-
clientId: clientId,
|
|
2982
|
+
clientId: this.clientId,
|
|
3091
2983
|
realm: account.tenantId,
|
|
3092
|
-
target: scopes
|
|
2984
|
+
target: scopes,
|
|
3093
2985
|
tokenType: authScheme,
|
|
3094
2986
|
keyId: request.sshKid,
|
|
3095
2987
|
requestedClaimsHash: request.requestedClaimsHash,
|
|
3096
2988
|
};
|
|
3097
|
-
var
|
|
3098
|
-
var accessTokens =
|
|
2989
|
+
var accessTokenKeys = tokenKeys && tokenKeys.accessToken || this.getTokenKeys().accessToken;
|
|
2990
|
+
var accessTokens = [];
|
|
2991
|
+
accessTokenKeys.forEach(function (key) {
|
|
2992
|
+
// Validate key
|
|
2993
|
+
if (_this.accessTokenKeyMatchesFilter(key, accessTokenFilter, true)) {
|
|
2994
|
+
var accessToken = _this.getAccessTokenCredential(key);
|
|
2995
|
+
// Validate value
|
|
2996
|
+
if (accessToken && _this.credentialMatchesFilter(accessToken, accessTokenFilter)) {
|
|
2997
|
+
accessTokens.push(accessToken);
|
|
2998
|
+
}
|
|
2999
|
+
}
|
|
3000
|
+
});
|
|
3099
3001
|
var numAccessTokens = accessTokens.length;
|
|
3100
3002
|
if (numAccessTokens < 1) {
|
|
3003
|
+
this.commonLogger.info("CacheManager:getAccessToken - No token found");
|
|
3101
3004
|
return null;
|
|
3102
3005
|
}
|
|
3103
3006
|
else if (numAccessTokens > 1) {
|
|
3104
3007
|
throw ClientAuthError.createMultipleMatchingTokensInCacheError();
|
|
3105
3008
|
}
|
|
3009
|
+
this.commonLogger.info("CacheManager:getAccessToken - Returning access token");
|
|
3106
3010
|
return accessTokens[0];
|
|
3107
3011
|
};
|
|
3012
|
+
/**
|
|
3013
|
+
* Validate the cache key against filter before retrieving and parsing cache value
|
|
3014
|
+
* @param key
|
|
3015
|
+
* @param filter
|
|
3016
|
+
* @param keyMustContainAllScopes
|
|
3017
|
+
* @returns
|
|
3018
|
+
*/
|
|
3019
|
+
CacheManager.prototype.accessTokenKeyMatchesFilter = function (inputKey, filter, keyMustContainAllScopes) {
|
|
3020
|
+
var key = inputKey.toLowerCase();
|
|
3021
|
+
if (filter.clientId && key.indexOf(filter.clientId.toLowerCase()) === -1) {
|
|
3022
|
+
return false;
|
|
3023
|
+
}
|
|
3024
|
+
if (filter.homeAccountId && key.indexOf(filter.homeAccountId.toLowerCase()) === -1) {
|
|
3025
|
+
return false;
|
|
3026
|
+
}
|
|
3027
|
+
if (filter.realm && key.indexOf(filter.realm.toLowerCase()) === -1) {
|
|
3028
|
+
return false;
|
|
3029
|
+
}
|
|
3030
|
+
if (filter.requestedClaimsHash && key.indexOf(filter.requestedClaimsHash.toLowerCase()) === -1) {
|
|
3031
|
+
return false;
|
|
3032
|
+
}
|
|
3033
|
+
if (filter.target) {
|
|
3034
|
+
var scopes = filter.target.asArray();
|
|
3035
|
+
for (var i = 0; i < scopes.length; i++) {
|
|
3036
|
+
if (keyMustContainAllScopes && !key.includes(scopes[i].toLowerCase())) {
|
|
3037
|
+
// When performing a cache lookup a missing scope would be a cache miss
|
|
3038
|
+
return false;
|
|
3039
|
+
}
|
|
3040
|
+
else if (!keyMustContainAllScopes && key.includes(scopes[i].toLowerCase())) {
|
|
3041
|
+
// When performing a cache write, any token with a subset of requested scopes should be replaced
|
|
3042
|
+
return true;
|
|
3043
|
+
}
|
|
3044
|
+
}
|
|
3045
|
+
}
|
|
3046
|
+
return true;
|
|
3047
|
+
};
|
|
3048
|
+
/**
|
|
3049
|
+
* Gets all access tokens matching the filter
|
|
3050
|
+
* @param filter
|
|
3051
|
+
* @returns
|
|
3052
|
+
*/
|
|
3053
|
+
CacheManager.prototype.getAccessTokensByFilter = function (filter) {
|
|
3054
|
+
var _this = this;
|
|
3055
|
+
var tokenKeys = this.getTokenKeys();
|
|
3056
|
+
var accessTokens = [];
|
|
3057
|
+
tokenKeys.accessToken.forEach(function (key) {
|
|
3058
|
+
if (!_this.accessTokenKeyMatchesFilter(key, filter, true)) {
|
|
3059
|
+
return;
|
|
3060
|
+
}
|
|
3061
|
+
var accessToken = _this.getAccessTokenCredential(key);
|
|
3062
|
+
if (accessToken && _this.credentialMatchesFilter(accessToken, filter)) {
|
|
3063
|
+
accessTokens.push(accessToken);
|
|
3064
|
+
}
|
|
3065
|
+
});
|
|
3066
|
+
return accessTokens;
|
|
3067
|
+
};
|
|
3108
3068
|
/**
|
|
3109
3069
|
* Helper to retrieve the appropriate refresh token from cache
|
|
3110
3070
|
* @param clientId
|
|
3111
3071
|
* @param account
|
|
3112
3072
|
* @param familyRT
|
|
3113
3073
|
*/
|
|
3114
|
-
CacheManager.prototype.
|
|
3074
|
+
CacheManager.prototype.getRefreshToken = function (account, familyRT, tokenKeys) {
|
|
3075
|
+
var _this = this;
|
|
3076
|
+
this.commonLogger.trace("CacheManager - getRefreshToken called");
|
|
3115
3077
|
var id = familyRT ? THE_FAMILY_ID : undefined;
|
|
3116
3078
|
var refreshTokenFilter = {
|
|
3117
3079
|
homeAccountId: account.homeAccountId,
|
|
3118
3080
|
environment: account.environment,
|
|
3119
3081
|
credentialType: CredentialType.REFRESH_TOKEN,
|
|
3120
|
-
clientId: clientId,
|
|
3082
|
+
clientId: this.clientId,
|
|
3121
3083
|
familyId: id,
|
|
3122
3084
|
};
|
|
3123
|
-
var
|
|
3124
|
-
var refreshTokens =
|
|
3085
|
+
var refreshTokenKeys = tokenKeys && tokenKeys.refreshToken || this.getTokenKeys().refreshToken;
|
|
3086
|
+
var refreshTokens = [];
|
|
3087
|
+
refreshTokenKeys.forEach(function (key) {
|
|
3088
|
+
// Validate key
|
|
3089
|
+
if (_this.refreshTokenKeyMatchesFilter(key, refreshTokenFilter)) {
|
|
3090
|
+
var refreshToken = _this.getRefreshTokenCredential(key);
|
|
3091
|
+
// Validate value
|
|
3092
|
+
if (refreshToken && _this.credentialMatchesFilter(refreshToken, refreshTokenFilter)) {
|
|
3093
|
+
refreshTokens.push(refreshToken);
|
|
3094
|
+
}
|
|
3095
|
+
}
|
|
3096
|
+
});
|
|
3125
3097
|
var numRefreshTokens = refreshTokens.length;
|
|
3126
3098
|
if (numRefreshTokens < 1) {
|
|
3099
|
+
this.commonLogger.info("CacheManager:getRefreshToken - No refresh token found.");
|
|
3127
3100
|
return null;
|
|
3128
3101
|
}
|
|
3129
3102
|
// address the else case after remove functions address environment aliases
|
|
3103
|
+
this.commonLogger.info("CacheManager:getRefreshToken - returning refresh token");
|
|
3130
3104
|
return refreshTokens[0];
|
|
3131
3105
|
};
|
|
3106
|
+
/**
|
|
3107
|
+
* Validate the cache key against filter before retrieving and parsing cache value
|
|
3108
|
+
* @param key
|
|
3109
|
+
* @param filter
|
|
3110
|
+
*/
|
|
3111
|
+
CacheManager.prototype.refreshTokenKeyMatchesFilter = function (inputKey, filter) {
|
|
3112
|
+
var key = inputKey.toLowerCase();
|
|
3113
|
+
if (filter.familyId && key.indexOf(filter.familyId.toLowerCase()) === -1) {
|
|
3114
|
+
return false;
|
|
3115
|
+
}
|
|
3116
|
+
// If familyId is used, clientId is not in the key
|
|
3117
|
+
if (!filter.familyId && filter.clientId && key.indexOf(filter.clientId.toLowerCase()) === -1) {
|
|
3118
|
+
return false;
|
|
3119
|
+
}
|
|
3120
|
+
if (filter.homeAccountId && key.indexOf(filter.homeAccountId.toLowerCase()) === -1) {
|
|
3121
|
+
return false;
|
|
3122
|
+
}
|
|
3123
|
+
return true;
|
|
3124
|
+
};
|
|
3132
3125
|
/**
|
|
3133
3126
|
* Retrieve AppMetadataEntity from cache
|
|
3134
3127
|
*/
|
|
3135
|
-
CacheManager.prototype.readAppMetadataFromCache = function (environment
|
|
3128
|
+
CacheManager.prototype.readAppMetadataFromCache = function (environment) {
|
|
3136
3129
|
var appMetadataFilter = {
|
|
3137
3130
|
environment: environment,
|
|
3138
|
-
clientId: clientId,
|
|
3131
|
+
clientId: this.clientId,
|
|
3139
3132
|
};
|
|
3140
3133
|
var appMetadata = this.getAppMetadataFilteredBy(appMetadataFilter);
|
|
3141
3134
|
var appMetadataEntries = Object.keys(appMetadata).map(function (key) { return appMetadata[key]; });
|
|
@@ -3153,8 +3146,8 @@
|
|
|
3153
3146
|
* @param environment
|
|
3154
3147
|
* @param clientId
|
|
3155
3148
|
*/
|
|
3156
|
-
CacheManager.prototype.isAppMetadataFOCI = function (environment
|
|
3157
|
-
var appMetadata = this.readAppMetadataFromCache(environment
|
|
3149
|
+
CacheManager.prototype.isAppMetadataFOCI = function (environment) {
|
|
3150
|
+
var appMetadata = this.readAppMetadataFromCache(environment);
|
|
3158
3151
|
return !!(appMetadata && appMetadata.familyId === THE_FAMILY_ID);
|
|
3159
3152
|
};
|
|
3160
3153
|
/**
|
|
@@ -3165,6 +3158,24 @@
|
|
|
3165
3158
|
CacheManager.prototype.matchHomeAccountId = function (entity, homeAccountId) {
|
|
3166
3159
|
return !!((typeof entity.homeAccountId === "string") && (homeAccountId === entity.homeAccountId));
|
|
3167
3160
|
};
|
|
3161
|
+
/**
|
|
3162
|
+
* helper to match account ids
|
|
3163
|
+
* @param entity
|
|
3164
|
+
* @param localAccountId
|
|
3165
|
+
* @returns
|
|
3166
|
+
*/
|
|
3167
|
+
CacheManager.prototype.matchLocalAccountId = function (entity, localAccountId) {
|
|
3168
|
+
return !!((typeof entity.localAccountId === "string") && (localAccountId === entity.localAccountId));
|
|
3169
|
+
};
|
|
3170
|
+
/**
|
|
3171
|
+
* helper to match usernames
|
|
3172
|
+
* @param entity
|
|
3173
|
+
* @param username
|
|
3174
|
+
* @returns
|
|
3175
|
+
*/
|
|
3176
|
+
CacheManager.prototype.matchUsername = function (entity, username) {
|
|
3177
|
+
return !!((typeof entity.username === "string") && (username.toLowerCase() === entity.username.toLowerCase()));
|
|
3178
|
+
};
|
|
3168
3179
|
/**
|
|
3169
3180
|
* helper to match assertion
|
|
3170
3181
|
* @param value
|
|
@@ -3237,14 +3248,7 @@
|
|
|
3237
3248
|
return false;
|
|
3238
3249
|
}
|
|
3239
3250
|
var entityScopeSet = ScopeSet.fromString(entity.target);
|
|
3240
|
-
|
|
3241
|
-
if (!requestTargetScopeSet.containsOnlyOIDCScopes()) {
|
|
3242
|
-
requestTargetScopeSet.removeOIDCScopes(); // ignore OIDC scopes
|
|
3243
|
-
}
|
|
3244
|
-
else {
|
|
3245
|
-
requestTargetScopeSet.removeScope(Constants.OFFLINE_ACCESS_SCOPE);
|
|
3246
|
-
}
|
|
3247
|
-
return entityScopeSet.containsScopeSet(requestTargetScopeSet);
|
|
3251
|
+
return entityScopeSet.containsScopeSet(target);
|
|
3248
3252
|
};
|
|
3249
3253
|
/**
|
|
3250
3254
|
* Returns true if the credential's tokenType or Authentication Scheme matches the one in the request, false otherwise
|
|
@@ -3282,27 +3286,6 @@
|
|
|
3282
3286
|
CacheManager.prototype.generateAuthorityMetadataCacheKey = function (authority) {
|
|
3283
3287
|
return AUTHORITY_METADATA_CONSTANTS.CACHE_KEY + "-" + this.clientId + "-" + authority;
|
|
3284
3288
|
};
|
|
3285
|
-
/**
|
|
3286
|
-
* Returns the specific credential (IdToken/AccessToken/RefreshToken) from the cache
|
|
3287
|
-
* @param key
|
|
3288
|
-
* @param credType
|
|
3289
|
-
*/
|
|
3290
|
-
CacheManager.prototype.getSpecificCredential = function (key, credType) {
|
|
3291
|
-
switch (credType) {
|
|
3292
|
-
case CredentialType.ID_TOKEN: {
|
|
3293
|
-
return this.getIdTokenCredential(key);
|
|
3294
|
-
}
|
|
3295
|
-
case CredentialType.ACCESS_TOKEN:
|
|
3296
|
-
case CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME: {
|
|
3297
|
-
return this.getAccessTokenCredential(key);
|
|
3298
|
-
}
|
|
3299
|
-
case CredentialType.REFRESH_TOKEN: {
|
|
3300
|
-
return this.getRefreshTokenCredential(key);
|
|
3301
|
-
}
|
|
3302
|
-
default:
|
|
3303
|
-
return null;
|
|
3304
|
-
}
|
|
3305
|
-
};
|
|
3306
3289
|
/**
|
|
3307
3290
|
* Helper to convert serialized data to object
|
|
3308
3291
|
* @param obj
|
|
@@ -3401,6 +3384,14 @@
|
|
|
3401
3384
|
var notImplErr = "Storage interface - getKeys() has not been implemented for the cacheStorage interface.";
|
|
3402
3385
|
throw AuthError.createUnexpectedError(notImplErr);
|
|
3403
3386
|
};
|
|
3387
|
+
DefaultStorageClass.prototype.getAccountKeys = function () {
|
|
3388
|
+
var notImplErr = "Storage interface - getAccountKeys() has not been implemented for the cacheStorage interface.";
|
|
3389
|
+
throw AuthError.createUnexpectedError(notImplErr);
|
|
3390
|
+
};
|
|
3391
|
+
DefaultStorageClass.prototype.getTokenKeys = function () {
|
|
3392
|
+
var notImplErr = "Storage interface - getTokenKeys() has not been implemented for the cacheStorage interface.";
|
|
3393
|
+
throw AuthError.createUnexpectedError(notImplErr);
|
|
3394
|
+
};
|
|
3404
3395
|
DefaultStorageClass.prototype.clear = function () {
|
|
3405
3396
|
return __awaiter(this, void 0, void 0, function () {
|
|
3406
3397
|
var notImplErr;
|
|
@@ -3417,7 +3408,7 @@
|
|
|
3417
3408
|
return DefaultStorageClass;
|
|
3418
3409
|
}(CacheManager));
|
|
3419
3410
|
|
|
3420
|
-
/*! @azure/msal-common
|
|
3411
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
3421
3412
|
|
|
3422
3413
|
/*
|
|
3423
3414
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3491,7 +3482,7 @@
|
|
|
3491
3482
|
authOptions: buildAuthOptions(userAuthOptions),
|
|
3492
3483
|
systemOptions: __assign(__assign({}, DEFAULT_SYSTEM_OPTIONS), userSystemOptions),
|
|
3493
3484
|
loggerOptions: loggerOptions,
|
|
3494
|
-
storageInterface: storageImplementation || new DefaultStorageClass(userAuthOptions.clientId, DEFAULT_CRYPTO_IMPLEMENTATION),
|
|
3485
|
+
storageInterface: storageImplementation || new DefaultStorageClass(userAuthOptions.clientId, DEFAULT_CRYPTO_IMPLEMENTATION, new Logger(loggerOptions)),
|
|
3495
3486
|
networkInterface: networkImplementation || DEFAULT_NETWORK_IMPLEMENTATION,
|
|
3496
3487
|
cryptoInterface: cryptoImplementation || DEFAULT_CRYPTO_IMPLEMENTATION,
|
|
3497
3488
|
clientCredentials: clientCredentials || DEFAULT_CLIENT_CREDENTIALS,
|
|
@@ -3510,7 +3501,7 @@
|
|
|
3510
3501
|
return __assign({ clientCapabilities: [], azureCloudOptions: DEFAULT_AZURE_CLOUD_OPTIONS, skipAuthorityMetadataCache: false }, authOptions);
|
|
3511
3502
|
}
|
|
3512
3503
|
|
|
3513
|
-
/*! @azure/msal-common
|
|
3504
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
3514
3505
|
|
|
3515
3506
|
/*
|
|
3516
3507
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3530,7 +3521,7 @@
|
|
|
3530
3521
|
return ServerError;
|
|
3531
3522
|
}(AuthError));
|
|
3532
3523
|
|
|
3533
|
-
/*! @azure/msal-common
|
|
3524
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
3534
3525
|
|
|
3535
3526
|
/*
|
|
3536
3527
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3557,7 +3548,7 @@
|
|
|
3557
3548
|
var value = cacheManager.getThrottlingCache(key);
|
|
3558
3549
|
if (value) {
|
|
3559
3550
|
if (value.throttleTime < Date.now()) {
|
|
3560
|
-
cacheManager.removeItem(key
|
|
3551
|
+
cacheManager.removeItem(key);
|
|
3561
3552
|
return;
|
|
3562
3553
|
}
|
|
3563
3554
|
throw new ServerError(((_a = value.errorCodes) === null || _a === void 0 ? void 0 : _a.join(" ")) || Constants.EMPTY_STRING, value.errorMessage, value.subError);
|
|
@@ -3621,12 +3612,12 @@
|
|
|
3621
3612
|
sshKid: request.sshKid
|
|
3622
3613
|
};
|
|
3623
3614
|
var key = this.generateThrottlingStorageKey(thumbprint);
|
|
3624
|
-
|
|
3615
|
+
cacheManager.removeItem(key);
|
|
3625
3616
|
};
|
|
3626
3617
|
return ThrottlingUtils;
|
|
3627
3618
|
}());
|
|
3628
3619
|
|
|
3629
|
-
/*! @azure/msal-common
|
|
3620
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
3630
3621
|
|
|
3631
3622
|
/*
|
|
3632
3623
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3675,7 +3666,7 @@
|
|
|
3675
3666
|
return NetworkManager;
|
|
3676
3667
|
}());
|
|
3677
3668
|
|
|
3678
|
-
/*! @azure/msal-common
|
|
3669
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
3679
3670
|
/*
|
|
3680
3671
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3681
3672
|
* Licensed under the MIT License.
|
|
@@ -3686,7 +3677,7 @@
|
|
|
3686
3677
|
CcsCredentialType["UPN"] = "UPN";
|
|
3687
3678
|
})(CcsCredentialType || (CcsCredentialType = {}));
|
|
3688
3679
|
|
|
3689
|
-
/*! @azure/msal-common
|
|
3680
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
3690
3681
|
|
|
3691
3682
|
/*
|
|
3692
3683
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3777,7 +3768,7 @@
|
|
|
3777
3768
|
return RequestValidator;
|
|
3778
3769
|
}());
|
|
3779
3770
|
|
|
3780
|
-
/*! @azure/msal-common
|
|
3771
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
3781
3772
|
|
|
3782
3773
|
/*
|
|
3783
3774
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4155,7 +4146,7 @@
|
|
|
4155
4146
|
return RequestParameterBuilder;
|
|
4156
4147
|
}());
|
|
4157
4148
|
|
|
4158
|
-
/*! @azure/msal-common
|
|
4149
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
4159
4150
|
|
|
4160
4151
|
/*
|
|
4161
4152
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4207,57 +4198,195 @@
|
|
|
4207
4198
|
break;
|
|
4208
4199
|
}
|
|
4209
4200
|
}
|
|
4210
|
-
return headers;
|
|
4201
|
+
return headers;
|
|
4202
|
+
};
|
|
4203
|
+
/**
|
|
4204
|
+
* Http post to token endpoint
|
|
4205
|
+
* @param tokenEndpoint
|
|
4206
|
+
* @param queryString
|
|
4207
|
+
* @param headers
|
|
4208
|
+
* @param thumbprint
|
|
4209
|
+
*/
|
|
4210
|
+
BaseClient.prototype.executePostToTokenEndpoint = function (tokenEndpoint, queryString, headers, thumbprint) {
|
|
4211
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
4212
|
+
var response;
|
|
4213
|
+
return __generator(this, function (_a) {
|
|
4214
|
+
switch (_a.label) {
|
|
4215
|
+
case 0: return [4 /*yield*/, this.networkManager.sendPostRequest(thumbprint, tokenEndpoint, { body: queryString, headers: headers })];
|
|
4216
|
+
case 1:
|
|
4217
|
+
response = _a.sent();
|
|
4218
|
+
if (this.config.serverTelemetryManager && response.status < 500 && response.status !== 429) {
|
|
4219
|
+
// Telemetry data successfully logged by server, clear Telemetry cache
|
|
4220
|
+
this.config.serverTelemetryManager.clearTelemetryCache();
|
|
4221
|
+
}
|
|
4222
|
+
return [2 /*return*/, response];
|
|
4223
|
+
}
|
|
4224
|
+
});
|
|
4225
|
+
});
|
|
4226
|
+
};
|
|
4227
|
+
/**
|
|
4228
|
+
* Updates the authority object of the client. Endpoint discovery must be completed.
|
|
4229
|
+
* @param updatedAuthority
|
|
4230
|
+
*/
|
|
4231
|
+
BaseClient.prototype.updateAuthority = function (updatedAuthority) {
|
|
4232
|
+
if (!updatedAuthority.discoveryComplete()) {
|
|
4233
|
+
throw ClientAuthError.createEndpointDiscoveryIncompleteError("Updated authority has not completed endpoint discovery.");
|
|
4234
|
+
}
|
|
4235
|
+
this.authority = updatedAuthority;
|
|
4236
|
+
};
|
|
4237
|
+
/**
|
|
4238
|
+
* Creates query string for the /token request
|
|
4239
|
+
* @param request
|
|
4240
|
+
*/
|
|
4241
|
+
BaseClient.prototype.createTokenQueryParameters = function (request) {
|
|
4242
|
+
var parameterBuilder = new RequestParameterBuilder();
|
|
4243
|
+
if (request.tokenQueryParameters) {
|
|
4244
|
+
parameterBuilder.addExtraQueryParameters(request.tokenQueryParameters);
|
|
4245
|
+
}
|
|
4246
|
+
return parameterBuilder.createQueryString();
|
|
4247
|
+
};
|
|
4248
|
+
return BaseClient;
|
|
4249
|
+
}());
|
|
4250
|
+
|
|
4251
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
4252
|
+
|
|
4253
|
+
/*
|
|
4254
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4255
|
+
* Licensed under the MIT License.
|
|
4256
|
+
*/
|
|
4257
|
+
/**
|
|
4258
|
+
* Base type for credentials to be stored in the cache: eg: ACCESS_TOKEN, ID_TOKEN etc
|
|
4259
|
+
*
|
|
4260
|
+
* Key:Value Schema:
|
|
4261
|
+
*
|
|
4262
|
+
* Key: <home_account_id*>-<environment>-<credential_type>-<client_id>-<realm*>-<target*>-<requestedClaims*>-<scheme*>
|
|
4263
|
+
*
|
|
4264
|
+
* Value Schema:
|
|
4265
|
+
* {
|
|
4266
|
+
* homeAccountId: home account identifier for the auth scheme,
|
|
4267
|
+
* environment: entity that issued the token, represented as a full host
|
|
4268
|
+
* credentialType: Type of credential as a string, can be one of the following: RefreshToken, AccessToken, IdToken, Password, Cookie, Certificate, Other
|
|
4269
|
+
* clientId: client ID of the application
|
|
4270
|
+
* secret: Actual credential as a string
|
|
4271
|
+
* familyId: Family ID identifier, usually only used for refresh tokens
|
|
4272
|
+
* realm: Full tenant or organizational identifier that the account belongs to
|
|
4273
|
+
* target: Permissions that are included in the token, or for refresh tokens, the resource identifier.
|
|
4274
|
+
* tokenType: Matches the authentication scheme for which the token was issued (i.e. Bearer or pop)
|
|
4275
|
+
* requestedClaimsHash: Matches the SHA 256 hash of the claims object included in the token request
|
|
4276
|
+
* userAssertionHash: Matches the SHA 256 hash of the obo_assertion for the OBO flow
|
|
4277
|
+
* }
|
|
4278
|
+
*/
|
|
4279
|
+
var CredentialEntity = /** @class */ (function () {
|
|
4280
|
+
function CredentialEntity() {
|
|
4281
|
+
}
|
|
4282
|
+
/**
|
|
4283
|
+
* Generate Account Id key component as per the schema: <home_account_id>-<environment>
|
|
4284
|
+
*/
|
|
4285
|
+
CredentialEntity.prototype.generateAccountId = function () {
|
|
4286
|
+
return CredentialEntity.generateAccountIdForCacheKey(this.homeAccountId, this.environment);
|
|
4287
|
+
};
|
|
4288
|
+
/**
|
|
4289
|
+
* Generate Credential Id key component as per the schema: <credential_type>-<client_id>-<realm>
|
|
4290
|
+
*/
|
|
4291
|
+
CredentialEntity.prototype.generateCredentialId = function () {
|
|
4292
|
+
return CredentialEntity.generateCredentialIdForCacheKey(this.credentialType, this.clientId, this.realm, this.familyId);
|
|
4293
|
+
};
|
|
4294
|
+
/**
|
|
4295
|
+
* Generate target key component as per schema: <target>
|
|
4296
|
+
*/
|
|
4297
|
+
CredentialEntity.prototype.generateTarget = function () {
|
|
4298
|
+
return CredentialEntity.generateTargetForCacheKey(this.target);
|
|
4299
|
+
};
|
|
4300
|
+
/**
|
|
4301
|
+
* generates credential key
|
|
4302
|
+
*/
|
|
4303
|
+
CredentialEntity.prototype.generateCredentialKey = function () {
|
|
4304
|
+
return CredentialEntity.generateCredentialCacheKey(this.homeAccountId, this.environment, this.credentialType, this.clientId, this.realm, this.target, this.familyId, this.tokenType, this.requestedClaimsHash);
|
|
4305
|
+
};
|
|
4306
|
+
/**
|
|
4307
|
+
* returns the type of the cache (in this case credential)
|
|
4308
|
+
*/
|
|
4309
|
+
CredentialEntity.prototype.generateType = function () {
|
|
4310
|
+
switch (this.credentialType) {
|
|
4311
|
+
case CredentialType.ID_TOKEN:
|
|
4312
|
+
return CacheType.ID_TOKEN;
|
|
4313
|
+
case CredentialType.ACCESS_TOKEN:
|
|
4314
|
+
case CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME:
|
|
4315
|
+
return CacheType.ACCESS_TOKEN;
|
|
4316
|
+
case CredentialType.REFRESH_TOKEN:
|
|
4317
|
+
return CacheType.REFRESH_TOKEN;
|
|
4318
|
+
default: {
|
|
4319
|
+
throw ClientAuthError.createUnexpectedCredentialTypeError();
|
|
4320
|
+
}
|
|
4321
|
+
}
|
|
4211
4322
|
};
|
|
4212
4323
|
/**
|
|
4213
|
-
*
|
|
4214
|
-
*
|
|
4215
|
-
* @param queryString
|
|
4216
|
-
* @param headers
|
|
4217
|
-
* @param thumbprint
|
|
4324
|
+
* generates credential key
|
|
4325
|
+
* <home_account_id*>-\<environment>-<credential_type>-<client_id>-<realm\*>-<target\*>-<scheme\*>
|
|
4218
4326
|
*/
|
|
4219
|
-
|
|
4220
|
-
|
|
4221
|
-
|
|
4222
|
-
|
|
4223
|
-
|
|
4224
|
-
|
|
4225
|
-
|
|
4226
|
-
|
|
4227
|
-
|
|
4228
|
-
// Telemetry data successfully logged by server, clear Telemetry cache
|
|
4229
|
-
this.config.serverTelemetryManager.clearTelemetryCache();
|
|
4230
|
-
}
|
|
4231
|
-
return [2 /*return*/, response];
|
|
4232
|
-
}
|
|
4233
|
-
});
|
|
4234
|
-
});
|
|
4327
|
+
CredentialEntity.generateCredentialCacheKey = function (homeAccountId, environment, credentialType, clientId, realm, target, familyId, tokenType, requestedClaimsHash) {
|
|
4328
|
+
var credentialKey = [
|
|
4329
|
+
this.generateAccountIdForCacheKey(homeAccountId, environment),
|
|
4330
|
+
this.generateCredentialIdForCacheKey(credentialType, clientId, realm, familyId),
|
|
4331
|
+
this.generateTargetForCacheKey(target),
|
|
4332
|
+
this.generateClaimsHashForCacheKey(requestedClaimsHash),
|
|
4333
|
+
this.generateSchemeForCacheKey(tokenType)
|
|
4334
|
+
];
|
|
4335
|
+
return credentialKey.join(Separators.CACHE_KEY_SEPARATOR).toLowerCase();
|
|
4235
4336
|
};
|
|
4236
4337
|
/**
|
|
4237
|
-
*
|
|
4238
|
-
* @param
|
|
4338
|
+
* generates Account Id for keys
|
|
4339
|
+
* @param homeAccountId
|
|
4340
|
+
* @param environment
|
|
4239
4341
|
*/
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
}
|
|
4244
|
-
this.authority = updatedAuthority;
|
|
4342
|
+
CredentialEntity.generateAccountIdForCacheKey = function (homeAccountId, environment) {
|
|
4343
|
+
var accountId = [homeAccountId, environment];
|
|
4344
|
+
return accountId.join(Separators.CACHE_KEY_SEPARATOR).toLowerCase();
|
|
4245
4345
|
};
|
|
4246
4346
|
/**
|
|
4247
|
-
*
|
|
4248
|
-
* @param
|
|
4347
|
+
* Generates Credential Id for keys
|
|
4348
|
+
* @param credentialType
|
|
4349
|
+
* @param realm
|
|
4350
|
+
* @param clientId
|
|
4351
|
+
* @param familyId
|
|
4249
4352
|
*/
|
|
4250
|
-
|
|
4251
|
-
var
|
|
4252
|
-
|
|
4253
|
-
|
|
4254
|
-
|
|
4255
|
-
|
|
4353
|
+
CredentialEntity.generateCredentialIdForCacheKey = function (credentialType, clientId, realm, familyId) {
|
|
4354
|
+
var clientOrFamilyId = credentialType === CredentialType.REFRESH_TOKEN
|
|
4355
|
+
? familyId || clientId
|
|
4356
|
+
: clientId;
|
|
4357
|
+
var credentialId = [
|
|
4358
|
+
credentialType,
|
|
4359
|
+
clientOrFamilyId,
|
|
4360
|
+
realm || Constants.EMPTY_STRING,
|
|
4361
|
+
];
|
|
4362
|
+
return credentialId.join(Separators.CACHE_KEY_SEPARATOR).toLowerCase();
|
|
4256
4363
|
};
|
|
4257
|
-
|
|
4364
|
+
/**
|
|
4365
|
+
* Generate target key component as per schema: <target>
|
|
4366
|
+
*/
|
|
4367
|
+
CredentialEntity.generateTargetForCacheKey = function (scopes) {
|
|
4368
|
+
return (scopes || Constants.EMPTY_STRING).toLowerCase();
|
|
4369
|
+
};
|
|
4370
|
+
/**
|
|
4371
|
+
* Generate requested claims key component as per schema: <requestedClaims>
|
|
4372
|
+
*/
|
|
4373
|
+
CredentialEntity.generateClaimsHashForCacheKey = function (requestedClaimsHash) {
|
|
4374
|
+
return (requestedClaimsHash || Constants.EMPTY_STRING).toLowerCase();
|
|
4375
|
+
};
|
|
4376
|
+
/**
|
|
4377
|
+
* Generate scheme key componenet as per schema: <scheme>
|
|
4378
|
+
*/
|
|
4379
|
+
CredentialEntity.generateSchemeForCacheKey = function (tokenType) {
|
|
4380
|
+
/*
|
|
4381
|
+
* PoP Tokens and SSH certs include scheme in cache key
|
|
4382
|
+
* Cast to lowercase to handle "bearer" from ADFS
|
|
4383
|
+
*/
|
|
4384
|
+
return (tokenType && tokenType.toLowerCase() !== exports.AuthenticationScheme.BEARER.toLowerCase()) ? tokenType.toLowerCase() : Constants.EMPTY_STRING;
|
|
4385
|
+
};
|
|
4386
|
+
return CredentialEntity;
|
|
4258
4387
|
}());
|
|
4259
4388
|
|
|
4260
|
-
/*! @azure/msal-common
|
|
4389
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
4261
4390
|
|
|
4262
4391
|
/*
|
|
4263
4392
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4321,7 +4450,7 @@
|
|
|
4321
4450
|
return IdTokenEntity;
|
|
4322
4451
|
}(CredentialEntity));
|
|
4323
4452
|
|
|
4324
|
-
/*! @azure/msal-common
|
|
4453
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
4325
4454
|
/*
|
|
4326
4455
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4327
4456
|
* Licensed under the MIT License.
|
|
@@ -4371,7 +4500,7 @@
|
|
|
4371
4500
|
return TimeUtils;
|
|
4372
4501
|
}());
|
|
4373
4502
|
|
|
4374
|
-
/*! @azure/msal-common
|
|
4503
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
4375
4504
|
|
|
4376
4505
|
/*
|
|
4377
4506
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4485,7 +4614,7 @@
|
|
|
4485
4614
|
return AccessTokenEntity;
|
|
4486
4615
|
}(CredentialEntity));
|
|
4487
4616
|
|
|
4488
|
-
/*! @azure/msal-common
|
|
4617
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
4489
4618
|
|
|
4490
4619
|
/*
|
|
4491
4620
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4552,7 +4681,7 @@
|
|
|
4552
4681
|
return RefreshTokenEntity;
|
|
4553
4682
|
}(CredentialEntity));
|
|
4554
4683
|
|
|
4555
|
-
/*! @azure/msal-common
|
|
4684
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
4556
4685
|
|
|
4557
4686
|
/*
|
|
4558
4687
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4631,7 +4760,7 @@
|
|
|
4631
4760
|
return InteractionRequiredAuthError;
|
|
4632
4761
|
}(AuthError));
|
|
4633
4762
|
|
|
4634
|
-
/*! @azure/msal-common
|
|
4763
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
4635
4764
|
/*
|
|
4636
4765
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4637
4766
|
* Licensed under the MIT License.
|
|
@@ -4647,7 +4776,7 @@
|
|
|
4647
4776
|
return CacheRecord;
|
|
4648
4777
|
}());
|
|
4649
4778
|
|
|
4650
|
-
/*! @azure/msal-common
|
|
4779
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
4651
4780
|
|
|
4652
4781
|
/*
|
|
4653
4782
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4718,7 +4847,7 @@
|
|
|
4718
4847
|
return ProtocolUtils;
|
|
4719
4848
|
}());
|
|
4720
4849
|
|
|
4721
|
-
/*! @azure/msal-common
|
|
4850
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
4722
4851
|
|
|
4723
4852
|
/*
|
|
4724
4853
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4952,7 +5081,7 @@
|
|
|
4952
5081
|
return UrlString;
|
|
4953
5082
|
}());
|
|
4954
5083
|
|
|
4955
|
-
/*! @azure/msal-common
|
|
5084
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
4956
5085
|
/*
|
|
4957
5086
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4958
5087
|
* Licensed under the MIT License.
|
|
@@ -5181,7 +5310,7 @@
|
|
|
5181
5310
|
"status",
|
|
5182
5311
|
]);
|
|
5183
5312
|
|
|
5184
|
-
/*! @azure/msal-common
|
|
5313
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
5185
5314
|
|
|
5186
5315
|
/*
|
|
5187
5316
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -5290,7 +5419,7 @@
|
|
|
5290
5419
|
return PopTokenGenerator;
|
|
5291
5420
|
}());
|
|
5292
5421
|
|
|
5293
|
-
/*! @azure/msal-common
|
|
5422
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
5294
5423
|
|
|
5295
5424
|
/*
|
|
5296
5425
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -5360,7 +5489,7 @@
|
|
|
5360
5489
|
return AppMetadataEntity;
|
|
5361
5490
|
}());
|
|
5362
5491
|
|
|
5363
|
-
/*! @azure/msal-common
|
|
5492
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
5364
5493
|
/*
|
|
5365
5494
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
5366
5495
|
* Licensed under the MIT License.
|
|
@@ -5396,7 +5525,7 @@
|
|
|
5396
5525
|
return TokenCacheContext;
|
|
5397
5526
|
}());
|
|
5398
5527
|
|
|
5399
|
-
/*! @azure/msal-common
|
|
5528
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
5400
5529
|
|
|
5401
5530
|
/*
|
|
5402
5531
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -5683,7 +5812,7 @@
|
|
|
5683
5812
|
return ResponseHandler;
|
|
5684
5813
|
}());
|
|
5685
5814
|
|
|
5686
|
-
/*! @azure/msal-common
|
|
5815
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
5687
5816
|
|
|
5688
5817
|
/*
|
|
5689
5818
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6161,7 +6290,7 @@
|
|
|
6161
6290
|
return AuthorizationCodeClient;
|
|
6162
6291
|
}(BaseClient));
|
|
6163
6292
|
|
|
6164
|
-
/*! @azure/msal-common
|
|
6293
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
6165
6294
|
|
|
6166
6295
|
/*
|
|
6167
6296
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6241,7 +6370,7 @@
|
|
|
6241
6370
|
if (!request.account) {
|
|
6242
6371
|
throw ClientAuthError.createNoAccountInSilentRequestError();
|
|
6243
6372
|
}
|
|
6244
|
-
isFOCI = this.cacheManager.isAppMetadataFOCI(request.account.environment
|
|
6373
|
+
isFOCI = this.cacheManager.isAppMetadataFOCI(request.account.environment);
|
|
6245
6374
|
// if the app is part of the family, retrive a Family refresh token if present and make a refreshTokenRequest
|
|
6246
6375
|
if (isFOCI) {
|
|
6247
6376
|
try {
|
|
@@ -6280,7 +6409,7 @@
|
|
|
6280
6409
|
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.RefreshTokenClientAcquireTokenWithCachedRefreshToken, request.correlationId);
|
|
6281
6410
|
atsMeasurement = (_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.startMeasurement(exports.PerformanceEvents.RefreshTokenClientAcquireTokenWithCachedRefreshToken, request.correlationId);
|
|
6282
6411
|
this.logger.verbose("RefreshTokenClientAcquireTokenWithCachedRefreshToken called", request.correlationId);
|
|
6283
|
-
refreshToken = this.cacheManager.
|
|
6412
|
+
refreshToken = this.cacheManager.getRefreshToken(request.account, foci);
|
|
6284
6413
|
if (!refreshToken) {
|
|
6285
6414
|
atsMeasurement === null || atsMeasurement === void 0 ? void 0 : atsMeasurement.discardMeasurement();
|
|
6286
6415
|
throw InteractionRequiredAuthError.createNoTokensFoundError();
|
|
@@ -6435,7 +6564,7 @@
|
|
|
6435
6564
|
return RefreshTokenClient;
|
|
6436
6565
|
}(BaseClient));
|
|
6437
6566
|
|
|
6438
|
-
/*! @azure/msal-common
|
|
6567
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
6439
6568
|
|
|
6440
6569
|
/*
|
|
6441
6570
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6500,7 +6629,7 @@
|
|
|
6500
6629
|
throw ClientAuthError.createNoAccountInSilentRequestError();
|
|
6501
6630
|
}
|
|
6502
6631
|
environment = request.authority || this.authority.getPreferredCache();
|
|
6503
|
-
cacheRecord = this.cacheManager.readCacheRecord(request.account,
|
|
6632
|
+
cacheRecord = this.cacheManager.readCacheRecord(request.account, request, environment);
|
|
6504
6633
|
if (!cacheRecord.accessToken) {
|
|
6505
6634
|
// Must refresh due to non-existent access_token.
|
|
6506
6635
|
(_b = this.serverTelemetryManager) === null || _b === void 0 ? void 0 : _b.setCacheOutcome(CacheOutcome.NO_CACHED_ACCESS_TOKEN);
|
|
@@ -6559,7 +6688,7 @@
|
|
|
6559
6688
|
return SilentFlowClient;
|
|
6560
6689
|
}(BaseClient));
|
|
6561
6690
|
|
|
6562
|
-
/*! @azure/msal-common
|
|
6691
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
6563
6692
|
/*
|
|
6564
6693
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
6565
6694
|
* Licensed under the MIT License.
|
|
@@ -6571,7 +6700,7 @@
|
|
|
6571
6700
|
response.hasOwnProperty("jwks_uri"));
|
|
6572
6701
|
}
|
|
6573
6702
|
|
|
6574
|
-
/*! @azure/msal-common
|
|
6703
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
6575
6704
|
/*
|
|
6576
6705
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
6577
6706
|
* Licensed under the MIT License.
|
|
@@ -6580,7 +6709,7 @@
|
|
|
6580
6709
|
var EndpointMetadata = rawMetdataJSON.endpointMetadata;
|
|
6581
6710
|
var InstanceDiscoveryMetadata = rawMetdataJSON.instanceDiscoveryMetadata;
|
|
6582
6711
|
|
|
6583
|
-
/*! @azure/msal-common
|
|
6712
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
6584
6713
|
/*
|
|
6585
6714
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
6586
6715
|
* Licensed under the MIT License.
|
|
@@ -6594,7 +6723,7 @@
|
|
|
6594
6723
|
ProtocolMode["OIDC"] = "OIDC";
|
|
6595
6724
|
})(exports.ProtocolMode || (exports.ProtocolMode = {}));
|
|
6596
6725
|
|
|
6597
|
-
/*! @azure/msal-common
|
|
6726
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
6598
6727
|
|
|
6599
6728
|
/*
|
|
6600
6729
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6671,7 +6800,7 @@
|
|
|
6671
6800
|
return AuthorityMetadataEntity;
|
|
6672
6801
|
}());
|
|
6673
6802
|
|
|
6674
|
-
/*! @azure/msal-common
|
|
6803
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
6675
6804
|
/*
|
|
6676
6805
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
6677
6806
|
* Licensed under the MIT License.
|
|
@@ -6681,7 +6810,7 @@
|
|
|
6681
6810
|
response.hasOwnProperty("metadata"));
|
|
6682
6811
|
}
|
|
6683
6812
|
|
|
6684
|
-
/*! @azure/msal-common
|
|
6813
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
6685
6814
|
/*
|
|
6686
6815
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
6687
6816
|
* Licensed under the MIT License.
|
|
@@ -6691,7 +6820,7 @@
|
|
|
6691
6820
|
response.hasOwnProperty("error_description"));
|
|
6692
6821
|
}
|
|
6693
6822
|
|
|
6694
|
-
/*! @azure/msal-common
|
|
6823
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
6695
6824
|
|
|
6696
6825
|
/*
|
|
6697
6826
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6823,7 +6952,7 @@
|
|
|
6823
6952
|
return RegionDiscovery;
|
|
6824
6953
|
}());
|
|
6825
6954
|
|
|
6826
|
-
/*! @azure/msal-common
|
|
6955
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
6827
6956
|
|
|
6828
6957
|
/*
|
|
6829
6958
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7558,7 +7687,7 @@
|
|
|
7558
7687
|
return Authority;
|
|
7559
7688
|
}());
|
|
7560
7689
|
|
|
7561
|
-
/*! @azure/msal-common
|
|
7690
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
7562
7691
|
|
|
7563
7692
|
/*
|
|
7564
7693
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7621,7 +7750,7 @@
|
|
|
7621
7750
|
return AuthorityFactory;
|
|
7622
7751
|
}());
|
|
7623
7752
|
|
|
7624
|
-
/*! @azure/msal-common
|
|
7753
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
7625
7754
|
|
|
7626
7755
|
/*
|
|
7627
7756
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7652,7 +7781,7 @@
|
|
|
7652
7781
|
return ServerTelemetryEntity;
|
|
7653
7782
|
}());
|
|
7654
7783
|
|
|
7655
|
-
/*! @azure/msal-common
|
|
7784
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
7656
7785
|
|
|
7657
7786
|
/*
|
|
7658
7787
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7680,7 +7809,7 @@
|
|
|
7680
7809
|
return ThrottlingEntity;
|
|
7681
7810
|
}());
|
|
7682
7811
|
|
|
7683
|
-
/*! @azure/msal-common
|
|
7812
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
7684
7813
|
|
|
7685
7814
|
/*
|
|
7686
7815
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7697,7 +7826,7 @@
|
|
|
7697
7826
|
}
|
|
7698
7827
|
};
|
|
7699
7828
|
|
|
7700
|
-
/*! @azure/msal-common
|
|
7829
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
7701
7830
|
|
|
7702
7831
|
/*
|
|
7703
7832
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7742,7 +7871,7 @@
|
|
|
7742
7871
|
return JoseHeaderError;
|
|
7743
7872
|
}(AuthError));
|
|
7744
7873
|
|
|
7745
|
-
/*! @azure/msal-common
|
|
7874
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
7746
7875
|
|
|
7747
7876
|
/*
|
|
7748
7877
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7782,7 +7911,7 @@
|
|
|
7782
7911
|
return JoseHeader;
|
|
7783
7912
|
}());
|
|
7784
7913
|
|
|
7785
|
-
/*! @azure/msal-common
|
|
7914
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
7786
7915
|
|
|
7787
7916
|
/*
|
|
7788
7917
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7841,7 +7970,7 @@
|
|
|
7841
7970
|
return AuthenticationHeaderParser;
|
|
7842
7971
|
}());
|
|
7843
7972
|
|
|
7844
|
-
/*! @azure/msal-common
|
|
7973
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
7845
7974
|
|
|
7846
7975
|
/*
|
|
7847
7976
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -8003,7 +8132,7 @@
|
|
|
8003
8132
|
return ServerTelemetryManager;
|
|
8004
8133
|
}());
|
|
8005
8134
|
|
|
8006
|
-
/*! @azure/msal-common
|
|
8135
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
8007
8136
|
|
|
8008
8137
|
/*
|
|
8009
8138
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -8406,7 +8535,7 @@
|
|
|
8406
8535
|
return PerformanceClient;
|
|
8407
8536
|
}());
|
|
8408
8537
|
|
|
8409
|
-
/*! @azure/msal-common
|
|
8538
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
8410
8539
|
|
|
8411
8540
|
/*
|
|
8412
8541
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -9022,6 +9151,11 @@
|
|
|
9022
9151
|
TemporaryCacheKeys["NATIVE_REQUEST"] = "request.native";
|
|
9023
9152
|
TemporaryCacheKeys["REDIRECT_CONTEXT"] = "request.redirect.context";
|
|
9024
9153
|
})(TemporaryCacheKeys || (TemporaryCacheKeys = {}));
|
|
9154
|
+
var StaticCacheKeys;
|
|
9155
|
+
(function (StaticCacheKeys) {
|
|
9156
|
+
StaticCacheKeys["ACCOUNT_KEYS"] = "msal.account.keys";
|
|
9157
|
+
StaticCacheKeys["TOKEN_KEYS"] = "msal.token.keys";
|
|
9158
|
+
})(StaticCacheKeys || (StaticCacheKeys = {}));
|
|
9025
9159
|
/**
|
|
9026
9160
|
* Cache keys stored in-memory
|
|
9027
9161
|
*/
|
|
@@ -9367,16 +9501,19 @@
|
|
|
9367
9501
|
var BrowserCacheManager = /** @class */ (function (_super) {
|
|
9368
9502
|
__extends$1(BrowserCacheManager, _super);
|
|
9369
9503
|
function BrowserCacheManager(clientId, cacheConfig, cryptoImpl, logger) {
|
|
9370
|
-
var _this = _super.call(this, clientId, cryptoImpl) || this;
|
|
9504
|
+
var _this = _super.call(this, clientId, cryptoImpl, logger) || this;
|
|
9371
9505
|
// Cookie life calculation (hours * minutes * seconds * ms)
|
|
9372
9506
|
_this.COOKIE_LIFE_MULTIPLIER = 24 * 60 * 60 * 1000;
|
|
9373
9507
|
_this.cacheConfig = cacheConfig;
|
|
9374
9508
|
_this.logger = logger;
|
|
9375
9509
|
_this.internalStorage = new MemoryStorage();
|
|
9376
9510
|
_this.browserStorage = _this.setupBrowserStorage(_this.cacheConfig.cacheLocation);
|
|
9377
|
-
_this.temporaryCacheStorage = _this.setupTemporaryCacheStorage(_this.cacheConfig.cacheLocation);
|
|
9378
|
-
// Migrate
|
|
9379
|
-
|
|
9511
|
+
_this.temporaryCacheStorage = _this.setupTemporaryCacheStorage(_this.cacheConfig.temporaryCacheLocation, _this.cacheConfig.cacheLocation);
|
|
9512
|
+
// Migrate cache entries from older versions of MSAL.
|
|
9513
|
+
if (cacheConfig.cacheMigrationEnabled) {
|
|
9514
|
+
_this.migrateCacheEntries();
|
|
9515
|
+
_this.createKeyMaps();
|
|
9516
|
+
}
|
|
9380
9517
|
return _this;
|
|
9381
9518
|
}
|
|
9382
9519
|
/**
|
|
@@ -9388,7 +9525,6 @@
|
|
|
9388
9525
|
case exports.BrowserCacheLocation.LocalStorage:
|
|
9389
9526
|
case exports.BrowserCacheLocation.SessionStorage:
|
|
9390
9527
|
try {
|
|
9391
|
-
// Temporary cache items will always be stored in session storage to mitigate problems caused by multiple tabs
|
|
9392
9528
|
return new BrowserStorage(cacheLocation);
|
|
9393
9529
|
}
|
|
9394
9530
|
catch (e) {
|
|
@@ -9401,16 +9537,20 @@
|
|
|
9401
9537
|
return new MemoryStorage();
|
|
9402
9538
|
};
|
|
9403
9539
|
/**
|
|
9404
|
-
*
|
|
9540
|
+
* Returns a window storage class implementing the IWindowStorage interface that corresponds to the configured temporaryCacheLocation.
|
|
9541
|
+
* @param temporaryCacheLocation
|
|
9405
9542
|
* @param cacheLocation
|
|
9406
9543
|
*/
|
|
9407
|
-
BrowserCacheManager.prototype.setupTemporaryCacheStorage = function (cacheLocation) {
|
|
9544
|
+
BrowserCacheManager.prototype.setupTemporaryCacheStorage = function (temporaryCacheLocation, cacheLocation) {
|
|
9408
9545
|
switch (cacheLocation) {
|
|
9409
9546
|
case exports.BrowserCacheLocation.LocalStorage:
|
|
9410
9547
|
case exports.BrowserCacheLocation.SessionStorage:
|
|
9411
9548
|
try {
|
|
9412
|
-
|
|
9413
|
-
|
|
9549
|
+
/*
|
|
9550
|
+
* When users do not explicitly choose their own temporaryCacheLocation,
|
|
9551
|
+
* temporary cache items will always be stored in session storage to mitigate problems caused by multiple tabs
|
|
9552
|
+
*/
|
|
9553
|
+
return new BrowserStorage(temporaryCacheLocation || exports.BrowserCacheLocation.SessionStorage);
|
|
9414
9554
|
}
|
|
9415
9555
|
catch (e) {
|
|
9416
9556
|
this.logger.verbose(e);
|
|
@@ -9450,6 +9590,91 @@
|
|
|
9450
9590
|
this.setTemporaryCache(newKey, value, true);
|
|
9451
9591
|
}
|
|
9452
9592
|
};
|
|
9593
|
+
/**
|
|
9594
|
+
* Searches all cache entries for MSAL accounts and creates the account key map
|
|
9595
|
+
* This is used to migrate users from older versions of MSAL which did not create the map.
|
|
9596
|
+
* @returns
|
|
9597
|
+
*/
|
|
9598
|
+
BrowserCacheManager.prototype.createKeyMaps = function () {
|
|
9599
|
+
var _this = this;
|
|
9600
|
+
this.logger.trace("BrowserCacheManager - createKeyMaps called.");
|
|
9601
|
+
var accountKeys = this.getItem(StaticCacheKeys.ACCOUNT_KEYS);
|
|
9602
|
+
var tokenKeys = this.getItem(StaticCacheKeys.TOKEN_KEYS + "." + this.clientId);
|
|
9603
|
+
if (accountKeys && tokenKeys) {
|
|
9604
|
+
this.logger.verbose("BrowserCacheManager:createKeyMaps - account and token key maps already exist, skipping migration.");
|
|
9605
|
+
// Key maps already exist, no need to iterate through cache
|
|
9606
|
+
return;
|
|
9607
|
+
}
|
|
9608
|
+
var allKeys = this.browserStorage.getKeys();
|
|
9609
|
+
allKeys.forEach(function (key) {
|
|
9610
|
+
if (_this.isCredentialKey(key)) {
|
|
9611
|
+
// Get item, parse, validate and write key to map
|
|
9612
|
+
var value = _this.getItem(key);
|
|
9613
|
+
if (value) {
|
|
9614
|
+
var credObj = _this.validateAndParseJson(value);
|
|
9615
|
+
if (credObj && credObj.hasOwnProperty("credentialType")) {
|
|
9616
|
+
switch (credObj["credentialType"]) {
|
|
9617
|
+
case CredentialType.ID_TOKEN:
|
|
9618
|
+
if (IdTokenEntity.isIdTokenEntity(credObj)) {
|
|
9619
|
+
_this.logger.trace("BrowserCacheManager:createKeyMaps - idToken found, saving key to token key map");
|
|
9620
|
+
_this.logger.tracePii("BrowserCacheManager:createKeyMaps - idToken with key: " + key + " found, saving key to token key map");
|
|
9621
|
+
var idTokenEntity = CacheManager.toObject(new IdTokenEntity(), credObj);
|
|
9622
|
+
var newKey = _this.updateCredentialCacheKey(key, idTokenEntity);
|
|
9623
|
+
_this.addTokenKey(newKey, CredentialType.ID_TOKEN);
|
|
9624
|
+
return;
|
|
9625
|
+
}
|
|
9626
|
+
else {
|
|
9627
|
+
_this.logger.trace("BrowserCacheManager:createKeyMaps - key found matching idToken schema with value containing idToken credentialType field but value failed IdTokenEntity validation, skipping.");
|
|
9628
|
+
_this.logger.tracePii("BrowserCacheManager:createKeyMaps - failed idToken validation on key: " + key);
|
|
9629
|
+
}
|
|
9630
|
+
break;
|
|
9631
|
+
case CredentialType.ACCESS_TOKEN:
|
|
9632
|
+
case CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME:
|
|
9633
|
+
if (AccessTokenEntity.isAccessTokenEntity(credObj)) {
|
|
9634
|
+
_this.logger.trace("BrowserCacheManager:createKeyMaps - accessToken found, saving key to token key map");
|
|
9635
|
+
_this.logger.tracePii("BrowserCacheManager:createKeyMaps - accessToken with key: " + key + " found, saving key to token key map");
|
|
9636
|
+
var accessTokenEntity = CacheManager.toObject(new AccessTokenEntity(), credObj);
|
|
9637
|
+
var newKey = _this.updateCredentialCacheKey(key, accessTokenEntity);
|
|
9638
|
+
_this.addTokenKey(newKey, CredentialType.ACCESS_TOKEN);
|
|
9639
|
+
return;
|
|
9640
|
+
}
|
|
9641
|
+
else {
|
|
9642
|
+
_this.logger.trace("BrowserCacheManager:createKeyMaps - key found matching accessToken schema with value containing accessToken credentialType field but value failed AccessTokenEntity validation, skipping.");
|
|
9643
|
+
_this.logger.tracePii("BrowserCacheManager:createKeyMaps - failed accessToken validation on key: " + key);
|
|
9644
|
+
}
|
|
9645
|
+
break;
|
|
9646
|
+
case CredentialType.REFRESH_TOKEN:
|
|
9647
|
+
if (RefreshTokenEntity.isRefreshTokenEntity(credObj)) {
|
|
9648
|
+
_this.logger.trace("BrowserCacheManager:createKeyMaps - refreshToken found, saving key to token key map");
|
|
9649
|
+
_this.logger.tracePii("BrowserCacheManager:createKeyMaps - refreshToken with key: " + key + " found, saving key to token key map");
|
|
9650
|
+
var refreshTokenEntity = CacheManager.toObject(new RefreshTokenEntity(), credObj);
|
|
9651
|
+
var newKey = _this.updateCredentialCacheKey(key, refreshTokenEntity);
|
|
9652
|
+
_this.addTokenKey(newKey, CredentialType.REFRESH_TOKEN);
|
|
9653
|
+
return;
|
|
9654
|
+
}
|
|
9655
|
+
else {
|
|
9656
|
+
_this.logger.trace("BrowserCacheManager:createKeyMaps - key found matching refreshToken schema with value containing refreshToken credentialType field but value failed RefreshTokenEntity validation, skipping.");
|
|
9657
|
+
_this.logger.tracePii("BrowserCacheManager:createKeyMaps - failed refreshToken validation on key: " + key);
|
|
9658
|
+
}
|
|
9659
|
+
break;
|
|
9660
|
+
// If credentialType isn't one of our predefined ones, it may not be an MSAL cache value. Ignore.
|
|
9661
|
+
}
|
|
9662
|
+
}
|
|
9663
|
+
}
|
|
9664
|
+
}
|
|
9665
|
+
if (_this.isAccountKey(key)) {
|
|
9666
|
+
var value = _this.getItem(key);
|
|
9667
|
+
if (value) {
|
|
9668
|
+
var accountObj = _this.validateAndParseJson(value);
|
|
9669
|
+
if (accountObj && AccountEntity.isAccountEntity(accountObj)) {
|
|
9670
|
+
_this.logger.trace("BrowserCacheManager:createKeyMaps - account found, saving key to account key map");
|
|
9671
|
+
_this.logger.tracePii("BrowserCacheManager:createKeyMaps - account with key: " + key + " found, saving key to account key map");
|
|
9672
|
+
_this.addAccountKeyToMap(key);
|
|
9673
|
+
}
|
|
9674
|
+
}
|
|
9675
|
+
}
|
|
9676
|
+
});
|
|
9677
|
+
};
|
|
9453
9678
|
/**
|
|
9454
9679
|
* Parses passed value as JSON object, JSON.parse() will throw an error.
|
|
9455
9680
|
* @param input
|
|
@@ -9489,12 +9714,15 @@
|
|
|
9489
9714
|
* @param accountKey
|
|
9490
9715
|
*/
|
|
9491
9716
|
BrowserCacheManager.prototype.getAccount = function (accountKey) {
|
|
9717
|
+
this.logger.trace("BrowserCacheManager.getAccount called");
|
|
9492
9718
|
var account = this.getItem(accountKey);
|
|
9493
9719
|
if (!account) {
|
|
9720
|
+
this.removeAccountKeyFromMap(accountKey);
|
|
9494
9721
|
return null;
|
|
9495
9722
|
}
|
|
9496
9723
|
var parsedAccount = this.validateAndParseJson(account);
|
|
9497
9724
|
if (!parsedAccount || !AccountEntity.isAccountEntity(parsedAccount)) {
|
|
9725
|
+
this.removeAccountKeyFromMap(accountKey);
|
|
9498
9726
|
return null;
|
|
9499
9727
|
}
|
|
9500
9728
|
return CacheManager.toObject(new AccountEntity(), parsedAccount);
|
|
@@ -9508,6 +9736,207 @@
|
|
|
9508
9736
|
this.logger.trace("BrowserCacheManager.setAccount called");
|
|
9509
9737
|
var key = account.generateAccountKey();
|
|
9510
9738
|
this.setItem(key, JSON.stringify(account));
|
|
9739
|
+
this.addAccountKeyToMap(key);
|
|
9740
|
+
};
|
|
9741
|
+
/**
|
|
9742
|
+
* Returns the array of account keys currently cached
|
|
9743
|
+
* @returns
|
|
9744
|
+
*/
|
|
9745
|
+
BrowserCacheManager.prototype.getAccountKeys = function () {
|
|
9746
|
+
this.logger.trace("BrowserCacheManager.getAccountKeys called");
|
|
9747
|
+
var accountKeys = this.getItem(StaticCacheKeys.ACCOUNT_KEYS);
|
|
9748
|
+
if (accountKeys) {
|
|
9749
|
+
return JSON.parse(accountKeys);
|
|
9750
|
+
}
|
|
9751
|
+
this.logger.verbose("BrowserCacheManager.getAccountKeys - No account keys found");
|
|
9752
|
+
return [];
|
|
9753
|
+
};
|
|
9754
|
+
/**
|
|
9755
|
+
* Add a new account to the key map
|
|
9756
|
+
* @param key
|
|
9757
|
+
*/
|
|
9758
|
+
BrowserCacheManager.prototype.addAccountKeyToMap = function (key) {
|
|
9759
|
+
this.logger.trace("BrowserCacheManager.addAccountKeyToMap called");
|
|
9760
|
+
this.logger.tracePii("BrowserCacheManager.addAccountKeyToMap called with key: " + key);
|
|
9761
|
+
var accountKeys = this.getAccountKeys();
|
|
9762
|
+
if (accountKeys.indexOf(key) === -1) {
|
|
9763
|
+
// Only add key if it does not already exist in the map
|
|
9764
|
+
accountKeys.push(key);
|
|
9765
|
+
this.setItem(StaticCacheKeys.ACCOUNT_KEYS, JSON.stringify(accountKeys));
|
|
9766
|
+
this.logger.verbose("BrowserCacheManager.addAccountKeyToMap account key added");
|
|
9767
|
+
}
|
|
9768
|
+
else {
|
|
9769
|
+
this.logger.verbose("BrowserCacheManager.addAccountKeyToMap account key already exists in map");
|
|
9770
|
+
}
|
|
9771
|
+
};
|
|
9772
|
+
/**
|
|
9773
|
+
* Remove an account from the key map
|
|
9774
|
+
* @param key
|
|
9775
|
+
*/
|
|
9776
|
+
BrowserCacheManager.prototype.removeAccountKeyFromMap = function (key) {
|
|
9777
|
+
this.logger.trace("BrowserCacheManager.removeAccountKeyFromMap called");
|
|
9778
|
+
this.logger.tracePii("BrowserCacheManager.removeAccountKeyFromMap called with key: " + key);
|
|
9779
|
+
var accountKeys = this.getAccountKeys();
|
|
9780
|
+
var removalIndex = accountKeys.indexOf(key);
|
|
9781
|
+
if (removalIndex > -1) {
|
|
9782
|
+
accountKeys.splice(removalIndex, 1);
|
|
9783
|
+
this.setItem(StaticCacheKeys.ACCOUNT_KEYS, JSON.stringify(accountKeys));
|
|
9784
|
+
this.logger.trace("BrowserCacheManager.removeAccountKeyFromMap account key removed");
|
|
9785
|
+
}
|
|
9786
|
+
else {
|
|
9787
|
+
this.logger.trace("BrowserCacheManager.removeAccountKeyFromMap key not found in existing map");
|
|
9788
|
+
}
|
|
9789
|
+
};
|
|
9790
|
+
/**
|
|
9791
|
+
* Extends inherited removeAccount function to include removal of the account key from the map
|
|
9792
|
+
* @param key
|
|
9793
|
+
*/
|
|
9794
|
+
BrowserCacheManager.prototype.removeAccount = function (key) {
|
|
9795
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
9796
|
+
return __generator$1(this, function (_a) {
|
|
9797
|
+
_super.prototype.removeAccount.call(this, key);
|
|
9798
|
+
this.removeAccountKeyFromMap(key);
|
|
9799
|
+
return [2 /*return*/];
|
|
9800
|
+
});
|
|
9801
|
+
});
|
|
9802
|
+
};
|
|
9803
|
+
/**
|
|
9804
|
+
* Removes given idToken from the cache and from the key map
|
|
9805
|
+
* @param key
|
|
9806
|
+
*/
|
|
9807
|
+
BrowserCacheManager.prototype.removeIdToken = function (key) {
|
|
9808
|
+
_super.prototype.removeIdToken.call(this, key);
|
|
9809
|
+
this.removeTokenKey(key, CredentialType.ID_TOKEN);
|
|
9810
|
+
};
|
|
9811
|
+
/**
|
|
9812
|
+
* Removes given accessToken from the cache and from the key map
|
|
9813
|
+
* @param key
|
|
9814
|
+
*/
|
|
9815
|
+
BrowserCacheManager.prototype.removeAccessToken = function (key) {
|
|
9816
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
9817
|
+
return __generator$1(this, function (_a) {
|
|
9818
|
+
_super.prototype.removeAccessToken.call(this, key);
|
|
9819
|
+
this.removeTokenKey(key, CredentialType.ACCESS_TOKEN);
|
|
9820
|
+
return [2 /*return*/];
|
|
9821
|
+
});
|
|
9822
|
+
});
|
|
9823
|
+
};
|
|
9824
|
+
/**
|
|
9825
|
+
* Removes given refreshToken from the cache and from the key map
|
|
9826
|
+
* @param key
|
|
9827
|
+
*/
|
|
9828
|
+
BrowserCacheManager.prototype.removeRefreshToken = function (key) {
|
|
9829
|
+
_super.prototype.removeRefreshToken.call(this, key);
|
|
9830
|
+
this.removeTokenKey(key, CredentialType.REFRESH_TOKEN);
|
|
9831
|
+
};
|
|
9832
|
+
/**
|
|
9833
|
+
* Gets the keys for the cached tokens associated with this clientId
|
|
9834
|
+
* @returns
|
|
9835
|
+
*/
|
|
9836
|
+
BrowserCacheManager.prototype.getTokenKeys = function () {
|
|
9837
|
+
this.logger.trace("BrowserCacheManager.getTokenKeys called");
|
|
9838
|
+
var item = this.getItem(StaticCacheKeys.TOKEN_KEYS + "." + this.clientId);
|
|
9839
|
+
if (item) {
|
|
9840
|
+
var tokenKeys = this.validateAndParseJson(item);
|
|
9841
|
+
if (tokenKeys &&
|
|
9842
|
+
tokenKeys.hasOwnProperty("idToken") &&
|
|
9843
|
+
tokenKeys.hasOwnProperty("accessToken") &&
|
|
9844
|
+
tokenKeys.hasOwnProperty("refreshToken")) {
|
|
9845
|
+
return tokenKeys;
|
|
9846
|
+
}
|
|
9847
|
+
else {
|
|
9848
|
+
this.logger.error("BrowserCacheManager.getTokenKeys - Token keys found but in an unknown format. Returning empty key map.");
|
|
9849
|
+
}
|
|
9850
|
+
}
|
|
9851
|
+
else {
|
|
9852
|
+
this.logger.verbose("BrowserCacheManager.getTokenKeys - No token keys found");
|
|
9853
|
+
}
|
|
9854
|
+
return {
|
|
9855
|
+
idToken: [],
|
|
9856
|
+
accessToken: [],
|
|
9857
|
+
refreshToken: []
|
|
9858
|
+
};
|
|
9859
|
+
};
|
|
9860
|
+
/**
|
|
9861
|
+
* Adds the given key to the token key map
|
|
9862
|
+
* @param key
|
|
9863
|
+
* @param type
|
|
9864
|
+
*/
|
|
9865
|
+
BrowserCacheManager.prototype.addTokenKey = function (key, type) {
|
|
9866
|
+
this.logger.trace("BrowserCacheManager addTokenKey called");
|
|
9867
|
+
var tokenKeys = this.getTokenKeys();
|
|
9868
|
+
switch (type) {
|
|
9869
|
+
case CredentialType.ID_TOKEN:
|
|
9870
|
+
if (tokenKeys.idToken.indexOf(key) === -1) {
|
|
9871
|
+
this.logger.info("BrowserCacheManager: addTokenKey - idToken added to map");
|
|
9872
|
+
tokenKeys.idToken.push(key);
|
|
9873
|
+
}
|
|
9874
|
+
break;
|
|
9875
|
+
case CredentialType.ACCESS_TOKEN:
|
|
9876
|
+
if (tokenKeys.accessToken.indexOf(key) === -1) {
|
|
9877
|
+
this.logger.info("BrowserCacheManager: addTokenKey - accessToken added to map");
|
|
9878
|
+
tokenKeys.accessToken.push(key);
|
|
9879
|
+
}
|
|
9880
|
+
break;
|
|
9881
|
+
case CredentialType.REFRESH_TOKEN:
|
|
9882
|
+
if (tokenKeys.refreshToken.indexOf(key) === -1) {
|
|
9883
|
+
this.logger.info("BrowserCacheManager: addTokenKey - refreshToken added to map");
|
|
9884
|
+
tokenKeys.refreshToken.push(key);
|
|
9885
|
+
}
|
|
9886
|
+
break;
|
|
9887
|
+
default:
|
|
9888
|
+
this.logger.error("BrowserCacheManager:addTokenKey - CredentialType provided invalid. CredentialType: " + type);
|
|
9889
|
+
ClientAuthError.createUnexpectedCredentialTypeError();
|
|
9890
|
+
}
|
|
9891
|
+
this.setItem(StaticCacheKeys.TOKEN_KEYS + "." + this.clientId, JSON.stringify(tokenKeys));
|
|
9892
|
+
};
|
|
9893
|
+
/**
|
|
9894
|
+
* Removes the given key from the token key map
|
|
9895
|
+
* @param key
|
|
9896
|
+
* @param type
|
|
9897
|
+
*/
|
|
9898
|
+
BrowserCacheManager.prototype.removeTokenKey = function (key, type) {
|
|
9899
|
+
this.logger.trace("BrowserCacheManager removeTokenKey called");
|
|
9900
|
+
var tokenKeys = this.getTokenKeys();
|
|
9901
|
+
switch (type) {
|
|
9902
|
+
case CredentialType.ID_TOKEN:
|
|
9903
|
+
this.logger.infoPii("BrowserCacheManager: removeTokenKey - attempting to remove idToken with key: " + key + " from map");
|
|
9904
|
+
var idRemoval = tokenKeys.idToken.indexOf(key);
|
|
9905
|
+
if (idRemoval > -1) {
|
|
9906
|
+
this.logger.info("BrowserCacheManager: removeTokenKey - idToken removed from map");
|
|
9907
|
+
tokenKeys.idToken.splice(idRemoval, 1);
|
|
9908
|
+
}
|
|
9909
|
+
else {
|
|
9910
|
+
this.logger.info("BrowserCacheManager: removeTokenKey - idToken does not exist in map. Either it was previously removed or it was never added.");
|
|
9911
|
+
}
|
|
9912
|
+
break;
|
|
9913
|
+
case CredentialType.ACCESS_TOKEN:
|
|
9914
|
+
this.logger.infoPii("BrowserCacheManager: removeTokenKey - attempting to remove accessToken with key: " + key + " from map");
|
|
9915
|
+
var accessRemoval = tokenKeys.accessToken.indexOf(key);
|
|
9916
|
+
if (accessRemoval > -1) {
|
|
9917
|
+
this.logger.info("BrowserCacheManager: removeTokenKey - accessToken removed from map");
|
|
9918
|
+
tokenKeys.accessToken.splice(accessRemoval, 1);
|
|
9919
|
+
}
|
|
9920
|
+
else {
|
|
9921
|
+
this.logger.info("BrowserCacheManager: removeTokenKey - accessToken does not exist in map. Either it was previously removed or it was never added.");
|
|
9922
|
+
}
|
|
9923
|
+
break;
|
|
9924
|
+
case CredentialType.REFRESH_TOKEN:
|
|
9925
|
+
this.logger.infoPii("BrowserCacheManager: removeTokenKey - attempting to remove refreshToken with key: " + key + " from map");
|
|
9926
|
+
var refreshRemoval = tokenKeys.refreshToken.indexOf(key);
|
|
9927
|
+
if (refreshRemoval > -1) {
|
|
9928
|
+
this.logger.info("BrowserCacheManager: removeTokenKey - refreshToken removed from map");
|
|
9929
|
+
tokenKeys.refreshToken.splice(refreshRemoval, 1);
|
|
9930
|
+
}
|
|
9931
|
+
else {
|
|
9932
|
+
this.logger.info("BrowserCacheManager: removeTokenKey - refreshToken does not exist in map. Either it was previously removed or it was never added.");
|
|
9933
|
+
}
|
|
9934
|
+
break;
|
|
9935
|
+
default:
|
|
9936
|
+
this.logger.error("BrowserCacheManager:removeTokenKey - CredentialType provided invalid. CredentialType: " + type);
|
|
9937
|
+
ClientAuthError.createUnexpectedCredentialTypeError();
|
|
9938
|
+
}
|
|
9939
|
+
this.setItem(StaticCacheKeys.TOKEN_KEYS + "." + this.clientId, JSON.stringify(tokenKeys));
|
|
9511
9940
|
};
|
|
9512
9941
|
/**
|
|
9513
9942
|
* generates idToken entity from a string
|
|
@@ -9517,11 +9946,13 @@
|
|
|
9517
9946
|
var value = this.getItem(idTokenKey);
|
|
9518
9947
|
if (!value) {
|
|
9519
9948
|
this.logger.trace("BrowserCacheManager.getIdTokenCredential: called, no cache hit");
|
|
9949
|
+
this.removeTokenKey(idTokenKey, CredentialType.ID_TOKEN);
|
|
9520
9950
|
return null;
|
|
9521
9951
|
}
|
|
9522
9952
|
var parsedIdToken = this.validateAndParseJson(value);
|
|
9523
9953
|
if (!parsedIdToken || !IdTokenEntity.isIdTokenEntity(parsedIdToken)) {
|
|
9524
9954
|
this.logger.trace("BrowserCacheManager.getIdTokenCredential: called, no cache hit");
|
|
9955
|
+
this.removeTokenKey(idTokenKey, CredentialType.ID_TOKEN);
|
|
9525
9956
|
return null;
|
|
9526
9957
|
}
|
|
9527
9958
|
this.logger.trace("BrowserCacheManager.getIdTokenCredential: cache hit");
|
|
@@ -9535,6 +9966,7 @@
|
|
|
9535
9966
|
this.logger.trace("BrowserCacheManager.setIdTokenCredential called");
|
|
9536
9967
|
var idTokenKey = idToken.generateCredentialKey();
|
|
9537
9968
|
this.setItem(idTokenKey, JSON.stringify(idToken));
|
|
9969
|
+
this.addTokenKey(idTokenKey, CredentialType.ID_TOKEN);
|
|
9538
9970
|
};
|
|
9539
9971
|
/**
|
|
9540
9972
|
* generates accessToken entity from a string
|
|
@@ -9544,11 +9976,13 @@
|
|
|
9544
9976
|
var value = this.getItem(accessTokenKey);
|
|
9545
9977
|
if (!value) {
|
|
9546
9978
|
this.logger.trace("BrowserCacheManager.getAccessTokenCredential: called, no cache hit");
|
|
9979
|
+
this.removeTokenKey(accessTokenKey, CredentialType.ACCESS_TOKEN);
|
|
9547
9980
|
return null;
|
|
9548
9981
|
}
|
|
9549
9982
|
var parsedAccessToken = this.validateAndParseJson(value);
|
|
9550
9983
|
if (!parsedAccessToken || !AccessTokenEntity.isAccessTokenEntity(parsedAccessToken)) {
|
|
9551
9984
|
this.logger.trace("BrowserCacheManager.getAccessTokenCredential: called, no cache hit");
|
|
9985
|
+
this.removeTokenKey(accessTokenKey, CredentialType.ACCESS_TOKEN);
|
|
9552
9986
|
return null;
|
|
9553
9987
|
}
|
|
9554
9988
|
this.logger.trace("BrowserCacheManager.getAccessTokenCredential: cache hit");
|
|
@@ -9562,6 +9996,7 @@
|
|
|
9562
9996
|
this.logger.trace("BrowserCacheManager.setAccessTokenCredential called");
|
|
9563
9997
|
var accessTokenKey = accessToken.generateCredentialKey();
|
|
9564
9998
|
this.setItem(accessTokenKey, JSON.stringify(accessToken));
|
|
9999
|
+
this.addTokenKey(accessTokenKey, CredentialType.ACCESS_TOKEN);
|
|
9565
10000
|
};
|
|
9566
10001
|
/**
|
|
9567
10002
|
* generates refreshToken entity from a string
|
|
@@ -9571,11 +10006,13 @@
|
|
|
9571
10006
|
var value = this.getItem(refreshTokenKey);
|
|
9572
10007
|
if (!value) {
|
|
9573
10008
|
this.logger.trace("BrowserCacheManager.getRefreshTokenCredential: called, no cache hit");
|
|
10009
|
+
this.removeTokenKey(refreshTokenKey, CredentialType.REFRESH_TOKEN);
|
|
9574
10010
|
return null;
|
|
9575
10011
|
}
|
|
9576
10012
|
var parsedRefreshToken = this.validateAndParseJson(value);
|
|
9577
10013
|
if (!parsedRefreshToken || !RefreshTokenEntity.isRefreshTokenEntity(parsedRefreshToken)) {
|
|
9578
10014
|
this.logger.trace("BrowserCacheManager.getRefreshTokenCredential: called, no cache hit");
|
|
10015
|
+
this.removeTokenKey(refreshTokenKey, CredentialType.REFRESH_TOKEN);
|
|
9579
10016
|
return null;
|
|
9580
10017
|
}
|
|
9581
10018
|
this.logger.trace("BrowserCacheManager.getRefreshTokenCredential: cache hit");
|
|
@@ -9589,6 +10026,7 @@
|
|
|
9589
10026
|
this.logger.trace("BrowserCacheManager.setRefreshTokenCredential called");
|
|
9590
10027
|
var refreshTokenKey = refreshToken.generateCredentialKey();
|
|
9591
10028
|
this.setItem(refreshTokenKey, JSON.stringify(refreshToken));
|
|
10029
|
+
this.addTokenKey(refreshTokenKey, CredentialType.REFRESH_TOKEN);
|
|
9592
10030
|
};
|
|
9593
10031
|
/**
|
|
9594
10032
|
* fetch appMetadata entity from the platform cache
|
|
@@ -9886,7 +10324,6 @@
|
|
|
9886
10324
|
this.logger.trace("BrowserCacheManager.removeItem: storeAuthStateInCookie is true, clearing item cookie");
|
|
9887
10325
|
this.clearItemCookie(key);
|
|
9888
10326
|
}
|
|
9889
|
-
return true;
|
|
9890
10327
|
};
|
|
9891
10328
|
/**
|
|
9892
10329
|
* Checks whether key is in cache.
|
|
@@ -10313,15 +10750,17 @@
|
|
|
10313
10750
|
var DEFAULT_BROWSER_CACHE_MANAGER = function (clientId, logger) {
|
|
10314
10751
|
var cacheOptions = {
|
|
10315
10752
|
cacheLocation: exports.BrowserCacheLocation.MemoryStorage,
|
|
10753
|
+
temporaryCacheLocation: exports.BrowserCacheLocation.MemoryStorage,
|
|
10316
10754
|
storeAuthStateInCookie: false,
|
|
10317
|
-
secureCookies: false
|
|
10755
|
+
secureCookies: false,
|
|
10756
|
+
cacheMigrationEnabled: false
|
|
10318
10757
|
};
|
|
10319
10758
|
return new BrowserCacheManager(clientId, cacheOptions, DEFAULT_CRYPTO_IMPLEMENTATION, logger);
|
|
10320
10759
|
};
|
|
10321
10760
|
|
|
10322
10761
|
/* eslint-disable header/header */
|
|
10323
10762
|
var name = "@azure/msal-browser";
|
|
10324
|
-
var version = "2.
|
|
10763
|
+
var version = "2.36.0";
|
|
10325
10764
|
|
|
10326
10765
|
/*
|
|
10327
10766
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -11792,15 +12231,18 @@
|
|
|
11792
12231
|
*/
|
|
11793
12232
|
NativeInteractionClient.prototype.acquireTokensFromCache = function (nativeAccountId, request) {
|
|
11794
12233
|
return __awaiter$1(this, void 0, void 0, function () {
|
|
11795
|
-
var
|
|
12234
|
+
var account, silentRequest, result, e_2;
|
|
11796
12235
|
return __generator$1(this, function (_a) {
|
|
11797
12236
|
switch (_a.label) {
|
|
11798
12237
|
case 0:
|
|
11799
|
-
|
|
11800
|
-
|
|
12238
|
+
if (!nativeAccountId) {
|
|
12239
|
+
this.logger.warning("NativeInteractionClient:acquireTokensFromCache - No nativeAccountId provided");
|
|
12240
|
+
throw ClientAuthError.createNoAccountFoundError();
|
|
12241
|
+
}
|
|
12242
|
+
account = this.browserStorage.getAccountInfoFilteredBy({ nativeAccountId: nativeAccountId });
|
|
12243
|
+
if (!account) {
|
|
11801
12244
|
throw ClientAuthError.createNoAccountFoundError();
|
|
11802
12245
|
}
|
|
11803
|
-
account = accountEntity.getAccountInfo();
|
|
11804
12246
|
_a.label = 1;
|
|
11805
12247
|
case 1:
|
|
11806
12248
|
_a.trys.push([1, 3, , 4]);
|
|
@@ -11940,10 +12382,6 @@
|
|
|
11940
12382
|
// User switch in native broker prompt is not supported. All users must first sign in through web flow to ensure server state is in sync
|
|
11941
12383
|
throw NativeAuthError.createUserSwitchError();
|
|
11942
12384
|
}
|
|
11943
|
-
if (response.account.id !== request.accountId) {
|
|
11944
|
-
// User switch in native broker prompt is not supported. All users must first sign in through web flow to ensure server state is in sync
|
|
11945
|
-
throw NativeAuthError.createUserSwitchError();
|
|
11946
|
-
}
|
|
11947
12385
|
return [4 /*yield*/, this.getDiscoveredAuthority(request.authority)];
|
|
11948
12386
|
case 1:
|
|
11949
12387
|
authority = _a.sent();
|
|
@@ -13446,8 +13884,11 @@
|
|
|
13446
13884
|
// Default cache options for browser
|
|
13447
13885
|
var DEFAULT_CACHE_OPTIONS = {
|
|
13448
13886
|
cacheLocation: exports.BrowserCacheLocation.SessionStorage,
|
|
13887
|
+
temporaryCacheLocation: exports.BrowserCacheLocation.SessionStorage,
|
|
13449
13888
|
storeAuthStateInCookie: false,
|
|
13450
|
-
secureCookies: false
|
|
13889
|
+
secureCookies: false,
|
|
13890
|
+
// Default cache migration to true if cache location is localStorage since entries are preserved across tabs/windows. Migration has little to no benefit in sessionStorage and memoryStorage
|
|
13891
|
+
cacheMigrationEnabled: userInputCache && userInputCache.cacheLocation === exports.BrowserCacheLocation.LocalStorage ? true : false
|
|
13451
13892
|
};
|
|
13452
13893
|
// Default logger options for browser
|
|
13453
13894
|
var DEFAULT_LOGGER_OPTIONS = {
|
|
@@ -15703,7 +16144,7 @@
|
|
|
15703
16144
|
this.logger.trace("BrowserPerformanceClient: Incomplete pre-queue " + preQueueEvent.name + " found", correlationId);
|
|
15704
16145
|
this.addQueueMeasurement(preQueueEvent.name, correlationId, undefined, true);
|
|
15705
16146
|
}
|
|
15706
|
-
this.preQueueTimeByCorrelationId.set(
|
|
16147
|
+
this.preQueueTimeByCorrelationId.set(correlationId, { name: eventName, time: window.performance.now() });
|
|
15707
16148
|
};
|
|
15708
16149
|
/**
|
|
15709
16150
|
* Calculates and adds queue time measurement for given performance event.
|
|
@@ -16129,8 +16570,10 @@
|
|
|
16129
16570
|
// initialize in memory storage for native flows
|
|
16130
16571
|
var nativeCacheOptions = {
|
|
16131
16572
|
cacheLocation: exports.BrowserCacheLocation.MemoryStorage,
|
|
16573
|
+
temporaryCacheLocation: exports.BrowserCacheLocation.MemoryStorage,
|
|
16132
16574
|
storeAuthStateInCookie: false,
|
|
16133
|
-
secureCookies: false
|
|
16575
|
+
secureCookies: false,
|
|
16576
|
+
cacheMigrationEnabled: false
|
|
16134
16577
|
};
|
|
16135
16578
|
this.nativeInternalStorage = new BrowserCacheManager(this.config.auth.clientId, nativeCacheOptions, this.browserCrypto, this.logger);
|
|
16136
16579
|
// Initialize the token cache
|
|
@@ -16763,15 +17206,20 @@
|
|
|
16763
17206
|
* (the account object is created at the time of successful login)
|
|
16764
17207
|
* or null when no matching account is found.
|
|
16765
17208
|
* This API is provided for convenience but getAccountById should be used for best reliability
|
|
16766
|
-
* @param
|
|
17209
|
+
* @param username
|
|
16767
17210
|
* @returns The account object stored in MSAL
|
|
16768
17211
|
*/
|
|
16769
|
-
ClientApplication.prototype.getAccountByUsername = function (
|
|
16770
|
-
|
|
16771
|
-
if (!
|
|
16772
|
-
this.logger.
|
|
16773
|
-
|
|
16774
|
-
|
|
17212
|
+
ClientApplication.prototype.getAccountByUsername = function (username) {
|
|
17213
|
+
this.logger.trace("getAccountByUsername called");
|
|
17214
|
+
if (!username) {
|
|
17215
|
+
this.logger.warning("getAccountByUsername: No username provided");
|
|
17216
|
+
return null;
|
|
17217
|
+
}
|
|
17218
|
+
var account = this.browserStorage.getAccountInfoFilteredBy({ username: username });
|
|
17219
|
+
if (account) {
|
|
17220
|
+
this.logger.verbose("getAccountByUsername: Account matching username found, returning");
|
|
17221
|
+
this.logger.verbosePii("getAccountByUsername: Returning signed-in accounts matching username: " + username);
|
|
17222
|
+
return account;
|
|
16775
17223
|
}
|
|
16776
17224
|
else {
|
|
16777
17225
|
this.logger.verbose("getAccountByUsername: No matching account found, returning null");
|
|
@@ -16786,11 +17234,16 @@
|
|
|
16786
17234
|
* @returns The account object stored in MSAL
|
|
16787
17235
|
*/
|
|
16788
17236
|
ClientApplication.prototype.getAccountByHomeId = function (homeAccountId) {
|
|
16789
|
-
|
|
16790
|
-
if (!
|
|
16791
|
-
this.logger.
|
|
16792
|
-
|
|
16793
|
-
|
|
17237
|
+
this.logger.trace("getAccountByHomeId called");
|
|
17238
|
+
if (!homeAccountId) {
|
|
17239
|
+
this.logger.warning("getAccountByHomeId: No homeAccountId provided");
|
|
17240
|
+
return null;
|
|
17241
|
+
}
|
|
17242
|
+
var account = this.browserStorage.getAccountInfoFilteredBy({ homeAccountId: homeAccountId });
|
|
17243
|
+
if (account) {
|
|
17244
|
+
this.logger.verbose("getAccountByHomeId: Account matching homeAccountId found, returning");
|
|
17245
|
+
this.logger.verbosePii("getAccountByHomeId: Returning signed-in accounts matching homeAccountId: " + homeAccountId);
|
|
17246
|
+
return account;
|
|
16794
17247
|
}
|
|
16795
17248
|
else {
|
|
16796
17249
|
this.logger.verbose("getAccountByHomeId: No matching account found, returning null");
|
|
@@ -16805,11 +17258,16 @@
|
|
|
16805
17258
|
* @returns The account object stored in MSAL
|
|
16806
17259
|
*/
|
|
16807
17260
|
ClientApplication.prototype.getAccountByLocalId = function (localAccountId) {
|
|
16808
|
-
|
|
16809
|
-
if (!
|
|
16810
|
-
this.logger.
|
|
16811
|
-
|
|
16812
|
-
|
|
17261
|
+
this.logger.trace("getAccountByLocalId called");
|
|
17262
|
+
if (!localAccountId) {
|
|
17263
|
+
this.logger.warning("getAccountByLocalId: No localAccountId provided");
|
|
17264
|
+
return null;
|
|
17265
|
+
}
|
|
17266
|
+
var account = this.browserStorage.getAccountInfoFilteredBy({ localAccountId: localAccountId });
|
|
17267
|
+
if (account) {
|
|
17268
|
+
this.logger.verbose("getAccountByLocalId: Account matching localAccountId found, returning");
|
|
17269
|
+
this.logger.verbosePii("getAccountByLocalId: Returning signed-in accounts matching localAccountId: " + localAccountId);
|
|
17270
|
+
return account;
|
|
16813
17271
|
}
|
|
16814
17272
|
else {
|
|
16815
17273
|
this.logger.verbose("getAccountByLocalId: No matching account found, returning null");
|