Skip to content

Update bitwarden extension: fix search when vault contains SSH keys#17492

Merged
raycastbot merged 7 commits intoraycast:mainfrom
jose-elias-alvarez:ext/bitwarden
Mar 4, 2025
Merged

Update bitwarden extension: fix search when vault contains SSH keys#17492
raycastbot merged 7 commits intoraycast:mainfrom
jose-elias-alvarez:ext/bitwarden

Conversation

@jose-elias-alvarez
Copy link
Contributor

@jose-elias-alvarez jose-elias-alvarez commented Mar 2, 2025

Description

Closes #15837 and #16976.

Currently, the Search Vault command, the extension's main entry point, errors out if the vault contains an SSH key, a new item type added in late 2024. (This is why some users may not have any problems and also why downgrading to an earlier version of the CLI "fixes" the issue, since older versions just ignore SSH keys.)

This PR updates the extension's code to correctly handle the new item type. It displays SSH keys in the list of search results and adds an action to copy the public key to the clipboard. (I can also add an action to copy the private key and / or key fingerprint, though I'm not sure how useful these would be.)

I also added a check to ensure that the command won't completely error out if a new item type is added in the future (it'll have placeholder icons and no actions, which seems sensible until proper handling can be added in a PR similar to this one).

Also, while not related, I went ahead and fixed a warning generated by specifying a shortcut for Action.SubmitForm (Raycast is already overriding this to Command + Enter).

Screencast

An SSH key in search results:

CleanShot 2025-03-02 at 12 59 17

Checklist

- docs: update changelog
- chore: unset removed shortcut
- fix: handle ssh keys in search
- Initial commit
@raycastbot raycastbot added extension fix / improvement Label for PRs with extension's fix improvements extension: bitwarden Issues related to the bitwarden extension labels Mar 2, 2025
@raycastbot
Copy link
Collaborator

raycastbot commented Mar 2, 2025

Thank you for your contribution! 🎉

🔔 @jomifepe @daniel-stoneuk @andreaselia @eth-p @YamenSharaf @undefinedzack @anirudhganwal06 @ivaarsson @gasparhabif @marinsokol you might want to have a look.

You can use this guide to learn how to check out the Pull Request locally in order to test it.

Due to our current reduced availability, the initial review may take up to 10-15 business days

@jose-elias-alvarez jose-elias-alvarez changed the title Update bitwarden extension Update bitwarden extension: fix search when vault contains SSH keys Mar 2, 2025
@pernielsentikaer
Copy link
Collaborator

@jomifepe can you check this?

@pernielsentikaer pernielsentikaer self-assigned this Mar 2, 2025
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

This PR adds support for SSH keys in the Bitwarden extension, fixing a critical bug where the Search Vault command would error out when encountering SSH keys in a user's vault.

  • Added proper handling for SSH_KEY item type in src/types/vault.ts with a new interface for SSH key properties
  • Created new CopyPublicKeyAction.tsx component to allow copying public keys to clipboard
  • Updated caching utility in caching.ts to properly handle SSH key items while maintaining security
  • Added icon and label mappings for SSH keys in general.ts and labels.ts for consistent UI representation
  • Implemented defensive error handling in useItemAccessories.ts to prevent crashes from unknown item types in the future

💡 (1/5) You can manually trigger the bot by mentioning @greptileai in a comment!

13 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings | Greptile

Comment on lines +93 to +97
export interface SshKey {
privateKey: string;
publicKey: string;
keyFingerprint: string;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: The SshKey interface properties are all defined as required strings without null options, unlike other interfaces like Card and Identity which allow null values. Consider whether these fields should also allow null values for consistency and to handle potential edge cases where some fields might not be present.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good bot. This is a fair observation, but at least as of now, SSH keys are not directly editable in the Bitwarden GUI (you have to either import them or generate them in Bitwarden itself), so I don't believe these are truly nullable, but I'm happy to change this for consistency.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, we can leave it like this and change if necessary.

Copy link
Contributor

@jomifepe jomifepe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great addition 💯
Looks clean overall. I've left a few comments.

- feat: add ssh key actions
- fix: use transient copy preference
@jose-elias-alvarez
Copy link
Contributor Author

Thanks for the feedback @jomifepe, should be good to go now.

Copy link
Contributor

@jomifepe jomifepe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, awesome job finding the culprit of that common error!

Ship it :shipit:

Comment on lines +93 to +97
export interface SshKey {
privateKey: string;
publicKey: string;
keyFingerprint: string;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, we can leave it like this and change if necessary.

…l.tsx

Co-authored-by: José Pereira <7235666+jomifepe@users.noreply.github.com>
@raycastbot raycastbot added the OP is contributor The OP of the PR is a contributor of the extension label Mar 3, 2025
@pernielsentikaer
Copy link
Collaborator

Can we merge as it is now @jomifepe

@jomifepe
Copy link
Contributor

jomifepe commented Mar 3, 2025

Can we merge as it is now @jomifepe

I'm not sure if the comment was resolved, it's still not exported/imported correctly 👀

But it wasn't a blocker, so feel free to merge anyway!

@pernielsentikaer
Copy link
Collaborator

Let's do that and have an eye out 🙂

Copy link
Collaborator

@pernielsentikaer pernielsentikaer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved 🔥

@raycastbot raycastbot merged commit d0348e7 into raycast:main Mar 4, 2025
2 checks passed
@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2025

Published to the Raycast Store:
https://raycast.com/jomifepe/bitwarden

@raycastbot
Copy link
Collaborator

🎉 🎉 🎉

We've rewarded your Raycast account with some credits. You will soon be able to exchange them for some swag.

@jose-elias-alvarez jose-elias-alvarez deleted the ext/bitwarden branch March 4, 2025 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extension: bitwarden Issues related to the bitwarden extension extension fix / improvement Label for PRs with extension's fix improvements OP is contributor The OP of the PR is a contributor of the extension

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bitwarden Vault] ...

4 participants