@xiaolikt/ai-vault 0.10.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Cargo.lock +1 -1
- package/README.md +44 -6
- package/README.zh.md +33 -4
- package/crates/ai-vault/Cargo.toml +1 -1
- package/crates/ai-vault/src/cli.rs +253 -57
- package/crates/ai-vault/src/import.rs +85 -48
- package/crates/ai-vault/src/store.rs +237 -5
- package/package.json +4 -4
- package/packages/pi-ai-vault/README.md +1 -1
- package/packages/pi-ai-vault/README.zh.md +1 -1
- package/packages/pi-ai-vault/package.json +2 -2
- package/packages/pi-ai-vault/src/bitwarden.ts +39 -24
- package/packages/pi-ai-vault/src/cli.ts +9 -3
- package/packages/pi-ai-vault/src/import-map.ts +166 -58
- package/packages/pi-ai-vault/src/index.ts +121 -42
- package/packages/pi-ai-vault/src/types.ts +52 -0
- package/test/cli.sh +44 -0
- package/tests/bitwarden-tools.test.mjs +2 -2
- package/tests/import-map.test.mjs +75 -38
- package/tests/mocks/bin/bw +5 -1
- package/tests/vault-cli.test.mjs +56 -0
package/tests/vault-cli.test.mjs
CHANGED
|
@@ -313,3 +313,59 @@ test("a relayed read approval is signed by the host: the raw CLI refuses a bare
|
|
|
313
313
|
assert.match(tampered.stderr, /modified outside ai-vault/);
|
|
314
314
|
assert.equal(readdirSync(dir).includes(`${token}.json`), false, "the tampered file is deleted");
|
|
315
315
|
});
|
|
316
|
+
|
|
317
|
+
test("vault_add stores a card: non-secret fields from the model, the CVV typed in a dialog", async () => {
|
|
318
|
+
const b = bind(aiVault, true);
|
|
319
|
+
const ctx = makeCtx().ctx;
|
|
320
|
+
answers.master(dir, PW);
|
|
321
|
+
answers.questions(dir, "y");
|
|
322
|
+
answers.entryPassword(dir, "000");
|
|
323
|
+
const result = await b.tool(
|
|
324
|
+
"vault_add",
|
|
325
|
+
{
|
|
326
|
+
name: "MyCard",
|
|
327
|
+
type: "card",
|
|
328
|
+
fields: { brand: "Mastercard", cardholderName: "Li Jun", expMonth: "01", expYear: "2030", code: undefined },
|
|
329
|
+
},
|
|
330
|
+
ctx,
|
|
331
|
+
);
|
|
332
|
+
assert.equal(result.isError, undefined, textOf(result));
|
|
333
|
+
assert.match(textOf(result), /as a card/);
|
|
334
|
+
// The list shows the type and the non-secret fields, never the code.
|
|
335
|
+
answers.master(dir, PW);
|
|
336
|
+
const listed = JSON.parse(textOf(await b.tool("vault_list", {}, ctx)));
|
|
337
|
+
const card = listed.find((i) => i.name === "MyCard");
|
|
338
|
+
assert.equal(card.type, "card");
|
|
339
|
+
assert.equal(card.fields.brand, "Mastercard");
|
|
340
|
+
assert.equal(JSON.stringify(listed).includes("000"), false);
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
test("vault_add refuses a secret the model tried to supply itself", async () => {
|
|
344
|
+
const b = bind(aiVault, true);
|
|
345
|
+
const ctx = makeCtx().ctx;
|
|
346
|
+
answers.master(dir, PW);
|
|
347
|
+
const result = await b.tool("vault_add", { name: "Leaky", type: "card", fields: { code: "123" } }, ctx);
|
|
348
|
+
assert.equal(result.isError, true);
|
|
349
|
+
assert.match(textOf(result), /secret field/);
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
test("vault_get falls back to Bitwarden for a non-login hit and imports it with its fields", async () => {
|
|
353
|
+
const b = bind(aiVault, true);
|
|
354
|
+
const ctx = makeCtx().ctx;
|
|
355
|
+
answers.master(dir, PW);
|
|
356
|
+
await b.cmd("unlock", ctx);
|
|
357
|
+
answers.master(dir, "testmaster");
|
|
358
|
+
answers.questions(dir, "y", "y");
|
|
359
|
+
const result = await b.tool("vault_get", { name: "CorpCard" }, ctx);
|
|
360
|
+
assert.equal(result.details.via, "imported-from-bitwarden");
|
|
361
|
+
const body = JSON.parse(textOf(result));
|
|
362
|
+
assert.equal(body.type, "card");
|
|
363
|
+
assert.equal(body.data.number, "4111111111111111");
|
|
364
|
+
assert.equal(body.data.code, "123");
|
|
365
|
+
answers.master(dir, PW);
|
|
366
|
+
const listed = JSON.parse(textOf(await b.tool("vault_list", {}, ctx)));
|
|
367
|
+
const card = listed.find((i) => i.name === "CorpCard");
|
|
368
|
+
assert.equal(card.type, "card");
|
|
369
|
+
assert.equal(card.fields.cardholderName, "Li Jun");
|
|
370
|
+
assert.equal(JSON.stringify(listed).includes("4111111111111111"), false, "list must mask the card number");
|
|
371
|
+
});
|