diff --git a/sea.js b/sea.js index 0a931a6a..f0a9725f 100644 --- a/sea.js +++ b/sea.js @@ -17,6 +17,13 @@ } if(typeof module !== "undefined"){ var common = module } /* UNBUILD */ + function atob(a) { + return new Buffer(a, 'base64').toString('binary'); + }; + + function btoa(b) { + return new Buffer(b).toString('base64'); + }; ;USE(function(module){ // Security, Encryption, and Authorization: SEA.js @@ -174,7 +181,7 @@ random: (len) => Buffer.from(crypto.randomBytes(len)) }); //try{ - const WebCrypto = USE('node-webcrypto-ossl', 1); + const { Crypto: WebCrypto } = USE('@peculiar/webcrypto', 1); api.ossl = api.subtle = new WebCrypto({directory: 'ossl'}).subtle // ECDH //}catch(e){ //console.log("node-webcrypto-ossl is optionally needed for ECDH, please install if needed."); diff --git a/sea/array.js b/sea/array.js index fecdde5d..d10c983c 100644 --- a/sea/array.js +++ b/sea/array.js @@ -1,4 +1,6 @@ - + function btoa(b) { + return new Buffer(b).toString('base64'); + }; // This is Array extended to have .toString(['utf8'|'hex'|'base64']) function SeaArray() {} Object.assign(SeaArray, { from: Array.from }) diff --git a/sea/buffer.js b/sea/buffer.js index 1854bd1c..37f753b4 100644 --- a/sea/buffer.js +++ b/sea/buffer.js @@ -1,4 +1,6 @@ - + function atob(a) { + return new Buffer(a, 'base64').toString('binary'); + }; // This is Buffer implementation used in SEA. Functionality is mostly // compatible with NodeJS 'safe-buffer' and is used for encoding conversions // between binary and 'hex' | 'utf8' | 'base64' diff --git a/sea/shim.js b/sea/shim.js index b6026e8c..21d94355 100644 --- a/sea/shim.js +++ b/sea/shim.js @@ -22,7 +22,7 @@ random: (len) => Buffer.from(crypto.randomBytes(len)) }); //try{ - const WebCrypto = require('node-webcrypto-ossl', 1); + const { Crypto: WebCrypto } = USE('@peculiar/webcrypto', 1); api.ossl = api.subtle = new WebCrypto({directory: 'ossl'}).subtle // ECDH //}catch(e){ //console.log("node-webcrypto-ossl is optionally needed for ECDH, please install if needed.");