Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(vault): a custom field emptied since the listing reads as gone, not as the login password
Santhi Prakashea748dc1c213
diff --git a/server/host/bitwarden-vault.test.ts b/server/host/bitwarden-vault.test.tsindex 306dff3d71..be83b4832f 100644--- a/server/host/bitwarden-vault.test.ts+++ b/server/host/bitwarden-vault.test.ts@@ -103,6 +103,23 @@ describe("Bitwarden through its command line tool", () => {expect(await read("bw://i-dup-2/password"), "two of a name: by id").toBe("fake-deploy-2");});+ it("answers a custom field emptied since the listing as gone, never as the login password", async () => {+ // The list's entry names the field a bare-name read takes; the item is fetched again at read time, and the entry+ // is only refreshed once a minute. A field deleted or emptied in Bitwarden in that window leaves nothing to read:+ // the login password is a different secret the name never asked for, and reading it would mark it used.+ const items: FakeBwItem[] = [+ { id: "i-key", name: "Api key", type: 1, login: { uris: [{ uri: "https://api.example.com" }], username: "me", password: "fake-api-login-pass" },+ fields: [{ name: "key", value: "fake-api-key-1", type: 1 }] },+ ];+ const fake = fakeBw({ ...CREDENTIALS, email: "[email protected]", items });+ const vault = new BitwardenLogins({ credentials: () => CREDENTIALS, run: fake.run });+ await vault.refresh();+ const read = () => readLinkedSecret(findLinkedSecret([vault], "Api key", "pepper")!);+ items[0]!.fields = [];+ await expect(read()).rejects.toThrow("Api key is no longer in Bitwarden");+ expect(linkedSecrets(vault).find((secret) => secret.name === "Api key"), "not marked used").not.toHaveProperty("lastUsedAt");+ });+it("parses bw:// references and checks the server address", () => {expect(parseBitwardenReference("bw://GitHub/totp")).toEqual({ item: "GitHub", field: "totp" });expect(parseBitwardenReference(" bw://Acme OAuth ")).toEqual({ item: "Acme OAuth" });diff --git a/server/host/bitwarden-vault.ts b/server/host/bitwarden-vault.tsindex 8970de4675..abe0031d5e 100644--- a/server/host/bitwarden-vault.ts+++ b/server/host/bitwarden-vault.ts@@ -139,6 +139,7 @@ const listedAsSecret = (entry: ItemEntry) => (entry.type === SECURE_NOTE && entrfunction valueOf(item: BwItem, entry: ItemEntry, field: string | undefined, now: number): string | undefined {if (!field) {const own = item.type === SECURE_NOTE && item.notes?.trim() ? item.notes : customValue(item, entry.main);+ if (entry.main !== undefined) return own;// A login has no custom field of its own to read: its name reads the password, like `bw://<name>` does.return own ?? (item.type === LOGIN ? item.login?.password ?? undefined : undefined);}