finish autofill from view, other misc cleanup (#1368)
* finish autofill from view, other misc cleanup * compare hostnames for authResult
This commit is contained in:
parent
d4d5ccc4a4
commit
b7c2c76230
|
@ -1303,8 +1303,8 @@
|
||||||
"autoFillAndSave": {
|
"autoFillAndSave": {
|
||||||
"message": "Auto-fill and Save"
|
"message": "Auto-fill and Save"
|
||||||
},
|
},
|
||||||
"savedUri": {
|
"autoFillSuccessAndSavedUri": {
|
||||||
"message": "Auto-filled and Saved Item"
|
"message": "Auto-filled Item and Saved URI"
|
||||||
},
|
},
|
||||||
"autoFillSuccess": {
|
"autoFillSuccess": {
|
||||||
"message": "Auto-filled Item"
|
"message": "Auto-filled Item"
|
||||||
|
|
|
@ -219,8 +219,8 @@ export default class MainBackground {
|
||||||
// Background
|
// Background
|
||||||
this.runtimeBackground = new RuntimeBackground(this, this.autofillService, this.cipherService,
|
this.runtimeBackground = new RuntimeBackground(this, this.autofillService, this.cipherService,
|
||||||
this.platformUtilsService as BrowserPlatformUtilsService, this.storageService, this.i18nService,
|
this.platformUtilsService as BrowserPlatformUtilsService, this.storageService, this.i18nService,
|
||||||
this.analytics, this.notificationsService, this.systemService, this.vaultTimeoutService, this.syncService,
|
this.analytics, this.notificationsService, this.systemService, this.vaultTimeoutService,
|
||||||
this.authService, this.stateService, this.environmentService, this.popupUtilsService);
|
this.environmentService);
|
||||||
this.commandsBackground = new CommandsBackground(this, this.passwordGenerationService,
|
this.commandsBackground = new CommandsBackground(this, this.passwordGenerationService,
|
||||||
this.platformUtilsService, this.analytics, this.vaultTimeoutService);
|
this.platformUtilsService, this.analytics, this.vaultTimeoutService);
|
||||||
|
|
||||||
|
|
|
@ -38,8 +38,7 @@ export default class RuntimeBackground {
|
||||||
private storageService: StorageService, private i18nService: I18nService,
|
private storageService: StorageService, private i18nService: I18nService,
|
||||||
private analytics: Analytics, private notificationsService: NotificationsService,
|
private analytics: Analytics, private notificationsService: NotificationsService,
|
||||||
private systemService: SystemService, private vaultTimeoutService: VaultTimeoutService,
|
private systemService: SystemService, private vaultTimeoutService: VaultTimeoutService,
|
||||||
private syncService: SyncService, private authService: AuthService, private stateService: StateService,
|
private environmentService: EnvironmentService) {
|
||||||
private environmentService: EnvironmentService, private popupUtilsService : PopupUtilsService) {
|
|
||||||
this.isSafari = this.platformUtilsService.isSafari();
|
this.isSafari = this.platformUtilsService.isSafari();
|
||||||
this.runtime = this.isSafari ? {} : chrome.runtime;
|
this.runtime = this.isSafari ? {} : chrome.runtime;
|
||||||
|
|
||||||
|
@ -165,25 +164,21 @@ export default class RuntimeBackground {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'authResult':
|
case 'authResult':
|
||||||
var vaultUrl = this.environmentService.webVaultUrl;
|
let vaultUrl = this.environmentService.webVaultUrl;
|
||||||
if(!vaultUrl) {
|
if (vaultUrl == null) {
|
||||||
vaultUrl = 'https://vault.bitwarden.com';
|
vaultUrl = 'https://vault.bitwarden.com';
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!msg.referrer) {
|
if (msg.referrer == null || Utils.getHostname(vaultUrl) !== msg.referrer) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!vaultUrl.includes(msg.referrer)) {
|
try {
|
||||||
return;
|
chrome.tabs.create({
|
||||||
}
|
url: 'popup/index.html?uilocation=popout#/sso?code=' + msg.code + '&state=' + msg.state
|
||||||
|
});
|
||||||
try {
|
}
|
||||||
chrome.tabs.create({
|
catch { }
|
||||||
url: 'popup/index.html?uilocation=popout#/sso?code=' + msg.code + '&state=' + msg.state
|
|
||||||
});
|
|
||||||
}
|
|
||||||
catch { }
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -14,6 +14,8 @@ export default class TabsBackground {
|
||||||
|
|
||||||
this.tabs.onActivated.addListener(async (activeInfo: any) => {
|
this.tabs.onActivated.addListener(async (activeInfo: any) => {
|
||||||
await this.main.refreshBadgeAndMenu();
|
await this.main.refreshBadgeAndMenu();
|
||||||
|
this.main.messagingService.send('tabActivated');
|
||||||
|
this.main.messagingService.send('tabChanged');
|
||||||
});
|
});
|
||||||
|
|
||||||
this.tabs.onReplaced.addListener(async (addedTabId: any, removedTabId: any) => {
|
this.tabs.onReplaced.addListener(async (addedTabId: any, removedTabId: any) => {
|
||||||
|
@ -23,6 +25,8 @@ export default class TabsBackground {
|
||||||
this.main.onReplacedRan = true;
|
this.main.onReplacedRan = true;
|
||||||
await this.main.checkNotificationQueue();
|
await this.main.checkNotificationQueue();
|
||||||
await this.main.refreshBadgeAndMenu();
|
await this.main.refreshBadgeAndMenu();
|
||||||
|
this.main.messagingService.send('tabReplaced');
|
||||||
|
this.main.messagingService.send('tabChanged');
|
||||||
});
|
});
|
||||||
|
|
||||||
this.tabs.onUpdated.addListener(async (tabId: any, changeInfo: any, tab: any) => {
|
this.tabs.onUpdated.addListener(async (tabId: any, changeInfo: any, tab: any) => {
|
||||||
|
@ -32,6 +36,8 @@ export default class TabsBackground {
|
||||||
this.main.onUpdatedRan = true;
|
this.main.onUpdatedRan = true;
|
||||||
await this.main.checkNotificationQueue();
|
await this.main.checkNotificationQueue();
|
||||||
await this.main.refreshBadgeAndMenu();
|
await this.main.refreshBadgeAndMenu();
|
||||||
|
this.main.messagingService.send('tabUpdated');
|
||||||
|
this.main.messagingService.send('tabChanged');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,8 @@ export default class WindowsBackground {
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.main.refreshBadgeAndMenu();
|
await this.main.refreshBadgeAndMenu();
|
||||||
|
this.main.messagingService.send('windowFocused');
|
||||||
|
this.main.messagingService.send('windowChanged');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -215,11 +215,9 @@ export class BrowserApi {
|
||||||
}
|
}
|
||||||
|
|
||||||
static reloadOpenWindows() {
|
static reloadOpenWindows() {
|
||||||
if(!BrowserApi.isSafariApi)
|
if (!BrowserApi.isSafariApi) {
|
||||||
{
|
const sidebarWindows = chrome.extension.getViews({ type: 'sidebar' });
|
||||||
var sidebarName : string = 'sidebar';
|
if (sidebarWindows && sidebarWindows.length > 0) {
|
||||||
var sidebarWindows = chrome.extension.getViews({ type: sidebarName });
|
|
||||||
if(sidebarWindows && sidebarWindows.length > 0) {
|
|
||||||
sidebarWindows[0].location.reload();
|
sidebarWindows[0].location.reload();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
window.addEventListener("message", function(event) {
|
window.addEventListener('message', (event) => {
|
||||||
if (event.source != window)
|
if (event.source !== window)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (event.data.command && (event.data.command == "authResult")) {
|
if (event.data.command && (event.data.command === 'authResult')) {
|
||||||
chrome.runtime.sendMessage({
|
chrome.runtime.sendMessage({
|
||||||
command: event.data.command,
|
command: event.data.command,
|
||||||
code: event.data.code,
|
code: event.data.code,
|
||||||
state: event.data.state,
|
state: event.data.state,
|
||||||
referrer: event.source.location.hostname
|
referrer: event.source.location.hostname,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, false)
|
}, false)
|
|
@ -14,42 +14,39 @@ import { Utils } from 'jslib/misc/utils';
|
||||||
templateUrl: 'home.component.html',
|
templateUrl: 'home.component.html',
|
||||||
})
|
})
|
||||||
export class HomeComponent {
|
export class HomeComponent {
|
||||||
constructor(
|
constructor(protected platformUtilsService: PlatformUtilsService,
|
||||||
protected platformUtilsService: PlatformUtilsService,
|
private passwordGenerationService: PasswordGenerationService, private storageService: StorageService,
|
||||||
private passwordGenerationService : PasswordGenerationService,
|
private cryptoFunctionService: CryptoFunctionService, private environmentService: EnvironmentService) { }
|
||||||
private cryptoFunctionService: CryptoFunctionService,
|
|
||||||
private environmentService: EnvironmentService,
|
|
||||||
private storageService : StorageService) { }
|
|
||||||
|
|
||||||
async launchSsoBrowser() {
|
async launchSsoBrowser() {
|
||||||
// Generate necessary sso params
|
// Generate necessary sso params
|
||||||
const passwordOptions: any = {
|
const passwordOptions: any = {
|
||||||
type: 'password',
|
type: 'password',
|
||||||
length: 64,
|
length: 64,
|
||||||
uppercase: true,
|
uppercase: true,
|
||||||
lowercase: true,
|
lowercase: true,
|
||||||
numbers: true,
|
numbers: true,
|
||||||
special: false,
|
special: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
const state = (await this.passwordGenerationService.generatePassword(passwordOptions)) + ':clientId=browser';
|
const state = (await this.passwordGenerationService.generatePassword(passwordOptions)) + ':clientId=browser';
|
||||||
let codeVerifier = await this.passwordGenerationService.generatePassword(passwordOptions);
|
const codeVerifier = await this.passwordGenerationService.generatePassword(passwordOptions);
|
||||||
const codeVerifierHash = await this.cryptoFunctionService.hash(codeVerifier, 'sha256');
|
const codeVerifierHash = await this.cryptoFunctionService.hash(codeVerifier, 'sha256');
|
||||||
const codeChallenge = Utils.fromBufferToUrlB64(codeVerifierHash);
|
const codeChallenge = Utils.fromBufferToUrlB64(codeVerifierHash);
|
||||||
|
|
||||||
await this.storageService.save(ConstantsService.ssoCodeVerifierKey, codeVerifier);
|
await this.storageService.save(ConstantsService.ssoCodeVerifierKey, codeVerifier);
|
||||||
await this.storageService.save(ConstantsService.ssoStateKey, state);
|
await this.storageService.save(ConstantsService.ssoStateKey, state);
|
||||||
|
|
||||||
let url = this.environmentService.getWebVaultUrl();
|
let url = this.environmentService.getWebVaultUrl();
|
||||||
if (url == null) {
|
if (url == null) {
|
||||||
url = 'https://vault.bitwarden.com';
|
url = 'https://vault.bitwarden.com';
|
||||||
}
|
|
||||||
|
|
||||||
const redirectUri = url + '/sso-connector.html';
|
|
||||||
|
|
||||||
// Launch browser
|
|
||||||
this.platformUtilsService.launchUri(url + '/#/sso?clientId=browser' +
|
|
||||||
'&redirectUri=' + encodeURIComponent(redirectUri) +
|
|
||||||
'&state=' + state + '&codeChallenge=' + codeChallenge);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const redirectUri = url + '/sso-connector.html';
|
||||||
|
|
||||||
|
// Launch browser
|
||||||
|
this.platformUtilsService.launchUri(url + '/#/sso?clientId=browser' +
|
||||||
|
'&redirectUri=' + encodeURIComponent(redirectUri) +
|
||||||
|
'&state=' + state + '&codeChallenge=' + codeChallenge);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,8 @@ export class LoginComponent extends BaseLoginComponent {
|
||||||
protected platformUtilsService: PlatformUtilsService, protected i18nService: I18nService,
|
protected platformUtilsService: PlatformUtilsService, protected i18nService: I18nService,
|
||||||
protected stateService: StateService, protected environmentService: EnvironmentService,
|
protected stateService: StateService, protected environmentService: EnvironmentService,
|
||||||
protected passwordGenerationService: PasswordGenerationService,
|
protected passwordGenerationService: PasswordGenerationService,
|
||||||
protected cryptoFunctionService: CryptoFunctionService,
|
protected cryptoFunctionService: CryptoFunctionService, storageService: StorageService,
|
||||||
storageService: StorageService, syncService : SyncService) {
|
syncService: SyncService) {
|
||||||
super(authService, router, platformUtilsService, i18nService, stateService, environmentService, passwordGenerationService, cryptoFunctionService, storageService);
|
super(authService, router, platformUtilsService, i18nService, stateService, environmentService, passwordGenerationService, cryptoFunctionService, storageService);
|
||||||
super.onSuccessfulLogin = () => {
|
super.onSuccessfulLogin = () => {
|
||||||
return syncService.fullSync(true);
|
return syncService.fullSync(true);
|
||||||
|
|
|
@ -29,7 +29,7 @@ export class SsoComponent extends BaseSsoComponent {
|
||||||
storageService: StorageService, stateService: StateService,
|
storageService: StorageService, stateService: StateService,
|
||||||
platformUtilsService: PlatformUtilsService, apiService: ApiService,
|
platformUtilsService: PlatformUtilsService, apiService: ApiService,
|
||||||
cryptoFunctionService: CryptoFunctionService, passwordGenerationService: PasswordGenerationService,
|
cryptoFunctionService: CryptoFunctionService, passwordGenerationService: PasswordGenerationService,
|
||||||
syncService: SyncService, private environmentService: EnvironmentService ) {
|
syncService: SyncService, private environmentService: EnvironmentService) {
|
||||||
super(authService, router, i18nService, route, storageService, stateService, platformUtilsService,
|
super(authService, router, i18nService, route, storageService, stateService, platformUtilsService,
|
||||||
apiService, cryptoFunctionService, passwordGenerationService);
|
apiService, cryptoFunctionService, passwordGenerationService);
|
||||||
|
|
||||||
|
@ -42,10 +42,10 @@ export class SsoComponent extends BaseSsoComponent {
|
||||||
this.clientId = 'browser';
|
this.clientId = 'browser';
|
||||||
|
|
||||||
super.onSuccessfulLogin = () => {
|
super.onSuccessfulLogin = () => {
|
||||||
BrowserApi.reloadOpenWindows();
|
BrowserApi.reloadOpenWindows();
|
||||||
const thisWindow = window.open('', '_self');
|
const thisWindow = window.open('', '_self');
|
||||||
thisWindow.close();
|
thisWindow.close();
|
||||||
return syncService.fullSync(true);
|
return syncService.fullSync(true);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
<div class="box-content">
|
<div class="box-content">
|
||||||
<div class="box-content-row">
|
<div class="box-content-row">
|
||||||
<span class="row-label">{{'name' | i18n}}</span>
|
<span class="row-label">{{'name' | i18n}}</span>
|
||||||
<input type="text" [value]="cipher.name" readonly aria-readonly="true"/>
|
<input type="text" [value]="cipher.name" readonly aria-readonly="true" />
|
||||||
</div>
|
</div>
|
||||||
<!-- Login -->
|
<!-- Login -->
|
||||||
<div *ngIf="cipher.login">
|
<div *ngIf="cipher.login">
|
||||||
|
@ -60,8 +60,7 @@
|
||||||
[ngClass]="{'fa-eye': !showPassword, 'fa-eye-slash': showPassword}"></i>
|
[ngClass]="{'fa-eye': !showPassword, 'fa-eye-slash': showPassword}"></i>
|
||||||
</a>
|
</a>
|
||||||
<a class="row-btn" href="#" appStopClick appA11yTitle="{{'copyPassword' | i18n}}"
|
<a class="row-btn" href="#" appStopClick appA11yTitle="{{'copyPassword' | i18n}}"
|
||||||
(click)="copy(cipher.login.password, 'password', 'Password')"
|
(click)="copy(cipher.login.password, 'password', 'Password')" *ngIf="cipher.viewPassword">
|
||||||
*ngIf="cipher.viewPassword">
|
|
||||||
<i class="fa fa-lg fa-clone" aria-hidden="true"></i>
|
<i class="fa fa-lg fa-clone" aria-hidden="true"></i>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
@ -238,7 +237,8 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="action-buttons">
|
<div class="action-buttons">
|
||||||
<a class="row-btn" href="#" appStopClick appA11yTitle="{{'toggleVisibility' | i18n}}"
|
<a class="row-btn" href="#" appStopClick appA11yTitle="{{'toggleVisibility' | i18n}}"
|
||||||
*ngIf="field.type === fieldType.Hidden && cipher.viewPassword" (click)="toggleFieldValue(field)">
|
*ngIf="field.type === fieldType.Hidden && cipher.viewPassword"
|
||||||
|
(click)="toggleFieldValue(field)">
|
||||||
<i class="fa fa-lg" aria-hidden="true"
|
<i class="fa fa-lg" aria-hidden="true"
|
||||||
[ngClass]="{'fa-eye': !field.showValue, 'fa-eye-slash': field.showValue}"></i>
|
[ngClass]="{'fa-eye': !field.showValue, 'fa-eye-slash': field.showValue}"></i>
|
||||||
</a>
|
</a>
|
||||||
|
|
|
@ -38,7 +38,9 @@ const BroadcasterSubscriptionId = 'ChildViewComponent';
|
||||||
export class ViewComponent extends BaseViewComponent {
|
export class ViewComponent extends BaseViewComponent {
|
||||||
showAttachments = true;
|
showAttachments = true;
|
||||||
pageDetails: any[] = [];
|
pageDetails: any[] = [];
|
||||||
inPopout: boolean = false;
|
tab: any;
|
||||||
|
loadPageDetailsTimeout: number;
|
||||||
|
inPopout = false;
|
||||||
|
|
||||||
constructor(cipherService: CipherService, totpService: TotpService,
|
constructor(cipherService: CipherService, totpService: TotpService,
|
||||||
tokenService: TokenService, i18nService: I18nService,
|
tokenService: TokenService, i18nService: I18nService,
|
||||||
|
@ -68,6 +70,7 @@ export class ViewComponent extends BaseViewComponent {
|
||||||
queryParamsSub.unsubscribe();
|
queryParamsSub.unsubscribe();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
super.ngOnInit();
|
super.ngOnInit();
|
||||||
|
|
||||||
this.broadcasterService.subscribe(BroadcasterSubscriptionId, (message: any) => {
|
this.broadcasterService.subscribe(BroadcasterSubscriptionId, (message: any) => {
|
||||||
|
@ -82,6 +85,13 @@ export class ViewComponent extends BaseViewComponent {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'tabChanged':
|
||||||
|
case 'windowChanged':
|
||||||
|
if (this.loadPageDetailsTimeout != null) {
|
||||||
|
window.clearTimeout(this.loadPageDetailsTimeout);
|
||||||
|
}
|
||||||
|
this.loadPageDetailsTimeout = window.setTimeout(() => this.loadPageDetails(), 500);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -90,8 +100,13 @@ export class ViewComponent extends BaseViewComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
this.broadcasterService.unsubscribe(BroadcasterSubscriptionId);
|
|
||||||
super.ngOnDestroy();
|
super.ngOnDestroy();
|
||||||
|
this.broadcasterService.unsubscribe(BroadcasterSubscriptionId);
|
||||||
|
}
|
||||||
|
|
||||||
|
async load() {
|
||||||
|
await super.load();
|
||||||
|
await this.loadPageDetails();
|
||||||
}
|
}
|
||||||
|
|
||||||
edit() {
|
edit() {
|
||||||
|
@ -116,7 +131,7 @@ export class ViewComponent extends BaseViewComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
async fillCipher() {
|
async fillCipher() {
|
||||||
const didAutofill: boolean = await this.doAutofill();
|
const didAutofill = await this.doAutofill();
|
||||||
if (didAutofill) {
|
if (didAutofill) {
|
||||||
this.platformUtilsService.showToast('success', null,
|
this.platformUtilsService.showToast('success', null,
|
||||||
this.i18nService.t('autoFillSuccess'));
|
this.i18nService.t('autoFillSuccess'));
|
||||||
|
@ -124,35 +139,32 @@ export class ViewComponent extends BaseViewComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
async fillCipherAndSave() {
|
async fillCipherAndSave() {
|
||||||
const didAutofill: boolean = await this.doAutofill();
|
const didAutofill = await this.doAutofill();
|
||||||
|
|
||||||
if (didAutofill) {
|
if (didAutofill) {
|
||||||
const tab = await BrowserApi.getTabFromCurrentWindow();
|
if (this.tab == null) {
|
||||||
if (!tab) {
|
|
||||||
throw new Error('No tab found.');
|
throw new Error('No tab found.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.cipher.login.uris == null) {
|
if (this.cipher.login.uris == null) {
|
||||||
this.cipher.login.uris = [];
|
this.cipher.login.uris = [];
|
||||||
} else {
|
} else {
|
||||||
if (this.cipher.login.uris.some((uri) => uri.uri === tab.url)) {
|
if (this.cipher.login.uris.some((uri) => uri.uri === this.tab.url)) {
|
||||||
this.platformUtilsService.showToast('success', null,
|
this.platformUtilsService.showToast('success', null,
|
||||||
this.i18nService.t('savedURI'));
|
this.i18nService.t('autoFillSuccessAndSavedUri'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const loginUri: LoginUriView = new LoginUriView();
|
const loginUri = new LoginUriView();
|
||||||
loginUri.uri = tab.url;
|
loginUri.uri = this.tab.url;
|
||||||
this.cipher.login.uris.push(loginUri);
|
this.cipher.login.uris.push(loginUri);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const cipher: Cipher = await this.cipherService.encrypt(this.cipher);
|
const cipher: Cipher = await this.cipherService.encrypt(this.cipher);
|
||||||
await this.cipherService.saveWithServer(cipher);
|
await this.cipherService.saveWithServer(cipher);
|
||||||
this.cipher.id = cipher.id;
|
|
||||||
|
|
||||||
this.platformUtilsService.showToast('success', null,
|
this.platformUtilsService.showToast('success', null,
|
||||||
this.i18nService.t('savedURI'));
|
this.i18nService.t('autoFillSuccessAndSavedUri'));
|
||||||
this.messagingService.send('editedCipher');
|
this.messagingService.send('editedCipher');
|
||||||
} catch {
|
} catch {
|
||||||
this.platformUtilsService.showToast('error', null,
|
this.platformUtilsService.showToast('error', null,
|
||||||
|
@ -161,45 +173,6 @@ export class ViewComponent extends BaseViewComponent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async doAutofill() {
|
|
||||||
if (this.pageDetails == null || this.pageDetails.length === 0) {
|
|
||||||
this.platformUtilsService.showToast('error', null,
|
|
||||||
this.i18nService.t('autofillError'));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
this.totpCode = await this.autofillService.doAutoFill({
|
|
||||||
cipher: this.cipher,
|
|
||||||
pageDetails: this.pageDetails,
|
|
||||||
doc: window.document,
|
|
||||||
});
|
|
||||||
if (this.totpCode != null) {
|
|
||||||
this.platformUtilsService.copyToClipboard(this.totpCode, { window: window });
|
|
||||||
}
|
|
||||||
} catch {
|
|
||||||
this.platformUtilsService.showToast('error', null,
|
|
||||||
this.i18nService.t('autofillError'));
|
|
||||||
this.changeDetectorRef.detectChanges();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
async load() {
|
|
||||||
await super.load();
|
|
||||||
|
|
||||||
const tab = await BrowserApi.getTabFromCurrentWindow();
|
|
||||||
|
|
||||||
this.pageDetails = [];
|
|
||||||
BrowserApi.tabSendMessage(tab, {
|
|
||||||
command: 'collectPageDetails',
|
|
||||||
tab: tab,
|
|
||||||
sender: BroadcasterSubscriptionId,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async restore() {
|
async restore() {
|
||||||
if (!this.cipher.isDeleted) {
|
if (!this.cipher.isDeleted) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -222,4 +195,43 @@ export class ViewComponent extends BaseViewComponent {
|
||||||
close() {
|
close() {
|
||||||
this.location.back();
|
this.location.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async loadPageDetails() {
|
||||||
|
this.pageDetails = [];
|
||||||
|
this.tab = await BrowserApi.getTabFromCurrentWindow();
|
||||||
|
if (this.tab == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
BrowserApi.tabSendMessage(this.tab, {
|
||||||
|
command: 'collectPageDetails',
|
||||||
|
tab: this.tab,
|
||||||
|
sender: BroadcasterSubscriptionId,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private async doAutofill() {
|
||||||
|
if (this.pageDetails == null || this.pageDetails.length === 0) {
|
||||||
|
this.platformUtilsService.showToast('error', null,
|
||||||
|
this.i18nService.t('autofillError'));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
this.totpCode = await this.autofillService.doAutoFill({
|
||||||
|
cipher: this.cipher,
|
||||||
|
pageDetails: this.pageDetails,
|
||||||
|
doc: window.document,
|
||||||
|
});
|
||||||
|
if (this.totpCode != null) {
|
||||||
|
this.platformUtilsService.copyToClipboard(this.totpCode, { window: window });
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
this.platformUtilsService.showToast('error', null,
|
||||||
|
this.i18nService.t('autofillError'));
|
||||||
|
this.changeDetectorRef.detectChanges();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue