shogun-core 4.0.3 → 4.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -86304,6 +86304,322 @@ module.exports = webpackEmptyContext;
86304
86304
  }());
86305
86305
 
86306
86306
 
86307
+ /***/ }),
86308
+
86309
+ /***/ "./node_modules/gun/lib/axe.js":
86310
+ /*!*************************************!*\
86311
+ !*** ./node_modules/gun/lib/axe.js ***!
86312
+ \*************************************/
86313
+ /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
86314
+
86315
+ /* provided dependency */ var process = __webpack_require__(/*! process/browser */ "./node_modules/process/browser.js");
86316
+ // I don't quite know where this should go yet, so putting it here
86317
+ // what will probably wind up happening is that minimal AXE logic added to end of gun.js
86318
+ // and then rest of AXE logic (here) will be moved back to gun/axe.js
86319
+ // but for now... I gotta rush this out!
86320
+ var Gun = ( true)? window.Gun : 0, u;
86321
+ Gun.on('opt', function(at){ start(at); this.to.next(at) }); // make sure to call the "next" middleware adapter.
86322
+ // TODO: BUG: panic test/panic/1 & test/panic/3 fail when AXE is on.
86323
+ function start(root){
86324
+ if(root.axe){ return }
86325
+ var opt = root.opt, peers = opt.peers;
86326
+ if(false === opt.axe){ return }
86327
+ if((typeof process !== "undefined") && 'false' === ''+(opt.env=process.env||'').AXE){ return }
86328
+ Gun.log.once("AXE", "AXE relay enabled!");
86329
+ var axe = root.axe = {}, tmp, id;
86330
+ var mesh = opt.mesh = opt.mesh || Gun.Mesh(root); // DAM!
86331
+ var dup = root.dup;
86332
+
86333
+ mesh.way = function(msg){
86334
+ if(!msg){ return }
86335
+ //relayUp(msg); // TEMPORARY!!!
86336
+ if(msg.get){ return GET(msg) }
86337
+ if(msg.put){ return }
86338
+ fall(msg);
86339
+ }
86340
+
86341
+ function GET(msg){
86342
+ if(!msg){ return }
86343
+ var via = (msg._||'').via, soul, has, tmp, ref;
86344
+ if(!via || !via.id){ return fall(msg) }
86345
+ // SUBSCRIPTION LOGIC MOVED TO GET'S ACK REPLY.
86346
+ if(!(ref = REF(msg)._)){ return fall(msg) }
86347
+ ref.asked = +new Date;
86348
+ GET.turn(msg, ref.route, 0);
86349
+ }
86350
+ GET.turn = function(msg, route, turn){
86351
+ var tmp = msg['#'], tag = dup.s[tmp], next;
86352
+ if(!tmp || !tag){ return } // message timed out, GUN may require us to relay, tho AXE does not like that. Rethink?
86353
+ // TOOD: BUG! Handle edge case where live updates occur while these turn hashes are being checked (they'll never be consistent), but we don't want to degrade to O(N), if we know the via asking peer got an update, then we should do something like cancel these turns asking for data.
86354
+ // Ideas: Save a random seed that sorts the route, store it and the index. // Or indexing on lowest latency is probably better.
86355
+ clearTimeout(tag.lack);
86356
+ if(tag.ack && (tmp = tag['##']) && msg['##'] === tmp){ return } // hashes match, stop asking other peers!
86357
+ next = (Object.maps(route||opt.peers)).slice(turn = turn || 0);
86358
+ if(!next.length){
86359
+ if(!route){ return } // asked all peers, stop asking!
86360
+ GET.turn(msg, u, 0); // asked all subs, now now ask any peers. (not always the best idea, but stays )
86361
+ return;
86362
+ }
86363
+ setTimeout.each(next, function(id){
86364
+ var peer = opt.peers[id]; turn++;
86365
+ if(!peer || !peer.wire){ route && route.delete(id); return } // bye! // TODO: CHECK IF 0 OTHER PEERS & UNSUBSCRIBE
86366
+ if(mesh.say(msg, peer) === false){ return } // was self
86367
+ if(0 == (turn % 3)){ return 1 }
86368
+ }, function(){
86369
+ tag['##'] = msg['##']; // should probably set this in a more clever manner, do live `in` checks ++ --, etc. but being lazy for now. // TODO: Yes, see `in` TODO, currently this might match against only in-mem cause no other peers reply, which is "fine", but could cause a false positive.
86370
+ tag.lack = setTimeout(function(){ GET.turn(msg, route, turn) }, 25);
86371
+ }, 3);
86372
+ }
86373
+ function fall(msg){ mesh.say(msg, opt.peers) }
86374
+ function REF(msg){
86375
+ var ref = '', soul, has, tmp;
86376
+ if(!msg || !msg.get){ return ref }
86377
+ if('string' == typeof (soul = msg.get['#'])){ ref = root.$.get(soul) }
86378
+ if('string' == typeof (tmp = msg.get['.'])){ has = tmp } else { has = '' }
86379
+
86380
+ var via = (msg._||'').via, sub = (via.sub || (via.sub = new Object.Map)); (sub.get(soul) || (sub.set(soul, tmp = new Object.Map) && tmp)).set(has, 1); // {soul: {'':1, has: 1}} // TEMPORARILY REVERT AXE TOWER TYING TO SUBSCRIBING TO EVERYTHING. UNDO THIS!
86381
+ via.id && ref._ && (ref._.route || (ref._.route = new Object.Map)).set(via.id, via); // SAME AS ^
86382
+
86383
+ return ref;
86384
+ }
86385
+ function LEX(lex){ return (lex = lex || '')['='] || lex['*'] || lex['>'] || lex }
86386
+
86387
+ root.on('in', function(msg){ var to = this.to, tmp;
86388
+ if((tmp = msg['@']) && (tmp = dup.s[tmp])){
86389
+ tmp.ack = (tmp.ack || 0) + 1; // count remote ACKs to GET. // TODO: If mismatch, should trigger next asks.
86390
+ if(tmp.it && tmp.it.get && msg.put){ // WHEN SEEING A PUT REPLY TO A GET...
86391
+ var get = tmp.it.get||'', ref = REF(tmp.it)._, via = (tmp.it._||'').via||'', sub;
86392
+ if(via && ref){ // SUBSCRIBE THE PEER WHO ASKED VIA FOR IT:
86393
+ //console.log("SUBSCRIBING", Object.maps(ref.route||''), "to", LEX(get['#']));
86394
+ via.id && (ref.route || (ref.route = new Object.Map)).set(via.id, via);
86395
+ sub = (via.sub || (via.sub = new Object.Map));
86396
+ ref && (sub.get(LEX(get['#'])) || (sub.set(LEX(get['#']), sub = new Object.Map) && sub)).set(LEX(get['.']), 1); // {soul: {'':1, has: 1}}
86397
+
86398
+ via = (msg._||'').via||'';
86399
+ if(via){ // BIDIRECTIONAL SUBSCRIBE: REPLIER IS NOW SUBSCRIBED. DO WE WANT THIS?
86400
+ via.id && (ref.route || (ref.route = new Object.Map)).set(via.id, via);
86401
+ sub = (via.sub || (via.sub = new Object.Map));
86402
+ if(ref){
86403
+ var soul = LEX(get['#']), sift = sub.get(soul), has = LEX(get['.']);
86404
+ if(has){
86405
+ (sift || (sub.set(soul, sift = new Object.Map) && sift)).set(has, 1);
86406
+ } else
86407
+ if(!sift){
86408
+ sub.set(soul, sift = new Object.Map);
86409
+ sift.set('', 1);
86410
+ }
86411
+ }
86412
+ }
86413
+ }
86414
+ }
86415
+ if((tmp = tmp.back)){ // backtrack OKs since AXE splits PUTs up.
86416
+ setTimeout.each(Object.keys(tmp), function(id){
86417
+ to.next({'#': msg['#'], '@': id, ok: msg.ok});
86418
+ });
86419
+ return;
86420
+ }
86421
+ }
86422
+ to.next(msg);
86423
+ });
86424
+
86425
+ root.on('create', function(root){
86426
+ this.to.next(root);
86427
+ var Q = {};
86428
+ root.on('put', function(msg){
86429
+ var eve = this, at = eve.as, put = msg.put, soul = put['#'], has = put['.'], val = put[':'], state = put['>'], q, tmp;
86430
+ eve.to.next(msg);
86431
+ if(msg['@']){ return } // acks send existing data, not updates, so no need to resend to others.
86432
+ if(!soul || !has){ return }
86433
+ var ref = root.$.get(soul)._, route = (ref||'').route;
86434
+ if(!route){ return }
86435
+ if(ref.skip && ref.skip.has == has){ ref.skip.now = msg['#']; return }
86436
+ (ref.skip = {now: msg['#'], has: has}).to = setTimeout(function(){
86437
+ setTimeout.each(Object.maps(route), function(pid){ var peer, tmp;
86438
+ var skip = ref.skip||''; ref.skip = null;
86439
+ if(!(peer = route.get(pid))){ return }
86440
+ if(!peer.wire){ route.delete(pid); return } // bye!
86441
+ var sub = (peer.sub || (peer.sub = new Object.Map)).get(soul);
86442
+ if(!sub){ return }
86443
+ if(!sub.get(has) && !sub.get('')){ return }
86444
+ var put = peer.put || (peer.put = {});
86445
+ var node = root.graph[soul], tmp;
86446
+ if(node && u !== (tmp = node[has])){
86447
+ state = state_is(node, has);
86448
+ val = tmp;
86449
+ }
86450
+ put[soul] = state_ify(put[soul], has, state, val, soul);
86451
+ tmp = dup.track(peer.next = peer.next || String.random(9));
86452
+ (tmp.back || (tmp.back = {}))[''+(skip.now||msg['#'])] = 1;
86453
+ if(peer.to){ return }
86454
+ peer.to = setTimeout(function(){ flush(peer) }, opt.gap);
86455
+ }) }, 9);
86456
+ });
86457
+ });
86458
+
86459
+ function flush(peer){
86460
+ var msg = {'#': peer.next, put: peer.put, ok: {'@': 3, '/': mesh.near}}; // BUG: TODO: sub count!
86461
+ // TODO: what about DAM's >< dedup? Current thinking is, don't use it, however, you could store first msg# & latest msg#, and if here... latest === first then likely it is the same >< thing, so if(firstMsg['><'][peer.id]){ return } don't send.
86462
+ peer.next = peer.put = peer.to = null;
86463
+ mesh.say(msg, peer);
86464
+ }
86465
+ var state_ify = Gun.state.ify, state_is = Gun.state.is;
86466
+
86467
+ function relayUp(msg){
86468
+ mesh.say(msg, axe.up);
86469
+ }
86470
+
86471
+ ;(function(){ // THIS IS THE UP MODULE;
86472
+ axe.up = {};
86473
+ var hi = mesh.hear['?']; // lower-level integration with DAM! This is abnormal but helps performance.
86474
+ mesh.hear['?'] = function(msg, peer){ var p; // deduplicate unnecessary connections:
86475
+ hi(msg, peer);
86476
+ if(!peer.pid){ return }
86477
+ if(peer.pid === opt.pid){ mesh.bye(peer); return } // if I connected to myself, drop.
86478
+ if(p = axe.up[peer.pid]){ // if we both connected to each other...
86479
+ if(p === peer){ return } // do nothing if no conflict,
86480
+ if(opt.pid > peer.pid){ // else deterministically sort
86481
+ p = peer; // so we will wind up choosing the same to keep
86482
+ peer = axe.up[p.pid]; // and the same to drop.
86483
+ }
86484
+ p.url = p.url || peer.url; // copy if not
86485
+ mesh.bye(peer); // drop
86486
+ axe.up[p.pid] = p; // update same to be same.
86487
+ return;
86488
+ }
86489
+ if(!peer.url){ return }
86490
+ axe.up[peer.pid] = peer;
86491
+ if(axe.stay){ axe.stay() }
86492
+ };
86493
+
86494
+ mesh.hear['opt'] = function(msg, peer){
86495
+ if(msg.ok){ return }
86496
+ var tmp = msg.opt;
86497
+ if(!tmp){ return }
86498
+ tmp = tmp.peers;
86499
+ if(!tmp || 'string' != typeof tmp){ return }
86500
+ if(99 <= Object.keys(axe.up).length){ return } // 99 TEMPORARILY UNTIL BENCHMARKED!
86501
+ mesh.hi({id: tmp, url: tmp, retry: 9});
86502
+ if(peer){ mesh.say({dam: 'opt', ok: 1, '@': msg['#']}, peer) }
86503
+ }
86504
+
86505
+ axe.stay = function(){
86506
+ clearTimeout(axe.stay.to);
86507
+ axe.stay.to = setTimeout(function(tmp, urls){
86508
+ if(!(tmp = root.stats && root.stats.stay)){ return }
86509
+ urls = {}; Object.keys(axe.up||'').forEach(function(p){
86510
+ p = (axe.up||'')[p]; if(p.url){ urls[p.url] = {} }
86511
+ });
86512
+ (tmp.axe = tmp.axe || {}).up = urls;
86513
+ }, 1000 * 9);//1000 * 60);
86514
+ };
86515
+ setTimeout(function(tmp){
86516
+ if(!(tmp = root.stats && root.stats.stay && root.stats.stay.axe)){ return }
86517
+ if(!(tmp = tmp.up)){ return }
86518
+ if(!(tmp instanceof Array)){ tmp = Object.keys(tmp) }
86519
+ setTimeout.each(tmp||[], function(url){ mesh.hear.opt({opt: {peers: url}}) });
86520
+ },1000);
86521
+ }());
86522
+
86523
+ setTimeout(function(){ __webpack_require__(/*! ./service */ "./node_modules/gun/lib/service.js")(root) },9);
86524
+
86525
+ ;(function(){ // THIS IS THE MOB MODULE;
86526
+ //return; // WORK IN PROGRESS, TEST FINALIZED, NEED TO MAKE STABLE.
86527
+ /*
86528
+ AXE should have a couple of threshold items...
86529
+ let's pretend there is a variable max peers connected
86530
+ mob = 10000
86531
+ if we get more peers than that...
86532
+ we should start sending those peers a remote command
86533
+ that they should connect to this or that other peer
86534
+ and then once they (or before they do?) drop them from us.
86535
+ sake of the test... gonna set that peer number to 1.
86536
+ The mob threshold might be determined by other factors,
86537
+ like how much RAM or CPU stress we have.
86538
+ */
86539
+ opt.mob = opt.mob || parseFloat((opt.env||'').MOB) || 999999; // should be based on ulimit, some clouds as low as 10K.
86540
+
86541
+ // handle rebalancing a mob of peers:
86542
+ root.on('hi', function(peer){
86543
+ this.to.next(peer);
86544
+ if(peer.url){ return } // I am assuming that if we are wanting to make an outbound connection to them, that we don't ever want to drop them unless our actual config settings change.
86545
+ var count = /*Object.keys(opt.peers).length ||*/ mesh.near; // TODO: BUG! This is slow, use .near, but near is buggy right now, fix in DAM.
86546
+ //console.log("are we mobbed?", opt.mob, Object.keys(opt.peers).length, mesh.near);
86547
+ if(opt.mob >= count){ return } // TODO: Make dynamic based on RAM/CPU also. Or possibly even weird stuff like opt.mob / axe.up length?
86548
+ var peers = {};Object.keys(axe.up).forEach(function(p){ p = axe.up[p]; p.url && (peers[p.url]={}) });
86549
+ // TODO: BUG!!! Infinite reconnection loop happens if not enough relays, or if some are missing. For instance, :8766 says to connect to :8767 which then says to connect to :8766. To not DDoS when system overload, figure clever way to tell peers to retry later, that network does not have enough capacity?
86550
+ mesh.say({dam: 'mob', mob: count, peers: peers}, peer);
86551
+ setTimeout(function(){ mesh.bye(peer) }, 9); // something with better perf?
86552
+ });
86553
+ root.on('bye', function(peer){
86554
+ this.to.next(peer);
86555
+ });
86556
+
86557
+ }());
86558
+
86559
+ ;(function(){ // THIS IS THE UNIVERSAL NOTIFICATION MODULE
86560
+ var to = {}, key = {}, email = __webpack_require__(/*! ./email */ "./node_modules/gun/lib/email.js");
86561
+ if(email.err){ return }
86562
+ mesh.hear['tag'] = function(msg, peer, who){
86563
+ if(who = key[msg.key]){ who.rate = Math.max(msg.rate||1000*60*15, 1000*60); return }
86564
+ if(!msg.src || !msg.email){ return }
86565
+ if(+new Date < peer.emailed + 1000*60*2){ mesh.say({dam:'tag',err:'too fast'},peer); return } // peer can only send notifications > 2min
86566
+ var src; try{ src = new URL(msg.src = msg.src.split(/\s/)[0]); } catch(e){ return } // throws if invalid URL.
86567
+ (who = (to[msg.email] = to[msg.email] || {go:{}})).go[''+src] = 1; // we're keeping in-memory for now, maybe will "stay" to disk in future.
86568
+ peer.emailed = +new Date;
86569
+ if(who.batch){ return }
86570
+ key[who.key = Math.random().toString(36).slice(2)] = who;
86571
+ who.batch = setTimeout(function(){
86572
+ email.send({
86573
+ from: process.env.EMAIL,
86574
+ to: msg.email,
86575
+ subject: "Notification:",
86576
+ text: 'Someone or a bot tagged you at: (⚠️ only click link if you recognize & trust it ⚠️)\n'+
86577
+ '[use #'+who.key+' to unsubscribe please mute this thread by tapping the top most "⋮" button and clicking mute]\n\n' +
86578
+ Object.keys(who.go).join('\n'), // TODO: NEEDS TO BE CPU SCHEDULED
86579
+ headers: {'message-id': '<123456789.8765@example.com>'} // hardcode id so all batches also group into the same email thread to reduce clutter.
86580
+ }, function(err, r){
86581
+ who.batch = null; who.go = {};
86582
+ err && console.log("email TAG:", err);
86583
+ });
86584
+ }, who.rate || (1000*60*60*24)); // default to 1 day
86585
+ };
86586
+ }());
86587
+ };
86588
+
86589
+ ;(function(){
86590
+ var from = Array.from;
86591
+ Object.maps = function(o){
86592
+ if(from && o instanceof Map){ return from(o.keys()) }
86593
+ if(o instanceof Object.Map){ o = o.s }
86594
+ return Object.keys(o);
86595
+ }
86596
+ if(from){ return Object.Map = Map }
86597
+ (Object.Map = function(){ this.s = {} }).prototype = {set:function(k,v){this.s[k]=v;return this},get:function(k){return this.s[k]},delete:function(k){delete this.s[k]}};
86598
+ }());
86599
+
86600
+
86601
+ /***/ }),
86602
+
86603
+ /***/ "./node_modules/gun/lib/email.js":
86604
+ /*!***************************************!*\
86605
+ !*** ./node_modules/gun/lib/email.js ***!
86606
+ \***************************************/
86607
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
86608
+
86609
+ /* provided dependency */ var process = __webpack_require__(/*! process/browser */ "./node_modules/process/browser.js");
86610
+ ;(function(){
86611
+ var email, fail = {send: function(opt, cb){ cb && cb("You do not have email installed.") } };
86612
+ if(!process.env.EMAIL){ return module.exports = fail }
86613
+ try{ email = __webpack_require__(Object(function webpackMissingModule() { var e = new Error("Cannot find module 'emailjs'"); e.code = 'MODULE_NOT_FOUND'; throw e; }())) }catch(e){};
86614
+ if(!email){ return module.exports = fail }
86615
+ return module.exports = email.server.connect({
86616
+ user: process.env.EMAIL,
86617
+ password: process.env.EMAIL_KEY,
86618
+ host: process.env.EMAIL_HOST || "smtp.gmail.com",
86619
+ ssl: process.env.EMAIL_SSL || true
86620
+ });
86621
+ }());
86622
+
86307
86623
  /***/ }),
86308
86624
 
86309
86625
  /***/ "./node_modules/gun/lib/radisk.js":
@@ -87172,6 +87488,64 @@ if (navigator.storage && navigator.storage.estimate) {
87172
87488
 
87173
87489
  /***/ }),
87174
87490
 
87491
+ /***/ "./node_modules/gun/lib/service.js":
87492
+ /*!*****************************************!*\
87493
+ !*** ./node_modules/gun/lib/service.js ***!
87494
+ \*****************************************/
87495
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
87496
+
87497
+ var __dirname = "/";
87498
+ /* provided dependency */ var process = __webpack_require__(/*! process/browser */ "./node_modules/process/browser.js");
87499
+ module.exports = function(root){
87500
+ var mesh = root.opt.mesh, cmd = {}, run = Object(function webpackMissingModule() { var e = new Error("Cannot find module 'child_process'"); e.code = 'MODULE_NOT_FOUND'; throw e; }()), fs = __webpack_require__(Object(function webpackMissingModule() { var e = new Error("Cannot find module 'fs'"); e.code = 'MODULE_NOT_FOUND'; throw e; }())), home = (__webpack_require__(/*! os */ "./node_modules/os-browserify/main.js").homedir)(), examp = (__webpack_require__(/*! path */ "./node_modules/path-browserify/index.js").resolve)(__dirname, '../examples');
87501
+ mesh.hear['service'] = function(msg, peer){
87502
+ if(!fs.existsSync('/lib/systemd/system/relay.service')){
87503
+ mesh.say({dam: '!', err: "Not serviced."});
87504
+ return;
87505
+ }
87506
+ try{ (cmd[msg.try]||cmd.any)(msg, peer); }catch(err){ mesh.say({dam: '!', err: "service error: "+err}) }
87507
+ }
87508
+ cmd.https = function(msg, peer){ var log;
87509
+ if(!msg.email || !msg.domain){
87510
+ mesh.say({dam: '!', err: 'Domain/email missing, use `location.hostname`!'});
87511
+ return;
87512
+ }
87513
+ if(fs.existsSync(home+'/cert.pem')){
87514
+ mesh.say({dam: '!', err: 'Cert already exists.'});
87515
+ return;
87516
+ }
87517
+ fs.writeFile(examp+'/../email', msg.email, function(){});
87518
+ run("bash "+examp+"/https.sh", {env: {'EMAIL': msg.email, 'WEB': examp, 'DOMAIN': msg.domain}}, function(e, out, err){
87519
+ log = "|"+e+"|"+out+"|"+err;
87520
+ mesh.say({dam: '!', log: ''+log}, peer);
87521
+ setTimeout(function(){ process.exit() },999);
87522
+ });
87523
+ }
87524
+ cmd.update = function(msg, peer){ var log, pass;
87525
+ try{ pass = (''+fs.readFileSync(home+'/pass')).trim() }catch(e){}
87526
+ if(!pass || (msg.pass||'').trim() != pass){ return }
87527
+ root.stats.stay.updated = +new Date;
87528
+ run("bash "+examp+"/install.sh", {env: {VERSION: msg.version||''}}, function(e, out, err){
87529
+ log = e+"|"+out+"|"+err;
87530
+ mesh.say({dam: '!', log: ''+log}, peer);
87531
+ setTimeout(function(){ process.exit() },999);
87532
+ });
87533
+ }
87534
+ ;(function update(){ var last;
87535
+ if(!fs.existsSync(home+'/cert.pem')){ return }
87536
+ setTimeout(update, 1000*60*60*24);
87537
+ last = root.stats.stay.updated || 0;
87538
+ if(+new Date - last < 1000*60*60*24*15){ return }
87539
+ root.stats.stay.updated = +new Date;
87540
+ run("bash "+examp+"/install.sh", {}, function(){});
87541
+ }());
87542
+
87543
+ cmd.any = function(){};
87544
+
87545
+ };
87546
+
87547
+ /***/ }),
87548
+
87175
87549
  /***/ "./node_modules/gun/lib/store.js":
87176
87550
  /*!***************************************!*\
87177
87551
  !*** ./node_modules/gun/lib/store.js ***!
@@ -87506,6 +87880,108 @@ Gun.chain.then = function(cb) {
87506
87880
  }());
87507
87881
 
87508
87882
 
87883
+ /***/ }),
87884
+
87885
+ /***/ "./node_modules/gun/lib/wire.js":
87886
+ /*!**************************************!*\
87887
+ !*** ./node_modules/gun/lib/wire.js ***!
87888
+ \**************************************/
87889
+ /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
87890
+
87891
+ var Gun = __webpack_require__(/*! ../gun */ "./node_modules/gun/gun.js");
87892
+
87893
+ /*
87894
+ An Ad-Hoc Mesh-Network Daisy-Chain
87895
+ should work even if humans are
87896
+ communicating with each other blind.
87897
+
87898
+ To prevent infinite broadcast loops,
87899
+ we use a deduplication process
87900
+ based on the message's identifier.
87901
+ This is currently implemented in core.
87902
+
87903
+ However, because this still creates a
87904
+ N*2 (where N is the number of connections)
87905
+ flood, it is not scalable for traditional
87906
+ services that have a hub network topology.
87907
+
87908
+ Does this mean we have to abandon mesh
87909
+ algorithms? No, we can simply layer more
87910
+ efficient optimizations in based on constraints.
87911
+ If these constraints exist, it automatically
87912
+ upgrades, but if not, it falls back to the
87913
+ brute-force mesh based robust algorithm.
87914
+ A simple example is to limit peer connections
87915
+ and rely upon daisy chaining to relay messages.
87916
+
87917
+ Another example, is if peers are willing to
87918
+ identify themselves, then we can improve the
87919
+ efficiency of the network by having each peer
87920
+ include the names of peers it is connected in
87921
+ each message. Then each subsequent peer will
87922
+ not relay it to them, since it is unnecessary.
87923
+ This should create N (where N is the number of
87924
+ peers) messages (or possibly N+ if there is a
87925
+ common peer of uncommon peers that receives it
87926
+ and relays at exact latency timings), which is
87927
+ optimal.
87928
+
87929
+ Since computer networks aren't actually blind,
87930
+ we will implement the above method to improve
87931
+ the performance of the ad-hoc mesh network.
87932
+
87933
+ But why not have every message contain the
87934
+ whole history of peers that it relayed through?
87935
+ Because in sufficiently large enough networks,
87936
+ with extensive daisy chaining, this will cause
87937
+ the message to become prohibitively slow and
87938
+ increase indefinitely in size.
87939
+
87940
+ */
87941
+
87942
+ Gun.on('opt', function (root) {
87943
+ var opt = root.opt;
87944
+ if (false === opt.ws || opt.once) {
87945
+ this.to.next(root);
87946
+ return;
87947
+ }
87948
+ opt.mesh = opt.mesh || Gun.Mesh(root);
87949
+ opt.WebSocket = opt.WebSocket || __webpack_require__(Object(function webpackMissingModule() { var e = new Error("Cannot find module 'ws'"); e.code = 'MODULE_NOT_FOUND'; throw e; }()));
87950
+ var ws = opt.ws = opt.ws || {};
87951
+ ws.path = ws.path || '/gun';
87952
+ // if we DO need an HTTP server, then choose ws specific one or GUN default one.
87953
+ if (!opt.web || ws.noServer) {
87954
+ this.to.next(root);
87955
+ return;// no server no sockets
87956
+ }
87957
+ ws.noServer = true;//workaround for ws.path
87958
+ ws.web = ws.web || new opt.WebSocket.Server(ws);
87959
+ opt.web.on('upgrade', (req, socket, head) => {
87960
+ opt.web.host = opt.web.host || (req.headers||'').origin || (req.headers||'').host;
87961
+ if (req.url == ws.path) {
87962
+ ws.web.handleUpgrade(req, socket, head, function done(ws) {
87963
+ open(ws, req);
87964
+ });
87965
+ }
87966
+ });
87967
+ function open(wire, req) {
87968
+ var peer;
87969
+ wire.headers = wire.headers || (req || '').headers || '';
87970
+ console.STAT && ((console.STAT.sites || (console.STAT.sites = {}))[wire.headers.origin] = 1);
87971
+ opt.mesh.hi(peer = { wire: wire });
87972
+ wire.on('message', function (msg) {
87973
+ opt.mesh.hear(msg.data || msg, peer);
87974
+ });
87975
+ wire.on('close', function () {
87976
+ opt.mesh.bye(peer);
87977
+ });
87978
+ wire.on('error', function (e) { });
87979
+ setTimeout(function heart() { if (!opt.peers[peer.id]) { return } try { wire.send("[]") } catch (e) { }; setTimeout(heart, 1000 * 20) }, 1000 * 20); // Some systems, like Heroku, require heartbeats to not time out. // TODO: Make this configurable? // TODO: PERF: Find better approach than try/timeouts?
87980
+ }
87981
+ this.to.next(root);
87982
+ });
87983
+
87984
+
87509
87985
  /***/ }),
87510
87986
 
87511
87987
  /***/ "./node_modules/gun/lib/yson.js":
@@ -101160,6 +101636,547 @@ parseKeys.signature = asn1.signature;
101160
101636
  module.exports = parseKeys;
101161
101637
 
101162
101638
 
101639
+ /***/ }),
101640
+
101641
+ /***/ "./node_modules/path-browserify/index.js":
101642
+ /*!***********************************************!*\
101643
+ !*** ./node_modules/path-browserify/index.js ***!
101644
+ \***********************************************/
101645
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
101646
+
101647
+ "use strict";
101648
+ /* provided dependency */ var process = __webpack_require__(/*! process/browser */ "./node_modules/process/browser.js");
101649
+ // 'path' module extracted from Node.js v8.11.1 (only the posix part)
101650
+ // transplited with Babel
101651
+
101652
+ // Copyright Joyent, Inc. and other Node contributors.
101653
+ //
101654
+ // Permission is hereby granted, free of charge, to any person obtaining a
101655
+ // copy of this software and associated documentation files (the
101656
+ // "Software"), to deal in the Software without restriction, including
101657
+ // without limitation the rights to use, copy, modify, merge, publish,
101658
+ // distribute, sublicense, and/or sell copies of the Software, and to permit
101659
+ // persons to whom the Software is furnished to do so, subject to the
101660
+ // following conditions:
101661
+ //
101662
+ // The above copyright notice and this permission notice shall be included
101663
+ // in all copies or substantial portions of the Software.
101664
+ //
101665
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
101666
+ // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
101667
+ // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
101668
+ // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
101669
+ // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
101670
+ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
101671
+ // USE OR OTHER DEALINGS IN THE SOFTWARE.
101672
+
101673
+
101674
+
101675
+ function assertPath(path) {
101676
+ if (typeof path !== 'string') {
101677
+ throw new TypeError('Path must be a string. Received ' + JSON.stringify(path));
101678
+ }
101679
+ }
101680
+
101681
+ // Resolves . and .. elements in a path with directory names
101682
+ function normalizeStringPosix(path, allowAboveRoot) {
101683
+ var res = '';
101684
+ var lastSegmentLength = 0;
101685
+ var lastSlash = -1;
101686
+ var dots = 0;
101687
+ var code;
101688
+ for (var i = 0; i <= path.length; ++i) {
101689
+ if (i < path.length)
101690
+ code = path.charCodeAt(i);
101691
+ else if (code === 47 /*/*/)
101692
+ break;
101693
+ else
101694
+ code = 47 /*/*/;
101695
+ if (code === 47 /*/*/) {
101696
+ if (lastSlash === i - 1 || dots === 1) {
101697
+ // NOOP
101698
+ } else if (lastSlash !== i - 1 && dots === 2) {
101699
+ if (res.length < 2 || lastSegmentLength !== 2 || res.charCodeAt(res.length - 1) !== 46 /*.*/ || res.charCodeAt(res.length - 2) !== 46 /*.*/) {
101700
+ if (res.length > 2) {
101701
+ var lastSlashIndex = res.lastIndexOf('/');
101702
+ if (lastSlashIndex !== res.length - 1) {
101703
+ if (lastSlashIndex === -1) {
101704
+ res = '';
101705
+ lastSegmentLength = 0;
101706
+ } else {
101707
+ res = res.slice(0, lastSlashIndex);
101708
+ lastSegmentLength = res.length - 1 - res.lastIndexOf('/');
101709
+ }
101710
+ lastSlash = i;
101711
+ dots = 0;
101712
+ continue;
101713
+ }
101714
+ } else if (res.length === 2 || res.length === 1) {
101715
+ res = '';
101716
+ lastSegmentLength = 0;
101717
+ lastSlash = i;
101718
+ dots = 0;
101719
+ continue;
101720
+ }
101721
+ }
101722
+ if (allowAboveRoot) {
101723
+ if (res.length > 0)
101724
+ res += '/..';
101725
+ else
101726
+ res = '..';
101727
+ lastSegmentLength = 2;
101728
+ }
101729
+ } else {
101730
+ if (res.length > 0)
101731
+ res += '/' + path.slice(lastSlash + 1, i);
101732
+ else
101733
+ res = path.slice(lastSlash + 1, i);
101734
+ lastSegmentLength = i - lastSlash - 1;
101735
+ }
101736
+ lastSlash = i;
101737
+ dots = 0;
101738
+ } else if (code === 46 /*.*/ && dots !== -1) {
101739
+ ++dots;
101740
+ } else {
101741
+ dots = -1;
101742
+ }
101743
+ }
101744
+ return res;
101745
+ }
101746
+
101747
+ function _format(sep, pathObject) {
101748
+ var dir = pathObject.dir || pathObject.root;
101749
+ var base = pathObject.base || (pathObject.name || '') + (pathObject.ext || '');
101750
+ if (!dir) {
101751
+ return base;
101752
+ }
101753
+ if (dir === pathObject.root) {
101754
+ return dir + base;
101755
+ }
101756
+ return dir + sep + base;
101757
+ }
101758
+
101759
+ var posix = {
101760
+ // path.resolve([from ...], to)
101761
+ resolve: function resolve() {
101762
+ var resolvedPath = '';
101763
+ var resolvedAbsolute = false;
101764
+ var cwd;
101765
+
101766
+ for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
101767
+ var path;
101768
+ if (i >= 0)
101769
+ path = arguments[i];
101770
+ else {
101771
+ if (cwd === undefined)
101772
+ cwd = process.cwd();
101773
+ path = cwd;
101774
+ }
101775
+
101776
+ assertPath(path);
101777
+
101778
+ // Skip empty entries
101779
+ if (path.length === 0) {
101780
+ continue;
101781
+ }
101782
+
101783
+ resolvedPath = path + '/' + resolvedPath;
101784
+ resolvedAbsolute = path.charCodeAt(0) === 47 /*/*/;
101785
+ }
101786
+
101787
+ // At this point the path should be resolved to a full absolute path, but
101788
+ // handle relative paths to be safe (might happen when process.cwd() fails)
101789
+
101790
+ // Normalize the path
101791
+ resolvedPath = normalizeStringPosix(resolvedPath, !resolvedAbsolute);
101792
+
101793
+ if (resolvedAbsolute) {
101794
+ if (resolvedPath.length > 0)
101795
+ return '/' + resolvedPath;
101796
+ else
101797
+ return '/';
101798
+ } else if (resolvedPath.length > 0) {
101799
+ return resolvedPath;
101800
+ } else {
101801
+ return '.';
101802
+ }
101803
+ },
101804
+
101805
+ normalize: function normalize(path) {
101806
+ assertPath(path);
101807
+
101808
+ if (path.length === 0) return '.';
101809
+
101810
+ var isAbsolute = path.charCodeAt(0) === 47 /*/*/;
101811
+ var trailingSeparator = path.charCodeAt(path.length - 1) === 47 /*/*/;
101812
+
101813
+ // Normalize the path
101814
+ path = normalizeStringPosix(path, !isAbsolute);
101815
+
101816
+ if (path.length === 0 && !isAbsolute) path = '.';
101817
+ if (path.length > 0 && trailingSeparator) path += '/';
101818
+
101819
+ if (isAbsolute) return '/' + path;
101820
+ return path;
101821
+ },
101822
+
101823
+ isAbsolute: function isAbsolute(path) {
101824
+ assertPath(path);
101825
+ return path.length > 0 && path.charCodeAt(0) === 47 /*/*/;
101826
+ },
101827
+
101828
+ join: function join() {
101829
+ if (arguments.length === 0)
101830
+ return '.';
101831
+ var joined;
101832
+ for (var i = 0; i < arguments.length; ++i) {
101833
+ var arg = arguments[i];
101834
+ assertPath(arg);
101835
+ if (arg.length > 0) {
101836
+ if (joined === undefined)
101837
+ joined = arg;
101838
+ else
101839
+ joined += '/' + arg;
101840
+ }
101841
+ }
101842
+ if (joined === undefined)
101843
+ return '.';
101844
+ return posix.normalize(joined);
101845
+ },
101846
+
101847
+ relative: function relative(from, to) {
101848
+ assertPath(from);
101849
+ assertPath(to);
101850
+
101851
+ if (from === to) return '';
101852
+
101853
+ from = posix.resolve(from);
101854
+ to = posix.resolve(to);
101855
+
101856
+ if (from === to) return '';
101857
+
101858
+ // Trim any leading backslashes
101859
+ var fromStart = 1;
101860
+ for (; fromStart < from.length; ++fromStart) {
101861
+ if (from.charCodeAt(fromStart) !== 47 /*/*/)
101862
+ break;
101863
+ }
101864
+ var fromEnd = from.length;
101865
+ var fromLen = fromEnd - fromStart;
101866
+
101867
+ // Trim any leading backslashes
101868
+ var toStart = 1;
101869
+ for (; toStart < to.length; ++toStart) {
101870
+ if (to.charCodeAt(toStart) !== 47 /*/*/)
101871
+ break;
101872
+ }
101873
+ var toEnd = to.length;
101874
+ var toLen = toEnd - toStart;
101875
+
101876
+ // Compare paths to find the longest common path from root
101877
+ var length = fromLen < toLen ? fromLen : toLen;
101878
+ var lastCommonSep = -1;
101879
+ var i = 0;
101880
+ for (; i <= length; ++i) {
101881
+ if (i === length) {
101882
+ if (toLen > length) {
101883
+ if (to.charCodeAt(toStart + i) === 47 /*/*/) {
101884
+ // We get here if `from` is the exact base path for `to`.
101885
+ // For example: from='/foo/bar'; to='/foo/bar/baz'
101886
+ return to.slice(toStart + i + 1);
101887
+ } else if (i === 0) {
101888
+ // We get here if `from` is the root
101889
+ // For example: from='/'; to='/foo'
101890
+ return to.slice(toStart + i);
101891
+ }
101892
+ } else if (fromLen > length) {
101893
+ if (from.charCodeAt(fromStart + i) === 47 /*/*/) {
101894
+ // We get here if `to` is the exact base path for `from`.
101895
+ // For example: from='/foo/bar/baz'; to='/foo/bar'
101896
+ lastCommonSep = i;
101897
+ } else if (i === 0) {
101898
+ // We get here if `to` is the root.
101899
+ // For example: from='/foo'; to='/'
101900
+ lastCommonSep = 0;
101901
+ }
101902
+ }
101903
+ break;
101904
+ }
101905
+ var fromCode = from.charCodeAt(fromStart + i);
101906
+ var toCode = to.charCodeAt(toStart + i);
101907
+ if (fromCode !== toCode)
101908
+ break;
101909
+ else if (fromCode === 47 /*/*/)
101910
+ lastCommonSep = i;
101911
+ }
101912
+
101913
+ var out = '';
101914
+ // Generate the relative path based on the path difference between `to`
101915
+ // and `from`
101916
+ for (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) {
101917
+ if (i === fromEnd || from.charCodeAt(i) === 47 /*/*/) {
101918
+ if (out.length === 0)
101919
+ out += '..';
101920
+ else
101921
+ out += '/..';
101922
+ }
101923
+ }
101924
+
101925
+ // Lastly, append the rest of the destination (`to`) path that comes after
101926
+ // the common path parts
101927
+ if (out.length > 0)
101928
+ return out + to.slice(toStart + lastCommonSep);
101929
+ else {
101930
+ toStart += lastCommonSep;
101931
+ if (to.charCodeAt(toStart) === 47 /*/*/)
101932
+ ++toStart;
101933
+ return to.slice(toStart);
101934
+ }
101935
+ },
101936
+
101937
+ _makeLong: function _makeLong(path) {
101938
+ return path;
101939
+ },
101940
+
101941
+ dirname: function dirname(path) {
101942
+ assertPath(path);
101943
+ if (path.length === 0) return '.';
101944
+ var code = path.charCodeAt(0);
101945
+ var hasRoot = code === 47 /*/*/;
101946
+ var end = -1;
101947
+ var matchedSlash = true;
101948
+ for (var i = path.length - 1; i >= 1; --i) {
101949
+ code = path.charCodeAt(i);
101950
+ if (code === 47 /*/*/) {
101951
+ if (!matchedSlash) {
101952
+ end = i;
101953
+ break;
101954
+ }
101955
+ } else {
101956
+ // We saw the first non-path separator
101957
+ matchedSlash = false;
101958
+ }
101959
+ }
101960
+
101961
+ if (end === -1) return hasRoot ? '/' : '.';
101962
+ if (hasRoot && end === 1) return '//';
101963
+ return path.slice(0, end);
101964
+ },
101965
+
101966
+ basename: function basename(path, ext) {
101967
+ if (ext !== undefined && typeof ext !== 'string') throw new TypeError('"ext" argument must be a string');
101968
+ assertPath(path);
101969
+
101970
+ var start = 0;
101971
+ var end = -1;
101972
+ var matchedSlash = true;
101973
+ var i;
101974
+
101975
+ if (ext !== undefined && ext.length > 0 && ext.length <= path.length) {
101976
+ if (ext.length === path.length && ext === path) return '';
101977
+ var extIdx = ext.length - 1;
101978
+ var firstNonSlashEnd = -1;
101979
+ for (i = path.length - 1; i >= 0; --i) {
101980
+ var code = path.charCodeAt(i);
101981
+ if (code === 47 /*/*/) {
101982
+ // If we reached a path separator that was not part of a set of path
101983
+ // separators at the end of the string, stop now
101984
+ if (!matchedSlash) {
101985
+ start = i + 1;
101986
+ break;
101987
+ }
101988
+ } else {
101989
+ if (firstNonSlashEnd === -1) {
101990
+ // We saw the first non-path separator, remember this index in case
101991
+ // we need it if the extension ends up not matching
101992
+ matchedSlash = false;
101993
+ firstNonSlashEnd = i + 1;
101994
+ }
101995
+ if (extIdx >= 0) {
101996
+ // Try to match the explicit extension
101997
+ if (code === ext.charCodeAt(extIdx)) {
101998
+ if (--extIdx === -1) {
101999
+ // We matched the extension, so mark this as the end of our path
102000
+ // component
102001
+ end = i;
102002
+ }
102003
+ } else {
102004
+ // Extension does not match, so our result is the entire path
102005
+ // component
102006
+ extIdx = -1;
102007
+ end = firstNonSlashEnd;
102008
+ }
102009
+ }
102010
+ }
102011
+ }
102012
+
102013
+ if (start === end) end = firstNonSlashEnd;else if (end === -1) end = path.length;
102014
+ return path.slice(start, end);
102015
+ } else {
102016
+ for (i = path.length - 1; i >= 0; --i) {
102017
+ if (path.charCodeAt(i) === 47 /*/*/) {
102018
+ // If we reached a path separator that was not part of a set of path
102019
+ // separators at the end of the string, stop now
102020
+ if (!matchedSlash) {
102021
+ start = i + 1;
102022
+ break;
102023
+ }
102024
+ } else if (end === -1) {
102025
+ // We saw the first non-path separator, mark this as the end of our
102026
+ // path component
102027
+ matchedSlash = false;
102028
+ end = i + 1;
102029
+ }
102030
+ }
102031
+
102032
+ if (end === -1) return '';
102033
+ return path.slice(start, end);
102034
+ }
102035
+ },
102036
+
102037
+ extname: function extname(path) {
102038
+ assertPath(path);
102039
+ var startDot = -1;
102040
+ var startPart = 0;
102041
+ var end = -1;
102042
+ var matchedSlash = true;
102043
+ // Track the state of characters (if any) we see before our first dot and
102044
+ // after any path separator we find
102045
+ var preDotState = 0;
102046
+ for (var i = path.length - 1; i >= 0; --i) {
102047
+ var code = path.charCodeAt(i);
102048
+ if (code === 47 /*/*/) {
102049
+ // If we reached a path separator that was not part of a set of path
102050
+ // separators at the end of the string, stop now
102051
+ if (!matchedSlash) {
102052
+ startPart = i + 1;
102053
+ break;
102054
+ }
102055
+ continue;
102056
+ }
102057
+ if (end === -1) {
102058
+ // We saw the first non-path separator, mark this as the end of our
102059
+ // extension
102060
+ matchedSlash = false;
102061
+ end = i + 1;
102062
+ }
102063
+ if (code === 46 /*.*/) {
102064
+ // If this is our first dot, mark it as the start of our extension
102065
+ if (startDot === -1)
102066
+ startDot = i;
102067
+ else if (preDotState !== 1)
102068
+ preDotState = 1;
102069
+ } else if (startDot !== -1) {
102070
+ // We saw a non-dot and non-path separator before our dot, so we should
102071
+ // have a good chance at having a non-empty extension
102072
+ preDotState = -1;
102073
+ }
102074
+ }
102075
+
102076
+ if (startDot === -1 || end === -1 ||
102077
+ // We saw a non-dot character immediately before the dot
102078
+ preDotState === 0 ||
102079
+ // The (right-most) trimmed path component is exactly '..'
102080
+ preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
102081
+ return '';
102082
+ }
102083
+ return path.slice(startDot, end);
102084
+ },
102085
+
102086
+ format: function format(pathObject) {
102087
+ if (pathObject === null || typeof pathObject !== 'object') {
102088
+ throw new TypeError('The "pathObject" argument must be of type Object. Received type ' + typeof pathObject);
102089
+ }
102090
+ return _format('/', pathObject);
102091
+ },
102092
+
102093
+ parse: function parse(path) {
102094
+ assertPath(path);
102095
+
102096
+ var ret = { root: '', dir: '', base: '', ext: '', name: '' };
102097
+ if (path.length === 0) return ret;
102098
+ var code = path.charCodeAt(0);
102099
+ var isAbsolute = code === 47 /*/*/;
102100
+ var start;
102101
+ if (isAbsolute) {
102102
+ ret.root = '/';
102103
+ start = 1;
102104
+ } else {
102105
+ start = 0;
102106
+ }
102107
+ var startDot = -1;
102108
+ var startPart = 0;
102109
+ var end = -1;
102110
+ var matchedSlash = true;
102111
+ var i = path.length - 1;
102112
+
102113
+ // Track the state of characters (if any) we see before our first dot and
102114
+ // after any path separator we find
102115
+ var preDotState = 0;
102116
+
102117
+ // Get non-dir info
102118
+ for (; i >= start; --i) {
102119
+ code = path.charCodeAt(i);
102120
+ if (code === 47 /*/*/) {
102121
+ // If we reached a path separator that was not part of a set of path
102122
+ // separators at the end of the string, stop now
102123
+ if (!matchedSlash) {
102124
+ startPart = i + 1;
102125
+ break;
102126
+ }
102127
+ continue;
102128
+ }
102129
+ if (end === -1) {
102130
+ // We saw the first non-path separator, mark this as the end of our
102131
+ // extension
102132
+ matchedSlash = false;
102133
+ end = i + 1;
102134
+ }
102135
+ if (code === 46 /*.*/) {
102136
+ // If this is our first dot, mark it as the start of our extension
102137
+ if (startDot === -1) startDot = i;else if (preDotState !== 1) preDotState = 1;
102138
+ } else if (startDot !== -1) {
102139
+ // We saw a non-dot and non-path separator before our dot, so we should
102140
+ // have a good chance at having a non-empty extension
102141
+ preDotState = -1;
102142
+ }
102143
+ }
102144
+
102145
+ if (startDot === -1 || end === -1 ||
102146
+ // We saw a non-dot character immediately before the dot
102147
+ preDotState === 0 ||
102148
+ // The (right-most) trimmed path component is exactly '..'
102149
+ preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
102150
+ if (end !== -1) {
102151
+ if (startPart === 0 && isAbsolute) ret.base = ret.name = path.slice(1, end);else ret.base = ret.name = path.slice(startPart, end);
102152
+ }
102153
+ } else {
102154
+ if (startPart === 0 && isAbsolute) {
102155
+ ret.name = path.slice(1, startDot);
102156
+ ret.base = path.slice(1, end);
102157
+ } else {
102158
+ ret.name = path.slice(startPart, startDot);
102159
+ ret.base = path.slice(startPart, end);
102160
+ }
102161
+ ret.ext = path.slice(startDot, end);
102162
+ }
102163
+
102164
+ if (startPart > 0) ret.dir = path.slice(0, startPart - 1);else if (isAbsolute) ret.dir = '/';
102165
+
102166
+ return ret;
102167
+ },
102168
+
102169
+ sep: '/',
102170
+ delimiter: ':',
102171
+ win32: null,
102172
+ posix: null
102173
+ };
102174
+
102175
+ posix.posix = posix;
102176
+
102177
+ module.exports = posix;
102178
+
102179
+
101163
102180
  /***/ }),
101164
102181
 
101165
102182
  /***/ "./node_modules/pbkdf2/browser.js":
@@ -145088,6 +146105,8 @@ __webpack_require__(/*! gun/lib/radisk */ "./node_modules/gun/lib/radisk.js");
145088
146105
  __webpack_require__(/*! gun/lib/store */ "./node_modules/gun/lib/store.js");
145089
146106
  __webpack_require__(/*! gun/lib/rindexed */ "./node_modules/gun/lib/rindexed.js");
145090
146107
  __webpack_require__(/*! gun/lib/webrtc */ "./node_modules/gun/lib/webrtc.js");
146108
+ __webpack_require__(/*! gun/lib/wire */ "./node_modules/gun/lib/wire.js");
146109
+ __webpack_require__(/*! gun/lib/axe */ "./node_modules/gun/lib/axe.js");
145091
146110
  const derive_1 = __importDefault(__webpack_require__(/*! ./derive */ "./src/gundb/derive.ts"));
145092
146111
  exports.derive = derive_1.default;
145093
146112
  const errorHandler_1 = __webpack_require__(/*! ../utils/errorHandler */ "./src/utils/errorHandler.ts");
@@ -145098,6 +146117,7 @@ const GunErrors = __importStar(__webpack_require__(/*! ./errors */ "./src/gundb/
145098
146117
  exports.GunErrors = GunErrors;
145099
146118
  const crypto = __importStar(__webpack_require__(/*! ./crypto */ "./src/gundb/crypto.ts"));
145100
146119
  exports.crypto = crypto;
146120
+ const shogun_relays_1 = __importStar(__webpack_require__(/*! shogun-relays */ "./node_modules/shogun-relays/index.js"));
145101
146121
  /**
145102
146122
  * Configuration constants for timeouts and security
145103
146123
  */
@@ -146865,11 +147885,30 @@ class DataBase {
146865
147885
  isAuthenticated() {
146866
147886
  return this.user?.is?.pub ? true : false;
146867
147887
  }
147888
+ /**
147889
+ *
147890
+ * @returns Promise resolving with the list of relays
147891
+ */
147892
+ async getRelays() {
147893
+ return (0, shogun_relays_1.default)();
147894
+ }
147895
+ /**
147896
+ *
147897
+ * @returns Promise resolving with the list of relays
147898
+ */
147899
+ async forceListUpdate() {
147900
+ const freshRelays = await (0, shogun_relays_1.forceListUpdate)();
147901
+ freshRelays.forEach((relay) => {
147902
+ console.log("Adding relay:", relay);
147903
+ this.addPeer(relay);
147904
+ });
147905
+ return freshRelays;
147906
+ }
146868
147907
  }
146869
147908
  exports.DataBase = DataBase;
146870
147909
  // Errors
146871
147910
  DataBase.Errors = GunErrors;
146872
- const createGun = (config, silent) => {
147911
+ const createGun = (config) => {
146873
147912
  const gunInstance = (0, gun_1.default)(config);
146874
147913
  return gunInstance;
146875
147914
  };
@@ -148120,10 +149159,13 @@ exports.AuthManager = AuthManager;
148120
149159
  /*!*****************************************!*\
148121
149160
  !*** ./src/managers/CoreInitializer.ts ***!
148122
149161
  \*****************************************/
148123
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
149162
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
148124
149163
 
148125
149164
  "use strict";
148126
149165
 
149166
+ var __importDefault = (this && this.__importDefault) || function (mod) {
149167
+ return (mod && mod.__esModule) ? mod : { "default": mod };
149168
+ };
148127
149169
  Object.defineProperty(exports, "__esModule", ({ value: true }));
148128
149170
  exports.CoreInitializer = void 0;
148129
149171
  const storage_1 = __webpack_require__(/*! ../storage/storage */ "./src/storage/storage.ts");
@@ -148133,7 +149175,7 @@ const web3ConnectorPlugin_1 = __webpack_require__(/*! ../plugins/web3/web3Connec
148133
149175
  const nostrConnectorPlugin_1 = __webpack_require__(/*! ../plugins/nostr/nostrConnectorPlugin */ "./src/plugins/nostr/nostrConnectorPlugin.ts");
148134
149176
  const zkProofPlugin_1 = __webpack_require__(/*! ../plugins/zkproof/zkProofPlugin */ "./src/plugins/zkproof/zkProofPlugin.ts");
148135
149177
  const gundb_1 = __webpack_require__(/*! ../gundb */ "./src/gundb/index.ts");
148136
- const shogun_relays_1 = __webpack_require__(/*! shogun-relays */ "./node_modules/shogun-relays/index.js");
149178
+ const shogun_relays_1 = __importDefault(__webpack_require__(/*! shogun-relays */ "./node_modules/shogun-relays/index.js"));
148137
149179
  /**
148138
149180
  * Handles initialization of ShogunCore components
148139
149181
  */
@@ -148190,17 +149232,17 @@ class CoreInitializer {
148190
149232
  // Sì, è corretto.
148191
149233
  async initializeGun(config) {
148192
149234
  try {
148193
- let peers = await (0, shogun_relays_1.forceListUpdate)();
148194
- if (config.gunOptions?.peers &&
148195
- (config.gunOptions?.peers?.length === 0 || !config.gunOptions?.peers) &&
148196
- !config.gunInstance) {
149235
+ let peers = await (0, shogun_relays_1.default)();
149236
+ if (!config.gunOptions?.peers && !config.gunInstance) {
148197
149237
  console.log("Using peers from forceListUpdate", peers);
148198
149238
  config.gunOptions.peers = peers;
148199
149239
  }
148200
149240
  if (config.gunInstance) {
149241
+ console.log("Using existing Gun instance:", config.gunInstance);
148201
149242
  this.core._gun = config.gunInstance;
148202
149243
  }
148203
149244
  else if (config.gunOptions && config.gunInstance === undefined) {
149245
+ console.log("Creating Gun instance with config:", config.gunOptions);
148204
149246
  this.core._gun = (0, gundb_1.createGun)(config.gunOptions);
148205
149247
  }
148206
149248
  else if (config.gunInstance && config.gunOptions) {