import type { AgentMessage } from '../../../agent/AgentMessage'; import type { InboundMessageContext } from '../../../agent/models/InboundMessageContext'; import type { AckMessage } from '../../common'; import type { OutOfBandRecord } from '../../oob/repository'; import type { ConnectionProblemReportMessage } from '../messages'; import type { ConnectionRecordProps } from '../repository/ConnectionRecord'; import { AgentConfig } from '../../../agent/AgentConfig'; import { EventEmitter } from '../../../agent/EventEmitter'; import { Wallet } from '../../../wallet/Wallet'; import { Key } from '../../dids'; import { DidRepository } from '../../dids/repository'; import { ConnectionRequestMessage, ConnectionResponseMessage, TrustPingMessage } from '../messages'; import { DidExchangeState } from '../models'; import { ConnectionRecord } from '../repository/ConnectionRecord'; import { ConnectionRepository } from '../repository/ConnectionRepository'; export interface ConnectionRequestParams { label?: string; imageUrl?: string; alias?: string; routing: Routing; autoAcceptConnection?: boolean; } export declare class ConnectionService { private wallet; private config; private connectionRepository; private didRepository; private eventEmitter; private logger; constructor(wallet: Wallet, config: AgentConfig, connectionRepository: ConnectionRepository, didRepository: DidRepository, eventEmitter: EventEmitter); /** * Create a connection request message for a given out-of-band. * * @param outOfBandRecord out-of-band record for which to create a connection request * @param config config for creation of connection request * @returns outbound message containing connection request */ createRequest(outOfBandRecord: OutOfBandRecord, config: ConnectionRequestParams): Promise>; processRequest(messageContext: InboundMessageContext, outOfBandRecord: OutOfBandRecord): Promise; /** * Create a connection response message for the connection with the specified connection id. * * @param connectionRecord the connection for which to create a connection response * @returns outbound message containing connection response */ createResponse(connectionRecord: ConnectionRecord, outOfBandRecord: OutOfBandRecord, routing?: Routing): Promise>; /** * Process a received connection response message. This will not accept the connection request * or send a connection acknowledgement message. It will only update the existing connection record * with all the new information from the connection response message. Use {@link ConnectionService.createTrustPing} * after calling this function to create a trust ping message. * * @param messageContext the message context containing a connection response message * @returns updated connection record */ processResponse(messageContext: InboundMessageContext, outOfBandRecord: OutOfBandRecord): Promise; /** * Create a trust ping message for the connection with the specified connection id. * * By default a trust ping message should elicit a response. If this is not desired the * `config.responseRequested` property can be set to `false`. * * @param connectionRecord the connection for which to create a trust ping message * @param config the config for the trust ping message * @returns outbound message containing trust ping message */ createTrustPing(connectionRecord: ConnectionRecord, config?: { responseRequested?: boolean; comment?: string; }): Promise>; /** * Process a received ack message. This will update the state of the connection * to Completed if this is not already the case. * * @param messageContext the message context containing an ack message * @returns updated connection record */ processAck(messageContext: InboundMessageContext): Promise; /** * Process a received {@link ProblemReportMessage}. * * @param messageContext The message context containing a connection problem report message * @returns connection record associated with the connection problem report message * */ processProblemReport(messageContext: InboundMessageContext): Promise; /** * Assert that an inbound message either has a connection associated with it, * or has everything correctly set up for connection-less exchange. * * @param messageContext - the inbound message context * @param previousRespondence - previous sent and received message to determine if a valid service decorator is present */ assertConnectionOrServiceDecorator(messageContext: InboundMessageContext, { previousSentMessage, previousReceivedMessage, }?: { previousSentMessage?: AgentMessage; previousReceivedMessage?: AgentMessage; }): void; updateState(connectionRecord: ConnectionRecord, newState: DidExchangeState): Promise; private emitStateChangedEvent; update(connectionRecord: ConnectionRecord): Promise; /** * Retrieve all connections records * * @returns List containing all connection records */ getAll(): Promise; /** * Retrieve a connection record by id * * @param connectionId The connection record id * @throws {RecordNotFoundError} If no record is found * @return The connection record * */ getById(connectionId: string): Promise; /** * Find a connection record by id * * @param connectionId the connection record id * @returns The connection record or null if not found */ findById(connectionId: string): Promise; /** * Delete a connection record by id * * @param connectionId the connection record id */ deleteById(connectionId: string): Promise; findSingleByQuery(query: { did: string; theirDid: string; }): Promise; /** * Retrieve a connection record by thread id * * @param threadId The thread id * @throws {RecordNotFoundError} If no record is found * @throws {RecordDuplicateError} If multiple records are found * @returns The connection record */ getByThreadId(threadId: string): Promise; findByTheirDid(did: string): Promise; findByOurDid(did: string): Promise; findAllByOutOfBandId(outOfBandId: string): Promise; findByInvitationDid(invitationDid: string): Promise; createConnection(options: ConnectionRecordProps): Promise; private createDid; private createDidDoc; private createDidDocFromOutOfBandDidCommServices; returnWhenIsConnected(connectionId: string, timeoutMs?: number): Promise; } export interface Routing { endpoints: string[]; recipientKey: Key; routingKeys: Key[]; mediatorId?: string; } export interface ConnectionProtocolMsgReturnType { message: MessageType; connectionRecord: ConnectionRecord; }