import { BrowserTypes } from '@finos/fdc3'; import { AppDirectoryApplication } from '../app-directory.contracts.js'; import { AppDirectory } from '../app-directory/index.js'; import { IRootPublisher } from '../contracts.internal.js'; import { EventMessage, FullyQualifiedAppIdentifier, IncomingMessageCallback, IProxyIncomingMessageEnvelope, IProxyOutgoingMessageEnvelope, IRootMessagingProvider, RequestMessage, ResponseMessage } from '../contracts.js'; type RequestMessageHandler = (message: RequestMessage | BrowserTypes.WebConnectionProtocol6Goodbye, source: FullyQualifiedAppIdentifier) => void; /** * Responsible for publishing all messages from the root agent to proxy agents * Maintains a lookup mapping app instances to channelIds */ export declare class RootMessagePublisher implements IRootPublisher { private rootMessagingProvider; private directory; private instanceIdToChannelId; private channelIdToAppIdentifier; private log; /** * Used for passing requests from incoming messages received from proxy agents (or from the root agent itself) to the request handler function in desktop-agent */ requestMessageHandler: RequestMessageHandler | undefined; /** * Used for loopback response messages that the desktop-agent has published but that need to be returned to the proxy-agent code (which desktop-agent extends) */ private proxyResponseHandlers; constructor(rootMessagingProvider: IRootMessagingProvider, directory: AppDirectory); /** * We need to handle this being called AFTER registerNewInstance * @param window * @param app * @returns */ awaitAppIdentity(connectionAttemptUuid: string, _app: AppDirectoryApplication): Promise; /** * IProxyMessagingProvider * Provides loopback functionality * The root agent is also a proxy agent as DesktopAgentImpl extends DesktopAgentProxy * Request messages that the DesktopAgentProxy send do not need to be sent to the messaging provider but need to be sent back to the root agent via the handleRequestMessage function */ addResponseHandler(callback: IncomingMessageCallback): void; sendMessage(message: IProxyOutgoingMessageEnvelope): void; /** * Publishes a response message to the appropriate channel or handler based on the source identifier. * If the source is the root agent, the message is passed back to the proxy response handlers. * @param responseMessage - The response message to be published. * @param source - The identifier of the source app instance. */ publishResponseMessage(responseMessage: ResponseMessage, source: FullyQualifiedAppIdentifier): void; publishEvent(event: EventMessage, appIdentifiers: [FullyQualifiedAppIdentifier, ...FullyQualifiedAppIdentifier[]]): void; /** * Maps app identifiers to channelIds * Filters out the root app identifier from the array and if it exists forwards the message back to the root agent * @param appIdentifiers * @param message */ private mapAppIdentifiersToChannels; /** * Listens to incoming messages from the messaging provider that have been sent from proxy agents */ private onMessage; /** * passes a request message to the root agent after verifying that the class has been properly initialized */ private handleRequestMessage; /** * generates a new instance id and new app identifier for a new proxy agent that is performing a handshake */ private registerNewInstance; private connectionAttemptUuidCallbacks; private awaitConnectionAttemptUuidValidateMessage; private lookupSource; private lookupChannelId; } export {};