Encrypt embedding model api keys (#1405)

This commit is contained in:
Logan Yang 2025-03-27 14:24:16 -07:00 committed by GitHub
parent c25455f08e
commit 7d451f787b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,6 +1,6 @@
import { type CopilotSettings } from "@/settings/model";
import { Platform } from "obsidian";
import { Buffer } from "buffer";
import { Platform } from "obsidian";
// @ts-ignore
let safeStorageInternal: Electron.SafeStorage | null = null;
@ -58,6 +58,15 @@ export async function encryptAllKeys(
);
}
if (Array.isArray(settings.activeEmbeddingModels)) {
newSettings.activeEmbeddingModels = await Promise.all(
settings.activeEmbeddingModels.map(async (model) => ({
...model,
apiKey: await getEncryptedKey(model.apiKey || ""),
}))
);
}
return newSettings;
}