import { EventEmitter } from '@herbcaudill/eventemitter42'; import { Team } from 'team/index.js'; import type { ConnectionContext, ConnectionEvents, Context } from './types.js'; /** * Wraps a state machine (using [XState](https://xstate.js.org/docs/)) that * implements the connection protocol. */ export declare class Connection extends EventEmitter { #private; constructor({ sendMessage, context }: ConnectionParams); /** Starts the state machine. Returns this Connection object. */ start: (storedMessages?: Uint8Array[]) => this; /** Shuts down and sends a disconnect message to the peer. */ stop: () => this; /** * Adds connection messages from the peer to the MessageQueue's incoming message queue, which * will pass them to the state machine in order. */ deliver(serializedMessage: Uint8Array): void; /** * Public interface for sending a message from the application to our peer via this connection's * encrypted channel. We don't care about the content of this message. */ send: (message: any) => void; /** Returns the current state of the protocol machine. */ get state(): "connected" | "disconnected" | "awaitingIdentityClaim" | "negotiating" | "synchronizing" | { authenticating: "done" | "checkingInvitations" | "awaitingInvitationAcceptance" | "validatingInvitation" | { checkingIdentity: { provingMyIdentity: "done" | "awaitingIdentityChallenge" | "awaitingIdentityAcceptance"; verifyingTheirIdentity: "done" | "challengingIdentity" | "awaitingIdentityProof"; }; }; }; /** * Returns the team that the connection's user is a member of. If the user has not yet joined a * team, returns undefined. */ get team(): Team | undefined; /** * Returns the connection's session key when we are in a connected state. Otherwise, returns * `undefined`. */ get _sessionKey(): Uint8Array | undefined; get _context(): ConnectionContext; } export type ConnectionParams = { /** A function to send messages to our peer. This how you hook this up to your network stack. */ sendMessage: (message: Uint8Array) => void; /** The initial context. */ context: Context; }; //# sourceMappingURL=Connection.d.ts.map