diff --git a/src/commands/encrypt-file.ts b/src/commands/encrypt-file.ts index 19ec47d..2a9df6e 100644 --- a/src/commands/encrypt-file.ts +++ b/src/commands/encrypt-file.ts @@ -6,7 +6,7 @@ * The file name does NOT change. The content is replaced with OCKE binary format. */ -import { Notice, Plugin, FuzzySuggestModal } from 'obsidian'; +import { App, Notice, Plugin, FuzzySuggestModal } from 'obsidian'; import type { CryptoEngine, EncryptionContext, PluginSettings } from '../types'; import { FORMAT_VERSION, KMS_FILE_TIMEOUT_MS, NOTICE_DURATION_MS } from '../constants'; import { serialize } from '../format/serializer'; @@ -82,13 +82,13 @@ async function executeEncryptFile( await doEncrypt(plugin, cryptoEngine, file.path, contentBytes, arn); } else { // Multiple keys — show picker - new KeyPickerModal(plugin.app, aliases, async (chosen) => { + new KeyPickerModal(plugin.app, aliases, (chosen) => { const arn = resolveKeyArn(chosen, settings); if (!arn) { new Notice(`Key "${chosen}" has no valid ARN.`, NOTICE_DURATION_MS); return; } - await doEncrypt(plugin, cryptoEngine, file.path, contentBytes, arn); + void doEncrypt(plugin, cryptoEngine, file.path, contentBytes, arn); }).open(); } } @@ -141,7 +141,7 @@ class KeyPickerModal extends FuzzySuggestModal { private readonly aliases: string[]; private readonly onChoose: (alias: string) => void; - constructor(app: any, aliases: string[], onChoose: (alias: string) => void) { + constructor(app: App, aliases: string[], onChoose: (alias: string) => void) { super(app); this.aliases = aliases; this.onChoose = onChoose; diff --git a/src/commands/encrypt-selection.ts b/src/commands/encrypt-selection.ts index c900837..a19fe9c 100644 --- a/src/commands/encrypt-selection.ts +++ b/src/commands/encrypt-selection.ts @@ -6,7 +6,7 @@ * The actual encryption happens transparently via the adapter patch on save. */ -import { Notice, Plugin, MarkdownView, FuzzySuggestModal } from 'obsidian'; +import { App, Editor, Notice, Plugin, MarkdownView, FuzzySuggestModal } from 'obsidian'; import type { CryptoEngine, PluginSettings } from '../types'; import { MAX_SELECTION_CHARS, NOTICE_DURATION_MS } from '../constants'; import { getKeyAliases } from '../utils/key-resolver'; @@ -37,7 +37,7 @@ function executeWrapSelection(plugin: Plugin, getSettings: () => PluginSettings) return; } - const editor = markdownView.editor; + const editor: Editor = markdownView.editor; const selection = editor.getSelection(); if (!selection || selection.length === 0) { @@ -68,7 +68,7 @@ function executeWrapSelection(plugin: Plugin, getSettings: () => PluginSettings) } } -function wrapWithAlias(editor: any, selection: string, alias: string | undefined): void { +function wrapWithAlias(editor: Editor, selection: string, alias: string | undefined): void { const startMarker = alias ? `%%secret-start:${alias}%%` : '%%secret-start%%'; const secretBlock = `${startMarker}\n${selection}\n%%secret-end%%`; editor.replaceSelection(secretBlock); @@ -81,7 +81,7 @@ class KeyPickerModal extends FuzzySuggestModal { private readonly aliases: string[]; private readonly onChoose: (alias: string) => void; - constructor(app: any, aliases: string[], onChoose: (alias: string) => void) { + constructor(app: App, aliases: string[], onChoose: (alias: string) => void) { super(app); this.aliases = aliases; this.onChoose = onChoose; diff --git a/src/main.ts b/src/main.ts index 5e5ec26..a7dc594 100644 --- a/src/main.ts +++ b/src/main.ts @@ -69,7 +69,7 @@ export default class CloudKmsPlugin extends Plugin { registerAttachmentHook(this, this.cryptoEngine, () => this.settings, this.bufferRegistry); // 9. File explorer badge for encrypted files - this.uninstallBadge = installFileExplorerBadge(this, this.originalReadBinary!); + this.uninstallBadge = installFileExplorerBadge(this, this.originalReadBinary); // 10. Status bar KMS indicator this.uninstallStatusBar = installStatusBar(this, () => this.settings); @@ -78,7 +78,7 @@ export default class CloudKmsPlugin extends Plugin { registerEncryptedFileView(this); } - async onunload(): Promise { + onunload(): void { // Restore original adapter methods if (this.uninstallAdapterPatch) { this.uninstallAdapterPatch(); diff --git a/src/ui/encrypted-view.ts b/src/ui/encrypted-view.ts index 6f6708d..fe6ac52 100644 --- a/src/ui/encrypted-view.ts +++ b/src/ui/encrypted-view.ts @@ -10,7 +10,7 @@ * or ciphertext integrity verification fails. */ -import { ItemView, Plugin, WorkspaceLeaf } from 'obsidian'; +import { ItemView, Plugin, WorkspaceLeaf, ViewStateResult } from 'obsidian'; /** Unique view type identifier for the encrypted file read-only view. */ export const ENCRYPTED_FILE_VIEW_TYPE = 'encrypted-file-view'; @@ -79,7 +79,7 @@ export class EncryptedFileView extends ItemView { }; } - async setState(state: Partial, result: any): Promise { + async setState(state: Partial, result: ViewStateResult): Promise { if (state.filePath !== undefined) this.filePath = state.filePath; if (state.errorMessage !== undefined) this.errorMessage = state.errorMessage; if (state.rawContentBase64 !== undefined) this.rawContentBase64 = state.rawContentBase64; @@ -191,8 +191,8 @@ export async function showEncryptedFileError( ): Promise { // Build error message with category if available (PluginError) let errorMessage: string; - if ('category' in error && typeof (error as any).category === 'string') { - errorMessage = `[${(error as any).category}] ${error.message}`; + if ('category' in error && typeof (error as Record).category === 'string') { + errorMessage = `[${(error as Record).category}] ${error.message}`; } else { errorMessage = error.message || 'Decryption failed'; } diff --git a/src/ui/file-explorer-badge.ts b/src/ui/file-explorer-badge.ts index 9f30bfc..b3ede7f 100644 --- a/src/ui/file-explorer-badge.ts +++ b/src/ui/file-explorer-badge.ts @@ -10,7 +10,7 @@ const encryptedPaths = new Set(); export function installFileExplorerBadge( plugin: Plugin, - originalReadBinary: (path: string) => Promise + originalReadBinary: ((path: string) => Promise) | undefined ): () => void { // Scan vault on layout ready plugin.app.workspace.onLayoutReady(async () => { @@ -40,8 +40,9 @@ export function markFileDecrypted(filePath: string): void { async function scanVaultForEncryptedFiles( plugin: Plugin, - originalReadBinary: (path: string) => Promise + originalReadBinary: ((path: string) => Promise) | undefined ): Promise { + if (!originalReadBinary) return; const files = plugin.app.vault.getFiles(); for (const file of files) { if (file.path.endsWith('.md')) continue; diff --git a/src/ui/status-bar.ts b/src/ui/status-bar.ts index 1a83923..d598ae0 100644 --- a/src/ui/status-bar.ts +++ b/src/ui/status-bar.ts @@ -68,7 +68,7 @@ export function installStatusBar( // Check on click only (no periodic background checks) statusBarEl.addEventListener('click', () => { - checkStatus(); + void checkStatus(); }); // Initial check after layout ready