Skip to content

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

Vault: linked password managers behind one provider interface; 1Password secrets; secret names in the bot's prompt (#5008)

Milind Soni6c7bcb02ea76
diff --git a/apps/docs/content/docs/security/permissions-and-secrets.mdx b/apps/docs/content/docs/security/permissions-and-secrets.mdx
index 2029744b17..d46fb1f1cc 100644
--- a/apps/docs/content/docs/security/permissions-and-secrets.mdx
+++ b/apps/docs/content/docs/security/permissions-and-secrets.mdx
@@ -32,7 +32,9 @@ Any other secret (a Stripe or npm token, a webhook signing secret, a Notion key
for an MCP server) the bot names. MausBot saves what you type in its encrypted
vault, beside your saved logins, for that bot only. When the bot asks for a
secret by the same name again, in any conversation, it gets it at once with no
-new card. The card says what the bot may do with it:
+new card. The bot's instructions list the names (never the values) of the
+secrets it may use, so it asks for them by name. The card says what the bot may
+do with it:
- **For MausBot's own tools.** The bot gets a one-use reference instead of the
value. Only `add_mcp_server` accepts it, only for that bot in that
@@ -205,6 +207,17 @@ the vault again; MausBot also does so when its copy of the list is more
than ten minutes old. **Disconnect** forgets the token and everything read
from 1Password.
+API Credential, Password and Secure Note items in those vaults are secrets a bot
+may use, by the item's title: a bot that asks for "Notion token" gets the item
+called Notion token the same way as a secret saved from a card, by one-use
+reference or private file, and with no card. The main value is an API
+Credential's credential, a Password's password or a Secure Note's text; any
+other field is asked for as the title and the field's name, such as "Acme OAuth
+client_secret". The value is read from 1Password at the moment the bot gets it,
+never kept in the Vault, and scrubbed like a filled password. The same vault
+choice of bots applies, and a secret saved in the Vault under the same name
+comes first.
+
1Password's [SDK](https://github.com/1Password/onepassword-sdk-js) (MIT
license) is part of the desktop app, the server image and the `openmausbot`
npm package; it talks to 1Password over the internet, and only once a token
diff --git a/scripts/testing/secret-card-descriptions.test.ts b/scripts/testing/secret-card-descriptions.test.ts
index ea42d9b8ce..a071344511 100644
--- a/scripts/testing/secret-card-descriptions.test.ts
+++ b/scripts/testing/secret-card-descriptions.test.ts
@@ -22,13 +22,13 @@ afterEach(() => {
vi.unstubAllGlobals();
});
-function producedCard(target: CredentialTargetId, reason: string, language?: string): Message {
+async function producedCard(target: CredentialTargetId, reason: string, language?: string): Promise<Message> {
const store = new Store(() => ({ instanceId: "fixture", model: "fixture-model" }));
const bot = store.createBot({ name: "Scout" });
const cards = createSecretCards({
store,
cfg: loadConfig(),
- botLogins: { credentialConfig: (config) => ({ ...config, onePassword: { connected: false } }) },
+ botLogins: { credentialConfig: (config) => ({ ...config, onePassword: { connected: false } }), linkedSecret: async () => null },
vaultStore: new VaultStore({ dataDir: DATA_DIR }),
phoneSecrets: { provide: vi.fn(), open: vi.fn() },
phoneSecretSubmissions: new PhoneSecretSubmissionRegistry(),
@@ -40,7 +40,7 @@ function producedCard(target: CredentialTargetId, reason: string, language?: str
turnVm: () => undefined,
threadLanguage: () => language,
});
- const response = cards.requestCredential(bot, bot.threadId, { credentialId: target, reason });
+ const response = await cards.requestCredential(bot, bot.threadId, { credentialId: target, reason });
expect(response.status).toBe(201);
return store.messagesFor(bot.threadId).find((message) => message.id === response.body.messageId)! as Message;
}
@@ -54,9 +54,9 @@ const localizedTargets = [
] as const;
describe("credential descriptions from the real producer to the renderer", () => {
- it.each(Object.keys(CREDENTIAL_TARGETS) as CredentialTargetId[])("preserves the complete English description for %s", (target) => {
+ it.each(Object.keys(CREDENTIAL_TARGETS) as CredentialTargetId[])("preserves the complete English description for %s", async (target) => {
const reason = "For today's report <draft>.";
- const message = producedCard(target, reason);
+ const message = await producedCard(target, reason);
const description = `${CREDENTIAL_TARGETS[target].description} ${reason} Scout can use it but never read it back.`;
expect(message.secret!.description).toBe(description);
const english = render(message);
@@ -69,9 +69,9 @@ describe("credential descriptions from the real producer to the renderer", () =>
}
});
- it.each(localizedTargets)("keeps the reason and guarantee when localizing %s", (target, base) => {
+ it.each(localizedTargets)("keeps the reason and guarantee when localizing %s", async (target, base) => {
const reason = "For today's report <draft>.";
- const message = producedCard(target, reason);
+ const message = await producedCard(target, reason);
const saved = JSON.stringify(message);
const english = render(message);
setLocale("pt-br");
@@ -81,8 +81,8 @@ describe("credential descriptions from the real producer to the renderer", () =>
expect(render(message)).toBe(english);
});
- it.each(localizedTargets)("uses the received English fallback verbatim for %s", (target) => {
- const message = producedCard(target, "For the requested report.", "pt-br");
+ it.each(localizedTargets)("uses the received English fallback verbatim for %s", async (target) => {
+ const message = await producedCard(target, "For the requested report.", "pt-br");
message.secret!.description += " Additional server context.";
message.secret!.label += " supplied label";
message.secret!.placeholder += " supplied placeholder";
@@ -97,15 +97,15 @@ describe("credential descriptions from the real producer to the renderer", () =>
["greenferenceApiKey", "pt-br"],
["geminiTtsKey", "en"],
["geminiTtsKey", "pt-br"],
- ] as const)("keeps the raw description of an older %s card in %s", (target, locale) => {
- const message = producedCard(target, "For the requested report.");
+ ] as const)("keeps the raw description of an older %s card in %s", async (target, locale) => {
+ const message = await producedCard(target, "For the requested report.");
delete message.secret!.descriptionParts;
setLocale(locale);
expect(render(message)).toContain(escapedText(message.secret!.description));
});
- it.each(localizedTargets)("keeps the guarantee without an optional reason for %s", (target, base) => {
- const message = producedCard(target, "");
+ it.each(localizedTargets)("keeps the guarantee without an optional reason for %s", async (target, base) => {
+ const message = await producedCard(target, "");
setLocale("pt-br");
expect(render(message)).toContain(escapedText(`${base} Scout pode usar o valor, mas nunca consegue lê-lo.`));
});
diff --git a/server/bot-logins.test.ts b/server/bot-logins.test.ts
index 851adffff9..bee052eb1f 100644
--- a/server/bot-logins.test.ts
+++ b/server/bot-logins.test.ts
@@ -56,7 +56,7 @@ describe("a login kept to some bots, and bots that share a browser", () => {
{ id: "payroll", browserProfile: "finance" }, { id: "infra", browserProfile: "finance" }, { id: "notes" }, { id: "audit", browserProfile: null },
{ id: "scout", browserProfile: "guest" }, { id: "visitor", browserProfile: "guest" },
];
- const onePassword = { fresh: async () => {}, sitesFor: () => [], candidates: () => [], markUsed: () => {} } as unknown as OnePasswordLogins;
+ const onePassword = { id: "1password", label: "1Password", fresh: async () => {}, items: () => [], read: async () => ({}), markUsed: () => {} } as unknown as OnePasswordLogins;
const world = () => {
const store = new VaultStore({ dataDir: mkdtempSync(join(tmpdir(), "omb-bot-logins-")) });
const logins = new BotLogins(store, onePassword, () => bots);
@@ -110,3 +110,32 @@ describe("a login kept to some bots, and bots that share a browser", () => {
});
});
+
+describe("the secrets a bot may use", () => {
+ it("are named from the Vault and any linked manager, never by value, and a linked one is read only when asked for", async () => {
+ const reads: string[] = [];
+ const held: string[] = [];
+ const provider = {
+ id: "fake", label: "Fake manager", fresh: async () => {}, markUsed: () => {},
+ items: () => [
+ { kind: "secret", id: "fake:1", name: "Deploy key", fields: ["user"], source: "linked", provider: "fake", bots: "all", readOnly: true },
+ { kind: "secret", id: "fake:2", name: "Payroll token", fields: [], source: "linked", provider: "fake", bots: ["payroll"], readOnly: true },
+ { kind: "login", id: "fake:3", site: "example.com", hosts: ["example.com"], exactHost: false, username: "u", hasTotp: false, source: "1password", bots: "all", createdAt: 0 },
+ ],
+ read: async (id: string, field?: string) => { reads.push(`${id}/${field ?? ""}`); return { value: `value-of-${id}-${field ?? "main"}` }; },
+ };
+ 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" }]);
+ 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([]);
+ const deploy = await logins.linkedSecret("deploy-key-user", "notes");
+ expect(deploy).toMatchObject({ name: "Deploy key user", value: "value-of-fake:1-user" });
+ expect(deploy!.id).toMatch(/^linked-[0-9a-f]{32}$/u);
+ expect(reads).toEqual(["fake:1/user"]);
+ expect(held).toEqual(["value-of-fake:1-user"]);
+ });
+});
diff --git a/server/bot-logins.ts b/server/bot-logins.ts
index c9b25bda27..b74b4801f9 100644
--- a/server/bot-logins.ts
+++ b/server/bot-logins.ts
@@ -1,9 +1,13 @@
+import { createHash } from "node:crypto";
+
import { browserMatesOf, loginPageCheck, loginPlace, loginSite, type LoginPlace } from "../shared/logins.ts";
+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 { OnePasswordLogins } from "./onepassword.ts";
import type { LoginRouteDeps } from "./routes/logins.ts";
+import { findLinkedSecret, linkedCandidates, linkedSecretNames, linkedSecrets, linkedSites, readLinkedSecret, type VaultProvider } from "./vault/providers.ts";
/** What the bot's browser shows while the person answers a sign-in card. */
export interface ObservedPage {
@@ -41,17 +45,24 @@ export function cardLoginPlace(cardHost: string, observed: ObservedPage | null,
return loginPlace(cardHost, [onSite, ...(elsewhere && confirmedHost === elsewhere ? [elsewhere] : [])]);
}
-/** Saved logins and 1Password items, as each bot may use them. A login kept to some bots is filled only where every bot
- * sharing that browser may use it: a sign-in stays in the browser, so a bot sharing it would be signed in as well. */
+/** Saved logins and secrets, and a linked password manager's, as each bot may use them. A login kept to some bots is
+ * filled only where every bot sharing that browser may use it: a sign-in stays in the browser, so a bot sharing it
+ * would be signed in as well. */
export class BotLogins {
readonly store: VaultStore;
readonly onePassword: OnePasswordLogins;
+ readonly providers: readonly VaultProvider[];
private readonly bots: () => ReadonlyArray<{ id: string; browserProfile?: string | null }>;
+ private readonly hold: (value: string) => void;
- constructor(store: VaultStore, onePassword: OnePasswordLogins, bots: () => ReadonlyArray<{ id: string; browserProfile?: string | null }> = () => []) {
+ /** `hold` masks a value read from a linked manager wherever text crosses to a bot or a transcript. */
+ constructor(store: VaultStore, onePassword: OnePasswordLogins, bots: () => ReadonlyArray<{ id: string; browserProfile?: string | null }> = () => [],
+ hold: (value: string) => void = () => {}) {
this.store = store;
this.onePassword = onePassword;
+ this.providers = [onePassword];
this.bots = bots;
+ this.hold = hold;
}
/** The bot and every other bot that signs in through its browser: who a login saved from its sign-in card is kept
@@ -68,25 +79,50 @@ export class BotLogins {
/** Where each login the bot may use fills, with its username. */
sitesFor(botId: string): Array<LoginPlace & { username: string }> {
const bots = this.cardBots(botId);
- return [...this.store.sitesFor(bots), ...this.onePassword.sitesFor(bots)];
+ return [...this.store.sitesFor(bots), ...this.providers.flatMap((provider) => linkedSites(provider, bots))];
+ }
+
+ private async fresh(): Promise<void> {
+ await Promise.all(this.providers.map((provider) => provider.fresh()));
}
/** Secrets are read only when one is filled. */
async candidates(botId: string, pageHost: string): Promise<FillCandidate[]> {
- await this.onePassword.fresh();
+ await this.fresh();
const bots = this.cardBots(botId);
return [
...this.store.usableFor(pageHost, bots).map((login): FillCandidate => ({
id: login.id, site: login.site, hosts: login.hosts, exactHost: login.exactHost, username: login.username, source: login.source,
secrets: async () => ({ password: login.password, totp: login.totp ?? null }),
})),
- ...this.onePassword.candidates(pageHost, bots),
+ ...this.providers.flatMap((provider) => linkedCandidates(provider, pageHost, bots)),
];
}
markUsed(id: string): void {
this.store.markUsed(id);
- this.onePassword.markUsed(id);
+ for (const provider of this.providers) provider.markUsed(id);
+ }
+
+ linkedSecrets(): LinkedSecret[] {
+ 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 }> {
+ const linked = this.providers.flatMap((provider) => linkedSecrets(provider, botId).flatMap((secret) => linkedSecretNames(secret).map(({ name }) => ({ name }))));
+ return [...this.store.secretNamesFor(botId), ...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. */
+ async linkedSecret(name: string, botId: string): Promise<{ id: string; name: string; value: string } | null> {
+ await this.fresh();
+ const use = findLinkedSecret(this.providers, name, botId);
+ if (!use) return null;
+ const value = await readLinkedSecret(use);
+ this.hold(value);
+ const id = `linked-${createHash("sha256").update(`${use.secret.id}\0${use.field ?? ""}`).digest("hex").slice(0, 32)}`;
+ return { id, name: use.field ? `${use.secret.name} ${use.field}` : use.secret.name, value };
}
/** The settings, plus whether a 1Password token is held: what a credential card's "configured" check reads. */
diff --git a/server/host/fill-login-turn.test.ts b/server/host/fill-login-turn.test.ts
index edbb1b80b3..b6b5d08b38 100644
--- a/server/host/fill-login-turn.test.ts
+++ b/server/host/fill-login-turn.test.ts
@@ -114,7 +114,7 @@ describe("fill_login in the bot's own browser", () => {
});
describe("fill_login and a login kept to some bots on a shared browser", () => {
- const onePassword = { fresh: async () => {}, sitesFor: () => [], candidates: () => [], markUsed: () => {} } as unknown as OnePasswordLogins;
+ const onePassword = { id: "1password", label: "1Password", fresh: async () => {}, items: () => [], read: async () => ({}), markUsed: () => {} } as unknown as OnePasswordLogins;
const logins = (bots: ReadonlyArray<{ id: string; browserProfile?: string }>) => {
const store = new VaultStore({ dataDir: mkdtempSync(join(tmpdir(), "omb-fill-shared-")) });
store.create({ ...BANK, password: "never-shown", source: "settings", bots: ["b1"] });
diff --git a/server/host/secret-cards.test.ts b/server/host/secret-cards.test.ts
index 596e4ee21f..b5a790bd04 100644
--- a/server/host/secret-cards.test.ts
+++ b/server/host/secret-cards.test.ts
@@ -1,4 +1,4 @@
-import { mkdtempSync, readFileSync, rmSync } from "node:fs";
+import { mkdtempSync, readFileSync, rmSync, statSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { afterEach, describe, expect, it } from "vitest";
@@ -6,16 +6,20 @@ import { afterEach, describe, expect, it } from "vitest";
import "../server-line-packs.ts";
import type { BotRecord, Message } from "../store.ts";
import { EMAIL_CANT_SEND_TEXT } from "../email/instructions.ts";
-import { createSecretCards } from "./secret-cards.ts";
+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 { BotLogins } from "../bot-logins.ts";
+import { OnePasswordLogins, sdkOnePasswordClient } from "../onepassword.ts";
+import { fakeOnePasswordSdk } from "../testing/fake-onepassword.ts";
+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) {
+function fixture(language?: string, linked?: (vaultStore: VaultStore) => SecretCardsDeps["botLogins"]) {
const dataDir = mkdtempSync(join(tmpdir(), "omb-secret-cards-"));
dirs.push(dataDir);
const lines: Message[] = [];
@@ -37,7 +41,8 @@ function fixture(language?: string) {
const vaultStore = new VaultStore({ dataDir });
const resumed: string[] = [];
const cards = createSecretCards({
- store: store as never, cfg: {} as never, botLogins: { credentialConfig: (config) => ({ ...config, onePassword: { connected: false } }) }, vaultStore,
+ store: store as never, cfg: {} as never, vaultStore,
+ 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,
layerFolder: () => dataDir, turnVm: () => undefined, ...(language ? { threadLanguage: () => language } : {}),
@@ -49,22 +54,22 @@ describe("the card a bot asks for a key or secret with", () => {
it.each([
["greenferenceApiKey", "secretCard.greenference.description"],
["geminiTtsKey", "secretCard.geminiTts.description"],
- ] as const)("keeps the fallback and structured description for %s", (credentialId, baseCode) => {
+ ] as const)("keeps the fallback and structured description for %s", async (credentialId, baseCode) => {
const { cards, lines, bot } = fixture();
const reason = "For the requested report.";
- expect(cards.requestCredential(bot, "ledger-main", { credentialId, reason: ` ${reason} ` }).status).toBe(201);
+ expect((await cards.requestCredential(bot, "ledger-main", { credentialId, reason: ` ${reason} ` })).status).toBe(201);
expect(lines[0]!.secret).toMatchObject({
description: `${CREDENTIAL_TARGETS[credentialId].description} ${reason} Ledger can use it but never read it back.`,
descriptionParts: { baseCode, reason, bot: "Ledger" },
});
});
- it.each(["greenferenceApiKey", "geminiTtsKey"] as const)("scrubs the structured description data for %s", (credentialId) => {
+ it.each(["greenferenceApiKey", "geminiTtsKey"] as const)("scrubs the structured description data for %s", async (credentialId) => {
const { cards, lines, bot } = fixture();
const key = `sk-ant-api03-${"abcdefghijklmnopqrstuvwxyz0123456789"}`;
const reason = `Use ${key} for this report.`;
bot.name = `Ledger ${key}`;
- cards.requestCredential(bot, "ledger-main", { credentialId, reason });
+ await cards.requestCredential(bot, "ledger-main", { credentialId, reason });
const scrubbed = redactBotAuthored(lines[0]!);
expect(JSON.stringify(scrubbed)).not.toContain(key);
expect(scrubbed.secret?.descriptionParts).toMatchObject({
@@ -74,10 +79,10 @@ describe("the card a bot asks for a key or secret with", () => {
expect(lines[0]!.secret!.descriptionParts!.reason).toBe(reason);
});
- it("asks in the language of the conversation's person", () => {
+ it("asks in the language of the conversation's person", async () => {
const { cards, lines, bot } = fixture("de");
- expect(cards.requestCredential(bot, "ledger-main", { credentialId: "xaiApiKey" }).status).toBe(201);
- expect(cards.requestCredential(bot, "ledger-main", { label: "Stripe-Testschlüssel", reason: "Für Testzahlungen.", delivery: "file" }).status).toBe(201);
+ expect((await cards.requestCredential(bot, "ledger-main", { credentialId: "xaiApiKey" })).status).toBe(201);
+ expect((await cards.requestCredential(bot, "ledger-main", { label: "Stripe-Testschlüssel", reason: "Für Testzahlungen.", delivery: "file" })).status).toBe(201);
expect(lines.map((line) => line.text)).toEqual([
"Gib xAI API key sicher in OpenMausBot auf deinem Telefon oder Computer ein. Es wird nie in den Chat übernommen.",
"Gib Stripe-Testschlüssel sicher in OpenMausBot auf deinem Telefon oder Computer ein. Es wird nie in den Chat übernommen.",
@@ -87,9 +92,9 @@ describe("the card a bot asks for a key or secret with", () => {
.toBe("Für Testzahlungen. Die Befehle von Ledger können es 24 Stunden lang aus einer privaten Datei lesen; es wird nie in den Chat übernommen. OpenMausBot bewahrt es sicher auf, damit Ledger es wieder nutzen kann, ohne dich erneut zu fragen.");
});
- it("asks in English where no language is known", () => {
+ it("asks in English where no language is known", async () => {
const { cards, lines, bot } = fixture();
- cards.requestCredential(bot, "ledger-main", { label: "Notion token", reason: "For Notion's MCP server.", delivery: "ref" });
+ await cards.requestCredential(bot, "ledger-main", { label: "Notion token", reason: "For Notion's MCP server.", delivery: "ref" });
expect(lines[0]!.text).toBe("Securely provide the Notion token from OpenMausBot on your phone or computer. It is never added to chat.");
expect(lines[0]!.secret!.description).toBe("For Notion's MCP server. Ledger gets a one-use reference for OpenMausBot's own tools and never sees it. OpenMausBot keeps it safely, so Ledger can use it again without asking you.");
});
@@ -101,9 +106,9 @@ describe("a secret a card saves to the Vault", () => {
one.cards.requestCredential(one.bot, threadId, { label: "Stripe secret key", reason: "For test charges.", delivery: "ref", ...extra });
const refIn = (text: unknown) => /secret-ref:[0-9a-f]{32}/u.exec(String(text))?.[0];
- it("is kept for the asking bot, and its next ask, in any conversation and after any ref is spent, gets a fresh one with no card", () => {
+ it("is kept for the asking bot, and its next ask, in any conversation and after any ref is spent, gets a fresh one with no card", async () => {
const one = fixture();
- const card = ask(one, "t1");
+ 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 }]);
@@ -111,7 +116,7 @@ describe("a secret a card saves to the Vault", () => {
expect(fromCard).toBeDefined();
const spent = one.cards.redeemMcpServer({ env: { STRIPE_SECRET_KEY: fromCard } }, "ledger", "t1");
if (spent.ok) spent.commit();
- const again = ask(one, "t2", { label: "stripe-secret-key" });
+ const again = await ask(one, "t2", { label: "stripe-secret-key" });
expect(again.status).toBe(200);
const fresh = refIn(again.body.text);
expect(fresh).toBeDefined();
@@ -123,29 +128,29 @@ describe("a secret a card saves to the Vault", () => {
expect(JSON.stringify([one.lines, one.resumed, again, one.vaultStore.listSecrets()])).not.toContain(KEY);
});
- it("is not another bot's, and a file for one saved for OpenMausBot's tools only needs its own card", () => {
+ it("is not another bot's, and a file for one saved for OpenMausBot's tools only needs its own card", async () => {
const one = fixture();
one.vaultStore.saveSecret({ name: "Stripe secret key", value: KEY, source: "card", bots: ["ledger"], refOnly: true });
- expect(one.cards.requestCredential({ ...one.bot, id: "quill", name: "Quill" }, "t9", { label: "Stripe secret key", reason: "r", delivery: "ref" }).status).toBe(201);
- expect(ask(one, "t1", { delivery: "file" })).toMatchObject({ status: 201, body: { savedAs: "ref" } });
+ expect((await one.cards.requestCredential({ ...one.bot, id: "quill", name: "Quill" }, "t9", { label: "Stripe secret key", reason: "r", delivery: "ref" })).status).toBe(201);
+ expect(await ask(one, "t1", { delivery: "file" })).toMatchObject({ status: 201, body: { savedAs: "ref" } });
});
- it("is written to a file for the bot's commands, which the Vault remakes when asked again", () => {
+ it("is written to a file for the bot's commands, which the Vault remakes when asked again", async () => {
const one = fixture();
const item = one.vaultStore.saveSecret({ name: "Stripe secret key", value: KEY, source: "settings", bots: "all" });
- const answer = ask(one, "t1", { delivery: "file" });
+ const answer = await ask(one, "t1", { delivery: "file" });
const file = join(one.dataDir, ".openmausbot-secrets", "t1", `vault-${item.id}`);
expect(answer).toMatchObject({ status: 200, body: { text: expect.stringContaining(`to the file ${file}`) } });
expect(readFileSync(file, "utf8")).toBe(KEY);
rmSync(file);
- ask(one, "t1", { delivery: "file" });
+ await ask(one, "t1", { delivery: "file" });
expect(readFileSync(file, "utf8")).toBe(KEY);
});
- it("is asked for again when the bot says the saved one is wrong, and the new value replaces it", () => {
+ it("is asked for again when the bot says the saved one is wrong, and the new value replaces it", async () => {
const one = fixture();
one.vaultStore.saveSecret({ name: "Stripe secret key", value: KEY, source: "card", bots: ["ledger"], refOnly: true });
- const card = ask(one, "t1", { replace: true });
+ const card = await ask(one, "t1", { replace: true });
expect(card.status).toBe(201);
one.cards.saveCustomSecret("ledger", "t1", String(card.body.messageId), "sk_test_fake-card-vault-2");
expect(one.vaultStore.secretValues()).toEqual(["sk_test_fake-card-vault-2"]);
@@ -174,7 +179,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 } }) }, 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 }),
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,
@@ -195,44 +200,44 @@ describe("the mailbox card", () => {
const ask = (fixture: ReturnType<typeof mail>, body: Record<string, unknown> = {}) => fixture.cards.requestCredential(fixture.bot, "t1", { credentialId: "email", ...body });
const card = (fixture: ReturnType<typeof mail>) => fixture.lines.findLast((line) => line.kind === "secret")!;
- it("is one card, which a phone shows as any secret, naming the address the bot knows", () => {
+ it("is one card, which a phone shows as any secret, naming the address the bot knows", async () => {
const fixture = mail();
- expect(ask(fixture, { address: "[email protected]", reason: "To read today's invoices." })).toMatchObject({ status: 201, body: { delivery: "email" } });
+ expect(await ask(fixture, { address: "[email protected]", reason: "To read today's invoices." })).toMatchObject({ status: 201, body: { delivery: "email" } });
expect(card(fixture).secret).toMatchObject({ target: "customSecret", delivery: "email", address: "[email protected]", label: "Connect your mailbox", placeholder: "Mailbox password", helpUrl: "" });
expect(card(fixture).secret!.description).toContain("To read today's invoices.");
expect(card(fixture).secret!.description).toContain("Ledger never sees the password.");
});
- it("names the person's own address when the bot knows none, and none at all when it can't", () => {
+ it("names the person's own address when the bot knows none, and none at all when it can't", async () => {
const known = mail({ profile: "[email protected]" });
- ask(known);
+ await ask(known);
expect(card(known).secret!.address).toBe("[email protected]");
const unknown = mail();
- ask(unknown, { address: "not an address" });
+ await ask(unknown, { address: "not an address" });
expect(card(unknown).secret!.address).toBeUndefined();
});
- it("doesn't ask again for a mailbox that works, and a newer card replaces an older one", () => {
+ it("doesn't ask again for a mailbox that works, and a newer card replaces an older one", async () => {
const working = mail({ connected: true });
- expect(ask(working, { address: "[email protected]" })).toEqual({ status: 200, body: { alreadyConfigured: true, label: "[email protected]", text: "[email protected] is already connected. Use the email tools." } });
+ expect(await ask(working, { address: "[email protected]" })).toEqual({ status: 200, body: { alreadyConfigured: true, label: "[email protected]", text: "[email protected] is already connected. Use the email tools." } });
expect(working.lines).toEqual([]);
const fixture = mail();
- ask(fixture);
+ await ask(fixture);
const first = card(fixture);
- ask(fixture);
+ await ask(fixture);
expect(first.secret!.superseded).toBe(true);
});
- it("is refused where a place can't have mailboxes, in its words", () => {
+ it("is refused where a place can't have mailboxes, in its words", async () => {
const fixture = mail({ refusal: "Email isn't on a Team Cloud yet." });
- expect(ask(fixture)).toEqual({ status: 403, body: { error: "Email isn't on a Team Cloud yet." } });
+ expect(await ask(fixture)).toEqual({ status: 403, body: { error: "Email isn't on a Team Cloud yet." } });
expect(fixture.lines).toEqual([]);
});
it("a refused password leaves the card open with why; the right one connects and resumes the bot without it", async () => {
let good = false;
const fixture = mail({ connect: () => (good ? undefined : { ok: false, error: "The mail server did not accept this address and password." }) });
- ask(fixture, { address: "[email protected]" });
+ await ask(fixture, { address: "[email protected]" });
const { id } = card(fixture);
expect(await fixture.cards.saveEmailSecret("ledger", "t1", id, { value: PASSWORD })).toEqual({ status: 400, body: { error: "The mail server did not accept this address and password." } });
expect(card(fixture).secret).not.toMatchObject({ provided: true });
@@ -249,7 +254,7 @@ describe("the mailbox card", () => {
it("the address and the server the person types win, and asking for a server is passed on", async () => {
const fixture = mail({ connect: (request) => (request.imapHost ? undefined : { ok: false, needsServer: true, error: "We couldn't find your mail server." }) });
- ask(fixture, { address: "[email protected]" });
+ await ask(fixture, { address: "[email protected]" });
const { id } = card(fixture);
expect(await fixture.cards.saveEmailSecret("ledger", "t1", id, { value: PASSWORD, address: "[email protected]" })).toEqual({ status: 400, body: { error: "We couldn't find your mail server.", needsServer: true } });
await fixture.cards.saveEmailSecret("ledger", "t1", id, { value: PASSWORD, address: "[email protected]", imapHost: "post.example", imapPort: 993, smtpHost: "out.example", smtpPort: 587, username: "m1", other: "ignored" });
@@ -258,7 +263,7 @@ describe("the mailbox card", () => {
it("needs an address and a password, and goes no further on a dismissed card", async () => {
const fixture = mail();
- ask(fixture);
+ await ask(fixture);
const { id } = card(fixture);
expect(await fixture.cards.saveEmailSecret("ledger", "t1", id, { value: PASSWORD })).toMatchObject({ status: 400 });
expect(await fixture.cards.saveEmailSecret("ledger", "t1", id, { value: "", address: "[email protected]" })).toMatchObject({ status: 400 });
@@ -285,7 +290,7 @@ describe("the mailbox card", () => {
shown.push(card(fixture).secret!.emailReading);
return fail ? { ok: false, error: "nope" } : undefined;
} });
- ask(fixture, { address: "[email protected]" });
+ await ask(fixture, { address: "[email protected]" });
const { id } = card(fixture);
await fixture.cards.saveEmailSecret("ledger", "t1", id, { value: PASSWORD });
expect(shown).toEqual(["imap.shop.example"]);
@@ -298,19 +303,19 @@ describe("the mailbox card", () => {
it("Gmail and Outlook's way to sign in reaches the card, and only reading connected tells the bot sending waits for the person", async () => {
const signIn = { provider: "Microsoft", app: "outlook" };
const refused = mail({ connect: () => ({ ok: false, error: "Microsoft doesn't let mail programs in with a password.", signIn }) });
- ask(refused, { address: "[email protected]" });
+ await ask(refused, { address: "[email protected]" });
expect(await refused.cards.saveEmailSecret("ledger", "t1", card(refused).id, { value: PASSWORD })).toEqual({ status: 400, body: { error: "Microsoft doesn't let mail programs in with a password.", signIn } });
const problem = "smtp.shop.example didn't answer on 465 or 587.";
const readOnly = mail({ sendingProblem: problem, connect: () => ({ ok: true, account: { ...ACCOUNT, smtpHost: undefined, sendingProblem: problem }, inbox: { messages: 3 }, sending: { ok: false, problem } }) });
- ask(readOnly, { address: "[email protected]" });
+ await ask(readOnly, { address: "[email protected]" });
expect(await readOnly.cards.saveEmailSecret("ledger", "t1", card(readOnly).id, { value: PASSWORD })).toMatchObject({ status: 200, body: { provided: true, sendingProblem: problem } });
expect(readOnly.resumed[0]).toContain(problem);
expect(readOnly.resumed[0]).not.toContain("EMAIL_SEND_MESSAGE");
});
- it("the bot hears that it may go on, or that the person declined, never a value", () => {
+ it("the bot hears that it may go on, or that the person declined, never a value", async () => {
const fixture = mail();
- ask(fixture, { address: "[email protected]" });
+ await ask(fixture, { address: "[email protected]" });
const secret = card(fixture).secret!;
expect(fixture.cards.updateText(card(fixture).id, secret, "provided")).toContain("EMAIL_LIST_MESSAGES");
expect(fixture.cards.updateText(card(fixture).id, secret, "dismissed")).toContain("chose not to connect a mailbox");
@@ -319,9 +324,9 @@ describe("the mailbox card", () => {
const problem = "smtp.shop.example didn't answer on 465 or 587.";
const readOnly = { ...ACCOUNT, smtpHost: undefined, smtpTried: { smtpHost: "smtp.shop.example", smtpPort: 587 }, smtpUsername: "me", sendingProblem: problem };
- it("gets a card for its outgoing server, started from the server it tried, never a password", () => {
+ it("gets a card for its outgoing server, started from the server it tried, never a password", async () => {
const fixture = mail({ connected: true, sendingProblem: problem, account: readOnly });
- expect(ask(fixture, { address: "[email protected]", reason: "To send the invoice." })).toMatchObject({ status: 201, body: { delivery: "email", outgoing: true } });
+ expect(await ask(fixture, { address: "[email protected]", reason: "To send the invoice." })).toMatchObject({ status: 201, body: { delivery: "email", outgoing: true } });
const first = card(fixture);
const secret = first.secret!;
expect(secret).toMatchObject({ target: "customSecret", delivery: "email", address: "[email protected]", label: "Outgoing server for [email protected]", placeholder: "Password for sending" });
@@ -329,7 +334,7 @@ describe("the mailbox card", () => {
expect(secret.description).toContain(problem);
expect(secret.description).toContain("To send the invoice.");
expect(secret.description).toContain("Ledger never sees the password.");
- ask(fixture, { address: "[email protected]" });
+ await ask(fixture, { address: "[email protected]" });
expect(first.secret!.superseded, "a newer one replaces it").toBe(true);
});
@@ -339,7 +344,7 @@ describe("the mailbox card", () => {
{ ok: true, account: { ...ACCOUNT, smtpHost: "smtp.easy.example", smtpPort: 587, smtpSecurity: "starttls" } },
];
const fixture = mail({ connected: true, sendingProblem: problem, account: readOnly, checkOutgoing: () => answers.shift() });
- ask(fixture, { address: "[email protected]" });
+ await ask(fixture, { address: "[email protected]" });
const id = card(fixture).id;
const typed = { smtpHost: "smtp.easy.example", smtpPort: 587, smtpSecurity: "starttls", smtpPassword: PASSWORD, address: "[email protected]", imapHost: "imap.other.example", value: "not this" };
expect(await fixture.cards.saveEmailSecret("ledger", "t1", id, typed)).toEqual({ status: 400, body: { error: "smtp.easy.example didn't answer on 587." } });
@@ -355,12 +360,74 @@ describe("the mailbox card", () => {
expect(await fixture.cards.saveEmailSecret("ledger", "t1", id, typed), "only once").toMatchObject({ status: 409 });
});
- it("the bot hears that the person declined, and still never a value", () => {
+ it("the bot hears that the person declined, and still never a value", async () => {
const fixture = mail({ connected: true, sendingProblem: problem, account: readOnly });
- ask(fixture, { address: "[email protected]" });
+ await ask(fixture, { address: "[email protected]" });
const secret = card(fixture).secret!;
expect(fixture.cards.updateText(card(fixture).id, secret, "dismissed")).toContain("chose not to set up sending for [email protected]");
expect(fixture.cards.updateText(card(fixture).id, secret, "provided")).toContain(problem);
});
});
});
+
+describe("a secret a linked 1Password holds", () => {
+ const TOKEN = "ops_fake-service-account-token";
+ const NOTION = "secret_fake-notion-token-123";
+ function linked(options: { grants?: Record<string, LoginBots>; fail?: () => Error | null } = {}) {
+ const { sdk, calls } = fakeOnePasswordSdk({ token: TOKEN, fail: options.fail, vaults: { v1: { title: "Shared", items: [
+ { id: "n1", title: "Notion token", category: "ApiCredentials", urls: [], fields: [{ id: "credential", title: "credential", fieldType: "Concealed", value: NOTION }] },
+ ] } } });
+ const held: string[] = [];
+ const one = fixture(undefined, (vaultStore) => new BotLogins(vaultStore, new OnePasswordLogins({ token: () => TOKEN, grants: () => options.grants ?? {},
+ connect: (token) => sdkOnePasswordClient(sdk, token, "0.0.0") }), () => [], (value) => held.push(value)));
+ return { ...one, calls, held };
+ }
+ const ask = (one: ReturnType<typeof fixture>, extra: Record<string, unknown> = {}) =>
+ one.cards.requestCredential(one.bot, "t1", { label: "notion-token", reason: "For Notion.", delivery: "ref", ...extra });
+
+ it("is handed over by ref with no card, read from 1Password only then, and never saved or shown", async () => {
+ const one = linked();
+ const answer = await ask(one);
+ expect(answer.status).toBe(200);
+ expect(one.calls.filter((call) => call === "items.getAll v1 n1")).toHaveLength(2);
+ expect(one.held).toEqual([NOTION]);
+ const ref = /secret-ref:[0-9a-f]{32}/u.exec(String(answer.body.text))?.[0];
+ const used = one.cards.redeemMcpServer({ env: { NOTION_TOKEN: ref } }, "ledger", "t1");
+ expect(used.ok && used.value).toEqual({ env: { NOTION_TOKEN: NOTION } });
+ expect(one.lines).toEqual([]);
+ expect(one.vaultStore.listSecrets()).toEqual([]);
+ expect(JSON.stringify(answer)).not.toContain(NOTION);
+ });
+
+ it("is written to a private file for the bot's commands", async () => {
+ const one = linked();
+ const answer = await ask(one, { delivery: "file" });
+ const file = /to the file (\S+)\. /u.exec(String(answer.body.text))?.[1];
+ expect(file?.startsWith(join(one.dataDir, ".openmausbot-secrets", "t1", "vault-linked-"))).toBe(true);
+ expect(readFileSync(file!, "utf8")).toBe(NOTION);
+ expect(statSync(file!).mode & 0o777).toBe(0o600);
+ });
+
+ it("is not for a bot its 1Password vault is kept from, which gets a card instead", async () => {
+ const one = linked({ grants: { v1: ["quill"] } });
+ expect(await ask(one)).toMatchObject({ status: 201 });
+ expect(one.held).toEqual([]);
+ });
+
+ it("comes after one saved in the Vault, and isn't read when the bot says it is wrong", async () => {
+ const one = linked();
+ one.vaultStore.saveSecret({ name: "Notion token", value: "secret_fake-saved", source: "settings", bots: "all" });
+ expect((await ask(one)).status).toBe(200);
+ expect(await ask(one, { replace: true })).toMatchObject({ status: 201 });
+ expect(one.held).toEqual([]);
+ });
+
+ it("tells the bot in plain words when 1Password can't be read, with no card", async () => {
+ let failure: Error | null = null;
+ const one = linked({ fail: () => failure });
+ await ask(one);
+ failure = new Error("getaddrinfo ENOTFOUND my.1password.com");
+ expect(await ask(one)).toEqual({ status: 502, body: { error: "notion-token is in a linked password manager, but it could not be read: Could not reach 1Password. Check the internet connection and try again." } });
+ expect(one.lines).toEqual([]);
+ });
+});
diff --git a/server/host/secret-cards.ts b/server/host/secret-cards.ts
index fe2a353620..23388a38fc 100644
--- a/server/host/secret-cards.ts
+++ b/server/host/secret-cards.ts
@@ -55,7 +55,7 @@ export const phoneSecretEnvelopeSchema = z.object({
export interface SecretCardsDeps {
store: Pick<Store, "activePath" | "appendMessage" | "patchMessage" | "messagesFor" | "botByThread" | "groupByThread" | "onChange">;
cfg: AppConfig;
- botLogins: Pick<BotLogins, "credentialConfig">;
+ botLogins: Pick<BotLogins, "credentialConfig" | "linkedSecret">;
/** 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">;
phoneSecrets: Pick<PhoneSecretBridge, "provide" | "open">;
@@ -463,7 +463,7 @@ export function createSecretCards(deps: SecretCardsDeps) {
}
/** request_credential's card: the id is the whole authority, and a newer request supersedes the pending ones. */
- function requestCredential(from: BotRecord, fromThreadId: string, body: Record<string, unknown>): { status: number; body: Record<string, unknown> } {
+ async function requestCredential(from: BotRecord, fromThreadId: string, body: Record<string, unknown>): Promise<{ status: number; body: Record<string, unknown> }> {
const owner = connectorThread(from.id, fromThreadId);
if (!owner) return { status: 403, body: { error: "source conversation does not belong to sender" } };
if (body.credentialId === undefined) return requestCustomSecret(from, fromThreadId, Boolean(owner.group), body);
@@ -561,19 +561,27 @@ export function createSecretCards(deps: SecretCardsDeps) {
return { messageId: message.id, label: card.label };
}
- /** A secret the Vault holds for the bot by this name is handed over at once, with no card; otherwise a card asks for it,
- * replacing the bot's pending card with the same name. */
- function requestCustomSecret(from: BotRecord, threadId: string, room: boolean, body: Record<string, unknown>): { status: number; body: Record<string, unknown> } {
+ /** A secret the Vault holds for the bot by this name, saved or from a linked password manager, is handed over at once,
+ * with no card; otherwise a card asks for it, replacing the bot's pending card with the same name. */
+ async function requestCustomSecret(from: BotRecord, threadId: string, room: boolean, body: Record<string, unknown>): Promise<{ status: number; body: Record<string, unknown> }> {
const asked = customRequest(body);
if ("error" in asked) return { status: 400, body: asked };
const vm = asked.delivery === "file" ? deps.turnVm(threadId) : undefined;
- const item = asked.replace ? null : vaultStore.usableSecret(asked.label, from.id, asked.delivery);
+ const saved = asked.replace ? null : vaultStore.usableSecret(asked.label, from.id, asked.delivery);
+ let item: { id: string; name: string; value: string } | null = saved;
+ if (!asked.replace && !item) {
+ try {
+ item = await botLogins.linkedSecret(asked.label, from.id);
+ } catch (error) {
+ return { status: 502, body: { error: `${asked.label} is in a linked password manager, but it could not be read: ${error instanceof Error ? error.message : String(error)}` } };
+ }
+ }
if (item) {
const owner = { botId: from.id, threadId };
try {
- const saved = asked.delivery === "file" ? { file: vault.mintFile(owner, item.id, item.value, fileHome(from.id, threadId, vm)) } : { ref: vault.mintRef(owner, item.name, item.value) };
- vaultStore.markUsed(item.id);
- return { status: 200, body: { label: asked.label, text: savedSecretText(asked.label, saved) } };
+ const handed = asked.delivery === "file" ? { file: vault.mintFile(owner, item.id, item.value, fileHome(from.id, threadId, vm)) } : { ref: vault.mintRef(owner, item.name, item.value) };
+ if (saved) vaultStore.markUsed(saved.id);
+ return { status: 200, body: { label: asked.label, text: savedSecretText(asked.label, handed) } };
} catch (error) {
console.warn(`secret card: could not hand over a saved secret: ${error instanceof Error ? error.message : String(error)}`);
return { status: 500, body: userError("serverError.secret.notKeptSafely") };
diff --git a/server/index.ts b/server/index.ts
index bb50591773..2aee79bbd3 100644
--- a/server/index.ts
+++ b/server/index.ts
@@ -413,7 +413,7 @@ import {
ROUTINE_EXECUTION_PROMPT, READ_ONLY_ROUTINE_EXECUTION_PROMPT,
WEBHOOK_PROMPT, BOT_API_PROMPT, AUTOMATION_REPLY_PROMPT,
resolveComputerPromptKind,
- savedLoginsPrompt, heavyPrompt,
+ savedLoginsPrompt, savedSecretsPrompt, heavyPrompt,
teamAvailabilityPart,
} from "./system-prompt.ts";
import { shellTimeoutHookResult } from "./shell-timeout-hint.ts";
@@ -749,7 +749,7 @@ const onePassword = new OnePasswordLogins({
},
});
if (logins.onePasswordToken()) void onePassword.refresh();
-const botLogins = new BotLogins(logins, onePassword, () => store.bots);
+const botLogins = new BotLogins(logins, onePassword, () => store.bots, (value) => heldSecrets.remember(value, "password"));
const SESSION_COOKIE = sessionCookieName(PORT, ENVIRONMENT_ID);
const HOSTED_WORKSPACE = hostedWorkspaceConfigured();
let workspaceAccess: WorkspaceAccess | null = null;
@@ -2988,7 +2988,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 : "" },
+ { id: "credential", label: "Credentials", text: agentsMounted ? CREDENTIAL_PROMPT + savedSecretsPrompt(botLogins.secretNamesFor(bot.id)) : "" },
{ 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) },
@@ -8288,7 +8288,7 @@ async function beginTurn(
: integrations.agents && sectionPeers.length > 0
? peerRosterSystemPrompt(sectionPeers, bot)
: "";
- const credentialPrompt = integrations.agents ? CREDENTIAL_PROMPT + THREADS_PROMPT + WIDGET_PROMPT : "";
+ const credentialPrompt = integrations.agents ? CREDENTIAL_PROMPT + savedSecretsPrompt(botLogins.secretNamesFor(bot.id)) + 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 : "";
@@ -10128,7 +10128,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 + (orchestration && !orchestration.roomHandoffId ? THREADS_PROMPT : "")).trim(),
+ integrations.agents && (CREDENTIAL_PROMPT + savedSecretsPrompt(botLogins.secretNamesFor(bot.id)) + (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(),
@@ -12341,7 +12341,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 }));
+const loginRoutes = botLogins.routes((id) => Boolean(store.bot(id))); ROUTES.push(createLoginRoutes(loginRoutes), createVaultRoutes({ logins: loginRoutes, secrets: logins, linked: () => botLogins.linkedSecrets() }));
ROUTES.push(createUsageRoutes({
dataDir: DATA_DIR, prices: operatorPrices,
budget: () => spendState(cfg, DATA_DIR),
diff --git a/server/onepassword.test.ts b/server/onepassword.test.ts
index 4e2af1aa1f..a191bfa40c 100644
--- a/server/onepassword.test.ts
+++ b/server/onepassword.test.ts
@@ -2,15 +2,20 @@ import { afterEach, describe, expect, it } from "vitest";
import type { LoginBots } from "../shared/logins.ts";
import { fillLogin, type FillCandidate } from "./login-fill.ts";
-import { loginFields, ONE_PASSWORD_MALFORMED, ONE_PASSWORD_REFUSED, OnePasswordLogins, onePasswordProblem, onePasswordUnavailable, OnePasswordUnavailableError, sdkOnePasswordClient } from "./onepassword.ts";
+import { loginFields, ONE_PASSWORD_MALFORMED, ONE_PASSWORD_REFUSED, OnePasswordLogins, onePasswordProblem, onePasswordUnavailable, OnePasswordUnavailableError, sdkOnePasswordClient, secretFields } from "./onepassword.ts";
import { FakeLoginPage, LOGIN_FORM } from "./testing/fake-login-page.ts";
import { fakeOnePasswordSdk } from "./testing/fake-onepassword.ts";
import { parseTotpKey, totpCode } from "./totp.ts";
+import { findLinkedSecret, linkedCandidates, linkedSecrets, linkedSites, readLinkedSecret } from "./vault/providers.ts";
// Obvious fakes only; no network.
const TOKEN = "ops_fake-service-account-token";
const VAULT_PASSWORD = "fake-1P-Passw0rd";
const KEY = "otpauth://totp/Example:alice?secret=JBSWY3DPEHPK3PXP&issuer=Example";
+const STRIPE = "sk_test_fake-stripe-key-123";
+const DEPLOY = "fake-deploy-Passw0rd";
+const NOTE = "fake-note-text-456";
+const ACME_SECRET = "fake-acme-client-secret-789";
function setup(options: { token?: string | null; fail?: () => Error | null; now?: () => number; grants?: Record<string, LoginBots> } = {}) {
const { sdk, calls } = fakeOnePasswordSdk({
@@ -26,6 +31,12 @@ function setup(options: { token?: string | null; fail?: () => Error | null; now?
{ id: "i3", title: "No website", urls: [], username: "x", password: "fake-x-pass" },
{ id: "i4", title: "A note", category: "SecureNote", urls: ["https://notes.example.com"] },
{ id: "i5", title: "No password", urls: ["https://empty.example.com"], username: "nobody" },
+ { id: "i6", title: "Stripe secret key", category: "ApiCredentials", urls: [], username: "acct_fake",
+ fields: [{ id: "credential", title: "credential", fieldType: "Concealed", value: STRIPE }] },
+ { id: "i7", title: "Deploy", category: "Password", urls: ["https://deploy.example.io"], password: DEPLOY },
+ { id: "i8", title: "Acme OAuth", category: "SecureNote", urls: [], notes: NOTE,
+ fields: [{ id: "s1", title: "client_secret", fieldType: "Concealed", value: ACME_SECRET }] },
+ { id: "i9", title: "A card", category: "CreditCard", urls: [], fields: [{ id: "n", title: "number", fieldType: "Concealed", value: "4111" }] },
] },
},
});
@@ -65,7 +76,7 @@ describe("1Password logins", () => {
{ id: "v2", title: "Finance", items: 1, bots: "all" },
{ id: "v1", title: "Shared with OMB", items: 2, bots: "all" },
] });
- expect(calls).toEqual(["createClient OpenMausBot", "vaults.list", "items.list v2", "items.getAll v2 f1", "items.list v1", "items.getAll v1 i1,i2,i5"]);
+ expect(calls).toEqual(["createClient OpenMausBot", "vaults.list", "items.list v2", "items.getAll v2 f1", "items.list v1", "items.getAll v1 i1,i2,i4,i5,i6,i7,i8"]);
const rows = source.list();
expect(rows.map((row) => [row.site, row.hosts, row.username, row.hasTotp, row.source, row.bots])).toEqual([
["example.com", ["accounts.example.com"], "[email protected]", true, "1password", "all"],
@@ -74,15 +85,15 @@ describe("1Password logins", () => {
]);
expect(JSON.stringify(rows)).not.toContain(VAULT_PASSWORD);
expect(JSON.stringify(source.status())).not.toContain(TOKEN);
- expect(source.sitesFor("pepper")).toContainEqual({ site: "example.com", hosts: ["accounts.example.com"], exactHost: false, username: "[email protected]" });
+ expect(linkedSites(source, "pepper")).toContainEqual({ site: "example.com", hosts: ["accounts.example.com"], exactHost: false, username: "[email protected]" });
});
it("offers a login on its site, and reads its password and 2FA key from 1Password at fill time", async () => {
const { source, calls } = setup();
await source.refresh();
- expect(source.candidates("example.org.evil.test", "pepper")).toEqual([]);
- expect(source.candidates("login.accounts.example.com", "pepper")).toHaveLength(1);
- const [candidate] = source.candidates("example.com", "pepper");
+ expect(linkedCandidates(source, "example.org.evil.test", "pepper")).toEqual([]);
+ expect(linkedCandidates(source, "login.accounts.example.com", "pepper")).toHaveLength(1);
+ const [candidate] = linkedCandidates(source, "example.com", "pepper");
expect(candidate).toMatchObject({ site: "example.com", hosts: ["accounts.example.com"], username: "[email protected]", source: "1password" });
calls.length = 0;
expect(await candidate!.secrets()).toEqual({ password: VAULT_PASSWORD, totp: parseTotpKey(KEY) });
@@ -96,11 +107,14 @@ describe("1Password logins", () => {
{ id: "v2", title: "Finance", items: 1, bots: ["quill"] },
{ id: "v1", title: "Shared with OMB", items: 2, bots: [] },
]);
- expect(source.candidates("bank.example.net", "pepper")).toEqual([]);
- expect(source.candidates("accounts.example.com", "pepper")).toEqual([]);
- expect(source.sitesFor("pepper")).toEqual([]);
- expect(source.candidates("bank.example.net", "quill").map((candidate) => candidate.username)).toEqual(["treasurer"]);
- expect(source.sitesFor("quill").map((login) => login.site)).toEqual(["example.net"]);
+ expect(linkedCandidates(source, "bank.example.net", "pepper")).toEqual([]);
+ expect(linkedCandidates(source, "accounts.example.com", "pepper")).toEqual([]);
+ expect(linkedSites(source, "pepper")).toEqual([]);
+ expect(linkedCandidates(source, "bank.example.net", "quill").map((candidate) => candidate.username)).toEqual(["treasurer"]);
+ expect(linkedSites(source, "quill").map((login) => login.site)).toEqual(["example.net"]);
+ expect(linkedSecrets(source, "pepper")).toEqual([]);
+ expect(findLinkedSecret([source], "Stripe secret key", "pepper")).toBeNull();
+ expect(linkedSecrets(source).map((secret) => [secret.name, secret.bots])).toContainEqual(["Stripe secret key", []]);
expect(source.list().find((row) => row.site === "example.net")?.bots).toEqual(["quill"]);
expect(source.hasVault("v2")).toBe(true);
expect(source.hasVault("v9")).toBe(false);
@@ -115,8 +129,8 @@ describe("1Password logins", () => {
const saved: FillCandidate = { id: "local", site: "example.org", hosts: ["other.example.org"], exactHost: true, username: "local", source: "settings", secrets: async () => ({ password: "fake-local", totp: null }) };
const fill = () => fillLogin({
submit: false,
- candidates: async (host) => [...[saved].filter((login) => login.hosts.includes(host)), ...source.candidates(host, "pepper")],
- available: async () => [{ ...saved }, ...source.sitesFor("pepper")],
+ candidates: async (host) => [...[saved].filter((login) => login.hosts.includes(host)), ...linkedCandidates(source, host, "pepper")],
+ available: async () => [{ ...saved }, ...linkedSites(source, "pepper")],
}, {
engine: (args) => page!.engine(args), insertText: (text) => page!.insertText(text), press: (key) => page!.press(key), click: (selector) => page!.click(selector),
remember: (value) => { remembered.push(value); }, now: () => now, sleep: async () => undefined,
@@ -191,11 +205,62 @@ describe("1Password logins", () => {
expect(calls.filter((call) => call === "vaults.list")).toHaveLength(2);
setToken(null);
expect(source.list()).toEqual([]);
- expect(source.sitesFor("pepper")).toEqual([]);
- expect(source.candidates("accounts.example.com", "pepper")).toEqual([]);
+ expect(linkedSites(source, "pepper")).toEqual([]);
+ expect(linkedCandidates(source, "accounts.example.com", "pepper")).toEqual([]);
source.clear();
expect(source.list()).toEqual([]);
- expect(source.candidates("accounts.example.com", "pepper")).toEqual([]);
+ expect(linkedCandidates(source, "accounts.example.com", "pepper")).toEqual([]);
expect(source.status()).toEqual({ connected: false });
});
});
+
+describe("1Password secrets", () => {
+ it("takes an API Credential's credential, a Password's password and a Secure Note's text as the main value, with other fields by title", () => {
+ const concealed = (id: string, title: string, value: string) => ({ id, title, fieldType: "Concealed", value });
+ expect([...secretFields("ApiCredentials", { fields: [{ id: "username", title: "username", fieldType: "Text", value: "acct" }, concealed("credential", "credential", "k1")] })])
+ .toEqual([["", "k1"], ["username", "acct"]]);
+ expect([...secretFields("Password", { fields: [concealed("password", "password", "p1")] })]).toEqual([["", "p1"]]);
+ expect([...secretFields("SecureNote", { fields: [concealed("s1", "client_secret", "c1")], notes: "n1" })]).toEqual([["", "n1"], ["client_secret", "c1"]]);
+ expect([...secretFields("SecureNote", { fields: [concealed("s1", "client_secret", "c1")] })]).toEqual([["", "c1"]]);
+ expect(secretFields("SecureNote", { fields: [] }).size).toBe(0);
+ });
+
+ it("lists API Credential, Password and Secure Note items with a value as secrets, by name and field names only", async () => {
+ const { source } = setup();
+ await source.refresh();
+ expect(linkedSecrets(source, "pepper").map((secret) => [secret.id, secret.name, secret.fields, secret.provider, secret.readOnly, secret.bots])).toEqual([
+ ["1password:v1:i8", "Acme OAuth", ["client_secret"], "1password", true, "all"],
+ ["1password:v1:i7", "Deploy", [], "1password", true, "all"],
+ ["1password:v1:i6", "Stripe secret key", ["username"], "1password", true, "all"],
+ ]);
+ expect(linkedCandidates(source, "deploy.example.io", "pepper")).toEqual([]);
+ const listed = JSON.stringify(source.items());
+ for (const value of [STRIPE, DEPLOY, NOTE, ACME_SECRET, VAULT_PASSWORD]) expect(listed).not.toContain(value);
+ });
+
+ it("finds one by its name or \"<name> <field>\", and reads its value from 1Password only then", async () => {
+ const { source, calls } = setup();
+ await source.refresh();
+ calls.length = 0;
+ const stripe = findLinkedSecret([source], "stripe-secret-key", "pepper");
+ expect(stripe).toMatchObject({ secret: { id: "1password:v1:i6" } });
+ expect(calls).toEqual([]);
+ expect(await readLinkedSecret(stripe!)).toBe(STRIPE);
+ expect(calls).toEqual(["items.getAll v1 i6"]);
+ expect(await readLinkedSecret(findLinkedSecret([source], "Acme OAuth", "pepper")!)).toBe(NOTE);
+ expect(await readLinkedSecret(findLinkedSecret([source], "Acme OAuth client secret", "pepper")!)).toBe(ACME_SECRET);
+ expect(findLinkedSecret([source], "A card", "pepper")).toBeNull();
+ expect(source.items().find((item) => item.id === "1password:v1:i6")?.lastUsedAt).toEqual(expect.any(Number));
+ });
+
+ it("says plainly when a secret left 1Password, and when 1Password can't be read", async () => {
+ let failure: Error | null = null;
+ const { source } = setup({ fail: () => failure });
+ await source.refresh();
+ const deploy = findLinkedSecret([source], "Deploy", "pepper")!;
+ failure = new Error("getaddrinfo ENOTFOUND my.1password.com");
+ await expect(readLinkedSecret(deploy)).rejects.toThrow("Could not reach 1Password.");
+ failure = null;
+ await expect(readLinkedSecret({ ...deploy, field: "nothing" })).rejects.toThrow("Deploy is no longer in 1Password, or has no value there.");
+ });
+});
diff --git a/server/onepassword.ts b/server/onepassword.ts
index dec7667164..a5cb041606 100644
--- a/server/onepassword.ts
+++ b/server/onepassword.ts
@@ -3,9 +3,9 @@
// WebAssembly core it reads from beside itself, so it is never bundled: it is
// required on first use, and only when a token exists.
import type { LoginBots, LoginPlace, LoginSummary, OnePasswordStatus, OnePasswordVault } from "../shared/logins.ts";
-import { loginMatchesHost, loginSite, loginUsableBy, normalizeLoginHost } from "../shared/logins.ts";
-import type { FillCandidate } from "./login-fill.ts";
+import { loginSite, normalizeLoginHost } from "../shared/logins.ts";
import { parseTotpKey } from "./totp.ts";
+import type { LinkedItem, LinkedValue, VaultProvider } from "./vault/providers.ts";
export interface OnePasswordItemFields {
username: string;
@@ -13,19 +13,20 @@ export interface OnePasswordItemFields {
totp: string | null;
}
+interface SdkField { id: string; title: string; fieldType: string; value: string }
+export interface OnePasswordItemContent { fields: SdkField[]; notes?: string }
+
export interface OnePasswordClient {
vaults(): Promise<Array<{ id: string; title: string }>>;
- loginItems(vaultId: string): Promise<Array<{ id: string; title: string; urls: string[] }>>;
- fields(vaultId: string, itemIds: string[]): Promise<Map<string, OnePasswordItemFields>>;
+ items(vaultId: string): Promise<Array<{ id: string; title: string; category: string; urls: string[] }>>;
+ contents(vaultId: string, itemIds: string[]): Promise<Map<string, OnePasswordItemContent>>;
}
-
-interface SdkField { id: string; title: string; fieldType: string; value: string }
interface SdkClient {
vaults: { list(): Promise<Array<{ id: string; title: string }>> };
items: {
list(vaultId: string): Promise<Array<{ id: string; title: string; category: string; websites?: Array<{ url: string }> }>>;
- getAll(vaultId: string, itemIds: string[]): Promise<{ individualResponses: Array<{ content?: { id: string; fields: SdkField[] }; error?: unknown }> }>;
+ getAll(vaultId: string, itemIds: string[]): Promise<{ individualResponses: Array<{ content?: { id: string; fields: SdkField[]; notes?: string }; error?: unknown }> }>;
};
}
export interface OnePasswordSdk {
@@ -41,6 +42,27 @@ export function loginFields(fields: readonly SdkField[]): OnePasswordItemFields
return { username: username?.value ?? "", password: password?.value ?? "", totp: totp?.value ?? null };
}
+/** The 1Password categories (SDK ItemCategory) whose items are secrets rather than logins. */
+const SECRET_CATEGORIES = new Set(["ApiCredentials", "Password", "SecureNote"]);
+const MAIN_FIELD: Record<string, string> = { ApiCredentials: "credential", Password: "password" };
+const FIELDS_MAX = 20;
+
+/** A secret item's values by field title, with "" for its main one: an API Credential's credential, a Password's
+ * password, a Secure Note's text, or else its first concealed field. */
+export function secretFields(category: string, content: OnePasswordItemContent): Map<string, string> {
+ const values = new Map<string, string>();
+ const usable = content.fields.filter((field) => field.value && (field.fieldType === "Concealed" || field.fieldType === "Text"));
+ const note = category === "SecureNote" ? content.notes : undefined;
+ const main = note ? undefined : usable.find((field) => field.id === MAIN_FIELD[category]) ?? usable.find((field) => field.fieldType === "Concealed");
+ const mainValue = note || main?.value;
+ if (mainValue) values.set("", mainValue);
+ for (const field of usable) {
+ const title = field.title.trim();
+ if (field !== main && title && !values.has(title) && values.size <= FIELDS_MAX) values.set(title, field.value);
+ }
+ return values;
+}
+
/** The SDK did not load: a fault in this installation, never in the person's token, which was not even checked. */
export class OnePasswordUnavailableError extends Error {
constructor() {
@@ -59,14 +81,13 @@ export async function sdkOnePasswordClient(sdk: OnePasswordSdk, token: string, v
const client = await sdk.createClient({ auth: token, integrationName: "OpenMausBot", integrationVersion: version });
return {
vaults: async () => (await client.vaults.list()).map((vault) => ({ id: vault.id, title: vault.title })),
- loginItems: async (vaultId) => (await client.items.list(vaultId))
- .filter((item) => item.category === "Login" && (item.websites?.length ?? 0) > 0)
- .map((item) => ({ id: item.id, title: item.title, urls: (item.websites ?? []).map((site) => site.url) })),
- fields: async (vaultId, itemIds) => {
- const found = new Map<string, OnePasswordItemFields>();
+ items: async (vaultId) => (await client.items.list(vaultId))
+ .map((item) => ({ id: item.id, title: item.title, category: item.category, urls: (item.websites ?? []).map((site) => site.url) })),
+ contents: async (vaultId, itemIds) => {
+ const found = new Map<string, OnePasswordItemContent>();
if (!itemIds.length) return found;
const { individualResponses } = await client.items.getAll(vaultId, itemIds);
- for (const response of individualResponses) if (response.content) found.set(response.content.id, loginFields(response.content.fields));
+ for (const { content } of individualResponses) if (content) found.set(content.id, { fields: content.fields, ...(content.notes ? { notes: content.notes } : {}) });
return found;
},
};
@@ -82,6 +103,17 @@ interface Entry extends LoginPlace {
hasTotp: boolean;
}
+interface SecretEntry {
+ id: string;
+ vaultId: string;
+ itemId: string;
+ category: string;
+ name: string;
+ fields: string[];
+}
+
+const isLogin = (item: { category: string; urls: string[] }) => item.category === "Login" && item.urls.length > 0;
+
const ID_PREFIX = "1password:";
const MAX_ITEMS = 500;
const FIELDS_BATCH = 50;
@@ -115,15 +147,18 @@ export function onePasswordProblem(error: unknown): string {
return "1Password could not be read. Try again, or connect it again with a new token.";
}
-export class OnePasswordLogins {
+export class OnePasswordLogins implements VaultProvider {
+ readonly id = "1password";
+ readonly label = "1Password";
private readonly token: () => string | null;
private readonly connect: (token: string) => Promise<OnePasswordClient>;
private readonly grants: () => Record<string, LoginBots>;
private readonly now: () => number;
private client: { token: string; client: OnePasswordClient } | null = null;
private entries: Entry[] = [];
+ private secrets: SecretEntry[] = [];
private vaults: Array<Omit<OnePasswordVault, "bots">> = [];
- private items = 0;
+ private itemCount = 0;
private refreshedAt: number | null = null;
private error: string | undefined;
private refreshing: Promise<OnePasswordStatus> | null = null;
@@ -142,7 +177,7 @@ export class OnePasswordLogins {
private connected(): OnePasswordStatus {
const vaults: OnePasswordVault[] = this.vaults.map((vault) => ({ ...vault, bots: this.botsFor(vault.id) }));
- return { connected: true, vaults, items: this.items, ...(this.error ? { error: this.error } : {}) };
+ return { connected: true, vaults, items: this.itemCount, ...(this.error ? { error: this.error } : {}) };
}
status(): OnePasswordStatus {
@@ -162,29 +197,38 @@ export class OnePasswordLogins {
refresh(token?: string): Promise<OnePasswordStatus> {
if (!token && this.refreshing) return this.refreshing;
- const run = this.read(token).finally(() => { if (this.refreshing === run) this.refreshing = null; });
+ const run = this.load(token).finally(() => { if (this.refreshing === run) this.refreshing = null; });
if (!token) this.refreshing = run;
return run;
}
- private async read(candidate?: string): Promise<OnePasswordStatus> {
+ private async load(candidate?: string): Promise<OnePasswordStatus> {
const token = candidate ?? this.token();
if (!token) { this.clear(); return this.status(); }
try {
const client = await this.clientFor(token);
const vaults = await client.vaults();
const entries: Entry[] = [];
+ const secrets: SecretEntry[] = [];
const counted: Array<Omit<OnePasswordVault, "bots">> = [];
for (const vault of vaults) {
let items = 0;
- const logins = (await client.loginItems(vault.id)).slice(0, MAX_ITEMS);
- for (let start = 0; start < logins.length; start += FIELDS_BATCH) {
- const batch = logins.slice(start, start + FIELDS_BATCH);
- // The password in this answer is dropped here and read again at fill.
- const fields = await client.fields(vault.id, batch.map((item) => item.id));
+ const wanted = (await client.items(vault.id)).filter((item) => isLogin(item) || SECRET_CATEGORIES.has(item.category)).slice(0, MAX_ITEMS);
+ for (let start = 0; start < wanted.length; start += FIELDS_BATCH) {
+ const batch = wanted.slice(start, start + FIELDS_BATCH);
+ // Every value in this answer is dropped here and read again when a bot uses it.
+ const contents = await client.contents(vault.id, batch.map((item) => item.id));
for (const item of batch) {
- const found = fields.get(item.id);
- if (!found?.password) continue;
+ const content = contents.get(item.id);
+ if (!content) continue;
+ if (!isLogin(item)) {
+ const fields = secretFields(item.category, content);
+ if (fields.has("")) secrets.push({ id: `${ID_PREFIX}${vault.id}:${item.id}`, vaultId: vault.id, itemId: item.id, category: item.category, name: item.title.trim() || item.category,
+ fields: [...fields.keys()].filter(Boolean) });
+ continue;
+ }
+ const found = loginFields(content.fields);
+ if (!found.password) continue;
items++;
for (const [site, hosts] of bySite(new Set(item.urls.flatMap((url) => normalizeLoginHost(url) ?? [])))) {
entries.push({ id: `${ID_PREFIX}${vault.id}:${item.id}:${site}`, vaultId: vault.id, itemId: item.id, site, hosts, exactHost: false,
@@ -195,8 +239,9 @@ export class OnePasswordLogins {
counted.push({ id: vault.id, title: vault.title, items });
}
this.entries = entries.sort((a, b) => a.site.localeCompare(b.site) || a.username.localeCompare(b.username));
+ this.secrets = secrets.sort((a, b) => a.name.localeCompare(b.name));
this.vaults = counted.sort((a, b) => a.title.localeCompare(b.title));
- this.items = counted.reduce((sum, vault) => sum + vault.items, 0);
+ this.itemCount = counted.reduce((sum, vault) => sum + vault.items, 0);
this.refreshedAt = this.now();
this.error = undefined;
return this.connected();
@@ -211,8 +256,9 @@ export class OnePasswordLogins {
clear(): void {
this.client = null;
this.entries = [];
+ this.secrets = [];
this.vaults = [];
- this.items = 0;
+ this.itemCount = 0;
this.refreshedAt = null;
this.error = undefined;
this.lastUsed.clear();
@@ -223,45 +269,58 @@ export class OnePasswordLogins {
if (this.refreshedAt === null || this.now() - this.refreshedAt > STALE_MS) await this.refresh();
}
- list(): LoginSummary[] {
- if (!this.token()) return [];
- return this.entries.map((entry) => ({
- id: entry.id, site: entry.site, hosts: [...entry.hosts], exactHost: false, username: entry.username, hasTotp: entry.hasTotp, source: "1password",
- bots: this.botsFor(entry.vaultId), createdAt: 0, ...(this.lastUsed.has(entry.itemId) ? { lastUsedAt: this.lastUsed.get(entry.itemId)! } : {}),
- }));
+ private lastUsedOf(itemId: string): { lastUsedAt?: number } {
+ const at = this.lastUsed.get(itemId);
+ return at === undefined ? {} : { lastUsedAt: at };
}
- /** A vault narrowed to other bots is invisible to this one. */
- private usable(botId: string | readonly string[]): Entry[] {
- return this.token() ? this.entries.filter((entry) => loginUsableBy({ bots: this.botsFor(entry.vaultId) }, botId)) : [];
+ items(): LinkedItem[] {
+ if (!this.token()) return [];
+ return [
+ ...this.entries.map((entry): LinkedItem => ({
+ kind: "login", id: entry.id, site: entry.site, hosts: [...entry.hosts], exactHost: false, username: entry.username, hasTotp: entry.hasTotp,
+ source: "1password", bots: this.botsFor(entry.vaultId), createdAt: 0, ...this.lastUsedOf(entry.itemId),
+ })),
+ ...this.secrets.map((entry): LinkedItem => ({
+ kind: "secret", id: entry.id, name: entry.name, fields: [...entry.fields], source: "linked", provider: this.id, bots: this.botsFor(entry.vaultId),
+ readOnly: true, ...this.lastUsedOf(entry.itemId),
+ })),
+ ];
}
- sitesFor(botId: string | readonly string[]): Array<LoginPlace & { username: string }> {
- return this.usable(botId).map((entry) => ({ site: entry.site, hosts: [...entry.hosts], exactHost: false, username: entry.username }));
+ list(): LoginSummary[] {
+ return this.items().flatMap(({ kind, ...item }) => (kind === "login" ? [item as LoginSummary] : []));
}
- candidates(pageHost: string, botId: string | readonly string[]): FillCandidate[] {
+ private async contentOf(vaultId: string, itemId: string): Promise<OnePasswordItemContent | undefined> {
const token = this.token();
- if (!token) return [];
- return this.usable(botId).filter((entry) => loginMatchesHost(entry, pageHost)).map((entry) => ({
- id: entry.id, site: entry.site, hosts: [...entry.hosts], exactHost: false, username: entry.username, source: "1password" as const,
- secrets: async () => {
- let found: OnePasswordItemFields | undefined;
- try {
- const client = await this.clientFor(token);
- found = (await client.fields(entry.vaultId, [entry.itemId])).get(entry.itemId);
- } catch (error) {
- this.client = null;
- throw new Error(onePasswordProblem(error));
- }
- if (!found?.password) throw new Error("This login is no longer in 1Password, or has no password there.");
- return { password: found.password, totp: found.totp ? parseTotpKey(found.totp) : null };
- },
- }));
+ if (!token) return undefined;
+ try {
+ const client = await this.clientFor(token);
+ return (await client.contents(vaultId, [itemId])).get(itemId);
+ } catch (error) {
+ this.client = null;
+ throw new Error(onePasswordProblem(error));
+ }
+ }
+
+ async read(itemId: string, field?: string): Promise<LinkedValue> {
+ const login = this.entries.find((entry) => entry.id === itemId);
+ if (login) {
+ const content = await this.contentOf(login.vaultId, login.itemId);
+ if (!content) return {};
+ const found = loginFields(content.fields);
+ return { password: found.password, totp: found.totp ? parseTotpKey(found.totp) : null };
+ }
+ const secret = this.secrets.find((entry) => entry.id === itemId);
+ const content = secret && await this.contentOf(secret.vaultId, secret.itemId);
+ if (!secret || !content) return {};
+ const value = secretFields(secret.category, content).get(field ?? "");
+ return value ? { value } : {};
}
markUsed(id: string): void {
- const entry = this.entries.find((candidate) => candidate.id === id);
+ const entry = this.entries.find((candidate) => candidate.id === id) ?? this.secrets.find((candidate) => candidate.id === id);
if (entry) this.lastUsed.set(entry.itemId, this.now());
}
}
diff --git a/server/routes/secret-cards.ts b/server/routes/secret-cards.ts
index 73a79bd2e5..ae3639bdb3 100644
--- a/server/routes/secret-cards.ts
+++ b/server/routes/secret-cards.ts
@@ -152,11 +152,11 @@ export function createSecretCardRoutes(deps: SecretCardRouteDeps): RouteHandler
* register this endpoint. */
export function createInternalCredentialRequestRoutes(deps: {
readBody(): ReturnType<RouteContext["readBody"]>;
- request(body: Record<string, unknown>): { status: number; body: Record<string, unknown> };
+ request(body: Record<string, unknown>): Promise<{ status: number; body: Record<string, unknown> }>;
}): RouteHandler {
return async ({ res, path, method, json }) => {
if (method !== "POST" || path !== "/api/internal/request-credential") return PASS;
- const result = deps.request(await deps.readBody());
+ const result = await deps.request(await deps.readBody());
return json(res, result.status, result.body);
};
}
diff --git a/server/routes/vault.test.ts b/server/routes/vault.test.ts
index 57216628ee..999a5df35c 100644
--- a/server/routes/vault.test.ts
+++ b/server/routes/vault.test.ts
@@ -7,7 +7,8 @@ import { afterEach, describe, expect, it } from "vitest";
import { BotLogins } from "../bot-logins.ts";
import { json, readBody } from "../harness/http.ts";
-import { OnePasswordLogins } from "../onepassword.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 { createLoginRoutes } from "./logins.ts";
@@ -16,6 +17,7 @@ import { createVaultRoutes, VAULT_ERRORS } from "./vault.ts";
const VALUE = "sk_test_fake-route-secret-1";
const NEW_VALUE = "sk_test_fake-route-secret-2";
+const LINKED_VALUE = "secret_fake-linked-route-3";
const servers: Server[] = [];
const dirs: string[] = [];
@@ -24,13 +26,18 @@ afterEach(async () => {
for (const dir of dirs.splice(0)) rmSync(dir, { recursive: true, force: true });
});
-async function serve() {
+async function serve(onePasswordToken: string | null = null) {
const dir = mkdtempSync(join(tmpdir(), "omb-vault-routes-"));
dirs.push(dir);
const store = new VaultStore({ dataDir: dir });
- const onePassword = new OnePasswordLogins({ token: () => null, grants: () => ({}), connect: async () => { throw new Error("not in this test"); } });
- const logins = new BotLogins(store, onePassword).routes((id) => ["pepper", "quill"].includes(id));
- const routes = [createLoginRoutes(logins), createVaultRoutes({ logins, secrets: store })];
+ const { sdk } = fakeOnePasswordSdk({ token: "ops_fake-route-token", vaults: { v1: { title: "Shared", items: [
+ { id: "n1", title: "Notion token", category: "ApiCredentials", urls: [], fields: [{ id: "credential", title: "credential", fieldType: "Concealed", value: LINKED_VALUE }] },
+ ] } } });
+ const onePassword = new OnePasswordLogins({ token: () => onePasswordToken, grants: () => ({}), connect: (token) => sdkOnePasswordClient(sdk, token, "0.0.0") });
+ 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() })];
const answers: string[] = [];
const server = createServer(async (req, res) => {
const url = new URL(req.url ?? "/", "http://localhost");
@@ -91,4 +98,15 @@ describe("the Vault routes", () => {
expect((await call("PUT", `/api/vault/secrets/${id}`, {})).status).toBe(405);
expect(store.secretValues()).toEqual([VALUE]);
});
+
+ it("list a linked 1Password secret beside the saved ones, by name only, and never change it", async () => {
+ const { call, answers } = await serve("ops_fake-route-token");
+ await call("POST", "/api/vault/secrets", { name: "Stripe secret key", value: VALUE });
+ const listed = await call("GET", "/api/vault");
+ expect(listed.body.secrets.map((secret: { name: string; source: string }) => [secret.name, secret.source])).toEqual([["Stripe secret key", "settings"], ["Notion token", "linked"]]);
+ expect(listed.body.secrets[1]).toEqual({ id: "1password:v1:n1", name: "Notion token", fields: [], source: "linked", provider: "1password", bots: "all", readOnly: true });
+ expect((await call("DELETE", "/api/vault/secrets/1password:v1:n1")).status).toBe(404);
+ 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);
+ });
});
diff --git a/server/routes/vault.ts b/server/routes/vault.ts
index bf1e18c9d9..343132c303 100644
--- a/server/routes/vault.ts
+++ b/server/routes/vault.ts
@@ -1,5 +1,5 @@
// No answer ever carries a saved value: a saved secret is only ever replaced.
-import { SECRET_VALUE_MAX_BYTES, VAULT_SECRET_NAME_MAX } from "../../shared/vault.ts";
+import { SECRET_VALUE_MAX_BYTES, VAULT_SECRET_NAME_MAX, type LinkedSecret } from "../../shared/vault.ts";
import type { VaultStore } from "../vault-store.ts";
import { isJson, parseBots, type LoginRouteDeps } from "./logins.ts";
import { PASS, type RouteHandler } from "./table.ts";
@@ -7,6 +7,8 @@ import { PASS, type RouteHandler } from "./table.ts";
export interface VaultRouteDeps {
logins: Pick<LoginRouteDeps, "list" | "botExists" | "onePassword">;
secrets: Pick<VaultStore, "listSecrets" | "saveSecret" | "updateSecret" | "removeSecret">;
+ /** A linked password manager's secrets, listed beside the saved ones and changed only in the manager. */
+ linked?: () => LinkedSecret[];
}
const SECRETS = "/api/vault/secrets";
@@ -38,7 +40,7 @@ export function createVaultRoutes(deps: VaultRouteDeps): RouteHandler {
res.setHeader("cache-control", "no-store");
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(), onePassword: deps.logins.onePassword.status() });
+ return json(res, 200, { logins: [...deps.logins.list(), ...deps.logins.onePassword.list()], secrets: [...deps.secrets.listSecrets(), ...(deps.linked?.() ?? [])], onePassword: deps.logins.onePassword.status() });
}
if (path !== SECRETS && !path.startsWith(`${SECRETS}/`)) return json(res, 404, { error: "not found" });
// JSON only, so a form posted from another local page cannot add or change one.
diff --git a/server/system-prompt.test.ts b/server/system-prompt.test.ts
index 1079c199b9..7921fcdecc 100644
--- a/server/system-prompt.test.ts
+++ b/server/system-prompt.test.ts
@@ -27,6 +27,7 @@ import {
SANDBOX_DESKTOP_INPUT,
SIGN_IN_PROMPT,
savedLoginsPrompt,
+ savedSecretsPrompt,
everyBotRulesPrompt,
heavyPrompt,
HEAVY_PROMPT_BYTES,
@@ -272,6 +273,15 @@ describe("computerPrompt", () => {
const many = Array.from({ length: 45 }, (_, index) => ({ ...loginPlace(`site${index}.com`), username: "a" }));
expect(savedLoginsPrompt(many)).toMatch(/site39\.com \(a\) and 5 more\.$/u);
});
+
+ it("names the Vault's secrets a bot may use, once each, so it asks for them by name", () => {
+ expect(savedSecretsPrompt([])).toBe("");
+ expect(savedSecretsPrompt([{ name: "Stripe key", refOnly: true }, { name: "stripe-key" }, { name: "Notion\n token" }, { name: "Acme", refOnly: true }]))
+ .toBe(' Secrets in the Vault you may use: "stripe-key", "Notion token", "Acme" (ref only). To use one, call request_credential with its name as the label: OpenMausBot hands it over at once with no card, and you never see the value.');
+ const many = Array.from({ length: 45 }, (_, index) => ({ name: `key ${index}` }));
+ expect(savedSecretsPrompt(many)).toContain('"key 39" and 5 more.');
+ expect(savedSecretsPrompt([{ name: "x".repeat(200) }])).toContain(`"${"x".repeat(80)}"`);
+ });
});
describe("shared sentences", () => {
diff --git a/server/system-prompt.ts b/server/system-prompt.ts
index 1945b6d289..41b5b509c4 100644
--- a/server/system-prompt.ts
+++ b/server/system-prompt.ts
@@ -5,6 +5,7 @@ import { agentsToolBridged } from "./drivers/agents-bridge.ts";
import { teammateAvailabilityPrompt, type RosterMember } from "./peer-roster.ts";
import type { ConnectorToolGrant } from "../shared/wire.ts";
import { loginLabel, type LoginPlace } from "../shared/logins.ts";
+import { vaultNameKey } from "../shared/vault.ts";
import { isConversational, type ReplyStyle } from "../shared/reply-style.ts";
import { REPLY_HABITS_PROMPT } from "./reply-habits.ts";
@@ -144,6 +145,23 @@ export function savedLoginsPrompt(logins: ReadonlyArray<LoginPlace & { username:
return ` Your saved logins, for fill_login on these sites and their sign-in pages: ${shown.join(", ")}${more}.`;
}
+const SECRET_NAMES_SHOWN = 40;
+const SECRET_NAME_SHOWN_MAX = 80;
+
+/** Names only, never a value. */
+export function savedSecretsPrompt(secrets: ReadonlyArray<{ name: string; refOnly?: true }>): string {
+ const names = new Map<string, string>();
+ for (const secret of [...secrets].sort((a, b) => Number(Boolean(a.refOnly)) - Number(Boolean(b.refOnly)))) {
+ const name = secret.name.replace(/[\p{Cc}\s]+/gu, " ").trim().slice(0, SECRET_NAME_SHOWN_MAX);
+ const key = vaultNameKey(name);
+ if (key && !names.has(key)) names.set(key, `${JSON.stringify(name)}${secret.refOnly ? " (ref only)" : ""}`);
+ }
+ if (!names.size) return "";
+ const shown = [...names.values()].slice(0, SECRET_NAMES_SHOWN);
+ const more = names.size > shown.length ? ` and ${names.size - shown.length} more` : "";
+ return ` Secrets in the Vault you may use: ${shown.join(", ")}${more}. To use one, call request_credential with its name as the label: OpenMausBot hands it over at once with no card, and you never see the value.`;
+}
+
export function computerPrompt(kind: ComputerPromptKind | null): string {
if (!kind) return "";
return COMPUTER_PARAGRAPH[kind] + SIGN_IN_PROMPT;
diff --git a/server/testing/fake-onepassword.ts b/server/testing/fake-onepassword.ts
index e27805f916..96e9ca199e 100644
--- a/server/testing/fake-onepassword.ts
+++ b/server/testing/fake-onepassword.ts
@@ -11,6 +11,10 @@ export interface FakeItem {
password?: string;
/** The one-time-password field's value (an otpauth:// address or secret). */
totp?: string;
+ /** A Secure Note's text. */
+ notes?: string;
+ /** Any other fields, such as an API Credential's credential. */
+ fields?: Array<{ id: string; title: string; fieldType: string; value: string }>;
}
export function fakeOnePasswordSdk(options: { token: string; vaults: Record<string, { title: string; items: FakeItem[] }>; fail?: () => Error | null }) {
@@ -37,7 +41,8 @@ export function fakeOnePasswordSdk(options: { token: string; vaults: Record<stri
...field("username", "username", "Text", item.username),
...field("password", "password", "Concealed", item.password),
...field("otp-1", "one-time password", "Totp", item.totp),
- ] } };
+ ...(item.fields ?? []),
+ ], ...(item.notes === undefined ? {} : { notes: item.notes }) } };
}) };
},
},
diff --git a/server/vault-store.ts b/server/vault-store.ts
index 88c3b02695..531ab52bc4 100644
--- a/server/vault-store.ts
+++ b/server/vault-store.ts
@@ -296,6 +296,10 @@ export class VaultStore {
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 } : {}) }));
+ }
+
/** The same name saved again for the same bots replaces its value; otherwise it is a new secret. */
saveSecret(input: NewSecret): VaultSecret {
const data = this.read();
diff --git a/server/vault/providers.ts b/server/vault/providers.ts
new file mode 100644
index 0000000000..2f9d235237
--- /dev/null
+++ b/server/vault/providers.ts
@@ -0,0 +1,79 @@
+// A password manager linked to the Vault adds its items to the same list, by name and site only. A value is read from
+// the manager at the moment a bot uses it, never kept or logged, and each item says which bots may use it.
+import { loginMatchesHost, loginUsableBy, type LoginPlace, type LoginSummary } from "../../shared/logins.ts";
+import { vaultNameKey, type LinkedSecret } from "../../shared/vault.ts";
+import type { FillCandidate } from "../login-fill.ts";
+import type { TotpKey } from "../totp.ts";
+
+export type LinkedItem = ({ kind: "login" } & LoginSummary) | ({ kind: "secret" } & LinkedSecret);
+
+export interface LinkedValue {
+ password?: string;
+ totp?: TotpKey | null;
+ value?: string;
+}
+
+export interface VaultProvider {
+ readonly id: string;
+ /** Shown to the person and the bot, such as 1Password. */
+ readonly label: string;
+ /** Reads the manager's list again once it is older than the provider allows. */
+ fresh(): Promise<void>;
+ /** Every item and the bots that may use it, never a value. */
+ items(): LinkedItem[];
+ /** A login's password and 2FA key, or a secret's main value (or its `field`), read from the manager now. */
+ read(itemId: string, field?: string): Promise<LinkedValue>;
+ markUsed(itemId: string): void;
+}
+
+function logins(provider: VaultProvider, bots: string | readonly string[]): LoginSummary[] {
+ return provider.items().flatMap(({ kind, ...item }) => (kind === "login" && loginUsableBy(item, bots) ? [item as LoginSummary] : []));
+}
+
+export function linkedSites(provider: VaultProvider, bots: string | readonly string[]): Array<LoginPlace & { username: string }> {
+ return logins(provider, bots).map((login) => ({ site: login.site, hosts: [...login.hosts], exactHost: login.exactHost, username: login.username }));
+}
+
+export function linkedCandidates(provider: VaultProvider, pageHost: string, bots: string | readonly string[]): FillCandidate[] {
+ return logins(provider, bots).filter((login) => loginMatchesHost(login, pageHost)).map((login) => ({
+ id: login.id, site: login.site, hosts: [...login.hosts], exactHost: login.exactHost, username: login.username, source: login.source,
+ secrets: async () => {
+ const { password, totp } = await provider.read(login.id);
+ if (!password) throw new Error(`This login is no longer in ${provider.label}, or has no password there.`);
+ return { password, totp: totp ?? null };
+ },
+ }));
+}
+
+export function linkedSecrets(provider: VaultProvider, botId?: string): LinkedSecret[] {
+ return provider.items().flatMap(({ kind, ...item }) => (kind === "secret" && (botId === undefined || loginUsableBy(item, botId)) ? [item as LinkedSecret] : []));
+}
+
+/** What a bot asks for a linked secret by: its name for the main value, "<name> <field>" for each other field. */
+export function linkedSecretNames(secret: LinkedSecret): Array<{ name: string; field?: string }> {
+ return [{ name: secret.name }, ...secret.fields.map((field) => ({ name: `${secret.name} ${field}`, field }))];
+}
+
+export interface LinkedSecretUse {
+ provider: VaultProvider;
+ secret: LinkedSecret;
+ field?: string;
+}
+
+export function findLinkedSecret(providers: readonly VaultProvider[], name: string, botId: string): LinkedSecretUse | null {
+ const key = vaultNameKey(name);
+ for (const provider of providers) {
+ for (const secret of linkedSecrets(provider, botId)) {
+ const found = linkedSecretNames(secret).find((one) => vaultNameKey(one.name) === key);
+ if (found) return { provider, secret, ...(found.field ? { field: found.field } : {}) };
+ }
+ }
+ return null;
+}
+
+export async function readLinkedSecret({ provider, secret, field }: LinkedSecretUse): Promise<string> {
+ const { value } = await provider.read(secret.id, field);
+ if (!value) throw new Error(`${secret.name} is no longer in ${provider.label}, or has no value there.`);
+ provider.markUsed(secret.id);
+ return value;
+}
diff --git a/shared/vault.ts b/shared/vault.ts
index 36d96bd79f..13a18bbf2a 100644
--- a/shared/vault.ts
+++ b/shared/vault.ts
@@ -30,3 +30,18 @@ export const SECRET_VALUE_MAX_BYTES = 4_096;
export function vaultNameKey(name: string): string {
return name.normalize("NFKC").toLowerCase().replace(/[^\p{L}\p{N}]+/gu, " ").trim();
}
+
+/** A secret from a linked password manager, as the Vault lists it: its name and field names, never a value. It is
+ * changed in the manager, and its group in the manager says which bots may use it. */
+export interface LinkedSecret {
+ id: string;
+ name: string;
+ /** Its other fields, each asked for as "<name> <field>"; the name alone is its main value. */
+ fields: string[];
+ source: "linked";
+ /** Who it is linked from, such as 1password. */
+ provider: string;
+ bots: LoginBots;
+ readOnly: true;
+ lastUsedAt?: number;
+}