Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(bitwarden): added field for server url during setup for self-hosted servers and others #2246

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

UnKnoWn-Consortium
Copy link

feat(bitwarden): added field for server url during setup for self-hosted servers
fix(bitwarden): fixed confusing cache logic that does not cache credential request responses properly
refactor(prompt): retrofitted the createPrompt function with promise
refactor(prompt): updated createPrompt usage for the promise retrofit
refactor: unwrapped AutofillSetup as individual functions and exported the initialize function that is used externally
refactor: unwrapped PasswordManagers as individual functions and exported functions that are used externally
refactor: replaced some usages of var with let and const

@PalmerAL
Copy link
Collaborator

This seems reasonable from reading over it; can you explain "fixed confusing cache logic that does not cache credential request responses properly"?

@UnKnoWn-Consortium
Copy link
Author

@PalmerAL In the original code, the cache list lastCallList for a domain is set to a promise instead of the suggestion returned from the password manager.

this.lastCallList[domain] = this.loadSuggestions(command, domain).then(suggestions => {

@UnKnoWn-Consortium
Copy link
Author

UnKnoWn-Consortium commented May 29, 2023

@PalmerAL Thanks for bringing us multi-window support. I will resolve the conflict asap. Done.

…ted servers

fix(bitwarden): fixed confusing cache logic that does not cache credential request responses properly
refactor(prompt): retrofitted the `createPrompt` function with promise
refactor(prompt): updated `createPrompt` usage for the promise retrofit
refactor: unwrapped AutofillSetup as individual functions and exported the `initialize` function that is used externally
refactor: unwrapped PasswordManagers as individual functions and exported functions that are used externally
refactor: replaced some usages of `var` with `let` and `const`
…e now thrown directly

fix(passwordCapture): renamed typo `handleRecieveCredentials` to `handleReceivedCredentials` and updated usage
refactor(passwordCapture): updated error handling for `getSuggestions` in `handleReceivedCredentials`
@UnKnoWn-Consortium
Copy link
Author

@PalmerAL Sorry to ping. Conflict resolved now.

@PalmerAL
Copy link
Collaborator

Sorry, I haven't had time to test this. Will do in the next few days.

@UnKnoWn-Consortium
Copy link
Author

@PalmerAL Sorry my fault. Please take your time.

Copy link
Collaborator

@PalmerAL PalmerAL left a comment

Choose a reason for hiding this comment

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

Looks good other than comments! I couldn't find a custom server to test this with (and didn't want to spend the time setting one up), but everything seems to work with the default server.

var signInFields = [
// show ask-for-credential dialog
const signInFields = [
{ placeholder: 'Server URL (Leave blank for the default Bitwarden server)', id: 'url', type: 'text' },
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should probably be a translated string - add it to en-US.json, then do l(stringName) like the examples below.
Actually, maybe "client ID" and "Client Secret" should be translated also, although I think the reason not to translate them was so that it would be clear in Bitwarden what we're referring to.

ok: l('dialogConfirmButton'),
cancel: l('dialogSkipButton'),
width: 500,
height: 260
Copy link
Collaborator

Choose a reason for hiding this comment

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

The dialog is a little bit too short now, at least on macOS:

Comment on lines -100 to -102
var formattedHostname = hostname
if (formattedHostname.startsWith('www.')) {
formattedHostname = formattedHostname.slice(4)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This breaks autofill on sites starting with www., because we pass hostname in the autofill response, and it then makes this check fail:

if (data.hostname !== window.location.hostname) {
throw new Error('password origin must match current page origin')
}

(We should keep the check, it's guarding against us accidentally sending IPC messages to the wrong tab)

BW_CLIENTID: credentials.clientID.trim(),
BW_CLIENTSECRET: credentials.clientSecret.trim()
})
credentials.url = credentials.url || 'bitwarden.com'
Copy link
Collaborator

Choose a reason for hiding this comment

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

It wasn't clear to me whether I was supposed to type "bitwarden.com" or "vault.bitwarden.com" - do they both work? If not, maybe we should special-case this so if the user enters one we convert to the other.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants