@azure/msal-browser
Version:
Microsoft Authentication Library for js
59 lines (56 loc) • 2.4 kB
JavaScript
/*! @azure/msal-browser v5.30.0 2026-11-18 */
;
import { InvalidArgumentError } from '../error/InvalidArgumentError.mjs';
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
function ensureArgumentIsNotNullOrUndefined(argName, argValue, correlationId) {
if (argValue === null || argValue === undefined) {
throw new InvalidArgumentError(argName, correlationId);
}
}
function ensureArgumentIsNotEmptyString(argName, argValue, correlationId) {
if (!argValue || argValue.trim() === "") {
throw new InvalidArgumentError(argName, correlationId);
}
}
function ensureArgumentIsJSONString(argName, argValue, correlationId) {
try {
const parsed = JSON.parse(argValue);
if (typeof parsed !== "object" ||
parsed === null ||
Array.isArray(parsed)) {
throw new InvalidArgumentError(argName, correlationId);
}
}
catch (e) {
if (e instanceof SyntaxError) {
throw new InvalidArgumentError(argName, correlationId);
}
throw e; // Rethrow unexpected errors
}
}
function ensureArgumentIsStringArray(argName, argValue, correlationId) {
if (!Array.isArray(argValue) ||
!argValue.every((value) => typeof value === "string")) {
throw new InvalidArgumentError(argName, correlationId);
}
}
function filterReservedSignUpAttributesV2(attributes, logger, correlationId) {
const reservedSignUpAttributeNames = new Set(["email", "password"]);
const reservedSignUpAttributeWarning = "Ignoring app-supplied sign-up attribute because it uses a reserved SDK attribute name.";
const filteredAttributes = [];
for (const [attributeId, value] of Object.entries(attributes ?? {})) {
if (reservedSignUpAttributeNames.has(attributeId.toLowerCase())) {
logger.warning(reservedSignUpAttributeWarning, correlationId);
continue;
}
if (value !== undefined) {
filteredAttributes.push([attributeId, value]);
}
}
return Object.fromEntries(filteredAttributes);
}
export { ensureArgumentIsJSONString, ensureArgumentIsNotEmptyString, ensureArgumentIsNotNullOrUndefined, ensureArgumentIsStringArray, filterReservedSignUpAttributesV2 };
//# sourceMappingURL=ArgumentValidator.mjs.map