fix: typo

This commit is contained in:
Hadar Rottenberg 2020-02-12 21:17:15 +02:00
parent 72c699f20b
commit 5016298b45
2 changed files with 10 additions and 6 deletions

2
sea.js
View File

@ -195,7 +195,7 @@
api.ossl = api.subtle = new WebCrypto({directory: 'ossl'}).subtle // ECDH api.ossl = api.subtle = new WebCrypto({directory: 'ossl'}).subtle // ECDH
} }
catch(e){ catch(e){
console.log("text-encoding and isomorphic-webcrypto may not be included by default, please add it to your package.json!"); console.log("text-encoding and peculiar/nwebcrypto may not be included by default, please add it to your package.json!");
TEXT_ENCODING_OR_PECULIAR_WEBCRYPTO_NOT_INSTALLED; TEXT_ENCODING_OR_PECULIAR_WEBCRYPTO_NOT_INSTALLED;
}} }}

View File

@ -17,16 +17,20 @@
api.TextDecoder = TextDecoder; api.TextDecoder = TextDecoder;
api.TextEncoder = TextEncoder; api.TextEncoder = TextEncoder;
} }
if(!api.crypto){try{ if(!api.crypto)
{
try
{
var crypto = require('crypto', 1); var crypto = require('crypto', 1);
Object.assign(api, { Object.assign(api, {
crypto, crypto,
random: (len) => Buffer.from(crypto.randomBytes(len)) random: (len) => Buffer.from(crypto.randomBytes(len))
}); });
const isocrypto = require('isomorphic-webcrypto'); const { Crypto: WebCrypto } = require('@peculiar/webcrypto', 1);
api.ossl = api.subtle = isocrypto.subtle; api.ossl = api.subtle = new WebCrypto({directory: 'ossl'}).subtle // ECDH
}catch(e){ }
console.log("text-encoding and isomorphic-webcrypto may not be included by default, please add it to your package.json!"); catch(e){
console.log("text-encoding and peculiar/nwebcrypto may not be included by default, please add it to your package.json!");
TEXT_ENCODING_OR_PECULIAR_WEBCRYPTO_NOT_INSTALLED; TEXT_ENCODING_OR_PECULIAR_WEBCRYPTO_NOT_INSTALLED;
}} }}