Skip to content

Commit f9e45c9

Browse files
committed
fix
1 parent eda2518 commit f9e45c9

File tree

23 files changed

+220
-159
lines changed

23 files changed

+220
-159
lines changed

extension/chrome/elements/attachment_preview.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import * as pdfjsLib from 'pdfjs';
1818
import { AttachmentPreviewPdf } from '../../js/common/ui/attachment_preview_pdf.js';
1919

2020
// https://github.com/FlowCrypt/flowcrypt-browser/issues/5822#issuecomment-2362529197
21-
// eslint-disable-next-line @typescript-eslint/no-deprecated
21+
2222
pdfjsLib.GlobalWorkerOptions.workerSrc = chrome.runtime.getURL(`lib/pdf.worker.min.mjs`);
2323
type AttachmentType = 'img' | 'txt' | 'pdf';
2424

extension/chrome/settings/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ View.run(
7070
}
7171

7272
public render = async () => {
73-
// eslint-disable-next-line @typescript-eslint/no-deprecated
7473
const isDevMode = !('update_url' in chrome.runtime.getManifest());
7574
$('#status-row #status_version').text(`v:${VERSION}${isDevMode ? '-dev' : ''}`);
7675
for (const webmailLName of await Env.webmails()) {

extension/js/common/api/authentication/configured-idp-oauth.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export class ConfiguredIdpOAuth extends OAuth {
100100
grant_type: 'refresh_token',
101101
refreshToken,
102102
client_id: authConf.oauth.clientId,
103-
// eslint-disable-next-line @typescript-eslint/no-deprecated
103+
104104
redirect_uri: chrome.identity.getRedirectURL('oauth'),
105105
},
106106
dataType: 'JSON',
@@ -120,7 +120,7 @@ export class ConfiguredIdpOAuth extends OAuth {
120120
access_type: 'offline',
121121
prompt: 'login',
122122
state,
123-
// eslint-disable-next-line @typescript-eslint/no-deprecated
123+
124124
redirect_uri: chrome.identity.getRedirectURL('oauth'),
125125
scope: this.OAUTH_REQUEST_SCOPES.join(' '),
126126
login_hint: acctEmail,
@@ -131,9 +131,8 @@ export class ConfiguredIdpOAuth extends OAuth {
131131
private static async getAuthRes({ acctEmail, expectedState, authUrl }: { acctEmail: string; expectedState: string; authUrl: string }): Promise<AuthRes> {
132132
/* eslint-disable @typescript-eslint/naming-convention */
133133
try {
134-
// eslint-disable-next-line @typescript-eslint/no-deprecated
135134
const redirectUri = await chrome.identity.launchWebAuthFlow({ url: authUrl, interactive: true });
136-
// eslint-disable-next-line @typescript-eslint/no-deprecated
135+
137136
if (chrome.runtime.lastError || !redirectUri || redirectUri?.includes('access_denied')) {
138137
return { acctEmail, result: 'Denied', error: `Failed to launch web auth flow`, id_token: undefined };
139138
}
@@ -207,7 +206,7 @@ export class ConfiguredIdpOAuth extends OAuth {
207206
grant_type: 'authorization_code',
208207
code,
209208
client_id: authConf.oauth.clientId,
210-
// eslint-disable-next-line @typescript-eslint/no-deprecated
209+
211210
redirect_uri: chrome.identity.getRedirectURL('oauth'),
212211
},
213212
dataType: 'JSON',

extension/js/common/api/email-provider/sendable-msg.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ export class SendableMsg {
5252
public type: MimeEncodeType,
5353
public externalId?: string // for binding a password-protected message
5454
) {
55-
const allEmails = this.getAllRecipients();
56-
if (!allEmails.length && !isDraft) {
55+
const allRecipients = this.getAllRecipients();
56+
if (!allRecipients.length && !isDraft) {
5757
throw new Error('The To:, Cc: and Bcc: fields are empty. Please add recipients and try again');
5858
}
59-
const invalidEmails = allEmails.filter(email => !Str.isEmailValid(email.email));
59+
const invalidEmails = allRecipients.map(recipient => recipient.email).filter(email => !Str.isEmailValid(email));
6060
// todo: distinguish To:, Cc: and Bcc: in error report?
6161
if (invalidEmails.length) {
6262
throw new InvalidRecipientError(`The To: field contains invalid emails: ${invalidEmails.join(', ')}\n\nPlease check recipients and try again.`);

extension/js/common/browser/browser-msg.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export interface ChildFrame {
2929

3030
export namespace Bm {
3131
export type Dest = string;
32-
// eslint-disable-next-line @typescript-eslint/no-deprecated
32+
3333
export type Sender = chrome.runtime.MessageSender | 'background';
3434
export type Response = unknown;
3535
export type RawResponse = { result: unknown; exception?: Bm.ErrAsJson };
@@ -415,7 +415,6 @@ export class BrowserMsg {
415415
}
416416

417417
public static listen(dest: Bm.Dest) {
418-
// eslint-disable-next-line @typescript-eslint/no-deprecated
419418
chrome.runtime.onMessage.addListener((msg: Bm.Raw, _sender, rawRespond: (rawResponse: Bm.RawResponse) => void) => {
420419
// console.debug(`listener(${dest}) new message: ${msg.name} to ${msg.to} with id ${msg.uid} from`, _sender);
421420
if (msg.to && [dest, 'broadcast'].includes(msg.to)) {
@@ -432,7 +431,7 @@ export class BrowserMsg {
432431

433432
public static createIntervalAlarm(action: string, periodInMinutes: number) {
434433
const alarmName = `${action}_interval_${Date.now()}`;
435-
// eslint-disable-next-line @typescript-eslint/no-deprecated
434+
436435
void chrome.alarms.create(alarmName, { periodInMinutes });
437436
}
438437

@@ -441,7 +440,6 @@ export class BrowserMsg {
441440
}
442441

443442
public static bgListen() {
444-
// eslint-disable-next-line @typescript-eslint/no-deprecated
445443
chrome.runtime.onMessage.addListener((msg: Bm.Raw, _sender, rawRespond: (rawRes: Bm.RawResponse) => void) => {
446444
const respondIfPageStillOpen = (response: Bm.RawResponse) => {
447445
try {
@@ -521,7 +519,7 @@ export class BrowserMsg {
521519
Catch.try(BrowserMsg.INTERVAL_HANDLERS[actionName])();
522520
}
523521
};
524-
// eslint-disable-next-line @typescript-eslint/no-deprecated
522+
525523
chrome.alarms.onAlarm.addListener(alarmListener);
526524
}
527525

@@ -646,7 +644,7 @@ export class BrowserMsg {
646644
resolve(undefined);
647645
} else if (!r || typeof r !== 'object') {
648646
// r can be null if we sent a message to a non-existent window id
649-
// eslint-disable-next-line @typescript-eslint/no-deprecated
647+
650648
const lastError = chrome.runtime.lastError ? chrome.runtime.lastError.message || '(empty lastError)' : '(no lastError)';
651649
let e: Error;
652650
if (typeof destString === 'undefined' && typeof r === 'undefined') {
@@ -676,24 +674,19 @@ export class BrowserMsg {
676674
}
677675
};
678676
try {
679-
// eslint-disable-next-line @typescript-eslint/no-deprecated
680677
if (chrome.runtime) {
681678
Env.isBackgroundPage()
682679
.then(isBackgroundPage => {
683680
if (isBackgroundPage) {
684-
// eslint-disable-next-line @typescript-eslint/no-deprecated
685681
chrome.tabs.query({ active: true, currentWindow: true }, tabs => {
686682
for (const tab of tabs) {
687-
// eslint-disable-next-line @typescript-eslint/no-deprecated
688683
chrome.tabs.sendMessage(Number(tab.id), msg, resolve);
689684
}
690685
});
691686
} else {
692687
if (awaitRes) {
693-
// eslint-disable-next-line @typescript-eslint/no-deprecated
694688
chrome.runtime.sendMessage(msg, processRawMsgResponse);
695689
} else {
696-
// eslint-disable-next-line @typescript-eslint/no-deprecated
697690
void chrome.runtime.sendMessage(msg);
698691
}
699692
}

extension/js/common/browser/browser.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ export class Browser {
5151
};
5252

5353
public static openSettingsPage = async (path = 'index.htm', acctEmail?: string, page = '', rawPageUrlParams?: Dict<UrlParam>, addNewAcct = false) => {
54-
// eslint-disable-next-line @typescript-eslint/no-deprecated
5554
const basePath = chrome.runtime.getURL(`chrome/settings/${path}`);
5655
const pageUrlParams = rawPageUrlParams ? JSON.stringify(rawPageUrlParams) : undefined;
5756
if (acctEmail || path === 'fatal.htm') {

extension/js/common/browser/chrome.ts

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,11 @@ const handleFatalErr = async (reason: 'storage_undefined', error: Error) => {
1717
throw error;
1818
} else if (Env.isContentScript()) {
1919
console.error('Incomplete extension environment in content script', error);
20-
// eslint-disable-next-line @typescript-eslint/no-deprecated
2120
} else if (!chrome.runtime) {
2221
console.error('Chrome.runtime missing, cannot continue', error);
2322
} else {
2423
// extension pages
25-
// eslint-disable-next-line @typescript-eslint/no-deprecated
24+
2625
window.location.href = chrome.runtime.getURL(Url.create(`chrome/settings/fatal.htm`, { reason, stack: error.stack }));
2726
}
2827
} catch (e) {
@@ -34,12 +33,10 @@ const handleFatalErr = async (reason: 'storage_undefined', error: Error) => {
3433
}
3534
}
3635
};
37-
// eslint-disable-next-line @typescript-eslint/no-deprecated
36+
3837
export const windowsCreate = async (q: chrome.windows.CreateData): Promise<chrome.windows.Window | undefined> => {
3938
return await new Promise(resolve => {
40-
// eslint-disable-next-line @typescript-eslint/no-deprecated
4139
if (typeof chrome.windows !== 'undefined') {
42-
// eslint-disable-next-line @typescript-eslint/no-deprecated
4340
chrome.windows.create(q, resolve);
4441
} else {
4542
Ui.modal.error('Your platform is not supported: browser does not support extension windows').catch(Catch.reportErr);
@@ -49,18 +46,14 @@ export const windowsCreate = async (q: chrome.windows.CreateData): Promise<chrom
4946

5047
export const storageGet = async (storageType: ChromeStorageType, keys: string[]): Promise<Dict<unknown>> => {
5148
return await new Promise((resolve, reject) => {
52-
// eslint-disable-next-line @typescript-eslint/no-deprecated
5349
if (typeof chrome.storage === 'undefined') {
5450
void handleFatalErr('storage_undefined', new Error('storage is undefined'));
5551
} else {
56-
// eslint-disable-next-line @typescript-eslint/no-deprecated
5752
const storage = chrome.storage[storageType];
5853
storage.get(keys, result => {
5954
if (typeof result !== 'undefined') {
6055
resolve(result);
61-
// eslint-disable-next-line @typescript-eslint/no-deprecated
6256
} else if (chrome.runtime.lastError) {
63-
// eslint-disable-next-line @typescript-eslint/no-deprecated
6457
reject(AbstractStore.errCategorize(chrome.runtime.lastError));
6558
} else {
6659
reject(new Error(`storageGet(${storageType}, ${keys.join(',')}) produced undefined result without an error`));
@@ -72,11 +65,9 @@ export const storageGet = async (storageType: ChromeStorageType, keys: string[])
7265

7366
export const storageGetAll = async (storageType: ChromeStorageType): Promise<{ [key: string]: unknown }> => {
7467
return await new Promise(resolve => {
75-
// eslint-disable-next-line @typescript-eslint/no-deprecated
7668
if (typeof chrome.storage === 'undefined') {
7769
void handleFatalErr('storage_undefined', new Error('storage is undefined'));
7870
} else {
79-
// eslint-disable-next-line @typescript-eslint/no-deprecated
8071
const storage = chrome.storage[storageType];
8172
storage.get(resolve);
8273
}
@@ -85,11 +76,9 @@ export const storageGetAll = async (storageType: ChromeStorageType): Promise<{ [
8576

8677
export const storageSet = async (storageType: ChromeStorageType, values: Dict<unknown>): Promise<void> => {
8778
return await new Promise(resolve => {
88-
// eslint-disable-next-line @typescript-eslint/no-deprecated
8979
if (typeof chrome.storage === 'undefined') {
9080
void handleFatalErr('storage_undefined', new Error('storage is undefined'));
9181
} else {
92-
// eslint-disable-next-line @typescript-eslint/no-deprecated
9382
const storage = chrome.storage[storageType];
9483
storage.set(values, resolve);
9584
}
@@ -98,11 +87,9 @@ export const storageSet = async (storageType: ChromeStorageType, values: Dict<un
9887

9988
export const storageRemove = async (storageType: ChromeStorageType, keys: string[]): Promise<void> => {
10089
return await new Promise(resolve => {
101-
// eslint-disable-next-line @typescript-eslint/no-deprecated
10290
if (typeof chrome.storage === 'undefined') {
10391
void handleFatalErr('storage_undefined', new Error('storage is undefined'));
10492
} else {
105-
// eslint-disable-next-line @typescript-eslint/no-deprecated
10693
const storage = chrome.storage[storageType];
10794
storage.remove(keys, resolve);
10895
}

extension/js/common/browser/env.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,17 @@ export type WebMailVersion = 'generic' | 'gmail2020' | 'gmail2022';
99

1010
export class Env {
1111
public static runtimeId(orig = false) {
12-
// eslint-disable-next-line @typescript-eslint/no-deprecated
1312
if (chrome?.runtime?.id) {
1413
if (orig) {
15-
// eslint-disable-next-line @typescript-eslint/no-deprecated
1614
return chrome.runtime.id;
1715
} else {
18-
// eslint-disable-next-line @typescript-eslint/no-deprecated
1916
return chrome.runtime.id.replace(/[^a-z0-9]/gi, '');
2017
}
2118
}
2219
return undefined;
2320
}
2421

2522
public static getExtensionOrigin() {
26-
// eslint-disable-next-line @typescript-eslint/no-deprecated
2723
const url = chrome.runtime.getURL('');
2824
return Url.removeTrailingSlash(url);
2925
}
@@ -32,7 +28,7 @@ export class Env {
3228
if (Env.isExtension()) {
3329
try {
3430
// Attempt to get the URL of an extension resource. This will succeed if we're in an extension context.
35-
// eslint-disable-next-line @typescript-eslint/no-deprecated
31+
3632
const extensionUrl = chrome.runtime.getURL('');
3733
// Check if the current page URL is different from the extension's base URL (i.e., it's not an extension page)
3834
return !window.location.href.startsWith(extensionUrl);

extension/js/common/browser/ui.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ export class Ui {
403403

404404
public static spinner = (color: string, placeholderCls: 'small_spinner' | 'large_spinner' = 'small_spinner') => {
405405
const path = `/img/svgs/spinner-${color}-small.svg`;
406-
// eslint-disable-next-line @typescript-eslint/no-deprecated
406+
407407
const url = typeof chrome !== 'undefined' && chrome.runtime?.getURL ? chrome.runtime.getURL(path) : path;
408408
return `<i class="${placeholderCls}" data-test="spinner"><img src="${url}" /></i>`;
409409
};

extension/js/common/oauth2/oauth2.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,14 @@ export class OAuth2 {
3030
// need to use chrome.runtime.onMessage because BrowserMsg.addListener doesn't work
3131
// In gmail page reconnect auth popup, it sends event to background page (BrowserMsg.send.bg.await.reconnectAcctAuthPopup)
3232
// thefore BrowserMsg.addListener doesn't work
33-
// eslint-disable-next-line @typescript-eslint/no-deprecated
33+
3434
chrome.runtime.onMessage.addListener((message: Bm.Raw) => {
3535
if (message.name === 'auth_window_result') {
36-
// eslint-disable-next-line @typescript-eslint/no-deprecated
3736
void chrome.tabs.remove(tabId!); // eslint-disable-line @typescript-eslint/no-non-null-assertion
3837
resolve(message.data.bm as Bm.AuthWindowResult);
3938
}
4039
});
41-
// eslint-disable-next-line @typescript-eslint/no-deprecated
40+
4241
chrome.tabs.onRemoved.addListener(removedTabId => {
4342
// Only reject error when auth result not successful
4443
if (removedTabId === tabId) {

0 commit comments

Comments
 (0)