/** * @file * * Mock of Obsidian's `SecretStorage`, the app's store of named secrets. */ import type { SecretStorage as SecretStorageOriginal } from 'obsidian'; import type { App } from './App.mjs'; import { Events } from './Events.mjs'; /** * Mock of Obsidian's `SecretStorage`, which stores secret values by id. * * Secrets are kept in an in-memory map for the lifetime of the instance, so nothing is encrypted or persisted. As in * Obsidian, {@link SecretStorage.setSecret} validates the id and triggers `changed`. */ export declare class SecretStorage extends Events { private readonly store; /** * Creates an empty secret storage. Use {@link SecretStorage.create2__} from outside the class. * * @param app - The app instance. */ protected constructor(app: App); /** * Mock-only factory: creates a secret storage, spyable via `vi.spyOn(SecretStorage, 'create2__')`. It is the * subclass variant of `Events`' factory. * * @param app - The app instance. * @returns The new secret storage. */ static create2__(app: App): SecretStorage; /** * Mock-only: views a value typed as Obsidian's `SecretStorage` as this mock. * * @param value - The value typed as the original `SecretStorage`. * @returns The same object, typed as the mock. */ static fromOriginalType2__(value: SecretStorageOriginal): SecretStorage; /** * Mock-only: views this mock as Obsidian's `SecretStorage` type. * * @returns The same object, typed as the original `SecretStorage`. */ asOriginalType2__(): SecretStorageOriginal; /** * Mock-only construction hook, called at the end of the constructor; a no-op meant for * `vi.spyOn(SecretStorage.prototype, 'constructor2__')`. * * @param _app - The app the storage was created with. */ constructor2__(_app: App): void; /** * Gets a secret from the storage. * * @param id - The secret id. * @returns The secret value, or `null` if none is stored under `id`. */ getSecret(id: string): null | string; /** * Lists the ids of all stored secrets. * * @returns The secret ids, in insertion order. */ listSecrets(): string[]; /** * Stores a secret, replacing any existing value under the same id, and triggers `changed`. * * @param id - The secret id: lowercase letters, digits and dashes, at most 64 characters. * @param secret - The secret value to store. * @throws Error with Obsidian's message when the id is invalid. */ setSecret(id: string, secret: string): void; }