Enable unlock on autofill via keyboard shortcut
This commit is contained in:
parent
86e3b9e423
commit
c793552dfd
|
@ -5,6 +5,7 @@ import MainBackground from './main.background';
|
||||||
import { PasswordGenerationService } from 'jslib-common/abstractions/passwordGeneration.service';
|
import { PasswordGenerationService } from 'jslib-common/abstractions/passwordGeneration.service';
|
||||||
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
|
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
|
||||||
import { VaultTimeoutService } from 'jslib-common/abstractions/vaultTimeout.service';
|
import { VaultTimeoutService } from 'jslib-common/abstractions/vaultTimeout.service';
|
||||||
|
import LockedVaultPendingNotificationsItem from './models/lockedVaultPendingNotificationsItem';
|
||||||
|
|
||||||
export default class CommandsBackground {
|
export default class CommandsBackground {
|
||||||
private isSafari: boolean;
|
private isSafari: boolean;
|
||||||
|
@ -17,13 +18,17 @@ export default class CommandsBackground {
|
||||||
}
|
}
|
||||||
|
|
||||||
async init() {
|
async init() {
|
||||||
if (this.isVivaldi) {
|
BrowserApi.messageListener('commands.background', async (msg: any, sender: chrome.runtime.MessageSender, sendResponse: any) => {
|
||||||
BrowserApi.messageListener('commands.background', async (msg: any, sender: chrome.runtime.MessageSender, sendResponse: any) => {
|
if (msg.command === 'unlockCompleted' && msg.data.target === 'commands.background') {
|
||||||
if (msg.command === 'keyboardShortcutTriggered' && msg.shortcut) {
|
await this.processCommand(msg.data.commandToRetry.msg.command, msg.data.commandToRetry.sender);
|
||||||
await this.processCommand(msg.shortcut, sender);
|
}
|
||||||
}
|
|
||||||
});
|
if (this.isVivaldi && msg.command === 'keyboardShortcutTriggered' && msg.shortcut) {
|
||||||
} else if (chrome && chrome.commands) {
|
await this.processCommand(msg.shortcut, sender);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!this.isVivaldi && chrome && chrome.commands) {
|
||||||
chrome.commands.onCommand.addListener(async (command: string) => {
|
chrome.commands.onCommand.addListener(async (command: string) => {
|
||||||
await this.processCommand(command);
|
await this.processCommand(command);
|
||||||
});
|
});
|
||||||
|
@ -57,10 +62,6 @@ export default class CommandsBackground {
|
||||||
}
|
}
|
||||||
|
|
||||||
private async autoFillLogin(tab?: chrome.tabs.Tab) {
|
private async autoFillLogin(tab?: chrome.tabs.Tab) {
|
||||||
if (await this.vaultTimeoutService.isLocked()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!tab) {
|
if (!tab) {
|
||||||
tab = await BrowserApi.getTabFromCurrentWindowId();
|
tab = await BrowserApi.getTabFromCurrentWindowId();
|
||||||
}
|
}
|
||||||
|
@ -69,6 +70,20 @@ export default class CommandsBackground {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (await this.vaultTimeoutService.isLocked()) {
|
||||||
|
const retryMessage: LockedVaultPendingNotificationsItem = {
|
||||||
|
commandToRetry: {
|
||||||
|
msg: { command: 'autofill_login' },
|
||||||
|
sender: { tab: tab },
|
||||||
|
},
|
||||||
|
target: 'commands.background',
|
||||||
|
};
|
||||||
|
await BrowserApi.tabSendMessageData(tab, 'addToLockedVaultPendingNotifications', retryMessage);
|
||||||
|
|
||||||
|
BrowserApi.tabSendMessageData(tab, 'promptForLogin');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
await this.main.collectPageDetailsForContentScript(tab, 'autofill_cmd');
|
await this.main.collectPageDetailsForContentScript(tab, 'autofill_cmd');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue