From 70aafa0fef78688c8319d2e6f4f3023bfe5aa05c Mon Sep 17 00:00:00 2001 From: CoNET project Date: Fri, 29 Nov 2019 00:45:39 -0800 Subject: [PATCH] v3.2.2 --- app/localWebServer.js | 8 ++- app/localWebServer.ts | 16 ++++-- app/public/scripts/appsManager.js | 34 +++++++----- app/public/scripts/appsManager.ts | 26 +++++---- app/public/scripts/home.js | 2 +- app/public/scripts/home.ts | 2 +- app/public/scripts/socket.io.js | 8 +-- app/tools/coNETConnect.js | 11 ++-- app/tools/coNETConnect.ts | 17 +++--- app/tools/imap.js | 89 +++++++++++++++--------------- app/tools/imap.ts | 90 +++++++++++++++---------------- index.js | 2 +- index.ts | 2 +- package.json | 14 ++--- 14 files changed, 174 insertions(+), 147 deletions(-) diff --git a/app/localWebServer.js b/app/localWebServer.js index b0b64a9..4a76945 100644 --- a/app/localWebServer.js +++ b/app/localWebServer.js @@ -239,11 +239,17 @@ class localServer { console.log(`active key success! \n[${key}]`); this.keyPair.publicKey = this.config.keypair.publicKey = key; this.keyPair.verified = this.config.keypair.verified = true; + this.imapConnectData.sendToQTGate = true; + _callBack(); + Tool.saveEncryptoData(Tool.imapDataFileName1, this.imapConnectData, this.config, this.savedPasswrod, err => { + if (err) { + saveLog(`Tool.saveConfig return Error: [${err.message}]`); + } + }); return Tool.saveConfig(this.config, err => { if (err) { saveLog(`Tool.saveConfig return Error: [${err.message}]`); } - _callBack(); }); } }); diff --git a/app/localWebServer.ts b/app/localWebServer.ts index 4643086..1ec7461 100644 --- a/app/localWebServer.ts +++ b/app/localWebServer.ts @@ -215,7 +215,8 @@ export default class localServer { } if ( !this.imapConnectData.confirmRisk ) { this.imapConnectData.confirmRisk = true - return Tool.saveEncryptoData ( Tool.imapDataFileName1,this.imapConnectData, this.config, this.savedPasswrod, err => { + + return Tool.saveEncryptoData ( Tool.imapDataFileName1, this.imapConnectData, this.config, this.savedPasswrod, err => { return this.tryConnectCoNET ( socket, sessionHash ) }) } @@ -252,12 +253,20 @@ export default class localServer { console.log ( `active key success! \n[${ key }]`) this.keyPair.publicKey = this.config.keypair.publicKey = key - this.keyPair.verified = this.config.keypair.verified = true + this.keyPair.verified = this.config.keypair.verified = true + this.imapConnectData.sendToQTGate = true + _callBack () + Tool.saveEncryptoData ( Tool.imapDataFileName1, this.imapConnectData, this.config, this.savedPasswrod, err => { + if ( err ) { + saveLog (`Tool.saveConfig return Error: [${ err.message }]`) + } + }) return Tool.saveConfig ( this.config, err => { if ( err ) { saveLog (`Tool.saveConfig return Error: [${ err.message }]`) } - _callBack () + + }) } @@ -580,7 +589,6 @@ export default class localServer { } - constructor( private cmdResponse: ( cmd: QTGateAPIRequestCommand ) => void, test: boolean ) { //Express.static.mime.define({ 'message/rfc822' : ['mhtml','mht'] }) //Express.static.mime.define ({ 'multipart/related' : ['mhtml','mht'] }) diff --git a/app/public/scripts/appsManager.js b/app/public/scripts/appsManager.js index 48423f1..9325c9c 100644 --- a/app/public/scripts/appsManager.js +++ b/app/public/scripts/appsManager.js @@ -85,8 +85,7 @@ const _mainMenuObj111 = { } ] }; -const appHtml = ` -
-
`; +
+ +
+ +
`; const appMenuData = 'appmenu'; class appsManager { constructor(exit) { @@ -532,19 +535,20 @@ class appsManager { * DEBUG APP use Temp pug * */ - this.tempAppHtml(true); - appScript.startup(appScript); - this.appScript(appScript); - _view.CanadaBackground(true); - return; + /* + this.tempAppHtml ( true ) + + appScript.startup ( appScript ) + + this.appScript ( appScript ) + _view.CanadaBackground ( true ) + return /** */ /** * * Use appHtml */ /* - - this.runningAppHtml ( appHtml ) this.appHtml ( true ) @@ -552,6 +556,7 @@ class appsManager { appScript.startup ( appScript ) this.appScript ( appScript ) + /** */ this.runningAppHtml(obj[1]); this.appHtml(true); @@ -567,7 +572,10 @@ class appsManager { * use Debug * */ - return runningApp(null); + /* + return runningApp ( null ) + + /** end Debug */ if (obj) { runningApp(obj); } diff --git a/app/public/scripts/appsManager.ts b/app/public/scripts/appsManager.ts index cac8ed6..22d4673 100644 --- a/app/public/scripts/appsManager.ts +++ b/app/public/scripts/appsManager.ts @@ -92,8 +92,7 @@ const _mainMenuObj111 = { } -const appHtml = ` -
-
` +
+ +
+ +
` const appMenuData = 'appmenu' declare const Jimp @@ -582,7 +585,7 @@ class appsManager { */ - + /* this.tempAppHtml ( true ) appScript.startup ( appScript ) @@ -598,9 +601,9 @@ class appsManager { * Use appHtml */ - /* - + + /* this.runningAppHtml ( appHtml ) this.appHtml ( true ) @@ -608,6 +611,7 @@ class appsManager { appScript.startup ( appScript ) this.appScript ( appScript ) + /** */ this.runningAppHtml ( obj[1] ) @@ -627,9 +631,13 @@ class appsManager { * use Debug * */ + /* return runningApp ( null ) - + /** end Debug */ + + + if ( obj ) { runningApp ( obj ) } diff --git a/app/public/scripts/home.js b/app/public/scripts/home.js index 7318d7e..d28bd9c 100644 --- a/app/public/scripts/home.js +++ b/app/public/scripts/home.js @@ -422,7 +422,7 @@ var view_layout; const wY = 30 - height / 2; backGround_mask_circle.animate({ transform: `t${wT} ${wY}`, - r: 30 + r: 60 }, 3000, mina.easeout, changeLanguage); } } diff --git a/app/public/scripts/home.ts b/app/public/scripts/home.ts index 866fdc2..0e972d5 100644 --- a/app/public/scripts/home.ts +++ b/app/public/scripts/home.ts @@ -511,7 +511,7 @@ module view_layout { const wY = 30 - height / 2 backGround_mask_circle.animate ({ transform: `t${ wT } ${ wY }`, - r: 30 + r: 60 }, 3000, mina.easeout, changeLanguage ) } diff --git a/app/public/scripts/socket.io.js b/app/public/scripts/socket.io.js index 2d89d90..270777b 100644 --- a/app/public/scripts/socket.io.js +++ b/app/public/scripts/socket.io.js @@ -3,7 +3,7 @@ * (c) 2014-2019 Guillermo Rauch * Released under the MIT License. */ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.io=e():t.io=e()}(this,function(){return function(t){function e(n){if(r[n])return r[n].exports;var o=r[n]={exports:{},id:n,loaded:!1};return t[n].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){"use strict";function n(t,e){"object"===("undefined"==typeof t?"undefined":o(t))&&(e=t,t=void 0),e=e||{};var r,n=i(t),s=n.source,p=n.id,h=n.path,u=c[p]&&h in c[p].nsps,f=e.forceNew||e["force new connection"]||!1===e.multiplex||u;return f?r=a(s,e):(c[p]||(c[p]=a(s,e)),r=c[p]),n.query&&!e.query&&(e.query=n.query),r.socket(n.path,e)}var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i=r(1),s=r(4),a=r(9);r(3)("socket.io-client");t.exports=e=n;var c=e.managers={};e.protocol=s.protocol,e.connect=n,e.Manager=r(9),e.Socket=r(33)},function(t,e,r){"use strict";function n(t,e){var r=t;e=e||"undefined"!=typeof location&&location,null==t&&(t=e.protocol+"//"+e.host),"string"==typeof t&&("/"===t.charAt(0)&&(t="/"===t.charAt(1)?e.protocol+t:e.host+t),/^(https?|wss?):\/\//.test(t)||(t="undefined"!=typeof e?e.protocol+"//"+t:"https://"+t),r=o(t)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";var n=r.host.indexOf(":")!==-1,i=n?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+i+":"+r.port,r.href=r.protocol+"://"+i+(e&&e.port===r.port?"":":"+r.port),r}var o=r(2);r(3)("socket.io-client:url");t.exports=n},function(t,e){var r=/^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,n=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];t.exports=function(t){var e=t,o=t.indexOf("["),i=t.indexOf("]");o!=-1&&i!=-1&&(t=t.substring(0,o)+t.substring(o,i).replace(/:/g,";")+t.substring(i,t.length));for(var s=r.exec(t||""),a={},c=14;c--;)a[n[c]]=s[c]||"";return o!=-1&&i!=-1&&(a.source=e,a.host=a.host.substring(1,a.host.length-1).replace(/;/g,":"),a.authority=a.authority.replace("[","").replace("]","").replace(/;/g,":"),a.ipv6uri=!0),a}},function(t,e){"use strict";t.exports=function(){return function(){}}},function(t,e,r){function n(){}function o(t){var r=""+t.type;if(e.BINARY_EVENT!==t.type&&e.BINARY_ACK!==t.type||(r+=t.attachments+"-"),t.nsp&&"/"!==t.nsp&&(r+=t.nsp+","),null!=t.id&&(r+=t.id),null!=t.data){var n=i(t.data);if(n===!1)return m;r+=n}return r}function i(t){try{return JSON.stringify(t)}catch(t){return!1}}function s(t,e){function r(t){var r=l.deconstructPacket(t),n=o(r.packet),i=r.buffers;i.unshift(n),e(i)}l.removeBlobs(t,r)}function a(){this.reconstructor=null}function c(t){var r=0,n={type:Number(t.charAt(0))};if(null==e.types[n.type])return u("unknown packet type "+n.type);if(e.BINARY_EVENT===n.type||e.BINARY_ACK===n.type){for(var o="";"-"!==t.charAt(++r)&&(o+=t.charAt(r),r!=t.length););if(o!=Number(o)||"-"!==t.charAt(r))throw new Error("Illegal attachments");n.attachments=Number(o)}if("/"===t.charAt(r+1))for(n.nsp="";++r;){var i=t.charAt(r);if(","===i)break;if(n.nsp+=i,r===t.length)break}else n.nsp="/";var s=t.charAt(r+1);if(""!==s&&Number(s)==s){for(n.id="";++r;){var i=t.charAt(r);if(null==i||Number(i)!=i){--r;break}if(n.id+=t.charAt(r),r===t.length)break}n.id=Number(n.id)}if(t.charAt(++r)){var a=p(t.substr(r)),c=a!==!1&&(n.type===e.ERROR||d(a));if(!c)return u("invalid payload");n.data=a}return n}function p(t){try{return JSON.parse(t)}catch(t){return!1}}function h(t){this.reconPack=t,this.buffers=[]}function u(t){return{type:e.ERROR,data:"parser error: "+t}}var f=(r(3)("socket.io-parser"),r(5)),l=r(6),d=r(7),y=r(8);e.protocol=4,e.types=["CONNECT","DISCONNECT","EVENT","ACK","ERROR","BINARY_EVENT","BINARY_ACK"],e.CONNECT=0,e.DISCONNECT=1,e.EVENT=2,e.ACK=3,e.ERROR=4,e.BINARY_EVENT=5,e.BINARY_ACK=6,e.Encoder=n,e.Decoder=a;var m=e.ERROR+'"encode error"';n.prototype.encode=function(t,r){if(e.BINARY_EVENT===t.type||e.BINARY_ACK===t.type)s(t,r);else{var n=o(t);r([n])}},f(a.prototype),a.prototype.add=function(t){var r;if("string"==typeof t)r=c(t),e.BINARY_EVENT===r.type||e.BINARY_ACK===r.type?(this.reconstructor=new h(r),0===this.reconstructor.reconPack.attachments&&this.emit("decoded",r)):this.emit("decoded",r);else{if(!y(t)&&!t.base64)throw new Error("Unknown type: "+t);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");r=this.reconstructor.takeBinaryData(t),r&&(this.reconstructor=null,this.emit("decoded",r))}},a.prototype.destroy=function(){this.reconstructor&&this.reconstructor.finishedReconstruction()},h.prototype.takeBinaryData=function(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){var e=l.reconstructPacket(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null},h.prototype.finishedReconstruction=function(){this.reconPack=null,this.buffers=[]}},function(t,e,r){function n(t){if(t)return o(t)}function o(t){for(var e in n.prototype)t[e]=n.prototype[e];return t}t.exports=n,n.prototype.on=n.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this},n.prototype.once=function(t,e){function r(){this.off(t,r),e.apply(this,arguments)}return r.fn=e,this.on(t,r),this},n.prototype.off=n.prototype.removeListener=n.prototype.removeAllListeners=n.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var r=this._callbacks["$"+t];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+t],this;for(var n,o=0;o0&&!this.encoding){var t=this.packetBuffer.shift();this.packet(t)}},n.prototype.cleanup=function(){for(var t=this.subs.length,e=0;e=this._reconnectionAttempts)this.backoff.reset(),this.emitAll("reconnect_failed"),this.reconnecting=!1;else{var e=this.backoff.duration();this.reconnecting=!0;var r=setTimeout(function(){t.skipReconnect||(t.emitAll("reconnect_attempt",t.backoff.attempts),t.emitAll("reconnecting",t.backoff.attempts),t.skipReconnect||t.open(function(e){e?(t.reconnecting=!1,t.reconnect(),t.emitAll("reconnect_error",e.data)):t.onreconnect()}))},e);this.subs.push({destroy:function(){clearTimeout(r)}})}},n.prototype.onreconnect=function(){var t=this.backoff.attempts;this.reconnecting=!1,this.backoff.reset(),this.updateSocketIds(),this.emitAll("reconnect",t)}},function(t,e,r){t.exports=r(11),t.exports.parser=r(18)},function(t,e,r){function n(t,e){return this instanceof n?(e=e||{},t&&"object"==typeof t&&(e=t,t=null),t?(t=p(t),e.hostname=t.host,e.secure="https"===t.protocol||"wss"===t.protocol,e.port=t.port,t.query&&(e.query=t.query)):e.host&&(e.hostname=p(e.host).host),this.secure=null!=e.secure?e.secure:"undefined"!=typeof location&&"https:"===location.protocol,e.hostname&&!e.port&&(e.port=this.secure?"443":"80"),this.agent=e.agent||!1,this.hostname=e.hostname||("undefined"!=typeof location?location.hostname:"localhost"),this.port=e.port||("undefined"!=typeof location&&location.port?location.port:this.secure?443:80),this.query=e.query||{},"string"==typeof this.query&&(this.query=h.decode(this.query)),this.upgrade=!1!==e.upgrade,this.path=(e.path||"/engine.io").replace(/\/$/,"")+"/",this.forceJSONP=!!e.forceJSONP,this.jsonp=!1!==e.jsonp,this.forceBase64=!!e.forceBase64,this.enablesXDR=!!e.enablesXDR,this.withCredentials=!1!==e.withCredentials,this.timestampParam=e.timestampParam||"t",this.timestampRequests=e.timestampRequests,this.transports=e.transports||["polling","websocket"],this.transportOptions=e.transportOptions||{},this.readyState="",this.writeBuffer=[],this.prevBufferLen=0,this.policyPort=e.policyPort||843,this.rememberUpgrade=e.rememberUpgrade||!1,this.binaryType=null,this.onlyBinaryUpgrades=e.onlyBinaryUpgrades,this.perMessageDeflate=!1!==e.perMessageDeflate&&(e.perMessageDeflate||{}),!0===this.perMessageDeflate&&(this.perMessageDeflate={}),this.perMessageDeflate&&null==this.perMessageDeflate.threshold&&(this.perMessageDeflate.threshold=1024),this.pfx=e.pfx||null,this.key=e.key||null,this.passphrase=e.passphrase||null,this.cert=e.cert||null,this.ca=e.ca||null,this.ciphers=e.ciphers||null,this.rejectUnauthorized=void 0===e.rejectUnauthorized||e.rejectUnauthorized,this.forceNode=!!e.forceNode,this.isReactNative="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase(),("undefined"==typeof self||this.isReactNative)&&(e.extraHeaders&&Object.keys(e.extraHeaders).length>0&&(this.extraHeaders=e.extraHeaders),e.localAddress&&(this.localAddress=e.localAddress)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingIntervalTimer=null,this.pingTimeoutTimer=null,void this.open()):new n(t,e)}function o(t){var e={};for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r]);return e}var i=r(12),s=r(5),a=(r(3)("engine.io-client:socket"),r(32)),c=r(18),p=r(2),h=r(26);t.exports=n,n.priorWebsocketSuccess=!1,s(n.prototype),n.protocol=c.protocol,n.Socket=n,n.Transport=r(17),n.transports=r(12),n.parser=r(18),n.prototype.createTransport=function(t){var e=o(this.query);e.EIO=c.protocol,e.transport=t;var r=this.transportOptions[t]||{};this.id&&(e.sid=this.id);var n=new i[t]({query:e,socket:this,agent:r.agent||this.agent,hostname:r.hostname||this.hostname,port:r.port||this.port,secure:r.secure||this.secure,path:r.path||this.path,forceJSONP:r.forceJSONP||this.forceJSONP,jsonp:r.jsonp||this.jsonp,forceBase64:r.forceBase64||this.forceBase64,enablesXDR:r.enablesXDR||this.enablesXDR,withCredentials:r.withCredentials||this.withCredentials,timestampRequests:r.timestampRequests||this.timestampRequests,timestampParam:r.timestampParam||this.timestampParam,policyPort:r.policyPort||this.policyPort,pfx:r.pfx||this.pfx,key:r.key||this.key,passphrase:r.passphrase||this.passphrase,cert:r.cert||this.cert,ca:r.ca||this.ca,ciphers:r.ciphers||this.ciphers,rejectUnauthorized:r.rejectUnauthorized||this.rejectUnauthorized,perMessageDeflate:r.perMessageDeflate||this.perMessageDeflate,extraHeaders:r.extraHeaders||this.extraHeaders,forceNode:r.forceNode||this.forceNode,localAddress:r.localAddress||this.localAddress,requestTimeout:r.requestTimeout||this.requestTimeout,protocols:r.protocols||void 0,isReactNative:this.isReactNative});return n},n.prototype.open=function(){var t;if(this.rememberUpgrade&&n.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1)t="websocket";else{if(0===this.transports.length){var e=this;return void setTimeout(function(){e.emit("error","No transports available")},0)}t=this.transports[0]}this.readyState="opening";try{t=this.createTransport(t)}catch(t){return this.transports.shift(),void this.open()}t.open(),this.setTransport(t)},n.prototype.setTransport=function(t){var e=this;this.transport&&this.transport.removeAllListeners(),this.transport=t,t.on("drain",function(){e.onDrain()}).on("packet",function(t){e.onPacket(t)}).on("error",function(t){e.onError(t)}).on("close",function(){e.onClose("transport close")})},n.prototype.probe=function(t){function e(){if(u.onlyBinaryUpgrades){var t=!this.supportsBinary&&u.transport.supportsBinary;h=h||t}h||(p.send([{type:"ping",data:"probe"}]),p.once("packet",function(t){if(!h)if("pong"===t.type&&"probe"===t.data){if(u.upgrading=!0,u.emit("upgrading",p),!p)return;n.priorWebsocketSuccess="websocket"===p.name,u.transport.pause(function(){h||"closed"!==u.readyState&&(c(),u.setTransport(p),p.send([{type:"upgrade"}]),u.emit("upgrade",p),p=null,u.upgrading=!1,u.flush())})}else{var e=new Error("probe error");e.transport=p.name,u.emit("upgradeError",e)}}))}function r(){h||(h=!0,c(),p.close(),p=null)}function o(t){var e=new Error("probe error: "+t);e.transport=p.name,r(),u.emit("upgradeError",e)}function i(){o("transport closed")}function s(){o("socket closed")}function a(t){p&&t.name!==p.name&&r()}function c(){p.removeListener("open",e),p.removeListener("error",o),p.removeListener("close",i),u.removeListener("close",s),u.removeListener("upgrading",a)}var p=this.createTransport(t,{probe:1}),h=!1,u=this;n.priorWebsocketSuccess=!1,p.once("open",e),p.once("error",o),p.once("close",i),this.once("close",s),this.once("upgrading",a),p.open()},n.prototype.onOpen=function(){if(this.readyState="open",n.priorWebsocketSuccess="websocket"===this.transport.name,this.emit("open"),this.flush(),"open"===this.readyState&&this.upgrade&&this.transport.pause)for(var t=0,e=this.upgrades.length;t1?{type:b[o],data:t.substring(1)}:{type:b[o]}:k}var i=new Uint8Array(t),o=i[0],s=f(t,1);return w&&"blob"===r&&(s=new w([s])),{type:b[o],data:s}},e.decodeBase64Packet=function(t,e){var r=b[t.charAt(0)];if(!p)return{type:r,data:{base64:!0,data:t.substr(1)}};var n=p.decode(t.substr(1));return"blob"===e&&w&&(n=new w([n])),{type:r,data:n}},e.encodePayload=function(t,r,n){function o(t){return t.length+":"+t}function i(t,n){e.encodePacket(t,!!s&&r,!1,function(t){n(null,o(t))})}"function"==typeof r&&(n=r,r=null);var s=u(t);return r&&s?w&&!g?e.encodePayloadAsBlob(t,n):e.encodePayloadAsArrayBuffer(t,n):t.length?void c(t,i,function(t,e){return n(e.join(""))}):n("0:")},e.decodePayload=function(t,r,n){if("string"!=typeof t)return e.decodePayloadAsBinary(t,r,n);"function"==typeof r&&(n=r,r=null);var o;if(""===t)return n(k,0,1);for(var i,s,a="",c=0,p=t.length;c0;){for(var s=new Uint8Array(o),a=0===s[0],c="",p=1;255!==s[p];p++){if(c.length>310)return n(k,0,1);c+=s[p]}o=f(o,2+c.length),c=parseInt(c);var h=f(o,0,c);if(a)try{h=String.fromCharCode.apply(null,new Uint8Array(h))}catch(t){var u=new Uint8Array(h);h="";for(var p=0;pn&&(r=n),e>=n||e>=r||0===n)return new ArrayBuffer(0);for(var o=new Uint8Array(t),i=new Uint8Array(r-e),s=e,a=0;s=55296&&e<=56319&&o65535&&(e-=65536,o+=d(e>>>10&1023|55296),e=56320|1023&e),o+=d(e);return o}function o(t,e){if(t>=55296&&t<=57343){if(e)throw Error("Lone surrogate U+"+t.toString(16).toUpperCase()+" is not a scalar value");return!1}return!0}function i(t,e){return d(t>>e&63|128)}function s(t,e){if(0==(4294967168&t))return d(t);var r="";return 0==(4294965248&t)?r=d(t>>6&31|192):0==(4294901760&t)?(o(t,e)||(t=65533),r=d(t>>12&15|224),r+=i(t,6)):0==(4292870144&t)&&(r=d(t>>18&7|240),r+=i(t,12),r+=i(t,6)),r+=d(63&t|128)}function a(t,e){e=e||{};for(var n,o=!1!==e.strict,i=r(t),a=i.length,c=-1,p="";++c=f)throw Error("Invalid byte index");var t=255&u[l];if(l++,128==(192&t))return 63&t;throw Error("Invalid continuation byte")}function p(t){var e,r,n,i,s;if(l>f)throw Error("Invalid byte index");if(l==f)return!1;if(e=255&u[l],l++,0==(128&e))return e;if(192==(224&e)){if(r=c(),s=(31&e)<<6|r,s>=128)return s;throw Error("Invalid continuation byte")}if(224==(240&e)){if(r=c(),n=c(),s=(15&e)<<12|r<<6|n,s>=2048)return o(s,t)?s:65533;throw Error("Invalid continuation byte")}if(240==(248&e)&&(r=c(),n=c(),i=c(),s=(7&e)<<18|r<<12|n<<6|i,s>=65536&&s<=1114111))return s;throw Error("Invalid UTF-8 detected")}function h(t,e){e=e||{};var o=!1!==e.strict;u=r(t),f=u.length,l=0;for(var i,s=[];(i=p(o))!==!1;)s.push(i);return n(s)}/*! https://mths.be/utf8js v2.1.2 by @mathias */ -var u,f,l,d=String.fromCharCode;t.exports={version:"2.1.2",encode:a,decode:h}},function(t,e){!function(){"use strict";for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r=new Uint8Array(256),n=0;n>2],i+=t[(3&n[r])<<4|n[r+1]>>4],i+=t[(15&n[r+1])<<2|n[r+2]>>6],i+=t[63&n[r+2]];return o%3===2?i=i.substring(0,i.length-1)+"=":o%3===1&&(i=i.substring(0,i.length-2)+"=="),i},e.decode=function(t){var e,n,o,i,s,a=.75*t.length,c=t.length,p=0;"="===t[t.length-1]&&(a--,"="===t[t.length-2]&&a--);var h=new ArrayBuffer(a),u=new Uint8Array(h);for(e=0;e>4,u[p++]=(15&o)<<4|i>>2,u[p++]=(3&i)<<6|63&s;return h}}()},function(t,e){function r(t){return t.map(function(t){if(t.buffer instanceof ArrayBuffer){var e=t.buffer;if(t.byteLength!==e.byteLength){var r=new Uint8Array(t.byteLength);r.set(new Uint8Array(e,t.byteOffset,t.byteLength)),e=r.buffer}return e}return t})}function n(t,e){e=e||{};var n=new i;return r(t).forEach(function(t){n.append(t)}),e.type?n.getBlob(e.type):n.getBlob()}function o(t,e){return new Blob(r(t),e||{})}var i="undefined"!=typeof i?i:"undefined"!=typeof WebKitBlobBuilder?WebKitBlobBuilder:"undefined"!=typeof MSBlobBuilder?MSBlobBuilder:"undefined"!=typeof MozBlobBuilder&&MozBlobBuilder,s=function(){try{var t=new Blob(["hi"]);return 2===t.size}catch(t){return!1}}(),a=s&&function(){try{var t=new Blob([new Uint8Array([1,2])]);return 2===t.size}catch(t){return!1}}(),c=i&&i.prototype.append&&i.prototype.getBlob;"undefined"!=typeof Blob&&(n.prototype=Blob.prototype,o.prototype=Blob.prototype),t.exports=function(){return s?a?Blob:o:c?n:void 0}()},function(t,e){e.encode=function(t){var e="";for(var r in t)t.hasOwnProperty(r)&&(e.length&&(e+="&"),e+=encodeURIComponent(r)+"="+encodeURIComponent(t[r]));return e},e.decode=function(t){for(var e={},r=t.split("&"),n=0,o=r.length;n0);return e}function n(t){var e=0;for(h=0;h';i=document.createElement(t)}catch(t){i=document.createElement("iframe"),i.name=o.iframeId,i.src="javascript:0"}i.id=o.iframeId,o.form.appendChild(i),o.iframe=i}var o=this;if(!this.form){var i,s=document.createElement("form"),a=document.createElement("textarea"),c=this.iframeId="eio_iframe_"+this.index;s.className="socketio",s.style.position="absolute",s.style.top="-1000px",s.style.left="-1000px",s.target=c,s.method="POST",s.setAttribute("accept-charset","utf-8"),a.name="d",s.appendChild(a),document.body.appendChild(s),this.form=s,this.area=a}this.form.action=this.uri(),n(),t=t.replace(h,"\\\n"),this.area.value=t.replace(p,"\\n");try{this.form.submit()}catch(t){}this.iframe.attachEvent?this.iframe.onreadystatechange=function(){"complete"===o.iframe.readyState&&r()}:this.iframe.onload=r}}).call(e,function(){return this}())},function(t,e,r){function n(t){var e=t&&t.forceBase64;e&&(this.supportsBinary=!1),this.perMessageDeflate=t.perMessageDeflate,this.usingBrowserWebSocket=o&&!t.forceNode,this.protocols=t.protocols,this.usingBrowserWebSocket||(u=i),s.call(this,t)}var o,i,s=r(17),a=r(18),c=r(26),p=r(27),h=r(28);r(3)("engine.io-client:websocket");if("undefined"!=typeof WebSocket?o=WebSocket:"undefined"!=typeof self&&(o=self.WebSocket||self.MozWebSocket),"undefined"==typeof window)try{i=r(31)}catch(t){}var u=o||i;t.exports=n,p(n,s),n.prototype.name="websocket",n.prototype.supportsBinary=!0,n.prototype.doOpen=function(){if(this.check()){var t=this.uri(),e=this.protocols,r={agent:this.agent,perMessageDeflate:this.perMessageDeflate};r.pfx=this.pfx,r.key=this.key,r.passphrase=this.passphrase,r.cert=this.cert,r.ca=this.ca,r.ciphers=this.ciphers,r.rejectUnauthorized=this.rejectUnauthorized,this.extraHeaders&&(r.headers=this.extraHeaders),this.localAddress&&(r.localAddress=this.localAddress);try{this.ws=this.usingBrowserWebSocket&&!this.isReactNative?e?new u(t,e):new u(t):new u(t,e,r)}catch(t){return this.emit("error",t)}void 0===this.ws.binaryType&&(this.supportsBinary=!1),this.ws.supports&&this.ws.supports.binary?(this.supportsBinary=!0,this.ws.binaryType="nodebuffer"):this.ws.binaryType="arraybuffer",this.addEventListeners()}},n.prototype.addEventListeners=function(){var t=this;this.ws.onopen=function(){t.onOpen()},this.ws.onclose=function(){t.onClose()},this.ws.onmessage=function(e){t.onData(e.data)},this.ws.onerror=function(e){t.onError("websocket error",e)}},n.prototype.write=function(t){function e(){r.emit("flush"),setTimeout(function(){r.writable=!0,r.emit("drain")},0)}var r=this;this.writable=!1;for(var n=t.length,o=0,i=n;o0&&t.jitter<=1?t.jitter:0,this.attempts=0}t.exports=r,r.prototype.duration=function(){var t=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),r=Math.floor(e*this.jitter*t);t=0==(1&Math.floor(10*e))?t-r:t+r}return 0|Math.min(t,this.max)},r.prototype.reset=function(){this.attempts=0},r.prototype.setMin=function(t){this.ms=t},r.prototype.setMax=function(t){this.max=t},r.prototype.setJitter=function(t){this.jitter=t}}])}); -//# sourceMappingURL=socket.io.slim.js.map \ No newline at end of file +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.io=e():t.io=e()}(this,function(){return function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return t[r].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){function r(t,e){"object"==typeof t&&(e=t,t=void 0),e=e||{};var n,r=o(t),i=r.source,u=r.id,p=r.path,h=c[u]&&p in c[u].nsps,f=e.forceNew||e["force new connection"]||!1===e.multiplex||h;return f?(a("ignoring socket cache for %s",i),n=s(i,e)):(c[u]||(a("new io instance for %s",i),c[u]=s(i,e)),n=c[u]),r.query&&!e.query&&(e.query=r.query),n.socket(r.path,e)}var o=n(1),i=n(7),s=n(15),a=n(3)("socket.io-client");t.exports=e=r;var c=e.managers={};e.protocol=i.protocol,e.connect=r,e.Manager=n(15),e.Socket=n(39)},function(t,e,n){function r(t,e){var n=t;e=e||"undefined"!=typeof location&&location,null==t&&(t=e.protocol+"//"+e.host),"string"==typeof t&&("/"===t.charAt(0)&&(t="/"===t.charAt(1)?e.protocol+t:e.host+t),/^(https?|wss?):\/\//.test(t)||(i("protocol-less url %s",t),t="undefined"!=typeof e?e.protocol+"//"+t:"https://"+t),i("parse %s",t),n=o(t)),n.port||(/^(http|ws)$/.test(n.protocol)?n.port="80":/^(http|ws)s$/.test(n.protocol)&&(n.port="443")),n.path=n.path||"/";var r=n.host.indexOf(":")!==-1,s=r?"["+n.host+"]":n.host;return n.id=n.protocol+"://"+s+":"+n.port,n.href=n.protocol+"://"+s+(e&&e.port===n.port?"":":"+n.port),n}var o=n(2),i=n(3)("socket.io-client:url");t.exports=r},function(t,e){var n=/^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,r=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];t.exports=function(t){var e=t,o=t.indexOf("["),i=t.indexOf("]");o!=-1&&i!=-1&&(t=t.substring(0,o)+t.substring(o,i).replace(/:/g,";")+t.substring(i,t.length));for(var s=n.exec(t||""),a={},c=14;c--;)a[r[c]]=s[c]||"";return o!=-1&&i!=-1&&(a.source=e,a.host=a.host.substring(1,a.host.length-1).replace(/;/g,":"),a.authority=a.authority.replace("[","").replace("]","").replace(/;/g,":"),a.ipv6uri=!0),a}},function(t,e,n){(function(r){"use strict";function o(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))}function i(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+t.exports.humanize(this.diff),this.useColors){var n="color: "+this.color;e.splice(1,0,n,"color: inherit");var r=0,o=0;e[0].replace(/%[a-zA-Z%]/g,function(t){"%%"!==t&&(r++,"%c"===t&&(o=r))}),e.splice(o,0,n)}}function s(){var t;return"object"===("undefined"==typeof console?"undefined":p(console))&&console.log&&(t=console).log.apply(t,arguments)}function a(t){try{t?e.storage.setItem("debug",t):e.storage.removeItem("debug")}catch(n){}}function c(){var t=void 0;try{t=e.storage.getItem("debug")}catch(n){}return!t&&"undefined"!=typeof r&&"env"in r&&(t=r.env.DEBUG),t}function u(){try{return localStorage}catch(t){}}var p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};e.log=s,e.formatArgs=i,e.save=a,e.load=c,e.useColors=o,e.storage=u(),e.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.exports=n(5)(e);var h=t.exports.formatters;h.j=function(t){try{return JSON.stringify(t)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}).call(e,n(4))},function(t,e){function n(){throw new Error("setTimeout has not been defined")}function r(){throw new Error("clearTimeout has not been defined")}function o(t){if(p===setTimeout)return setTimeout(t,0);if((p===n||!p)&&setTimeout)return p=setTimeout,setTimeout(t,0);try{return p(t,0)}catch(e){try{return p.call(null,t,0)}catch(e){return p.call(this,t,0)}}}function i(t){if(h===clearTimeout)return clearTimeout(t);if((h===r||!h)&&clearTimeout)return h=clearTimeout,clearTimeout(t);try{return h(t)}catch(e){try{return h.call(null,t)}catch(e){return h.call(this,t)}}}function s(){y&&l&&(y=!1,l.length?d=l.concat(d):m=-1,d.length&&a())}function a(){if(!y){var t=o(s);y=!0;for(var e=d.length;e;){for(l=d,d=[];++m1)for(var n=1;n100)){var e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(t);if(e){var n=parseFloat(e[1]),r=(e[2]||"ms").toLowerCase();switch(r){case"years":case"year":case"yrs":case"yr":case"y":return n*h;case"weeks":case"week":case"w":return n*p;case"days":case"day":case"d":return n*u;case"hours":case"hour":case"hrs":case"hr":case"h":return n*c;case"minutes":case"minute":case"mins":case"min":case"m":return n*a;case"seconds":case"second":case"secs":case"sec":case"s":return n*s;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}}}function r(t){var e=Math.abs(t);return e>=u?Math.round(t/u)+"d":e>=c?Math.round(t/c)+"h":e>=a?Math.round(t/a)+"m":e>=s?Math.round(t/s)+"s":t+"ms"}function o(t){var e=Math.abs(t);return e>=u?i(t,e,u,"day"):e>=c?i(t,e,c,"hour"):e>=a?i(t,e,a,"minute"):e>=s?i(t,e,s,"second"):t+" ms"}function i(t,e,n,r){var o=e>=1.5*n;return Math.round(t/n)+" "+r+(o?"s":"")}var s=1e3,a=60*s,c=60*a,u=24*c,p=7*u,h=365.25*u;t.exports=function(t,e){e=e||{};var i=typeof t;if("string"===i&&t.length>0)return n(t);if("number"===i&&isFinite(t))return e["long"]?o(t):r(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))}},function(t,e,n){function r(){}function o(t){var n=""+t.type;if(e.BINARY_EVENT!==t.type&&e.BINARY_ACK!==t.type||(n+=t.attachments+"-"),t.nsp&&"/"!==t.nsp&&(n+=t.nsp+","),null!=t.id&&(n+=t.id),null!=t.data){var r=i(t.data);if(r===!1)return g;n+=r}return f("encoded %j as %s",t,n),n}function i(t){try{return JSON.stringify(t)}catch(e){return!1}}function s(t,e){function n(t){var n=d.deconstructPacket(t),r=o(n.packet),i=n.buffers;i.unshift(r),e(i)}d.removeBlobs(t,n)}function a(){this.reconstructor=null}function c(t){var n=0,r={type:Number(t.charAt(0))};if(null==e.types[r.type])return h("unknown packet type "+r.type);if(e.BINARY_EVENT===r.type||e.BINARY_ACK===r.type){for(var o="";"-"!==t.charAt(++n)&&(o+=t.charAt(n),n!=t.length););if(o!=Number(o)||"-"!==t.charAt(n))throw new Error("Illegal attachments");r.attachments=Number(o)}if("/"===t.charAt(n+1))for(r.nsp="";++n;){var i=t.charAt(n);if(","===i)break;if(r.nsp+=i,n===t.length)break}else r.nsp="/";var s=t.charAt(n+1);if(""!==s&&Number(s)==s){for(r.id="";++n;){var i=t.charAt(n);if(null==i||Number(i)!=i){--n;break}if(r.id+=t.charAt(n),n===t.length)break}r.id=Number(r.id)}if(t.charAt(++n)){var a=u(t.substr(n)),c=a!==!1&&(r.type===e.ERROR||y(a));if(!c)return h("invalid payload");r.data=a}return f("decoded %s as %j",t,r),r}function u(t){try{return JSON.parse(t)}catch(e){return!1}}function p(t){this.reconPack=t,this.buffers=[]}function h(t){return{type:e.ERROR,data:"parser error: "+t}}var f=n(8)("socket.io-parser"),l=n(11),d=n(12),y=n(13),m=n(14);e.protocol=4,e.types=["CONNECT","DISCONNECT","EVENT","ACK","ERROR","BINARY_EVENT","BINARY_ACK"],e.CONNECT=0,e.DISCONNECT=1,e.EVENT=2,e.ACK=3,e.ERROR=4,e.BINARY_EVENT=5,e.BINARY_ACK=6,e.Encoder=r,e.Decoder=a;var g=e.ERROR+'"encode error"';r.prototype.encode=function(t,n){if(f("encoding packet %j",t),e.BINARY_EVENT===t.type||e.BINARY_ACK===t.type)s(t,n);else{var r=o(t);n([r])}},l(a.prototype),a.prototype.add=function(t){var n;if("string"==typeof t)n=c(t),e.BINARY_EVENT===n.type||e.BINARY_ACK===n.type?(this.reconstructor=new p(n),0===this.reconstructor.reconPack.attachments&&this.emit("decoded",n)):this.emit("decoded",n);else{if(!m(t)&&!t.base64)throw new Error("Unknown type: "+t);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");n=this.reconstructor.takeBinaryData(t),n&&(this.reconstructor=null,this.emit("decoded",n))}},a.prototype.destroy=function(){this.reconstructor&&this.reconstructor.finishedReconstruction()},p.prototype.takeBinaryData=function(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){var e=d.reconstructPacket(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null},p.prototype.finishedReconstruction=function(){this.reconPack=null,this.buffers=[]}},function(t,e,n){(function(r){"use strict";function o(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))}function i(t){var n=this.useColors;if(t[0]=(n?"%c":"")+this.namespace+(n?" %c":" ")+t[0]+(n?"%c ":" ")+"+"+e.humanize(this.diff),n){var r="color: "+this.color;t.splice(1,0,r,"color: inherit");var o=0,i=0;t[0].replace(/%[a-zA-Z%]/g,function(t){"%%"!==t&&(o++,"%c"===t&&(i=o))}),t.splice(i,0,r)}}function s(){return"object"===("undefined"==typeof console?"undefined":p(console))&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function a(t){try{null==t?e.storage.removeItem("debug"):e.storage.debug=t}catch(n){}}function c(){var t;try{t=e.storage.debug}catch(n){}return!t&&"undefined"!=typeof r&&"env"in r&&(t=r.env.DEBUG),t}function u(){try{return window.localStorage}catch(t){}}var p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};e=t.exports=n(9),e.log=s,e.formatArgs=i,e.save=a,e.load=c,e.useColors=o,e.storage="undefined"!=typeof chrome&&"undefined"!=typeof chrome.storage?chrome.storage.local:u(),e.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],e.formatters.j=function(t){try{return JSON.stringify(t)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},e.enable(c())}).call(e,n(4))},function(t,e,n){"use strict";function r(t){var n,r=0;for(n in t)r=(r<<5)-r+t.charCodeAt(n),r|=0;return e.colors[Math.abs(r)%e.colors.length]}function o(t){function n(){if(n.enabled){var t=n,r=+new Date,i=r-(o||r);t.diff=i,t.prev=o,t.curr=r,o=r;for(var s=new Array(arguments.length),a=0;a100)){var e=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(t);if(e){var n=parseFloat(e[1]),r=(e[2]||"ms").toLowerCase();switch(r){case"years":case"year":case"yrs":case"yr":case"y":return n*p;case"days":case"day":case"d":return n*u;case"hours":case"hour":case"hrs":case"hr":case"h":return n*c;case"minutes":case"minute":case"mins":case"min":case"m":return n*a;case"seconds":case"second":case"secs":case"sec":case"s":return n*s;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}}}function r(t){return t>=u?Math.round(t/u)+"d":t>=c?Math.round(t/c)+"h":t>=a?Math.round(t/a)+"m":t>=s?Math.round(t/s)+"s":t+"ms"}function o(t){return i(t,u,"day")||i(t,c,"hour")||i(t,a,"minute")||i(t,s,"second")||t+" ms"}function i(t,e,n){if(!(t0)return n(t);if("number"===i&&isNaN(t)===!1)return e["long"]?o(t):r(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))}},function(t,e,n){function r(t){if(t)return o(t)}function o(t){for(var e in r.prototype)t[e]=r.prototype[e];return t}t.exports=r,r.prototype.on=r.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this},r.prototype.once=function(t,e){function n(){this.off(t,n),e.apply(this,arguments)}return n.fn=e,this.on(t,n),this},r.prototype.off=r.prototype.removeListener=r.prototype.removeAllListeners=r.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n=this._callbacks["$"+t];if(!n)return this;if(1==arguments.length)return delete this._callbacks["$"+t],this;for(var r,o=0;o0&&!this.encoding){var t=this.packetBuffer.shift();this.packet(t)}},r.prototype.cleanup=function(){p("cleanup");for(var t=this.subs.length,e=0;e=this._reconnectionAttempts)p("reconnect failed"),this.backoff.reset(),this.emitAll("reconnect_failed"),this.reconnecting=!1;else{var e=this.backoff.duration();p("will wait %dms before reconnect attempt",e),this.reconnecting=!0;var n=setTimeout(function(){t.skipReconnect||(p("attempting reconnect"),t.emitAll("reconnect_attempt",t.backoff.attempts),t.emitAll("reconnecting",t.backoff.attempts),t.skipReconnect||t.open(function(e){e?(p("reconnect attempt error"),t.reconnecting=!1,t.reconnect(),t.emitAll("reconnect_error",e.data)):(p("reconnect success"),t.onreconnect())}))},e);this.subs.push({destroy:function(){clearTimeout(n)}})}},r.prototype.onreconnect=function(){var t=this.backoff.attempts;this.reconnecting=!1,this.backoff.reset(),this.updateSocketIds(),this.emitAll("reconnect",t)}},function(t,e,n){t.exports=n(17),t.exports.parser=n(24)},function(t,e,n){function r(t,e){return this instanceof r?(e=e||{},t&&"object"==typeof t&&(e=t,t=null),t?(t=p(t),e.hostname=t.host,e.secure="https"===t.protocol||"wss"===t.protocol,e.port=t.port,t.query&&(e.query=t.query)):e.host&&(e.hostname=p(e.host).host),this.secure=null!=e.secure?e.secure:"undefined"!=typeof location&&"https:"===location.protocol,e.hostname&&!e.port&&(e.port=this.secure?"443":"80"),this.agent=e.agent||!1,this.hostname=e.hostname||("undefined"!=typeof location?location.hostname:"localhost"),this.port=e.port||("undefined"!=typeof location&&location.port?location.port:this.secure?443:80),this.query=e.query||{},"string"==typeof this.query&&(this.query=h.decode(this.query)),this.upgrade=!1!==e.upgrade,this.path=(e.path||"/engine.io").replace(/\/$/,"")+"/",this.forceJSONP=!!e.forceJSONP,this.jsonp=!1!==e.jsonp,this.forceBase64=!!e.forceBase64,this.enablesXDR=!!e.enablesXDR,this.withCredentials=!1!==e.withCredentials,this.timestampParam=e.timestampParam||"t",this.timestampRequests=e.timestampRequests,this.transports=e.transports||["polling","websocket"],this.transportOptions=e.transportOptions||{},this.readyState="",this.writeBuffer=[],this.prevBufferLen=0,this.policyPort=e.policyPort||843,this.rememberUpgrade=e.rememberUpgrade||!1,this.binaryType=null,this.onlyBinaryUpgrades=e.onlyBinaryUpgrades,this.perMessageDeflate=!1!==e.perMessageDeflate&&(e.perMessageDeflate||{}),!0===this.perMessageDeflate&&(this.perMessageDeflate={}),this.perMessageDeflate&&null==this.perMessageDeflate.threshold&&(this.perMessageDeflate.threshold=1024),this.pfx=e.pfx||null,this.key=e.key||null,this.passphrase=e.passphrase||null,this.cert=e.cert||null,this.ca=e.ca||null,this.ciphers=e.ciphers||null,this.rejectUnauthorized=void 0===e.rejectUnauthorized||e.rejectUnauthorized,this.forceNode=!!e.forceNode,this.isReactNative="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase(),("undefined"==typeof self||this.isReactNative)&&(e.extraHeaders&&Object.keys(e.extraHeaders).length>0&&(this.extraHeaders=e.extraHeaders),e.localAddress&&(this.localAddress=e.localAddress)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingIntervalTimer=null,this.pingTimeoutTimer=null,void this.open()):new r(t,e)}function o(t){var e={};for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);return e}var i=n(18),s=n(11),a=n(3)("engine.io-client:socket"),c=n(38),u=n(24),p=n(2),h=n(32);t.exports=r,r.priorWebsocketSuccess=!1,s(r.prototype),r.protocol=u.protocol,r.Socket=r,r.Transport=n(23),r.transports=n(18),r.parser=n(24),r.prototype.createTransport=function(t){a('creating transport "%s"',t);var e=o(this.query);e.EIO=u.protocol,e.transport=t;var n=this.transportOptions[t]||{};this.id&&(e.sid=this.id);var r=new i[t]({query:e,socket:this,agent:n.agent||this.agent,hostname:n.hostname||this.hostname,port:n.port||this.port,secure:n.secure||this.secure,path:n.path||this.path,forceJSONP:n.forceJSONP||this.forceJSONP,jsonp:n.jsonp||this.jsonp,forceBase64:n.forceBase64||this.forceBase64,enablesXDR:n.enablesXDR||this.enablesXDR,withCredentials:n.withCredentials||this.withCredentials,timestampRequests:n.timestampRequests||this.timestampRequests,timestampParam:n.timestampParam||this.timestampParam,policyPort:n.policyPort||this.policyPort,pfx:n.pfx||this.pfx,key:n.key||this.key,passphrase:n.passphrase||this.passphrase,cert:n.cert||this.cert,ca:n.ca||this.ca,ciphers:n.ciphers||this.ciphers,rejectUnauthorized:n.rejectUnauthorized||this.rejectUnauthorized,perMessageDeflate:n.perMessageDeflate||this.perMessageDeflate,extraHeaders:n.extraHeaders||this.extraHeaders,forceNode:n.forceNode||this.forceNode,localAddress:n.localAddress||this.localAddress,requestTimeout:n.requestTimeout||this.requestTimeout,protocols:n.protocols||void 0,isReactNative:this.isReactNative});return r},r.prototype.open=function(){var t;if(this.rememberUpgrade&&r.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1)t="websocket";else{ +if(0===this.transports.length){var e=this;return void setTimeout(function(){e.emit("error","No transports available")},0)}t=this.transports[0]}this.readyState="opening";try{t=this.createTransport(t)}catch(n){return this.transports.shift(),void this.open()}t.open(),this.setTransport(t)},r.prototype.setTransport=function(t){a("setting transport %s",t.name);var e=this;this.transport&&(a("clearing existing transport %s",this.transport.name),this.transport.removeAllListeners()),this.transport=t,t.on("drain",function(){e.onDrain()}).on("packet",function(t){e.onPacket(t)}).on("error",function(t){e.onError(t)}).on("close",function(){e.onClose("transport close")})},r.prototype.probe=function(t){function e(){if(f.onlyBinaryUpgrades){var e=!this.supportsBinary&&f.transport.supportsBinary;h=h||e}h||(a('probe transport "%s" opened',t),p.send([{type:"ping",data:"probe"}]),p.once("packet",function(e){if(!h)if("pong"===e.type&&"probe"===e.data){if(a('probe transport "%s" pong',t),f.upgrading=!0,f.emit("upgrading",p),!p)return;r.priorWebsocketSuccess="websocket"===p.name,a('pausing current transport "%s"',f.transport.name),f.transport.pause(function(){h||"closed"!==f.readyState&&(a("changing transport and sending upgrade packet"),u(),f.setTransport(p),p.send([{type:"upgrade"}]),f.emit("upgrade",p),p=null,f.upgrading=!1,f.flush())})}else{a('probe transport "%s" failed',t);var n=new Error("probe error");n.transport=p.name,f.emit("upgradeError",n)}}))}function n(){h||(h=!0,u(),p.close(),p=null)}function o(e){var r=new Error("probe error: "+e);r.transport=p.name,n(),a('probe transport "%s" failed because of error: %s',t,e),f.emit("upgradeError",r)}function i(){o("transport closed")}function s(){o("socket closed")}function c(t){p&&t.name!==p.name&&(a('"%s" works - aborting "%s"',t.name,p.name),n())}function u(){p.removeListener("open",e),p.removeListener("error",o),p.removeListener("close",i),f.removeListener("close",s),f.removeListener("upgrading",c)}a('probing transport "%s"',t);var p=this.createTransport(t,{probe:1}),h=!1,f=this;r.priorWebsocketSuccess=!1,p.once("open",e),p.once("error",o),p.once("close",i),this.once("close",s),this.once("upgrading",c),p.open()},r.prototype.onOpen=function(){if(a("socket open"),this.readyState="open",r.priorWebsocketSuccess="websocket"===this.transport.name,this.emit("open"),this.flush(),"open"===this.readyState&&this.upgrade&&this.transport.pause){a("starting upgrade probes");for(var t=0,e=this.upgrades.length;t1?{type:b[o],data:t.substring(1)}:{type:b[o]}:C}var i=new Uint8Array(t),o=i[0],s=f(t,1);return w&&"blob"===n&&(s=new w([s])),{type:b[o],data:s}},e.decodeBase64Packet=function(t,e){var n=b[t.charAt(0)];if(!u)return{type:n,data:{base64:!0,data:t.substr(1)}};var r=u.decode(t.substr(1));return"blob"===e&&w&&(r=new w([r])),{type:n,data:r}},e.encodePayload=function(t,n,r){function o(t){return t.length+":"+t}function i(t,r){e.encodePacket(t,!!s&&n,!1,function(t){r(null,o(t))})}"function"==typeof n&&(r=n,n=null);var s=h(t);return n&&s?w&&!g?e.encodePayloadAsBlob(t,r):e.encodePayloadAsArrayBuffer(t,r):t.length?void c(t,i,function(t,e){return r(e.join(""))}):r("0:")},e.decodePayload=function(t,n,r){if("string"!=typeof t)return e.decodePayloadAsBinary(t,n,r);"function"==typeof n&&(r=n,n=null);var o;if(""===t)return r(C,0,1);for(var i,s,a="",c=0,u=t.length;c0;){for(var s=new Uint8Array(o),a=0===s[0],c="",u=1;255!==s[u];u++){if(c.length>310)return r(C,0,1);c+=s[u]}o=f(o,2+c.length),c=parseInt(c);var p=f(o,0,c);if(a)try{p=String.fromCharCode.apply(null,new Uint8Array(p))}catch(h){var l=new Uint8Array(p);p="";for(var u=0;ur&&(n=r),e>=r||e>=n||0===r)return new ArrayBuffer(0);for(var o=new Uint8Array(t),i=new Uint8Array(n-e),s=e,a=0;s=55296&&e<=56319&&o65535&&(e-=65536,o+=d(e>>>10&1023|55296),e=56320|1023&e),o+=d(e);return o}function o(t,e){if(t>=55296&&t<=57343){if(e)throw Error("Lone surrogate U+"+t.toString(16).toUpperCase()+" is not a scalar value");return!1}return!0}function i(t,e){return d(t>>e&63|128)}function s(t,e){if(0==(4294967168&t))return d(t);var n="";return 0==(4294965248&t)?n=d(t>>6&31|192):0==(4294901760&t)?(o(t,e)||(t=65533),n=d(t>>12&15|224),n+=i(t,6)):0==(4292870144&t)&&(n=d(t>>18&7|240),n+=i(t,12),n+=i(t,6)),n+=d(63&t|128)}function a(t,e){e=e||{};for(var r,o=!1!==e.strict,i=n(t),a=i.length,c=-1,u="";++c=f)throw Error("Invalid byte index");var t=255&h[l];if(l++,128==(192&t))return 63&t;throw Error("Invalid continuation byte")}function u(t){var e,n,r,i,s;if(l>f)throw Error("Invalid byte index");if(l==f)return!1;if(e=255&h[l],l++,0==(128&e))return e;if(192==(224&e)){if(n=c(),s=(31&e)<<6|n,s>=128)return s;throw Error("Invalid continuation byte")}if(224==(240&e)){if(n=c(),r=c(),s=(15&e)<<12|n<<6|r,s>=2048)return o(s,t)?s:65533;throw Error("Invalid continuation byte")}if(240==(248&e)&&(n=c(),r=c(),i=c(),s=(7&e)<<18|n<<12|r<<6|i,s>=65536&&s<=1114111))return s;throw Error("Invalid UTF-8 detected")}function p(t,e){e=e||{};var o=!1!==e.strict;h=n(t),f=h.length,l=0;for(var i,s=[];(i=u(o))!==!1;)s.push(i);return r(s)}/*! https://mths.be/utf8js v2.1.2 by @mathias */ +var h,f,l,d=String.fromCharCode;t.exports={version:"2.1.2",encode:a,decode:p}},function(t,e){!function(){"use strict";for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n=new Uint8Array(256),r=0;r>2],i+=t[(3&r[n])<<4|r[n+1]>>4],i+=t[(15&r[n+1])<<2|r[n+2]>>6],i+=t[63&r[n+2]];return o%3===2?i=i.substring(0,i.length-1)+"=":o%3===1&&(i=i.substring(0,i.length-2)+"=="),i},e.decode=function(t){var e,r,o,i,s,a=.75*t.length,c=t.length,u=0;"="===t[t.length-1]&&(a--,"="===t[t.length-2]&&a--);var p=new ArrayBuffer(a),h=new Uint8Array(p);for(e=0;e>4,h[u++]=(15&o)<<4|i>>2,h[u++]=(3&i)<<6|63&s;return p}}()},function(t,e){function n(t){return t.map(function(t){if(t.buffer instanceof ArrayBuffer){var e=t.buffer;if(t.byteLength!==e.byteLength){var n=new Uint8Array(t.byteLength);n.set(new Uint8Array(e,t.byteOffset,t.byteLength)),e=n.buffer}return e}return t})}function r(t,e){e=e||{};var r=new i;return n(t).forEach(function(t){r.append(t)}),e.type?r.getBlob(e.type):r.getBlob()}function o(t,e){return new Blob(n(t),e||{})}var i="undefined"!=typeof i?i:"undefined"!=typeof WebKitBlobBuilder?WebKitBlobBuilder:"undefined"!=typeof MSBlobBuilder?MSBlobBuilder:"undefined"!=typeof MozBlobBuilder&&MozBlobBuilder,s=function(){try{var t=new Blob(["hi"]);return 2===t.size}catch(e){return!1}}(),a=s&&function(){try{var t=new Blob([new Uint8Array([1,2])]);return 2===t.size}catch(e){return!1}}(),c=i&&i.prototype.append&&i.prototype.getBlob;"undefined"!=typeof Blob&&(r.prototype=Blob.prototype,o.prototype=Blob.prototype),t.exports=function(){return s?a?Blob:o:c?r:void 0}()},function(t,e){e.encode=function(t){var e="";for(var n in t)t.hasOwnProperty(n)&&(e.length&&(e+="&"),e+=encodeURIComponent(n)+"="+encodeURIComponent(t[n]));return e},e.decode=function(t){for(var e={},n=t.split("&"),r=0,o=n.length;r0);return e}function r(t){var e=0;for(p=0;p';i=document.createElement(e)}catch(t){i=document.createElement("iframe"),i.name=o.iframeId,i.src="javascript:0"}i.id=o.iframeId,o.form.appendChild(i),o.iframe=i}var o=this;if(!this.form){var i,s=document.createElement("form"),a=document.createElement("textarea"),c=this.iframeId="eio_iframe_"+this.index;s.className="socketio",s.style.position="absolute",s.style.top="-1000px",s.style.left="-1000px",s.target=c,s.method="POST",s.setAttribute("accept-charset","utf-8"),a.name="d",s.appendChild(a),document.body.appendChild(s),this.form=s,this.area=a}this.form.action=this.uri(),r(),t=t.replace(p,"\\\n"),this.area.value=t.replace(u,"\\n");try{this.form.submit()}catch(h){}this.iframe.attachEvent?this.iframe.onreadystatechange=function(){"complete"===o.iframe.readyState&&n()}:this.iframe.onload=n}}).call(e,function(){return this}())},function(t,e,n){function r(t){var e=t&&t.forceBase64;e&&(this.supportsBinary=!1),this.perMessageDeflate=t.perMessageDeflate,this.usingBrowserWebSocket=o&&!t.forceNode,this.protocols=t.protocols,this.usingBrowserWebSocket||(l=i),s.call(this,t)}var o,i,s=n(23),a=n(24),c=n(32),u=n(33),p=n(34),h=n(3)("engine.io-client:websocket");if("undefined"!=typeof WebSocket?o=WebSocket:"undefined"!=typeof self&&(o=self.WebSocket||self.MozWebSocket),"undefined"==typeof window)try{i=n(37)}catch(f){}var l=o||i;t.exports=r,u(r,s),r.prototype.name="websocket",r.prototype.supportsBinary=!0,r.prototype.doOpen=function(){if(this.check()){var t=this.uri(),e=this.protocols,n={agent:this.agent,perMessageDeflate:this.perMessageDeflate};n.pfx=this.pfx,n.key=this.key,n.passphrase=this.passphrase,n.cert=this.cert,n.ca=this.ca,n.ciphers=this.ciphers,n.rejectUnauthorized=this.rejectUnauthorized,this.extraHeaders&&(n.headers=this.extraHeaders),this.localAddress&&(n.localAddress=this.localAddress);try{this.ws=this.usingBrowserWebSocket&&!this.isReactNative?e?new l(t,e):new l(t):new l(t,e,n)}catch(r){return this.emit("error",r)}void 0===this.ws.binaryType&&(this.supportsBinary=!1),this.ws.supports&&this.ws.supports.binary?(this.supportsBinary=!0,this.ws.binaryType="nodebuffer"):this.ws.binaryType="arraybuffer",this.addEventListeners()}},r.prototype.addEventListeners=function(){var t=this;this.ws.onopen=function(){t.onOpen()},this.ws.onclose=function(){t.onClose()},this.ws.onmessage=function(e){t.onData(e.data)},this.ws.onerror=function(e){t.onError("websocket error",e)}},r.prototype.write=function(t){function e(){n.emit("flush"),setTimeout(function(){n.writable=!0,n.emit("drain")},0)}var n=this;this.writable=!1;for(var r=t.length,o=0,i=r;o0&&t.jitter<=1?t.jitter:0,this.attempts=0}t.exports=n,n.prototype.duration=function(){var t=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),n=Math.floor(e*this.jitter*t);t=0==(1&Math.floor(10*e))?t-n:t+n}return 0|Math.min(t,this.max)},n.prototype.reset=function(){this.attempts=0},n.prototype.setMin=function(t){this.ms=t},n.prototype.setMax=function(t){this.max=t},n.prototype.setJitter=function(t){this.jitter=t}}])}); +//# sourceMappingURL=socket.io.js.map \ No newline at end of file diff --git a/app/tools/coNETConnect.js b/app/tools/coNETConnect.js index 3e6b991..a3c7e62 100644 --- a/app/tools/coNETConnect.js +++ b/app/tools/coNETConnect.js @@ -79,12 +79,13 @@ class default_1 extends Imap.imapPeer { }); this.on('ping', () => { this.sockerServer.emit('tryConnectCoNETStage', null, 1); - return this.sockerServer.emit('tryConnectCoNETStage', null, 2); + this.sockerServer.emit('tryConnectCoNETStage', null, 2); + if (sentConnectMail) { + console.log(`CoNETConnect class sentConnectMail = true`); + this.sockerServer.emit('tryConnectCoNETStage', null, 3); + return this.sendRequestMail(); + } }); - if (sentConnectMail) { - this.sockerServer.emit('tryConnectCoNETStage', null, 3); - return this.sendRequestMail(); - } } exit1(err) { this.sockerServer.emit('tryConnectCoNETStage', null, -1); diff --git a/app/tools/coNETConnect.ts b/app/tools/coNETConnect.ts index 3231cce..a647a9c 100644 --- a/app/tools/coNETConnect.ts +++ b/app/tools/coNETConnect.ts @@ -69,7 +69,7 @@ export default class extends Imap.imapPeer { - constructor ( public imapData: IinputData, private sockerServer: SocketIO.Server, private openKeyOption, private sentConnectMail, private publicKey, private nodeEmailAddress, + constructor ( public imapData: IinputData, private sockerServer, private openKeyOption, private sentConnectMail, private publicKey, private nodeEmailAddress, private cmdResponse: ( mail: string, hashCode: string ) => void, public _exit: ( err ) => void ) { super ( imapData, imapData.clientFolder, imapData.serverFolder, ( encryptText: string, CallBack ) => { @@ -117,15 +117,16 @@ export default class extends Imap.imapPeer { this.on ( 'ping', () => { this.sockerServer.emit ( 'tryConnectCoNETStage', null, 1 ) - return this.sockerServer.emit ( 'tryConnectCoNETStage', null, 2 ) + this.sockerServer.emit ( 'tryConnectCoNETStage', null, 2 ) + + if ( sentConnectMail ) { + console.log (`CoNETConnect class sentConnectMail = true`) + this.sockerServer.emit ( 'tryConnectCoNETStage', null, 3 ) + return this.sendRequestMail () + + } }) - if ( sentConnectMail ) { - this.sockerServer.emit ( 'tryConnectCoNETStage', null, 3 ) - return this.sendRequestMail () - - } - } public requestCoNET_v1 ( uuid: string, text: string, CallBack ) { diff --git a/app/tools/imap.js b/app/tools/imap.js index c50e009..cbe2efb 100644 --- a/app/tools/imap.js +++ b/app/tools/imap.js @@ -296,7 +296,7 @@ class ImapServerSwitchStream extends Stream.Transform { }, (err) => { this.runningCommand = null; if (err) { - saveLog(`ImapServerSwitchStream [${this.imapServer.listenFolder || this.imapServer.imapSerialID}] doNewMail ERROR! [${err.message}]`); + debug ? saveLog(`ImapServerSwitchStream [${this.imapServer.listenFolder || this.imapServer.imapSerialID}] doNewMail ERROR! [${err.message}]`) : null; return this.imapServer.destroyAll(err); } if (haveMoreNewMail || havemore) { @@ -819,7 +819,7 @@ class ImapServerSwitchStream extends Stream.Transform { this.commandProcess = (text, cmdArray, next, _callback) => { switch (cmdArray[0]) { case '*': { - saveLog(`IMAP listAllMailBox this.commandProcess text = [${text}]`); + debug ? saveLog(`IMAP listAllMailBox this.commandProcess text = [${text}]`) : null; if (/^LIST/i.test(cmdArray[1])) { boxes.push(cmdArray[2] + ',' + cmdArray[4]); } @@ -864,7 +864,7 @@ class qtGateImap extends Event.EventEmitter { //saveLog ( `new qtGateImap imapSerialID [${ this.imapSerialID }] listenFolder [${ this.listenFolder }] writeFolder [${ this.writeFolder }]`, true ) this.connect(); this.once(`error`, err => { - saveLog(`[${this.imapSerialID}] this.on error ${err && err.message ? err.message : null}`); + debug ? saveLog(`[${this.imapSerialID}] this.on error ${err && err.message ? err.message : null}`) : null; this.imapEnd = true; this.destroyAll(err); }); @@ -910,9 +910,6 @@ class qtGateImap extends Event.EventEmitter { if (this.socket && typeof this.socket.end === 'function') { this.socket.end(); } - if (err) { - return this.emit('error', err); - } this.emit('end', err); } logout(CallBack = null) { @@ -936,7 +933,7 @@ class qtGateImap extends Event.EventEmitter { } exports.qtGateImap = qtGateImap; exports.seneMessageToFolder = (IMapConnect, writeFolder, message, subject, CallBack) => { - const wImap = new qtGateImap(IMapConnect, null, false, writeFolder, true, null); + const wImap = new qtGateImap(IMapConnect, null, false, writeFolder, false, null); let _callback = false; wImap.once('error', err => { wImap.destroyAll(err); @@ -993,7 +990,7 @@ exports.getMailSubject = (email) => { return /^subject: /i.test(n); }); if (!yy || !yy.length) { - saveLog(`\n\n${ret} \n`); + debug ? saveLog(`\n\n${ret} \n`) : null; return ''; } return yy.split(/^subject: /i)[1]; @@ -1008,7 +1005,7 @@ exports.getMailAttachedBase64 = (email) => { return attachment.toString(); }; exports.imapBasicTest = (IMapConnect, CallBack) => { - saveLog(`start imapBasicTest imap [${JSON.stringify(IMapConnect)}]`); + debug ? saveLog(`start imapBasicTest imap [${JSON.stringify(IMapConnect)}]`) : null; let callbackCall = false; let append = false; let timeout = null; @@ -1026,7 +1023,7 @@ exports.imapBasicTest = (IMapConnect, CallBack) => { let didFatch = false; let err = null; let rImap = new qtGateImapRead(IMapConnect, listenFolder, false, mail => { - saveLog(`new mail`); + debug ? saveLog(`new mail`) : null; const attach = exports.getMailAttached(mail); if (!attach) { err = new Error(`imapAccountTest ERROR: can't read attachment!`); @@ -1044,14 +1041,14 @@ exports.imapBasicTest = (IMapConnect, CallBack) => { if (_err) { err = _err; } - saveLog(`rImap.fetchAndDelete finished by err [${err && err.message ? err.message : null}]`); + debug ? saveLog(`rImap.fetchAndDelete finished by err [${err && err.message ? err.message : null}]`) : null; rImap.logout(); rImap = null; }); }); rImap.once('end', err => { if (!didFatch) { - saveLog(`doCatchMail rImap.once end but didFatch = false try again!`); + debug ? saveLog(`doCatchMail rImap.once end but didFatch = false try again!`) : null; return doCatchMail(id, _CallBack); } _CallBack(err, getText); @@ -1059,13 +1056,13 @@ exports.imapBasicTest = (IMapConnect, CallBack) => { }; exports.seneMessageToFolder(IMapConnect, listenFolder, ramdomText.toString('base64'), null, (err, code) => { if (err) { - saveLog(`seneMessageToFolder got error [${err.message}]`); + debug ? saveLog(`seneMessageToFolder got error [${err.message}]`) : null; return doCallBack(err, null); } }); }; exports.imapAccountTest = (IMapConnect, CallBack) => { - saveLog(`start test imap [${IMapConnect.imapUserName}]`, true); + debug ? saveLog(`start test imap [${IMapConnect.imapUserName}]`, true) : null; let callbackCall = false; let startTime = null; const listenFolder = Uuid.v4(); @@ -1083,7 +1080,7 @@ exports.imapAccountTest = (IMapConnect, CallBack) => { rImap.logout(); rImap = null; const attach = exports.getMailAttached(mail); - saveLog(`test rImap on new mail! `); + debug ? saveLog(`test rImap on new mail! `) : null; if (!attach) { return doCallBack(new Error(`imapAccountTest ERROR: can't read attachment!`), null); } @@ -1093,30 +1090,30 @@ exports.imapAccountTest = (IMapConnect, CallBack) => { return doCallBack(null, new Date().getTime() - startTime); }); rImap.once('ready', () => { - saveLog(`rImap.once ( 'ready' ) do new qtGateImapwrite`); + debug ? saveLog(`rImap.once ( 'ready' ) do new qtGateImapwrite`) : null; startTime = new Date().getTime(); timeout = timers_1.setTimeout(() => { if (rImap) { rImap.logout(); } - saveLog(`imapAccountTest doing timeout`); + debug ? saveLog(`imapAccountTest doing timeout`) : null; doCallBack(new Error('timeout'), null); }, pingFailureTime); exports.seneMessageToFolder(IMapConnect, listenFolder, ramdomText.toString('base64'), null, err => { if (err) { - saveLog(`imapAccountTest seneMessageToFolder Error! ${err.message}`); + debug ? saveLog(`imapAccountTest seneMessageToFolder Error! ${err.message}`) : null; } }); }); rImap.once('end', () => { }); rImap.once('error', err => { - saveLog(`rImap.once ( 'error' ) [${err.message}]`, true); + debug ? saveLog(`rImap.once ( 'error' ) [${err.message}]`, true) : null; return doCallBack(err); }); }; exports.imapGetMediaFile = (IMapConnect, fileName, CallBack) => { - let rImap = new qtGateImapRead(IMapConnect, fileName, true, mail => { + let rImap = new qtGateImapRead(IMapConnect, fileName, false, mail => { rImap.logout(); const retText = exports.getMailAttachedBase64(mail); return CallBack(null, retText); @@ -1145,7 +1142,7 @@ class imapPeer extends Event.EventEmitter { this.needPing = false; this.needPingTimeOut = null; this.rImap = null; - saveLog(`doing peer account [${imapData.imapUserName}] listen with[${listenBox}], write with [${writeBox}] `); + debug ? saveLog(`doing peer account [${imapData.imapUserName}] listen with[${listenBox}], write with [${writeBox}] `) : null; this.newReadImap(); } mail(email) { @@ -1154,52 +1151,52 @@ class imapPeer extends Event.EventEmitter { const attr = exports.getMailAttached(email).toString(); //console.log ( attr ) if (subject) { - saveLog(`\n\nnew mail have subject [${subject}]return to APP !\n\n`); + debug ? saveLog(`\n\nnew mail have subject [${subject}]return to APP !\n\n`) : null; return this.newMail(attr, subject); } - saveLog(`\n\nnew mail to this.deCrypto!\n\n`); + debug ? saveLog(`\n\nnew mail to this.deCrypto!\n\n`) : null; return this.deCrypto(attr, (err, data) => { if (err) { - saveLog(email.toString()); - saveLog('******************'); - saveLog(attr); - saveLog('****************************************'); - return saveLog(`deCrypto GOT ERROR! [${err.message}]`); + debug ? saveLog(email.toString()) : null; + debug ? saveLog('******************') : null; + debug ? saveLog(attr) : null; + debug ? saveLog('****************************************') : null; + return debug ? saveLog(`deCrypto GOT ERROR! [${err.message}]`) : null; } - saveLog(`\n\nnew mail Try to JSON parse \n\n`); + debug ? saveLog(`\n\nnew mail Try to JSON parse \n\n`) : null; let uu = null; try { uu = JSON.parse(data); console.log(Util.inspect(uu, false, 4, true)); } catch (ex) { - return saveLog(`imapPeer mail deCrypto JSON.parse got ERROR [${ex.message}] data = [${Util.inspect(data)}]`, true); + return debug ? saveLog(`imapPeer mail deCrypto JSON.parse got ERROR [${ex.message}] data = [${Util.inspect(data)}]`, true) : null; } if (uu.ping && uu.ping.length) { - saveLog(`GOT PING [${uu.ping}]`, true); + debug ? saveLog(`GOT PING [${uu.ping}]`, true) : null; if (!this.peerReady) { if (/outlook\.com/i.test(this.imapData.imapServer)) { - saveLog(`doing outlook server support!`); + debug ? saveLog(`doing outlook server support!`) : null; return timers_1.setTimeout(() => { - saveLog(`outlook replyPing ()`, true); + debug ? saveLog(`outlook replyPing ()`, true) : null; this.replyPing(uu); return this.Ping(); }, 5000); } this.replyPing(uu); - return saveLog(`THIS peerConnect have not ready send ping!`, true); + return debug ? saveLog(`THIS peerConnect have not ready send ping!`, true) : null; } return this.replyPing(uu); } if (uu.pong && uu.pong.length) { //saveLog ( `===> new PONG come!`, true ) if (!this.pingUuid) { - return saveLog(`GOT in the past PONG [${uu.pong}]!`, true); + return debug ? saveLog(`GOT in the past PONG [${uu.pong}]!`, true) : null; } if (this.pingUuid !== uu.pong) { - return saveLog(`GOT unknow PONG [${uu.pong}]! this.pingUuid = [${this.pingUuid}]`, true); + return debug ? saveLog(`GOT unknow PONG [${uu.pong}]! this.pingUuid = [${this.pingUuid}]`, true) : null; } - saveLog(`imapPeer connected Clear waitingReplyTimeOut!`, true); + debug ? saveLog(`imapPeer connected Clear waitingReplyTimeOut!`, true) : null; this.pingUuid = null; this.peerReady = true; this.pingCount = 0; @@ -1215,7 +1212,7 @@ class imapPeer extends Event.EventEmitter { replyPing(uu) { return this.encryptAndAppendWImap1(JSON.stringify({ pong: uu.ping }), null, err => { if (err) { - saveLog(`reply Ping ERROR! [${err.message ? err.message : null}]`); + debug ? saveLog(`reply Ping ERROR! [${err.message ? err.message : null}]`) : null; } }); } @@ -1231,15 +1228,15 @@ class imapPeer extends Event.EventEmitter { timers_1.clearTimeout(this.waitingReplyTimeOut); timers_1.clearTimeout(this.needPingTimeOut); this.needPing = false; - saveLog(`Make Time Out for a Ping, ping ID = [${this.pingUuid}]`, true); + debug ? saveLog(`Make Time Out for a Ping, ping ID = [${this.pingUuid}]`, true) : null; return this.waitingReplyTimeOut = timers_1.setTimeout(() => { - saveLog(`ON setTimeOutOfPing this.emit ( 'pingTimeOut' ) `, true); + debug ? saveLog(`ON setTimeOutOfPing this.emit ( 'pingTimeOut' ) `, true) : null; return this.emit('pingTimeOut'); }, pingPongTimeOut); } Ping() { if (this.pingUuid) { - return saveLog(`Ping already waiting other ping, STOP!`); + return debug ? saveLog(`Ping already waiting other ping, STOP!`) : null; } this.emit('ping'); const pingUuid = Uuid.v4(); @@ -1253,7 +1250,7 @@ class imapPeer extends Event.EventEmitter { } newReadImap() { if (this.makeRImap || this.rImap && this.rImap.imapStream && this.rImap.imapStream.readable) { - return saveLog(`newReadImap have rImap.imapStream.readable = true, stop!`, true); + return debug ? saveLog(`newReadImap have rImap.imapStream.readable = true, stop!`, true) : null; } this.makeRImap = true; //saveLog ( `=====> newReadImap!`, true ) @@ -1262,12 +1259,12 @@ class imapPeer extends Event.EventEmitter { }); this.rImap.once('ready', () => { this.makeRImap = false; - saveLog(`this.rImap.once on ready `); + debug ? saveLog(`this.rImap.once on ready `) : null; this.Ping(); }); this.rImap.once('error', err => { this.makeRImap = false; - saveLog(`rImap on Error [${err.message}]`, true); + debug ? saveLog(`rImap on Error [${err.message}]`, true) : null; if (err && err.message && /auth|login|log in|Too many simultaneous|UNAVAILABLE/i.test(err.message)) { return this.destroy(1); } @@ -1279,11 +1276,11 @@ class imapPeer extends Event.EventEmitter { this.rImap = null; this.makeRImap = false; if (typeof this.exit === 'function') { - saveLog(`imapPeer rImap on END!`); + debug ? saveLog(`imapPeer rImap on END!`) : null; this.exit(err); return this.exit = null; } - saveLog(`imapPeer rImap on END! but this.exit have not a function `); + debug ? saveLog(`imapPeer rImap on END! but this.exit have not a function `) : null; }); } destroy(err) { diff --git a/app/tools/imap.ts b/app/tools/imap.ts index 70a0445..1b5a5cd 100644 --- a/app/tools/imap.ts +++ b/app/tools/imap.ts @@ -357,7 +357,7 @@ class ImapServerSwitchStream extends Stream.Transform { }, ( err ) => { this.runningCommand = null if ( err ) { - saveLog ( `ImapServerSwitchStream [${ this.imapServer.listenFolder || this.imapServer.imapSerialID }] doNewMail ERROR! [${ err.message }]`) + debug ? saveLog ( `ImapServerSwitchStream [${ this.imapServer.listenFolder || this.imapServer.imapSerialID }] doNewMail ERROR! [${ err.message }]`) : null return this.imapServer.destroyAll ( err ) } if ( haveMoreNewMail || havemore ) { @@ -1008,7 +1008,7 @@ class ImapServerSwitchStream extends Stream.Transform { this.commandProcess = ( text: string, cmdArray: string[], next, _callback ) => { switch ( cmdArray[0] ) { case '*': { - saveLog ( `IMAP listAllMailBox this.commandProcess text = [${ text }]` ) + debug ? saveLog ( `IMAP listAllMailBox this.commandProcess text = [${ text }]` ) : null if ( /^LIST/i.test ( cmdArray [1] ) ) { boxes.push ( cmdArray[2] + ',' + cmdArray[4] ) } @@ -1097,7 +1097,7 @@ export class qtGateImap extends Event.EventEmitter { //saveLog ( `new qtGateImap imapSerialID [${ this.imapSerialID }] listenFolder [${ this.listenFolder }] writeFolder [${ this.writeFolder }]`, true ) this.connect () this.once ( `error`, err => { - saveLog ( `[${ this.imapSerialID }] this.on error ${ err && err.message ? err.message : null }`) + debug ? saveLog ( `[${ this.imapSerialID }] this.on error ${ err && err.message ? err.message : null }`) : null this.imapEnd = true this.destroyAll ( err ) @@ -1113,9 +1113,7 @@ export class qtGateImap extends Event.EventEmitter { if ( this.socket && typeof this.socket.end === 'function' ) { this.socket.end () } - if ( err ) { - return this.emit ( 'error', err ) - } + this.emit ( 'end', err ) } @@ -1147,7 +1145,7 @@ export class qtGateImap extends Event.EventEmitter { } export const seneMessageToFolder = ( IMapConnect: imapConnect, writeFolder: string, message: string, subject: string, CallBack ) => { - const wImap = new qtGateImap ( IMapConnect, null, false, writeFolder, true, null ) + const wImap = new qtGateImap ( IMapConnect, null, false, writeFolder, false, null ) let _callback = false wImap.once ('error', err => { @@ -1219,7 +1217,7 @@ export const getMailSubject = ( email: Buffer ) => { return /^subject: /i.test( n ) }) if ( !yy || !yy.length ) { - saveLog(`\n\n${ ret } \n`) + debug ? saveLog(`\n\n${ ret } \n`) : null return '' } return yy.split(/^subject: /i)[1] @@ -1237,7 +1235,7 @@ export const getMailAttachedBase64 = ( email: Buffer ) => { } export const imapBasicTest = ( IMapConnect: imapConnect, CallBack ) => { - saveLog ( `start imapBasicTest imap [${ JSON.stringify (IMapConnect) }]`) + debug ? saveLog ( `start imapBasicTest imap [${ JSON.stringify (IMapConnect) }]`): null let callbackCall = false let append = false let timeout: NodeJS.Timer = null @@ -1260,7 +1258,7 @@ export const imapBasicTest = ( IMapConnect: imapConnect, CallBack ) => { let err: Error = null let rImap = new qtGateImapRead ( IMapConnect, listenFolder, false, mail => { - saveLog (`new mail`) + debug ? saveLog (`new mail`) : null const attach = getMailAttached ( mail ) if ( ! attach ) { err = new Error ( `imapAccountTest ERROR: can't read attachment!`) @@ -1280,7 +1278,7 @@ export const imapBasicTest = ( IMapConnect: imapConnect, CallBack ) => { if ( _err ) { err = _err } - saveLog (`rImap.fetchAndDelete finished by err [${ err && err.message ? err.message : null }]` ) + debug ? saveLog (`rImap.fetchAndDelete finished by err [${ err && err.message ? err.message : null }]` ): null rImap.logout () rImap = null }) @@ -1288,7 +1286,7 @@ export const imapBasicTest = ( IMapConnect: imapConnect, CallBack ) => { rImap.once ( 'end', err => { if ( !didFatch ) { - saveLog (`doCatchMail rImap.once end but didFatch = false try again!`) + debug ? saveLog (`doCatchMail rImap.once end but didFatch = false try again!`) : null return doCatchMail ( id, _CallBack ) } _CallBack ( err , getText ) @@ -1297,7 +1295,7 @@ export const imapBasicTest = ( IMapConnect: imapConnect, CallBack ) => { seneMessageToFolder ( IMapConnect, listenFolder, ramdomText.toString ('base64'), null, ( err, code ) => { if ( err ) { - saveLog (`seneMessageToFolder got error [${ err.message }]`) + debug ? saveLog (`seneMessageToFolder got error [${ err.message }]`): null return doCallBack ( err, null ) } }) @@ -1307,7 +1305,7 @@ export const imapBasicTest = ( IMapConnect: imapConnect, CallBack ) => { } export const imapAccountTest = ( IMapConnect: imapConnect, CallBack ) => { - saveLog ( `start test imap [${ IMapConnect.imapUserName }]`, true ) + debug ? saveLog ( `start test imap [${ IMapConnect.imapUserName }]`, true ) : null let callbackCall = false let startTime = null @@ -1329,7 +1327,7 @@ export const imapAccountTest = ( IMapConnect: imapConnect, CallBack ) => { rImap.logout () rImap = null const attach = getMailAttached ( mail ) - saveLog ( `test rImap on new mail! ` ) + debug ? saveLog ( `test rImap on new mail! ` ) : null if ( ! attach ) { return doCallBack ( new Error ( `imapAccountTest ERROR: can't read attachment!`), null ) } @@ -1343,7 +1341,7 @@ export const imapAccountTest = ( IMapConnect: imapConnect, CallBack ) => { rImap.once ( 'ready', () => { - saveLog ( `rImap.once ( 'ready' ) do new qtGateImapwrite`) + debug ? saveLog ( `rImap.once ( 'ready' ) do new qtGateImapwrite`): null startTime = new Date ().getTime () @@ -1351,13 +1349,13 @@ export const imapAccountTest = ( IMapConnect: imapConnect, CallBack ) => { if ( rImap ) { rImap.logout () } - saveLog (`imapAccountTest doing timeout`) + debug ? saveLog (`imapAccountTest doing timeout`) : null doCallBack ( new Error ( 'timeout' ), null ) }, pingFailureTime ) seneMessageToFolder ( IMapConnect, listenFolder, ramdomText.toString ('base64'), null, err => { if ( err ) { - saveLog (`imapAccountTest seneMessageToFolder Error! ${ err.message }`) + debug ? saveLog (`imapAccountTest seneMessageToFolder Error! ${ err.message }`): null } }) @@ -1368,7 +1366,7 @@ export const imapAccountTest = ( IMapConnect: imapConnect, CallBack ) => { }) rImap.once ( 'error', err => { - saveLog ( `rImap.once ( 'error' ) [${ err.message }]`, true ) + debug ? saveLog ( `rImap.once ( 'error' ) [${ err.message }]`, true ): null return doCallBack ( err ) }) @@ -1376,7 +1374,7 @@ export const imapAccountTest = ( IMapConnect: imapConnect, CallBack ) => { } export const imapGetMediaFile = ( IMapConnect: imapConnect, fileName: string, CallBack ) => { - let rImap = new qtGateImapRead ( IMapConnect, fileName, true, mail => { + let rImap = new qtGateImapRead ( IMapConnect, fileName, false, mail => { rImap.logout () const retText = getMailAttachedBase64 ( mail ) return CallBack ( null, retText ) @@ -1415,42 +1413,42 @@ export class imapPeer extends Event.EventEmitter { const attr = getMailAttached ( email ).toString () //console.log ( attr ) if ( subject ) { - saveLog(`\n\nnew mail have subject [${ subject }]return to APP !\n\n`) + debug ? saveLog(`\n\nnew mail have subject [${ subject }]return to APP !\n\n`): null return this.newMail ( attr, subject ) } - saveLog(`\n\nnew mail to this.deCrypto!\n\n`) + debug ? saveLog(`\n\nnew mail to this.deCrypto!\n\n`): null return this.deCrypto ( attr, ( err, data ) => { if ( err ) { - saveLog ( email.toString()) - saveLog ('******************') - saveLog ( attr ) - saveLog ('****************************************') - return saveLog ( `deCrypto GOT ERROR! [${ err.message }]` ) + debug ? saveLog ( email.toString()): null + debug ? saveLog ('******************'): null + debug ? saveLog ( attr ): null + debug ? saveLog ('****************************************'): null + return debug ? saveLog ( `deCrypto GOT ERROR! [${ err.message }]` ): null } - saveLog(`\n\nnew mail Try to JSON parse \n\n`) + debug ? saveLog(`\n\nnew mail Try to JSON parse \n\n`): null let uu = null try { uu = JSON.parse ( data ) console.log ( Util.inspect ( uu, false, 4, true )) } catch ( ex ) { - return saveLog ( `imapPeer mail deCrypto JSON.parse got ERROR [${ ex.message }] data = [${ Util.inspect ( data )}]`, true ) + return debug ? saveLog ( `imapPeer mail deCrypto JSON.parse got ERROR [${ ex.message }] data = [${ Util.inspect ( data )}]`, true ): null } if ( uu.ping && uu.ping.length ) { - saveLog ( `GOT PING [${ uu.ping }]`, true ) + debug ? saveLog ( `GOT PING [${ uu.ping }]`, true ): null if ( ! this.peerReady ) { if ( /outlook\.com/i.test ( this.imapData.imapServer)) { - saveLog ( `doing outlook server support!`) + debug ? saveLog ( `doing outlook server support!`): null return setTimeout (() => { - saveLog (`outlook replyPing ()`, true ) + debug ? saveLog (`outlook replyPing ()`, true ): null this.replyPing ( uu ) return this.Ping () }, 5000 ) } this.replyPing ( uu ) - return saveLog ( `THIS peerConnect have not ready send ping!`, true) + return debug ? saveLog ( `THIS peerConnect have not ready send ping!`, true ): null } return this.replyPing ( uu ) @@ -1459,13 +1457,13 @@ export class imapPeer extends Event.EventEmitter { if ( uu.pong && uu.pong.length ) { //saveLog ( `===> new PONG come!`, true ) if ( !this.pingUuid ) { - return saveLog ( `GOT in the past PONG [${ uu.pong }]!`, true ) + return debug ? saveLog ( `GOT in the past PONG [${ uu.pong }]!`, true ): null } if ( this.pingUuid !== uu.pong ) { - return saveLog ( `GOT unknow PONG [${ uu.pong }]! this.pingUuid = [${ this.pingUuid }]`, true ) + return debug ? saveLog ( `GOT unknow PONG [${ uu.pong }]! this.pingUuid = [${ this.pingUuid }]`, true ): null } - saveLog ( `imapPeer connected Clear waitingReplyTimeOut!`, true ) + debug ? saveLog ( `imapPeer connected Clear waitingReplyTimeOut!`, true ): null this.pingUuid = null this.peerReady = true this.pingCount = 0 @@ -1488,7 +1486,7 @@ export class imapPeer extends Event.EventEmitter { return this.encryptAndAppendWImap1 ( JSON.stringify ({ pong: uu.ping }), null, err => { if ( err ) { - saveLog (`reply Ping ERROR! [${ err.message ? err.message : null }]`) + debug ? saveLog (`reply Ping ERROR! [${ err.message ? err.message : null }]`): null } }) @@ -1510,9 +1508,9 @@ export class imapPeer extends Event.EventEmitter { clearTimeout ( this.waitingReplyTimeOut ) clearTimeout ( this.needPingTimeOut ) this.needPing = false - saveLog ( `Make Time Out for a Ping, ping ID = [${ this.pingUuid }]`, true ) + debug ? saveLog ( `Make Time Out for a Ping, ping ID = [${ this.pingUuid }]`, true ): null return this.waitingReplyTimeOut = setTimeout (() => { - saveLog ( `ON setTimeOutOfPing this.emit ( 'pingTimeOut' ) `, true ) + debug ? saveLog ( `ON setTimeOutOfPing this.emit ( 'pingTimeOut' ) `, true ): null return this.emit ( 'pingTimeOut' ) }, pingPongTimeOut ) @@ -1521,7 +1519,7 @@ export class imapPeer extends Event.EventEmitter { public Ping () { if ( this.pingUuid ) { - return saveLog ( `Ping already waiting other ping, STOP!`) + return debug ? saveLog ( `Ping already waiting other ping, STOP!`): null } this.emit ('ping') @@ -1542,7 +1540,7 @@ export class imapPeer extends Event.EventEmitter { public newReadImap() { if ( this.makeRImap || this.rImap && this.rImap.imapStream && this.rImap.imapStream.readable ) { - return saveLog (`newReadImap have rImap.imapStream.readable = true, stop!`, true ) + return debug ? saveLog (`newReadImap have rImap.imapStream.readable = true, stop!`, true ): null } this.makeRImap = true //saveLog ( `=====> newReadImap!`, true ) @@ -1554,13 +1552,13 @@ export class imapPeer extends Event.EventEmitter { this.rImap.once ( 'ready', () => { this.makeRImap = false - saveLog ( `this.rImap.once on ready `) + debug ? saveLog ( `this.rImap.once on ready `): null this.Ping () }) this.rImap.once ( 'error', err => { this.makeRImap = false - saveLog ( `rImap on Error [${ err.message }]`, true ) + debug ? saveLog ( `rImap on Error [${ err.message }]`, true ): null if ( err && err.message && /auth|login|log in|Too many simultaneous|UNAVAILABLE/i.test ( err.message )) { return this.destroy (1) } @@ -1576,11 +1574,11 @@ export class imapPeer extends Event.EventEmitter { this.rImap = null this.makeRImap = false if ( typeof this.exit === 'function') { - saveLog (`imapPeer rImap on END!`) + debug ? saveLog (`imapPeer rImap on END!`): null this.exit ( err ) return this.exit = null } - saveLog (`imapPeer rImap on END! but this.exit have not a function `) + debug ? saveLog (`imapPeer rImap on END! but this.exit have not a function `): null }) @@ -1591,7 +1589,7 @@ export class imapPeer extends Event.EventEmitter { private deCrypto: ( text: string, callback: ( err?: Error, data?: string ) => void ) => void, public exit: ( err?: number ) => void) { super () - saveLog ( `doing peer account [${ imapData.imapUserName }] listen with[${ listenBox }], write with [${ writeBox }] `) + debug ? saveLog ( `doing peer account [${ imapData.imapUserName }] listen with[${ listenBox }], write with [${ writeBox }] `): null this.newReadImap () } diff --git a/index.js b/index.js index 39e952c..c094052 100644 --- a/index.js +++ b/index.js @@ -58,7 +58,7 @@ const _doUpdate = (tag_name, _port) => { }; const createLocalBrowser = () => { const localServer = new BrowserWindow({ - show: DEBUG, + show: true, webPreferences: { nodeIntegration: true } diff --git a/index.ts b/index.ts index 46390fd..25ab337 100644 --- a/index.ts +++ b/index.ts @@ -71,7 +71,7 @@ const _doUpdate = ( tag_name: string, _port ) => { const createLocalBrowser = () => { const localServer = new BrowserWindow ( { - show: DEBUG, + show: true, webPreferences: { nodeIntegration: true } diff --git a/package.json b/package.json index 1fc3f43..c9c468d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "conet", - "version": "3.2.0", + "version": "3.2.2", "license": "MIT", "description": "CoNET platform", "scripts": { @@ -18,17 +18,17 @@ "node": ">=50.9" }, "devDependencies": { - "@types/cookie-parser": "^1.4.1", + "@types/cookie-parser": "^1.4.2", "@types/express": "^4.17.2", "@types/jquery": "^3.3.31", "@types/knockout": "^3.4.66", "@types/node": "^12.12.14", "@types/node-uuid": "^0.0.28", "@types/snapsvg": "0.5.0", - "@types/socket.io": "^1.4.40", - "@types/socket.io-client": "^1.4.32", - "electron": "^6.1.5", - "electron-builder-squirrel-windows": "22.1.0" + "@types/socket.io": "^2.1.4", + "@types/socket.io-client": "1.4.32", + "electron": "^7.1.2", + "electron-builder-squirrel-windows": "22.2.0" }, "build": { "appId": "com.CoNET.Platform", @@ -85,7 +85,7 @@ "async": "^3.1.0", "cookie-parser": "^1.4.4", "express": "^4.17.1", - "jimp": "^0.8.5", + "jimp": "^0.9.3", "jszip": "^3.2.2", "knockout": "^3.5.1", "mime-types": "^2.1.25",