Revert "Remove some polyfills"
This commit is contained in:
parent
643287e235
commit
71587a604e
|
@ -5,24 +5,21 @@ env:
|
|||
extends:
|
||||
- eslint:recommended
|
||||
- prettier
|
||||
- plugin:n/recommended
|
||||
- plugin:node/recommended
|
||||
- plugin:security/recommended
|
||||
|
||||
plugins:
|
||||
- n
|
||||
- node
|
||||
- security
|
||||
|
||||
root: true
|
||||
|
||||
rules:
|
||||
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
|
||||
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
|
||||
|
||||
security/detect-non-literal-fs-filename: off
|
||||
security/detect-object-injection: off
|
||||
|
|
|
@ -63,6 +63,7 @@ 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
|
||||
|
|
|
@ -6,4 +6,4 @@ parserOptions:
|
|||
sourceType: module
|
||||
|
||||
rules:
|
||||
n/no-unsupported-features: off
|
||||
node/no-unsupported-features: off
|
||||
|
|
|
@ -45,9 +45,15 @@ 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function checkStreams() {
|
||||
try {
|
||||
|
@ -60,12 +66,25 @@ 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;
|
||||
|
@ -87,10 +106,10 @@ export default async function getCapabilities() {
|
|||
account,
|
||||
crypto,
|
||||
serviceWorker,
|
||||
streamUpload: nativeStreams,
|
||||
streamUpload: nativeStreams || polyStreams,
|
||||
streamDownload:
|
||||
nativeStreams && serviceWorker && browser !== 'safari' && !mobileFirefox,
|
||||
multifile: nativeStreams,
|
||||
multifile: nativeStreams || polyStreams,
|
||||
share,
|
||||
standalone
|
||||
};
|
||||
|
|
|
@ -48,7 +48,7 @@ class ECETransformer {
|
|||
name: 'AES-GCM',
|
||||
length: 128
|
||||
},
|
||||
false,
|
||||
true, // Edge polyfill requires key to be extractable to encrypt :/
|
||||
['encrypt', 'decrypt']
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/* 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';
|
||||
|
|
|
@ -110,7 +110,7 @@ class Storage {
|
|||
}
|
||||
|
||||
set user(info) {
|
||||
this.engine.setItem('user', JSON.stringify(info));
|
||||
return this.engine.setItem('user', JSON.stringify(info));
|
||||
}
|
||||
|
||||
getFileById(id) {
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
/* global TransformStream */
|
||||
|
||||
export function transformStream(readable, transformer, oncancel) {
|
||||
try {
|
||||
return readable.pipeThrough(new TransformStream(transformer));
|
||||
|
|
18
app/utils.js
18
app/utils.js
|
@ -23,15 +23,21 @@ 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);
|
||||
}
|
||||
|
||||
async function copyToClipboard(str) {
|
||||
try {
|
||||
await navigator.clipboard.writeText(str);
|
||||
} catch {
|
||||
// Older browsers or the clipboard API fails because of a missing permission
|
||||
function copyToClipboard(str) {
|
||||
const aux = document.createElement('input');
|
||||
aux.setAttribute('value', str);
|
||||
aux.contentEditable = true;
|
||||
|
@ -51,7 +57,6 @@ async function copyToClipboard(str) {
|
|||
document.body.removeChild(aux);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
const LOCALIZE_NUMBERS = !!(
|
||||
typeof Intl === 'object' &&
|
||||
|
@ -282,6 +287,7 @@ module.exports = {
|
|||
copyToClipboard,
|
||||
arrayToB64,
|
||||
b64ToArray,
|
||||
loadShim,
|
||||
isFile,
|
||||
openLinksInNewTab,
|
||||
browserName,
|
||||
|
|
|
@ -3,7 +3,7 @@ const isServer = typeof genmap === 'function';
|
|||
let prefix = '';
|
||||
let manifest = {};
|
||||
try {
|
||||
//eslint-disable-next-line n/no-missing-require
|
||||
//eslint-disable-next-line node/no-missing-require
|
||||
manifest = require('../dist/manifest.json');
|
||||
} catch (e) {
|
||||
// use middleware
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
- 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
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* global window, document */
|
||||
/* global window, document, fetch */
|
||||
|
||||
const MAXFILESIZE = 1024 * 1024 * 1024 * 2;
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
23
package.json
23
package.json
|
@ -66,10 +66,13 @@
|
|||
"@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": "^6.1.1",
|
||||
"babel-plugin-istanbul": "^5.2.0",
|
||||
"base64-js": "^1.5.1",
|
||||
"content-disposition": "^0.5.4",
|
||||
"copy-webpack-plugin": "^6.4.0",
|
||||
|
@ -77,15 +80,20 @@
|
|||
"crc": "^3.8.0",
|
||||
"cross-env": "^6.0.3",
|
||||
"css-loader": "^5.2.7",
|
||||
"css-mqpacker": "^7.0.0",
|
||||
"cssnano": "^5.1.12",
|
||||
"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",
|
||||
"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",
|
||||
"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",
|
||||
|
@ -105,6 +113,7 @@
|
|||
"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",
|
||||
|
@ -131,8 +140,10 @@
|
|||
"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",
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
rules:
|
||||
n/shebang: off
|
||||
node/shebang: off
|
||||
security/detect-child-process: off
|
||||
|
||||
no-console: off
|
||||
|
|
|
@ -5,7 +5,7 @@ const clientConstants = require('./clientConstants');
|
|||
|
||||
let sentry = '';
|
||||
if (config.sentry_id) {
|
||||
//eslint-disable-next-line n/no-missing-require
|
||||
//eslint-disable-next-line node/no-missing-require
|
||||
const version = require('../dist/version.json');
|
||||
sentry = `
|
||||
var SENTRY_CONFIG = {
|
||||
|
|
|
@ -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 n/no-missing-require
|
||||
// eslint-disable-next-line node/no-missing-require
|
||||
res.sendFile(require.resolve('../../dist/version.json'));
|
||||
});
|
||||
|
||||
|
|
|
@ -6,10 +6,10 @@ extends:
|
|||
|
||||
plugins:
|
||||
- mocha
|
||||
- n
|
||||
- node
|
||||
|
||||
rules:
|
||||
n/no-unpublished-require: off
|
||||
node/no-unpublished-require: off
|
||||
|
||||
mocha/handle-done-callback: error
|
||||
mocha/no-exclusive-tests: error
|
||||
|
|
|
@ -5,4 +5,4 @@ parserOptions:
|
|||
sourceType: module
|
||||
|
||||
rules:
|
||||
n/no-unsupported-features: off
|
||||
node/no-unsupported-features: off
|
|
@ -9,7 +9,7 @@ module.exports = function() {
|
|||
const files = fs
|
||||
.readdirSync(path.join(__dirname, 'tests'))
|
||||
.filter(p => /\.js$/.test(p));
|
||||
const code = files.map(kv).join(';\n');
|
||||
const code = "require('fast-text-encoding');\n" + files.map(kv).join(';\n');
|
||||
return {
|
||||
code,
|
||||
dependencies: files.map(f => require.resolve('./tests/' + f)),
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// eslint-disable-next-line n/no-extraneous-require
|
||||
// eslint-disable-next-line node/no-extraneous-require
|
||||
const ip = require('ip');
|
||||
const common = require('./wdio.common.conf');
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// eslint-disable-next-line n/no-extraneous-require
|
||||
// eslint-disable-next-line node/no-extraneous-require
|
||||
const ip = require('ip');
|
||||
const common = require('./wdio.common.conf');
|
||||
const dir =
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// eslint-disable-next-line n/no-extraneous-require
|
||||
// eslint-disable-next-line node/no-extraneous-require
|
||||
const ip = require('ip');
|
||||
const common = require('./wdio.common.conf');
|
||||
|
||||
|
|
|
@ -111,6 +111,10 @@ 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')
|
||||
],
|
||||
|
@ -123,7 +127,8 @@ 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/tslib'),
|
||||
path.resolve(__dirname, 'node_modules/webcrypto-core')
|
||||
],
|
||||
loader: 'webpack-unassert-loader'
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue