Skip to content

Commit 643287e

Browse files
committed
Merge branch 'AaronDewes-chore/cleanup-dependencies' into master
See #101
2 parents 625fdf5 + c619be5 commit 643287e

24 files changed

+1404
-3759
lines changed

.eslintrc.yml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,24 @@ env:
55
extends:
66
- eslint:recommended
77
- prettier
8-
- plugin:node/recommended
8+
- plugin:n/recommended
99
- plugin:security/recommended
1010

1111
plugins:
12-
- node
12+
- n
1313
- security
1414

1515
root: true
1616

1717
rules:
18-
node/no-deprecated-api: off
19-
node/no-unsupported-features/es-syntax: off
20-
node/no-unsupported-features/node-builtins: off
21-
node/no-unpublished-require: off
22-
node/no-unpublished-import: off
18+
n/no-deprecated-api: off
19+
n/no-unsupported-features/es-syntax: off
20+
n/no-unsupported-features/node-builtins: off
21+
n/no-unpublished-require: off
22+
n/no-unpublished-import: off
23+
n/no-process-exit: off
24+
# This forces using file extensions in imports, which is a best practice, but refactoring would take some time
25+
n/no-missing-import: off
2326

2427
security/detect-non-literal-fs-filename: off
2528
security/detect-object-injection: off

Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ COPY --chown=app:app server server
6363
COPY --chown=app:app --from=builder /app/dist dist
6464

6565
RUN npm ci --production && npm cache clean --force
66-
RUN mkdir -p /app/.config/configstore
6766
RUN ln -s dist/version.json version.json
6867

6968
ENV PORT=1443

app/.eslintrc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ parserOptions:
66
sourceType: module
77

88
rules:
9-
node/no-unsupported-features: off
9+
n/no-unsupported-features: off

app/capabilities.js

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,7 @@ async function checkCrypto() {
4545
);
4646
return true;
4747
} catch (err) {
48-
try {
49-
window.asmCrypto = await import('asmcrypto.js');
50-
await import('@dannycoates/webcrypto-liner/build/shim');
51-
return true;
52-
} catch (e) {
53-
return false;
54-
}
48+
return false;
5549
}
5650
}
5751

@@ -66,25 +60,12 @@ function checkStreams() {
6660
}
6761
}
6862

69-
async function polyfillStreams() {
70-
try {
71-
await import('@mattiasbuelens/web-streams-polyfill');
72-
return true;
73-
} catch (e) {
74-
return false;
75-
}
76-
}
77-
7863
export default async function getCapabilities() {
7964
const browser = browserName();
8065
const isMobile = /mobi|android/i.test(navigator.userAgent);
8166
const serviceWorker = 'serviceWorker' in navigator && browser !== 'edge';
8267
let crypto = await checkCrypto();
8368
const nativeStreams = checkStreams();
84-
let polyStreams = false;
85-
if (!nativeStreams) {
86-
polyStreams = await polyfillStreams();
87-
}
8869
let account = typeof AUTH_CONFIG !== 'undefined';
8970
try {
9071
account = account && !!localStorage;
@@ -106,10 +87,10 @@ export default async function getCapabilities() {
10687
account,
10788
crypto,
10889
serviceWorker,
109-
streamUpload: nativeStreams || polyStreams,
90+
streamUpload: nativeStreams,
11091
streamDownload:
11192
nativeStreams && serviceWorker && browser !== 'safari' && !mobileFirefox,
112-
multifile: nativeStreams || polyStreams,
93+
multifile: nativeStreams,
11394
share,
11495
standalone
11596
};

app/ece.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class ECETransformer {
4848
name: 'AES-GCM',
4949
length: 128
5050
},
51-
true, // Edge polyfill requires key to be extractable to encrypt :/
51+
false,
5252
['encrypt', 'decrypt']
5353
);
5454
}

app/main.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/* global DEFAULTS LIMITS WEB_UI PREFS */
22
import 'core-js';
3-
import 'fast-text-encoding'; // MS Edge support
43
import 'intl-pluralrules';
54
import choo from 'choo';
65
import nanotiming from 'nanotiming';

app/storage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ class Storage {
110110
}
111111

112112
set user(info) {
113-
return this.engine.setItem('user', JSON.stringify(info));
113+
this.engine.setItem('user', JSON.stringify(info));
114114
}
115115

116116
getFileById(id) {

app/streams.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* global TransformStream */
2-
31
export function transformStream(readable, transformer, oncancel) {
42
try {
53
return readable.pipeThrough(new TransformStream(transformer));

app/utils.js

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -23,39 +23,34 @@ function locale() {
2323
return document.querySelector('html').lang;
2424
}
2525

26-
function loadShim(polyfill) {
27-
return new Promise((resolve, reject) => {
28-
const shim = document.createElement('script');
29-
shim.src = polyfill;
30-
shim.addEventListener('load', () => resolve(true));
31-
shim.addEventListener('error', () => resolve(false));
32-
document.head.appendChild(shim);
33-
});
34-
}
35-
3626
function isFile(id) {
3727
return /^[0-9a-fA-F]{10,16}$/.test(id);
3828
}
3929

40-
function copyToClipboard(str) {
41-
const aux = document.createElement('input');
42-
aux.setAttribute('value', str);
43-
aux.contentEditable = true;
44-
aux.readOnly = true;
45-
document.body.appendChild(aux);
46-
if (navigator.userAgent.match(/iphone|ipad|ipod/i)) {
47-
const range = document.createRange();
48-
range.selectNodeContents(aux);
49-
const sel = getSelection();
50-
sel.removeAllRanges();
51-
sel.addRange(range);
52-
aux.setSelectionRange(0, str.length);
53-
} else {
54-
aux.select();
30+
async function copyToClipboard(str) {
31+
try {
32+
await navigator.clipboard.writeText(str);
33+
} catch {
34+
// Older browsers or the clipboard API fails because of a missing permission
35+
const aux = document.createElement('input');
36+
aux.setAttribute('value', str);
37+
aux.contentEditable = true;
38+
aux.readOnly = true;
39+
document.body.appendChild(aux);
40+
if (navigator.userAgent.match(/iphone|ipad|ipod/i)) {
41+
const range = document.createRange();
42+
range.selectNodeContents(aux);
43+
const sel = getSelection();
44+
sel.removeAllRanges();
45+
sel.addRange(range);
46+
aux.setSelectionRange(0, str.length);
47+
} else {
48+
aux.select();
49+
}
50+
const result = document.execCommand('copy');
51+
document.body.removeChild(aux);
52+
return result;
5553
}
56-
const result = document.execCommand('copy');
57-
document.body.removeChild(aux);
58-
return result;
5954
}
6055

6156
const LOCALIZE_NUMBERS = !!(
@@ -287,7 +282,6 @@ module.exports = {
287282
copyToClipboard,
288283
arrayToB64,
289284
b64ToArray,
290-
loadShim,
291285
isFile,
292286
openLinksInNewTab,
293287
browserName,

common/assets.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const isServer = typeof genmap === 'function';
33
let prefix = '';
44
let manifest = {};
55
try {
6-
//eslint-disable-next-line node/no-missing-require
6+
//eslint-disable-next-line n/no-missing-require
77
manifest = require('../dist/manifest.json');
88
} catch (e) {
99
// use middleware

0 commit comments

Comments
 (0)