mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 16:23:44 +00:00
Add types for addLogin and changePassword runtime messages
This commit is contained in:
5
src/background/models/addLoginRuntimeMessage.ts
Normal file
5
src/background/models/addLoginRuntimeMessage.ts
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
export default class AddLoginRuntimeMessage {
|
||||||
|
username: string;
|
||||||
|
password: string;
|
||||||
|
url: string;
|
||||||
|
}
|
||||||
5
src/background/models/changePasswordRuntimeMessage.ts
Normal file
5
src/background/models/changePasswordRuntimeMessage.ts
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
export default class ChangePasswordRuntimeMessage {
|
||||||
|
currentPassword: string;
|
||||||
|
newPassword: string;
|
||||||
|
url: string;
|
||||||
|
}
|
||||||
@@ -22,6 +22,8 @@ import { PolicyType } from 'jslib-common/enums/policyType';
|
|||||||
|
|
||||||
import AddChangePasswordQueueMessage from './models/addChangePasswordQueueMessage';
|
import AddChangePasswordQueueMessage from './models/addChangePasswordQueueMessage';
|
||||||
import AddLoginQueueMessage from './models/addLoginQueueMessage';
|
import AddLoginQueueMessage from './models/addLoginQueueMessage';
|
||||||
|
import AddLoginRuntimeMessage from './models/addLoginRuntimeMessage';
|
||||||
|
import ChangePasswordRuntimeMessage from './models/changePasswordRuntimeMessage';
|
||||||
import LockedVaultPendingNotificationsItem from './models/lockedVaultPendingNotificationsItem';
|
import LockedVaultPendingNotificationsItem from './models/lockedVaultPendingNotificationsItem';
|
||||||
import { NotificationQueueMessageType } from './models/NotificationQueueMessageType';
|
import { NotificationQueueMessageType } from './models/NotificationQueueMessageType';
|
||||||
|
|
||||||
@@ -178,7 +180,7 @@ export default class NotificationBackground {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async addLogin(loginInfo: any, tab: chrome.tabs.Tab) {
|
private async addLogin(loginInfo: AddLoginRuntimeMessage, tab: chrome.tabs.Tab) {
|
||||||
const loginDomain = Utils.getDomain(loginInfo.url);
|
const loginDomain = Utils.getDomain(loginInfo.url);
|
||||||
if (loginDomain == null) {
|
if (loginDomain == null) {
|
||||||
return;
|
return;
|
||||||
@@ -220,7 +222,7 @@ export default class NotificationBackground {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async pushAddLoginToQueue(loginDomain: string, loginInfo: any, tab: chrome.tabs.Tab, isVaultLocked: boolean = false) {
|
private async pushAddLoginToQueue(loginDomain: string, loginInfo: AddLoginRuntimeMessage, tab: chrome.tabs.Tab, isVaultLocked: boolean = false) {
|
||||||
// remove any old messages for this tab
|
// remove any old messages for this tab
|
||||||
this.removeTabFromNotificationQueue(tab);
|
this.removeTabFromNotificationQueue(tab);
|
||||||
const message: AddLoginQueueMessage = {
|
const message: AddLoginQueueMessage = {
|
||||||
@@ -237,7 +239,7 @@ export default class NotificationBackground {
|
|||||||
await this.checkNotificationQueue(tab);
|
await this.checkNotificationQueue(tab);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async changedPassword(changeData: any, tab: chrome.tabs.Tab) {
|
private async changedPassword(changeData: ChangePasswordRuntimeMessage, tab: chrome.tabs.Tab) {
|
||||||
const loginDomain = Utils.getDomain(changeData.url);
|
const loginDomain = Utils.getDomain(changeData.url);
|
||||||
if (loginDomain == null) {
|
if (loginDomain == null) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
import AddLoginRuntimeMessage from 'src/background/models/addLoginRuntimeMessage';
|
||||||
|
import ChangePasswordRuntimeMessage from 'src/background/models/changePasswordRuntimeMessage';
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', event => {
|
document.addEventListener('DOMContentLoaded', event => {
|
||||||
if (window.location.hostname.indexOf('vault.bitwarden.com') > -1) {
|
if (window.location.hostname.indexOf('vault.bitwarden.com') > -1) {
|
||||||
return;
|
return;
|
||||||
@@ -294,7 +297,7 @@ document.addEventListener('DOMContentLoaded', event => {
|
|||||||
}
|
}
|
||||||
const disabledBoth = disabledChangedPasswordNotification && disabledAddLoginNotification;
|
const disabledBoth = disabledChangedPasswordNotification && disabledAddLoginNotification;
|
||||||
if (!disabledBoth && formData[i].usernameEl != null && formData[i].passwordEl != null) {
|
if (!disabledBoth && formData[i].usernameEl != null && formData[i].passwordEl != null) {
|
||||||
const login = {
|
const login: AddLoginRuntimeMessage = {
|
||||||
username: formData[i].usernameEl.value,
|
username: formData[i].usernameEl.value,
|
||||||
password: formData[i].passwordEl.value,
|
password: formData[i].passwordEl.value,
|
||||||
url: document.URL,
|
url: document.URL,
|
||||||
@@ -343,13 +346,15 @@ document.addEventListener('DOMContentLoaded', event => {
|
|||||||
|
|
||||||
if (newPass != null && curPass != null || (newPassOnly && newPass != null)) {
|
if (newPass != null && curPass != null || (newPassOnly && newPass != null)) {
|
||||||
processedForm(form);
|
processedForm(form);
|
||||||
|
|
||||||
|
const changePasswordRuntimeMessage: ChangePasswordRuntimeMessage = {
|
||||||
|
newPassword: newPass,
|
||||||
|
currentPassword: curPass,
|
||||||
|
url: document.URL,
|
||||||
|
};
|
||||||
sendPlatformMessage({
|
sendPlatformMessage({
|
||||||
command: 'bgChangedPassword',
|
command: 'bgChangedPassword',
|
||||||
data: {
|
data: changePasswordRuntimeMessage,
|
||||||
newPassword: newPass,
|
|
||||||
currentPassword: curPass,
|
|
||||||
url: document.URL,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user