diff --git a/js/passwordManager/onePassword.js b/js/passwordManager/onePassword.js index 699054cea..60f4facdb 100644 --- a/js/passwordManager/onePassword.js +++ b/js/passwordManager/onePassword.js @@ -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 diff --git a/js/preload/passwordFill.js b/js/preload/passwordFill.js index a8a0eb17d..176b09a15 100644 --- a/js/preload/passwordFill.js +++ b/js/preload/passwordFill.js @@ -24,7 +24,18 @@ wanted to keep it lightweight and not impact browser performace too much. */ // "carbon:password" -const keyIcon = '' + +const getKeyIcon = () => { + const keyIcon = '' + + const keyIconPolicy = trustedTypes.createPolicy('minAutofillTrustedKeyIcon', { + createHTML: (string) => string + }) + + return keyIconPolicy.createHTML(keyIcon) +} + +const keyIcon = getKeyIcon() // Ref to added unlock button. var currentUnlockButton = null @@ -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.