import type { AgentMessage } from '../../agent/AgentMessage'; import type { Attachment } from '../../decorators/attachment/Attachment'; import type { ConnectionRecord, Routing, ConnectionInvitationMessage } from '../../modules/connections'; import type { DependencyManager } from '../../plugins'; import type { Key } from '../dids'; import { AgentConfig } from '../../agent/AgentConfig'; import { Dispatcher } from '../../agent/Dispatcher'; import { EventEmitter } from '../../agent/EventEmitter'; import { MessageSender } from '../../agent/MessageSender'; import { HandshakeProtocol, ConnectionsModule } from '../../modules/connections'; import { DidCommMessageRepository } from '../../storage'; import { RoutingService } from '../routing/services/RoutingService'; import { OutOfBandService } from './OutOfBandService'; import { OutOfBandInvitation } from './messages'; import { OutOfBandRecord } from './repository/OutOfBandRecord'; export interface CreateOutOfBandInvitationConfig { label?: string; alias?: string; imageUrl?: string; goalCode?: string; goal?: string; handshake?: boolean; handshakeProtocols?: HandshakeProtocol[]; messages?: AgentMessage[]; multiUseInvitation?: boolean; autoAcceptConnection?: boolean; routing?: Routing; appendedAttachments?: Attachment[]; } export interface CreateLegacyInvitationConfig { label?: string; alias?: string; imageUrl?: string; multiUseInvitation?: boolean; autoAcceptConnection?: boolean; routing?: Routing; } export interface ReceiveOutOfBandInvitationConfig { label?: string; alias?: string; imageUrl?: string; autoAcceptInvitation?: boolean; autoAcceptConnection?: boolean; reuseConnection?: boolean; routing?: Routing; } export declare class OutOfBandModule { private outOfBandService; private routingService; private connectionsModule; private didCommMessageRepository; private dispatcher; private messageSender; private eventEmitter; private agentConfig; private logger; constructor(dispatcher: Dispatcher, agentConfig: AgentConfig, outOfBandService: OutOfBandService, routingService: RoutingService, connectionsModule: ConnectionsModule, didCommMessageRepository: DidCommMessageRepository, messageSender: MessageSender, eventEmitter: EventEmitter); /** * Creates an outbound out-of-band record containing out-of-band invitation message defined in * Aries RFC 0434: Out-of-Band Protocol 1.1. * * It automatically adds all supported handshake protocols by agent to `handshake_protocols`. You * can modify this by setting `handshakeProtocols` in `config` parameter. If you want to create * invitation without handshake, you can set `handshake` to `false`. * * If `config` parameter contains `messages` it adds them to `requests~attach` attribute. * * Agent role: sender (inviter) * * @param config configuration of how out-of-band invitation should be created * @returns out-of-band record */ createInvitation(config?: CreateOutOfBandInvitationConfig): Promise; /** * Creates an outbound out-of-band record in the same way how `createInvitation` method does it, * but it also converts out-of-band invitation message to an "legacy" invitation message defined * in RFC 0160: Connection Protocol and returns it together with out-of-band record. * * Agent role: sender (inviter) * * @param config configuration of how a connection invitation should be created * @returns out-of-band record and connection invitation */ createLegacyInvitation(config?: CreateLegacyInvitationConfig): Promise<{ outOfBandRecord: OutOfBandRecord; invitation: ConnectionInvitationMessage; }>; createLegacyConnectionlessInvitation(config: { recordId: string; message: Message; domain: string; }): Promise<{ message: Message; invitationUrl: string; }>; /** * Parses URL, decodes invitation and calls `receiveMessage` with parsed invitation message. * * Agent role: receiver (invitee) * * @param invitationUrl url containing a base64 encoded invitation to receive * @param config configuration of how out-of-band invitation should be processed * @returns out-of-band record and connection record if one has been created */ receiveInvitationFromUrl(invitationUrl: string, config?: ReceiveOutOfBandInvitationConfig): Promise<{ outOfBandRecord: OutOfBandRecord; connectionRecord?: ConnectionRecord | undefined; }>; /** * Parses URL containing encoded invitation and returns invitation message. * * @param invitationUrl URL containing encoded invitation * * @returns OutOfBandInvitation */ parseInvitation(invitationUrl: string): OutOfBandInvitation; /** * Parses URL containing encoded invitation and returns invitation message. Compatible with * parsing shortened URLs * * @param invitationUrl URL containing encoded invitation * * @returns OutOfBandInvitation */ parseInvitationShortUrl(invitation: string): Promise; /** * Creates inbound out-of-band record and assigns out-of-band invitation message to it if the * message is valid. It automatically passes out-of-band invitation for further processing to * `acceptInvitation` method. If you don't want to do that you can set `autoAcceptInvitation` * attribute in `config` parameter to `false` and accept the message later by calling * `acceptInvitation`. * * It supports both OOB (Aries RFC 0434: Out-of-Band Protocol 1.1) and Connection Invitation * (0160: Connection Protocol). * * Agent role: receiver (invitee) * * @param invitation either OutOfBandInvitation or ConnectionInvitationMessage * @param config config for handling of invitation * * @returns out-of-band record and connection record if one has been created. */ receiveInvitation(invitation: OutOfBandInvitation | ConnectionInvitationMessage, config?: ReceiveOutOfBandInvitationConfig): Promise<{ outOfBandRecord: OutOfBandRecord; connectionRecord?: ConnectionRecord; }>; /** * Creates a connection if the out-of-band invitation message contains `handshake_protocols` * attribute, except for the case when connection already exists and `reuseConnection` is enabled. * * It passes first supported message from `requests~attach` attribute to the agent, except for the * case reuse of connection is applied when it just sends `handshake-reuse` message to existing * connection. * * Agent role: receiver (invitee) * * @param outOfBandId * @param config * @returns out-of-band record and connection record if one has been created. */ acceptInvitation(outOfBandId: string, config: { autoAcceptConnection?: boolean; reuseConnection?: boolean; label?: string; alias?: string; imageUrl?: string; mediatorId?: string; routing?: Routing; }): Promise<{ outOfBandRecord: OutOfBandRecord; connectionRecord: ConnectionRecord; } | { outOfBandRecord: OutOfBandRecord; connectionRecord?: undefined; }>; findByRecipientKey(recipientKey: Key): Promise; findByInvitationId(invitationId: string): Promise; /** * Retrieve all out of bands records * * @returns List containing all out of band records */ getAll(): Promise; /** * Retrieve a out of band record by id * * @param outOfBandId The out of band record id * @throws {RecordNotFoundError} If no record is found * @return The out of band record * */ getById(outOfBandId: string): Promise; /** * Find an out of band record by id * * @param outOfBandId the out of band record id * @returns The out of band record or null if not found */ findById(outOfBandId: string): Promise; /** * Delete an out of band record by id * * @param outOfBandId the out of band record id */ deleteById(outOfBandId: string): Promise; private assertHandshakeProtocols; private areHandshakeProtocolsSupported; private getSupportedHandshakeProtocols; private getFirstSupportedProtocol; private findExistingConnection; private emitWithConnection; private emitWithServices; private handleHandshakeReuse; private registerHandlers; /** * Registers the dependencies of the ot of band module on the dependency manager. */ static register(dependencyManager: DependencyManager): void; }