gun-eth 1.4.0 → 1.4.1
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/gun-eth.js +2580 -0
- package/dist/gun-eth.min.js +1 -1
- package/package.json +1 -1
package/dist/gun-eth.min.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n(require("gun/sea"),require("ethers")):"function"==typeof define&&define.amd?define(["gun/sea","ethers"],n):(t="undefined"!=typeof globalThis?globalThis:t||self).GunEth=n(t.SEA,t.ethers)}(this,(function(t,n){"use strict";var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function o(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var i={exports:{}};var r,a={exports:{}};function s(){return r||(r=1,function(t){!function(){function n(t,e){return e?function(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}(t):t.slice?n[o(t)]:function(e,i){t(e={exports:{}}),n[o(i)]=e.exports};function o(t){return t.split("/").slice(-1).toString().replace(".js","")}}var e=t;n((function(t){String.random=function(t,n){var e="";for(t=t||24,n=n||"0123456789ABCDEFGHIJKLMNOPQRSTUVWXZabcdefghijklmnopqrstuvwxyz";t-- >0;)e+=n.charAt(Math.floor(Math.random()*n.length));return e},String.match=function(t,n){var e,o;return"string"==typeof t&&("string"==typeof n&&(n={"=":n}),t===(e=(n=n||{})["="]||n["*"]||n[">"]||n["<"])||o===n["="]&&(e=n["*"]||n[">"],t.slice(0,(e||"").length)===e||o===n["*"]&&(o!==n[">"]&&o!==n["<"]?t>=n[">"]&&t<=n["<"]:o!==n[">"]&&t>=n[">"]||o!==n["<"]&&t<=n["<"])))},String.hash=function(t,n){if("string"==typeof t){if(n=n||0,!t.length)return n;for(var e=0,o=t.length;e<o;++e)n=(n<<5)-n+t.charCodeAt(e),n|=0;return n}};var n,e,o,i,r,a,s=Object.prototype.hasOwnProperty;Object.plain=function(t){return!!t&&(t instanceof Object&&t.constructor===Object||"Object"===Object.prototype.toString.call(t).match(/^\[object (\w+)\]$/)[1])},Object.empty=function(t,n){for(var e in t)if(s.call(t,e)&&(!n||-1==n.indexOf(e)))return!1;return!0},Object.keys=Object.keys||function(t){var n=[];for(var e in t)s.call(t,e)&&n.push(e);return n},e=setTimeout,o=0,i=0,r=typeof setImmediate!=""+n&&setImmediate||function(t,o){return typeof MessageChannel==""+n?e:((t=new MessageChannel).port1.onmessage=function(t){""==t.data&&o()},function(n){o=n,t.port2.postMessage("")})}(),a=e.check=e.check||typeof performance!=""+n&&performance||{now:function(){return+new Date}},e.hold=e.hold||9,e.poll=e.poll||function(t){e.hold>=a.now()-o&&i++<3333?t():r((function(){o=a.now(),t()}),i=0)},function(){var t,n=setTimeout,e=n.turn=n.turn||function(t){1==o.push(t)&&i(a)},o=e.s=[],i=n.poll,r=0,a=function(){(t=o[r++])&&t(),r!=o.length&&99!=r||(o=e.s=o.slice(r),r=0),o.length&&i(a)}}(),function(){var t,n=setTimeout,e=n.turn;(n.each=n.each||function(n,o,i,r){r=r||9,function a(s,u,c){if(u=(s=(n||[]).splice(0,r)).length){for(var f=0;f<u&&t===(c=o(s[f]));f++);if(t===c)return void e(a)}i&&i(c)}()})()}()}))(n,"./shim"),n((function(t){t.exports=function t(n,e,o){if(!n)return{to:t};var i="function"==typeof e;n=(this.tag||(this.tag={}))[n]||i&&(this.tag[n]={tag:n,to:t._={next:function(t){var n;(n=this.to)&&n.next(t)}}});if(i){var r={off:t.off||(t.off=function(){if(this.next===t._.next)return!0;this===this.the.last&&(this.the.last=this.back),this.to.back=this.back,this.next=t._.next,this.back.to=this.to,this.the.last===this.the&&delete this.on.tag[this.the.tag]}),to:t._,next:e,the:n,on:this,as:o};return(r.back=n.last||n).to=r,n.last=r}return(n=n.to)&&undefined!==e&&n.next(e),n}}))(n,"./onto"),n((function(t){t.exports=function(t){return null===t||"string"==typeof t||"boolean"==typeof t||"number"==typeof t&&t!=1/0&&t!=-1/0&&t==t||!!t&&"string"==typeof t["#"]&&1===Object.keys(t).length&&t["#"]}}))(n,"./valid"),n((function(t){function e(){var t=+new Date;return s<t?(r=0,s=t+e.drift):s=t+(r+=1)/a+e.drift}n("./shim"),e.drift=0;var o,i=-1/0,r=0,a=999,s=i;e.is=function(t,n,e){var o=n&&t&&t._&&t._[">"]||e;if(o)return"number"==typeof(o=o[n])?o:i},e.ify=function(t,n,e,i,r){(t=t||{})._=t._||{},r&&(t._["#"]=r);var a=t._[">"]||(t._[">"]={});return o!==n&&"_"!==n&&("number"==typeof e&&(a[n]=e),o!==i&&(t[n]=i)),t},t.exports=e}))(n,"./state"),n((function(t){n("./shim"),t.exports=function(t){var n={s:{}},e=n.s;t=t||{max:999,age:9e3},n.check=function(t){return!!e[t]&&o(t)};var o=n.track=function(i){var r=e[i]||(e[i]={});return r.was=n.now=+new Date,n.to||(n.to=setTimeout(n.drop,t.age+9)),o.ed&&o.ed(i),r};return n.drop=function(o){n.to=null,n.now=+new Date;var i=Object.keys(e);console.STAT&&console.STAT(n.now,+new Date-n.now,"dup drop keys"),setTimeout.each(i,(function(i){var r=e[i];r&&(o||t.age)>n.now-r.was||delete e[i]}),0,99)},n}}))(n,"./dup"),n((function(t){n("./onto"),t.exports=function(t,n){if(this.on){var o=(this.opt||{}).lack||9e3;if("function"!=typeof t){if(!t)return;var i=t["#"]||t,r=(this.tag||"")[i];if(!r)return;return n&&(r=this.on(i,n),clearTimeout(r.err),r.err=setTimeout((function(){r.off()}),o)),!0}i=n&&n["#"]||e(9);if(!t)return i;var a=this.on(i,t,n);return a.err=a.err||setTimeout((function(){a.off(),a.next({err:"Error: No ACK yet.",lack:!0})}),o),i}};var e=String.random||function(){return Math.random().toString(36).slice(2)}}))(n,"./ask"),n((function(t){function o(t){return t instanceof o?(this._={$:this}).$:this instanceof o?o.create(this._={$:this,opt:t}):new o(t)}o.is=function(t){return t instanceof o||t&&t._&&t===t._.$||!1},o.version=.202,o.chain=o.prototype,o.chain.toJSON=function(){},n("./shim"),o.valid=n("./valid"),o.state=n("./state"),o.on=n("./onto"),o.dup=n("./dup"),o.ask=n("./ask"),function(){function t(e){if(e)if(e.out!==t){var i,r=this.as,u=r.at||r,c=u.$,f=u.dup,l=e.DBG;if((i=e["#"])||(i=e["#"]=s(9)),!f.check(i)){if(f.track(i),i=e._,e._="function"==typeof i?i:function(){},e.$&&e.$===(e.$._||"").$||(e.$=c),e["@"]&&!e.put&&function(t){var n,e=t["@"]||"";if(!(n=e._)){var o=(o=t.$)&&(o=o._)&&(o=o.root)&&(o=o.dup);if(!(o=o.check(e)))return;return void(t["@"]=o["#"]||t["@"])}n.acks=(n.acks||0)+1,(n.err=t.err)&&(t["@"]=n["#"],a(n));n.ok=t.ok||n.ok,n.stop||n.crack||(n.crack=n.match&&n.match.push((function(){h(n)})));h(n)}(e),!u.ask(e["@"],e)){if(l&&(l.u=+new Date),e.put)return void n(e);e.get&&o.on.get(e,c)}l&&(l.uc=+new Date),this.to.next(e),l&&(l.ua=+new Date),e.nts||e.NTS||(e.out=t,u.on("out",e),l&&(l.ue=+new Date))}}else this.to.next(e)}function n(n){if(n){var o=n._||"",r=o.root=((o.$=n.$||"")._||"").root;if(n["@"]&&o.faith&&!o.miss)return n.out=t,void r.on("out",n);o.latch=r.hatch,o.match=r.hatch=[];var s=n.put,f=o.DBG=n.DBG,l=+new Date;if(d=d||l,!s["#"]||!s["."]){f&&(f.p=l),o["#"]=n["#"],o.msg=n,o.all=0,o.stun=1;var p=Object.keys(s);console.STAT&&console.STAT(l,((f||o).pk=+new Date)-l,"put sort");var h,v,m,b,w,_,T,x=0;!function t(r){if(h!=x){if(h=x,!(m=p[x]))return console.STAT&&console.STAT(l,((f||o).pd=+new Date)-l,"put"),void a(o);(b=s[m])?(T=b._)?m!==T["#"]?_=g+y(m)+"soul not same.":(w=T[">"])||(_=g+y(m)+"no state."):_=g+y(m)+"no meta.":_=g+y(m)+"no node.",v=Object.keys(b||{})}if(_)return n.err=o.err=_,void a(o);var d,$=0;for(r=r||0;r++<9&&(d=v[$++]);)if("_"!==d){var j=b[d],S=w[d];if(i===S){_=g+y(d)+"on"+y(m)+"no state.";break}if(!c(j)){_=g+y(d)+"on"+y(m)+"bad "+typeof j+y(j);break}e(j,d,m,S,n),++k}(v=v.slice($)).length?u(t):(++x,v=null,t(r))}()}}}function e(t,n,o,i,r){var a,s=r._||"",u=s.root,c=u.graph,l=c[o]||p,h=f(l,n,1),d=l[n],g=s.DBG;(a=console.STAT)&&(c[o]&&d||(a.has=(a.has||0)+1));var y=b();if(i>y)return setTimeout((function(){e(t,n,o,i,r)}),(a=i-y)>m?m:a),void(console.STAT&&console.STAT((g||s).Hf=+new Date,a,"future"));if(!(i<h)&&(s.faith||i!==h||!(t===d||v(t)<=v(d))||s.miss)){s.stun++;var k=r["#"]+s.all++,w={toString:function(){return k},_:s};w.toJSON=w.toString,u.dup.track(w)["#"]=r["#"],g&&(g.ph=g.ph||+new Date),u.on("put",{"#":w,"@":r["@"],put:{"#":o,".":n,":":t,">":i},ok:r.ok,_:s})}}function r(t){var n;(n=(t._||"").DBG)&&(n.pa=+new Date,n.pm=n.pm||+new Date);var e,o=this.as,i=o.graph,r=t._,s=t.put,u=s["#"],c=s["."],f=s[":"],p=s[">"];t["#"],(e=r.msg)&&(e=e.put)&&(e=e[u])&&l(e,c,p,f,u),i[u]=l(i[u],c,p,f,u),(e=(o.next||"")[u])&&e.on("in",t),a(r),this.to.next(t)}function a(n,e){var o;if(!n.stop&&(n.err||!(0<--n.stun))&&(n.stop=1,o=n.root)){var i=n.match;i.end=1,i===o.hatch&&(!(i=n.latch)||i.end?delete o.hatch:o.hatch=i),n.hatch&&n.hatch(),setTimeout.each(n.match,(function(t){t&&t()})),!(e=n.msg)||n.err||e.err||(e.out=t,n.root.on("out",e),w())}}function h(t){t&&t.root&&(t.stun||t.acks!==t.all||t.root.on("in",{"@":t["#"],err:t.err,ok:t.err?i:t.ok||{"":1}}))}o.create=function(n){n.root=n.root||n,n.graph=n.graph||{},n.on=n.on||o.on,n.ask=n.ask||o.ask,n.dup=n.dup||o.dup();var e=n.$.opt(n.opt);return n.once||(n.on("in",t,n),n.on("out",t,n),n.on("put",r,n),o.on("create",n),n.on("create",n)),n.once=1,e},o.on.put=n;var d,g="Error: Invalid graph!",y=function(t){return" '"+(""+t).slice(0,9)+"...' "},v=JSON.stringify,m=2147483647,b=o.state,k=0,w=function(){k>999&&k/-(d-(d=+new Date))>1&&(o.window&&console.log("Warning: You're syncing 1K+ records a second, faster than DOM can update - consider limiting query."),w=function(){k=0})}}(),function(){function t(t,n){var e=+new Date,o=t._||{},r=o.DBG=t.DBG,a=t["#"],u=s(9),c=Object.keys(n||"").sort(),p=((n||"")._||"")["#"];c.length;var h=t.$._.root,d=n===h.graph[p];console.STAT&&console.STAT(e,((r||o).gk=+new Date)-e,"got keys"),n&&function t(){e=+new Date;for(var o,g,y,v=0,m={};v<9&&(o=c[v++]);)l(m,o,f(n,o),n[o],p);c=c.slice(v),(g={})[p]=m,m=g,d&&((y=function(){}).ram=y.faith=!0),g=c.length,console.STAT&&console.STAT(e,-(e-(e=+new Date)),"got copied some"),r&&(r.ga=+new Date),h.on("in",{"@":a,"#":u,put:m,"%":g?u=s(9):i,$:h.$,_:y,DBG:r,FOO:1}),console.STAT&&console.STAT(e,+new Date-e,"got in"),g&&setTimeout.turn(t)}(),n||h.on("in",{"@":t["#"]})}o.on.get=function(n,e){var o=e._,r=n.get,a=r["#"],s=o.graph[a],u=r["."],c=(o.next||(o.next={}))[a],p=(n._||{}).DBG=n.DBG;if(p&&(p.g=+new Date),!s)return o.on("get",n);if(u){if(("string"!=typeof u||i===s[u])&&!((c||"").next||"")[u])return void o.on("get",n);s=l({},u,f(s,u),s[u],a)}s&&t(n,s),o.on("get",n)},o.on.get.ack=t}(),o.chain.opt=function(t){t=t||{};var n=this._,e=t.peers||t;return Object.plain(t)||(t={}),Object.plain(n.opt)||(n.opt=t),"string"==typeof e&&(e=[e]),Object.plain(n.opt.peers)||(n.opt.peers={}),e instanceof Array&&(t.peers={},e.forEach((function(e){var o={};o.id=o.url=e,t.peers[e]=n.opt.peers[e]=n.opt.peers[e]||o}))),a(t,(function t(n){var e=this[n];this&&this.hasOwnProperty(n)||"string"==typeof e||Object.empty(e)?this[n]=e:(!e||e.constructor===Object||e instanceof Array)&&a(e,t)})),n.opt.from=t,o.on("opt",n),n.opt.uuid=n.opt.uuid||function(t){return o.state().toString(36).replace(".","")+String.random(t||12)},this};var i,r,a=function(t,n){Object.keys(t).forEach(n,t)},s=String.random,u=setTimeout.turn,c=o.valid,f=o.state.is,l=o.state.ify,p={};o.log=function(){return!o.log.off&&r.log.apply(r,arguments),[].slice.call(arguments).join(" ")},o.log.once=function(t,n,e){return(e=o.log.once)[t]=e[t]||0,e[t]++||o.log(n)},"undefined"!=typeof window&&((window.GUN=window.Gun=o).window=window);try{void 0!==e&&(e.exports=o)}catch(t){}t.exports=o,(o.window||{}).console=(o.window||{}).console||{log:function(){}},(r=console).only=function(t,n){return r.only.i&&t===r.only.i&&r.only.i++&&(r.log.apply(r,arguments)||n)},o.log.once("welcome","Hello wonderful person! :) Thanks for using GUN, please ask for help on http://chat.gun.eco if anything takes you longer than 5min to figure out!")}))(n,"./root"),n((function(t){n("./root").chain.back=function(t,n){if(-1===(t=t||1)||1/0===t)return this._.root.$;if(1===t)return(this._.back||this._).$;var i=this._;if("string"==typeof t&&(t=t.split(".")),t instanceof Array){for(var r=0,a=t.length,s=i;r<a;r++)s=(s||o)[t[r]];return e!==s?n?this:s:(s=i.back)?s.$.back(t,n):void 0}if("function"==typeof t){var u;for(s={back:i};(s=s.back)&&e===(u=t(s,n)););return u}return"number"==typeof t?(i.back||i).$.back(t-1):this};var e,o={}}))(n,"./back"),n((function(t){var e=n("./root");function o(t,n){if(n=n||this.as||t.$._,(!t.$$||this===e.on)&&t.put&&!n.soul){var o=t.put||"",i=o["="]||o[":"],r=n.root,a=r.$.get(o["#"]).get(o["."])._;if("string"==typeof(i=c(i))){if(!(a.echo||(a.echo={}))[n.id]||(r.pass||"")[n.id]){if(s=r.pass){if(s[i+n.id])return;s[i+n.id]=1}(a.echo||(a.echo={}))[n.id]=n,n.has&&(n.link=i);var s,u=r.$.get(a.link=i)._;(u.echo||(u.echo={}))[a.id]=a,((s=n.ask||"")[""]||n.lex)&&u.on("out",{get:{"#":i}}),setTimeout.each(Object.keys(s),(function(t,n){t&&(n=s[t])&&n.on("out",{get:{"#":i,".":t}})}),0,99)}}else this===e.on&&((a.echo||(a.echo={}))[n.id]=n)}}function i(t,n){var e,o,r=t.put||"",s=a!==r["="]?r["="]:r[":"],u=n.root;if(a===s){if(n.soul&&a!==n.put)return;if(o=(t.$$||t.$||"")._||"",t["@"]&&(a!==o.put||a!==n.put))return;return(e=n.link||t.linked)&&delete(u.$.get(e)._.echo||"")[n.id],n.has&&(n.link=null),n.put=a,void setTimeout.each(Object.keys(n.next||""),(function(t,o){(o=n.next[t])&&(e&&delete(u.$.get(e).get(t)._.echo||"")[o.id],o.on("in",{get:t,put:a,$:o.$}))}),0,99)}n.soul||t.$$||(e=c(s),o=t.$._||"",(e!==o.link&&(!n.has||o.link)||(u.pass||"")[n.id]&&"string"!=typeof e)&&(delete(o.echo||"")[n.id],i({get:n.get,put:a,$:t.$,linked:t.linked=t.linked||o.link},n)))}function r(t,n){var o=this.as,i=o.$._;i.root;var r=o.get||"",s=(t.put||"")[r["#"]]||"";if(!t.put||"string"==typeof r["."]&&a===s[r["."]]){if(a!==i.put)return;if(!i.soul&&!i.has)return;return i.ack=(i.ack||0)+1,void i.on("in",{get:i.get,put:i.put=a,$:i.$,"@":t["@"]})}(t._||{}).miss=1,e.on.put(t)}e.chain.chain=function(t){var n,o=this,i=o._,r=new(t||o).constructor(o),a=r._;return a.root=n=i.root,a.id=++n.once,a.back=o._,a.on=e.on,a.on("in",e.on.in,a),a.on("out",e.on.out,a),r},e.on.out=function(t){var n,e,o=this.as,i=o.back,s=o.root;if(t.$||(t.$=o.$),this.to.next(t),!o.err){if(n=t.get){if(s.pass&&(s.pass[o.id]=o),o.lex&&Object.keys(o.lex).forEach((function(t){e[t]=o.lex[t]}),e=t.get=t.get||{}),n["#"]||o.soul){if(n["#"]=n["#"]||o.soul,t["#"]||(t["#"]=u(9)),i=s.$.get(n["#"])._,n=n["."]){if(f(i.put,n)&&(e=i.ask&&i.ask[n],(i.ask||(i.ask={}))[n]=i.$.get(n)._,i.on("in",{get:n,put:{"#":i.soul,".":n,":":i.put[n],">":p(s.graph[i.soul],n)}}),e))return}else{if(e=i.ask&&i.ask[""],(i.ask||(i.ask={}))[""]=i,a!==i.put&&(i.on("in",i),e))return;t.$=i.$}return s.ask(r,t),s.on("in",t)}if(n["."])return o.get?(t={get:{".":o.get},$:o.$},(i.ask||(i.ask={}))[o.get]=t.$._,i.on("out",t)):(t={get:o.lex?t.get:{},$:o.$},i.on("out",t));if((o.ask||(o.ask={}))[""]=o,o.get)return n["."]=o.get,(i.ask||(i.ask={}))[o.get]=t.$._,i.on("out",t)}return i.on("out",t)}o.on("in",{put:o.put=a,$:o.$})},e.on.in=function(t,n){var e,r=(n=n||this.as).root,u=t.$||(t.$=n.$),f=(u||"")._||s,l=t.put||"",d=l["#"],g=l["."],y=a!==l["="]?l["="]:l[":"],v=l[">"]||-1/0;if(a!==t.put&&(a===l["#"]||a===l["."]||a===l[":"]&&a===l["="]||a===l[">"]))return c(l)?void n.on("in",{$:f.back.$,put:{"#":d=f.back.soul,".":g=f.has||f.get,"=":l,">":p(f.back.put,g)},via:t}):(d=((l||"")._||"")["#"])?(u=n.root.$.get(d),setTimeout.each(Object.keys(l).sort(),(function(e){"_"!=e&&a!==(v=p(l,e))&&n.on("in",{$:u,put:{"#":d,".":e,"=":l[e],">":v},VIA:t})}))):void console.log("chain not yet supported for",l,"...",t,n);(t.seen||"")[n.id]||((t.seen||(t.seen=function(){}))[n.id]=n,n!==f&&(Object.keys(t).forEach((function(n){l[n]=t[n]}),l={}),l.get=n.get||l.get,n.soul||n.has?f.soul&&(l.$=n.$,l.$$=l.$$||f.$):l.$$$=l.$$$||n.$,t=l),i(t,n),(n.soul||t.$$)&&v>=p(r.graph[d],g)&&((l=r.$.get(d)._).put=h(l.put,g,v,y,d)),!f.soul&&v>=p(r.graph[d],g)&&(e=(r.$.get(d)._.next||"")[g])&&(e.put=y,"string"==typeof(l=c(y))&&(e.put=r.$.get(l)._.put||y)),this.to&&this.to.next(t),n.any&&setTimeout.each(Object.keys(n.any),(function(e){(e=n.any[e])&&e(t)}),0,99),n.echo&&setTimeout.each(Object.keys(n.echo),(function(e){(e=n.echo[e])&&e.on("in",t)}),0,99),((t.$$||"")._||f).soul&&(e=n.next)&&(e=e[g])&&(l={},Object.keys(t).forEach((function(n){l[n]=t[n]})),l.$=(t.$$||t.$).get(l.get=g),delete l.$$,delete l.$$$,e.on("in",l)),o(t,n))},e.on.link=o,e.on.unlink=i;var a,s={},u=String.random,c=e.valid,f=function(t,n){return t&&Object.prototype.hasOwnProperty.call(t,n)},l=e.state,p=l.is,h=l.ify}))(n,"./chain"),n((function(t){var e=n("./root");function o(t){var n=this.at||this.on;if(!t||n.soul||n.has)return this.off();if(t=(t=(t=t.$||t)._||t).id){var e;if(n.map,(e=this.seen||(this.seen={}))[t])return!0;e[t]=!0}}e.chain.get=function(t,n,s){var u,c;if("string"==typeof t){if(0==t.length)return(u=this.chain())._.err={err:e.log("0 length key!",t)},n&&n.call(u,u._.err),u;(u=((l=this._).next||r)[t])||(u=t&&function(t,n){var e=n._,o=e.next,i=n.chain(),r=i._;o||(o=e.next={});o[r.get=t]=r,n===e.root.$?r.soul=t:(e.soul||e.has)&&(r.has=t);return r}(t,this)),u=u&&u.$}else{if("function"==typeof t){if(!0===n)return function(t,n,o,r){var a,s=t._,u=0;if(a=s.soul||s.link)return n(a,r,s);if(s.jam)return s.jam.push([n,r]);s.jam=[[n,r]],t.get((function(t,n){if(!(i===t.put&&!s.root.opt.super&&(a=Object.keys(s.root.opt.peers).length)&&++u<=a)){n.rid(t);var o,r=(r=t.$)&&r._||{},c=0;for(a=s.jam,delete s.jam;o=a[c++];){var f=o[0];o=o[1],f&&f(r.link||r.soul||e.valid(t.put)||((t.put||{})._||{})["#"],o,t,n)}}}),{out:{get:{".":!0}}})}(this,t,0,s),this;var f,l=(u=this)._,p=n||{},h=l.root;p.at=l,p.ok=t;var d={};function g(t,n,o){if(!g.stun&&(!(r=h.pass)||r[f])){var r,a=t.$._,s=(t.$$||"")._,u=(s||a).put,c=!a.has&&!a.soul,y={};if((c||i===u)&&(u=i===((r=t.put)||"")["="]?i===(r||"")[":"]?r:r[":"]:r["="]),"string"==typeof(r=e.valid(u))&&(u=i===(r=h.$.get(r)._.put)?p.not?i:u:r),!p.not||i!==u){if(i===p.stun){if((r=h.stun)&&r.on&&(l.$.back((function(t){if(r.on(""+t.id,y={}),(y.run||0)<g.id)return y})),!y.run&&r.on(""+a.id,y={}),!y.run&&s&&r.on(""+s.id,y={}),g.id>y.run&&(y.stun&&!y.stun.end||(y.stun=r.on("stun"),y.stun=y.stun&&y.stun.last),y.stun&&!y.stun.end)))return void((y.stun.add||(y.stun.add={}))[f]=function(){g(t,n,1)});if(i===u&&(o=0),(r=h.hatch)&&!r.end&&i===p.hatch&&!o){if(d[a.$._.id])return;return d[a.$._.id]=1,void r.push((function(){g(t,n,1)}))}d={}}if(h.pass){if(h.pass[f+a.id])return;h.pass[f+a.id]=1}p.on?p.ok.call(a.$,u,a.get,t,n||g):p.v2020?p.ok(t,n||g):(Object.keys(t).forEach((function(n){r[n]=t[n]}),r={}),(t=r).put=u,p.ok.call(p.as,t,n||g))}}}return g.at=l,(l.any||(l.any={}))[f=String.random(7)]=g,g.off=function(){g.stun=1,l.any&&delete l.any[f]},g.rid=o,g.id=p.run||++h.once,c=h.pass,(h.pass={})[f]=1,p.out=p.out||{get:{}},l.on("out",p.out),h.pass=c,u}if("number"==typeof t)return this.get(""+t,n,s);if("string"==typeof(c=a(t)))return this.get(c,n,s);(c=this.get.next)&&(u=c(this,t))}return u?(n&&"function"==typeof n&&u.get(n,s),u):((u=this.chain())._.err={err:e.log("Invalid get request!",t)},n&&n.call(u,u._.err),u)};var i,r={},a=e.valid}))(n,"./get"),n((function(t){var e=n("./root");function o(t,n){if(n){n=(n._||"").id||n;var o,i=t.root.stun||(t.root.stun={on:e.on}),r={};t.stun||(t.stun=i.on("stun",(function(){}))),(o=i.on(""+n))&&o.the.last.next(r),r.run>=t.run||i.on(""+n,(function(n){if(t.stun.end)return this.off(),void this.to.next(n);n.run=n.run||t.run,n.stun=n.stun||t.stun}))}}function i(t){if(t.err)i.end(t.stun,t.root);else if(!t.todo.length&&!t.end&&Object.empty(t.wait)){t.end=1;var n,o=t.$.back(-1)._,r=o.root,a=o.ask((function(n){r.on("ack",n),n.err&&!n.lack&&e.log(n),++s>(t.acks||0)&&this.off(),t.ack&&t.ack(n,this)}),t.opt),s=0,u=t.stun;(n=function(){u&&(i.end(u,r),setTimeout.each(Object.keys(u=u.add||""),(function(t){(t=u[t])&&t()})))}).hatch=n,t.ack&&!t.ok&&(t.ok=t.acks||9),t.via._.on("out",{put:t.out=t.graph,ok:t.ok&&{"@":t.ok+1},opt:t.opt,"#":a,_:n})}}e.chain.put=function(t,n,a){var f=this,l=f._,p=l.root;(a=a||{}).root=l.root,a.run||(a.run=p.once),o(a,l.id),a.ack=a.ack||n,a.via=a.via||f,a.data=a.data||t,a.soul||(a.soul=l.soul||"string"==typeof n&&n);var h=a.state=a.state||e.state();return"function"==typeof t?(t((function(t){a.data=t,f.put(r,r,a)})),f):a.soul?(a.$=p.$.get(a.soul),a.todo=[{it:a.data,ref:a.$}],a.turn=a.turn||s,a.ran=a.ran||i,function t(){var n,r,s,f,l,p=a.todo,d=p.pop(),g=d.it;if(d.ref&&d.ref._.id,o(a,d.ref),(f=d.todo)&&(g=g[r=f.pop()],f.length&&p.push(d)),r&&(p.path||(p.path=[])).push(r),!(n=u(g))&&!(l=e.is(g))){if(!Object.plain(g))return void i.err(a,"Invalid data: "+function(t,n){return t&&(n=t.constructor)&&n.name||typeof t}(g)+" at "+(a.via.back((function(t){t.get&&f.push(t.get)}),f=[])||f.join("."))+"."+(p.path||[]).join("."));for(var y=a.seen||(a.seen=[]),v=y.length;v--;)if(g===(f=y[v]).it){n=g=f.link;break}}if(r&&n)d.node=c(d.node,r,h,g);else{if(!a.seen)return void i.err(a,"Data at root of graph must be a node (an object).");a.seen.push(s={it:g,link:{},todo:l?[]:Object.keys(g).sort().reverse(),path:(p.path||[]).slice(),up:d}),d.node=c(d.node,r,h,s.link),!l&&s.todo.length&&p.push(s);var m=a.seen.length;function b(t,n){var e=s.link["#"];n&&(n.off(),n.rid(t));var i=e||t.soul||(f=(t.$$||t.$)._||"").soul||f.link||((f=f.put||"")._||"")["#"]||f["#"]||((f=t.put||"")&&t.$$?f["#"]:(f["="]||f[":"]||"")["#"]);!e&&o(a,t.$),i||d.link["#"]?(i||(i=[],(t.$$||t.$).back((function(t){if(f=t.soul||t.link)return i.push(f);i.push(t.get)})),i=i.reverse().join("/")),s.link["#"]=i,!l&&(((a.graph||(a.graph={}))[i]=s.node||(s.node={_:{}}))._["#"]=i),delete a.wait[m],s.wait&&setTimeout.each(s.wait,(function(t){t&&t()})),a.ran(a)):(d.wait||(d.wait=[])).push((function(){b(t,n)}))}(a.wait||(a.wait={}))[m]="",f=(s.ref=l?g:r?d.ref.get(r):d.ref)._,(f=g&&(g._||"")["#"]||f.soul||f.link)?b({soul:f}):s.ref.get(b,{run:a.run,v2020:1,out:{get:{".":" "}}})}if(!p.length)return a.ran(a);a.turn(t)}(),f):(function(t){var n,e=t.via._;t.via=t.via.back((function(e){if(e.soul||!e.get)return e.$;n=t.data,(t.data={})[e.get]=n})),t.via&&t.via._.soul||(t.via=e.root.$.get(((t.data||"")._||"")["#"]||e.$.back("opt.uuid")()));t.via.put(t.data,t.ack,t)}(a),f)},i.end=function(t,n){t.end=a,t.the.to===t&&t===t.the.last&&delete n.stun,t.off()},i.err=function(t,n){(t.ack||a).call(t,t.out={err:t.err=e.log(n)}),t.ran(t)};var r,a=function(){},s=setTimeout.turn,u=e.valid,c=e.state.ify}))(n,"./put"),n((function(t){var e=n("./root");n("./chain"),n("./back"),n("./put"),n("./get"),t.exports=e}))(n,"./index"),n((function(t){var e,o=n("./index");o.chain.on=function(t,n,e,o){var i,r=this,a=r._;if(a.root,"string"==typeof t)return n?(i=a.on(t,n,e||a,o),e&&e.$&&(e.subs||(e.subs=[])).push(i),r):a.on(t);var s=n;return(s=!0===s?{change:!0}:s||{}).not=1,s.on=1,r.get(t,s),r},o.chain.once=function(t,n){if(n=n||{},!t)return function(t,n,e){return o.log.once("valonce","Chainable val is experimental, its behavior and API may change moving forward. Please play with it and report bugs and ideas on how to improve it."),(e=t.chain())._.nix=t.once((function(t,n){e._.on("in",this._)})),e._.lex=t._.lex,e}(this);var i=this,r=i._,a=r.root;r.put;var s,u=String.random(7);return i.get((function(i,c,f,l){var p=this,h=p._,d=h.one||(h.one={});function g(y){h.has||h.soul||(h={put:i,get:c}),e===(s=h.put)&&(s=((f.$$||"")._||"").put),"string"!=typeof o.valid(s)||(s=a.$.get(s)._.put)!==e||y?l.stun||""!==d[u]&&(d[u]="",(r.soul||r.has)&&l.off(),t.call(p,s,h.get),clearTimeout(d[u])):d[u]=setTimeout((function(){g(1)}),n.wait||99)}l.stun||""!==d[u]&&(!0!==(s=o.valid(i))?"string"!=typeof s&&(clearTimeout((r.one||"")[u]),clearTimeout(d[u]),d[u]=setTimeout(g,n.wait||99)):g())}),{on:1}),i},o.chain.off=function(){var t,n=this._,e=n.back;if(e)return n.ack=0,(t=e.next)&&t[n.get]&&delete t[n.get],(t=e.any)&&(delete e.any,e.any={}),(t=e.ask)&&delete t[n.get],(t=e.put)&&delete t[n.get],(t=n.soul)&&delete e.root.graph[t],(t=n.map)&&Object.keys(t).forEach((function(n,o){(o=t[n]).link&&e.root.$.get(o.link).off()})),(t=n.next)&&Object.keys(t).forEach((function(n,e){t[n].$.off()})),n.on("off",{}),this}}))(n,"./on"),n((function(t){var e=n("./index"),o=e.chain.get.next;function i(t){this.to.next(t);var n,o=this.as,i=t.$._,r=t.put;(i.soul||t.$$)&&((n=o.lex)&&!String.match(t.get||(r||"")["."],n["."]||n["#"]||n)||e.on.link(t,o))}e.chain.get.next=function(t,n){var e;return Object.plain(n)?(e=((e=n["#"])||"")["="]||e)?t.get(e):((e=t.chain()._).lex=n,t.on("in",(function(t){String.match(t.get||(t.put||"")["."],n["."]||n["#"]||n)&&e.on("in",t),this.to.next(t)})),e.$):(o||a)(t,n)},e.chain.map=function(t,n,o){var s,u,c=this,f=c._;return Object.plain(t)&&(s=t["."]?t:{".":t},t=r),t?(e.log.once("mapfn","Map functions are experimental, their behavior and API may change moving forward. Please play with it and report bugs and ideas on how to improve it."),u=c.chain(),c.map().on((function(n,o,i,s){var c=(t||a).call(this,n,o,i,s);if(r!==c){if(n===c)return u._.on("in",i);if(e.is(c))return u._.on("in",c._);var f={};Object.keys(i.put).forEach((function(t){f[t]=i.put[t]}),f),f["="]=c,u._.on("in",{get:o,put:f})}})),u):((u=f.each)||((f.each=u=c.chain())._.lex=s||u._.lex||f.lex,u._.nix=c.back("nix"),c.on("in",i,u._)),u)};var r,a=function(){}}))(n,"./map"),n((function(t){var e=n("./index");e.chain.set=function(t,n,o){var i,r,a=this,s=a.back(-1);return n=n||function(){},(o=o||{}).item=o.item||t,(i=((t||"")._||"")["#"])&&((t={})["#"]=i),"string"==typeof(r=e.valid(t))?a.get(i=r).put(t,n,o):e.is(t)?(a.put((function(o){t.get((function(t,i,s){if(!t)return n.call(a,{err:e.log('Only a node can be linked! Not "'+s.put+'"!')});(r={})[t]={"#":t},o(r)}),!0)})),t):(Object.plain(t)&&(t=s.get(i=a.back("opt.uuid")()).put(t)),a.get(i||s.back("opt.uuid")(7)).put(t,n,o))}}))(n,"./set"),n((function(t){n("./shim");var e,o=function(){},i=JSON.parseAsync||function(t,n,e){var o=+new Date;try{n(undefined,JSON.parse(t,e),r.sucks(+new Date-o))}catch(t){n(t)}},r=JSON.stringifyAsync||function(t,n,e,o){var i=+new Date;try{n(undefined,JSON.stringify(t,e,o),r.sucks(+new Date-i))}catch(t){n(t)}};r.sucks=function(t){t>99&&(console.log("Warning: JSON blocking CPU detected. Add `gun/lib/yson.js` to fix."),r.sucks=o)};try{t.exports=function(t){var n=function(){},o=t.opt||{};o.log=o.log||console.log,o.gap=o.gap||o.wait||0,o.max=o.max||.3*(o.memory?999*o.memory*999:3e8),o.pack=o.pack||.01*o.max*.01,o.puff=o.puff||9;var a=setTimeout.turn||setTimeout,s=t.dup,u=s.check,c=s.track,f=n.hear=function(t,e){if(t){if(o.max<=t.length)return n.say({dam:"!",err:"Message too big!"},e);n===this&&(f.d+=t.length||0,++f.c);var r,s=e.SH=+new Date,u=t[0];return"["===u?(i(t,(function(t,i){if(t||!i)return n.say({dam:"!",err:"DAM JSON parse error."},e);console.STAT&&console.STAT(+new Date,i.length,"# on hear batch");var r=o.puff;!function t(){for(var o,s=+new Date,u=0;u<r&&(o=i[u++]);)n.hear(o,e);i=i.slice(u),console.STAT&&console.STAT(s,+new Date-s,"hear loop"),l(e),i.length&&a(t,0)}()})),void(t="")):"{"===u||(t["#"]||Object.plain(t))&&(r=t)?r?f.one(r,e,s):void i(t,(function(t,o){if(t||!o)return n.say({dam:"!",err:"DAM JSON parse error."},e);f.one(o,e,s)})):void 0}};function l(t){var n=t.batch,e="string"==typeof n;if(e&&(n+="]"),t.batch=t.tail=null,n&&!(e?3>n.length:!n.length)){if(!e)try{n=1===n.length?n[0]:JSON.stringify(n)}catch(t){return o.log("DAM JSON stringify error",t)}n&&p(n,t)}}function p(t,e){try{var o=e.wire;e.say?e.say(t):o.send&&o.send(t),n.say.d+=t.length||0,++n.say.c}catch(n){(e.queue=e.queue||[]).push(t)}}return f.one=function(e,o,i){var r,a,f,l,p;if(e.DBG&&(e.DBG=p={DBG:e.DBG}),p&&(p.h=i),p&&(p.hp=+new Date),(r=e["#"])||(r=e["#"]=String.random(9)),!((f=u(r))||(a=e["##"])&&(f=e["@"]||e.get&&r)&&s.check(l=f+a))){if((e._=function(){}).via=n.leap=o,(f=e["><"])&&"string"==typeof f&&f.slice(0,99).split(",").forEach((function(t){this[t]=1}),e._.yo={}),f=e.dam)return(f=n.hear[f])&&f(e,o,t),void c(r);(f=e.ok)&&(e._.near=f["/"]),i=+new Date,p&&(p.is=i),o.SI=r,c.ed=function(t){r===t&&(c.ed=0,(t=s.s[r])&&(t.via=o,e.get&&(t.it=e)))},t.on("in",n.last=e),p&&(p.hd=+new Date),console.STAT&&console.STAT(i,+new Date-i,e.get?"msg get":e.put?"msg put":"msg"),c(r),l&&c(l),n.leap=n.last=null}},f.c=f.d=0,function(){var t,i=0;function f(t,n){var e;return n instanceof Object?(Object.keys(n).sort().forEach(h,{to:e={},on:n}),e):n}function h(t){this.to[t]=this.on[t]}n.hash=function(t,e){var o,i,s,u=+new Date;r(t.put,(function r(c,f){var l=(i||(i=s=f||"")).slice(0,32768);o=String.hash(l,o),(i=i.slice(32768))?a(r,0):(console.STAT&&console.STAT(u,+new Date-u,"say json+hash"),t._.$put=s,t["##"]=o,n.say(t,e),delete t._.$put)}),f)},(n.say=function(r,u){var f;if((f=this)&&(f=f.to)&&f.next&&f.next(r),!r)return!1;var h,d,g,y=r["@"],v=r._||(r._=function(){}),m=r.DBG,b=+new Date;if(v.y=v.y||b,u||m&&(m.y=b),(h=r["#"])||(h=r["#"]=String.random(9)),!t&&c(h),(d=r["##"])||e===r.put||v.via||!y){if(!u&&y&&(u=(f=s.s[y])&&(f.via||(f=f.it)&&(f=f._)&&f.via)||(f=n.last)&&y===f["#"]&&n.leap),!u&&y){if(s.s[y])return;return console.STAT&&console.STAT(+new Date,++i,"total no peer to ack to"),!1}if(y&&!r.put&&!d&&((s.s[y]||"").it||"")["##"])return!1;if(!u&&n.way)return n.way(r);if(m&&(m.yh=+new Date),g=v.raw){if(m&&(m.yr=+new Date),!u||!u.id){if(!Object.plain(u||o.peers))return!1;b=+new Date,o.puff;var k=o.peers,w=Object.keys(u||o.peers||{});return console.STAT&&console.STAT(b,+new Date-b,"peer keys"),void function e(){var o=+new Date;t=1;var i=v.raw;v.raw=g;for(var s,f=0;f<9&&(s=(w||"")[f++]);)(s=k[s]||(u||"")[s])&&n.say(r,s);v.raw=i,t=0,w=w.slice(f),console.STAT&&console.STAT(o,+new Date-o,"say loop"),w.length&&(a(e,0),y&&c(y))}()}if(!u.wire&&n.wire&&n.wire(u),h!==u.last){if(u.last=h,u===v.via)return!1;if((f=v.yo)&&(f[u.url]||f[u.pid]||f[u.id]))return!1;if(console.STAT&&console.STAT(b,((m||v).yp=+new Date)-(v.y||b),"say prep"),!t&&y&&c(y),u.batch){if(u.tail=(f=u.tail||0)+g.length,u.tail<=o.pack)return void(u.batch+=(f?",":"")+g);l(u)}u.batch="[";var _=+new Date;setTimeout((function(){console.STAT&&console.STAT(_,+new Date-_,"0ms TO"),l(u)}),o.gap),p(g,u),console.STAT&&y===u.SI&&console.STAT(b,+new Date-u.SH,"say ack")}}else n.raw(r,u)}else n.hash(r,u)}).c=n.say.d=0,n.raw=function(t,i){if(!t)return"";var a,c,f=t._||{};if(c=f.raw)return c;if("string"==typeof t)return t;var l=t["##"],p=t["@"];if(l&&p){if(!f.via&&u(p+l))return!1;if(c=(s.s[p]||"").it){if(l===c["##"])return!1;c["##"]||(c["##"]=l)}}if(!t.dam&&!t["@"]){var h=0,d=[];for(var g in c=o.peers){var y=c[g];if(d.push(y.url||y.pid||y.id),++h>6)break}h>1&&(t["><"]=d.join())}if(t.put&&(c=t.ok)&&(t.ok={"@":(c["@"]||1)-1,"/":c["/"]==t._.near?n.near:c["/"]}),a=f.$put)return c={},Object.keys(t).forEach((function(n){c[n]=t[n]})),c.put=":])([:",void r(c,(function(t,n){if(!t){var o=+new Date;c=n.indexOf('"put":":])([:"'),v(e,n=n.slice(0,c+6)+a+n.slice(c+14)),console.STAT&&console.STAT(o,+new Date-o,"say slice")}}));function v(e,o){e||(f.raw=o,n.say(t,i))}r(t,v)}}(),n.near=0,n.hi=function(e){var i;e.wire?(e.id?o.peers[e.url||e.id]=e:(i=e.id=e.id||e.url||String.random(9),n.say({dam:"?",pid:t.opt.pid},o.peers[i]=e),delete s.s[e.last]),e.met||(n.near++,e.met=+new Date,t.on("hi",e)),i=e.queue,e.queue=[],setTimeout.each(i||[],(function(t){p(t,e)}),0,9)):n.wire(e.length&&{url:e,id:e}||e)},n.bye=function(e){e.met&&--n.near,delete e.met,t.on("bye",e);var o=+new Date;o-=e.met||o,n.bye.time=((n.bye.time||o)+o)/2},n.hear["!"]=function(t,n){o.log("Error:",t.err)},n.hear["?"]=function(t,e){t.pid&&(e.pid||(e.pid=t.pid),t["@"])||(n.say({dam:"?",pid:o.pid,"@":t["#"]},e),delete s.s[e.last])},n.hear.mob=function(t,e){if(t.peers){var o=Object.keys(t.peers),i=o[Math.random()*o.length|0];i&&(n.bye(e),n.hi(i))}},t.on("create",(function(t){t.opt.pid=t.opt.pid||String.random(9),this.to.next(t),t.on("out",n.say)})),t.on("bye",(function(t,n){t=o.peers[t.id||t]||t,this.to.next(t),t.bye?t.bye():(n=t.wire)&&n.close&&n.close(),delete o.peers[t.id],t.wire=null})),t.on("bye",(function(t,e){this.to.next(t),(e=console.STAT)&&(e.peers=n.near),(e=t.url)&&setTimeout((function(){}),o.lack||9e3)})),t.on("hi",(function(e,i){if(this.to.next(e),(i=console.STAT)&&(i.peers=n.near),!o.super){var r=Object.keys(t.next||"");r.length>9999&&!console.SUBS&&console.log(console.SUBS="Warning: You have more than 10K live GETs, which might use more bandwidth than your screen can show - consider `.off()`."),setTimeout.each(r,(function(i){var r=t.next[i];o.super||(r.ask||"")[""]?n.say({get:{"#":i}},e):setTimeout.each(Object.keys(r.ask||""),(function(o){o&&n.say({"##":String.hash((t.graph[i]||"")[o]),get:{"#":i,".":o}},e)}))}))}})),n}}catch(t){}}))(n,"./mesh"),n((function(t){var e=n("./index");e.Mesh=n("./mesh"),e.on("opt",(function(t){if(this.to.next(t),!t.once){var n=t.opt;if(!1!==n.WebSocket){var o=e.window||{},i=n.WebSocket||o.WebSocket||o.webkitWebSocket||o.mozWebSocket;if(i){n.WebSocket=i;var r=n.mesh=n.mesh||e.Mesh(t);r.wire||n.wire,r.wire=n.wire=u,setTimeout((function(){!n.super&&t.on("out",{dam:"hi"})}),1);var a=1998,s=""+undefined!=typeof document&&document}}}function u(t){try{if(!t||!t.url)return o&&o(t);var e=t.url.replace(/^http/,"ws"),o=t.wire=new n.WebSocket(e);return o.onclose=function(){c(t),n.mesh.bye(t)},o.onerror=function(n){c(t)},o.onopen=function(){n.mesh.hi(t)},o.onmessage=function(e){e&&n.mesh.hear(e.data||e,t)},o}catch(e){n.mesh.bye(t)}}function c(t){clearTimeout(t.defer),n.peers[t.url]&&(s&&t.retry<=0||(t.retry=(t.retry||n.retry+1||60)-(-t.tried+(t.tried=+new Date)<4*a?1:0),t.defer=setTimeout((function n(){if(s&&s.hidden)return setTimeout(n,a);u(t)}),a)))}}))}))(n,"./websocket"),n((function(t){if("undefined"!=typeof Gun){var n;try{n=(Gun.window||function(){}).localStorage}catch(t){}n||(Gun.log("Warning: No localStorage exists to persist data to!"),n={setItem:function(t,n){this[t]=n},removeItem:function(t){delete this[t]},getItem:function(t){return this[t]}});var e=JSON.stringifyAsync||function(t,n,e,o){try{n(undefined,JSON.stringify(t,e,o))}catch(t){n(t)}};Gun.on("create",(function t(o){this.to.next(o);var i=o.opt;o.graph;var r,a,s,u,c=[];if(!1!==i.localStorage){i.prefix=i.file||"gun/";try{r=t[i.prefix]=t[i.prefix]||JSON.parse(s=n.getItem(i.prefix))||{}}catch(n){r=t[i.prefix]={}}s=(s||"").length,o.on("get",(function(t){this.to.next(t);var n,e,o,i=t.get;i&&(n=i["#"])&&((e=r[n]||undefined)&&(o=i["."])&&!Object.plain(o)&&(e=Gun.state.ify({},o,Gun.state.is(e,o),e[o],n)),Gun.on.get.ack(t,e))})),o.on("put",(function(t){this.to.next(t);var n=t.put,e=n["#"],i=n["."],l=t["#"],p=t.ok||"";r[e]=Gun.state.ify(r[e],i,n[">"],n[":"],e),u&&s>4999880?o.on("in",{"@":l,err:"localStorage max!"}):(t["@"]||t._.via&&!(Math.random()<p["@"]/p["/"])||c.push(l),a||(a=setTimeout(f,9+s/333)))}))}function f(){if(c.length||!((setTimeout.turn||"").s||"").length){var t=c;clearTimeout(a),a=!1,c=[],e(r,(function(e,a){try{!e&&n.setItem(i.prefix,a)}catch(t){e=u=t||"localStorage failure"}e&&(Gun.log(e+" Consider using GUN's IndexedDB plugin for RAD for more storage space, https://gun.eco/docs/RAD#install"),o.on("localStorage:error",{err:e,get:i.prefix,put:r})),s=a.length,setTimeout.each(t,(function(t){o.on("in",{"@":t,err:e,ok:0})}),0,99)}))}else setTimeout(f,99)}}))}}))(n,"./localStorage")}(),function(){if(""+_!=typeof Gun){var t=function(t){console.warn("Warning! Deprecated internal utility will break in next version:",t)},n=Gun;n.fn=n.fn||{is:function(n){return t("fn"),!!n&&"function"==typeof n}},n.bi=n.bi||{is:function(n){return t("bi"),n instanceof Boolean||"boolean"==typeof n}},n.num=n.num||{is:function(n){return t("num"),!o(n)&&(n-parseFloat(n)+1>=0||1/0===n||-1/0===n)}},n.text=n.text||{is:function(n){return t("text"),"string"==typeof n}},n.text.ify=n.text.ify||function(e){return t("text.ify"),n.text.is(e)?e:"undefined"!=typeof JSON?JSON.stringify(e):e&&e.toString?e.toString():e},n.text.random=n.text.random||function(n,e){t("text.random");var o="";for(n=n||24,e=e||"0123456789ABCDEFGHIJKLMNOPQRSTUVWXZabcdefghijklmnopqrstuvwxyz";n>0;)o+=e.charAt(Math.floor(Math.random()*e.length)),n--;return o},n.text.match=n.text.match||function(n,e){var o,i;return t("text.match"),"string"==typeof n&&("string"==typeof e&&(e={"=":e}),n===(o=(e=e||{})["="]||e["*"]||e[">"]||e["<"])||i===e["="]&&(o=e["*"]||e[">"]||e["<"],n.slice(0,(o||"").length)===o||i===e["*"]&&(i!==e[">"]&&i!==e["<"]?n>=e[">"]&&n<=e["<"]:i!==e[">"]&&n>=e[">"]||i!==e["<"]&&n<=e["<"])))},n.text.hash=n.text.hash||function(n,e){if(t("text.hash"),"string"==typeof n){if(e=e||0,!n.length)return e;for(var o=0,i=n.length;o<i;++o)e=(e<<5)-e+n.charCodeAt(o),e|=0;return e}},n.list=n.list||{is:function(n){return t("list"),n instanceof Array}},n.list.slit=n.list.slit||Array.prototype.slice,n.list.sort=n.list.sort||function(n){return t("list.sort"),function(t,e){return t&&e?(t=t[n])<(e=e[n])?-1:t>e?1:0:0}},n.list.map=n.list.map||function(n,e,o){return t("list.map"),a(n,e,o)},n.list.index=1,n.obj=n.boj||{is:function(n){return t("obj"),!!n&&(n instanceof Object&&n.constructor===Object||"Object"===Object.prototype.toString.call(n).match(/^\[object (\w+)\]$/)[1])}},n.obj.put=n.obj.put||function(n,e,o){return t("obj.put"),(n||{})[e]=o,n},n.obj.has=n.obj.has||function(n,e){return t("obj.has"),n&&Object.prototype.hasOwnProperty.call(n,e)},n.obj.del=n.obj.del||function(n,e){if(t("obj.del"),n)return n[e]=null,delete n[e],n},n.obj.as=n.obj.as||function(n,e,o,i){return t("obj.as"),n[e]=n[e]||(i===o?{}:o)},n.obj.ify=n.obj.ify||function(n){if(t("obj.ify"),i(n))return n;try{n=JSON.parse(n)}catch(t){n={}}return n},function(){function e(t,n){r(this,n)&&undefined!==this[n]||(this[n]=t)}n.obj.to=n.obj.to||function(n,o){return t("obj.to"),a(n,e,o=o||{}),o}}(),n.obj.copy=n.obj.copy||function(n){return t("obj.copy"),n?JSON.parse(JSON.stringify(n)):n},function(){function e(t,n){var e=this.n;if(!e||!(n===e||i(e)&&r(e,n)))return undefined!==n||void 0}n.obj.empty=n.obj.empty||function(n,o){return t("obj.empty"),!n||!a(n,e,{n:o})}}(),function(){function e(t,n){if(2===arguments.length)return e.r=e.r||{},void(e.r[t]=n);e.r=e.r||[],e.r.push(t)}var a,s=Object.keys;Object.keys=Object.keys||function(t){return a(t,(function(t,n,e){e(n)}))},n.obj.map=a=n.obj.map||function(a,u,c){t("obj.map");var f,l,p,h,d,g=0,y="function"==typeof u;if(e.r=f,s&&i(a)&&(h=s(a),d=!0),c=c||{},o(a)||h)for(l=(h||a).length;g<l;g++){var v=g+n.list.index;if(y){if((p=d?u.call(c,a[h[g]],h[g],e):u.call(c,a[g],v,e))!==f)return p}else if(u===a[d?h[g]:g])return h?h[g]:v}else for(g in a)if(y){if(r(a,g)&&(p=c?u.call(c,a[g],g,e):u(a[g],g,e))!==f)return p}else if(u===a[g])return g;return y?e.r:n.list.index?0:-1}}(),n.time=n.time||{},n.time.is=n.time.is||function(n){return t("time"),n?n instanceof Date:+(new Date).getTime()};var e=n.fn.is,o=n.list.is,i=(w=n.obj).is,r=w.has,a=w.map,s={is:function(n){return t("val.is"),n!==_&&(null===n||n!==1/0&&(!!(l(n)||c(n)||f(n))||(s.link.is(n)||!1)))}};s.link=s.rel={_:"#"},function(){function n(t,n){var e=this;return e.id?e.id=!1:n==u&&l(t)?void(e.id=t):e.id=!1}s.link.is=function(e){if(t("val.link.is"),e&&e[u]&&!e._&&i(e)){var o={};if(a(e,n,o),o.id)return o.id}return!1}}(),s.link.ify=function(n){return t("val.link.ify"),p({},u,n)},n.obj.has._=".";var u=s.link._,c=n.bi.is,f=n.num.is,l=n.text.is,p=(i=(w=n.obj).is,w.put);a=w.map;n.val=n.val||s;var h={_:"_",soul:function(n,e){return t("node.soul"),n&&n._&&n._[e||y]}};h.soul.ify=function(n,e){return t("node.soul.ify"),e="string"==typeof e?{soul:e}:e||{},(n=n||{})._=n._||{},n._[y]=e.soul||n._[y]||g(),n},h.soul._=s.link._,function(){function n(t,n){if(n!==h._)return!s.is(t)||void(this.cb&&this.cb.call(this.as,t,n,this.n,this.s))}h.is=function(e,o,r){var s;return t("node.is"),!!i(e)&&(!!(s=h.soul(e))&&!a(e,n,{as:r,cb:o,s:s,n:e}))}}(),function(){function n(t,n){var e,o=this.o;o.map?undefined===(e=o.map.call(this.as,t,""+n,o.node))?d(o.node,n):o.node&&(o.node[n]=e):s.is(t)&&(o.node[n]=t)}h.ify=function(e,o,i){return t("node.ify"),o?"string"==typeof o?o={soul:o}:"function"==typeof o&&(o={map:o}):o={},o.map&&(o.node=o.map.call(i,e,_,o.node||{})),(o.node=h.soul.ify(o.node||{},o))&&a(e,n,{o:o,as:i}),o.node}}();i=(w=n.obj).is;var d=w.del,g=(a=w.map,n.text.random),y=h.soul._;n.node=n.node||h;var v=n.state;v.lex=function(){return t("state.lex"),v().toString(36).replace(".","")},v.to=function(n,e,o){t("state.to");var r=(n||{})[e];return i(r)&&(r=m(r)),v.ify(o,e,v.is(n,e),r,h.soul(n))},function(){function n(t,n){b!==n&&v.ify(this.o,n,this.s)}v.map=function(o,s,u){var c;t("state.map");var l=i(l=o||s)?l:null;return o=e(o=o||s)?o:null,l&&!o?(s=f(s)?s:v(),l[b]=l[b]||{},a(l,n,{o:l,s:s}),l):(u=u||i(s)?s:c,s=f(s)?s:v(),function(t,e,i,a){if(!o)return n.call({o:i,s:s},t,e),t;o.call(u||this||{},t,e,i,a),r(i,e)&&c===i[e]||n.call({o:i,s:s},t,e)})}}(),(w=n.obj).as;r=w.has,i=w.is,a=w.map;var m=w.copy,b=(f=n.num.is,e=n.fn.is,h._),k={};!function(){function n(t,n){if(!t||n!==h.soul(t)||!h.is(t,this.fn,this.as))return!0;this.cb&&(e.n=t,e.as=this.as,this.cb.call(e.as,t,n,e))}function e(t){t&&h.is(e.n,t,e.as)}k.is=function(e,o,r,s){return t("graph.is"),!(!e||!i(e)||T(e))&&!a(e,n,{cb:o,fn:r,as:s})}}(),function(){function e(t,n){var e;return(e=function(t,n){var e,o=t.seen,i=o.length;for(;i--;)if(e=o[i],n.obj===e.obj)return e;o.push(n)}(t,n))?e:(n.env=t,n.soul=a,h.ify(n.obj,o,n)&&(n.link=n.link||s.link.ify(h.soul(n.node)),n.obj!==t.shell&&(t.graph[s.link.is(n.link)]=n.node)),n)}function o(t,n,o){var i,a,c=this,f=c.env;if(h._===n&&r(t,s.link._))return o._;if(i=u(t,n,o,c,f)){if(n||(c.node=c.node||o||{},r(t,h._)&&h.soul(t)&&(c.node._=m(t._)),c.node=h.soul.ify(c.node,s.link.is(c.link)),c.link=c.link||s.link.ify(h.soul(c.node))),(a=f.map)&&(a.call(f.as||{},t,n,o,c),r(o,n))){if(t=o[n],_===t)return void d(o,n);if(!(i=u(t,n,o,c,f)))return}if(!n)return c.node;if(!0===i)return t;if((a=e(f,{obj:t,path:c.path.concat(n)})).node)return a.link}}function a(t){var n=this,e=s.link.is(n.link),o=n.env.graph;n.link=n.link||s.link.ify(t),n.link[s.link._]=t,n.node&&n.node[h._]&&(n.node[h._][s.link._]=t),r(o,e)&&(o[t]=o[e],d(o,e))}function u(t,e,o,r,a){var c;return!!s.is(t)||(i(t)?1:(c=a.invalid)?u(t=c.call(a.as||{},t,e,o),e,o,r,a):(a.err="Invalid value at '"+r.path.concat(e).join(".")+"'!",void(n.list.is(t)&&(a.err+=" Use `.set(item)` instead of an Array."))))}k.ify=function(n,o,i){t("graph.ify");var r={path:[],obj:n};return o?"string"==typeof o?o={soul:o}:"function"==typeof o&&(o.map=o):o={},"string"==typeof i&&(o.soul=o.soul||i,i=_),o.soul&&(r.link=s.link.ify(o.soul)),o.shell=(i||{}).shell,o.graph=o.graph||{},o.seen=o.seen||[],o.as=o.as||i,e(o,r),o.root=r.node,o.graph}}(),k.node=function(n){t("graph.node");var e=h.soul(n);if(e)return p({},e,n)},function(){function n(t,n){var e,o;if(h._!==n)(e=s.link.is(t))?(o=this.opt.seen[e])?this.obj[n]=o:this.obj[n]=this.opt.seen[e]=k.to(this.graph,e,this.opt):this.obj[n]=t;else{if(T(t,s.link._))return;this.obj[n]=m(t)}}k.to=function(e,o,i){if(t("graph.to"),e){var r={};return i=i||{seen:{}},a(e[o],n,{obj:r,graph:e,opt:i}),r}}}();e=n.fn.is,i=(w=n.obj).is,d=w.del,r=w.has;var w,_,T=w.empty;p=w.put,a=w.map,m=w.copy;n.graph=n.graph||k}}()}(a)),a.exports}return function(o){var i,r;i="undefined"!=typeof self?self:e,r=function(t,n,e){console.log("Factory del plugin Gun-Eth chiamata");const o="Accesso a GunDB con Ethereum";let i,r=[{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes",name:"nodeId",type:"bytes"},{indexed:!1,internalType:"bytes32",name:"contentHash",type:"bytes32"},{indexed:!1,internalType:"address",name:"updater",type:"address"}],name:"DataUpdated",type:"event"},{inputs:[{internalType:"bytes[]",name:"nodeIds",type:"bytes[]"},{internalType:"bytes32[]",name:"contentHashes",type:"bytes32[]"}],name:"batchUpdateData",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes",name:"nodeId",type:"bytes"}],name:"getLatestRecord",outputs:[{internalType:"bytes32",name:"",type:"bytes32"},{internalType:"uint256",name:"",type:"uint256"},{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes",name:"",type:"bytes"}],name:"nodeData",outputs:[{internalType:"bytes32",name:"contentHash",type:"bytes32"},{internalType:"uint256",name:"timestamp",type:"uint256"},{internalType:"address",name:"updater",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes",name:"nodeId",type:"bytes"},{internalType:"bytes32",name:"contentHash",type:"bytes32"}],name:"updateData",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes",name:"nodeId",type:"bytes"},{internalType:"bytes32",name:"contentHash",type:"bytes32"}],name:"verifyData",outputs:[{internalType:"bool",name:"",type:"bool"},{internalType:"uint256",name:"",type:"uint256"},{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"}],a="",s="";const u=async()=>{if(a&&s){const t=new e.JsonRpcProvider(a);return new e.Wallet(s,t)}if("undefined"!=typeof window&&void 0!==window.ethereum)return await window.ethereum.request({method:"eth_requestAccounts"}),new e.BrowserProvider(window.ethereum).getSigner();throw new Error("No valid Ethereum provider found")};t.chain.setStandaloneConfig=function(t,n){return a=t,s=n,console.log("Standalone configuration set"),this},t.chain.verifySignature=async function(t,n){try{return e.verifyMessage(t,n)}catch(t){return console.error("Error verifying signature:",t),null}},t.chain.generatePassword=function(t){try{const n=e.hexlify(t),o=e.keccak256(n);return console.log("Generated password:",o),o}catch(t){return console.error("Error generating password:",t),null}},t.chain.createSignature=async function(t){try{if(t!==o)throw new Error("Invalid message, valid message is: "+o);const n=await u(),e=await n.signMessage(t);return console.log("Signature created:",e),e}catch(t){return console.error("Error creating signature:",t),null}},t.chain.createAndStoreEncryptedPair=async function(t,e){try{const o=this,i=await n.pair(),r=await n.encrypt(JSON.stringify(i),e);await o.get("gun-eth").get("users").get(t).put({encryptedPair:r}),console.log("Encrypted pair stored for:",t)}catch(t){console.error("Error creating and storing encrypted pair:",t)}},t.chain.getAndDecryptPair=async function(t,e){try{const o=this,i=await o.get("gun-eth").get("users").get(t).get("encryptedPair").then();if(!i)throw new Error("No encrypted data found for this address");const r=await n.decrypt(i,e);return console.log(r),r}catch(t){return console.error("Error retrieving and decrypting pair:",t),null}},t.chain.shine=function(n,o,a,s){if(console.log("SHINE plugin called with:",{chain:n,nodeId:o,data:a}),!(void 0===e?(console.error("Ethers.js non è disponibile. Assicurati che sia caricato prima di questo script."),0):(console.log("Ethers version:",e.version),1)))return s&&s({err:"Ethers.js non è disponibile"}),this;if("function"!=typeof s)return console.error("Callback must be a function"),this;const c=this;if("optimismSepolia"!==n)throw new Error("Chain not supported");if(i="0x43D838b683F772F08f321E5FA265ad3e333BE9C2",o&&!a)c.get(o).once((async t=>{if(!t)return void(s&&s({err:"Node not found in GunDB"}));console.log("existingData",t);const n=t._contentHash;if(console.log("contentHash",n),n)try{const{isValid:t,timestamp:a,updater:c}=await(async(t,n)=>{console.log("Verifying on chain:",{nodeId:t,contentHash:n});const o=await u(),a=new e.Contract(i,r,o),[s,c,f]=await a.verifyData(e.toUtf8Bytes(t),n);return console.log("Verification result:",{isValid:s,timestamp:c,updater:f}),{isValid:s,timestamp:c,updater:f}})(o,n),f=await(async t=>{const n=await u(),o=new e.Contract(i,r,n),[a,s,c]=await o.getLatestRecord(e.toUtf8Bytes(t));return console.log("Latest record from blockchain:",{nodeId:t,contentHash:a,timestamp:s,updater:c}),{contentHash:a,timestamp:s,updater:c}})(o);t?s&&s({ok:!0,message:"Data verified on blockchain",timestamp:a,updater:c,latestRecord:f}):s&&s({ok:!1,message:"Data not verified on blockchain",latestRecord:f})}catch(t){s&&s({err:t.message})}else s&&s({err:"No content hash found for this node"})}));else if(a&&!o){const n=t.text.random(),o=JSON.stringify(a),f=e.keccak256(e.toUtf8Bytes(o));c.get(n).put({...a,_contentHash:f},(async t=>{if(console.log("ack",t),t.err)s&&s({err:"Error saving data to GunDB"});else try{const t=await(async(t,n)=>{console.log("Writing on chain:",{nodeId:t,contentHash:n});const o=await u(),a=new e.Contract(i,r,o),s=await a.updateData(e.toUtf8Bytes(t),n);console.log("Transaction sent:",s.hash);const c=await s.wait();return console.log("Transaction confirmed:",c),s})(n,f);s&&s({ok:!0,message:"Data written to GunDB and blockchain",nodeId:n,txHash:t.hash})}catch(t){s&&s({err:t.message})}}))}else s&&s({err:"Invalid input. Provide either nodeId or data, not both."});return c},t.chain.gunToEthAccount=function(t){const n="0x"+(t=>{const n="=".repeat((4-t.length%4)%4),e=t.replace(/-/g,"+").replace(/_/g,"/")+n,o=atob(e);return Array.from(o,(t=>t.charCodeAt(0).toString(16).padStart(2,"0"))).join("")})(t),o=new e.Wallet(n);return{account:o,publicKey:o.address}},console.log("Plugin Gun-Eth successfully loaded")},o.exports?o.exports=r(s(),t,n):r(i.Gun,i.SEA,i.ethers)}(i),o(i.exports)}));
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("gun"),require("ethers"),require("fs"),require("url"),require("path")):"function"==typeof define&&define.amd?define(["exports","gun","ethers","fs","url","path"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).GunEth={},e.Gun,e.ethers,e.fs,e.url,e.path$1)}(this,(function(e,t,r,n,o,a){"use strict";var i="undefined"!=typeof document?document.currentScript:null,s="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function c(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var u={exports:{}};!function(e){!function(){function t(e,r){return r?function(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}(e):e.slice?t[n(e)]:function(r,o){e(r={exports:{}}),t[n(o)]=r.exports};function n(e){return e.split("/").slice(-1).toString().replace(".js","")}}var r=e;t((function(e){"undefined"!=typeof self&&(e.window=self),"undefined"!=typeof window&&(e.window=window);var t=(e.window||e).SEA||{};(t.window=e.window)&&(t.window.SEA=t);try{undefined+""!=typeof r&&(r.exports=t)}catch(e){}e.exports=t}))(t,"./root"),t((function(e){var r=t("./root");try{r.window&&location.protocol.indexOf("s")<0&&location.host.indexOf("localhost")<0&&!/^127\.\d+\.\d+\.\d+$/.test(location.hostname)&&location.protocol.indexOf("file:")<0&&(console.warn("HTTPS needed for WebCrypto in SEA, redirecting..."),location.protocol="https:")}catch(e){}}))(t,"./https"),t((function(e){var r;if(r+""==typeof btoa){if(r+""==typeof Buffer)try{s.Buffer=t("buffer",1).Buffer}catch(e){console.log("Please `npm install buffer` or add it to your package.json !")}s.btoa=function(e){return Buffer.from(e,"binary").toString("base64")},s.atob=function(e){return Buffer.from(e,"base64").toString("binary")}}}))(t,"./base64"),t((function(e){function r(){}t("./base64"),Object.assign(r,{from:Array.from}),r.prototype=Object.create(Array.prototype),r.prototype.toString=function(e,t,r){e=e||"utf8",t=t||0;const n=this.length;if("hex"===e){const e=new Uint8Array(this);return[...Array((r&&r+1||n)-t).keys()].map((r=>e[r+t].toString(16).padStart(2,"0"))).join("")}return"utf8"===e?Array.from({length:(r||n)-t},((e,r)=>String.fromCharCode(this[r+t]))).join(""):"base64"===e?btoa(this):void 0},e.exports=r}))(t,"./array"),t((function(e){t("./base64");var r=t("./array");function n(...e){return console.warn("new SafeBuffer() is depreciated, please use SafeBuffer.from()"),n.from(...e)}n.prototype=Object.create(Array.prototype),Object.assign(n,{from(){if(!Object.keys(arguments).length||null==arguments[0])throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.");const e=arguments[0];let t;if("string"==typeof e){const n=arguments[1]||"utf8";if("hex"===n){const n=e.match(/([\da-fA-F]{2})/g).map((e=>parseInt(e,16)));if(!n||!n.length)throw new TypeError("Invalid first argument for type 'hex'.");t=r.from(n)}else if("utf8"===n||"binary"===n){const n=e.length,o=new Uint16Array(n);Array.from({length:n},((t,r)=>o[r]=e.charCodeAt(r))),t=r.from(o)}else if("base64"===n){const n=atob(e),o=n.length,a=new Uint8Array(o);Array.from({length:o},((e,t)=>a[t]=n.charCodeAt(t))),t=r.from(a)}else"binary"===n?t=r.from(e):console.info("SafeBuffer.from unknown encoding: "+n);return t}e.byteLength;if(e.byteLength?e.byteLength:e.length){let t;return e instanceof ArrayBuffer&&(t=new Uint8Array(e)),r.from(t||e)}},alloc:(e,t=0)=>r.from(new Uint8Array(Array.from({length:e},(()=>t)))),allocUnsafe:e=>r.from(new Uint8Array(Array.from({length:e}))),concat(e){if(!Array.isArray(e))throw new TypeError("First argument must be Array containing ArrayBuffer or Uint8Array instances.");return r.from(e.reduce(((e,t)=>e.concat(Array.from(t))),[]))}}),n.prototype.from=n.from,n.prototype.toString=r.prototype.toString,e.exports=n}))(t,"./buffer"),t((function(e){const n=t("./root"),o={Buffer:t("./buffer")};var a={};if(JSON.parseAsync=JSON.parseAsync||function(e,t,r){try{t(undefined,JSON.parse(e,r))}catch(e){t(e)}},JSON.stringifyAsync=JSON.stringifyAsync||function(e,t,r,n){try{t(undefined,JSON.stringify(e,r,n))}catch(e){t(e)}},o.parse=function(e,t){return new Promise((function(r,n){JSON.parseAsync(e,(function(e,t){e?n(e):r(t)}),t)}))},o.stringify=function(e,t,r){return new Promise((function(n,o){JSON.stringifyAsync(e,(function(e,t){e?o(e):n(t)}),t,r)}))},n.window&&(o.crypto=n.window.crypto||n.window.msCrypto,o.subtle=(o.crypto||a).subtle||(o.crypto||a).webkitSubtle,o.TextEncoder=n.window.TextEncoder,o.TextDecoder=n.window.TextDecoder,o.random=e=>o.Buffer.from(o.crypto.getRandomValues(new Uint8Array(o.Buffer.alloc(e))))),!o.TextDecoder){const{TextEncoder:e,TextDecoder:n}=t((undefined+""==typeof r?".":"")+"./lib/text-encoding",1);o.TextDecoder=n,o.TextEncoder=e}if(!o.crypto)try{var i=t("crypto",1);Object.assign(o,{crypto:i,random:e=>o.Buffer.from(i.randomBytes(e))});const{Crypto:e}=t("@peculiar/webcrypto",1);o.ossl=o.subtle=new e({directory:"ossl"}).subtle}catch(e){console.log("Please `npm install @peculiar/webcrypto` or add it to your package.json !")}e.exports=o}))(t,"./shim"),t((function(e){var r=t("./root"),n=t("./shim"),o={pbkdf2:{hash:{name:"SHA-256"},iter:1e5,ks:64},ecdsa:{pair:{name:"ECDSA",namedCurve:"P-256"},sign:{name:"ECDSA",hash:{name:"SHA-256"}}},ecdh:{name:"ECDH",namedCurve:"P-256"},jwk:function(e,t){var r={kty:"EC",crv:"P-256",x:(e=e.split("."))[0],y:e[1],ext:!0};return r.key_ops=t?["sign"]:["verify"],t&&(r.d=t),r},keyToJwk:function(e){return{kty:"oct",k:e.toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,""),ext:!1,alg:"A256GCM"}},recall:{validity:43200,hook:function(e){return e}},check:function(e){return"string"==typeof e&&"SEA{"===e.slice(0,4)},parse:async function(e){try{var t="string"==typeof e;return t&&"SEA{"===e.slice(0,4)&&(e=e.slice(3)),t?await n.parse(e):e}catch(e){}return e}};r.opt=o,e.exports=o}))(t,"./settings"),t((function(e){var r=t("./shim");e.exports=async function(e,t){var n="string"==typeof e?e:await r.stringify(e),o=await r.subtle.digest({name:t||"SHA-256"},(new r.TextEncoder).encode(n));return r.Buffer.from(o)}}))(t,"./sha256"),t((function(e){const r=t("./shim"),n=r.subtle,o=r.ossl?r.ossl:n;e.exports=e=>o.digest({name:"SHA-1"},new ArrayBuffer(e))}))(t,"./sha1"),t((function(e){var r=t("./root"),n=t("./shim"),o=t("./settings"),a=t("./sha256");r.work=r.work||(async(e,t,i,s)=>{try{var c=(t||{}).epub||t;if(s=s||{},c instanceof Function&&(i=c,c=undefined),e="string"==typeof e?e:await n.stringify(e),"sha"===(s.name||"").toLowerCase().slice(0,3)){var u=n.Buffer.from(await a(e,s.name),"binary").toString(s.encode||"base64");if(i)try{i(u)}catch(e){console.log(e)}return u}c=c||n.random(9);var f=await(n.ossl||n.subtle).importKey("raw",(new n.TextEncoder).encode(e),{name:s.name||"PBKDF2"},!1,["deriveBits"]),p=await(n.ossl||n.subtle).deriveBits({name:s.name||"PBKDF2",iterations:s.iterations||o.pbkdf2.iter,salt:(new n.TextEncoder).encode(s.salt||c),hash:s.hash||o.pbkdf2.hash},f,s.length||8*o.pbkdf2.ks);e=n.random(e.length);var l=n.Buffer.from(p,"binary").toString(s.encode||"base64");if(i)try{i(l)}catch(e){console.log(e)}return l}catch(e){if(console.log(e),r.err=e,r.throw)throw e;return void(i&&i())}}),e.exports=r.work}))(t,"./work"),t((function(e){var r=t("./root"),n=t("./shim");t("./settings"),r.name=r.name||(async(e,t)=>{try{if(e)try{e()}catch(e){console.log(e)}return}catch(t){if(console.log(t),r.err=t,r.throw)throw t;return void(e&&e())}}),r.pair=r.pair||(async(e,t)=>{try{var o=n.ossl||n.subtle,a=await n.subtle.generateKey({name:"ECDSA",namedCurve:"P-256"},!0,["sign","verify"]).then((async e=>{var t={};t.priv=(await n.subtle.exportKey("jwk",e.privateKey)).d;var r=await n.subtle.exportKey("jwk",e.publicKey);return t.pub=r.x+"."+r.y,t}));try{var i=await o.generateKey({name:"ECDH",namedCurve:"P-256"},!0,["deriveKey"]).then((async e=>{var t={};t.epriv=(await o.exportKey("jwk",e.privateKey)).d;var r=await o.exportKey("jwk",e.publicKey);return t.epub=r.x+"."+r.y,t}))}catch(e){if(r.window)throw e;if("Error: ECDH is not a supported algorithm"!=e)throw e;console.log("Ignoring ECDH...")}i=i||{};var s={pub:a.pub,priv:a.priv,epub:i.epub,epriv:i.epriv};if(e)try{e(s)}catch(e){console.log(e)}return s}catch(t){if(console.log(t),r.err=t,r.throw)throw t;return void(e&&e())}}),e.exports=r.pair}))(t,"./pair"),t((function(e){var r,n=t("./root"),o=t("./shim"),a=t("./settings"),i=t("./sha256");n.sign=n.sign||(async(e,t,s,c)=>{try{if(c=c||{},!(t||c).priv){if(!n.I)throw"No signing key.";t=await n.I(null,{what:e,how:"sign",why:c.why})}if(r===e)throw"`undefined` not allowed.";var u=await a.parse(e),f=c.check=c.check||u;if(n.verify&&(n.opt.check(f)||f&&f.s&&f.m)&&r!==await n.verify(f,t)){var p=await a.parse(f);if(c.raw||(p="SEA"+await o.stringify(p)),s)try{s(p)}catch(e){console.log(e)}return p}var l=t.pub,y=t.priv,h=a.jwk(l,y),d=await i(u),g=await(o.ossl||o.subtle).importKey("jwk",h,{name:"ECDSA",namedCurve:"P-256"},!1,["sign"]).then((e=>(o.ossl||o.subtle).sign({name:"ECDSA",hash:{name:"SHA-256"}},e,new Uint8Array(d))));p={m:u,s:o.Buffer.from(g,"binary").toString(c.encode||"base64")};if(c.raw||(p="SEA"+await o.stringify(p)),s)try{s(p)}catch(e){console.log(e)}return p}catch(e){if(console.log(e),n.err=e,n.throw)throw e;return void(s&&s())}}),e.exports=n.sign}))(t,"./sign"),t((function(e){var r,n=t("./root"),o=t("./shim"),a=t("./settings"),i=t("./sha256");n.verify=n.verify||(async(e,t,s,c)=>{try{var u=await a.parse(e);if(!1===t){var f=await a.parse(u.m);if(s)try{s(f)}catch(e){console.log(e)}return f}c=c||{};var p,l,y,h=t.pub||t,d=n.opt.slow_leak?await n.opt.slow_leak(h):await(o.ossl||o.subtle).importKey("jwk",a.jwk(h),{name:"ECDSA",namedCurve:"P-256"},!1,["verify"]),g=await i(u.m);try{if(p=o.Buffer.from(u.s,c.encode||"base64"),l=new Uint8Array(p),!(y=await(o.ossl||o.subtle).verify({name:"ECDSA",hash:{name:"SHA-256"}},d,l,new Uint8Array(g))))throw"Signature did not match."}catch(r){if(n.opt.fallback)return await n.opt.fall_verify(e,t,s,c)}var w=y?await a.parse(u.m):r;if(s)try{s(w)}catch(e){console.log(e)}return w}catch(e){if(console.log(e),n.err=e,n.throw)throw e;return void(s&&s())}}),e.exports=n.verify;var s={};n.opt.slow_leak=e=>{if(s[e])return s[e];var t=a.jwk(e);return s[e]=(o.ossl||o.subtle).importKey("jwk",t,{name:"ECDSA",namedCurve:"P-256"},!1,["verify"]),s[e]};var c=n.opt;n.opt.fall_verify=async function(e,t,s,u,f){if(f===n.opt.fallback)throw"Signature did not match";f=f||1;var p=e||"";e=n.opt.unpack(e)||e;var l,y,h,d=await a.parse(e),g=t.pub||t,w=await n.opt.slow_leak(g),b=f<=n.opt.fallback?o.Buffer.from(await o.subtle.digest({name:"SHA-256"},(new o.TextEncoder).encode(await a.parse(d.m)))):await i(d.m);try{if(l=o.Buffer.from(d.s,u.encode||"base64"),y=new Uint8Array(l),!(h=await(o.ossl||o.subtle).verify({name:"ECDSA",hash:{name:"SHA-256"}},w,y,new Uint8Array(b))))throw"Signature did not match."}catch(e){try{l=o.Buffer.from(d.s,"utf8"),y=new Uint8Array(l),h=await(o.ossl||o.subtle).verify({name:"ECDSA",hash:{name:"SHA-256"}},w,y,new Uint8Array(b))}catch(e){if(!h)throw"Signature did not match."}}var m=h?await a.parse(d.m):r;if(c.fall_soul=p["#"],c.fall_key=p["."],c.fall_val=e,c.fall_state=p[">"],s)try{s(m)}catch(e){console.log(e)}return m},n.opt.fallback=2}))(t,"./verify"),t((function(e){var r=t("./shim"),n=t("./settings"),o=t("./sha256");e.exports=async(e,t,a)=>{const i=e+(t||r.random(8)).toString("utf8"),s=r.Buffer.from(await o(i),"binary"),c=n.keyToJwk(s);return await r.subtle.importKey("jwk",c,{name:"AES-GCM"},!1,["encrypt","decrypt"])}}))(t,"./aeskey"),t((function(e){var r=t("./root"),n=t("./shim");t("./settings");var o=t("./aeskey");r.encrypt=r.encrypt||(async(e,t,a,i)=>{try{i=i||{};var s=(t||i).epriv||t;if(undefined===e)throw"`undefined` not allowed.";if(!s){if(!r.I)throw"No encryption key.";s=(t=await r.I(null,{what:e,how:"encrypt",why:i.why})).epriv||t}var c="string"==typeof e?e:await n.stringify(e),u={s:n.random(9),iv:n.random(15)},f=await o(s,u.s,i).then((e=>n.subtle.encrypt({name:i.name||"AES-GCM",iv:new Uint8Array(u.iv)},e,(new n.TextEncoder).encode(c)))),p={ct:n.Buffer.from(f,"binary").toString(i.encode||"base64"),iv:u.iv.toString(i.encode||"base64"),s:u.s.toString(i.encode||"base64")};if(i.raw||(p="SEA"+await n.stringify(p)),a)try{a(p)}catch(e){console.log(e)}return p}catch(e){if(console.log(e),r.err=e,r.throw)throw e;return void(a&&a())}}),e.exports=r.encrypt}))(t,"./encrypt"),t((function(e){var r=t("./root"),n=t("./shim"),o=t("./settings"),a=t("./aeskey");r.decrypt=r.decrypt||(async(e,t,i,s)=>{try{s=s||{};var c=(t||s).epriv||t;if(!c){if(!r.I)throw"No decryption key.";c=(t=await r.I(null,{what:e,how:"decrypt",why:s.why})).epriv||t}var u,f,p,l=await o.parse(e);try{u=n.Buffer.from(l.s,s.encode||"base64"),f=n.Buffer.from(l.iv,s.encode||"base64"),p=n.Buffer.from(l.ct,s.encode||"base64");var y=await a(c,u,s).then((e=>n.subtle.decrypt({name:s.name||"AES-GCM",iv:new Uint8Array(f),tagLength:128},e,new Uint8Array(p))))}catch(n){if("utf8"===s.encode)throw"Could not decrypt";if(r.opt.fallback)return s.encode="utf8",await r.decrypt(e,t,i,s)}var h=await o.parse(new n.TextDecoder("utf8").decode(y));if(i)try{i(h)}catch(e){console.log(e)}return h}catch(e){if(console.log(e),r.err=e,r.throw)throw e;return void(i&&i())}}),e.exports=r.decrypt}))(t,"./decrypt"),t((function(e){var r=t("./root"),n=t("./shim");t("./settings"),r.secret=r.secret||(async(e,t,a,i)=>{try{if(i=i||{},!t||!t.epriv||!t.epub){if(!r.I)throw"No secret mix.";t=await r.I(null,{what:e,how:"secret",why:i.why})}var s=e.epub||e,c=t.epub,u=t.epriv,f=n.ossl||n.subtle,p=o(s),l=Object.assign({public:await f.importKey(...p,!0,[])},{name:"ECDH",namedCurve:"P-256"}),y=o(c,u),h=await f.importKey(...y,!1,["deriveBits"]).then((async e=>{var t=await f.deriveBits(l,e,256),r=new Uint8Array(t),n=await f.importKey("raw",r,{name:"AES-GCM",length:256},!0,["encrypt","decrypt"]);return f.exportKey("jwk",n).then((({k:e})=>e))}));if(a)try{a(h)}catch(e){console.log(e)}return h}catch(e){if(console.log(e),r.err=e,r.throw)throw e;return void(a&&a())}});var o=(e,t)=>{var[r,n]=e.split("."),o=t?{d:t}:{};return["jwk",Object.assign(o,{x:r,y:n,kty:"EC",crv:"P-256",ext:!0}),{name:"ECDH",namedCurve:"P-256"}]};e.exports=r.secret}))(t,"./secret"),t((function(e){var r=t("./root");r.certify=r.certify||(async(e,t={},n,o,a={})=>{try{if(console.log("SEA.certify() is an early experimental community supported method that may change API behavior without warning in any future version."),e=(()=>{var t=[];if(e){if(("string"==typeof e||Array.isArray(e))&&e.indexOf("*")>-1)return"*";if("string"==typeof e)return e;if(Array.isArray(e)){if(1===e.length&&e[0])return"object"==typeof e[0]&&e[0].pub?e[0].pub:"string"==typeof e[0]?e[0]:null;e.map((e=>{"string"==typeof e?t.push(e):"object"==typeof e&&e.pub&&t.push(e.pub)}))}return"object"==typeof e&&e.pub?e.pub:t.length>0?t:null}})(),!e)return console.log("No certificant found.");const s=!a.expiry||"number"!=typeof a.expiry&&"string"!=typeof a.expiry?null:parseFloat(a.expiry),c=(t||{}).read?t.read:null,u=(t||{}).write?t.write:"string"==typeof t||Array.isArray(t)||t["+"]||t["#"]||t["."]||t["="]||t["*"]||t[">"]||t["<"]?t:null,f=(a||{}).block||(a||{}).blacklist||(a||{}).ban||{},p=f.read&&("string"==typeof f.read||(f.read||{})["#"])?f.read:null,l="string"==typeof f?f:f.write&&("string"==typeof f.write||f.write["#"])?f.write:null;if(!c&&!u)return console.log("No policy found.");const y=JSON.stringify({c:e,...s?{e:s}:{},...c?{r:c}:{},...u?{w:u}:{},...p?{rb:p}:{},...l?{wb:l}:{}});var i=await r.sign(y,n,null,{raw:1});if(a.raw||(i="SEA"+JSON.stringify(i)),o)try{o(i)}catch(e){console.log(e)}return i}catch(e){if(r.err=e,r.throw)throw e;return void(o&&o())}}),e.exports=r.certify}))(t,"./certify"),t((function(e){var r=t("./shim"),n=t("./root");n.work=t("./work"),n.sign=t("./sign"),n.verify=t("./verify"),n.encrypt=t("./encrypt"),n.decrypt=t("./decrypt"),n.certify=t("./certify"),n.random=n.random||r.random,n.Buffer=n.Buffer||t("./buffer"),n.keyid=n.keyid||(async e=>{try{const t=r.Buffer.concat(e.replace(/-/g,"+").replace(/_/g,"/").split(".").map((e=>r.Buffer.from(e,"base64")))),n=r.Buffer.concat([r.Buffer.from([153,t.length/256,t.length%256]),t]),o=await sha1hash(n),a=r.Buffer.from(o,"binary");return a.toString("hex",a.length-8)}catch(e){throw console.log(e),e}}),((n.window||{}).GUN||{}).SEA=n,e.exports=n}))(t,"./sea"),t((function(e){var n,o=t("./sea");function a(e){this._={$:this}}function i(){return n.state().toString(36).replace(".","")}n=o.window?o.window.GUN||{chain:{}}:t((undefined+""==typeof r?".":"")+"./gun",1),o.GUN=n,a.prototype=function(){function e(){}return e.prototype=n.chain,new e}(),a.prototype.constructor=a,n.chain.user=function(e){var t,r=this.back(-1);if(e)return e=o.opt.pub((e._||"")["#"])||e,r.get("~"+e);if(t=r.back("user"))return t;var n=r=r._,s=n.opt.uuid||i;return(n=(t=n.user=this.chain(new a))._).opt={},n.opt.uuid=function(e){var t=s(),n=r.user;return n&&(n=n.is)&&(n=n.pub)?(t="~"+n+"/"+t,e&&e.call&&e(null,t),t):t},t},n.User=a,a.GUN=n,a.SEA=n.SEA=o,e.exports=a}))(t,"./user"),t((function(e){var n;(""+n!=typeof GUN?GUN||{chain:{}}:t((""+n==typeof r?".":"")+"./gun",1)).chain.then=function(e,t){var r=this,n=new Promise((function(e,n){r.once(e,t)}));return e?n.then(e):n}}))(t,"./then"),t((function(e){var r=t("./user"),n=r.SEA,o=r.GUN,a=function(){};r.prototype.create=function(...e){var t,r="object"==typeof e[0]&&(e[0].pub||e[0].epub)?e[0]:"object"==typeof e[1]&&(e[1].pub||e[1].epub)?e[1]:null,i=r&&(r.pub||r.epub)?r.pub:"string"==typeof e[0]?e[0]:null,s=r&&(r.pub||r.epub)?r:i&&"string"==typeof e[1]?e[1]:null,c=e.filter((e=>"function"==typeof e))[0]||null,u=e&&e.length>1&&"object"==typeof e[e.length-1]?e[e.length-1]:{},f=this,p=f._,l=f.back(-1);if((c=c||a,!1!==(u=u||{}).check)&&(i||(t="No user."),(s||"").length<8&&(t="Password too short!"),t))return c({err:o.log(t)}),f;if(p.ing)return(c||a)({err:o.log("User is already being created or authenticated!"),wait:!0}),f;p.ing=!0;var y={a:function(e){if(y.pubs=e,e&&!u.already){var t={err:o.log("User already created!")};return p.ing=!1,(c||a)(t),void f.leave()}y.salt=String.random(64),n.work(s,y.salt,y.b)},b:function(e){y.proof=e,r?y.c(r):n.pair(y.c)},c:function(e){var t;y.pair=e||{},(t=p.root.user)&&(t._.sea=e,t.is={pub:e.pub,epub:e.epub,alias:i}),y.data={pub:e.pub},y.d()},d:function(){y.data.alias=i,y.e()},e:function(){y.data.epub=y.pair.epub,n.encrypt({priv:y.pair.priv,epriv:y.pair.epriv},y.proof,y.f,{raw:1})},f:function(e){y.data.auth=JSON.stringify({ek:e,s:y.salt}),y.g(y.data.auth)},g:function(e){var t;y.data.auth=y.data.auth||e,l.get(t="~"+y.pair.pub).put(y.data).on(y.h);var r={};r[t]={"#":t},l.get("~@"+i).put(r).get(t).on(y.i)},h:function(e,t,r,n){n.off(),y.h.ok=1,y.i()},i:function(e,t,n,o){o&&(y.i.ok=1,o.off()),y.h.ok&&y.i.ok&&(p.ing=!1,c({ok:0,pub:y.pair.pub}),a===c&&(r?f.auth(r):f.auth(i,s)))}};return l.get("~@"+i).once(y.a),f},r.prototype.leave=function(e,t){var r=this.back(-1)._.user;if(r&&(delete r.is,delete r._.is,delete r._.sea),n.window)try{var o={};delete(o=n.window.sessionStorage).recall,delete o.pair}catch(e){}return this}}))(t,"./create"),t((function(e){var r=t("./user"),n=r.SEA,o=r.GUN,a=function(){};function i(e){if("string"!=typeof e)return e;try{e=JSON.parse(e)}catch(t){e={}}return e}r.prototype.auth=function(...e){var t="object"==typeof e[0]&&(e[0].pub||e[0].epub)?e[0]:"object"==typeof e[1]&&(e[1].pub||e[1].epub)?e[1]:null,r=t||"string"!=typeof e[0]?null:e[0],s=!r&&(!t||t.priv&&t.epriv)||"string"!=typeof e[1]?null:e[1],c=e.filter((e=>"function"==typeof e))[0]||null,u=e&&e.length>1&&"object"==typeof e[e.length-1]?e[e.length-1]:{},f=this,p=f._,l=f.back(-1);if(p.ing)return(c||a)({err:o.log("User is already being created or authenticated!"),wait:!0}),f;p.ing=!0;var y,h={},d=9;return h.a=function(e){if(!e)return h.b();if(!e.pub){var t=[];return Object.keys(e).forEach((function(r){"_"!=r&&t.push(e[r])})),h.b(t)}if(h.name)return h.f(e);h.c((h.data=e).auth)},h.b=function(e){var t=(h.list=(h.list||[]).concat(e||[])).shift();if(y===t)return h.name?h.err("Your user account is not published for dApps to access, please consider syncing it online, or allowing local access by adding your device as a peer."):r&&d--?void l.get("~@"+r).once(h.a):h.err("Wrong user or password.");l.get(t).once(h.a)},h.c=function(e){return y===e?h.b():"string"==typeof e?h.c(i(e)):void n.work(s,(h.auth=e).s,h.d,h.enc)},h.d=function(e){n.decrypt(h.auth.ek,e,h.e,h.enc)},h.e=function(e){if(y===e)return h.enc?(h.enc=null,h.b()):(h.enc={encode:"utf8"},h.c(h.auth));h.half=e,h.f(h.data)},h.f=function(e){var t=h.half||{},r=h.data||{};h.g(h.lol={pub:e.pub||r.pub,epub:e.epub||r.epub,priv:e.priv||t.priv,epriv:e.epriv||t.epriv})},h.g=function(e){if(!e||!e.pub||!e.epub)return h.b();h.pair=e;var t=l._.user,d=t._;d.tag;var g=d.opt;(d=t._=l.get("~"+e.pub)._).opt=g,t.is={pub:e.pub,epub:e.epub,alias:r||e.pub},d.sea=h.pair,p.ing=!1;try{s&&y==(i(p.root.graph["~"+e.pub].auth)||"")[":"]&&(u.shuffle=u.change=s)}catch(e){}if(u.change?h.z():(c||a)(d),n.window&&(f.back("user")._.opt||u).remember)try{var w={};(w=n.window.sessionStorage).recall=!0,w.pair=JSON.stringify(e)}catch(e){}try{l._.tag.auth?l._.on("auth",d):setTimeout((function(){l._.on("auth",d)}),1)}catch(e){o.log("Your 'auth' callback crashed with:",e)}},h.h=function(e){return e?((r=e.alias)||(r=e.alias="~"+t.pub),e.auth?(t=null,void h.c((h.data=e).auth)):h.g(t)):h.b()},h.z=function(){h.salt=String.random(64),n.work(u.change,h.salt,h.y)},h.y=function(e){n.encrypt({priv:h.pair.priv,epriv:h.pair.epriv},e,h.x,{raw:1})},h.x=function(e){h.w(JSON.stringify({ek:e,s:h.salt}))},h.w=function(e){if(u.shuffle){console.log("migrate core account from UTF8 & shuffle");var t={};Object.keys(h.data).forEach((function(e){t[e]=h.data[e]})),delete t._,t.auth=e,l.get("~"+h.pair.pub).put(t)}l.get("~"+h.pair.pub).get("auth").put(e,c||a)},h.err=function(e){var t={err:o.log(e||"User cannot be found!")};p.ing=!1,(c||a)(t)},h.plugin=function(e){if(!(h.name=e))return h.err();var t=[e];"~"!==e[0]&&(t[1]="~"+e,t[2]="~@"+e),h.b(t)},t?t.priv&&t.epriv?h.g(t):l.get("~"+t.pub).once(h.h):r?l.get("~@"+r).once(h.a):r||s||n.name(h.plugin),f}}))(t,"./auth"),t((function(e){var r=t("./user"),n=r.SEA;r.GUN,r.prototype.recall=function(e,t){var r=this,o=r.back(-1);if((e=e||{})&&e.sessionStorage){if(n.window)try{var a;(a=n.window.sessionStorage)&&(o._.opt.remember=!0,(r.back("user")._.opt||e).remember=!0,(a.recall||a.pair)&&o.user().auth(JSON.parse(a.pair),t))}catch(e){}return r}return r}}))(t,"./recall"),t((function(e){var r=t("./user"),n=r.SEA,o=r.GUN,a=function(){};r.prototype.pair=function(){var e,t=this;try{e=new Proxy({DANGER:"☠"},{get:function(e,r,n){if(t.is&&(t._||"").sea)return t._.sea[r]}})}catch(e){}return e},r.prototype.delete=async function(e,t,r){console.log("user.delete() IS DEPRECATED AND WILL BE MOVED TO A MODULE!!!");var n=this;n.back(-1);var i=n.back("user");try{i.auth(e,t,(function(e){(i.is||{}).pub;i.map().once((function(){this.put(null)})),i.leave(),(r||a)({ok:0})}))}catch(e){o.log("User.delete failed! Error:",e)}return n},r.prototype.alive=async function(){console.log("user.alive() IS DEPRECATED!!!");const e=this.back(-1);try{return await authRecall(e),e._.user._}catch(e){const t="No session!";throw o.log(t),{err:t}}},r.prototype.trust=async function(e){console.log("`.trust` API MAY BE DELETED OR CHANGED OR RENAMED, DO NOT USE!"),o.is(e)&&e.get("pub").get(((e,t)=>{console.log(e,t)})),e.get("trust").get(path).put(theirPubkey)},r.prototype.grant=function(e,t){console.log("`.grant` API MAY BE DELETED OR CHANGED OR RENAMED, DO NOT USE!");var r=this,o=r.back(-1).user(),a=o._.sea,i="";return r.back((function(e){e.is||(i+=e.get||"")})),async function(){var r,s=await o.get("grant").get(a.pub).get(i).then();(s=await n.decrypt(s,a))||(s=n.random(16).toString(),r=await n.encrypt(s,a),o.get("grant").get(a.pub).get(i).put(r));var c=e.get("pub").then(),u=e.get("epub").then();c=await c,u=await u;var f=await n.secret(u,a);r=await n.encrypt(s,f),o.get("grant").get(c).get(i).put(r,t)}(),r},r.prototype.secret=function(e,t){console.log("`.secret` API MAY BE DELETED OR CHANGED OR RENAMED, DO NOT USE!");var r=this,o=r.back(-1).user(),a=o.pair(),i="";return r.back((function(e){e.is||(i+=e.get||"")})),async function(){var s,c=await o.get("trust").get(a.pub).get(i).then();(c=await n.decrypt(c,a))||(c=n.random(16).toString(),s=await n.encrypt(c,a),o.get("trust").get(a.pub).get(i).put(s)),s=await n.encrypt(e,c),r.put(s,t)}(),r},e.exports=r}))(t,"./share"),t((function(e){var n,o=t("./sea"),a=t("./settings"),i=(o.window||"").GUN||t((""+n==typeof r?".":"")+"./gun",1);function s(e){var t,r=this,n=r.as,a=e.put,c=a["#"],u=a["."],f=a[":"],p=a[">"],l=e["#"];if(c&&u)if((e._||"").faith&&(n.opt||"").faith&&"function"==typeof e._)o.opt.pack(a,(function(t){o.verify(t,!1,(function(t){a["="]=o.opt.unpack(t),r.to.next(e)}))}));else{var y=function(t){n.on("in",{"@":l,err:e.err=t})};(e._||"").DBG&&((e._||"").DBG.c=+new Date),0<=c.indexOf("<?")&&(t=parseFloat(c.split("<?")[1]||""))&&p<i.state()-1e3*t?(t=e._)&&t.stun&&t.stun--:"~@"!==c?"~@"!==c.slice(0,2)?(t=o.opt.pub(c))?s.pub(r,e,f,u,c,n,y,n.user||"",t):0<=c.indexOf("#")?s.hash(r,e,f,u,c,n,y):s.any(r,e,f,u,c,n,y,n.user||""):s.pubs(r,e,f,u,c,n,y):s.alias(r,e,f,u,c,n,y)}}i.on("opt",(function(e){e.sea||(e.sea={own:{}},e.on("put",s,e)),this.to.next(e)})),s.hash=function(e,t,r,n,a,i,s){o.work(r,null,(function(r){return r&&r===n.split("#").slice(-1)[0]||r&&r===function(e){let t="";for(let r=0;r<e.length;r++)t+=r-1&1?"":String.fromCharCode(parseInt(e.substring(r-1,r+1),16));return btoa(t)}(n.split("#").slice(-1)[0])?e.to.next(t):void s("Data hash not same as hash!")}),{name:"SHA-256"})},s.alias=function(e,t,r,n,o,a,i){return r?"~@"+n===u(r)?e.to.next(t):void i("Alias not same!"):i("Data must exist!")},s.pubs=function(e,t,r,n,o,a,i){return r?n===u(r)?e.to.next(t):void i("Alias not same!"):i("Alias must exist!")},s.pub=async function(e,t,r,s,c,f,p,l,y){var h;const d=await a.parse(r)||{},g=(r,a,u)=>{if(r.m&&r.s&&a&&y)return o.verify(r,y,(r=>{if(n!==r&&n!==r.e&&t.put[">"]&&t.put[">"]>parseFloat(r.e))return p("Certificate expired.");if(n!==r&&r.c&&r.w&&(r.c===a||r.c.indexOf("*")>-1)){let t=c.indexOf("/")>-1?c.replace(c.substring(0,c.indexOf("/")+1),""):"";String.match=String.match||i.text.match;const n=Array.isArray(r.w)?r.w:"object"==typeof r.w||"string"==typeof r.w?[r.w]:[];for(const i of n)if(String.match(t,i["#"])&&String.match(s,i["."])||!i["."]&&String.match(t,i["#"])||!i["#"]&&String.match(s,i["."])||String.match(t?t+"/"+s:s,i["#"]||i)){if(i["+"]&&i["+"].indexOf("*")>-1&&t&&-1==t.indexOf(a)&&-1==s.indexOf(a))return p(`Path "${t}" or key "${s}" must contain string "${a}".`);if(r.wb&&("string"==typeof r.wb||(r.wb||{})["#"])){var o=e.as.root.$.back(-1);return"string"==typeof r.wb&&"~"!==r.wb.slice(0,1)&&(o=o.get("~"+y)),o.get(r.wb).get(a).once((e=>!e||1!==e&&!0!==e?u(r):p(`Certificant ${a} blocked.`)))}return u(r)}return p("Certificate verification fail.")}}))};if("pub"===s&&"~"+y===c)return r===y?e.to.next(t):p("Account not same!");(h=l.is)&&h.pub&&!d["*"]&&!d["+"]&&(y===h.pub||y!==h.pub&&((t._.msg||{}).opt||{}).cert)?o.opt.pack(t.put,(i=>{o.sign(i,l._.sea,(async function(i){if(n===i)return p(o.err||"Signature fail.");if(t.put[":"]={":":h=o.opt.unpack(i.m),"~":i.s},t.put["="]=h,y===l.is.pub)return(h=u(r))&&((f.sea.own[h]=f.sea.own[h]||{})[y]=1),void JSON.stringifyAsync(t.put[":"],(function(r,n){return r?p(r||"Stringify error."):(t.put[":"]=n,e.to.next(t))}));if(y!==l.is.pub&&((t._.msg||{}).opt||{}).cert){const r=await a.parse(t._.msg.opt.cert);r&&r.m&&r.s&&g(r,l.is.pub,(n=>{t.put[":"]["+"]=r,t.put[":"]["*"]=l.is.pub,JSON.stringifyAsync(t.put[":"],(function(r,n){return r?p(r||"Stringify error."):(t.put[":"]=n,e.to.next(t))}))}))}}),{raw:1})})):o.opt.pack(t.put,(r=>{o.verify(r,d["*"]||y,(function(r){var a;return r=o.opt.unpack(r),n===r?p("Unverified data."):((a=u(r))&&y===o.opt.pub(a)&&((f.sea.own[a]=f.sea.own[a]||{})[y]=1),d["+"]&&d["+"].m&&d["+"].s&&d["*"]?void g(d["+"],d["*"],(n=>(t.put["="]=r,e.to.next(t)))):(t.put["="]=r,e.to.next(t)))}))}))},s.any=function(e,t,r,n,o,a,i,s){if(a.opt.secure)return i("Soul missing public key at '"+n+"'.");a.on("secure",(function(t){if(this.off(),!a.opt.secure)return e.to.next(t);i("Data cannot be changed.")})).on.on("secure",t)};var c=i.valid,u=function(e,t){return"string"==typeof(t=c(e))&&t};(i.state||"").ify;var f=/[^\w_-]/;o.opt.pub=function(e){if(e&&(e=e.split("~"))&&(e=e[1])&&(e=e.split(f).slice(0,2))&&2==e.length&&"@"!==(e[0]||"")[0])return e=e.slice(0,2).join(".")},o.opt.stringy=function(e){},o.opt.pack=function(e,t,r,a,s){var c,u;if(o.opt.check(e))return t(e);e&&e["#"]&&e["."]&&e[">"]&&(c=e[":"],u=1),JSON.parseAsync(u?c:e,(function(o,c){var u=n!==(c||"")[":"]&&(c||"")["~"];t(u?{m:{"#":s||e["#"],".":r||e["."],":":(c||"")[":"],">":e[">"]||i.state.is(a,r)},s:u}:e)}))};var p=o.opt;o.opt.unpack=function(e,t,r){var a;if(n!==e){if(e&&n!==(a=e[":"]))return a;if(t=t||p.fall_key,!r&&p.fall_val&&((r={})[t]=p.fall_val),t&&r){if(e===r[t])return e;if(!o.opt.check(r[t]))return e;var s=r&&r._&&r._["#"]||p.fall_soul,c=i.state.is(r,t)||p.fall_state;return e&&4===e.length&&s===e[0]&&t===e[1]&&l(c)===l(e[3])?e[2]:c<o.opt.shuffle_attack?e:void 0}}},o.opt.shuffle_attack=15463296e5;var l=Math.floor}))(t,"./index")}()}(u);var f=c(u.exports);const p=o.fileURLToPath("undefined"==typeof document&&"undefined"==typeof location?require("url").pathToFileURL(p).href:"undefined"==typeof document?location.href:i&&"SCRIPT"===i.tagName.toUpperCase()&&i.src||new URL("gun-eth.min.js",document.baseURI).href),l=a.dirname(p);let y={PROOF_OF_INTEGRITY_ADDRESS:null,STEALTH_ANNOUNCER_ADDRESS:null};try{const e=n.readFileSync(a.join(l,"contract-address.json"),"utf8");y=JSON.parse(e),console.log("Loaded contract addresses:",y)}catch(e){console.warn("Warning: contract-address.json not found or invalid")}const h={PROOF_OF_INTEGRITY_ADDRESS:y.PROOF_OF_INTEGRITY_ADDRESS,STEALTH_ANNOUNCER_ADDRESS:y.STEALTH_ANNOUNCER_ADDRESS,RPC_URL:"http://127.0.0.1:8545",GUN_PEER:"http://localhost:8765/gun",CHAIN_ID:31337};process.env.NODE_ENV;const d="development"===process.env.NODE_ENV?h.PROOF_OF_INTEGRITY_ADDRESS:"0x...";process.env.NODE_ENV;const g=[{inputs:[{internalType:"bytes[]",name:"nodeIds",type:"bytes[]"},{internalType:"bytes32[]",name:"contentHashes",type:"bytes32[]"}],name:"batchUpdateData",outputs:[],stateMutability:"nonpayable",type:"function"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes",name:"nodeId",type:"bytes"},{indexed:!1,internalType:"bytes32",name:"contentHash",type:"bytes32"},{indexed:!1,internalType:"address",name:"updater",type:"address"}],name:"DataUpdated",type:"event"},{inputs:[{internalType:"bytes",name:"nodeId",type:"bytes"}],name:"getLatestRecord",outputs:[{internalType:"bytes32",name:"",type:"bytes32"},{internalType:"uint256",name:"",type:"uint256"},{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes",name:"nodeId",type:"bytes"},{internalType:"bytes32",name:"contentHash",type:"bytes32"}],name:"updateData",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes",name:"nodeId",type:"bytes"},{internalType:"bytes32",name:"contentHash",type:"bytes32"}],name:"verifyData",outputs:[{internalType:"bool",name:"",type:"bool"},{internalType:"uint256",name:"",type:"uint256"},{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"}];let w,b="",m="";const v="Access GunDB with Ethereum";function S(e){try{const t=r.ethers.hexlify(e),n=r.ethers.keccak256(t);return console.log("Generated password:",n),n}catch(e){return console.error("Error generating password:",e),null}}function A(e){const t="0x"+(e=>{const t="=".repeat((4-e.length%4)%4),r=e.replace(/-/g,"+").replace(/_/g,"/")+t,n=atob(r);return Array.from(n,(e=>e.charCodeAt(0).toString(16).padStart(2,"0"))).join("")})(e),n=new r.ethers.Wallet(t);return{account:n,publicKey:n.address,privateKey:t}}const E=async()=>{if(b&&m){const e=new r.ethers.JsonRpcProvider(b,{chainId:h.CHAIN_ID,name:"localhost"});return new r.ethers.Wallet(m,e)}if("undefined"!=typeof window&&void 0!==window.ethereum){await window.ethereum.request({method:"eth_requestAccounts"});return new r.ethers.BrowserProvider(window.ethereum).getSigner()}throw new Error("No valid Ethereum provider found")};function k(e,t){try{const n=Buffer.from(e,"base64"),o=r.ethers.keccak256(r.ethers.concat([n,r.ethers.getBytes(t)])),a=new r.ethers.Wallet(o);return console.log("Debug deriveStealthAddress:",{sharedSecretHex:r.ethers.hexlify(n),spendingPublicKey:t,stealthPrivateKey:o,stealthAddress:a.address}),{stealthPrivateKey:o,stealthAddress:a.address,wallet:a}}catch(e){throw console.error("Error in deriveStealthAddress:",e),e}}t.chain.MESSAGE_TO_SIGN=v,t.chain.setSigner=function(e,t){return b=e,m=t,console.log("Standalone configuration set"),this},t.chain.verifySignature=async function(e,t){try{return r.ethers.verifyMessage(e,t)}catch(e){return console.error("Error verifying signature:",e),null}},t.chain.generatePassword=function(e){return S(e)},t.chain.createSignature=async function(e){try{if(e!==v)throw new Error("Invalid message, valid message is: "+v);const t=await E(),r=await t.signMessage(e);return console.log("Signature created:",r),r}catch(e){return console.error("Error creating signature:",e),null}},t.chain.createAndStoreEncryptedPair=async function(e,t){try{const r=this,n=await f.pair(),o=await f.pair(),a=await f.pair(),i=S(t),s=await f.encrypt(JSON.stringify(n),i),c=await f.encrypt(JSON.stringify(o),i),u=await f.encrypt(JSON.stringify(a),i),p=A(o.priv),l=A(a.priv);await r.get("gun-eth").get("users").get(e).put({pair:s,v_pair:c,s_pair:u,publicKeys:{viewingPublicKey:o.epub,viewingPublicKey:o.epub,spendingPublicKey:l.publicKey,ethViewingAddress:p.publicKey}}),console.log("Encrypted pairs and public keys stored for:",e)}catch(e){throw console.error("Error creating and storing encrypted pair:",e),e}},t.chain.getAndDecryptPair=async function(e,t){try{const r=this,n=await r.get("gun-eth").get("users").get(e).get("pair").then();if(!n)throw new Error("No encrypted data found for this address");const o=await f.decrypt(n,t);return console.log(o),o}catch(e){return console.error("Error retrieving and decrypting pair:",e),null}},t.chain.proof=function(e,t,n,o){if(console.log("Proof plugin called with:",{chain:e,nodeId:t,data:n}),"function"!=typeof o)return console.error("Callback must be a function"),this;const a=this;if("optimismSepolia"!==e&&"localhost"!==e)return o({err:"Chain not supported"}),this;if(w="development"===process.env.NODE_ENV?h.PROOF_OF_INTEGRITY_ADDRESS:d,console.log("Using contract address:",w),!w)return o({err:"Contract address not found. Did you deploy the contract?"}),this;if(t&&!n)a.get(t).once((async e=>{if(!e)return void(o&&o({err:"Node not found in GunDB"}));console.log("existingData",e);const n=e._contentHash;if(console.log("contentHash",n),n)try{const{isValid:e,timestamp:a,updater:i}=await(async(e,t)=>{console.log("Verifying on chain:",{nodeId:e,contentHash:t});const n=await E(),o=new r.ethers.Contract(w,g,n),[a,i,s]=await o.verifyData(r.ethers.toUtf8Bytes(e),t);return console.log("Verification result:",{isValid:a,timestamp:i,updater:s}),{isValid:a,timestamp:i,updater:s}})(t,n),s=await(async e=>{const t=await E(),n=new r.ethers.Contract(w,g,t),[o,a,i]=await n.getLatestRecord(r.ethers.toUtf8Bytes(e));return console.log("Latest record from blockchain:",{nodeId:e,contentHash:o,timestamp:a,updater:i}),{contentHash:o,timestamp:a,updater:i}})(t);e?o&&o({ok:!0,message:"Data verified on blockchain",timestamp:a,updater:i,latestRecord:s}):o&&o({ok:!1,message:"Data not verified on blockchain",latestRecord:s})}catch(e){o&&o({err:e.message})}else o&&o({err:"No content hash found for this node"})}));else if(n&&!t){const e=r.ethers.hexlify(r.ethers.randomBytes(32)).slice(2),t=JSON.stringify(n),i=r.ethers.keccak256(r.ethers.toUtf8Bytes(t));a.get(e).put({...n,_contentHash:i},(async t=>{if(console.log("ack",t),t.err)o&&o({err:"Error saving data to GunDB"});else try{const t=await(async(e,t)=>{console.log("Writing on chain:",{nodeId:e,contentHash:t});const n=await E(),o=new r.ethers.Contract(w,g,n),a=await o.updateData(r.ethers.toUtf8Bytes(e),t);console.log("Transaction sent:",a.hash);const i=await a.wait();return console.log("Transaction confirmed:",i),a})(e,i);o&&o({ok:!0,message:"Data written to GunDB and blockchain",nodeId:e,txHash:t.hash})}catch(e){o&&o({err:e.message})}}))}else o&&o({err:"Invalid input. Provide either nodeId or data, not both."});return a},t.chain.gunToEthAccount=function(e){return A(e)},t.chain.generateStealthAddress=async function(e,t){try{const r=this,n=await r.get("gun-eth").get("users").get(e).get("publicKeys").then();if(!n||!n.viewingPublicKey||!n.spendingPublicKey)throw new Error("Recipient's public keys not found");const o=await this.verifySignature(v,t),a=S(t),i=await r.get("gun-eth").get("users").get(o).then();if(!i||!i.s_pair)throw new Error("Sender's keys not found");let s;try{const e=await f.decrypt(i.s_pair,a);s="string"==typeof e?JSON.parse(e):e}catch(e){throw console.error("Error decrypting spending pair:",e),new Error("Unable to decrypt spending pair")}const c=await f.secret(n.viewingPublicKey,s);if(!c)throw new Error("Unable to generate shared secret");console.log("Generate shared secret:",c);const{stealthAddress:u}=k(c,n.spendingPublicKey);return{stealthAddress:u,senderPublicKey:s.epub,spendingPublicKey:n.spendingPublicKey}}catch(e){throw console.error("Error generating stealth address:",e),e}},t.chain.publishStealthKeys=async function(e){try{const t=this,r=await this.verifySignature(v,e),n=S(e),o=await t.get("gun-eth").get("users").get(r).then();if(!o||!o.v_pair||!o.s_pair)throw new Error("Keys not found");const a=JSON.parse(await f.decrypt(o.v_pair,n)),i=JSON.parse(await f.decrypt(o.s_pair,n)),s=A(a.priv),c=A(i.priv);await t.get("gun-eth").get("users").get(r).get("publicKeys").put({viewingPublicKey:s.publicKey,spendingPublicKey:c.publicKey}),console.log("Stealth public keys published successfully")}catch(e){throw console.error("Error publishing stealth keys:",e),e}},t.chain.recoverStealthFunds=async function(e,t,r,n){try{const o=this,a=S(r),i=await this.verifySignature(v,r),s=await o.get("gun-eth").get("users").get(i).then();if(!s||!s.v_pair||!s.s_pair)throw new Error("Keys not found");let c;try{const e=await f.decrypt(s.v_pair,a);c="string"==typeof e?JSON.parse(e):e}catch(e){throw console.error("Error decrypting keys:",e),new Error("Unable to decrypt keys")}const u=await f.secret(t,c);if(!u)throw new Error("Unable to generate shared secret");console.log("Recover shared secret:",u);const{wallet:p,stealthAddress:l}=k(u,n);if(l.toLowerCase()!==e.toLowerCase())throw console.error("Mismatch:",{recovered:l,expected:e,sharedSecret:u}),new Error("Recovered stealth address does not match");return{wallet:p,address:l}}catch(e){throw console.error("Error recovering stealth funds:",e),e}},t.chain.announceStealthPayment=async function(e,t,n,o,a={onChain:!1}){try{const i=this,s=await this.verifySignature(v,o);if(a.onChain){const o=await E(),a="development"===process.env.NODE_ENV?h.STEALTH_ANNOUNCER_ADDRESS:STEALTH_ANNOUNCER_ADDRESS;console.log("Using contract address:",a);const i=new r.ethers.Contract(a,STEALTH_ANNOUNCER_ABI,o),s=await i.devFee();console.log("Dev fee:",s.toString());const c=await i.announcePayment(t,n,e,{value:s});console.log("Transaction sent:",c.hash);const u=await c.wait();console.log("Transaction confirmed:",u.hash),console.log("Stealth payment announced on-chain (dev fee paid)")}else await i.get("gun-eth").get("stealth-payments").set({stealthAddress:e,senderAddress:s,senderPublicKey:t,spendingPublicKey:n,timestamp:Date.now()}),console.log("Stealth payment announced off-chain")}catch(e){throw console.error("Error announcing stealth payment:",e),console.error("Error details:",e.stack),e}},t.chain.getStealthPayments=async function(e,t={source:"both"}){try{const n=[];if("onChain"===t.source||"both"===t.source){const t=await E(),o="development"===process.env.NODE_ENV?h.STEALTH_ANNOUNCER_ADDRESS:STEALTH_ANNOUNCER_ADDRESS,a=new r.ethers.Contract(o,STEALTH_ANNOUNCER_ABI,t);try{const t=await a.getAnnouncementsCount(),r=Number(t.toString());if(console.log("Total on-chain announcements:",r),r>0){const t=100,o=r-1;for(let r=0;r<=o;r+=t){const i=Math.min(r+t-1,o),s=await a.getAnnouncementsInRange(r,i);for(const t of s)try{if(!(t&&t.stealthAddress&&t.senderPublicKey&&t.spendingPublicKey)){console.log("Invalid announcement:",t);continue}const r=await this.recoverStealthFunds(t.stealthAddress,t.senderPublicKey,e,t.spendingPublicKey);n.push({stealthAddress:t.stealthAddress,senderPublicKey:t.senderPublicKey,spendingPublicKey:t.spendingPublicKey,timestamp:Number(t.timestamp),source:"onChain",wallet:r})}catch(e){console.log(`Announcement not for us: ${t.stealthAddress}`);continue}}}}catch(e){console.error("Error retrieving on-chain announcements:",e)}}if("offChain"===t.source||"both"===t.source){const e=this,t=await new Promise((t=>{const r=[];e.get("gun-eth").get("stealth-payments").get(recipientAddress).map().once(((e,t)=>{e?.stealthAddress&&r.push({...e,id:t,source:"offChain"})})),setTimeout((()=>t(r)),2e3)}));n.push(...t)}return console.log(`Found ${n.length} stealth payments`),n}catch(e){throw console.error("Error retrieving stealth payments:",e),e}},t.chain.cleanStealthPayments=async function(e){try{const t=this,r=await t.get("gun-eth").get("stealth-payments").get(e).map().once().then();r&&Object.keys(r).forEach((async n=>{const o=r[n];o&&o.stealthAddress&&o.senderPublicKey&&o.spendingPublicKey||await t.get("gun-eth").get("stealth-payments").get(e).get(n).put(null)}))}catch(e){console.error("Error cleaning stealth payments:",e)}},e.default=t,e.MESSAGE_TO_SIGN=v,e.generatePassword=S,e.gunToEthAccount=A,Object.defineProperty(e,"__esModule",{value:!0})}));
|