Skip to content

Commit 9ea68aa

Browse files
committed
Update GUN to fix $ replace issue
1 parent b8af340 commit 9ea68aa

File tree

3 files changed

+31
-30
lines changed

3 files changed

+31
-30
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "notabug",
3-
"version": "0.8.22",
3+
"version": "0.8.23",
44
"dependencies": {
55
"@trust/webcrypto": "^0.9.2",
66
"babel-cli": "^6.26.0",
@@ -23,7 +23,7 @@
2323
"forever": "^0.15.3",
2424
"formidable": "^1.2.1",
2525
"freactal": "^2.0.3",
26-
"gun": "^0.9.9997",
26+
"gun": "^0.9.99991",
2727
"gun-file": "^1.0.123",
2828
"gun-flint": "^0.0.28",
2929
"ignore-styles": "^5.0.1",

src/sea.js

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
4040

4141
function SEA() {}
4242
if (typeof window !== "undefined") {
43-
SEA.window = window;
43+
(SEA.window = window).SEA = SEA;
4444
}
4545

4646
module.exports = SEA;
@@ -50,7 +50,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
5050
var SEA = USE('./root');
5151
if (SEA.window) {
5252
if (location.protocol.indexOf('s') < 0 && location.host.indexOf('localhost') < 0 && location.protocol.indexOf('file:') < 0) {
53-
// location.protocol = 'https:'; // WebCrypto does NOT work without HTTPS!
53+
location.protocol = 'https:'; // WebCrypto does NOT work without HTTPS!
5454
}
5555
}
5656
})(USE, './https');
@@ -203,7 +203,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
203203
_subtle = _require.subtle; // All but ECDH
204204

205205

206-
var _eequire2 = require('text-encoding'),
206+
var _require2 = require('text-encoding'),
207207
_TextEncoder = _require2.TextEncoder,
208208
_TextDecoder = _require2.TextDecoder;
209209

@@ -218,7 +218,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
218218
});
219219
try {
220220
var WebCrypto = require('node-webcrypto-ossl');
221-
api.ossl = new WebCrypto({ directory: 'key_storage' }).subtle; // ECDH
221+
api.ossl = new WebCrypto({ directory: 'ossl' }).subtle; // ECDH
222222
} catch (e) {
223223
console.log("node-webcrypto-ossl is optionally needed for ECDH, please install if needed.");
224224
}
@@ -295,19 +295,12 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
295295
;USE(function (module) {
296296
var _this2 = this;
297297

298-
var _USE = USE('./shim'),
299-
subtle = _USE.subtle,
300-
_USE$ossl = _USE.ossl,
301-
ossl = _USE$ossl === undefined ? subtle : _USE$ossl,
302-
getRandomBytes = _USE.random,
303-
TextEncoder = _USE.TextEncoder,
304-
TextDecoder = _USE.TextDecoder;
305-
298+
var shim = USE('./shim');
306299
var Buffer = USE('./buffer');
307300
var parse = USE('./parse');
308301

309-
var _USE2 = USE('./settings'),
310-
pbkdf2 = _USE2.pbkdf2;
302+
var _USE = USE('./settings'),
303+
pbkdf2 = _USE.pbkdf2;
311304
// This internal func returns SHA-256 hashed data for signing
312305

313306

@@ -320,7 +313,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
320313
case 0:
321314
m = parse(mm);
322315
_context.next = 3;
323-
return ossl.digest({ name: pbkdf2.hash }, new TextEncoder().encode(m));
316+
return shim.subtle.digest({ name: pbkdf2.hash }, new shim.TextEncoder().encode(m));
324317

325318
case 3:
326319
hash = _context.sent;
@@ -606,13 +599,14 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
606599
_context5.prev = 26;
607600
_context5.t1 = _context5["catch"](0);
608601

602+
console.log(_context5.t1);
609603
SEA.err = _context5.t1;
610604
if (cb) {
611605
cb();
612606
}
613607
return _context5.abrupt("return");
614608

615-
case 31:
609+
case 32:
616610
case "end":
617611
return _context5.stop();
618612
}
@@ -696,13 +690,14 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
696690
_context6.prev = 19;
697691
_context6.t0 = _context6["catch"](0);
698692

693+
console.log(_context6.t0);
699694
SEA.err = _context6.t0;
700695
if (cb) {
701696
cb();
702697
}
703698
return _context6.abrupt("return");
704699

705-
case 24:
700+
case 25:
706701
case "end":
707702
return _context6.stop();
708703
}
@@ -799,13 +794,14 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
799794
_context7.prev = 25;
800795
_context7.t0 = _context7["catch"](0);
801796

797+
console.log(_context7.t0);
802798
SEA.err = _context7.t0;
803799
if (cb) {
804800
cb();
805801
}
806802
return _context7.abrupt("return");
807803

808-
case 30:
804+
case 31:
809805
case "end":
810806
return _context7.stop();
811807
}
@@ -1221,7 +1217,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
12211217
// But all other behavior needs to be equally easy, like opinionated ways of
12221218
// Adding friends (trusted public keys), sending private messages, etc.
12231219
// Cheers! Tell me what you think.
1224-
var Gun = (SEA.window || {}).Gun;
1220+
var Gun = (SEA.window || {}).Gun; // || require("./gun");
12251221
Gun.SEA = SEA;
12261222
SEA.Gun = Gun;
12271223

@@ -2214,9 +2210,8 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
22142210
var Gun = SEA.Gun;
22152211
var then = USE('./then');
22162212

2217-
function User() {
2213+
function User(root) {
22182214
this._ = { $: this };
2219-
Gun.call();
22202215
}
22212216
User.prototype = function () {
22222217
function F() {};F.prototype = Gun.chain;return new F();
@@ -2606,7 +2601,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
26062601
return user._.sea;
26072602
};
26082603
User.prototype.leave = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee28() {
2609-
var gun, user;
2604+
var gun, user, tmp;
26102605
return regeneratorRuntime.wrap(function _callee28$(_context28) {
26112606
while (1) {
26122607
switch (_context28.prev = _context28.next) {
@@ -2618,13 +2613,19 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
26182613
delete user._.is;
26192614
delete user._.sea;
26202615
}
2621-
_context28.next = 4;
2616+
if (typeof window !== 'undefined') {
2617+
tmp = window.sessionStorage;
2618+
2619+
delete tmp.alias;
2620+
delete tmp.tmp;
2621+
}
2622+
_context28.next = 5;
26222623
return authLeave(this.back(-1));
26232624

2624-
case 4:
2625+
case 5:
26252626
return _context28.abrupt("return", _context28.sent);
26262627

2627-
case 5:
2628+
case 6:
26282629
case "end":
26292630
return _context28.stop();
26302631
}

yarn.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3791,9 +3791,9 @@ gun@^0.9.96:
37913791
dependencies:
37923792
ws "~>5.2.0"
37933793

3794-
gun@^0.9.9997:
3795-
version "0.9.9997"
3796-
resolved "https://registry.yarnpkg.com/gun/-/gun-0.9.9997.tgz#266c40c25ecbc5aafd77211789decc3f21d8b126"
3794+
gun@^0.9.99991:
3795+
version "0.9.99991"
3796+
resolved "https://registry.yarnpkg.com/gun/-/gun-0.9.99991.tgz#0663d10e52b7cf36f97d7bfb532fc29dc7031100"
37973797
dependencies:
37983798
ws "~>5.2.0"
37993799

0 commit comments

Comments
 (0)