Remove some polyfills
This should reduce the runtime size & load times somewhat by removing polyfills for older browsers which are not used much
This commit is contained in:
parent
625fdf5bca
commit
64644b57e3
|
@ -45,14 +45,8 @@ async function checkCrypto() {
|
||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
try {
|
|
||||||
window.asmCrypto = await import('asmcrypto.js');
|
|
||||||
await import('@dannycoates/webcrypto-liner/build/shim');
|
|
||||||
return true;
|
|
||||||
} catch (e) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkStreams() {
|
function checkStreams() {
|
||||||
|
@ -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() {
|
export default async function getCapabilities() {
|
||||||
const browser = browserName();
|
const browser = browserName();
|
||||||
const isMobile = /mobi|android/i.test(navigator.userAgent);
|
const isMobile = /mobi|android/i.test(navigator.userAgent);
|
||||||
const serviceWorker = 'serviceWorker' in navigator && browser !== 'edge';
|
const serviceWorker = 'serviceWorker' in navigator && browser !== 'edge';
|
||||||
let crypto = await checkCrypto();
|
let crypto = await checkCrypto();
|
||||||
const nativeStreams = checkStreams();
|
const nativeStreams = checkStreams();
|
||||||
let polyStreams = false;
|
|
||||||
if (!nativeStreams) {
|
|
||||||
polyStreams = await polyfillStreams();
|
|
||||||
}
|
|
||||||
let account = typeof AUTH_CONFIG !== 'undefined';
|
let account = typeof AUTH_CONFIG !== 'undefined';
|
||||||
try {
|
try {
|
||||||
account = account && !!localStorage;
|
account = account && !!localStorage;
|
||||||
|
@ -106,10 +87,10 @@ export default async function getCapabilities() {
|
||||||
account,
|
account,
|
||||||
crypto,
|
crypto,
|
||||||
serviceWorker,
|
serviceWorker,
|
||||||
streamUpload: nativeStreams || polyStreams,
|
streamUpload: nativeStreams,
|
||||||
streamDownload:
|
streamDownload:
|
||||||
nativeStreams && serviceWorker && browser !== 'safari' && !mobileFirefox,
|
nativeStreams && serviceWorker && browser !== 'safari' && !mobileFirefox,
|
||||||
multifile: nativeStreams || polyStreams,
|
multifile: nativeStreams,
|
||||||
share,
|
share,
|
||||||
standalone
|
standalone
|
||||||
};
|
};
|
||||||
|
|
|
@ -48,7 +48,7 @@ class ECETransformer {
|
||||||
name: 'AES-GCM',
|
name: 'AES-GCM',
|
||||||
length: 128
|
length: 128
|
||||||
},
|
},
|
||||||
true, // Edge polyfill requires key to be extractable to encrypt :/
|
false,
|
||||||
['encrypt', 'decrypt']
|
['encrypt', 'decrypt']
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
18
app/utils.js
18
app/utils.js
|
@ -23,21 +23,15 @@ function locale() {
|
||||||
return document.querySelector('html').lang;
|
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) {
|
function isFile(id) {
|
||||||
return /^[0-9a-fA-F]{10,16}$/.test(id);
|
return /^[0-9a-fA-F]{10,16}$/.test(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
function copyToClipboard(str) {
|
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');
|
const aux = document.createElement('input');
|
||||||
aux.setAttribute('value', str);
|
aux.setAttribute('value', str);
|
||||||
aux.contentEditable = true;
|
aux.contentEditable = true;
|
||||||
|
@ -56,6 +50,7 @@ function copyToClipboard(str) {
|
||||||
const result = document.execCommand('copy');
|
const result = document.execCommand('copy');
|
||||||
document.body.removeChild(aux);
|
document.body.removeChild(aux);
|
||||||
return result;
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const LOCALIZE_NUMBERS = !!(
|
const LOCALIZE_NUMBERS = !!(
|
||||||
|
@ -287,7 +282,6 @@ module.exports = {
|
||||||
copyToClipboard,
|
copyToClipboard,
|
||||||
arrayToB64,
|
arrayToB64,
|
||||||
b64ToArray,
|
b64ToArray,
|
||||||
loadShim,
|
|
||||||
isFile,
|
isFile,
|
||||||
openLinksInNewTab,
|
openLinksInNewTab,
|
||||||
browserName,
|
browserName,
|
||||||
|
|
|
@ -6,8 +6,6 @@
|
||||||
- https://github.com/whatwg/streams/tree/master/reference-implementation
|
- https://github.com/whatwg/streams/tree/master/reference-implementation
|
||||||
- Examples
|
- Examples
|
||||||
- https://github.com/mdn/dom-examples/tree/master/streams
|
- https://github.com/mdn/dom-examples/tree/master/streams
|
||||||
- Polyfill
|
|
||||||
- https://github.com/MattiasBuelens/web-streams-polyfill
|
|
||||||
|
|
||||||
# Encrypted Content Encoding
|
# Encrypted Content Encoding
|
||||||
|
|
||||||
|
|
|
@ -36,9 +36,7 @@
|
||||||
"@babel/plugin-proposal-class-properties": "^7.16.7",
|
"@babel/plugin-proposal-class-properties": "^7.16.7",
|
||||||
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
|
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
|
||||||
"@babel/preset-env": "^7.16.11",
|
"@babel/preset-env": "^7.16.11",
|
||||||
"@dannycoates/webcrypto-liner": "^0.1.37",
|
|
||||||
"@fullhuman/postcss-purgecss": "^4.1.3",
|
"@fullhuman/postcss-purgecss": "^4.1.3",
|
||||||
"@mattiasbuelens/web-streams-polyfill": "0.2.1",
|
|
||||||
"@sentry/browser": "^5.30.0",
|
"@sentry/browser": "^5.30.0",
|
||||||
"asmcrypto.js": "^0.22.0",
|
"asmcrypto.js": "^0.22.0",
|
||||||
"babel-loader": "^8.2.4",
|
"babel-loader": "^8.2.4",
|
||||||
|
@ -1908,21 +1906,6 @@
|
||||||
"postcss-selector-parser": "^6.0.10"
|
"postcss-selector-parser": "^6.0.10"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@dannycoates/elliptic": {
|
|
||||||
"version": "6.4.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/@dannycoates/elliptic/-/elliptic-6.4.2.tgz",
|
|
||||||
"integrity": "sha512-2G4qWMB2SRBk4H75d+BFBbz2b1cseIYCI8G7duGxtxdnjGxhewpripDsVr1lCagmijyYX4zDyfKTNoId5GGyow==",
|
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
|
||||||
"bn.js": "^4.4.0",
|
|
||||||
"brorand": "^1.0.1",
|
|
||||||
"hash.js": "^1.0.0",
|
|
||||||
"hmac-drbg": "^1.0.0",
|
|
||||||
"inherits": "^2.0.1",
|
|
||||||
"minimalistic-assert": "^1.0.0",
|
|
||||||
"minimalistic-crypto-utils": "^1.0.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@dannycoates/express-ws": {
|
"node_modules/@dannycoates/express-ws": {
|
||||||
"version": "5.0.3",
|
"version": "5.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/@dannycoates/express-ws/-/express-ws-5.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/@dannycoates/express-ws/-/express-ws-5.0.3.tgz",
|
||||||
|
@ -1938,17 +1921,6 @@
|
||||||
"express": "^4.0.0 || ^5.0.0-alpha.1"
|
"express": "^4.0.0 || ^5.0.0-alpha.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@dannycoates/webcrypto-liner": {
|
|
||||||
"version": "0.1.37",
|
|
||||||
"resolved": "https://registry.npmjs.org/@dannycoates/webcrypto-liner/-/webcrypto-liner-0.1.37.tgz",
|
|
||||||
"integrity": "sha512-EM29TDkn7GJaa/oOfLeS1vrAxEkyM+WfUsmHTz7OyrxvMZNqz2SiYdZkXBIvg+QCnKTfXc2x//ORAilesugQlg==",
|
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
|
||||||
"@dannycoates/elliptic": "^6.4.2",
|
|
||||||
"asmcrypto.js": "^0.22.0",
|
|
||||||
"webcrypto-core": "github:dannycoates/webcrypto-core"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@fluent/bundle": {
|
"node_modules/@fluent/bundle": {
|
||||||
"version": "0.17.1",
|
"version": "0.17.1",
|
||||||
"resolved": "https://registry.npmjs.org/@fluent/bundle/-/bundle-0.17.1.tgz",
|
"resolved": "https://registry.npmjs.org/@fluent/bundle/-/bundle-0.17.1.tgz",
|
||||||
|
@ -2076,19 +2048,6 @@
|
||||||
"@jridgewell/sourcemap-codec": "^1.4.10"
|
"@jridgewell/sourcemap-codec": "^1.4.10"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@mattiasbuelens/web-streams-polyfill": {
|
|
||||||
"version": "0.2.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/@mattiasbuelens/web-streams-polyfill/-/web-streams-polyfill-0.2.1.tgz",
|
|
||||||
"integrity": "sha512-oKuFCQFa3W7Hj7zKn0+4ypI8JFm4ZKIoncwAC6wd5WwFW2sL7O1hpPoJdSWpynQ4DJ4lQ6MvFoVDmCLilonDFg==",
|
|
||||||
"deprecated": "moved to web-streams-polyfill@2.0.0",
|
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
|
||||||
"@types/whatwg-streams": "^0.0.7"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 8"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@nodelib/fs.scandir": {
|
"node_modules/@nodelib/fs.scandir": {
|
||||||
"version": "2.1.5",
|
"version": "2.1.5",
|
||||||
"resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz",
|
"resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz",
|
||||||
|
@ -2521,12 +2480,6 @@
|
||||||
"@types/node": "*"
|
"@types/node": "*"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@types/whatwg-streams": {
|
|
||||||
"version": "0.0.7",
|
|
||||||
"resolved": "https://registry.npmjs.org/@types/whatwg-streams/-/whatwg-streams-0.0.7.tgz",
|
|
||||||
"integrity": "sha512-6sDiSEP6DWcY2ZolsJ2s39ZmsoGQ7KVwBDI3sESQsEm9P2dHTcqnDIHRZFRNtLCzWp7hCFGqYbw5GyfpQnJ01A==",
|
|
||||||
"dev": true
|
|
||||||
},
|
|
||||||
"node_modules/@webassemblyjs/ast": {
|
"node_modules/@webassemblyjs/ast": {
|
||||||
"version": "1.8.5",
|
"version": "1.8.5",
|
||||||
"resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.8.5.tgz",
|
"resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.8.5.tgz",
|
||||||
|
@ -21049,16 +21002,6 @@
|
||||||
"minimalistic-assert": "^1.0.0"
|
"minimalistic-assert": "^1.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/webcrypto-core": {
|
|
||||||
"version": "0.1.19",
|
|
||||||
"resolved": "git+ssh://git@github.com/dannycoates/webcrypto-core.git#8e0152a66d3ae6329cf080ccb3085eb06637070f",
|
|
||||||
"integrity": "sha512-FQXkmbl8syEGw0LtxcbO5aBmC6dmntkMMSzUxnC0U3Ue8vRrS9LKFsNOfs2XK1Nr5Sw1uGA0k4n7RZXa44vHeQ==",
|
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"tslib": "^1.7.1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/webidl-conversions": {
|
"node_modules/webidl-conversions": {
|
||||||
"version": "3.0.1",
|
"version": "3.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
|
||||||
|
@ -23619,21 +23562,6 @@
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {}
|
"requires": {}
|
||||||
},
|
},
|
||||||
"@dannycoates/elliptic": {
|
|
||||||
"version": "6.4.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/@dannycoates/elliptic/-/elliptic-6.4.2.tgz",
|
|
||||||
"integrity": "sha512-2G4qWMB2SRBk4H75d+BFBbz2b1cseIYCI8G7duGxtxdnjGxhewpripDsVr1lCagmijyYX4zDyfKTNoId5GGyow==",
|
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
|
||||||
"bn.js": "^4.4.0",
|
|
||||||
"brorand": "^1.0.1",
|
|
||||||
"hash.js": "^1.0.0",
|
|
||||||
"hmac-drbg": "^1.0.0",
|
|
||||||
"inherits": "^2.0.1",
|
|
||||||
"minimalistic-assert": "^1.0.0",
|
|
||||||
"minimalistic-crypto-utils": "^1.0.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"@dannycoates/express-ws": {
|
"@dannycoates/express-ws": {
|
||||||
"version": "5.0.3",
|
"version": "5.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/@dannycoates/express-ws/-/express-ws-5.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/@dannycoates/express-ws/-/express-ws-5.0.3.tgz",
|
||||||
|
@ -23643,17 +23571,6 @@
|
||||||
"ws": "^7.1.1"
|
"ws": "^7.1.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@dannycoates/webcrypto-liner": {
|
|
||||||
"version": "0.1.37",
|
|
||||||
"resolved": "https://registry.npmjs.org/@dannycoates/webcrypto-liner/-/webcrypto-liner-0.1.37.tgz",
|
|
||||||
"integrity": "sha512-EM29TDkn7GJaa/oOfLeS1vrAxEkyM+WfUsmHTz7OyrxvMZNqz2SiYdZkXBIvg+QCnKTfXc2x//ORAilesugQlg==",
|
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
|
||||||
"@dannycoates/elliptic": "^6.4.2",
|
|
||||||
"asmcrypto.js": "^0.22.0",
|
|
||||||
"webcrypto-core": "github:dannycoates/webcrypto-core"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"@fluent/bundle": {
|
"@fluent/bundle": {
|
||||||
"version": "0.17.1",
|
"version": "0.17.1",
|
||||||
"resolved": "https://registry.npmjs.org/@fluent/bundle/-/bundle-0.17.1.tgz",
|
"resolved": "https://registry.npmjs.org/@fluent/bundle/-/bundle-0.17.1.tgz",
|
||||||
|
@ -23754,15 +23671,6 @@
|
||||||
"@jridgewell/sourcemap-codec": "^1.4.10"
|
"@jridgewell/sourcemap-codec": "^1.4.10"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@mattiasbuelens/web-streams-polyfill": {
|
|
||||||
"version": "0.2.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/@mattiasbuelens/web-streams-polyfill/-/web-streams-polyfill-0.2.1.tgz",
|
|
||||||
"integrity": "sha512-oKuFCQFa3W7Hj7zKn0+4ypI8JFm4ZKIoncwAC6wd5WwFW2sL7O1hpPoJdSWpynQ4DJ4lQ6MvFoVDmCLilonDFg==",
|
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
|
||||||
"@types/whatwg-streams": "^0.0.7"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"@nodelib/fs.scandir": {
|
"@nodelib/fs.scandir": {
|
||||||
"version": "2.1.5",
|
"version": "2.1.5",
|
||||||
"resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz",
|
"resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz",
|
||||||
|
@ -24115,12 +24023,6 @@
|
||||||
"@types/node": "*"
|
"@types/node": "*"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@types/whatwg-streams": {
|
|
||||||
"version": "0.0.7",
|
|
||||||
"resolved": "https://registry.npmjs.org/@types/whatwg-streams/-/whatwg-streams-0.0.7.tgz",
|
|
||||||
"integrity": "sha512-6sDiSEP6DWcY2ZolsJ2s39ZmsoGQ7KVwBDI3sESQsEm9P2dHTcqnDIHRZFRNtLCzWp7hCFGqYbw5GyfpQnJ01A==",
|
|
||||||
"dev": true
|
|
||||||
},
|
|
||||||
"@webassemblyjs/ast": {
|
"@webassemblyjs/ast": {
|
||||||
"version": "1.8.5",
|
"version": "1.8.5",
|
||||||
"resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.8.5.tgz",
|
"resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.8.5.tgz",
|
||||||
|
@ -38880,15 +38782,6 @@
|
||||||
"minimalistic-assert": "^1.0.0"
|
"minimalistic-assert": "^1.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"webcrypto-core": {
|
|
||||||
"version": "git+ssh://git@github.com/dannycoates/webcrypto-core.git#8e0152a66d3ae6329cf080ccb3085eb06637070f",
|
|
||||||
"integrity": "sha512-FQXkmbl8syEGw0LtxcbO5aBmC6dmntkMMSzUxnC0U3Ue8vRrS9LKFsNOfs2XK1Nr5Sw1uGA0k4n7RZXa44vHeQ==",
|
|
||||||
"dev": true,
|
|
||||||
"from": "webcrypto-core@github:dannycoates/webcrypto-core",
|
|
||||||
"requires": {
|
|
||||||
"tslib": "^1.7.1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"webidl-conversions": {
|
"webidl-conversions": {
|
||||||
"version": "3.0.1",
|
"version": "3.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
|
||||||
|
|
|
@ -66,9 +66,7 @@
|
||||||
"@babel/plugin-proposal-class-properties": "^7.16.7",
|
"@babel/plugin-proposal-class-properties": "^7.16.7",
|
||||||
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
|
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
|
||||||
"@babel/preset-env": "^7.16.11",
|
"@babel/preset-env": "^7.16.11",
|
||||||
"@dannycoates/webcrypto-liner": "^0.1.37",
|
|
||||||
"@fullhuman/postcss-purgecss": "^4.1.3",
|
"@fullhuman/postcss-purgecss": "^4.1.3",
|
||||||
"@mattiasbuelens/web-streams-polyfill": "0.2.1",
|
|
||||||
"@sentry/browser": "^5.30.0",
|
"@sentry/browser": "^5.30.0",
|
||||||
"asmcrypto.js": "^0.22.0",
|
"asmcrypto.js": "^0.22.0",
|
||||||
"babel-loader": "^8.2.4",
|
"babel-loader": "^8.2.4",
|
||||||
|
|
Loading…
Reference in New Issue