Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions extension/chrome/dev/ci_pgp_host_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import { Env } from '../../js/common/browser/env.js';
Catch.try(async () => {
const tabId = await BrowserMsg.requiredTabId();

BrowserMsg.addPgpListeners();
// BrowserMsg.addPgpListeners(); // todo - re-allow when https://github.com/FlowCrypt/flowcrypt-browser/issues/2560 fixed
BrowserMsg.listen(tabId);

let src = Env.getBaseUrl();
src += `/chrome/elements/pgp_block.htm?${location.search}`;
src += `/chrome/elements/pgp_block.htm${location.search}`;
src += `&parentTabId=${encodeURIComponent(tabId)}`;
$('body').append(`<iframe src="${Xss.escape(src)}" frameborder="0"></iframe>`); // xss-escaped
$('body').append(`<iframe width="100%" src="${Xss.escape(src)}" frameborder="0"></iframe>`); // xss-escaped
})();
4 changes: 2 additions & 2 deletions extension/chrome/dev/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { Catch } from '../../js/common/platform/catch.js';
import { Gmail } from '../../js/common/api/email-provider/gmail/gmail.js';
import { Ui } from '../../js/common/browser/ui.js';
import { Url } from '../../js/common/core/common.js';
import { openpgp } from '../../js/common/core/pgp.js';
import { opgp } from '../../js/common/core/pgp.js';

Catch.try(async () => {

Expand Down Expand Up @@ -111,7 +111,7 @@ Catch.try(async () => {
const pwd = prompt('Please enter encryption password');
if (pwd) {
print('encrypting..');
const encrypted = await openpgp.encrypt({ armor: false, message: openpgp.message.fromBinary(data), passwords: [pwd] });
const encrypted = await opgp.encrypt({ armor: false, message: opgp.message.fromBinary(data), passwords: [pwd] });
save(encrypted.message.packets.write());
} else {
save(data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { CollectPubkeysResult } from './compose-types.js';
import { PUBKEY_LOOKUP_RESULT_FAIL } from './compose-err-module.js';
import { PgpKey } from '../../../js/common/core/pgp-key.js';
import { Store } from '../../../js/common/platform/store.js';
import { openpgp } from '../../../js/common/core/pgp.js';
import { opgp } from '../../../js/common/core/pgp.js';
import { ViewModule } from '../../../js/common/view-module.js';
import { ComposeView } from '../compose.js';

Expand Down Expand Up @@ -119,7 +119,7 @@ export class ComposeStorageModule extends ViewModule<ComposeView> {
const lookupResult = await Keyserver.lookupEmail(this.view.acctEmail, email);
if (lookupResult && email) {
if (lookupResult.pubkey) {
const parsed = await openpgp.key.readArmored(lookupResult.pubkey);
const parsed = await opgp.key.readArmored(lookupResult.pubkey);
const key = parsed.keys[0];
if (!key) {
console.info('Dropping found but incompatible public key', { for: email, err: parsed.err ? ' * ' + parsed.err.join('\n * ') : undefined });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { SendableMsg } from '../../../../js/common/api/email-provider/sendable-m
import { Settings } from '../../../../js/common/settings.js';
import { Ui } from '../../../../js/common/browser/ui.js';
import { Xss } from '../../../../js/common/platform/xss.js';
import { openpgp } from '../../../../js/common/core/pgp.js';
import { opgp } from '../../../../js/common/core/pgp.js';

export class EncryptedMsgMailFormatter extends BaseMailFormatter {

Expand Down Expand Up @@ -124,7 +124,7 @@ export class EncryptedMsgMailFormatter extends BaseMailFormatter {
const usableUntil: number[] = [];
const usableFrom: number[] = [];
for (const armoredPubkey of pubs) {
const { keys: [pub] } = await openpgp.key.readArmored(armoredPubkey.pubkey);
const { keys: [pub] } = await opgp.key.readArmored(armoredPubkey.pubkey);
const oneSecondBeforeExpiration = await PgpKey.dateBeforeExpiration(pub);
usableFrom.push(pub.getCreationTime().getTime());
if (typeof oneSecondBeforeExpiration !== 'undefined') { // key does expire
Expand Down
4 changes: 2 additions & 2 deletions extension/chrome/elements/compose.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { Ui } from '../../js/common/browser/ui.js';
import { Url } from '../../js/common/core/common.js';
import { View } from '../../js/common/view.js';
import { XssSafeFactory } from '../../js/common/xss-safe-factory.js';
import { openpgp } from '../../js/common/core/pgp.js';
import { opgp } from '../../js/common/core/pgp.js';
import { ComposeAttsModule } from './compose-modules/compose-atts-module.js';
import { ComposeDraftModule } from './compose-modules/compose-draft-module.js';
import { ComposeErrModule } from './compose-modules/compose-err-module.js';
Expand Down Expand Up @@ -132,7 +132,7 @@ export class ComposeView extends View {
this.isReplyBox = !!this.replyMsgId;
this.emailProvider = new Gmail(this.acctEmail);
Backend.getSubscriptionWithoutLogin(this.acctEmail).catch(ApiErr.reportIfSignificant); // updates storage
openpgp.initWorker({ path: '/lib/openpgp.worker.js' });
opgp.initWorker({ path: '/lib/openpgp.worker.js' });
}

public render = async () => {
Expand Down
4 changes: 2 additions & 2 deletions extension/chrome/elements/passphrase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { Url, Str } from '../../js/common/core/common.js';
import { View } from '../../js/common/view.js';
import { Xss } from '../../js/common/platform/xss.js';
import { initPassphraseToggle } from '../../js/common/ui/passphrase-ui.js';
import { openpgp } from '../../js/common/core/pgp.js';
import { opgp } from '../../js/common/core/pgp.js';

View.run(class PassphraseView extends View {
private readonly acctEmail: string;
Expand Down Expand Up @@ -107,7 +107,7 @@ View.run(class PassphraseView extends View {
const storageType: StorageType = $('.forget').prop('checked') ? 'session' : 'local';
let atLeastOneMatched = false;
for (const keyinfo of this.myPrivateKeys!) { // if passphrase matches more keys, it will save the pass phrase for all keys
const { keys: [prv] } = await openpgp.key.readArmored(keyinfo.private);
const { keys: [prv] } = await opgp.key.readArmored(keyinfo.private);
try {
if (await PgpKey.decrypt(prv, pass) === true) {
await Store.passphraseSave(storageType, this.acctEmail, keyinfo.longid, pass);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class PgpBlockViewAttachmentsModule {

private decryptAndSaveAttToDownloads = async (encrypted: Att, renderIn: JQuery<HTMLElement>) => {
const kisWithPp = await Store.keysGetAllWithPp(this.view.acctEmail);
const decrypted = await BrowserMsg.send.bg.await.pgpMsgDecrypt({ kisWithPp, encryptedData: encrypted.getData(), msgPwd: await this.view.pwdEncryptedMsgModule.getDecryptPwd() });
const decrypted = await BrowserMsg.send.bg.await.pgpMsgDecrypt({ kisWithPp, encryptedData: encrypted.getData(), msgPwd: await this.view.pwdEncryptedMsgModule.getDecryptPwd() }); // eslint-disable-line max-len
if (decrypted.success) {
const att = new Att({ name: encrypted.name.replace(/\.(pgp|gpg)$/, ''), type: encrypted.type, data: decrypted.content });
Browser.saveToDownloads(att, renderIn);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class PgpBlockViewErrorModule {
}

public handlePrivateKeyMismatch = async (message: Uint8Array, isPwdMsg: boolean) => { // todo - make it work for multiple stored keys
const msgDiagnosis = await BrowserMsg.send.await.pgpMsgDiagnosePubkeys(this.view.parentTabId, { privateKis: await Store.keysGet(this.view.acctEmail), message });
const msgDiagnosis = await BrowserMsg.send.bg.await.pgpMsgDiagnosePubkeys({ privateKis: await Store.keysGet(this.view.acctEmail), message });
if (msgDiagnosis.found_match) {
await this.renderErr(Lang.pgpBlock.cantOpen + Lang.pgpBlock.encryptedCorrectlyFileBug, undefined);
} else if (isPwdMsg) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export class PgpBlockViewPwdEncryptedMsgModule {
public getDecryptPwd = async (suppliedPwd?: string | undefined): Promise<string | undefined> => {
const pwd = suppliedPwd || this.userEnteredMsgPassword;
if (pwd && this.view.hasChallengePassword) {
const { hashed } = await BrowserMsg.send.await.pgpHashChallengeAnswer(this.view.parentTabId, { answer: pwd });
const { hashed } = await BrowserMsg.send.bg.await.pgpHashChallengeAnswer({ answer: pwd });
return hashed;
}
return pwd;
Expand Down
4 changes: 2 additions & 2 deletions extension/chrome/elements/pgp_pubkey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { Ui } from '../../js/common/browser/ui.js';
import { Url } from '../../js/common/core/common.js';
import { View } from '../../js/common/view.js';
import { Xss } from '../../js/common/platform/xss.js';
import { openpgp } from '../../js/common/core/pgp.js';
import { opgp } from '../../js/common/core/pgp.js';

// todo - this should use KeyImportUI for consistency.
View.run(class PgpPubkeyView extends View {
Expand All @@ -41,7 +41,7 @@ View.run(class PgpPubkeyView extends View {

public render = async () => {
Ui.event.protect();
this.publicKeys = (await openpgp.key.readArmored(this.armoredPubkey)).keys;
this.publicKeys = (await opgp.key.readArmored(this.armoredPubkey)).keys;
this.primaryPubKey = this.publicKeys[0];
this.isExpired = await PgpKey.expired(this.primaryPubKey);
$('.pubkey').text(this.armoredPubkey);
Expand Down
2 changes: 1 addition & 1 deletion extension/chrome/settings/inbox/inbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export class InboxView extends View {
}

public setHandlers = () => {
BrowserMsg.addPgpListeners();
// BrowserMsg.addPgpListeners(); // todo - re-allow when https://github.com/FlowCrypt/flowcrypt-browser/issues/2560 fixed
BrowserMsg.listen(this.tabId);
Catch.setHandledInterval(this.webmailCommon.addOrRemoveEndSessionBtnIfNeeded, 30000);
}
Expand Down
12 changes: 6 additions & 6 deletions extension/chrome/settings/modules/compatibility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { PgpMsg } from '../../../js/common/core/pgp-msg.js';
import { Ui } from '../../../js/common/browser/ui.js';
import { View } from '../../../js/common/view.js';
import { Xss } from '../../../js/common/platform/xss.js';
import { openpgp } from '../../../js/common/core/pgp.js';
import { opgp } from '../../../js/common/core/pgp.js';
import { Str } from '../../../js/common/core/common.js';

View.run(class CompatibilityView extends View {
Expand Down Expand Up @@ -75,7 +75,7 @@ View.run(class CompatibilityView extends View {
}
this.appendResult(`${kn} Primary key verify: ${await this.test(async () => {
const verifyResNum = await key.verifyPrimaryKey();
const veryfyResWord = openpgp.enums.read(openpgp.enums.keyStatus, 1);
const veryfyResWord = opgp.enums.read(opgp.enums.keyStatus, 1);
return `${verifyResNum}: ${veryfyResWord}`;
})}`);
this.appendResult(`${kn} Primary key creation? ${await this.test(async () => this.formatDate(await key.getCreationTime()))}`);
Expand All @@ -93,7 +93,7 @@ View.run(class CompatibilityView extends View {
this.appendResult(`${skn} Algo: ${await this.test(async () => `${subKey.getAlgorithmInfo().algorithm}`)}`);
this.appendResult(`${skn} Verify: ${await this.test(async () => {
const verifyResNum = await subKey.verify(key.primaryKey);
const veryfyResWord = openpgp.enums.read(openpgp.enums.keyStatus, 1);
const veryfyResWord = opgp.enums.read(opgp.enums.keyStatus, 1);
return `${verifyResNum}: ${veryfyResWord}`;
})}`);
this.appendResult(`${skn} Subkey tag: ${await this.test(async () => subKey.keyPacket.tag)}`);
Expand Down Expand Up @@ -153,10 +153,10 @@ View.run(class CompatibilityView extends View {
private testEncryptDecrypt = async (key: OpenPGP.key.Key): Promise<string[]> => {
const output: string[] = [];
try {
const encryptedMsg = await openpgp.encrypt({ message: openpgp.message.fromText(this.encryptionText), publicKeys: key.toPublic(), armor: true });
const encryptedMsg = await opgp.encrypt({ message: opgp.message.fromText(this.encryptionText), publicKeys: key.toPublic(), armor: true });
output.push(`Encryption with key was successful`);
if (key.isPrivate() && key.isFullyDecrypted()) {
const decryptedMsg = await openpgp.decrypt({ message: await openpgp.message.readArmored(encryptedMsg.data), privateKeys: key });
const decryptedMsg = await opgp.decrypt({ message: await opgp.message.readArmored(encryptedMsg.data), privateKeys: key });
output.push(`Decryption with key ${decryptedMsg.data === this.encryptionText ? 'succeeded' : 'failed!'}`);
} else {
output.push(`Skipping decryption because isPrivate:${key.isPrivate()} isFullyDecrypted:${key.isFullyDecrypted()}`);
Expand All @@ -173,7 +173,7 @@ View.run(class CompatibilityView extends View {
if (!key.isFullyDecrypted()) {
return 'skiped, not fully decrypted';
}
const signedMessage = await openpgp.message.fromText(this.encryptionText).sign([key]);
const signedMessage = await opgp.message.fromText(this.encryptionText).sign([key]);
output.push('sign msg ok');
const verifyResult = await PgpMsg.verify(signedMessage, [key]);
if (verifyResult.error !== null && typeof verifyResult.error !== 'undefined') {
Expand Down
8 changes: 4 additions & 4 deletions extension/chrome/settings/modules/my_key_update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { Store } from '../../../js/common/platform/store.js';
import { Ui } from '../../../js/common/browser/ui.js';
import { Url, Str } from '../../../js/common/core/common.js';
import { View } from '../../../js/common/view.js';
import { openpgp } from '../../../js/common/core/pgp.js';
import { opgp } from '../../../js/common/core/pgp.js';

View.run(class MyKeyUpdateView extends View {
private readonly acctEmail: string;
Expand Down Expand Up @@ -63,8 +63,8 @@ View.run(class MyKeyUpdateView extends View {
}

private updatePrivateKeyHandler = async () => {
const { keys: [uddatedKey] } = await openpgp.key.readArmored(String(this.inputPrivateKey.val()));
const { keys: [uddatedKeyEncrypted] } = await openpgp.key.readArmored(String(this.inputPrivateKey.val()));
const { keys: [uddatedKey] } = await opgp.key.readArmored(String(this.inputPrivateKey.val()));
const { keys: [uddatedKeyEncrypted] } = await opgp.key.readArmored(String(this.inputPrivateKey.val()));
const uddatedKeyPassphrase = String($('.input_passphrase').val());
if (typeof uddatedKey === 'undefined') {
await Ui.modal.warning(Lang.setup.keyFormattedWell(this.prvHeaders.begin, String(this.prvHeaders.end)), Ui.testCompatibilityLink);
Expand All @@ -78,7 +78,7 @@ View.run(class MyKeyUpdateView extends View {
if (await uddatedKey.getEncryptionKey()) {
await this.storeUpdatedKeyAndPassphrase(uddatedKeyEncrypted, uddatedKeyPassphrase);
} else { // cannot get a valid encryption key packet
if ((await uddatedKey.verifyPrimaryKey() === openpgp.enums.keyStatus.no_self_cert) || await PgpKey.usableButExpired(uddatedKey)) { // known issues - key can be fixed
if ((await uddatedKey.verifyPrimaryKey() === opgp.enums.keyStatus.no_self_cert) || await PgpKey.usableButExpired(uddatedKey)) { // known issues - key can be fixed
const fixedEncryptedPrv = await Settings.renderPrvCompatFixUiAndWaitTilSubmittedByUser(
this.acctEmail, '.compatibility_fix_container', uddatedKeyEncrypted, uddatedKeyPassphrase, this.showKeyUrl
);
Expand Down
10 changes: 3 additions & 7 deletions extension/js/background_page/background_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@ import { BgHandlers } from './bg-handlers.js';
import { BgUtils } from './bgutils.js';
import { Catch } from '../common/platform/catch.js';
import { GoogleAuth } from '../common/api/google-auth.js';
import { PgpMsg } from '../common/core/pgp-msg.js';
import { VERSION } from '../common/core/const.js';
import { injectFcIntoWebmail } from './inject.js';
import { migrateGlobal } from './migrations.js';
import { openpgp } from '../common/core/pgp.js';
import { opgp } from '../common/core/pgp.js';

console.info('background_process.js starting');

openpgp.initWorker({ path: '/lib/openpgp.worker.js' });
opgp.initWorker({ path: '/lib/openpgp.worker.js' });

(async () => {

Expand Down Expand Up @@ -54,10 +53,7 @@ openpgp.initWorker({ path: '/lib/openpgp.worker.js' });
BrowserMsg.bgAddListener('storeAcctGet', (r: Bm.StoreAcctGet) => Store.getAcct(r.acctEmail, r.keys));
BrowserMsg.bgAddListener('storeAcctSet', (r: Bm.StoreAcctSet) => Store.setAcct(r.acctEmail, r.values));

// openpgp related handlers
BrowserMsg.bgAddListener('pgpMsgDecrypt', PgpMsg.decrypt);
BrowserMsg.bgAddListener('pgpMsgVerifyDetached', PgpMsg.verifyDetached);
BrowserMsg.bgAddListener('pgpKeyDetails', BgHandlers.pgpKeyDetails);
BrowserMsg.addPgpListeners(); // todo - remove https://github.com/FlowCrypt/flowcrypt-browser/issues/2560 fixed

BrowserMsg.bgAddListener('ajax', BgHandlers.ajaxHandler);
BrowserMsg.bgAddListener('ajaxGmailAttGetChunk', BgHandlers.ajaxGmailAttGetChunkHandler);
Expand Down
5 changes: 0 additions & 5 deletions extension/js/background_page/bg-handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { Api } from '../common/api/api.js';
import { BgUtils } from './bgutils.js';
import { Bm } from '../common/browser/browser-msg.js';
import { Gmail } from '../common/api/email-provider/gmail/gmail.js';
import { PgpKey } from '../common/core/pgp-key.js';
import { Store } from '../common/platform/store.js';
import { Url } from '../common/core/common.js';

Expand Down Expand Up @@ -40,10 +39,6 @@ export class BgHandlers {
return { chunk: await new Gmail(r.acctEmail).attGetChunk(r.msgId, r.attId) };
}

public static pgpKeyDetails = async ({ pubkey }: Bm.PgpKeyDetails): Promise<Bm.Res.PgpKeyDetails> => {
return await PgpKey.parseDetails(pubkey);
}

public static updateUninstallUrl: Bm.AsyncResponselessHandler = async () => {
const acctEmails = await Store.acctEmailsGet();
if (typeof chrome.runtime.setUninstallURL !== 'undefined') {
Expand Down
Loading