const require_InvalidParamError = require('./InvalidParamError-D-SHhcTB.cjs');
const require_isMfaRequiredForAction = require('./isMfaRequiredForAction-V3A2BO7c.cjs');

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

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

//#endregion
//#region src/modules/sessionKeys/getSignedSessionId/getSignedSessionId.ts
/** @instrumented */
const getSignedSessionId = async (client) => {
	const sessionId = require_InvalidParamError.getCore(client).state.get().user?.sessionId;
	require_InvalidParamError.assertDefined(sessionId, "Session ID is required");
	const { signature: signedSessionId } = await generateSessionSignature({ sessionId }, client);
	require_InvalidParamError.assertDefined(signedSessionId, "Signed session ID is required");
	const nonce = await require_InvalidParamError.__getNonce_wrapped(client);
	const { signature: nonceSignature } = await generateNonceSignature({ nonce }, client);
	require_InvalidParamError.assertDefined(nonceSignature, "Nonce signature is required");
	return { signature: `${signedSessionId}/${nonceSignature}/${nonce}` };
};
const __getSignedSessionId_impl = getSignedSessionId;
const __getSignedSessionId_wrapped = require_InvalidParamError.instrumentFunction({
	fn: __getSignedSessionId_impl,
	functionName: "getSignedSessionId",
	getCore: () => {
		try {
			return require_InvalidParamError.getCore(require_InvalidParamError.getDefaultClient());
		} catch {
			return;
		}
	}
});

//#endregion
Object.defineProperty(exports, '__consumeMfaTokenIfRequiredForAction_wrapped', {
  enumerable: true,
  get: function () {
    return __consumeMfaTokenIfRequiredForAction_wrapped;
  }
});
Object.defineProperty(exports, '__getSignedSessionId_wrapped', {
  enumerable: true,
  get: function () {
    return __getSignedSessionId_wrapped;
  }
});
//# sourceMappingURL=getSignedSessionId-CWNj8rZW.cjs.map