diff --git a/sea.js b/sea.js index fc83ff5c..2a5e907f 100644 --- a/sea.js +++ b/sea.js @@ -24,7 +24,7 @@ // THIS IS AN EARLY ALPHA! function SEA(){} - if(typeof window !== "undefined"){ SEA.window = window } + if(typeof window !== "undefined"){ (SEA.window = window).SEA = SEA } module.exports = SEA; })(USE, './root'); @@ -174,7 +174,7 @@ }); try{ const WebCrypto = require('node-webcrypto-ossl') - api.ossl = new WebCrypto({directory: 'key_storage'}).subtle // ECDH + api.ossl = new WebCrypto({directory: 'ossl'}).subtle // ECDH }catch(e){ console.log("node-webcrypto-ossl is optionally needed for ECDH, please install if needed."); } @@ -240,16 +240,14 @@ })(USE, './parse'); ;USE(function(module){ - const { - subtle, ossl = subtle, random: getRandomBytes, TextEncoder, TextDecoder - } = USE('./shim') + const shim = USE('./shim'); const Buffer = USE('./buffer') const parse = USE('./parse') const { pbkdf2 } = USE('./settings') // This internal func returns SHA-256 hashed data for signing const sha256hash = async (mm) => { const m = parse(mm) - const hash = await ossl.digest({name: pbkdf2.hash}, new TextEncoder().encode(m)) + const hash = await shim.subtle.digest({name: pbkdf2.hash}, new shim.TextEncoder().encode(m)) return Buffer.from(hash) } module.exports = sha256hash @@ -368,7 +366,8 @@ const r = { pub: sa.pub, priv: sa.priv, /* pubId, */ epub: dh.epub, epriv: dh.epriv } if(cb){ try{ cb(r) }catch(e){console.log(e)} } return r; - } catch(e) { + } catch(e) { + console.log(e); SEA.err = e; if(cb){ cb() } return; @@ -404,7 +403,8 @@ if(cb){ try{ cb(r) }catch(e){console.log(e)} } return r; - } catch(e) { + } catch(e) { + console.log(e); SEA.err = e; if(cb){ cb() } return; @@ -441,7 +441,8 @@ if(cb){ try{ cb(r) }catch(e){console.log(e)} } return r; - } catch(e) { + } catch(e) { + console.log(e); SEA.err = e; if(cb){ cb() } return; diff --git a/test/panic/who.js b/test/panic/who.js index a6f9e3e3..1deaa5d5 100644 --- a/test/panic/who.js +++ b/test/panic/who.js @@ -7,7 +7,6 @@ var config = { '/': __dirname + '/index.html', '/gun.js': __dirname + '/../../gun.js', '/jquery.js': __dirname + '/../../examples/jquery.js', - '/cryptomodules.js': __dirname + '/../../lib/cryptomodules.js', '/sea.js': __dirname + '/../../sea.js' } } @@ -57,6 +56,7 @@ describe("Make sure SEA syncs correctly", function(){ res.end("I am "+ env.i +"!"); }); var Gun = require('gun'); + require('gun/sea'); var gun = Gun({file: env.i+'data', web: server}); server.listen(port, function(){ test.done(); @@ -80,10 +80,8 @@ describe("Make sure SEA syncs correctly", function(){ script.onload = cb; script.src = src; document.head.appendChild(script); } - load('cryptomodules.js', function(){ - load('sea.js', function(){ - test.done(); - }); + load('sea.js', function(){ + test.done(); }); }, {i: i += 1, config: config})); }); @@ -140,8 +138,8 @@ describe("Make sure SEA syncs correctly", function(){ return bob.run(function(test){ test.async(); - window.gun.get('alias/alice').map().val(function(data){ - window.ref = gun.get('pub/'+data.pub); + window.gun.get('~@alice').map().once(function(data){ + window.ref = gun.get('~'+data.pub); test.done(); }); }); @@ -152,7 +150,7 @@ describe("Make sure SEA syncs correctly", function(){ test.async(); window.count = []; - ref.get('who').get('said').map().val(function(data){ + ref.get('who').get('said').map().once(function(data){ console.log("read...", data); window.count.push(data); if(window.count.length - 1){ return } @@ -181,10 +179,8 @@ describe("Make sure SEA syncs correctly", function(){ script.onload = cb; script.src = src; document.head.appendChild(script); } - load('cryptomodules.js', function(){ - load('sea.js', function(){ - test.done(); - }); + load('sea.js', function(){ + test.done(); }); }, {i: 1, config: config}); });