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

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