Skip to content

Commit

Permalink
Updated to use modules and updated CI.
Browse files Browse the repository at this point in the history
  • Loading branch information
tdulcet committed Nov 13, 2023
1 parent 8dd7be2 commit 5bdf581
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 23 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
- name: Install
run: npm install -g eslint
- name: Script
Expand All @@ -28,7 +28,7 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
- name: Install
run: npm install -g typescript
- name: Script
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Copyright © 2020 Teal Dulcet

![](icons/icon.svg)

Thunderbird add-on/MailExtension to easily and securely encrypt and upload large attachments to any [Send service instance](https://github.com/timvisee/send-instances/#instances) (formerly [Firefox Send](https://github.com/mozilla/send)) and send the links via e-mail using the [CloudFile/FileLink API](https://thunderbird-webextensions.readthedocs.io/en/latest/cloudFile.html). Firefox Send was [discontinued by Mozilla](https://support.mozilla.org/kb/what-happened-firefox-send) in 2020. It is now maintained by @timvisee and called just [Send](https://github.com/timvisee/send).
Thunderbird add-on/MailExtension to easily and securely encrypt and upload large attachments to any [Send service instance](https://github.com/timvisee/send-instances/#instances) (formerly [Firefox Send](https://github.com/mozilla/send)) and send the links via e-mail using the [CloudFile/FileLink API](https://thunderbird-webextensions.readthedocs.io/en/latest/cloudFile.html). Firefox Send was [discontinued by Mozilla](https://support.mozilla.org/kb/what-happened-firefox-send) in 2020. It is now maintained by @timvisee and called just [Send](https://github.com/timvisee/send), but soon will be [resurrected by Thunderbird](https://youtu.be/zt_2xiNjQBo).

* Enables simple, yet private file sharing with end-to-end encryption
* Files are securely [encrypted](https://github.com/timvisee/send/blob/master/docs/encryption.md) and uploaded locally in Thunderbird using the [Web Crypto](https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API) and [WebSocket](https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API) APIs
Expand Down Expand Up @@ -44,6 +44,7 @@ Pull requests welcome! Ideas for contributions:
* Refactor into more modules
* Open the popup in the compose window instead of a separate standalone window (see [Bug 1711446](https://bugzilla.mozilla.org/show_bug.cgi?id=1711446) and [Bug 1752114](https://bugzilla.mozilla.org/show_bug.cgi?id=1752114))
* Show the upload progress (also see [Bug 736169](https://bugzilla.mozilla.org/show_bug.cgi?id=736169))
* Support consolidation/zipping of multiple attachments into a single link (see [Bug 1856232](https://bugzilla.mozilla.org/show_bug.cgi?id=1856232))
* [Improve the management page](https://github.com/TinyWebEx/AutomaticSettings/issues/13)
* [Check validity of input before saving values](https://github.com/TinyWebEx/AutomaticSettings/issues/14)
* Sync settings (see [bug 446444](https://bugzilla.mozilla.org/show_bug.cgi?id=446444))
Expand Down
2 changes: 1 addition & 1 deletion background.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<head>
<meta charset="utf-8">
<script src="common.js"></script>
<!-- <script src="common.js"></script> -->
<script src="background.js" type="module" charset="utf-8"></script>
</head>

Expand Down
25 changes: 15 additions & 10 deletions background.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"use strict";

import { BACKGROUND, POPUP, VERIFY, numberFormat, outputunit } from "/common.js";

import * as AddonSettings from "/common/modules/AddonSettings/AddonSettings.js";

const TITLE = "FileLink provider for Send";
Expand Down Expand Up @@ -78,8 +80,8 @@ function getSecondsAsDigitalClock(sec_num) {
// console.log(sec_num);
const d = Math.floor(sec_num / 86400);
const h = Math.floor(sec_num % 86400 / 3600);
const m = Math.floor(sec_num % 86400 % 3600 / 60);
const s = sec_num % 86400 % 3600 % 60;
const m = Math.floor(sec_num % 3600 / 60);
const s = sec_num % 60;
const text = [];
if (d > 0) {
text.push(numberFormat1.format(d));
Expand Down Expand Up @@ -518,7 +520,7 @@ async function checkServerVersion(service) {
const json = await response.json();
console.log(json);

const version = json.version;
const { version } = json;
if (version && version.startsWith("v") && Number.parseInt(version.slice(1).split(".")[0], 10) >= 3) {
return true;
}
Expand Down Expand Up @@ -579,7 +581,7 @@ async function uploaded(account, { id, name, data }, tab, relatedFileInfo) {
const promise = tabs.get(tabId).then(async () => {
browser.composeAction.enable(tabId);
browser.composeAction.setBadgeText({
text: numberFormat.format(promiseMap.size + 1),
text: numberFormat.format(promiseMap.size + 1)
// tabId
});

Expand All @@ -596,7 +598,7 @@ async function uploaded(account, { id, name, data }, tab, relatedFileInfo) {
});

browser.composeAction.setBadgeText({
text: promiseMap.size ? numberFormat.format(promiseMap.size) : null,
text: promiseMap.size ? numberFormat.format(promiseMap.size) : null
// tabId
});
browser.composeAction.disable(tabId);
Expand Down Expand Up @@ -791,6 +793,7 @@ async function uploaded(account, { id, name, data }, tab, relatedFileInfo) {

const url = `${uploadInfo.url}#${arrayToB64(rawSecret)}`;
// console.info(url);
console.assert(!URL.canParse || URL.canParse(url), "Error: Invalid URL", url);

if (upload.password) {
const authKey = await crypto.subtle.importKey("raw", encoder.encode(upload.password), { name: "PBKDF2" }, false, [
Expand Down Expand Up @@ -866,7 +869,7 @@ browser.cloudFile.onFileUpload.addListener(uploaded);
* @param {Object} tab
* @returns {void}
*/
function canceled(account, id, tab) {
function canceled(account, id/* , tab */) {
console.log(account, id);
const upload = uploads.get(id);
if (upload) {
Expand All @@ -891,7 +894,7 @@ browser.cloudFile.onFileUploadAbort.addListener(canceled);
* @param {Object} tab
* @returns {Promise<void>}
*/
async function deleted(account, id, tab) {
async function deleted(account, id/* , tab */) {
console.log(account, id);
let aaccount = await AddonSettings.get("account");
aaccount = aaccount[account.id] || aaccount;
Expand Down Expand Up @@ -950,9 +953,11 @@ browser.cloudFile.onAccountAdded.addListener((account) => {
* @returns {void}
*/
function setSettings(asettings) {
SEND = asettings.send;
LINK = asettings.link;
composeAction = asettings.composeAction;
({
send: SEND,
link: LINK,
composeAction
} = asettings);
}

/**
Expand Down
10 changes: 5 additions & 5 deletions common.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
"use strict";

// communication type
const BACKGROUND = "background";
const POPUP = "popup";
const VERIFY = "verify";
export const BACKGROUND = "background";
export const POPUP = "popup";
export const VERIFY = "verify";

const suffix_power_char = Object.freeze(["", "K", "M", "G", "T", "P", "E", "Z", "Y", "R", "Q"]);

const numberFormat = new Intl.NumberFormat();
export const numberFormat = new Intl.NumberFormat();

/**
* Auto-scale number to unit.
Expand All @@ -17,7 +17,7 @@ const numberFormat = new Intl.NumberFormat();
* @param {boolean} scale
* @returns {string}
*/
function outputunit(number, scale) {
export function outputunit(number, scale) {
let str = "";

const scale_base = scale ? 1000 : 1024;
Expand Down
2 changes: 1 addition & 1 deletion popup/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<link rel="stylesheet" href="popup.css">

<!-- <script defer src="../common/common.js" type="module"></script> -->
<script defer src="../common.js"></script>
<!-- <script defer src="../common.js"></script> -->
<script defer src="./popup.js" type="module"></script>
<title>📤 Thunderbird Send</title>
</head>
Expand Down
7 changes: 4 additions & 3 deletions popup/popup.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"use strict";

import { POPUP, outputunit } from "/common.js";

import * as characters from "/common/modules/data/Characters.js";
import * as words from "/common/modules/data/Words.js";
import * as emojis from "/common/modules/data/Emojis.js";
Expand Down Expand Up @@ -264,13 +266,12 @@ cancel.addEventListener("click", (event) => {
browser.runtime.sendMessage({ type: POPUP }).then((message) => {
// console.log(message);
if (message.type === POPUP) {
const send = message.send;
const { send, file } = message;
downloads.value = send.downloads;
days.value = Math.floor(send.time / 1440);
hours.value = Math.floor(send.time % 1440 / 60);
minutes.value = send.time % 1440 % 60;
minutes.value = send.time % 60;

const file = message.file;
document.getElementById("name").textContent = file.name;
document.getElementById("size").textContent = `${outputunit(file.size, false)}B${file.size >= 1000 ? ` (${outputunit(file.size, true)}B)` : ""}`;

Expand Down

0 comments on commit 5bdf581

Please sign in to comment.