diff options
Diffstat (limited to 'utils')
-rw-r--r-- | utils/secret.ts | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/utils/secret.ts b/utils/secret.ts index 9847aa6..8860998 100644 --- a/utils/secret.ts +++ b/utils/secret.ts @@ -15,7 +15,7 @@ export class BitwardenSession { public async getItem<T extends LoginItem | SecureNote>( secretName: string, - ): Promise<T | undefined> { + ): Promise<T> { return await this.sessionInitializer.then((session) => getStdout(`bw list items`, { env: { @@ -24,7 +24,10 @@ export class BitwardenSession { }) ).then((items) => JSON.parse(items)).then((items) => items.find(({ name }: { name: string }) => name === secretName) - ); + ).then((item) => { + if (!item) throw new Error("Could not find bitwarden item " + secretName); + return item; + }); } async close(): Promise<void> { |