import { D as instrumentFunction, F as getDefaultClient, u as __createApiClient_wrapped, w as assertDefined, z as getCore } from "./InvalidParamError-CY4JGkjq.native.esm.js";

//#region src/modules/mfa/consumeMfaToken/consumeMfaToken.ts
/**
* Consumes and clears the current MFA token from the client state.
*
* This function retrieves the MFA token obtained from a successful MFA authentication,
* and removes it from the client, to prevent it from being used again.
*
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
* @returns The MFA token that was consumed.
* @throws Error if no MFA token is found.
* @instrumented
*/
const consumeMfaToken = (client = getDefaultClient()) => {
	const core = getCore(client);
	const mfaToken = core.state.get().mfaToken;
	assertDefined(mfaToken, "No MFA token found");
	core.state.set({ mfaToken: null });
	return mfaToken;
};
const __consumeMfaToken_impl = consumeMfaToken;
const __consumeMfaToken_wrapped = instrumentFunction({
	fn: __consumeMfaToken_impl,
	functionName: "consumeMfaToken",
	getCore: () => {
		try {
			return getCore(getDefaultClient());
		} catch {
			return;
		}
	}
});

//#endregion
//#region src/modules/mfa/getMfaMethods/getMfaMethods.ts
/**
* Retrieves the available MFA methods for the current user.
*
* This function fetches information about which multi-factor authentication
* methods are available and configured for the user's account.
*
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
* @returns A promise that resolves to the user's MFA methods configuration.
* @instrumented
*/
const getMfaMethods = async (client = getDefaultClient()) => {
	const core = getCore(client);
	return await __createApiClient_wrapped({}, client).getUserMfaMethods({
		environmentId: core.environmentId,
		verifiedOnly: true
	});
};
const __getMfaMethods_impl = getMfaMethods;
const __getMfaMethods_wrapped = instrumentFunction({
	fn: __getMfaMethods_impl,
	functionName: "getMfaMethods",
	getCore: () => {
		try {
			return getCore(getDefaultClient());
		} catch {
			return;
		}
	}
});

//#endregion
//#region src/modules/mfa/isMfaRequiredForAction/isMfaRequiredForAction.ts
/**
* Checks if MFA is required for a specific action.
*
* This function determines whether multi-factor authentication is required
* for the specified action based on project settings and user configuration.
*
* @param params.mfaAction - The action to check MFA requirements for.
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
* @returns A promise that resolves to true if MFA is required for the action, false otherwise.
* @not-instrumented
*/
const isMfaRequiredForAction = async ({ mfaAction }, client = getDefaultClient()) => {
	const projectSettings = client.projectSettings;
	if (!projectSettings?.security?.mfa?.actions?.some((action) => action.action === mfaAction && action.required)) return false;
	if (projectSettings?.security?.mfa?.required) return true;
	return (await __getMfaMethods_wrapped(client)).userHasVerifiedMfaMethods;
};

//#endregion
export { __getMfaMethods_wrapped as n, __consumeMfaToken_wrapped as r, isMfaRequiredForAction as t };
//# sourceMappingURL=isMfaRequiredForAction-DaZoGOB-.native.esm.js.map