Skip to content

Commit

Permalink
Merge branch '1password-fixes-2151'
Browse files Browse the repository at this point in the history
  • Loading branch information
PalmerAL committed Jan 8, 2024
2 parents 9efaf3b + 7a1c5ac commit 5d7f3c0
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
20 changes: 19 additions & 1 deletion js/passwordManager/onePassword.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,29 @@ class OnePassword {
return compareVersions('2.2.0', data) >= 0
}

async _completeIntegrationPrompt (command) {
try {
const process = new ProcessSpawner(command, ['whoami'], {}, 1000)
await process.executeSyncInAsyncContext()
} catch (e) {
if (e.toString().includes('Would you like to turn on the 1Password app integration?')) {
console.warn('disabling 1password app integration')
try {
const retryProcess = new ProcessSpawner(command, ['whoami'], {}, 1000)
await retryProcess.executeSyncInAsyncContext('n\n')
} catch (e) {
console.warn(e)
}
}
}
return true
}

// Checks if 1Password integration is configured properly by trying to
// obtain a valid 1Password-CLI tool path.
async checkIfConfigured () {
this.path = await this._getToolPath()
return this.path != null && (await this._checkVersion(this.path))
return this.path != null && (await this._checkVersion(this.path)) && (await this._completeIntegrationPrompt(this.path))
}

// Returns current 1Password-CLI status. If we have a session key, then
Expand Down
15 changes: 13 additions & 2 deletions js/preload/passwordFill.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,18 @@ wanted to keep it lightweight and not impact browser performace too much.
*/

// "carbon:password"
const keyIcon = '<svg width="22px" height="22px" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" focusable="false" width="1em" height="1em" style="vertical-align: -0.125em;-ms-transform: rotate(360deg); -webkit-transform: rotate(360deg); transform: rotate(360deg);" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M21 2a9 9 0 0 0-9 9a8.87 8.87 0 0 0 .39 2.61L2 24v6h6l10.39-10.39A9 9 0 0 0 30 11.74a8.77 8.77 0 0 0-1.65-6A9 9 0 0 0 21 2zm0 16a7 7 0 0 1-2-.3l-1.15-.35l-.85.85l-3.18 3.18L12.41 20L11 21.41l1.38 1.38l-1.59 1.59L9.41 23L8 24.41l1.38 1.38L7.17 28H4v-3.17L13.8 15l.85-.85l-.29-.95a7.14 7.14 0 0 1 3.4-8.44a7 7 0 0 1 10.24 6a6.69 6.69 0 0 1-1.09 4A7 7 0 0 1 21 18z" fill="currentColor"/><circle cx="22" cy="10" r="2" fill="currentColor"/></svg>'

const getKeyIcon = () => {
const keyIcon = '<svg width="22px" height="22px" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" focusable="false" width="1em" height="1em" style="vertical-align: -0.125em;-ms-transform: rotate(360deg); -webkit-transform: rotate(360deg); transform: rotate(360deg);" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M21 2a9 9 0 0 0-9 9a8.87 8.87 0 0 0 .39 2.61L2 24v6h6l10.39-10.39A9 9 0 0 0 30 11.74a8.77 8.77 0 0 0-1.65-6A9 9 0 0 0 21 2zm0 16a7 7 0 0 1-2-.3l-1.15-.35l-.85.85l-3.18 3.18L12.41 20L11 21.41l1.38 1.38l-1.59 1.59L9.41 23L8 24.41l1.38 1.38L7.17 28H4v-3.17L13.8 15l.85-.85l-.29-.95a7.14 7.14 0 0 1 3.4-8.44a7 7 0 0 1 10.24 6a6.69 6.69 0 0 1-1.09 4A7 7 0 0 1 21 18z" fill="currentColor"/><circle cx="22" cy="10" r="2" fill="currentColor"/></svg>'

const keyIconPolicy = trustedTypes.createPolicy('minAutofillTrustedKeyIcon', {
createHTML: (string) => string
})

return keyIconPolicy.createHTML(keyIcon)
}

const keyIcon = getKeyIcon()

// Ref to added unlock button.
var currentUnlockButton = null
Expand Down Expand Up @@ -120,7 +131,7 @@ function getBestInput (names, exclusionNames, types) {

// Shortcut to get username fields from a page.
function getBestUsernameField () {
return getBestInput(['user', 'name', 'mail', 'login', 'auth', 'identifier'], ['confirm', 'filename'], ['text', 'email'])
return getBestInput(['user', 'name', 'mail', 'login', 'auth', 'identifier', 'account', 'acct'], ['confirm', 'filename'], ['text', 'email'])
}

// Shortcut to get password fields from a page.
Expand Down

0 comments on commit 5d7f3c0

Please sign in to comment.