import { VerifiedEvent, UnsignedEvent } from "nostr-tools"; import { SessionState, Unsubscribe, EventCallback, Rumor } from "./types"; /** * Double ratchet secure communication session over Nostr * * Very similar to Signal's "Double Ratchet with header encryption" * https://signal.org/docs/specifications/doubleratchet/ */ export declare class Session { state: SessionState; private internalSubscriptions; private currentInternalSubscriptionId; name: string; constructor(state: SessionState); /** * Initializes a new secure communication session * @param theirEphemeralNostrPublicKey The ephemeral public key of the other party for the initial handshake * @param ourEphemeralNostrPrivateKey Our ephemeral private key for the initial handshake * @param isInitiator Whether we are initiating the conversation (true) or responding (false) * @param sharedSecret Initial shared secret for securing the first message chain * @param name Optional name for the session (for debugging) * @returns A new Session instance */ static init(theirEphemeralNostrPublicKey: string, ourEphemeralNostrPrivateKey: Uint8Array, isInitiator: boolean, sharedSecret: Uint8Array, name?: string): Session; /** * Send a partial Nostr event through the encrypted session. * Message builders are responsible for chat-specific kinds, tags, and expiration policy. * @param event Partial inner event to send. Must be unsigned. Id will be generated if not provided. * @returns A verified Nostr event containing the encrypted message. You need to publish this event to the Nostr network. * @throws Error if we are not the initiator and trying to send the first message */ sendEvent(event: Partial): { event: VerifiedEvent; innerEvent: Rumor; }; /** * Subscribe to rumors decrypted by receiveEvent(). * @param callback Function to be called when a message is received * @returns Unsubscribe function to stop receiving messages */ onEvent(callback: EventCallback): Unsubscribe; /** * Stop local receiveEvent() callbacks. */ close(): void; private ratchetEncrypt; private ratchetDecrypt; private ratchetStep; private skipMessageKeys; private trySkippedMessageKeys; private decryptHeader; receiveEvent(e: VerifiedEvent): Rumor | undefined; } //# sourceMappingURL=Session.d.ts.map