import { EditorState } from "prosemirror-state"; import type { Transaction } from "prosemirror-state"; import { Merge } from "./merge/index.js"; import type { ModCollab } from "./index.js"; interface IncomingDoc { v: number; content: unknown; comments: unknown; bibliography: unknown; images?: Record; template?: { content: unknown; }; } interface DiffData { type?: string; v?: number; rid?: number; cid?: string | number; ds?: unknown[]; fs?: unknown[]; cu?: unknown[]; bu?: unknown[]; iu?: unknown[]; footnoterender?: boolean; reject_request_id?: number; ep?: string; e2ee_salt?: string; } export declare class ModCollabDoc { mod: ModCollab; merge: Merge; unconfirmedDiffs: Record; confirmStepsRequestCounter: number; awaitingDiffResponse: boolean; receiving: boolean; currentlyCheckingVersion: boolean; enableCheckVersion?: number; footnoteRender: boolean; initialVersionConfirmed: boolean; initialDocLoaded: boolean; templateAdjustmentPending: boolean; sendNextDiffTimer?: number; lastSelectionUpdateState?: EditorState; constructor(mod: ModCollab); cancelCurrentlyCheckingVersion(): void; checkVersion(offline?: boolean): void; disableDiffSending(): void; enableDiffSending(): void; receiveDocument(data: { doc: IncomingDoc; }): void; finishInitialLoad(): void; confirmVersion(version: number): void; loadDocument(data: { doc: IncomingDoc; time: number; doc_info: Record; }): void; /** * Load an E2EE document: try passphrase/DEK first, then fall back to * per-document password prompt, decrypt, then load. * @private */ _loadE2EEDocument(doc: IncomingDoc, doc_info: Record, isInitialLoad: boolean, urlFragmentPassword?: string): Promise; /** * Prompt for a password, derive the key, and decrypt/load the document. * @private */ _promptPasswordAndDecrypt(doc: IncomingDoc, doc_info: Record, salt: string | undefined, iterations: number | undefined, isInitialLoad: boolean, urlFragmentPassword?: string): Promise; /** * Decrypt document content/comments/bibliography with the given key * and load into ProseMirror. * * For a newly created E2EE document, no encrypted snapshot has been * saved yet, so the content/comments/bibliography are still plaintext * JSON objects (the template content). We detect this by checking * whether the value is a string (encrypted = Base64 ciphertext) or * an object (plaintext). * * @private */ _decryptAndLoadDoc(doc: IncomingDoc, key: CryptoKey, salt: string | undefined, iterations: number | undefined, isInitialLoad: boolean, urlFragmentPassword: string): Promise; /** * Load an unencrypted (or already decrypted) document into ProseMirror. * This is the original loadDocument logic, extracted for reuse. * @private */ _loadUnencryptedDocument(doc: IncomingDoc, isInitialLoad: boolean): void; setDocSettings(): void; sendToCollaborators(): void; /** * Send an encrypted diff for an E2EE document. * * For E2EE documents, the diff payload (steps, comments, bibliography, * image updates) is encrypted as a single blob before sending. The * server relays the encrypted diff to other clients without being able * to read the content. * * The unencrypted diff is stored locally in `unconfirmedDiffs` for * confirmation/rejection handling. Only the wire format is encrypted. * * @private */ _sendE2EEDiff(): Promise; /** * Send a selection change for an E2EE document. * Selection changes are not encrypted (they only contain cursor position). * * @private */ _sendE2EESelectionChange(): void; receiveSelectionChange(data: { id: number; editor: string; session_id: string; anchor: number; head: number; }): void; receiveDiff(data: DiffData, serverFix?: boolean): void; /** * Process a diff (unencrypted or already decrypted). * @private */ _processDiff(data: DiffData, serverFix?: boolean): void; /** * Receive and decrypt an E2EE diff from another client. * * For E2EE documents, diffs arrive with an "ep" (encrypted payload) * field containing the encrypted steps, comments, bibliography, and * image updates. This method decrypts the payload and then processes * the diff using the standard _processDiff path. * * @param data - The diff message with "ep" field * @param serverFix - Whether this is a server-generated fix * @private */ _receiveE2EEDiff(data: DiffData, serverFix?: boolean): Promise; setConfirmedDoc(tr: Transaction, stepsLength: number): void; confirmDiff(request_id: number): void; rejectDiff(request_id: number): void; applyDiffs(diffs: unknown[], cid: string | number | undefined): void; } export {}; //# sourceMappingURL=doc.d.ts.map