Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/npm_and_yarn/puppeteer-21.3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
sosnovsky authored Oct 16, 2023
2 parents aa47364 + 768ebbb commit 93c4082
Show file tree
Hide file tree
Showing 17 changed files with 638 additions and 314 deletions.
2 changes: 2 additions & 0 deletions extension/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<div class="lightboxed">

version 8.5.1 on October 9, 2023: <a href="https://github.com/FlowCrypt/flowcrypt-browser/milestone/475?closed=1" target="_blank">Clickable links, improved login and google search popups</a>

version 8.5.0 on August 16, 2023: <a href="https://github.com/FlowCrypt/flowcrypt-browser/milestone/473?closed=1" target="_blank">Clickable links, improved login and google search popups</a>

version 8.4.8 on June 12, 2023: <a href="https://github.com/FlowCrypt/flowcrypt-browser/milestone/474?closed=1" target="_blank">Clickable links, improved login and google search popups</a>
Expand Down
2 changes: 2 additions & 0 deletions extension/css/cryptup.css
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,8 @@ body#settings > div#content pre {
padding: 8px;
font-size: 12px;
border-radius: 2px;
white-space: pre-wrap;
word-wrap: break-word;
}

body#settings > div#content.setup {
Expand Down
2 changes: 1 addition & 1 deletion extension/js/background_page/bg-handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class BgHandlers {
};

public static ajaxGmailAttachmentGetChunkHandler = async (r: Bm.AjaxGmailAttachmentGetChunk): Promise<Bm.Res.AjaxGmailAttachmentGetChunk> => {
return { chunk: await new Gmail(r.acctEmail).attachmentGetChunk(r.msgId, r.attachmentId) };
return { chunk: await new Gmail(r.acctEmail).attachmentGetChunk(r.msgId, r.attachmentId, r.treatAs) };
};

public static updateUninstallUrl: Bm.AsyncResponselessHandler = async () => {
Expand Down
7 changes: 4 additions & 3 deletions extension/js/common/api/email-provider/gmail/gmail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,15 @@ export class Gmail extends EmailProviderApi implements EmailProviderInterface {
return { attachmentId, size, data: Buf.fromBase64UrlStr(data) }; // data should be a Buf for ease of passing to/from bg page
};

public attachmentGetChunk = async (msgId: string, attachmentId: string): Promise<Buf> => {
public attachmentGetChunk = async (msgId: string, attachmentId: string, treatAs: string): Promise<Buf> => {
if (Env.isContentScript()) {
// content script CORS not allowed anymore, have to drag it through background page
// https://www.chromestatus.com/feature/5629709824032768
const { chunk } = await BrowserMsg.send.bg.await.ajaxGmailAttachmentGetChunk({
acctEmail: this.acctEmail,
msgId,
attachmentId,
treatAs,
});
return chunk;
}
Expand Down Expand Up @@ -185,7 +186,7 @@ export class Gmail extends EmailProviderApi implements EmailProviderInterface {
r.send();
let status: number;
const responsePollInterval = Catch.setHandledInterval(() => {
if (status >= 200 && status <= 299 && r.responseText.length >= minBytes) {
if (status >= 200 && status <= 299 && (r.responseText.length >= minBytes || treatAs === 'publicKey')) {
window.clearInterval(responsePollInterval);
processChunkAndResolve(r.responseText);
r.abort();
Expand All @@ -203,7 +204,7 @@ export class Gmail extends EmailProviderApi implements EmailProviderInterface {
}
if (r.readyState === 3 || r.readyState === 4) {
// loading, done
if (status >= 200 && status <= 299 && r.responseText.length >= minBytes) {
if (status >= 200 && status <= 299 && (r.responseText.length >= minBytes || treatAs === 'publicKey')) {
// done as a success - resolve in case response_poll didn't catch this yet
processChunkAndResolve(r.responseText);
window.clearInterval(responsePollInterval);
Expand Down
2 changes: 1 addition & 1 deletion extension/js/common/browser/browser-msg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export namespace Bm {
export type PgpKeyBinaryToArmored = { binaryKeysData: Uint8Array };
export type Ajax = { req: JQuery.AjaxSettings<ApiCallContext>; stack: string };
export type AjaxProgress = { operationId: string; percent?: number; loaded: number; total: number; expectedTransferSize: number };
export type AjaxGmailAttachmentGetChunk = { acctEmail: string; msgId: string; attachmentId: string };
export type AjaxGmailAttachmentGetChunk = { acctEmail: string; msgId: string; attachmentId: string; treatAs: string };
export type ShowAttachmentPreview = { iframeUrl: string };
export type ShowConfirmation = { text: string; isHTML: boolean; messageSender: Dest; requestUid: string; footer?: string };
export type ReRenderRecipient = { email: string };
Expand Down
5 changes: 4 additions & 1 deletion extension/js/common/core/attachment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ export class Attachment {
return 'signature';
} else if (this.inline && this.isAttachmentAnImage()) {
return 'inlineImage';
} else if (!this.name && !this.isAttachmentAnImage()) {
} else if (!this.name && !this.isAttachmentAnImage() && this.type !== 'application/octet-stream') {
// this.name may be '' or undefined - catch either
return this.length < 100 ? 'hidden' : 'encryptedMsg';
} else if (this.name === 'msg.asc' && this.length < 100 && this.type === 'application/pgp-encrypted') {
Expand All @@ -221,6 +221,9 @@ export class Attachment {
const isAmbiguousAscFile = /\.asc$/.test(this.name); // ambiguous .asc name
const isAmbiguousNonameFile = !this.name || this.name === 'noname'; // may not even be OpenPGP related
if (!this.inline && this.length < 100000 && (isAmbiguousAscFile || isAmbiguousNonameFile) && !this.isAttachmentAnImage()) {
if (isAmbiguousNonameFile && this.type === 'application/octet-stream') {
return 'plainFile';
}
return this.hasData() ? 'maybePgp' : 'needChunk';
}
return 'plainFile';
Expand Down
10 changes: 5 additions & 5 deletions extension/js/common/downloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import { GmailRes } from './api/email-provider/gmail/gmail-parser.js';
import { Gmail } from './api/email-provider/gmail/gmail.js';
import { Attachment } from './core/attachment.js';
import { Attachment, Attachment$treatAs } from './core/attachment.js';
import { Buf } from './core/buf.js';
import { ExpirationCache } from './core/expiration-cache.js';

Expand All @@ -23,22 +23,22 @@ export class Downloader {
});
};

public queueAttachmentChunkDownload = (a: Attachment): { result: Promise<Buf> } => {
public queueAttachmentChunkDownload = (a: Attachment, treatAs: Attachment$treatAs): { result: Promise<Buf> } => {
if (a.hasData()) {
return { result: Promise.resolve(a.getData()) };
}
let download = this.chunkDownloads.get(a);
if (!download) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
download = this.gmail.attachmentGetChunk(a.msgId!, a.id!);
download = this.gmail.attachmentGetChunk(a.msgId!, a.id!, treatAs);
this.chunkDownloads.set(a, download);
}
return { result: download };
};

public waitForAttachmentChunkDownload = async (a: Attachment) => {
public waitForAttachmentChunkDownload = async (a: Attachment, treatAs: Attachment$treatAs) => {
if (a.hasData()) return a.getData();
return this.chunkDownloads.await(a, this.queueAttachmentChunkDownload(a).result);
return this.chunkDownloads.await(a, this.queueAttachmentChunkDownload(a, treatAs).result);
};

public msgGetRaw = async (msgId: string): Promise<string> => {
Expand Down
6 changes: 3 additions & 3 deletions extension/js/common/message-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ export class MessageRenderer {
if (this.debug) {
console.debug('processAttachment() try -> awaiting chunk + awaiting type');
}
const data = await this.downloader.waitForAttachmentChunkDownload(a);
const data = await this.downloader.waitForAttachmentChunkDownload(a, treatAs);
const openpgpType = MsgUtil.type({ data });
if (openpgpType && openpgpType.type === 'publicKey' && openpgpType.armored) {
// todo: publicKey attachment can't be too big, so we could do preparePubkey() call (checking file length) right here
Expand Down Expand Up @@ -406,11 +406,11 @@ export class MessageRenderer {
const treatAs = a.treatAs(attachments, isBodyEmpty);
if (treatAs === 'plainFile') continue;
if (treatAs === 'needChunk') {
this.downloader.queueAttachmentChunkDownload(a);
this.downloader.queueAttachmentChunkDownload(a, treatAs);
} else if (treatAs === 'publicKey') {
// we also want a chunk before we replace the publicKey-looking attachment in the UI
// todo: or simply queue full attachment download?
this.downloader.queueAttachmentChunkDownload(a);
this.downloader.queueAttachmentChunkDownload(a, treatAs);
} else {
// todo: queue full attachment download, when the cache is implemented?
// note: this cache should return void or throw an exception because the data bytes are set to the Attachment object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,6 @@ export class GmailElementReplacer implements WebmailElementReplacer {
}
const loaderContext = new GmailLoaderContext(this.factory, msgEl, attachmentsContainerInner);
attachmentsContainerInner = $(attachmentsContainerInner);
attachmentsContainerInner.parent().find(this.sel.numberOfAttachments).hide();
let nRenderedAttachments = attachments.length;
for (const a of attachments) {
const attachmentSel = this.filterAttachments(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,16 @@ export const contentScriptSetupIfVacant = async (webmailSpecific: WebmailSpecifi
BrowserMsg.addListener('ajax_progress', async (progress: Bm.AjaxProgress) => {
relayManager.renderProgress(progress);
});
BrowserMsg.addListener('render_public_keys', async ({ traverseUp, afterFrameId, publicKeys }: Bm.RenderPublicKeys) => {
const traverseUpLevels = traverseUp || 0;
let appendAfter = $(`iframe#${afterFrameId}`);
for (let i = 0; i < traverseUpLevels; i++) {
appendAfter = appendAfter.parent();
}
for (const armoredPubkey of publicKeys) {
appendAfter.after(factory.embeddedPubkey(armoredPubkey, false)); // xss-safe-value
}
});
BrowserMsg.listen(tabId);
};

Expand Down Expand Up @@ -394,9 +404,9 @@ export const contentScriptSetupIfVacant = async (webmailSpecific: WebmailSpecifi
if (expireInDays > 30) {
return;
}
let warningMsg;
let warningMsg: string;
if (clientConfiguration.usesKeyManager()) {
let expirationText;
let expirationText: string;
if (expireInDays > 0) {
expirationText = `Your local keys expire in ${Str.pluralize(expireInDays, 'day')}.<br/>`;
} else {
Expand All @@ -407,7 +417,7 @@ export const contentScriptSetupIfVacant = async (webmailSpecific: WebmailSpecifi
`To receive the latest keys, please ensure that you can connect to your corporate network either through VPN or in person and reload Gmail.<br/>` +
`If this notification still shows after that, please contact your Help Desk.`;
} else {
let expirationText;
let expirationText: string;
if (expireInDays > 0) {
expirationText = `Your keys are expiring in ${Str.pluralize(expireInDays, 'day')}.`;
} else {
Expand Down
Loading

0 comments on commit 93c4082

Please sign in to comment.