24
1
Fork 0

Merge branch 'AaronDewes-chore/cleanup-dependencies' into master

See https://github.com/timvisee/send/pull/101
This commit is contained in:
timvisee 2022-08-10 19:04:33 +02:00
commit 643287e235
No known key found for this signature in database
GPG Key ID: B8DB720BC383E172
24 changed files with 1430 additions and 3785 deletions

View File

@ -5,21 +5,24 @@ env:
extends:
- eslint:recommended
- prettier
- plugin:node/recommended
- plugin:n/recommended
- plugin:security/recommended
plugins:
- node
- n
- security
root: true
rules:
node/no-deprecated-api: off
node/no-unsupported-features/es-syntax: off
node/no-unsupported-features/node-builtins: off
node/no-unpublished-require: off
node/no-unpublished-import: off
n/no-deprecated-api: off
n/no-unsupported-features/es-syntax: off
n/no-unsupported-features/node-builtins: off
n/no-unpublished-require: off
n/no-unpublished-import: off
n/no-process-exit: off
# This forces using file extensions in imports, which is a best practice, but refactoring would take some time
n/no-missing-import: off
security/detect-non-literal-fs-filename: off
security/detect-object-injection: off

View File

@ -63,7 +63,6 @@ COPY --chown=app:app server server
COPY --chown=app:app --from=builder /app/dist dist
RUN npm ci --production && npm cache clean --force
RUN mkdir -p /app/.config/configstore
RUN ln -s dist/version.json version.json
ENV PORT=1443

View File

@ -6,4 +6,4 @@ parserOptions:
sourceType: module
rules:
node/no-unsupported-features: off
n/no-unsupported-features: off

View File

@ -45,13 +45,7 @@ async function checkCrypto() {
);
return true;
} catch (err) {
try {
window.asmCrypto = await import('asmcrypto.js');
await import('@dannycoates/webcrypto-liner/build/shim');
return true;
} catch (e) {
return false;
}
return false;
}
}
@ -66,25 +60,12 @@ function checkStreams() {
}
}
async function polyfillStreams() {
try {
await import('@mattiasbuelens/web-streams-polyfill');
return true;
} catch (e) {
return false;
}
}
export default async function getCapabilities() {
const browser = browserName();
const isMobile = /mobi|android/i.test(navigator.userAgent);
const serviceWorker = 'serviceWorker' in navigator && browser !== 'edge';
let crypto = await checkCrypto();
const nativeStreams = checkStreams();
let polyStreams = false;
if (!nativeStreams) {
polyStreams = await polyfillStreams();
}
let account = typeof AUTH_CONFIG !== 'undefined';
try {
account = account && !!localStorage;
@ -106,10 +87,10 @@ export default async function getCapabilities() {
account,
crypto,
serviceWorker,
streamUpload: nativeStreams || polyStreams,
streamUpload: nativeStreams,
streamDownload:
nativeStreams && serviceWorker && browser !== 'safari' && !mobileFirefox,
multifile: nativeStreams || polyStreams,
multifile: nativeStreams,
share,
standalone
};

View File

@ -48,7 +48,7 @@ class ECETransformer {
name: 'AES-GCM',
length: 128
},
true, // Edge polyfill requires key to be extractable to encrypt :/
false,
['encrypt', 'decrypt']
);
}

View File

@ -1,6 +1,5 @@
/* global DEFAULTS LIMITS WEB_UI PREFS */
import 'core-js';
import 'fast-text-encoding'; // MS Edge support
import 'intl-pluralrules';
import choo from 'choo';
import nanotiming from 'nanotiming';

View File

@ -110,7 +110,7 @@ class Storage {
}
set user(info) {
return this.engine.setItem('user', JSON.stringify(info));
this.engine.setItem('user', JSON.stringify(info));
}
getFileById(id) {

View File

@ -1,5 +1,3 @@
/* global TransformStream */
export function transformStream(readable, transformer, oncancel) {
try {
return readable.pipeThrough(new TransformStream(transformer));

View File

@ -23,39 +23,34 @@ function locale() {
return document.querySelector('html').lang;
}
function loadShim(polyfill) {
return new Promise((resolve, reject) => {
const shim = document.createElement('script');
shim.src = polyfill;
shim.addEventListener('load', () => resolve(true));
shim.addEventListener('error', () => resolve(false));
document.head.appendChild(shim);
});
}
function isFile(id) {
return /^[0-9a-fA-F]{10,16}$/.test(id);
}
function copyToClipboard(str) {
const aux = document.createElement('input');
aux.setAttribute('value', str);
aux.contentEditable = true;
aux.readOnly = true;
document.body.appendChild(aux);
if (navigator.userAgent.match(/iphone|ipad|ipod/i)) {
const range = document.createRange();
range.selectNodeContents(aux);
const sel = getSelection();
sel.removeAllRanges();
sel.addRange(range);
aux.setSelectionRange(0, str.length);
} else {
aux.select();
async function copyToClipboard(str) {
try {
await navigator.clipboard.writeText(str);
} catch {
// Older browsers or the clipboard API fails because of a missing permission
const aux = document.createElement('input');
aux.setAttribute('value', str);
aux.contentEditable = true;
aux.readOnly = true;
document.body.appendChild(aux);
if (navigator.userAgent.match(/iphone|ipad|ipod/i)) {
const range = document.createRange();
range.selectNodeContents(aux);
const sel = getSelection();
sel.removeAllRanges();
sel.addRange(range);
aux.setSelectionRange(0, str.length);
} else {
aux.select();
}
const result = document.execCommand('copy');
document.body.removeChild(aux);
return result;
}
const result = document.execCommand('copy');
document.body.removeChild(aux);
return result;
}
const LOCALIZE_NUMBERS = !!(
@ -287,7 +282,6 @@ module.exports = {
copyToClipboard,
arrayToB64,
b64ToArray,
loadShim,
isFile,
openLinksInNewTab,
browserName,

View File

@ -3,7 +3,7 @@ const isServer = typeof genmap === 'function';
let prefix = '';
let manifest = {};
try {
//eslint-disable-next-line node/no-missing-require
//eslint-disable-next-line n/no-missing-require
manifest = require('../dist/manifest.json');
} catch (e) {
// use middleware

View File

@ -6,8 +6,6 @@
- https://github.com/whatwg/streams/tree/master/reference-implementation
- Examples
- https://github.com/mdn/dom-examples/tree/master/streams
- Polyfill
- https://github.com/MattiasBuelens/web-streams-polyfill
# Encrypted Content Encoding

View File

@ -1,4 +1,4 @@
/* global window, document, fetch */
/* global window, document */
const MAXFILESIZE = 1024 * 1024 * 1024 * 2;

5055
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -66,13 +66,10 @@
"@babel/plugin-proposal-class-properties": "^7.16.7",
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
"@babel/preset-env": "^7.16.11",
"@dannycoates/webcrypto-liner": "^0.1.37",
"@fullhuman/postcss-purgecss": "^4.1.3",
"@mattiasbuelens/web-streams-polyfill": "0.2.1",
"@sentry/browser": "^5.30.0",
"asmcrypto.js": "^0.22.0",
"babel-loader": "^8.2.4",
"babel-plugin-istanbul": "^5.2.0",
"babel-plugin-istanbul": "^6.1.1",
"base64-js": "^1.5.1",
"content-disposition": "^0.5.4",
"copy-webpack-plugin": "^6.4.0",
@ -80,20 +77,15 @@
"crc": "^3.8.0",
"cross-env": "^6.0.3",
"css-loader": "^5.2.7",
"css-mqpacker": "^7.0.0",
"cssnano": "^5.1.12",
"eslint": "^6.6.0",
"eslint-config-prettier": "^6.15.0",
"eslint-plugin-mocha": "^6.2.1",
"eslint-plugin-node": "^10.0.0",
"eslint-plugin-security": "^1.4.0",
"expose-loader": "^0.7.5",
"extract-loader": "^3.2.0",
"eslint": "^8.21.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-mocha": "^10.1.0",
"eslint-plugin-n": "^15.2.4",
"eslint-plugin-security": "^1.5.0",
"extract-text-webpack-plugin": "^4.0.0-beta.0",
"fast-text-encoding": "^1.0.3",
"file-loader": "^6.2.0",
"git-rev-sync": "^3.0.2",
"html-loader": "^0.5.5",
"http_ece": "^1.1.0",
"husky": "^3.0.9",
"intl-pluralrules": "^1.3.1",
@ -113,7 +105,6 @@
"puppeteer": "^2.0.0",
"raw-loader": "^3.1.0",
"rimraf": "^3.0.0",
"script-loader": "^0.7.2",
"sinon": "^7.5.0",
"string-hash": "^1.1.3",
"stylelint": "^14.9.1",
@ -140,10 +131,8 @@
"body-parser": "^1.20.0",
"choo": "^7.0.0",
"cldr-core": "^35.1.0",
"configstore": "github:dannycoates/configstore#master",
"convict": "^6.2.3",
"convict-format-with-validator": "^6.2.0",
"double-ended-queue": "^2.1.0-0",
"express": "^4.17.3",
"helmet": "^3.23.3",
"mozlog": "^3.0.1",

View File

@ -1,5 +1,5 @@
rules:
node/shebang: off
n/shebang: off
security/detect-child-process: off
no-console: off

View File

@ -5,7 +5,7 @@ const clientConstants = require('./clientConstants');
let sentry = '';
if (config.sentry_id) {
//eslint-disable-next-line node/no-missing-require
//eslint-disable-next-line n/no-missing-require
const version = require('../dist/version.json');
sentry = `
var SENTRY_CONFIG = {

View File

@ -120,7 +120,7 @@ module.exports = function(app) {
);
app.post(`/api/info/:id${ID_REGEX}`, auth.owner, require('./info'));
app.get('/__version__', function(req, res) {
// eslint-disable-next-line node/no-missing-require
// eslint-disable-next-line n/no-missing-require
res.sendFile(require.resolve('../../dist/version.json'));
});

View File

@ -6,10 +6,10 @@ extends:
plugins:
- mocha
- node
- n
rules:
node/no-unpublished-require: off
n/no-unpublished-require: off
mocha/handle-done-callback: error
mocha/no-exclusive-tests: error

View File

@ -5,4 +5,4 @@ parserOptions:
sourceType: module
rules:
node/no-unsupported-features: off
n/no-unsupported-features: off

View File

@ -9,7 +9,7 @@ module.exports = function() {
const files = fs
.readdirSync(path.join(__dirname, 'tests'))
.filter(p => /\.js$/.test(p));
const code = "require('fast-text-encoding');\n" + files.map(kv).join(';\n');
const code = files.map(kv).join(';\n');
return {
code,
dependencies: files.map(f => require.resolve('./tests/' + f)),

View File

@ -1,4 +1,4 @@
// eslint-disable-next-line node/no-extraneous-require
// eslint-disable-next-line n/no-extraneous-require
const ip = require('ip');
const common = require('./wdio.common.conf');

View File

@ -1,4 +1,4 @@
// eslint-disable-next-line node/no-extraneous-require
// eslint-disable-next-line n/no-extraneous-require
const ip = require('ip');
const common = require('./wdio.common.conf');
const dir =

View File

@ -1,4 +1,4 @@
// eslint-disable-next-line node/no-extraneous-require
// eslint-disable-next-line n/no-extraneous-require
const ip = require('ip');
const common = require('./wdio.common.conf');

View File

@ -111,10 +111,6 @@ const web = {
path.resolve(__dirname, 'common'),
// some dependencies need to get re-babeled because we
// have different targets than their default configs
path.resolve(
__dirname,
'node_modules/@dannycoates/webcrypto-liner'
),
path.resolve(__dirname, 'node_modules/@fluent'),
path.resolve(__dirname, 'node_modules/intl-pluralrules')
],
@ -127,8 +123,7 @@ const web = {
path.resolve(__dirname, 'node_modules/crc'),
path.resolve(__dirname, 'node_modules/@fluent'),
path.resolve(__dirname, 'node_modules/@sentry'),
path.resolve(__dirname, 'node_modules/tslib'),
path.resolve(__dirname, 'node_modules/webcrypto-core')
path.resolve(__dirname, 'node_modules/tslib')
],
loader: 'webpack-unassert-loader'
}