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
@@ -0,0 +1,32 @@
|
||||
import { randomUUID } from "node:crypto";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { describe, expect, test } from "vitest";
|
||||
import { DatabaseConnection } from "../../src/main/database/connection";
|
||||
import { composioKeyPurgeSchema } from "../../src/main/database/migrations/046-composio-key-purge";
|
||||
import { OrganizationService } from "../../src/main/services/organization-service";
|
||||
|
||||
describe("composio key purge migration", () => {
|
||||
test("removes stored api_key and toolkits rows but keeps connection state", () => {
|
||||
const connection = new DatabaseConnection(join(tmpdir(), `ac-purge-${randomUUID()}.db`));
|
||||
const organization = new OrganizationService(connection.db);
|
||||
let orgId = "";
|
||||
connection.transaction(() => {
|
||||
orgId = organization.createOrganization({ organizationName: "OrbitOps", employeeName: "Yang", mission: "m", goal: "g" });
|
||||
});
|
||||
const now = new Date().toISOString();
|
||||
const insert = connection.db.prepare(
|
||||
"insert into composio_settings(org_id, key, value, updated_at) values (?, ?, ?, ?)",
|
||||
);
|
||||
insert.run(orgId, "api_key", "ak_revoked", now);
|
||||
insert.run(orgId, "toolkits", '["github"]', now);
|
||||
insert.run(orgId, "entity_id", orgId, now);
|
||||
insert.run(orgId, "auth_config:github", "ac_123", now);
|
||||
|
||||
connection.db.exec(composioKeyPurgeSchema);
|
||||
|
||||
const keys = (connection.db.prepare("select key from composio_settings where org_id = ? order by key asc").all(orgId) as Array<{ key: string }>)
|
||||
.map((row) => row.key);
|
||||
expect(keys).toEqual(["auth_config:github", "entity_id"]);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user