load cryptofill.js async

This commit is contained in:
Danny Coates 2018-11-26 10:36:49 -08:00
parent 5845fa5c05
commit 87ac8b241b
No known key found for this signature in database
GPG Key ID: 4C442633C62E00CB
9 changed files with 14627 additions and 48 deletions

View File

@ -4,3 +4,4 @@ firefox
coverage coverage
app/locale.js app/locale.js
app/capabilities.js app/capabilities.js
app/cryptofill.js

View File

@ -1,5 +1,5 @@
dist dist
android/app/src/main/assets android/app/src/main/assets
android/app/build android/app/build
assets/*.js app/cryptofill.js
coverage coverage

View File

@ -35,11 +35,24 @@ async function checkCrypto() {
false, false,
['deriveKey'] ['deriveKey']
); );
await crypto.subtle.generateKey(
{
name: 'ECDH',
namedCurve: 'P-256'
},
true,
['deriveBits']
);
return true; return true;
} catch (err) { } catch (err) {
try {
await import('./cryptofill');
return true;
} catch (e) {
return false; return false;
} }
} }
}
function checkStreams() { function checkStreams() {
try { try {
@ -62,7 +75,7 @@ async function polyfillStreams() {
} }
export default async function capabilities() { export default async function capabilities() {
const crypto = await checkCrypto(); let crypto = await checkCrypto();
const nativeStreams = checkStreams(); const nativeStreams = checkStreams();
let polyStreams = false; let polyStreams = false;
if (!nativeStreams) { if (!nativeStreams) {
@ -72,7 +85,7 @@ export default async function capabilities() {
try { try {
account = account && !!localStorage; account = account && !!localStorage;
} catch (e) { } catch (e) {
// nevermind account = false;
} }
return { return {

14596
app/cryptofill.js Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

9
package-lock.json generated
View File

@ -17062,6 +17062,15 @@
} }
} }
}, },
"script-loader": {
"version": "0.7.2",
"resolved": "https://registry.npmjs.org/script-loader/-/script-loader-0.7.2.tgz",
"integrity": "sha512-UMNLEvgOAQuzK8ji8qIscM3GIrRCWN6MmMXGD4SD5l6cSycgGsCo0tX5xRnfQcoghqct0tjHjcykgI1PyBE2aA==",
"dev": true,
"requires": {
"raw-loader": "~0.5.1"
}
},
"scroll-to-anchor": { "scroll-to-anchor": {
"version": "1.1.0", "version": "1.1.0",
"resolved": "https://registry.npmjs.org/scroll-to-anchor/-/scroll-to-anchor-1.1.0.tgz", "resolved": "https://registry.npmjs.org/scroll-to-anchor/-/scroll-to-anchor-1.1.0.tgz",

View File

@ -109,6 +109,7 @@
"raw-loader": "^0.5.1", "raw-loader": "^0.5.1",
"redis-mock": "^0.39.0", "redis-mock": "^0.39.0",
"rimraf": "^2.6.2", "rimraf": "^2.6.2",
"script-loader": "^0.7.2",
"sinon": "^7.1.1", "sinon": "^7.1.1",
"string-hash": "^1.1.3", "string-hash": "^1.1.3",
"stylelint": "^9.8.0", "stylelint": "^9.8.0",

View File

@ -36,7 +36,6 @@ module.exports = function(app) {
locale: 'en-US' locale: 'en-US'
}) })
} }
<script src="${assets.get('cryptofill.js')}"></script>
<script src="${assets.get('tests.js')}"></script> <script src="${assets.get('tests.js')}"></script>
</head> </head>
<body> <body>

View File

@ -36,17 +36,6 @@ const serviceWorker = {
devtool: 'source-map', devtool: 'source-map',
module: { module: {
rules: [ rules: [
{
include: [require.resolve('./assets/cryptofill')],
use: [
{
loader: 'file-loader',
options: {
name: '[name].[hash:8].[ext]'
}
}
]
},
{ {
test: /\.(png|jpg)$/, test: /\.(png|jpg)$/,
loader: 'file-loader', loader: 'file-loader',
@ -102,15 +91,8 @@ const web = {
test: /\.js$/, test: /\.js$/,
oneOf: [ oneOf: [
{ {
include: [require.resolve('./assets/cryptofill')], include: [require.resolve('./app/cryptofill')],
use: [ use: ['script-loader']
{
loader: 'file-loader',
options: {
name: '[name].[hash:8].[ext]'
}
}
]
}, },
{ {
loader: 'babel-loader', loader: 'babel-loader',
@ -120,6 +102,7 @@ const web = {
// some dependencies need to get re-babeled because we // some dependencies need to get re-babeled because we
// have different targets than their default configs // have different targets than their default configs
path.resolve(__dirname, 'node_modules/testpilot-ga/src'), path.resolve(__dirname, 'node_modules/testpilot-ga/src'),
path.resolve(__dirname, 'node_modules/fluent'),
path.resolve(__dirname, 'node_modules/fluent-intl-polyfill'), path.resolve(__dirname, 'node_modules/fluent-intl-polyfill'),
path.resolve(__dirname, 'node_modules/intl-pluralrules') path.resolve(__dirname, 'node_modules/intl-pluralrules')
], ],