Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
martgil committed Jul 28, 2024
1 parent eb5a1b0 commit cd8dbb9
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export const contentScriptSetupIfVacant = async (webmailSpecific: WebmailSpecifi
let acctEmailInterval = 1000;
const webmails = await Env.webmails();
while (true) {
// todo - find a way to obtain current user account from Thundermail
const acctEmail = webmailSpecific.getUserAccountEmail();
if (typeof acctEmail !== 'undefined') {
win.account_email_global = acctEmail;
Expand Down Expand Up @@ -515,6 +516,9 @@ export const contentScriptSetupIfVacant = async (webmailSpecific: WebmailSpecifi
document.dispatchEvent(new CustomEvent(win.destruction_event));
document.addEventListener(win.destruction_event, win.destroy);

if (Catch.isThunderbirdMail()) {
await entrypoint();
}
if (win.vacant()) {
await entrypoint();
} else if (Catch.isFirefox()) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,27 @@

'use strict';

import { Catch } from '../../../common/platform/catch';
import { IntervalFunction, WebmailElementReplacer } from '../generic/webmail-element-replacer';

export class ThunderbirdElementReplacer extends WebmailElementReplacer {
public getIntervalFunctions: () => IntervalFunction[];
// public getIntervalFunctions: () => IntervalFunction[];
public setReplyBoxEditable: () => Promise<void>;
public reinsertReplyBox: (replyMsgId: string) => void;
public scrollToReplyBox: (replyMsgId: string) => void;
public scrollToCursorInReplyBox: (replyMsgId: string, cursorOffsetTop: number) => void;

public getIntervalFunctions = (): IntervalFunction[] => {
return [{ interval: 1000, handler: () => this.replaceThunderbirdMsgPane() }];
};

public replaceThunderbirdMsgPane = () => {
if (Catch.isThunderbirdMail()) {
// const fullMsg = (await messenger.runtime.sendMessage('decrypt')) as messenger.messages.MessagePart;
// if (fullMsg?.headers && 'openpgp' in fullMsg.headers) {
// // note : embeddedMsg for pgp_block injection -> replaceArmoredBlocks
// // do secure compose badge injection eg. signed or encrypted, (secure email status rendering) etc
// // render decrypted message right into the messageDisplay
}
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ export class ThunderbirdWebmailStartup {
// relayManager: RelayManager // todo in another issue
) => {
// injector.btns(); // todo in another issue - add compose button
this.replacer.runIntervalFunctionsPeriodically();
this.replacer = new ThunderbirdElementReplacer();
this.replacer.getIntervalFunctions();
await notifications.showInitial(acctEmail);
notifications.show(
'FlowCrypt Thunderbird support is still in early development, and not expected to function properly yet. Support will be gradually added in upcoming versions.'
Expand Down
12 changes: 1 addition & 11 deletions extension/js/service_worker/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,6 @@ console.info('background.js service worker starting');
if (Catch.isThunderbirdMail()) {
BgHandlers.thunderbirdSecureComposeHandler();
await BgHandlers.thunderbirdContentScriptRegistration();
chrome.runtime.onMessage.addListener(async (message, sender) => {
if (message === 'decrypt') {
const tabId = sender.tab?.id;
if (tabId) {
const res = await messenger.messageDisplay.getDisplayedMessage(tabId);
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
return await messenger.messages.getFull(res!.id);
}
}
return;
});
// todo - add background listener here with name "thunderbird_msg_decrypt"
}
})().catch(Catch.reportErr);
20 changes: 19 additions & 1 deletion tooling/bundle-content-scripts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,24 @@ buildContentScript(

// thunderbird
buildContentScript(
([] as string[]).concat(getFilesInDir(`${sourceDir}/js/content_scripts/webmail/thunderbird/message-display-scripts`, /\.js$/)),
([] as string[]).concat(
getFilesInDir(`${sourceDir}/js/common/platform`, /\.js$/, false),
getFilesInDir(`${sourceDir}/js/common/platform/store`, /\.js$/, false),
getFilesInDir(`${sourceDir}/js/common/core`, /\.js$/, false),
getFilesInDir(`${sourceDir}/js/common/core/crypto/`, /\.js$/, false),
getFilesInDir(`${sourceDir}/js/common/core/crypto/smime`, /\.js$/, false),
getFilesInDir(`${sourceDir}/js/common/api/shared`, /\.js$/, false),
getFilesInDir(`${sourceDir}/js/common/api/key-server`, /\.js$/, false),
getFilesInDir(`${sourceDir}/js/common/api/account-servers`, /\.js$/, false),
getFilesInDir(`${sourceDir}/js/common/api/authentication/generic`, /\.js$/, false),
getFilesInDir(`${sourceDir}/js/common/api/authentication/google`, /\.js$/, false),
getFilesInDir(`${sourceDir}/js/common/api/authentication`, /\.js$/, false),
getFilesInDir(`${sourceDir}/js/common/api/email-provider`, /\.js$/, false),
getFilesInDir(`${sourceDir}/js/common/api/email-provider/gmail`, /\.js$/, false),
getFilesInDir(`${sourceDir}/js/common/api`, /\.js$/, false),
getFilesInDir(`${sourceDir}/js/common/browser`, /\.js$/, false),
getFilesInDir(`${sourceDir}/js/common`, /\.js$/, false),
getFilesInDir(`${sourceDir}/js/content_scripts/webmail`, /\.js$/)
),
'thunderbird-content-script.js'
);

0 comments on commit cd8dbb9

Please sign in to comment.