Embed the Composio key in the app bundle instead of shipping cred.txt
Root cause of the recurring 401: a revoked key was hardcoded in startup-recovery.ts and onboarding-service.ts and reseeded into composio_settings on every launch, and the interim fix shipped cred.txt as a visible file under resources/. - electron.vite.config.ts reads the gitignored cred.txt at build time and injects the key into the main-process bundle as __COMPOSIO_API_KEY__; no credential file is packaged and the key is not user-visible or configurable. The renderer bundle never sees it. - Delete both hardcoded-key seeders; migration 046 purges stored api_key and never-read toolkits rows while keeping entity_id and auth_config state. - Stop shipping composio_settings in the renderer snapshot.
This commit is contained in:
1 parent
2d43950123
commit
a2de132083
16 files changed
+105
-181
No files matched your search
@@ -1,3 +1,4 @@
|
||||
import { existsSync, readFileSync } from "node:fs";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { dirname, resolve } from "node:path";
|
||||
import { defineConfig, externalizeDepsPlugin } from "electron-vite";
|
||||
@@ -5,9 +6,26 @@ import react from "@vitejs/plugin-react";
|
||||
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
/**
|
||||
* The Composio integration key is compiled into the main-process bundle so
|
||||
* no credential file ever ships with the app. It lives in the gitignored
|
||||
* cred.txt at the repository root (first line "Composio apikey: ak_...");
|
||||
* a checkout without the file builds an app whose connector features report
|
||||
* the integration as unconfigured. Rotation = update cred.txt, rebuild.
|
||||
*/
|
||||
function composioApiKeyForBuild(): string {
|
||||
const credPath = resolve(__dirname, "cred.txt");
|
||||
if (!existsSync(credPath)) return "";
|
||||
const firstLine = readFileSync(credPath, "utf8").split("\n")[0] ?? "";
|
||||
return firstLine.split(":").slice(1).join(":").trim();
|
||||
}
|
||||
|
||||
export default defineConfig({
|
||||
main: {
|
||||
plugins: [externalizeDepsPlugin()],
|
||||
define: {
|
||||
__COMPOSIO_API_KEY__: JSON.stringify(composioApiKeyForBuild()),
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
"@shared": resolve(__dirname, "src/shared"),
|
||||
|
||||
Reference in new issue
Block a user