@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/dist/index.cjs.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
|
'use strict';
|
|
4
4
|
|
|
@@ -117,7 +117,7 @@ function __spread() {
|
|
|
117
117
|
return ar;
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
/*! @azure/msal-common
|
|
120
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
121
121
|
/*! *****************************************************************************
|
|
122
122
|
Copyright (c) Microsoft Corporation.
|
|
123
123
|
|
|
@@ -204,7 +204,7 @@ function __spreadArrays() {
|
|
|
204
204
|
return r;
|
|
205
205
|
}
|
|
206
206
|
|
|
207
|
-
/*! @azure/msal-common
|
|
207
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
208
208
|
|
|
209
209
|
/*
|
|
210
210
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -451,22 +451,6 @@ var CredentialType;
|
|
|
451
451
|
CredentialType["ACCESS_TOKEN_WITH_AUTH_SCHEME"] = "AccessToken_With_AuthScheme";
|
|
452
452
|
CredentialType["REFRESH_TOKEN"] = "RefreshToken";
|
|
453
453
|
})(CredentialType || (CredentialType = {}));
|
|
454
|
-
/**
|
|
455
|
-
* Credential Type stored in the cache
|
|
456
|
-
*/
|
|
457
|
-
var CacheSchemaType;
|
|
458
|
-
(function (CacheSchemaType) {
|
|
459
|
-
CacheSchemaType["ACCOUNT"] = "Account";
|
|
460
|
-
CacheSchemaType["CREDENTIAL"] = "Credential";
|
|
461
|
-
CacheSchemaType["ID_TOKEN"] = "IdToken";
|
|
462
|
-
CacheSchemaType["ACCESS_TOKEN"] = "AccessToken";
|
|
463
|
-
CacheSchemaType["REFRESH_TOKEN"] = "RefreshToken";
|
|
464
|
-
CacheSchemaType["APP_METADATA"] = "AppMetadata";
|
|
465
|
-
CacheSchemaType["TEMPORARY"] = "TempCache";
|
|
466
|
-
CacheSchemaType["TELEMETRY"] = "Telemetry";
|
|
467
|
-
CacheSchemaType["UNDEFINED"] = "Undefined";
|
|
468
|
-
CacheSchemaType["THROTTLING"] = "Throttling";
|
|
469
|
-
})(CacheSchemaType || (CacheSchemaType = {}));
|
|
470
454
|
/**
|
|
471
455
|
* Combine all cache types
|
|
472
456
|
*/
|
|
@@ -586,9 +570,10 @@ var JsonTypes;
|
|
|
586
570
|
(function (JsonTypes) {
|
|
587
571
|
JsonTypes["Jwt"] = "JWT";
|
|
588
572
|
JsonTypes["Jwk"] = "JWK";
|
|
573
|
+
JsonTypes["Pop"] = "pop";
|
|
589
574
|
})(JsonTypes || (JsonTypes = {}));
|
|
590
575
|
|
|
591
|
-
/*! @azure/msal-common
|
|
576
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
592
577
|
|
|
593
578
|
/*
|
|
594
579
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -644,7 +629,7 @@ var AuthError = /** @class */ (function (_super) {
|
|
|
644
629
|
return AuthError;
|
|
645
630
|
}(Error));
|
|
646
631
|
|
|
647
|
-
/*! @azure/msal-common
|
|
632
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
648
633
|
|
|
649
634
|
/*
|
|
650
635
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -719,7 +704,7 @@ var DEFAULT_CRYPTO_IMPLEMENTATION = {
|
|
|
719
704
|
}
|
|
720
705
|
};
|
|
721
706
|
|
|
722
|
-
/*! @azure/msal-common
|
|
707
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
723
708
|
|
|
724
709
|
/*
|
|
725
710
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -923,6 +908,14 @@ var ClientAuthErrorMessage = {
|
|
|
923
908
|
keyIdMissing: {
|
|
924
909
|
code: "key_id_missing",
|
|
925
910
|
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."
|
|
911
|
+
},
|
|
912
|
+
noNetworkConnectivity: {
|
|
913
|
+
code: "no_network_connectivity",
|
|
914
|
+
desc: "No network connectivity. Check your internet connection."
|
|
915
|
+
},
|
|
916
|
+
userCanceledError: {
|
|
917
|
+
code: "user_canceled",
|
|
918
|
+
desc: "User canceled the flow."
|
|
926
919
|
}
|
|
927
920
|
};
|
|
928
921
|
/**
|
|
@@ -1211,10 +1204,22 @@ var ClientAuthError = /** @class */ (function (_super) {
|
|
|
1211
1204
|
ClientAuthError.createKeyIdMissingError = function () {
|
|
1212
1205
|
return new ClientAuthError(ClientAuthErrorMessage.keyIdMissing.code, ClientAuthErrorMessage.keyIdMissing.desc);
|
|
1213
1206
|
};
|
|
1207
|
+
/**
|
|
1208
|
+
* Create an error when the client does not have network connectivity
|
|
1209
|
+
*/
|
|
1210
|
+
ClientAuthError.createNoNetworkConnectivityError = function () {
|
|
1211
|
+
return new ClientAuthError(ClientAuthErrorMessage.noNetworkConnectivity.code, ClientAuthErrorMessage.noNetworkConnectivity.desc);
|
|
1212
|
+
};
|
|
1213
|
+
/**
|
|
1214
|
+
* Create an error when the user cancels the flow
|
|
1215
|
+
*/
|
|
1216
|
+
ClientAuthError.createUserCanceledError = function () {
|
|
1217
|
+
return new ClientAuthError(ClientAuthErrorMessage.userCanceledError.code, ClientAuthErrorMessage.userCanceledError.desc);
|
|
1218
|
+
};
|
|
1214
1219
|
return ClientAuthError;
|
|
1215
1220
|
}(AuthError));
|
|
1216
1221
|
|
|
1217
|
-
/*! @azure/msal-common
|
|
1222
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
1218
1223
|
|
|
1219
1224
|
/*
|
|
1220
1225
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1339,7 +1344,7 @@ var StringUtils = /** @class */ (function () {
|
|
|
1339
1344
|
return StringUtils;
|
|
1340
1345
|
}());
|
|
1341
1346
|
|
|
1342
|
-
/*! @azure/msal-common
|
|
1347
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
1343
1348
|
|
|
1344
1349
|
/*
|
|
1345
1350
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1529,12 +1534,12 @@ var Logger = /** @class */ (function () {
|
|
|
1529
1534
|
return Logger;
|
|
1530
1535
|
}());
|
|
1531
1536
|
|
|
1532
|
-
/*! @azure/msal-common
|
|
1537
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
1533
1538
|
/* eslint-disable header/header */
|
|
1534
1539
|
var name$1 = "@azure/msal-common";
|
|
1535
|
-
var version$1 = "
|
|
1540
|
+
var version$1 = "12.0.0";
|
|
1536
1541
|
|
|
1537
|
-
/*! @azure/msal-common
|
|
1542
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
1538
1543
|
/*
|
|
1539
1544
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
1540
1545
|
* Licensed under the MIT License.
|
|
@@ -1555,181 +1560,7 @@ exports.AzureCloudInstance = void 0;
|
|
|
1555
1560
|
AzureCloudInstance["AzureUsGovernment"] = "https://login.microsoftonline.us";
|
|
1556
1561
|
})(exports.AzureCloudInstance || (exports.AzureCloudInstance = {}));
|
|
1557
1562
|
|
|
1558
|
-
/*! @azure/msal-common
|
|
1559
|
-
|
|
1560
|
-
/*
|
|
1561
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
1562
|
-
* Licensed under the MIT License.
|
|
1563
|
-
*/
|
|
1564
|
-
/**
|
|
1565
|
-
* Base type for credentials to be stored in the cache: eg: ACCESS_TOKEN, ID_TOKEN etc
|
|
1566
|
-
*
|
|
1567
|
-
* Key:Value Schema:
|
|
1568
|
-
*
|
|
1569
|
-
* Key: <home_account_id*>-<environment>-<credential_type>-<client_id>-<realm*>-<target*>-<requestedClaims*>-<scheme*>
|
|
1570
|
-
*
|
|
1571
|
-
* Value Schema:
|
|
1572
|
-
* {
|
|
1573
|
-
* homeAccountId: home account identifier for the auth scheme,
|
|
1574
|
-
* environment: entity that issued the token, represented as a full host
|
|
1575
|
-
* credentialType: Type of credential as a string, can be one of the following: RefreshToken, AccessToken, IdToken, Password, Cookie, Certificate, Other
|
|
1576
|
-
* clientId: client ID of the application
|
|
1577
|
-
* secret: Actual credential as a string
|
|
1578
|
-
* familyId: Family ID identifier, usually only used for refresh tokens
|
|
1579
|
-
* realm: Full tenant or organizational identifier that the account belongs to
|
|
1580
|
-
* target: Permissions that are included in the token, or for refresh tokens, the resource identifier.
|
|
1581
|
-
* tokenType: Matches the authentication scheme for which the token was issued (i.e. Bearer or pop)
|
|
1582
|
-
* requestedClaimsHash: Matches the SHA 256 hash of the claims object included in the token request
|
|
1583
|
-
* userAssertionHash: Matches the SHA 256 hash of the obo_assertion for the OBO flow
|
|
1584
|
-
* }
|
|
1585
|
-
*/
|
|
1586
|
-
var CredentialEntity = /** @class */ (function () {
|
|
1587
|
-
function CredentialEntity() {
|
|
1588
|
-
}
|
|
1589
|
-
/**
|
|
1590
|
-
* Initializes a map with credential {CredentialType} regular expressions.
|
|
1591
|
-
*/
|
|
1592
|
-
CredentialEntity._initRegex = function () {
|
|
1593
|
-
var separator = Separators.CACHE_KEY_SEPARATOR;
|
|
1594
|
-
CredentialEntity.credentialRegexMap = new Map();
|
|
1595
|
-
for (var _i = 0, _a = Object.keys(CredentialType); _i < _a.length; _i++) {
|
|
1596
|
-
var credKey = _a[_i];
|
|
1597
|
-
var credVal = CredentialType[credKey].toLowerCase();
|
|
1598
|
-
try {
|
|
1599
|
-
// Verify credential type is preceded by a valid host name (environment) using lookbehind
|
|
1600
|
-
CredentialEntity.credentialRegexMap.set(CredentialType[credKey], new RegExp("(?<=" + separator + CredentialEntity.credentialDomainRegex + ")" + separator + credVal + separator));
|
|
1601
|
-
}
|
|
1602
|
-
catch (err) {
|
|
1603
|
-
// Lookbehind is not supported (Safari or older versions of IE) - removing it
|
|
1604
|
-
CredentialEntity.credentialRegexMap.set(CredentialType[credKey], new RegExp("" + separator + CredentialEntity.credentialDomainRegex + separator + credVal + separator));
|
|
1605
|
-
}
|
|
1606
|
-
}
|
|
1607
|
-
};
|
|
1608
|
-
/**
|
|
1609
|
-
* Generate Account Id key component as per the schema: <home_account_id>-<environment>
|
|
1610
|
-
*/
|
|
1611
|
-
CredentialEntity.prototype.generateAccountId = function () {
|
|
1612
|
-
return CredentialEntity.generateAccountIdForCacheKey(this.homeAccountId, this.environment);
|
|
1613
|
-
};
|
|
1614
|
-
/**
|
|
1615
|
-
* Generate Credential Id key component as per the schema: <credential_type>-<client_id>-<realm>
|
|
1616
|
-
*/
|
|
1617
|
-
CredentialEntity.prototype.generateCredentialId = function () {
|
|
1618
|
-
return CredentialEntity.generateCredentialIdForCacheKey(this.credentialType, this.clientId, this.realm, this.familyId);
|
|
1619
|
-
};
|
|
1620
|
-
/**
|
|
1621
|
-
* Generate target key component as per schema: <target>
|
|
1622
|
-
*/
|
|
1623
|
-
CredentialEntity.prototype.generateTarget = function () {
|
|
1624
|
-
return CredentialEntity.generateTargetForCacheKey(this.target);
|
|
1625
|
-
};
|
|
1626
|
-
/**
|
|
1627
|
-
* generates credential key
|
|
1628
|
-
*/
|
|
1629
|
-
CredentialEntity.prototype.generateCredentialKey = function () {
|
|
1630
|
-
return CredentialEntity.generateCredentialCacheKey(this.homeAccountId, this.environment, this.credentialType, this.clientId, this.realm, this.target, this.familyId, this.tokenType, this.requestedClaimsHash);
|
|
1631
|
-
};
|
|
1632
|
-
/**
|
|
1633
|
-
* returns the type of the cache (in this case credential)
|
|
1634
|
-
*/
|
|
1635
|
-
CredentialEntity.prototype.generateType = function () {
|
|
1636
|
-
switch (this.credentialType) {
|
|
1637
|
-
case CredentialType.ID_TOKEN:
|
|
1638
|
-
return CacheType.ID_TOKEN;
|
|
1639
|
-
case CredentialType.ACCESS_TOKEN:
|
|
1640
|
-
case CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME:
|
|
1641
|
-
return CacheType.ACCESS_TOKEN;
|
|
1642
|
-
case CredentialType.REFRESH_TOKEN:
|
|
1643
|
-
return CacheType.REFRESH_TOKEN;
|
|
1644
|
-
default: {
|
|
1645
|
-
throw ClientAuthError.createUnexpectedCredentialTypeError();
|
|
1646
|
-
}
|
|
1647
|
-
}
|
|
1648
|
-
};
|
|
1649
|
-
/**
|
|
1650
|
-
* helper function to return `CredentialType`
|
|
1651
|
-
* @param key
|
|
1652
|
-
*/
|
|
1653
|
-
CredentialEntity.getCredentialType = function (key) {
|
|
1654
|
-
var _a;
|
|
1655
|
-
for (var _i = 0, _b = Object.keys(CredentialType); _i < _b.length; _i++) {
|
|
1656
|
-
var credKey = _b[_i];
|
|
1657
|
-
if ((_a = this.credentialRegexMap.get(CredentialType[credKey])) === null || _a === void 0 ? void 0 : _a.test(key.toLowerCase())) {
|
|
1658
|
-
return CredentialType[credKey];
|
|
1659
|
-
}
|
|
1660
|
-
}
|
|
1661
|
-
return Constants.NOT_DEFINED;
|
|
1662
|
-
};
|
|
1663
|
-
/**
|
|
1664
|
-
* generates credential key
|
|
1665
|
-
* <home_account_id*>-\<environment>-<credential_type>-<client_id>-<realm\*>-<target\*>-<scheme\*>
|
|
1666
|
-
*/
|
|
1667
|
-
CredentialEntity.generateCredentialCacheKey = function (homeAccountId, environment, credentialType, clientId, realm, target, familyId, tokenType, requestedClaimsHash) {
|
|
1668
|
-
var credentialKey = [
|
|
1669
|
-
this.generateAccountIdForCacheKey(homeAccountId, environment),
|
|
1670
|
-
this.generateCredentialIdForCacheKey(credentialType, clientId, realm, familyId),
|
|
1671
|
-
this.generateTargetForCacheKey(target),
|
|
1672
|
-
this.generateClaimsHashForCacheKey(requestedClaimsHash),
|
|
1673
|
-
this.generateSchemeForCacheKey(tokenType)
|
|
1674
|
-
];
|
|
1675
|
-
return credentialKey.join(Separators.CACHE_KEY_SEPARATOR).toLowerCase();
|
|
1676
|
-
};
|
|
1677
|
-
/**
|
|
1678
|
-
* generates Account Id for keys
|
|
1679
|
-
* @param homeAccountId
|
|
1680
|
-
* @param environment
|
|
1681
|
-
*/
|
|
1682
|
-
CredentialEntity.generateAccountIdForCacheKey = function (homeAccountId, environment) {
|
|
1683
|
-
var accountId = [homeAccountId, environment];
|
|
1684
|
-
return accountId.join(Separators.CACHE_KEY_SEPARATOR).toLowerCase();
|
|
1685
|
-
};
|
|
1686
|
-
/**
|
|
1687
|
-
* Generates Credential Id for keys
|
|
1688
|
-
* @param credentialType
|
|
1689
|
-
* @param realm
|
|
1690
|
-
* @param clientId
|
|
1691
|
-
* @param familyId
|
|
1692
|
-
*/
|
|
1693
|
-
CredentialEntity.generateCredentialIdForCacheKey = function (credentialType, clientId, realm, familyId) {
|
|
1694
|
-
var clientOrFamilyId = credentialType === CredentialType.REFRESH_TOKEN
|
|
1695
|
-
? familyId || clientId
|
|
1696
|
-
: clientId;
|
|
1697
|
-
var credentialId = [
|
|
1698
|
-
credentialType,
|
|
1699
|
-
clientOrFamilyId,
|
|
1700
|
-
realm || Constants.EMPTY_STRING,
|
|
1701
|
-
];
|
|
1702
|
-
return credentialId.join(Separators.CACHE_KEY_SEPARATOR).toLowerCase();
|
|
1703
|
-
};
|
|
1704
|
-
/**
|
|
1705
|
-
* Generate target key component as per schema: <target>
|
|
1706
|
-
*/
|
|
1707
|
-
CredentialEntity.generateTargetForCacheKey = function (scopes) {
|
|
1708
|
-
return (scopes || Constants.EMPTY_STRING).toLowerCase();
|
|
1709
|
-
};
|
|
1710
|
-
/**
|
|
1711
|
-
* Generate requested claims key component as per schema: <requestedClaims>
|
|
1712
|
-
*/
|
|
1713
|
-
CredentialEntity.generateClaimsHashForCacheKey = function (requestedClaimsHash) {
|
|
1714
|
-
return (requestedClaimsHash || Constants.EMPTY_STRING).toLowerCase();
|
|
1715
|
-
};
|
|
1716
|
-
/**
|
|
1717
|
-
* Generate scheme key componenet as per schema: <scheme>
|
|
1718
|
-
*/
|
|
1719
|
-
CredentialEntity.generateSchemeForCacheKey = function (tokenType) {
|
|
1720
|
-
/*
|
|
1721
|
-
* PoP Tokens and SSH certs include scheme in cache key
|
|
1722
|
-
* Cast to lowercase to handle "bearer" from ADFS
|
|
1723
|
-
*/
|
|
1724
|
-
return (tokenType && tokenType.toLowerCase() !== exports.AuthenticationScheme.BEARER.toLowerCase()) ? tokenType.toLowerCase() : Constants.EMPTY_STRING;
|
|
1725
|
-
};
|
|
1726
|
-
// Match host names like "login.microsoftonline.com", "https://accounts.google.com:4000", https://localhost:5000, etc.
|
|
1727
|
-
CredentialEntity.credentialDomainRegex = "(https?:\\/\\/)?((([\\w-]+\\.)*([\\w-]{1,63})(\\.(\\w{2,63})))|(localhost))(\\:[0-9]{4,5})?";
|
|
1728
|
-
return CredentialEntity;
|
|
1729
|
-
}());
|
|
1730
|
-
CredentialEntity._initRegex();
|
|
1731
|
-
|
|
1732
|
-
/*! @azure/msal-common v10.0.0 2023-02-06 */
|
|
1563
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
1733
1564
|
|
|
1734
1565
|
/*
|
|
1735
1566
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1984,7 +1815,7 @@ var ClientConfigurationError = /** @class */ (function (_super) {
|
|
|
1984
1815
|
return ClientConfigurationError;
|
|
1985
1816
|
}(ClientAuthError));
|
|
1986
1817
|
|
|
1987
|
-
/*! @azure/msal-common
|
|
1818
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
1988
1819
|
|
|
1989
1820
|
/*
|
|
1990
1821
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2017,6 +1848,21 @@ var ScopeSet = /** @class */ (function () {
|
|
|
2017
1848
|
var inputScopes = scopeString.split(" ");
|
|
2018
1849
|
return new ScopeSet(inputScopes);
|
|
2019
1850
|
};
|
|
1851
|
+
/**
|
|
1852
|
+
* Creates the set of scopes to search for in cache lookups
|
|
1853
|
+
* @param inputScopeString
|
|
1854
|
+
* @returns
|
|
1855
|
+
*/
|
|
1856
|
+
ScopeSet.createSearchScopes = function (inputScopeString) {
|
|
1857
|
+
var scopeSet = new ScopeSet(inputScopeString);
|
|
1858
|
+
if (!scopeSet.containsOnlyOIDCScopes()) {
|
|
1859
|
+
scopeSet.removeOIDCScopes();
|
|
1860
|
+
}
|
|
1861
|
+
else {
|
|
1862
|
+
scopeSet.removeScope(Constants.OFFLINE_ACCESS_SCOPE);
|
|
1863
|
+
}
|
|
1864
|
+
return scopeSet;
|
|
1865
|
+
};
|
|
2020
1866
|
/**
|
|
2021
1867
|
* Used to validate the scopes input parameter requested by the developer.
|
|
2022
1868
|
* @param {Array<string>} inputScopes - Developer requested permissions. Not all scopes are guaranteed to be included in the access token returned.
|
|
@@ -2168,7 +2014,7 @@ var ScopeSet = /** @class */ (function () {
|
|
|
2168
2014
|
return ScopeSet;
|
|
2169
2015
|
}());
|
|
2170
2016
|
|
|
2171
|
-
/*! @azure/msal-common
|
|
2017
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
2172
2018
|
|
|
2173
2019
|
/*
|
|
2174
2020
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2206,7 +2052,7 @@ function buildClientInfoFromHomeAccountId(homeAccountId) {
|
|
|
2206
2052
|
};
|
|
2207
2053
|
}
|
|
2208
2054
|
|
|
2209
|
-
/*! @azure/msal-common
|
|
2055
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
2210
2056
|
/*
|
|
2211
2057
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2212
2058
|
* Licensed under the MIT License.
|
|
@@ -2221,7 +2067,7 @@ var AuthorityType;
|
|
|
2221
2067
|
AuthorityType[AuthorityType["Dsts"] = 2] = "Dsts";
|
|
2222
2068
|
})(AuthorityType || (AuthorityType = {}));
|
|
2223
2069
|
|
|
2224
|
-
/*! @azure/msal-common
|
|
2070
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
2225
2071
|
|
|
2226
2072
|
/*
|
|
2227
2073
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2460,7 +2306,7 @@ var AccountEntity = /** @class */ (function () {
|
|
|
2460
2306
|
return AccountEntity;
|
|
2461
2307
|
}());
|
|
2462
2308
|
|
|
2463
|
-
/*! @azure/msal-common
|
|
2309
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
2464
2310
|
|
|
2465
2311
|
/*
|
|
2466
2312
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2512,7 +2358,7 @@ var AuthToken = /** @class */ (function () {
|
|
|
2512
2358
|
return AuthToken;
|
|
2513
2359
|
}());
|
|
2514
2360
|
|
|
2515
|
-
/*! @azure/msal-common
|
|
2361
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
2516
2362
|
|
|
2517
2363
|
/*
|
|
2518
2364
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2522,35 +2368,59 @@ var AuthToken = /** @class */ (function () {
|
|
|
2522
2368
|
* Interface class which implement cache storage functions used by MSAL to perform validity checks, and store tokens.
|
|
2523
2369
|
*/
|
|
2524
2370
|
var CacheManager = /** @class */ (function () {
|
|
2525
|
-
function CacheManager(clientId, cryptoImpl) {
|
|
2371
|
+
function CacheManager(clientId, cryptoImpl, logger) {
|
|
2526
2372
|
this.clientId = clientId;
|
|
2527
2373
|
this.cryptoImpl = cryptoImpl;
|
|
2374
|
+
this.commonLogger = logger.clone(name$1, version$1);
|
|
2528
2375
|
}
|
|
2529
2376
|
/**
|
|
2530
2377
|
* Returns all accounts in cache
|
|
2531
2378
|
*/
|
|
2532
2379
|
CacheManager.prototype.getAllAccounts = function () {
|
|
2533
2380
|
var _this = this;
|
|
2534
|
-
var
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2381
|
+
var allAccountKeys = this.getAccountKeys();
|
|
2382
|
+
if (allAccountKeys.length < 1) {
|
|
2383
|
+
return [];
|
|
2384
|
+
}
|
|
2385
|
+
var accountEntities = allAccountKeys.reduce(function (accounts, key) {
|
|
2386
|
+
var entity = _this.getAccount(key);
|
|
2387
|
+
if (!entity) {
|
|
2388
|
+
return accounts;
|
|
2389
|
+
}
|
|
2390
|
+
accounts.push(entity);
|
|
2391
|
+
return accounts;
|
|
2392
|
+
}, []);
|
|
2393
|
+
if (accountEntities.length < 1) {
|
|
2538
2394
|
return [];
|
|
2539
2395
|
}
|
|
2540
2396
|
else {
|
|
2541
|
-
var allAccounts =
|
|
2542
|
-
|
|
2543
|
-
var accountInfo = accountEntity.getAccountInfo();
|
|
2544
|
-
var idToken = _this.readIdTokenFromCache(_this.clientId, accountInfo);
|
|
2545
|
-
if (idToken && !accountInfo.idTokenClaims) {
|
|
2546
|
-
accountInfo.idToken = idToken.secret;
|
|
2547
|
-
accountInfo.idTokenClaims = new AuthToken(idToken.secret, _this.cryptoImpl).claims;
|
|
2548
|
-
}
|
|
2549
|
-
return accountInfo;
|
|
2397
|
+
var allAccounts = accountEntities.map(function (accountEntity) {
|
|
2398
|
+
return _this.getAccountInfoFromEntity(accountEntity);
|
|
2550
2399
|
});
|
|
2551
2400
|
return allAccounts;
|
|
2552
2401
|
}
|
|
2553
2402
|
};
|
|
2403
|
+
/**
|
|
2404
|
+
* Gets accountInfo object based on provided filters
|
|
2405
|
+
*/
|
|
2406
|
+
CacheManager.prototype.getAccountInfoFilteredBy = function (accountFilter) {
|
|
2407
|
+
var allAccounts = this.getAccountsFilteredBy(accountFilter);
|
|
2408
|
+
if (allAccounts.length > 0) {
|
|
2409
|
+
return this.getAccountInfoFromEntity(allAccounts[0]);
|
|
2410
|
+
}
|
|
2411
|
+
else {
|
|
2412
|
+
return null;
|
|
2413
|
+
}
|
|
2414
|
+
};
|
|
2415
|
+
CacheManager.prototype.getAccountInfoFromEntity = function (accountEntity) {
|
|
2416
|
+
var accountInfo = accountEntity.getAccountInfo();
|
|
2417
|
+
var idToken = this.getIdToken(accountInfo);
|
|
2418
|
+
if (idToken) {
|
|
2419
|
+
accountInfo.idToken = idToken.secret;
|
|
2420
|
+
accountInfo.idTokenClaims = new AuthToken(idToken.secret, this.cryptoImpl).claims;
|
|
2421
|
+
}
|
|
2422
|
+
return accountInfo;
|
|
2423
|
+
};
|
|
2554
2424
|
/**
|
|
2555
2425
|
* saves a cache record
|
|
2556
2426
|
* @param cacheRecord
|
|
@@ -2592,12 +2462,12 @@ var CacheManager = /** @class */ (function () {
|
|
|
2592
2462
|
*/
|
|
2593
2463
|
CacheManager.prototype.saveAccessToken = function (credential) {
|
|
2594
2464
|
return __awaiter(this, void 0, void 0, function () {
|
|
2595
|
-
var
|
|
2465
|
+
var accessTokenFilter, tokenKeys, currentScopes, removedAccessTokens;
|
|
2596
2466
|
var _this = this;
|
|
2597
2467
|
return __generator(this, function (_a) {
|
|
2598
2468
|
switch (_a.label) {
|
|
2599
2469
|
case 0:
|
|
2600
|
-
|
|
2470
|
+
accessTokenFilter = {
|
|
2601
2471
|
clientId: credential.clientId,
|
|
2602
2472
|
credentialType: credential.credentialType,
|
|
2603
2473
|
environment: credential.environment,
|
|
@@ -2605,22 +2475,25 @@ var CacheManager = /** @class */ (function () {
|
|
|
2605
2475
|
realm: credential.realm,
|
|
2606
2476
|
tokenType: credential.tokenType,
|
|
2607
2477
|
requestedClaimsHash: credential.requestedClaimsHash
|
|
2608
|
-
}
|
|
2478
|
+
};
|
|
2479
|
+
tokenKeys = this.getTokenKeys();
|
|
2609
2480
|
currentScopes = ScopeSet.fromString(credential.target);
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2481
|
+
removedAccessTokens = [];
|
|
2482
|
+
tokenKeys.accessToken.forEach(function (key) {
|
|
2483
|
+
if (!_this.accessTokenKeyMatchesFilter(key, accessTokenFilter, false)) {
|
|
2484
|
+
return;
|
|
2485
|
+
}
|
|
2486
|
+
var tokenEntity = _this.getAccessTokenCredential(key);
|
|
2487
|
+
if (tokenEntity && _this.credentialMatchesFilter(tokenEntity, accessTokenFilter)) {
|
|
2488
|
+
var tokenScopeSet = ScopeSet.fromString(tokenEntity.target);
|
|
2489
|
+
if (tokenScopeSet.intersectingScopeSets(currentScopes)) {
|
|
2490
|
+
removedAccessTokens.push(_this.removeAccessToken(key));
|
|
2491
|
+
}
|
|
2617
2492
|
}
|
|
2618
2493
|
});
|
|
2619
|
-
return [4 /*yield*/, Promise.all(
|
|
2494
|
+
return [4 /*yield*/, Promise.all(removedAccessTokens)];
|
|
2620
2495
|
case 1:
|
|
2621
2496
|
_a.sent();
|
|
2622
|
-
_a.label = 2;
|
|
2623
|
-
case 2:
|
|
2624
2497
|
this.setAccessTokenCredential(credential);
|
|
2625
2498
|
return [2 /*return*/];
|
|
2626
2499
|
}
|
|
@@ -2635,149 +2508,151 @@ var CacheManager = /** @class */ (function () {
|
|
|
2635
2508
|
* @param realm
|
|
2636
2509
|
*/
|
|
2637
2510
|
CacheManager.prototype.getAccountsFilteredBy = function (accountFilter) {
|
|
2638
|
-
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);
|
|
2639
|
-
};
|
|
2640
|
-
/**
|
|
2641
|
-
* retrieve accounts matching all provided filters; if no filter is set, get all accounts
|
|
2642
|
-
* not checking for casing as keys are all generated in lower case, remember to convert to lower case if object properties are compared
|
|
2643
|
-
* @param homeAccountId
|
|
2644
|
-
* @param environment
|
|
2645
|
-
* @param realm
|
|
2646
|
-
*/
|
|
2647
|
-
CacheManager.prototype.getAccountsFilteredByInternal = function (homeAccountId, environment, realm, nativeAccountId) {
|
|
2648
2511
|
var _this = this;
|
|
2649
|
-
var
|
|
2650
|
-
var matchingAccounts =
|
|
2651
|
-
|
|
2512
|
+
var allAccountKeys = this.getAccountKeys();
|
|
2513
|
+
var matchingAccounts = [];
|
|
2514
|
+
allAccountKeys.forEach(function (cacheKey) {
|
|
2515
|
+
if (!_this.isAccountKey(cacheKey, accountFilter.homeAccountId, accountFilter.realm)) {
|
|
2516
|
+
// Don't parse value if the key doesn't match the account filters
|
|
2517
|
+
return;
|
|
2518
|
+
}
|
|
2652
2519
|
var entity = _this.getAccount(cacheKey);
|
|
2653
2520
|
if (!entity) {
|
|
2654
2521
|
return;
|
|
2655
2522
|
}
|
|
2656
|
-
if (!!homeAccountId && !_this.matchHomeAccountId(entity, homeAccountId)) {
|
|
2523
|
+
if (!!accountFilter.homeAccountId && !_this.matchHomeAccountId(entity, accountFilter.homeAccountId)) {
|
|
2657
2524
|
return;
|
|
2658
2525
|
}
|
|
2659
|
-
if (!!
|
|
2526
|
+
if (!!accountFilter.localAccountId && !_this.matchLocalAccountId(entity, accountFilter.localAccountId)) {
|
|
2527
|
+
return;
|
|
2528
|
+
}
|
|
2529
|
+
if (!!accountFilter.username && !_this.matchUsername(entity, accountFilter.username)) {
|
|
2660
2530
|
return;
|
|
2661
2531
|
}
|
|
2662
|
-
if (!!
|
|
2532
|
+
if (!!accountFilter.environment && !_this.matchEnvironment(entity, accountFilter.environment)) {
|
|
2663
2533
|
return;
|
|
2664
2534
|
}
|
|
2665
|
-
if (!!
|
|
2535
|
+
if (!!accountFilter.realm && !_this.matchRealm(entity, accountFilter.realm)) {
|
|
2666
2536
|
return;
|
|
2667
2537
|
}
|
|
2668
|
-
|
|
2538
|
+
if (!!accountFilter.nativeAccountId && !_this.matchNativeAccountId(entity, accountFilter.nativeAccountId)) {
|
|
2539
|
+
return;
|
|
2540
|
+
}
|
|
2541
|
+
matchingAccounts.push(entity);
|
|
2669
2542
|
});
|
|
2670
2543
|
return matchingAccounts;
|
|
2671
2544
|
};
|
|
2672
2545
|
/**
|
|
2673
|
-
*
|
|
2546
|
+
* Returns true if the given key matches our account key schema. Also matches homeAccountId and/or tenantId if provided
|
|
2547
|
+
* @param key
|
|
2674
2548
|
* @param homeAccountId
|
|
2675
|
-
* @param
|
|
2676
|
-
* @
|
|
2677
|
-
* @param clientId
|
|
2678
|
-
* @param realm
|
|
2679
|
-
* @param target
|
|
2549
|
+
* @param tenantId
|
|
2550
|
+
* @returns
|
|
2680
2551
|
*/
|
|
2681
|
-
CacheManager.prototype.
|
|
2682
|
-
|
|
2552
|
+
CacheManager.prototype.isAccountKey = function (key, homeAccountId, tenantId) {
|
|
2553
|
+
if (key.split(Separators.CACHE_KEY_SEPARATOR).length < 3) {
|
|
2554
|
+
// Account cache keys contain 3 items separated by '-' (each item may also contain '-')
|
|
2555
|
+
return false;
|
|
2556
|
+
}
|
|
2557
|
+
if (homeAccountId && !key.toLowerCase().includes(homeAccountId.toLowerCase())) {
|
|
2558
|
+
return false;
|
|
2559
|
+
}
|
|
2560
|
+
if (tenantId && !key.toLowerCase().includes(tenantId.toLowerCase())) {
|
|
2561
|
+
return false;
|
|
2562
|
+
}
|
|
2563
|
+
// Do not check environment as aliasing can cause false negatives
|
|
2564
|
+
return true;
|
|
2683
2565
|
};
|
|
2684
2566
|
/**
|
|
2685
|
-
*
|
|
2686
|
-
* @param
|
|
2687
|
-
* @param environment
|
|
2688
|
-
* @param credentialType
|
|
2689
|
-
* @param clientId
|
|
2690
|
-
* @param realm
|
|
2691
|
-
* @param target
|
|
2692
|
-
* @param userAssertionHash
|
|
2693
|
-
* @param tokenType
|
|
2567
|
+
* Returns true if the given key matches our credential key schema.
|
|
2568
|
+
* @param key
|
|
2694
2569
|
*/
|
|
2695
|
-
CacheManager.prototype.
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
//
|
|
2710
|
-
var
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
if (!!userAssertionHash && !_this.matchUserAssertionHash(entity, userAssertionHash)) {
|
|
2715
|
-
return;
|
|
2716
|
-
}
|
|
2717
|
-
/*
|
|
2718
|
-
* homeAccountId can undefined, and we want to filter out cached items that have a homeAccountId of ""
|
|
2719
|
-
* because we don't want a client_credential request to return a cached token that has a homeAccountId
|
|
2720
|
-
*/
|
|
2721
|
-
if ((typeof homeAccountId === "string") && !_this.matchHomeAccountId(entity, homeAccountId)) {
|
|
2722
|
-
return;
|
|
2723
|
-
}
|
|
2724
|
-
if (!!environment && !_this.matchEnvironment(entity, environment)) {
|
|
2725
|
-
return;
|
|
2726
|
-
}
|
|
2727
|
-
if (!!realm && !_this.matchRealm(entity, realm)) {
|
|
2728
|
-
return;
|
|
2729
|
-
}
|
|
2730
|
-
if (!!credentialType && !_this.matchCredentialType(entity, credentialType)) {
|
|
2731
|
-
return;
|
|
2732
|
-
}
|
|
2733
|
-
if (!!clientId && !_this.matchClientId(entity, clientId)) {
|
|
2734
|
-
return;
|
|
2735
|
-
}
|
|
2736
|
-
if (!!familyId && !_this.matchFamilyId(entity, familyId)) {
|
|
2737
|
-
return;
|
|
2570
|
+
CacheManager.prototype.isCredentialKey = function (key) {
|
|
2571
|
+
if (key.split(Separators.CACHE_KEY_SEPARATOR).length < 6) {
|
|
2572
|
+
// Credential cache keys contain 6 items separated by '-' (each item may also contain '-')
|
|
2573
|
+
return false;
|
|
2574
|
+
}
|
|
2575
|
+
var lowerCaseKey = key.toLowerCase();
|
|
2576
|
+
// Credential keys must indicate what credential type they represent
|
|
2577
|
+
if (lowerCaseKey.indexOf(CredentialType.ID_TOKEN.toLowerCase()) === -1 &&
|
|
2578
|
+
lowerCaseKey.indexOf(CredentialType.ACCESS_TOKEN.toLowerCase()) === -1 &&
|
|
2579
|
+
lowerCaseKey.indexOf(CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME.toLowerCase()) === -1 &&
|
|
2580
|
+
lowerCaseKey.indexOf(CredentialType.REFRESH_TOKEN.toLowerCase()) === -1) {
|
|
2581
|
+
return false;
|
|
2582
|
+
}
|
|
2583
|
+
if (lowerCaseKey.indexOf(CredentialType.REFRESH_TOKEN.toLowerCase()) > -1) {
|
|
2584
|
+
// Refresh tokens must contain the client id or family id
|
|
2585
|
+
var clientIdValidation = "" + CredentialType.REFRESH_TOKEN + Separators.CACHE_KEY_SEPARATOR + this.clientId + Separators.CACHE_KEY_SEPARATOR;
|
|
2586
|
+
var familyIdValidation = "" + CredentialType.REFRESH_TOKEN + Separators.CACHE_KEY_SEPARATOR + THE_FAMILY_ID + Separators.CACHE_KEY_SEPARATOR;
|
|
2587
|
+
if (lowerCaseKey.indexOf(clientIdValidation.toLowerCase()) === -1 && lowerCaseKey.indexOf(familyIdValidation.toLowerCase()) === -1) {
|
|
2588
|
+
return false;
|
|
2738
2589
|
}
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2590
|
+
}
|
|
2591
|
+
else if (lowerCaseKey.indexOf(this.clientId.toLowerCase()) === -1) {
|
|
2592
|
+
// Tokens must contain the clientId
|
|
2593
|
+
return false;
|
|
2594
|
+
}
|
|
2595
|
+
return true;
|
|
2596
|
+
};
|
|
2597
|
+
/**
|
|
2598
|
+
* Returns whether or not the given credential entity matches the filter
|
|
2599
|
+
* @param entity
|
|
2600
|
+
* @param filter
|
|
2601
|
+
* @returns
|
|
2602
|
+
*/
|
|
2603
|
+
CacheManager.prototype.credentialMatchesFilter = function (entity, filter) {
|
|
2604
|
+
if (!!filter.clientId && !this.matchClientId(entity, filter.clientId)) {
|
|
2605
|
+
return false;
|
|
2606
|
+
}
|
|
2607
|
+
if (!!filter.userAssertionHash && !this.matchUserAssertionHash(entity, filter.userAssertionHash)) {
|
|
2608
|
+
return false;
|
|
2609
|
+
}
|
|
2610
|
+
/*
|
|
2611
|
+
* homeAccountId can be undefined, and we want to filter out cached items that have a homeAccountId of ""
|
|
2612
|
+
* because we don't want a client_credential request to return a cached token that has a homeAccountId
|
|
2613
|
+
*/
|
|
2614
|
+
if ((typeof filter.homeAccountId === "string") && !this.matchHomeAccountId(entity, filter.homeAccountId)) {
|
|
2615
|
+
return false;
|
|
2616
|
+
}
|
|
2617
|
+
if (!!filter.environment && !this.matchEnvironment(entity, filter.environment)) {
|
|
2618
|
+
return false;
|
|
2619
|
+
}
|
|
2620
|
+
if (!!filter.realm && !this.matchRealm(entity, filter.realm)) {
|
|
2621
|
+
return false;
|
|
2622
|
+
}
|
|
2623
|
+
if (!!filter.credentialType && !this.matchCredentialType(entity, filter.credentialType)) {
|
|
2624
|
+
return false;
|
|
2625
|
+
}
|
|
2626
|
+
if (!!filter.familyId && !this.matchFamilyId(entity, filter.familyId)) {
|
|
2627
|
+
return false;
|
|
2628
|
+
}
|
|
2629
|
+
/*
|
|
2630
|
+
* idTokens do not have "target", target specific refreshTokens do exist for some types of authentication
|
|
2631
|
+
* Resource specific refresh tokens case will be added when the support is deemed necessary
|
|
2632
|
+
*/
|
|
2633
|
+
if (!!filter.target && !this.matchTarget(entity, filter.target)) {
|
|
2634
|
+
return false;
|
|
2635
|
+
}
|
|
2636
|
+
// If request OR cached entity has requested Claims Hash, check if they match
|
|
2637
|
+
if (filter.requestedClaimsHash || entity.requestedClaimsHash) {
|
|
2638
|
+
// Don't match if either is undefined or they are different
|
|
2639
|
+
if (entity.requestedClaimsHash !== filter.requestedClaimsHash) {
|
|
2640
|
+
return false;
|
|
2745
2641
|
}
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
}
|
|
2642
|
+
}
|
|
2643
|
+
// Access Token with Auth Scheme specific matching
|
|
2644
|
+
if (entity.credentialType === CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME) {
|
|
2645
|
+
if (!!filter.tokenType && !this.matchTokenType(entity, filter.tokenType)) {
|
|
2646
|
+
return false;
|
|
2752
2647
|
}
|
|
2753
|
-
//
|
|
2754
|
-
if (
|
|
2755
|
-
if (
|
|
2756
|
-
return;
|
|
2757
|
-
}
|
|
2758
|
-
// KeyId (sshKid) in request must match cached SSH certificate keyId because SSH cert is bound to a specific key
|
|
2759
|
-
if (tokenType === exports.AuthenticationScheme.SSH) {
|
|
2760
|
-
if (keyId && !_this.matchKeyId(entity, keyId)) {
|
|
2761
|
-
return;
|
|
2762
|
-
}
|
|
2648
|
+
// KeyId (sshKid) in request must match cached SSH certificate keyId because SSH cert is bound to a specific key
|
|
2649
|
+
if (filter.tokenType === exports.AuthenticationScheme.SSH) {
|
|
2650
|
+
if (filter.keyId && !this.matchKeyId(entity, filter.keyId)) {
|
|
2651
|
+
return false;
|
|
2763
2652
|
}
|
|
2764
2653
|
}
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
switch (credType) {
|
|
2768
|
-
case CredentialType.ID_TOKEN:
|
|
2769
|
-
matchingCredentials.idTokens[updatedCacheKey] = entity;
|
|
2770
|
-
break;
|
|
2771
|
-
case CredentialType.ACCESS_TOKEN:
|
|
2772
|
-
case CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME:
|
|
2773
|
-
matchingCredentials.accessTokens[updatedCacheKey] = entity;
|
|
2774
|
-
break;
|
|
2775
|
-
case CredentialType.REFRESH_TOKEN:
|
|
2776
|
-
matchingCredentials.refreshTokens[updatedCacheKey] = entity;
|
|
2777
|
-
break;
|
|
2778
|
-
}
|
|
2779
|
-
});
|
|
2780
|
-
return matchingCredentials;
|
|
2654
|
+
}
|
|
2655
|
+
return true;
|
|
2781
2656
|
};
|
|
2782
2657
|
/**
|
|
2783
2658
|
* retrieve appMetadata matching all provided filters; if no filter is set, get all appMetadata
|
|
@@ -2845,30 +2720,26 @@ var CacheManager = /** @class */ (function () {
|
|
|
2845
2720
|
*/
|
|
2846
2721
|
CacheManager.prototype.removeAllAccounts = function () {
|
|
2847
2722
|
return __awaiter(this, void 0, void 0, function () {
|
|
2848
|
-
var
|
|
2723
|
+
var allAccountKeys, removedAccounts;
|
|
2849
2724
|
var _this = this;
|
|
2850
2725
|
return __generator(this, function (_a) {
|
|
2851
2726
|
switch (_a.label) {
|
|
2852
2727
|
case 0:
|
|
2853
|
-
|
|
2728
|
+
allAccountKeys = this.getAccountKeys();
|
|
2854
2729
|
removedAccounts = [];
|
|
2855
|
-
|
|
2856
|
-
var entity = _this.getAccount(cacheKey);
|
|
2857
|
-
if (!entity) {
|
|
2858
|
-
return;
|
|
2859
|
-
}
|
|
2730
|
+
allAccountKeys.forEach(function (cacheKey) {
|
|
2860
2731
|
removedAccounts.push(_this.removeAccount(cacheKey));
|
|
2861
2732
|
});
|
|
2862
2733
|
return [4 /*yield*/, Promise.all(removedAccounts)];
|
|
2863
2734
|
case 1:
|
|
2864
2735
|
_a.sent();
|
|
2865
|
-
return [2 /*return
|
|
2736
|
+
return [2 /*return*/];
|
|
2866
2737
|
}
|
|
2867
2738
|
});
|
|
2868
2739
|
});
|
|
2869
2740
|
};
|
|
2870
2741
|
/**
|
|
2871
|
-
*
|
|
2742
|
+
* Removes the account and related tokens for a given account key
|
|
2872
2743
|
* @param account
|
|
2873
2744
|
*/
|
|
2874
2745
|
CacheManager.prototype.removeAccount = function (accountKey) {
|
|
@@ -2882,7 +2753,10 @@ var CacheManager = /** @class */ (function () {
|
|
|
2882
2753
|
throw ClientAuthError.createNoAccountFoundError();
|
|
2883
2754
|
}
|
|
2884
2755
|
return [4 /*yield*/, this.removeAccountContext(account)];
|
|
2885
|
-
case 1:
|
|
2756
|
+
case 1:
|
|
2757
|
+
_a.sent();
|
|
2758
|
+
this.removeItem(accountKey);
|
|
2759
|
+
return [2 /*return*/];
|
|
2886
2760
|
}
|
|
2887
2761
|
});
|
|
2888
2762
|
});
|
|
@@ -2893,29 +2767,33 @@ var CacheManager = /** @class */ (function () {
|
|
|
2893
2767
|
*/
|
|
2894
2768
|
CacheManager.prototype.removeAccountContext = function (account) {
|
|
2895
2769
|
return __awaiter(this, void 0, void 0, function () {
|
|
2896
|
-
var
|
|
2770
|
+
var allTokenKeys, accountId, removedCredentials;
|
|
2897
2771
|
var _this = this;
|
|
2898
2772
|
return __generator(this, function (_a) {
|
|
2899
2773
|
switch (_a.label) {
|
|
2900
2774
|
case 0:
|
|
2901
|
-
|
|
2775
|
+
allTokenKeys = this.getTokenKeys();
|
|
2902
2776
|
accountId = account.generateAccountId();
|
|
2903
2777
|
removedCredentials = [];
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
if (credType === Constants.NOT_DEFINED) {
|
|
2908
|
-
return;
|
|
2778
|
+
allTokenKeys.idToken.forEach(function (key) {
|
|
2779
|
+
if (key.indexOf(accountId) === 0) {
|
|
2780
|
+
_this.removeIdToken(key);
|
|
2909
2781
|
}
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2782
|
+
});
|
|
2783
|
+
allTokenKeys.accessToken.forEach(function (key) {
|
|
2784
|
+
if (key.indexOf(accountId) === 0) {
|
|
2785
|
+
removedCredentials.push(_this.removeAccessToken(key));
|
|
2786
|
+
}
|
|
2787
|
+
});
|
|
2788
|
+
allTokenKeys.refreshToken.forEach(function (key) {
|
|
2789
|
+
if (key.indexOf(accountId) === 0) {
|
|
2790
|
+
_this.removeRefreshToken(key);
|
|
2913
2791
|
}
|
|
2914
2792
|
});
|
|
2915
2793
|
return [4 /*yield*/, Promise.all(removedCredentials)];
|
|
2916
2794
|
case 1:
|
|
2917
2795
|
_a.sent();
|
|
2918
|
-
return [2 /*return
|
|
2796
|
+
return [2 /*return*/];
|
|
2919
2797
|
}
|
|
2920
2798
|
});
|
|
2921
2799
|
});
|
|
@@ -2924,13 +2802,16 @@ var CacheManager = /** @class */ (function () {
|
|
|
2924
2802
|
* returns a boolean if the given credential is removed
|
|
2925
2803
|
* @param credential
|
|
2926
2804
|
*/
|
|
2927
|
-
CacheManager.prototype.
|
|
2805
|
+
CacheManager.prototype.removeAccessToken = function (key) {
|
|
2928
2806
|
return __awaiter(this, void 0, void 0, function () {
|
|
2929
|
-
var
|
|
2807
|
+
var credential, accessTokenWithAuthSchemeEntity, kid;
|
|
2930
2808
|
return __generator(this, function (_a) {
|
|
2931
2809
|
switch (_a.label) {
|
|
2932
2810
|
case 0:
|
|
2933
|
-
|
|
2811
|
+
credential = this.getAccessTokenCredential(key);
|
|
2812
|
+
if (!credential) {
|
|
2813
|
+
return [2 /*return*/];
|
|
2814
|
+
}
|
|
2934
2815
|
if (!(credential.credentialType.toLowerCase() === CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME.toLowerCase())) return [3 /*break*/, 4];
|
|
2935
2816
|
if (!(credential.tokenType === exports.AuthenticationScheme.POP)) return [3 /*break*/, 4];
|
|
2936
2817
|
accessTokenWithAuthSchemeEntity = credential;
|
|
@@ -2946,7 +2827,7 @@ var CacheManager = /** @class */ (function () {
|
|
|
2946
2827
|
case 3:
|
|
2947
2828
|
_a.sent();
|
|
2948
2829
|
throw ClientAuthError.createBindingKeyNotRemovedError();
|
|
2949
|
-
case 4: return [2 /*return*/, this.removeItem(key
|
|
2830
|
+
case 4: return [2 /*return*/, this.removeItem(key)];
|
|
2950
2831
|
}
|
|
2951
2832
|
});
|
|
2952
2833
|
});
|
|
@@ -2959,7 +2840,7 @@ var CacheManager = /** @class */ (function () {
|
|
|
2959
2840
|
var allCacheKeys = this.getKeys();
|
|
2960
2841
|
allCacheKeys.forEach(function (cacheKey) {
|
|
2961
2842
|
if (_this.isAppMetadata(cacheKey)) {
|
|
2962
|
-
_this.removeItem(cacheKey
|
|
2843
|
+
_this.removeItem(cacheKey);
|
|
2963
2844
|
}
|
|
2964
2845
|
});
|
|
2965
2846
|
return true;
|
|
@@ -2972,12 +2853,13 @@ var CacheManager = /** @class */ (function () {
|
|
|
2972
2853
|
* @param environment
|
|
2973
2854
|
* @param authScheme
|
|
2974
2855
|
*/
|
|
2975
|
-
CacheManager.prototype.readCacheRecord = function (account,
|
|
2856
|
+
CacheManager.prototype.readCacheRecord = function (account, request, environment) {
|
|
2857
|
+
var tokenKeys = this.getTokenKeys();
|
|
2976
2858
|
var cachedAccount = this.readAccountFromCache(account);
|
|
2977
|
-
var cachedIdToken = this.
|
|
2978
|
-
var cachedAccessToken = this.
|
|
2979
|
-
var cachedRefreshToken = this.
|
|
2980
|
-
var cachedAppMetadata = this.readAppMetadataFromCache(environment
|
|
2859
|
+
var cachedIdToken = this.getIdToken(account, tokenKeys);
|
|
2860
|
+
var cachedAccessToken = this.getAccessToken(account, request, tokenKeys);
|
|
2861
|
+
var cachedRefreshToken = this.getRefreshToken(account, false, tokenKeys);
|
|
2862
|
+
var cachedAppMetadata = this.readAppMetadataFromCache(environment);
|
|
2981
2863
|
if (cachedAccount && cachedIdToken) {
|
|
2982
2864
|
cachedAccount.idTokenClaims = new AuthToken(cachedIdToken.secret, this.cryptoImpl).claims;
|
|
2983
2865
|
}
|
|
@@ -2997,51 +2879,83 @@ var CacheManager = /** @class */ (function () {
|
|
|
2997
2879
|
var accountKey = AccountEntity.generateAccountCacheKey(account);
|
|
2998
2880
|
return this.getAccount(accountKey);
|
|
2999
2881
|
};
|
|
3000
|
-
/**
|
|
3001
|
-
* Retrieve AccountEntity from cache
|
|
3002
|
-
* @param nativeAccountId
|
|
3003
|
-
* @returns AccountEntity or Null
|
|
3004
|
-
*/
|
|
3005
|
-
CacheManager.prototype.readAccountFromCacheWithNativeAccountId = function (nativeAccountId) {
|
|
3006
|
-
// fetch account from memory
|
|
3007
|
-
var accountFilter = {
|
|
3008
|
-
nativeAccountId: nativeAccountId
|
|
3009
|
-
};
|
|
3010
|
-
var accountCache = this.getAccountsFilteredBy(accountFilter);
|
|
3011
|
-
var accounts = Object.keys(accountCache).map(function (key) { return accountCache[key]; });
|
|
3012
|
-
if (accounts.length < 1) {
|
|
3013
|
-
return null;
|
|
3014
|
-
}
|
|
3015
|
-
else if (accounts.length > 1) {
|
|
3016
|
-
throw ClientAuthError.createMultipleMatchingAccountsInCacheError();
|
|
3017
|
-
}
|
|
3018
|
-
return accountCache[0];
|
|
3019
|
-
};
|
|
3020
2882
|
/**
|
|
3021
2883
|
* Retrieve IdTokenEntity from cache
|
|
3022
2884
|
* @param clientId
|
|
3023
2885
|
* @param account
|
|
3024
2886
|
* @param inputRealm
|
|
3025
2887
|
*/
|
|
3026
|
-
CacheManager.prototype.
|
|
2888
|
+
CacheManager.prototype.getIdToken = function (account, tokenKeys) {
|
|
2889
|
+
this.commonLogger.trace("CacheManager - getIdToken called");
|
|
3027
2890
|
var idTokenFilter = {
|
|
3028
2891
|
homeAccountId: account.homeAccountId,
|
|
3029
2892
|
environment: account.environment,
|
|
3030
2893
|
credentialType: CredentialType.ID_TOKEN,
|
|
3031
|
-
clientId: clientId,
|
|
2894
|
+
clientId: this.clientId,
|
|
3032
2895
|
realm: account.tenantId,
|
|
3033
2896
|
};
|
|
3034
|
-
var
|
|
3035
|
-
var idTokens = Object.keys(credentialCache.idTokens).map(function (key) { return credentialCache.idTokens[key]; });
|
|
2897
|
+
var idTokens = this.getIdTokensByFilter(idTokenFilter, tokenKeys);
|
|
3036
2898
|
var numIdTokens = idTokens.length;
|
|
3037
2899
|
if (numIdTokens < 1) {
|
|
2900
|
+
this.commonLogger.info("CacheManager:getIdToken - No token found");
|
|
3038
2901
|
return null;
|
|
3039
2902
|
}
|
|
3040
2903
|
else if (numIdTokens > 1) {
|
|
3041
2904
|
throw ClientAuthError.createMultipleMatchingTokensInCacheError();
|
|
3042
2905
|
}
|
|
2906
|
+
this.commonLogger.info("CacheManager:getIdToken - Returning id token");
|
|
3043
2907
|
return idTokens[0];
|
|
3044
2908
|
};
|
|
2909
|
+
/**
|
|
2910
|
+
* Gets all idTokens matching the given filter
|
|
2911
|
+
* @param filter
|
|
2912
|
+
* @returns
|
|
2913
|
+
*/
|
|
2914
|
+
CacheManager.prototype.getIdTokensByFilter = function (filter, tokenKeys) {
|
|
2915
|
+
var _this = this;
|
|
2916
|
+
var idTokenKeys = tokenKeys && tokenKeys.idToken || this.getTokenKeys().idToken;
|
|
2917
|
+
var idTokens = [];
|
|
2918
|
+
idTokenKeys.forEach(function (key) {
|
|
2919
|
+
if (!_this.idTokenKeyMatchesFilter(key, __assign({ clientId: _this.clientId }, filter))) {
|
|
2920
|
+
return;
|
|
2921
|
+
}
|
|
2922
|
+
var idToken = _this.getIdTokenCredential(key);
|
|
2923
|
+
if (idToken && _this.credentialMatchesFilter(idToken, filter)) {
|
|
2924
|
+
idTokens.push(idToken);
|
|
2925
|
+
}
|
|
2926
|
+
});
|
|
2927
|
+
return idTokens;
|
|
2928
|
+
};
|
|
2929
|
+
/**
|
|
2930
|
+
* Validate the cache key against filter before retrieving and parsing cache value
|
|
2931
|
+
* @param key
|
|
2932
|
+
* @param filter
|
|
2933
|
+
* @returns
|
|
2934
|
+
*/
|
|
2935
|
+
CacheManager.prototype.idTokenKeyMatchesFilter = function (inputKey, filter) {
|
|
2936
|
+
var key = inputKey.toLowerCase();
|
|
2937
|
+
if (filter.clientId && key.indexOf(filter.clientId.toLowerCase()) === -1) {
|
|
2938
|
+
return false;
|
|
2939
|
+
}
|
|
2940
|
+
if (filter.homeAccountId && key.indexOf(filter.homeAccountId.toLowerCase()) === -1) {
|
|
2941
|
+
return false;
|
|
2942
|
+
}
|
|
2943
|
+
return true;
|
|
2944
|
+
};
|
|
2945
|
+
/**
|
|
2946
|
+
* Removes idToken from the cache
|
|
2947
|
+
* @param key
|
|
2948
|
+
*/
|
|
2949
|
+
CacheManager.prototype.removeIdToken = function (key) {
|
|
2950
|
+
this.removeItem(key);
|
|
2951
|
+
};
|
|
2952
|
+
/**
|
|
2953
|
+
* Removes refresh token from the cache
|
|
2954
|
+
* @param key
|
|
2955
|
+
*/
|
|
2956
|
+
CacheManager.prototype.removeRefreshToken = function (key) {
|
|
2957
|
+
this.removeItem(key);
|
|
2958
|
+
};
|
|
3045
2959
|
/**
|
|
3046
2960
|
* Retrieve AccessTokenEntity from cache
|
|
3047
2961
|
* @param clientId
|
|
@@ -3049,8 +2963,10 @@ var CacheManager = /** @class */ (function () {
|
|
|
3049
2963
|
* @param scopes
|
|
3050
2964
|
* @param authScheme
|
|
3051
2965
|
*/
|
|
3052
|
-
CacheManager.prototype.
|
|
3053
|
-
var
|
|
2966
|
+
CacheManager.prototype.getAccessToken = function (account, request, tokenKeys) {
|
|
2967
|
+
var _this = this;
|
|
2968
|
+
this.commonLogger.trace("CacheManager - getAccessToken called");
|
|
2969
|
+
var scopes = ScopeSet.createSearchScopes(request.scopes);
|
|
3054
2970
|
var authScheme = request.authenticationScheme || exports.AuthenticationScheme.BEARER;
|
|
3055
2971
|
/*
|
|
3056
2972
|
* Distinguish between Bearer and PoP/SSH token cache types
|
|
@@ -3061,55 +2977,156 @@ var CacheManager = /** @class */ (function () {
|
|
|
3061
2977
|
homeAccountId: account.homeAccountId,
|
|
3062
2978
|
environment: account.environment,
|
|
3063
2979
|
credentialType: credentialType,
|
|
3064
|
-
clientId: clientId,
|
|
2980
|
+
clientId: this.clientId,
|
|
3065
2981
|
realm: account.tenantId,
|
|
3066
|
-
target: scopes
|
|
2982
|
+
target: scopes,
|
|
3067
2983
|
tokenType: authScheme,
|
|
3068
2984
|
keyId: request.sshKid,
|
|
3069
2985
|
requestedClaimsHash: request.requestedClaimsHash,
|
|
3070
2986
|
};
|
|
3071
|
-
var
|
|
3072
|
-
var accessTokens =
|
|
2987
|
+
var accessTokenKeys = tokenKeys && tokenKeys.accessToken || this.getTokenKeys().accessToken;
|
|
2988
|
+
var accessTokens = [];
|
|
2989
|
+
accessTokenKeys.forEach(function (key) {
|
|
2990
|
+
// Validate key
|
|
2991
|
+
if (_this.accessTokenKeyMatchesFilter(key, accessTokenFilter, true)) {
|
|
2992
|
+
var accessToken = _this.getAccessTokenCredential(key);
|
|
2993
|
+
// Validate value
|
|
2994
|
+
if (accessToken && _this.credentialMatchesFilter(accessToken, accessTokenFilter)) {
|
|
2995
|
+
accessTokens.push(accessToken);
|
|
2996
|
+
}
|
|
2997
|
+
}
|
|
2998
|
+
});
|
|
3073
2999
|
var numAccessTokens = accessTokens.length;
|
|
3074
3000
|
if (numAccessTokens < 1) {
|
|
3001
|
+
this.commonLogger.info("CacheManager:getAccessToken - No token found");
|
|
3075
3002
|
return null;
|
|
3076
3003
|
}
|
|
3077
3004
|
else if (numAccessTokens > 1) {
|
|
3078
3005
|
throw ClientAuthError.createMultipleMatchingTokensInCacheError();
|
|
3079
3006
|
}
|
|
3007
|
+
this.commonLogger.info("CacheManager:getAccessToken - Returning access token");
|
|
3080
3008
|
return accessTokens[0];
|
|
3081
3009
|
};
|
|
3010
|
+
/**
|
|
3011
|
+
* Validate the cache key against filter before retrieving and parsing cache value
|
|
3012
|
+
* @param key
|
|
3013
|
+
* @param filter
|
|
3014
|
+
* @param keyMustContainAllScopes
|
|
3015
|
+
* @returns
|
|
3016
|
+
*/
|
|
3017
|
+
CacheManager.prototype.accessTokenKeyMatchesFilter = function (inputKey, filter, keyMustContainAllScopes) {
|
|
3018
|
+
var key = inputKey.toLowerCase();
|
|
3019
|
+
if (filter.clientId && key.indexOf(filter.clientId.toLowerCase()) === -1) {
|
|
3020
|
+
return false;
|
|
3021
|
+
}
|
|
3022
|
+
if (filter.homeAccountId && key.indexOf(filter.homeAccountId.toLowerCase()) === -1) {
|
|
3023
|
+
return false;
|
|
3024
|
+
}
|
|
3025
|
+
if (filter.realm && key.indexOf(filter.realm.toLowerCase()) === -1) {
|
|
3026
|
+
return false;
|
|
3027
|
+
}
|
|
3028
|
+
if (filter.requestedClaimsHash && key.indexOf(filter.requestedClaimsHash.toLowerCase()) === -1) {
|
|
3029
|
+
return false;
|
|
3030
|
+
}
|
|
3031
|
+
if (filter.target) {
|
|
3032
|
+
var scopes = filter.target.asArray();
|
|
3033
|
+
for (var i = 0; i < scopes.length; i++) {
|
|
3034
|
+
if (keyMustContainAllScopes && !key.includes(scopes[i].toLowerCase())) {
|
|
3035
|
+
// When performing a cache lookup a missing scope would be a cache miss
|
|
3036
|
+
return false;
|
|
3037
|
+
}
|
|
3038
|
+
else if (!keyMustContainAllScopes && key.includes(scopes[i].toLowerCase())) {
|
|
3039
|
+
// When performing a cache write, any token with a subset of requested scopes should be replaced
|
|
3040
|
+
return true;
|
|
3041
|
+
}
|
|
3042
|
+
}
|
|
3043
|
+
}
|
|
3044
|
+
return true;
|
|
3045
|
+
};
|
|
3046
|
+
/**
|
|
3047
|
+
* Gets all access tokens matching the filter
|
|
3048
|
+
* @param filter
|
|
3049
|
+
* @returns
|
|
3050
|
+
*/
|
|
3051
|
+
CacheManager.prototype.getAccessTokensByFilter = function (filter) {
|
|
3052
|
+
var _this = this;
|
|
3053
|
+
var tokenKeys = this.getTokenKeys();
|
|
3054
|
+
var accessTokens = [];
|
|
3055
|
+
tokenKeys.accessToken.forEach(function (key) {
|
|
3056
|
+
if (!_this.accessTokenKeyMatchesFilter(key, filter, true)) {
|
|
3057
|
+
return;
|
|
3058
|
+
}
|
|
3059
|
+
var accessToken = _this.getAccessTokenCredential(key);
|
|
3060
|
+
if (accessToken && _this.credentialMatchesFilter(accessToken, filter)) {
|
|
3061
|
+
accessTokens.push(accessToken);
|
|
3062
|
+
}
|
|
3063
|
+
});
|
|
3064
|
+
return accessTokens;
|
|
3065
|
+
};
|
|
3082
3066
|
/**
|
|
3083
3067
|
* Helper to retrieve the appropriate refresh token from cache
|
|
3084
3068
|
* @param clientId
|
|
3085
3069
|
* @param account
|
|
3086
3070
|
* @param familyRT
|
|
3087
3071
|
*/
|
|
3088
|
-
CacheManager.prototype.
|
|
3072
|
+
CacheManager.prototype.getRefreshToken = function (account, familyRT, tokenKeys) {
|
|
3073
|
+
var _this = this;
|
|
3074
|
+
this.commonLogger.trace("CacheManager - getRefreshToken called");
|
|
3089
3075
|
var id = familyRT ? THE_FAMILY_ID : undefined;
|
|
3090
3076
|
var refreshTokenFilter = {
|
|
3091
3077
|
homeAccountId: account.homeAccountId,
|
|
3092
3078
|
environment: account.environment,
|
|
3093
3079
|
credentialType: CredentialType.REFRESH_TOKEN,
|
|
3094
|
-
clientId: clientId,
|
|
3080
|
+
clientId: this.clientId,
|
|
3095
3081
|
familyId: id,
|
|
3096
3082
|
};
|
|
3097
|
-
var
|
|
3098
|
-
var refreshTokens =
|
|
3083
|
+
var refreshTokenKeys = tokenKeys && tokenKeys.refreshToken || this.getTokenKeys().refreshToken;
|
|
3084
|
+
var refreshTokens = [];
|
|
3085
|
+
refreshTokenKeys.forEach(function (key) {
|
|
3086
|
+
// Validate key
|
|
3087
|
+
if (_this.refreshTokenKeyMatchesFilter(key, refreshTokenFilter)) {
|
|
3088
|
+
var refreshToken = _this.getRefreshTokenCredential(key);
|
|
3089
|
+
// Validate value
|
|
3090
|
+
if (refreshToken && _this.credentialMatchesFilter(refreshToken, refreshTokenFilter)) {
|
|
3091
|
+
refreshTokens.push(refreshToken);
|
|
3092
|
+
}
|
|
3093
|
+
}
|
|
3094
|
+
});
|
|
3099
3095
|
var numRefreshTokens = refreshTokens.length;
|
|
3100
3096
|
if (numRefreshTokens < 1) {
|
|
3097
|
+
this.commonLogger.info("CacheManager:getRefreshToken - No refresh token found.");
|
|
3101
3098
|
return null;
|
|
3102
3099
|
}
|
|
3103
3100
|
// address the else case after remove functions address environment aliases
|
|
3101
|
+
this.commonLogger.info("CacheManager:getRefreshToken - returning refresh token");
|
|
3104
3102
|
return refreshTokens[0];
|
|
3105
3103
|
};
|
|
3104
|
+
/**
|
|
3105
|
+
* Validate the cache key against filter before retrieving and parsing cache value
|
|
3106
|
+
* @param key
|
|
3107
|
+
* @param filter
|
|
3108
|
+
*/
|
|
3109
|
+
CacheManager.prototype.refreshTokenKeyMatchesFilter = function (inputKey, filter) {
|
|
3110
|
+
var key = inputKey.toLowerCase();
|
|
3111
|
+
if (filter.familyId && key.indexOf(filter.familyId.toLowerCase()) === -1) {
|
|
3112
|
+
return false;
|
|
3113
|
+
}
|
|
3114
|
+
// If familyId is used, clientId is not in the key
|
|
3115
|
+
if (!filter.familyId && filter.clientId && key.indexOf(filter.clientId.toLowerCase()) === -1) {
|
|
3116
|
+
return false;
|
|
3117
|
+
}
|
|
3118
|
+
if (filter.homeAccountId && key.indexOf(filter.homeAccountId.toLowerCase()) === -1) {
|
|
3119
|
+
return false;
|
|
3120
|
+
}
|
|
3121
|
+
return true;
|
|
3122
|
+
};
|
|
3106
3123
|
/**
|
|
3107
3124
|
* Retrieve AppMetadataEntity from cache
|
|
3108
3125
|
*/
|
|
3109
|
-
CacheManager.prototype.readAppMetadataFromCache = function (environment
|
|
3126
|
+
CacheManager.prototype.readAppMetadataFromCache = function (environment) {
|
|
3110
3127
|
var appMetadataFilter = {
|
|
3111
3128
|
environment: environment,
|
|
3112
|
-
clientId: clientId,
|
|
3129
|
+
clientId: this.clientId,
|
|
3113
3130
|
};
|
|
3114
3131
|
var appMetadata = this.getAppMetadataFilteredBy(appMetadataFilter);
|
|
3115
3132
|
var appMetadataEntries = Object.keys(appMetadata).map(function (key) { return appMetadata[key]; });
|
|
@@ -3127,8 +3144,8 @@ var CacheManager = /** @class */ (function () {
|
|
|
3127
3144
|
* @param environment
|
|
3128
3145
|
* @param clientId
|
|
3129
3146
|
*/
|
|
3130
|
-
CacheManager.prototype.isAppMetadataFOCI = function (environment
|
|
3131
|
-
var appMetadata = this.readAppMetadataFromCache(environment
|
|
3147
|
+
CacheManager.prototype.isAppMetadataFOCI = function (environment) {
|
|
3148
|
+
var appMetadata = this.readAppMetadataFromCache(environment);
|
|
3132
3149
|
return !!(appMetadata && appMetadata.familyId === THE_FAMILY_ID);
|
|
3133
3150
|
};
|
|
3134
3151
|
/**
|
|
@@ -3139,6 +3156,24 @@ var CacheManager = /** @class */ (function () {
|
|
|
3139
3156
|
CacheManager.prototype.matchHomeAccountId = function (entity, homeAccountId) {
|
|
3140
3157
|
return !!((typeof entity.homeAccountId === "string") && (homeAccountId === entity.homeAccountId));
|
|
3141
3158
|
};
|
|
3159
|
+
/**
|
|
3160
|
+
* helper to match account ids
|
|
3161
|
+
* @param entity
|
|
3162
|
+
* @param localAccountId
|
|
3163
|
+
* @returns
|
|
3164
|
+
*/
|
|
3165
|
+
CacheManager.prototype.matchLocalAccountId = function (entity, localAccountId) {
|
|
3166
|
+
return !!((typeof entity.localAccountId === "string") && (localAccountId === entity.localAccountId));
|
|
3167
|
+
};
|
|
3168
|
+
/**
|
|
3169
|
+
* helper to match usernames
|
|
3170
|
+
* @param entity
|
|
3171
|
+
* @param username
|
|
3172
|
+
* @returns
|
|
3173
|
+
*/
|
|
3174
|
+
CacheManager.prototype.matchUsername = function (entity, username) {
|
|
3175
|
+
return !!((typeof entity.username === "string") && (username.toLowerCase() === entity.username.toLowerCase()));
|
|
3176
|
+
};
|
|
3142
3177
|
/**
|
|
3143
3178
|
* helper to match assertion
|
|
3144
3179
|
* @param value
|
|
@@ -3211,14 +3246,7 @@ var CacheManager = /** @class */ (function () {
|
|
|
3211
3246
|
return false;
|
|
3212
3247
|
}
|
|
3213
3248
|
var entityScopeSet = ScopeSet.fromString(entity.target);
|
|
3214
|
-
|
|
3215
|
-
if (!requestTargetScopeSet.containsOnlyOIDCScopes()) {
|
|
3216
|
-
requestTargetScopeSet.removeOIDCScopes(); // ignore OIDC scopes
|
|
3217
|
-
}
|
|
3218
|
-
else {
|
|
3219
|
-
requestTargetScopeSet.removeScope(Constants.OFFLINE_ACCESS_SCOPE);
|
|
3220
|
-
}
|
|
3221
|
-
return entityScopeSet.containsScopeSet(requestTargetScopeSet);
|
|
3249
|
+
return entityScopeSet.containsScopeSet(target);
|
|
3222
3250
|
};
|
|
3223
3251
|
/**
|
|
3224
3252
|
* Returns true if the credential's tokenType or Authentication Scheme matches the one in the request, false otherwise
|
|
@@ -3256,27 +3284,6 @@ var CacheManager = /** @class */ (function () {
|
|
|
3256
3284
|
CacheManager.prototype.generateAuthorityMetadataCacheKey = function (authority) {
|
|
3257
3285
|
return AUTHORITY_METADATA_CONSTANTS.CACHE_KEY + "-" + this.clientId + "-" + authority;
|
|
3258
3286
|
};
|
|
3259
|
-
/**
|
|
3260
|
-
* Returns the specific credential (IdToken/AccessToken/RefreshToken) from the cache
|
|
3261
|
-
* @param key
|
|
3262
|
-
* @param credType
|
|
3263
|
-
*/
|
|
3264
|
-
CacheManager.prototype.getSpecificCredential = function (key, credType) {
|
|
3265
|
-
switch (credType) {
|
|
3266
|
-
case CredentialType.ID_TOKEN: {
|
|
3267
|
-
return this.getIdTokenCredential(key);
|
|
3268
|
-
}
|
|
3269
|
-
case CredentialType.ACCESS_TOKEN:
|
|
3270
|
-
case CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME: {
|
|
3271
|
-
return this.getAccessTokenCredential(key);
|
|
3272
|
-
}
|
|
3273
|
-
case CredentialType.REFRESH_TOKEN: {
|
|
3274
|
-
return this.getRefreshTokenCredential(key);
|
|
3275
|
-
}
|
|
3276
|
-
default:
|
|
3277
|
-
return null;
|
|
3278
|
-
}
|
|
3279
|
-
};
|
|
3280
3287
|
/**
|
|
3281
3288
|
* Helper to convert serialized data to object
|
|
3282
3289
|
* @param obj
|
|
@@ -3375,6 +3382,14 @@ var DefaultStorageClass = /** @class */ (function (_super) {
|
|
|
3375
3382
|
var notImplErr = "Storage interface - getKeys() has not been implemented for the cacheStorage interface.";
|
|
3376
3383
|
throw AuthError.createUnexpectedError(notImplErr);
|
|
3377
3384
|
};
|
|
3385
|
+
DefaultStorageClass.prototype.getAccountKeys = function () {
|
|
3386
|
+
var notImplErr = "Storage interface - getAccountKeys() has not been implemented for the cacheStorage interface.";
|
|
3387
|
+
throw AuthError.createUnexpectedError(notImplErr);
|
|
3388
|
+
};
|
|
3389
|
+
DefaultStorageClass.prototype.getTokenKeys = function () {
|
|
3390
|
+
var notImplErr = "Storage interface - getTokenKeys() has not been implemented for the cacheStorage interface.";
|
|
3391
|
+
throw AuthError.createUnexpectedError(notImplErr);
|
|
3392
|
+
};
|
|
3378
3393
|
DefaultStorageClass.prototype.clear = function () {
|
|
3379
3394
|
return __awaiter(this, void 0, void 0, function () {
|
|
3380
3395
|
var notImplErr;
|
|
@@ -3391,7 +3406,7 @@ var DefaultStorageClass = /** @class */ (function (_super) {
|
|
|
3391
3406
|
return DefaultStorageClass;
|
|
3392
3407
|
}(CacheManager));
|
|
3393
3408
|
|
|
3394
|
-
/*! @azure/msal-common
|
|
3409
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
3395
3410
|
|
|
3396
3411
|
/*
|
|
3397
3412
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3465,7 +3480,7 @@ function buildClientConfiguration(_a) {
|
|
|
3465
3480
|
authOptions: buildAuthOptions(userAuthOptions),
|
|
3466
3481
|
systemOptions: __assign(__assign({}, DEFAULT_SYSTEM_OPTIONS), userSystemOptions),
|
|
3467
3482
|
loggerOptions: loggerOptions,
|
|
3468
|
-
storageInterface: storageImplementation || new DefaultStorageClass(userAuthOptions.clientId, DEFAULT_CRYPTO_IMPLEMENTATION),
|
|
3483
|
+
storageInterface: storageImplementation || new DefaultStorageClass(userAuthOptions.clientId, DEFAULT_CRYPTO_IMPLEMENTATION, new Logger(loggerOptions)),
|
|
3469
3484
|
networkInterface: networkImplementation || DEFAULT_NETWORK_IMPLEMENTATION,
|
|
3470
3485
|
cryptoInterface: cryptoImplementation || DEFAULT_CRYPTO_IMPLEMENTATION,
|
|
3471
3486
|
clientCredentials: clientCredentials || DEFAULT_CLIENT_CREDENTIALS,
|
|
@@ -3484,7 +3499,7 @@ function buildAuthOptions(authOptions) {
|
|
|
3484
3499
|
return __assign({ clientCapabilities: [], azureCloudOptions: DEFAULT_AZURE_CLOUD_OPTIONS, skipAuthorityMetadataCache: false }, authOptions);
|
|
3485
3500
|
}
|
|
3486
3501
|
|
|
3487
|
-
/*! @azure/msal-common
|
|
3502
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
3488
3503
|
|
|
3489
3504
|
/*
|
|
3490
3505
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3504,7 +3519,7 @@ var ServerError = /** @class */ (function (_super) {
|
|
|
3504
3519
|
return ServerError;
|
|
3505
3520
|
}(AuthError));
|
|
3506
3521
|
|
|
3507
|
-
/*! @azure/msal-common
|
|
3522
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
3508
3523
|
|
|
3509
3524
|
/*
|
|
3510
3525
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3531,7 +3546,7 @@ var ThrottlingUtils = /** @class */ (function () {
|
|
|
3531
3546
|
var value = cacheManager.getThrottlingCache(key);
|
|
3532
3547
|
if (value) {
|
|
3533
3548
|
if (value.throttleTime < Date.now()) {
|
|
3534
|
-
cacheManager.removeItem(key
|
|
3549
|
+
cacheManager.removeItem(key);
|
|
3535
3550
|
return;
|
|
3536
3551
|
}
|
|
3537
3552
|
throw new ServerError(((_a = value.errorCodes) === null || _a === void 0 ? void 0 : _a.join(" ")) || Constants.EMPTY_STRING, value.errorMessage, value.subError);
|
|
@@ -3595,12 +3610,12 @@ var ThrottlingUtils = /** @class */ (function () {
|
|
|
3595
3610
|
sshKid: request.sshKid
|
|
3596
3611
|
};
|
|
3597
3612
|
var key = this.generateThrottlingStorageKey(thumbprint);
|
|
3598
|
-
|
|
3613
|
+
cacheManager.removeItem(key);
|
|
3599
3614
|
};
|
|
3600
3615
|
return ThrottlingUtils;
|
|
3601
3616
|
}());
|
|
3602
3617
|
|
|
3603
|
-
/*! @azure/msal-common
|
|
3618
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
3604
3619
|
|
|
3605
3620
|
/*
|
|
3606
3621
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3649,7 +3664,7 @@ var NetworkManager = /** @class */ (function () {
|
|
|
3649
3664
|
return NetworkManager;
|
|
3650
3665
|
}());
|
|
3651
3666
|
|
|
3652
|
-
/*! @azure/msal-common
|
|
3667
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
3653
3668
|
/*
|
|
3654
3669
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3655
3670
|
* Licensed under the MIT License.
|
|
@@ -3660,7 +3675,7 @@ var CcsCredentialType;
|
|
|
3660
3675
|
CcsCredentialType["UPN"] = "UPN";
|
|
3661
3676
|
})(CcsCredentialType || (CcsCredentialType = {}));
|
|
3662
3677
|
|
|
3663
|
-
/*! @azure/msal-common
|
|
3678
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
3664
3679
|
|
|
3665
3680
|
/*
|
|
3666
3681
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3751,7 +3766,7 @@ var RequestValidator = /** @class */ (function () {
|
|
|
3751
3766
|
return RequestValidator;
|
|
3752
3767
|
}());
|
|
3753
3768
|
|
|
3754
|
-
/*! @azure/msal-common
|
|
3769
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
3755
3770
|
|
|
3756
3771
|
/*
|
|
3757
3772
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4129,7 +4144,7 @@ var RequestParameterBuilder = /** @class */ (function () {
|
|
|
4129
4144
|
return RequestParameterBuilder;
|
|
4130
4145
|
}());
|
|
4131
4146
|
|
|
4132
|
-
/*! @azure/msal-common
|
|
4147
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
4133
4148
|
|
|
4134
4149
|
/*
|
|
4135
4150
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4231,7 +4246,145 @@ var BaseClient = /** @class */ (function () {
|
|
|
4231
4246
|
return BaseClient;
|
|
4232
4247
|
}());
|
|
4233
4248
|
|
|
4234
|
-
/*! @azure/msal-common
|
|
4249
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
4250
|
+
|
|
4251
|
+
/*
|
|
4252
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4253
|
+
* Licensed under the MIT License.
|
|
4254
|
+
*/
|
|
4255
|
+
/**
|
|
4256
|
+
* Base type for credentials to be stored in the cache: eg: ACCESS_TOKEN, ID_TOKEN etc
|
|
4257
|
+
*
|
|
4258
|
+
* Key:Value Schema:
|
|
4259
|
+
*
|
|
4260
|
+
* Key: <home_account_id*>-<environment>-<credential_type>-<client_id>-<realm*>-<target*>-<requestedClaims*>-<scheme*>
|
|
4261
|
+
*
|
|
4262
|
+
* Value Schema:
|
|
4263
|
+
* {
|
|
4264
|
+
* homeAccountId: home account identifier for the auth scheme,
|
|
4265
|
+
* environment: entity that issued the token, represented as a full host
|
|
4266
|
+
* credentialType: Type of credential as a string, can be one of the following: RefreshToken, AccessToken, IdToken, Password, Cookie, Certificate, Other
|
|
4267
|
+
* clientId: client ID of the application
|
|
4268
|
+
* secret: Actual credential as a string
|
|
4269
|
+
* familyId: Family ID identifier, usually only used for refresh tokens
|
|
4270
|
+
* realm: Full tenant or organizational identifier that the account belongs to
|
|
4271
|
+
* target: Permissions that are included in the token, or for refresh tokens, the resource identifier.
|
|
4272
|
+
* tokenType: Matches the authentication scheme for which the token was issued (i.e. Bearer or pop)
|
|
4273
|
+
* requestedClaimsHash: Matches the SHA 256 hash of the claims object included in the token request
|
|
4274
|
+
* userAssertionHash: Matches the SHA 256 hash of the obo_assertion for the OBO flow
|
|
4275
|
+
* }
|
|
4276
|
+
*/
|
|
4277
|
+
var CredentialEntity = /** @class */ (function () {
|
|
4278
|
+
function CredentialEntity() {
|
|
4279
|
+
}
|
|
4280
|
+
/**
|
|
4281
|
+
* Generate Account Id key component as per the schema: <home_account_id>-<environment>
|
|
4282
|
+
*/
|
|
4283
|
+
CredentialEntity.prototype.generateAccountId = function () {
|
|
4284
|
+
return CredentialEntity.generateAccountIdForCacheKey(this.homeAccountId, this.environment);
|
|
4285
|
+
};
|
|
4286
|
+
/**
|
|
4287
|
+
* Generate Credential Id key component as per the schema: <credential_type>-<client_id>-<realm>
|
|
4288
|
+
*/
|
|
4289
|
+
CredentialEntity.prototype.generateCredentialId = function () {
|
|
4290
|
+
return CredentialEntity.generateCredentialIdForCacheKey(this.credentialType, this.clientId, this.realm, this.familyId);
|
|
4291
|
+
};
|
|
4292
|
+
/**
|
|
4293
|
+
* Generate target key component as per schema: <target>
|
|
4294
|
+
*/
|
|
4295
|
+
CredentialEntity.prototype.generateTarget = function () {
|
|
4296
|
+
return CredentialEntity.generateTargetForCacheKey(this.target);
|
|
4297
|
+
};
|
|
4298
|
+
/**
|
|
4299
|
+
* generates credential key
|
|
4300
|
+
*/
|
|
4301
|
+
CredentialEntity.prototype.generateCredentialKey = function () {
|
|
4302
|
+
return CredentialEntity.generateCredentialCacheKey(this.homeAccountId, this.environment, this.credentialType, this.clientId, this.realm, this.target, this.familyId, this.tokenType, this.requestedClaimsHash);
|
|
4303
|
+
};
|
|
4304
|
+
/**
|
|
4305
|
+
* returns the type of the cache (in this case credential)
|
|
4306
|
+
*/
|
|
4307
|
+
CredentialEntity.prototype.generateType = function () {
|
|
4308
|
+
switch (this.credentialType) {
|
|
4309
|
+
case CredentialType.ID_TOKEN:
|
|
4310
|
+
return CacheType.ID_TOKEN;
|
|
4311
|
+
case CredentialType.ACCESS_TOKEN:
|
|
4312
|
+
case CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME:
|
|
4313
|
+
return CacheType.ACCESS_TOKEN;
|
|
4314
|
+
case CredentialType.REFRESH_TOKEN:
|
|
4315
|
+
return CacheType.REFRESH_TOKEN;
|
|
4316
|
+
default: {
|
|
4317
|
+
throw ClientAuthError.createUnexpectedCredentialTypeError();
|
|
4318
|
+
}
|
|
4319
|
+
}
|
|
4320
|
+
};
|
|
4321
|
+
/**
|
|
4322
|
+
* generates credential key
|
|
4323
|
+
* <home_account_id*>-\<environment>-<credential_type>-<client_id>-<realm\*>-<target\*>-<scheme\*>
|
|
4324
|
+
*/
|
|
4325
|
+
CredentialEntity.generateCredentialCacheKey = function (homeAccountId, environment, credentialType, clientId, realm, target, familyId, tokenType, requestedClaimsHash) {
|
|
4326
|
+
var credentialKey = [
|
|
4327
|
+
this.generateAccountIdForCacheKey(homeAccountId, environment),
|
|
4328
|
+
this.generateCredentialIdForCacheKey(credentialType, clientId, realm, familyId),
|
|
4329
|
+
this.generateTargetForCacheKey(target),
|
|
4330
|
+
this.generateClaimsHashForCacheKey(requestedClaimsHash),
|
|
4331
|
+
this.generateSchemeForCacheKey(tokenType)
|
|
4332
|
+
];
|
|
4333
|
+
return credentialKey.join(Separators.CACHE_KEY_SEPARATOR).toLowerCase();
|
|
4334
|
+
};
|
|
4335
|
+
/**
|
|
4336
|
+
* generates Account Id for keys
|
|
4337
|
+
* @param homeAccountId
|
|
4338
|
+
* @param environment
|
|
4339
|
+
*/
|
|
4340
|
+
CredentialEntity.generateAccountIdForCacheKey = function (homeAccountId, environment) {
|
|
4341
|
+
var accountId = [homeAccountId, environment];
|
|
4342
|
+
return accountId.join(Separators.CACHE_KEY_SEPARATOR).toLowerCase();
|
|
4343
|
+
};
|
|
4344
|
+
/**
|
|
4345
|
+
* Generates Credential Id for keys
|
|
4346
|
+
* @param credentialType
|
|
4347
|
+
* @param realm
|
|
4348
|
+
* @param clientId
|
|
4349
|
+
* @param familyId
|
|
4350
|
+
*/
|
|
4351
|
+
CredentialEntity.generateCredentialIdForCacheKey = function (credentialType, clientId, realm, familyId) {
|
|
4352
|
+
var clientOrFamilyId = credentialType === CredentialType.REFRESH_TOKEN
|
|
4353
|
+
? familyId || clientId
|
|
4354
|
+
: clientId;
|
|
4355
|
+
var credentialId = [
|
|
4356
|
+
credentialType,
|
|
4357
|
+
clientOrFamilyId,
|
|
4358
|
+
realm || Constants.EMPTY_STRING,
|
|
4359
|
+
];
|
|
4360
|
+
return credentialId.join(Separators.CACHE_KEY_SEPARATOR).toLowerCase();
|
|
4361
|
+
};
|
|
4362
|
+
/**
|
|
4363
|
+
* Generate target key component as per schema: <target>
|
|
4364
|
+
*/
|
|
4365
|
+
CredentialEntity.generateTargetForCacheKey = function (scopes) {
|
|
4366
|
+
return (scopes || Constants.EMPTY_STRING).toLowerCase();
|
|
4367
|
+
};
|
|
4368
|
+
/**
|
|
4369
|
+
* Generate requested claims key component as per schema: <requestedClaims>
|
|
4370
|
+
*/
|
|
4371
|
+
CredentialEntity.generateClaimsHashForCacheKey = function (requestedClaimsHash) {
|
|
4372
|
+
return (requestedClaimsHash || Constants.EMPTY_STRING).toLowerCase();
|
|
4373
|
+
};
|
|
4374
|
+
/**
|
|
4375
|
+
* Generate scheme key componenet as per schema: <scheme>
|
|
4376
|
+
*/
|
|
4377
|
+
CredentialEntity.generateSchemeForCacheKey = function (tokenType) {
|
|
4378
|
+
/*
|
|
4379
|
+
* PoP Tokens and SSH certs include scheme in cache key
|
|
4380
|
+
* Cast to lowercase to handle "bearer" from ADFS
|
|
4381
|
+
*/
|
|
4382
|
+
return (tokenType && tokenType.toLowerCase() !== exports.AuthenticationScheme.BEARER.toLowerCase()) ? tokenType.toLowerCase() : Constants.EMPTY_STRING;
|
|
4383
|
+
};
|
|
4384
|
+
return CredentialEntity;
|
|
4385
|
+
}());
|
|
4386
|
+
|
|
4387
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
4235
4388
|
|
|
4236
4389
|
/*
|
|
4237
4390
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4295,7 +4448,7 @@ var IdTokenEntity = /** @class */ (function (_super) {
|
|
|
4295
4448
|
return IdTokenEntity;
|
|
4296
4449
|
}(CredentialEntity));
|
|
4297
4450
|
|
|
4298
|
-
/*! @azure/msal-common
|
|
4451
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
4299
4452
|
/*
|
|
4300
4453
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4301
4454
|
* Licensed under the MIT License.
|
|
@@ -4345,7 +4498,7 @@ var TimeUtils = /** @class */ (function () {
|
|
|
4345
4498
|
return TimeUtils;
|
|
4346
4499
|
}());
|
|
4347
4500
|
|
|
4348
|
-
/*! @azure/msal-common
|
|
4501
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
4349
4502
|
|
|
4350
4503
|
/*
|
|
4351
4504
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4459,7 +4612,7 @@ var AccessTokenEntity = /** @class */ (function (_super) {
|
|
|
4459
4612
|
return AccessTokenEntity;
|
|
4460
4613
|
}(CredentialEntity));
|
|
4461
4614
|
|
|
4462
|
-
/*! @azure/msal-common
|
|
4615
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
4463
4616
|
|
|
4464
4617
|
/*
|
|
4465
4618
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4526,7 +4679,7 @@ var RefreshTokenEntity = /** @class */ (function (_super) {
|
|
|
4526
4679
|
return RefreshTokenEntity;
|
|
4527
4680
|
}(CredentialEntity));
|
|
4528
4681
|
|
|
4529
|
-
/*! @azure/msal-common
|
|
4682
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
4530
4683
|
|
|
4531
4684
|
/*
|
|
4532
4685
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4605,7 +4758,7 @@ var InteractionRequiredAuthError = /** @class */ (function (_super) {
|
|
|
4605
4758
|
return InteractionRequiredAuthError;
|
|
4606
4759
|
}(AuthError));
|
|
4607
4760
|
|
|
4608
|
-
/*! @azure/msal-common
|
|
4761
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
4609
4762
|
/*
|
|
4610
4763
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4611
4764
|
* Licensed under the MIT License.
|
|
@@ -4621,7 +4774,7 @@ var CacheRecord = /** @class */ (function () {
|
|
|
4621
4774
|
return CacheRecord;
|
|
4622
4775
|
}());
|
|
4623
4776
|
|
|
4624
|
-
/*! @azure/msal-common
|
|
4777
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
4625
4778
|
|
|
4626
4779
|
/*
|
|
4627
4780
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4692,7 +4845,7 @@ var ProtocolUtils = /** @class */ (function () {
|
|
|
4692
4845
|
return ProtocolUtils;
|
|
4693
4846
|
}());
|
|
4694
4847
|
|
|
4695
|
-
/*! @azure/msal-common
|
|
4848
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
4696
4849
|
|
|
4697
4850
|
/*
|
|
4698
4851
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4926,7 +5079,7 @@ var UrlString = /** @class */ (function () {
|
|
|
4926
5079
|
return UrlString;
|
|
4927
5080
|
}());
|
|
4928
5081
|
|
|
4929
|
-
/*! @azure/msal-common
|
|
5082
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
4930
5083
|
/*
|
|
4931
5084
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4932
5085
|
* Licensed under the MIT License.
|
|
@@ -5063,6 +5216,7 @@ exports.PerformanceEvents = void 0;
|
|
|
5063
5216
|
* Internal API for initializing silent request in SilentCacheClient (msal-browser)
|
|
5064
5217
|
*/
|
|
5065
5218
|
PerformanceEvents["InitializeSilentRequest"] = "initializeSilentRequest";
|
|
5219
|
+
PerformanceEvents["InitializeClientApplication"] = "initializeClientApplication";
|
|
5066
5220
|
/**
|
|
5067
5221
|
* Helper function in SilentIframeClient class (msal-browser).
|
|
5068
5222
|
*/
|
|
@@ -5128,6 +5282,7 @@ exports.PerformanceEvents = void 0;
|
|
|
5128
5282
|
PerformanceEvents["HandleRedirectPromiseMeasurement"] = "handleRedirectPromiseMeasurement";
|
|
5129
5283
|
PerformanceEvents["UpdateCloudDiscoveryMetadataMeasurement"] = "updateCloudDiscoveryMetadataMeasurement";
|
|
5130
5284
|
PerformanceEvents["UsernamePasswordClientAcquireToken"] = "usernamePasswordClientAcquireToken";
|
|
5285
|
+
PerformanceEvents["NativeMessageHandlerHandshake"] = "nativeMessageHandlerHandshake";
|
|
5131
5286
|
})(exports.PerformanceEvents || (exports.PerformanceEvents = {}));
|
|
5132
5287
|
/**
|
|
5133
5288
|
* State of the performance event.
|
|
@@ -5153,7 +5308,7 @@ var IntFields = new Set([
|
|
|
5153
5308
|
"status",
|
|
5154
5309
|
]);
|
|
5155
5310
|
|
|
5156
|
-
/*! @azure/msal-common
|
|
5311
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
5157
5312
|
|
|
5158
5313
|
/*
|
|
5159
5314
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -5262,7 +5417,7 @@ var PopTokenGenerator = /** @class */ (function () {
|
|
|
5262
5417
|
return PopTokenGenerator;
|
|
5263
5418
|
}());
|
|
5264
5419
|
|
|
5265
|
-
/*! @azure/msal-common
|
|
5420
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
5266
5421
|
|
|
5267
5422
|
/*
|
|
5268
5423
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -5332,7 +5487,7 @@ var AppMetadataEntity = /** @class */ (function () {
|
|
|
5332
5487
|
return AppMetadataEntity;
|
|
5333
5488
|
}());
|
|
5334
5489
|
|
|
5335
|
-
/*! @azure/msal-common
|
|
5490
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
5336
5491
|
/*
|
|
5337
5492
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
5338
5493
|
* Licensed under the MIT License.
|
|
@@ -5368,7 +5523,7 @@ var AppMetadataEntity = /** @class */ (function () {
|
|
|
5368
5523
|
return TokenCacheContext;
|
|
5369
5524
|
}());
|
|
5370
5525
|
|
|
5371
|
-
/*! @azure/msal-common
|
|
5526
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
5372
5527
|
|
|
5373
5528
|
/*
|
|
5374
5529
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -5500,7 +5655,7 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
5500
5655
|
_b.sent();
|
|
5501
5656
|
_b.label = 7;
|
|
5502
5657
|
case 7: return [7 /*endfinally*/];
|
|
5503
|
-
case 8: return [2 /*return*/, ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenObj, requestStateObj, serverTokenResponse
|
|
5658
|
+
case 8: return [2 /*return*/, ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenObj, requestStateObj, serverTokenResponse, serverRequestId)];
|
|
5504
5659
|
}
|
|
5505
5660
|
});
|
|
5506
5661
|
});
|
|
@@ -5586,7 +5741,7 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
5586
5741
|
* @param fromTokenCache
|
|
5587
5742
|
* @param stateString
|
|
5588
5743
|
*/
|
|
5589
|
-
ResponseHandler.generateAuthenticationResult = function (cryptoObj, authority, cacheRecord, fromTokenCache, request, idTokenObj, requestState,
|
|
5744
|
+
ResponseHandler.generateAuthenticationResult = function (cryptoObj, authority, cacheRecord, fromTokenCache, request, idTokenObj, requestState, serverTokenResponse, requestId) {
|
|
5590
5745
|
var _a, _b, _c;
|
|
5591
5746
|
return __awaiter(this, void 0, void 0, function () {
|
|
5592
5747
|
var accessToken, responseScopes, expiresOn, extExpiresOn, familyId, popTokenGenerator, _d, secret, keyId, uid, tid;
|
|
@@ -5622,6 +5777,10 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
5622
5777
|
}
|
|
5623
5778
|
uid = (idTokenObj === null || idTokenObj === void 0 ? void 0 : idTokenObj.claims.oid) || (idTokenObj === null || idTokenObj === void 0 ? void 0 : idTokenObj.claims.sub) || Constants.EMPTY_STRING;
|
|
5624
5779
|
tid = (idTokenObj === null || idTokenObj === void 0 ? void 0 : idTokenObj.claims.tid) || Constants.EMPTY_STRING;
|
|
5780
|
+
// for hybrid + native bridge enablement, send back the native account Id
|
|
5781
|
+
if ((serverTokenResponse === null || serverTokenResponse === void 0 ? void 0 : serverTokenResponse.spa_accountid) && !!cacheRecord.account) {
|
|
5782
|
+
cacheRecord.account.nativeAccountId = serverTokenResponse === null || serverTokenResponse === void 0 ? void 0 : serverTokenResponse.spa_accountid;
|
|
5783
|
+
}
|
|
5625
5784
|
return [2 /*return*/, {
|
|
5626
5785
|
authority: authority.canonicalAuthority,
|
|
5627
5786
|
uniqueId: uid,
|
|
@@ -5641,7 +5800,7 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
5641
5800
|
state: requestState ? requestState.userRequestState : Constants.EMPTY_STRING,
|
|
5642
5801
|
cloudGraphHostName: ((_b = cacheRecord.account) === null || _b === void 0 ? void 0 : _b.cloudGraphHostName) || Constants.EMPTY_STRING,
|
|
5643
5802
|
msGraphHost: ((_c = cacheRecord.account) === null || _c === void 0 ? void 0 : _c.msGraphHost) || Constants.EMPTY_STRING,
|
|
5644
|
-
code:
|
|
5803
|
+
code: serverTokenResponse === null || serverTokenResponse === void 0 ? void 0 : serverTokenResponse.spa_code,
|
|
5645
5804
|
fromNativeBroker: false,
|
|
5646
5805
|
}];
|
|
5647
5806
|
}
|
|
@@ -5651,7 +5810,7 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
5651
5810
|
return ResponseHandler;
|
|
5652
5811
|
}());
|
|
5653
5812
|
|
|
5654
|
-
/*! @azure/msal-common
|
|
5813
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
5655
5814
|
|
|
5656
5815
|
/*
|
|
5657
5816
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6129,7 +6288,7 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
|
6129
6288
|
return AuthorizationCodeClient;
|
|
6130
6289
|
}(BaseClient));
|
|
6131
6290
|
|
|
6132
|
-
/*! @azure/msal-common
|
|
6291
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
6133
6292
|
|
|
6134
6293
|
/*
|
|
6135
6294
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6209,7 +6368,7 @@ var RefreshTokenClient = /** @class */ (function (_super) {
|
|
|
6209
6368
|
if (!request.account) {
|
|
6210
6369
|
throw ClientAuthError.createNoAccountInSilentRequestError();
|
|
6211
6370
|
}
|
|
6212
|
-
isFOCI = this.cacheManager.isAppMetadataFOCI(request.account.environment
|
|
6371
|
+
isFOCI = this.cacheManager.isAppMetadataFOCI(request.account.environment);
|
|
6213
6372
|
// if the app is part of the family, retrive a Family refresh token if present and make a refreshTokenRequest
|
|
6214
6373
|
if (isFOCI) {
|
|
6215
6374
|
try {
|
|
@@ -6248,7 +6407,7 @@ var RefreshTokenClient = /** @class */ (function (_super) {
|
|
|
6248
6407
|
(_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.addQueueMeasurement(exports.PerformanceEvents.RefreshTokenClientAcquireTokenWithCachedRefreshToken, request.correlationId);
|
|
6249
6408
|
atsMeasurement = (_b = this.performanceClient) === null || _b === void 0 ? void 0 : _b.startMeasurement(exports.PerformanceEvents.RefreshTokenClientAcquireTokenWithCachedRefreshToken, request.correlationId);
|
|
6250
6409
|
this.logger.verbose("RefreshTokenClientAcquireTokenWithCachedRefreshToken called", request.correlationId);
|
|
6251
|
-
refreshToken = this.cacheManager.
|
|
6410
|
+
refreshToken = this.cacheManager.getRefreshToken(request.account, foci);
|
|
6252
6411
|
if (!refreshToken) {
|
|
6253
6412
|
atsMeasurement === null || atsMeasurement === void 0 ? void 0 : atsMeasurement.discardMeasurement();
|
|
6254
6413
|
throw InteractionRequiredAuthError.createNoTokensFoundError();
|
|
@@ -6403,7 +6562,7 @@ var RefreshTokenClient = /** @class */ (function (_super) {
|
|
|
6403
6562
|
return RefreshTokenClient;
|
|
6404
6563
|
}(BaseClient));
|
|
6405
6564
|
|
|
6406
|
-
/*! @azure/msal-common
|
|
6565
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
6407
6566
|
|
|
6408
6567
|
/*
|
|
6409
6568
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6468,7 +6627,7 @@ var SilentFlowClient = /** @class */ (function (_super) {
|
|
|
6468
6627
|
throw ClientAuthError.createNoAccountInSilentRequestError();
|
|
6469
6628
|
}
|
|
6470
6629
|
environment = request.authority || this.authority.getPreferredCache();
|
|
6471
|
-
cacheRecord = this.cacheManager.readCacheRecord(request.account,
|
|
6630
|
+
cacheRecord = this.cacheManager.readCacheRecord(request.account, request, environment);
|
|
6472
6631
|
if (!cacheRecord.accessToken) {
|
|
6473
6632
|
// Must refresh due to non-existent access_token.
|
|
6474
6633
|
(_b = this.serverTelemetryManager) === null || _b === void 0 ? void 0 : _b.setCacheOutcome(CacheOutcome.NO_CACHED_ACCESS_TOKEN);
|
|
@@ -6527,7 +6686,7 @@ var SilentFlowClient = /** @class */ (function (_super) {
|
|
|
6527
6686
|
return SilentFlowClient;
|
|
6528
6687
|
}(BaseClient));
|
|
6529
6688
|
|
|
6530
|
-
/*! @azure/msal-common
|
|
6689
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
6531
6690
|
/*
|
|
6532
6691
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
6533
6692
|
* Licensed under the MIT License.
|
|
@@ -6539,7 +6698,7 @@ function isOpenIdConfigResponse(response) {
|
|
|
6539
6698
|
response.hasOwnProperty("jwks_uri"));
|
|
6540
6699
|
}
|
|
6541
6700
|
|
|
6542
|
-
/*! @azure/msal-common
|
|
6701
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
6543
6702
|
/*
|
|
6544
6703
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
6545
6704
|
* Licensed under the MIT License.
|
|
@@ -6548,7 +6707,7 @@ var rawMetdataJSON = { "endpointMetadata": { "https://login.microsoftonline.com/
|
|
|
6548
6707
|
var EndpointMetadata = rawMetdataJSON.endpointMetadata;
|
|
6549
6708
|
var InstanceDiscoveryMetadata = rawMetdataJSON.instanceDiscoveryMetadata;
|
|
6550
6709
|
|
|
6551
|
-
/*! @azure/msal-common
|
|
6710
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
6552
6711
|
/*
|
|
6553
6712
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
6554
6713
|
* Licensed under the MIT License.
|
|
@@ -6562,7 +6721,7 @@ exports.ProtocolMode = void 0;
|
|
|
6562
6721
|
ProtocolMode["OIDC"] = "OIDC";
|
|
6563
6722
|
})(exports.ProtocolMode || (exports.ProtocolMode = {}));
|
|
6564
6723
|
|
|
6565
|
-
/*! @azure/msal-common
|
|
6724
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
6566
6725
|
|
|
6567
6726
|
/*
|
|
6568
6727
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6639,7 +6798,7 @@ var AuthorityMetadataEntity = /** @class */ (function () {
|
|
|
6639
6798
|
return AuthorityMetadataEntity;
|
|
6640
6799
|
}());
|
|
6641
6800
|
|
|
6642
|
-
/*! @azure/msal-common
|
|
6801
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
6643
6802
|
/*
|
|
6644
6803
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
6645
6804
|
* Licensed under the MIT License.
|
|
@@ -6649,7 +6808,7 @@ function isCloudInstanceDiscoveryResponse(response) {
|
|
|
6649
6808
|
response.hasOwnProperty("metadata"));
|
|
6650
6809
|
}
|
|
6651
6810
|
|
|
6652
|
-
/*! @azure/msal-common
|
|
6811
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
6653
6812
|
/*
|
|
6654
6813
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
6655
6814
|
* Licensed under the MIT License.
|
|
@@ -6659,7 +6818,7 @@ function isCloudInstanceDiscoveryErrorResponse(response) {
|
|
|
6659
6818
|
response.hasOwnProperty("error_description"));
|
|
6660
6819
|
}
|
|
6661
6820
|
|
|
6662
|
-
/*! @azure/msal-common
|
|
6821
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
6663
6822
|
|
|
6664
6823
|
/*
|
|
6665
6824
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6791,7 +6950,7 @@ var RegionDiscovery = /** @class */ (function () {
|
|
|
6791
6950
|
return RegionDiscovery;
|
|
6792
6951
|
}());
|
|
6793
6952
|
|
|
6794
|
-
/*! @azure/msal-common
|
|
6953
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
6795
6954
|
|
|
6796
6955
|
/*
|
|
6797
6956
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7526,7 +7685,7 @@ var Authority = /** @class */ (function () {
|
|
|
7526
7685
|
return Authority;
|
|
7527
7686
|
}());
|
|
7528
7687
|
|
|
7529
|
-
/*! @azure/msal-common
|
|
7688
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
7530
7689
|
|
|
7531
7690
|
/*
|
|
7532
7691
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7589,7 +7748,7 @@ var AuthorityFactory = /** @class */ (function () {
|
|
|
7589
7748
|
return AuthorityFactory;
|
|
7590
7749
|
}());
|
|
7591
7750
|
|
|
7592
|
-
/*! @azure/msal-common
|
|
7751
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
7593
7752
|
|
|
7594
7753
|
/*
|
|
7595
7754
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7620,7 +7779,7 @@ var ServerTelemetryEntity = /** @class */ (function () {
|
|
|
7620
7779
|
return ServerTelemetryEntity;
|
|
7621
7780
|
}());
|
|
7622
7781
|
|
|
7623
|
-
/*! @azure/msal-common
|
|
7782
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
7624
7783
|
|
|
7625
7784
|
/*
|
|
7626
7785
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7648,7 +7807,7 @@ var ThrottlingEntity = /** @class */ (function () {
|
|
|
7648
7807
|
return ThrottlingEntity;
|
|
7649
7808
|
}());
|
|
7650
7809
|
|
|
7651
|
-
/*! @azure/msal-common
|
|
7810
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
7652
7811
|
|
|
7653
7812
|
/*
|
|
7654
7813
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7665,7 +7824,7 @@ var StubbedNetworkModule = {
|
|
|
7665
7824
|
}
|
|
7666
7825
|
};
|
|
7667
7826
|
|
|
7668
|
-
/*! @azure/msal-common
|
|
7827
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
7669
7828
|
|
|
7670
7829
|
/*
|
|
7671
7830
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7710,7 +7869,7 @@ var JoseHeaderError = /** @class */ (function (_super) {
|
|
|
7710
7869
|
return JoseHeaderError;
|
|
7711
7870
|
}(AuthError));
|
|
7712
7871
|
|
|
7713
|
-
/*! @azure/msal-common
|
|
7872
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
7714
7873
|
|
|
7715
7874
|
/*
|
|
7716
7875
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7740,8 +7899,8 @@ var JoseHeader = /** @class */ (function () {
|
|
|
7740
7899
|
throw JoseHeaderError.createMissingAlgError();
|
|
7741
7900
|
}
|
|
7742
7901
|
var shrHeader = new JoseHeader({
|
|
7743
|
-
// Access Token PoP headers must have type
|
|
7744
|
-
typ: shrHeaderOptions.typ || JsonTypes.
|
|
7902
|
+
// Access Token PoP headers must have type pop, but the type header can be overriden for special cases
|
|
7903
|
+
typ: shrHeaderOptions.typ || JsonTypes.Pop,
|
|
7745
7904
|
kid: shrHeaderOptions.kid,
|
|
7746
7905
|
alg: shrHeaderOptions.alg
|
|
7747
7906
|
});
|
|
@@ -7750,7 +7909,7 @@ var JoseHeader = /** @class */ (function () {
|
|
|
7750
7909
|
return JoseHeader;
|
|
7751
7910
|
}());
|
|
7752
7911
|
|
|
7753
|
-
/*! @azure/msal-common
|
|
7912
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
7754
7913
|
|
|
7755
7914
|
/*
|
|
7756
7915
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7809,7 +7968,7 @@ var AuthenticationHeaderParser = /** @class */ (function () {
|
|
|
7809
7968
|
return AuthenticationHeaderParser;
|
|
7810
7969
|
}());
|
|
7811
7970
|
|
|
7812
|
-
/*! @azure/msal-common
|
|
7971
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
7813
7972
|
|
|
7814
7973
|
/*
|
|
7815
7974
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7971,7 +8130,7 @@ var ServerTelemetryManager = /** @class */ (function () {
|
|
|
7971
8130
|
return ServerTelemetryManager;
|
|
7972
8131
|
}());
|
|
7973
8132
|
|
|
7974
|
-
/*! @azure/msal-common
|
|
8133
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
7975
8134
|
|
|
7976
8135
|
/*
|
|
7977
8136
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7998,11 +8157,8 @@ var PerformanceClient = /** @class */ (function () {
|
|
|
7998
8157
|
this.logger = logger;
|
|
7999
8158
|
this.callbacks = new Map();
|
|
8000
8159
|
this.eventsByCorrelationId = new Map();
|
|
8001
|
-
this.staticFieldsByCorrelationId = new Map();
|
|
8002
|
-
this.measurementsById = new Map();
|
|
8003
8160
|
this.queueMeasurements = new Map();
|
|
8004
8161
|
this.preQueueTimeByCorrelationId = new Map();
|
|
8005
|
-
this.countersByCorrelationId = new Map();
|
|
8006
8162
|
}
|
|
8007
8163
|
/**
|
|
8008
8164
|
* Starts and returns an platform-specific implementation of IPerformanceMeasurement.
|
|
@@ -8043,16 +8199,16 @@ var PerformanceClient = /** @class */ (function () {
|
|
|
8043
8199
|
* @returns {number}
|
|
8044
8200
|
*/
|
|
8045
8201
|
PerformanceClient.prototype.getPreQueueTime = function (eventName, correlationId) {
|
|
8046
|
-
var
|
|
8047
|
-
if (!
|
|
8202
|
+
var preQueueEvent = this.preQueueTimeByCorrelationId.get(correlationId);
|
|
8203
|
+
if (!preQueueEvent) {
|
|
8048
8204
|
this.logger.trace("PerformanceClient.getPreQueueTime: no pre-queue times found for correlationId: " + correlationId + ", unable to add queue measurement");
|
|
8049
8205
|
return;
|
|
8050
8206
|
}
|
|
8051
|
-
else if (
|
|
8207
|
+
else if (preQueueEvent.name !== eventName) {
|
|
8052
8208
|
this.logger.trace("PerformanceClient.getPreQueueTime: no pre-queue time found for " + eventName + ", unable to add queue measurement");
|
|
8053
8209
|
return;
|
|
8054
8210
|
}
|
|
8055
|
-
return
|
|
8211
|
+
return preQueueEvent.time;
|
|
8056
8212
|
};
|
|
8057
8213
|
/**
|
|
8058
8214
|
* Calculates the difference between current time and time when function was queued.
|
|
@@ -8080,12 +8236,13 @@ var PerformanceClient = /** @class */ (function () {
|
|
|
8080
8236
|
/**
|
|
8081
8237
|
* Adds queue measurement time to QueueMeasurements array for given correlation ID.
|
|
8082
8238
|
*
|
|
8083
|
-
* @param {PerformanceEvents}
|
|
8239
|
+
* @param {PerformanceEvents} eventName
|
|
8084
8240
|
* @param {?string} correlationId
|
|
8085
|
-
* @param {?number}
|
|
8241
|
+
* @param {?number} queueTime
|
|
8242
|
+
* @param {?boolean} manuallyCompleted - indicator for manually completed queue measurements
|
|
8086
8243
|
* @returns
|
|
8087
8244
|
*/
|
|
8088
|
-
PerformanceClient.prototype.addQueueMeasurement = function (eventName, correlationId, queueTime) {
|
|
8245
|
+
PerformanceClient.prototype.addQueueMeasurement = function (eventName, correlationId, queueTime, manuallyCompleted) {
|
|
8089
8246
|
if (!correlationId) {
|
|
8090
8247
|
this.logger.trace("PerformanceClient.addQueueMeasurement: correlationId not provided for " + eventName + ", cannot add queue measurement");
|
|
8091
8248
|
return;
|
|
@@ -8098,7 +8255,7 @@ var PerformanceClient = /** @class */ (function () {
|
|
|
8098
8255
|
this.logger.trace("PerformanceClient.addQueueMeasurement: no queue time provided for " + eventName);
|
|
8099
8256
|
return;
|
|
8100
8257
|
}
|
|
8101
|
-
var queueMeasurement = { eventName: eventName, queueTime: queueTime };
|
|
8258
|
+
var queueMeasurement = { eventName: eventName, queueTime: queueTime, manuallyCompleted: manuallyCompleted };
|
|
8102
8259
|
// Adds to existing correlation Id if present in queueMeasurements
|
|
8103
8260
|
var existingMeasurements = this.queueMeasurements.get(correlationId);
|
|
8104
8261
|
if (existingMeasurements) {
|
|
@@ -8111,6 +8268,8 @@ var PerformanceClient = /** @class */ (function () {
|
|
|
8111
8268
|
var measurementArray = [queueMeasurement];
|
|
8112
8269
|
this.queueMeasurements.set(correlationId, measurementArray);
|
|
8113
8270
|
}
|
|
8271
|
+
// Delete processed pre-queue event.
|
|
8272
|
+
this.preQueueTimeByCorrelationId.delete(correlationId);
|
|
8114
8273
|
};
|
|
8115
8274
|
/**
|
|
8116
8275
|
* Starts measuring performance for a given operation. Returns a function that should be used to end the measurement.
|
|
@@ -8129,17 +8288,8 @@ var PerformanceClient = /** @class */ (function () {
|
|
|
8129
8288
|
}
|
|
8130
8289
|
// Duplicate code to address spelling error will be removed at the next major version bump.
|
|
8131
8290
|
this.logger.trace("PerformanceClient: Performance measurement started for " + measureName, eventCorrelationId);
|
|
8132
|
-
var
|
|
8133
|
-
|
|
8134
|
-
if (performanceMeasuremeant.startMeasurement) {
|
|
8135
|
-
performanceMeasuremeant.startMeasurement();
|
|
8136
|
-
validMeasurement = performanceMeasuremeant;
|
|
8137
|
-
}
|
|
8138
|
-
else {
|
|
8139
|
-
var performanceMeasurement = this.startPerformanceMeasurement(measureName, eventCorrelationId);
|
|
8140
|
-
performanceMeasurement.startMeasurement();
|
|
8141
|
-
validMeasurement = performanceMeasurement;
|
|
8142
|
-
}
|
|
8291
|
+
var performanceMeasurement = this.startPerformanceMeasuremeant(measureName, eventCorrelationId);
|
|
8292
|
+
performanceMeasurement.startMeasurement();
|
|
8143
8293
|
var inProgressEvent = {
|
|
8144
8294
|
eventId: this.generateId(),
|
|
8145
8295
|
status: PerformanceEventStatus.InProgress,
|
|
@@ -8150,27 +8300,15 @@ var PerformanceClient = /** @class */ (function () {
|
|
|
8150
8300
|
name: measureName,
|
|
8151
8301
|
startTimeMs: Date.now(),
|
|
8152
8302
|
correlationId: eventCorrelationId,
|
|
8153
|
-
};
|
|
8154
|
-
// Store in progress events so they can be discarded if not ended properly
|
|
8155
|
-
this.cacheEventByCorrelationId(inProgressEvent);
|
|
8156
|
-
var staticFields = {
|
|
8157
8303
|
appName: (_a = this.applicationTelemetry) === null || _a === void 0 ? void 0 : _a.appName,
|
|
8158
8304
|
appVersion: (_b = this.applicationTelemetry) === null || _b === void 0 ? void 0 : _b.appVersion,
|
|
8159
8305
|
};
|
|
8160
|
-
|
|
8161
|
-
this.
|
|
8306
|
+
// Store in progress events so they can be discarded if not ended properly
|
|
8307
|
+
this.cacheEventByCorrelationId(inProgressEvent);
|
|
8162
8308
|
// Return the event and functions the caller can use to properly end/flush the measurement
|
|
8163
8309
|
return {
|
|
8164
8310
|
endMeasurement: function (event) {
|
|
8165
|
-
|
|
8166
|
-
if (completedEvent) {
|
|
8167
|
-
// Cache event so that submeasurements can be added downstream
|
|
8168
|
-
_this.cacheEventByCorrelationId(completedEvent);
|
|
8169
|
-
}
|
|
8170
|
-
return completedEvent;
|
|
8171
|
-
},
|
|
8172
|
-
flushMeasurement: function () {
|
|
8173
|
-
return _this.flushMeasurements(inProgressEvent.name, inProgressEvent.correlationId);
|
|
8311
|
+
return _this.endMeasurement(__assign(__assign({}, inProgressEvent), event), performanceMeasurement);
|
|
8174
8312
|
},
|
|
8175
8313
|
discardMeasurement: function () {
|
|
8176
8314
|
return _this.discardMeasurements(inProgressEvent.correlationId);
|
|
@@ -8181,40 +8319,66 @@ var PerformanceClient = /** @class */ (function () {
|
|
|
8181
8319
|
increment: function (counters) {
|
|
8182
8320
|
return _this.increment(counters, inProgressEvent.correlationId);
|
|
8183
8321
|
},
|
|
8184
|
-
measurement:
|
|
8322
|
+
measurement: performanceMeasurement,
|
|
8185
8323
|
event: inProgressEvent
|
|
8186
8324
|
};
|
|
8187
8325
|
};
|
|
8188
8326
|
/**
|
|
8189
8327
|
* Stops measuring the performance for an operation. Should only be called directly by PerformanceClient classes,
|
|
8190
8328
|
* as consumers should instead use the function returned by startMeasurement.
|
|
8329
|
+
* Adds a new field named as "[event name]DurationMs" for sub-measurements, completes and emits an event
|
|
8330
|
+
* otherwise.
|
|
8191
8331
|
*
|
|
8192
8332
|
* @param {PerformanceEvent} event
|
|
8333
|
+
* @param {IPerformanceMeasurement} measurement
|
|
8193
8334
|
* @returns {(PerformanceEvent | null)}
|
|
8194
8335
|
*/
|
|
8195
|
-
PerformanceClient.prototype.endMeasurement = function (event) {
|
|
8196
|
-
var
|
|
8197
|
-
|
|
8198
|
-
|
|
8199
|
-
|
|
8200
|
-
|
|
8201
|
-
|
|
8202
|
-
|
|
8203
|
-
|
|
8204
|
-
|
|
8205
|
-
|
|
8206
|
-
|
|
8207
|
-
|
|
8208
|
-
|
|
8209
|
-
|
|
8210
|
-
|
|
8211
|
-
|
|
8212
|
-
}
|
|
8336
|
+
PerformanceClient.prototype.endMeasurement = function (event, measurement) {
|
|
8337
|
+
var _this = this;
|
|
8338
|
+
var _a, _b;
|
|
8339
|
+
var rootEvent = this.eventsByCorrelationId.get(event.correlationId);
|
|
8340
|
+
if (!rootEvent) {
|
|
8341
|
+
this.logger.trace("PerformanceClient: Measurement not found for " + event.eventId, event.correlationId);
|
|
8342
|
+
return null;
|
|
8343
|
+
}
|
|
8344
|
+
var isRoot = event.eventId === rootEvent.eventId;
|
|
8345
|
+
var queueInfo = {
|
|
8346
|
+
totalQueueTime: 0,
|
|
8347
|
+
totalQueueCount: 0,
|
|
8348
|
+
manuallyCompletedCount: 0
|
|
8349
|
+
};
|
|
8350
|
+
if (isRoot) {
|
|
8351
|
+
queueInfo = this.getQueueInfo(event.correlationId);
|
|
8352
|
+
this.discardCache(rootEvent.correlationId);
|
|
8213
8353
|
}
|
|
8214
8354
|
else {
|
|
8215
|
-
|
|
8355
|
+
(_a = rootEvent.incompleteSubMeasurements) === null || _a === void 0 ? void 0 : _a.delete(event.eventId);
|
|
8216
8356
|
}
|
|
8217
|
-
|
|
8357
|
+
measurement === null || measurement === void 0 ? void 0 : measurement.endMeasurement();
|
|
8358
|
+
var durationMs = measurement === null || measurement === void 0 ? void 0 : measurement.flushMeasurement();
|
|
8359
|
+
// null indicates no measurement was taken (e.g. needed performance APIs not present)
|
|
8360
|
+
if (!durationMs) {
|
|
8361
|
+
this.logger.trace("PerformanceClient: Performance measurement not taken", rootEvent.correlationId);
|
|
8362
|
+
return null;
|
|
8363
|
+
}
|
|
8364
|
+
this.logger.trace("PerformanceClient: Performance measurement ended for " + event.name + ": " + durationMs + " ms", event.correlationId);
|
|
8365
|
+
// Add sub-measurement attribute to root event.
|
|
8366
|
+
if (!isRoot) {
|
|
8367
|
+
rootEvent[event.name + "DurationMs"] = Math.floor(durationMs);
|
|
8368
|
+
return __assign({}, rootEvent);
|
|
8369
|
+
}
|
|
8370
|
+
var finalEvent = __assign(__assign({}, rootEvent), event);
|
|
8371
|
+
var incompleteSubsCount = 0;
|
|
8372
|
+
// Incomplete sub-measurements are discarded. They are likely an instrumentation bug that should be fixed.
|
|
8373
|
+
(_b = finalEvent.incompleteSubMeasurements) === null || _b === void 0 ? void 0 : _b.forEach(function (subMeasurement) {
|
|
8374
|
+
_this.logger.trace("PerformanceClient: Incomplete submeasurement " + subMeasurement.name + " found for " + event.name, finalEvent.correlationId);
|
|
8375
|
+
incompleteSubsCount++;
|
|
8376
|
+
});
|
|
8377
|
+
finalEvent.incompleteSubMeasurements = undefined;
|
|
8378
|
+
finalEvent = __assign(__assign({}, finalEvent), { durationMs: Math.round(durationMs), queuedTimeMs: queueInfo.totalQueueTime, queuedCount: queueInfo.totalQueueCount, queuedManuallyCompletedCount: queueInfo.manuallyCompletedCount, status: PerformanceEventStatus.Completed, incompleteSubsCount: incompleteSubsCount });
|
|
8379
|
+
this.truncateIntegralFields(finalEvent, this.getIntFields());
|
|
8380
|
+
this.emitEvents([finalEvent], event.correlationId);
|
|
8381
|
+
return finalEvent;
|
|
8218
8382
|
};
|
|
8219
8383
|
/**
|
|
8220
8384
|
* Saves extra information to be emitted when the measurements are flushed
|
|
@@ -8222,14 +8386,13 @@ var PerformanceClient = /** @class */ (function () {
|
|
|
8222
8386
|
* @param correlationId
|
|
8223
8387
|
*/
|
|
8224
8388
|
PerformanceClient.prototype.addStaticFields = function (fields, correlationId) {
|
|
8225
|
-
|
|
8226
|
-
|
|
8227
|
-
|
|
8228
|
-
this.
|
|
8389
|
+
this.logger.trace("PerformanceClient: Updating static fields");
|
|
8390
|
+
var event = this.eventsByCorrelationId.get(correlationId);
|
|
8391
|
+
if (event) {
|
|
8392
|
+
this.eventsByCorrelationId.set(correlationId, __assign(__assign({}, event), fields));
|
|
8229
8393
|
}
|
|
8230
8394
|
else {
|
|
8231
|
-
this.logger.trace("PerformanceClient:
|
|
8232
|
-
this.staticFieldsByCorrelationId.set(correlationId, fields);
|
|
8395
|
+
this.logger.trace("PerformanceClient: Event not found for", correlationId);
|
|
8233
8396
|
}
|
|
8234
8397
|
};
|
|
8235
8398
|
/**
|
|
@@ -8238,18 +8401,18 @@ var PerformanceClient = /** @class */ (function () {
|
|
|
8238
8401
|
* @param correlationId {string} correlation identifier
|
|
8239
8402
|
*/
|
|
8240
8403
|
PerformanceClient.prototype.increment = function (counters, correlationId) {
|
|
8241
|
-
var existing = this.countersByCorrelationId.get(correlationId);
|
|
8242
|
-
if (!existing) {
|
|
8243
|
-
this.logger.trace("PerformanceClient: Setting counters");
|
|
8244
|
-
this.countersByCorrelationId.set(correlationId, __assign({}, counters));
|
|
8245
|
-
return;
|
|
8246
|
-
}
|
|
8247
8404
|
this.logger.trace("PerformanceClient: Updating counters");
|
|
8248
|
-
|
|
8249
|
-
|
|
8250
|
-
|
|
8405
|
+
var event = this.eventsByCorrelationId.get(correlationId);
|
|
8406
|
+
if (event) {
|
|
8407
|
+
for (var counter in counters) {
|
|
8408
|
+
if (!event.hasOwnProperty(counter)) {
|
|
8409
|
+
event[counter] = 0;
|
|
8410
|
+
}
|
|
8411
|
+
event[counter] += counters[counter];
|
|
8251
8412
|
}
|
|
8252
|
-
|
|
8413
|
+
}
|
|
8414
|
+
else {
|
|
8415
|
+
this.logger.trace("PerformanceClient: Event not found for", correlationId);
|
|
8253
8416
|
}
|
|
8254
8417
|
};
|
|
8255
8418
|
/**
|
|
@@ -8262,117 +8425,35 @@ var PerformanceClient = /** @class */ (function () {
|
|
|
8262
8425
|
* @param {PerformanceEvent} event
|
|
8263
8426
|
*/
|
|
8264
8427
|
PerformanceClient.prototype.cacheEventByCorrelationId = function (event) {
|
|
8265
|
-
var
|
|
8266
|
-
if (
|
|
8428
|
+
var rootEvent = this.eventsByCorrelationId.get(event.correlationId);
|
|
8429
|
+
if (rootEvent) {
|
|
8267
8430
|
this.logger.trace("PerformanceClient: Performance measurement for " + event.name + " added/updated", event.correlationId);
|
|
8268
|
-
|
|
8431
|
+
rootEvent.incompleteSubMeasurements = rootEvent.incompleteSubMeasurements || new Map();
|
|
8432
|
+
rootEvent.incompleteSubMeasurements.set(event.eventId, { name: event.name, startTimeMs: event.startTimeMs });
|
|
8269
8433
|
}
|
|
8270
8434
|
else {
|
|
8271
8435
|
this.logger.trace("PerformanceClient: Performance measurement for " + event.name + " started", event.correlationId);
|
|
8272
|
-
this.eventsByCorrelationId.set(event.correlationId,
|
|
8436
|
+
this.eventsByCorrelationId.set(event.correlationId, __assign({}, event));
|
|
8273
8437
|
}
|
|
8274
8438
|
};
|
|
8275
|
-
|
|
8276
|
-
* Cache measurements by their id.
|
|
8277
|
-
*
|
|
8278
|
-
* @private
|
|
8279
|
-
* @param {PerformanceEvent} event
|
|
8280
|
-
* @param {IPerformanceMeasurement} measurement
|
|
8281
|
-
*/
|
|
8282
|
-
PerformanceClient.prototype.cacheMeasurement = function (event, measurement) {
|
|
8283
|
-
this.measurementsById.set(event.eventId, measurement);
|
|
8284
|
-
};
|
|
8285
|
-
/**
|
|
8286
|
-
* Gathers and emits performance events for measurements taked for the given top-level API and correlation ID.
|
|
8287
|
-
*
|
|
8288
|
-
* @param {PerformanceEvents} measureName
|
|
8289
|
-
* @param {string} correlationId
|
|
8290
|
-
*/
|
|
8291
|
-
PerformanceClient.prototype.flushMeasurements = function (measureName, correlationId) {
|
|
8292
|
-
var _this = this;
|
|
8293
|
-
this.logger.trace("PerformanceClient: Performance measurements flushed for " + measureName, correlationId);
|
|
8294
|
-
/**
|
|
8295
|
-
* Adds all queue time and count measurements for given correlation ID
|
|
8296
|
-
* then deletes queue times for given correlation ID from queueMeasurements map.
|
|
8297
|
-
*/
|
|
8439
|
+
PerformanceClient.prototype.getQueueInfo = function (correlationId) {
|
|
8298
8440
|
var queueMeasurementForCorrelationId = this.queueMeasurements.get(correlationId);
|
|
8299
8441
|
if (!queueMeasurementForCorrelationId) {
|
|
8300
8442
|
this.logger.trace("PerformanceClient: no queue measurements found for for correlationId: " + correlationId);
|
|
8301
8443
|
}
|
|
8302
8444
|
var totalQueueTime = 0;
|
|
8303
8445
|
var totalQueueCount = 0;
|
|
8446
|
+
var manuallyCompletedCount = 0;
|
|
8304
8447
|
queueMeasurementForCorrelationId === null || queueMeasurementForCorrelationId === void 0 ? void 0 : queueMeasurementForCorrelationId.forEach(function (measurement) {
|
|
8305
8448
|
totalQueueTime += measurement.queueTime;
|
|
8306
8449
|
totalQueueCount++;
|
|
8450
|
+
manuallyCompletedCount += measurement.manuallyCompleted ? 1 : 0;
|
|
8307
8451
|
});
|
|
8308
|
-
|
|
8309
|
-
|
|
8310
|
-
|
|
8311
|
-
|
|
8312
|
-
|
|
8313
|
-
/*
|
|
8314
|
-
* Manually end incomplete submeasurements to ensure there arent orphaned/never ending events.
|
|
8315
|
-
* Incomplete submeasurements are likely an instrumentation bug that should be fixed.
|
|
8316
|
-
* IE only supports Map.forEach.
|
|
8317
|
-
*/
|
|
8318
|
-
var completedEvents_1 = [];
|
|
8319
|
-
var incompleteSubsCount_1 = 0;
|
|
8320
|
-
eventsForCorrelationId.forEach(function (event) {
|
|
8321
|
-
if (event.name !== measureName && event.status !== PerformanceEventStatus.Completed) {
|
|
8322
|
-
_this.logger.trace("PerformanceClient: Incomplete submeasurement " + event.name + " found for " + measureName, correlationId);
|
|
8323
|
-
incompleteSubsCount_1++;
|
|
8324
|
-
var completedEvent = _this.endMeasurement(event);
|
|
8325
|
-
if (completedEvent) {
|
|
8326
|
-
completedEvents_1.push(completedEvent);
|
|
8327
|
-
}
|
|
8328
|
-
}
|
|
8329
|
-
completedEvents_1.push(event);
|
|
8330
|
-
});
|
|
8331
|
-
// Sort events by start time (earliest first)
|
|
8332
|
-
var sortedCompletedEvents = completedEvents_1.sort(function (eventA, eventB) { return eventA.startTimeMs - eventB.startTimeMs; });
|
|
8333
|
-
// Take completed top level event and add completed submeasurements durations as properties
|
|
8334
|
-
var topLevelEvents = sortedCompletedEvents.filter(function (event) { return event.name === measureName && event.status === PerformanceEventStatus.Completed; });
|
|
8335
|
-
if (topLevelEvents.length > 0) {
|
|
8336
|
-
/*
|
|
8337
|
-
* Only take the first top-level event if there are multiple events with the same correlation id.
|
|
8338
|
-
* This greatly simplifies logic for submeasurements.
|
|
8339
|
-
*/
|
|
8340
|
-
if (topLevelEvents.length > 1) {
|
|
8341
|
-
this.logger.verbose("PerformanceClient: Multiple distinct top-level performance events found, using the first", correlationId);
|
|
8342
|
-
}
|
|
8343
|
-
var topLevelEvent = topLevelEvents[0];
|
|
8344
|
-
this.logger.verbose("PerformanceClient: Measurement found for " + measureName, correlationId);
|
|
8345
|
-
// Build event object with top level and sub measurements
|
|
8346
|
-
var eventToEmit = sortedCompletedEvents.reduce(function (previous, current) {
|
|
8347
|
-
if (current.name !== measureName) {
|
|
8348
|
-
_this.logger.trace("PerformanceClient: Complete submeasurement found for " + current.name, correlationId);
|
|
8349
|
-
// TODO: Emit additional properties for each subMeasurement
|
|
8350
|
-
var subMeasurementName = current.name + "DurationMs";
|
|
8351
|
-
/*
|
|
8352
|
-
* Some code paths, such as resolving an authority, can occur multiple times.
|
|
8353
|
-
* Only take the first measurement, since the second could be read from the cache,
|
|
8354
|
-
* or due to the same correlation id being used for two distinct requests.
|
|
8355
|
-
*/
|
|
8356
|
-
if (!previous[subMeasurementName]) {
|
|
8357
|
-
previous[subMeasurementName] = current.durationMs;
|
|
8358
|
-
}
|
|
8359
|
-
else {
|
|
8360
|
-
_this.logger.verbose("PerformanceClient: Submeasurement for " + measureName + " already exists for " + current.name + ", ignoring", correlationId);
|
|
8361
|
-
}
|
|
8362
|
-
}
|
|
8363
|
-
return previous;
|
|
8364
|
-
}, topLevelEvent);
|
|
8365
|
-
var finalEvent = __assign(__assign(__assign(__assign({}, eventToEmit), staticFields), counters), { queuedTimeMs: totalQueueTime, queuedCount: totalQueueCount, incompleteSubsCount: incompleteSubsCount_1 });
|
|
8366
|
-
this.truncateIntegralFields(finalEvent, this.getIntFields());
|
|
8367
|
-
this.emitEvents([finalEvent], eventToEmit.correlationId);
|
|
8368
|
-
}
|
|
8369
|
-
else {
|
|
8370
|
-
this.logger.verbose("PerformanceClient: No completed top-level measurements found for " + measureName, correlationId);
|
|
8371
|
-
}
|
|
8372
|
-
}
|
|
8373
|
-
else {
|
|
8374
|
-
this.logger.verbose("PerformanceClient: No measurements found", correlationId);
|
|
8375
|
-
}
|
|
8452
|
+
return {
|
|
8453
|
+
totalQueueTime: totalQueueTime,
|
|
8454
|
+
totalQueueCount: totalQueueCount,
|
|
8455
|
+
manuallyCompletedCount: manuallyCompletedCount
|
|
8456
|
+
};
|
|
8376
8457
|
};
|
|
8377
8458
|
/**
|
|
8378
8459
|
* Removes measurements for a given correlation id.
|
|
@@ -8386,14 +8467,10 @@ var PerformanceClient = /** @class */ (function () {
|
|
|
8386
8467
|
/**
|
|
8387
8468
|
* Removes cache for a given correlation id.
|
|
8388
8469
|
*
|
|
8389
|
-
* @param {string} correlation identifier
|
|
8470
|
+
* @param {string} correlationId correlation identifier
|
|
8390
8471
|
*/
|
|
8391
8472
|
PerformanceClient.prototype.discardCache = function (correlationId) {
|
|
8392
8473
|
this.discardMeasurements(correlationId);
|
|
8393
|
-
this.logger.trace("PerformanceClient: Static fields discarded", correlationId);
|
|
8394
|
-
this.staticFieldsByCorrelationId.delete(correlationId);
|
|
8395
|
-
this.logger.trace("PerformanceClient: Counters discarded", correlationId);
|
|
8396
|
-
this.countersByCorrelationId.delete(correlationId);
|
|
8397
8474
|
this.logger.trace("PerformanceClient: QueueMeasurements discarded", correlationId);
|
|
8398
8475
|
this.queueMeasurements.delete(correlationId);
|
|
8399
8476
|
this.logger.trace("PerformanceClient: Pre-queue times discarded", correlationId);
|
|
@@ -8456,7 +8533,7 @@ var PerformanceClient = /** @class */ (function () {
|
|
|
8456
8533
|
return PerformanceClient;
|
|
8457
8534
|
}());
|
|
8458
8535
|
|
|
8459
|
-
/*! @azure/msal-common
|
|
8536
|
+
/*! @azure/msal-common v12.0.0 2023-04-03 */
|
|
8460
8537
|
|
|
8461
8538
|
/*
|
|
8462
8539
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -8659,6 +8736,10 @@ var BrowserAuthErrorMessage = {
|
|
|
8659
8736
|
code: "auth_code_or_nativeAccountId_required",
|
|
8660
8737
|
desc: "An authorization code or nativeAccountId must be provided to this flow."
|
|
8661
8738
|
},
|
|
8739
|
+
spaCodeAndNativeAccountPresent: {
|
|
8740
|
+
code: "spa_code_and_nativeAccountId_present",
|
|
8741
|
+
desc: "Request cannot contain both spa code and native account id."
|
|
8742
|
+
},
|
|
8662
8743
|
databaseUnavailable: {
|
|
8663
8744
|
code: "database_unavailable",
|
|
8664
8745
|
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."
|
|
@@ -8931,6 +9012,12 @@ var BrowserAuthError = /** @class */ (function (_super) {
|
|
|
8931
9012
|
BrowserAuthError.createAuthCodeOrNativeAccountIdRequiredError = function () {
|
|
8932
9013
|
return new BrowserAuthError(BrowserAuthErrorMessage.authCodeOrNativeAccountRequired.code, BrowserAuthErrorMessage.authCodeOrNativeAccountRequired.desc);
|
|
8933
9014
|
};
|
|
9015
|
+
/**
|
|
9016
|
+
* Create an error when both authorization code and native account ID are provided
|
|
9017
|
+
*/
|
|
9018
|
+
BrowserAuthError.createSpaCodeAndNativeAccountIdPresentError = function () {
|
|
9019
|
+
return new BrowserAuthError(BrowserAuthErrorMessage.spaCodeAndNativeAccountPresent.code, BrowserAuthErrorMessage.spaCodeAndNativeAccountPresent.desc);
|
|
9020
|
+
};
|
|
8934
9021
|
/**
|
|
8935
9022
|
* Create an error when IndexedDB is unavailable
|
|
8936
9023
|
*/
|
|
@@ -9062,6 +9149,11 @@ var TemporaryCacheKeys;
|
|
|
9062
9149
|
TemporaryCacheKeys["NATIVE_REQUEST"] = "request.native";
|
|
9063
9150
|
TemporaryCacheKeys["REDIRECT_CONTEXT"] = "request.redirect.context";
|
|
9064
9151
|
})(TemporaryCacheKeys || (TemporaryCacheKeys = {}));
|
|
9152
|
+
var StaticCacheKeys;
|
|
9153
|
+
(function (StaticCacheKeys) {
|
|
9154
|
+
StaticCacheKeys["ACCOUNT_KEYS"] = "msal.account.keys";
|
|
9155
|
+
StaticCacheKeys["TOKEN_KEYS"] = "msal.token.keys";
|
|
9156
|
+
})(StaticCacheKeys || (StaticCacheKeys = {}));
|
|
9065
9157
|
/**
|
|
9066
9158
|
* Cache keys stored in-memory
|
|
9067
9159
|
*/
|
|
@@ -9407,7 +9499,7 @@ var BrowserProtocolUtils = /** @class */ (function () {
|
|
|
9407
9499
|
var BrowserCacheManager = /** @class */ (function (_super) {
|
|
9408
9500
|
__extends$1(BrowserCacheManager, _super);
|
|
9409
9501
|
function BrowserCacheManager(clientId, cacheConfig, cryptoImpl, logger) {
|
|
9410
|
-
var _this = _super.call(this, clientId, cryptoImpl) || this;
|
|
9502
|
+
var _this = _super.call(this, clientId, cryptoImpl, logger) || this;
|
|
9411
9503
|
// Cookie life calculation (hours * minutes * seconds * ms)
|
|
9412
9504
|
_this.COOKIE_LIFE_MULTIPLIER = 24 * 60 * 60 * 1000;
|
|
9413
9505
|
_this.cacheConfig = cacheConfig;
|
|
@@ -9415,8 +9507,11 @@ var BrowserCacheManager = /** @class */ (function (_super) {
|
|
|
9415
9507
|
_this.internalStorage = new MemoryStorage();
|
|
9416
9508
|
_this.browserStorage = _this.setupBrowserStorage(_this.cacheConfig.cacheLocation);
|
|
9417
9509
|
_this.temporaryCacheStorage = _this.setupTemporaryCacheStorage(_this.cacheConfig.cacheLocation);
|
|
9418
|
-
// Migrate
|
|
9419
|
-
|
|
9510
|
+
// Migrate cache entries from older versions of MSAL.
|
|
9511
|
+
if (cacheConfig.cacheMigrationEnabled) {
|
|
9512
|
+
_this.migrateCacheEntries();
|
|
9513
|
+
_this.createKeyMaps();
|
|
9514
|
+
}
|
|
9420
9515
|
return _this;
|
|
9421
9516
|
}
|
|
9422
9517
|
/**
|
|
@@ -9490,6 +9585,91 @@ var BrowserCacheManager = /** @class */ (function (_super) {
|
|
|
9490
9585
|
this.setTemporaryCache(newKey, value, true);
|
|
9491
9586
|
}
|
|
9492
9587
|
};
|
|
9588
|
+
/**
|
|
9589
|
+
* Searches all cache entries for MSAL accounts and creates the account key map
|
|
9590
|
+
* This is used to migrate users from older versions of MSAL which did not create the map.
|
|
9591
|
+
* @returns
|
|
9592
|
+
*/
|
|
9593
|
+
BrowserCacheManager.prototype.createKeyMaps = function () {
|
|
9594
|
+
var _this = this;
|
|
9595
|
+
this.logger.trace("BrowserCacheManager - createKeyMaps called.");
|
|
9596
|
+
var accountKeys = this.getItem(StaticCacheKeys.ACCOUNT_KEYS);
|
|
9597
|
+
var tokenKeys = this.getItem(StaticCacheKeys.TOKEN_KEYS + "." + this.clientId);
|
|
9598
|
+
if (accountKeys && tokenKeys) {
|
|
9599
|
+
this.logger.verbose("BrowserCacheManager:createKeyMaps - account and token key maps already exist, skipping migration.");
|
|
9600
|
+
// Key maps already exist, no need to iterate through cache
|
|
9601
|
+
return;
|
|
9602
|
+
}
|
|
9603
|
+
var allKeys = this.browserStorage.getKeys();
|
|
9604
|
+
allKeys.forEach(function (key) {
|
|
9605
|
+
if (_this.isCredentialKey(key)) {
|
|
9606
|
+
// Get item, parse, validate and write key to map
|
|
9607
|
+
var value = _this.getItem(key);
|
|
9608
|
+
if (value) {
|
|
9609
|
+
var credObj = _this.validateAndParseJson(value);
|
|
9610
|
+
if (credObj && credObj.hasOwnProperty("credentialType")) {
|
|
9611
|
+
switch (credObj["credentialType"]) {
|
|
9612
|
+
case CredentialType.ID_TOKEN:
|
|
9613
|
+
if (IdTokenEntity.isIdTokenEntity(credObj)) {
|
|
9614
|
+
_this.logger.trace("BrowserCacheManager:createKeyMaps - idToken found, saving key to token key map");
|
|
9615
|
+
_this.logger.tracePii("BrowserCacheManager:createKeyMaps - idToken with key: " + key + " found, saving key to token key map");
|
|
9616
|
+
var idTokenEntity = CacheManager.toObject(new IdTokenEntity(), credObj);
|
|
9617
|
+
var newKey = _this.updateCredentialCacheKey(key, idTokenEntity);
|
|
9618
|
+
_this.addTokenKey(newKey, CredentialType.ID_TOKEN);
|
|
9619
|
+
return;
|
|
9620
|
+
}
|
|
9621
|
+
else {
|
|
9622
|
+
_this.logger.trace("BrowserCacheManager:createKeyMaps - key found matching idToken schema with value containing idToken credentialType field but value failed IdTokenEntity validation, skipping.");
|
|
9623
|
+
_this.logger.tracePii("BrowserCacheManager:createKeyMaps - failed idToken validation on key: " + key);
|
|
9624
|
+
}
|
|
9625
|
+
break;
|
|
9626
|
+
case CredentialType.ACCESS_TOKEN:
|
|
9627
|
+
case CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME:
|
|
9628
|
+
if (AccessTokenEntity.isAccessTokenEntity(credObj)) {
|
|
9629
|
+
_this.logger.trace("BrowserCacheManager:createKeyMaps - accessToken found, saving key to token key map");
|
|
9630
|
+
_this.logger.tracePii("BrowserCacheManager:createKeyMaps - accessToken with key: " + key + " found, saving key to token key map");
|
|
9631
|
+
var accessTokenEntity = CacheManager.toObject(new AccessTokenEntity(), credObj);
|
|
9632
|
+
var newKey = _this.updateCredentialCacheKey(key, accessTokenEntity);
|
|
9633
|
+
_this.addTokenKey(newKey, CredentialType.ACCESS_TOKEN);
|
|
9634
|
+
return;
|
|
9635
|
+
}
|
|
9636
|
+
else {
|
|
9637
|
+
_this.logger.trace("BrowserCacheManager:createKeyMaps - key found matching accessToken schema with value containing accessToken credentialType field but value failed AccessTokenEntity validation, skipping.");
|
|
9638
|
+
_this.logger.tracePii("BrowserCacheManager:createKeyMaps - failed accessToken validation on key: " + key);
|
|
9639
|
+
}
|
|
9640
|
+
break;
|
|
9641
|
+
case CredentialType.REFRESH_TOKEN:
|
|
9642
|
+
if (RefreshTokenEntity.isRefreshTokenEntity(credObj)) {
|
|
9643
|
+
_this.logger.trace("BrowserCacheManager:createKeyMaps - refreshToken found, saving key to token key map");
|
|
9644
|
+
_this.logger.tracePii("BrowserCacheManager:createKeyMaps - refreshToken with key: " + key + " found, saving key to token key map");
|
|
9645
|
+
var refreshTokenEntity = CacheManager.toObject(new RefreshTokenEntity(), credObj);
|
|
9646
|
+
var newKey = _this.updateCredentialCacheKey(key, refreshTokenEntity);
|
|
9647
|
+
_this.addTokenKey(newKey, CredentialType.REFRESH_TOKEN);
|
|
9648
|
+
return;
|
|
9649
|
+
}
|
|
9650
|
+
else {
|
|
9651
|
+
_this.logger.trace("BrowserCacheManager:createKeyMaps - key found matching refreshToken schema with value containing refreshToken credentialType field but value failed RefreshTokenEntity validation, skipping.");
|
|
9652
|
+
_this.logger.tracePii("BrowserCacheManager:createKeyMaps - failed refreshToken validation on key: " + key);
|
|
9653
|
+
}
|
|
9654
|
+
break;
|
|
9655
|
+
// If credentialType isn't one of our predefined ones, it may not be an MSAL cache value. Ignore.
|
|
9656
|
+
}
|
|
9657
|
+
}
|
|
9658
|
+
}
|
|
9659
|
+
}
|
|
9660
|
+
if (_this.isAccountKey(key)) {
|
|
9661
|
+
var value = _this.getItem(key);
|
|
9662
|
+
if (value) {
|
|
9663
|
+
var accountObj = _this.validateAndParseJson(value);
|
|
9664
|
+
if (accountObj && AccountEntity.isAccountEntity(accountObj)) {
|
|
9665
|
+
_this.logger.trace("BrowserCacheManager:createKeyMaps - account found, saving key to account key map");
|
|
9666
|
+
_this.logger.tracePii("BrowserCacheManager:createKeyMaps - account with key: " + key + " found, saving key to account key map");
|
|
9667
|
+
_this.addAccountKeyToMap(key);
|
|
9668
|
+
}
|
|
9669
|
+
}
|
|
9670
|
+
}
|
|
9671
|
+
});
|
|
9672
|
+
};
|
|
9493
9673
|
/**
|
|
9494
9674
|
* Parses passed value as JSON object, JSON.parse() will throw an error.
|
|
9495
9675
|
* @param input
|
|
@@ -9529,12 +9709,15 @@ var BrowserCacheManager = /** @class */ (function (_super) {
|
|
|
9529
9709
|
* @param accountKey
|
|
9530
9710
|
*/
|
|
9531
9711
|
BrowserCacheManager.prototype.getAccount = function (accountKey) {
|
|
9712
|
+
this.logger.trace("BrowserCacheManager.getAccount called");
|
|
9532
9713
|
var account = this.getItem(accountKey);
|
|
9533
9714
|
if (!account) {
|
|
9715
|
+
this.removeAccountKeyFromMap(accountKey);
|
|
9534
9716
|
return null;
|
|
9535
9717
|
}
|
|
9536
9718
|
var parsedAccount = this.validateAndParseJson(account);
|
|
9537
9719
|
if (!parsedAccount || !AccountEntity.isAccountEntity(parsedAccount)) {
|
|
9720
|
+
this.removeAccountKeyFromMap(accountKey);
|
|
9538
9721
|
return null;
|
|
9539
9722
|
}
|
|
9540
9723
|
return CacheManager.toObject(new AccountEntity(), parsedAccount);
|
|
@@ -9548,6 +9731,207 @@ var BrowserCacheManager = /** @class */ (function (_super) {
|
|
|
9548
9731
|
this.logger.trace("BrowserCacheManager.setAccount called");
|
|
9549
9732
|
var key = account.generateAccountKey();
|
|
9550
9733
|
this.setItem(key, JSON.stringify(account));
|
|
9734
|
+
this.addAccountKeyToMap(key);
|
|
9735
|
+
};
|
|
9736
|
+
/**
|
|
9737
|
+
* Returns the array of account keys currently cached
|
|
9738
|
+
* @returns
|
|
9739
|
+
*/
|
|
9740
|
+
BrowserCacheManager.prototype.getAccountKeys = function () {
|
|
9741
|
+
this.logger.trace("BrowserCacheManager.getAccountKeys called");
|
|
9742
|
+
var accountKeys = this.getItem(StaticCacheKeys.ACCOUNT_KEYS);
|
|
9743
|
+
if (accountKeys) {
|
|
9744
|
+
return JSON.parse(accountKeys);
|
|
9745
|
+
}
|
|
9746
|
+
this.logger.verbose("BrowserCacheManager.getAccountKeys - No account keys found");
|
|
9747
|
+
return [];
|
|
9748
|
+
};
|
|
9749
|
+
/**
|
|
9750
|
+
* Add a new account to the key map
|
|
9751
|
+
* @param key
|
|
9752
|
+
*/
|
|
9753
|
+
BrowserCacheManager.prototype.addAccountKeyToMap = function (key) {
|
|
9754
|
+
this.logger.trace("BrowserCacheManager.addAccountKeyToMap called");
|
|
9755
|
+
this.logger.tracePii("BrowserCacheManager.addAccountKeyToMap called with key: " + key);
|
|
9756
|
+
var accountKeys = this.getAccountKeys();
|
|
9757
|
+
if (accountKeys.indexOf(key) === -1) {
|
|
9758
|
+
// Only add key if it does not already exist in the map
|
|
9759
|
+
accountKeys.push(key);
|
|
9760
|
+
this.setItem(StaticCacheKeys.ACCOUNT_KEYS, JSON.stringify(accountKeys));
|
|
9761
|
+
this.logger.verbose("BrowserCacheManager.addAccountKeyToMap account key added");
|
|
9762
|
+
}
|
|
9763
|
+
else {
|
|
9764
|
+
this.logger.verbose("BrowserCacheManager.addAccountKeyToMap account key already exists in map");
|
|
9765
|
+
}
|
|
9766
|
+
};
|
|
9767
|
+
/**
|
|
9768
|
+
* Remove an account from the key map
|
|
9769
|
+
* @param key
|
|
9770
|
+
*/
|
|
9771
|
+
BrowserCacheManager.prototype.removeAccountKeyFromMap = function (key) {
|
|
9772
|
+
this.logger.trace("BrowserCacheManager.removeAccountKeyFromMap called");
|
|
9773
|
+
this.logger.tracePii("BrowserCacheManager.removeAccountKeyFromMap called with key: " + key);
|
|
9774
|
+
var accountKeys = this.getAccountKeys();
|
|
9775
|
+
var removalIndex = accountKeys.indexOf(key);
|
|
9776
|
+
if (removalIndex > -1) {
|
|
9777
|
+
accountKeys.splice(removalIndex, 1);
|
|
9778
|
+
this.setItem(StaticCacheKeys.ACCOUNT_KEYS, JSON.stringify(accountKeys));
|
|
9779
|
+
this.logger.trace("BrowserCacheManager.removeAccountKeyFromMap account key removed");
|
|
9780
|
+
}
|
|
9781
|
+
else {
|
|
9782
|
+
this.logger.trace("BrowserCacheManager.removeAccountKeyFromMap key not found in existing map");
|
|
9783
|
+
}
|
|
9784
|
+
};
|
|
9785
|
+
/**
|
|
9786
|
+
* Extends inherited removeAccount function to include removal of the account key from the map
|
|
9787
|
+
* @param key
|
|
9788
|
+
*/
|
|
9789
|
+
BrowserCacheManager.prototype.removeAccount = function (key) {
|
|
9790
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
9791
|
+
return __generator$1(this, function (_a) {
|
|
9792
|
+
_super.prototype.removeAccount.call(this, key);
|
|
9793
|
+
this.removeAccountKeyFromMap(key);
|
|
9794
|
+
return [2 /*return*/];
|
|
9795
|
+
});
|
|
9796
|
+
});
|
|
9797
|
+
};
|
|
9798
|
+
/**
|
|
9799
|
+
* Removes given idToken from the cache and from the key map
|
|
9800
|
+
* @param key
|
|
9801
|
+
*/
|
|
9802
|
+
BrowserCacheManager.prototype.removeIdToken = function (key) {
|
|
9803
|
+
_super.prototype.removeIdToken.call(this, key);
|
|
9804
|
+
this.removeTokenKey(key, CredentialType.ID_TOKEN);
|
|
9805
|
+
};
|
|
9806
|
+
/**
|
|
9807
|
+
* Removes given accessToken from the cache and from the key map
|
|
9808
|
+
* @param key
|
|
9809
|
+
*/
|
|
9810
|
+
BrowserCacheManager.prototype.removeAccessToken = function (key) {
|
|
9811
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
9812
|
+
return __generator$1(this, function (_a) {
|
|
9813
|
+
_super.prototype.removeAccessToken.call(this, key);
|
|
9814
|
+
this.removeTokenKey(key, CredentialType.ACCESS_TOKEN);
|
|
9815
|
+
return [2 /*return*/];
|
|
9816
|
+
});
|
|
9817
|
+
});
|
|
9818
|
+
};
|
|
9819
|
+
/**
|
|
9820
|
+
* Removes given refreshToken from the cache and from the key map
|
|
9821
|
+
* @param key
|
|
9822
|
+
*/
|
|
9823
|
+
BrowserCacheManager.prototype.removeRefreshToken = function (key) {
|
|
9824
|
+
_super.prototype.removeRefreshToken.call(this, key);
|
|
9825
|
+
this.removeTokenKey(key, CredentialType.REFRESH_TOKEN);
|
|
9826
|
+
};
|
|
9827
|
+
/**
|
|
9828
|
+
* Gets the keys for the cached tokens associated with this clientId
|
|
9829
|
+
* @returns
|
|
9830
|
+
*/
|
|
9831
|
+
BrowserCacheManager.prototype.getTokenKeys = function () {
|
|
9832
|
+
this.logger.trace("BrowserCacheManager.getTokenKeys called");
|
|
9833
|
+
var item = this.getItem(StaticCacheKeys.TOKEN_KEYS + "." + this.clientId);
|
|
9834
|
+
if (item) {
|
|
9835
|
+
var tokenKeys = this.validateAndParseJson(item);
|
|
9836
|
+
if (tokenKeys &&
|
|
9837
|
+
tokenKeys.hasOwnProperty("idToken") &&
|
|
9838
|
+
tokenKeys.hasOwnProperty("accessToken") &&
|
|
9839
|
+
tokenKeys.hasOwnProperty("refreshToken")) {
|
|
9840
|
+
return tokenKeys;
|
|
9841
|
+
}
|
|
9842
|
+
else {
|
|
9843
|
+
this.logger.error("BrowserCacheManager.getTokenKeys - Token keys found but in an unknown format. Returning empty key map.");
|
|
9844
|
+
}
|
|
9845
|
+
}
|
|
9846
|
+
else {
|
|
9847
|
+
this.logger.verbose("BrowserCacheManager.getTokenKeys - No token keys found");
|
|
9848
|
+
}
|
|
9849
|
+
return {
|
|
9850
|
+
idToken: [],
|
|
9851
|
+
accessToken: [],
|
|
9852
|
+
refreshToken: []
|
|
9853
|
+
};
|
|
9854
|
+
};
|
|
9855
|
+
/**
|
|
9856
|
+
* Adds the given key to the token key map
|
|
9857
|
+
* @param key
|
|
9858
|
+
* @param type
|
|
9859
|
+
*/
|
|
9860
|
+
BrowserCacheManager.prototype.addTokenKey = function (key, type) {
|
|
9861
|
+
this.logger.trace("BrowserCacheManager addTokenKey called");
|
|
9862
|
+
var tokenKeys = this.getTokenKeys();
|
|
9863
|
+
switch (type) {
|
|
9864
|
+
case CredentialType.ID_TOKEN:
|
|
9865
|
+
if (tokenKeys.idToken.indexOf(key) === -1) {
|
|
9866
|
+
this.logger.info("BrowserCacheManager: addTokenKey - idToken added to map");
|
|
9867
|
+
tokenKeys.idToken.push(key);
|
|
9868
|
+
}
|
|
9869
|
+
break;
|
|
9870
|
+
case CredentialType.ACCESS_TOKEN:
|
|
9871
|
+
if (tokenKeys.accessToken.indexOf(key) === -1) {
|
|
9872
|
+
this.logger.info("BrowserCacheManager: addTokenKey - accessToken added to map");
|
|
9873
|
+
tokenKeys.accessToken.push(key);
|
|
9874
|
+
}
|
|
9875
|
+
break;
|
|
9876
|
+
case CredentialType.REFRESH_TOKEN:
|
|
9877
|
+
if (tokenKeys.refreshToken.indexOf(key) === -1) {
|
|
9878
|
+
this.logger.info("BrowserCacheManager: addTokenKey - refreshToken added to map");
|
|
9879
|
+
tokenKeys.refreshToken.push(key);
|
|
9880
|
+
}
|
|
9881
|
+
break;
|
|
9882
|
+
default:
|
|
9883
|
+
this.logger.error("BrowserCacheManager:addTokenKey - CredentialType provided invalid. CredentialType: " + type);
|
|
9884
|
+
ClientAuthError.createUnexpectedCredentialTypeError();
|
|
9885
|
+
}
|
|
9886
|
+
this.setItem(StaticCacheKeys.TOKEN_KEYS + "." + this.clientId, JSON.stringify(tokenKeys));
|
|
9887
|
+
};
|
|
9888
|
+
/**
|
|
9889
|
+
* Removes the given key from the token key map
|
|
9890
|
+
* @param key
|
|
9891
|
+
* @param type
|
|
9892
|
+
*/
|
|
9893
|
+
BrowserCacheManager.prototype.removeTokenKey = function (key, type) {
|
|
9894
|
+
this.logger.trace("BrowserCacheManager removeTokenKey called");
|
|
9895
|
+
var tokenKeys = this.getTokenKeys();
|
|
9896
|
+
switch (type) {
|
|
9897
|
+
case CredentialType.ID_TOKEN:
|
|
9898
|
+
this.logger.infoPii("BrowserCacheManager: removeTokenKey - attempting to remove idToken with key: " + key + " from map");
|
|
9899
|
+
var idRemoval = tokenKeys.idToken.indexOf(key);
|
|
9900
|
+
if (idRemoval > -1) {
|
|
9901
|
+
this.logger.info("BrowserCacheManager: removeTokenKey - idToken removed from map");
|
|
9902
|
+
tokenKeys.idToken.splice(idRemoval, 1);
|
|
9903
|
+
}
|
|
9904
|
+
else {
|
|
9905
|
+
this.logger.info("BrowserCacheManager: removeTokenKey - idToken does not exist in map. Either it was previously removed or it was never added.");
|
|
9906
|
+
}
|
|
9907
|
+
break;
|
|
9908
|
+
case CredentialType.ACCESS_TOKEN:
|
|
9909
|
+
this.logger.infoPii("BrowserCacheManager: removeTokenKey - attempting to remove accessToken with key: " + key + " from map");
|
|
9910
|
+
var accessRemoval = tokenKeys.accessToken.indexOf(key);
|
|
9911
|
+
if (accessRemoval > -1) {
|
|
9912
|
+
this.logger.info("BrowserCacheManager: removeTokenKey - accessToken removed from map");
|
|
9913
|
+
tokenKeys.idToken.splice(accessRemoval, 1);
|
|
9914
|
+
}
|
|
9915
|
+
else {
|
|
9916
|
+
this.logger.info("BrowserCacheManager: removeTokenKey - accessToken does not exist in map. Either it was previously removed or it was never added.");
|
|
9917
|
+
}
|
|
9918
|
+
break;
|
|
9919
|
+
case CredentialType.REFRESH_TOKEN:
|
|
9920
|
+
this.logger.infoPii("BrowserCacheManager: removeTokenKey - attempting to remove refreshToken with key: " + key + " from map");
|
|
9921
|
+
var refreshRemoval = tokenKeys.refreshToken.indexOf(key);
|
|
9922
|
+
if (refreshRemoval > -1) {
|
|
9923
|
+
this.logger.info("BrowserCacheManager: removeTokenKey - refreshToken removed from map");
|
|
9924
|
+
tokenKeys.idToken.splice(refreshRemoval, 1);
|
|
9925
|
+
}
|
|
9926
|
+
else {
|
|
9927
|
+
this.logger.info("BrowserCacheManager: removeTokenKey - refreshToken does not exist in map. Either it was previously removed or it was never added.");
|
|
9928
|
+
}
|
|
9929
|
+
break;
|
|
9930
|
+
default:
|
|
9931
|
+
this.logger.error("BrowserCacheManager:removeTokenKey - CredentialType provided invalid. CredentialType: " + type);
|
|
9932
|
+
ClientAuthError.createUnexpectedCredentialTypeError();
|
|
9933
|
+
}
|
|
9934
|
+
this.setItem(StaticCacheKeys.TOKEN_KEYS + "." + this.clientId, JSON.stringify(tokenKeys));
|
|
9551
9935
|
};
|
|
9552
9936
|
/**
|
|
9553
9937
|
* generates idToken entity from a string
|
|
@@ -9557,11 +9941,13 @@ var BrowserCacheManager = /** @class */ (function (_super) {
|
|
|
9557
9941
|
var value = this.getItem(idTokenKey);
|
|
9558
9942
|
if (!value) {
|
|
9559
9943
|
this.logger.trace("BrowserCacheManager.getIdTokenCredential: called, no cache hit");
|
|
9944
|
+
this.removeTokenKey(idTokenKey, CredentialType.ID_TOKEN);
|
|
9560
9945
|
return null;
|
|
9561
9946
|
}
|
|
9562
9947
|
var parsedIdToken = this.validateAndParseJson(value);
|
|
9563
9948
|
if (!parsedIdToken || !IdTokenEntity.isIdTokenEntity(parsedIdToken)) {
|
|
9564
9949
|
this.logger.trace("BrowserCacheManager.getIdTokenCredential: called, no cache hit");
|
|
9950
|
+
this.removeTokenKey(idTokenKey, CredentialType.ID_TOKEN);
|
|
9565
9951
|
return null;
|
|
9566
9952
|
}
|
|
9567
9953
|
this.logger.trace("BrowserCacheManager.getIdTokenCredential: cache hit");
|
|
@@ -9575,6 +9961,7 @@ var BrowserCacheManager = /** @class */ (function (_super) {
|
|
|
9575
9961
|
this.logger.trace("BrowserCacheManager.setIdTokenCredential called");
|
|
9576
9962
|
var idTokenKey = idToken.generateCredentialKey();
|
|
9577
9963
|
this.setItem(idTokenKey, JSON.stringify(idToken));
|
|
9964
|
+
this.addTokenKey(idTokenKey, CredentialType.ID_TOKEN);
|
|
9578
9965
|
};
|
|
9579
9966
|
/**
|
|
9580
9967
|
* generates accessToken entity from a string
|
|
@@ -9584,11 +9971,13 @@ var BrowserCacheManager = /** @class */ (function (_super) {
|
|
|
9584
9971
|
var value = this.getItem(accessTokenKey);
|
|
9585
9972
|
if (!value) {
|
|
9586
9973
|
this.logger.trace("BrowserCacheManager.getAccessTokenCredential: called, no cache hit");
|
|
9974
|
+
this.removeTokenKey(accessTokenKey, CredentialType.ACCESS_TOKEN);
|
|
9587
9975
|
return null;
|
|
9588
9976
|
}
|
|
9589
9977
|
var parsedAccessToken = this.validateAndParseJson(value);
|
|
9590
9978
|
if (!parsedAccessToken || !AccessTokenEntity.isAccessTokenEntity(parsedAccessToken)) {
|
|
9591
9979
|
this.logger.trace("BrowserCacheManager.getAccessTokenCredential: called, no cache hit");
|
|
9980
|
+
this.removeTokenKey(accessTokenKey, CredentialType.ACCESS_TOKEN);
|
|
9592
9981
|
return null;
|
|
9593
9982
|
}
|
|
9594
9983
|
this.logger.trace("BrowserCacheManager.getAccessTokenCredential: cache hit");
|
|
@@ -9602,6 +9991,7 @@ var BrowserCacheManager = /** @class */ (function (_super) {
|
|
|
9602
9991
|
this.logger.trace("BrowserCacheManager.setAccessTokenCredential called");
|
|
9603
9992
|
var accessTokenKey = accessToken.generateCredentialKey();
|
|
9604
9993
|
this.setItem(accessTokenKey, JSON.stringify(accessToken));
|
|
9994
|
+
this.addTokenKey(accessTokenKey, CredentialType.ACCESS_TOKEN);
|
|
9605
9995
|
};
|
|
9606
9996
|
/**
|
|
9607
9997
|
* generates refreshToken entity from a string
|
|
@@ -9611,11 +10001,13 @@ var BrowserCacheManager = /** @class */ (function (_super) {
|
|
|
9611
10001
|
var value = this.getItem(refreshTokenKey);
|
|
9612
10002
|
if (!value) {
|
|
9613
10003
|
this.logger.trace("BrowserCacheManager.getRefreshTokenCredential: called, no cache hit");
|
|
10004
|
+
this.removeTokenKey(refreshTokenKey, CredentialType.REFRESH_TOKEN);
|
|
9614
10005
|
return null;
|
|
9615
10006
|
}
|
|
9616
10007
|
var parsedRefreshToken = this.validateAndParseJson(value);
|
|
9617
10008
|
if (!parsedRefreshToken || !RefreshTokenEntity.isRefreshTokenEntity(parsedRefreshToken)) {
|
|
9618
10009
|
this.logger.trace("BrowserCacheManager.getRefreshTokenCredential: called, no cache hit");
|
|
10010
|
+
this.removeTokenKey(refreshTokenKey, CredentialType.REFRESH_TOKEN);
|
|
9619
10011
|
return null;
|
|
9620
10012
|
}
|
|
9621
10013
|
this.logger.trace("BrowserCacheManager.getRefreshTokenCredential: cache hit");
|
|
@@ -9629,6 +10021,7 @@ var BrowserCacheManager = /** @class */ (function (_super) {
|
|
|
9629
10021
|
this.logger.trace("BrowserCacheManager.setRefreshTokenCredential called");
|
|
9630
10022
|
var refreshTokenKey = refreshToken.generateCredentialKey();
|
|
9631
10023
|
this.setItem(refreshTokenKey, JSON.stringify(refreshToken));
|
|
10024
|
+
this.addTokenKey(refreshTokenKey, CredentialType.REFRESH_TOKEN);
|
|
9632
10025
|
};
|
|
9633
10026
|
/**
|
|
9634
10027
|
* fetch appMetadata entity from the platform cache
|
|
@@ -9926,7 +10319,6 @@ var BrowserCacheManager = /** @class */ (function (_super) {
|
|
|
9926
10319
|
this.logger.trace("BrowserCacheManager.removeItem: storeAuthStateInCookie is true, clearing item cookie");
|
|
9927
10320
|
this.clearItemCookie(key);
|
|
9928
10321
|
}
|
|
9929
|
-
return true;
|
|
9930
10322
|
};
|
|
9931
10323
|
/**
|
|
9932
10324
|
* Checks whether key is in cache.
|
|
@@ -10354,14 +10746,15 @@ var DEFAULT_BROWSER_CACHE_MANAGER = function (clientId, logger) {
|
|
|
10354
10746
|
var cacheOptions = {
|
|
10355
10747
|
cacheLocation: exports.BrowserCacheLocation.MemoryStorage,
|
|
10356
10748
|
storeAuthStateInCookie: false,
|
|
10357
|
-
secureCookies: false
|
|
10749
|
+
secureCookies: false,
|
|
10750
|
+
cacheMigrationEnabled: false
|
|
10358
10751
|
};
|
|
10359
10752
|
return new BrowserCacheManager(clientId, cacheOptions, DEFAULT_CRYPTO_IMPLEMENTATION, logger);
|
|
10360
10753
|
};
|
|
10361
10754
|
|
|
10362
10755
|
/* eslint-disable header/header */
|
|
10363
10756
|
var name = "@azure/msal-browser";
|
|
10364
|
-
var version = "2.
|
|
10757
|
+
var version = "2.35.0";
|
|
10365
10758
|
|
|
10366
10759
|
/*
|
|
10367
10760
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -11832,15 +12225,18 @@ var NativeInteractionClient = /** @class */ (function (_super) {
|
|
|
11832
12225
|
*/
|
|
11833
12226
|
NativeInteractionClient.prototype.acquireTokensFromCache = function (nativeAccountId, request) {
|
|
11834
12227
|
return __awaiter$1(this, void 0, void 0, function () {
|
|
11835
|
-
var
|
|
12228
|
+
var account, silentRequest, result, e_2;
|
|
11836
12229
|
return __generator$1(this, function (_a) {
|
|
11837
12230
|
switch (_a.label) {
|
|
11838
12231
|
case 0:
|
|
11839
|
-
|
|
11840
|
-
|
|
12232
|
+
if (!nativeAccountId) {
|
|
12233
|
+
this.logger.warning("NativeInteractionClient:acquireTokensFromCache - No nativeAccountId provided");
|
|
12234
|
+
throw ClientAuthError.createNoAccountFoundError();
|
|
12235
|
+
}
|
|
12236
|
+
account = this.browserStorage.getAccountInfoFilteredBy({ nativeAccountId: nativeAccountId });
|
|
12237
|
+
if (!account) {
|
|
11841
12238
|
throw ClientAuthError.createNoAccountFoundError();
|
|
11842
12239
|
}
|
|
11843
|
-
account = accountEntity.getAccountInfo();
|
|
11844
12240
|
_a.label = 1;
|
|
11845
12241
|
case 1:
|
|
11846
12242
|
_a.trys.push([1, 3, , 4]);
|
|
@@ -11971,60 +12367,92 @@ var NativeInteractionClient = /** @class */ (function (_super) {
|
|
|
11971
12367
|
*/
|
|
11972
12368
|
NativeInteractionClient.prototype.handleNativeResponse = function (response, request, reqTimestamp) {
|
|
11973
12369
|
return __awaiter$1(this, void 0, void 0, function () {
|
|
11974
|
-
var
|
|
11975
|
-
|
|
11976
|
-
|
|
11977
|
-
switch (_b.label) {
|
|
12370
|
+
var authority, authorityPreferredCache, idTokenObj, homeAccountIdentifier, accountEntity, result;
|
|
12371
|
+
return __generator$1(this, function (_a) {
|
|
12372
|
+
switch (_a.label) {
|
|
11978
12373
|
case 0:
|
|
11979
12374
|
this.logger.trace("NativeInteractionClient - handleNativeResponse called.");
|
|
11980
|
-
mats = this.getMATSFromResponse(response);
|
|
11981
|
-
this.performanceClient.addStaticFields({
|
|
11982
|
-
extensionId: this.nativeMessageHandler.getExtensionId(),
|
|
11983
|
-
extensionVersion: this.nativeMessageHandler.getExtensionVersion(),
|
|
11984
|
-
matsBrokerVersion: mats ? mats.broker_version : undefined,
|
|
11985
|
-
matsAccountJoinOnStart: mats ? mats.account_join_on_start : undefined,
|
|
11986
|
-
matsAccountJoinOnEnd: mats ? mats.account_join_on_end : undefined,
|
|
11987
|
-
matsDeviceJoin: mats ? mats.device_join : undefined,
|
|
11988
|
-
matsPromptBehavior: mats ? mats.prompt_behavior : undefined,
|
|
11989
|
-
matsApiErrorCode: mats ? mats.api_error_code : undefined,
|
|
11990
|
-
matsUiVisible: mats ? mats.ui_visible : undefined,
|
|
11991
|
-
matsSilentCode: mats ? mats.silent_code : undefined,
|
|
11992
|
-
matsSilentBiSubCode: mats ? mats.silent_bi_sub_code : undefined,
|
|
11993
|
-
matsSilentMessage: mats ? mats.silent_message : undefined,
|
|
11994
|
-
matsSilentStatus: mats ? mats.silent_status : undefined,
|
|
11995
|
-
matsHttpStatus: mats ? mats.http_status : undefined,
|
|
11996
|
-
matsHttpEventCount: mats ? mats.http_event_count : undefined
|
|
11997
|
-
}, this.correlationId);
|
|
11998
12375
|
if (response.account.id !== request.accountId) {
|
|
11999
12376
|
// 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
|
|
12000
12377
|
throw NativeAuthError.createUserSwitchError();
|
|
12001
12378
|
}
|
|
12002
|
-
idTokenObj = new AuthToken(response.id_token || Constants.EMPTY_STRING, this.browserCrypto);
|
|
12003
12379
|
return [4 /*yield*/, this.getDiscoveredAuthority(request.authority)];
|
|
12004
12380
|
case 1:
|
|
12005
|
-
authority =
|
|
12381
|
+
authority = _a.sent();
|
|
12006
12382
|
authorityPreferredCache = authority.getPreferredCache();
|
|
12007
|
-
|
|
12008
|
-
|
|
12009
|
-
this.
|
|
12010
|
-
|
|
12011
|
-
accountProperties = response.account.properties || {};
|
|
12012
|
-
uid = accountProperties["UID"] || idTokenObj.claims.oid || idTokenObj.claims.sub || Constants.EMPTY_STRING;
|
|
12013
|
-
tid = accountProperties["TenantId"] || idTokenObj.claims.tid || Constants.EMPTY_STRING;
|
|
12014
|
-
responseTokenType = exports.AuthenticationScheme.BEARER;
|
|
12015
|
-
_a = request.tokenType;
|
|
12016
|
-
switch (_a) {
|
|
12017
|
-
case exports.AuthenticationScheme.POP: return [3 /*break*/, 2];
|
|
12018
|
-
}
|
|
12019
|
-
return [3 /*break*/, 4];
|
|
12383
|
+
idTokenObj = this.createIdTokenObj(response);
|
|
12384
|
+
homeAccountIdentifier = this.createHomeAccountIdentifier(response, idTokenObj);
|
|
12385
|
+
accountEntity = this.createAccountEntity(response, homeAccountIdentifier, idTokenObj, authorityPreferredCache);
|
|
12386
|
+
return [4 /*yield*/, this.generateAuthenticationResult(response, request, idTokenObj, accountEntity, authority.canonicalAuthority, reqTimestamp)];
|
|
12020
12387
|
case 2:
|
|
12021
|
-
|
|
12022
|
-
|
|
12388
|
+
result = _a.sent();
|
|
12389
|
+
// cache accounts and tokens in the appropriate storage
|
|
12390
|
+
this.cacheAccount(accountEntity);
|
|
12391
|
+
this.cacheNativeTokens(response, request, homeAccountIdentifier, idTokenObj, result.accessToken, result.tenantId, reqTimestamp);
|
|
12392
|
+
return [2 /*return*/, result];
|
|
12393
|
+
}
|
|
12394
|
+
});
|
|
12395
|
+
});
|
|
12396
|
+
};
|
|
12397
|
+
/**
|
|
12398
|
+
* Create an idToken Object (not entity)
|
|
12399
|
+
* @param response
|
|
12400
|
+
* @returns
|
|
12401
|
+
*/
|
|
12402
|
+
NativeInteractionClient.prototype.createIdTokenObj = function (response) {
|
|
12403
|
+
return new AuthToken(response.id_token || Constants.EMPTY_STRING, this.browserCrypto);
|
|
12404
|
+
};
|
|
12405
|
+
/**
|
|
12406
|
+
* creates an homeAccountIdentifier for the account
|
|
12407
|
+
* @param response
|
|
12408
|
+
* @param idTokenObj
|
|
12409
|
+
* @returns
|
|
12410
|
+
*/
|
|
12411
|
+
NativeInteractionClient.prototype.createHomeAccountIdentifier = function (response, idTokenObj) {
|
|
12412
|
+
// Save account in browser storage
|
|
12413
|
+
var homeAccountIdentifier = AccountEntity.generateHomeAccountId(response.client_info || Constants.EMPTY_STRING, AuthorityType.Default, this.logger, this.browserCrypto, idTokenObj);
|
|
12414
|
+
return homeAccountIdentifier;
|
|
12415
|
+
};
|
|
12416
|
+
/**
|
|
12417
|
+
* Creates account entity
|
|
12418
|
+
* @param response
|
|
12419
|
+
* @param homeAccountIdentifier
|
|
12420
|
+
* @param idTokenObj
|
|
12421
|
+
* @param authority
|
|
12422
|
+
* @returns
|
|
12423
|
+
*/
|
|
12424
|
+
NativeInteractionClient.prototype.createAccountEntity = function (response, homeAccountIdentifier, idTokenObj, authority) {
|
|
12425
|
+
return AccountEntity.createAccount(response.client_info, homeAccountIdentifier, idTokenObj, undefined, undefined, undefined, authority, response.account.id);
|
|
12426
|
+
};
|
|
12427
|
+
/**
|
|
12428
|
+
* Helper to generate scopes
|
|
12429
|
+
* @param response
|
|
12430
|
+
* @param request
|
|
12431
|
+
* @returns
|
|
12432
|
+
*/
|
|
12433
|
+
NativeInteractionClient.prototype.generateScopes = function (response, request) {
|
|
12434
|
+
return response.scope ? ScopeSet.fromString(response.scope) : ScopeSet.fromString(request.scope);
|
|
12435
|
+
};
|
|
12436
|
+
/**
|
|
12437
|
+
* If PoP token is requesred, records the PoP token if returned from the WAM, else generates one in the browser
|
|
12438
|
+
* @param request
|
|
12439
|
+
* @param response
|
|
12440
|
+
*/
|
|
12441
|
+
NativeInteractionClient.prototype.generatePopAccessToken = function (response, request) {
|
|
12442
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
12443
|
+
var popTokenGenerator, shrParameters;
|
|
12444
|
+
return __generator$1(this, function (_a) {
|
|
12445
|
+
switch (_a.label) {
|
|
12446
|
+
case 0:
|
|
12447
|
+
if (!(request.tokenType === exports.AuthenticationScheme.POP)) return [3 /*break*/, 2];
|
|
12448
|
+
/**
|
|
12449
|
+
* This code prioritizes SHR returned from the native layer. In case of error/SHR not calculated from WAM and the AT
|
|
12450
|
+
* is still received, SHR is calculated locally
|
|
12451
|
+
*/
|
|
12023
12452
|
// Check if native layer returned an SHR token
|
|
12024
12453
|
if (response.shr) {
|
|
12025
12454
|
this.logger.trace("handleNativeServerResponse: SHR is enabled in native layer");
|
|
12026
|
-
|
|
12027
|
-
return [3 /*break*/, 5];
|
|
12455
|
+
return [2 /*return*/, response.shr];
|
|
12028
12456
|
}
|
|
12029
12457
|
popTokenGenerator = new PopTokenGenerator(this.browserCrypto);
|
|
12030
12458
|
shrParameters = {
|
|
@@ -12041,17 +12469,39 @@ var NativeInteractionClient = /** @class */ (function (_super) {
|
|
|
12041
12469
|
throw ClientAuthError.createKeyIdMissingError();
|
|
12042
12470
|
}
|
|
12043
12471
|
return [4 /*yield*/, popTokenGenerator.signPopToken(response.access_token, request.keyId, shrParameters)];
|
|
12044
|
-
case
|
|
12045
|
-
|
|
12046
|
-
|
|
12047
|
-
|
|
12048
|
-
|
|
12049
|
-
|
|
12050
|
-
|
|
12051
|
-
|
|
12052
|
-
|
|
12472
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
12473
|
+
case 2: return [2 /*return*/, response.access_token];
|
|
12474
|
+
}
|
|
12475
|
+
});
|
|
12476
|
+
});
|
|
12477
|
+
};
|
|
12478
|
+
/**
|
|
12479
|
+
* Generates authentication result
|
|
12480
|
+
* @param response
|
|
12481
|
+
* @param request
|
|
12482
|
+
* @param idTokenObj
|
|
12483
|
+
* @param accountEntity
|
|
12484
|
+
* @param authority
|
|
12485
|
+
* @param reqTimestamp
|
|
12486
|
+
* @returns
|
|
12487
|
+
*/
|
|
12488
|
+
NativeInteractionClient.prototype.generateAuthenticationResult = function (response, request, idTokenObj, accountEntity, authority, reqTimestamp) {
|
|
12489
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
12490
|
+
var mats, responseScopes, accountProperties, uid, tid, responseAccessToken, tokenType, result;
|
|
12491
|
+
return __generator$1(this, function (_a) {
|
|
12492
|
+
switch (_a.label) {
|
|
12493
|
+
case 0:
|
|
12494
|
+
mats = this.addTelemetryFromNativeResponse(response);
|
|
12495
|
+
responseScopes = response.scope ? ScopeSet.fromString(response.scope) : ScopeSet.fromString(request.scope);
|
|
12496
|
+
accountProperties = response.account.properties || {};
|
|
12497
|
+
uid = accountProperties["UID"] || idTokenObj.claims.oid || idTokenObj.claims.sub || Constants.EMPTY_STRING;
|
|
12498
|
+
tid = accountProperties["TenantId"] || idTokenObj.claims.tid || Constants.EMPTY_STRING;
|
|
12499
|
+
return [4 /*yield*/, this.generatePopAccessToken(response, request)];
|
|
12500
|
+
case 1:
|
|
12501
|
+
responseAccessToken = _a.sent();
|
|
12502
|
+
tokenType = (request.tokenType === exports.AuthenticationScheme.POP) ? exports.AuthenticationScheme.POP : exports.AuthenticationScheme.BEARER;
|
|
12053
12503
|
result = {
|
|
12054
|
-
authority: authority
|
|
12504
|
+
authority: authority,
|
|
12055
12505
|
uniqueId: uid,
|
|
12056
12506
|
tenantId: tid,
|
|
12057
12507
|
scopes: responseScopes.asArray(),
|
|
@@ -12061,30 +12511,78 @@ var NativeInteractionClient = /** @class */ (function (_super) {
|
|
|
12061
12511
|
accessToken: responseAccessToken,
|
|
12062
12512
|
fromCache: mats ? this.isResponseFromCache(mats) : false,
|
|
12063
12513
|
expiresOn: new Date(Number(reqTimestamp + response.expires_in) * 1000),
|
|
12064
|
-
tokenType:
|
|
12514
|
+
tokenType: tokenType,
|
|
12065
12515
|
correlationId: this.correlationId,
|
|
12066
12516
|
state: response.state,
|
|
12067
12517
|
fromNativeBroker: true
|
|
12068
12518
|
};
|
|
12069
|
-
idTokenEntity = IdTokenEntity.createIdTokenEntity(homeAccountIdentifier, request.authority, response.id_token || Constants.EMPTY_STRING, request.clientId, idTokenObj.claims.tid || Constants.EMPTY_STRING);
|
|
12070
|
-
this.nativeStorageManager.setIdTokenCredential(idTokenEntity);
|
|
12071
|
-
expiresIn = (responseTokenType === exports.AuthenticationScheme.POP)
|
|
12072
|
-
? Constants.SHR_NONCE_VALIDITY
|
|
12073
|
-
: (typeof response.expires_in === "string"
|
|
12074
|
-
? parseInt(response.expires_in, 10)
|
|
12075
|
-
: response.expires_in) || 0;
|
|
12076
|
-
tokenExpirationSeconds = reqTimestamp + expiresIn;
|
|
12077
|
-
accessTokenEntity = AccessTokenEntity.createAccessTokenEntity(homeAccountIdentifier, request.authority, responseAccessToken, request.clientId, tid, responseScopes.printScopes(), tokenExpirationSeconds, 0, this.browserCrypto);
|
|
12078
|
-
this.nativeStorageManager.setAccessTokenCredential(accessTokenEntity);
|
|
12079
|
-
// Remove any existing cached tokens for this account in browser storage
|
|
12080
|
-
this.browserStorage.removeAccountContext(accountEntity).catch(function (e) {
|
|
12081
|
-
_this.logger.error("Error occurred while removing account context from browser storage. " + e);
|
|
12082
|
-
});
|
|
12083
12519
|
return [2 /*return*/, result];
|
|
12084
12520
|
}
|
|
12085
12521
|
});
|
|
12086
12522
|
});
|
|
12087
12523
|
};
|
|
12524
|
+
/**
|
|
12525
|
+
* cache the account entity in browser storage
|
|
12526
|
+
* @param accountEntity
|
|
12527
|
+
*/
|
|
12528
|
+
NativeInteractionClient.prototype.cacheAccount = function (accountEntity) {
|
|
12529
|
+
var _this = this;
|
|
12530
|
+
// Store the account info and hence `nativeAccountId` in browser cache
|
|
12531
|
+
this.browserStorage.setAccount(accountEntity);
|
|
12532
|
+
// Remove any existing cached tokens for this account in browser storage
|
|
12533
|
+
this.browserStorage.removeAccountContext(accountEntity).catch(function (e) {
|
|
12534
|
+
_this.logger.error("Error occurred while removing account context from browser storage. " + e);
|
|
12535
|
+
});
|
|
12536
|
+
};
|
|
12537
|
+
/**
|
|
12538
|
+
* Stores the access_token and id_token in inmemory storage
|
|
12539
|
+
* @param response
|
|
12540
|
+
* @param request
|
|
12541
|
+
* @param homeAccountIdentifier
|
|
12542
|
+
* @param idTokenObj
|
|
12543
|
+
* @param responseAccessToken
|
|
12544
|
+
* @param tenantId
|
|
12545
|
+
* @param reqTimestamp
|
|
12546
|
+
*/
|
|
12547
|
+
NativeInteractionClient.prototype.cacheNativeTokens = function (response, request, homeAccountIdentifier, idTokenObj, responseAccessToken, tenantId, reqTimestamp) {
|
|
12548
|
+
// cache idToken in inmemory storage
|
|
12549
|
+
var idTokenEntity = IdTokenEntity.createIdTokenEntity(homeAccountIdentifier, request.authority, response.id_token || Constants.EMPTY_STRING, request.clientId, idTokenObj.claims.tid || Constants.EMPTY_STRING);
|
|
12550
|
+
this.nativeStorageManager.setIdTokenCredential(idTokenEntity);
|
|
12551
|
+
// cache accessToken in inmemory storage
|
|
12552
|
+
var expiresIn = (request.tokenType === exports.AuthenticationScheme.POP)
|
|
12553
|
+
? Constants.SHR_NONCE_VALIDITY
|
|
12554
|
+
: (typeof response.expires_in === "string"
|
|
12555
|
+
? parseInt(response.expires_in, 10)
|
|
12556
|
+
: response.expires_in) || 0;
|
|
12557
|
+
var tokenExpirationSeconds = reqTimestamp + expiresIn;
|
|
12558
|
+
var responseScopes = this.generateScopes(response, request);
|
|
12559
|
+
var accessTokenEntity = AccessTokenEntity.createAccessTokenEntity(homeAccountIdentifier, request.authority, responseAccessToken, request.clientId, tenantId, responseScopes.printScopes(), tokenExpirationSeconds, 0, this.browserCrypto);
|
|
12560
|
+
this.nativeStorageManager.setAccessTokenCredential(accessTokenEntity);
|
|
12561
|
+
};
|
|
12562
|
+
NativeInteractionClient.prototype.addTelemetryFromNativeResponse = function (response) {
|
|
12563
|
+
var mats = this.getMATSFromResponse(response);
|
|
12564
|
+
if (!mats) {
|
|
12565
|
+
return null;
|
|
12566
|
+
}
|
|
12567
|
+
this.performanceClient.addStaticFields({
|
|
12568
|
+
extensionId: this.nativeMessageHandler.getExtensionId(),
|
|
12569
|
+
extensionVersion: this.nativeMessageHandler.getExtensionVersion(),
|
|
12570
|
+
matsBrokerVersion: mats.broker_version,
|
|
12571
|
+
matsAccountJoinOnStart: mats.account_join_on_start,
|
|
12572
|
+
matsAccountJoinOnEnd: mats.account_join_on_end,
|
|
12573
|
+
matsDeviceJoin: mats.device_join,
|
|
12574
|
+
matsPromptBehavior: mats.prompt_behavior,
|
|
12575
|
+
matsApiErrorCode: mats.api_error_code,
|
|
12576
|
+
matsUiVisible: mats.ui_visible,
|
|
12577
|
+
matsSilentCode: mats.silent_code,
|
|
12578
|
+
matsSilentBiSubCode: mats.silent_bi_sub_code,
|
|
12579
|
+
matsSilentMessage: mats.silent_message,
|
|
12580
|
+
matsSilentStatus: mats.silent_status,
|
|
12581
|
+
matsHttpStatus: mats.http_status,
|
|
12582
|
+
matsHttpEventCount: mats.http_event_count
|
|
12583
|
+
}, this.correlationId);
|
|
12584
|
+
return mats;
|
|
12585
|
+
};
|
|
12088
12586
|
/**
|
|
12089
12587
|
* Validates native platform response before processing
|
|
12090
12588
|
* @param response
|
|
@@ -12203,7 +12701,7 @@ var NativeInteractionClient = /** @class */ (function (_super) {
|
|
|
12203
12701
|
* Licensed under the MIT License.
|
|
12204
12702
|
*/
|
|
12205
12703
|
var NativeMessageHandler = /** @class */ (function () {
|
|
12206
|
-
function NativeMessageHandler(logger, handshakeTimeoutMs, extensionId) {
|
|
12704
|
+
function NativeMessageHandler(logger, handshakeTimeoutMs, performanceClient, extensionId) {
|
|
12207
12705
|
this.logger = logger;
|
|
12208
12706
|
this.handshakeTimeoutMs = handshakeTimeoutMs;
|
|
12209
12707
|
this.extensionId = extensionId;
|
|
@@ -12212,6 +12710,8 @@ var NativeMessageHandler = /** @class */ (function () {
|
|
|
12212
12710
|
this.responseId = 0;
|
|
12213
12711
|
this.messageChannel = new MessageChannel();
|
|
12214
12712
|
this.windowListener = this.onWindowMessage.bind(this); // Window event callback doesn't have access to 'this' unless it's bound
|
|
12713
|
+
this.performanceClient = performanceClient;
|
|
12714
|
+
this.handshakeEvent = performanceClient.startMeasurement(exports.PerformanceEvents.NativeMessageHandlerHandshake);
|
|
12215
12715
|
}
|
|
12216
12716
|
/**
|
|
12217
12717
|
* Sends a given message to the extension and resolves with the extension response
|
|
@@ -12240,10 +12740,11 @@ var NativeMessageHandler = /** @class */ (function () {
|
|
|
12240
12740
|
};
|
|
12241
12741
|
/**
|
|
12242
12742
|
* Returns an instance of the MessageHandler that has successfully established a connection with an extension
|
|
12243
|
-
* @param logger
|
|
12244
|
-
* @param handshakeTimeoutMs
|
|
12743
|
+
* @param {Logger} logger
|
|
12744
|
+
* @param {number} handshakeTimeoutMs
|
|
12745
|
+
* @param {IPerformanceClient} performanceClient
|
|
12245
12746
|
*/
|
|
12246
|
-
NativeMessageHandler.createProvider = function (logger, handshakeTimeoutMs) {
|
|
12747
|
+
NativeMessageHandler.createProvider = function (logger, handshakeTimeoutMs, performanceClient) {
|
|
12247
12748
|
return __awaiter$1(this, void 0, void 0, function () {
|
|
12248
12749
|
var preferredProvider, backupProvider;
|
|
12249
12750
|
return __generator$1(this, function (_a) {
|
|
@@ -12253,14 +12754,14 @@ var NativeMessageHandler = /** @class */ (function () {
|
|
|
12253
12754
|
_a.label = 1;
|
|
12254
12755
|
case 1:
|
|
12255
12756
|
_a.trys.push([1, 3, , 5]);
|
|
12256
|
-
preferredProvider = new NativeMessageHandler(logger, handshakeTimeoutMs, NativeConstants.PREFERRED_EXTENSION_ID);
|
|
12757
|
+
preferredProvider = new NativeMessageHandler(logger, handshakeTimeoutMs, performanceClient, NativeConstants.PREFERRED_EXTENSION_ID);
|
|
12257
12758
|
return [4 /*yield*/, preferredProvider.sendHandshakeRequest()];
|
|
12258
12759
|
case 2:
|
|
12259
12760
|
_a.sent();
|
|
12260
12761
|
return [2 /*return*/, preferredProvider];
|
|
12261
12762
|
case 3:
|
|
12262
12763
|
_a.sent();
|
|
12263
|
-
backupProvider = new NativeMessageHandler(logger, handshakeTimeoutMs);
|
|
12764
|
+
backupProvider = new NativeMessageHandler(logger, handshakeTimeoutMs, performanceClient);
|
|
12264
12765
|
return [4 /*yield*/, backupProvider.sendHandshakeRequest()];
|
|
12265
12766
|
case 4:
|
|
12266
12767
|
_a.sent();
|
|
@@ -12289,6 +12790,10 @@ var NativeMessageHandler = /** @class */ (function () {
|
|
|
12289
12790
|
method: NativeExtensionMethod.HandshakeRequest
|
|
12290
12791
|
}
|
|
12291
12792
|
};
|
|
12793
|
+
this.handshakeEvent.addStaticFields({
|
|
12794
|
+
extensionId: this.extensionId,
|
|
12795
|
+
extensionHandshakeTimeoutMs: this.handshakeTimeoutMs
|
|
12796
|
+
});
|
|
12292
12797
|
this.messageChannel.port1.onmessage = function (event) {
|
|
12293
12798
|
_this.onChannelMessage(event);
|
|
12294
12799
|
};
|
|
@@ -12303,6 +12808,7 @@ var NativeMessageHandler = /** @class */ (function () {
|
|
|
12303
12808
|
window.removeEventListener("message", _this.windowListener, false);
|
|
12304
12809
|
_this.messageChannel.port1.close();
|
|
12305
12810
|
_this.messageChannel.port2.close();
|
|
12811
|
+
_this.handshakeEvent.endMeasurement({ extensionHandshakeTimedOut: true, success: false });
|
|
12306
12812
|
reject(BrowserAuthError.createNativeHandshakeTimeoutError());
|
|
12307
12813
|
_this.handshakeResolvers.delete(req.responseId);
|
|
12308
12814
|
}, _this.handshakeTimeoutMs); // Use a reasonable timeout in milliseconds here
|
|
@@ -12336,6 +12842,7 @@ var NativeMessageHandler = /** @class */ (function () {
|
|
|
12336
12842
|
window.removeEventListener("message", this.windowListener, false);
|
|
12337
12843
|
var handshakeResolver = this.handshakeResolvers.get(request.responseId);
|
|
12338
12844
|
if (handshakeResolver) {
|
|
12845
|
+
this.handshakeEvent.endMeasurement({ success: false, extensionInstalled: false });
|
|
12339
12846
|
handshakeResolver.reject(BrowserAuthError.createNativeExtensionNotInstalledError());
|
|
12340
12847
|
}
|
|
12341
12848
|
}
|
|
@@ -12383,6 +12890,7 @@ var NativeMessageHandler = /** @class */ (function () {
|
|
|
12383
12890
|
this.extensionId = request.extensionId;
|
|
12384
12891
|
this.extensionVersion = request.body.version;
|
|
12385
12892
|
this.logger.verbose("NativeMessageHandler - Received HandshakeResponse from extension: " + this.extensionId);
|
|
12893
|
+
this.handshakeEvent.endMeasurement({ extensionInstalled: true, success: true });
|
|
12386
12894
|
handshakeResolver.resolve();
|
|
12387
12895
|
this.handshakeResolvers.delete(request.responseId);
|
|
12388
12896
|
}
|
|
@@ -13371,7 +13879,9 @@ function buildConfiguration(_a, isBrowserEnvironment) {
|
|
|
13371
13879
|
var DEFAULT_CACHE_OPTIONS = {
|
|
13372
13880
|
cacheLocation: exports.BrowserCacheLocation.SessionStorage,
|
|
13373
13881
|
storeAuthStateInCookie: false,
|
|
13374
|
-
secureCookies: false
|
|
13882
|
+
secureCookies: false,
|
|
13883
|
+
// 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
|
|
13884
|
+
cacheMigrationEnabled: userInputCache && userInputCache.cacheLocation === exports.BrowserCacheLocation.LocalStorage ? true : false
|
|
13375
13885
|
};
|
|
13376
13886
|
// Default logger options for browser
|
|
13377
13887
|
var DEFAULT_LOGGER_OPTIONS = {
|
|
@@ -15452,10 +15962,19 @@ var CryptoOps = /** @class */ (function () {
|
|
|
15452
15962
|
var BrowserPerformanceMeasurement = /** @class */ (function () {
|
|
15453
15963
|
function BrowserPerformanceMeasurement(name, correlationId) {
|
|
15454
15964
|
this.correlationId = correlationId;
|
|
15455
|
-
this.measureName =
|
|
15456
|
-
this.startMark =
|
|
15457
|
-
this.endMark =
|
|
15965
|
+
this.measureName = BrowserPerformanceMeasurement.makeMeasureName(name, correlationId);
|
|
15966
|
+
this.startMark = BrowserPerformanceMeasurement.makeStartMark(name, correlationId);
|
|
15967
|
+
this.endMark = BrowserPerformanceMeasurement.makeEndMark(name, correlationId);
|
|
15458
15968
|
}
|
|
15969
|
+
BrowserPerformanceMeasurement.makeMeasureName = function (name, correlationId) {
|
|
15970
|
+
return "msal.measure." + name + "." + correlationId;
|
|
15971
|
+
};
|
|
15972
|
+
BrowserPerformanceMeasurement.makeStartMark = function (name, correlationId) {
|
|
15973
|
+
return "msal.start." + name + "." + correlationId;
|
|
15974
|
+
};
|
|
15975
|
+
BrowserPerformanceMeasurement.makeEndMark = function (name, correlationId) {
|
|
15976
|
+
return "msal.end." + name + "." + correlationId;
|
|
15977
|
+
};
|
|
15459
15978
|
BrowserPerformanceMeasurement.supportsBrowserPerformance = function () {
|
|
15460
15979
|
return typeof window !== "undefined" &&
|
|
15461
15980
|
typeof window.performance !== "undefined" &&
|
|
@@ -15465,6 +15984,29 @@ var BrowserPerformanceMeasurement = /** @class */ (function () {
|
|
|
15465
15984
|
typeof window.performance.clearMeasures === "function" &&
|
|
15466
15985
|
typeof window.performance.getEntriesByName === "function";
|
|
15467
15986
|
};
|
|
15987
|
+
/**
|
|
15988
|
+
* Flush browser marks and measurements.
|
|
15989
|
+
* @param {string} correlationId
|
|
15990
|
+
* @param {SubMeasurement} measurements
|
|
15991
|
+
*/
|
|
15992
|
+
BrowserPerformanceMeasurement.flushMeasurements = function (correlationId, measurements) {
|
|
15993
|
+
if (BrowserPerformanceMeasurement.supportsBrowserPerformance()) {
|
|
15994
|
+
try {
|
|
15995
|
+
measurements.forEach(function (measurement) {
|
|
15996
|
+
var measureName = BrowserPerformanceMeasurement.makeMeasureName(measurement.name, correlationId);
|
|
15997
|
+
var entriesForMeasurement = window.performance.getEntriesByName(measureName, "measure");
|
|
15998
|
+
if (entriesForMeasurement.length > 0) {
|
|
15999
|
+
window.performance.clearMeasures(measureName);
|
|
16000
|
+
window.performance.clearMarks(BrowserPerformanceMeasurement.makeStartMark(measureName, correlationId));
|
|
16001
|
+
window.performance.clearMarks(BrowserPerformanceMeasurement.makeEndMark(measureName, correlationId));
|
|
16002
|
+
}
|
|
16003
|
+
});
|
|
16004
|
+
}
|
|
16005
|
+
catch (e) {
|
|
16006
|
+
// Silently catch and return null
|
|
16007
|
+
}
|
|
16008
|
+
}
|
|
16009
|
+
};
|
|
15468
16010
|
BrowserPerformanceMeasurement.prototype.startMeasurement = function () {
|
|
15469
16011
|
if (BrowserPerformanceMeasurement.supportsBrowserPerformance()) {
|
|
15470
16012
|
try {
|
|
@@ -15529,6 +16071,20 @@ var BrowserPerformanceClient = /** @class */ (function (_super) {
|
|
|
15529
16071
|
var _a;
|
|
15530
16072
|
return ((_a = document.visibilityState) === null || _a === void 0 ? void 0 : _a.toString()) || null;
|
|
15531
16073
|
};
|
|
16074
|
+
BrowserPerformanceClient.prototype.deleteIncompleteSubMeasurements = function (inProgressEvent) {
|
|
16075
|
+
var rootEvent = this.eventsByCorrelationId.get(inProgressEvent.event.correlationId);
|
|
16076
|
+
var isRootEvent = rootEvent && rootEvent.eventId === inProgressEvent.event.eventId;
|
|
16077
|
+
var incompleteMeasurements = [];
|
|
16078
|
+
if (isRootEvent && (rootEvent === null || rootEvent === void 0 ? void 0 : rootEvent.incompleteSubMeasurements)) {
|
|
16079
|
+
rootEvent.incompleteSubMeasurements.forEach(function (subMeasurement) {
|
|
16080
|
+
incompleteMeasurements.push(__assign$1({}, subMeasurement));
|
|
16081
|
+
});
|
|
16082
|
+
}
|
|
16083
|
+
// Clean up remaining marks for incomplete sub-measurements
|
|
16084
|
+
if (incompleteMeasurements.length > 0) {
|
|
16085
|
+
BrowserPerformanceMeasurement.flushMeasurements(inProgressEvent.event.correlationId, incompleteMeasurements);
|
|
16086
|
+
}
|
|
16087
|
+
};
|
|
15532
16088
|
BrowserPerformanceClient.prototype.supportsBrowserPerformanceNow = function () {
|
|
15533
16089
|
return typeof window !== "undefined" &&
|
|
15534
16090
|
typeof window.performance !== "undefined" &&
|
|
@@ -15548,7 +16104,13 @@ var BrowserPerformanceClient = /** @class */ (function (_super) {
|
|
|
15548
16104
|
var startPageVisibility = this.getPageVisibility();
|
|
15549
16105
|
var inProgressEvent = _super.prototype.startMeasurement.call(this, measureName, correlationId);
|
|
15550
16106
|
return __assign$1(__assign$1({}, inProgressEvent), { endMeasurement: function (event) {
|
|
15551
|
-
|
|
16107
|
+
var res = inProgressEvent.endMeasurement(__assign$1({ startPageVisibility: startPageVisibility, endPageVisibility: _this.getPageVisibility() }, event));
|
|
16108
|
+
_this.deleteIncompleteSubMeasurements(inProgressEvent);
|
|
16109
|
+
return res;
|
|
16110
|
+
}, discardMeasurement: function () {
|
|
16111
|
+
inProgressEvent.discardMeasurement();
|
|
16112
|
+
_this.deleteIncompleteSubMeasurements(inProgressEvent);
|
|
16113
|
+
inProgressEvent.measurement.flushMeasurement();
|
|
15552
16114
|
} });
|
|
15553
16115
|
};
|
|
15554
16116
|
/**
|
|
@@ -15566,26 +16128,27 @@ var BrowserPerformanceClient = /** @class */ (function (_super) {
|
|
|
15566
16128
|
this.logger.trace("BrowserPerformanceClient: correlationId for " + eventName + " not provided, unable to set telemetry queue time");
|
|
15567
16129
|
return;
|
|
15568
16130
|
}
|
|
15569
|
-
var
|
|
15570
|
-
|
|
15571
|
-
|
|
15572
|
-
|
|
15573
|
-
|
|
15574
|
-
|
|
15575
|
-
|
|
15576
|
-
|
|
15577
|
-
this.preQueueTimeByCorrelationId.set(correlationId, preQueueTimes);
|
|
16131
|
+
var preQueueEvent = this.preQueueTimeByCorrelationId.get(correlationId);
|
|
16132
|
+
/**
|
|
16133
|
+
* Manually complete queue measurement if there is an incomplete pre-queue event.
|
|
16134
|
+
* Incomplete pre-queue events are instrumentation bugs that should be fixed.
|
|
16135
|
+
*/
|
|
16136
|
+
if (preQueueEvent) {
|
|
16137
|
+
this.logger.trace("BrowserPerformanceClient: Incomplete pre-queue " + preQueueEvent.name + " found", correlationId);
|
|
16138
|
+
this.addQueueMeasurement(preQueueEvent.name, correlationId, undefined, true);
|
|
15578
16139
|
}
|
|
16140
|
+
this.preQueueTimeByCorrelationId.set(correlationId, { name: eventName, time: window.performance.now() });
|
|
15579
16141
|
};
|
|
15580
16142
|
/**
|
|
15581
16143
|
* Calculates and adds queue time measurement for given performance event.
|
|
15582
16144
|
*
|
|
15583
|
-
* @param {PerformanceEvents}
|
|
16145
|
+
* @param {PerformanceEvents} eventName
|
|
15584
16146
|
* @param {?string} correlationId
|
|
15585
|
-
* @param {?number}
|
|
16147
|
+
* @param {?number} queueTime
|
|
16148
|
+
* @param {?boolean} manuallyCompleted - indicator for manually completed queue measurements
|
|
15586
16149
|
* @returns
|
|
15587
16150
|
*/
|
|
15588
|
-
BrowserPerformanceClient.prototype.addQueueMeasurement = function (eventName, correlationId) {
|
|
16151
|
+
BrowserPerformanceClient.prototype.addQueueMeasurement = function (eventName, correlationId, queueTime, manuallyCompleted) {
|
|
15589
16152
|
if (!this.supportsBrowserPerformanceNow()) {
|
|
15590
16153
|
this.logger.trace("BrowserPerformanceClient: window performance API not available, unable to add queue measurement for " + eventName);
|
|
15591
16154
|
return;
|
|
@@ -15599,8 +16162,8 @@ var BrowserPerformanceClient = /** @class */ (function (_super) {
|
|
|
15599
16162
|
return;
|
|
15600
16163
|
}
|
|
15601
16164
|
var currentTime = window.performance.now();
|
|
15602
|
-
var
|
|
15603
|
-
return _super.prototype.addQueueMeasurement.call(this, eventName, correlationId,
|
|
16165
|
+
var resQueueTime = queueTime || _super.prototype.calculateQueuedTime.call(this, preQueueTime, currentTime);
|
|
16166
|
+
return _super.prototype.addQueueMeasurement.call(this, eventName, correlationId, resQueueTime, manuallyCompleted);
|
|
15604
16167
|
};
|
|
15605
16168
|
return BrowserPerformanceClient;
|
|
15606
16169
|
}(PerformanceClient));
|
|
@@ -15619,6 +16182,7 @@ var internals = /*#__PURE__*/Object.freeze({
|
|
|
15619
16182
|
SilentIframeClient: SilentIframeClient,
|
|
15620
16183
|
SilentCacheClient: SilentCacheClient,
|
|
15621
16184
|
SilentRefreshClient: SilentRefreshClient,
|
|
16185
|
+
NativeInteractionClient: NativeInteractionClient,
|
|
15622
16186
|
RedirectHandler: RedirectHandler,
|
|
15623
16187
|
EventHandler: EventHandler,
|
|
15624
16188
|
NativeMessageHandler: NativeMessageHandler,
|
|
@@ -16000,7 +16564,8 @@ var ClientApplication = /** @class */ (function () {
|
|
|
16000
16564
|
var nativeCacheOptions = {
|
|
16001
16565
|
cacheLocation: exports.BrowserCacheLocation.MemoryStorage,
|
|
16002
16566
|
storeAuthStateInCookie: false,
|
|
16003
|
-
secureCookies: false
|
|
16567
|
+
secureCookies: false,
|
|
16568
|
+
cacheMigrationEnabled: false
|
|
16004
16569
|
};
|
|
16005
16570
|
this.nativeInternalStorage = new BrowserCacheManager(this.config.auth.clientId, nativeCacheOptions, this.browserCrypto, this.logger);
|
|
16006
16571
|
// Initialize the token cache
|
|
@@ -16013,7 +16578,7 @@ var ClientApplication = /** @class */ (function () {
|
|
|
16013
16578
|
*/
|
|
16014
16579
|
ClientApplication.prototype.initialize = function () {
|
|
16015
16580
|
return __awaiter$1(this, void 0, void 0, function () {
|
|
16016
|
-
var _a, e_1;
|
|
16581
|
+
var allowNativeBroker, initMeasurement, _a, e_1;
|
|
16017
16582
|
return __generator$1(this, function (_b) {
|
|
16018
16583
|
switch (_b.label) {
|
|
16019
16584
|
case 0:
|
|
@@ -16022,13 +16587,15 @@ var ClientApplication = /** @class */ (function () {
|
|
|
16022
16587
|
this.logger.info("initialize has already been called, exiting early.");
|
|
16023
16588
|
return [2 /*return*/];
|
|
16024
16589
|
}
|
|
16590
|
+
allowNativeBroker = this.config.system.allowNativeBroker;
|
|
16591
|
+
initMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.InitializeClientApplication);
|
|
16025
16592
|
this.eventHandler.emitEvent(exports.EventType.INITIALIZE_START);
|
|
16026
|
-
if (!
|
|
16593
|
+
if (!allowNativeBroker) return [3 /*break*/, 4];
|
|
16027
16594
|
_b.label = 1;
|
|
16028
16595
|
case 1:
|
|
16029
16596
|
_b.trys.push([1, 3, , 4]);
|
|
16030
16597
|
_a = this;
|
|
16031
|
-
return [4 /*yield*/, NativeMessageHandler.createProvider(this.logger, this.config.system.nativeBrokerHandshakeTimeout)];
|
|
16598
|
+
return [4 /*yield*/, NativeMessageHandler.createProvider(this.logger, this.config.system.nativeBrokerHandshakeTimeout, this.performanceClient)];
|
|
16032
16599
|
case 2:
|
|
16033
16600
|
_a.nativeExtensionProvider = _b.sent();
|
|
16034
16601
|
return [3 /*break*/, 4];
|
|
@@ -16039,6 +16606,7 @@ var ClientApplication = /** @class */ (function () {
|
|
|
16039
16606
|
case 4:
|
|
16040
16607
|
this.initialized = true;
|
|
16041
16608
|
this.eventHandler.emitEvent(exports.EventType.INITIALIZE_END);
|
|
16609
|
+
initMeasurement.endMeasurement({ allowNativeBroker: allowNativeBroker, success: true });
|
|
16042
16610
|
return [2 /*return*/];
|
|
16043
16611
|
}
|
|
16044
16612
|
});
|
|
@@ -16214,7 +16782,6 @@ var ClientApplication = /** @class */ (function () {
|
|
|
16214
16782
|
isNativeBroker: true,
|
|
16215
16783
|
requestId: response.requestId
|
|
16216
16784
|
});
|
|
16217
|
-
atPopupMeasurement.flushMeasurement();
|
|
16218
16785
|
return response;
|
|
16219
16786
|
}).catch(function (e) {
|
|
16220
16787
|
if (e instanceof NativeAuthError && e.isFatal()) {
|
|
@@ -16254,7 +16821,6 @@ var ClientApplication = /** @class */ (function () {
|
|
|
16254
16821
|
success: true,
|
|
16255
16822
|
requestId: result.requestId
|
|
16256
16823
|
});
|
|
16257
|
-
atPopupMeasurement.flushMeasurement();
|
|
16258
16824
|
return result;
|
|
16259
16825
|
}).catch(function (e) {
|
|
16260
16826
|
if (loggedInAccounts.length > 0) {
|
|
@@ -16268,7 +16834,6 @@ var ClientApplication = /** @class */ (function () {
|
|
|
16268
16834
|
subErrorCode: e.subError,
|
|
16269
16835
|
success: false
|
|
16270
16836
|
});
|
|
16271
|
-
atPopupMeasurement.flushMeasurement();
|
|
16272
16837
|
// Since this function is syncronous we need to reject
|
|
16273
16838
|
return Promise.reject(e);
|
|
16274
16839
|
});
|
|
@@ -16334,7 +16899,7 @@ var ClientApplication = /** @class */ (function () {
|
|
|
16334
16899
|
result = silentIframeClient.acquireToken(validRequest);
|
|
16335
16900
|
}
|
|
16336
16901
|
return [2 /*return*/, result.then(function (response) {
|
|
16337
|
-
var _a, _b
|
|
16902
|
+
var _a, _b;
|
|
16338
16903
|
_this.eventHandler.emitEvent(exports.EventType.SSO_SILENT_SUCCESS, exports.InteractionType.Silent, response);
|
|
16339
16904
|
(_a = _this.ssoSilentMeasurement) === null || _a === void 0 ? void 0 : _a.addStaticFields({
|
|
16340
16905
|
accessTokenSize: response.accessToken.length,
|
|
@@ -16345,17 +16910,15 @@ var ClientApplication = /** @class */ (function () {
|
|
|
16345
16910
|
isNativeBroker: response.fromNativeBroker,
|
|
16346
16911
|
requestId: response.requestId
|
|
16347
16912
|
});
|
|
16348
|
-
(_c = _this.ssoSilentMeasurement) === null || _c === void 0 ? void 0 : _c.flushMeasurement();
|
|
16349
16913
|
return response;
|
|
16350
16914
|
}).catch(function (e) {
|
|
16351
|
-
var _a
|
|
16915
|
+
var _a;
|
|
16352
16916
|
_this.eventHandler.emitEvent(exports.EventType.SSO_SILENT_FAILURE, exports.InteractionType.Silent, null, e);
|
|
16353
16917
|
(_a = _this.ssoSilentMeasurement) === null || _a === void 0 ? void 0 : _a.endMeasurement({
|
|
16354
16918
|
errorCode: e.errorCode,
|
|
16355
16919
|
subErrorCode: e.subError,
|
|
16356
16920
|
success: false
|
|
16357
16921
|
});
|
|
16358
|
-
(_b = _this.ssoSilentMeasurement) === null || _b === void 0 ? void 0 : _b.flushMeasurement();
|
|
16359
16922
|
throw e;
|
|
16360
16923
|
}).finally(function () {
|
|
16361
16924
|
document.removeEventListener("visibilitychange", _this.trackPageVisibilityWithMeasurement);
|
|
@@ -16384,7 +16947,11 @@ var ClientApplication = /** @class */ (function () {
|
|
|
16384
16947
|
this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_BY_CODE_START, exports.InteractionType.Silent, request);
|
|
16385
16948
|
atbcMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.AcquireTokenByCode, request.correlationId);
|
|
16386
16949
|
try {
|
|
16387
|
-
if (request.code) {
|
|
16950
|
+
if (request.code && request.nativeAccountId) {
|
|
16951
|
+
// Throw error in case server returns both spa_code and spa_accountid in exchange for auth code.
|
|
16952
|
+
throw BrowserAuthError.createSpaCodeAndNativeAccountIdPresentError();
|
|
16953
|
+
}
|
|
16954
|
+
else if (request.code) {
|
|
16388
16955
|
hybridAuthCode_1 = request.code;
|
|
16389
16956
|
response = this.hybridAuthCodeResponses.get(hybridAuthCode_1);
|
|
16390
16957
|
if (!response) {
|
|
@@ -16402,7 +16969,6 @@ var ClientApplication = /** @class */ (function () {
|
|
|
16402
16969
|
isNativeBroker: result.fromNativeBroker,
|
|
16403
16970
|
requestId: result.requestId
|
|
16404
16971
|
});
|
|
16405
|
-
atbcMeasurement.flushMeasurement();
|
|
16406
16972
|
return result;
|
|
16407
16973
|
})
|
|
16408
16974
|
.catch(function (error) {
|
|
@@ -16413,16 +16979,12 @@ var ClientApplication = /** @class */ (function () {
|
|
|
16413
16979
|
subErrorCode: error.subError,
|
|
16414
16980
|
success: false
|
|
16415
16981
|
});
|
|
16416
|
-
atbcMeasurement.flushMeasurement();
|
|
16417
16982
|
throw error;
|
|
16418
16983
|
});
|
|
16419
16984
|
this.hybridAuthCodeResponses.set(hybridAuthCode_1, response);
|
|
16420
16985
|
}
|
|
16421
16986
|
else {
|
|
16422
16987
|
this.logger.verbose("Existing acquireTokenByCode request found", request.correlationId);
|
|
16423
|
-
atbcMeasurement.endMeasurement({
|
|
16424
|
-
success: true
|
|
16425
|
-
});
|
|
16426
16988
|
atbcMeasurement.discardMeasurement();
|
|
16427
16989
|
}
|
|
16428
16990
|
return [2 /*return*/, response];
|
|
@@ -16636,15 +17198,20 @@ var ClientApplication = /** @class */ (function () {
|
|
|
16636
17198
|
* (the account object is created at the time of successful login)
|
|
16637
17199
|
* or null when no matching account is found.
|
|
16638
17200
|
* This API is provided for convenience but getAccountById should be used for best reliability
|
|
16639
|
-
* @param
|
|
17201
|
+
* @param username
|
|
16640
17202
|
* @returns The account object stored in MSAL
|
|
16641
17203
|
*/
|
|
16642
|
-
ClientApplication.prototype.getAccountByUsername = function (
|
|
16643
|
-
|
|
16644
|
-
if (!
|
|
16645
|
-
this.logger.
|
|
16646
|
-
|
|
16647
|
-
|
|
17204
|
+
ClientApplication.prototype.getAccountByUsername = function (username) {
|
|
17205
|
+
this.logger.trace("getAccountByUsername called");
|
|
17206
|
+
if (!username) {
|
|
17207
|
+
this.logger.warning("getAccountByUsername: No username provided");
|
|
17208
|
+
return null;
|
|
17209
|
+
}
|
|
17210
|
+
var account = this.browserStorage.getAccountInfoFilteredBy({ username: username });
|
|
17211
|
+
if (account) {
|
|
17212
|
+
this.logger.verbose("getAccountByUsername: Account matching username found, returning");
|
|
17213
|
+
this.logger.verbosePii("getAccountByUsername: Returning signed-in accounts matching username: " + username);
|
|
17214
|
+
return account;
|
|
16648
17215
|
}
|
|
16649
17216
|
else {
|
|
16650
17217
|
this.logger.verbose("getAccountByUsername: No matching account found, returning null");
|
|
@@ -16659,11 +17226,16 @@ var ClientApplication = /** @class */ (function () {
|
|
|
16659
17226
|
* @returns The account object stored in MSAL
|
|
16660
17227
|
*/
|
|
16661
17228
|
ClientApplication.prototype.getAccountByHomeId = function (homeAccountId) {
|
|
16662
|
-
|
|
16663
|
-
if (!
|
|
16664
|
-
this.logger.
|
|
16665
|
-
|
|
16666
|
-
|
|
17229
|
+
this.logger.trace("getAccountByHomeId called");
|
|
17230
|
+
if (!homeAccountId) {
|
|
17231
|
+
this.logger.warning("getAccountByHomeId: No homeAccountId provided");
|
|
17232
|
+
return null;
|
|
17233
|
+
}
|
|
17234
|
+
var account = this.browserStorage.getAccountInfoFilteredBy({ homeAccountId: homeAccountId });
|
|
17235
|
+
if (account) {
|
|
17236
|
+
this.logger.verbose("getAccountByHomeId: Account matching homeAccountId found, returning");
|
|
17237
|
+
this.logger.verbosePii("getAccountByHomeId: Returning signed-in accounts matching homeAccountId: " + homeAccountId);
|
|
17238
|
+
return account;
|
|
16667
17239
|
}
|
|
16668
17240
|
else {
|
|
16669
17241
|
this.logger.verbose("getAccountByHomeId: No matching account found, returning null");
|
|
@@ -16678,11 +17250,16 @@ var ClientApplication = /** @class */ (function () {
|
|
|
16678
17250
|
* @returns The account object stored in MSAL
|
|
16679
17251
|
*/
|
|
16680
17252
|
ClientApplication.prototype.getAccountByLocalId = function (localAccountId) {
|
|
16681
|
-
|
|
16682
|
-
if (!
|
|
16683
|
-
this.logger.
|
|
16684
|
-
|
|
16685
|
-
|
|
17253
|
+
this.logger.trace("getAccountByLocalId called");
|
|
17254
|
+
if (!localAccountId) {
|
|
17255
|
+
this.logger.warning("getAccountByLocalId: No localAccountId provided");
|
|
17256
|
+
return null;
|
|
17257
|
+
}
|
|
17258
|
+
var account = this.browserStorage.getAccountInfoFilteredBy({ localAccountId: localAccountId });
|
|
17259
|
+
if (account) {
|
|
17260
|
+
this.logger.verbose("getAccountByLocalId: Account matching localAccountId found, returning");
|
|
17261
|
+
this.logger.verbosePii("getAccountByLocalId: Returning signed-in accounts matching localAccountId: " + localAccountId);
|
|
17262
|
+
return account;
|
|
16686
17263
|
}
|
|
16687
17264
|
else {
|
|
16688
17265
|
this.logger.verbose("getAccountByLocalId: No matching account found, returning null");
|
|
@@ -17073,7 +17650,6 @@ var PublicClientApplication = /** @class */ (function (_super) {
|
|
|
17073
17650
|
cacheLookupPolicy: request.cacheLookupPolicy,
|
|
17074
17651
|
requestId: result.requestId,
|
|
17075
17652
|
});
|
|
17076
|
-
atsMeasurement.flushMeasurement();
|
|
17077
17653
|
return result;
|
|
17078
17654
|
})
|
|
17079
17655
|
.catch(function (error) {
|
|
@@ -17083,7 +17659,6 @@ var PublicClientApplication = /** @class */ (function (_super) {
|
|
|
17083
17659
|
subErrorCode: error.subError,
|
|
17084
17660
|
success: false
|
|
17085
17661
|
});
|
|
17086
|
-
atsMeasurement.flushMeasurement();
|
|
17087
17662
|
throw error;
|
|
17088
17663
|
});
|
|
17089
17664
|
this.activeSilentTokenRequests.set(silentRequestKey, response);
|
|
@@ -17091,9 +17666,6 @@ var PublicClientApplication = /** @class */ (function (_super) {
|
|
|
17091
17666
|
}
|
|
17092
17667
|
else {
|
|
17093
17668
|
this.logger.verbose("acquireTokenSilent has been called previously, returning the result from the first call", correlationId);
|
|
17094
|
-
atsMeasurement.endMeasurement({
|
|
17095
|
-
success: true
|
|
17096
|
-
});
|
|
17097
17669
|
// Discard measurements for memoized calls, as they are usually only a couple of ms and will artificially deflate metrics
|
|
17098
17670
|
atsMeasurement.discardMeasurement();
|
|
17099
17671
|
return [2 /*return*/, cachedResponse];
|