Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

Team Cloud: a secret a member types in their private chat stays theirs (#5459)

Milind Soni29264c5fcb1c
diff --git a/apps/docs/content/docs/security/permissions-and-secrets.mdx b/apps/docs/content/docs/security/permissions-and-secrets.mdx
index 41656d281c..5a8b8be833 100644
--- a/apps/docs/content/docs/security/permissions-and-secrets.mdx
+++ b/apps/docs/content/docs/security/permissions-and-secrets.mdx
@@ -51,7 +51,11 @@ do with it:
to My Cloud, Cloud Files, chat links, attachments, published pages, browser
uploads and checkpoints all leave that folder out.
-On a Team Cloud only the person the conversation belongs to can enter it. A
+On a Team Cloud only the person the conversation belongs to can enter it, and
+what a person types in their own private chat is theirs alone: the bot uses it
+only in that person's own chats with it, never in a teammate's chat, a shared
+chat, a group chat or an MCP server, where it asks with a card as if nothing
+were saved. A
freshly QR-paired phone can enter either kind; an AI provider key needs the
computer or My Cloud. MausBot masks every saved value if it appears in a
transcript, an event or a log.
@@ -143,7 +147,10 @@ it was last used. **Change** renames a secret, replaces its value or changes
which bots may use it; **Delete** removes it. A saved value is never shown
again, and no screen or API returns it: it can only be replaced. Only an owner
or an admin sees the Vault, and a Vault link (such as the Keys page's 1Password
-row, **Set up in Vault**) opens it.
+row, **Set up in Vault**) opens it. On a Team Cloud a member's Vault lists only
+the secrets they gave bots in their own chats, which they can delete; an
+admin's lists the team's and never a member's own. Leaving the team deletes a
+member's own secrets.
Keys MausBot uses itself (an AI provider's key, Composio, voice, the Boat key)
stay in **Settings → API keys**, which the Vault's **AI and app keys** row
diff --git a/docs/team-cloud.md b/docs/team-cloud.md
index de0d1d752a..f9a215c3e0 100644
--- a/docs/team-cloud.md
+++ b/docs/team-cloud.md
@@ -80,7 +80,12 @@ keeps people apart on it. The bot box ([bot-box.md](bot-box.md)) is what makes t
person's own* (below): then every member connects their own, and only their own chats use it. A person's
connections from elsewhere have no way in: a share code, a moved MCP sign-in or a mailbox is refused with
*"Personal connections never enter Acme. Ask an admin to connect it for Acme."* A login from a sign-in card is saved by
- an Admin only, for the whole team.
+ an Admin only, for the whole team. A secret (an API key, a token) a person types into a bot's card in their own private
+ chat is theirs: that bot uses it only in their own chats with it (and their routines there), never in another
+ member's chat, a shared chat, a group chat or an MCP server, all of which get the card as if nothing were saved. They
+ see and delete it in Settings → Vault, which shows a member their own secrets only; an Admin's Vault, exports and
+ backups never list it, and leaving the team deletes it. A secret an Admin saves in Settings → Vault, or one typed into a
+ card in a shared chat or a group chat, is the team's. One saved before this rule is the team's.
- **Browsers.** Each private chat with a bot drives that person's own browser of the bot, each group chat the group
chat's, and the bot's main chat the team's: separate Chrome profiles, saved sign-ins and live views, so a site one
member signed in to in their chat never opens signed in for another member. The live view shows the browser of the
@@ -929,6 +934,9 @@ opens the team's page on the Cloud site (`/cloud/team/<id>`), not a chat. Nothin
- **Saved logins per member.** A login saved from a sign-in card is the team's (an Admin saves it, for every bot in the
team); per-member saved logins are not built. Sign-ins a member makes in their own browser stay in it (above).
+- **A secret typed into a card outside a private chat.** In a bot's shared chats and group chats the card is entered by
+ whoever looks after the bot there (the Admins when nobody does), and what they type is the team's, for that bot
+ everywhere, as before; only a private chat's secrets are the person's own.
- **The new browser engine and temporary browsers in a box.** The new engine (`browserEngine.engine: "chrome"`, off by
default) starts Chrome itself over a pipe and is not boxed; a temporary browser is boxed, but a file a turn uploads
into it is not reachable from its box.
diff --git a/scripts/ci-scope.mjs b/scripts/ci-scope.mjs
index a5fe9588ea..cc8fdd5c69 100644
--- a/scripts/ci-scope.mjs
+++ b/scripts/ci-scope.mjs
@@ -90,6 +90,7 @@ export const VITEST_SUBSETS = {
"server/cloud-team-gateway-mcp.e2e.test.ts",
"server/cloud-team-inbox.e2e.test.ts",
"server/cloud-team-mausbot-reach.e2e.test.ts",
+ "server/cloud-team-member-secrets.e2e.test.ts",
"server/cloud-team-new-chat-private.e2e.test.ts",
"server/cloud-team-open-reach.e2e.test.ts",
"server/cloud-team-own-key-apps.e2e.test.ts",
diff --git a/scripts/ci-scope.test.ts b/scripts/ci-scope.test.ts
index 90f7ad9f3d..4cdb4ee9a4 100644
--- a/scripts/ci-scope.test.ts
+++ b/scripts/ci-scope.test.ts
@@ -230,6 +230,7 @@ describe("CI outputs", () => {
"server/cloud-team-gateway-mcp.e2e.test.ts",
"server/cloud-team-inbox.e2e.test.ts",
"server/cloud-team-mausbot-reach.e2e.test.ts",
+ "server/cloud-team-member-secrets.e2e.test.ts",
"server/cloud-team-new-chat-private.e2e.test.ts",
"server/cloud-team-open-reach.e2e.test.ts",
"server/cloud-team-own-key-apps.e2e.test.ts",
diff --git a/server/bot-logins.test.ts b/server/bot-logins.test.ts
index bee052eb1f..8523a042fe 100644
--- a/server/bot-logins.test.ts
+++ b/server/bot-logins.test.ts
@@ -6,7 +6,7 @@ import { join } from "node:path";
import { browserMatesOf, loginHeldBackFor } from "../shared/logins.ts";
import { BotLogins, cardLoginPlace, cardSignInElsewhere, observeSignInPage } from "./bot-logins.ts";
-import { VaultStore } from "./vault-store.ts";
+import { TEAM_READER, VaultStore } from "./vault-store.ts";
import type { OnePasswordLogins } from "./onepassword.ts";
import { FakeLoginPage, LOGIN_FORM } from "./testing/fake-login-page.ts";
@@ -127,8 +127,11 @@ describe("the secrets a bot may use", () => {
const store = new VaultStore({ dataDir: mkdtempSync(join(tmpdir(), "omb-bot-logins-")) });
store.saveSecret({ name: "Stripe key", value: "sk_fake-saved", source: "card", bots: ["notes"], refOnly: true });
const logins = new BotLogins(store, provider as unknown as OnePasswordLogins, () => [], (value) => held.push(value));
- expect(logins.secretNamesFor("notes")).toEqual([{ name: "Stripe key", refOnly: true }, { name: "Deploy key" }, { name: "Deploy key user" }]);
- expect(logins.secretNamesFor("payroll")).toEqual([{ name: "Deploy key" }, { name: "Deploy key user" }, { name: "Payroll token" }]);
+ store.saveSecret({ name: "Ada's key", value: "sk_fake-ada-own", source: "card", bots: ["notes"], person: "p_ada0000000000000000000" });
+ expect(logins.secretNamesFor("notes", TEAM_READER)).toEqual([{ name: "Stripe key", refOnly: true }, { name: "Deploy key" }, { name: "Deploy key user" }]);
+ expect(logins.secretNamesFor("notes", { person: "p_ben0000000000000000000", team: true }), "never another member's own").toEqual([{ name: "Stripe key", refOnly: true }, { name: "Deploy key" }, { name: "Deploy key user" }]);
+ expect(logins.secretNamesFor("notes", { person: "p_ada0000000000000000000", team: true }).map((one) => one.name)).toContain("Ada's key");
+ expect(logins.secretNamesFor("payroll", TEAM_READER)).toEqual([{ name: "Deploy key" }, { name: "Deploy key user" }, { name: "Payroll token" }]);
expect(logins.sitesFor("notes")).toEqual([{ site: "example.com", hosts: ["example.com"], exactHost: false, username: "u" }]);
expect(await logins.linkedSecret("payroll token", "notes")).toBeNull();
expect(reads).toEqual([]);
diff --git a/server/bot-logins.ts b/server/bot-logins.ts
index 3155e739ef..9bd741c137 100644
--- a/server/bot-logins.ts
+++ b/server/bot-logins.ts
@@ -4,7 +4,7 @@ import { browserMatesOf, loginPageCheck, loginPlace, loginSite, type LoginBots,
import type { LinkedSecret } from "../shared/vault.ts";
import type { FillCandidate } from "./login-fill.ts";
import { receiveLoginHandoff, type ConnectionHandoffAnswer, type ConnectionHandoffWhat, type LoginHandoffResult } from "./login-handoff.ts";
-import type { VaultStore } from "./vault-store.ts";
+import type { VaultReader, VaultStore } from "./vault-store.ts";
import type { OnePasswordLogins } from "./onepassword.ts";
import type { LoginRouteDeps } from "./routes/logins.ts";
import { findLinkedSecret, linkedCandidates, linkedSecretNames, linkedSecrets, linkedSites, readLinkedSecret, type VaultProvider } from "./vault/providers.ts";
@@ -111,10 +111,10 @@ export class BotLogins {
return this.providers.flatMap((provider) => linkedSecrets(provider));
}
- /** The names of the secrets the bot may use, for its prompt: never a value. */
- secretNamesFor(botId: string): Array<{ name: string; refOnly?: true }> {
+ /** The names of the secrets the bot may use in a turn `reader` names, for its prompt: never a value. */
+ secretNamesFor(botId: string, reader: VaultReader): Array<{ name: string; refOnly?: true }> {
const linked = this.providers.flatMap((provider) => linkedSecrets(provider, botId).flatMap((secret) => linkedSecretNames(secret).map(({ name }) => ({ name }))));
- return [...this.store.secretNamesFor(botId), ...linked];
+ return [...this.store.secretNamesFor(botId, reader), ...linked];
}
/** A secret a linked manager holds for the bot by this name, read from it now; its id is safe as a file name. */
diff --git a/server/cloud-send-verify.ts b/server/cloud-send-verify.ts
index 4bced543bb..0f10facd44 100644
--- a/server/cloud-send-verify.ts
+++ b/server/cloud-send-verify.ts
@@ -7,7 +7,7 @@ import { createHmac } from "node:crypto";
import { itemKey } from "../electron/cloud-send-parts.mjs";
import { canonicalJson } from "../shared/package-format.ts";
-import type { VaultStore } from "./vault-store.ts";
+import { TEAM_READER, type VaultStore } from "./vault-store.ts";
/** At least 32 random bytes, base64url. */
export const VERIFY_NONCE = /^[A-Za-z0-9_-]{43,128}$/u;
@@ -22,7 +22,7 @@ export function loginFingerprints(nonce: string, store: Pick<VaultStore, "change
if (!login) continue;
out[itemKey.login(login.site, login.username, login.exactHost ? login.hosts[0] : undefined)] = fingerprint(nonce, { password: login.password, totp: login.totp ?? null });
}
- for (const { id } of store.listSecrets()) {
+ for (const { id } of store.listSecrets(TEAM_READER)) {
const secret = store.secret(id);
if (secret) out[itemKey.secret(id)] = fingerprint(nonce, { value: secret.value });
}
diff --git a/server/cloud-team-member-secrets.e2e.test.ts b/server/cloud-team-member-secrets.e2e.test.ts
new file mode 100644
index 0000000000..d0eced9ca3
--- /dev/null
+++ b/server/cloud-team-member-secrets.e2e.test.ts
@@ -0,0 +1,165 @@
+// A secret a member types into a bot's card in her own private chat is hers, on a real Team Cloud (OMB_CLOUD_ROLE=team)
+// with the synthetic Claude CLI, tried as the people it must hold against: the same bot in another member's private chat,
+// in its shared chat, in a group chat and in a routine run for that other member asks with a card, as if nothing were
+// saved; no Admin or Owner lists, changes or deletes it; she lists and deletes hers; leaving deletes it. A secret an Admin
+// saves stays the team's everywhere. No value is ever printed: each check says only whether it holds.
+import { randomBytes } from "node:crypto";
+import { readFileSync } from "node:fs";
+import { join } from "node:path";
+import { afterAll, beforeAll, expect, it } from "vitest";
+
+import { launchCloudSendFixture, type CloudSendFixture, type CloudTeamFixture } from "../scripts/testing/cloud-send-fixture.ts";
+import { decryptBrowserState } from "./browser-sites.ts";
+import { personKey } from "./person-key.ts";
+import { hostTimeout } from "./testing/host-timeout.ts";
+import { LOGINS_KEY_FILE, MEMBER_SECRETS_FILE } from "./vault-store.ts";
+
+const OWNER = { email: "[email protected]", role: "owner" as const };
+const ADMIN = { email: "[email protected]", role: "admin" as const };
+const ADA = { email: "[email protected]", role: "member" as const };
+const BEN = { email: "[email protected]", role: "member" as const };
+const LATER = { type: "interval", everyMinutes: 1440, anchorAt: Date.now() + 86_400_000 };
+const ADA_VALUE = `sk_test_fake-ada-${randomBytes(12).toString("hex")}`;
+const ADA_SECOND = `sk_test_fake-ada-${randomBytes(12).toString("hex")}`;
+const TEAM_VALUE = `sk_test_fake-team-${randomBytes(12).toString("hex")}`;
+const LABEL = "Stripe secret key";
+
+type Bot = { id: string; threadId: string };
+type Run = { id: string; routineId: string; status: string; threadId?: string };
+type Asked = { status: number; body: { messageId?: string; text?: string; savedAs?: string } };
+
+let fx: CloudSendFixture, team: CloudTeamFixture;
+let owner = "", admin = "", ada = "", ben = "";
+let ledger: Bot;
+let adaThread = "", benThread = "", roomThread = "", benRunThread = "";
+const said: string[] = [];
+
+const sleep = (ms: number) => new Promise((done) => setTimeout(done, ms));
+async function until(done: () => Promise<boolean> | boolean, timeoutMs = 60_000): Promise<void> {
+ const end = Date.now() + timeoutMs;
+ while (!(await done())) {
+ if (Date.now() > end) throw new Error("timed out waiting");
+ await sleep(150);
+ }
+}
+const as = async (token: string, method: string, path: string, body?: unknown) => {
+ const answer = await team.as(token, method, path, body);
+ said.push(JSON.stringify(answer.body));
+ return answer;
+};
+/** request_credential from Ledger's turn in this conversation, as its agents tools send it. */
+async function ask(threadId: string, label = LABEL, delivery = "ref"): Promise<Asked> {
+ const bearer = await team.capability(ledger.id, threadId);
+ const answer = await fetch(`${team.base}/api/internal/request-credential`, { method: "POST", headers: { authorization: `Bearer ${bearer}`, "content-type": "application/json" },
+ body: JSON.stringify({ label, reason: "For test charges.", delivery }) });
+ const text = await answer.text();
+ said.push(text);
+ return { status: answer.status, body: JSON.parse(text) };
+}
+const save = (token: string, threadId: string, messageId: string, value: string) =>
+ as(token, "POST", `/api/bots/${ledger.id}/secret-cards/${messageId}/save`, { threadId, value });
+const vaultOf = async (token: string) => (await as(token, "GET", "/api/vault")).body as { logins: unknown[]; secrets: Array<{ id: string; name: string }> };
+/** Whether any answer, or the server's log, holds this value: never the value itself in a failure. */
+const leaked = (value: string) => [...said, ...fx.answers, fx.logs()].some((text) => text.includes(value));
+
+beforeAll(async () => {
+ fx = await launchCloudSendFixture({ onePasswordToken: `ops_fake-team-${randomBytes(8).toString("hex")}`, team: { id: "team-acme-secrets", name: "Acme" } });
+ team = fx.team!;
+ owner = (await team.pair(OWNER)).token!;
+ admin = (await team.pair(ADMIN)).token!;
+ ada = (await team.pair(ADA)).token!;
+ ben = (await team.pair(BEN)).token!;
+ ledger = (await as(owner, "POST", "/api/bots", { name: "Ledger" })).body.bot;
+ adaThread = (await as(ada, "POST", `/api/bots/${ledger.id}/tasks`, { title: "Billing" })).body.task.threadId;
+ benThread = (await as(ben, "POST", `/api/bots/${ledger.id}/tasks`, { title: "Billing" })).body.task.threadId;
+ const room = await as(owner, "POST", "/api/groups", { name: "Finance", memberIds: [ledger.id] });
+ expect(room.status, JSON.stringify(room.body)).toBeLessThan(300);
+ roomThread = room.body.group.threadId;
+ const made = await as(ben, "POST", "/api/routines", { name: "Ben's billing check", prompt: "Check the invoices", botId: ledger.id, schedule: LATER, resultsThreadId: "just-me" });
+ expect(made.status, JSON.stringify(made.body)).toBe(201);
+ const ran = await as(ben, "POST", `/api/routines/${made.body.routine.id}/run`);
+ expect(ran.status, JSON.stringify(ran.body)).toBe(201);
+ let run: Run | undefined;
+ await until(async () => {
+ run = ((await as(ben, "GET", "/api/routines")).body.runs as Run[]).find((candidate) => candidate.id === ran.body.run.id);
+ return Boolean(run?.threadId);
+ }, 90_000);
+ benRunThread = run!.threadId!;
+
+ const card = await ask(adaThread);
+ expect(card.status, "the first ask in her chat is a card").toBe(201);
+ expect((await save(ada, adaThread, card.body.messageId!, ADA_VALUE)).status).toBe(200);
+}, hostTimeout(300_000));
+
+afterAll(async () => {
+ await fx?.close();
+});
+
+it("Ledger gets it again in her own chat with no card", async () => {
+ const again = await ask(adaThread);
+ expect(again.status).toBe(200);
+ expect(again.body.text).toMatch(/secret-ref:[0-9a-f]{32}/u);
+}, hostTimeout(30_000));
+
+it("Ledger in Ben's private chat, its shared chat, a group chat and Ben's routine asks with a card, as if nothing were saved", async () => {
+ for (const [where, threadId] of [["Ben's private chat", benThread], ["the shared chat", ledger.threadId], ["a group chat", roomThread], ["Ben's routine", benRunThread]] as const) {
+ const asked = await ask(threadId);
+ expect(asked.status, where).toBe(201);
+ expect(asked.body.messageId, where).toBeTruthy();
+ const file = await ask(threadId, LABEL, "file");
+ expect([file.status, file.body.savedAs], `${where}, as a file`).toEqual([201, undefined]);
+ }
+ expect(leaked(ADA_VALUE), "her value in any answer or log").toBe(false);
+}, hostTimeout(60_000));
+
+it("no Admin, Owner or other member lists, changes or deletes it; she lists hers", async () => {
+ const hers = await vaultOf(ada);
+ expect(hers.secrets.map((one) => one.name)).toEqual([LABEL]);
+ expect(hers.logins).toEqual([]);
+ const id = hers.secrets[0]!.id;
+ for (const [who, token] of [["an Admin", admin], ["the Owner", owner], ["Ben", ben]] as const) {
+ const listed = await vaultOf(token);
+ expect(listed.secrets.map((one) => one.id), `${who}: the Vault`).not.toContain(id);
+ expect(JSON.stringify(listed).includes(LABEL), `${who}: her secret's name`).toBe(false);
+ expect((await as(token, "DELETE", `/api/vault/secrets/${id}`)).status, `${who}: delete`).toBe(404);
+ expect((await as(token, "PATCH", `/api/vault/secrets/${id}`, { bots: "all" })).status, `${who}: change`).toBeGreaterThanOrEqual(403);
+ }
+ for (const token of [admin, owner]) {
+ expect((await as(token, "POST", "/api/vault/secrets", { id, name: LABEL, value: "fake-overwrite", bots: "all" })).status, "a move's secret by her id").toBe(404);
+ for (const format of ["backup", "share"]) {
+ const exported = await as(token, "POST", "/api/teams/export", { format });
+ expect(JSON.stringify(exported.body).includes(id), `the team export as ${format}`).toBe(false);
+ }
+ }
+ expect((await ask(adaThread)).status, "still hers after all that").toBe(200);
+}, hostTimeout(60_000));
+
+it("a secret an Admin saves stays the team's: every chat gets it, hers too", async () => {
+ expect((await as(admin, "POST", "/api/vault/secrets", { name: "Team deploy key", value: TEAM_VALUE, bots: "all" })).status).toBe(201);
+ for (const [where, threadId] of [["Ada's chat", adaThread], ["Ben's chat", benThread], ["the shared chat", ledger.threadId], ["a group chat", roomThread], ["Ben's routine", benRunThread]] as const) {
+ expect((await ask(threadId, "Team deploy key")).status, where).toBe(200);
+ }
+ expect((await vaultOf(admin)).secrets.map((one) => one.name)).toEqual(["Team deploy key"]);
+ expect((await vaultOf(ben)).secrets).toEqual([]);
+ expect(leaked(TEAM_VALUE), "the team's value in any answer or log").toBe(false);
+}, hostTimeout(60_000));
+
+it("she deletes hers, and leaving deletes the rest of hers from the disk", async () => {
+ const id = (await vaultOf(ada)).secrets[0]!.id;
+ expect((await as(ada, "DELETE", `/api/vault/secrets/${id}`)).status).toBe(200);
+ const card = await ask(adaThread);
+ expect(card.status, "gone: Ledger asks again").toBe(201);
+ expect((await save(ada, adaThread, card.body.messageId!, ADA_SECOND)).status).toBe(200);
+ expect((await vaultOf(ada)).secrets).toHaveLength(1);
+
+ const left = await team.signed("POST", "/api/cloud/team/member-left", { email: ADA.email });
+ expect(left.status, JSON.stringify(left.body)).toBeLessThan(300);
+ const dataDir = join(team.home, ".openmausbot");
+ const key = readFileSync(join(dataDir, LOGINS_KEY_FILE), "utf8").trim();
+ const kept = JSON.parse(decryptBrowserState(readFileSync(join(dataDir, MEMBER_SECRETS_FILE)), key)) as { secrets: Array<{ id: string; person: string }> };
+ expect(kept.secrets.filter((one) => one.person === personKey({ id: "", email: ADA.email })).map((one) => one.id), "hers, sealed on the disk").toEqual([]);
+ const back = (await team.pair(ADA)).token!;
+ expect((await vaultOf(back)).secrets, "joining again restores nothing").toEqual([]);
+ expect((await vaultOf(admin)).secrets.map((one) => one.name)).toEqual(["Team deploy key"]);
+ expect(leaked(ADA_SECOND), "her second value in any answer or log").toBe(false);
+}, hostTimeout(60_000));
diff --git a/server/host/secret-cards.test.ts b/server/host/secret-cards.test.ts
index a613c65ad9..5368f661bc 100644
--- a/server/host/secret-cards.test.ts
+++ b/server/host/secret-cards.test.ts
@@ -10,7 +10,7 @@ import { createSecretCards, type SecretCardsDeps } from "./secret-cards.ts";
import { CREDENTIAL_TARGETS } from "../../shared/credential-request.ts";
import { redactBotAuthored } from "../message-redaction.ts";
import { redactSecretsInText } from "../redact.ts";
-import { VaultStore } from "../vault-store.ts";
+import { TEAM_READER, VaultStore } from "../vault-store.ts";
import { BotLogins } from "../bot-logins.ts";
import { OnePasswordLogins, sdkOnePasswordClient } from "../onepassword.ts";
import { fakeOnePasswordSdk } from "../testing/fake-onepassword.ts";
@@ -19,7 +19,8 @@ import type { LoginBots } from "../../shared/logins.ts";
const dirs: string[] = [];
afterEach(() => { for (const dir of dirs.splice(0)) rmSync(dir, { recursive: true, force: true }); });
-function fixture(language?: string, linked?: (vaultStore: VaultStore) => SecretCardsDeps["botLogins"]) {
+/** `privateTo`: a Team Cloud's private chats, by conversation, and whose each is; any other conversation is the team's. */
+function fixture(language?: string, linked?: (vaultStore: VaultStore) => SecretCardsDeps["botLogins"], privateTo: Record<string, string> = {}) {
const dataDir = mkdtempSync(join(tmpdir(), "omb-secret-cards-"));
dirs.push(dataDir);
const lines: Message[] = [];
@@ -41,7 +42,7 @@ function fixture(language?: string, linked?: (vaultStore: VaultStore) => SecretC
const vaultStore = new VaultStore({ dataDir });
const resumed: string[] = [];
const cards = createSecretCards({
- store: store as never, cfg: {} as never, vaultStore,
+ store: store as never, cfg: {} as never, vaultStore, vaultReader: (threadId) => ({ person: privateTo[threadId] ?? null, team: true }),
botLogins: linked?.(vaultStore) ?? { credentialConfig: (config) => ({ ...config, onePassword: { connected: false } }), linkedSecret: async () => null },
phoneSecrets: { provide: async () => {}, open: () => {} } as never, phoneSecretSubmissions: { has: () => false } as never,
connectorThread: () => ({ bot, group: undefined }), answerCardNode: (_thread, _id, text) => { resumed.push(text); return true; }, followCard: () => {}, dataDir, providerKeysRefused: false,
@@ -112,7 +113,7 @@ describe("a secret a card saves to the Vault", () => {
const card = await ask(one, "t1");
expect(card.status).toBe(201);
expect(one.cards.saveCustomSecret("ledger", "t1", String(card.body.messageId), ` ${KEY} `).status).toBe(200);
- expect(one.vaultStore.listSecrets()).toMatchObject([{ name: "Stripe secret key", source: "card", bots: ["ledger"], refOnly: true }]);
+ expect(one.vaultStore.listSecrets(TEAM_READER)).toMatchObject([{ name: "Stripe secret key", source: "card", bots: ["ledger"], refOnly: true }]);
const fromCard = refIn(one.resumed[0]);
expect(fromCard).toBeDefined();
const spent = one.cards.redeemMcpServer({ env: { STRIPE_SECRET_KEY: fromCard } }, "ledger", "t1", "stripe");
@@ -124,17 +125,17 @@ describe("a secret a card saves to the Vault", () => {
expect(fresh).not.toBe(fromCard);
expect(one.lines.filter((line) => line.kind === "secret")).toHaveLength(1);
const used = one.cards.redeemMcpServer({ env: { STRIPE_SECRET_KEY: fresh } }, "ledger", "t2", "stripe");
- const pointer = `vault:${one.vaultStore.listSecrets()[0]!.id}`;
+ const pointer = `vault:${one.vaultStore.listSecrets(TEAM_READER)[0]!.id}`;
expect(used.ok && used.value).toEqual({ env: { STRIPE_SECRET_KEY: pointer } });
- expect(one.vaultStore.listSecrets()[0]!.lastUsedAt).toBeGreaterThan(0);
- expect(JSON.stringify([one.lines, one.resumed, again, one.vaultStore.listSecrets()])).not.toContain(KEY);
+ expect(one.vaultStore.listSecrets(TEAM_READER)[0]!.lastUsedAt).toBeGreaterThan(0);
+ expect(JSON.stringify([one.lines, one.resumed, again, one.vaultStore.listSecrets(TEAM_READER)])).not.toContain(KEY);
});
it("redeems as a vault: pointer to the saved item, kept out of config.json, and gives only that server the item once it is saved", async () => {
const one = fixture();
const card = await ask(one, "t1");
one.cards.saveCustomSecret("ledger", "t1", String(card.body.messageId), KEY);
- const item = one.vaultStore.listSecrets()[0]!.id;
+ const item = one.vaultStore.listSecrets(TEAM_READER)[0]!.id;
const redeemed = one.cards.redeemMcpServer({ headers: { Authorization: `Bearer ${refIn(one.resumed[0])}` } }, "ledger", "t1", "stripe");
expect(redeemed.ok && redeemed.value).toEqual({ headers: { Authorization: `Bearer vault:${item}` } });
expect(JSON.stringify(redeemed)).not.toContain(KEY);
@@ -172,6 +173,79 @@ describe("a secret a card saves to the Vault", () => {
});
});
+describe("on a Team Cloud, a secret typed into a card in a member's private chat", () => {
+ const ADA = "p_ada0000000000000000000", BEN = "p_ben0000000000000000000";
+ const KEY = "sk_test_fake-ada-own-1";
+ const team = () => fixture(undefined, undefined, { "ada-chat": ADA, "ada-routine": ADA, "ben-chat": BEN, "ben-routine": BEN });
+ const ask = (one: ReturnType<typeof fixture>, threadId: string, extra: Record<string, unknown> = {}) =>
+ one.cards.requestCredential(one.bot, threadId, { label: "Stripe secret key", reason: "For test charges.", delivery: "ref", ...extra });
+ async function adaSaves(one: ReturnType<typeof fixture>) {
+ const card = await ask(one, "ada-chat");
+ expect(one.cards.saveCustomSecret("ledger", "ada-chat", String(card.body.messageId), KEY).status).toBe(200);
+ return one.vaultStore.listSecrets({ person: ADA, team: false })[0]!;
+ }
+
+ it("is hers: the same bot gets it in her own chats, and nowhere else is it saved", async () => {
+ const one = team();
+ const own = await adaSaves(one);
+ expect(own).toMatchObject({ name: "Stripe secret key", source: "card", bots: ["ledger"] });
+ expect(JSON.stringify(own)).not.toContain(ADA);
+ for (const threadId of ["ada-chat", "ada-routine"]) expect((await ask(one, threadId)).status, threadId).toBe(200);
+ for (const threadId of ["ben-chat", "ben-routine", "ledger-main", "room-1"]) {
+ const asked = await ask(one, threadId);
+ expect(asked.status, `${threadId}: a card, as if nothing were saved`).toBe(201);
+ expect(one.cards.savedChoices("ledger", threadId, String(asked.body.messageId)), `${threadId}: never offered by name`).toEqual([]);
+ expect(await ask(one, threadId, { delivery: "file" }), `${threadId}: a file`).toMatchObject({ status: 201, body: expect.not.objectContaining({ savedAs: expect.anything() }) });
+ }
+ expect(one.vaultStore.listSecrets(TEAM_READER), "an admin's view").toEqual([]);
+ expect(one.vaultStore.listSecrets({ person: BEN, team: false })).toEqual([]);
+ expect(JSON.stringify([one.lines, one.resumed])).not.toContain(KEY);
+ });
+
+ it("is never offered by name under Use a saved one outside her own chats", async () => {
+ const one = team();
+ const live = await ask(one, "ada-chat", { label: "STRIPE_LIVE_KEY" });
+ one.cards.saveCustomSecret("ledger", "ada-chat", String(live.body.messageId), KEY);
+ const own = one.vaultStore.listSecrets({ person: ADA, team: false })[0]!;
+ for (const threadId of ["ben-chat", "ledger-main", "room-1"]) {
+ const card = await ask(one, threadId);
+ expect(one.cards.savedChoices("ledger", threadId, String(card.body.messageId)), threadId).toEqual([]);
+ expect(await one.cards.useSavedSecret("ledger", threadId, String(card.body.messageId), own.id), threadId).toMatchObject({ status: 404 });
+ }
+ const mine = await ask(one, "ada-chat");
+ expect(one.cards.savedChoices("ledger", "ada-chat", String(mine.body.messageId))).toEqual([{ id: own.id, name: "STRIPE_LIVE_KEY" }]);
+ });
+
+ it("never goes into an MCP server, which serves the whole team, even from her own chat", async () => {
+ const one = team();
+ const own = await adaSaves(one);
+ const ref = /secret-ref:[0-9a-f]{32}/u.exec(one.resumed[0]!)?.[0];
+ const redeemed = one.cards.redeemMcpServer({ env: { STRIPE: ref } }, "ledger", "ada-chat", "stripe");
+ expect(redeemed).toEqual({ ok: false, error: expect.stringContaining("Stripe secret key is the person's own") });
+ expect(one.vaultStore.mcpServerKeys("stripe")).toEqual([]);
+ expect(one.vaultStore.serversUsingKey(own.id)).toEqual([]);
+ });
+
+ it("leaves the team's secret of the same name as it was, which every other chat still gets", async () => {
+ const one = team();
+ const shared = one.vaultStore.saveSecret({ name: "Stripe secret key", value: "sk_test_fake-team", source: "settings", bots: ["ledger"] });
+ const card = await ask(one, "ada-chat", { replace: true });
+ one.cards.saveCustomSecret("ledger", "ada-chat", String(card.body.messageId), KEY);
+ expect(one.vaultStore.secret(shared.id)?.value).toBe("sk_test_fake-team");
+ expect(one.vaultStore.usableSecret("Stripe secret key", "ledger", "ref", { person: ADA, team: true })?.value).toBe(KEY);
+ expect(one.vaultStore.usableSecret("Stripe secret key", "ledger", "ref", { person: BEN, team: true })?.id).toBe(shared.id);
+ for (const threadId of ["ben-chat", "ledger-main", "room-1"]) expect((await ask(one, threadId)).status, threadId).toBe(200);
+ });
+
+ it("is the team's when typed in a shared chat, as before", async () => {
+ const one = team();
+ const card = await ask(one, "ledger-main");
+ one.cards.saveCustomSecret("ledger", "ledger-main", String(card.body.messageId), KEY);
+ expect(one.vaultStore.listSecrets(TEAM_READER)).toHaveLength(1);
+ for (const threadId of ["ada-chat", "ben-chat", "room-1"]) expect((await ask(one, threadId)).status, threadId).toBe(200);
+ });
+});
+
describe("Use a saved one on a secret card", () => {
const KEY = "sk_test_fake-picked-1";
const card = async (one: ReturnType<typeof fixture>, extra: Record<string, unknown> = {}) =>
@@ -184,7 +258,7 @@ describe("Use a saved one on a secret card", () => {
const id = await card(one);
expect(one.cards.savedChoices("ledger", "t1", id)).toEqual([{ id: kept.id, name: "STRIPE_LIVE_KEY" }]);
expect(await one.cards.useSavedSecret("ledger", "t1", id, kept.id)).toMatchObject({ status: 200, body: { provided: true, resumed: true } });
- expect(one.vaultStore.listSecrets().find((secret) => secret.id === kept.id)).toMatchObject({ bots: ["quill", "ledger"], lastUsedAt: expect.any(Number) });
+ expect(one.vaultStore.listSecrets(TEAM_READER).find((secret) => secret.id === kept.id)).toMatchObject({ bots: ["quill", "ledger"], lastUsedAt: expect.any(Number) });
const ref = /secret-ref:[0-9a-f]{32}/u.exec(one.resumed[0]!)?.[0];
const used = one.cards.redeemMcpServer({ env: { STRIPE: ref } }, "ledger", "t1", "stripe");
expect(used.ok && used.value).toEqual({ env: { STRIPE: `vault:${kept.id}` } });
@@ -227,7 +301,7 @@ describe("the mailbox card", () => {
const resumed: string[] = [];
const bot = { id: "ledger", name: "Ledger" } as BotRecord;
const cards = createSecretCards({
- store: store as never, cfg: {} as never, botLogins: { credentialConfig: (config) => ({ ...config, onePassword: { connected: false } }), linkedSecret: async () => null }, vaultStore: new VaultStore({ dataDir }),
+ store: store as never, cfg: {} as never, botLogins: { credentialConfig: (config) => ({ ...config, onePassword: { connected: false } }), linkedSecret: async () => null }, vaultStore: new VaultStore({ dataDir }), vaultReader: () => TEAM_READER,
phoneSecrets: { provide: async () => {}, open: async () => PASSWORD } as never, phoneSecretSubmissions: { has: () => false, run: async (_card: unknown, _op: unknown, work: () => Promise<void>) => work() } as never,
connectorThread: () => ({ bot, group: undefined }), answerCardNode: (_thread, _id, text) => { resumed.push(text); return true; }, followCard: () => {}, dataDir, providerKeysRefused: false,
layerFolder: () => dataDir, turnVm: () => undefined,
@@ -443,7 +517,7 @@ describe("a secret a linked 1Password holds", () => {
const used = one.cards.redeemMcpServer({ env: { NOTION_TOKEN: ref } }, "ledger", "t1", "stripe");
expect(used.ok && used.value).toEqual({ env: { NOTION_TOKEN: expect.stringMatching(/^vault:linked-[0-9a-f]{32}$/u) } });
expect(one.lines).toEqual([]);
- expect(one.vaultStore.listSecrets()).toEqual([]);
+ expect(one.vaultStore.listSecrets(TEAM_READER)).toEqual([]);
expect(JSON.stringify(answer)).not.toContain(NOTION);
});
@@ -481,7 +555,7 @@ describe("a secret a linked 1Password holds", () => {
const ref = /secret-ref:[0-9a-f]{32}/u.exec(one.resumed[0]!)?.[0];
const used = one.cards.redeemMcpServer({ env: { NOTION_TOKEN: ref } }, "ledger", "t1", "stripe");
expect(used.ok && used.value).toEqual({ env: { NOTION_TOKEN: expect.stringMatching(/^vault:linked-[0-9a-f]{32}$/u) } });
- expect(one.vaultStore.listSecrets()).toEqual([]);
+ expect(one.vaultStore.listSecrets(TEAM_READER)).toEqual([]);
});
it("tells the bot in plain words when 1Password can't be read, with no card", async () => {
diff --git a/server/host/secret-cards.ts b/server/host/secret-cards.ts
index a321a2fb2b..69791695ec 100644
--- a/server/host/secret-cards.ts
+++ b/server/host/secret-cards.ts
@@ -37,7 +37,7 @@ import {
type PhoneSecretSubmissionRegistry,
} from "../phone-secret.ts";
import type { BotLogins } from "../bot-logins.ts";
-import type { VaultStore } from "../vault-store.ts";
+import type { VaultReader, VaultStore } from "../vault-store.ts";
import { loginUsableBy } from "../../shared/logins.ts";
import { vaultNameKey, type VaultChoice } from "../../shared/vault.ts";
import { fittingChoices } from "../vault/choices.ts";
@@ -62,6 +62,9 @@ export interface SecretCardsDeps {
botLogins: Pick<BotLogins, "credentialConfig" | "linkedSecret"> & Partial<Pick<BotLogins, "linkedSecrets">>;
/** Where a custom card's value is saved, and found again the next time the same bot asks for it by name. */
vaultStore: Pick<VaultStore, "saveSecret" | "usableSecret" | "markUsed" | "listSecrets" | "secret" | "updateSecret" | "grantMcpKeys">;
+ /** Whose saved secrets a turn in this conversation reaches: the team's, and on a Team Cloud the person's own whose
+ * private chat it is, who also owns what is typed into its card. */
+ vaultReader(threadId: string): VaultReader;
phoneSecrets: Pick<PhoneSecretBridge, "provide" | "open">;
phoneSecretSubmissions: PhoneSecretSubmissionRegistry;
connectorThread(botId: string, threadId: string): { bot: BotRecord; group: GroupRecord | undefined } | null;
@@ -225,7 +228,8 @@ export function createSecretCards(deps: SecretCardsDeps) {
/** Saves a custom card's value to the Vault for the asking bot, then hands it over. */
function storeCustomSecret(message: Message, botId: string, threadId: string, value: string): void {
- const saved = vaultStore.saveSecret({ name: message.secret!.label, value, source: "card", bots: [botId], refOnly: message.secret!.delivery !== "file" });
+ const person = deps.vaultReader(threadId).person;
+ const saved = vaultStore.saveSecret({ name: message.secret!.label, value, source: "card", bots: [botId], refOnly: message.secret!.delivery !== "file", ...(person ? { person } : {}) });
handOver(message, botId, threadId, value, saved.id);
}
@@ -285,7 +289,7 @@ export function createSecretCards(deps: SecretCardsDeps) {
const card = message.secret!;
const asked = vaultNameKey(card.label);
const fresh = (name: string, usable: boolean) => !(usable && vaultNameKey(name) === asked);
- const saved = vaultStore.listSecrets().filter((one) => !(card.delivery === "file" && one.refOnly) && fresh(one.name, loginUsableBy(one, botId)))
+ const saved = vaultStore.listSecrets(deps.vaultReader(threadId)).filter((one) => !(card.delivery === "file" && one.refOnly) && fresh(one.name, loginUsableBy(one, botId)))
.map((one) => ({ id: one.id, name: one.name, use: async () => {
// Picking it is the person letting this bot use it.
if (one.bots !== "all" && !one.bots.includes(botId)) vaultStore.updateSecret(one.id, { bots: [...one.bots, botId] });
@@ -379,7 +383,10 @@ export function createSecretCards(deps: SecretCardsDeps) {
const redeemed = vault.redeem(body, { botId, threadId }, (path) =>
(path.length === 2 && (path[0] === "env" || path[0] === "headers")) || (path.length === 2 && path[0] === "oauth" && path[1] === "clientSecret"),
"mcp_server's env, headers and oauth.clientSecret");
- return !redeemed.ok ? redeemed : { ...redeemed, commit: () => { redeemed.commit(); vaultStore.grantMcpKeys(server, redeemed.pointers); } };
+ if (!redeemed.ok) return redeemed;
+ const own = redeemed.pointers.map((id) => vaultStore.secret(id)).find((item) => item?.person);
+ if (own) return { ok: false as const, error: `${own.name} is the person's own, and an MCP server here serves the whole team, so it cannot hold it. Ask a workspace admin to save the key for the team in Settings → Vault, then ask for it again.` };
+ return { ...redeemed, commit: () => { redeemed.commit(); vaultStore.grantMcpKeys(server, redeemed.pointers); } };
}
function phoneSecretSubmissionKey(threadId: string, messageId: string, requestKey: string): string {
@@ -634,7 +641,8 @@ export function createSecretCards(deps: SecretCardsDeps) {
const asked = customRequest(body);
if ("error" in asked) return { status: 400, body: asked };
const vm = asked.delivery === "file" ? deps.turnVm(threadId) : undefined;
- const saved = asked.replace ? null : vaultStore.usableSecret(asked.label, from.id, asked.delivery);
+ const reader = deps.vaultReader(threadId);
+ const saved = asked.replace ? null : vaultStore.usableSecret(asked.label, from.id, asked.delivery, reader);
let item: { id: string; name: string; value: string } | null = saved;
if (!asked.replace && !item) {
try {
@@ -678,7 +686,7 @@ export function createSecretCards(deps: SecretCardsDeps) {
store.patchMessage(threadId, prior.id, { secret: { ...prior.secret, superseded: true } });
deps.followCard(threadId, prior.id, message.id);
}
- const savedAs = asked.delivery === "file" && !asked.replace && vaultStore.usableSecret(asked.label, from.id, "ref") ? { savedAs: "ref" } : {};
+ const savedAs = asked.delivery === "file" && !asked.replace && vaultStore.usableSecret(asked.label, from.id, "ref", reader) ? { savedAs: "ref" } : {};
return { status: 201, body: { messageId: message.id, label: asked.label, delivery: asked.delivery, ...savedAs } };
}
diff --git a/server/host/team-member-left.test.ts b/server/host/team-member-left.test.ts
index 3c0d9885fd..9e62417b79 100644
--- a/server/host/team-member-left.test.ts
+++ b/server/host/team-member-left.test.ts
@@ -4,6 +4,7 @@ import { join } from "node:path";
import { describe, expect, it } from "vitest";
import { personKey } from "../person-key.ts";
+import { TEAM_READER, VaultStore } from "../vault-store.ts";
import { createUploadOwners } from "./member-uploads.ts";
import { createTeamMemberLeft, type TeamMemberLeftDeps } from "./team-member-left.ts";
@@ -26,6 +27,7 @@ function fixture() {
const routines: Array<{ id: string; name: string; botId: string; home: string | null; writer: string | undefined; files: string[] }> = [];
const handed: Array<[string, string, string | null]> = [];
const rows: unknown[] = [];
+ const vault = new VaultStore({ dataDir });
const deps: TeamMemberLeftDeps = {
dataDir,
store: { get bots() { return bots; }, messagesFor: (threadId) => messages.get(threadId) ?? [] },
@@ -51,6 +53,7 @@ function fixture() {
deleteAttachment: (file) => deleted.push(file),
eraseBrowsers: async () => true,
forgetConnections: () => {},
+ forgetSecrets: (person) => { vault.forgetPerson(person); },
routines: () => routines,
deleteRoutine: (id) => { routines.splice(routines.findIndex((routine) => routine.id === id), 1); },
handRoutine: (id, left, to) => { handed.push([id, left, to]); },
@@ -59,7 +62,7 @@ function fixture() {
record: (row) => { rows.push(row); },
};
const file = (n: number) => { writeFileSync(join(attachments, name(n)), "x"); return name(n); };
- return { dataDir, attachments, messages, bots, deleted, deletedBots, working, deps, file, routines, handed, rows };
+ return { dataDir, attachments, messages, bots, deleted, deletedBots, working, deps, file, routines, handed, rows, vault };
}
describe("createTeamMemberLeft", () => {
@@ -129,4 +132,18 @@ describe("createTeamMemberLeft", () => {
expect(result.files).toBe(1);
expect(existsSync(join(fx.dataDir, "people", bob))).toBe(false);
});
+
+ it("deletes the secrets they typed into cards in their own chats, and nobody else's, and says nothing of them", async () => {
+ const fx = fixture();
+ const ada = personKey({ id: "", email: "[email protected]" });
+ const own = (person: string) => fx.vault.saveSecret({ name: "Stripe secret key", value: `sk_test_fake-${person}`, source: "card", bots: ["scout"], person });
+ const theirs = own(bob), hers = own(ada);
+ const team = fx.vault.saveSecret({ name: "Stripe secret key", value: "sk_test_fake-team", source: "settings", bots: "all" });
+ await createTeamMemberLeft(fx.deps)(BOB);
+ expect(fx.vault.secret(theirs.id)).toBeNull();
+ expect(fx.vault.secret(hers.id)).not.toBeNull();
+ expect(fx.vault.listSecrets(TEAM_READER).map((one) => one.id)).toEqual([team.id]);
+ expect(new VaultStore({ dataDir: fx.dataDir }).secret(theirs.id), "and from the disk").toBeNull();
+ expect(JSON.stringify(fx.rows)).not.toContain("Stripe");
+ });
});
diff --git a/server/host/team-member-left.ts b/server/host/team-member-left.ts
index 7c09084de4..c7bc13bb1b 100644
--- a/server/host/team-member-left.ts
+++ b/server/host/team-member-left.ts
@@ -2,7 +2,7 @@
// own MausBot with its chats and notes, their private chats with every bot (messages, notifications, the files only
// those chats used, and the files they uploaded and never sent), the routines that live in those chats, their memory
// layers, their
-// engine home (its transcripts), their "About you", their own connections, their own browsers, and every session and
+// engine home (its transcripts), their "About you", their own connections and saved secrets, their own browsers, and every session and
// phone of theirs. Nothing of it is handed to an admin. A routine they wrote for a shared place keeps running, as the
// routine of whoever looks after its bot now (the Admins when nobody does), and admin activity says it was handed over.
// They come off every bot's sharing and "Looked after by" (what they looked after falls to the Admins), so joining again
@@ -63,6 +63,8 @@ export interface TeamMemberLeftDeps {
eraseBrowsers(audience: Audience): Promise<boolean>;
/** Their own connections, keys and MCP sign-ins (team-connections.ts). */
forgetConnections(person: string): void | Promise<void>;
+ /** The secrets they typed into cards in their own chats (vault-store.ts). */
+ forgetSecrets(person: string): void;
/** Every routine: `home` is the person whose private chat it lives in (routine-home.ts), `writer` who last wrote it,
* `files` the attachments/ names it carries. */
routines(): ReadonlyArray<{ id: string; name: string; botId: string; home: string | null; writer: string | undefined; files: readonly string[] }>;
@@ -150,6 +152,7 @@ export function createTeamMemberLeft(deps: TeamMemberLeftDeps): (email: string)
rmSync(join(deps.dataDir, "people", person), { recursive: true, force: true });
rmSync(audienceHome(deps.dataDir, memberAudience(person)), { recursive: true, force: true });
await Promise.resolve(deps.forgetConnections(person)).catch((error: unknown) => { console.warn(`[team] a leaving member's connections were not all removed: ${error instanceof Error ? error.message : String(error)}`); });
+ try { deps.forgetSecrets(person); } catch (error) { console.warn(`[team] a leaving member's saved secrets were not removed: ${error instanceof Error ? error.message : String(error)}`); }
const browsers = await deps.eraseBrowsers(memberAudience(person)).catch(() => false);
// Counts of shared things only: nothing here says what was theirs alone.
deps.record({ category: "people", action: "member.left", target: { kind: "person", name: address }, after: { botsHandedBack, routinesHandedOver: written.length } });
diff --git a/server/host/vault-readers.ts b/server/host/vault-readers.ts
new file mode 100644
index 0000000000..0b4d5249c1
--- /dev/null
+++ b/server/host/vault-readers.ts
@@ -0,0 +1,27 @@
+// Whose saved secrets a turn and a Settings session reach. On a Team Cloud a secret a member typed into a card in their
+// own private chat is theirs alone: no other member's chat, shared chat, group chat or routine reaches it, and no admin
+// sees it. Off a Team Cloud every secret is the install's, as it always was.
+import { audienceMember, type Audience } from "../audience.ts";
+import type { RequestAuth } from "../request-auth.ts";
+import { TEAM_READER, type VaultReader } from "../vault-store.ts";
+
+export interface VaultReadersDeps {
+ team: boolean;
+ audienceOf(threadId: string): Audience;
+ personOf(auth: Extract<RequestAuth, { kind: "session" }>): string;
+}
+
+export function createVaultReaders(deps: VaultReadersDeps) {
+ return {
+ /** A turn in this conversation: the team's secrets, and the person's own whose private chat it is. */
+ turn(threadId: string): VaultReader {
+ return deps.team ? { person: audienceMember(deps.audienceOf(threadId)), team: true } : TEAM_READER;
+ },
+ /** Settings → Vault: an admin sees the team's (and on a team their own), anyone else only their own. */
+ viewer(auth: RequestAuth): VaultReader {
+ return { person: deps.team && auth.kind === "session" ? deps.personOf(auth) : null, team: auth.scopes.includes("admin") };
+ },
+ };
+}
+
+export type VaultReaders = ReturnType<typeof createVaultReaders>;
diff --git a/server/index.ts b/server/index.ts
index 8f61cc09f1..34a2babf52 100644
--- a/server/index.ts
+++ b/server/index.ts
@@ -437,14 +437,14 @@ import { CalendarCallManager, type CalendarCall } from "./calendar-calls.ts";
import { BROWSER_UPLOAD_TOOL, browserRuntimeEnv } from "./browser-runtime.ts";
import { BrowserUploadRefusal, uploadableFiles } from "./browser-upload.ts";
import { listSignedInSites, signOutOfSites } from "./browser-sites.ts";
-import { HeldSecrets, VaultStore } from "./vault-store.ts";
+import { HeldSecrets, TEAM_READER, VaultStore } from "./vault-store.ts";
import { OnePasswordLogins, onePasswordUnavailable, sdkOnePasswordClient, type OnePasswordSdk } from "./onepassword.ts";
import { nativeRequire } from "./data/engine.ts";
import { createFillLoginTurn } from "./host/fill-login-turn.ts";
import { BotLogins, cardLoginPlace, cardSignInElsewhere, observeSignInPage, type ObservedPage } from "./bot-logins.ts";
import { relayFrame } from "./browser-relay.ts";
import { browserEvidence, stepContext } from "./browser-steps.ts";
-import { parseLoginFields, parseTotpField, createLoginRoutes } from "./routes/logins.ts"; import { createVaultRoutes } from "./routes/vault.ts"; import { createSignInVaultChoices } from "./vault/choices.ts";
+import { parseLoginFields, parseTotpField, createLoginRoutes } from "./routes/logins.ts"; import { createVaultRoutes } from "./routes/vault.ts"; import { createVaultReaders } from "./host/vault-readers.ts"; import { createSignInVaultChoices } from "./vault/choices.ts";
import { loginSite } from "../shared/logins.ts";
import { browserRestartRefusal } from "./browser-live.ts";
import { browserEngineStatus } from "./browser-engine.ts";
@@ -955,7 +955,7 @@ const CLOUD_OWNER_KEY = CLOUD_PERSONAL ? `p_${createHash("sha256").update(`cloud
let cloudEarlierOwners: Pick<CloudOwnership, "adopted" | "proven"> = { adopted: new Set(), proven: new Set() };
/** Until it is settled, a Cloud home counts as shared. */
let cloudHome: ReturnType<typeof settleCloudHome> | null = null; const teamHost = createCloudTeamHost({ team: CLOUD_TEAM, dataDir: DATA_DIR, store: { groupByThread: (threadId) => store.groupByThread(threadId), get bots() { return store.bots; } }, engineHomes, starters: threadStarters, markers: new Set([CLOUD_NOBODY_KEY, CLOUD_OUTSIDE_KEY]), language: appLanguage,
- serverProfile: { read: () => cfg.profile, clear: () => { adminActorScope.exit(() => saveConfig({ profile: { name: "", email: "", aboutMe: "", avatarUrl: "" } })); Object.assign(cfg, loadConfig()); } } });
+ serverProfile: { read: () => cfg.profile, clear: () => { adminActorScope.exit(() => saveConfig({ profile: { name: "", email: "", aboutMe: "", avatarUrl: "" } })); Object.assign(cfg, loadConfig()); } } }); const vaultReaders = createVaultReaders({ team: CLOUD_TEAM !== null, audienceOf: (threadId) => teamHost.audienceOf(threadId), personOf: actorKey });
const teamOwners = createTeamOwners({ team: CLOUD_TEAM, dataDir: DATA_DIR, sessions, store: () => store, audienceOf: (threadId) => teamHost.audienceOf(threadId), starters: threadStarters }); const mausbotOwnChat = createMausBotOwnChat({ bots: () => store.bots, starters: threadStarters, personKey: (email) => personKey({ id: "", email }), moveNotes: (from, to, person) => moveMemoryLayer(from, to, personLanguages.forLine(person)) });
const personRooms = createPersonRooms({ reads: CLOUD_TEAM ? createRoomReads(DATA_DIR, (person) => { botOrders?.forgetPerson(person); forgetNotificationReader(person); }) : null, store: () => store, newestMessageId: (threadId) => readCursor(threadId).lastReadMessageId, publicGroupState, broadcast, shared: (threadId) => teamHost.privateTo(threadId) === null, wireBot: (botId) => { const bot = store.bot(botId); return bot ? wireBot(bot) : null; } });
const botOrders = CLOUD_TEAM ? createPersonBotOrder(DATA_DIR) : null; const teamRoutines = createTeamRoutines({ team: Boolean(CLOUD_TEAM), privateTo: teamHost.privateTo, task: (botId, threadId) => store.taskByThread(botId, threadId), routines: () => routines, authors: cloudRoutineAuthors, withWriter: withRoutineWriter, ownBot: (botId) => { const person = store.bot(botId)?.defaultBot?.person; return person ? personKey({ id: "", email: person }) : null; }, tasks: (botId) => store.tasks(botId), threadRefusal: cloudThreadRefusal, openChat: (botId, title, person) => { const threadId = store.createTask(botId, title, false)?.threadId; if (threadId) threadStarters.set(threadId, person); return threadId; } });
@@ -2989,7 +2989,7 @@ function previewSystemPrompt(bot: BotRecord) {
{ id: "mcp", label: "MCP servers", text: caps?.customMcp ? customMcpPrompt(Object.keys(engineMcpServers(bot)), mcpServersHost.off(bot)) : "" }, { id: "to-connect", label: "Connections to make", text: cloudConnections.prompt(bot) },
{ id: "browser", label: "Browser", text: previewPlan.browser ? browserPromptFor(bot, agentsMounted) : "" },
{ id: "coordination", label: "Team", text: agentsMounted && coordination ? ` ${coordination}` : "" },
- { id: "credential", label: "Credentials", text: agentsMounted ? CREDENTIAL_PROMPT + savedSecretsPrompt(botLogins.secretNamesFor(bot.id)) : "" },
+ { id: "credential", label: "Credentials", text: agentsMounted ? CREDENTIAL_PROMPT + savedSecretsPrompt(botLogins.secretNamesFor(bot.id, TEAM_READER)) : "" },
{ id: "routine", label: "Triggers", text: agentsMounted ? TRIGGER_PROMPT : "" },
{ id: "profile", label: "Profile changes", text: agentsMounted ? PROFILE_PROMPT : "" },
{ id: "section-context", label: "Section context", text: sectionContextSystemPrompt(bot.section) },
@@ -8274,7 +8274,7 @@ async function beginTurn(
: integrations.agents && sectionPeers.length > 0
? peerRosterSystemPrompt(sectionPeers, bot)
: "") + (integrations.agents ? personalReach.prompt(bot, threadId, sectionPeers) : "");
- const credentialPrompt = integrations.agents ? CREDENTIAL_PROMPT + savedSecretsPrompt(botLogins.secretNamesFor(bot.id)) + THREADS_PROMPT + WIDGET_PROMPT : "";
+ const credentialPrompt = integrations.agents ? CREDENTIAL_PROMPT + savedSecretsPrompt(botLogins.secretNamesFor(bot.id, vaultReaders.turn(threadId))) + THREADS_PROMPT + WIDGET_PROMPT : "";
const routinePrompt = integrations.agents ? TRIGGER_PROMPT : "";
const profilePrompt = integrations.agents ? PROFILE_PROMPT : "";
const recallPrompt = integrations.agents && bot.memoryEnabled !== false ? SESSION_SEARCH_SYSTEM_PROMPT : "";
@@ -10109,7 +10109,7 @@ async function runClaimedGroupMemberTurn(
readyGroup.bulletin.trim() && `Room bulletin (shared instructions for everyone):\n${readyGroup.bulletin.trim()}`,
`Reply as yourself, briefly and conversationally. To bring a teammate in, mention them like @Name — they'll see the conversation and respond.${readyGroup.dm ? "" : ` To get ${typeof userName === "string" ? `${userName}'s` : "a person's"} attention or ask them something blocking, write @you.`} A "[reacted 👍 to …]" line is that person's whole reply to the message it names: 👍 means yes, go ahead, and 👎 means no.`,
outsideRoom.length > 0 && roomPeerRosterSystemPrompt(outsideRoom), sharedNamesNote(roomMembers.filter((member) => member.id !== bot.id), Boolean(integrations.agents)),
- integrations.agents && (CREDENTIAL_PROMPT + savedSecretsPrompt(botLogins.secretNamesFor(bot.id)) + (orchestration && !orchestration.roomHandoffId ? THREADS_PROMPT : "")).trim(),
+ integrations.agents && (CREDENTIAL_PROMPT + savedSecretsPrompt(botLogins.secretNamesFor(bot.id, vaultReaders.turn(threadId))) + (orchestration && !orchestration.roomHandoffId ? THREADS_PROMPT : "")).trim(),
integrations.agents && (!orchestration || orchestration.roomHandoffId) && "For actual OpenMausBot teamwork, discover IDs with list_room_targets and use coordinate_bots for advice or work in this or another room. Do not substitute native coding helpers for these named bots. Consult only when needed to make a decision; no discussion step is mandatory. Give concrete responsibilities, exact accessible paths and acceptance checks. End your turn after assigning; busy teammates queue and results automatically resume you. When they return, finish the requested verification and give the user one final answer. Native helper names are not evidence that an OpenMausBot teammate participated. Plain @mentions are only for conversational replies in this room." + requesterRule,
integrations.agents && TRIGGER_PROMPT.trim(),
integrations.agents && PROFILE_PROMPT.trim(),
@@ -11522,7 +11522,7 @@ function claimPhoneSecretBotDeletion(botId: string): (() => void) | null {
};
}
-const secretCards = createSecretCards({ store, cfg, botLogins, vaultStore: logins, phoneSecrets, phoneSecretSubmissions, connectorThread, answerCardNode, followCard: (threadId, from, to) => coordinator.followCard(threadId, from, to), threadLanguage, email: { connect: (request, reading) => emailService.connect(request, reading), refusal: () => emailService.status().reason, connected: (address) => { const one = emailService.store.get(address); return Boolean(one && !one.problem); }, sendingProblem: (address) => emailService.sendingProblem(address), account: (address) => emailService.status().accounts.find((one) => one.address.toLowerCase() === address.toLowerCase()), checkOutgoing: (address, fields) => emailService.checkOutgoing(address, fields), profileAddress: () => cfg.profile?.email?.trim() || undefined }, dataDir: DATA_DIR, providerKeysRefused: Boolean(hostedModels), layerFolder: (botId, threadId) => workspaceDir(teamHost.layer(botId, threadId)), turnVm: (threadId) => localVmThreadTargets.get(threadId)?.key });
+const secretCards = createSecretCards({ store, cfg, botLogins, vaultStore: logins, vaultReader: vaultReaders.turn, phoneSecrets, phoneSecretSubmissions, connectorThread, answerCardNode, followCard: (threadId, from, to) => coordinator.followCard(threadId, from, to), threadLanguage, email: { connect: (request, reading) => emailService.connect(request, reading), refusal: () => emailService.status().reason, connected: (address) => { const one = emailService.store.get(address); return Boolean(one && !one.problem); }, sendingProblem: (address) => emailService.sendingProblem(address), account: (address) => emailService.status().accounts.find((one) => one.address.toLowerCase() === address.toLowerCase()), checkOutgoing: (address, fields) => emailService.checkOutgoing(address, fields), profileAddress: () => cfg.profile?.email?.trim() || undefined }, dataDir: DATA_DIR, providerKeysRefused: Boolean(hostedModels), layerFolder: (botId, threadId) => workspaceDir(teamHost.layer(botId, threadId)), turnVm: (threadId) => localVmThreadTargets.get(threadId)?.key });
ROUTES.push(createBurstRoutes({ owner: (id) => burst.owner(id), sees: (auth, threadId) => visibleTo(viewerFor(auth)).thread(threadId), refusal: (auth, threadId, id) => cardAnswerRefusal(auth, threadId, id, "allow"), view: (id) => burst.view(id), run: (id) => burst.run(id), cancel: (id) => burst.cancel(id), retry: (id) => burst.retryFailed(id), edit: (id, plan) => burst.edit(id, plan) })); ROUTES.push(createSecretCardRoutes({ cards: secretCards, phoneSecretSubmissions, threadVisible: (auth, threadId) => visibleTo(viewerFor(auth)).thread(threadId), answerContext: (auth, botId, threadId) => ({ personalCloud: Boolean(CLOUD_PERSONAL), shared: sharedMembership(), owner: (CLOUD_TEAM ? teamOwners.routing.askedPerson(botId, threadId) : null) ?? threadStarters.get(threadId) ?? null, person: auth.kind === "session" ? personKey(auth.session) : null }) }));
// By design OpenMausBot never receives a website password: the person signs in where the bot works, and the bot uses that session.
@@ -12302,7 +12302,7 @@ const taskRoutes = createTaskRoutes({
revokeInternalCapabilitiesForThread,
stagedSkillCleanupsForThread,
rejectDeletedThreadSkillStages,
-}); ROUTES.push(taskRoutes); const leaveTeam = CLOUD_TEAM ? createTeamMemberLeft({ dataDir: DATA_DIR, store, openedBy: (person) => threadStarters.threadsOf(person, 50_000), privateTo: teamHost.privateTo, revokeSessions: (email) => sessions.revokeMember(email), busy: threadBusy, stop: (botId, threadId) => interruptDirectThread(botId, threadId, "The person left the team"), deleteTasks: taskRoutes.deleteTasks, stopBot: (botId) => memberOwnBot.stopWork(botId, "The person left the team"), deleteBot: memberOwnBot.remove, threadsReferencing, deleteAttachment: (name) => deleteAttachment(join(ATTACHMENTS_DIR, name)), eraseBrowsers: eraseAudienceBrowsers, forgetConnections: (person) => { connectionHealth.forgetPerson(person); personRooms.reads?.forgetPerson(person); return teamConnections.forgetPerson(person); }, ...teamRoutines.leaving, forgetOnBots: (email) => forgetMember(store, email, (bot, access) => writeAccess({ store, publicGroupState, broadcast, audienceChanged }, bot, access)).length, ownerOf: (botId) => { const bot = store.bot(botId); return bot ? botOwner(bot) : null; }, record: (row) => appendAdminAction(DATA_DIR, { ...row, actor: { kind: "session", sessionId: "", label: "MausBot Cloud" } }) }) : null;
+}); ROUTES.push(taskRoutes); const leaveTeam = CLOUD_TEAM ? createTeamMemberLeft({ dataDir: DATA_DIR, store, openedBy: (person) => threadStarters.threadsOf(person, 50_000), privateTo: teamHost.privateTo, revokeSessions: (email) => sessions.revokeMember(email), busy: threadBusy, stop: (botId, threadId) => interruptDirectThread(botId, threadId, "The person left the team"), deleteTasks: taskRoutes.deleteTasks, stopBot: (botId) => memberOwnBot.stopWork(botId, "The person left the team"), deleteBot: memberOwnBot.remove, threadsReferencing, deleteAttachment: (name) => deleteAttachment(join(ATTACHMENTS_DIR, name)), eraseBrowsers: eraseAudienceBrowsers, forgetConnections: (person) => { connectionHealth.forgetPerson(person); personRooms.reads?.forgetPerson(person); return teamConnections.forgetPerson(person); }, forgetSecrets: (person) => { logins.forgetPerson(person); }, ...teamRoutines.leaving, forgetOnBots: (email) => forgetMember(store, email, (bot, access) => writeAccess({ store, publicGroupState, broadcast, audienceChanged }, bot, access)).length, ownerOf: (botId) => { const bot = store.bot(botId); return bot ? botOwner(bot) : null; }, record: (row) => appendAdminAction(DATA_DIR, { ...row, actor: { kind: "session", sessionId: "", label: "MausBot Cloud" } }) }) : null;
ROUTES.push(createTeamRoutes({
store,
cfg,
@@ -12325,7 +12325,7 @@ ROUTES.push(createBrowserSiteRoutes({
signOut: (target, site) => signOutOfSites(target, site),
}));
ROUTES.push(createBrowserEvidenceRoutes({ evidence: browserEvidence.attach({ onChange: (listener) => store.onChange(listener), threadExists: (id) => Boolean(threadOwner(id)) }), threadExists: (id) => Boolean(threadOwner(id)) }));
-const loginRoutes = botLogins.routes((id) => Boolean(store.bot(id))); ROUTES.push(createLoginRoutes(loginRoutes), createVaultRoutes({ logins: loginRoutes, secrets: logins, linked: () => botLogins.linkedSecrets(), keys: mcpKeys }));
+const loginRoutes = botLogins.routes((id) => Boolean(store.bot(id))); ROUTES.push(createLoginRoutes(loginRoutes), createVaultRoutes({ logins: loginRoutes, secrets: logins, linked: () => botLogins.linkedSecrets(), keys: mcpKeys, reader: vaultReaders.viewer }));
const privateRecords = createPrivateRecords({ visibleFor: (auth) => visibleTo(viewerFor(auth)), botExists: (id) => Boolean(store.bot(id)), routine: (id) => routines?.listRoutines().find((routine) => routine.id === id) }); ROUTES.push(createUsageRoutes({
dataDir: DATA_DIR, prices: operatorPrices,
budget: () => spendState(cfg, DATA_DIR),
diff --git a/server/login-handoff.ts b/server/login-handoff.ts
index 56dc18baa8..0f538f8d99 100644
--- a/server/login-handoff.ts
+++ b/server/login-handoff.ts
@@ -102,7 +102,7 @@ export function answerLoginHandoff(store: HandoffStore, what: Exclude<LoginHando
}
if (what.kind === "secret") {
const secret = store.secret(what.id);
- if (!secret) return { ok: false, error: "This secret is no longer saved on this computer." };
+ if (!secret || secret.person) return { ok: false, error: "This secret is no longer saved on this computer." };
return { ok: true, secret: { id: secret.id, name: secret.name, value: secret.value, bots: secret.bots, source: secret.source, ...(secret.refOnly ? { refOnly: true } : {}) } };
}
const login = store.get(what.id);
diff --git a/server/request-auth.test.ts b/server/request-auth.test.ts
index e0df5603b1..114c601e1b 100644
--- a/server/request-auth.test.ts
+++ b/server/request-auth.test.ts
@@ -176,7 +176,7 @@ describe("scopes", () => {
["POST", "/api/bots/x/sign-in-cards/m/provide"], ["POST", "/api/browser-engine/install"],
["GET", "/api/logins"], ["POST", "/api/logins"], ["PATCH", "/api/logins/l1"], ["DELETE", "/api/logins/l1"],
["POST", "/api/logins/1password"], ["POST", "/api/logins/1password/refresh"], ["DELETE", "/api/logins/1password"],
- ["GET", "/api/vault"], ["POST", "/api/vault/secrets"], ["PATCH", "/api/vault/secrets/s1"], ["DELETE", "/api/vault/secrets/s1"],
+ ["POST", "/api/vault/secrets"], ["PATCH", "/api/vault/secrets/s1"], ["GET", "/api/vault/secrets/s1"], ["DELETE", "/api/vault/secrets"],
["POST", "/api/threads/t/messages/m/app"], ["GET", "/api/bots/x/apps/m/rpc"], ["POST", "/api/bots/x/apps/m/delete"],
["POST", "/api/bots/x/apps/m/rpc/extra"], ["DELETE", "/api/bots/x/apps/m/context"],
["PATCH", "/api/logins/1password/vaults/v1"], ["GET", "/api/bots/x/sign-in-cards/m/done"],
@@ -189,6 +189,7 @@ describe("scopes", () => {
for (const [method, path] of [
["GET", "/api/team/my-connections"], ["POST", "/api/team/my-connections/apps/gmail/connect"], ["DELETE", "/api/team/my-connections/apps/gmail"],
["POST", "/api/team/my-connections/mcp/mail/sign-in"], ["PUT", "/api/team/my-connections/mcp/mail/key"], ["DELETE", "/api/team/my-connections/mcp/mail"],
+ ["GET", "/api/vault"], ["DELETE", "/api/vault/secrets/s1"],
] as const) expect(requiredScope(method, path), `${method} ${path}`).toBe("client");
for (const [method, path] of [
["PUT", "/api/team/connection-scopes"], ["GET", "/api/team/my-connections/mcp/mail/key"], ["POST", "/api/team/my-connections/apps/gmail"],
diff --git a/server/request-auth.ts b/server/request-auth.ts
index cff4038ec1..9d40b979be 100644
--- a/server/request-auth.ts
+++ b/server/request-auth.ts
@@ -438,6 +438,9 @@ export const CLIENT_ALLOW: ReadonlyArray<{ methods: readonly string[]; path: Reg
{ methods: ["POST"], path: /^\/api\/team\/my-connections\/(?:apps\/[\w-]{1,64}\/connect|mcp\/[a-z][a-z0-9_-]{0,31}\/sign-in)$/ },
{ methods: ["PUT"], path: /^\/api\/team\/my-connections\/mcp\/[a-z][a-z0-9_-]{0,31}\/key$/ },
{ methods: ["DELETE"], path: /^\/api\/team\/my-connections\/(?:apps\/[\w-]{1,64}|mcp\/[a-z][a-z0-9_-]{0,31})$/ },
+ // a Team Cloud member's own saved secrets, by name only: the handler lists and deletes the session's own alone (routes/vault.ts)
+ { methods: ["GET"], path: /^\/api\/vault$/ },
+ { methods: ["DELETE"], path: /^\/api\/vault\/secrets\/[\w-]{1,128}$/ },
// the person opened the app: their own brief on a Team Cloud, nothing recorded for anyone else
{ methods: ["POST"], path: /^\/api\/presence\/active$/ },
// which shared conversation a team member's window shows: the handler keeps only one they and others may read
diff --git a/server/routes/cloud-send.ts b/server/routes/cloud-send.ts
index 5c2077780b..c418f7c653 100644
--- a/server/routes/cloud-send.ts
+++ b/server/routes/cloud-send.ts
@@ -21,7 +21,7 @@ import { cloudSendSummary, partHash, type CloudSendSources } from "../cloud-send
import { cloudSendChatsRoute, type CloudSendChatsDeps } from "../cloud-send-chats.ts";
import { loginFingerprints, VERIFY_NONCE } from "../cloud-send-verify.ts";
import type { AppConfig } from "../config.ts";
-import type { VaultStore } from "../vault-store.ts";
+import { TEAM_READER, type VaultStore } from "../vault-store.ts";
import type { MoveAutomations } from "../move-freeze.ts";
import { threadHeads } from "../message-db.ts";
import type { LineLanguage } from "../server-lines.ts";
@@ -69,7 +69,7 @@ export function createCloudSendRoutes(deps: CloudSendRouteDeps): RouteHandler {
skills: deps.skills,
picture: (avatarUrl) => botAvatarUrlSchema.safeParse(avatarUrl).success ? readAttachment(avatarUrl.slice("/api/attachments/".length))?.bytes ?? null : null,
logins: () => deps.logins.changes(),
- secrets: () => deps.logins.listSecrets(),
+ secrets: () => deps.logins.listSecrets(TEAM_READER),
onePassword: () => {
const connectedAt = deps.logins.onePasswordConnectedAt();
return connectedAt === null ? null : { connectedAt, grants: deps.logins.onePasswordGrants() };
diff --git a/server/routes/vault.test.ts b/server/routes/vault.test.ts
index f69f15eedc..b06aaba74a 100644
--- a/server/routes/vault.test.ts
+++ b/server/routes/vault.test.ts
@@ -10,7 +10,8 @@ import { json, readBody } from "../harness/http.ts";
import { OnePasswordLogins, sdkOnePasswordClient } from "../onepassword.ts";
import { fakeOnePasswordSdk } from "../testing/fake-onepassword.ts";
import type { RequestAuth } from "../request-auth.ts";
-import { VaultStore } from "../vault-store.ts";
+import { createVaultReaders } from "../host/vault-readers.ts";
+import { TEAM_READER, VaultStore } from "../vault-store.ts";
import { createLoginRoutes } from "./logins.ts";
import { dispatchRoutes } from "./table.ts";
import { createVaultRoutes, VAULT_ERRORS } from "./vault.ts";
@@ -26,7 +27,8 @@ afterEach(async () => {
for (const dir of dirs.splice(0)) rmSync(dir, { recursive: true, force: true });
});
-async function serve(onePasswordToken: string | null = null) {
+/** `team`: a Team Cloud, where each call says who makes it (`as`: "admin" or "member", and their person key). */
+async function serve(onePasswordToken: string | null = null, team = false) {
const dir = mkdtempSync(join(tmpdir(), "omb-vault-routes-"));
dirs.push(dir);
const store = new VaultStore({ dataDir: dir });
@@ -37,18 +39,21 @@ async function serve(onePasswordToken: string | null = null) {
await onePassword.refresh();
const botLogins = new BotLogins(store, onePassword);
const logins = botLogins.routes((id) => ["pepper", "quill"].includes(id));
- const routes = [createLoginRoutes(logins), createVaultRoutes({ logins, secrets: store, linked: () => botLogins.linkedSecrets(), keys: { usedBy: (item) => store.serversUsingKey(item) } })];
+ const readers = createVaultReaders({ team, audienceOf: () => "team", personOf: (auth) => auth.session.id });
+ const routes = [createLoginRoutes(logins), createVaultRoutes({ logins, secrets: store, linked: () => botLogins.linkedSecrets(), keys: { usedBy: (item) => store.serversUsingKey(item) }, reader: readers.viewer })];
const answers: string[] = [];
const server = createServer(async (req, res) => {
const url = new URL(req.url ?? "/", "http://localhost");
- const auth = { kind: "loopback", scopes: ["admin"] } as unknown as RequestAuth;
+ const [role, person] = String(req.headers["x-test-as"] ?? "").split(":");
+ const auth = (role ? { kind: "session", session: { id: person }, via: "bearer", scopes: role === "admin" ? ["admin", "client"] : ["client"] }
+ : { kind: "loopback", scopes: ["admin"] }) as unknown as RequestAuth;
if (!await dispatchRoutes(routes, { req, res, url, path: url.pathname, method: req.method ?? "GET", auth, json, readBody })) json(res, 404, {});
});
servers.push(server);
await new Promise<void>((ready) => server.listen(0, "127.0.0.1", ready));
const base = `http://127.0.0.1:${(server.address() as AddressInfo).port}`;
- const call = async (method: string, path: string, body?: unknown, type = "application/json") => {
- const response = await fetch(base + path, { method, headers: { "content-type": type }, ...(body === undefined ? {} : { body: JSON.stringify(body) }) });
+ const call = async (method: string, path: string, body?: unknown, type = "application/json", as?: string) => {
+ const response = await fetch(base + path, { method, headers: { "content-type": type, ...(as ? { "x-test-as": as } : {}) }, ...(body === undefined ? {} : { body: JSON.stringify(body) }) });
const text = await response.text();
answers.push(text);
return { status: response.status, body: JSON.parse(text), cache: response.headers.get("cache-control") };
@@ -74,7 +79,7 @@ describe("the Vault routes", () => {
const added = await call("POST", "/api/vault/secrets", { name: " Stripe secret key ", value: ` ${VALUE} ` });
expect(added).toMatchObject({ status: 201, body: { secret: { name: "Stripe secret key", source: "settings", bots: "all" } } });
const id = added.body.secret.id;
- expect(store.usableSecret("Stripe secret key", "pepper", "file")?.value).toBe(VALUE);
+ expect(store.usableSecret("Stripe secret key", "pepper", "file", TEAM_READER)?.value).toBe(VALUE);
const listed = await call("GET", "/api/vault");
expect(listed).toMatchObject({ status: 200, cache: "no-store" });
@@ -83,11 +88,11 @@ describe("the Vault routes", () => {
expect(listed.body.onePassword).toEqual({ connected: false });
expect((await call("PATCH", `/api/vault/secrets/${id}`, { value: NEW_VALUE, bots: ["quill"] })).body.secret).toMatchObject({ bots: ["quill"], name: "Stripe secret key" });
- expect(store.usableSecret("Stripe secret key", "quill", "ref")?.value).toBe(NEW_VALUE);
- expect(store.usableSecret("Stripe secret key", "pepper", "ref")).toBeNull();
+ expect(store.usableSecret("Stripe secret key", "quill", "ref", TEAM_READER)?.value).toBe(NEW_VALUE);
+ expect(store.usableSecret("Stripe secret key", "pepper", "ref", TEAM_READER)).toBeNull();
expect((await call("DELETE", `/api/vault/secrets/${id}`)).body).toEqual({ ok: true });
expect((await call("DELETE", `/api/vault/secrets/${id}`)).status).toBe(404);
- expect(store.listSecrets()).toEqual([]);
+ expect(store.listSecrets(TEAM_READER)).toEqual([]);
for (const answer of answers) {
expect(answer).not.toContain(VALUE);
expect(answer).not.toContain(NEW_VALUE);
@@ -120,4 +125,43 @@ describe("the Vault routes", () => {
expect((await call("PATCH", "/api/vault/secrets/1password:v1:n1", { name: "x" })).status).toBe(404);
for (const answer of answers) expect(answer).not.toContain(LINKED_VALUE);
});
+
+ it("on a Team Cloud show a member only the secrets of their own, which they may delete, and an admin never those", async () => {
+ const ADA = "p_ada0000000000000000000", BEN = "p_ben0000000000000000000", ARI = "p_ari0000000000000000000";
+ const { store, call, answers } = await serve(null, true);
+ const as = (who: string) => (method: string, path: string, body?: unknown) => call(method, path, body, "application/json", who);
+ const ada = as(`member:${ADA}`), ben = as(`member:${BEN}`), ari = as(`admin:${ARI}`);
+ const team = (await ari("POST", "/api/vault/secrets", { name: "Team key", value: VALUE })).body.secret;
+ const own = store.saveSecret({ name: "Stripe secret key", value: NEW_VALUE, source: "card", bots: ["pepper"], refOnly: true, person: ADA });
+ await ari("POST", "/api/logins", { site: "example.com", username: "ops", password: "fake-route-login-pass" });
+
+ expect((await ari("GET", "/api/vault")).body.secrets.map((one: { id: string }) => one.id)).toEqual([team.id]);
+ expect(await ada("GET", "/api/vault")).toMatchObject({ status: 200, cache: "no-store", body: { logins: [], secrets: [{ id: own.id, name: "Stripe secret key" }], onePassword: { connected: false } } });
+ expect((await ben("GET", "/api/vault")).body).toEqual({ logins: [], secrets: [], onePassword: { connected: false } });
+
+ for (const [who, caller] of [["an admin", ari], ["another member", ben]] as const) {
+ expect((await caller("DELETE", `/api/vault/secrets/${own.id}`)).status, who).toBe(404);
+ expect((await caller("PATCH", `/api/vault/secrets/${own.id}`, { value: "fake-overwrite", bots: "all" })).status, who).toBeGreaterThanOrEqual(403);
+ }
+ expect((await ari("POST", "/api/vault/secrets", { id: own.id, name: "Stripe secret key", value: "fake-overwrite", bots: "all" })).status).toBe(404);
+ expect((await ada("DELETE", `/api/vault/secrets/${team.id}`)).status, "a member never deletes the team's").toBe(404);
+ expect((await ada("POST", "/api/vault/secrets", { name: "Mine", value: VALUE })).status).toBe(403);
+ expect((await ada("PATCH", `/api/vault/secrets/${own.id}`, { bots: "all" })).status).toBe(403);
+ expect(store.secret(own.id)).toMatchObject({ value: NEW_VALUE, bots: ["pepper"], person: ADA });
+
+ expect(await ada("DELETE", `/api/vault/secrets/${own.id}`)).toMatchObject({ status: 200, body: { ok: true } });
+ expect(store.secret(own.id)).toBeNull();
+ expect(store.secret(team.id)).not.toBeNull();
+ for (const answer of answers) {
+ expect(answer).not.toContain(NEW_VALUE);
+ expect(answer).not.toContain(VALUE);
+ }
+ });
+
+ it("off a Team Cloud show a session without admin nothing, and a member's own never exist there", async () => {
+ const { call } = await serve();
+ await call("POST", "/api/vault/secrets", { name: "Stripe secret key", value: VALUE });
+ expect((await call("GET", "/api/vault", undefined, "application/json", "member:p_phone000000000000000000")).body).toEqual({ logins: [], secrets: [], onePassword: { connected: false } });
+ expect((await call("GET", "/api/vault")).body.secrets).toHaveLength(1);
+ });
});
diff --git a/server/routes/vault.ts b/server/routes/vault.ts
index 821795fe76..2880984a02 100644
--- a/server/routes/vault.ts
+++ b/server/routes/vault.ts
@@ -1,7 +1,9 @@
-// No answer ever carries a saved value: a saved secret is only ever replaced.
+// No answer ever carries a saved value: a saved secret is only ever replaced. A Team Cloud member sees and deletes only
+// the secrets of their own; an admin, only the team's and their own.
import { SECRET_VALUE_MAX_BYTES, VAULT_SECRET_NAME_MAX, type LinkedSecret } from "../../shared/vault.ts";
+import type { RequestAuth } from "../request-auth.ts";
import type { McpKeys } from "../vault/mcp-keys.ts";
-import type { VaultStore } from "../vault-store.ts";
+import { TEAM_READER, type VaultReader, type VaultStore } from "../vault-store.ts";
import { isJson, parseBots, type LoginRouteDeps } from "./logins.ts";
import { PASS, type RouteHandler } from "./table.ts";
@@ -12,6 +14,8 @@ export interface VaultRouteDeps {
linked?: () => LinkedSecret[];
/** Which MCP servers lose their key when a secret is deleted. */
keys?: Pick<McpKeys, "usedBy">;
+ /** Whose secrets this caller sees; absent: the team's, as an admin's. */
+ reader?(auth: RequestAuth): VaultReader;
}
const SECRETS = "/api/vault/secrets";
@@ -38,14 +42,18 @@ function parseValue(raw: unknown): Parsed<string | undefined> {
}
export function createVaultRoutes(deps: VaultRouteDeps): RouteHandler {
- return async ({ req, res, path, method, json, readBody }) => {
+ return async ({ req, res, path, method, auth, json, readBody }) => {
if (path !== "/api/vault" && !path.startsWith("/api/vault/")) return PASS;
res.setHeader("cache-control", "no-store");
+ const reader = deps.reader?.(auth) ?? TEAM_READER;
+ const readable = (id: string) => deps.secrets.listSecrets(reader).some((secret) => secret.id === id);
if (path === "/api/vault") {
if (method !== "GET") return json(res, 405, { error: "method not allowed" });
- return json(res, 200, { logins: [...deps.logins.list(), ...deps.logins.onePassword.list()], secrets: [...deps.secrets.listSecrets(), ...(deps.linked?.() ?? [])], onePassword: deps.logins.onePassword.status() });
+ if (!reader.team) return json(res, 200, { logins: [], secrets: deps.secrets.listSecrets(reader), onePassword: { connected: false } });
+ return json(res, 200, { logins: [...deps.logins.list(), ...deps.logins.onePassword.list()], secrets: [...deps.secrets.listSecrets(reader), ...(deps.linked?.() ?? [])], onePassword: deps.logins.onePassword.status() });
}
if (path !== SECRETS && !path.startsWith(`${SECRETS}/`)) return json(res, 404, { error: "not found" });
+ if (!reader.team && method !== "DELETE") return json(res, 403, { error: "Only an admin can add or change a secret in the Vault." });
// JSON only, so a form posted from another local page cannot add or change one.
if (method !== "GET" && method !== "DELETE" && !isJson(req)) return json(res, 415, { error: "content-type must be application/json" });
if (path === SECRETS) {
@@ -62,10 +70,11 @@ export function createVaultRoutes(deps: VaultRouteDeps): RouteHandler {
if (body.id === undefined) return json(res, 201, { secret: deps.secrets.saveSecret({ ...fields, source: "settings" }) });
// A secret arriving from this person's computer keeps that computer's id, so an MCP server's `vault:<id>` still names it.
if (typeof body.id !== "string" || !ID.test(body.id)) return json(res, 400, { error: "send the secret's id" });
- return json(res, 201, { secret: deps.secrets.receiveSecret({ ...fields, id: body.id, source: body.source === "card" ? "card" : "settings", ...(body.refOnly === true ? { refOnly: true } : {}) }) });
+ const received = deps.secrets.receiveSecret({ ...fields, id: body.id, source: body.source === "card" ? "card" : "settings", ...(body.refOnly === true ? { refOnly: true } : {}) });
+ return received ? json(res, 201, { secret: received }) : json(res, 404, { error: "no such secret" });
}
const id = path.slice(`${SECRETS}/`.length);
- if (!ID.test(id)) return json(res, 404, { error: "no such secret" });
+ if (!ID.test(id) || !readable(id)) return json(res, 404, { error: "no such secret" });
if (method === "DELETE") {
if (!deps.secrets.removeSecret(id)) return json(res, 404, { error: "no such secret" });
const keysOff = deps.keys?.usedBy(id) ?? [];
diff --git a/server/vault-store.test.ts b/server/vault-store.test.ts
index b538106142..da7a5d58c8 100644
--- a/server/vault-store.test.ts
+++ b/server/vault-store.test.ts
@@ -7,7 +7,7 @@ import { z } from "zod";
import { loginPlace } from "../shared/logins.ts";
import { addHeldSecretScrubber, redactSecretsInText } from "../shared/redact.ts";
import { decryptBrowserState, encryptBrowserState } from "./browser-sites.ts";
-import { HeldSecrets, LOGINS_FILE, LOGINS_KEY_FILE, VaultStore, secretForms } from "./vault-store.ts";
+import { HeldSecrets, LOGINS_FILE, LOGINS_KEY_FILE, MEMBER_SECRETS_FILE, TEAM_READER, VaultStore, secretForms } from "./vault-store.ts";
import { parseTotpKey } from "./totp.ts";
// Obvious fakes only: nothing here is anyone's real login.
@@ -170,8 +170,8 @@ describe("the Vault's saved secrets", () => {
expect(readdirSync(dir).sort()).toEqual([LOGINS_KEY_FILE, LOGINS_FILE].sort());
expect(readFileSync(join(dir, LOGINS_FILE)).includes(Buffer.from(STRIPE))).toBe(false);
const reopened = new VaultStore({ dataDir: dir });
- expect(reopened.listSecrets()).toEqual([saved]);
- expect(JSON.stringify(reopened.listSecrets())).not.toContain(STRIPE);
+ expect(reopened.listSecrets(TEAM_READER)).toEqual([saved]);
+ expect(JSON.stringify(reopened.listSecrets(TEAM_READER))).not.toContain(STRIPE);
const key = readFileSync(join(dir, LOGINS_KEY_FILE), "utf8").trim();
const written = JSON.parse(decryptBrowserState(readFileSync(join(dir, LOGINS_FILE)), key));
expect(written.version).toBe(1);
@@ -193,14 +193,14 @@ describe("the Vault's saved secrets", () => {
it("are found by name for the bots that may use them, one kept to the bot first, and a ref-only one never as a file", () => {
const store = new VaultStore({ dataDir: dir, now: () => 1 });
const shared = store.saveSecret({ name: "Stripe secret key", value: "sk_test_fake-shared", source: "settings", bots: "all" });
- expect(store.usableSecret("stripe-secret-key", "pepper", "file")?.id).toBe(shared.id);
+ expect(store.usableSecret("stripe-secret-key", "pepper", "file", TEAM_READER)?.id).toBe(shared.id);
const own = store.saveSecret({ name: "STRIPE secret key", value: "sk_test_fake-own", source: "card", bots: ["pepper"], refOnly: true });
- expect(store.usableSecret("Stripe secret key", "pepper", "ref")?.id).toBe(own.id);
- expect(store.usableSecret("Stripe secret key", "pepper", "file")?.id).toBe(shared.id);
- expect(store.usableSecret("Stripe secret key", "quill", "ref")?.id).toBe(shared.id);
+ expect(store.usableSecret("Stripe secret key", "pepper", "ref", TEAM_READER)?.id).toBe(own.id);
+ expect(store.usableSecret("Stripe secret key", "pepper", "file", TEAM_READER)?.id).toBe(shared.id);
+ expect(store.usableSecret("Stripe secret key", "quill", "ref", TEAM_READER)?.id).toBe(shared.id);
store.removeSecret(shared.id);
- expect(store.usableSecret("Stripe secret key", "quill", "ref")).toBeNull();
- expect(store.usableSecret("Stripe publishable key", "pepper", "ref")).toBeNull();
+ expect(store.usableSecret("Stripe secret key", "quill", "ref", TEAM_READER)).toBeNull();
+ expect(store.usableSecret("Stripe publishable key", "pepper", "ref", TEAM_READER)).toBeNull();
});
it("saving one name again for the same bots replaces its value; for other bots it is another secret", () => {
@@ -211,12 +211,77 @@ describe("the Vault's saved secrets", () => {
expect(again.refOnly).toBeUndefined();
expect(store.secretValues()).toEqual(["ntn_fake-two"]);
expect(store.saveSecret({ name: "Notion key", value: "ntn_fake-three", source: "card", bots: ["quill"] }).id).not.toBe(first.id);
- expect(store.listSecrets()).toHaveLength(2);
+ expect(store.listSecrets(TEAM_READER)).toHaveLength(2);
expect(store.updateSecret("missing", { name: "x" })).toBeNull();
expect(store.removeSecret("missing")).toBe(false);
});
});
+describe("a Team Cloud member's own secrets", () => {
+ const ADA = "p_ada0000000000000000000", BEN = "p_ben0000000000000000000";
+ const own = (store: VaultStore, person = ADA, name = "Stripe secret key") =>
+ store.saveSecret({ name, value: `sk_test_fake-${person}`, source: "card", bots: ["pepper"], refOnly: true, person });
+
+ it("are sealed in a file of their own, which the previous release never opens, and read back as theirs", () => {
+ const store = new VaultStore({ dataDir: dir, now: () => 9 });
+ store.saveSecret({ name: "Team key", value: "fake-team-value", source: "settings", bots: "all" });
+ const saved = own(store);
+ expect(saved).toEqual({ id: saved.id, name: "Stripe secret key", source: "card", bots: ["pepper"], refOnly: true, createdAt: 9, updatedAt: 9 });
+ expect(readdirSync(dir).sort()).toEqual([LOGINS_KEY_FILE, LOGINS_FILE, MEMBER_SECRETS_FILE].sort());
+ const key = readFileSync(join(dir, LOGINS_KEY_FILE), "utf8").trim();
+ expect(JSON.parse(decryptBrowserState(readFileSync(join(dir, LOGINS_FILE)), key)).secrets.map((one: { name: string }) => one.name)).toEqual(["Team key"]);
+ for (const word of ["sk_test_fake", ADA, "Stripe"]) expect(readFileSync(join(dir, MEMBER_SECRETS_FILE)).includes(Buffer.from(word)), word).toBe(false);
+ if (process.platform !== "win32") expect(statSync(join(dir, MEMBER_SECRETS_FILE)).mode & 0o777).toBe(0o600);
+ const reopened = new VaultStore({ dataDir: dir });
+ expect(reopened.listSecrets({ person: ADA, team: false })).toEqual([saved]);
+ expect(reopened.secret(saved.id)).toMatchObject({ person: ADA, value: `sk_test_fake-${ADA}` });
+ expect(reopened.secretValues()).toContain(`sk_test_fake-${ADA}`);
+ });
+
+ it("reach only turns and views of that person: not another member's, not the team's, not an admin's list", () => {
+ const store = new VaultStore({ dataDir: dir });
+ const team = store.saveSecret({ name: "Notion key", value: "fake-notion", source: "settings", bots: "all" });
+ const ada = own(store);
+ expect(store.usableSecret("Stripe secret key", "pepper", "ref", { person: ADA, team: true })?.id).toBe(ada.id);
+ for (const reader of [{ person: BEN, team: true }, TEAM_READER, { person: null, team: false }]) {
+ expect(store.usableSecret("Stripe secret key", "pepper", "ref", reader), JSON.stringify(reader)).toBeNull();
+ expect(store.secretNamesFor("pepper", reader).map((one) => one.name), JSON.stringify(reader)).toEqual(reader.team ? ["Notion key"] : []);
+ }
+ expect(store.secretNamesFor("pepper", { person: ADA, team: true }).map((one) => one.name).sort()).toEqual(["Notion key", "Stripe secret key"]);
+ expect(store.listSecrets(TEAM_READER).map((one) => one.id)).toEqual([team.id]);
+ expect(store.listSecrets({ person: BEN, team: true }).map((one) => one.id)).toEqual([team.id]);
+ expect(store.listSecrets({ person: BEN, team: false })).toEqual([]);
+ expect(store.listSecrets({ person: ADA, team: false }).map((one) => one.id)).toEqual([ada.id]);
+ });
+
+ it("are another secret than the team's or another member's of the same name, and are never replaced from elsewhere", () => {
+ const store = new VaultStore({ dataDir: dir });
+ const team = store.saveSecret({ name: "Stripe secret key", value: "fake-team", source: "card", bots: ["pepper"], refOnly: true });
+ const ada = own(store);
+ const ben = own(store, BEN);
+ expect(new Set([team.id, ada.id, ben.id]).size).toBe(3);
+ expect(own(store).id, "saved again by her, it replaces hers").toBe(ada.id);
+ expect(store.secret(team.id)?.value).toBe("fake-team");
+ expect(store.receiveSecret({ id: ada.id, name: "Stripe secret key", value: "fake-moved", source: "settings", bots: "all" })).toBeNull();
+ expect(store.secret(ada.id)).toMatchObject({ value: `sk_test_fake-${ADA}`, person: ADA });
+ });
+
+ it("go when the person leaves, and only theirs", () => {
+ const changed: string[] = [];
+ const store = new VaultStore({ dataDir: dir, secretChanged: (id) => changed.push(id) });
+ const team = store.saveSecret({ name: "Team key", value: "fake-team-value", source: "settings", bots: "all" });
+ const ada = [own(store), own(store, ADA, "GitHub token")];
+ const ben = own(store, BEN);
+ expect(store.forgetPerson(ADA)).toBe(2);
+ expect(changed.sort()).toEqual(ada.map((one) => one.id).sort());
+ expect(store.forgetPerson(ADA)).toBe(0);
+ const reopened = new VaultStore({ dataDir: dir });
+ expect(reopened.listSecrets({ person: ADA, team: true }).map((one) => one.id)).toEqual([team.id]);
+ expect(reopened.listSecrets({ person: BEN, team: false }).map((one) => one.id)).toEqual([ben.id]);
+ expect(reopened.secretValues()).not.toContain(`sk_test_fake-${ADA}`);
+ });
+});
+
describe("what saved secrets go with", () => {
it("a deleted bot leaves every secret kept to it, and a secret kept only to it goes with it", () => {
const changed: string[] = [];
@@ -237,7 +302,7 @@ describe("what saved secrets go with", () => {
expect(store.receiveSecret({ id, name: "Stripe", value: "fake-first", source: "card", bots: ["ada"], refOnly: true })).toMatchObject({ id, refOnly: true, source: "card", bots: ["ada"] });
expect(store.secret(id)?.value).toBe("fake-first");
store.receiveSecret({ id, name: "Stripe key", value: "fake-second", source: "settings", bots: "all" });
- expect(store.listSecrets()).toHaveLength(1);
+ expect(store.listSecrets(TEAM_READER)).toHaveLength(1);
expect(store.secret(id)).toMatchObject({ name: "Stripe key", value: "fake-second", bots: "all" });
expect(store.secret(id)?.refOnly).toBeUndefined();
});
diff --git a/server/vault-store.ts b/server/vault-store.ts
index 9fcd242fdc..c8af7394c1 100644
--- a/server/vault-store.ts
+++ b/server/vault-store.ts
@@ -1,5 +1,5 @@
// The Vault: saved logins and saved secrets. Sealed under a key of its own (a 0600 file beside it), never the browser
-// engine's, which every browser process gets in its environment. Neither file is ever backed up, exported or moved: a
+// engine's, which every browser process gets in its environment. None of its files is ever backed up, exported or moved: a
// saved value stays on its computer, unless the person sends it to their own Cloud with Also use on My Cloud
// (login-handoff.ts).
import { randomBytes, randomUUID } from "node:crypto";
@@ -16,6 +16,9 @@ import type { TotpKey } from "./totp.ts";
export const LOGINS_FILE = "logins.json.enc";
export const LOGINS_KEY_FILE = "logins-key";
+/** A Team Cloud member's own secrets, sealed under the same key. A file of their own, so the previous release, which
+ * would read them as the team's, never opens it. */
+export const MEMBER_SECRETS_FILE = "member-secrets.json.enc";
const totpSchema = z.object({
secret: z.string().regex(/^[A-Z2-7]{16,}$/u),
@@ -69,14 +72,34 @@ const fileSchema = z.object({
mcpKeys: z.record(z.string(), z.array(z.string().min(1))).optional(),
});
+const memberSecretsSchema = z.object({
+ version: z.literal(1),
+ secrets: z.array(diskSecretSchema.extend({ person: z.string().regex(/^p_[\w-]{22}$/u) })),
+});
+
type DiskLogin = z.infer<typeof diskLoginSchema>;
type DiskFile = z.infer<typeof fileSchema>;
/** One saved login with its secrets. Server-only: no route returns this. */
export type StoredLogin = Omit<DiskLogin, "host" | "site" | "hosts" | "exactHost"> & LoginPlace;
-type StoreFile = Omit<DiskFile, "logins"> & { logins: StoredLogin[] };
-/** One saved secret with its value. Server-only: no route returns this. */
-export type StoredSecret = z.infer<typeof diskSecretSchema>;
+type StoreFile = Omit<DiskFile, "logins" | "secrets"> & { logins: StoredLogin[]; secrets?: StoredSecret[] };
+/** One saved secret with its value. Server-only: no route returns this. `person`: a Team Cloud member's own, typed
+ * into a card in their private chat; absent: the team's (every secret off a Team Cloud). */
+export type StoredSecret = z.infer<typeof diskSecretSchema> & { person?: string };
+
+/** Who reads the Vault: `person`'s own secrets, and the team's when `team`. */
+export interface VaultReader {
+ person: string | null;
+ team: boolean;
+}
+
+/** A turn off a Team Cloud, or in a conversation that is no one person's own, and an admin's view with no person. */
+export const TEAM_READER: VaultReader = { person: null, team: true };
+
+/** Security: a member's own secret reaches only their own turns and their own Settings, never an admin's. */
+export function secretReadable(secret: { person?: string }, reader: VaultReader): boolean {
+ return secret.person ? secret.person === reader.person : reader.team;
+}
export interface NewSecret {
name: string;
@@ -84,6 +107,7 @@ export interface NewSecret {
source: "card" | "settings";
bots: LoginBots;
refOnly?: boolean;
+ person?: string;
}
export interface SecretPatch {
@@ -127,7 +151,7 @@ export function summarizeLogin(login: StoredLogin): LoginSummary {
};
}
-export function summarizeSecret({ value: _value, ...secret }: StoredSecret): VaultSecret {
+export function summarizeSecret({ value: _value, person: _person, ...secret }: StoredSecret): VaultSecret {
return secret;
}
@@ -144,6 +168,7 @@ function sameAccount(login: StoredLogin, input: NewLogin): boolean {
export class VaultStore {
private readonly file: string;
+ private readonly memberFile: string;
private readonly keyFile: string;
private readonly now: () => number;
private readonly secretChanged: (id: string) => void;
@@ -154,6 +179,7 @@ export class VaultStore {
/** `secretChanged`: a saved secret's value or who may use it changed, or it is gone. */
constructor(options: { dataDir: string; now?: () => number; secretChanged?: (id: string) => void }) {
this.file = join(options.dataDir, LOGINS_FILE);
+ this.memberFile = join(options.dataDir, MEMBER_SECRETS_FILE);
this.keyFile = join(options.dataDir, LOGINS_KEY_FILE);
this.now = options.now ?? Date.now;
this.secretChanged = options.secretChanged ?? (() => {});
@@ -188,17 +214,36 @@ export class VaultStore {
data = EMPTY;
}
}
+ const members = this.readMembers();
+ if (members.length) data = { ...data, secrets: [...data.secrets ?? [], ...members] };
this.cache = data;
this.version++;
return data;
}
+ private readMembers(): StoredSecret[] {
+ if (!existsSync(this.memberFile)) return [];
+ try {
+ const key = this.key(false);
+ if (!key) throw new Error("missing key");
+ return memberSecretsSchema.parse(JSON.parse(decryptBrowserState(readFileSync(this.memberFile), key))).secrets;
+ } catch {
+ if (!this.unreadableWarned) console.warn("saved logins: the members' secrets file could not be opened; it will be replaced on the next save");
+ this.unreadableWarned = true;
+ return [];
+ }
+ }
+
private write(data: StoreFile): void {
- const parsed = fileSchema.parse({ ...data, logins: data.logins.map(toDisk) });
+ const members = (data.secrets ?? []).filter((secret) => secret.person);
+ const team = data.secrets?.filter((secret) => !secret.person);
+ const parsed = fileSchema.parse({ ...data, logins: data.logins.map(toDisk), ...(team ? { secrets: team } : {}) });
+ const ownParsed = memberSecretsSchema.parse({ version: 1, secrets: members });
const key = this.key(true)!;
mkdirSync(join(this.file, ".."), { recursive: true });
writeFileAtomic(this.file, encryptBrowserState(JSON.stringify(parsed), key), { mode: 0o600 });
- this.cache = { ...parsed, logins: parsed.logins.map(fromDisk) };
+ if (members.length || existsSync(this.memberFile)) writeFileAtomic(this.memberFile, encryptBrowserState(JSON.stringify(ownParsed), key), { mode: 0o600 });
+ this.cache = { ...parsed, logins: parsed.logins.map(fromDisk), ...(ownParsed.secrets.length ? { secrets: [...parsed.secrets ?? [], ...ownParsed.secrets] } : {}) };
this.version++;
}
@@ -294,29 +339,30 @@ export class VaultStore {
return this.read().secrets?.find((secret) => secret.id === id) ?? null;
}
- listSecrets(): VaultSecret[] {
- return (this.read().secrets ?? []).map(summarizeSecret).sort((a, b) => a.name.localeCompare(b.name));
+ listSecrets(reader: VaultReader): VaultSecret[] {
+ return (this.read().secrets ?? []).filter((secret) => secretReadable(secret, reader)).map(summarizeSecret).sort((a, b) => a.name.localeCompare(b.name));
}
- /** The secret `botId` may use by this name, as a ref or a file: one kept to some bots before one for every bot, then
- * the newest. */
- usableSecret(name: string, botId: string, delivery: "ref" | "file"): StoredSecret | null {
+ /** The secret `botId` may use by this name, as a ref or a file, in a turn `reader` names: one kept to some bots before
+ * one for every bot, then the newest. */
+ usableSecret(name: string, botId: string, delivery: "ref" | "file", reader: VaultReader): StoredSecret | null {
const key = vaultNameKey(name);
const matches = (this.read().secrets ?? []).filter((secret) => vaultNameKey(secret.name) === key && loginUsableBy(secret, botId) &&
- (delivery === "ref" || !secret.refOnly));
+ secretReadable(secret, reader) && (delivery === "ref" || !secret.refOnly));
return matches.sort((a, b) => Number(b.bots !== "all") - Number(a.bots !== "all") || b.updatedAt - a.updatedAt)[0] ?? null;
}
- secretNamesFor(botId: string): Array<{ name: string; refOnly?: true }> {
- return (this.read().secrets ?? []).filter((secret) => loginUsableBy(secret, botId)).map(({ name, refOnly }) => ({ name, ...(refOnly ? { refOnly } : {}) }));
+ secretNamesFor(botId: string, reader: VaultReader): Array<{ name: string; refOnly?: true }> {
+ return (this.read().secrets ?? []).filter((secret) => loginUsableBy(secret, botId) && secretReadable(secret, reader))
+ .map(({ name, refOnly }) => ({ name, ...(refOnly ? { refOnly } : {}) }));
}
- /** The same name saved again for the same bots replaces its value; otherwise it is a new secret. */
+ /** The same name saved again for the same bots and the same person replaces its value; otherwise it is a new secret. */
saveSecret(input: NewSecret): VaultSecret {
const data = this.read();
const secrets = data.secrets ?? [];
const at = this.now();
- const same = secrets.find((secret) => vaultNameKey(secret.name) === vaultNameKey(input.name) && sameBots(secret.bots, input.bots));
+ const same = secrets.find((secret) => vaultNameKey(secret.name) === vaultNameKey(input.name) && sameBots(secret.bots, input.bots) && secret.person === input.person);
if (same) {
const { refOnly: _refOnly, ...rest } = same;
const updated: StoredSecret = { ...rest, value: input.value, updatedAt: at, ...(input.refOnly ? { refOnly: true } : {}) };
@@ -326,18 +372,20 @@ export class VaultStore {
}
const secret: StoredSecret = {
id: randomUUID(), name: input.name, value: input.value, source: input.source, bots: input.bots, ...(input.refOnly ? { refOnly: true } : {}), createdAt: at, updatedAt: at,
+ ...(input.person ? { person: input.person } : {}),
};
this.write({ ...data, secrets: [...secrets, secret] });
return summarizeSecret(secret);
}
/** A secret arriving from this person's other computer, under the id it has there: an MCP server's `vault:<id>` moves
- * with it. Sent again, it replaces the one it came from. */
- receiveSecret(input: NewSecret & { id: string }): VaultSecret {
+ * with it. Sent again, it replaces the one it came from; never a member's own (null). */
+ receiveSecret(input: Omit<NewSecret, "person"> & { id: string }): VaultSecret | null {
const data = this.read();
const secrets = data.secrets ?? [];
const at = this.now();
const current = secrets.find((secret) => secret.id === input.id);
+ if (current?.person) return null;
const received: StoredSecret = {
id: input.id, name: input.name, value: input.value, source: input.source, bots: input.bots, ...(input.refOnly ? { refOnly: true } : {}),
createdAt: current?.createdAt ?? at, updatedAt: at, ...(current?.lastUsedAt === undefined ? {} : { lastUsedAt: current.lastUsedAt }),
@@ -371,6 +419,16 @@ export class VaultStore {
return true;
}
+ /** A member who left the team: every secret of their own goes. */
+ forgetPerson(person: string): number {
+ const data = this.read();
+ const gone = (data.secrets ?? []).filter((secret) => secret.person === person).map((secret) => secret.id);
+ if (!gone.length) return 0;
+ this.write({ ...data, secrets: data.secrets!.filter((secret) => secret.person !== person) });
+ for (const id of gone) this.secretChanged(id);
+ return gone.length;
+ }
+
/** A deleted bot leaves every secret kept to it; a secret kept only to it goes with it. */
forgetBot(botId: string): void {
const data = this.read();
diff --git a/server/vault/mcp-keys.test.ts b/server/vault/mcp-keys.test.ts
index 0450e8fc58..c5dd6be87a 100644
--- a/server/vault/mcp-keys.test.ts
+++ b/server/vault/mcp-keys.test.ts
@@ -35,6 +35,14 @@ describe("a Vault key behind a vault: pointer in an MCP server", () => {
}
});
+ it("never reads a Team Cloud member's own secret, for any bot or for a test", () => {
+ const { store, keys } = setup();
+ const own = store.saveSecret({ name: "Ada's Stripe key", value: "sk_test_fake-ada-own", source: "card", bots: ["ledger"], person: "p_ada0000000000000000000" });
+ store.grantMcpKeys("stripe", [own.id]);
+ const server = stdio({ STRIPE_KEY: vaultPointer(own.id) });
+ for (const bot of ["ledger", undefined]) expect(keys.resolve("stripe", server, bot), String(bot)).toMatchObject({ ok: false, reason: "removed" });
+ });
+
it("reads the value where the server is started, for a bot the item lets use it", () => {
const { keys, pointer } = setup();
const server = stdio({ STRIPE_KEY: pointer, OTHER: "kept" });
diff --git a/server/vault/mcp-keys.ts b/server/vault/mcp-keys.ts
index f3ebe86083..6634723acf 100644
--- a/server/vault/mcp-keys.ts
+++ b/server/vault/mcp-keys.ts
@@ -61,7 +61,8 @@ export function createMcpKeys(deps: McpKeysDeps) {
return kept && now() - kept.at < LINKED_KEPT_MS ? kept.value : UNREAD;
}
const secret = deps.store.secret(item);
- if (!secret) return REMOVED;
+ // Security: an MCP server serves the whole team, so a member's own secret is never its key.
+ if (!secret || secret.person) return REMOVED;
if (botId !== undefined && !loginUsableBy(secret, botId)) return KEPT;
if (botId !== undefined && now() - (lastMarked.get(item) ?? 0) >= MARK_USED_MS) { lastMarked.set(item, now()); deps.store.markUsed(item); }
return secret.value;
diff --git a/server/workspace-backup-policy.test.ts b/server/workspace-backup-policy.test.ts
index b93b32e261..1ce33ba30f 100644
--- a/server/workspace-backup-policy.test.ts
+++ b/server/workspace-backup-policy.test.ts
@@ -55,7 +55,7 @@ describe("workspace backup data boundary", () => {
});
it("never exports or restores saved website logins or their key, or the key sealing webhook secrets", () => {
- for (const path of ["logins.json.enc", "logins-key", "logins.json.enc.4242.05a7b3e0-1234-4abc-8def-0123456789ab.tmp", "logins-key.12.05a7b3e0-1234.tmp", "webhook-key", "webhook-key.12.05a7b3e0-1234.tmp"]) {
+ for (const path of ["logins.json.enc", "member-secrets.json.enc", "member-secrets.json.enc.4242.05a7b3e0-1234-4abc-8def-0123456789ab.tmp", "logins-key", "logins.json.enc.4242.05a7b3e0-1234-4abc-8def-0123456789ab.tmp", "logins-key.12.05a7b3e0-1234.tmp", "webhook-key", "webhook-key.12.05a7b3e0-1234.tmp"]) {
expect(excludedWorkspaceAuthPath(path)).toBe(true);
}
for (const path of ["logins.json", "logins.md", "workspaces/bot/logins.json.enc", "attachments/logins-key"]) expect(excludedWorkspaceAuthPath(path)).toBe(false);
diff --git a/server/workspace-backup-policy.ts b/server/workspace-backup-policy.ts
index 84aeda5570..8f8f61d8f9 100644
--- a/server/workspace-backup-policy.ts
+++ b/server/workspace-backup-policy.ts
@@ -39,7 +39,7 @@ export function excludedWorkspaceAuthPath(path: string): boolean {
if (/^command-allowlist\.json(?:$|\.\d+\.[0-9a-f-]+\.tmp$)/.test(path)) return true;
if (/^mcp-oauth\.json(?:$|\.\d+\.[0-9a-f-]+\.tmp$)/.test(path)) return true;
// Saved website logins and their key never leave the computer they were saved on, nor does the key sealing webhook secrets.
- if (/^(?:logins\.json\.enc|logins-key|webhook-key)(?:$|\.\d+\.[0-9a-f-]+\.tmp$)/.test(path)) return true;
+ if (/^(?:logins\.json\.enc|member-secrets\.json\.enc|logins-key|webhook-key)(?:$|\.\d+\.[0-9a-f-]+\.tmp$)/.test(path)) return true;
// A Cloud home's connected-apps installation: its connected accounts belong to it, so a copy would share them.
if (/^connected-apps-installation\.json(?:$|\.\d+\.[0-9a-f-]+\.tmp$)/.test(path)) return true;
// A Team Cloud's kept rules: a restored Cloud asks the Admin for the ones in force now.
diff --git a/src/components/VaultSettings.test.ts b/src/components/VaultSettings.test.ts
index 9afb7149f6..d47a828580 100644
--- a/src/components/VaultSettings.test.ts
+++ b/src/components/VaultSettings.test.ts
@@ -3,7 +3,7 @@ import { act, createElement } from "react";
import { createRoot, type Root } from "react-dom/client";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
-const fixture = vi.hoisted(() => ({ api: vi.fn(), dispatch: vi.fn(), admin: true as boolean | null, config: null as { cloudHome?: boolean } | null }));
+const fixture = vi.hoisted(() => ({ api: vi.fn(), dispatch: vi.fn(), admin: true as boolean | null, config: null as { cloudHome?: boolean; team?: { id: string; name: string } } | null }));
vi.mock("@/state/store", async (importOriginal) => ({
...await importOriginal<typeof import("@/state/store")>(),
api: fixture.api,
@@ -197,6 +197,23 @@ describe("Settings → Vault: logins", () => {
expect(fixture.api).not.toHaveBeenCalled();
expect(host.textContent).toContain("Only an admin of this installation can see and change the Vault.");
});
+
+ it("shows a Team Cloud member only the secrets they gave bots in their own chats, which they can delete and nothing more", async () => {
+ fixture.admin = false;
+ fixture.config = { team: { id: "acme", name: "Acme" } };
+ const own = { id: "s9", name: "Stripe secret key", source: "card", bots: ["pepper"], createdAt: 1, updatedAt: 1 };
+ fixture.api.mockResolvedValueOnce({ logins: [], secrets: [own], onePassword: OFF }).mockResolvedValueOnce({ ok: true }).mockResolvedValueOnce({ logins: [], secrets: [], onePassword: OFF });
+ await render();
+ expect(fixture.api).toHaveBeenCalledWith("/api/vault");
+ expect(host.textContent).toContain("Only you can use them, in your own chats with that bot");
+ expect([...host.querySelectorAll("[data-secret-row]")].map((row) => row.textContent)).toEqual([expect.stringContaining("Saved from a chat · Pepper")]);
+ for (const absent of ["Add", "Change Stripe secret key"]) expect(button(absent), absent).toBeUndefined();
+ for (const selector of ["[data-onepassword]", "[data-vault-keys]", "[data-vault-filter]"]) expect(host.querySelector(selector), selector).toBeNull();
+ await click("Delete Stripe secret key");
+ await click("Delete for good");
+ expect(fixture.api).toHaveBeenNthCalledWith(2, "/api/vault/secrets/s9", { method: "DELETE" });
+ expect(host.textContent).toContain("A key you type into a bot's card in your own chat shows here.");
+ });
});
describe("Settings → Vault: keys and secrets", () => {
diff --git a/src/components/VaultSettings.tsx b/src/components/VaultSettings.tsx
index f9456e069c..08c9aa132c 100644
--- a/src/components/VaultSettings.tsx
+++ b/src/components/VaultSettings.tsx
@@ -43,6 +43,7 @@ function rowsOf(logins: LoginSummary[], secrets: Array<VaultSecret | LinkedSecre
export function VaultSettings() {
const { state, dispatch } = useStore();
const ownerOrAdmin = useOwnerOrAdmin();
+ const member = ownerOrAdmin === false && Boolean(state.config?.team);
const bots = state.bots.map((bot) => ({ id: bot.id, name: bot.name }));
const [logins, setLogins] = useState<LoginSummary[] | null>(null);
const [secrets, setSecrets] = useState<Array<VaultSecret | LinkedSecret>>([]);
@@ -73,9 +74,9 @@ export function VaultSettings() {
}
catch (cause) { setError(cause instanceof Error && cause.message ? cause.message : t("settings.vault.loadError")); }
};
- useEffect(() => { if (ownerOrAdmin) void load(); }, [ownerOrAdmin]);
+ useEffect(() => { if (ownerOrAdmin || member) void load(); }, [ownerOrAdmin, member]);
- if (ownerOrAdmin === false) {
+ if (ownerOrAdmin === false && !member) {
return <Card title={t("settings.vault.title")} subtitle={t("settings.vault.adminOnly")} />;
}
@@ -113,8 +114,8 @@ export function VaultSettings() {
};
const rowButtons = (id: string, kind: "login" | "secret", name: string, onChange: () => void) => (
<div className="flex shrink-0 gap-1">
- <button type="button" className={ROW_BUTTON} disabled={busy} onClick={onChange}
- aria-label={kind === "login" ? t("settings.logins.changeFor", { site: name }) : t("settings.vault.secret.changeFor", { name })}>{t("settings.logins.change")}</button>
+ {!member && <button type="button" className={ROW_BUTTON} disabled={busy} onClick={onChange}
+ aria-label={kind === "login" ? t("settings.logins.changeFor", { site: name }) : t("settings.vault.secret.changeFor", { name })}>{t("settings.logins.change")}</button>}
<button type="button" className={ROW_BUTTON} disabled={busy} onClick={() => void remove(id, kind)}
aria-label={deleting === id ? t("settings.logins.deleteConfirm") : kind === "login" ? t("settings.logins.deleteFor", { site: name }) : t("settings.vault.secret.deleteFor", { name })}>
<Trash2 size={13} />{deleting === id ? t("settings.logins.deleteConfirm") : t("settings.logins.delete")}
@@ -195,9 +196,9 @@ export function VaultSettings() {
);
return (
- <Card title={t("settings.vault.title")} subtitle={t("settings.vault.subtitle")}>
+ <Card title={t("settings.vault.title")} subtitle={t(member ? "settings.vault.memberSubtitle" : "settings.vault.subtitle")}>
<div className="flex flex-col gap-3" aria-busy={logins === null || busy} data-vault>
- {state.config?.cloudHome === true && <p className="text-[12px] leading-relaxed text-ink-secondary" data-logins-cloud-own>{t("settings.logins.cloudOwn")}</p>}
+ {state.config?.cloudHome === true && !member && <p className="text-[12px] leading-relaxed text-ink-secondary" data-logins-cloud-own>{t("settings.logins.cloudOwn")}</p>}
<div className="flex flex-wrap items-center gap-2">
<div className="flex h-8 min-w-[12rem] flex-1 items-center gap-2 rounded-lg bg-ink/[0.05] px-[9px] focus-within:ring-2 focus-within:ring-focus/60">
<Search size={15} aria-hidden="true" className="shrink-0 text-ink-secondary" />
@@ -205,7 +206,7 @@ export function VaultSettings() {
placeholder={t("settings.vault.search")} aria-label={t("settings.vault.search")}
className="w-full min-w-0 bg-transparent text-[13px] text-ink placeholder:text-ink-secondary focus:outline-none" />
</div>
- <div className="relative">
+ {!member && <div className="relative">
<button type="button" className="ui-button ui-button-md" disabled={logins === null} aria-expanded={menu} onClick={() => setMenu(!menu)}
onKeyDown={(event) => { if (event.key === "Escape") setMenu(false); }}>
<Plus size={14} />{t("settings.vault.add")}<ChevronDown size={13} aria-hidden="true" />
@@ -217,10 +218,10 @@ export function VaultSettings() {
))}
</div>
)}
- </div>
+ </div>}
</div>
- <Segmented label={t("settings.vault.filter")} attr="data-vault-filter" value={filter} onChange={setFilter}
- options={[{ value: "all", label: t("settings.vault.filter.all") }, { value: "logins", label: t("settings.vault.filter.logins") }, { value: "secrets", label: t("settings.vault.filter.secrets") }]} />
+ {!member && <Segmented label={t("settings.vault.filter")} attr="data-vault-filter" value={filter} onChange={setFilter}
+ options={[{ value: "all", label: t("settings.vault.filter.all") }, { value: "logins", label: t("settings.vault.filter.logins") }, { value: "secrets", label: t("settings.vault.filter.secrets") }]} />}
{adding === "login" && (
<div className="rounded-lg bg-inset/60 p-3">
<LoginForm site={{ value: site, onChange: setSite }} submitLabel={t("settings.logins.save")} autoFocus
@@ -249,16 +250,17 @@ export function VaultSettings() {
</div>
)}
{logins === null && !error && <p className="text-[12px] text-ink-secondary">{t("settings.vault.loading")}</p>}
- {empty && !adding && <p className="text-[12px] leading-relaxed text-ink-secondary">{t("settings.vault.empty")}</p>}
+ {empty && !adding && <p className="text-[12px] leading-relaxed text-ink-secondary">{t(member ? "settings.vault.memberEmpty" : "settings.vault.empty")}</p>}
{!empty && logins !== null && rows.length === 0 && <p className="text-[12px] text-ink-secondary" data-vault-none>{t("settings.vault.noMatch")}</p>}
{rows.length > 0 && (
<ul className="divide-y divide-hairline/30" data-logins-list>
{rows.map((row) => row.kind === "login" ? loginRow(row.login) : secretRow(row.secret))}
</ul>
)}
- <p className="text-[12px] leading-relaxed text-ink-tertiary">{t("settings.logins.limits")}</p>
+ {!member && <p className="text-[12px] leading-relaxed text-ink-tertiary">{t("settings.logins.limits")}</p>}
{keysOff.length > 0 && <p role="status" className="text-[12px] leading-relaxed text-warning" data-vault-keys-off>{t("settings.vault.secret.keyOff", { servers: keysOff.join(", ") })}</p>}
{error && <p role="alert" className="text-[12px] text-danger">{error}</p>}
+ {!member && <>
<div className="flex flex-wrap items-center gap-x-3 gap-y-2 border-t border-hairline/30 pt-3" data-vault-keys>
<div className="min-w-0 flex-1">
<div className="text-[13px] font-medium text-ink">{t("settings.vault.keys.title")}</div>
@@ -270,6 +272,7 @@ export function VaultSettings() {
</div>
<OnePasswordConnection status={onePassword} disabled={logins === null} bots={bots} botNames={botNames}
onChange={async (next) => { setOnePassword(next); await load(); }} />
+ </>}
</div>
</Card>
);
diff --git a/src/locales/en.json b/src/locales/en.json
index ad4b1b10fc..0a85dde933 100644
--- a/src/locales/en.json
+++ b/src/locales/en.json
@@ -3875,6 +3875,8 @@
"settings.vault.title": "Vault",
"settings.vault.subtitle": "Passwords and keys your bots can use. Bots never see them: {app} types a password into the login page for a bot, and gives a key to its tools without showing it.",
"settings.vault.adminOnly": "Only an admin of this installation can see and change the Vault.",
+ "settings.vault.memberSubtitle": "Keys you gave a bot in your own chats. Only you can use them, in your own chats with that bot: no teammate and no admin sees them.",
+ "settings.vault.memberEmpty": "Nothing saved yet. A key you type into a bot's card in your own chat shows here.",
"settings.vault.loading": "Loading the Vault…",
"settings.vault.loadError": "Could not load the Vault.",
"settings.vault.empty": "Nothing saved yet. Add a login or a secret here, or save one when a bot asks for it.",
diff --git a/src/locales/pt-br.json b/src/locales/pt-br.json
index b7530ef2f6..68ccb04675 100644
--- a/src/locales/pt-br.json
+++ b/src/locales/pt-br.json
@@ -3698,6 +3698,8 @@
"settings.vault.title": "Cofre",
"settings.vault.subtitle": "Senhas e chaves que seus bots podem usar. Os bots nunca as veem: o app {app} digita a senha na página de login pelo bot e entrega a chave às ferramentas dele sem mostrá-la.",
"settings.vault.adminOnly": "Só um admin desta instalação pode ver e alterar o Cofre.",
+ "settings.vault.memberSubtitle": "Chaves que você deu a um bot nos seus próprios chats. Só você pode usá-las, nos seus chats com esse bot: nenhum colega e nenhum admin as vê.",
+ "settings.vault.memberEmpty": "Nada salvo ainda. Uma chave que você digitar no cartão de um bot no seu próprio chat aparece aqui.",
"settings.vault.loading": "Carregando o Cofre…",
"settings.vault.loadError": "Não foi possível carregar o Cofre.",
"settings.vault.empty": "Nada salvo ainda. Adicione um login ou um segredo aqui, ou salve um quando um bot pedir.",
diff --git a/src/locales/source-hashes.json b/src/locales/source-hashes.json
index e60495c958..2091906f67 100644
--- a/src/locales/source-hashes.json
+++ b/src/locales/source-hashes.json
@@ -33687,6 +33687,8 @@
"settings.vault.title": "5d55c415e356dd7b59f329aa5c83a34ee10c3803516ac569fde5e68804a7e06c",
"settings.vault.subtitle": "bf4c7aa113cfea45e0476ae1c37bb38cbcddfc19a0251d83add7f3fbb871a29e",
"settings.vault.adminOnly": "7af6e368ff2acf55789041492750d831d7ffb3a2f7e0f01b273385fd1a398610",
+ "settings.vault.memberSubtitle": "8c168e2b50487ce44bff1e44b06f7a74771650ed20eaf138ac4540028d8a9fc4",
+ "settings.vault.memberEmpty": "0b981e9a0ad8b4a2bf317822c9b1e4df265ff0ad73a1e53c8486009e1b7253af",
"settings.vault.loading": "5e8596af8bfdd823c815d5655d0f7dffdf72bc94a881d3eaa708c79c06fe2ac9",
"settings.vault.loadError": "0e106906a32d54500fe7431bb3554d41f431f4d433fa99e656dbc63907dd65d6",
"settings.vault.empty": "e7e59d4d82d03af6f8595fffff2823815ffafa56b6b0746e7297cf977a60d35c",