import { CredoError } from "@credo-ts/core";

//#region ../didcomm/src/models/DidCommInboundMessageContext.ts
var DidCommInboundMessageContext = class {
	constructor(message, context) {
		this.message = message;
		this.recipientKey = context.recipientKey;
		this.senderKey = context.senderKey;
		this.connection = context.connection;
		this.sessionId = context.sessionId;
		this.agentContext = context.agentContext;
		this.receivedAt = context.receivedAt ?? /* @__PURE__ */ new Date();
		this.encryptedMessage = context.encryptedMessage;
	}
	setMessageHandler(messageHandler) {
		this.messageHandler = messageHandler;
	}
	setResponseMessage(outboundMessageContext) {
		this.responseMessage = outboundMessageContext;
	}
	/**
	* Assert the inbound message has a ready connection associated with it.
	*
	* @throws {CredoError} if there is no connection or the connection is not ready
	*/
	assertReadyConnection() {
		if (!this.connection) throw new CredoError(`No connection associated with incoming message ${this.message.type}`);
		this.connection.assertReady();
		return this.connection;
	}
	toJSON() {
		return {
			message: this.message,
			recipientKey: this.recipientKey?.fingerprint,
			senderKey: this.senderKey?.fingerprint,
			sessionId: this.sessionId,
			agentContext: this.agentContext.toJSON()
		};
	}
};

//#endregion
export { DidCommInboundMessageContext };
//# sourceMappingURL=DidCommInboundMessageContext.mjs.map