@azure/msal-browser 2.33.0 → 2.35.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 +49 -36
- package/dist/app/ClientApplication.js.map +1 -1
- package/dist/app/IPublicClientApplication.js +1 -1
- package/dist/app/PublicClientApplication.d.ts.map +1 -1
- package/dist/app/PublicClientApplication.js +1 -6
- package/dist/app/PublicClientApplication.js.map +1 -1
- package/dist/broker/nativeBroker/NativeMessageHandler.d.ts +10 -7
- package/dist/broker/nativeBroker/NativeMessageHandler.d.ts.map +1 -1
- package/dist/broker/nativeBroker/NativeMessageHandler.js +18 -8
- package/dist/broker/nativeBroker/NativeMessageHandler.js.map +1 -1
- package/dist/cache/AsyncMemoryStorage.js +1 -1
- package/dist/cache/BrowserCacheManager.d.ts +60 -2
- package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
- package/dist/cache/BrowserCacheManager.js +310 -9
- 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 +4 -0
- package/dist/config/Configuration.d.ts.map +1 -1
- package/dist/config/Configuration.js +4 -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.d.ts +8 -0
- package/dist/error/BrowserAuthError.d.ts.map +1 -1
- package/dist/error/BrowserAuthError.js +11 -1
- package/dist/error/BrowserAuthError.js.map +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 +1388 -816
- 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 +66 -3
- package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
- package/dist/interaction_client/NativeInteractionClient.js +177 -72
- 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.d.ts +3 -0
- package/dist/internals.d.ts.map +1 -1
- package/dist/internals.js +2 -1
- package/dist/internals.js.map +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.d.ts +5 -3
- package/dist/telemetry/BrowserPerformanceClient.d.ts.map +1 -1
- package/dist/telemetry/BrowserPerformanceClient.js +37 -16
- package/dist/telemetry/BrowserPerformanceClient.js.map +1 -1
- package/dist/telemetry/BrowserPerformanceMeasurement.d.ts +14 -5
- package/dist/telemetry/BrowserPerformanceMeasurement.d.ts.map +1 -1
- package/dist/telemetry/BrowserPerformanceMeasurement.js +36 -4
- package/dist/telemetry/BrowserPerformanceMeasurement.js.map +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 +1388 -816
- 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.35.0 2023-04-03 */
|
|
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
|
*/
|
|
@@ -588,9 +572,10 @@
|
|
|
588
572
|
(function (JsonTypes) {
|
|
589
573
|
JsonTypes["Jwt"] = "JWT";
|
|
590
574
|
JsonTypes["Jwk"] = "JWK";
|
|
575
|
+
JsonTypes["Pop"] = "pop";
|
|
591
576
|
})(JsonTypes || (JsonTypes = {}));
|
|
592
577
|
|
|
593
|
-
/*! @azure/msal-common
|
|
578
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
594
579
|
|
|
595
580
|
/*
|
|
596
581
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -646,7 +631,7 @@
|
|
|
646
631
|
return AuthError;
|
|
647
632
|
}(Error));
|
|
648
633
|
|
|
649
|
-
/*! @azure/msal-common
|
|
634
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
650
635
|
|
|
651
636
|
/*
|
|
652
637
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -721,7 +706,7 @@
|
|
|
721
706
|
}
|
|
722
707
|
};
|
|
723
708
|
|
|
724
|
-
/*! @azure/msal-common
|
|
709
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
725
710
|
|
|
726
711
|
/*
|
|
727
712
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -925,6 +910,14 @@
|
|
|
925
910
|
keyIdMissing: {
|
|
926
911
|
code: "key_id_missing",
|
|
927
912
|
desc: "A keyId value is missing from the requested bound token's cache record and is required to match the token to it's stored binding key."
|
|
913
|
+
},
|
|
914
|
+
noNetworkConnectivity: {
|
|
915
|
+
code: "no_network_connectivity",
|
|
916
|
+
desc: "No network connectivity. Check your internet connection."
|
|
917
|
+
},
|
|
918
|
+
userCanceledError: {
|
|
919
|
+
code: "user_canceled",
|
|
920
|
+
desc: "User canceled the flow."
|
|
928
921
|
}
|
|
929
922
|
};
|
|
930
923
|
/**
|
|
@@ -1213,10 +1206,22 @@
|
|
|
1213
1206
|
ClientAuthError.createKeyIdMissingError = function () {
|
|
1214
1207
|
return new ClientAuthError(ClientAuthErrorMessage.keyIdMissing.code, ClientAuthErrorMessage.keyIdMissing.desc);
|
|
1215
1208
|
};
|
|
1209
|
+
/**
|
|
1210
|
+
* Create an error when the client does not have network connectivity
|
|
1211
|
+
*/
|
|
1212
|
+
ClientAuthError.createNoNetworkConnectivityError = function () {
|
|
1213
|
+
return new ClientAuthError(ClientAuthErrorMessage.noNetworkConnectivity.code, ClientAuthErrorMessage.noNetworkConnectivity.desc);
|
|
1214
|
+
};
|
|
1215
|
+
/**
|
|
1216
|
+
* Create an error when the user cancels the flow
|
|
1217
|
+
*/
|
|
1218
|
+
ClientAuthError.createUserCanceledError = function () {
|
|
1219
|
+
return new ClientAuthError(ClientAuthErrorMessage.userCanceledError.code, ClientAuthErrorMessage.userCanceledError.desc);
|
|
1220
|
+
};
|
|
1216
1221
|
return ClientAuthError;
|
|
1217
1222
|
}(AuthError));
|
|
1218
1223
|
|
|
1219
|
-
/*! @azure/msal-common
|
|
1224
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
1220
1225
|
|
|
1221
1226
|
/*
|
|
1222
1227
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1341,7 +1346,7 @@
|
|
|
1341
1346
|
return StringUtils;
|
|
1342
1347
|
}());
|
|
1343
1348
|
|
|
1344
|
-
/*! @azure/msal-common
|
|
1349
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
1345
1350
|
|
|
1346
1351
|
/*
|
|
1347
1352
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1531,12 +1536,12 @@
|
|
|
1531
1536
|
return Logger;
|
|
1532
1537
|
}());
|
|
1533
1538
|
|
|
1534
|
-
/*! @azure/msal-common
|
|
1539
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
1535
1540
|
/* eslint-disable header/header */
|
|
1536
1541
|
var name$1 = "@azure/msal-common";
|
|
1537
|
-
var version$1 = "
|
|
1542
|
+
var version$1 = "12.0.0";
|
|
1538
1543
|
|
|
1539
|
-
/*! @azure/msal-common
|
|
1544
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
1540
1545
|
/*
|
|
1541
1546
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
1542
1547
|
* Licensed under the MIT License.
|
|
@@ -1557,181 +1562,7 @@
|
|
|
1557
1562
|
AzureCloudInstance["AzureUsGovernment"] = "https://login.microsoftonline.us";
|
|
1558
1563
|
})(exports.AzureCloudInstance || (exports.AzureCloudInstance = {}));
|
|
1559
1564
|
|
|
1560
|
-
/*! @azure/msal-common
|
|
1561
|
-
|
|
1562
|
-
/*
|
|
1563
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
1564
|
-
* Licensed under the MIT License.
|
|
1565
|
-
*/
|
|
1566
|
-
/**
|
|
1567
|
-
* Base type for credentials to be stored in the cache: eg: ACCESS_TOKEN, ID_TOKEN etc
|
|
1568
|
-
*
|
|
1569
|
-
* Key:Value Schema:
|
|
1570
|
-
*
|
|
1571
|
-
* Key: <home_account_id*>-<environment>-<credential_type>-<client_id>-<realm*>-<target*>-<requestedClaims*>-<scheme*>
|
|
1572
|
-
*
|
|
1573
|
-
* Value Schema:
|
|
1574
|
-
* {
|
|
1575
|
-
* homeAccountId: home account identifier for the auth scheme,
|
|
1576
|
-
* environment: entity that issued the token, represented as a full host
|
|
1577
|
-
* credentialType: Type of credential as a string, can be one of the following: RefreshToken, AccessToken, IdToken, Password, Cookie, Certificate, Other
|
|
1578
|
-
* clientId: client ID of the application
|
|
1579
|
-
* secret: Actual credential as a string
|
|
1580
|
-
* familyId: Family ID identifier, usually only used for refresh tokens
|
|
1581
|
-
* realm: Full tenant or organizational identifier that the account belongs to
|
|
1582
|
-
* target: Permissions that are included in the token, or for refresh tokens, the resource identifier.
|
|
1583
|
-
* tokenType: Matches the authentication scheme for which the token was issued (i.e. Bearer or pop)
|
|
1584
|
-
* requestedClaimsHash: Matches the SHA 256 hash of the claims object included in the token request
|
|
1585
|
-
* userAssertionHash: Matches the SHA 256 hash of the obo_assertion for the OBO flow
|
|
1586
|
-
* }
|
|
1587
|
-
*/
|
|
1588
|
-
var CredentialEntity = /** @class */ (function () {
|
|
1589
|
-
function CredentialEntity() {
|
|
1590
|
-
}
|
|
1591
|
-
/**
|
|
1592
|
-
* Initializes a map with credential {CredentialType} regular expressions.
|
|
1593
|
-
*/
|
|
1594
|
-
CredentialEntity._initRegex = function () {
|
|
1595
|
-
var separator = Separators.CACHE_KEY_SEPARATOR;
|
|
1596
|
-
CredentialEntity.credentialRegexMap = new Map();
|
|
1597
|
-
for (var _i = 0, _a = Object.keys(CredentialType); _i < _a.length; _i++) {
|
|
1598
|
-
var credKey = _a[_i];
|
|
1599
|
-
var credVal = CredentialType[credKey].toLowerCase();
|
|
1600
|
-
try {
|
|
1601
|
-
// Verify credential type is preceded by a valid host name (environment) using lookbehind
|
|
1602
|
-
CredentialEntity.credentialRegexMap.set(CredentialType[credKey], new RegExp("(?<=" + separator + CredentialEntity.credentialDomainRegex + ")" + separator + credVal + separator));
|
|
1603
|
-
}
|
|
1604
|
-
catch (err) {
|
|
1605
|
-
// Lookbehind is not supported (Safari or older versions of IE) - removing it
|
|
1606
|
-
CredentialEntity.credentialRegexMap.set(CredentialType[credKey], new RegExp("" + separator + CredentialEntity.credentialDomainRegex + separator + credVal + separator));
|
|
1607
|
-
}
|
|
1608
|
-
}
|
|
1609
|
-
};
|
|
1610
|
-
/**
|
|
1611
|
-
* Generate Account Id key component as per the schema: <home_account_id>-<environment>
|
|
1612
|
-
*/
|
|
1613
|
-
CredentialEntity.prototype.generateAccountId = function () {
|
|
1614
|
-
return CredentialEntity.generateAccountIdForCacheKey(this.homeAccountId, this.environment);
|
|
1615
|
-
};
|
|
1616
|
-
/**
|
|
1617
|
-
* Generate Credential Id key component as per the schema: <credential_type>-<client_id>-<realm>
|
|
1618
|
-
*/
|
|
1619
|
-
CredentialEntity.prototype.generateCredentialId = function () {
|
|
1620
|
-
return CredentialEntity.generateCredentialIdForCacheKey(this.credentialType, this.clientId, this.realm, this.familyId);
|
|
1621
|
-
};
|
|
1622
|
-
/**
|
|
1623
|
-
* Generate target key component as per schema: <target>
|
|
1624
|
-
*/
|
|
1625
|
-
CredentialEntity.prototype.generateTarget = function () {
|
|
1626
|
-
return CredentialEntity.generateTargetForCacheKey(this.target);
|
|
1627
|
-
};
|
|
1628
|
-
/**
|
|
1629
|
-
* generates credential key
|
|
1630
|
-
*/
|
|
1631
|
-
CredentialEntity.prototype.generateCredentialKey = function () {
|
|
1632
|
-
return CredentialEntity.generateCredentialCacheKey(this.homeAccountId, this.environment, this.credentialType, this.clientId, this.realm, this.target, this.familyId, this.tokenType, this.requestedClaimsHash);
|
|
1633
|
-
};
|
|
1634
|
-
/**
|
|
1635
|
-
* returns the type of the cache (in this case credential)
|
|
1636
|
-
*/
|
|
1637
|
-
CredentialEntity.prototype.generateType = function () {
|
|
1638
|
-
switch (this.credentialType) {
|
|
1639
|
-
case CredentialType.ID_TOKEN:
|
|
1640
|
-
return CacheType.ID_TOKEN;
|
|
1641
|
-
case CredentialType.ACCESS_TOKEN:
|
|
1642
|
-
case CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME:
|
|
1643
|
-
return CacheType.ACCESS_TOKEN;
|
|
1644
|
-
case CredentialType.REFRESH_TOKEN:
|
|
1645
|
-
return CacheType.REFRESH_TOKEN;
|
|
1646
|
-
default: {
|
|
1647
|
-
throw ClientAuthError.createUnexpectedCredentialTypeError();
|
|
1648
|
-
}
|
|
1649
|
-
}
|
|
1650
|
-
};
|
|
1651
|
-
/**
|
|
1652
|
-
* helper function to return `CredentialType`
|
|
1653
|
-
* @param key
|
|
1654
|
-
*/
|
|
1655
|
-
CredentialEntity.getCredentialType = function (key) {
|
|
1656
|
-
var _a;
|
|
1657
|
-
for (var _i = 0, _b = Object.keys(CredentialType); _i < _b.length; _i++) {
|
|
1658
|
-
var credKey = _b[_i];
|
|
1659
|
-
if ((_a = this.credentialRegexMap.get(CredentialType[credKey])) === null || _a === void 0 ? void 0 : _a.test(key.toLowerCase())) {
|
|
1660
|
-
return CredentialType[credKey];
|
|
1661
|
-
}
|
|
1662
|
-
}
|
|
1663
|
-
return Constants.NOT_DEFINED;
|
|
1664
|
-
};
|
|
1665
|
-
/**
|
|
1666
|
-
* generates credential key
|
|
1667
|
-
* <home_account_id*>-\<environment>-<credential_type>-<client_id>-<realm\*>-<target\*>-<scheme\*>
|
|
1668
|
-
*/
|
|
1669
|
-
CredentialEntity.generateCredentialCacheKey = function (homeAccountId, environment, credentialType, clientId, realm, target, familyId, tokenType, requestedClaimsHash) {
|
|
1670
|
-
var credentialKey = [
|
|
1671
|
-
this.generateAccountIdForCacheKey(homeAccountId, environment),
|
|
1672
|
-
this.generateCredentialIdForCacheKey(credentialType, clientId, realm, familyId),
|
|
1673
|
-
this.generateTargetForCacheKey(target),
|
|
1674
|
-
this.generateClaimsHashForCacheKey(requestedClaimsHash),
|
|
1675
|
-
this.generateSchemeForCacheKey(tokenType)
|
|
1676
|
-
];
|
|
1677
|
-
return credentialKey.join(Separators.CACHE_KEY_SEPARATOR).toLowerCase();
|
|
1678
|
-
};
|
|
1679
|
-
/**
|
|
1680
|
-
* generates Account Id for keys
|
|
1681
|
-
* @param homeAccountId
|
|
1682
|
-
* @param environment
|
|
1683
|
-
*/
|
|
1684
|
-
CredentialEntity.generateAccountIdForCacheKey = function (homeAccountId, environment) {
|
|
1685
|
-
var accountId = [homeAccountId, environment];
|
|
1686
|
-
return accountId.join(Separators.CACHE_KEY_SEPARATOR).toLowerCase();
|
|
1687
|
-
};
|
|
1688
|
-
/**
|
|
1689
|
-
* Generates Credential Id for keys
|
|
1690
|
-
* @param credentialType
|
|
1691
|
-
* @param realm
|
|
1692
|
-
* @param clientId
|
|
1693
|
-
* @param familyId
|
|
1694
|
-
*/
|
|
1695
|
-
CredentialEntity.generateCredentialIdForCacheKey = function (credentialType, clientId, realm, familyId) {
|
|
1696
|
-
var clientOrFamilyId = credentialType === CredentialType.REFRESH_TOKEN
|
|
1697
|
-
? familyId || clientId
|
|
1698
|
-
: clientId;
|
|
1699
|
-
var credentialId = [
|
|
1700
|
-
credentialType,
|
|
1701
|
-
clientOrFamilyId,
|
|
1702
|
-
realm || Constants.EMPTY_STRING,
|
|
1703
|
-
];
|
|
1704
|
-
return credentialId.join(Separators.CACHE_KEY_SEPARATOR).toLowerCase();
|
|
1705
|
-
};
|
|
1706
|
-
/**
|
|
1707
|
-
* Generate target key component as per schema: <target>
|
|
1708
|
-
*/
|
|
1709
|
-
CredentialEntity.generateTargetForCacheKey = function (scopes) {
|
|
1710
|
-
return (scopes || Constants.EMPTY_STRING).toLowerCase();
|
|
1711
|
-
};
|
|
1712
|
-
/**
|
|
1713
|
-
* Generate requested claims key component as per schema: <requestedClaims>
|
|
1714
|
-
*/
|
|
1715
|
-
CredentialEntity.generateClaimsHashForCacheKey = function (requestedClaimsHash) {
|
|
1716
|
-
return (requestedClaimsHash || Constants.EMPTY_STRING).toLowerCase();
|
|
1717
|
-
};
|
|
1718
|
-
/**
|
|
1719
|
-
* Generate scheme key componenet as per schema: <scheme>
|
|
1720
|
-
*/
|
|
1721
|
-
CredentialEntity.generateSchemeForCacheKey = function (tokenType) {
|
|
1722
|
-
/*
|
|
1723
|
-
* PoP Tokens and SSH certs include scheme in cache key
|
|
1724
|
-
* Cast to lowercase to handle "bearer" from ADFS
|
|
1725
|
-
*/
|
|
1726
|
-
return (tokenType && tokenType.toLowerCase() !== exports.AuthenticationScheme.BEARER.toLowerCase()) ? tokenType.toLowerCase() : Constants.EMPTY_STRING;
|
|
1727
|
-
};
|
|
1728
|
-
// Match host names like "login.microsoftonline.com", "https://accounts.google.com:4000", https://localhost:5000, etc.
|
|
1729
|
-
CredentialEntity.credentialDomainRegex = "(https?:\\/\\/)?((([\\w-]+\\.)*([\\w-]{1,63})(\\.(\\w{2,63})))|(localhost))(\\:[0-9]{4,5})?";
|
|
1730
|
-
return CredentialEntity;
|
|
1731
|
-
}());
|
|
1732
|
-
CredentialEntity._initRegex();
|
|
1733
|
-
|
|
1734
|
-
/*! @azure/msal-common v10.0.0 2023-02-06 */
|
|
1565
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
1735
1566
|
|
|
1736
1567
|
/*
|
|
1737
1568
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1986,7 +1817,7 @@
|
|
|
1986
1817
|
return ClientConfigurationError;
|
|
1987
1818
|
}(ClientAuthError));
|
|
1988
1819
|
|
|
1989
|
-
/*! @azure/msal-common
|
|
1820
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
1990
1821
|
|
|
1991
1822
|
/*
|
|
1992
1823
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2019,6 +1850,21 @@
|
|
|
2019
1850
|
var inputScopes = scopeString.split(" ");
|
|
2020
1851
|
return new ScopeSet(inputScopes);
|
|
2021
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
|
+
};
|
|
2022
1868
|
/**
|
|
2023
1869
|
* Used to validate the scopes input parameter requested by the developer.
|
|
2024
1870
|
* @param {Array<string>} inputScopes - Developer requested permissions. Not all scopes are guaranteed to be included in the access token returned.
|
|
@@ -2170,7 +2016,7 @@
|
|
|
2170
2016
|
return ScopeSet;
|
|
2171
2017
|
}());
|
|
2172
2018
|
|
|
2173
|
-
/*! @azure/msal-common
|
|
2019
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
2174
2020
|
|
|
2175
2021
|
/*
|
|
2176
2022
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2208,7 +2054,7 @@
|
|
|
2208
2054
|
};
|
|
2209
2055
|
}
|
|
2210
2056
|
|
|
2211
|
-
/*! @azure/msal-common
|
|
2057
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
2212
2058
|
/*
|
|
2213
2059
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2214
2060
|
* Licensed under the MIT License.
|
|
@@ -2223,7 +2069,7 @@
|
|
|
2223
2069
|
AuthorityType[AuthorityType["Dsts"] = 2] = "Dsts";
|
|
2224
2070
|
})(AuthorityType || (AuthorityType = {}));
|
|
2225
2071
|
|
|
2226
|
-
/*! @azure/msal-common
|
|
2072
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
2227
2073
|
|
|
2228
2074
|
/*
|
|
2229
2075
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2462,7 +2308,7 @@
|
|
|
2462
2308
|
return AccountEntity;
|
|
2463
2309
|
}());
|
|
2464
2310
|
|
|
2465
|
-
/*! @azure/msal-common
|
|
2311
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
2466
2312
|
|
|
2467
2313
|
/*
|
|
2468
2314
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2514,7 +2360,7 @@
|
|
|
2514
2360
|
return AuthToken;
|
|
2515
2361
|
}());
|
|
2516
2362
|
|
|
2517
|
-
/*! @azure/msal-common
|
|
2363
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
2518
2364
|
|
|
2519
2365
|
/*
|
|
2520
2366
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2524,35 +2370,59 @@
|
|
|
2524
2370
|
* Interface class which implement cache storage functions used by MSAL to perform validity checks, and store tokens.
|
|
2525
2371
|
*/
|
|
2526
2372
|
var CacheManager = /** @class */ (function () {
|
|
2527
|
-
function CacheManager(clientId, cryptoImpl) {
|
|
2373
|
+
function CacheManager(clientId, cryptoImpl, logger) {
|
|
2528
2374
|
this.clientId = clientId;
|
|
2529
2375
|
this.cryptoImpl = cryptoImpl;
|
|
2376
|
+
this.commonLogger = logger.clone(name$1, version$1);
|
|
2530
2377
|
}
|
|
2531
2378
|
/**
|
|
2532
2379
|
* Returns all accounts in cache
|
|
2533
2380
|
*/
|
|
2534
2381
|
CacheManager.prototype.getAllAccounts = function () {
|
|
2535
2382
|
var _this = this;
|
|
2536
|
-
var
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
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) {
|
|
2540
2396
|
return [];
|
|
2541
2397
|
}
|
|
2542
2398
|
else {
|
|
2543
|
-
var allAccounts =
|
|
2544
|
-
|
|
2545
|
-
var accountInfo = accountEntity.getAccountInfo();
|
|
2546
|
-
var idToken = _this.readIdTokenFromCache(_this.clientId, accountInfo);
|
|
2547
|
-
if (idToken && !accountInfo.idTokenClaims) {
|
|
2548
|
-
accountInfo.idToken = idToken.secret;
|
|
2549
|
-
accountInfo.idTokenClaims = new AuthToken(idToken.secret, _this.cryptoImpl).claims;
|
|
2550
|
-
}
|
|
2551
|
-
return accountInfo;
|
|
2399
|
+
var allAccounts = accountEntities.map(function (accountEntity) {
|
|
2400
|
+
return _this.getAccountInfoFromEntity(accountEntity);
|
|
2552
2401
|
});
|
|
2553
2402
|
return allAccounts;
|
|
2554
2403
|
}
|
|
2555
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
|
+
};
|
|
2556
2426
|
/**
|
|
2557
2427
|
* saves a cache record
|
|
2558
2428
|
* @param cacheRecord
|
|
@@ -2594,12 +2464,12 @@
|
|
|
2594
2464
|
*/
|
|
2595
2465
|
CacheManager.prototype.saveAccessToken = function (credential) {
|
|
2596
2466
|
return __awaiter(this, void 0, void 0, function () {
|
|
2597
|
-
var
|
|
2467
|
+
var accessTokenFilter, tokenKeys, currentScopes, removedAccessTokens;
|
|
2598
2468
|
var _this = this;
|
|
2599
2469
|
return __generator(this, function (_a) {
|
|
2600
2470
|
switch (_a.label) {
|
|
2601
2471
|
case 0:
|
|
2602
|
-
|
|
2472
|
+
accessTokenFilter = {
|
|
2603
2473
|
clientId: credential.clientId,
|
|
2604
2474
|
credentialType: credential.credentialType,
|
|
2605
2475
|
environment: credential.environment,
|
|
@@ -2607,22 +2477,25 @@
|
|
|
2607
2477
|
realm: credential.realm,
|
|
2608
2478
|
tokenType: credential.tokenType,
|
|
2609
2479
|
requestedClaimsHash: credential.requestedClaimsHash
|
|
2610
|
-
}
|
|
2480
|
+
};
|
|
2481
|
+
tokenKeys = this.getTokenKeys();
|
|
2611
2482
|
currentScopes = ScopeSet.fromString(credential.target);
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
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
|
+
}
|
|
2619
2494
|
}
|
|
2620
2495
|
});
|
|
2621
|
-
return [4 /*yield*/, Promise.all(
|
|
2496
|
+
return [4 /*yield*/, Promise.all(removedAccessTokens)];
|
|
2622
2497
|
case 1:
|
|
2623
2498
|
_a.sent();
|
|
2624
|
-
_a.label = 2;
|
|
2625
|
-
case 2:
|
|
2626
2499
|
this.setAccessTokenCredential(credential);
|
|
2627
2500
|
return [2 /*return*/];
|
|
2628
2501
|
}
|
|
@@ -2637,149 +2510,151 @@
|
|
|
2637
2510
|
* @param realm
|
|
2638
2511
|
*/
|
|
2639
2512
|
CacheManager.prototype.getAccountsFilteredBy = function (accountFilter) {
|
|
2640
|
-
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);
|
|
2641
|
-
};
|
|
2642
|
-
/**
|
|
2643
|
-
* retrieve accounts matching all provided filters; if no filter is set, get all accounts
|
|
2644
|
-
* not checking for casing as keys are all generated in lower case, remember to convert to lower case if object properties are compared
|
|
2645
|
-
* @param homeAccountId
|
|
2646
|
-
* @param environment
|
|
2647
|
-
* @param realm
|
|
2648
|
-
*/
|
|
2649
|
-
CacheManager.prototype.getAccountsFilteredByInternal = function (homeAccountId, environment, realm, nativeAccountId) {
|
|
2650
2513
|
var _this = this;
|
|
2651
|
-
var
|
|
2652
|
-
var matchingAccounts =
|
|
2653
|
-
|
|
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
|
+
}
|
|
2654
2521
|
var entity = _this.getAccount(cacheKey);
|
|
2655
2522
|
if (!entity) {
|
|
2656
2523
|
return;
|
|
2657
2524
|
}
|
|
2658
|
-
if (!!homeAccountId && !_this.matchHomeAccountId(entity, homeAccountId)) {
|
|
2525
|
+
if (!!accountFilter.homeAccountId && !_this.matchHomeAccountId(entity, accountFilter.homeAccountId)) {
|
|
2659
2526
|
return;
|
|
2660
2527
|
}
|
|
2661
|
-
if (!!
|
|
2528
|
+
if (!!accountFilter.localAccountId && !_this.matchLocalAccountId(entity, accountFilter.localAccountId)) {
|
|
2529
|
+
return;
|
|
2530
|
+
}
|
|
2531
|
+
if (!!accountFilter.username && !_this.matchUsername(entity, accountFilter.username)) {
|
|
2662
2532
|
return;
|
|
2663
2533
|
}
|
|
2664
|
-
if (!!
|
|
2534
|
+
if (!!accountFilter.environment && !_this.matchEnvironment(entity, accountFilter.environment)) {
|
|
2665
2535
|
return;
|
|
2666
2536
|
}
|
|
2667
|
-
if (!!
|
|
2537
|
+
if (!!accountFilter.realm && !_this.matchRealm(entity, accountFilter.realm)) {
|
|
2668
2538
|
return;
|
|
2669
2539
|
}
|
|
2670
|
-
|
|
2540
|
+
if (!!accountFilter.nativeAccountId && !_this.matchNativeAccountId(entity, accountFilter.nativeAccountId)) {
|
|
2541
|
+
return;
|
|
2542
|
+
}
|
|
2543
|
+
matchingAccounts.push(entity);
|
|
2671
2544
|
});
|
|
2672
2545
|
return matchingAccounts;
|
|
2673
2546
|
};
|
|
2674
2547
|
/**
|
|
2675
|
-
*
|
|
2548
|
+
* Returns true if the given key matches our account key schema. Also matches homeAccountId and/or tenantId if provided
|
|
2549
|
+
* @param key
|
|
2676
2550
|
* @param homeAccountId
|
|
2677
|
-
* @param
|
|
2678
|
-
* @
|
|
2679
|
-
* @param clientId
|
|
2680
|
-
* @param realm
|
|
2681
|
-
* @param target
|
|
2551
|
+
* @param tenantId
|
|
2552
|
+
* @returns
|
|
2682
2553
|
*/
|
|
2683
|
-
CacheManager.prototype.
|
|
2684
|
-
|
|
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;
|
|
2685
2567
|
};
|
|
2686
2568
|
/**
|
|
2687
|
-
*
|
|
2688
|
-
* @param
|
|
2689
|
-
* @param environment
|
|
2690
|
-
* @param credentialType
|
|
2691
|
-
* @param clientId
|
|
2692
|
-
* @param realm
|
|
2693
|
-
* @param target
|
|
2694
|
-
* @param userAssertionHash
|
|
2695
|
-
* @param tokenType
|
|
2569
|
+
* Returns true if the given key matches our credential key schema.
|
|
2570
|
+
* @param key
|
|
2696
2571
|
*/
|
|
2697
|
-
CacheManager.prototype.
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
//
|
|
2712
|
-
var
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
if (!!userAssertionHash && !_this.matchUserAssertionHash(entity, userAssertionHash)) {
|
|
2717
|
-
return;
|
|
2718
|
-
}
|
|
2719
|
-
/*
|
|
2720
|
-
* homeAccountId can undefined, and we want to filter out cached items that have a homeAccountId of ""
|
|
2721
|
-
* because we don't want a client_credential request to return a cached token that has a homeAccountId
|
|
2722
|
-
*/
|
|
2723
|
-
if ((typeof homeAccountId === "string") && !_this.matchHomeAccountId(entity, homeAccountId)) {
|
|
2724
|
-
return;
|
|
2725
|
-
}
|
|
2726
|
-
if (!!environment && !_this.matchEnvironment(entity, environment)) {
|
|
2727
|
-
return;
|
|
2728
|
-
}
|
|
2729
|
-
if (!!realm && !_this.matchRealm(entity, realm)) {
|
|
2730
|
-
return;
|
|
2731
|
-
}
|
|
2732
|
-
if (!!credentialType && !_this.matchCredentialType(entity, credentialType)) {
|
|
2733
|
-
return;
|
|
2734
|
-
}
|
|
2735
|
-
if (!!clientId && !_this.matchClientId(entity, clientId)) {
|
|
2736
|
-
return;
|
|
2737
|
-
}
|
|
2738
|
-
if (!!familyId && !_this.matchFamilyId(entity, familyId)) {
|
|
2739
|
-
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;
|
|
2740
2591
|
}
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
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;
|
|
2747
2643
|
}
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
}
|
|
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;
|
|
2754
2649
|
}
|
|
2755
|
-
//
|
|
2756
|
-
if (
|
|
2757
|
-
if (
|
|
2758
|
-
return;
|
|
2759
|
-
}
|
|
2760
|
-
// KeyId (sshKid) in request must match cached SSH certificate keyId because SSH cert is bound to a specific key
|
|
2761
|
-
if (tokenType === exports.AuthenticationScheme.SSH) {
|
|
2762
|
-
if (keyId && !_this.matchKeyId(entity, keyId)) {
|
|
2763
|
-
return;
|
|
2764
|
-
}
|
|
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;
|
|
2765
2654
|
}
|
|
2766
2655
|
}
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
switch (credType) {
|
|
2770
|
-
case CredentialType.ID_TOKEN:
|
|
2771
|
-
matchingCredentials.idTokens[updatedCacheKey] = entity;
|
|
2772
|
-
break;
|
|
2773
|
-
case CredentialType.ACCESS_TOKEN:
|
|
2774
|
-
case CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME:
|
|
2775
|
-
matchingCredentials.accessTokens[updatedCacheKey] = entity;
|
|
2776
|
-
break;
|
|
2777
|
-
case CredentialType.REFRESH_TOKEN:
|
|
2778
|
-
matchingCredentials.refreshTokens[updatedCacheKey] = entity;
|
|
2779
|
-
break;
|
|
2780
|
-
}
|
|
2781
|
-
});
|
|
2782
|
-
return matchingCredentials;
|
|
2656
|
+
}
|
|
2657
|
+
return true;
|
|
2783
2658
|
};
|
|
2784
2659
|
/**
|
|
2785
2660
|
* retrieve appMetadata matching all provided filters; if no filter is set, get all appMetadata
|
|
@@ -2847,30 +2722,26 @@
|
|
|
2847
2722
|
*/
|
|
2848
2723
|
CacheManager.prototype.removeAllAccounts = function () {
|
|
2849
2724
|
return __awaiter(this, void 0, void 0, function () {
|
|
2850
|
-
var
|
|
2725
|
+
var allAccountKeys, removedAccounts;
|
|
2851
2726
|
var _this = this;
|
|
2852
2727
|
return __generator(this, function (_a) {
|
|
2853
2728
|
switch (_a.label) {
|
|
2854
2729
|
case 0:
|
|
2855
|
-
|
|
2730
|
+
allAccountKeys = this.getAccountKeys();
|
|
2856
2731
|
removedAccounts = [];
|
|
2857
|
-
|
|
2858
|
-
var entity = _this.getAccount(cacheKey);
|
|
2859
|
-
if (!entity) {
|
|
2860
|
-
return;
|
|
2861
|
-
}
|
|
2732
|
+
allAccountKeys.forEach(function (cacheKey) {
|
|
2862
2733
|
removedAccounts.push(_this.removeAccount(cacheKey));
|
|
2863
2734
|
});
|
|
2864
2735
|
return [4 /*yield*/, Promise.all(removedAccounts)];
|
|
2865
2736
|
case 1:
|
|
2866
2737
|
_a.sent();
|
|
2867
|
-
return [2 /*return
|
|
2738
|
+
return [2 /*return*/];
|
|
2868
2739
|
}
|
|
2869
2740
|
});
|
|
2870
2741
|
});
|
|
2871
2742
|
};
|
|
2872
2743
|
/**
|
|
2873
|
-
*
|
|
2744
|
+
* Removes the account and related tokens for a given account key
|
|
2874
2745
|
* @param account
|
|
2875
2746
|
*/
|
|
2876
2747
|
CacheManager.prototype.removeAccount = function (accountKey) {
|
|
@@ -2884,7 +2755,10 @@
|
|
|
2884
2755
|
throw ClientAuthError.createNoAccountFoundError();
|
|
2885
2756
|
}
|
|
2886
2757
|
return [4 /*yield*/, this.removeAccountContext(account)];
|
|
2887
|
-
case 1:
|
|
2758
|
+
case 1:
|
|
2759
|
+
_a.sent();
|
|
2760
|
+
this.removeItem(accountKey);
|
|
2761
|
+
return [2 /*return*/];
|
|
2888
2762
|
}
|
|
2889
2763
|
});
|
|
2890
2764
|
});
|
|
@@ -2895,29 +2769,33 @@
|
|
|
2895
2769
|
*/
|
|
2896
2770
|
CacheManager.prototype.removeAccountContext = function (account) {
|
|
2897
2771
|
return __awaiter(this, void 0, void 0, function () {
|
|
2898
|
-
var
|
|
2772
|
+
var allTokenKeys, accountId, removedCredentials;
|
|
2899
2773
|
var _this = this;
|
|
2900
2774
|
return __generator(this, function (_a) {
|
|
2901
2775
|
switch (_a.label) {
|
|
2902
2776
|
case 0:
|
|
2903
|
-
|
|
2777
|
+
allTokenKeys = this.getTokenKeys();
|
|
2904
2778
|
accountId = account.generateAccountId();
|
|
2905
2779
|
removedCredentials = [];
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
if (credType === Constants.NOT_DEFINED) {
|
|
2910
|
-
return;
|
|
2780
|
+
allTokenKeys.idToken.forEach(function (key) {
|
|
2781
|
+
if (key.indexOf(accountId) === 0) {
|
|
2782
|
+
_this.removeIdToken(key);
|
|
2911
2783
|
}
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
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);
|
|
2915
2793
|
}
|
|
2916
2794
|
});
|
|
2917
2795
|
return [4 /*yield*/, Promise.all(removedCredentials)];
|
|
2918
2796
|
case 1:
|
|
2919
2797
|
_a.sent();
|
|
2920
|
-
return [2 /*return
|
|
2798
|
+
return [2 /*return*/];
|
|
2921
2799
|
}
|
|
2922
2800
|
});
|
|
2923
2801
|
});
|
|
@@ -2926,13 +2804,16 @@
|
|
|
2926
2804
|
* returns a boolean if the given credential is removed
|
|
2927
2805
|
* @param credential
|
|
2928
2806
|
*/
|
|
2929
|
-
CacheManager.prototype.
|
|
2807
|
+
CacheManager.prototype.removeAccessToken = function (key) {
|
|
2930
2808
|
return __awaiter(this, void 0, void 0, function () {
|
|
2931
|
-
var
|
|
2809
|
+
var credential, accessTokenWithAuthSchemeEntity, kid;
|
|
2932
2810
|
return __generator(this, function (_a) {
|
|
2933
2811
|
switch (_a.label) {
|
|
2934
2812
|
case 0:
|
|
2935
|
-
|
|
2813
|
+
credential = this.getAccessTokenCredential(key);
|
|
2814
|
+
if (!credential) {
|
|
2815
|
+
return [2 /*return*/];
|
|
2816
|
+
}
|
|
2936
2817
|
if (!(credential.credentialType.toLowerCase() === CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME.toLowerCase())) return [3 /*break*/, 4];
|
|
2937
2818
|
if (!(credential.tokenType === exports.AuthenticationScheme.POP)) return [3 /*break*/, 4];
|
|
2938
2819
|
accessTokenWithAuthSchemeEntity = credential;
|
|
@@ -2948,7 +2829,7 @@
|
|
|
2948
2829
|
case 3:
|
|
2949
2830
|
_a.sent();
|
|
2950
2831
|
throw ClientAuthError.createBindingKeyNotRemovedError();
|
|
2951
|
-
case 4: return [2 /*return*/, this.removeItem(key
|
|
2832
|
+
case 4: return [2 /*return*/, this.removeItem(key)];
|
|
2952
2833
|
}
|
|
2953
2834
|
});
|
|
2954
2835
|
});
|
|
@@ -2961,7 +2842,7 @@
|
|
|
2961
2842
|
var allCacheKeys = this.getKeys();
|
|
2962
2843
|
allCacheKeys.forEach(function (cacheKey) {
|
|
2963
2844
|
if (_this.isAppMetadata(cacheKey)) {
|
|
2964
|
-
_this.removeItem(cacheKey
|
|
2845
|
+
_this.removeItem(cacheKey);
|
|
2965
2846
|
}
|
|
2966
2847
|
});
|
|
2967
2848
|
return true;
|
|
@@ -2974,12 +2855,13 @@
|
|
|
2974
2855
|
* @param environment
|
|
2975
2856
|
* @param authScheme
|
|
2976
2857
|
*/
|
|
2977
|
-
CacheManager.prototype.readCacheRecord = function (account,
|
|
2858
|
+
CacheManager.prototype.readCacheRecord = function (account, request, environment) {
|
|
2859
|
+
var tokenKeys = this.getTokenKeys();
|
|
2978
2860
|
var cachedAccount = this.readAccountFromCache(account);
|
|
2979
|
-
var cachedIdToken = this.
|
|
2980
|
-
var cachedAccessToken = this.
|
|
2981
|
-
var cachedRefreshToken = this.
|
|
2982
|
-
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);
|
|
2983
2865
|
if (cachedAccount && cachedIdToken) {
|
|
2984
2866
|
cachedAccount.idTokenClaims = new AuthToken(cachedIdToken.secret, this.cryptoImpl).claims;
|
|
2985
2867
|
}
|
|
@@ -2999,51 +2881,83 @@
|
|
|
2999
2881
|
var accountKey = AccountEntity.generateAccountCacheKey(account);
|
|
3000
2882
|
return this.getAccount(accountKey);
|
|
3001
2883
|
};
|
|
3002
|
-
/**
|
|
3003
|
-
* Retrieve AccountEntity from cache
|
|
3004
|
-
* @param nativeAccountId
|
|
3005
|
-
* @returns AccountEntity or Null
|
|
3006
|
-
*/
|
|
3007
|
-
CacheManager.prototype.readAccountFromCacheWithNativeAccountId = function (nativeAccountId) {
|
|
3008
|
-
// fetch account from memory
|
|
3009
|
-
var accountFilter = {
|
|
3010
|
-
nativeAccountId: nativeAccountId
|
|
3011
|
-
};
|
|
3012
|
-
var accountCache = this.getAccountsFilteredBy(accountFilter);
|
|
3013
|
-
var accounts = Object.keys(accountCache).map(function (key) { return accountCache[key]; });
|
|
3014
|
-
if (accounts.length < 1) {
|
|
3015
|
-
return null;
|
|
3016
|
-
}
|
|
3017
|
-
else if (accounts.length > 1) {
|
|
3018
|
-
throw ClientAuthError.createMultipleMatchingAccountsInCacheError();
|
|
3019
|
-
}
|
|
3020
|
-
return accountCache[0];
|
|
3021
|
-
};
|
|
3022
2884
|
/**
|
|
3023
2885
|
* Retrieve IdTokenEntity from cache
|
|
3024
2886
|
* @param clientId
|
|
3025
2887
|
* @param account
|
|
3026
2888
|
* @param inputRealm
|
|
3027
2889
|
*/
|
|
3028
|
-
CacheManager.prototype.
|
|
2890
|
+
CacheManager.prototype.getIdToken = function (account, tokenKeys) {
|
|
2891
|
+
this.commonLogger.trace("CacheManager - getIdToken called");
|
|
3029
2892
|
var idTokenFilter = {
|
|
3030
2893
|
homeAccountId: account.homeAccountId,
|
|
3031
2894
|
environment: account.environment,
|
|
3032
2895
|
credentialType: CredentialType.ID_TOKEN,
|
|
3033
|
-
clientId: clientId,
|
|
2896
|
+
clientId: this.clientId,
|
|
3034
2897
|
realm: account.tenantId,
|
|
3035
2898
|
};
|
|
3036
|
-
var
|
|
3037
|
-
var idTokens = Object.keys(credentialCache.idTokens).map(function (key) { return credentialCache.idTokens[key]; });
|
|
2899
|
+
var idTokens = this.getIdTokensByFilter(idTokenFilter, tokenKeys);
|
|
3038
2900
|
var numIdTokens = idTokens.length;
|
|
3039
2901
|
if (numIdTokens < 1) {
|
|
2902
|
+
this.commonLogger.info("CacheManager:getIdToken - No token found");
|
|
3040
2903
|
return null;
|
|
3041
2904
|
}
|
|
3042
2905
|
else if (numIdTokens > 1) {
|
|
3043
2906
|
throw ClientAuthError.createMultipleMatchingTokensInCacheError();
|
|
3044
2907
|
}
|
|
2908
|
+
this.commonLogger.info("CacheManager:getIdToken - Returning id token");
|
|
3045
2909
|
return idTokens[0];
|
|
3046
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
|
+
};
|
|
3047
2961
|
/**
|
|
3048
2962
|
* Retrieve AccessTokenEntity from cache
|
|
3049
2963
|
* @param clientId
|
|
@@ -3051,8 +2965,10 @@
|
|
|
3051
2965
|
* @param scopes
|
|
3052
2966
|
* @param authScheme
|
|
3053
2967
|
*/
|
|
3054
|
-
CacheManager.prototype.
|
|
3055
|
-
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);
|
|
3056
2972
|
var authScheme = request.authenticationScheme || exports.AuthenticationScheme.BEARER;
|
|
3057
2973
|
/*
|
|
3058
2974
|
* Distinguish between Bearer and PoP/SSH token cache types
|
|
@@ -3063,55 +2979,156 @@
|
|
|
3063
2979
|
homeAccountId: account.homeAccountId,
|
|
3064
2980
|
environment: account.environment,
|
|
3065
2981
|
credentialType: credentialType,
|
|
3066
|
-
clientId: clientId,
|
|
2982
|
+
clientId: this.clientId,
|
|
3067
2983
|
realm: account.tenantId,
|
|
3068
|
-
target: scopes
|
|
2984
|
+
target: scopes,
|
|
3069
2985
|
tokenType: authScheme,
|
|
3070
2986
|
keyId: request.sshKid,
|
|
3071
2987
|
requestedClaimsHash: request.requestedClaimsHash,
|
|
3072
2988
|
};
|
|
3073
|
-
var
|
|
3074
|
-
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
|
+
});
|
|
3075
3001
|
var numAccessTokens = accessTokens.length;
|
|
3076
3002
|
if (numAccessTokens < 1) {
|
|
3003
|
+
this.commonLogger.info("CacheManager:getAccessToken - No token found");
|
|
3077
3004
|
return null;
|
|
3078
3005
|
}
|
|
3079
3006
|
else if (numAccessTokens > 1) {
|
|
3080
3007
|
throw ClientAuthError.createMultipleMatchingTokensInCacheError();
|
|
3081
3008
|
}
|
|
3009
|
+
this.commonLogger.info("CacheManager:getAccessToken - Returning access token");
|
|
3082
3010
|
return accessTokens[0];
|
|
3083
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
|
+
};
|
|
3084
3068
|
/**
|
|
3085
3069
|
* Helper to retrieve the appropriate refresh token from cache
|
|
3086
3070
|
* @param clientId
|
|
3087
3071
|
* @param account
|
|
3088
3072
|
* @param familyRT
|
|
3089
3073
|
*/
|
|
3090
|
-
CacheManager.prototype.
|
|
3074
|
+
CacheManager.prototype.getRefreshToken = function (account, familyRT, tokenKeys) {
|
|
3075
|
+
var _this = this;
|
|
3076
|
+
this.commonLogger.trace("CacheManager - getRefreshToken called");
|
|
3091
3077
|
var id = familyRT ? THE_FAMILY_ID : undefined;
|
|
3092
3078
|
var refreshTokenFilter = {
|
|
3093
3079
|
homeAccountId: account.homeAccountId,
|
|
3094
3080
|
environment: account.environment,
|
|
3095
3081
|
credentialType: CredentialType.REFRESH_TOKEN,
|
|
3096
|
-
clientId: clientId,
|
|
3082
|
+
clientId: this.clientId,
|
|
3097
3083
|
familyId: id,
|
|
3098
3084
|
};
|
|
3099
|
-
var
|
|
3100
|
-
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
|
+
});
|
|
3101
3097
|
var numRefreshTokens = refreshTokens.length;
|
|
3102
3098
|
if (numRefreshTokens < 1) {
|
|
3099
|
+
this.commonLogger.info("CacheManager:getRefreshToken - No refresh token found.");
|
|
3103
3100
|
return null;
|
|
3104
3101
|
}
|
|
3105
3102
|
// address the else case after remove functions address environment aliases
|
|
3103
|
+
this.commonLogger.info("CacheManager:getRefreshToken - returning refresh token");
|
|
3106
3104
|
return refreshTokens[0];
|
|
3107
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
|
+
};
|
|
3108
3125
|
/**
|
|
3109
3126
|
* Retrieve AppMetadataEntity from cache
|
|
3110
3127
|
*/
|
|
3111
|
-
CacheManager.prototype.readAppMetadataFromCache = function (environment
|
|
3128
|
+
CacheManager.prototype.readAppMetadataFromCache = function (environment) {
|
|
3112
3129
|
var appMetadataFilter = {
|
|
3113
3130
|
environment: environment,
|
|
3114
|
-
clientId: clientId,
|
|
3131
|
+
clientId: this.clientId,
|
|
3115
3132
|
};
|
|
3116
3133
|
var appMetadata = this.getAppMetadataFilteredBy(appMetadataFilter);
|
|
3117
3134
|
var appMetadataEntries = Object.keys(appMetadata).map(function (key) { return appMetadata[key]; });
|
|
@@ -3129,8 +3146,8 @@
|
|
|
3129
3146
|
* @param environment
|
|
3130
3147
|
* @param clientId
|
|
3131
3148
|
*/
|
|
3132
|
-
CacheManager.prototype.isAppMetadataFOCI = function (environment
|
|
3133
|
-
var appMetadata = this.readAppMetadataFromCache(environment
|
|
3149
|
+
CacheManager.prototype.isAppMetadataFOCI = function (environment) {
|
|
3150
|
+
var appMetadata = this.readAppMetadataFromCache(environment);
|
|
3134
3151
|
return !!(appMetadata && appMetadata.familyId === THE_FAMILY_ID);
|
|
3135
3152
|
};
|
|
3136
3153
|
/**
|
|
@@ -3141,6 +3158,24 @@
|
|
|
3141
3158
|
CacheManager.prototype.matchHomeAccountId = function (entity, homeAccountId) {
|
|
3142
3159
|
return !!((typeof entity.homeAccountId === "string") && (homeAccountId === entity.homeAccountId));
|
|
3143
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
|
+
};
|
|
3144
3179
|
/**
|
|
3145
3180
|
* helper to match assertion
|
|
3146
3181
|
* @param value
|
|
@@ -3213,14 +3248,7 @@
|
|
|
3213
3248
|
return false;
|
|
3214
3249
|
}
|
|
3215
3250
|
var entityScopeSet = ScopeSet.fromString(entity.target);
|
|
3216
|
-
|
|
3217
|
-
if (!requestTargetScopeSet.containsOnlyOIDCScopes()) {
|
|
3218
|
-
requestTargetScopeSet.removeOIDCScopes(); // ignore OIDC scopes
|
|
3219
|
-
}
|
|
3220
|
-
else {
|
|
3221
|
-
requestTargetScopeSet.removeScope(Constants.OFFLINE_ACCESS_SCOPE);
|
|
3222
|
-
}
|
|
3223
|
-
return entityScopeSet.containsScopeSet(requestTargetScopeSet);
|
|
3251
|
+
return entityScopeSet.containsScopeSet(target);
|
|
3224
3252
|
};
|
|
3225
3253
|
/**
|
|
3226
3254
|
* Returns true if the credential's tokenType or Authentication Scheme matches the one in the request, false otherwise
|
|
@@ -3258,27 +3286,6 @@
|
|
|
3258
3286
|
CacheManager.prototype.generateAuthorityMetadataCacheKey = function (authority) {
|
|
3259
3287
|
return AUTHORITY_METADATA_CONSTANTS.CACHE_KEY + "-" + this.clientId + "-" + authority;
|
|
3260
3288
|
};
|
|
3261
|
-
/**
|
|
3262
|
-
* Returns the specific credential (IdToken/AccessToken/RefreshToken) from the cache
|
|
3263
|
-
* @param key
|
|
3264
|
-
* @param credType
|
|
3265
|
-
*/
|
|
3266
|
-
CacheManager.prototype.getSpecificCredential = function (key, credType) {
|
|
3267
|
-
switch (credType) {
|
|
3268
|
-
case CredentialType.ID_TOKEN: {
|
|
3269
|
-
return this.getIdTokenCredential(key);
|
|
3270
|
-
}
|
|
3271
|
-
case CredentialType.ACCESS_TOKEN:
|
|
3272
|
-
case CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME: {
|
|
3273
|
-
return this.getAccessTokenCredential(key);
|
|
3274
|
-
}
|
|
3275
|
-
case CredentialType.REFRESH_TOKEN: {
|
|
3276
|
-
return this.getRefreshTokenCredential(key);
|
|
3277
|
-
}
|
|
3278
|
-
default:
|
|
3279
|
-
return null;
|
|
3280
|
-
}
|
|
3281
|
-
};
|
|
3282
3289
|
/**
|
|
3283
3290
|
* Helper to convert serialized data to object
|
|
3284
3291
|
* @param obj
|
|
@@ -3377,6 +3384,14 @@
|
|
|
3377
3384
|
var notImplErr = "Storage interface - getKeys() has not been implemented for the cacheStorage interface.";
|
|
3378
3385
|
throw AuthError.createUnexpectedError(notImplErr);
|
|
3379
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
|
+
};
|
|
3380
3395
|
DefaultStorageClass.prototype.clear = function () {
|
|
3381
3396
|
return __awaiter(this, void 0, void 0, function () {
|
|
3382
3397
|
var notImplErr;
|
|
@@ -3393,7 +3408,7 @@
|
|
|
3393
3408
|
return DefaultStorageClass;
|
|
3394
3409
|
}(CacheManager));
|
|
3395
3410
|
|
|
3396
|
-
/*! @azure/msal-common
|
|
3411
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
3397
3412
|
|
|
3398
3413
|
/*
|
|
3399
3414
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3467,7 +3482,7 @@
|
|
|
3467
3482
|
authOptions: buildAuthOptions(userAuthOptions),
|
|
3468
3483
|
systemOptions: __assign(__assign({}, DEFAULT_SYSTEM_OPTIONS), userSystemOptions),
|
|
3469
3484
|
loggerOptions: loggerOptions,
|
|
3470
|
-
storageInterface: storageImplementation || new DefaultStorageClass(userAuthOptions.clientId, DEFAULT_CRYPTO_IMPLEMENTATION),
|
|
3485
|
+
storageInterface: storageImplementation || new DefaultStorageClass(userAuthOptions.clientId, DEFAULT_CRYPTO_IMPLEMENTATION, new Logger(loggerOptions)),
|
|
3471
3486
|
networkInterface: networkImplementation || DEFAULT_NETWORK_IMPLEMENTATION,
|
|
3472
3487
|
cryptoInterface: cryptoImplementation || DEFAULT_CRYPTO_IMPLEMENTATION,
|
|
3473
3488
|
clientCredentials: clientCredentials || DEFAULT_CLIENT_CREDENTIALS,
|
|
@@ -3486,7 +3501,7 @@
|
|
|
3486
3501
|
return __assign({ clientCapabilities: [], azureCloudOptions: DEFAULT_AZURE_CLOUD_OPTIONS, skipAuthorityMetadataCache: false }, authOptions);
|
|
3487
3502
|
}
|
|
3488
3503
|
|
|
3489
|
-
/*! @azure/msal-common
|
|
3504
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
3490
3505
|
|
|
3491
3506
|
/*
|
|
3492
3507
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3506,7 +3521,7 @@
|
|
|
3506
3521
|
return ServerError;
|
|
3507
3522
|
}(AuthError));
|
|
3508
3523
|
|
|
3509
|
-
/*! @azure/msal-common
|
|
3524
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
3510
3525
|
|
|
3511
3526
|
/*
|
|
3512
3527
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3533,7 +3548,7 @@
|
|
|
3533
3548
|
var value = cacheManager.getThrottlingCache(key);
|
|
3534
3549
|
if (value) {
|
|
3535
3550
|
if (value.throttleTime < Date.now()) {
|
|
3536
|
-
cacheManager.removeItem(key
|
|
3551
|
+
cacheManager.removeItem(key);
|
|
3537
3552
|
return;
|
|
3538
3553
|
}
|
|
3539
3554
|
throw new ServerError(((_a = value.errorCodes) === null || _a === void 0 ? void 0 : _a.join(" ")) || Constants.EMPTY_STRING, value.errorMessage, value.subError);
|
|
@@ -3597,12 +3612,12 @@
|
|
|
3597
3612
|
sshKid: request.sshKid
|
|
3598
3613
|
};
|
|
3599
3614
|
var key = this.generateThrottlingStorageKey(thumbprint);
|
|
3600
|
-
|
|
3615
|
+
cacheManager.removeItem(key);
|
|
3601
3616
|
};
|
|
3602
3617
|
return ThrottlingUtils;
|
|
3603
3618
|
}());
|
|
3604
3619
|
|
|
3605
|
-
/*! @azure/msal-common
|
|
3620
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
3606
3621
|
|
|
3607
3622
|
/*
|
|
3608
3623
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3651,7 +3666,7 @@
|
|
|
3651
3666
|
return NetworkManager;
|
|
3652
3667
|
}());
|
|
3653
3668
|
|
|
3654
|
-
/*! @azure/msal-common
|
|
3669
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
3655
3670
|
/*
|
|
3656
3671
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3657
3672
|
* Licensed under the MIT License.
|
|
@@ -3662,7 +3677,7 @@
|
|
|
3662
3677
|
CcsCredentialType["UPN"] = "UPN";
|
|
3663
3678
|
})(CcsCredentialType || (CcsCredentialType = {}));
|
|
3664
3679
|
|
|
3665
|
-
/*! @azure/msal-common
|
|
3680
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
3666
3681
|
|
|
3667
3682
|
/*
|
|
3668
3683
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3753,7 +3768,7 @@
|
|
|
3753
3768
|
return RequestValidator;
|
|
3754
3769
|
}());
|
|
3755
3770
|
|
|
3756
|
-
/*! @azure/msal-common
|
|
3771
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
3757
3772
|
|
|
3758
3773
|
/*
|
|
3759
3774
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4131,7 +4146,7 @@
|
|
|
4131
4146
|
return RequestParameterBuilder;
|
|
4132
4147
|
}());
|
|
4133
4148
|
|
|
4134
|
-
/*! @azure/msal-common
|
|
4149
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
4135
4150
|
|
|
4136
4151
|
/*
|
|
4137
4152
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4233,7 +4248,145 @@
|
|
|
4233
4248
|
return BaseClient;
|
|
4234
4249
|
}());
|
|
4235
4250
|
|
|
4236
|
-
/*! @azure/msal-common
|
|
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
|
+
}
|
|
4322
|
+
};
|
|
4323
|
+
/**
|
|
4324
|
+
* generates credential key
|
|
4325
|
+
* <home_account_id*>-\<environment>-<credential_type>-<client_id>-<realm\*>-<target\*>-<scheme\*>
|
|
4326
|
+
*/
|
|
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();
|
|
4336
|
+
};
|
|
4337
|
+
/**
|
|
4338
|
+
* generates Account Id for keys
|
|
4339
|
+
* @param homeAccountId
|
|
4340
|
+
* @param environment
|
|
4341
|
+
*/
|
|
4342
|
+
CredentialEntity.generateAccountIdForCacheKey = function (homeAccountId, environment) {
|
|
4343
|
+
var accountId = [homeAccountId, environment];
|
|
4344
|
+
return accountId.join(Separators.CACHE_KEY_SEPARATOR).toLowerCase();
|
|
4345
|
+
};
|
|
4346
|
+
/**
|
|
4347
|
+
* Generates Credential Id for keys
|
|
4348
|
+
* @param credentialType
|
|
4349
|
+
* @param realm
|
|
4350
|
+
* @param clientId
|
|
4351
|
+
* @param familyId
|
|
4352
|
+
*/
|
|
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();
|
|
4363
|
+
};
|
|
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;
|
|
4387
|
+
}());
|
|
4388
|
+
|
|
4389
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
4237
4390
|
|
|
4238
4391
|
/*
|
|
4239
4392
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4297,7 +4450,7 @@
|
|
|
4297
4450
|
return IdTokenEntity;
|
|
4298
4451
|
}(CredentialEntity));
|
|
4299
4452
|
|
|
4300
|
-
/*! @azure/msal-common
|
|
4453
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
4301
4454
|
/*
|
|
4302
4455
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4303
4456
|
* Licensed under the MIT License.
|
|
@@ -4347,7 +4500,7 @@
|
|
|
4347
4500
|
return TimeUtils;
|
|
4348
4501
|
}());
|
|
4349
4502
|
|
|
4350
|
-
/*! @azure/msal-common
|
|
4503
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
4351
4504
|
|
|
4352
4505
|
/*
|
|
4353
4506
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4461,7 +4614,7 @@
|
|
|
4461
4614
|
return AccessTokenEntity;
|
|
4462
4615
|
}(CredentialEntity));
|
|
4463
4616
|
|
|
4464
|
-
/*! @azure/msal-common
|
|
4617
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
4465
4618
|
|
|
4466
4619
|
/*
|
|
4467
4620
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4528,7 +4681,7 @@
|
|
|
4528
4681
|
return RefreshTokenEntity;
|
|
4529
4682
|
}(CredentialEntity));
|
|
4530
4683
|
|
|
4531
|
-
/*! @azure/msal-common
|
|
4684
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
4532
4685
|
|
|
4533
4686
|
/*
|
|
4534
4687
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4607,7 +4760,7 @@
|
|
|
4607
4760
|
return InteractionRequiredAuthError;
|
|
4608
4761
|
}(AuthError));
|
|
4609
4762
|
|
|
4610
|
-
/*! @azure/msal-common
|
|
4763
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
4611
4764
|
/*
|
|
4612
4765
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4613
4766
|
* Licensed under the MIT License.
|
|
@@ -4623,7 +4776,7 @@
|
|
|
4623
4776
|
return CacheRecord;
|
|
4624
4777
|
}());
|
|
4625
4778
|
|
|
4626
|
-
/*! @azure/msal-common
|
|
4779
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
4627
4780
|
|
|
4628
4781
|
/*
|
|
4629
4782
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4694,7 +4847,7 @@
|
|
|
4694
4847
|
return ProtocolUtils;
|
|
4695
4848
|
}());
|
|
4696
4849
|
|
|
4697
|
-
/*! @azure/msal-common
|
|
4850
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
4698
4851
|
|
|
4699
4852
|
/*
|
|
4700
4853
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4928,7 +5081,7 @@
|
|
|
4928
5081
|
return UrlString;
|
|
4929
5082
|
}());
|
|
4930
5083
|
|
|
4931
|
-
/*! @azure/msal-common
|
|
5084
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
4932
5085
|
/*
|
|
4933
5086
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4934
5087
|
* Licensed under the MIT License.
|
|
@@ -5065,6 +5218,7 @@
|
|
|
5065
5218
|
* Internal API for initializing silent request in SilentCacheClient (msal-browser)
|
|
5066
5219
|
*/
|
|
5067
5220
|
PerformanceEvents["InitializeSilentRequest"] = "initializeSilentRequest";
|
|
5221
|
+
PerformanceEvents["InitializeClientApplication"] = "initializeClientApplication";
|
|
5068
5222
|
/**
|
|
5069
5223
|
* Helper function in SilentIframeClient class (msal-browser).
|
|
5070
5224
|
*/
|
|
@@ -5130,6 +5284,7 @@
|
|
|
5130
5284
|
PerformanceEvents["HandleRedirectPromiseMeasurement"] = "handleRedirectPromiseMeasurement";
|
|
5131
5285
|
PerformanceEvents["UpdateCloudDiscoveryMetadataMeasurement"] = "updateCloudDiscoveryMetadataMeasurement";
|
|
5132
5286
|
PerformanceEvents["UsernamePasswordClientAcquireToken"] = "usernamePasswordClientAcquireToken";
|
|
5287
|
+
PerformanceEvents["NativeMessageHandlerHandshake"] = "nativeMessageHandlerHandshake";
|
|
5133
5288
|
})(exports.PerformanceEvents || (exports.PerformanceEvents = {}));
|
|
5134
5289
|
/**
|
|
5135
5290
|
* State of the performance event.
|
|
@@ -5155,7 +5310,7 @@
|
|
|
5155
5310
|
"status",
|
|
5156
5311
|
]);
|
|
5157
5312
|
|
|
5158
|
-
/*! @azure/msal-common
|
|
5313
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
5159
5314
|
|
|
5160
5315
|
/*
|
|
5161
5316
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -5264,7 +5419,7 @@
|
|
|
5264
5419
|
return PopTokenGenerator;
|
|
5265
5420
|
}());
|
|
5266
5421
|
|
|
5267
|
-
/*! @azure/msal-common
|
|
5422
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
5268
5423
|
|
|
5269
5424
|
/*
|
|
5270
5425
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -5334,7 +5489,7 @@
|
|
|
5334
5489
|
return AppMetadataEntity;
|
|
5335
5490
|
}());
|
|
5336
5491
|
|
|
5337
|
-
/*! @azure/msal-common
|
|
5492
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
5338
5493
|
/*
|
|
5339
5494
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
5340
5495
|
* Licensed under the MIT License.
|
|
@@ -5370,7 +5525,7 @@
|
|
|
5370
5525
|
return TokenCacheContext;
|
|
5371
5526
|
}());
|
|
5372
5527
|
|
|
5373
|
-
/*! @azure/msal-common
|
|
5528
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
5374
5529
|
|
|
5375
5530
|
/*
|
|
5376
5531
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -5502,7 +5657,7 @@
|
|
|
5502
5657
|
_b.sent();
|
|
5503
5658
|
_b.label = 7;
|
|
5504
5659
|
case 7: return [7 /*endfinally*/];
|
|
5505
|
-
case 8: return [2 /*return*/, ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenObj, requestStateObj, serverTokenResponse
|
|
5660
|
+
case 8: return [2 /*return*/, ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenObj, requestStateObj, serverTokenResponse, serverRequestId)];
|
|
5506
5661
|
}
|
|
5507
5662
|
});
|
|
5508
5663
|
});
|
|
@@ -5588,7 +5743,7 @@
|
|
|
5588
5743
|
* @param fromTokenCache
|
|
5589
5744
|
* @param stateString
|
|
5590
5745
|
*/
|
|
5591
|
-
ResponseHandler.generateAuthenticationResult = function (cryptoObj, authority, cacheRecord, fromTokenCache, request, idTokenObj, requestState,
|
|
5746
|
+
ResponseHandler.generateAuthenticationResult = function (cryptoObj, authority, cacheRecord, fromTokenCache, request, idTokenObj, requestState, serverTokenResponse, requestId) {
|
|
5592
5747
|
var _a, _b, _c;
|
|
5593
5748
|
return __awaiter(this, void 0, void 0, function () {
|
|
5594
5749
|
var accessToken, responseScopes, expiresOn, extExpiresOn, familyId, popTokenGenerator, _d, secret, keyId, uid, tid;
|
|
@@ -5624,6 +5779,10 @@
|
|
|
5624
5779
|
}
|
|
5625
5780
|
uid = (idTokenObj === null || idTokenObj === void 0 ? void 0 : idTokenObj.claims.oid) || (idTokenObj === null || idTokenObj === void 0 ? void 0 : idTokenObj.claims.sub) || Constants.EMPTY_STRING;
|
|
5626
5781
|
tid = (idTokenObj === null || idTokenObj === void 0 ? void 0 : idTokenObj.claims.tid) || Constants.EMPTY_STRING;
|
|
5782
|
+
// for hybrid + native bridge enablement, send back the native account Id
|
|
5783
|
+
if ((serverTokenResponse === null || serverTokenResponse === void 0 ? void 0 : serverTokenResponse.spa_accountid) && !!cacheRecord.account) {
|
|
5784
|
+
cacheRecord.account.nativeAccountId = serverTokenResponse === null || serverTokenResponse === void 0 ? void 0 : serverTokenResponse.spa_accountid;
|
|
5785
|
+
}
|
|
5627
5786
|
return [2 /*return*/, {
|
|
5628
5787
|
authority: authority.canonicalAuthority,
|
|
5629
5788
|
uniqueId: uid,
|
|
@@ -5643,7 +5802,7 @@
|
|
|
5643
5802
|
state: requestState ? requestState.userRequestState : Constants.EMPTY_STRING,
|
|
5644
5803
|
cloudGraphHostName: ((_b = cacheRecord.account) === null || _b === void 0 ? void 0 : _b.cloudGraphHostName) || Constants.EMPTY_STRING,
|
|
5645
5804
|
msGraphHost: ((_c = cacheRecord.account) === null || _c === void 0 ? void 0 : _c.msGraphHost) || Constants.EMPTY_STRING,
|
|
5646
|
-
code:
|
|
5805
|
+
code: serverTokenResponse === null || serverTokenResponse === void 0 ? void 0 : serverTokenResponse.spa_code,
|
|
5647
5806
|
fromNativeBroker: false,
|
|
5648
5807
|
}];
|
|
5649
5808
|
}
|
|
@@ -5653,7 +5812,7 @@
|
|
|
5653
5812
|
return ResponseHandler;
|
|
5654
5813
|
}());
|
|
5655
5814
|
|
|
5656
|
-
/*! @azure/msal-common
|
|
5815
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
5657
5816
|
|
|
5658
5817
|
/*
|
|
5659
5818
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6131,7 +6290,7 @@
|
|
|
6131
6290
|
return AuthorizationCodeClient;
|
|
6132
6291
|
}(BaseClient));
|
|
6133
6292
|
|
|
6134
|
-
/*! @azure/msal-common
|
|
6293
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
6135
6294
|
|
|
6136
6295
|
/*
|
|
6137
6296
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6211,7 +6370,7 @@
|
|
|
6211
6370
|
if (!request.account) {
|
|
6212
6371
|
throw ClientAuthError.createNoAccountInSilentRequestError();
|
|
6213
6372
|
}
|
|
6214
|
-
isFOCI = this.cacheManager.isAppMetadataFOCI(request.account.environment
|
|
6373
|
+
isFOCI = this.cacheManager.isAppMetadataFOCI(request.account.environment);
|
|
6215
6374
|
// if the app is part of the family, retrive a Family refresh token if present and make a refreshTokenRequest
|
|
6216
6375
|
if (isFOCI) {
|
|
6217
6376
|
try {
|
|
@@ -6250,7 +6409,7 @@
|
|
|
6250
6409
|
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.RefreshTokenClientAcquireTokenWithCachedRefreshToken, request.correlationId);
|
|
6251
6410
|
atsMeasurement = (_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.startMeasurement(exports.PerformanceEvents.RefreshTokenClientAcquireTokenWithCachedRefreshToken, request.correlationId);
|
|
6252
6411
|
this.logger.verbose("RefreshTokenClientAcquireTokenWithCachedRefreshToken called", request.correlationId);
|
|
6253
|
-
refreshToken = this.cacheManager.
|
|
6412
|
+
refreshToken = this.cacheManager.getRefreshToken(request.account, foci);
|
|
6254
6413
|
if (!refreshToken) {
|
|
6255
6414
|
atsMeasurement === null || atsMeasurement === void 0 ? void 0 : atsMeasurement.discardMeasurement();
|
|
6256
6415
|
throw InteractionRequiredAuthError.createNoTokensFoundError();
|
|
@@ -6405,7 +6564,7 @@
|
|
|
6405
6564
|
return RefreshTokenClient;
|
|
6406
6565
|
}(BaseClient));
|
|
6407
6566
|
|
|
6408
|
-
/*! @azure/msal-common
|
|
6567
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
6409
6568
|
|
|
6410
6569
|
/*
|
|
6411
6570
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6470,7 +6629,7 @@
|
|
|
6470
6629
|
throw ClientAuthError.createNoAccountInSilentRequestError();
|
|
6471
6630
|
}
|
|
6472
6631
|
environment = request.authority || this.authority.getPreferredCache();
|
|
6473
|
-
cacheRecord = this.cacheManager.readCacheRecord(request.account,
|
|
6632
|
+
cacheRecord = this.cacheManager.readCacheRecord(request.account, request, environment);
|
|
6474
6633
|
if (!cacheRecord.accessToken) {
|
|
6475
6634
|
// Must refresh due to non-existent access_token.
|
|
6476
6635
|
(_b = this.serverTelemetryManager) === null || _b === void 0 ? void 0 : _b.setCacheOutcome(CacheOutcome.NO_CACHED_ACCESS_TOKEN);
|
|
@@ -6529,7 +6688,7 @@
|
|
|
6529
6688
|
return SilentFlowClient;
|
|
6530
6689
|
}(BaseClient));
|
|
6531
6690
|
|
|
6532
|
-
/*! @azure/msal-common
|
|
6691
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
6533
6692
|
/*
|
|
6534
6693
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
6535
6694
|
* Licensed under the MIT License.
|
|
@@ -6541,7 +6700,7 @@
|
|
|
6541
6700
|
response.hasOwnProperty("jwks_uri"));
|
|
6542
6701
|
}
|
|
6543
6702
|
|
|
6544
|
-
/*! @azure/msal-common
|
|
6703
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
6545
6704
|
/*
|
|
6546
6705
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
6547
6706
|
* Licensed under the MIT License.
|
|
@@ -6550,7 +6709,7 @@
|
|
|
6550
6709
|
var EndpointMetadata = rawMetdataJSON.endpointMetadata;
|
|
6551
6710
|
var InstanceDiscoveryMetadata = rawMetdataJSON.instanceDiscoveryMetadata;
|
|
6552
6711
|
|
|
6553
|
-
/*! @azure/msal-common
|
|
6712
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
6554
6713
|
/*
|
|
6555
6714
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
6556
6715
|
* Licensed under the MIT License.
|
|
@@ -6564,7 +6723,7 @@
|
|
|
6564
6723
|
ProtocolMode["OIDC"] = "OIDC";
|
|
6565
6724
|
})(exports.ProtocolMode || (exports.ProtocolMode = {}));
|
|
6566
6725
|
|
|
6567
|
-
/*! @azure/msal-common
|
|
6726
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
6568
6727
|
|
|
6569
6728
|
/*
|
|
6570
6729
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6641,7 +6800,7 @@
|
|
|
6641
6800
|
return AuthorityMetadataEntity;
|
|
6642
6801
|
}());
|
|
6643
6802
|
|
|
6644
|
-
/*! @azure/msal-common
|
|
6803
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
6645
6804
|
/*
|
|
6646
6805
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
6647
6806
|
* Licensed under the MIT License.
|
|
@@ -6651,7 +6810,7 @@
|
|
|
6651
6810
|
response.hasOwnProperty("metadata"));
|
|
6652
6811
|
}
|
|
6653
6812
|
|
|
6654
|
-
/*! @azure/msal-common
|
|
6813
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
6655
6814
|
/*
|
|
6656
6815
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
6657
6816
|
* Licensed under the MIT License.
|
|
@@ -6661,7 +6820,7 @@
|
|
|
6661
6820
|
response.hasOwnProperty("error_description"));
|
|
6662
6821
|
}
|
|
6663
6822
|
|
|
6664
|
-
/*! @azure/msal-common
|
|
6823
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
6665
6824
|
|
|
6666
6825
|
/*
|
|
6667
6826
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6793,7 +6952,7 @@
|
|
|
6793
6952
|
return RegionDiscovery;
|
|
6794
6953
|
}());
|
|
6795
6954
|
|
|
6796
|
-
/*! @azure/msal-common
|
|
6955
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
6797
6956
|
|
|
6798
6957
|
/*
|
|
6799
6958
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7528,7 +7687,7 @@
|
|
|
7528
7687
|
return Authority;
|
|
7529
7688
|
}());
|
|
7530
7689
|
|
|
7531
|
-
/*! @azure/msal-common
|
|
7690
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
7532
7691
|
|
|
7533
7692
|
/*
|
|
7534
7693
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7591,7 +7750,7 @@
|
|
|
7591
7750
|
return AuthorityFactory;
|
|
7592
7751
|
}());
|
|
7593
7752
|
|
|
7594
|
-
/*! @azure/msal-common
|
|
7753
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
7595
7754
|
|
|
7596
7755
|
/*
|
|
7597
7756
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7622,7 +7781,7 @@
|
|
|
7622
7781
|
return ServerTelemetryEntity;
|
|
7623
7782
|
}());
|
|
7624
7783
|
|
|
7625
|
-
/*! @azure/msal-common
|
|
7784
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
7626
7785
|
|
|
7627
7786
|
/*
|
|
7628
7787
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7650,7 +7809,7 @@
|
|
|
7650
7809
|
return ThrottlingEntity;
|
|
7651
7810
|
}());
|
|
7652
7811
|
|
|
7653
|
-
/*! @azure/msal-common
|
|
7812
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
7654
7813
|
|
|
7655
7814
|
/*
|
|
7656
7815
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7667,7 +7826,7 @@
|
|
|
7667
7826
|
}
|
|
7668
7827
|
};
|
|
7669
7828
|
|
|
7670
|
-
/*! @azure/msal-common
|
|
7829
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
7671
7830
|
|
|
7672
7831
|
/*
|
|
7673
7832
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7712,7 +7871,7 @@
|
|
|
7712
7871
|
return JoseHeaderError;
|
|
7713
7872
|
}(AuthError));
|
|
7714
7873
|
|
|
7715
|
-
/*! @azure/msal-common
|
|
7874
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
7716
7875
|
|
|
7717
7876
|
/*
|
|
7718
7877
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7742,8 +7901,8 @@
|
|
|
7742
7901
|
throw JoseHeaderError.createMissingAlgError();
|
|
7743
7902
|
}
|
|
7744
7903
|
var shrHeader = new JoseHeader({
|
|
7745
|
-
// Access Token PoP headers must have type
|
|
7746
|
-
typ: shrHeaderOptions.typ || JsonTypes.
|
|
7904
|
+
// Access Token PoP headers must have type pop, but the type header can be overriden for special cases
|
|
7905
|
+
typ: shrHeaderOptions.typ || JsonTypes.Pop,
|
|
7747
7906
|
kid: shrHeaderOptions.kid,
|
|
7748
7907
|
alg: shrHeaderOptions.alg
|
|
7749
7908
|
});
|
|
@@ -7752,7 +7911,7 @@
|
|
|
7752
7911
|
return JoseHeader;
|
|
7753
7912
|
}());
|
|
7754
7913
|
|
|
7755
|
-
/*! @azure/msal-common
|
|
7914
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
7756
7915
|
|
|
7757
7916
|
/*
|
|
7758
7917
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7811,7 +7970,7 @@
|
|
|
7811
7970
|
return AuthenticationHeaderParser;
|
|
7812
7971
|
}());
|
|
7813
7972
|
|
|
7814
|
-
/*! @azure/msal-common
|
|
7973
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
7815
7974
|
|
|
7816
7975
|
/*
|
|
7817
7976
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7973,7 +8132,7 @@
|
|
|
7973
8132
|
return ServerTelemetryManager;
|
|
7974
8133
|
}());
|
|
7975
8134
|
|
|
7976
|
-
/*! @azure/msal-common
|
|
8135
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
7977
8136
|
|
|
7978
8137
|
/*
|
|
7979
8138
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -8000,11 +8159,8 @@
|
|
|
8000
8159
|
this.logger = logger;
|
|
8001
8160
|
this.callbacks = new Map();
|
|
8002
8161
|
this.eventsByCorrelationId = new Map();
|
|
8003
|
-
this.staticFieldsByCorrelationId = new Map();
|
|
8004
|
-
this.measurementsById = new Map();
|
|
8005
8162
|
this.queueMeasurements = new Map();
|
|
8006
8163
|
this.preQueueTimeByCorrelationId = new Map();
|
|
8007
|
-
this.countersByCorrelationId = new Map();
|
|
8008
8164
|
}
|
|
8009
8165
|
/**
|
|
8010
8166
|
* Starts and returns an platform-specific implementation of IPerformanceMeasurement.
|
|
@@ -8045,16 +8201,16 @@
|
|
|
8045
8201
|
* @returns {number}
|
|
8046
8202
|
*/
|
|
8047
8203
|
PerformanceClient.prototype.getPreQueueTime = function (eventName, correlationId) {
|
|
8048
|
-
var
|
|
8049
|
-
if (!
|
|
8204
|
+
var preQueueEvent = this.preQueueTimeByCorrelationId.get(correlationId);
|
|
8205
|
+
if (!preQueueEvent) {
|
|
8050
8206
|
this.logger.trace("PerformanceClient.getPreQueueTime: no pre-queue times found for correlationId: " + correlationId + ", unable to add queue measurement");
|
|
8051
8207
|
return;
|
|
8052
8208
|
}
|
|
8053
|
-
else if (
|
|
8209
|
+
else if (preQueueEvent.name !== eventName) {
|
|
8054
8210
|
this.logger.trace("PerformanceClient.getPreQueueTime: no pre-queue time found for " + eventName + ", unable to add queue measurement");
|
|
8055
8211
|
return;
|
|
8056
8212
|
}
|
|
8057
|
-
return
|
|
8213
|
+
return preQueueEvent.time;
|
|
8058
8214
|
};
|
|
8059
8215
|
/**
|
|
8060
8216
|
* Calculates the difference between current time and time when function was queued.
|
|
@@ -8082,12 +8238,13 @@
|
|
|
8082
8238
|
/**
|
|
8083
8239
|
* Adds queue measurement time to QueueMeasurements array for given correlation ID.
|
|
8084
8240
|
*
|
|
8085
|
-
* @param {PerformanceEvents}
|
|
8241
|
+
* @param {PerformanceEvents} eventName
|
|
8086
8242
|
* @param {?string} correlationId
|
|
8087
|
-
* @param {?number}
|
|
8243
|
+
* @param {?number} queueTime
|
|
8244
|
+
* @param {?boolean} manuallyCompleted - indicator for manually completed queue measurements
|
|
8088
8245
|
* @returns
|
|
8089
8246
|
*/
|
|
8090
|
-
PerformanceClient.prototype.addQueueMeasurement = function (eventName, correlationId, queueTime) {
|
|
8247
|
+
PerformanceClient.prototype.addQueueMeasurement = function (eventName, correlationId, queueTime, manuallyCompleted) {
|
|
8091
8248
|
if (!correlationId) {
|
|
8092
8249
|
this.logger.trace("PerformanceClient.addQueueMeasurement: correlationId not provided for " + eventName + ", cannot add queue measurement");
|
|
8093
8250
|
return;
|
|
@@ -8100,7 +8257,7 @@
|
|
|
8100
8257
|
this.logger.trace("PerformanceClient.addQueueMeasurement: no queue time provided for " + eventName);
|
|
8101
8258
|
return;
|
|
8102
8259
|
}
|
|
8103
|
-
var queueMeasurement = { eventName: eventName, queueTime: queueTime };
|
|
8260
|
+
var queueMeasurement = { eventName: eventName, queueTime: queueTime, manuallyCompleted: manuallyCompleted };
|
|
8104
8261
|
// Adds to existing correlation Id if present in queueMeasurements
|
|
8105
8262
|
var existingMeasurements = this.queueMeasurements.get(correlationId);
|
|
8106
8263
|
if (existingMeasurements) {
|
|
@@ -8113,6 +8270,8 @@
|
|
|
8113
8270
|
var measurementArray = [queueMeasurement];
|
|
8114
8271
|
this.queueMeasurements.set(correlationId, measurementArray);
|
|
8115
8272
|
}
|
|
8273
|
+
// Delete processed pre-queue event.
|
|
8274
|
+
this.preQueueTimeByCorrelationId.delete(correlationId);
|
|
8116
8275
|
};
|
|
8117
8276
|
/**
|
|
8118
8277
|
* Starts measuring performance for a given operation. Returns a function that should be used to end the measurement.
|
|
@@ -8131,17 +8290,8 @@
|
|
|
8131
8290
|
}
|
|
8132
8291
|
// Duplicate code to address spelling error will be removed at the next major version bump.
|
|
8133
8292
|
this.logger.trace("PerformanceClient: Performance measurement started for " + measureName, eventCorrelationId);
|
|
8134
|
-
var
|
|
8135
|
-
|
|
8136
|
-
if (performanceMeasuremeant.startMeasurement) {
|
|
8137
|
-
performanceMeasuremeant.startMeasurement();
|
|
8138
|
-
validMeasurement = performanceMeasuremeant;
|
|
8139
|
-
}
|
|
8140
|
-
else {
|
|
8141
|
-
var performanceMeasurement = this.startPerformanceMeasurement(measureName, eventCorrelationId);
|
|
8142
|
-
performanceMeasurement.startMeasurement();
|
|
8143
|
-
validMeasurement = performanceMeasurement;
|
|
8144
|
-
}
|
|
8293
|
+
var performanceMeasurement = this.startPerformanceMeasuremeant(measureName, eventCorrelationId);
|
|
8294
|
+
performanceMeasurement.startMeasurement();
|
|
8145
8295
|
var inProgressEvent = {
|
|
8146
8296
|
eventId: this.generateId(),
|
|
8147
8297
|
status: PerformanceEventStatus.InProgress,
|
|
@@ -8152,27 +8302,15 @@
|
|
|
8152
8302
|
name: measureName,
|
|
8153
8303
|
startTimeMs: Date.now(),
|
|
8154
8304
|
correlationId: eventCorrelationId,
|
|
8155
|
-
};
|
|
8156
|
-
// Store in progress events so they can be discarded if not ended properly
|
|
8157
|
-
this.cacheEventByCorrelationId(inProgressEvent);
|
|
8158
|
-
var staticFields = {
|
|
8159
8305
|
appName: (_a = this.applicationTelemetry) === null || _a === void 0 ? void 0 : _a.appName,
|
|
8160
8306
|
appVersion: (_b = this.applicationTelemetry) === null || _b === void 0 ? void 0 : _b.appVersion,
|
|
8161
8307
|
};
|
|
8162
|
-
|
|
8163
|
-
this.
|
|
8308
|
+
// Store in progress events so they can be discarded if not ended properly
|
|
8309
|
+
this.cacheEventByCorrelationId(inProgressEvent);
|
|
8164
8310
|
// Return the event and functions the caller can use to properly end/flush the measurement
|
|
8165
8311
|
return {
|
|
8166
8312
|
endMeasurement: function (event) {
|
|
8167
|
-
|
|
8168
|
-
if (completedEvent) {
|
|
8169
|
-
// Cache event so that submeasurements can be added downstream
|
|
8170
|
-
_this.cacheEventByCorrelationId(completedEvent);
|
|
8171
|
-
}
|
|
8172
|
-
return completedEvent;
|
|
8173
|
-
},
|
|
8174
|
-
flushMeasurement: function () {
|
|
8175
|
-
return _this.flushMeasurements(inProgressEvent.name, inProgressEvent.correlationId);
|
|
8313
|
+
return _this.endMeasurement(__assign(__assign({}, inProgressEvent), event), performanceMeasurement);
|
|
8176
8314
|
},
|
|
8177
8315
|
discardMeasurement: function () {
|
|
8178
8316
|
return _this.discardMeasurements(inProgressEvent.correlationId);
|
|
@@ -8183,40 +8321,66 @@
|
|
|
8183
8321
|
increment: function (counters) {
|
|
8184
8322
|
return _this.increment(counters, inProgressEvent.correlationId);
|
|
8185
8323
|
},
|
|
8186
|
-
measurement:
|
|
8324
|
+
measurement: performanceMeasurement,
|
|
8187
8325
|
event: inProgressEvent
|
|
8188
8326
|
};
|
|
8189
8327
|
};
|
|
8190
8328
|
/**
|
|
8191
8329
|
* Stops measuring the performance for an operation. Should only be called directly by PerformanceClient classes,
|
|
8192
8330
|
* as consumers should instead use the function returned by startMeasurement.
|
|
8331
|
+
* Adds a new field named as "[event name]DurationMs" for sub-measurements, completes and emits an event
|
|
8332
|
+
* otherwise.
|
|
8193
8333
|
*
|
|
8194
8334
|
* @param {PerformanceEvent} event
|
|
8335
|
+
* @param {IPerformanceMeasurement} measurement
|
|
8195
8336
|
* @returns {(PerformanceEvent | null)}
|
|
8196
8337
|
*/
|
|
8197
|
-
PerformanceClient.prototype.endMeasurement = function (event) {
|
|
8198
|
-
var
|
|
8199
|
-
|
|
8200
|
-
|
|
8201
|
-
|
|
8202
|
-
|
|
8203
|
-
|
|
8204
|
-
|
|
8205
|
-
|
|
8206
|
-
|
|
8207
|
-
|
|
8208
|
-
|
|
8209
|
-
|
|
8210
|
-
|
|
8211
|
-
|
|
8212
|
-
|
|
8213
|
-
|
|
8214
|
-
}
|
|
8338
|
+
PerformanceClient.prototype.endMeasurement = function (event, measurement) {
|
|
8339
|
+
var _this = this;
|
|
8340
|
+
var _a, _b;
|
|
8341
|
+
var rootEvent = this.eventsByCorrelationId.get(event.correlationId);
|
|
8342
|
+
if (!rootEvent) {
|
|
8343
|
+
this.logger.trace("PerformanceClient: Measurement not found for " + event.eventId, event.correlationId);
|
|
8344
|
+
return null;
|
|
8345
|
+
}
|
|
8346
|
+
var isRoot = event.eventId === rootEvent.eventId;
|
|
8347
|
+
var queueInfo = {
|
|
8348
|
+
totalQueueTime: 0,
|
|
8349
|
+
totalQueueCount: 0,
|
|
8350
|
+
manuallyCompletedCount: 0
|
|
8351
|
+
};
|
|
8352
|
+
if (isRoot) {
|
|
8353
|
+
queueInfo = this.getQueueInfo(event.correlationId);
|
|
8354
|
+
this.discardCache(rootEvent.correlationId);
|
|
8215
8355
|
}
|
|
8216
8356
|
else {
|
|
8217
|
-
|
|
8357
|
+
(_a = rootEvent.incompleteSubMeasurements) === null || _a === void 0 ? void 0 : _a.delete(event.eventId);
|
|
8218
8358
|
}
|
|
8219
|
-
|
|
8359
|
+
measurement === null || measurement === void 0 ? void 0 : measurement.endMeasurement();
|
|
8360
|
+
var durationMs = measurement === null || measurement === void 0 ? void 0 : measurement.flushMeasurement();
|
|
8361
|
+
// null indicates no measurement was taken (e.g. needed performance APIs not present)
|
|
8362
|
+
if (!durationMs) {
|
|
8363
|
+
this.logger.trace("PerformanceClient: Performance measurement not taken", rootEvent.correlationId);
|
|
8364
|
+
return null;
|
|
8365
|
+
}
|
|
8366
|
+
this.logger.trace("PerformanceClient: Performance measurement ended for " + event.name + ": " + durationMs + " ms", event.correlationId);
|
|
8367
|
+
// Add sub-measurement attribute to root event.
|
|
8368
|
+
if (!isRoot) {
|
|
8369
|
+
rootEvent[event.name + "DurationMs"] = Math.floor(durationMs);
|
|
8370
|
+
return __assign({}, rootEvent);
|
|
8371
|
+
}
|
|
8372
|
+
var finalEvent = __assign(__assign({}, rootEvent), event);
|
|
8373
|
+
var incompleteSubsCount = 0;
|
|
8374
|
+
// Incomplete sub-measurements are discarded. They are likely an instrumentation bug that should be fixed.
|
|
8375
|
+
(_b = finalEvent.incompleteSubMeasurements) === null || _b === void 0 ? void 0 : _b.forEach(function (subMeasurement) {
|
|
8376
|
+
_this.logger.trace("PerformanceClient: Incomplete submeasurement " + subMeasurement.name + " found for " + event.name, finalEvent.correlationId);
|
|
8377
|
+
incompleteSubsCount++;
|
|
8378
|
+
});
|
|
8379
|
+
finalEvent.incompleteSubMeasurements = undefined;
|
|
8380
|
+
finalEvent = __assign(__assign({}, finalEvent), { durationMs: Math.round(durationMs), queuedTimeMs: queueInfo.totalQueueTime, queuedCount: queueInfo.totalQueueCount, queuedManuallyCompletedCount: queueInfo.manuallyCompletedCount, status: PerformanceEventStatus.Completed, incompleteSubsCount: incompleteSubsCount });
|
|
8381
|
+
this.truncateIntegralFields(finalEvent, this.getIntFields());
|
|
8382
|
+
this.emitEvents([finalEvent], event.correlationId);
|
|
8383
|
+
return finalEvent;
|
|
8220
8384
|
};
|
|
8221
8385
|
/**
|
|
8222
8386
|
* Saves extra information to be emitted when the measurements are flushed
|
|
@@ -8224,14 +8388,13 @@
|
|
|
8224
8388
|
* @param correlationId
|
|
8225
8389
|
*/
|
|
8226
8390
|
PerformanceClient.prototype.addStaticFields = function (fields, correlationId) {
|
|
8227
|
-
|
|
8228
|
-
|
|
8229
|
-
|
|
8230
|
-
this.
|
|
8391
|
+
this.logger.trace("PerformanceClient: Updating static fields");
|
|
8392
|
+
var event = this.eventsByCorrelationId.get(correlationId);
|
|
8393
|
+
if (event) {
|
|
8394
|
+
this.eventsByCorrelationId.set(correlationId, __assign(__assign({}, event), fields));
|
|
8231
8395
|
}
|
|
8232
8396
|
else {
|
|
8233
|
-
this.logger.trace("PerformanceClient:
|
|
8234
|
-
this.staticFieldsByCorrelationId.set(correlationId, fields);
|
|
8397
|
+
this.logger.trace("PerformanceClient: Event not found for", correlationId);
|
|
8235
8398
|
}
|
|
8236
8399
|
};
|
|
8237
8400
|
/**
|
|
@@ -8240,18 +8403,18 @@
|
|
|
8240
8403
|
* @param correlationId {string} correlation identifier
|
|
8241
8404
|
*/
|
|
8242
8405
|
PerformanceClient.prototype.increment = function (counters, correlationId) {
|
|
8243
|
-
var existing = this.countersByCorrelationId.get(correlationId);
|
|
8244
|
-
if (!existing) {
|
|
8245
|
-
this.logger.trace("PerformanceClient: Setting counters");
|
|
8246
|
-
this.countersByCorrelationId.set(correlationId, __assign({}, counters));
|
|
8247
|
-
return;
|
|
8248
|
-
}
|
|
8249
8406
|
this.logger.trace("PerformanceClient: Updating counters");
|
|
8250
|
-
|
|
8251
|
-
|
|
8252
|
-
|
|
8407
|
+
var event = this.eventsByCorrelationId.get(correlationId);
|
|
8408
|
+
if (event) {
|
|
8409
|
+
for (var counter in counters) {
|
|
8410
|
+
if (!event.hasOwnProperty(counter)) {
|
|
8411
|
+
event[counter] = 0;
|
|
8412
|
+
}
|
|
8413
|
+
event[counter] += counters[counter];
|
|
8253
8414
|
}
|
|
8254
|
-
|
|
8415
|
+
}
|
|
8416
|
+
else {
|
|
8417
|
+
this.logger.trace("PerformanceClient: Event not found for", correlationId);
|
|
8255
8418
|
}
|
|
8256
8419
|
};
|
|
8257
8420
|
/**
|
|
@@ -8264,117 +8427,35 @@
|
|
|
8264
8427
|
* @param {PerformanceEvent} event
|
|
8265
8428
|
*/
|
|
8266
8429
|
PerformanceClient.prototype.cacheEventByCorrelationId = function (event) {
|
|
8267
|
-
var
|
|
8268
|
-
if (
|
|
8430
|
+
var rootEvent = this.eventsByCorrelationId.get(event.correlationId);
|
|
8431
|
+
if (rootEvent) {
|
|
8269
8432
|
this.logger.trace("PerformanceClient: Performance measurement for " + event.name + " added/updated", event.correlationId);
|
|
8270
|
-
|
|
8433
|
+
rootEvent.incompleteSubMeasurements = rootEvent.incompleteSubMeasurements || new Map();
|
|
8434
|
+
rootEvent.incompleteSubMeasurements.set(event.eventId, { name: event.name, startTimeMs: event.startTimeMs });
|
|
8271
8435
|
}
|
|
8272
8436
|
else {
|
|
8273
8437
|
this.logger.trace("PerformanceClient: Performance measurement for " + event.name + " started", event.correlationId);
|
|
8274
|
-
this.eventsByCorrelationId.set(event.correlationId,
|
|
8438
|
+
this.eventsByCorrelationId.set(event.correlationId, __assign({}, event));
|
|
8275
8439
|
}
|
|
8276
8440
|
};
|
|
8277
|
-
|
|
8278
|
-
* Cache measurements by their id.
|
|
8279
|
-
*
|
|
8280
|
-
* @private
|
|
8281
|
-
* @param {PerformanceEvent} event
|
|
8282
|
-
* @param {IPerformanceMeasurement} measurement
|
|
8283
|
-
*/
|
|
8284
|
-
PerformanceClient.prototype.cacheMeasurement = function (event, measurement) {
|
|
8285
|
-
this.measurementsById.set(event.eventId, measurement);
|
|
8286
|
-
};
|
|
8287
|
-
/**
|
|
8288
|
-
* Gathers and emits performance events for measurements taked for the given top-level API and correlation ID.
|
|
8289
|
-
*
|
|
8290
|
-
* @param {PerformanceEvents} measureName
|
|
8291
|
-
* @param {string} correlationId
|
|
8292
|
-
*/
|
|
8293
|
-
PerformanceClient.prototype.flushMeasurements = function (measureName, correlationId) {
|
|
8294
|
-
var _this = this;
|
|
8295
|
-
this.logger.trace("PerformanceClient: Performance measurements flushed for " + measureName, correlationId);
|
|
8296
|
-
/**
|
|
8297
|
-
* Adds all queue time and count measurements for given correlation ID
|
|
8298
|
-
* then deletes queue times for given correlation ID from queueMeasurements map.
|
|
8299
|
-
*/
|
|
8441
|
+
PerformanceClient.prototype.getQueueInfo = function (correlationId) {
|
|
8300
8442
|
var queueMeasurementForCorrelationId = this.queueMeasurements.get(correlationId);
|
|
8301
8443
|
if (!queueMeasurementForCorrelationId) {
|
|
8302
8444
|
this.logger.trace("PerformanceClient: no queue measurements found for for correlationId: " + correlationId);
|
|
8303
8445
|
}
|
|
8304
8446
|
var totalQueueTime = 0;
|
|
8305
8447
|
var totalQueueCount = 0;
|
|
8448
|
+
var manuallyCompletedCount = 0;
|
|
8306
8449
|
queueMeasurementForCorrelationId === null || queueMeasurementForCorrelationId === void 0 ? void 0 : queueMeasurementForCorrelationId.forEach(function (measurement) {
|
|
8307
8450
|
totalQueueTime += measurement.queueTime;
|
|
8308
8451
|
totalQueueCount++;
|
|
8452
|
+
manuallyCompletedCount += measurement.manuallyCompleted ? 1 : 0;
|
|
8309
8453
|
});
|
|
8310
|
-
|
|
8311
|
-
|
|
8312
|
-
|
|
8313
|
-
|
|
8314
|
-
|
|
8315
|
-
/*
|
|
8316
|
-
* Manually end incomplete submeasurements to ensure there arent orphaned/never ending events.
|
|
8317
|
-
* Incomplete submeasurements are likely an instrumentation bug that should be fixed.
|
|
8318
|
-
* IE only supports Map.forEach.
|
|
8319
|
-
*/
|
|
8320
|
-
var completedEvents_1 = [];
|
|
8321
|
-
var incompleteSubsCount_1 = 0;
|
|
8322
|
-
eventsForCorrelationId.forEach(function (event) {
|
|
8323
|
-
if (event.name !== measureName && event.status !== PerformanceEventStatus.Completed) {
|
|
8324
|
-
_this.logger.trace("PerformanceClient: Incomplete submeasurement " + event.name + " found for " + measureName, correlationId);
|
|
8325
|
-
incompleteSubsCount_1++;
|
|
8326
|
-
var completedEvent = _this.endMeasurement(event);
|
|
8327
|
-
if (completedEvent) {
|
|
8328
|
-
completedEvents_1.push(completedEvent);
|
|
8329
|
-
}
|
|
8330
|
-
}
|
|
8331
|
-
completedEvents_1.push(event);
|
|
8332
|
-
});
|
|
8333
|
-
// Sort events by start time (earliest first)
|
|
8334
|
-
var sortedCompletedEvents = completedEvents_1.sort(function (eventA, eventB) { return eventA.startTimeMs - eventB.startTimeMs; });
|
|
8335
|
-
// Take completed top level event and add completed submeasurements durations as properties
|
|
8336
|
-
var topLevelEvents = sortedCompletedEvents.filter(function (event) { return event.name === measureName && event.status === PerformanceEventStatus.Completed; });
|
|
8337
|
-
if (topLevelEvents.length > 0) {
|
|
8338
|
-
/*
|
|
8339
|
-
* Only take the first top-level event if there are multiple events with the same correlation id.
|
|
8340
|
-
* This greatly simplifies logic for submeasurements.
|
|
8341
|
-
*/
|
|
8342
|
-
if (topLevelEvents.length > 1) {
|
|
8343
|
-
this.logger.verbose("PerformanceClient: Multiple distinct top-level performance events found, using the first", correlationId);
|
|
8344
|
-
}
|
|
8345
|
-
var topLevelEvent = topLevelEvents[0];
|
|
8346
|
-
this.logger.verbose("PerformanceClient: Measurement found for " + measureName, correlationId);
|
|
8347
|
-
// Build event object with top level and sub measurements
|
|
8348
|
-
var eventToEmit = sortedCompletedEvents.reduce(function (previous, current) {
|
|
8349
|
-
if (current.name !== measureName) {
|
|
8350
|
-
_this.logger.trace("PerformanceClient: Complete submeasurement found for " + current.name, correlationId);
|
|
8351
|
-
// TODO: Emit additional properties for each subMeasurement
|
|
8352
|
-
var subMeasurementName = current.name + "DurationMs";
|
|
8353
|
-
/*
|
|
8354
|
-
* Some code paths, such as resolving an authority, can occur multiple times.
|
|
8355
|
-
* Only take the first measurement, since the second could be read from the cache,
|
|
8356
|
-
* or due to the same correlation id being used for two distinct requests.
|
|
8357
|
-
*/
|
|
8358
|
-
if (!previous[subMeasurementName]) {
|
|
8359
|
-
previous[subMeasurementName] = current.durationMs;
|
|
8360
|
-
}
|
|
8361
|
-
else {
|
|
8362
|
-
_this.logger.verbose("PerformanceClient: Submeasurement for " + measureName + " already exists for " + current.name + ", ignoring", correlationId);
|
|
8363
|
-
}
|
|
8364
|
-
}
|
|
8365
|
-
return previous;
|
|
8366
|
-
}, topLevelEvent);
|
|
8367
|
-
var finalEvent = __assign(__assign(__assign(__assign({}, eventToEmit), staticFields), counters), { queuedTimeMs: totalQueueTime, queuedCount: totalQueueCount, incompleteSubsCount: incompleteSubsCount_1 });
|
|
8368
|
-
this.truncateIntegralFields(finalEvent, this.getIntFields());
|
|
8369
|
-
this.emitEvents([finalEvent], eventToEmit.correlationId);
|
|
8370
|
-
}
|
|
8371
|
-
else {
|
|
8372
|
-
this.logger.verbose("PerformanceClient: No completed top-level measurements found for " + measureName, correlationId);
|
|
8373
|
-
}
|
|
8374
|
-
}
|
|
8375
|
-
else {
|
|
8376
|
-
this.logger.verbose("PerformanceClient: No measurements found", correlationId);
|
|
8377
|
-
}
|
|
8454
|
+
return {
|
|
8455
|
+
totalQueueTime: totalQueueTime,
|
|
8456
|
+
totalQueueCount: totalQueueCount,
|
|
8457
|
+
manuallyCompletedCount: manuallyCompletedCount
|
|
8458
|
+
};
|
|
8378
8459
|
};
|
|
8379
8460
|
/**
|
|
8380
8461
|
* Removes measurements for a given correlation id.
|
|
@@ -8388,14 +8469,10 @@
|
|
|
8388
8469
|
/**
|
|
8389
8470
|
* Removes cache for a given correlation id.
|
|
8390
8471
|
*
|
|
8391
|
-
* @param {string} correlation identifier
|
|
8472
|
+
* @param {string} correlationId correlation identifier
|
|
8392
8473
|
*/
|
|
8393
8474
|
PerformanceClient.prototype.discardCache = function (correlationId) {
|
|
8394
8475
|
this.discardMeasurements(correlationId);
|
|
8395
|
-
this.logger.trace("PerformanceClient: Static fields discarded", correlationId);
|
|
8396
|
-
this.staticFieldsByCorrelationId.delete(correlationId);
|
|
8397
|
-
this.logger.trace("PerformanceClient: Counters discarded", correlationId);
|
|
8398
|
-
this.countersByCorrelationId.delete(correlationId);
|
|
8399
8476
|
this.logger.trace("PerformanceClient: QueueMeasurements discarded", correlationId);
|
|
8400
8477
|
this.queueMeasurements.delete(correlationId);
|
|
8401
8478
|
this.logger.trace("PerformanceClient: Pre-queue times discarded", correlationId);
|
|
@@ -8458,7 +8535,7 @@
|
|
|
8458
8535
|
return PerformanceClient;
|
|
8459
8536
|
}());
|
|
8460
8537
|
|
|
8461
|
-
/*! @azure/msal-common
|
|
8538
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
8462
8539
|
|
|
8463
8540
|
/*
|
|
8464
8541
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -8661,6 +8738,10 @@
|
|
|
8661
8738
|
code: "auth_code_or_nativeAccountId_required",
|
|
8662
8739
|
desc: "An authorization code or nativeAccountId must be provided to this flow."
|
|
8663
8740
|
},
|
|
8741
|
+
spaCodeAndNativeAccountPresent: {
|
|
8742
|
+
code: "spa_code_and_nativeAccountId_present",
|
|
8743
|
+
desc: "Request cannot contain both spa code and native account id."
|
|
8744
|
+
},
|
|
8664
8745
|
databaseUnavailable: {
|
|
8665
8746
|
code: "database_unavailable",
|
|
8666
8747
|
desc: "IndexedDB, which is required for persistent cryptographic key storage, is unavailable. This may be caused by browser privacy features which block persistent storage in third-party contexts."
|
|
@@ -8933,6 +9014,12 @@
|
|
|
8933
9014
|
BrowserAuthError.createAuthCodeOrNativeAccountIdRequiredError = function () {
|
|
8934
9015
|
return new BrowserAuthError(BrowserAuthErrorMessage.authCodeOrNativeAccountRequired.code, BrowserAuthErrorMessage.authCodeOrNativeAccountRequired.desc);
|
|
8935
9016
|
};
|
|
9017
|
+
/**
|
|
9018
|
+
* Create an error when both authorization code and native account ID are provided
|
|
9019
|
+
*/
|
|
9020
|
+
BrowserAuthError.createSpaCodeAndNativeAccountIdPresentError = function () {
|
|
9021
|
+
return new BrowserAuthError(BrowserAuthErrorMessage.spaCodeAndNativeAccountPresent.code, BrowserAuthErrorMessage.spaCodeAndNativeAccountPresent.desc);
|
|
9022
|
+
};
|
|
8936
9023
|
/**
|
|
8937
9024
|
* Create an error when IndexedDB is unavailable
|
|
8938
9025
|
*/
|
|
@@ -9064,6 +9151,11 @@
|
|
|
9064
9151
|
TemporaryCacheKeys["NATIVE_REQUEST"] = "request.native";
|
|
9065
9152
|
TemporaryCacheKeys["REDIRECT_CONTEXT"] = "request.redirect.context";
|
|
9066
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 = {}));
|
|
9067
9159
|
/**
|
|
9068
9160
|
* Cache keys stored in-memory
|
|
9069
9161
|
*/
|
|
@@ -9409,7 +9501,7 @@
|
|
|
9409
9501
|
var BrowserCacheManager = /** @class */ (function (_super) {
|
|
9410
9502
|
__extends$1(BrowserCacheManager, _super);
|
|
9411
9503
|
function BrowserCacheManager(clientId, cacheConfig, cryptoImpl, logger) {
|
|
9412
|
-
var _this = _super.call(this, clientId, cryptoImpl) || this;
|
|
9504
|
+
var _this = _super.call(this, clientId, cryptoImpl, logger) || this;
|
|
9413
9505
|
// Cookie life calculation (hours * minutes * seconds * ms)
|
|
9414
9506
|
_this.COOKIE_LIFE_MULTIPLIER = 24 * 60 * 60 * 1000;
|
|
9415
9507
|
_this.cacheConfig = cacheConfig;
|
|
@@ -9417,8 +9509,11 @@
|
|
|
9417
9509
|
_this.internalStorage = new MemoryStorage();
|
|
9418
9510
|
_this.browserStorage = _this.setupBrowserStorage(_this.cacheConfig.cacheLocation);
|
|
9419
9511
|
_this.temporaryCacheStorage = _this.setupTemporaryCacheStorage(_this.cacheConfig.cacheLocation);
|
|
9420
|
-
// Migrate
|
|
9421
|
-
|
|
9512
|
+
// Migrate cache entries from older versions of MSAL.
|
|
9513
|
+
if (cacheConfig.cacheMigrationEnabled) {
|
|
9514
|
+
_this.migrateCacheEntries();
|
|
9515
|
+
_this.createKeyMaps();
|
|
9516
|
+
}
|
|
9422
9517
|
return _this;
|
|
9423
9518
|
}
|
|
9424
9519
|
/**
|
|
@@ -9492,6 +9587,91 @@
|
|
|
9492
9587
|
this.setTemporaryCache(newKey, value, true);
|
|
9493
9588
|
}
|
|
9494
9589
|
};
|
|
9590
|
+
/**
|
|
9591
|
+
* Searches all cache entries for MSAL accounts and creates the account key map
|
|
9592
|
+
* This is used to migrate users from older versions of MSAL which did not create the map.
|
|
9593
|
+
* @returns
|
|
9594
|
+
*/
|
|
9595
|
+
BrowserCacheManager.prototype.createKeyMaps = function () {
|
|
9596
|
+
var _this = this;
|
|
9597
|
+
this.logger.trace("BrowserCacheManager - createKeyMaps called.");
|
|
9598
|
+
var accountKeys = this.getItem(StaticCacheKeys.ACCOUNT_KEYS);
|
|
9599
|
+
var tokenKeys = this.getItem(StaticCacheKeys.TOKEN_KEYS + "." + this.clientId);
|
|
9600
|
+
if (accountKeys && tokenKeys) {
|
|
9601
|
+
this.logger.verbose("BrowserCacheManager:createKeyMaps - account and token key maps already exist, skipping migration.");
|
|
9602
|
+
// Key maps already exist, no need to iterate through cache
|
|
9603
|
+
return;
|
|
9604
|
+
}
|
|
9605
|
+
var allKeys = this.browserStorage.getKeys();
|
|
9606
|
+
allKeys.forEach(function (key) {
|
|
9607
|
+
if (_this.isCredentialKey(key)) {
|
|
9608
|
+
// Get item, parse, validate and write key to map
|
|
9609
|
+
var value = _this.getItem(key);
|
|
9610
|
+
if (value) {
|
|
9611
|
+
var credObj = _this.validateAndParseJson(value);
|
|
9612
|
+
if (credObj && credObj.hasOwnProperty("credentialType")) {
|
|
9613
|
+
switch (credObj["credentialType"]) {
|
|
9614
|
+
case CredentialType.ID_TOKEN:
|
|
9615
|
+
if (IdTokenEntity.isIdTokenEntity(credObj)) {
|
|
9616
|
+
_this.logger.trace("BrowserCacheManager:createKeyMaps - idToken found, saving key to token key map");
|
|
9617
|
+
_this.logger.tracePii("BrowserCacheManager:createKeyMaps - idToken with key: " + key + " found, saving key to token key map");
|
|
9618
|
+
var idTokenEntity = CacheManager.toObject(new IdTokenEntity(), credObj);
|
|
9619
|
+
var newKey = _this.updateCredentialCacheKey(key, idTokenEntity);
|
|
9620
|
+
_this.addTokenKey(newKey, CredentialType.ID_TOKEN);
|
|
9621
|
+
return;
|
|
9622
|
+
}
|
|
9623
|
+
else {
|
|
9624
|
+
_this.logger.trace("BrowserCacheManager:createKeyMaps - key found matching idToken schema with value containing idToken credentialType field but value failed IdTokenEntity validation, skipping.");
|
|
9625
|
+
_this.logger.tracePii("BrowserCacheManager:createKeyMaps - failed idToken validation on key: " + key);
|
|
9626
|
+
}
|
|
9627
|
+
break;
|
|
9628
|
+
case CredentialType.ACCESS_TOKEN:
|
|
9629
|
+
case CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME:
|
|
9630
|
+
if (AccessTokenEntity.isAccessTokenEntity(credObj)) {
|
|
9631
|
+
_this.logger.trace("BrowserCacheManager:createKeyMaps - accessToken found, saving key to token key map");
|
|
9632
|
+
_this.logger.tracePii("BrowserCacheManager:createKeyMaps - accessToken with key: " + key + " found, saving key to token key map");
|
|
9633
|
+
var accessTokenEntity = CacheManager.toObject(new AccessTokenEntity(), credObj);
|
|
9634
|
+
var newKey = _this.updateCredentialCacheKey(key, accessTokenEntity);
|
|
9635
|
+
_this.addTokenKey(newKey, CredentialType.ACCESS_TOKEN);
|
|
9636
|
+
return;
|
|
9637
|
+
}
|
|
9638
|
+
else {
|
|
9639
|
+
_this.logger.trace("BrowserCacheManager:createKeyMaps - key found matching accessToken schema with value containing accessToken credentialType field but value failed AccessTokenEntity validation, skipping.");
|
|
9640
|
+
_this.logger.tracePii("BrowserCacheManager:createKeyMaps - failed accessToken validation on key: " + key);
|
|
9641
|
+
}
|
|
9642
|
+
break;
|
|
9643
|
+
case CredentialType.REFRESH_TOKEN:
|
|
9644
|
+
if (RefreshTokenEntity.isRefreshTokenEntity(credObj)) {
|
|
9645
|
+
_this.logger.trace("BrowserCacheManager:createKeyMaps - refreshToken found, saving key to token key map");
|
|
9646
|
+
_this.logger.tracePii("BrowserCacheManager:createKeyMaps - refreshToken with key: " + key + " found, saving key to token key map");
|
|
9647
|
+
var refreshTokenEntity = CacheManager.toObject(new RefreshTokenEntity(), credObj);
|
|
9648
|
+
var newKey = _this.updateCredentialCacheKey(key, refreshTokenEntity);
|
|
9649
|
+
_this.addTokenKey(newKey, CredentialType.REFRESH_TOKEN);
|
|
9650
|
+
return;
|
|
9651
|
+
}
|
|
9652
|
+
else {
|
|
9653
|
+
_this.logger.trace("BrowserCacheManager:createKeyMaps - key found matching refreshToken schema with value containing refreshToken credentialType field but value failed RefreshTokenEntity validation, skipping.");
|
|
9654
|
+
_this.logger.tracePii("BrowserCacheManager:createKeyMaps - failed refreshToken validation on key: " + key);
|
|
9655
|
+
}
|
|
9656
|
+
break;
|
|
9657
|
+
// If credentialType isn't one of our predefined ones, it may not be an MSAL cache value. Ignore.
|
|
9658
|
+
}
|
|
9659
|
+
}
|
|
9660
|
+
}
|
|
9661
|
+
}
|
|
9662
|
+
if (_this.isAccountKey(key)) {
|
|
9663
|
+
var value = _this.getItem(key);
|
|
9664
|
+
if (value) {
|
|
9665
|
+
var accountObj = _this.validateAndParseJson(value);
|
|
9666
|
+
if (accountObj && AccountEntity.isAccountEntity(accountObj)) {
|
|
9667
|
+
_this.logger.trace("BrowserCacheManager:createKeyMaps - account found, saving key to account key map");
|
|
9668
|
+
_this.logger.tracePii("BrowserCacheManager:createKeyMaps - account with key: " + key + " found, saving key to account key map");
|
|
9669
|
+
_this.addAccountKeyToMap(key);
|
|
9670
|
+
}
|
|
9671
|
+
}
|
|
9672
|
+
}
|
|
9673
|
+
});
|
|
9674
|
+
};
|
|
9495
9675
|
/**
|
|
9496
9676
|
* Parses passed value as JSON object, JSON.parse() will throw an error.
|
|
9497
9677
|
* @param input
|
|
@@ -9531,12 +9711,15 @@
|
|
|
9531
9711
|
* @param accountKey
|
|
9532
9712
|
*/
|
|
9533
9713
|
BrowserCacheManager.prototype.getAccount = function (accountKey) {
|
|
9714
|
+
this.logger.trace("BrowserCacheManager.getAccount called");
|
|
9534
9715
|
var account = this.getItem(accountKey);
|
|
9535
9716
|
if (!account) {
|
|
9717
|
+
this.removeAccountKeyFromMap(accountKey);
|
|
9536
9718
|
return null;
|
|
9537
9719
|
}
|
|
9538
9720
|
var parsedAccount = this.validateAndParseJson(account);
|
|
9539
9721
|
if (!parsedAccount || !AccountEntity.isAccountEntity(parsedAccount)) {
|
|
9722
|
+
this.removeAccountKeyFromMap(accountKey);
|
|
9540
9723
|
return null;
|
|
9541
9724
|
}
|
|
9542
9725
|
return CacheManager.toObject(new AccountEntity(), parsedAccount);
|
|
@@ -9550,6 +9733,207 @@
|
|
|
9550
9733
|
this.logger.trace("BrowserCacheManager.setAccount called");
|
|
9551
9734
|
var key = account.generateAccountKey();
|
|
9552
9735
|
this.setItem(key, JSON.stringify(account));
|
|
9736
|
+
this.addAccountKeyToMap(key);
|
|
9737
|
+
};
|
|
9738
|
+
/**
|
|
9739
|
+
* Returns the array of account keys currently cached
|
|
9740
|
+
* @returns
|
|
9741
|
+
*/
|
|
9742
|
+
BrowserCacheManager.prototype.getAccountKeys = function () {
|
|
9743
|
+
this.logger.trace("BrowserCacheManager.getAccountKeys called");
|
|
9744
|
+
var accountKeys = this.getItem(StaticCacheKeys.ACCOUNT_KEYS);
|
|
9745
|
+
if (accountKeys) {
|
|
9746
|
+
return JSON.parse(accountKeys);
|
|
9747
|
+
}
|
|
9748
|
+
this.logger.verbose("BrowserCacheManager.getAccountKeys - No account keys found");
|
|
9749
|
+
return [];
|
|
9750
|
+
};
|
|
9751
|
+
/**
|
|
9752
|
+
* Add a new account to the key map
|
|
9753
|
+
* @param key
|
|
9754
|
+
*/
|
|
9755
|
+
BrowserCacheManager.prototype.addAccountKeyToMap = function (key) {
|
|
9756
|
+
this.logger.trace("BrowserCacheManager.addAccountKeyToMap called");
|
|
9757
|
+
this.logger.tracePii("BrowserCacheManager.addAccountKeyToMap called with key: " + key);
|
|
9758
|
+
var accountKeys = this.getAccountKeys();
|
|
9759
|
+
if (accountKeys.indexOf(key) === -1) {
|
|
9760
|
+
// Only add key if it does not already exist in the map
|
|
9761
|
+
accountKeys.push(key);
|
|
9762
|
+
this.setItem(StaticCacheKeys.ACCOUNT_KEYS, JSON.stringify(accountKeys));
|
|
9763
|
+
this.logger.verbose("BrowserCacheManager.addAccountKeyToMap account key added");
|
|
9764
|
+
}
|
|
9765
|
+
else {
|
|
9766
|
+
this.logger.verbose("BrowserCacheManager.addAccountKeyToMap account key already exists in map");
|
|
9767
|
+
}
|
|
9768
|
+
};
|
|
9769
|
+
/**
|
|
9770
|
+
* Remove an account from the key map
|
|
9771
|
+
* @param key
|
|
9772
|
+
*/
|
|
9773
|
+
BrowserCacheManager.prototype.removeAccountKeyFromMap = function (key) {
|
|
9774
|
+
this.logger.trace("BrowserCacheManager.removeAccountKeyFromMap called");
|
|
9775
|
+
this.logger.tracePii("BrowserCacheManager.removeAccountKeyFromMap called with key: " + key);
|
|
9776
|
+
var accountKeys = this.getAccountKeys();
|
|
9777
|
+
var removalIndex = accountKeys.indexOf(key);
|
|
9778
|
+
if (removalIndex > -1) {
|
|
9779
|
+
accountKeys.splice(removalIndex, 1);
|
|
9780
|
+
this.setItem(StaticCacheKeys.ACCOUNT_KEYS, JSON.stringify(accountKeys));
|
|
9781
|
+
this.logger.trace("BrowserCacheManager.removeAccountKeyFromMap account key removed");
|
|
9782
|
+
}
|
|
9783
|
+
else {
|
|
9784
|
+
this.logger.trace("BrowserCacheManager.removeAccountKeyFromMap key not found in existing map");
|
|
9785
|
+
}
|
|
9786
|
+
};
|
|
9787
|
+
/**
|
|
9788
|
+
* Extends inherited removeAccount function to include removal of the account key from the map
|
|
9789
|
+
* @param key
|
|
9790
|
+
*/
|
|
9791
|
+
BrowserCacheManager.prototype.removeAccount = function (key) {
|
|
9792
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
9793
|
+
return __generator$1(this, function (_a) {
|
|
9794
|
+
_super.prototype.removeAccount.call(this, key);
|
|
9795
|
+
this.removeAccountKeyFromMap(key);
|
|
9796
|
+
return [2 /*return*/];
|
|
9797
|
+
});
|
|
9798
|
+
});
|
|
9799
|
+
};
|
|
9800
|
+
/**
|
|
9801
|
+
* Removes given idToken from the cache and from the key map
|
|
9802
|
+
* @param key
|
|
9803
|
+
*/
|
|
9804
|
+
BrowserCacheManager.prototype.removeIdToken = function (key) {
|
|
9805
|
+
_super.prototype.removeIdToken.call(this, key);
|
|
9806
|
+
this.removeTokenKey(key, CredentialType.ID_TOKEN);
|
|
9807
|
+
};
|
|
9808
|
+
/**
|
|
9809
|
+
* Removes given accessToken from the cache and from the key map
|
|
9810
|
+
* @param key
|
|
9811
|
+
*/
|
|
9812
|
+
BrowserCacheManager.prototype.removeAccessToken = function (key) {
|
|
9813
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
9814
|
+
return __generator$1(this, function (_a) {
|
|
9815
|
+
_super.prototype.removeAccessToken.call(this, key);
|
|
9816
|
+
this.removeTokenKey(key, CredentialType.ACCESS_TOKEN);
|
|
9817
|
+
return [2 /*return*/];
|
|
9818
|
+
});
|
|
9819
|
+
});
|
|
9820
|
+
};
|
|
9821
|
+
/**
|
|
9822
|
+
* Removes given refreshToken from the cache and from the key map
|
|
9823
|
+
* @param key
|
|
9824
|
+
*/
|
|
9825
|
+
BrowserCacheManager.prototype.removeRefreshToken = function (key) {
|
|
9826
|
+
_super.prototype.removeRefreshToken.call(this, key);
|
|
9827
|
+
this.removeTokenKey(key, CredentialType.REFRESH_TOKEN);
|
|
9828
|
+
};
|
|
9829
|
+
/**
|
|
9830
|
+
* Gets the keys for the cached tokens associated with this clientId
|
|
9831
|
+
* @returns
|
|
9832
|
+
*/
|
|
9833
|
+
BrowserCacheManager.prototype.getTokenKeys = function () {
|
|
9834
|
+
this.logger.trace("BrowserCacheManager.getTokenKeys called");
|
|
9835
|
+
var item = this.getItem(StaticCacheKeys.TOKEN_KEYS + "." + this.clientId);
|
|
9836
|
+
if (item) {
|
|
9837
|
+
var tokenKeys = this.validateAndParseJson(item);
|
|
9838
|
+
if (tokenKeys &&
|
|
9839
|
+
tokenKeys.hasOwnProperty("idToken") &&
|
|
9840
|
+
tokenKeys.hasOwnProperty("accessToken") &&
|
|
9841
|
+
tokenKeys.hasOwnProperty("refreshToken")) {
|
|
9842
|
+
return tokenKeys;
|
|
9843
|
+
}
|
|
9844
|
+
else {
|
|
9845
|
+
this.logger.error("BrowserCacheManager.getTokenKeys - Token keys found but in an unknown format. Returning empty key map.");
|
|
9846
|
+
}
|
|
9847
|
+
}
|
|
9848
|
+
else {
|
|
9849
|
+
this.logger.verbose("BrowserCacheManager.getTokenKeys - No token keys found");
|
|
9850
|
+
}
|
|
9851
|
+
return {
|
|
9852
|
+
idToken: [],
|
|
9853
|
+
accessToken: [],
|
|
9854
|
+
refreshToken: []
|
|
9855
|
+
};
|
|
9856
|
+
};
|
|
9857
|
+
/**
|
|
9858
|
+
* Adds the given key to the token key map
|
|
9859
|
+
* @param key
|
|
9860
|
+
* @param type
|
|
9861
|
+
*/
|
|
9862
|
+
BrowserCacheManager.prototype.addTokenKey = function (key, type) {
|
|
9863
|
+
this.logger.trace("BrowserCacheManager addTokenKey called");
|
|
9864
|
+
var tokenKeys = this.getTokenKeys();
|
|
9865
|
+
switch (type) {
|
|
9866
|
+
case CredentialType.ID_TOKEN:
|
|
9867
|
+
if (tokenKeys.idToken.indexOf(key) === -1) {
|
|
9868
|
+
this.logger.info("BrowserCacheManager: addTokenKey - idToken added to map");
|
|
9869
|
+
tokenKeys.idToken.push(key);
|
|
9870
|
+
}
|
|
9871
|
+
break;
|
|
9872
|
+
case CredentialType.ACCESS_TOKEN:
|
|
9873
|
+
if (tokenKeys.accessToken.indexOf(key) === -1) {
|
|
9874
|
+
this.logger.info("BrowserCacheManager: addTokenKey - accessToken added to map");
|
|
9875
|
+
tokenKeys.accessToken.push(key);
|
|
9876
|
+
}
|
|
9877
|
+
break;
|
|
9878
|
+
case CredentialType.REFRESH_TOKEN:
|
|
9879
|
+
if (tokenKeys.refreshToken.indexOf(key) === -1) {
|
|
9880
|
+
this.logger.info("BrowserCacheManager: addTokenKey - refreshToken added to map");
|
|
9881
|
+
tokenKeys.refreshToken.push(key);
|
|
9882
|
+
}
|
|
9883
|
+
break;
|
|
9884
|
+
default:
|
|
9885
|
+
this.logger.error("BrowserCacheManager:addTokenKey - CredentialType provided invalid. CredentialType: " + type);
|
|
9886
|
+
ClientAuthError.createUnexpectedCredentialTypeError();
|
|
9887
|
+
}
|
|
9888
|
+
this.setItem(StaticCacheKeys.TOKEN_KEYS + "." + this.clientId, JSON.stringify(tokenKeys));
|
|
9889
|
+
};
|
|
9890
|
+
/**
|
|
9891
|
+
* Removes the given key from the token key map
|
|
9892
|
+
* @param key
|
|
9893
|
+
* @param type
|
|
9894
|
+
*/
|
|
9895
|
+
BrowserCacheManager.prototype.removeTokenKey = function (key, type) {
|
|
9896
|
+
this.logger.trace("BrowserCacheManager removeTokenKey called");
|
|
9897
|
+
var tokenKeys = this.getTokenKeys();
|
|
9898
|
+
switch (type) {
|
|
9899
|
+
case CredentialType.ID_TOKEN:
|
|
9900
|
+
this.logger.infoPii("BrowserCacheManager: removeTokenKey - attempting to remove idToken with key: " + key + " from map");
|
|
9901
|
+
var idRemoval = tokenKeys.idToken.indexOf(key);
|
|
9902
|
+
if (idRemoval > -1) {
|
|
9903
|
+
this.logger.info("BrowserCacheManager: removeTokenKey - idToken removed from map");
|
|
9904
|
+
tokenKeys.idToken.splice(idRemoval, 1);
|
|
9905
|
+
}
|
|
9906
|
+
else {
|
|
9907
|
+
this.logger.info("BrowserCacheManager: removeTokenKey - idToken does not exist in map. Either it was previously removed or it was never added.");
|
|
9908
|
+
}
|
|
9909
|
+
break;
|
|
9910
|
+
case CredentialType.ACCESS_TOKEN:
|
|
9911
|
+
this.logger.infoPii("BrowserCacheManager: removeTokenKey - attempting to remove accessToken with key: " + key + " from map");
|
|
9912
|
+
var accessRemoval = tokenKeys.accessToken.indexOf(key);
|
|
9913
|
+
if (accessRemoval > -1) {
|
|
9914
|
+
this.logger.info("BrowserCacheManager: removeTokenKey - accessToken removed from map");
|
|
9915
|
+
tokenKeys.idToken.splice(accessRemoval, 1);
|
|
9916
|
+
}
|
|
9917
|
+
else {
|
|
9918
|
+
this.logger.info("BrowserCacheManager: removeTokenKey - accessToken does not exist in map. Either it was previously removed or it was never added.");
|
|
9919
|
+
}
|
|
9920
|
+
break;
|
|
9921
|
+
case CredentialType.REFRESH_TOKEN:
|
|
9922
|
+
this.logger.infoPii("BrowserCacheManager: removeTokenKey - attempting to remove refreshToken with key: " + key + " from map");
|
|
9923
|
+
var refreshRemoval = tokenKeys.refreshToken.indexOf(key);
|
|
9924
|
+
if (refreshRemoval > -1) {
|
|
9925
|
+
this.logger.info("BrowserCacheManager: removeTokenKey - refreshToken removed from map");
|
|
9926
|
+
tokenKeys.idToken.splice(refreshRemoval, 1);
|
|
9927
|
+
}
|
|
9928
|
+
else {
|
|
9929
|
+
this.logger.info("BrowserCacheManager: removeTokenKey - refreshToken does not exist in map. Either it was previously removed or it was never added.");
|
|
9930
|
+
}
|
|
9931
|
+
break;
|
|
9932
|
+
default:
|
|
9933
|
+
this.logger.error("BrowserCacheManager:removeTokenKey - CredentialType provided invalid. CredentialType: " + type);
|
|
9934
|
+
ClientAuthError.createUnexpectedCredentialTypeError();
|
|
9935
|
+
}
|
|
9936
|
+
this.setItem(StaticCacheKeys.TOKEN_KEYS + "." + this.clientId, JSON.stringify(tokenKeys));
|
|
9553
9937
|
};
|
|
9554
9938
|
/**
|
|
9555
9939
|
* generates idToken entity from a string
|
|
@@ -9559,11 +9943,13 @@
|
|
|
9559
9943
|
var value = this.getItem(idTokenKey);
|
|
9560
9944
|
if (!value) {
|
|
9561
9945
|
this.logger.trace("BrowserCacheManager.getIdTokenCredential: called, no cache hit");
|
|
9946
|
+
this.removeTokenKey(idTokenKey, CredentialType.ID_TOKEN);
|
|
9562
9947
|
return null;
|
|
9563
9948
|
}
|
|
9564
9949
|
var parsedIdToken = this.validateAndParseJson(value);
|
|
9565
9950
|
if (!parsedIdToken || !IdTokenEntity.isIdTokenEntity(parsedIdToken)) {
|
|
9566
9951
|
this.logger.trace("BrowserCacheManager.getIdTokenCredential: called, no cache hit");
|
|
9952
|
+
this.removeTokenKey(idTokenKey, CredentialType.ID_TOKEN);
|
|
9567
9953
|
return null;
|
|
9568
9954
|
}
|
|
9569
9955
|
this.logger.trace("BrowserCacheManager.getIdTokenCredential: cache hit");
|
|
@@ -9577,6 +9963,7 @@
|
|
|
9577
9963
|
this.logger.trace("BrowserCacheManager.setIdTokenCredential called");
|
|
9578
9964
|
var idTokenKey = idToken.generateCredentialKey();
|
|
9579
9965
|
this.setItem(idTokenKey, JSON.stringify(idToken));
|
|
9966
|
+
this.addTokenKey(idTokenKey, CredentialType.ID_TOKEN);
|
|
9580
9967
|
};
|
|
9581
9968
|
/**
|
|
9582
9969
|
* generates accessToken entity from a string
|
|
@@ -9586,11 +9973,13 @@
|
|
|
9586
9973
|
var value = this.getItem(accessTokenKey);
|
|
9587
9974
|
if (!value) {
|
|
9588
9975
|
this.logger.trace("BrowserCacheManager.getAccessTokenCredential: called, no cache hit");
|
|
9976
|
+
this.removeTokenKey(accessTokenKey, CredentialType.ACCESS_TOKEN);
|
|
9589
9977
|
return null;
|
|
9590
9978
|
}
|
|
9591
9979
|
var parsedAccessToken = this.validateAndParseJson(value);
|
|
9592
9980
|
if (!parsedAccessToken || !AccessTokenEntity.isAccessTokenEntity(parsedAccessToken)) {
|
|
9593
9981
|
this.logger.trace("BrowserCacheManager.getAccessTokenCredential: called, no cache hit");
|
|
9982
|
+
this.removeTokenKey(accessTokenKey, CredentialType.ACCESS_TOKEN);
|
|
9594
9983
|
return null;
|
|
9595
9984
|
}
|
|
9596
9985
|
this.logger.trace("BrowserCacheManager.getAccessTokenCredential: cache hit");
|
|
@@ -9604,6 +9993,7 @@
|
|
|
9604
9993
|
this.logger.trace("BrowserCacheManager.setAccessTokenCredential called");
|
|
9605
9994
|
var accessTokenKey = accessToken.generateCredentialKey();
|
|
9606
9995
|
this.setItem(accessTokenKey, JSON.stringify(accessToken));
|
|
9996
|
+
this.addTokenKey(accessTokenKey, CredentialType.ACCESS_TOKEN);
|
|
9607
9997
|
};
|
|
9608
9998
|
/**
|
|
9609
9999
|
* generates refreshToken entity from a string
|
|
@@ -9613,11 +10003,13 @@
|
|
|
9613
10003
|
var value = this.getItem(refreshTokenKey);
|
|
9614
10004
|
if (!value) {
|
|
9615
10005
|
this.logger.trace("BrowserCacheManager.getRefreshTokenCredential: called, no cache hit");
|
|
10006
|
+
this.removeTokenKey(refreshTokenKey, CredentialType.REFRESH_TOKEN);
|
|
9616
10007
|
return null;
|
|
9617
10008
|
}
|
|
9618
10009
|
var parsedRefreshToken = this.validateAndParseJson(value);
|
|
9619
10010
|
if (!parsedRefreshToken || !RefreshTokenEntity.isRefreshTokenEntity(parsedRefreshToken)) {
|
|
9620
10011
|
this.logger.trace("BrowserCacheManager.getRefreshTokenCredential: called, no cache hit");
|
|
10012
|
+
this.removeTokenKey(refreshTokenKey, CredentialType.REFRESH_TOKEN);
|
|
9621
10013
|
return null;
|
|
9622
10014
|
}
|
|
9623
10015
|
this.logger.trace("BrowserCacheManager.getRefreshTokenCredential: cache hit");
|
|
@@ -9631,6 +10023,7 @@
|
|
|
9631
10023
|
this.logger.trace("BrowserCacheManager.setRefreshTokenCredential called");
|
|
9632
10024
|
var refreshTokenKey = refreshToken.generateCredentialKey();
|
|
9633
10025
|
this.setItem(refreshTokenKey, JSON.stringify(refreshToken));
|
|
10026
|
+
this.addTokenKey(refreshTokenKey, CredentialType.REFRESH_TOKEN);
|
|
9634
10027
|
};
|
|
9635
10028
|
/**
|
|
9636
10029
|
* fetch appMetadata entity from the platform cache
|
|
@@ -9928,7 +10321,6 @@
|
|
|
9928
10321
|
this.logger.trace("BrowserCacheManager.removeItem: storeAuthStateInCookie is true, clearing item cookie");
|
|
9929
10322
|
this.clearItemCookie(key);
|
|
9930
10323
|
}
|
|
9931
|
-
return true;
|
|
9932
10324
|
};
|
|
9933
10325
|
/**
|
|
9934
10326
|
* Checks whether key is in cache.
|
|
@@ -10356,14 +10748,15 @@
|
|
|
10356
10748
|
var cacheOptions = {
|
|
10357
10749
|
cacheLocation: exports.BrowserCacheLocation.MemoryStorage,
|
|
10358
10750
|
storeAuthStateInCookie: false,
|
|
10359
|
-
secureCookies: false
|
|
10751
|
+
secureCookies: false,
|
|
10752
|
+
cacheMigrationEnabled: false
|
|
10360
10753
|
};
|
|
10361
10754
|
return new BrowserCacheManager(clientId, cacheOptions, DEFAULT_CRYPTO_IMPLEMENTATION, logger);
|
|
10362
10755
|
};
|
|
10363
10756
|
|
|
10364
10757
|
/* eslint-disable header/header */
|
|
10365
10758
|
var name = "@azure/msal-browser";
|
|
10366
|
-
var version = "2.
|
|
10759
|
+
var version = "2.35.0";
|
|
10367
10760
|
|
|
10368
10761
|
/*
|
|
10369
10762
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -11834,15 +12227,18 @@
|
|
|
11834
12227
|
*/
|
|
11835
12228
|
NativeInteractionClient.prototype.acquireTokensFromCache = function (nativeAccountId, request) {
|
|
11836
12229
|
return __awaiter$1(this, void 0, void 0, function () {
|
|
11837
|
-
var
|
|
12230
|
+
var account, silentRequest, result, e_2;
|
|
11838
12231
|
return __generator$1(this, function (_a) {
|
|
11839
12232
|
switch (_a.label) {
|
|
11840
12233
|
case 0:
|
|
11841
|
-
|
|
11842
|
-
|
|
12234
|
+
if (!nativeAccountId) {
|
|
12235
|
+
this.logger.warning("NativeInteractionClient:acquireTokensFromCache - No nativeAccountId provided");
|
|
12236
|
+
throw ClientAuthError.createNoAccountFoundError();
|
|
12237
|
+
}
|
|
12238
|
+
account = this.browserStorage.getAccountInfoFilteredBy({ nativeAccountId: nativeAccountId });
|
|
12239
|
+
if (!account) {
|
|
11843
12240
|
throw ClientAuthError.createNoAccountFoundError();
|
|
11844
12241
|
}
|
|
11845
|
-
account = accountEntity.getAccountInfo();
|
|
11846
12242
|
_a.label = 1;
|
|
11847
12243
|
case 1:
|
|
11848
12244
|
_a.trys.push([1, 3, , 4]);
|
|
@@ -11973,60 +12369,92 @@
|
|
|
11973
12369
|
*/
|
|
11974
12370
|
NativeInteractionClient.prototype.handleNativeResponse = function (response, request, reqTimestamp) {
|
|
11975
12371
|
return __awaiter$1(this, void 0, void 0, function () {
|
|
11976
|
-
var
|
|
11977
|
-
|
|
11978
|
-
|
|
11979
|
-
switch (_b.label) {
|
|
12372
|
+
var authority, authorityPreferredCache, idTokenObj, homeAccountIdentifier, accountEntity, result;
|
|
12373
|
+
return __generator$1(this, function (_a) {
|
|
12374
|
+
switch (_a.label) {
|
|
11980
12375
|
case 0:
|
|
11981
12376
|
this.logger.trace("NativeInteractionClient - handleNativeResponse called.");
|
|
11982
|
-
mats = this.getMATSFromResponse(response);
|
|
11983
|
-
this.performanceClient.addStaticFields({
|
|
11984
|
-
extensionId: this.nativeMessageHandler.getExtensionId(),
|
|
11985
|
-
extensionVersion: this.nativeMessageHandler.getExtensionVersion(),
|
|
11986
|
-
matsBrokerVersion: mats ? mats.broker_version : undefined,
|
|
11987
|
-
matsAccountJoinOnStart: mats ? mats.account_join_on_start : undefined,
|
|
11988
|
-
matsAccountJoinOnEnd: mats ? mats.account_join_on_end : undefined,
|
|
11989
|
-
matsDeviceJoin: mats ? mats.device_join : undefined,
|
|
11990
|
-
matsPromptBehavior: mats ? mats.prompt_behavior : undefined,
|
|
11991
|
-
matsApiErrorCode: mats ? mats.api_error_code : undefined,
|
|
11992
|
-
matsUiVisible: mats ? mats.ui_visible : undefined,
|
|
11993
|
-
matsSilentCode: mats ? mats.silent_code : undefined,
|
|
11994
|
-
matsSilentBiSubCode: mats ? mats.silent_bi_sub_code : undefined,
|
|
11995
|
-
matsSilentMessage: mats ? mats.silent_message : undefined,
|
|
11996
|
-
matsSilentStatus: mats ? mats.silent_status : undefined,
|
|
11997
|
-
matsHttpStatus: mats ? mats.http_status : undefined,
|
|
11998
|
-
matsHttpEventCount: mats ? mats.http_event_count : undefined
|
|
11999
|
-
}, this.correlationId);
|
|
12000
12377
|
if (response.account.id !== request.accountId) {
|
|
12001
12378
|
// 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
|
|
12002
12379
|
throw NativeAuthError.createUserSwitchError();
|
|
12003
12380
|
}
|
|
12004
|
-
idTokenObj = new AuthToken(response.id_token || Constants.EMPTY_STRING, this.browserCrypto);
|
|
12005
12381
|
return [4 /*yield*/, this.getDiscoveredAuthority(request.authority)];
|
|
12006
12382
|
case 1:
|
|
12007
|
-
authority =
|
|
12383
|
+
authority = _a.sent();
|
|
12008
12384
|
authorityPreferredCache = authority.getPreferredCache();
|
|
12009
|
-
|
|
12010
|
-
|
|
12011
|
-
this.
|
|
12012
|
-
|
|
12013
|
-
accountProperties = response.account.properties || {};
|
|
12014
|
-
uid = accountProperties["UID"] || idTokenObj.claims.oid || idTokenObj.claims.sub || Constants.EMPTY_STRING;
|
|
12015
|
-
tid = accountProperties["TenantId"] || idTokenObj.claims.tid || Constants.EMPTY_STRING;
|
|
12016
|
-
responseTokenType = exports.AuthenticationScheme.BEARER;
|
|
12017
|
-
_a = request.tokenType;
|
|
12018
|
-
switch (_a) {
|
|
12019
|
-
case exports.AuthenticationScheme.POP: return [3 /*break*/, 2];
|
|
12020
|
-
}
|
|
12021
|
-
return [3 /*break*/, 4];
|
|
12385
|
+
idTokenObj = this.createIdTokenObj(response);
|
|
12386
|
+
homeAccountIdentifier = this.createHomeAccountIdentifier(response, idTokenObj);
|
|
12387
|
+
accountEntity = this.createAccountEntity(response, homeAccountIdentifier, idTokenObj, authorityPreferredCache);
|
|
12388
|
+
return [4 /*yield*/, this.generateAuthenticationResult(response, request, idTokenObj, accountEntity, authority.canonicalAuthority, reqTimestamp)];
|
|
12022
12389
|
case 2:
|
|
12023
|
-
|
|
12024
|
-
|
|
12390
|
+
result = _a.sent();
|
|
12391
|
+
// cache accounts and tokens in the appropriate storage
|
|
12392
|
+
this.cacheAccount(accountEntity);
|
|
12393
|
+
this.cacheNativeTokens(response, request, homeAccountIdentifier, idTokenObj, result.accessToken, result.tenantId, reqTimestamp);
|
|
12394
|
+
return [2 /*return*/, result];
|
|
12395
|
+
}
|
|
12396
|
+
});
|
|
12397
|
+
});
|
|
12398
|
+
};
|
|
12399
|
+
/**
|
|
12400
|
+
* Create an idToken Object (not entity)
|
|
12401
|
+
* @param response
|
|
12402
|
+
* @returns
|
|
12403
|
+
*/
|
|
12404
|
+
NativeInteractionClient.prototype.createIdTokenObj = function (response) {
|
|
12405
|
+
return new AuthToken(response.id_token || Constants.EMPTY_STRING, this.browserCrypto);
|
|
12406
|
+
};
|
|
12407
|
+
/**
|
|
12408
|
+
* creates an homeAccountIdentifier for the account
|
|
12409
|
+
* @param response
|
|
12410
|
+
* @param idTokenObj
|
|
12411
|
+
* @returns
|
|
12412
|
+
*/
|
|
12413
|
+
NativeInteractionClient.prototype.createHomeAccountIdentifier = function (response, idTokenObj) {
|
|
12414
|
+
// Save account in browser storage
|
|
12415
|
+
var homeAccountIdentifier = AccountEntity.generateHomeAccountId(response.client_info || Constants.EMPTY_STRING, AuthorityType.Default, this.logger, this.browserCrypto, idTokenObj);
|
|
12416
|
+
return homeAccountIdentifier;
|
|
12417
|
+
};
|
|
12418
|
+
/**
|
|
12419
|
+
* Creates account entity
|
|
12420
|
+
* @param response
|
|
12421
|
+
* @param homeAccountIdentifier
|
|
12422
|
+
* @param idTokenObj
|
|
12423
|
+
* @param authority
|
|
12424
|
+
* @returns
|
|
12425
|
+
*/
|
|
12426
|
+
NativeInteractionClient.prototype.createAccountEntity = function (response, homeAccountIdentifier, idTokenObj, authority) {
|
|
12427
|
+
return AccountEntity.createAccount(response.client_info, homeAccountIdentifier, idTokenObj, undefined, undefined, undefined, authority, response.account.id);
|
|
12428
|
+
};
|
|
12429
|
+
/**
|
|
12430
|
+
* Helper to generate scopes
|
|
12431
|
+
* @param response
|
|
12432
|
+
* @param request
|
|
12433
|
+
* @returns
|
|
12434
|
+
*/
|
|
12435
|
+
NativeInteractionClient.prototype.generateScopes = function (response, request) {
|
|
12436
|
+
return response.scope ? ScopeSet.fromString(response.scope) : ScopeSet.fromString(request.scope);
|
|
12437
|
+
};
|
|
12438
|
+
/**
|
|
12439
|
+
* If PoP token is requesred, records the PoP token if returned from the WAM, else generates one in the browser
|
|
12440
|
+
* @param request
|
|
12441
|
+
* @param response
|
|
12442
|
+
*/
|
|
12443
|
+
NativeInteractionClient.prototype.generatePopAccessToken = function (response, request) {
|
|
12444
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
12445
|
+
var popTokenGenerator, shrParameters;
|
|
12446
|
+
return __generator$1(this, function (_a) {
|
|
12447
|
+
switch (_a.label) {
|
|
12448
|
+
case 0:
|
|
12449
|
+
if (!(request.tokenType === exports.AuthenticationScheme.POP)) return [3 /*break*/, 2];
|
|
12450
|
+
/**
|
|
12451
|
+
* This code prioritizes SHR returned from the native layer. In case of error/SHR not calculated from WAM and the AT
|
|
12452
|
+
* is still received, SHR is calculated locally
|
|
12453
|
+
*/
|
|
12025
12454
|
// Check if native layer returned an SHR token
|
|
12026
12455
|
if (response.shr) {
|
|
12027
12456
|
this.logger.trace("handleNativeServerResponse: SHR is enabled in native layer");
|
|
12028
|
-
|
|
12029
|
-
return [3 /*break*/, 5];
|
|
12457
|
+
return [2 /*return*/, response.shr];
|
|
12030
12458
|
}
|
|
12031
12459
|
popTokenGenerator = new PopTokenGenerator(this.browserCrypto);
|
|
12032
12460
|
shrParameters = {
|
|
@@ -12043,17 +12471,39 @@
|
|
|
12043
12471
|
throw ClientAuthError.createKeyIdMissingError();
|
|
12044
12472
|
}
|
|
12045
12473
|
return [4 /*yield*/, popTokenGenerator.signPopToken(response.access_token, request.keyId, shrParameters)];
|
|
12046
|
-
case
|
|
12047
|
-
|
|
12048
|
-
|
|
12049
|
-
|
|
12050
|
-
|
|
12051
|
-
|
|
12052
|
-
|
|
12053
|
-
|
|
12054
|
-
|
|
12474
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
12475
|
+
case 2: return [2 /*return*/, response.access_token];
|
|
12476
|
+
}
|
|
12477
|
+
});
|
|
12478
|
+
});
|
|
12479
|
+
};
|
|
12480
|
+
/**
|
|
12481
|
+
* Generates authentication result
|
|
12482
|
+
* @param response
|
|
12483
|
+
* @param request
|
|
12484
|
+
* @param idTokenObj
|
|
12485
|
+
* @param accountEntity
|
|
12486
|
+
* @param authority
|
|
12487
|
+
* @param reqTimestamp
|
|
12488
|
+
* @returns
|
|
12489
|
+
*/
|
|
12490
|
+
NativeInteractionClient.prototype.generateAuthenticationResult = function (response, request, idTokenObj, accountEntity, authority, reqTimestamp) {
|
|
12491
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
12492
|
+
var mats, responseScopes, accountProperties, uid, tid, responseAccessToken, tokenType, result;
|
|
12493
|
+
return __generator$1(this, function (_a) {
|
|
12494
|
+
switch (_a.label) {
|
|
12495
|
+
case 0:
|
|
12496
|
+
mats = this.addTelemetryFromNativeResponse(response);
|
|
12497
|
+
responseScopes = response.scope ? ScopeSet.fromString(response.scope) : ScopeSet.fromString(request.scope);
|
|
12498
|
+
accountProperties = response.account.properties || {};
|
|
12499
|
+
uid = accountProperties["UID"] || idTokenObj.claims.oid || idTokenObj.claims.sub || Constants.EMPTY_STRING;
|
|
12500
|
+
tid = accountProperties["TenantId"] || idTokenObj.claims.tid || Constants.EMPTY_STRING;
|
|
12501
|
+
return [4 /*yield*/, this.generatePopAccessToken(response, request)];
|
|
12502
|
+
case 1:
|
|
12503
|
+
responseAccessToken = _a.sent();
|
|
12504
|
+
tokenType = (request.tokenType === exports.AuthenticationScheme.POP) ? exports.AuthenticationScheme.POP : exports.AuthenticationScheme.BEARER;
|
|
12055
12505
|
result = {
|
|
12056
|
-
authority: authority
|
|
12506
|
+
authority: authority,
|
|
12057
12507
|
uniqueId: uid,
|
|
12058
12508
|
tenantId: tid,
|
|
12059
12509
|
scopes: responseScopes.asArray(),
|
|
@@ -12063,30 +12513,78 @@
|
|
|
12063
12513
|
accessToken: responseAccessToken,
|
|
12064
12514
|
fromCache: mats ? this.isResponseFromCache(mats) : false,
|
|
12065
12515
|
expiresOn: new Date(Number(reqTimestamp + response.expires_in) * 1000),
|
|
12066
|
-
tokenType:
|
|
12516
|
+
tokenType: tokenType,
|
|
12067
12517
|
correlationId: this.correlationId,
|
|
12068
12518
|
state: response.state,
|
|
12069
12519
|
fromNativeBroker: true
|
|
12070
12520
|
};
|
|
12071
|
-
idTokenEntity = IdTokenEntity.createIdTokenEntity(homeAccountIdentifier, request.authority, response.id_token || Constants.EMPTY_STRING, request.clientId, idTokenObj.claims.tid || Constants.EMPTY_STRING);
|
|
12072
|
-
this.nativeStorageManager.setIdTokenCredential(idTokenEntity);
|
|
12073
|
-
expiresIn = (responseTokenType === exports.AuthenticationScheme.POP)
|
|
12074
|
-
? Constants.SHR_NONCE_VALIDITY
|
|
12075
|
-
: (typeof response.expires_in === "string"
|
|
12076
|
-
? parseInt(response.expires_in, 10)
|
|
12077
|
-
: response.expires_in) || 0;
|
|
12078
|
-
tokenExpirationSeconds = reqTimestamp + expiresIn;
|
|
12079
|
-
accessTokenEntity = AccessTokenEntity.createAccessTokenEntity(homeAccountIdentifier, request.authority, responseAccessToken, request.clientId, tid, responseScopes.printScopes(), tokenExpirationSeconds, 0, this.browserCrypto);
|
|
12080
|
-
this.nativeStorageManager.setAccessTokenCredential(accessTokenEntity);
|
|
12081
|
-
// Remove any existing cached tokens for this account in browser storage
|
|
12082
|
-
this.browserStorage.removeAccountContext(accountEntity).catch(function (e) {
|
|
12083
|
-
_this.logger.error("Error occurred while removing account context from browser storage. " + e);
|
|
12084
|
-
});
|
|
12085
12521
|
return [2 /*return*/, result];
|
|
12086
12522
|
}
|
|
12087
12523
|
});
|
|
12088
12524
|
});
|
|
12089
12525
|
};
|
|
12526
|
+
/**
|
|
12527
|
+
* cache the account entity in browser storage
|
|
12528
|
+
* @param accountEntity
|
|
12529
|
+
*/
|
|
12530
|
+
NativeInteractionClient.prototype.cacheAccount = function (accountEntity) {
|
|
12531
|
+
var _this = this;
|
|
12532
|
+
// Store the account info and hence `nativeAccountId` in browser cache
|
|
12533
|
+
this.browserStorage.setAccount(accountEntity);
|
|
12534
|
+
// Remove any existing cached tokens for this account in browser storage
|
|
12535
|
+
this.browserStorage.removeAccountContext(accountEntity).catch(function (e) {
|
|
12536
|
+
_this.logger.error("Error occurred while removing account context from browser storage. " + e);
|
|
12537
|
+
});
|
|
12538
|
+
};
|
|
12539
|
+
/**
|
|
12540
|
+
* Stores the access_token and id_token in inmemory storage
|
|
12541
|
+
* @param response
|
|
12542
|
+
* @param request
|
|
12543
|
+
* @param homeAccountIdentifier
|
|
12544
|
+
* @param idTokenObj
|
|
12545
|
+
* @param responseAccessToken
|
|
12546
|
+
* @param tenantId
|
|
12547
|
+
* @param reqTimestamp
|
|
12548
|
+
*/
|
|
12549
|
+
NativeInteractionClient.prototype.cacheNativeTokens = function (response, request, homeAccountIdentifier, idTokenObj, responseAccessToken, tenantId, reqTimestamp) {
|
|
12550
|
+
// cache idToken in inmemory storage
|
|
12551
|
+
var idTokenEntity = IdTokenEntity.createIdTokenEntity(homeAccountIdentifier, request.authority, response.id_token || Constants.EMPTY_STRING, request.clientId, idTokenObj.claims.tid || Constants.EMPTY_STRING);
|
|
12552
|
+
this.nativeStorageManager.setIdTokenCredential(idTokenEntity);
|
|
12553
|
+
// cache accessToken in inmemory storage
|
|
12554
|
+
var expiresIn = (request.tokenType === exports.AuthenticationScheme.POP)
|
|
12555
|
+
? Constants.SHR_NONCE_VALIDITY
|
|
12556
|
+
: (typeof response.expires_in === "string"
|
|
12557
|
+
? parseInt(response.expires_in, 10)
|
|
12558
|
+
: response.expires_in) || 0;
|
|
12559
|
+
var tokenExpirationSeconds = reqTimestamp + expiresIn;
|
|
12560
|
+
var responseScopes = this.generateScopes(response, request);
|
|
12561
|
+
var accessTokenEntity = AccessTokenEntity.createAccessTokenEntity(homeAccountIdentifier, request.authority, responseAccessToken, request.clientId, tenantId, responseScopes.printScopes(), tokenExpirationSeconds, 0, this.browserCrypto);
|
|
12562
|
+
this.nativeStorageManager.setAccessTokenCredential(accessTokenEntity);
|
|
12563
|
+
};
|
|
12564
|
+
NativeInteractionClient.prototype.addTelemetryFromNativeResponse = function (response) {
|
|
12565
|
+
var mats = this.getMATSFromResponse(response);
|
|
12566
|
+
if (!mats) {
|
|
12567
|
+
return null;
|
|
12568
|
+
}
|
|
12569
|
+
this.performanceClient.addStaticFields({
|
|
12570
|
+
extensionId: this.nativeMessageHandler.getExtensionId(),
|
|
12571
|
+
extensionVersion: this.nativeMessageHandler.getExtensionVersion(),
|
|
12572
|
+
matsBrokerVersion: mats.broker_version,
|
|
12573
|
+
matsAccountJoinOnStart: mats.account_join_on_start,
|
|
12574
|
+
matsAccountJoinOnEnd: mats.account_join_on_end,
|
|
12575
|
+
matsDeviceJoin: mats.device_join,
|
|
12576
|
+
matsPromptBehavior: mats.prompt_behavior,
|
|
12577
|
+
matsApiErrorCode: mats.api_error_code,
|
|
12578
|
+
matsUiVisible: mats.ui_visible,
|
|
12579
|
+
matsSilentCode: mats.silent_code,
|
|
12580
|
+
matsSilentBiSubCode: mats.silent_bi_sub_code,
|
|
12581
|
+
matsSilentMessage: mats.silent_message,
|
|
12582
|
+
matsSilentStatus: mats.silent_status,
|
|
12583
|
+
matsHttpStatus: mats.http_status,
|
|
12584
|
+
matsHttpEventCount: mats.http_event_count
|
|
12585
|
+
}, this.correlationId);
|
|
12586
|
+
return mats;
|
|
12587
|
+
};
|
|
12090
12588
|
/**
|
|
12091
12589
|
* Validates native platform response before processing
|
|
12092
12590
|
* @param response
|
|
@@ -12205,7 +12703,7 @@
|
|
|
12205
12703
|
* Licensed under the MIT License.
|
|
12206
12704
|
*/
|
|
12207
12705
|
var NativeMessageHandler = /** @class */ (function () {
|
|
12208
|
-
function NativeMessageHandler(logger, handshakeTimeoutMs, extensionId) {
|
|
12706
|
+
function NativeMessageHandler(logger, handshakeTimeoutMs, performanceClient, extensionId) {
|
|
12209
12707
|
this.logger = logger;
|
|
12210
12708
|
this.handshakeTimeoutMs = handshakeTimeoutMs;
|
|
12211
12709
|
this.extensionId = extensionId;
|
|
@@ -12214,6 +12712,8 @@
|
|
|
12214
12712
|
this.responseId = 0;
|
|
12215
12713
|
this.messageChannel = new MessageChannel();
|
|
12216
12714
|
this.windowListener = this.onWindowMessage.bind(this); // Window event callback doesn't have access to 'this' unless it's bound
|
|
12715
|
+
this.performanceClient = performanceClient;
|
|
12716
|
+
this.handshakeEvent = performanceClient.startMeasurement(exports.PerformanceEvents.NativeMessageHandlerHandshake);
|
|
12217
12717
|
}
|
|
12218
12718
|
/**
|
|
12219
12719
|
* Sends a given message to the extension and resolves with the extension response
|
|
@@ -12242,10 +12742,11 @@
|
|
|
12242
12742
|
};
|
|
12243
12743
|
/**
|
|
12244
12744
|
* Returns an instance of the MessageHandler that has successfully established a connection with an extension
|
|
12245
|
-
* @param logger
|
|
12246
|
-
* @param handshakeTimeoutMs
|
|
12745
|
+
* @param {Logger} logger
|
|
12746
|
+
* @param {number} handshakeTimeoutMs
|
|
12747
|
+
* @param {IPerformanceClient} performanceClient
|
|
12247
12748
|
*/
|
|
12248
|
-
NativeMessageHandler.createProvider = function (logger, handshakeTimeoutMs) {
|
|
12749
|
+
NativeMessageHandler.createProvider = function (logger, handshakeTimeoutMs, performanceClient) {
|
|
12249
12750
|
return __awaiter$1(this, void 0, void 0, function () {
|
|
12250
12751
|
var preferredProvider, backupProvider;
|
|
12251
12752
|
return __generator$1(this, function (_a) {
|
|
@@ -12255,14 +12756,14 @@
|
|
|
12255
12756
|
_a.label = 1;
|
|
12256
12757
|
case 1:
|
|
12257
12758
|
_a.trys.push([1, 3, , 5]);
|
|
12258
|
-
preferredProvider = new NativeMessageHandler(logger, handshakeTimeoutMs, NativeConstants.PREFERRED_EXTENSION_ID);
|
|
12759
|
+
preferredProvider = new NativeMessageHandler(logger, handshakeTimeoutMs, performanceClient, NativeConstants.PREFERRED_EXTENSION_ID);
|
|
12259
12760
|
return [4 /*yield*/, preferredProvider.sendHandshakeRequest()];
|
|
12260
12761
|
case 2:
|
|
12261
12762
|
_a.sent();
|
|
12262
12763
|
return [2 /*return*/, preferredProvider];
|
|
12263
12764
|
case 3:
|
|
12264
12765
|
_a.sent();
|
|
12265
|
-
backupProvider = new NativeMessageHandler(logger, handshakeTimeoutMs);
|
|
12766
|
+
backupProvider = new NativeMessageHandler(logger, handshakeTimeoutMs, performanceClient);
|
|
12266
12767
|
return [4 /*yield*/, backupProvider.sendHandshakeRequest()];
|
|
12267
12768
|
case 4:
|
|
12268
12769
|
_a.sent();
|
|
@@ -12291,6 +12792,10 @@
|
|
|
12291
12792
|
method: NativeExtensionMethod.HandshakeRequest
|
|
12292
12793
|
}
|
|
12293
12794
|
};
|
|
12795
|
+
this.handshakeEvent.addStaticFields({
|
|
12796
|
+
extensionId: this.extensionId,
|
|
12797
|
+
extensionHandshakeTimeoutMs: this.handshakeTimeoutMs
|
|
12798
|
+
});
|
|
12294
12799
|
this.messageChannel.port1.onmessage = function (event) {
|
|
12295
12800
|
_this.onChannelMessage(event);
|
|
12296
12801
|
};
|
|
@@ -12305,6 +12810,7 @@
|
|
|
12305
12810
|
window.removeEventListener("message", _this.windowListener, false);
|
|
12306
12811
|
_this.messageChannel.port1.close();
|
|
12307
12812
|
_this.messageChannel.port2.close();
|
|
12813
|
+
_this.handshakeEvent.endMeasurement({ extensionHandshakeTimedOut: true, success: false });
|
|
12308
12814
|
reject(BrowserAuthError.createNativeHandshakeTimeoutError());
|
|
12309
12815
|
_this.handshakeResolvers.delete(req.responseId);
|
|
12310
12816
|
}, _this.handshakeTimeoutMs); // Use a reasonable timeout in milliseconds here
|
|
@@ -12338,6 +12844,7 @@
|
|
|
12338
12844
|
window.removeEventListener("message", this.windowListener, false);
|
|
12339
12845
|
var handshakeResolver = this.handshakeResolvers.get(request.responseId);
|
|
12340
12846
|
if (handshakeResolver) {
|
|
12847
|
+
this.handshakeEvent.endMeasurement({ success: false, extensionInstalled: false });
|
|
12341
12848
|
handshakeResolver.reject(BrowserAuthError.createNativeExtensionNotInstalledError());
|
|
12342
12849
|
}
|
|
12343
12850
|
}
|
|
@@ -12385,6 +12892,7 @@
|
|
|
12385
12892
|
this.extensionId = request.extensionId;
|
|
12386
12893
|
this.extensionVersion = request.body.version;
|
|
12387
12894
|
this.logger.verbose("NativeMessageHandler - Received HandshakeResponse from extension: " + this.extensionId);
|
|
12895
|
+
this.handshakeEvent.endMeasurement({ extensionInstalled: true, success: true });
|
|
12388
12896
|
handshakeResolver.resolve();
|
|
12389
12897
|
this.handshakeResolvers.delete(request.responseId);
|
|
12390
12898
|
}
|
|
@@ -13373,7 +13881,9 @@
|
|
|
13373
13881
|
var DEFAULT_CACHE_OPTIONS = {
|
|
13374
13882
|
cacheLocation: exports.BrowserCacheLocation.SessionStorage,
|
|
13375
13883
|
storeAuthStateInCookie: false,
|
|
13376
|
-
secureCookies: false
|
|
13884
|
+
secureCookies: false,
|
|
13885
|
+
// 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
|
|
13886
|
+
cacheMigrationEnabled: userInputCache && userInputCache.cacheLocation === exports.BrowserCacheLocation.LocalStorage ? true : false
|
|
13377
13887
|
};
|
|
13378
13888
|
// Default logger options for browser
|
|
13379
13889
|
var DEFAULT_LOGGER_OPTIONS = {
|
|
@@ -15454,10 +15964,19 @@
|
|
|
15454
15964
|
var BrowserPerformanceMeasurement = /** @class */ (function () {
|
|
15455
15965
|
function BrowserPerformanceMeasurement(name, correlationId) {
|
|
15456
15966
|
this.correlationId = correlationId;
|
|
15457
|
-
this.measureName =
|
|
15458
|
-
this.startMark =
|
|
15459
|
-
this.endMark =
|
|
15967
|
+
this.measureName = BrowserPerformanceMeasurement.makeMeasureName(name, correlationId);
|
|
15968
|
+
this.startMark = BrowserPerformanceMeasurement.makeStartMark(name, correlationId);
|
|
15969
|
+
this.endMark = BrowserPerformanceMeasurement.makeEndMark(name, correlationId);
|
|
15460
15970
|
}
|
|
15971
|
+
BrowserPerformanceMeasurement.makeMeasureName = function (name, correlationId) {
|
|
15972
|
+
return "msal.measure." + name + "." + correlationId;
|
|
15973
|
+
};
|
|
15974
|
+
BrowserPerformanceMeasurement.makeStartMark = function (name, correlationId) {
|
|
15975
|
+
return "msal.start." + name + "." + correlationId;
|
|
15976
|
+
};
|
|
15977
|
+
BrowserPerformanceMeasurement.makeEndMark = function (name, correlationId) {
|
|
15978
|
+
return "msal.end." + name + "." + correlationId;
|
|
15979
|
+
};
|
|
15461
15980
|
BrowserPerformanceMeasurement.supportsBrowserPerformance = function () {
|
|
15462
15981
|
return typeof window !== "undefined" &&
|
|
15463
15982
|
typeof window.performance !== "undefined" &&
|
|
@@ -15467,6 +15986,29 @@
|
|
|
15467
15986
|
typeof window.performance.clearMeasures === "function" &&
|
|
15468
15987
|
typeof window.performance.getEntriesByName === "function";
|
|
15469
15988
|
};
|
|
15989
|
+
/**
|
|
15990
|
+
* Flush browser marks and measurements.
|
|
15991
|
+
* @param {string} correlationId
|
|
15992
|
+
* @param {SubMeasurement} measurements
|
|
15993
|
+
*/
|
|
15994
|
+
BrowserPerformanceMeasurement.flushMeasurements = function (correlationId, measurements) {
|
|
15995
|
+
if (BrowserPerformanceMeasurement.supportsBrowserPerformance()) {
|
|
15996
|
+
try {
|
|
15997
|
+
measurements.forEach(function (measurement) {
|
|
15998
|
+
var measureName = BrowserPerformanceMeasurement.makeMeasureName(measurement.name, correlationId);
|
|
15999
|
+
var entriesForMeasurement = window.performance.getEntriesByName(measureName, "measure");
|
|
16000
|
+
if (entriesForMeasurement.length > 0) {
|
|
16001
|
+
window.performance.clearMeasures(measureName);
|
|
16002
|
+
window.performance.clearMarks(BrowserPerformanceMeasurement.makeStartMark(measureName, correlationId));
|
|
16003
|
+
window.performance.clearMarks(BrowserPerformanceMeasurement.makeEndMark(measureName, correlationId));
|
|
16004
|
+
}
|
|
16005
|
+
});
|
|
16006
|
+
}
|
|
16007
|
+
catch (e) {
|
|
16008
|
+
// Silently catch and return null
|
|
16009
|
+
}
|
|
16010
|
+
}
|
|
16011
|
+
};
|
|
15470
16012
|
BrowserPerformanceMeasurement.prototype.startMeasurement = function () {
|
|
15471
16013
|
if (BrowserPerformanceMeasurement.supportsBrowserPerformance()) {
|
|
15472
16014
|
try {
|
|
@@ -15531,6 +16073,20 @@
|
|
|
15531
16073
|
var _a;
|
|
15532
16074
|
return ((_a = document.visibilityState) === null || _a === void 0 ? void 0 : _a.toString()) || null;
|
|
15533
16075
|
};
|
|
16076
|
+
BrowserPerformanceClient.prototype.deleteIncompleteSubMeasurements = function (inProgressEvent) {
|
|
16077
|
+
var rootEvent = this.eventsByCorrelationId.get(inProgressEvent.event.correlationId);
|
|
16078
|
+
var isRootEvent = rootEvent && rootEvent.eventId === inProgressEvent.event.eventId;
|
|
16079
|
+
var incompleteMeasurements = [];
|
|
16080
|
+
if (isRootEvent && (rootEvent === null || rootEvent === void 0 ? void 0 : rootEvent.incompleteSubMeasurements)) {
|
|
16081
|
+
rootEvent.incompleteSubMeasurements.forEach(function (subMeasurement) {
|
|
16082
|
+
incompleteMeasurements.push(__assign$1({}, subMeasurement));
|
|
16083
|
+
});
|
|
16084
|
+
}
|
|
16085
|
+
// Clean up remaining marks for incomplete sub-measurements
|
|
16086
|
+
if (incompleteMeasurements.length > 0) {
|
|
16087
|
+
BrowserPerformanceMeasurement.flushMeasurements(inProgressEvent.event.correlationId, incompleteMeasurements);
|
|
16088
|
+
}
|
|
16089
|
+
};
|
|
15534
16090
|
BrowserPerformanceClient.prototype.supportsBrowserPerformanceNow = function () {
|
|
15535
16091
|
return typeof window !== "undefined" &&
|
|
15536
16092
|
typeof window.performance !== "undefined" &&
|
|
@@ -15550,7 +16106,13 @@
|
|
|
15550
16106
|
var startPageVisibility = this.getPageVisibility();
|
|
15551
16107
|
var inProgressEvent = _super.prototype.startMeasurement.call(this, measureName, correlationId);
|
|
15552
16108
|
return __assign$1(__assign$1({}, inProgressEvent), { endMeasurement: function (event) {
|
|
15553
|
-
|
|
16109
|
+
var res = inProgressEvent.endMeasurement(__assign$1({ startPageVisibility: startPageVisibility, endPageVisibility: _this.getPageVisibility() }, event));
|
|
16110
|
+
_this.deleteIncompleteSubMeasurements(inProgressEvent);
|
|
16111
|
+
return res;
|
|
16112
|
+
}, discardMeasurement: function () {
|
|
16113
|
+
inProgressEvent.discardMeasurement();
|
|
16114
|
+
_this.deleteIncompleteSubMeasurements(inProgressEvent);
|
|
16115
|
+
inProgressEvent.measurement.flushMeasurement();
|
|
15554
16116
|
} });
|
|
15555
16117
|
};
|
|
15556
16118
|
/**
|
|
@@ -15568,26 +16130,27 @@
|
|
|
15568
16130
|
this.logger.trace("BrowserPerformanceClient: correlationId for " + eventName + " not provided, unable to set telemetry queue time");
|
|
15569
16131
|
return;
|
|
15570
16132
|
}
|
|
15571
|
-
var
|
|
15572
|
-
|
|
15573
|
-
|
|
15574
|
-
|
|
15575
|
-
|
|
15576
|
-
|
|
15577
|
-
|
|
15578
|
-
|
|
15579
|
-
this.preQueueTimeByCorrelationId.set(correlationId, preQueueTimes);
|
|
16133
|
+
var preQueueEvent = this.preQueueTimeByCorrelationId.get(correlationId);
|
|
16134
|
+
/**
|
|
16135
|
+
* Manually complete queue measurement if there is an incomplete pre-queue event.
|
|
16136
|
+
* Incomplete pre-queue events are instrumentation bugs that should be fixed.
|
|
16137
|
+
*/
|
|
16138
|
+
if (preQueueEvent) {
|
|
16139
|
+
this.logger.trace("BrowserPerformanceClient: Incomplete pre-queue " + preQueueEvent.name + " found", correlationId);
|
|
16140
|
+
this.addQueueMeasurement(preQueueEvent.name, correlationId, undefined, true);
|
|
15580
16141
|
}
|
|
16142
|
+
this.preQueueTimeByCorrelationId.set(correlationId, { name: eventName, time: window.performance.now() });
|
|
15581
16143
|
};
|
|
15582
16144
|
/**
|
|
15583
16145
|
* Calculates and adds queue time measurement for given performance event.
|
|
15584
16146
|
*
|
|
15585
|
-
* @param {PerformanceEvents}
|
|
16147
|
+
* @param {PerformanceEvents} eventName
|
|
15586
16148
|
* @param {?string} correlationId
|
|
15587
|
-
* @param {?number}
|
|
16149
|
+
* @param {?number} queueTime
|
|
16150
|
+
* @param {?boolean} manuallyCompleted - indicator for manually completed queue measurements
|
|
15588
16151
|
* @returns
|
|
15589
16152
|
*/
|
|
15590
|
-
BrowserPerformanceClient.prototype.addQueueMeasurement = function (eventName, correlationId) {
|
|
16153
|
+
BrowserPerformanceClient.prototype.addQueueMeasurement = function (eventName, correlationId, queueTime, manuallyCompleted) {
|
|
15591
16154
|
if (!this.supportsBrowserPerformanceNow()) {
|
|
15592
16155
|
this.logger.trace("BrowserPerformanceClient: window performance API not available, unable to add queue measurement for " + eventName);
|
|
15593
16156
|
return;
|
|
@@ -15601,8 +16164,8 @@
|
|
|
15601
16164
|
return;
|
|
15602
16165
|
}
|
|
15603
16166
|
var currentTime = window.performance.now();
|
|
15604
|
-
var
|
|
15605
|
-
return _super.prototype.addQueueMeasurement.call(this, eventName, correlationId,
|
|
16167
|
+
var resQueueTime = queueTime || _super.prototype.calculateQueuedTime.call(this, preQueueTime, currentTime);
|
|
16168
|
+
return _super.prototype.addQueueMeasurement.call(this, eventName, correlationId, resQueueTime, manuallyCompleted);
|
|
15606
16169
|
};
|
|
15607
16170
|
return BrowserPerformanceClient;
|
|
15608
16171
|
}(PerformanceClient));
|
|
@@ -15621,6 +16184,7 @@
|
|
|
15621
16184
|
SilentIframeClient: SilentIframeClient,
|
|
15622
16185
|
SilentCacheClient: SilentCacheClient,
|
|
15623
16186
|
SilentRefreshClient: SilentRefreshClient,
|
|
16187
|
+
NativeInteractionClient: NativeInteractionClient,
|
|
15624
16188
|
RedirectHandler: RedirectHandler,
|
|
15625
16189
|
EventHandler: EventHandler,
|
|
15626
16190
|
NativeMessageHandler: NativeMessageHandler,
|
|
@@ -16002,7 +16566,8 @@
|
|
|
16002
16566
|
var nativeCacheOptions = {
|
|
16003
16567
|
cacheLocation: exports.BrowserCacheLocation.MemoryStorage,
|
|
16004
16568
|
storeAuthStateInCookie: false,
|
|
16005
|
-
secureCookies: false
|
|
16569
|
+
secureCookies: false,
|
|
16570
|
+
cacheMigrationEnabled: false
|
|
16006
16571
|
};
|
|
16007
16572
|
this.nativeInternalStorage = new BrowserCacheManager(this.config.auth.clientId, nativeCacheOptions, this.browserCrypto, this.logger);
|
|
16008
16573
|
// Initialize the token cache
|
|
@@ -16015,7 +16580,7 @@
|
|
|
16015
16580
|
*/
|
|
16016
16581
|
ClientApplication.prototype.initialize = function () {
|
|
16017
16582
|
return __awaiter$1(this, void 0, void 0, function () {
|
|
16018
|
-
var _a, e_1;
|
|
16583
|
+
var allowNativeBroker, initMeasurement, _a, e_1;
|
|
16019
16584
|
return __generator$1(this, function (_b) {
|
|
16020
16585
|
switch (_b.label) {
|
|
16021
16586
|
case 0:
|
|
@@ -16024,13 +16589,15 @@
|
|
|
16024
16589
|
this.logger.info("initialize has already been called, exiting early.");
|
|
16025
16590
|
return [2 /*return*/];
|
|
16026
16591
|
}
|
|
16592
|
+
allowNativeBroker = this.config.system.allowNativeBroker;
|
|
16593
|
+
initMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.InitializeClientApplication);
|
|
16027
16594
|
this.eventHandler.emitEvent(exports.EventType.INITIALIZE_START);
|
|
16028
|
-
if (!
|
|
16595
|
+
if (!allowNativeBroker) return [3 /*break*/, 4];
|
|
16029
16596
|
_b.label = 1;
|
|
16030
16597
|
case 1:
|
|
16031
16598
|
_b.trys.push([1, 3, , 4]);
|
|
16032
16599
|
_a = this;
|
|
16033
|
-
return [4 /*yield*/, NativeMessageHandler.createProvider(this.logger, this.config.system.nativeBrokerHandshakeTimeout)];
|
|
16600
|
+
return [4 /*yield*/, NativeMessageHandler.createProvider(this.logger, this.config.system.nativeBrokerHandshakeTimeout, this.performanceClient)];
|
|
16034
16601
|
case 2:
|
|
16035
16602
|
_a.nativeExtensionProvider = _b.sent();
|
|
16036
16603
|
return [3 /*break*/, 4];
|
|
@@ -16041,6 +16608,7 @@
|
|
|
16041
16608
|
case 4:
|
|
16042
16609
|
this.initialized = true;
|
|
16043
16610
|
this.eventHandler.emitEvent(exports.EventType.INITIALIZE_END);
|
|
16611
|
+
initMeasurement.endMeasurement({ allowNativeBroker: allowNativeBroker, success: true });
|
|
16044
16612
|
return [2 /*return*/];
|
|
16045
16613
|
}
|
|
16046
16614
|
});
|
|
@@ -16216,7 +16784,6 @@
|
|
|
16216
16784
|
isNativeBroker: true,
|
|
16217
16785
|
requestId: response.requestId
|
|
16218
16786
|
});
|
|
16219
|
-
atPopupMeasurement.flushMeasurement();
|
|
16220
16787
|
return response;
|
|
16221
16788
|
}).catch(function (e) {
|
|
16222
16789
|
if (e instanceof NativeAuthError && e.isFatal()) {
|
|
@@ -16256,7 +16823,6 @@
|
|
|
16256
16823
|
success: true,
|
|
16257
16824
|
requestId: result.requestId
|
|
16258
16825
|
});
|
|
16259
|
-
atPopupMeasurement.flushMeasurement();
|
|
16260
16826
|
return result;
|
|
16261
16827
|
}).catch(function (e) {
|
|
16262
16828
|
if (loggedInAccounts.length > 0) {
|
|
@@ -16270,7 +16836,6 @@
|
|
|
16270
16836
|
subErrorCode: e.subError,
|
|
16271
16837
|
success: false
|
|
16272
16838
|
});
|
|
16273
|
-
atPopupMeasurement.flushMeasurement();
|
|
16274
16839
|
// Since this function is syncronous we need to reject
|
|
16275
16840
|
return Promise.reject(e);
|
|
16276
16841
|
});
|
|
@@ -16336,7 +16901,7 @@
|
|
|
16336
16901
|
result = silentIframeClient.acquireToken(validRequest);
|
|
16337
16902
|
}
|
|
16338
16903
|
return [2 /*return*/, result.then(function (response) {
|
|
16339
|
-
var _a, _b
|
|
16904
|
+
var _a, _b;
|
|
16340
16905
|
_this.eventHandler.emitEvent(exports.EventType.SSO_SILENT_SUCCESS, exports.InteractionType.Silent, response);
|
|
16341
16906
|
(_a = _this.ssoSilentMeasurement) === null || _a === void 0 ? void 0 : _a.addStaticFields({
|
|
16342
16907
|
accessTokenSize: response.accessToken.length,
|
|
@@ -16347,17 +16912,15 @@
|
|
|
16347
16912
|
isNativeBroker: response.fromNativeBroker,
|
|
16348
16913
|
requestId: response.requestId
|
|
16349
16914
|
});
|
|
16350
|
-
(_c = _this.ssoSilentMeasurement) === null || _c === void 0 ? void 0 : _c.flushMeasurement();
|
|
16351
16915
|
return response;
|
|
16352
16916
|
}).catch(function (e) {
|
|
16353
|
-
var _a
|
|
16917
|
+
var _a;
|
|
16354
16918
|
_this.eventHandler.emitEvent(exports.EventType.SSO_SILENT_FAILURE, exports.InteractionType.Silent, null, e);
|
|
16355
16919
|
(_a = _this.ssoSilentMeasurement) === null || _a === void 0 ? void 0 : _a.endMeasurement({
|
|
16356
16920
|
errorCode: e.errorCode,
|
|
16357
16921
|
subErrorCode: e.subError,
|
|
16358
16922
|
success: false
|
|
16359
16923
|
});
|
|
16360
|
-
(_b = _this.ssoSilentMeasurement) === null || _b === void 0 ? void 0 : _b.flushMeasurement();
|
|
16361
16924
|
throw e;
|
|
16362
16925
|
}).finally(function () {
|
|
16363
16926
|
document.removeEventListener("visibilitychange", _this.trackPageVisibilityWithMeasurement);
|
|
@@ -16386,7 +16949,11 @@
|
|
|
16386
16949
|
this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_BY_CODE_START, exports.InteractionType.Silent, request);
|
|
16387
16950
|
atbcMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.AcquireTokenByCode, request.correlationId);
|
|
16388
16951
|
try {
|
|
16389
|
-
if (request.code) {
|
|
16952
|
+
if (request.code && request.nativeAccountId) {
|
|
16953
|
+
// Throw error in case server returns both spa_code and spa_accountid in exchange for auth code.
|
|
16954
|
+
throw BrowserAuthError.createSpaCodeAndNativeAccountIdPresentError();
|
|
16955
|
+
}
|
|
16956
|
+
else if (request.code) {
|
|
16390
16957
|
hybridAuthCode_1 = request.code;
|
|
16391
16958
|
response = this.hybridAuthCodeResponses.get(hybridAuthCode_1);
|
|
16392
16959
|
if (!response) {
|
|
@@ -16404,7 +16971,6 @@
|
|
|
16404
16971
|
isNativeBroker: result.fromNativeBroker,
|
|
16405
16972
|
requestId: result.requestId
|
|
16406
16973
|
});
|
|
16407
|
-
atbcMeasurement.flushMeasurement();
|
|
16408
16974
|
return result;
|
|
16409
16975
|
})
|
|
16410
16976
|
.catch(function (error) {
|
|
@@ -16415,16 +16981,12 @@
|
|
|
16415
16981
|
subErrorCode: error.subError,
|
|
16416
16982
|
success: false
|
|
16417
16983
|
});
|
|
16418
|
-
atbcMeasurement.flushMeasurement();
|
|
16419
16984
|
throw error;
|
|
16420
16985
|
});
|
|
16421
16986
|
this.hybridAuthCodeResponses.set(hybridAuthCode_1, response);
|
|
16422
16987
|
}
|
|
16423
16988
|
else {
|
|
16424
16989
|
this.logger.verbose("Existing acquireTokenByCode request found", request.correlationId);
|
|
16425
|
-
atbcMeasurement.endMeasurement({
|
|
16426
|
-
success: true
|
|
16427
|
-
});
|
|
16428
16990
|
atbcMeasurement.discardMeasurement();
|
|
16429
16991
|
}
|
|
16430
16992
|
return [2 /*return*/, response];
|
|
@@ -16638,15 +17200,20 @@
|
|
|
16638
17200
|
* (the account object is created at the time of successful login)
|
|
16639
17201
|
* or null when no matching account is found.
|
|
16640
17202
|
* This API is provided for convenience but getAccountById should be used for best reliability
|
|
16641
|
-
* @param
|
|
17203
|
+
* @param username
|
|
16642
17204
|
* @returns The account object stored in MSAL
|
|
16643
17205
|
*/
|
|
16644
|
-
ClientApplication.prototype.getAccountByUsername = function (
|
|
16645
|
-
|
|
16646
|
-
if (!
|
|
16647
|
-
this.logger.
|
|
16648
|
-
|
|
16649
|
-
|
|
17206
|
+
ClientApplication.prototype.getAccountByUsername = function (username) {
|
|
17207
|
+
this.logger.trace("getAccountByUsername called");
|
|
17208
|
+
if (!username) {
|
|
17209
|
+
this.logger.warning("getAccountByUsername: No username provided");
|
|
17210
|
+
return null;
|
|
17211
|
+
}
|
|
17212
|
+
var account = this.browserStorage.getAccountInfoFilteredBy({ username: username });
|
|
17213
|
+
if (account) {
|
|
17214
|
+
this.logger.verbose("getAccountByUsername: Account matching username found, returning");
|
|
17215
|
+
this.logger.verbosePii("getAccountByUsername: Returning signed-in accounts matching username: " + username);
|
|
17216
|
+
return account;
|
|
16650
17217
|
}
|
|
16651
17218
|
else {
|
|
16652
17219
|
this.logger.verbose("getAccountByUsername: No matching account found, returning null");
|
|
@@ -16661,11 +17228,16 @@
|
|
|
16661
17228
|
* @returns The account object stored in MSAL
|
|
16662
17229
|
*/
|
|
16663
17230
|
ClientApplication.prototype.getAccountByHomeId = function (homeAccountId) {
|
|
16664
|
-
|
|
16665
|
-
if (!
|
|
16666
|
-
this.logger.
|
|
16667
|
-
|
|
16668
|
-
|
|
17231
|
+
this.logger.trace("getAccountByHomeId called");
|
|
17232
|
+
if (!homeAccountId) {
|
|
17233
|
+
this.logger.warning("getAccountByHomeId: No homeAccountId provided");
|
|
17234
|
+
return null;
|
|
17235
|
+
}
|
|
17236
|
+
var account = this.browserStorage.getAccountInfoFilteredBy({ homeAccountId: homeAccountId });
|
|
17237
|
+
if (account) {
|
|
17238
|
+
this.logger.verbose("getAccountByHomeId: Account matching homeAccountId found, returning");
|
|
17239
|
+
this.logger.verbosePii("getAccountByHomeId: Returning signed-in accounts matching homeAccountId: " + homeAccountId);
|
|
17240
|
+
return account;
|
|
16669
17241
|
}
|
|
16670
17242
|
else {
|
|
16671
17243
|
this.logger.verbose("getAccountByHomeId: No matching account found, returning null");
|
|
@@ -16680,11 +17252,16 @@
|
|
|
16680
17252
|
* @returns The account object stored in MSAL
|
|
16681
17253
|
*/
|
|
16682
17254
|
ClientApplication.prototype.getAccountByLocalId = function (localAccountId) {
|
|
16683
|
-
|
|
16684
|
-
if (!
|
|
16685
|
-
this.logger.
|
|
16686
|
-
|
|
16687
|
-
|
|
17255
|
+
this.logger.trace("getAccountByLocalId called");
|
|
17256
|
+
if (!localAccountId) {
|
|
17257
|
+
this.logger.warning("getAccountByLocalId: No localAccountId provided");
|
|
17258
|
+
return null;
|
|
17259
|
+
}
|
|
17260
|
+
var account = this.browserStorage.getAccountInfoFilteredBy({ localAccountId: localAccountId });
|
|
17261
|
+
if (account) {
|
|
17262
|
+
this.logger.verbose("getAccountByLocalId: Account matching localAccountId found, returning");
|
|
17263
|
+
this.logger.verbosePii("getAccountByLocalId: Returning signed-in accounts matching localAccountId: " + localAccountId);
|
|
17264
|
+
return account;
|
|
16688
17265
|
}
|
|
16689
17266
|
else {
|
|
16690
17267
|
this.logger.verbose("getAccountByLocalId: No matching account found, returning null");
|
|
@@ -17075,7 +17652,6 @@
|
|
|
17075
17652
|
cacheLookupPolicy: request.cacheLookupPolicy,
|
|
17076
17653
|
requestId: result.requestId,
|
|
17077
17654
|
});
|
|
17078
|
-
atsMeasurement.flushMeasurement();
|
|
17079
17655
|
return result;
|
|
17080
17656
|
})
|
|
17081
17657
|
.catch(function (error) {
|
|
@@ -17085,7 +17661,6 @@
|
|
|
17085
17661
|
subErrorCode: error.subError,
|
|
17086
17662
|
success: false
|
|
17087
17663
|
});
|
|
17088
|
-
atsMeasurement.flushMeasurement();
|
|
17089
17664
|
throw error;
|
|
17090
17665
|
});
|
|
17091
17666
|
this.activeSilentTokenRequests.set(silentRequestKey, response);
|
|
@@ -17093,9 +17668,6 @@
|
|
|
17093
17668
|
}
|
|
17094
17669
|
else {
|
|
17095
17670
|
this.logger.verbose("acquireTokenSilent has been called previously, returning the result from the first call", correlationId);
|
|
17096
|
-
atsMeasurement.endMeasurement({
|
|
17097
|
-
success: true
|
|
17098
|
-
});
|
|
17099
17671
|
// Discard measurements for memoized calls, as they are usually only a couple of ms and will artificially deflate metrics
|
|
17100
17672
|
atsMeasurement.discardMeasurement();
|
|
17101
17673
|
return [2 /*return*/, cachedResponse];
|