const require_InvalidParamError = require('./InvalidParamError-Cu4kK02f.cjs');

//#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 = require_InvalidParamError.getDefaultClient()) => {
	const core = require_InvalidParamError.getCore(client);
	const mfaToken = core.state.get().mfaToken;
	require_InvalidParamError.assertDefined(mfaToken, "No MFA token found");
	core.state.set({ mfaToken: null });
	return mfaToken;
};
const __consumeMfaToken_impl = consumeMfaToken;
const __consumeMfaToken_wrapped = require_InvalidParamError.instrumentFunction({
	fn: __consumeMfaToken_impl,
	functionName: "consumeMfaToken",
	getCore: () => {
		try {
			return require_InvalidParamError.getCore(require_InvalidParamError.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 = require_InvalidParamError.getDefaultClient()) => {
	const core = require_InvalidParamError.getCore(client);
	return await require_InvalidParamError.__createApiClient_wrapped({}, client).getUserMfaMethods({
		environmentId: core.environmentId,
		verifiedOnly: true
	});
};
const __getMfaMethods_impl = getMfaMethods;
const __getMfaMethods_wrapped = require_InvalidParamError.instrumentFunction({
	fn: __getMfaMethods_impl,
	functionName: "getMfaMethods",
	getCore: () => {
		try {
			return require_InvalidParamError.getCore(require_InvalidParamError.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 = require_InvalidParamError.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
Object.defineProperty(exports, '__consumeMfaToken_wrapped', {
  enumerable: true,
  get: function () {
    return __consumeMfaToken_wrapped;
  }
});
Object.defineProperty(exports, '__getMfaMethods_wrapped', {
  enumerable: true,
  get: function () {
    return __getMfaMethods_wrapped;
  }
});
Object.defineProperty(exports, 'isMfaRequiredForAction', {
  enumerable: true,
  get: function () {
    return isMfaRequiredForAction;
  }
});
//# sourceMappingURL=isMfaRequiredForAction-qSv2yrfd.cjs.map