From e4df72cd446270cf867ec308995a05e21b3aa601 Mon Sep 17 00:00:00 2001 From: Elizabeth Hunt Date: Sun, 27 Jul 2025 00:06:30 -0700 Subject: Add search string to bw list. --- worker/secret.ts | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'worker/secret.ts') diff --git a/worker/secret.ts b/worker/secret.ts index 071b539..34056c2 100644 --- a/worker/secret.ts +++ b/worker/secret.ts @@ -52,13 +52,14 @@ export class Bitwarden implements IVault { .move(this.config) .flatMap(TraceUtil.withMetricTrace(Bitwarden.loginMetric)) .map((tConfig) => - Either.fromFailable }>( - () => { - const sessionPath = path.join(this.config.sessionBaseDirectory, randomUUID()); - mkdirSync(sessionPath, { recursive: true }); - return { config: tConfig.get(), key: { BITWARDENCLI_APPDATA_DIR: sessionPath } }; - }, - ), + Either.fromFailable< + Error, + { config: BitwardenConfig; key: Pick } + >(() => { + const sessionPath = path.join(this.config.sessionBaseDirectory, randomUUID()); + mkdirSync(sessionPath, { recursive: true }); + return { config: tConfig.get(), key: { BITWARDENCLI_APPDATA_DIR: sessionPath } }; + }), ) .map((tEitherConfig) => tEitherConfig @@ -78,12 +79,18 @@ export class Bitwarden implements IVault { .get(); } - public fetchSecret(client: TClient, key: BitwardenKey, item: string): Promise> { + public fetchSecret( + client: TClient, + key: BitwardenKey, + item: string, + ): Promise> { return client .move(key) .flatMap(TraceUtil.withMetricTrace(Bitwarden.fetchSecretMetric)) .peek((tSession) => tSession.trace.trace(`looking for your secret ${item} (⑅˘꒳˘)`)) - .flatMap((tSession) => tSession.move('bw list items').map((listCmd) => getStdout(listCmd, { env: key }))) + .flatMap((tSession) => + tSession.move(`bw list items --search ${item}`).map((listCmd) => getStdout(listCmd, { env: key })), + ) .map( TraceUtil.promiseify((tEitherItemsJson) => tEitherItemsJson -- cgit v1.2.3-70-g09d2