import { D as instrumentFunction, F as getDefaultClient, h as __getNonce_wrapped, w as assertDefined, z as getCore } from "./InvalidParamError-0lP4zZBe.esm.js";
import { r as __consumeMfaToken_wrapped, t as isMfaRequiredForAction } from "./isMfaRequiredForAction-CTghrtq8.esm.js";

//#region src/modules/mfa/consumeMfaTokenIfRequiredForAction/consumeMfaTokenIfRequiredForAction.ts
/** @instrumented */
const consumeMfaTokenIfRequiredForAction = async ({ mfaAction }, client) => {
	if (!await isMfaRequiredForAction({ mfaAction }, client)) return;
	return __consumeMfaToken_wrapped(client);
};
const __consumeMfaTokenIfRequiredForAction_impl = consumeMfaTokenIfRequiredForAction;
const __consumeMfaTokenIfRequiredForAction_wrapped = instrumentFunction({
	fn: __consumeMfaTokenIfRequiredForAction_impl,
	functionName: "consumeMfaTokenIfRequiredForAction",
	getCore: () => {
		try {
			return getCore(getDefaultClient());
		} catch {
			return;
		}
	}
});

//#endregion
//#region src/modules/sessionKeys/generateNonceSignature/generateNonceSignature.ts
/** @not-instrumented */
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
/** @not-instrumented */
const generateSessionSignature = async ({ sessionId }, client) => {
	return { signature: await getCore(client).keychain.sign("session", sessionId) };
};

//#endregion
//#region src/modules/sessionKeys/getSignedSessionId/getSignedSessionId.ts
/** @instrumented */
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_wrapped(client);
	const { signature: nonceSignature } = await generateNonceSignature({ nonce }, client);
	assertDefined(nonceSignature, "Nonce signature is required");
	return { signature: `${signedSessionId}/${nonceSignature}/${nonce}` };
};
const __getSignedSessionId_impl = getSignedSessionId;
const __getSignedSessionId_wrapped = instrumentFunction({
	fn: __getSignedSessionId_impl,
	functionName: "getSignedSessionId",
	getCore: () => {
		try {
			return getCore(getDefaultClient());
		} catch {
			return;
		}
	}
});

//#endregion
export { __consumeMfaTokenIfRequiredForAction_wrapped as n, __getSignedSessionId_wrapped as t };
//# sourceMappingURL=getSignedSessionId-DQr-WJ3a.esm.js.map