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
1 change: 1 addition & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ const commonConfig = {
'@typescript-eslint/consistent-type-definitions': 'off',
'@typescript-eslint/dot-notation': 'error',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-unnecessary-type-conversion': 'warn',
'@typescript-eslint/explicit-member-accessibility': [
'error',
{
Expand Down
2 changes: 1 addition & 1 deletion extension/chrome/elements/add_pubkey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ View.run(
await Ui.modal.warning(`some keys could not be processed due to errors:\n${errs.map(e => `-> ${e.message}\n`).join('')}`);
}
$('.copy_from_email').val('');
$('.pubkey').val(String(KeyUtil.armor(keys[0])));
$('.pubkey').val(KeyUtil.armor(keys[0]));
$('.action_ok').trigger('click');
} else if (errs.length) {
await Ui.modal.error(`error processing public keys:\n${errs.map(e => `-> ${e.message}\n`).join('')}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ export class ComposeQuoteModule extends ViewModule<ComposeView> {
}
const text = this.messageToReplyOrForward.text;
const from = Str.parseEmail(this.messageToReplyOrForward.headers.from || '').email;
const date = new Date(String(this.messageToReplyOrForward.headers.date));
const date = new Date(this.messageToReplyOrForward.headers.date);
const dateStr = Str.fromDate(date).replace(' ', ' at ');
const rtl = new RegExp('[' + Str.rtlChars + ']').exec(text);
const dirAttr = `dir="${rtl ? 'rtl' : 'ltr'}"`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ export class ComposeRecipientsModule extends ViewModule<ComposeView> {
this.view.S.now('send_btn_text').text(this.BTN_LOADING);
this.view.sizeModule.setInputTextHeightManuallyIfNeeded();
recipientEl.evaluating = (async () => {
this.view.errModule.debug(`evaluateRecipients.evaluat.recipient.email(${String(recipientEl.email)})`);
this.view.errModule.debug(`evaluateRecipients.evaluat.recipient.email(${recipientEl.email})`);
this.view.errModule.debug(`evaluateRecipients.evaluating.recipient.status(${recipientEl.status})`);
this.view.errModule.debug(`evaluateRecipients.evaluating: calling getUpToDatePubkeys`);
const info = await this.view.storageModule.getUpToDatePubkeys(recipientEl.email);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ export class PgpBlockViewAttachmentsModule {
const size = filesize(attachments[i].length);

const htmlContent = `<b>${Xss.escape(nameVisible)}</b>&nbsp;&nbsp;&nbsp;${size}<span class="progress"><span class="percent"></span></span>`;
const attachment = $(`<a href="#" index="${Number(i)}">`);
const attachment = $(`<a href="#" index="${i}">`);
attachment.attr('title', name);
Xss.sanitizeAppend(attachment, htmlContent);
if (isEncrypted) {
attachment.addClass('preview-attachment');
attachment.attr('data-test', 'preview-attachment');
attachment.append(
`<button class="download-attachment" data-test="download-attachment-${Number(i)}" index="${Number(
`<button class="download-attachment" data-test="download-attachment-${i}" index="${
i
)}" title="DOWNLOAD"><img src="/img/svgs/download-link-green.svg"></button>`
}" title="DOWNLOAD"><img src="/img/svgs/download-link-green.svg"></button>`
); // xss-escaped
} else {
attachment.attr('data-test', `download-attachment-${Number(i)}`);
attachment.attr('data-test', `download-attachment-${i}`);
attachment.addClass('download-attachment');
}
$('#attachments').append(attachment); // xss-escaped
Expand Down
2 changes: 1 addition & 1 deletion extension/js/common/api/email-provider/gmail/gmail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class Gmail extends EmailProviderApi implements EmailProviderInterface {
method: 'GET',
data: {
labelIds: labelId !== 'ALL' ? labelId : undefined,
includeSpamTrash: Boolean(labelId === 'SPAM' || labelId === 'TRASH'),
includeSpamTrash: labelId === 'SPAM' || labelId === 'TRASH',
// pageToken: page_token,
// q,
// maxResults
Expand Down
2 changes: 1 addition & 1 deletion extension/js/common/api/shared/api-error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export class AjaxErr extends ApiCallErr {
const redactedPayload = AjaxErr.redactSensitiveData(Catch.stringify(req.data).substring(0, 1000));
stack += `\n\nresponseText(0, 1000):\n${redactedRes}\n\npayload(0, 1000):\n${redactedPayload}`;
}
const message = `${String(xhr.statusText || '(no status text)')}: ${String(xhr.status || -1)} when ${ApiCallErr.describeApiAction(req)} -> ${
const message = `${xhr.statusText || '(no status text)'}: ${xhr.status || -1} when ${ApiCallErr.describeApiAction(req)} -> ${
resMsg || '(no standard err msg)'
}`;
return new AjaxErr(message, stack, status, CatchHelper.censoredUrl(req.url), responseText, xhr.statusText || '(no status text)', resMsg, resDetails);
Expand Down
2 changes: 1 addition & 1 deletion extension/js/common/browser/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { BgUtils } from '../../service_worker/bgutils.js';

export class Browser {
public static objUrlCreate = (content: Uint8Array | string) => {
return URL.createObjectURL(new Blob([content], { type: 'application/octet-stream' }));
return URL.createObjectURL(new Blob([content as BlobPart], { type: 'application/octet-stream' }));
};

public static saveToDownloads = (attachment: Attachment) => {
Expand Down
6 changes: 3 additions & 3 deletions extension/js/common/core/crypto/smime/smime-key.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export class SmimeKey {
}
p7.addRecipient(certificate);
}
p7.content = this.forge.util.createBuffer(input);
p7.content = this.forge.util.createBuffer(new Uint8Array(input));
p7.encrypt();
let data: Uint8Array;
if (armor) {
Expand Down Expand Up @@ -151,7 +151,7 @@ export class SmimeKey {
type: this.forge.pki.oids.messageDigest
}] */
});
p7.content = this.forge.util.createBuffer(data);
p7.content = this.forge.util.createBuffer(new Uint8Array(data));
p7.sign();
return SmimeKey.messageToDer(p7);
}
Expand Down Expand Up @@ -413,7 +413,7 @@ export class SmimeKey {
if (!eku) {
return false;
}
return !!(eku as { emailProtection: boolean }).emailProtection;
return (eku as { emailProtection: boolean }).emailProtection;
}

private static dateToNumber(date: Date): undefined | number {
Expand Down
8 changes: 4 additions & 4 deletions extension/js/common/core/mime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ export class Mime {
const parser = new MimeParser();
const leafNodes: { [key: string]: MimeParserNode } = {};
parser.onbody = (node: MimeParserNode) => {
const path = String(node.path.join('.'));
const path = node.path.join('.');
if (typeof leafNodes[path] === 'undefined') {
leafNodes[path] = node;
}
Expand Down Expand Up @@ -343,7 +343,7 @@ export class Mime {
let from: string | undefined;
const getHdrValAsArr = (hdr: MimeContentHeader) =>
typeof hdr === 'string' ? ([hdr].map(h => Str.parseEmail(h).email).filter(e => !!e) as string[]) : hdr.map(h => h.address);
const getHdrValAsStr = (hdr: MimeContentHeader) => Str.parseEmail((Array.isArray(hdr) ? hdr[0]?.address : String(hdr || '')) || '').email;
const getHdrValAsStr = (hdr: MimeContentHeader) => Str.parseEmail((Array.isArray(hdr) ? hdr[0]?.address : hdr || '') || '').email;
for (const hdrName of headersNames) {
const header = parsedMimeMsg.headers[hdrName];
if (header) {
Expand Down Expand Up @@ -427,13 +427,13 @@ export class Mime {
if (node.headers['content-disposition']?.[0]) {
const header = node.headers['content-disposition'][0];
if (header.params?.filename) {
return String(header.params.filename);
return header.params.filename;
}
}
if (node.headers['content-type']?.[0]) {
const header = node.headers['content-type'][0];
if (header.params?.name) {
return String(header.params.name);
return header.params.name;
}
}
return;
Expand Down
1 change: 1 addition & 0 deletions extension/js/common/message-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,7 @@ export class MessageRenderer {
signerEmail,
verificationPubs,
result.content,
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-conversion
!!result.isEncrypted,
result.signature,
renderModule,
Expand Down
2 changes: 1 addition & 1 deletion extension/js/common/platform/catch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ export class Catch {
thrown.stack += Catch.formattedStackBlock('Catch.reportErr calling stack', CatchHelper.stackTrace());
if (thrown.hasOwnProperty('workerStack')) {
// https://github.com/openpgpjs/openpgpjs/issues/656#event-1498323188
thrown.stack += Catch.formattedStackBlock('openpgp.js worker stack', String((thrown as Error & { workerStack: string }).workerStack));
thrown.stack += Catch.formattedStackBlock('openpgp.js worker stack', (thrown as Error & { workerStack: string }).workerStack);
}
}
const exception = Catch.formExceptionFromThrown(thrown);
Expand Down
11 changes: 9 additions & 2 deletions extension/js/common/platform/store/encryption-key-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,24 @@ import { storageGet, storageSet } from '../../browser/chrome.js';
import { Buf } from '../../core/buf.js';
import { secureRandomBytes } from '../util.js';

const toArrayBufferStrict = (view: ArrayBufferView): ArrayBuffer => {
const ab = new ArrayBuffer(view.byteLength);
new Uint8Array(ab).set(new Uint8Array(view.buffer, view.byteOffset, view.byteLength));
return ab;
};

export class EncryptionKeyStore {
private static key = 'cryptup_cryptokey' as const;

public static async get(length?: number): Promise<ArrayBuffer> {
const storageObj = await storageGet('local', [EncryptionKeyStore.key]);
const value = storageObj[EncryptionKeyStore.key];
if (!length || typeof value !== 'undefined') {
return Buf.fromBase64Str(value as string);
const buf = Buf.fromBase64Str(value as string); // Buf extends Uint8Array
return toArrayBufferStrict(buf);
}
const newKey = secureRandomBytes(length);
await storageSet('local', { [EncryptionKeyStore.key]: new Buf(newKey).toBase64Str() });
return newKey;
return toArrayBufferStrict(newKey);
}
}
2 changes: 1 addition & 1 deletion extension/js/common/ui/backup-ui/backup-ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export class BackupUi {
private renderPrvKeysBackupSelection = async (kinfos: KeyInfoWithIdentity[]) => {
for (const ki of kinfos) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const email = Xss.escape(String(ki.emails![0]));
const email = Xss.escape(ki.emails![0]);
const dom = `
<div class="mb-20">
<div class="details">
Expand Down
4 changes: 2 additions & 2 deletions extension/js/common/xss-safe-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ export class XssSafeFactory {
const params: UrlParams = {
isReplyBox: true,
frameId: `frame_${Str.sloppyRandom(10)}`,
skipClickPrompt: Boolean(skipClickPrompt),
ignoreDraft: Boolean(ignoreDraft),
skipClickPrompt,
ignoreDraft,
replyMsgId: convoParams.replyMsgId,
draftId: convoParams.draftId,
removeAfterClose: convoParams.removeAfterClose,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ export const contentScriptSetupIfVacant = async (webmailSpecific: WebmailSpecifi
await webmailSpecific.start(acctEmail, clientConfiguration, inject, notifications, factory, relayManager);
} catch (e) {
if (e instanceof TabIdRequiredError) {
console.error(`FlowCrypt cannot start: ${String(e.message)}`);
console.error(`FlowCrypt cannot start: ${e.message}`);
} else if (e instanceof Error && e.message === 'Extension context invalidated.') {
console.info(`FlowCrypt cannot start: extension context invalidated. Destroying.`);
win.destroy();
Expand Down
2 changes: 1 addition & 1 deletion extension/js/service_worker/bg-handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export class BgHandlers {
if (tab.id) {
const message = await messenger.messageDisplay.getDisplayedMessage(tab.id);
if (message?.id) {
return await messenger.messages.getFull(Number(message.id));
return await messenger.messages.getFull(message.id);
}
}
return;
Expand Down
Loading
Loading