import { Z as getNonce, _t as getCore, ot as assertDefined } from "./updateAuthFromVerifyResponse-D1w-Aw9P.native.esm.js";
import { r as __consumeMfaToken_wrapped, t as isMfaRequiredForAction } from "./isMfaRequiredForAction-Demz9zlH.native.esm.js";

//#region src/modules/mfa/consumeMfaTokenIfRequiredForAction/consumeMfaTokenIfRequiredForAction.ts
/** @notInstrumented */
const consumeMfaTokenIfRequiredForAction = async ({ mfaAction }, client) => {
	if (!await isMfaRequiredForAction({ mfaAction }, client)) return;
	return __consumeMfaToken_wrapped(client);
};

//#endregion
//#region src/modules/sessionKeys/generateNonceSignature/generateNonceSignature.ts
/** @notInstrumented */
const generateNonceSignature = async ({ nonce }, client) => {
	const core = getCore(client);
	assertDefined(core.keychain, "Keychain service not available");
	return { signature: await core.keychain.sign("session", nonce) };
};

//#endregion
//#region src/modules/sessionKeys/generateSessionSignature/generateSessionSignature.ts
/** @notInstrumented */
const generateSessionSignature = async ({ sessionId }, client) => {
	return { signature: await getCore(client).keychain.sign("session", sessionId) };
};

//#endregion
//#region src/modules/sessionKeys/getSignedSessionId/getSignedSessionId.ts
/** @notInstrumented */
const getSignedSessionId = async (client) => {
	const sessionId = getCore(client).state.get().user?.sessionId;
	assertDefined(sessionId, "Session ID is required");
	const { signature: signedSessionId } = await generateSessionSignature({ sessionId }, client);
	assertDefined(signedSessionId, "Signed session ID is required");
	const nonce = await getNonce(client);
	const { signature: nonceSignature } = await generateNonceSignature({ nonce }, client);
	assertDefined(nonceSignature, "Nonce signature is required");
	return { signature: `${signedSessionId}/${nonceSignature}/${nonce}` };
};

//#endregion
export { consumeMfaTokenIfRequiredForAction as n, getSignedSessionId as t };
//# sourceMappingURL=getSignedSessionId-Cl3PEqa8.native.esm.js.map