diff --git a/.semaphore/semaphore.yml b/.semaphore/semaphore.yml index f455d528a98..9aa96b58350 100644 --- a/.semaphore/semaphore.yml +++ b/.semaphore/semaphore.yml @@ -12,7 +12,7 @@ blocks: - name: Mock UI Tests dependencies: [] execution_time_limit: - minutes: 30 + minutes: 45 task: secrets: - name: flowcrypt-browser-ci-secrets diff --git a/extension/chrome/dev/ci_pgp_host_page.htm b/extension/chrome/dev/ci_pgp_host_page.htm deleted file mode 100644 index d5cde5101a5..00000000000 --- a/extension/chrome/dev/ci_pgp_host_page.htm +++ /dev/null @@ -1,15 +0,0 @@ - - - -
- - - - - - - - - - - diff --git a/extension/chrome/dev/ci_pgp_host_page.ts b/extension/chrome/dev/ci_pgp_host_page.ts deleted file mode 100644 index 3f4c2304062..00000000000 --- a/extension/chrome/dev/ci_pgp_host_page.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* ©️ 2016 - present FlowCrypt a.s. Limitations apply. Contact human@flowcrypt.com */ - -'use strict'; - -import { BrowserMsg } from '../../js/common/browser/browser-msg.js'; -import { Catch } from '../../js/common/platform/catch.js'; -import { Xss } from '../../js/common/platform/xss.js'; -import { Env } from '../../js/common/browser/env.js'; - -Catch.try(async () => { - const tabId = await BrowserMsg.requiredTabId(); - - // 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 += `&parentTabId=${encodeURIComponent(tabId)}`; - $('body').append(``); // xss-escaped - $('body').attr('data-test-view-state', 'loaded'); -})(); diff --git a/extension/chrome/dev/export.ts b/extension/chrome/dev/export.ts index 5f25164f562..a8f2272c68c 100644 --- a/extension/chrome/dev/export.ts +++ b/extension/chrome/dev/export.ts @@ -87,7 +87,7 @@ Catch.try(async () => { const fetchableAttachments: Attachment[] = []; const skippedAttachments: Attachment[] = []; for (const msg of messages) { - for (const attachment of GmailParser.findAttachments(msg)) { + for (const attachment of GmailParser.findAttachments(msg, msg.id)) { if (attachment.length > 1024 * 1024 * 7) { // over 7 mb - attachment too big skippedAttachments.push( @@ -102,7 +102,7 @@ Catch.try(async () => { } } } - await gmail.fetchAttachments(fetchableAttachments, percent => print(`Percent attachments done: ${percent}`)); + await gmail.fetchAttachmentsMissingData(fetchableAttachments, percent => print(`Percent attachments done: ${percent}`)); const attachments: { [id: string]: { data: string; size: number } } = {}; for (const attachment of fetchableAttachments.concat(skippedAttachments)) { // eslint-disable-next-line @typescript-eslint/no-non-null-assertion diff --git a/extension/chrome/elements/attachment.ts b/extension/chrome/elements/attachment.ts index 33e2342a4da..b1891a43a82 100644 --- a/extension/chrome/elements/attachment.ts +++ b/extension/chrome/elements/attachment.ts @@ -8,7 +8,7 @@ import { PromiseCancellation, Str, Url } from '../../js/common/core/common.js'; import { Api } from '../../js/common/api/shared/api.js'; import { ApiErr } from '../../js/common/api/shared/api-error.js'; import { Assert } from '../../js/common/assert.js'; -import { Attachment } from '../../js/common/core/attachment.js'; +import { Attachment, AttachmentId } from '../../js/common/core/attachment.js'; import { Browser } from '../../js/common/browser/browser.js'; import { Catch } from '../../js/common/platform/catch.js'; import { Gmail } from '../../js/common/api/email-provider/gmail/gmail.js'; @@ -32,10 +32,8 @@ export class AttachmentDownloadView extends View { protected readonly isEncrypted: boolean; protected readonly errorDetailsOpened: boolean; protected readonly type: string | undefined; - protected readonly msgId: string | undefined; - protected readonly id: string | undefined; protected readonly name: string | undefined; - protected readonly url: string | undefined; + protected readonly attachmentId: AttachmentId; protected readonly gmail: Gmail; protected attachment!: Attachment; protected ppChangedPromiseCancellation: PromiseCancellation = { cancel: false }; @@ -73,11 +71,17 @@ export class AttachmentDownloadView extends View { this.errorDetailsOpened = uncheckedUrlParams.errorDetailsOpened === true; this.size = uncheckedUrlParams.size ? parseInt(String(uncheckedUrlParams.size)) : undefined; this.type = Assert.urlParamRequire.optionalString(uncheckedUrlParams, 'type'); - this.msgId = Assert.urlParamRequire.optionalString(uncheckedUrlParams, 'msgId'); - this.id = Assert.urlParamRequire.optionalString(uncheckedUrlParams, 'attachmentId'); this.name = Assert.urlParamRequire.optionalString(uncheckedUrlParams, 'name'); // url contains either actual url of remote content or objectUrl for direct content, either way needs to be downloaded - this.url = Assert.urlParamRequire.optionalString(uncheckedUrlParams, 'url'); + const url = Assert.urlParamRequire.optionalString(uncheckedUrlParams, 'url'); + if (url) { + this.attachmentId = { url }; + } else { + this.attachmentId = { + msgId: Assert.urlParamRequire.string(uncheckedUrlParams, 'msgId'), + id: Assert.urlParamRequire.string(uncheckedUrlParams, 'attachmentId'), + }; + } this.gmail = new Gmail(this.acctEmail); } @@ -91,11 +95,9 @@ export class AttachmentDownloadView extends View { this.fesUrl = storage.fesUrl; try { this.attachment = new Attachment({ + ...this.attachmentId, name: this.origNameBasedOnFilename, type: this.type, - msgId: this.msgId, - id: this.id, - url: this.url, }); } catch (e) { Catch.reportErr(e); @@ -107,9 +109,9 @@ export class AttachmentDownloadView extends View { this.renderHeader(); $('#name').attr('title', this.name || ''); $('img#file-format').attr('src', this.getFileIconSrc()); - if (!this.size && this.url) { + if (!this.size && 'url' in this.attachmentId) { // download url of a file that has an unknown size - this.getUrlFileSize(this.url) + this.getUrlFileSize(this.attachmentId.url) .then(fileSize => { if (typeof fileSize !== 'undefined') { this.size = fileSize; @@ -162,7 +164,7 @@ export class AttachmentDownloadView extends View { this.attachment.setData(await Api.download(this.attachment.url, this.renderProgress)); } else if (this.attachment.id && this.attachment.msgId) { // gmail attId - const { data } = await this.gmail.attachmentGet(this.attachment.msgId, this.attachment.id, this.renderProgress); + const { data } = await this.gmail.attachmentGet(this.attachment.msgId, this.attachment.id, { download: this.renderProgress }); this.attachment.setData(data); } else { throw new Error('File is missing both id and url - this should be fixed'); @@ -246,6 +248,7 @@ export class AttachmentDownloadView extends View { private processAsPublicKeyAndHideAttachmentIfAppropriate = async () => { // todo: we should call this detection in the main `core/Attachment.treatAs` (e.g. in the context of GmailElementReplacer and InboxActiveThreadModule) + // and we'll also be able to minimize the pgp_pubkey block if isOutgoing // should be possible after #4906 is done if (((this.attachment.msgId && this.attachment.id) || this.attachment.url) && this.attachment.isPublicKey()) { // this is encrypted public key - download && decrypt & parse & render diff --git a/extension/chrome/elements/attachment_preview.ts b/extension/chrome/elements/attachment_preview.ts index af687abbfff..446e61d7713 100644 --- a/extension/chrome/elements/attachment_preview.ts +++ b/extension/chrome/elements/attachment_preview.ts @@ -36,11 +36,9 @@ View.run( try { Xss.sanitizeRender(this.attachmentPreviewContainer, `${Ui.spinner('green', 'large_spinner')}`); this.attachment = new Attachment({ + ...this.attachmentId, name: this.origNameBasedOnFilename, type: this.type, - msgId: this.msgId, - id: this.id, - url: this.url, }); await this.downloadDataIfNeeded(); const result = this.isEncrypted ? await this.decrypt() : this.attachment.getData(); diff --git a/extension/chrome/elements/backup.htm b/extension/chrome/elements/backup.htm index 75335266130..3e3f1820c59 100644 --- a/extension/chrome/elements/backup.htm +++ b/extension/chrome/elements/backup.htm @@ -21,7 +21,7 @@