65 lines
2.2 KiB
JavaScript
Executable file
65 lines
2.2 KiB
JavaScript
Executable file
/*! @azure/msal-react v3.0.17 2025-08-05 */
|
|
'use strict';
|
|
/*
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the MIT License.
|
|
*/
|
|
function getChildrenOrFunction(children, args) {
|
|
if (typeof children === "function") {
|
|
return children(args);
|
|
}
|
|
return children;
|
|
}
|
|
/**
|
|
* Helper function to determine whether 2 arrays are equal
|
|
* Used to avoid unnecessary state updates
|
|
* @param arrayA
|
|
* @param arrayB
|
|
*/
|
|
function accountArraysAreEqual(arrayA, arrayB) {
|
|
if (arrayA.length !== arrayB.length) {
|
|
return false;
|
|
}
|
|
const comparisonArray = [...arrayB];
|
|
return arrayA.every((elementA) => {
|
|
const elementB = comparisonArray.shift();
|
|
if (!elementA || !elementB) {
|
|
return false;
|
|
}
|
|
return (elementA.homeAccountId === elementB.homeAccountId &&
|
|
elementA.localAccountId === elementB.localAccountId &&
|
|
elementA.username === elementB.username);
|
|
});
|
|
}
|
|
function getAccountByIdentifiers(allAccounts, accountIdentifiers) {
|
|
if (allAccounts.length > 0 &&
|
|
(accountIdentifiers.homeAccountId ||
|
|
accountIdentifiers.localAccountId ||
|
|
accountIdentifiers.username)) {
|
|
const matchedAccounts = allAccounts.filter((accountObj) => {
|
|
if (accountIdentifiers.username &&
|
|
accountIdentifiers.username.toLowerCase() !==
|
|
accountObj.username.toLowerCase()) {
|
|
return false;
|
|
}
|
|
if (accountIdentifiers.homeAccountId &&
|
|
accountIdentifiers.homeAccountId.toLowerCase() !==
|
|
accountObj.homeAccountId.toLowerCase()) {
|
|
return false;
|
|
}
|
|
if (accountIdentifiers.localAccountId &&
|
|
accountIdentifiers.localAccountId.toLowerCase() !==
|
|
accountObj.localAccountId.toLowerCase()) {
|
|
return false;
|
|
}
|
|
return true;
|
|
});
|
|
return matchedAccounts[0] || null;
|
|
}
|
|
else {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
export { accountArraysAreEqual, getAccountByIdentifiers, getChildrenOrFunction };
|
|
//# sourceMappingURL=utilities.js.map
|