clients/src/content/message_handler.ts
Daniel James Smith 71913a5eb5
Update badge number when saving a new entry (#2284)
* Rename message to changePasswordMessage

* Rename message variable to addLoginMessage

* Add early return and remove unneeded if below

* Update badge and menu after adding an entry

* Adjusted casing of enum properties

* Add explicit check for queueMessageType

* Turn NotificationQueueMessageType into simple enum
2022-01-25 08:16:36 +01:00

39 lines
941 B
TypeScript

window.addEventListener(
"message",
(event) => {
if (event.source !== window) return;
if (event.data.command && event.data.command === "authResult") {
chrome.runtime.sendMessage({
command: event.data.command,
code: event.data.code,
state: event.data.state,
referrer: event.source.location.hostname,
});
}
if (event.data.command && event.data.command === "webAuthnResult") {
chrome.runtime.sendMessage({
command: event.data.command,
data: event.data.data,
remember: event.data.remember,
referrer: event.source.location.hostname,
});
}
},
false
);
const forwardCommands = [
"promptForLogin",
"addToLockedVaultPendingNotifications",
"unlockCompleted",
"addedCipher",
];
chrome.runtime.onMessage.addListener((event) => {
if (forwardCommands.includes(event.command)) {
chrome.runtime.sendMessage(event);
}
});