Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(deps): bump the npm-deps group with 11 updates #5875

Merged
merged 4 commits into from
Dec 4, 2024
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
2 changes: 1 addition & 1 deletion extension/chrome/elements/attachment_preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import * as pdfjsLib from 'pdfjs';
import { AttachmentPreviewPdf } from '../../js/common/ui/attachment_preview_pdf.js';

// https://github.com/FlowCrypt/flowcrypt-browser/issues/5822#issuecomment-2362529197
// eslint-disable-next-line @typescript-eslint/no-deprecated

pdfjsLib.GlobalWorkerOptions.workerSrc = chrome.runtime.getURL(`lib/pdf.worker.min.mjs`);
type AttachmentType = 'img' | 'txt' | 'pdf';

Expand Down
1 change: 0 additions & 1 deletion extension/chrome/settings/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ View.run(
}

public render = async () => {
// eslint-disable-next-line @typescript-eslint/no-deprecated
const isDevMode = !('update_url' in chrome.runtime.getManifest());
$('#status-row #status_version').text(`v:${VERSION}${isDevMode ? '-dev' : ''}`);
for (const webmailLName of await Env.webmails()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export class ConfiguredIdpOAuth extends OAuth {
grant_type: 'refresh_token',
refreshToken,
client_id: authConf.oauth.clientId,
// eslint-disable-next-line @typescript-eslint/no-deprecated

redirect_uri: chrome.identity.getRedirectURL('oauth'),
},
dataType: 'JSON',
Expand All @@ -120,7 +120,7 @@ export class ConfiguredIdpOAuth extends OAuth {
access_type: 'offline',
prompt: 'login',
state,
// eslint-disable-next-line @typescript-eslint/no-deprecated

redirect_uri: chrome.identity.getRedirectURL('oauth'),
scope: this.OAUTH_REQUEST_SCOPES.join(' '),
login_hint: acctEmail,
Expand All @@ -131,9 +131,8 @@ export class ConfiguredIdpOAuth extends OAuth {
private static async getAuthRes({ acctEmail, expectedState, authUrl }: { acctEmail: string; expectedState: string; authUrl: string }): Promise<AuthRes> {
/* eslint-disable @typescript-eslint/naming-convention */
try {
// eslint-disable-next-line @typescript-eslint/no-deprecated
const redirectUri = await chrome.identity.launchWebAuthFlow({ url: authUrl, interactive: true });
// eslint-disable-next-line @typescript-eslint/no-deprecated

if (chrome.runtime.lastError || !redirectUri || redirectUri?.includes('access_denied')) {
return { acctEmail, result: 'Denied', error: `Failed to launch web auth flow`, id_token: undefined };
}
Expand Down Expand Up @@ -207,7 +206,7 @@ export class ConfiguredIdpOAuth extends OAuth {
grant_type: 'authorization_code',
code,
client_id: authConf.oauth.clientId,
// eslint-disable-next-line @typescript-eslint/no-deprecated

redirect_uri: chrome.identity.getRedirectURL('oauth'),
},
dataType: 'JSON',
Expand Down
6 changes: 3 additions & 3 deletions extension/js/common/api/email-provider/sendable-msg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ export class SendableMsg {
public type: MimeEncodeType,
public externalId?: string // for binding a password-protected message
) {
const allEmails = this.getAllRecipients();
if (!allEmails.length && !isDraft) {
const allRecipients = this.getAllRecipients();
if (!allRecipients.length && !isDraft) {
throw new Error('The To:, Cc: and Bcc: fields are empty. Please add recipients and try again');
}
const invalidEmails = allEmails.filter(email => !Str.isEmailValid(email.email));
const invalidEmails = allRecipients.map(recipient => recipient.email).filter(email => !Str.isEmailValid(email));
// todo: distinguish To:, Cc: and Bcc: in error report?
if (invalidEmails.length) {
throw new InvalidRecipientError(`The To: field contains invalid emails: ${invalidEmails.join(', ')}\n\nPlease check recipients and try again.`);
Expand Down
15 changes: 4 additions & 11 deletions extension/js/common/browser/browser-msg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export interface ChildFrame {

export namespace Bm {
export type Dest = string;
// eslint-disable-next-line @typescript-eslint/no-deprecated

export type Sender = chrome.runtime.MessageSender | 'background';
export type Response = unknown;
export type RawResponse = { result: unknown; exception?: Bm.ErrAsJson };
Expand Down Expand Up @@ -415,7 +415,6 @@ export class BrowserMsg {
}

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

public static createIntervalAlarm(action: string, periodInMinutes: number) {
const alarmName = `${action}_interval_${Date.now()}`;
// eslint-disable-next-line @typescript-eslint/no-deprecated

void chrome.alarms.create(alarmName, { periodInMinutes });
}

Expand All @@ -441,7 +440,6 @@ export class BrowserMsg {
}

public static bgListen() {
// eslint-disable-next-line @typescript-eslint/no-deprecated
chrome.runtime.onMessage.addListener((msg: Bm.Raw, _sender, rawRespond: (rawRes: Bm.RawResponse) => void) => {
const respondIfPageStillOpen = (response: Bm.RawResponse) => {
try {
Expand Down Expand Up @@ -521,7 +519,7 @@ export class BrowserMsg {
Catch.try(BrowserMsg.INTERVAL_HANDLERS[actionName])();
}
};
// eslint-disable-next-line @typescript-eslint/no-deprecated

chrome.alarms.onAlarm.addListener(alarmListener);
}

Expand Down Expand Up @@ -646,7 +644,7 @@ export class BrowserMsg {
resolve(undefined);
} else if (!r || typeof r !== 'object') {
// r can be null if we sent a message to a non-existent window id
// eslint-disable-next-line @typescript-eslint/no-deprecated

const lastError = chrome.runtime.lastError ? chrome.runtime.lastError.message || '(empty lastError)' : '(no lastError)';
let e: Error;
if (typeof destString === 'undefined' && typeof r === 'undefined') {
Expand Down Expand Up @@ -676,24 +674,19 @@ export class BrowserMsg {
}
};
try {
// eslint-disable-next-line @typescript-eslint/no-deprecated
if (chrome.runtime) {
Env.isBackgroundPage()
.then(isBackgroundPage => {
if (isBackgroundPage) {
// eslint-disable-next-line @typescript-eslint/no-deprecated
chrome.tabs.query({ active: true, currentWindow: true }, tabs => {
for (const tab of tabs) {
// eslint-disable-next-line @typescript-eslint/no-deprecated
chrome.tabs.sendMessage(Number(tab.id), msg, resolve);
}
});
} else {
if (awaitRes) {
// eslint-disable-next-line @typescript-eslint/no-deprecated
chrome.runtime.sendMessage(msg, processRawMsgResponse);
} else {
// eslint-disable-next-line @typescript-eslint/no-deprecated
void chrome.runtime.sendMessage(msg);
}
}
Expand Down
1 change: 0 additions & 1 deletion extension/js/common/browser/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ export class Browser {
};

public static openSettingsPage = async (path = 'index.htm', acctEmail?: string, page = '', rawPageUrlParams?: Dict<UrlParam>, addNewAcct = false) => {
// eslint-disable-next-line @typescript-eslint/no-deprecated
const basePath = chrome.runtime.getURL(`chrome/settings/${path}`);
const pageUrlParams = rawPageUrlParams ? JSON.stringify(rawPageUrlParams) : undefined;
if (acctEmail || path === 'fatal.htm') {
Expand Down
17 changes: 2 additions & 15 deletions extension/js/common/browser/chrome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@ const handleFatalErr = async (reason: 'storage_undefined', error: Error) => {
throw error;
} else if (Env.isContentScript()) {
console.error('Incomplete extension environment in content script', error);
// eslint-disable-next-line @typescript-eslint/no-deprecated
} else if (!chrome.runtime) {
console.error('Chrome.runtime missing, cannot continue', error);
} else {
// extension pages
// eslint-disable-next-line @typescript-eslint/no-deprecated

window.location.href = chrome.runtime.getURL(Url.create(`chrome/settings/fatal.htm`, { reason, stack: error.stack }));
}
} catch (e) {
Expand All @@ -34,12 +33,10 @@ const handleFatalErr = async (reason: 'storage_undefined', error: Error) => {
}
}
};
// eslint-disable-next-line @typescript-eslint/no-deprecated

export const windowsCreate = async (q: chrome.windows.CreateData): Promise<chrome.windows.Window | undefined> => {
return await new Promise(resolve => {
// eslint-disable-next-line @typescript-eslint/no-deprecated
if (typeof chrome.windows !== 'undefined') {
// eslint-disable-next-line @typescript-eslint/no-deprecated
chrome.windows.create(q, resolve);
} else {
Ui.modal.error('Your platform is not supported: browser does not support extension windows').catch(Catch.reportErr);
Expand All @@ -49,18 +46,14 @@ export const windowsCreate = async (q: chrome.windows.CreateData): Promise<chrom

export const storageGet = async (storageType: ChromeStorageType, keys: string[]): Promise<Dict<unknown>> => {
return await new Promise((resolve, reject) => {
// eslint-disable-next-line @typescript-eslint/no-deprecated
if (typeof chrome.storage === 'undefined') {
void handleFatalErr('storage_undefined', new Error('storage is undefined'));
} else {
// eslint-disable-next-line @typescript-eslint/no-deprecated
const storage = chrome.storage[storageType];
storage.get(keys, result => {
if (typeof result !== 'undefined') {
resolve(result);
// eslint-disable-next-line @typescript-eslint/no-deprecated
} else if (chrome.runtime.lastError) {
// eslint-disable-next-line @typescript-eslint/no-deprecated
reject(AbstractStore.errCategorize(chrome.runtime.lastError));
} else {
reject(new Error(`storageGet(${storageType}, ${keys.join(',')}) produced undefined result without an error`));
Expand All @@ -72,11 +65,9 @@ export const storageGet = async (storageType: ChromeStorageType, keys: string[])

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

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

export const storageRemove = async (storageType: ChromeStorageType, keys: string[]): Promise<void> => {
return await new Promise(resolve => {
// eslint-disable-next-line @typescript-eslint/no-deprecated
if (typeof chrome.storage === 'undefined') {
void handleFatalErr('storage_undefined', new Error('storage is undefined'));
} else {
// eslint-disable-next-line @typescript-eslint/no-deprecated
const storage = chrome.storage[storageType];
storage.remove(keys, resolve);
}
Expand Down
6 changes: 1 addition & 5 deletions extension/js/common/browser/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,17 @@ export type WebMailVersion = 'generic' | 'gmail2020' | 'gmail2022';

export class Env {
public static runtimeId(orig = false) {
// eslint-disable-next-line @typescript-eslint/no-deprecated
if (chrome?.runtime?.id) {
if (orig) {
// eslint-disable-next-line @typescript-eslint/no-deprecated
return chrome.runtime.id;
} else {
// eslint-disable-next-line @typescript-eslint/no-deprecated
return chrome.runtime.id.replace(/[^a-z0-9]/gi, '');
}
}
return undefined;
}

public static getExtensionOrigin() {
// eslint-disable-next-line @typescript-eslint/no-deprecated
const url = chrome.runtime.getURL('');
return Url.removeTrailingSlash(url);
}
Expand All @@ -32,7 +28,7 @@ export class Env {
if (Env.isExtension()) {
try {
// Attempt to get the URL of an extension resource. This will succeed if we're in an extension context.
// eslint-disable-next-line @typescript-eslint/no-deprecated

const extensionUrl = chrome.runtime.getURL('');
// Check if the current page URL is different from the extension's base URL (i.e., it's not an extension page)
return !window.location.href.startsWith(extensionUrl);
Expand Down
2 changes: 1 addition & 1 deletion extension/js/common/browser/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ export class Ui {

public static spinner = (color: string, placeholderCls: 'small_spinner' | 'large_spinner' = 'small_spinner') => {
const path = `/img/svgs/spinner-${color}-small.svg`;
// eslint-disable-next-line @typescript-eslint/no-deprecated

const url = typeof chrome !== 'undefined' && chrome.runtime?.getURL ? chrome.runtime.getURL(path) : path;
return `<i class="${placeholderCls}" data-test="spinner"><img src="${url}" /></i>`;
};
Expand Down
5 changes: 2 additions & 3 deletions extension/js/common/oauth2/oauth2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,14 @@ export class OAuth2 {
// need to use chrome.runtime.onMessage because BrowserMsg.addListener doesn't work
// In gmail page reconnect auth popup, it sends event to background page (BrowserMsg.send.bg.await.reconnectAcctAuthPopup)
// thefore BrowserMsg.addListener doesn't work
// eslint-disable-next-line @typescript-eslint/no-deprecated

chrome.runtime.onMessage.addListener((message: Bm.Raw) => {
if (message.name === 'auth_window_result') {
// eslint-disable-next-line @typescript-eslint/no-deprecated
void chrome.tabs.remove(tabId!); // eslint-disable-line @typescript-eslint/no-non-null-assertion
resolve(message.data.bm as Bm.AuthWindowResult);
}
});
// eslint-disable-next-line @typescript-eslint/no-deprecated

chrome.tabs.onRemoved.addListener(removedTabId => {
// Only reject error when auth result not successful
if (removedTabId === tabId) {
Expand Down
2 changes: 1 addition & 1 deletion extension/js/common/oauth2/oauth2_inject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const win: Window = window;

// Redirect back to the extension itself so that we have priveledged access again
// Need to send BrowserMsg event back to GoogleAuth
// eslint-disable-next-line @typescript-eslint/no-deprecated

const redirect = chrome.runtime.getURL('/chrome/elements/oauth2.htm');

win.location = redirect + win.location.search;
1 change: 0 additions & 1 deletion extension/js/common/platform/xss.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,6 @@ export class Xss {
private static sanitizeHrefRegexp = () => {
if (typeof Xss.HREF_REGEX_CACHE === 'undefined') {
Xss.HREF_REGEX_CACHE = new RegExp(
// eslint-disable-next-line @typescript-eslint/no-deprecated
`^(?:(http|https|cid):|data:image/|${Str.regexEscape(chrome.runtime.getURL('/'))}|[^a-z]|[a-z+.\\-]+(?:[^a-z+.\\-:]|$))`,
'i'
);
Expand Down
4 changes: 1 addition & 3 deletions extension/js/common/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ export class Settings {
throw new Error('Filter is empty for account_email"' + acctEmail + '"');
}
await new Promise<void>((resolve, reject) => {
// eslint-disable-next-line @typescript-eslint/no-deprecated
chrome.storage.local.get(async storage => {
try {
for (const storageIndex of Object.keys(storage)) {
Expand Down Expand Up @@ -440,10 +439,9 @@ export class Settings {
}

public static async loginWithPopupShowModalOnErr(acctEmail: string, isCustomIDP: boolean, then: () => void = () => undefined) {
// eslint-disable-next-line @typescript-eslint/no-deprecated
if (window !== window.top && !chrome.windows) {
// Firefox, chrome.windows isn't available in iframes
// eslint-disable-next-line @typescript-eslint/no-deprecated

await Browser.openExtensionTab(Url.create(chrome.runtime.getURL(`chrome/settings/index.htm`), { acctEmail }));
await Ui.modal.info(`Reload after logging in.`);
window.location.reload();
Expand Down
1 change: 0 additions & 1 deletion extension/js/common/xss-safe-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,6 @@ export class XssSafeFactory {
};

private extUrl = (s: string) => {
// eslint-disable-next-line @typescript-eslint/no-deprecated
return chrome.runtime.getURL(s);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export class GmailWebmailStartup {

private injectFCVarScript = () => {
const scriptElement = document.createElement('script');
// eslint-disable-next-line @typescript-eslint/no-deprecated

scriptElement.src = chrome.runtime.getURL('/js/common/core/feature-config-injector.js');
(document.head || document.documentElement).appendChild(scriptElement);
};
Expand Down
8 changes: 3 additions & 5 deletions extension/js/service_worker/bg-handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,22 +72,21 @@ export class BgHandlers {

public static updateUninstallUrl: Bm.AsyncResponselessHandler = async () => {
const acctEmails = await GlobalStore.acctEmailsGet();
// eslint-disable-next-line @typescript-eslint/no-deprecated

if (typeof chrome.runtime.setUninstallURL !== 'undefined') {
const email = acctEmails?.length ? acctEmails[0] : undefined;
// eslint-disable-next-line @typescript-eslint/no-deprecated

chrome.runtime.setUninstallURL(`https://flowcrypt.com/leaving.htm#${JSON.stringify({ email, metrics: null })}`); // eslint-disable-line no-null/no-null
}
};

public static getActiveTabInfo: Bm.AsyncRespondingHandler = () =>
new Promise((resolve, reject) => {
// eslint-disable-next-line @typescript-eslint/no-deprecated
chrome.tabs.query({ active: true, currentWindow: true, url: ['*://mail.google.com/*', '*://inbox.google.com/*'] }, activeTabs => {
if (activeTabs.length) {
if (activeTabs[0].id !== undefined) {
type ScriptRes = { acctEmail: string | undefined; sameWorld: boolean | undefined };
// eslint-disable-next-line @typescript-eslint/no-deprecated

chrome.scripting.executeScript(
{
target: { tabId: activeTabs[0].id },
Expand Down Expand Up @@ -152,7 +151,6 @@ export class BgHandlers {
};

public static thunderbirdContentScriptRegistration = async () => {
// eslint-disable-next-line @typescript-eslint/no-deprecated
const contentScriptGroups = chrome.runtime.getManifest().content_scripts ?? []; // we know it's in the manifest
// sweetalert2.js throws error in Thunderbird environment
const files = contentScriptGroups[0].js?.filter(url => !url.includes('sweetalert2')).map(url => url.replace(/moz-extension:\/\/[^/]+\//, './')) ?? [];
Expand Down
Loading
Loading