From f0d4952b279d693820aedcf286c666c7d407b1e3 Mon Sep 17 00:00:00 2001 From: MiaoWoo Date: Wed, 10 Jul 2019 17:53:52 +0800 Subject: [PATCH] style: comment unused code and format Signed-off-by: MiaoWoo --- src/HTML/JS/client-electron.js | 16 +- src/HTML/JS/client.js | 1196 ++++----- src/HTML/JS/crypto-client.js | 199 +- src/HTML/JS/dapp-inner.js | 379 ++- src/HTML/JS/diagram.js | 264 +- src/HTML/JS/lexer.js | 833 +++---- src/HTML/JS/mobile-wallet.js | 711 +++--- src/HTML/JS/sec256k1.js | 220 +- src/HTML/JS/sha3.js | 390 ++- src/HTML/JS/sign-lib-min.js | 4289 ++++++++++++++------------------ src/HTML/JS/wallet-lib.js | 442 ++-- src/HTML/JS/wallet-web.js | 191 +- src/core/api/api-exchange.ts | 4 +- src/core/base.ts | 24 +- src/core/block-exchange.ts | 20 +- src/core/block-loader.ts | 35 +- src/core/connect.ts | 6 +- src/core/crypto-library.ts | 105 +- src/core/html-server.ts | 88 +- src/core/library.ts | 10 +- src/core/log.ts | 103 +- src/core/server.ts | 8 +- src/core/update.ts | 2 +- src/core/wallet.ts | 6 +- src/process/main-process.ts | 10 +- src/process/static-process.ts | 6 +- src/process/tx-process.ts | 7 +- src/process/web-process.ts | 47 +- src/system/accounts.ts | 51 +- src/system/dapp.ts | 24 +- src/system/smart.ts | 10 +- tsconfig.json | 1 + 32 files changed, 3958 insertions(+), 5739 deletions(-) diff --git a/src/HTML/JS/client-electron.js b/src/HTML/JS/client-electron.js index 42ae61f..5377447 100644 --- a/src/HTML/JS/client-electron.js +++ b/src/HTML/JS/client-electron.js @@ -10,23 +10,19 @@ const ipcRenderer = require('electron').ipcRenderer; -function GetDataElectron(Method,ObjPost,Func) -{ - if(Func === undefined) - { +function GetDataElectron(Method, ObjPost, Func) { + if (Func === undefined) { Func = ObjPost; ObjPost = null; } var reply; - try - { - reply = ipcRenderer.sendSync('GetData', {path:Method, obj:ObjPost}); + try { + reply = ipcRenderer.sendSync('GetData', { path: Method, obj: ObjPost }); } - catch(e) - { + catch (e) { reply = undefined; } - if(Func) + if (Func) Func(reply); }; window.GetData = GetDataElectron; diff --git a/src/HTML/JS/client.js b/src/HTML/JS/client.js index 0902dc8..3e04b24 100644 --- a/src/HTML/JS/client.js +++ b/src/HTML/JS/client.js @@ -9,40 +9,32 @@ */ -function $(id) -{ +function $(id) { return document.getElementById(id); }; var WALLET_KEY_NAME = "WALLET_KEY"; var WALLET_PUB_KEY_NAME = "WALLET_PUB_KEY"; -if(!Math.log2) - Math.log2 = Math.log2 || function (x) - { +if (!Math.log2) + Math.log2 = Math.log2 || function(x) { return Math.log(x) * Math.LOG2E; }; -if(!window.crypto) +if (!window.crypto) window.crypto = window.msCrypto; -if(!window.toStaticHTML) - toStaticHTML = function (Str) - { +if (!window.toStaticHTML) + toStaticHTML = function(Str) { return Str; }; -if(!String.prototype.padStart) -{ +if (!String.prototype.padStart) { window.BrowserIE = 1; - String.prototype.padStart = function padStart(targetLength,padString) - { + String.prototype.padStart = function padStart(targetLength, padString) { targetLength = targetLength >> 0; padString = String((typeof padString !== 'undefined' ? padString : ' ')); - if(this.length > targetLength) - { + if (this.length > targetLength) { return String(this); } - else - { + else { targetLength = targetLength - this.length; - if(targetLength > padString.length) - { + if (targetLength > padString.length) { padString += padString.repeat(targetLength / padString.length); } return padString.slice(0, targetLength) + String(this); @@ -50,60 +42,47 @@ if(!String.prototype.padStart) }; } window.Storage = {}; -window.Storage.setItem = function (Key,Value) -{ - if(window.localStorage) +window.Storage.setItem = function(Key, Value) { + if (window.localStorage) localStorage.setItem(Key, Value); }; -window.Storage.getItem = function (Key) -{ - if(window.localStorage) +window.Storage.getItem = function(Key) { + if (window.localStorage) return localStorage.getItem(Key); }; -window.IsLocalClient = function () -{ +window.IsLocalClient = function() { return (window.location.protocol.substr(0, 4) !== "http"); }; var ServerHTTP; var MainServer; -if(window.nw) -{ - window.Open = function (path,iconname,width,height) - { +if (window.nw) { + window.Open = function(path, iconname, width, height) { width = width || 840; height = height || 1000; - var params = {width:width, height:height}; - if(iconname) + var params = { width: width, height: height }; + if (iconname) params.icon = "../HTML/PIC/" + iconname + ".png"; - window.nw.Window.open(path, params, function (win) - { + window.nw.Window.open(path, params, function(win) { }); }; - window.GetData = function (Method,ObjPost,Func) - { - window.nw.global.RunRPC({path:Method, obj:ObjPost}, Func); + window.GetData = function(Method, ObjPost, Func) { + window.nw.global.RunRPC({ path: Method, obj: ObjPost }, Func); }; - global.RunRPC = function (message,Func) - { - if(!ServerHTTP) + global.RunRPC = function(message, Func) { + if (!ServerHTTP) ServerHTTP = require('../core/html-server'); var reply = ServerHTTP.SendData(message); - if(Func) - { + if (Func) { Func(reply); } }; } -else -{ - window.Open = function (path,iconname,width,height) - { - if(!window.NWMODE) - { +else { + window.Open = function(path, iconname, width, height) { + if (!window.NWMODE) { var win = window.open(path); } - else - { + else { width = width || 840; height = height || 1000; var left = (screen.width - width) / 2; @@ -113,50 +92,38 @@ else var win = window.open(path, undefined, params); } }; - window.GetData = function (Method,ObjPost,Func) - { - if(Method.substr(0, 4) !== "http") - { - if(Method.substr(0, 1) !== "/") + window.GetData = function(Method, ObjPost, Func) { + if (Method.substr(0, 4) !== "http") { + if (Method.substr(0, 1) !== "/") Method = "/" + Method; - if(MainServer) - { + if (MainServer) { Method = GetProtocolServerPath(MainServer) + Method; } - else - { - if(IsLocalClient()) - return ; + else { + if (IsLocalClient()) + return; } } var StrPost = null; var serv = new XMLHttpRequest(); - if(ObjPost !== null) - { + if (ObjPost !== null) { StrPost = JSON.stringify(ObjPost); serv.open("POST", Method, true); } - else - { + else { throw "ERROR GET-TYPE"; } var STACK = "" + new Error().stack; serv.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); - serv.onreadystatechange = function () - { - if(serv.readyState == 4) - { - if(serv.status == 200) - { - if(Func) - { + serv.onreadystatechange = function() { + if (serv.readyState == 4) { + if (serv.status == 200) { + if (Func) { var Data; - try - { + try { Data = JSON.parse(serv.responseText); } - catch(e) - { + catch (e) { console.log("Error parsing: " + e); console.log(serv.responseText); console.log(STACK); @@ -164,9 +131,8 @@ else Func(Data, serv.responseText); } } - else - { - if(Func) + else { + if (Func) Func(undefined, undefined); } } @@ -175,78 +141,67 @@ else }; } -function IsIPAddres(Str) -{ +function IsIPAddres(Str) { var arr = Str.split("."); - if(arr.length !== 3) + if (arr.length !== 3) return 0; - for(var i = 0; i < arr.length; i++) - if(arr[i] !== "" + ParseNum(arr[i])) + for (var i = 0; i < arr.length; i++) + if (arr[i] !== "" + ParseNum(arr[i])) return 0; return 1; }; -function GetProtocolServerPath(Item) -{ - if(Item.port === 443) +function GetProtocolServerPath(Item) { + if (Item.port === 443) return "https://" + Item.ip; else - if(Item.port === 80) + if (Item.port === 80) return "http://" + Item.ip; else return "http://" + Item.ip + ":" + Item.port; }; -function SUM_TO_STRING(Value,Currency,bFloat,bLocal) -{ +function SUM_TO_STRING(Value, Currency, bFloat, bLocal) { var Str; - if(Value.SumCOIN || Value.SumCENT) - if(bFloat) - { + if (Value.SumCOIN || Value.SumCENT) + if (bFloat) { Str = "" + FLOAT_FROM_COIN(Value).toStringF(); } - else - { + else { var SumCOIN = Value.SumCOIN; - if(bLocal) + if (bLocal) SumCOIN = SumCOIN.toLocaleString(); Str = "" + SumCOIN + "." + Rigth("000000000" + Value.SumCENT, 9); } else Str = ""; - if(Currency !== undefined) - { - if(Str === "") + if (Currency !== undefined) { + if (Str === "") Str = "0"; Str += " " + CurrencyName(Currency); } return Str; }; -function GetArrFromHex(Str) -{ +function GetArrFromHex(Str) { var array = []; - for(var i = 0; Str && i < Str.length / 2; i++) - { + for (var i = 0; Str && i < Str.length / 2; i++) { array[i] = parseInt(Str.substr(i * 2, 2), 16); } return array; }; -function GetHexFromArr(arr) -{ - if(!(arr instanceof Array) && arr.data) +function GetHexFromArr(arr) { + if (!(arr instanceof Array) && arr.data) arr = arr.data; var Str = ""; - for(var i = 0; arr && i < arr.length; i++) - { - if(!arr[i]) + for (var i = 0; arr && i < arr.length; i++) { + if (!arr[i]) Str += "00"; - else - { + else { var Val = arr[i] & 255; var A = Val.toString(16); - if(A.length === 1) + if (A.length === 1) A = "0" + A; Str = Str + A; } @@ -254,59 +209,48 @@ function GetHexFromArr(arr) return Str.toUpperCase(); }; -function GetStrFromAddr(arr) -{ +function GetStrFromAddr(arr) { return GetHexFromArr(arr); }; -function GetHexFromArrBlock(Arr,LenBlock) -{ +function GetHexFromArrBlock(Arr, LenBlock) { var Str = ""; var Arr2 = []; - for(var i = 0; i < Arr.length; i++) - { + for (var i = 0; i < Arr.length; i++) { Arr2[i % LenBlock] = Arr[i]; - if(Arr2.length >= LenBlock) - { + if (Arr2.length >= LenBlock) { Str += GetHexFromArr(Arr2) + "\n"; Arr2 = []; } } - if(Arr2.length) - { + if (Arr2.length) { Str += GetHexFromArr(Arr2); } return Str; }; -function Rigth(Str,Count) -{ - if(Str.length < Count) +function Rigth(Str, Count) { + if (Str.length < Count) return Str; else return Str.substr(Str.length - Count); }; -function toUTF8Array(str) -{ +function toUTF8Array(str) { var utf8 = []; - for(var i = 0; i < str.length; i++) - { + for (var i = 0; i < str.length; i++) { var charcode = str.charCodeAt(i); - if(charcode < 0x80) + if (charcode < 0x80) utf8.push(charcode); else - if(charcode < 0x800) - { + if (charcode < 0x800) { utf8.push(0xc0 | (charcode >> 6), 0x80 | (charcode & 0x3f)); } else - if(charcode < 0xd800 || charcode >= 0xe000) - { + if (charcode < 0xd800 || charcode >= 0xe000) { utf8.push(0xe0 | (charcode >> 12), 0x80 | ((charcode >> 6) & 0x3f), 0x80 | (charcode & 0x3f)); } - else - { + else { i++; charcode = 0x10000 + (((charcode & 0x3ff) << 10) | (str.charCodeAt(i) & 0x3ff)); utf8.push(0xf0 | (charcode >> 18), 0x80 | ((charcode >> 12) & 0x3f), 0x80 | ((charcode >> 6) & 0x3f), 0x80 | (charcode & 0x3f)); @@ -315,18 +259,15 @@ function toUTF8Array(str) return utf8; }; -function Utf8ArrayToStr(array) -{ +function Utf8ArrayToStr(array) { var out, i, len, c; var char2, char3; out = ""; len = array.length; i = 0; - while(i < len) - { + while (i < len) { c = array[i++]; - switch(c >> 4) - { + switch (c >> 4) { case 0: case 1: case 2: @@ -349,10 +290,8 @@ function Utf8ArrayToStr(array) break; } } - for(var i = 0; i < out.length; i++) - { - if(out.charCodeAt(i) === 0) - { + for (var i = 0; i < out.length; i++) { + if (out.charCodeAt(i) === 0) { out = out.substr(0, i); break; } @@ -360,28 +299,23 @@ function Utf8ArrayToStr(array) return out; }; -function GetArr32FromStr(Str) -{ +function GetArr32FromStr(Str) { return GetArrFromStr(Str, 32); }; -function GetArrFromStr(Str,Len) -{ +function GetArrFromStr(Str, Len) { var arr = toUTF8Array(Str); - for(var i = arr.length; i < Len; i++) - { + for (var i = arr.length; i < Len; i++) { arr[i] = 0; } return arr.slice(0, Len); }; -function WriteByte(arr,Num) -{ +function WriteByte(arr, Num) { arr[arr.length] = Num & 0xFF; }; -function WriteUint(arr,Num) -{ +function WriteUint(arr, Num) { var len = arr.length; arr[len] = Num & 0xFF; arr[len + 1] = (Num >>> 8) & 0xFF; @@ -392,15 +326,13 @@ function WriteUint(arr,Num) arr[len + 5] = (NumH >>> 8) & 0xFF; }; -function WriteUint16(arr,Num) -{ +function WriteUint16(arr, Num) { var len = arr.length; arr[len] = Num & 0xFF; arr[len + 1] = (Num >>> 8) & 0xFF; }; -function WriteUint32(arr,Num) -{ +function WriteUint32(arr, Num) { var len = arr.length; arr[len] = Num & 0xFF; arr[len + 1] = (Num >>> 8) & 0xFF; @@ -408,58 +340,48 @@ function WriteUint32(arr,Num) arr[len + 3] = (Num >>> 24) & 0xFF; }; -function WriteStr(arr,Str,ConstLength) -{ - if(!Str) +function WriteStr(arr, Str, ConstLength) { + if (!Str) Str = ""; var arrStr = toUTF8Array(Str); var length; var len = arr.length; - if(ConstLength) - { + if (ConstLength) { length = ConstLength; } - else - { + else { length = arrStr.length; - if(length > 65535) + if (length > 65535) length = 65535; arr[len] = length & 0xFF; arr[len + 1] = (length >>> 8) & 0xFF; len += 2; } - for(var i = 0; i < length; i++) - { + for (var i = 0; i < length; i++) { arr[len + i] = arrStr[i]; } }; -function WriteArr(arr,arr2,ConstLength) -{ +function WriteArr(arr, arr2, ConstLength) { var len = arr.length; - for(var i = 0; i < ConstLength; i++) - { + for (var i = 0; i < ConstLength; i++) { arr[len + i] = arr2[i]; } }; -function WriteTr(arr,arr2) -{ +function WriteTr(arr, arr2) { var len2 = arr2.length; var len = arr.length; arr[len] = len2 & 0xFF; arr[len + 1] = (len2 >>> 8) & 0xFF; len += 2; - for(var i = 0; i < len2; i++) - { + for (var i = 0; i < len2; i++) { arr[len + i] = arr2[i]; } }; -function ReadUintFromArr(arr,len) -{ - if(len === undefined) - { +function ReadUintFromArr(arr, len) { + if (len === undefined) { len = arr.len; arr.len += 6; } @@ -469,10 +391,8 @@ function ReadUintFromArr(arr,len) return value; }; -function ReadUint32FromArr(arr,len) -{ - if(len === undefined) - { +function ReadUint32FromArr(arr, len) { + if (len === undefined) { len = arr.len; arr.len += 4; } @@ -480,20 +400,17 @@ function ReadUint32FromArr(arr,len) return value; }; -function ReadArr(arr,length) -{ +function ReadArr(arr, length) { var Ret = []; var len = arr.len; - for(var i = 0; i < length; i++) - { + for (var i = 0; i < length; i++) { Ret[i] = arr[len + i]; } arr.len += length; return Ret; }; -function ReadStr(arr) -{ +function ReadStr(arr) { var length = arr[arr.len] + arr[arr.len + 1] * 256; arr.len += 2; var arr2 = arr.slice(arr.len, arr.len + length); @@ -502,46 +419,39 @@ function ReadStr(arr) return Str; }; -function ParseNum(Str) -{ +function ParseNum(Str) { var Res = parseInt(Str); - if(isNaN(Res)) + if (isNaN(Res)) Res = 0; - if(!Res) + if (!Res) Res = 0; - if(Res < 0) + if (Res < 0) Res = 0; return Res; }; -function parseUint(Str) -{ +function parseUint(Str) { var Res = parseInt(Str); - if(isNaN(Res)) + if (isNaN(Res)) Res = 0; - if(!Res) + if (!Res) Res = 0; - if(Res < 0) + if (Res < 0) Res = 0; return Res; }; -function CopyObjKeys(dest,src) -{ - for(var key in src) - { +function CopyObjKeys(dest, src) { + for (var key in src) { dest[key] = src[key]; } }; -function SaveToArr(Arr,Obj) -{ - for(var key in Obj) - { +function SaveToArr(Arr, Obj) { + for (var key in Obj) { Arr[0]++; var Value = Obj[key]; - switch(typeof Value) - { + switch (typeof Value) { case "number": WriteByte(Arr, 241); WriteUint(Arr, Value); @@ -551,8 +461,7 @@ function SaveToArr(Arr,Obj) WriteStr(Arr, Value); break; case "object": - if(Value && (Value.length > 0 || Value.length === 0) && Value.length <= 240) - { + if (Value && (Value.length > 0 || Value.length === 0) && Value.length <= 240) { WriteByte(Arr, Value.length); WriteArr(Arr, Value, Value.length); break; @@ -563,21 +472,18 @@ function SaveToArr(Arr,Obj) } }; -function LoadFromArr(Arr,Obj) -{ - if(!Arr.length) +function LoadFromArr(Arr, Obj) { + if (!Arr.length) return false; var Count = Arr[0]; Arr.len = 1; - for(var key in Obj) - { - if(!Count) + for (var key in Obj) { + if (!Count) break; Count--; var Type = Arr[Arr.len]; Arr.len++; - switch(Type) - { + switch (Type) { case 241: Obj[key] = ReadUintFromArr(Arr); break; @@ -585,200 +491,168 @@ function LoadFromArr(Arr,Obj) Obj[key] = ReadStr(Arr); break; default: - if(Type <= 240) - { + if (Type <= 240) { var length = Type; Obj[key] = ReadArr(Arr, length); break; } - else - { + else { Obj[key] = undefined; } } } - if(Arr[0]) + if (Arr[0]) return true; else return false; }; -var entityMap = {"&":"&", "<":"<", ">":">", '"':'"', "'":''', "/":'/', "\n":'
', " ":' ', }; +var entityMap = { "&": "&", "<": "<", ">": ">", '"': '"', "'": ''', "/": '/', "\n": '
', " ": ' ', }; -function escapeHtml(string) -{ +function escapeHtml(string) { string = string.replace(/\\n/g, "\n"); string = string.replace(/\\"/g, "\""); - return String(string).replace(/[\s\n&<>"'\/]/g, function (s) - { + return String(string).replace(/[\s\n&<>"'\/]/g, function(s) { return entityMap[s]; }); }; -function InsertAfter(elem,refElem) -{ +function InsertAfter(elem, refElem) { var parent = refElem.parentNode; var next = refElem.nextSibling; - if(next) - { + if (next) { return parent.insertBefore(elem, next); } - else - { + else { return parent.appendChild(elem); } }; -function MoveUp(elem) -{ +function MoveUp(elem) { var parent = elem.parentNode; - for(var i = 0; i < parent.children.length; i++) - { + for (var i = 0; i < parent.children.length; i++) { var item = parent.children[i]; - if(item.id && item.id !== undefined) - { + if (item.id && item.id !== undefined) { return parent.insertBefore(elem, item); } } }; -function ViewGrid(APIName,Params,nameid,bClear,TotalSum) -{ - GetData(APIName, Params, function (Data) - { - if(!Data || !Data.result) - return ; +function ViewGrid(APIName, Params, nameid, bClear, TotalSum) { + GetData(APIName, Params, function(Data) { + if (!Data || !Data.result) + return; SetGridData(Data.arr, nameid, TotalSum, bClear); }); }; -function CheckNewSearch(Def) -{ +function CheckNewSearch(Def) { var Str = $(Def.FilterName).value; - if(Str) - { + if (Str) { $(Def.NumName).value = "0"; } }; -function ViewCurrent(Def,flag,This) -{ - if(Def.BlockName) - { +function ViewCurrent(Def, flag, This) { + if (Def.BlockName) { var element = $(Def.BlockName); - if(flag) - { + if (flag) { var bVisible = IsVisibleBlock(Def.BlockName); - if(!bVisible) + if (!bVisible) MoveUp(element); SetVisibleBlock(Def.BlockName, !bVisible); } - else - { + else { SetVisibleBlock(Def.BlockName, true); } var ResVisible = IsVisibleBlock(Def.BlockName); - if(This && This.className) - { + if (This && This.className) { This.className = This.className.replace("btpress", ""); - if(ResVisible) + if (ResVisible) This.className += " btpress"; } - if(!ResVisible) - return ; + if (!ResVisible) + return; } var item = $(Def.NumName); var Filter = "", Filter2 = ""; - if(Def.FilterName) - { + if (Def.FilterName) { Filter = $(Def.FilterName).value; } - if(Def.FilterName2) - { + if (Def.FilterName2) { Filter2 = $(Def.FilterName2).value; } - if(!Def.Param3) + if (!Def.Param3) Def.Param3 = ""; - ViewGrid(Def.APIName, {StartNum:ParseNum(item.value), CountNum:GetCountViewRows(Def), Param3:Def.Param3, Filter:Filter, Filter2:Filter2, + ViewGrid(Def.APIName, { + StartNum: ParseNum(item.value), CountNum: GetCountViewRows(Def), Param3: Def.Param3, Filter: Filter, Filter2: Filter2, }, Def.TabName, 1, Def.TotalSum); SaveValues(); - if(This) + if (This) SetImg(This, Def.BlockName); }; -function ViewPrev(Def) -{ +function ViewPrev(Def) { var item = document.getElementById(Def.NumName); var Num = ParseNum(item.value); Num -= GetCountViewRows(Def); - if(Num < 0) + if (Num < 0) Num = 0; item.value = Num; ViewCurrent(Def); }; -function ViewNext(Def,MaxNum) -{ +function ViewNext(Def, MaxNum) { var item = document.getElementById(Def.NumName); var Num = ParseNum(item.value); Num += GetCountViewRows(Def); - if(Def.FilterName) - { - if(document.getElementById(Def.FilterName).value) - { + if (Def.FilterName) { + if (document.getElementById(Def.FilterName).value) { Num = document.getElementById(Def.TabName).MaxNum + 1; } } - if(Num < MaxNum) - { + if (Num < MaxNum) { item.value = Num; } - else - { + else { item.value = MaxNum - MaxNum % GetCountViewRows(Def); } ViewCurrent(Def); }; -function ViewBegin(Def) -{ +function ViewBegin(Def) { document.getElementById(Def.NumName).value = 0; ViewCurrent(Def); }; -function ViewEnd(Def,MaxNum,bInitOnly) -{ +function ViewEnd(Def, MaxNum, bInitOnly) { document.getElementById(Def.NumName).value = MaxNum - MaxNum % GetCountViewRows(Def); - if(bInitOnly) - return ; + if (bInitOnly) + return; ViewCurrent(Def); }; -function GetCountViewRows(Def) -{ - if(Def.CountViewRows) +function GetCountViewRows(Def) { + if (Def.CountViewRows) return Def.CountViewRows; else return CountViewRows; }; -function DoStableScroll() -{ +function DoStableScroll() { var item = $("idStableScroll"); - if(!item) - return ; + if (!item) + return; var scrollHeight = Math.max(document.body.scrollHeight, document.documentElement.scrollHeight, document.body.offsetHeight, - document.documentElement.offsetHeight, document.body.clientHeight, document.documentElement.clientHeight); + document.documentElement.offsetHeight, document.body.clientHeight, document.documentElement.clientHeight); var itemlHeight = Math.max(item.scrollHeight, item.offsetHeight, item.clientHeight); scrollHeight = scrollHeight - itemlHeight; item.style.top = "" + scrollHeight + "px"; }; var glEvalMap = {}; -function CreateEval(formula,StrParams) -{ +function CreateEval(formula, StrParams) { var Ret = glEvalMap[formula]; - if(!Ret) - { + if (!Ret) { eval("function M(" + StrParams + "){return " + formula + "}; Ret=M;"); glEvalMap[formula] = Ret; } @@ -787,48 +661,42 @@ function CreateEval(formula,StrParams) var glWorkNum = 0; var CUR_ROW; -function SetGridData(arr,id_name,TotalSum,bclear,revert) -{ +function SetGridData(arr, id_name, TotalSum, bclear, revert) { var htmlTable = document.getElementById(id_name); - if(!htmlTable) - { + if (!htmlTable) { console.log("Error id_name: " + id_name); - return ; + return; } - if(bclear) + if (bclear) ClearTable(htmlTable); - if(!htmlTable.ItemsMap) - { + if (!htmlTable.ItemsMap) { htmlTable.ItemsMap = {}; htmlTable.RowCount = 0; } var map = htmlTable.ItemsMap; glWorkNum++; - var ValueTotal = {SumCOIN:0, SumCENT:0}; + var ValueTotal = { SumCOIN: 0, SumCENT: 0 }; var row0 = htmlTable.rows[0]; var row0cells = row0.cells; var colcount = row0cells.length; - for(var i = 0; arr && i < arr.length; i++) - { + for (var i = 0; arr && i < arr.length; i++) { var Item = arr[i]; var ID = Item.Num; htmlTable.MaxNum = Item.Num; var row = map[ID]; - if(!row) - { + if (!row) { htmlTable.RowCount++; - if(revert) + if (revert) row = htmlTable.insertRow(1); else - row = htmlTable.insertRow( - 1); + row = htmlTable.insertRow(- 1); map[ID] = row; - for(var n = 0; n < colcount; n++) - { + for (var n = 0; n < colcount; n++) { var cell0 = row0cells[n]; - if(cell0.innerText == "") + if (cell0.innerText == "") continue; cell0.F = CreateEval(cell0.id, "Item"); - if(cell0.id.substr(0, 1) === "(") + if (cell0.id.substr(0, 1) === "(") cell0.H = 1; var cell = row.insertCell(n); cell.className = cell0.className; @@ -836,45 +704,38 @@ function SetGridData(arr,id_name,TotalSum,bclear,revert) } row.Work = glWorkNum; CUR_ROW = row; - for(var n = 0; n < colcount; n++) - { + for (var n = 0; n < colcount; n++) { var cell = row.cells[n]; - if(!cell) + if (!cell) continue; var cell0 = row0cells[n]; - if(cell0.H) - { + if (cell0.H) { var text = "" + cell0.F(Item); text = toStaticHTML(text.trim()); - if(cell.innerHTML !== text) + if (cell.innerHTML !== text) cell.innerHTML = text; } - else - { + else { var text = "" + cell0.F(Item); text.trim(); - if(cell.innerText !== text) + if (cell.innerText !== text) cell.innerText = text; } } - if(TotalSum && Item.Currency === 0) + if (TotalSum && Item.Currency === 0) ADD(ValueTotal, Item.Value); } - for(var key in map) - { + for (var key in map) { var row = map[key]; - if(row.Work !== glWorkNum) - { + if (row.Work !== glWorkNum) { htmlTable.deleteRow(row.rowIndex); delete map[key]; } } - if(TotalSum) - { + if (TotalSum) { var id = document.getElementById(TotalSum); - if(id) - { - if(!ISZERO(ValueTotal)) + if (id) { + if (!ISZERO(ValueTotal)) id.innerText = "Total on page: " + SUM_TO_STRING(ValueTotal, 0, 0, 1); else id.innerText = ""; @@ -883,24 +744,19 @@ function SetGridData(arr,id_name,TotalSum,bclear,revert) DoStableScroll(); }; -function ClearTable(htmlTable) -{ - for(var i = htmlTable.rows.length - 1; i > 0; i--) +function ClearTable(htmlTable) { + for (var i = htmlTable.rows.length - 1; i > 0; i--) htmlTable.deleteRow(i); htmlTable.ItemsMap = {}; htmlTable.RowCount = 0; }; -function RetOpenBlock(BlockNum,bTrDataLen) -{ - if(BlockNum && bTrDataLen) - { - if(bTrDataLen === 2) - { +function RetOpenBlock(BlockNum, bTrDataLen) { + if (BlockNum && bTrDataLen) { + if (bTrDataLen === 2) { return '' + BlockNum + ''; } - else - { + else { return ''; } } @@ -908,55 +764,45 @@ function RetOpenBlock(BlockNum,bTrDataLen) return '' + BlockNum + ''; }; -function RetBool(Value) -{ - if(Value) +function RetBool(Value) { + if (Value) return "✔"; else return ""; }; -function RetNumDapp(Item) -{ +function RetNumDapp(Item) { return Item.Num; }; -function RetIconPath(Item,bCurrency) -{ - if(bCurrency && MapCurrencyIcon[Item.Num]) - { +function RetIconPath(Item, bCurrency) { + if (bCurrency && MapCurrencyIcon[Item.Num]) { return MapCurrencyIcon[Item.Num]; } var StrPath = ""; - if(MainServer) - { + if (MainServer) { StrPath = GetProtocolServerPath(MainServer); } - if(Item.IconBlockNum) - { + if (Item.IconBlockNum) { return StrPath + '/file/' + Item.IconBlockNum + '/' + Item.IconTrNum; } else return StrPath + "/PIC/blank.svg"; }; -function RetIconDapp(Item) -{ - if(Item.IconBlockNum) - { +function RetIconDapp(Item) { + if (Item.IconBlockNum) { return ' '; } else return ""; }; -function RetOpenDapps(Item,bNum,AccountNum) -{ +function RetOpenDapps(Item, bNum, AccountNum) { var Name = escapeHtml(Item.Name); - if(bNum) + if (bNum) Name = "" + Item.Num + "." + Name; - if(Item.HTMLLength > 0) - { + if (Item.HTMLLength > 0) { var StrText = RetIconDapp(Item) + Name; return ''; } @@ -964,37 +810,30 @@ function RetOpenDapps(Item,bNum,AccountNum) return RetIconDapp(Item) + Name; }; -function RetDirect(Value) -{ - if(Value === "-") - { +function RetDirect(Value) { + if (Value === "-") { return "-"; } else - if(Value === "+") - { + if (Value === "+") { return "+"; } else return ""; }; -function RetCategory(Item) -{ +function RetCategory(Item) { var Str = ""; var Num = 0; - if(Item.Category1 && MapCategory[Item.Category1]) - { + if (Item.Category1 && MapCategory[Item.Category1]) { Num++; Str += "" + Num + "." + MapCategory[Item.Category1] + "
"; } - if(Item.Category2 && MapCategory[Item.Category2]) - { + if (Item.Category2 && MapCategory[Item.Category2]) { Num++; Str += "" + Num + "." + MapCategory[Item.Category2] + "
"; } - if(Item.Category3 && MapCategory[Item.Category3]) - { + if (Item.Category3 && MapCategory[Item.Category3]) { Num++; Str += "" + Num + "." + MapCategory[Item.Category3] + "
"; } @@ -1002,56 +841,49 @@ function RetCategory(Item) return Str; }; -function RetChangeSmart(Item) -{ +function RetChangeSmart(Item) { var Name = ""; var State = ""; var bOpen = 0; - if(Item.SmartObj) - { - if(Item.SmartObj.HTMLLength) - { + if (Item.SmartObj) { + if (Item.SmartObj.HTMLLength) { Name = RetOpenDapps(Item.SmartObj, 1, Item.Num); bOpen = 1; } else Name = "" + Item.SmartObj.Num + "." + escapeHtml(Item.SmartObj.Name) + "
"; - if(window.DEBUG_WALLET) + if (window.DEBUG_WALLET) State = "
State:" + JSON.stringify(Item.SmartState); } var Height = 20; - if(bOpen) + if (bOpen) Height = 40; return '
' + Name + '' + State + '
'; }; -function RetHistoryAccount(Item,Name) -{ +function RetHistoryAccount(Item, Name) { var Num; - if(Name) + if (Name) Num = Item[Name]; else Num = Item.Num; - if(Num < 1) + if (Num < 1) return "" + Num; return "" + Num + ""; }; -function RetBaseAccount(Item) -{ +function RetBaseAccount(Item) { var Str = RetHistoryAccount(Item, "Account"); - if(Item.AccountLength > 1) + if (Item.AccountLength > 1) Str += "-" + (Item.Account + Item.AccountLength - 1); return Str; }; -function ViewTransaction(BlockNum) -{ +function ViewTransaction(BlockNum) { window.Open('./blockviewer.html#' + BlockNum, 'viewer', 800, 800); }; -function formatDate(now) -{ +function formatDate(now) { var year = now.getFullYear(); var month = now.getMonth() + 1; var date = now.getDate(); @@ -1059,129 +891,108 @@ function formatDate(now) var minute = now.getMinutes(); var second = now.getSeconds(); return year + "-" + String(month).padStart(2, "0") + "-" + String(date).padStart(2, "0") + " " + String(hour).padStart(2, - "0") + ":" + String(minute).padStart(2, "0") + ":" + String(second).padStart(2, "0"); + "0") + ":" + String(minute).padStart(2, "0") + ":" + String(second).padStart(2, "0"); }; -function DateFromBlock(BlockNum) -{ +function DateFromBlock(BlockNum) { var Str; - if(window.FIRST_TIME_BLOCK) - { + if (window.FIRST_TIME_BLOCK) { var now = new Date(window.FIRST_TIME_BLOCK + BlockNum * 1000); Str = formatDate(now); } - else - { + else { Str = ""; } return Str; }; -function SetCheckPoint(BlockNum) -{ - if(!BlockNum) - { +function SetCheckPoint(BlockNum) { + if (!BlockNum) { SetError("Not set BlockNum"); - return ; + return; } - GetData("SetCheckPoint", BlockNum, function (Data) - { - if(Data) - { + GetData("SetCheckPoint", BlockNum, function(Data) { + if (Data) { SetStatus(Data.text, !Data.result); } }); }; -function AddDiagramToArr(Arr,Item) -{ +function AddDiagramToArr(Arr, Item) { var bWas = 0; - for(var i = 0; i < Arr.length; i++) - { - if(Arr[i].name === Item.name) - { + for (var i = 0; i < Arr.length; i++) { + if (Arr[i].name === Item.name) { Item.Delete = 0; Arr[i] = Item; bWas = 1; break; } } - if(!bWas) - { + if (!bWas) { Item.num = Arr.length; Arr.push(Item); } }; -function SetVisibleBlock(name,bSet) -{ +function SetVisibleBlock(name, bSet) { var Item = document.getElementById(name); - if(!Item) - return ; - if(bSet && typeof bSet === "string") + if (!Item) + return; + if (bSet && typeof bSet === "string") Item.style.display = bSet; else - if(bSet) - { + if (bSet) { Item.style.display = 'block'; DoStableScroll(); } - else - { + else { Item.style.display = 'none'; } return Item; }; -function IsVisibleBlock(name) -{ +function IsVisibleBlock(name) { var Item = document.getElementById(name); - if(Item && (Item.style.display === 'block' || Item.style.display === "table-row")) + if (Item && (Item.style.display === 'block' || Item.style.display === "table-row")) return true; else return false; }; -function SetVisibleClass(Arr,Visible) -{ - if(typeof Arr === "string") +function SetVisibleClass(Arr, Visible) { + if (typeof Arr === "string") Arr = [Arr]; - for(var i = 0; i < Arr.length; i++) - { + for (var i = 0; i < Arr.length; i++) { var item = document.querySelector(Arr[i]); - if(!item) - { + if (!item) { ToLog("Error class name: " + Arr[i]); continue; } - if(!Visible) + if (!Visible) item.classList.add("hidden"); else item.classList.remove("hidden"); } }; -function IsVisibleClass(name) -{ +function IsVisibleClass(name) { var List = document.querySelector(name); - if(List.className.indexOf(" hidden") >= 0) + if (List.className.indexOf(" hidden") >= 0) return 0; else return 1; }; -function LoadValuesByArr(Arr,DopStr) -{ - if(!DopStr) +function LoadValuesByArr(Arr, DopStr) { + if (!DopStr) DopStr = ""; - if(Storage.getItem("VerSave") !== "3") + if (Storage.getItem("VerSave") !== "3") return 0; - for(var i = 0; i < Arr.length; i++) - { + for (var i = 0; i < Arr.length; i++) { var name = Arr[i]; var Item = document.getElementById(name); var name2 = DopStr + name; - if(Item.type === "checkbox") + if (Item.type === "checkbox") Item.checked = parseInt(Storage.getItem(name2)); else Item.value = Storage.getItem(name2); @@ -1189,17 +1000,15 @@ function LoadValuesByArr(Arr,DopStr) return 1; }; -function SaveValuesByArr(Arr,DopStr) -{ - if(!DopStr) +function SaveValuesByArr(Arr, DopStr) { + if (!DopStr) DopStr = ""; Storage.setItem("VerSave", "3"); - for(var i = 0; i < Arr.length; i++) - { + for (var i = 0; i < Arr.length; i++) { var name = Arr[i]; var name2 = DopStr + name; var Item = $(name); - if(Item.type === "checkbox") + if (Item.type === "checkbox") window.Storage.setItem(name2, 0 + Item.checked); else window.Storage.setItem(name2, Item.value); @@ -1260,20 +1069,17 @@ MapCategory[44] = "Governance"; MapCategory[45] = "Property"; MapCategory[46] = "Insurance"; -function GetTokenName(Num,Name) -{ - if(!Name) +function GetTokenName(Num, Name) { + if (!Name) Name = "Token"; return "(" + Num + "." + Name + ")"; return "{" + Num + "." + Name + "}"; }; -function CurrencyNameItem(Item) -{ +function CurrencyNameItem(Item) { var Name = MapCurrency[Item.Currency]; - if(!Name) - { - if(Item.CurrencyObj) + if (!Name) { + if (Item.CurrencyObj) Name = GetTokenName(Item.Currency, Item.CurrencyObj.ShortName); else Name = GetTokenName(Item.Currency, ""); @@ -1282,15 +1088,11 @@ function CurrencyNameItem(Item) return Name; }; -function CurrencyName(Num) -{ +function CurrencyName(Num) { var Name = MapCurrency[Num]; - if(!Name) - { - GetData("GetDappList", {StartNum:Num, CountNum:1}, function (Data) - { - if(Data && Data.result) - { + if (!Name) { + GetData("GetDappList", { StartNum: Num, CountNum: 1 }, function(Data) { + if (Data && Data.result) { var Smart = Data.arr[0]; Name = GetTokenName(Smart.Num, Smart.ShortName); MapCurrency[Smart.Num] = Name; @@ -1301,30 +1103,24 @@ function CurrencyName(Num) return Name; }; -function FillCurrencyAsync(IdName,StartNum) -{ - if(!StartNum) +function FillCurrencyAsync(IdName, StartNum) { + if (!StartNum) StartNum = 8; var MaxCountViewRows = 10; - GetData("DappSmartList", {StartNum:StartNum, CountNum:MaxCountViewRows, TokenGenerate:1}, function (Data) - { - if(Data && Data.result && Data.arr) - { + GetData("DappSmartList", { StartNum: StartNum, CountNum: MaxCountViewRows, TokenGenerate: 1 }, function(Data) { + if (Data && Data.result && Data.arr) { var MaxNum = 0; - for(var i = 0; i < Data.arr.length; i++) - { + for (var i = 0; i < Data.arr.length; i++) { var Smart = Data.arr[i]; - if(!MapCurrency[Smart.Num]) - { + if (!MapCurrency[Smart.Num]) { Name = GetTokenName(Smart.Num, Smart.ShortName); MapCurrency[Smart.Num] = Name; } - if(Smart.Num > MaxNum) + if (Smart.Num > MaxNum) MaxNum = Smart.Num; } FillSelect(IdName, MapCurrency, 1); - if(Data.arr.length === MaxCountViewRows && MaxNum) - { + if (Data.arr.length === MaxCountViewRows && MaxNum) { SetStatus("Cet currency in next iteration: " + (MaxNum + 1)); FillCurrencyAsync(IdName, MaxNum + 1); } @@ -1332,124 +1128,105 @@ function FillCurrencyAsync(IdName,StartNum) }); }; -function FillSelect(IdName,arr,bNatural) -{ +function FillSelect(IdName, arr, bNatural) { var Select = $(IdName); var Value = Select.value; var Options = Select.options; var strJSON = JSON.stringify(arr); - if(Select.strJSON === strJSON) - return ; + if (Select.strJSON === strJSON) + return; Select.strJSON = strJSON; var Value = Select.value; - if(bNatural) - { + if (bNatural) { Options.length = 0; - for(var key in arr) - { + for (var key in arr) { var name; - if(bNatural === "KEY") + if (bNatural === "KEY") name = key; else name = arr[key]; Options[Options.length] = new Option(name, key); - if(key == Value) + if (key == Value) Select.value = key; } } - else - { + else { Options.length = 0; - for(var i = 0; i < arr.length; i++) - { + for (var i = 0; i < arr.length; i++) { var item = arr[i]; Options[Options.length] = new Option(item.text, item.value); - if(item.value == Value) + if (item.value == Value) Select.value = item.value; } - if(!arr.length) - for(var key in arr) - { + if (!arr.length) + for (var key in arr) { var item = arr[key]; Options[Options.length] = new Option(item.text, item.value); - if(item.value == Value) + if (item.value == Value) Select.value = item.value; } } }; -function GetArrFromSelect(IdName) -{ +function GetArrFromSelect(IdName) { var Select = $(IdName); var Options = Select.options; var arr = []; - for(var i = 0; i < Options.length; i++) - { + for (var i = 0; i < Options.length; i++) { var item = Options[i]; - arr.push({text:item.text, value:item.value}); + arr.push({ text: item.text, value: item.value }); } return arr; }; -function FillCategory(IdName) -{ +function FillCategory(IdName) { var arr = []; - for(var key in MapCategory) - { - arr.push({sort:MapCategory[key].toUpperCase(), text:MapCategory[key], value:key}); + for (var key in MapCategory) { + arr.push({ sort: MapCategory[key].toUpperCase(), text: MapCategory[key], value: key }); } FillCategoryAndSort(IdName, arr); }; -function FillCategoryAndSort(IdName,arr) -{ - arr.sort(function (a,b) - { - if(a.sort < b.sort) - return - 1; - if(a.sort > b.sort) +function FillCategoryAndSort(IdName, arr) { + arr.sort(function(a, b) { + if (a.sort < b.sort) + return - 1; + if (a.sort > b.sort) return 1; return 0; }); FillSelect(IdName, arr); }; -function AddToInvoiceList(Item) -{ +function AddToInvoiceList(Item) { var arr; var Str = Storage.getItem("InvoiceList"); - if(Str) - { + if (Str) { arr = JSON.parse(Str); } - else - { + else { arr = []; } arr.unshift(Item); Storage.setItem("InvoiceList", JSON.stringify(arr)); }; -function OpenDapps(Num,AccountNum) -{ - if(!Num) - return ; +function OpenDapps(Num, AccountNum) { + if (!Num) + return; var StrPath = '/dapp/' + Num; - if(IsLocalClient()) - { + if (IsLocalClient()) { StrPath = "./dapp-frame.html?dapp=" + Num; } - if(AccountNum) + if (AccountNum) StrPath += '#' + AccountNum; window.Open(StrPath, 'dapp', 1200); }; -function ParseFileName(Str) -{ - var Ret = {BlockNum:0, TrNum:0}; +function ParseFileName(Str) { + var Ret = { BlockNum: 0, TrNum: 0 }; var index1 = Str.indexOf("file/"); - if(index1) - { + if (index1) { var index2 = Str.indexOf("/", index1 + 6); Ret.BlockNum = parseInt(Str.substr(index1 + 5, index2 - index1 - 5)); Ret.TrNum = parseInt(Str.substr(index2 + 1)); @@ -1458,65 +1235,54 @@ function ParseFileName(Str) }; window.MapSendTransaction = {}; -function SendTransaction(Body,TR,SumPow,F) -{ - if(Body.length > 16000) - { - if(window.SetStatus) +function SendTransaction(Body, TR, SumPow, F) { + if (Body.length > 16000) { + if (window.SetStatus) SetStatus("Error length transaction =" + Body.length + " (max size=16000)"); - if(F) + if (F) F(1, TR, Body); - return ; + return; } - if(window.SetStatus) + if (window.SetStatus) SetStatus("Prepare to sending..."); CreateNonceAndSend(1, 0, 0); - -function CreateNonceAndSend(bCreateNonce,startnonce,NumNext) - { - if(!NumNext) + + function CreateNonceAndSend(bCreateNonce, startnonce, NumNext) { + if (!NumNext) NumNext = 0; var nonce = startnonce; - if(bCreateNonce) + if (bCreateNonce) nonce = CreateHashBodyPOWInnerMinPower(Body, SumPow, startnonce); var StrHex = GetHexFromArr(Body); - if(NumNext > 10) - { + if (NumNext > 10) { SetError("Not sending. Cannt calc pow."); - return ; + return; } - GetData("SendTransactionHex", {Hex:StrHex}, function (Data) - { - if(Data) - { + GetData("SendTransactionHex", { Hex: StrHex }, function(Data) { + if (Data) { var key = GetHexFromArr(sha3(Body)); - if(window.SetStatus) + if (window.SetStatus) SetStatus("Send '" + key.substr(0, 16) + "' result:" + Data.text); - if(Data.text === "Not add") - { + if (Data.text === "Not add") { CreateNonceAndSend(1, nonce + 1, NumNext + 1); } else - if(Data.text === "Bad time") - { - if(window.DELTA_FOR_TIME_TX < 6) - { + if (Data.text === "Bad time") { + if (window.DELTA_FOR_TIME_TX < 6) { window.DELTA_FOR_TIME_TX++; console.log("New set Delta time: " + window.DELTA_FOR_TIME_TX); CreateNonceAndSend(1, 0, NumNext + 1); } } - else - { + else { var key = GetHexFromArr(sha3(Body)); MapSendTransaction[key] = TR; - if(F) + if (F) F(0, TR, Body); } } - else - { - if(window.SetStatus) + else { + if (window.SetStatus) SetStatus("Error Data"); } }); @@ -1524,51 +1290,40 @@ function CreateNonceAndSend(bCreateNonce,startnonce,NumNext) }; var MapSendID = {}; -function SendCallMethod(Account,MethodName,Params,FromNum,FromSmartNum) -{ - var TR = {Type:135}; +function SendCallMethod(Account, MethodName, Params, FromNum, FromSmartNum) { + var TR = { Type: 135 }; var Body = [TR.Type]; WriteUint(Body, Account); WriteStr(Body, MethodName); WriteStr(Body, JSON.stringify(Params)); WriteUint(Body, FromNum); - if(FromNum) - { - GetData("GetAccount", Account, function (Data) - { - if(!Data || Data.result !== 1 || !Data.Item) - { + if (FromNum) { + GetData("GetAccount", Account, function(Data) { + if (!Data || Data.result !== 1 || !Data.Item) { SetStatus("Error account number: " + Account); - return ; + return; } - if(Data.Item.Value.Smart !== FromSmartNum) - { + if (Data.Item.Value.Smart !== FromSmartNum) { SetStatus("Error - The account:" + Account + " does not belong to a smart contract:" + FromSmartNum + " (have: " + Data.Item.Value.Smart + ")"); - return ; + return; } - GetData("GetAccount", FromNum, function (Data) - { - if(!Data || Data.result !== 1 || !Data.Item) - { + GetData("GetAccount", FromNum, function(Data) { + if (!Data || Data.result !== 1 || !Data.Item) { SetStatus("Error account number: " + FromNum); - return ; + return; } - if(Data.Item.Num != FromNum) - { + if (Data.Item.Num != FromNum) { SetStatus("Error read from account number: " + FromNum + " read data=" + Data.Item.Num); - return ; + return; } var OperationID; - if(!MapSendID[FromNum]) - { + if (!MapSendID[FromNum]) { OperationID = Data.Item.Value.OperationID + 10; MapSendID[FromNum] = {}; } - else - { + else { OperationID = MapSendID[FromNum].OperationID; - if((new Date() - MapSendID[FromNum].Date) > 8 * 1000) - { + if ((new Date() - MapSendID[FromNum].Date) > 8 * 1000) { OperationID += 20; } } @@ -1582,8 +1337,7 @@ function SendCallMethod(Account,MethodName,Params,FromNum,FromSmartNum) }); }); } - else - { + else { WriteUint(Body, 0); Body.length += 10; Body.length += 64; @@ -1592,23 +1346,18 @@ function SendCallMethod(Account,MethodName,Params,FromNum,FromSmartNum) } }; -function SendTrArrayWithSign(Body,Account,TR) -{ - if(MainServer || CanClientSign()) - { +function SendTrArrayWithSign(Body, Account, TR) { + if (MainServer || CanClientSign()) { var Sign = GetSignFromArr(Body); var Arr = GetArrFromHex(Sign); WriteArr(Body, Arr, 64); Body.length += 12; SendTransaction(Body, TR); } - else - { + else { var StrHex = GetHexFromArr(Body); - GetData("GetSignFromHEX", {Hex:StrHex, Account:Account}, function (Data) - { - if(Data && Data.result) - { + GetData("GetSignFromHEX", { Hex: StrHex, Account: Account }, function(Data) { + if (Data && Data.result) { var Arr = GetArrFromHex(Data.Sign); WriteArr(Body, Arr, 64); Body.length += 12; @@ -1618,14 +1367,12 @@ function SendTrArrayWithSign(Body,Account,TR) } }; -function GetTrCreateAcc(Currency,PubKey,Description,Adviser,Smart) -{ - var TR = {Type:TYPE_TRANSACTION_CREATE, Currency:Currency, PubKey:PubKey, Name:Description, Adviser:Adviser, Smart:Smart, }; +function GetTrCreateAcc(Currency, PubKey, Description, Adviser, Smart) { + var TR = { Type: TYPE_TRANSACTION_CREATE, Currency: Currency, PubKey: PubKey, Name: Description, Adviser: Adviser, Smart: Smart, }; return TR; }; -function GetBodyCreateAcc(TR) -{ +function GetBodyCreateAcc(TR) { var Body = []; WriteByte(Body, TR.Type); WriteUint(Body, TR.Currency); @@ -1638,8 +1385,7 @@ function GetBodyCreateAcc(TR) return Body; }; -function GetArrFromTR(TR) -{ +function GetArrFromTR(TR) { MaxBlockNum = GetCurrentBlockNumByTime(); var Body = []; WriteByte(Body, TR.Type); @@ -1647,27 +1393,23 @@ function GetArrFromTR(TR) WriteUint(Body, 0); WriteUint(Body, TR.FromID); WriteUint32(Body, TR.To.length); - for(var i = 0; i < TR.To.length; i++) - { + for (var i = 0; i < TR.To.length; i++) { var Item = TR.To[i]; - if(TR.Version >= 3) + if (TR.Version >= 3) WriteTr(Body, Item.PubKey); WriteUint(Body, Item.ID); WriteUint(Body, Item.SumCOIN); WriteUint32(Body, Item.SumCENT); - if(MapAccounts && MapAccounts[Item.ID]) + if (MapAccounts && MapAccounts[Item.ID]) MapAccounts[Item.ID].MustUpdate = MaxBlockNum + 10; } WriteStr(Body, TR.Description); WriteUint(Body, TR.OperationID); - if(TR.Version >= 3) - { - if(TR.Body) - { + if (TR.Version >= 3) { + if (TR.Body) { WriteTr(Body, TR.Body); } - else - { + else { WriteByte(Body, 0); WriteByte(Body, 0); } @@ -1675,30 +1417,23 @@ function GetArrFromTR(TR) return Body; }; -function GetSignTransaction(TR,StrPrivKey,F) -{ - if(window.SignLib) - { - if(TR.Version === 3) - { +function GetSignTransaction(TR, StrPrivKey, F) { + if (window.SignLib) { + if (TR.Version === 3) { var Arr = []; var GetCount = 0; - for(var i = 0; i < TR.To.length; i++) - { + for (var i = 0; i < TR.To.length; i++) { var Item = TR.To[i]; - GetData("GetAccountList", {StartNum:Item.ID}, function (Data) - { - if(Data && Data.result === 1 && Data.arr.length) - { + GetData("GetAccountList", { StartNum: Item.ID }, function(Data) { + if (Data && Data.result === 1 && Data.arr.length) { GetCount++; var DataItem = Data.arr[0]; var DataPubArr = DataItem.PubKey.data; - for(var j = 0; j < 33; j++) + for (var j = 0; j < 33; j++) Arr[Arr.length] = DataPubArr[j]; - if(GetCount === TR.To.length) - { + if (GetCount === TR.To.length) { var Body = GetArrFromTR(TR); - for(var j = 0; j < Body.length; j++) + for (var j = 0; j < Body.length; j++) Arr[Arr.length] = Body[j]; TR.Sign = GetArrFromHex(GetSignFromArr(Arr, StrPrivKey)); F(TR); @@ -1707,18 +1442,14 @@ function GetSignTransaction(TR,StrPrivKey,F) }); } } - else - { + else { TR.Sign = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; F(TR); } } - else - { - GetData("GetSignTransaction", TR, function (Data) - { - if(Data && Data.result === 1) - { + else { + GetData("GetSignTransaction", TR, function(Data) { + if (Data && Data.result === 1) { TR.Sign = GetArrFromHex(Data.Sign); F(TR); } @@ -1726,87 +1457,74 @@ function GetSignTransaction(TR,StrPrivKey,F) } }; -function GetSignFromArr(Arr,StrPrivKey) -{ - if(!StrPrivKey) +function GetSignFromArr(Arr, StrPrivKey) { + if (!StrPrivKey) StrPrivKey = GetPrivKey(); - if(!IsHexStr(StrPrivKey) || StrPrivKey.length !== 64) + if (!IsHexStr(StrPrivKey) || StrPrivKey.length !== 64) return "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; var PrivKey = GetArrFromHex(StrPrivKey); var sigObj = SignLib.sign(SHA3BUF(Arr), Buffer.from(PrivKey), null, null); return GetHexFromArr(sigObj.signature); }; -function IsHexStr(Str) -{ - if(!Str) +function IsHexStr(Str) { + if (!Str) return false; var arr = GetArrFromHex(Str); var Str2 = GetHexFromArr(arr); - if(Str2 === Str.toUpperCase()) + if (Str2 === Str.toUpperCase()) return true; else return false; }; -function RetJSON(Item) -{ +function RetJSON(Item) { return JSON.stringify(Item); }; -Number.prototype.toStringF = function () -{ +Number.prototype.toStringF = function() { var data = String(this).split(/[eE]/); - if(data.length == 1) + if (data.length == 1) return data[0]; var z = '', sign = this < 0 ? '-' : '', str = data[0].replace('.', ''), mag = Number(data[1]) + 1; - if(mag < 0) - { + if (mag < 0) { z = sign + '0.'; - while(mag++) + while (mag++) z += '0'; return z + str.replace(/^\-/, ''); } mag -= str.length; - while(mag--) + while (mag--) z += '0'; return str + z; }; -function CanClientSign() -{ +function CanClientSign() { var StrPrivKey = GetPrivKey(); - if(!IsHexStr(StrPrivKey) || StrPrivKey.length !== 64) - { + if (!IsHexStr(StrPrivKey) || StrPrivKey.length !== 64) { return 0; } return 1; }; -function random(max) -{ +function random(max) { return Math.floor(Math.random() * max); }; -function ToLog(Str) -{ +function ToLog(Str) { console.log(Str); }; -function InitMainServer() -{ +function InitMainServer() { var Str = localStorage["MainServer"]; - if(Str && !localStorage["BIGWALLET"] && Str.substr(0, 1) === "{") - { + if (Str && !localStorage["BIGWALLET"] && Str.substr(0, 1) === "{") { MainServer = JSON.parse(Str); } }; -function IsZeroArr(arr) -{ - if(arr) - for(var i = 0; i < arr.length; i++) - { - if(arr[i]) +function IsZeroArr(arr) { + if (arr) + for (var i = 0; i < arr.length; i++) { + if (arr[i]) return false; } return true; @@ -1814,90 +1532,75 @@ function IsZeroArr(arr) var WALLET_PASSWORD; var KeyPasswordMap = {}; -function InitWalletKeyName() -{ - if(!localStorage["WALLET_KEY"]) - { +function InitWalletKeyName() { + if (!localStorage["WALLET_KEY"]) { localStorage["WALLET_KEY"] = localStorage["idPrivKey"]; } - if(!localStorage["WALLET_PUB_KEY"]) - { + if (!localStorage["WALLET_PUB_KEY"]) { localStorage["WALLET_PUB_KEY"] = localStorage["idPubKey"]; } }; -function OpenWalletKey() -{ +function OpenWalletKey() { var Key = Storage.getItem(WALLET_KEY_NAME); - if(Key && Key.substr(0, 1) === "!" && WALLET_PASSWORD) - { + if (Key && Key.substr(0, 1) === "!" && WALLET_PASSWORD) { Key = Key.substr(1); var StrKey = WALLET_PASSWORD + "-" + Key; var RetKey = KeyPasswordMap[StrKey]; - if(!RetKey) - { + if (!RetKey) { var Hash = HashProtect(WALLET_PASSWORD); RetKey = GetHexFromArr(XORHash(GetArrFromHex(Key), Hash, 32)); KeyPasswordMap[StrKey] = RetKey; } } - else - { + else { RetKey = Key; } var PubKeyStr; - if(RetKey && IsHexStr(RetKey) && RetKey.length === 64) - { + if (RetKey && IsHexStr(RetKey) && RetKey.length === 64) { var PrivKey = GetArrFromHex(RetKey); PubKeyStr = GetHexFromArr(SignLib.publicKeyCreate(PrivKey, 1)); } - else - { + else { PubKeyStr = ""; } sessionStorage[WALLET_KEY_NAME] = RetKey; sessionStorage[WALLET_PUB_KEY_NAME] = PubKeyStr; - if(!WALLET_PASSWORD) + if (!WALLET_PASSWORD) Storage.setItem(WALLET_PUB_KEY_NAME, PubKeyStr); return RetKey; }; -function IsLockedWallet() -{ +function IsLockedWallet() { var Key = Storage.getItem(WALLET_KEY_NAME); - if(Key && Key.substr(0, 1) === "!") + if (Key && Key.substr(0, 1) === "!") return 1; else return 0; }; -function GetPrivKey() -{ +function GetPrivKey() { var Key = sessionStorage[WALLET_KEY_NAME]; - if(!Key) + if (!Key) Key = Storage.getItem(WALLET_KEY_NAME); return Key; }; -function GetPubKey() -{ +function GetPubKey() { var Key = sessionStorage[WALLET_PUB_KEY_NAME]; - if(!Key) + if (!Key) Key = Storage.getItem(WALLET_PUB_KEY_NAME); return Key; }; -function SetPrivKey(StrPrivKey) -{ +function SetPrivKey(StrPrivKey) { var Key; - if(WALLET_PASSWORD) - { + if (WALLET_PASSWORD) { var Hash = HashProtect(WALLET_PASSWORD); var KeyXOR = GetHexFromArr(XORHash(GetArrFromHex(StrPrivKey), Hash, 32)); Key = "!" + KeyXOR; } - else - { + else { Key = StrPrivKey; } var PrivKey = GetArrFromHex(StrPrivKey); @@ -1909,28 +1612,23 @@ function SetPrivKey(StrPrivKey) sessionStorage[WALLET_PUB_KEY_NAME] = StrPubKey; }; -function SetWalletPassword(Str) -{ +function SetWalletPassword(Str) { WALLET_PASSWORD = Str; - if(localStorage["idPrivKey"]) + if (localStorage["idPrivKey"]) delete localStorage["idPrivKey"]; }; -function HashProtect(Str) -{ +function HashProtect(Str) { var arr = sha3(Str); - for(var i = 0; i < 30000; i++) - { + for (var i = 0; i < 30000; i++) { arr = sha3(arr); } return arr; }; -function XORHash(arr1,arr2,length) -{ +function XORHash(arr1, arr2, length) { var arr3 = []; - for(var i = 0; i < length; i++) - { + for (var i = 0; i < length; i++) { arr3[i] = arr1[i] ^ arr2[i]; } return arr3; diff --git a/src/HTML/JS/crypto-client.js b/src/HTML/JS/crypto-client.js index 7a467cb..589621d 100644 --- a/src/HTML/JS/crypto-client.js +++ b/src/HTML/JS/crypto-client.js @@ -11,10 +11,9 @@ var MAX_SUPER_VALUE_POW = (1 << 30) * 2; window.TYPE_TRANSACTION_CREATE = 100; -function GetHashWithValues(hash0,value1,value2,bNotCopy) -{ +function GetHashWithValues(hash0, value1, value2, bNotCopy) { var hash; - if(bNotCopy) + if (bNotCopy) hash = hash0; else hash = hash0.slice(); @@ -30,20 +29,15 @@ function GetHashWithValues(hash0,value1,value2,bNotCopy) return arrhash; }; -function GetPowPower(arrhash) -{ +function GetPowPower(arrhash) { var SumBit = 0; - for(var i = 0; i < arrhash.length; i++) - { + for (var i = 0; i < arrhash.length; i++) { var byte = arrhash[i]; - for(var b = 7; b >= 0; b--) - { - if((byte >> b) & 1) - { + for (var b = 7; b >= 0; b--) { + if ((byte >> b) & 1) { return SumBit; } - else - { + else { SumBit++; } } @@ -51,29 +45,25 @@ function GetPowPower(arrhash) return SumBit; }; -function GetPowValue(arrhash) -{ +function GetPowValue(arrhash) { var value = (arrhash[0] << 23) * 2 + (arrhash[1] << 16) + (arrhash[2] << 8) + arrhash[3]; value = value * 256 + arrhash[4]; value = value * 256 + arrhash[5]; return value; }; -function CreateNoncePOWExtern(arr0,BlockNum,count,startnone) -{ +function CreateNoncePOWExtern(arr0, BlockNum, count, startnone) { var arr = []; - for(var i = 0; i < arr0.length; i++) + for (var i = 0; i < arr0.length; i++) arr[i] = arr0[i]; - if(!startnone) + if (!startnone) startnone = 0; var maxnonce = 0; var supervalue = MAX_SUPER_VALUE_POW; - for(var nonce = startnone; nonce <= startnone + count; nonce++) - { + for (var nonce = startnone; nonce <= startnone + count; nonce++) { var arrhash = GetHashWithValues(arr, nonce, BlockNum, true); var value = GetPowValue(arrhash); - if(value < supervalue) - { + if (value < supervalue) { maxnonce = nonce; supervalue = value; } @@ -82,8 +72,7 @@ function CreateNoncePOWExtern(arr0,BlockNum,count,startnone) }; window.TR_TICKET_HASH_LENGTH = 10; -function CreateHashBody(body,Num,Nonce) -{ +function CreateHashBody(body, Num, Nonce) { var length = body.length - 12; body[length + 0] = Num & 0xFF; body[length + 1] = (Num >>> 8) & 0xFF; @@ -100,7 +89,7 @@ function CreateHashBody(body,Num,Nonce) body[length + 5] = 0; var HASH = sha3(body); var FullHashTicket = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; - for(var i = 0; i < TR_TICKET_HASH_LENGTH; i++) + for (var i = 0; i < TR_TICKET_HASH_LENGTH; i++) FullHashTicket[i] = HASH[i]; WriteUintToArrOnPos(FullHashTicket, Num, TR_TICKET_HASH_LENGTH); return sha3(FullHashTicket); @@ -111,18 +100,16 @@ window.MIN_POWER_POW_TR = 0; window.CONSENSUS_PERIOD_TIME = 1000; window.FIRST_TIME_BLOCK = 1530446400000; window.NEW_SIGN_TIME = 25500000; -window.SetBlockChainConstant = function (Data) -{ +window.SetBlockChainConstant = function(Data) { var DeltaServerClient = new Date() - Data.CurTime; - if(!Data.DELTA_CURRENT_TIME) + if (!Data.DELTA_CURRENT_TIME) Data.DELTA_CURRENT_TIME = 0; window.DELTA_CURRENT_TIME2 = Data.DELTA_CURRENT_TIME - DeltaServerClient; window.MIN_POWER_POW_TR = DELTA_POWER_POW_TR + Data.MIN_POWER_POW_TR; window.FIRST_TIME_BLOCK = Data.FIRST_TIME_BLOCK; window.NEW_SIGN_TIME = Data.NEW_SIGN_TIME; window.CONSENSUS_PERIOD_TIME = Data.CONSENSUS_PERIOD_TIME; - window.GetCurrentBlockNumByTime = function () - { + window.GetCurrentBlockNumByTime = function() { var CurrentTime = Date.now() + DELTA_CURRENT_TIME2; var CurTimeNum = CurrentTime - FIRST_TIME_BLOCK; var StartBlockNum = Math.floor((CurTimeNum + CONSENSUS_PERIOD_TIME) / CONSENSUS_PERIOD_TIME); @@ -130,18 +117,15 @@ window.SetBlockChainConstant = function (Data) }; window.NWMODE = Data.NWMODE; }; -window.GetCurrentBlockNumByTime = function () -{ +window.GetCurrentBlockNumByTime = function() { return 0; }; -function GetBlockNumTr(arr) -{ +function GetBlockNumTr(arr) { var BlockNum = window.DELTA_FOR_TIME_TX + GetCurrentBlockNumByTime(); - if(arr[0] === TYPE_TRANSACTION_CREATE) - { + if (arr[0] === TYPE_TRANSACTION_CREATE) { var BlockNum2 = Math.floor(BlockNum / 10) * 10; - if(BlockNum2 < BlockNum) + if (BlockNum2 < BlockNum) BlockNum2 = BlockNum2 + 10; BlockNum = BlockNum2; } @@ -151,26 +135,20 @@ var LastCreatePOWTrType = 0; var LastCreatePOWBlockNum = 0; var LastCreatePOWHash = [255, 255, 255, 255]; -function CreateHashBodyPOWInnerMinPower(arr,MinPow,startnonce) -{ +function CreateHashBodyPOWInnerMinPower(arr, MinPow, startnonce) { var TrType = arr[0]; var BlockNum = GetBlockNumTr(arr); - if(MinPow === undefined) - { + if (MinPow === undefined) { MinPow = MIN_POWER_POW_TR + Math.log2(arr.length / 128); } var nonce = startnonce; - while(1) - { + while (1) { var arrhash = CreateHashBody(arr, BlockNum, nonce); var power = GetPowPower(arrhash); - if(power >= MinPow) - { - if(LastCreatePOWBlockNum === BlockNum && LastCreatePOWTrType === TrType && CompareArr(LastCreatePOWHash, arrhash) > 0) - { + if (power >= MinPow) { + if (LastCreatePOWBlockNum === BlockNum && LastCreatePOWTrType === TrType && CompareArr(LastCreatePOWHash, arrhash) > 0) { } - else - { + else { LastCreatePOWBlockNum = BlockNum; LastCreatePOWTrType = TrType; LastCreatePOWHash = arrhash; @@ -178,35 +156,31 @@ function CreateHashBodyPOWInnerMinPower(arr,MinPow,startnonce) } } nonce++; - if(nonce % 2000 === 0) - { + if (nonce % 2000 === 0) { BlockNum = GetBlockNumTr(arr); } } }; -function CalcHashFromArray(ArrHashes,bOriginalSeq) -{ - if(bOriginalSeq === undefined) +function CalcHashFromArray(ArrHashes, bOriginalSeq) { + if (bOriginalSeq === undefined) ArrHashes.sort(CompareArr); var Buf = []; - for(var i = 0; i < ArrHashes.length; i++) - { + for (var i = 0; i < ArrHashes.length; i++) { var Value = ArrHashes[i]; - for(var n = 0; n < Value.length; n++) + for (var n = 0; n < Value.length; n++) Buf.push(Value[n]); } - if(Buf.length === 0) + if (Buf.length === 0) return [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; else - if(Buf.length === 32) + if (Buf.length === 32) return Buf; var Hash = shaarr(Buf); return Hash; }; -function GetArrFromValue(Num) -{ +function GetArrFromValue(Num) { var arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; arr[0] = Num & 0xFF; arr[1] = (Num >>> 8) & 0xFF; @@ -218,54 +192,44 @@ function GetArrFromValue(Num) return arr; }; -function LoadLib(Path) -{ +function LoadLib(Path) { var item = document.createElement('script'); item.type = "text/javascript"; item.src = Path; document.getElementsByTagName('head')[0].appendChild(item); }; -function IsMS() -{ +function IsMS() { var ua = window.navigator.userAgent; var msie = ua.indexOf("MSIE "); - if(msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./)) - { + if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./)) { return 1; } - else - { + else { return 0; } }; -function LoadSignLib() -{ - if(window.SignLib) - return ; +function LoadSignLib() { + if (window.SignLib) + return; LoadLib("./JS/sign-lib-min.js"); }; -function ComputeSecretWithCheck(PubKey,StrPrivKey,F) -{ - if(!window.SignLib) - { +function ComputeSecretWithCheck(PubKey, StrPrivKey, F) { + if (!window.SignLib) { SetError("Error - SignLib not installed"); - return ; + return; } - if(!IsHexStr(StrPrivKey) || StrPrivKey.length !== 64) - { + if (!IsHexStr(StrPrivKey) || StrPrivKey.length !== 64) { SetError("Error set PrivKey"); - return ; + return; } var PrivKey = Buffer.from(GetArrFromHex(StrPrivKey)); - if(typeof PubKey === "string") - { - if(!IsHexStr(PubKey) || PubKey.length !== 66) - { + if (typeof PubKey === "string") { + if (!IsHexStr(PubKey) || PubKey.length !== 66) { SetError("Error PubKey"); - return ; + return; } PubKey = Buffer.from(GetArrFromHex(PubKey)); } @@ -273,35 +237,29 @@ function ComputeSecretWithCheck(PubKey,StrPrivKey,F) F(sha3(Result)); }; -function ComputeSecret(Account,PubKey,F) -{ - if(GetPrivKey()) - { +function ComputeSecret(Account, PubKey, F) { + if (GetPrivKey()) { ComputeSecretWithCheck(PubKey, GetPrivKey(), F); } - else - { - GetData("GetWalletInfo", {Account:Account}, function (Data) - { - if(!Data || !Data.result) - return ; + else { + GetData("GetWalletInfo", { Account: Account }, function(Data) { + if (!Data || !Data.result) + return; ComputeSecretWithCheck(PubKey, Data.PrivateKey, F); }); } }; -function Encrypt(ArrSecret,StartEncrypt,StrName,StrValue) -{ +function Encrypt(ArrSecret, StartEncrypt, StrName, StrValue) { var arrRnd = sha3arr2(ArrSecret, sha3(StrName + StartEncrypt)); var Arr = toUTF8Array(StrValue); return DoSecret(Arr, arrRnd); }; -function Decrypt(ArrSecret,StartEncrypt,StrName,Arr) -{ - if(!ArrSecret) +function Decrypt(ArrSecret, StartEncrypt, StrName, Arr) { + if (!ArrSecret) return "".padEnd(Arr.length / 2, "."); - if(typeof Arr === "string") + if (typeof Arr === "string") Arr = GetArrFromHex(Arr); var arrRnd = sha3arr2(ArrSecret, sha3(StrName + StartEncrypt)); var Arr2 = DoSecret(Arr, arrRnd); @@ -309,18 +267,15 @@ function Decrypt(ArrSecret,StartEncrypt,StrName,Arr) return Str; }; -function DoSecret(Arr,arrRnd) -{ +function DoSecret(Arr, arrRnd) { var Arr2 = []; var CryptID = 0; var Pos = 0; - while(Pos < Arr.length) - { + while (Pos < Arr.length) { CryptID++; WriteUintToArrOnPos(arrRnd, CryptID, 0); var CurBuf = sha3(arrRnd); - for(var i = 0; i < 32 && Pos < Arr.length; i++, Pos++) - { + for (var i = 0; i < 32 && Pos < Arr.length; i++ , Pos++) { Arr2[Pos] = Arr[Pos] ^ CurBuf[i]; } } @@ -328,26 +283,22 @@ function DoSecret(Arr,arrRnd) }; var glEncryptInit = 0; -function EncryptInit() -{ +function EncryptInit() { glEncryptInit++; var Time = Date.now() - new Date(2019, 0, 1); return Math.floor(Time * 100 + Math.random() * 100) * 100 + glEncryptInit; }; -function EncryptID(ArrSecret,StartEncrypt,id) -{ +function EncryptID(ArrSecret, StartEncrypt, id) { var Value = $(id).value; Value = Value.padEnd(Value.length + random(5), " "); return GetHexFromArr(Encrypt(ArrSecret, StartEncrypt, id, Value)); }; -function EncryptFields(ArrSecret,Params,ArrName) -{ - if(!Params.Crypto) +function EncryptFields(ArrSecret, Params, ArrName) { + if (!Params.Crypto) Params.Crypto = EncryptInit(); - for(var i = 0; i < ArrName.length; i++) - { + for (var i = 0; i < ArrName.length; i++) { var Name = ArrName[i]; var Value = Params[Name]; Value = Value.padEnd(Value.length + random(5), " "); @@ -355,17 +306,13 @@ function EncryptFields(ArrSecret,Params,ArrName) } }; -function DecryptFields(ArrSecret,Params,ArrName) -{ - for(var i = 0; i < ArrName.length; i++) - { +function DecryptFields(ArrSecret, Params, ArrName) { + for (var i = 0; i < ArrName.length; i++) { var Name = ArrName[i]; - if(Params[Name]) - { + if (Params[Name]) { Params[Name] = Decrypt(ArrSecret, Params.Crypto, Name, GetArrFromHex(Params[Name])); } - else - { + else { Params[Name] = ""; } } diff --git a/src/HTML/JS/dapp-inner.js b/src/HTML/JS/dapp-inner.js index cc1eb56..59dc630 100644 --- a/src/HTML/JS/dapp-inner.js +++ b/src/HTML/JS/dapp-inner.js @@ -9,181 +9,147 @@ */ -function SendPay(Data) -{ +function SendPay(Data) { Data.cmd = "pay"; SendData(Data); }; -function SetStorage(Key,Value) -{ - var Data = {cmd:"setstorage", Key:Key, Value:Value}; +function SetStorage(Key, Value) { + var Data = { cmd: "setstorage", Key: Key, Value: Value }; SendData(Data); }; -function GetStorage(Key,F) -{ - var Data = {cmd:"getstorage", Key:Key}; +function GetStorage(Key, F) { + var Data = { cmd: "getstorage", Key: Key }; SendData(Data, F); }; -function SetCommon(Key,Value) -{ - var Data = {cmd:"setcommon", Key:Key, Value:Value}; +function SetCommon(Key, Value) { + var Data = { cmd: "setcommon", Key: Key, Value: Value }; SendData(Data); }; -function GetCommon(Key,F) -{ - var Data = {cmd:"getcommon", Key:Key}; +function GetCommon(Key, F) { + var Data = { cmd: "getcommon", Key: Key }; SendData(Data, F); }; -function GetInfo(F,bUseCache) -{ - var Data = {cmd:"DappInfo", AllAccounts:ALL_ACCOUNTS, AllData:!bUseCache}; +function GetInfo(F, bUseCache) { + var Data = { cmd: "DappInfo", AllAccounts: ALL_ACCOUNTS, AllData: !bUseCache }; SendData(Data, F); }; -function Call(Account,MethodName,Params,F) -{ - var Data = {cmd:"DappCall", MethodName:MethodName, Params:Params, Account:Account}; +function Call(Account, MethodName, Params, F) { + var Data = { cmd: "DappCall", MethodName: MethodName, Params: Params, Account: Account }; SendData(Data, F); }; -function SendCall(Account,MethodName,Params,FromNum) -{ - if(!INFO.WalletCanSign) - { +function SendCall(Account, MethodName, Params, FromNum) { + if (!INFO.WalletCanSign) { SetError("Pls, open wallet"); return 0; } - var Data = {cmd:"DappSendCall", MethodName:MethodName, Params:Params, Account:Account, FromNum:FromNum}; + var Data = { cmd: "DappSendCall", MethodName: MethodName, Params: Params, Account: Account, FromNum: FromNum }; SendData(Data); return 1; }; -function GetWalletAccounts(F) -{ - var Data = {cmd:"DappWalletList"}; +function GetWalletAccounts(F) { + var Data = { cmd: "DappWalletList" }; SendData(Data, F); }; -function GetAccountList(Params,F) -{ - var Data = {cmd:"DappAccountList", Params:Params}; +function GetAccountList(Params, F) { + var Data = { cmd: "DappAccountList", Params: Params }; SendData(Data, F); }; -function GetSmartList(Params,F) -{ - var Data = {cmd:"DappSmartList", Params:Params}; +function GetSmartList(Params, F) { + var Data = { cmd: "DappSmartList", Params: Params }; SendData(Data, F); }; -function GetBlockList(Params,F) -{ - var Data = {cmd:"DappBlockList", Params:Params}; +function GetBlockList(Params, F) { + var Data = { cmd: "DappBlockList", Params: Params }; SendData(Data, F); }; -function GetTransactionList(Params,F) -{ - var Data = {cmd:"DappTransactionList", Params:Params}; +function GetTransactionList(Params, F) { + var Data = { cmd: "DappTransactionList", Params: Params }; SendData(Data, F); }; -function DappSmartHTMLFile(Smart,F) -{ - var Data = {cmd:"DappSmartHTMLFile", Params:{Smart:Smart}}; +function DappSmartHTMLFile(Smart, F) { + var Data = { cmd: "DappSmartHTMLFile", Params: { Smart: Smart } }; SendData(Data, F); }; -function DappBlockFile(BlockNum,TrNum,F) -{ - var Data = {cmd:"DappBlockFile", Params:{BlockNum:BlockNum, TrNum:TrNum}}; +function DappBlockFile(BlockNum, TrNum, F) { + var Data = { cmd: "DappBlockFile", Params: { BlockNum: BlockNum, TrNum: TrNum } }; SendData(Data, F); }; -function SetStatus(Str) -{ - SendData({cmd:"SetStatus", Message:Str}); +function SetStatus(Str) { + SendData({ cmd: "SetStatus", Message: Str }); }; -function SetError(Str) -{ - SendData({cmd:"SetError", Message:Str}); +function SetError(Str) { + SendData({ cmd: "SetError", Message: Str }); }; -function SetLocationPath(Str) -{ - SendData({cmd:"SetLocationHash", Message:Str}); +function SetLocationPath(Str) { + SendData({ cmd: "SetLocationHash", Message: Str }); }; -function CreateNewAccount(Currency) -{ - SendData({cmd:"CreateNewAccount", Currency:Currency}); +function CreateNewAccount(Currency) { + SendData({ cmd: "CreateNewAccount", Currency: Currency }); }; -function OpenLink(Str) -{ - SendData({cmd:"OpenLink", Message:Str}); +function OpenLink(Str) { + SendData({ cmd: "OpenLink", Message: Str }); }; -function SetMobileMode() -{ - SendData({cmd:"SetMobileMode"}); +function SetMobileMode() { + SendData({ cmd: "SetMobileMode" }); }; -function ComputeSecret(PubKey,F,Account) -{ - if(!INFO.WalletCanSign) - { +function ComputeSecret(PubKey, F, Account) { + if (!INFO.WalletCanSign) { SetError("Pls, open wallet"); return 0; } - if(!Account && USER_ACCOUNT.length) + if (!Account && USER_ACCOUNT.length) Account = USER_ACCOUNT[0].Num; - if(typeof PubKey === "number") - { + if (typeof PubKey === "number") { var AccNum = PubKey; - GetAccountList({StartNum:AccNum, CountNum:1}, function (Err,Arr) - { - if(Err) - { + GetAccountList({ StartNum: AccNum, CountNum: 1 }, function(Err, Arr) { + if (Err) { SetError(Err); } - else - { - SendData({cmd:"ComputeSecret", Account:Account, PubKey:Arr[0].PubKey.data}, F); + else { + SendData({ cmd: "ComputeSecret", Account: Account, PubKey: Arr[0].PubKey.data }, F); } }); } - else - { - SendData({cmd:"ComputeSecret", Account:Account, PubKey:PubKey}, F); + else { + SendData({ cmd: "ComputeSecret", Account: Account, PubKey: PubKey }, F); } }; -function CheckInstall() -{ - SendData({cmd:"CheckInstall"}); +function CheckInstall() { + SendData({ cmd: "CheckInstall" }); }; -function SendTransaction(Body,TR,SumPow,F) -{ +function SendTransaction(Body, TR, SumPow, F) { SetError("Cannt SEND TR: " + JSON.stringify(TR)); }; -function CurrencyName(Num) -{ +function CurrencyName(Num) { var Name = MapCurrency[Num]; - if(!Name) - { - GetSmartList({StartNum:Num, CountNum:1, TokenGenerate:1}, function (Err,Arr) - { - if(Err || Arr.length === 0) - return ; + if (!Name) { + GetSmartList({ StartNum: Num, CountNum: 1, TokenGenerate: 1 }, function(Err, Arr) { + if (Err || Arr.length === 0) + return; var Smart = Arr[0]; Name = GetTokenName(Smart.Num, Smart.ShortName); MapCurrency[Smart.Num] = Name; @@ -194,19 +160,15 @@ function CurrencyName(Num) }; var SendCountUpdate = 0; -function FindAllCurrency() -{ +function FindAllCurrency() { SendCountUpdate++; - GetSmartList({StartNum:8, CountNum:100, TokenGenerate:1}, function (Err,Arr) - { + GetSmartList({ StartNum: 8, CountNum: 100, TokenGenerate: 1 }, function(Err, Arr) { SendCountUpdate--; - if(Err) - return ; - for(var i = 0; i < Arr.length; i++) - { + if (Err) + return; + for (var i = 0; i < Arr.length; i++) { var Smart = Arr[i]; - if(!MapCurrency[Smart.Num]) - { + if (!MapCurrency[Smart.Num]) { var Name = GetTokenName(Smart.Num, Smart.ShortName); MapCurrency[Smart.Num] = Name; } @@ -214,62 +176,50 @@ function FindAllCurrency() }); }; -function GetFilePath(Path) -{ - if(window.PROTOCOL_SERVER_PATH && Path.indexOf("file/")) - { - if(Path.substr(0, 1) !== "/") +function GetFilePath(Path) { + if (window.PROTOCOL_SERVER_PATH && Path.indexOf("file/")) { + if (Path.substr(0, 1) !== "/") Path = "/" + Path; Path = window.PROTOCOL_SERVER_PATH + Path; } return Path; }; -function GetParamsFromPath(Name) -{ - if(!OPEN_PATH) +function GetParamsFromPath(Name) { + if (!OPEN_PATH) return undefined; var arr = OPEN_PATH.split("&"); - for(var i = 0; i < arr.length; i++) - { - if(arr[i].indexOf(Name + "=") === 0) - { + for (var i = 0; i < arr.length; i++) { + if (arr[i].indexOf(Name + "=") === 0) { return arr[i].split("=")[1]; } } }; -function GetState(AccNum,F,FErr) -{ +function GetState(AccNum, F, FErr) { SendCountUpdate++; - GetAccountList({StartNum:AccNum, CountNum:1}, function (Err,Arr) - { + GetAccountList({ StartNum: AccNum, CountNum: 1 }, function(Err, Arr) { SendCountUpdate--; - if(!Err && Arr.length) - { + if (!Err && Arr.length) { var Item = Arr[0].SmartState; - if(Item) - { + if (Item) { F(Item); - return ; + return; } } - if(FErr) - { + if (FErr) { FErr(); - return ; + return; } }); }; var glMapF = {}; var glKeyF = 0; -function SendData(Data,F) -{ - if(!window.parent) - return ; - if(F) - { +function SendData(Data, F) { + if (!window.parent) + return; + if (F) { glKeyF++; Data.CallID = glKeyF; glMapF[glKeyF] = F; @@ -277,22 +227,18 @@ function SendData(Data,F) window.parent.postMessage(Data, "*"); }; -function OnMessage(event) -{ +function OnMessage(event) { var Data = event.data; - if(!Data || typeof Data !== "object") - return ; + if (!Data || typeof Data !== "object") + return; var CallID = Data.CallID; var cmd = Data.cmd; - if(CallID) - { + if (CallID) { var F = glMapF[CallID]; - if(F) - { + if (F) { delete Data.CallID; delete Data.cmd; - switch(cmd) - { + switch (cmd) { case "getstorage": case "getcommon": F(Data.Key, Data.Value); @@ -323,49 +269,40 @@ function OnMessage(event) delete glMapF[CallID]; } } - else - { - switch(cmd) - { + else { + switch (cmd) { case "History": - var eventEvent = new CustomEvent("History", {detail:Data}); + var eventEvent = new CustomEvent("History", { detail: Data }); window.dispatchEvent(eventEvent); break; case "OnEvent": - if(window.OnEvent) - { + if (window.OnEvent) { window.OnEvent(Data); } - var eventEvent = new CustomEvent("Event", {detail:Data}); + var eventEvent = new CustomEvent("Event", { detail: Data }); window.dispatchEvent(eventEvent); } } }; -function OpenRefFile(Str) -{ +function OpenRefFile(Str) { var Param = ParseFileName(Str); - if(Param.BlockNum) - DappBlockFile(Param.BlockNum, Param.TrNum, function (Err,Body) - { + if (Param.BlockNum) + DappBlockFile(Param.BlockNum, Param.TrNum, function(Err, Body) { document.write(Body); }); - else - { + else { OpenLink(Str); } }; -function SaveToStorageByArr(Arr) -{ +function SaveToStorageByArr(Arr) { SetStorage("VerSave", "1"); - for(var i = 0; i < Arr.length; i++) - { + for (var i = 0; i < Arr.length; i++) { var name = Arr[i]; var Item = $(name); - if(Item) - { - if(Item.type === "checkbox") + if (Item) { + if (Item.type === "checkbox") SetStorage(name, 0 + Item.checked); else SetStorage(name, Item.value); @@ -373,94 +310,74 @@ function SaveToStorageByArr(Arr) } }; -function LoadFromStorageByArr(Arr,F,bAll) -{ - GetStorage("VerSave", function (Key,Value) - { - if(Value === "1") - { - for(var i = 0; i < Arr.length; i++) - { - if(i === Arr.length - 1) +function LoadFromStorageByArr(Arr, F, bAll) { + GetStorage("VerSave", function(Key, Value) { + if (Value === "1") { + for (var i = 0; i < Arr.length; i++) { + if (i === Arr.length - 1) LoadFromStorageById(Arr[i], F); else LoadFromStorageById(Arr[i]); } } - if(bAll && F) + if (bAll && F) F(0); }); }; -function LoadFromStorageById(Name,F) -{ - GetStorage(Name, function (Key,Value) - { +function LoadFromStorageById(Name, F) { + GetStorage(Name, function(Key, Value) { var Item = document.getElementById(Name); - if(Item) - { - if(Item.type === "checkbox") + if (Item) { + if (Item.type === "checkbox") Item.checked = parseInt(Value); else Item.value = Value; } - if(F) + if (F) F(Key, Value); }); }; var SendCountDappParams = 0; -function GetDappParams(BNum,TrNum,F,bAll) -{ - if(!BNum) - { - if(bAll) +function GetDappParams(BNum, TrNum, F, bAll) { + if (!BNum) { + if (bAll) F(); - return ; + return; } SendCountDappParams++; - DappBlockFile(BNum, TrNum, function (Err,Data) - { + DappBlockFile(BNum, TrNum, function(Err, Data) { SendCountDappParams--; - if(!Err && Data.Type === 135) - { - try - { + if (!Err && Data.Type === 135) { + try { var Params = JSON.parse(Data.Params); } - catch(e) - { + catch (e) { } - if(Params) - { + if (Params) { F(Params, Data.MethodName, Data.FromNum); - return ; + return; } } - if(bAll) + if (bAll) F(); }); }; -document.addEventListener("DOMContentLoaded", function () -{ +document.addEventListener("DOMContentLoaded", function() { var refs = document.getElementsByTagName("A"); - for(var i = 0, L = refs.length; i < L; i++) - { - if(refs[i].href.indexOf("/file/") >= 0) - { - refs[i].onclick = function () - { + for (var i = 0, L = refs.length; i < L; i++) { + if (refs[i].href.indexOf("/file/") >= 0) { + refs[i].onclick = function() { OpenRefFile(this.href); }; } } }); -if(window.addEventListener) -{ +if (window.addEventListener) { window.addEventListener("message", OnMessage); } -else -{ +else { window.attachEvent("onmessage", OnMessage); } var SMART = {}, BASE_ACCOUNT = {}, INFO = {}, USER_ACCOUNT = [], USER_ACCOUNT_MAP = {}, OPEN_PATH = "", ACCOUNT_OPEN_NUM = 0; @@ -468,13 +385,10 @@ var ALL_ACCOUNTS = 0; var WasStartInit = 0, WasStartInit2 = 0; var eventInfo = new Event("UpdateInfo"); -function UpdateDappInfo() -{ - GetInfo(function (Err,Data) - { - if(Err) - { - return ; +function UpdateDappInfo() { + GetInfo(function(Err, Data) { + if (Err) { + return; } INFO = Data; SMART = Data.Smart; @@ -484,37 +398,32 @@ function UpdateDappInfo() SetBlockChainConstant(Data); USER_ACCOUNT = Data.ArrWallet; USER_ACCOUNT_MAP = {}; - for(var i = 0; i < USER_ACCOUNT.length; i++) + for (var i = 0; i < USER_ACCOUNT.length; i++) USER_ACCOUNT_MAP[USER_ACCOUNT[i].Num] = USER_ACCOUNT[i]; - if(window.OnInit && !WasStartInit) - { + if (window.OnInit && !WasStartInit) { WasStartInit = 1; window.OnInit(1); } else - if(window.OnUpdateInfo) - { + if (window.OnUpdateInfo) { window.OnUpdateInfo(); } - if(!WasStartInit2) - { + if (!WasStartInit2) { WasStartInit2 = 1; var eventInit = new Event("Init"); window.dispatchEvent(eventInit); } window.dispatchEvent(eventInfo); - if(Data.ArrEvent) - for(var i = 0; i < Data.ArrEvent.length; i++) - { + if (Data.ArrEvent) + for (var i = 0; i < Data.ArrEvent.length; i++) { var Item = Data.ArrEvent[i]; Item.cmd = "OnEvent"; - OnMessage({data:Item}); + OnMessage({ data: Item }); } }, 1); }; -window.addEventListener('load', function () -{ - if(!window.sha3) +window.addEventListener('load', function() { + if (!window.sha3) LoadLib("./JS/sha3.js"); UpdateDappInfo(); setInterval(UpdateDappInfo, 1000); diff --git a/src/HTML/JS/diagram.js b/src/HTML/JS/diagram.js index 6dbe0c3..485f510 100644 --- a/src/HTML/JS/diagram.js +++ b/src/HTML/JS/diagram.js @@ -11,80 +11,67 @@ var DiagramMap = {}; var DiagramMapId = {}; var LMouseOn = false; -if(!window.toStaticHTML) - toStaticHTML = function (Str) - { +if (!window.toStaticHTML) + toStaticHTML = function(Str) { return Str; }; -function Rigth(Str,Count) -{ - if(Str.length < Count) +function Rigth(Str, Count) { + if (Str.length < Count) return Str; else return Str.substr(Str.length - Count); }; -function SetHTMLDiagramItem(Item,width) -{ +function SetHTMLDiagramItem(Item, width) { Item.mouseX = width - 50; - if(Item.Extern || Item.Delete) - return ; + if (Item.Extern || Item.Delete) + return; var MinHeight = 80; - if(!Item.id) + if (!Item.id) Item.id = "DgrmId" + Item.num; DiagramMap[Item.name] = Item; DiagramMapId[Item.id] = Item; - if(Item.isLine) - { - if(Item.text) + if (Item.isLine) { + if (Item.text) Str = "
" + Item.text + ''; else Str = "
"; } - else - { + else { Str = '
' + Item.text + '
\
'; } var ElBlock = document.getElementById("B" + Item.id); - if(ElBlock) + if (ElBlock) ElBlock.innerHTML = toStaticHTML(Str); - else - { + else { var diargams = document.getElementById("diargams"); diargams.innerHTML = toStaticHTML(diargams.innerHTML + "
" + Str + "
"); } }; -function SetDiagramMouseX(event,mode) -{ - if(event.srcElement && event.srcElement.className && event.srcElement.className.indexOf && event.srcElement.className.indexOf("DIAGRAM") >= 0) - { - if(mode === "down") +function SetDiagramMouseX(event, mode) { + if (event.srcElement && event.srcElement.className && event.srcElement.className.indexOf && event.srcElement.className.indexOf("DIAGRAM") >= 0) { + if (mode === "down") LMouseOn = true; else - if(mode === "up") + if (mode === "up") LMouseOn = false; event.preventDefault(); - if(LMouseOn === true) - { + if (LMouseOn === true) { var obj = event.srcElement; var mouse = getMouse(obj, event); - if(event.ctrlKey === true) - { - for(var key in DiagramMapId) - { + if (event.ctrlKey === true) { + for (var key in DiagramMapId) { var Item = DiagramMapId[key]; Item.mouseX = mouse.x; DrawDiagram(Item); } } - else - { + else { var Item = DiagramMapId[obj.id]; - if(Item) - { + if (Item) { Item.mouseX = mouse.x; DrawDiagram(Item); } @@ -93,12 +80,11 @@ function SetDiagramMouseX(event,mode) } }; -function DrawDiagram(Item) -{ - if(Item.Delete) - return ; +function DrawDiagram(Item) { + if (Item.Delete) + return; var arr = Item.arr; - if(!arr) + if (!arr) arr = Item.ArrList; var arrX = Item.arrX; var GreenValue = Item.value; @@ -107,71 +93,69 @@ function DrawDiagram(Item) var StartServer = Item.starttime; var mouseX = Item.mouseX; var KPrecision = Item.KPrecision; - if(!KPrecision) + if (!KPrecision) KPrecision = 1; - if(!arr) - return ; + if (!arr) + return; var obj = document.getElementById(Item.id); var ctx = obj.getContext('2d'); var Left = 50; var Top = 11; var Button = 15; var Right = 50; - if(Item.fillStyle) + if (Item.fillStyle) ctx.fillStyle = Item.fillStyle; else ctx.fillStyle = "#FFF"; ctx.fillRect(0, 0, obj.width, obj.height); - if(arr.length <= 0) - return ; + if (arr.length <= 0) + return; var Pow2 = 0; - if(Item.name.substr(Item.name.length - 2) === "**") + if (Item.name.substr(Item.name.length - 2) === "**") Pow2 = 1; var MaxValue = arr[0]; var MinValue = arr[0]; var AvgValue = 0; - for(var i = 0; i < arr.length; i++) - { - if(arr[i] > MaxValue) + for (var i = 0; i < arr.length; i++) { + if (arr[i] > MaxValue) MaxValue = arr[i]; - if(arr[i] < MinValue) + if (arr[i] < MinValue) MinValue = arr[i]; - if(arr[i]) + if (arr[i]) AvgValue += arr[i]; } - if(Item.name.substr(0, 4) !== "MAX:" || !Item.AvgValue) + if (Item.name.substr(0, 4) !== "MAX:" || !Item.AvgValue) AvgValue = AvgValue / arr.length; else AvgValue = Item.AvgValue; - if(Pow2 && AvgValue) + if (Pow2 && AvgValue) AvgValue = Math.pow(2, AvgValue) / 1000000; - if(AvgValue < 50) + if (AvgValue < 50) AvgValue = AvgValue.toFixed(2); else AvgValue = Math.floor(AvgValue); - if(Item.MaxValue !== undefined) + if (Item.MaxValue !== undefined) MaxValue = Item.MaxValue; - if(Pow2 && MaxValue) + if (Pow2 && MaxValue) MaxValue = Math.pow(2, MaxValue) / 1000000; var HValue = MaxValue; - if(HValue <= 0) + if (HValue <= 0) HValue = 1; var KX = (obj.width - Left - Right) / arr.length; var KY = (obj.height - Top - Button) / HValue; var DeltaY = 0; var bLine = Item.line; - if(Item.zero) - { + if (Item.zero) { bLine = 1; DeltaY -= Item.zero * KY; MaxValue -= Item.zero; AvgValue -= Item.zero; } MaxValue = Math.floor(MaxValue + 0.5); - if(bLine) + if (bLine) ctx.lineWidth = 3; else - if(KX > 1) + if (KX > 1) ctx.lineWidth = KX; else ctx.lineWidth = 1; @@ -180,69 +164,58 @@ function DrawDiagram(Item) var mouseValueX = 0; var mouseValue = undefined; var mouseColor = undefined; - -function DrawLines(arr,mode,color) - { + + function DrawLines(arr, mode, color) { var WasMove0 = 0; ctx.beginPath(); ctx.moveTo(Left, obj.height - Button); ctx.strokeStyle = color; var PrevX = undefined; - for(var i = 0; i < arr.length; i++) - { + for (var i = 0; i < arr.length; i++) { var Value = arr[i]; - if(!Value) + if (!Value) Value = 0; - if(Value) - { - if(Pow2) + if (Value) { + if (Pow2) Value = Math.pow(2, Value) / 1000000; } - if(mode === "green") - { - if(Value > GreenValue) + if (mode === "green") { + if (Value > GreenValue) continue; } else - if(mode === "red") - { - if(Value <= GreenValue) + if (mode === "red") { + if (Value <= GreenValue) continue; } var Value1 = Value; - if(Value1 > GreenValue) + if (Value1 > GreenValue) Value1 = GreenValue; var VX1 = Math.floor(Value1 * KY); var VX2 = Math.floor(Value * KY); - if(VX1 === VX2) + if (VX1 === VX2) VX1 -= 2; var x = StartX + ctx.lineWidth / 2 + (i) * KX; - if(bLine) - { - if(!WasMove0) - { + if (bLine) { + if (!WasMove0) { WasMove0 = 1; ctx.moveTo(x, StartY - VX2); } - else - { + else { ctx.lineTo(x, StartY - VX2); } } - else - { + else { ctx.moveTo(x, StartY - VX1); ctx.lineTo(x, StartY - VX2); } - if(mouseX) - { + if (mouseX) { var deltaCur = Math.abs(x - mouseX); var deltaWas = Math.abs(mouseValueX - mouseX); - if(deltaCur < deltaWas) - { + if (deltaCur < deltaWas) { mouseValueX = x; mouseValue = Value; - if(Item.zero) + if (Item.zero) mouseValue -= Item.zero; mouseColor = color; } @@ -250,16 +223,14 @@ function DrawLines(arr,mode,color) } ctx.stroke(); }; - if(!Item.red) + if (!Item.red) Item.red = "#A00"; - if(bLine) - { + if (bLine) { DrawLines(arr, "line", Item.red); } - else - { + else { DrawLines(arr, "red", Item.red); - if(GreenValue > 0) + if (GreenValue > 0) DrawLines(arr, "green", "#0A0"); } var MaxValueText = GetValueByItemProperty(MaxValue, Item); @@ -275,20 +246,18 @@ function DrawLines(arr,mode,color) ctx.moveTo(StartX, StartY + DeltaY); ctx.lineTo(obj.width - 10, StartY + DeltaY); ctx.stroke(); - if(mouseX !== undefined) - { + if (mouseX !== undefined) { ctx.beginPath(); ctx.lineWidth = 0.5; ctx.strokeStyle = "#00F"; ctx.moveTo(mouseX, Top); ctx.lineTo(mouseX, StartY); ctx.stroke(); - if(mouseValue !== undefined) - { + if (mouseValue !== undefined) { ctx.fillStyle = mouseColor; var Val = GetValueByItemProperty(mouseValue, Item); var mouseTextX = mouseX; - if(Item.MouseText) + if (Item.MouseText) mouseTextX -= 3 * Item.MouseText.length; else Item.MouseText = ""; @@ -296,16 +265,14 @@ function DrawLines(arr,mode,color) } } ctx.fillStyle = "#000"; - if(!Item.NoTextMax) + if (!Item.NoTextMax) ctx.fillText(Rigth("          " + MaxValueText, 8), 0, Top - 3); - if(MaxValue > 0 && AvgValue > 0) - { + if (MaxValue > 0 && AvgValue > 0) { var heigh = StartY - Top; var KKY = AvgValue / MaxValue; var y = (heigh - Math.floor(KKY * heigh)); var yT = y; - if(yT < 10) - { + if (yT < 10) { yT = 10; } ctx.beginPath(); @@ -316,67 +283,58 @@ function DrawLines(arr,mode,color) ctx.fillText(Rigth("          " + AvgValueText, 8), 0, yT + Top); } var CountNameX = 10; - if(arr.length < CountNameX) + if (arr.length < CountNameX) CountNameX = arr.length; var KX3 = (obj.width - Left - Right) / CountNameX; var KDelitel = 1; var Step = arr.length / CountNameX; var StartTime, bNumber; - if(arrX) - { + if (arrX) { } else - if(StartNumber !== undefined) - { + if (StartNumber !== undefined) { bNumber = 1; StartTime = StartNumber; } else - if(StartServer) - { + if (StartServer) { bNumber = 1; StartTime = Math.floor(((Date.now() - StartServer) - StepTime * arr.length * 1000) / 1000); - if(StartTime < 0) + if (StartTime < 0) StartTime = 0; var KDelitel = Math.floor(Step / 10) * 10; - if(KDelitel == 0) + if (KDelitel == 0) KDelitel = 1; } - else - { + else { bNumber = 0; StartTime = Date.now() - StepTime * arr.length * 1000; StartX = StartX - 16; } - for(i = 0; i <= CountNameX; i++) - { + for (i = 0; i <= CountNameX; i++) { var Val; - if(i === CountNameX) - { + if (i === CountNameX) { Val = arr.length * StepTime; KDelitel = 1; } else - if(i === 0) + if (i === 0) Val = 0; else Val = i * Step * StepTime; var Str; - if(arrX) - { + if (arrX) { Val = Math.floor(Val); Str = arrX[Val]; - if(Str === undefined) + if (Str === undefined) Str = ""; } else - if(bNumber) - { + if (bNumber) { Val = Math.floor((StartTime + Val) / KDelitel) * KDelitel; Str = Val; } - else - { + else { var Time = new Date(StartTime + Val * 1000); Str = "" + Time.getHours(); Str += ":" + Rigth("0" + Time.getMinutes(), 2); @@ -386,68 +344,56 @@ function DrawLines(arr,mode,color) } }; -function GetValueByItemProperty(Value,Item) -{ - if(Item.MathPow && Item.MathDiv) - { +function GetValueByItemProperty(Value, Item) { + if (Item.MathPow && Item.MathDiv) { Value = Math.pow(Item.MathPow, Value) / Item.MathDiv; } var KPrecision = Item.KPrecision; - if(!Item.KPrecision) + if (!Item.KPrecision) KPrecision = 1; Value = Math.floor(Value * KPrecision + 0.5) / KPrecision; return Value; }; -function InitDiagramByArr(Arr,width) -{ - for(var i = 0; i < Arr.length; i++) - { +function InitDiagramByArr(Arr, width) { + for (var i = 0; i < Arr.length; i++) { Arr[i].num = i + 1; SetHTMLDiagramItem(Arr[i], width); } - window.addEventListener('mousedown', function (event) - { + window.addEventListener('mousedown', function(event) { SetDiagramMouseX(event, "down"); }, false); - window.addEventListener('mouseup', function (event) - { + window.addEventListener('mouseup', function(event) { SetDiagramMouseX(event, "up"); }, false); - window.addEventListener('onmousemove', function (event) - { + window.addEventListener('onmousemove', function(event) { SetDiagramMouseX(event, "move"); }, false); }; -function getMouse(canvas,e) -{ +function getMouse(canvas, e) { var x = e.clientX - getTrueOffsetLeft(canvas); - if(window.pageXOffset) + if (window.pageXOffset) x = x + window.pageXOffset; var y = e.clientY - getTrueOffsetTop(canvas); - if(window.pageYOffset) + if (window.pageYOffset) y = y + window.pageYOffset; - var coord = {x:x, y:y}; + var coord = { x: x, y: y }; return coord; }; -function getTrueOffsetLeft(ele) -{ +function getTrueOffsetLeft(ele) { var n = 0; - while(ele) - { + while (ele) { n += ele.offsetLeft || 0; ele = ele.offsetParent; } return n; }; -function getTrueOffsetTop(ele) -{ +function getTrueOffsetTop(ele) { var n = 0; - while(ele) - { + while (ele) { n += ele.offsetTop || 0; ele = ele.offsetParent; } diff --git a/src/HTML/JS/lexer.js b/src/HTML/JS/lexer.js index ac78a0e..6b11161 100644 --- a/src/HTML/JS/lexer.js +++ b/src/HTML/JS/lexer.js @@ -9,8 +9,7 @@ */ const LOC_ADD_NAME = "$"; -module.exports = function () -{ +module.exports = function() { 'use strict'; this.ErrorIgnore = false; this.ErrorOne = true; @@ -19,8 +18,7 @@ module.exports = function () this.FileNumber = 0; this.InjectCheck = true; this.SideMode = "client"; - this.Clear = function () - { + this.Clear = function() { this.ExternMap = {}; this.FunctionMap = {}; this.WasPlus = 0; @@ -38,18 +36,22 @@ module.exports = function () this.ErrCount = 0; this.WasEnter = false; this.lastComment = 0; - this.lastAddCode = - 1; + this.lastAddCode = - 1; this.LineNumber = 0; this.posLineNumber = 0; this.IgnoreCodeLevel = false; this.AddToStream = this.AddToStreamAddTab; }; - this.AllowedWords = {true:1, false:1, undefined:1, Infinity:1, NaN:1, null:1, context:5, this:5, arguments:5, }; - this.KeyWords = {break:1, return:1, case:1, do:1, if:1, switch:1, var:1, throw:1, while:1, default:1, for:1, try:1, continue:1, - with:1, function:3, void:3, new:3, delete:3, typeof:3, finally:5, catch:5, else:5, instanceof:4, in:4, }; - this.ProcessWords = {break:"break", return:"return", case:"case", do:"do", if:"if", switch:"switch", var:"var", throw:"throw", - with:"with", while:"while", default:"default", for:"for", try:"try", continue:"continue", function:"function", void:"void", - new:"new", delete:"delete", typeof:"typeof", finally:"finally", catch:"catch", else:"else", }; + this.AllowedWords = { true: 1, false: 1, undefined: 1, Infinity: 1, NaN: 1, null: 1, context: 5, this: 5, arguments: 5, }; + this.KeyWords = { + break: 1, return: 1, case: 1, do: 1, if: 1, switch: 1, var: 1, throw: 1, while: 1, default: 1, for: 1, try: 1, continue: 1, + with: 1, function: 3, void: 3, new: 3, delete: 3, typeof: 3, finally: 5, catch: 5, else: 5, instanceof: 4, in: 4, + }; + this.ProcessWords = { + break: "break", return: "return", case: "case", do: "do", if: "if", switch: "switch", var: "var", throw: "throw", + with: "with", while: "while", default: "default", for: "for", try: "try", continue: "continue", function: "function", void: "void", + new: "new", delete: "delete", typeof: "typeof", finally: "finally", catch: "catch", else: "else", + }; this.enIndenifier = "1"; this.enString = "2"; this.enNumber = "3"; @@ -67,8 +69,7 @@ module.exports = function () this.lexTypeNewLines = new Array(0x10000); this.lexTypeRegStart = new Array(0x10000); this.SpacesArray = new Array(100); - this.Init = function () - { + this.Init = function() { var BufNumbers = "0123456789"; var BufNumbers16 = "0123456789ABCDEFabcdef"; var BufChars = "~!%^&*-+/<>`@#()=\\|{}[];':\"?,."; @@ -96,42 +97,34 @@ module.exports = function () Normalize(this.lexTypeIdentifier); this.SpacesArray[0] = ""; this.SpacesArray[1] = ""; - for(var i = 2; i < 100; i++) + for (var i = 2; i < 100; i++) this.SpacesArray[i] = this.SpacesArray[i - 1] + " "; - -function SetType(type,buf,TypeArray) - { - for(var pos = 0; pos < buf.length; pos++) - { + + function SetType(type, buf, TypeArray) { + for (var pos = 0; pos < buf.length; pos++) { var c = buf.charCodeAt(pos); TypeArray[c] = type; } }; - -function SetLetterType(type,lexTypeAll,TypeArray) - { - for(var i = 32; i < 0x10000; i++) - { - if(!lexTypeAll[i] || lexTypeAll[i] == "L") + + function SetLetterType(type, lexTypeAll, TypeArray) { + for (var i = 32; i < 0x10000; i++) { + if (!lexTypeAll[i] || lexTypeAll[i] == "L") TypeArray[i] = "L"; } TypeArray[92] = "L"; }; - -function Normalize(TypeArray) - { - for(var i = 0; i < 0x10000; i++) - { + + function Normalize(TypeArray) { + for (var i = 0; i < 0x10000; i++) { TypeArray[i] = TypeArray[i] || false; } }; - -function SetVeryQuickly(TypeArray) - { + + function SetVeryQuickly(TypeArray) { var Ret = 0; - for(var i = 0; i < 0x10000; i++) - { - if(TypeArray[i]) + for (var i = 0; i < 0x10000; i++) { + if (TypeArray[i]) Ret = 1; else Ret = 0; @@ -140,87 +133,73 @@ function SetVeryQuickly(TypeArray) }; }; this.Init(); - -function LANG(Str) - { - for(var i = 1; i < arguments.length; i++) + + function LANG(Str) { + for (var i = 1; i < arguments.length; i++) Str = Str.replace("%" + i, arguments[i]); return Str; }; - this.Error = function () - { + this.Error = function() { var Str1 = LANG.apply(this, arguments); var begin = 0; - for(var i = this.start; i >= 0; i--) - if(this.buf[i] == "\n" || this.buf[i] == "\r") - { + for (var i = this.start; i >= 0; i--) + if (this.buf[i] == "\n" || this.buf[i] == "\r") { begin = i + 1; break; } var end = this.buf.length - 1; - for(var i = this.pos; i < this.buf.length; i++) - if(this.buf[i] == "\n" || this.buf[i] == "\r") - { + for (var i = this.pos; i < this.buf.length; i++) + if (this.buf[i] == "\n" || this.buf[i] == "\r") { end = i; break; } var line = 1; - for(var i = 0; i < this.start; i++) - if(this.buf[i] == "\n") - { + for (var i = 0; i < this.start; i++) + if (this.buf[i] == "\n") { line++; } var col = this.start + 1 - begin; var Dots1 = ""; var Dots2 = ""; - if(this.start - begin > 100) - { + if (this.start - begin > 100) { begin = this.start - 100; Dots1 = "..."; } - if(end - this.start > 100) - { + if (end - this.start > 100) { end = this.start + 100; Dots2 = "..."; } this.ErrCount++; var ErrLabel; - if(!this.ErrorOne && this.ErrorIgnore) + if (!this.ErrorOne && this.ErrorIgnore) ErrLabel = " <> "; else ErrLabel = " <> "; var StrLine = this.buf.substring(begin, this.start) + ErrLabel + this.buf.substring(this.start, end); var Str2 = LANG("At line: %1 col: %2", line - 1, col - 1); var Str = "SyntaxError: " + Str1 + ". " + Str2 + "\n" + Dots1 + StrLine + Dots2; - if(this.ErrorIgnore) - { + if (this.ErrorIgnore) { console.log(Str); this.stream += ErrLabel; this.stream += this.value + " "; - if(this.ErrorOne) - { + if (this.ErrorOne) { this.stream += "\n\n" + Str; } - else - { + else { this.NotBackPos(); - return ; + return; } } throw Str; }; this.code_base = '\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x7f\u0402\u0403\u201a\u0453\u201e\u2026\u2020\u2021\u20ac\u2030\u0409\u2039\u040a\u040c\u040b\u040f\u0452\u2018\u2019\u201c\u201d\u2022\u2013\u2014\ufffd\u2122\u0459\u203a\u045a\u045c\u045b\u045f\xa0\u040e\u045e\u0408\xa4\u0490\xa6\xa7\u0401\xa9\u0404\xab\xac\xad\xae\u0407\xb0\xb1\u0406\u0456\u0491\xb5\xb6\xb7\u0451\u2116\u0454\xbb\u0458\u0405\u0455\u0457\u0410\u0411\u0412\u0413\u0414\u0415\u0416\u0417\u0418\u0419\u041a\u041b\u041c\u041d\u041e\u041f\u0420\u0421\u0422\u0423\u0424\u0425\u0426\u0427\u0428\u0429\u042a\u042b\u042c\u042d\u042e\u042f\u0430\u0431\u0432\u0433\u0434\u0435\u0436\u0437\u0438\u0439\u043a\u043b\u043c\u043d\u043e\u043f\u0440\u0441\u0442\u0443\u0444\u0445\u0446\u0447\u0448\u0449\u044a\u044b\u044c\u044d\u044e\u044f'; - this.FromBackSlashString = function (str) - { + this.FromBackSlashString = function(str) { var Ret = ""; - for(var i = 0; i < str.length; i++) - { + for (var i = 0; i < str.length; i++) { var s = str[i]; - if(s == "\\") - { + if (s == "\\") { var s2 = str[i + 1]; - switch(s2) - { + switch (s2) { case "r": i = i + 1; Ret = Ret + "\r"; @@ -244,7 +223,7 @@ function LANG(Str) case "u": var s = str.substring(i + 2, i + 6); var code = parseInt(s); - if(isNaN(code)) + if (isNaN(code)) this.Error("Unrecognize unicode symbol: '%1'", "\\u" + s); else Ret = Ret + String.fromCharCode(code); @@ -253,7 +232,7 @@ function LANG(Str) case "x": var s = str.substring(i + 2, i + 4); var code = parseInt(s, 16); - if(isNaN(code)) + if (isNaN(code)) this.Error("Unrecognize Latin symbol: '%1'", "\\x" + s); else Ret = Ret + this.code_base.charAt(code); @@ -261,11 +240,10 @@ function LANG(Str) break; default: var c = str.charCodeAt(i + 1); - if(this.lexTypeNumbers[c] == "N") - { + if (this.lexTypeNumbers[c] == "N") { var s = str.substring(i + 1, i + 4); var code = parseInt(s, 8); - if(isNaN(code)) + if (isNaN(code)) this.Error("Unrecognize Latin symbol: '%1'", "\\" + s); else Ret = Ret + this.code_base.charAt(code); @@ -274,194 +252,159 @@ function LANG(Str) break; } } - else - { + else { Ret = Ret + s; } } return Ret; }; - this.PosString = function () - { + this.PosString = function() { var separator = this.buf[this.pos]; this.pos++; - while(this.pos < this.buf.length) - { + while (this.pos < this.buf.length) { var s = this.buf[this.pos]; - if(s == separator) - { + if (s == separator) { this.pos++; - return ; + return; } else - if(s == "\\") - { + if (s == "\\") { this.pos++; this.bWasBackSlash = true; } else - if(s == "\n") - { + if (s == "\n") { this.Error("Found end of line during calculate string"); - return ; + return; } this.pos++; } this.Error("Found end of file during calculate string"); }; - this.PosRegExp = function () - { + this.PosRegExp = function() { this.Error("RegExp not support"); - return ; + return; var separator = "/"; this.pos++; - while(this.pos < this.buf.length) - { + while (this.pos < this.buf.length) { var s = this.buf[this.pos]; - if(s == separator) - { + if (s == separator) { this.pos++; - return ; + return; } else - if(s == "[") - { + if (s == "[") { separator = ""; } else - if(s == "]" && separator == "") - { + if (s == "]" && separator == "") { separator = "/"; } else - if(s == "\\") - { + if (s == "\\") { this.pos++; this.bWasBackSlash = true; } else - if(s == "\n") - { + if (s == "\n") { this.Error("Found end of line during calculate regexp"); - return ; + return; } this.pos++; } this.Error("Found end of file during calculate regexp"); }; - this.PosCurrentType = function (TypeArray) - { - while(this.pos < this.buf.length) - { + this.PosCurrentType = function(TypeArray) { + while (this.pos < this.buf.length) { var c = this.buf.charCodeAt(this.pos); - if(!TypeArray[c]) + if (!TypeArray[c]) break; - if(c == 92) + if (c == 92) this.bWasBackSlash = true; this.pos++; } }; - this.PosIdentifier = function () - { + this.PosIdentifier = function() { this.PosCurrentType(this.lexTypeIdentifier); }; - this.PosSpaces = function () - { + this.PosSpaces = function() { this.PosCurrentType(this.lexTypeSpaces); }; - this.PosNewLines = function () - { + this.PosNewLines = function() { this.PosCurrentType(this.lexTypeNewLines); }; - this.PosNumber = function () - { - if(this.buf[this.pos] == "0") - { + this.PosNumber = function() { + if (this.buf[this.pos] == "0") { this.pos++; var s = this.buf[this.pos]; - if(s == "x" || s == "X") - { + if (s == "x" || s == "X") { this.pos++; this.PosCurrentType(this.lexTypeNumbers16); } else - if(s == ".") - { + if (s == ".") { this.pos++; this.PosCurrentType(this.lexTypeNumbers); } - else - { + else { this.PosCurrentType(this.lexTypeNumbers); } - return ; + return; } this.PosCurrentType(this.lexTypeNumbers); - if(this.buf[this.pos] == ".") - { + if (this.buf[this.pos] == ".") { this.pos++; this.PosCurrentType(this.lexTypeNumbers); } - if(this.buf[this.pos] == "e" || this.buf[this.pos] == "E") - { + if (this.buf[this.pos] == "e" || this.buf[this.pos] == "E") { this.pos++; var s2 = this.buf[this.pos]; - if(s2 == "+" || s2 == "-") + if (s2 == "+" || s2 == "-") this.pos++; var posstart = this.pos; this.PosCurrentType(this.lexTypeNumbers); - if(posstart == this.pos) + if (posstart == this.pos) this.Error("Unrecognize exponent number"); } var c = this.buf.charCodeAt(this.pos); var type = this.lexTypeAll[c]; - if(type == "L") + if (type == "L") this.Error("Unrecognize number"); }; - this.PosCommentsOneLine = function () - { - while(this.pos < this.buf.length) - { + this.PosCommentsOneLine = function() { + while (this.pos < this.buf.length) { var s = this.buf[this.pos]; - if(s == '\n') + if (s == '\n') break; else - if(s == '\r') + if (s == '\r') break; this.pos++; } }; - this.PosCommentsMultiLine = function () - { - while(this.pos < this.buf.length) - { + this.PosCommentsMultiLine = function() { + while (this.pos < this.buf.length) { var s = this.buf[this.pos] + this.buf[this.pos + 1]; - if(s == '*/') - { + if (s == '*/') { this.pos += 2; break; } this.pos++; } }; - this.BackPos = function () - { - if(this.type != this.enEndFile) + this.BackPos = function() { + if (this.type != this.enEndFile) this.pos = this.start; }; - this.NotBackPos = function () - { - if(this.pos == this.start) + this.NotBackPos = function() { + if (this.pos == this.start) this.PosNextItem(); }; - this.PosNextToken = function () - { + this.PosNextToken = function() { this.WasEnter = false; - while(true) - { + while (true) { this.PosNextItem(); - switch(this.type) - { + switch (this.type) { case this.enNewLine: this.WasEnter = true; break; @@ -473,28 +416,24 @@ function LANG(Str) } } }; - this.PosNextItem = function () - { + this.PosNextItem = function() { this.start = this.pos; - if(this.pos >= this.buf.length) - { + if (this.pos >= this.buf.length) { this.type = this.enEndFile; return this.enEndFile; } var c = this.buf.charCodeAt(this.pos); var lex = this.lexTypeAll[c]; - switch(lex) - { + switch (lex) { case "L": this.bWasBackSlash = false; this.PosIdentifier(); this.value = this.buf.substring(this.start, this.pos); - if(this.bWasBackSlash) + if (this.bWasBackSlash) this.value = this.FromBackSlashString(this.value); this.beforeRegExp = 65; this.type = this.enIndenifier; - if(this.value == "in" || this.value == "of" || this.value == "instanceof") - { + if (this.value == "in" || this.value == "of" || this.value == "instanceof") { return this.value; } return this.enIndenifier; @@ -514,8 +453,7 @@ function LANG(Str) return this.enNewLine; case "C": var s = this.buf[this.pos]; - switch(s) - { + switch (s) { case '"': case "'": this.bWasBackSlash = false; @@ -526,11 +464,9 @@ function LANG(Str) return this.enString; case "/": var s2 = this.buf[this.pos + 1]; - if(s2 == '/') - { + if (s2 == '/') { this.PosCommentsOneLine(); - if(!this.CommentIgnore && this.lastComment <= this.start) - { + if (!this.CommentIgnore && this.lastComment <= this.start) { this.lastComment = this.start + 1; this.value = this.buf.substring(this.start, this.pos); this.AddToStream(this.value); @@ -540,16 +476,13 @@ function LANG(Str) return this.enComments; } else - if(s2 == '*') - { + if (s2 == '*') { this.PosCommentsMultiLine(); - if(!this.CommentIgnore && this.lastComment <= this.start) - { + if (!this.CommentIgnore && this.lastComment <= this.start) { this.lastComment = this.start + 1; this.value = this.buf.substring(this.start, this.pos); this.AddToStream(this.value); - if(this.buf[this.pos] == "\n") - { + if (this.buf[this.pos] == "\n") { this.AddToStream("\n"); this.pos++; } @@ -558,12 +491,10 @@ function LANG(Str) return this.enComments; } else - if(this.lexTypeRegStart[this.beforeRegExp] == "R") - { + if (this.lexTypeRegStart[this.beforeRegExp] == "R") { this.PosRegExp(); this.beforeRegExp = 65; - while("gmi".indexOf(this.buf[this.pos]) >= 0) - { + while ("gmi".indexOf(this.buf[this.pos]) >= 0) { this.pos++; } this.value = this.buf.substring(this.start, this.pos); @@ -583,7 +514,7 @@ function LANG(Str) case ">": s += this.AddNextOperator(">"); s += this.AddNextOperator("="); - if(s == ">>=") + if (s == ">>=") break; s += this.AddNextOperator(">"); s += this.AddNextOperator("="); @@ -600,13 +531,13 @@ function LANG(Str) break; case "+": s += this.AddNextOperator("+"); - if(s == "++") + if (s == "++") break; s += this.AddNextOperator("="); break; case "-": s += this.AddNextOperator("-"); - if(s == "--") + if (s == "--") break; s += this.AddNextOperator("="); break; @@ -615,13 +546,13 @@ function LANG(Str) break; case "&": s += this.AddNextOperator("&"); - if(s == "&&") + if (s == "&&") break; s += this.AddNextOperator("="); break; case "|": s += this.AddNextOperator("|"); - if(s == "||") + if (s == "||") break; s += this.AddNextOperator("="); break; @@ -633,8 +564,7 @@ function LANG(Str) break; case ".": var c2 = this.buf.charCodeAt(this.pos + 1); - if(this.lexTypeNumbers[c2]) - { + if (this.lexTypeNumbers[c2]) { this.pos++; this.PosNumber(); this.value = this.buf.substring(this.start, this.pos); @@ -655,109 +585,90 @@ function LANG(Str) this.type = this.enNewLine; return this.enNewLine; }; - this.AddNextOperator = function (find) - { + this.AddNextOperator = function(find) { var s2 = this.buf[this.pos + 1]; - if(s2 == find) - { + if (s2 == find) { this.pos++; return s2; } - else - { + else { return ""; } }; - this.ParseLexem = function (Code,bWrite) - { + this.ParseLexem = function(Code, bWrite) { this.Clear(); this.buf = Code; this.beforeRegExp = 61; var AllStr = ""; - while(true) - { + while (true) { var type = this.PosNextItem(); - if(type == this.enEndFile) + if (type == this.enEndFile) break; - if(bWrite) - { + if (bWrite) { AllStr = AllStr + this.value + "\n"; } } - if(AllStr) - { + if (AllStr) { console.log(AllStr); } return AllStr; }; - this.ParseLexem2 = function (Code) - { + this.ParseLexem2 = function(Code) { this.Clear(); this.buf = Code; this.beforeRegExp = 61; var n = 0; var Value1 = new Uint32Array(Code.length); var Value2 = new Uint32Array(Code.length); - while(true) - { + while (true) { var type = this.PosNextItem(); - if(type == this.enEndFile) + if (type == this.enEndFile) break; Value1[n] = this.start; Value2[n] = this.pos; n++; } - return {Value1:Value1, Value2:Value2}; + return { Value1: Value1, Value2: Value2 }; }; - this.ParseCode = function (Code) - { + this.ParseCode = function(Code) { this.Clear(); this.buf = Code; this.ParseSmart(); }; - this.ParseSmart = function () - { + this.ParseSmart = function() { var bPublic = 0; - while(true) - { + while (true) { var type = this.PosNextToken(); - if(type === this.enEndFile) + if (type === this.enEndFile) break; - if(type === this.enString && this.value === '"public"') - { + if (type === this.enString && this.value === '"public"') { bPublic = 1; continue; } - if(this.value === "function") - { + if (this.value === "function") { var FuncName = this.Parse_function(0, 1); - if(bPublic) + if (bPublic) this.ExternMap[FuncName] = bPublic; bPublic = 0; this.AddNewLineToStream(";\n"); } - else - { + else { this.Error("Require 'function' indenifier"); } } }; - this.ParseBlock = function (sConditions,bOneIteration,bSimpleMode,bNotCheck) - { - if(!bOneIteration) + this.ParseBlock = function(sConditions, bOneIteration, bSimpleMode, bNotCheck) { + if (!bOneIteration) this.BlockLevel++; var WasIgnoreCodeLevel = this.IgnoreCodeLevel; var bWasLabel = false; this.beforeRegExp = 61; Main: - while(true) - { + while (true) { var posSave = this.pos; var type = this.PosNextToken(); - if(!bNotCheck && !bSimpleMode && !bWasLabel) - { - switch(type) - { + if (!bNotCheck && !bSimpleMode && !bWasLabel) { + switch (type) { case ";": case ":": case "{": @@ -769,8 +680,7 @@ function LANG(Str) this.AddCheckLineToStream(); } } - switch(type) - { + switch (type) { case ";": bWasLabel = false; break; @@ -792,11 +702,9 @@ function LANG(Str) bNotCheck = false; var Name = this.value; var key = this.KeyWords[Name]; - if(key == 1 || Name == "function") - { + if (key == 1 || Name == "function") { this["Parse_" + this.ProcessWords[Name]](); - if(!bSimpleMode) - { + if (!bSimpleMode) { this.AddNewLineToStream(";\n"); } type = this.type; @@ -805,67 +713,55 @@ function LANG(Str) default: this.pos = posSave; type = this.ParseExpressionWithComma(false, false, true); - if(type === ":") - { + if (type === ":") { bWasLabel = true; } - else - { + else { bWasLabel = false; - if(!bSimpleMode) - { + if (!bSimpleMode) { this.AddNewLineToStream(";\n"); } } } - if(bOneIteration && type != ":") + if (bOneIteration && type != ":") break; } - if(sConditions) - { - if(sConditions.indexOf(type) == - 1) - { + if (sConditions) { + if (sConditions.indexOf(type) == - 1) { this.Error("Error block closing. Unexpected token: '%1'", this.GetTokenName(type)); } } this.IgnoreCodeLevel = WasIgnoreCodeLevel; - if(!bOneIteration) + if (!bOneIteration) this.BlockLevel--; return type; }; - this.ParseOneBlock = function () - { + this.ParseOneBlock = function() { var type = this.PosNextToken(); - if(type == "{") - { + if (type == "{") { this.AddNewLineToStream("\n"); this.AddNewLineToStream("{\n", true); var type = this.ParseBlock("}"); this.AddNewLineToStream("}\n", true); } else - if(type == ";") - { - if(this.InjectCheck) - { + if (type == ";") { + if (this.InjectCheck) { this.AddCheckLineToStream(); this.AddNewLineToStream("\n"); } else this.AddNewLineToStream(";\n"); } - else - { - if(this.InjectCheck) - { + else { + if (this.InjectCheck) { this.AddNewLineToStream("\n"); this.AddNewLineToStream("{\n", true); this.BackPos(); var type = this.ParseBlock(false, true); this.AddNewLineToStream("}\n", true); } - else - { + else { this.AddNewLineToStream("\n"); this.BackPos(); this.BlockLevel++; @@ -873,59 +769,52 @@ function LANG(Str) this.BlockLevel--; } } - if(type == ";") - { + if (type == ";") { this.NotBackPos(); } return type; }; - this.ParseExpressionWithComma = function (sConditions,bCanEmpty,bCanLabel) - { + this.ParseExpressionWithComma = function(sConditions, bCanEmpty, bCanLabel) { var sConditions2; - if(sConditions) + if (sConditions) sConditions2 = "," + sConditions; - while(true) - { + while (true) { var prev = this.pos; var type = this.ParseExpression(sConditions2, bCanEmpty, bCanLabel); - if(type != ",") + if (type != ",") break; - if(prev == this.pos || !sConditions2) + if (prev == this.pos || !sConditions2) this.PosNextItem(); bCanLabel = false; - if(this.CountCol <= this.PrintMargin) + if (this.CountCol <= this.PrintMargin) this.AddToStream(", "); else this.AddNewLineToStream(",\n", true); } return type; }; - this.ParseExpression = function (sConditions,bCanEmpty,bCanLabel) - { + this.ParseExpression = function(sConditions, bCanEmpty, bCanLabel) { var WasPlus2 = this.WasPlus; var stream2 = this.stream; this.WasPlus = 0; this.stream = ""; var type = this.ParseExpression0(sConditions, bCanEmpty, bCanLabel); - if(this.WasPlus) + if (this.WasPlus) this.stream = stream2 + "CHKL(" + this.stream + ")"; else this.stream = stream2 + this.stream; this.WasPlus = WasPlus2; return type; }; - this.ParseExpression0 = function (sConditions,bCanEmpty,bCanLabel) - { + this.ParseExpression0 = function(sConditions, bCanEmpty, bCanLabel) { var bWasExpr = false; var bCanDot = false; var bCanLeftSide = false; this.beforeRegExp = 61; Main: - while(true) - { + while (true) { var type = this.PosNextItem(); - switch(type) - { + switch (type) { case this.enSpaces: case this.enComments: continue; @@ -938,43 +827,36 @@ function LANG(Str) case this.enString: case this.enRegular: case "{": - if(bWasExpr) + if (bWasExpr) break Main; } - switch(type) - { + switch (type) { case this.enIndenifier: var Name = this.value; var key = this.KeyWords[Name]; - if(key == 3) - { + if (key == 3) { this["Parse_" + this.ProcessWords[Name]](); } else - if(key == 1 || key == 5) - { + if (key == 1 || key == 5) { type = this.enOperator; this.BackPos(); break Main; } - else - { - if(!this.AllowedWords[Name]) + else { + if (!this.AllowedWords[Name]) Name = LOC_ADD_NAME + Name; this.AddToStream(Name); - if(bCanLabel) - { + if (bCanLabel) { var posSave2 = this.pos; var type2 = this.PosNextToken(); - if(type2 == ":") - { + if (type2 == ":") { type = type2; bWasExpr = true; this.AddNewLineToStream(":\n", true); return ":"; } - else - { + else { this.pos = posSave2; } } @@ -1020,7 +902,7 @@ function LANG(Str) bWasExpr = true; break; case ".": - if(!bCanDot) + if (!bCanDot) this.Error("Unexpected token: '%1'", type); this.AddToStream("."); this.RequireIndenifier(); @@ -1029,7 +911,7 @@ function LANG(Str) bWasExpr = true; break; case "?": - if(!bWasExpr) + if (!bWasExpr) this.Error("Require expression before token: '%1'", type); this.ParseIfCondition(); bCanLeftSide = false; @@ -1038,9 +920,9 @@ function LANG(Str) break; case "=": case "+=": - if(type === "+=") + if (type === "+=") this.WasPlus = 1; - if(!bCanLeftSide) + if (!bCanLeftSide) this.Error("Unexpected token: '%1'", type); this.AddToStream(" " + type + " "); var type2 = this.ParseExpression(undefined, false, false); @@ -1058,7 +940,7 @@ function LANG(Str) case "|=": case "^=": case "%=": - if(!bCanLeftSide) + if (!bCanLeftSide) this.Error("Unexpected token: '%1'", type); this.AddToStream(" " + type + " "); bCanLeftSide = false; @@ -1095,7 +977,7 @@ function LANG(Str) case "/": case "&&": case "||": - if(!bWasExpr) + if (!bWasExpr) this.Error("Require expression before token: '%1'", type); bWasExpr = false; this.AddToStream(" " + type + " "); @@ -1104,7 +986,7 @@ function LANG(Str) break; case "-": case "+": - if(type === "+") + if (type === "+") this.WasPlus = 1; bWasExpr = false; this.AddToStream(" " + type + " "); @@ -1113,14 +995,13 @@ function LANG(Str) break; case "++": case "--": - if(this.WasEnter) - if(bWasExpr) - { + if (this.WasEnter) + if (bWasExpr) { type = ";"; break Main; } - if(bWasExpr) - if(!bCanDot) + if (bWasExpr) + if (!bCanDot) this.Error("Invalid left-side argument before token: '%1'", type); this.AddToStream(type); bCanLeftSide = false; @@ -1129,7 +1010,7 @@ function LANG(Str) case "in": case "of": case "instanceof": - if(!bWasExpr) + if (!bWasExpr) this.Error("Invalid argument before: '%1'", type); this.AddToStream(" " + type + " "); this.ParseExpressionWithComma(false, false); @@ -1150,46 +1031,38 @@ function LANG(Str) } this.WasEnter = false; } - if(sConditions) - { - if(sConditions.indexOf(type) == - 1) - { - if(type == this.enOperator) + if (sConditions) { + if (sConditions.indexOf(type) == - 1) { + if (type == this.enOperator) this.Error("Unexpected keywords: '%1'", Name); - else - { + else { var str = this.GetTokenName(type); - if(str == type) + if (str == type) this.Error("Error expression closing. Unexpected token: '%1'", str); else this.Error("Error expression closing. Unexpected %1", str); } } } - else - { + else { this.BackPos(); } - if(!bCanEmpty && !bWasExpr) - { + if (!bCanEmpty && !bWasExpr) { var str; - if(type == this.enOperator) + if (type == this.enOperator) str = Name; - else - { + else { str = this.GetTokenName(type); } - if(str == type) + if (str == type) this.Error("Require expression before token: '%1'", str); else this.Error("Require expression before: %1", str); } return type; }; - this.GetTokenName = function (type) - { - switch(type) - { + this.GetTokenName = function(type) { + switch (type) { case this.enNumber: return "number"; case this.enIndenifier: @@ -1204,98 +1077,81 @@ function LANG(Str) return type; } }; - this.RequireChar = function (sFind) - { + this.RequireChar = function(sFind) { var type = this.PosNextToken(); - if(type != sFind) + if (type != sFind) this.Error("Require token: '%1'", sFind); }; - this.RequireIndenifier = function (Name,DopStr) - { + this.RequireIndenifier = function(Name, DopStr) { var type = this.PosNextToken(); - if(type != this.enIndenifier || (Name && this.value != Name)) - { - if(Name) + if (type != this.enIndenifier || (Name && this.value != Name)) { + if (Name) this.Error("Require indenifier: '%1'", Name); else this.Error("Require indenifier"); } - if(DopStr) + if (DopStr) this.AddToStream(DopStr + this.value); else this.AddToStream(this.value); return this.value; }; - this.RequireIndenifierOptional = function () - { + this.RequireIndenifierOptional = function() { var type = this.PosNextToken(); - if(type != this.enIndenifier) - { + if (type != this.enIndenifier) { this.BackPos(); } - else - { + else { this.AddToStream(" " + this.value); } }; - this.HasEnter = function () - { + this.HasEnter = function() { this.PosNextToken(); this.BackPos(); return this.WasEnter; }; - this.Parse_var = function () - { + this.Parse_var = function() { this.AddToStream("var "); - while(true) - { + while (true) { this.RequireIndenifier(undefined, LOC_ADD_NAME); var type = this.PosNextToken(); this.AddToStream(type); - if(type === "=") + if (type === "=") this.ParseExpressionWithComma(false, false); - if(type !== ",") - { + if (type !== ",") { break; } } }; - this.Parse_function = function (bGetSet,bFindExternal) - { - if(!bGetSet) - { + this.Parse_function = function(bGetSet, bFindExternal) { + if (!bGetSet) { this.AddToStream("function "); } var FuncName; var type = this.PosNextToken(); - if(type == this.enIndenifier) - { + if (type == this.enIndenifier) { FuncName = this.value; - if(bGetSet) + if (bGetSet) this.AddToStream(FuncName); else this.AddToStream(LOC_ADD_NAME + FuncName); type = this.PosNextToken(); } else - if(bGetSet) - { + if (bGetSet) { this.Error("Require name before: '%1'", type); } - if(type != "(") + if (type != "(") this.Error("Require token: '%1'", "("); this.AddToStream("("); var bMustIdentifier = false; - while(true) - { + while (true) { type = this.PosNextToken(); - if(type == this.enIndenifier) - { + if (type == this.enIndenifier) { var Name = this.value; this.AddToStream(LOC_ADD_NAME + Name); type = this.PosNextToken(); - if(type == ",") - { + if (type == ",") { this.AddToStream(","); bMustIdentifier = true; continue; @@ -1303,33 +1159,28 @@ function LANG(Str) bMustIdentifier = false; } else - if(bMustIdentifier) - { + if (bMustIdentifier) { this.Error("Require indenifier"); break; } - if(type == ")") + if (type == ")") break; this.Error("Require indenifier"); } - if(FuncName && bFindExternal) - { + if (FuncName && bFindExternal) { this.FunctionMap[FuncName] = 1; type = this.PosNextToken(); - if(this.value === 'public') - { + if (this.value === 'public') { this.ExternMap[FuncName] = 1; } - else - { + else { this.BackPos(); } } this.RequireChar("{"); this.AddNewLineToStream(")\n", true); this.AddNewLineToStream("{\n", true); - if(this.InjectCheck) - { + if (this.InjectCheck) { this.AddCheckLineToStream(30); } this.ParseBlock("}", false, false, false); @@ -1337,86 +1188,71 @@ function LANG(Str) this.AddToStream("}", "} "); return FuncName; }; - this.ParseFunctionCall = function (bCanEmpty) - { + this.ParseFunctionCall = function(bCanEmpty) { this.AddToStream("("); this.ParseExpressionWithComma(")", true); this.AddToStream(")"); }; - this.Parse_void = function () - { + this.Parse_void = function() { this.AddToStream("void "); var type = this.ParseExpression(); }; - this.Parse_new = function () - { + this.Parse_new = function() { this.AddToStream("new "); var type = this.ParseExpression(); }; - this.Parse_delete = function () - { + this.Parse_delete = function() { this.AddToStream("delete "); this.ParseExpression(); }; - this.ParseIfCondition = function () - { + this.ParseIfCondition = function() { this.AddToStream(" ? "); this.ParseExpression(":"); this.AddToStream(" : "); this.ParseExpression(); }; - this.ParseDefArray = function () - { + this.ParseDefArray = function() { this.AddToStream("["); this.ParseExpressionWithComma("]", true); this.AddToStream("]"); }; - this.ParseDefObject = function () - { + this.ParseDefObject = function() { this.BlockLevel++; this.AddToStream("{"); - while(true) - { + while (true) { var type = this.PosNextToken(); - if(type == this.enIndenifier || type == this.enString || type == this.enNumber) - { + if (type == this.enIndenifier || type == this.enString || type == this.enNumber) { var Name = this.value; - if(Name === "get" || Name === "set") - { + if (Name === "get" || Name === "set") { type = this.PosNextToken(); - if(type == ":") - { + if (type == ":") { this.AddToStream(Name + ":"); type = this.ParseExpression(",}"); } - else - { + else { this.AddToStream(Name + " "); this.BackPos(); this.Parse_function(true); type = this.PosNextToken(); } } - else - { + else { this.RequireChar(":"); this.AddToStream(Name + ":"); type = this.ParseExpression(",}"); } } - if(type == "}") + if (type == "}") break; else - if(type == ",") - { - if(this.CountCol <= this.PrintMargin) + if (type == ",") { + if (this.CountCol <= this.PrintMargin) this.AddToStream(", "); else this.AddNewLineToStream(",\n", true); continue; } - else - { + else { this.Error("Unexpected token: '%1'", this.GetTokenName(type)); break; } @@ -1424,34 +1260,29 @@ function LANG(Str) this.BlockLevel--; this.AddToStream("}", "} "); }; - this.Parse_break = function () - { + this.Parse_break = function() { this.AddToStream("break"); - if(this.HasEnter()) - return ; + if (this.HasEnter()) + return; this.RequireIndenifierOptional(); }; - this.Parse_continue = function () - { + this.Parse_continue = function() { this.AddToStream("continue"); - if(this.HasEnter()) - return ; + if (this.HasEnter()) + return; this.RequireIndenifierOptional(); }; - this.Parse_return = function () - { + this.Parse_return = function() { this.AddToStream("return "); - if(this.HasEnter()) - return ; + if (this.HasEnter()) + return; this.ParseExpressionWithComma(false, true); }; - this.Parse_typeof = function () - { + this.Parse_typeof = function() { this.AddToStream("typeof "); this.ParseExpression(); }; - this.Parse_for = function () - { + this.Parse_for = function() { this.AddToStream("for("); this.RequireChar("("); var bForInMode = false; @@ -1459,32 +1290,27 @@ function LANG(Str) var bWasName; var posSave = this.pos; var type = this.PosNextToken(); - if(type == this.enIndenifier) - { - if(this.value == "var") - { + if (type == this.enIndenifier) { + if (this.value == "var") { type = this.PosNextToken(); bWasVar = true; } - if(type == this.enIndenifier) - { + if (type == this.enIndenifier) { bWasName = this.value; type = this.PosNextToken(); - if(type == this.enIndenifier && (this.value == "in" || this.value == "of")) + if (type == this.enIndenifier && (this.value == "in" || this.value == "of")) bForInMode = true; } } - if(bForInMode) - { - if(bWasVar) + if (bForInMode) { + if (bWasVar) this.AddToStream("var "); this.AddToStream(LOC_ADD_NAME + bWasName + " " + this.value + " "); } - else - { + else { this.pos = posSave; var type = this.ParseBlock(";", true, true); - if(type == ";") + if (type == ";") this.NotBackPos(); this.AddToStream("; "); this.ParseExpressionWithComma(";", true); @@ -1494,16 +1320,14 @@ function LANG(Str) this.AddToStream(")"); this.ParseOneBlock(); }; - this.Parse_while = function () - { + this.Parse_while = function() { this.RequireChar("("); this.AddToStream("while("); this.ParseExpressionWithComma(")"); this.AddToStream(")"); this.ParseOneBlock(); }; - this.Parse_do = function () - { + this.Parse_do = function() { this.AddToStream("do"); this.ParseOneBlock(); this.RequireIndenifier("while"); @@ -1512,26 +1336,22 @@ function LANG(Str) this.ParseExpressionWithComma(")"); this.AddToStream(")"); }; - this.Parse_if = function () - { + this.Parse_if = function() { this.AddToStream("if("); this.RequireChar("("); this.ParseExpressionWithComma(")"); this.AddToStream(")"); this.ParseOneBlock(); var type = this.PosNextToken(); - if(type == this.enIndenifier && this.ProcessWords[this.value] == "else") - { + if (type == this.enIndenifier && this.ProcessWords[this.value] == "else") { this.AddToStream("else"); this.ParseOneBlock(); } - else - { + else { this.BackPos(); } }; - this.Parse_switch = function () - { + this.Parse_switch = function() { this.RequireChar("("); this.AddToStream("switch("); this.ParseExpressionWithComma(")"); @@ -1543,41 +1363,36 @@ function LANG(Str) this.BlockLevel--; this.AddNewLineToStream("}\n", true); }; - this.Parse_case = function () - { + this.Parse_case = function() { this.BlockLevel--; this.AddToStream("case "); this.ParseExpressionWithComma(":"); this.AddNewLineToStream(":\n", true); this.BlockLevel++; }; - this.Parse_default = function () - { + this.Parse_default = function() { this.RequireChar(":"); this.BlockLevel--; this.AddNewLineToStream("default:\n", true); this.BlockLevel++; }; - this.Parse_with = function () - { + this.Parse_with = function() { this.RequireChar("("); this.AddToStream("with("); this.ParseExpressionWithComma(")"); this.AddToStream(")"); this.ParseOneBlock(); }; - this.Parse_try = function () - { + this.Parse_try = function() { this.Error("try-catch not support"); - return ; + return; this.RequireChar("{"); this.AddToStream("try\n"); this.AddNewLineToStream("{\n", true); this.ParseBlock("}"); this.AddNewLineToStream("}\n", true); var type = this.PosNextToken(); - if(type == this.enIndenifier && this.ProcessWords[this.value] == "catch") - { + if (type == this.enIndenifier && this.ProcessWords[this.value] == "catch") { this.AddToStream("catch("); this.RequireChar("("); this.RequireIndenifier(); @@ -1589,8 +1404,7 @@ function LANG(Str) this.AddToStream("}"); type = this.PosNextToken(); } - if(type == this.enIndenifier && this.ProcessWords[this.value] == "finally") - { + if (type == this.enIndenifier && this.ProcessWords[this.value] == "finally") { this.RequireChar("{"); this.AddNewLineToStream("\n"); this.AddNewLineToStream("finally\n", true); @@ -1598,86 +1412,69 @@ function LANG(Str) this.ParseBlock("}"); this.AddToStream("}"); } - else - { + else { this.BackPos(); } }; - this.Parse_throw = function () - { + this.Parse_throw = function() { this.AddToStream("throw "); - if(this.HasEnter()) - return ; + if (this.HasEnter()) + return; var type = this.ParseExpressionWithComma(); }; - this.AddCheckLineToStream = function (Count) - { - if(this.InjectCheck) - { - if(!Count) + this.AddCheckLineToStream = function(Count) { + if (this.InjectCheck) { + if (!Count) Count = 1; this.CalculateLineNumber(); this.AddToStream("DO(" + Count + ");"); } }; - this.CalculateLineNumber = function () - { - for(var i = this.posLineNumber; i < this.pos; i++) - if(this.buf[i] == "\n") + this.CalculateLineNumber = function() { + for (var i = this.posLineNumber; i < this.pos; i++) + if (this.buf[i] == "\n") this.LineNumber++; this.posLineNumber = this.pos; }; - this.CalculateLineNumber0 = function (str) - { - for(var i = 0; i < str.length; i++) - if(str[i] == "\n") + this.CalculateLineNumber0 = function(str) { + for (var i = 0; i < str.length; i++) + if (str[i] == "\n") this.LineNumber++; }; - this.AddCheckToStream = function (str) - { - if(this.InjectCheck) - { + this.AddCheckToStream = function(str) { + if (this.InjectCheck) { this.AddToStream(str); } }; - this.AddToStreamSimple = function (str,strMustLast) - { - if(strMustLast) + this.AddToStreamSimple = function(str, strMustLast) { + if (strMustLast) this.LastStreamValue = strMustLast; else this.LastStreamValue = str; - if(!this.IgnoreCodeLevel) + if (!this.IgnoreCodeLevel) this.stream += str; }; - this.AddToStreamAddTab = function (str,strMustLast) - { - if(this.LastStreamValue[this.LastStreamValue.length - 1] == "\n") - { + this.AddToStreamAddTab = function(str, strMustLast) { + if (this.LastStreamValue[this.LastStreamValue.length - 1] == "\n") { this.CountCol = 0; - if(!this.IgnoreCodeLevel) + if (!this.IgnoreCodeLevel) this.stream += this.SpacesArray[this.BlockLevel >= 100 ? 99 : this.BlockLevel]; } - if(str[str.length - 1] == "\n") - { + if (str[str.length - 1] == "\n") { this.CountCol = 0; } - else - { + else { this.CountCol += str.length; } this.AddToStreamSimple(str, strMustLast); }; - this.AddNewLineToStream = function (str,bAlways) - { + this.AddNewLineToStream = function(str, bAlways) { var sLast = this.LastStreamValue[this.LastStreamValue.length - 1]; - if(bAlways || sLast != "\n") - { - if(str == ";\n" && (sLast == "}" || sLast == ";")) - { + if (bAlways || sLast != "\n") { + if (str == ";\n" && (sLast == "}" || sLast == ";")) { this.AddToStream("\n"); } - else - { + else { this.AddToStream(str); } } diff --git a/src/HTML/JS/mobile-wallet.js b/src/HTML/JS/mobile-wallet.js index ce2ed6b..3151a85 100644 --- a/src/HTML/JS/mobile-wallet.js +++ b/src/HTML/JS/mobile-wallet.js @@ -9,34 +9,30 @@ */ var SaveIdArr = ["idAccount", "idTo", "idSumSend", "idDescription", "idCurTabName", "idViewBlockNum", "idViewAccountNum", "idViewDappNum", -"idLang"]; -var CONFIG_DATA = {PRICE_DAO:{NewAccount:10}, MaxNumBlockDB:0, MaxAccID:0, MaxDappsID:0}; + "idLang"]; +var CONFIG_DATA = { PRICE_DAO: { NewAccount: 10 }, MaxNumBlockDB: 0, MaxAccID: 0, MaxDappsID: 0 }; var CountViewRows = 20; -var DefAccounts = {BlockName:"idPaginationAccount", NumName:"idViewAccountNum", TabName:"explorer_accounts", APIName:"GetAccountList"}; -var DefBlock = {BlockName:"idPaginationBlock", NumName:"idViewBlockNum", TabName:"explorer_blocks", APIName:"GetBlockList"}; -var DefDapps = {BlockName:"idPaginationDapps", NumName:"idViewDappNum", TabName:"dapps_list", APIName:"GetDappList", CountViewRows:10, - FilterName:"idCategory"}; +var DefAccounts = { BlockName: "idPaginationAccount", NumName: "idViewAccountNum", TabName: "explorer_accounts", APIName: "GetAccountList" }; +var DefBlock = { BlockName: "idPaginationBlock", NumName: "idViewBlockNum", TabName: "explorer_blocks", APIName: "GetBlockList" }; +var DefDapps = { + BlockName: "idPaginationDapps", NumName: "idViewDappNum", TabName: "dapps_list", APIName: "GetDappList", CountViewRows: 10, + FilterName: "idCategory" +}; -function SetImg() -{ +function SetImg() { }; var CONNECT_STATUS = 0; var NotModalClose = 0; -window.onload = function () -{ +window.onload = function() { InitAccountsCard(); DoLangScript(); InitWalletKeyName(); - if(Storage.getItem("NETWORK") || IsLocalClient()) - { + if (Storage.getItem("NETWORK") || IsLocalClient()) { OnLoad(); } - else - { - GetData("/GetCurrentInfo", {}, function (Data) - { - if(Data && Data.result) - { + else { + GetData("/GetCurrentInfo", {}, function(Data) { + if (Data && Data.result) { Storage.setItem("NETWORK", Data.NETWORK); console.log("Default network: " + Data.NETWORK); OnLoad(); @@ -44,31 +40,25 @@ window.onload = function () }); } var HasPassword = IsLockedWallet(); - if(HasPassword) - { + if (HasPassword) { NotModalClose = 1; openModal('password-modal-enter'); } - else - { + else { OpenWalletKey(); } SetUsePassword(HasPassword); - window.onkeydown = function (e) - { - if(e.keyCode === 27) - { - if(IsVisibleBlock("overlay")) + window.onkeydown = function(e) { + if (e.keyCode === 27) { + if (IsVisibleBlock("overlay")) closeModal(); } }; $("idAccountsList").addEventListener("click", MyToggleList); }; -function OnLoad() -{ - if(Storage.getItem("NETWORK")) - { +function OnLoad() { + if (Storage.getItem("NETWORK")) { NETWORK = Storage.getItem("NETWORK"); } $("idCurNetwork").value = NETWORK; @@ -80,22 +70,18 @@ function OnLoad() setInterval(UpdatesExplorerData, 1000); setInterval(UpdatesAccountsData, 1000); DoStableScroll(); - window.onmousemove = function (event) - { + window.onmousemove = function(event) { SetDiagramMouseX(event); }; - if(window.location.hash) - { + if (window.location.hash) { var LocationPath = window.location.hash.substr(1); - if(LocationPath) - { + if (LocationPath) { SelectTab(LocationPath); } } }; -function ChangeNetwork() -{ +function ChangeNetwork() { CONNECT_STATUS = 0; NETWORK = $("idCurNetwork").value; Storage.setItem("NETWORK", NETWORK); @@ -104,196 +90,164 @@ function ChangeNetwork() UpdatesAccountsData(); }; -function OnFindServer() -{ - if(!MainServer) - { - CONNECT_STATUS = - 1; +function OnFindServer() { + if (!MainServer) { + CONNECT_STATUS = - 1; SetStatus("Server not found"); Storage.setItem("MainServer", undefined); - return ; + return; } CONNECT_STATUS = 2; - Storage.setItem("MainServer", JSON.stringify({ip:MainServer.ip, port:MainServer.port})); + Storage.setItem("MainServer", JSON.stringify({ ip: MainServer.ip, port: MainServer.port })); FillCurrencyAsync("idAccountCur"); }; -function LoadValues() -{ +function LoadValues() { var StrDelList = localStorage["DelList"]; - if(StrDelList) + if (StrDelList) DelList = JSON.parse(StrDelList); - if(LoadValuesByArr(SaveIdArr)) - { + if (LoadValuesByArr(SaveIdArr)) { ChangeLang(); } InitPrivKey(); }; -function SaveValues() -{ +function SaveValues() { SaveValuesByArr(SaveIdArr); localStorage["DelList"] = JSON.stringify(DelList); }; -var TabArr = [{name:"TabWelcome"}, {name:"TabWalletSet"}, {name:"TabKeySet"}, {name:"TabAccounts"}, {name:"TabSend"}, {name:"TabDapps"}, - {name:"TabExplorer"}, {name:"TabLogo"}]; +var TabArr = [{ name: "TabWelcome" }, { name: "TabWalletSet" }, { name: "TabKeySet" }, { name: "TabAccounts" }, { name: "TabSend" }, { name: "TabDapps" }, +{ name: "TabExplorer" }, { name: "TabLogo" }]; -function SelectTab(name) -{ +function SelectTab(name) { SetStatus(""); $("idCurTabName").value = name; SetVisibleTab(); SaveValues(); OnSelectTab(name); - if(name && history.pushState) + if (name && history.pushState) history.pushState(null, null, "#" + name); }; -function OnSelectTab(name) -{ - if(!GetPrivKey()) - { +function OnSelectTab(name) { + if (!GetPrivKey()) { GenerateKeyNew(); SetPrivKey($("idPrivKeyEdit").value.trim()); InitPrivKey(); } - if(name === "TabDapps") - { + if (name === "TabDapps") { ViewDapps(); } }; -function SetVisibleTab() -{ +function SetVisibleTab() { var CurTabName = $("idCurTabName").value; - if(!CurTabName || CurTabName === "undefined") + if (!CurTabName || CurTabName === "undefined") CurTabName = TabArr[0].name; var str; - for(var i = 0; i < TabArr.length; i++) - { + for (var i = 0; i < TabArr.length; i++) { var name = TabArr[i].name; var Item = $(name); - if(!Item) + if (!Item) continue; - if(CurTabName === name) - { + if (CurTabName === name) { Item.style.display = 'block'; str = "active"; } - else - { + else { Item.style.display = 'none'; str = ""; } var ItemM = $("M" + name); - if(ItemM) - { - if(str) - { + if (ItemM) { + if (str) { ItemM.classList.add(str); } - else - { + else { ItemM.classList.remove("active"); } } } }; -function IsPrivateMode() -{ +function IsPrivateMode() { var PrivKeyStr = GetPrivKey(); - if(PrivKeyStr && PrivKeyStr.length === 64) + if (PrivKeyStr && PrivKeyStr.length === 64) return 1; else return 0; }; -function SetVisiblePrivKey() -{ - if(bShowPrivKey) +function SetVisiblePrivKey() { + if (bShowPrivKey) $("idPrivKeyStatic").innerText = GetPrivKey(); else $("idPrivKeyStatic").innerText = "••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••"; }; var bShowPrivKey = 0; -function OnVisiblePrivKey() -{ +function OnVisiblePrivKey() { bShowPrivKey = !bShowPrivKey; SetVisiblePrivKey(); }; -function SetPubKeyHTML() -{ +function SetPubKeyHTML() { $("idPubKeyStatic").innerText = GetPubKey(); }; -function GenerateKeyNew() -{ +function GenerateKeyNew() { var arr = new Uint8Array(32); window.crypto.getRandomValues(arr); var Str = GetHexFromArr(sha3(arr)); $("idPrivKeyEdit").value = Str; }; -function OnGenerateKeyNew() -{ +function OnGenerateKeyNew() { GenerateKeyNew(); }; -function OnEditPrivKey() -{ +function OnEditPrivKey() { }; -function OnPrivKeyOK() -{ +function OnPrivKeyOK() { SetPrivKey($("idPrivKeyEdit").value.trim()); InitPrivKey(); SelectTab('TabKeySet'); ClearSend(); }; -function OnPrivKeyCancel() -{ +function OnPrivKeyCancel() { InitPrivKey(); SelectTab('TabKeySet'); }; var FirstAccountsData = 1; -var AccountsCount = - 1; +var AccountsCount = - 1; -function UpdatesAccountsData() -{ - if(IsVisibleClass(".accounts-info__add")) - return ; - if(!CONNECT_STATUS) - return ; +function UpdatesAccountsData() { + if (IsVisibleClass(".accounts-info__add")) + return; + if (!CONNECT_STATUS) + return; var Str = GetPubKey(); - if(!Str) - { - return ; + if (!Str) { + return; } - GetData("/GetAccountListByKey", {Key:Str, AllData:FirstAccountsData}, function (Data,responseText) - { - if(!Data || !Data.result || !Data.arr) - return ; - if(AccountsCount === Data.arr.length) - { - if(IsVisibleClass(".accounts-info__add2")) - return ; + GetData("/GetAccountListByKey", { Key: Str, AllData: FirstAccountsData }, function(Data, responseText) { + if (!Data || !Data.result || !Data.arr) + return; + if (AccountsCount === Data.arr.length) { + if (IsVisibleClass(".accounts-info__add2")) + return; } AccountsCount = Data.arr.length; SetVisibleClass(".accounts-info__acc-list", AccountsCount); SetVisibleClass(".accounts-info__empty", !AccountsCount); SetVisibleClass(".accounts-info__add2", 0); - if(AccountsCount) - { + if (AccountsCount) { SetAccountsCard(Data, responseText); } - else - { - if(FirstAccountsData && !Data.arr.length) - { + else { + if (FirstAccountsData && !Data.arr.length) { SelectTab('TabAccounts'); } } @@ -301,41 +255,34 @@ function UpdatesAccountsData() }); }; -function ViewAddAccount(Visible) -{ +function ViewAddAccount(Visible) { SetVisibleClass(".accounts-info__add", Visible); SetVisibleClass(".accounts-info__acc-list", !Visible); SetVisibleClass(".accounts-info__empty", 0); }; -function OnViewAddAccount() -{ +function OnViewAddAccount() { OnChangeAccName(); ViewAddAccount(1); $("idAccountName").focus(); }; -function CancelAddAccount() -{ +function CancelAddAccount() { ViewAddAccount(0); }; -function OnChangeAccName() -{ +function OnChangeAccName() { $("idBtAddAccount").disabled = !($("idAccountName").value.length); }; -function CancelCreateAccount() -{ +function CancelCreateAccount() { }; -function OnAddAccount() -{ +function OnAddAccount() { var Name = $("idAccountName").value; - if(!Name) - { + if (!Name) { SetError("Enter the account name"); - return ; + return; } var Smart = 0; var Currency = ParseNum($("idAccountCur").value); @@ -347,36 +294,29 @@ function OnAddAccount() var WasAccountsDataStr; var StrAccCardTemplate; -function InitAccountsCard() -{ - if($("AccCardTemplate")) - { +function InitAccountsCard() { + if ($("AccCardTemplate")) { StrAccCardTemplate = $("AccCardTemplate").outerHTML; $("AccCardTemplate").outerHTML = ""; } }; -function SetAccountsCard(Data,AccountsDataStr) -{ - if(!Data || !Data.result) - { - return ; +function SetAccountsCard(Data, AccountsDataStr) { + if (!Data || !Data.result) { + return; } - if(AccountsDataStr === WasAccountsDataStr) - return ; + if (AccountsDataStr === WasAccountsDataStr) + return; WasAccountsDataStr = AccountsDataStr; var arr = []; - for(var i = 0; Data.arr && i < Data.arr.length; i++) - { + for (var i = 0; Data.arr && i < Data.arr.length; i++) { var Item = Data.arr[i]; - if(!DelList[Item.Num]) - { + if (!DelList[Item.Num]) { arr.push(Item); } } var Select = $("idAccount"); - if(arr.length !== Select.options.length) - { + if (arr.length !== Select.options.length) { var options = Select.options; options.length = arr.length; } @@ -384,17 +324,16 @@ function SetAccountsCard(Data,AccountsDataStr) $("idListCount").innerText = arr.length; var StrList = ""; var ListTotal = {}; - for(var i = 0; arr && i < arr.length; i++) - { + for (var i = 0; arr && i < arr.length; i++) { var Item = arr[i]; Item.MyAccount = true; var Num = ParseNum(Item.Num); - if(!MapAccounts[Num]) + if (!MapAccounts[Num]) MapAccounts[Num] = {}; CopyObjKeys(MapAccounts[Num], Item); var option = Select.options[i]; var StrText = GetAccountText(Item, Num, 1); - if(option.text !== StrText) + if (option.text !== StrText) CheckNameAccTo(); option.value = Num; option.text = StrText; @@ -405,35 +344,32 @@ function SetAccountsCard(Data,AccountsDataStr) Str = Str.replace("{Value.SumCENT}", Item.Value.SumCENT); Str = Str.replace("{Value.CurrencyName}", CurrencyName(Item.Currency)); var CurrencyObj = Item.CurrencyObj; - if(!CurrencyObj) - CurrencyObj = {IconBlockNum:0, Num:0}; + if (!CurrencyObj) + CurrencyObj = { IconBlockNum: 0, Num: 0 }; Str = Str.replace("{Value.CurrencyIconPath}", RetIconPath(CurrencyObj, 1)); var CurrencyPath = RetIconPath(CurrencyObj); - if(CurrencyPath.substr(0, 6) !== "/file/") + if (CurrencyPath.substr(0, 6) !== "/file/") Str = Str.replace("prod-card__currency--with-dot", ""); Str = Str.replace("{Item.Name}", escapeHtml(Item.Name)); var SmartObj = Item.SmartObj; - if(!SmartObj) - SmartObj = {Name:"", Num:0}; + if (!SmartObj) + SmartObj = { Name: "", Num: 0 }; SmartObj.IconPath = RetIconPath(SmartObj, 0); Str = Str.replace("{SmartObj.IconPath}", SmartObj.IconPath); Str = Str.replace("{SmartObj.Name}", escapeHtml(SmartObj.Name)); Str = Str.replace(/{SmartObj.Num}/g, SmartObj.Num); - if(SmartObj.Num) - { + if (SmartObj.Num) { Str = Str.replace("prod-card__link--connect", "myhidden"); } - else - { + else { Str = Str.replace("prod-card__link--dapp", "myhidden"); Str = Str.replace("prod-card__dropdown", "prod-card__dropdown nodapp"); } StrList += Str; Str = ""; var Total = ListTotal[Item.Currency]; - if(!Total) - { - Total = {SumCOIN:0, SumCENT:0, Name:CurrencyName(Item.Currency)}; + if (!Total) { + Total = { SumCOIN: 0, SumCENT: 0, Name: CurrencyName(Item.Currency) }; ListTotal[Item.Currency] = Total; } ADD(Total, Item.Value); @@ -441,73 +377,61 @@ function SetAccountsCard(Data,AccountsDataStr) $("idAccountsList").innerHTML = StrList; StrList = ""; var StrTotal = ""; - for(var key in ListTotal) - { + for (var key in ListTotal) { var Total = ListTotal[key]; StrTotal += '
' + Total.Name + '
' + STRING_FROM_COIN(Total) + '
'; } $("idTotalList").innerHTML = StrTotal; var CurentValue = LoadMapAfter["idAccount"]; - if(CurentValue) - { + if (CurentValue) { Select.value = CurentValue; delete LoadMapAfter["idAccount"]; } }; -function ConnectSmart(NumAccount) -{ +function ConnectSmart(NumAccount) { ChangeSmart(NumAccount, 0); }; -function SetSmart(NumAccount,WasSmart) -{ +function SetSmart(NumAccount, WasSmart) { ChangeSmart(NumAccount, WasSmart); }; -function DelSmart(NumAccount,WasSmart) -{ +function DelSmart(NumAccount, WasSmart) { SetSmartToAccount(NumAccount, 0); }; -function DelAccount(NumAccount) -{ +function DelAccount(NumAccount) { DelList[NumAccount] = 1; AccountsCount = 0; WasAccountsDataStr = ""; SaveValues(); }; -function RestoreAllAccounts() -{ +function RestoreAllAccounts() { DelList = {}; DelAccount(0); }; -function UpdatesExplorerData() -{ +function UpdatesExplorerData() { var WasSendTr = 0; - for(var key in MapSendTransaction) - { + for (var key in MapSendTransaction) { var Item = MapSendTransaction[key]; - if(!Item.WasProcess && !Item.final) - { + if (!Item.WasProcess && !Item.final) { WasSendTr = 1; break; } } - GetData("GetCurrentInfo", {Diagram:IsVisibleBlock("idStatBlock") ? 1 : 0, ArrLog:WasSendTr}, function (Data) - { - if(!Data || !Data.result) - return ; + GetData("GetCurrentInfo", { Diagram: IsVisibleBlock("idStatBlock") ? 1 : 0, ArrLog: WasSendTr }, function(Data) { + if (!Data || !Data.result) + return; SetExplorerData(Data); SetBlockChainConstant(Data); var arr = Data.arr; - for(var i = 0; arr && i < arr.length; i++) - { + for (var i = 0; arr && i < arr.length; i++) { var ItemServer = arr[i]; var ItemClient = DiagramMap[ItemServer.name]; - if(!ItemClient || ItemClient.Extern) + if (!ItemClient || ItemClient.Extern) continue; ItemClient.arr = ItemServer.arr; ItemClient.AvgValue = ItemServer.AvgValue; @@ -519,14 +443,12 @@ function UpdatesExplorerData() }; var FirstCallDiagram = 1; -function SetExplorerData(Data) -{ - if(!Data || !Data.result) - return ; +function SetExplorerData(Data) { + if (!Data || !Data.result) + return; CONFIG_DATA = Data; window.FIRST_TIME_BLOCK = Data.FIRST_TIME_BLOCK; - if(FirstCallDiagram) - { + if (FirstCallDiagram) { ViewEnd(DefAccounts, CONFIG_DATA.MaxAccID, 1); ViewEnd(DefBlock, CONFIG_DATA.MaxNumBlockDB, 1); InitDiagram(); @@ -539,31 +461,25 @@ function SetExplorerData(Data) SetArrLog(Data.ArrLog); }; -function SetArrLog(arr) -{ - if(!arr) - return ; - for(var i = 0; i < arr.length; i++) - { +function SetArrLog(arr) { + if (!arr) + return; + for (var i = 0; i < arr.length; i++) { var Item = arr[i]; - if(!Item.final) + if (!Item.final) continue; var TR = MapSendTransaction[Item.key]; - if(TR && !TR.WasProcess && Item.final) - { + if (TR && !TR.WasProcess && Item.final) { TR.WasProcess = 1; SetStatus(Item.text); - if(Item.text.indexOf("Add to blockchain") >= 0) - { - if(TR.Run) - { + if (Item.text.indexOf("Add to blockchain") >= 0) { + if (TR.Run) { TR.Run(TR); TR.Run = undefined; } } var Account = MapCheckTransaction[Item.key]; - if(Account) - { + if (Account) { delete MapCheckTransaction[Item.key]; Account.NextSendTime = 0; } @@ -571,47 +487,43 @@ function SetArrLog(arr) } CheckSending(); }; -var DiagramArr = [{name:"MAX:ALL_NODES", text:"All nodes count", value:0, red:"#1d506b", MouseText:" nodes"}, {name:"MAX:HASH_RATE_B", - text:"HashRate, Tera hash/s", value:0, red:"#286b16", MathPow:2, MathDiv:1024 * 1024 * 1024 * 1024, KPrecision:10, NoTextMax:1, - MouseText:" T h/s"}, ]; +var DiagramArr = [{ name: "MAX:ALL_NODES", text: "All nodes count", value: 0, red: "#1d506b", MouseText: " nodes" }, { + name: "MAX:HASH_RATE_B", + text: "HashRate, Tera hash/s", value: 0, red: "#286b16", MathPow: 2, MathDiv: 1024 * 1024 * 1024 * 1024, KPrecision: 10, NoTextMax: 1, + MouseText: " T h/s" +},]; -function InitDiagram() -{ +function InitDiagram() { InitDiagramByArr(DiagramArr, 1120); }; -function ViewCounters(This) -{ +function ViewCounters(This) { var BlockName = "idStatBlock"; var element = $(BlockName); var bVisible = IsVisibleBlock(BlockName); - if(!bVisible) + if (!bVisible) MoveUp(element); SetVisibleBlock(BlockName, !bVisible); var ResVisible = IsVisibleBlock(BlockName); - if(This && This.className) - { + if (This && This.className) { This.className = This.className.replace("btpress", ""); - if(ResVisible) + if (ResVisible) This.className += " btpress"; } }; setInterval(CheckSending, 1000); -function OpenAddressBook() -{ - return ; +function OpenAddressBook() { + return; var bVisible = IsVisibleBlock("idAddressBook"); SetVisibleBlock("idAddressBook", !bVisible); }; -function CloaseAddressBook() -{ +function CloaseAddressBook() { OpenAddressBook(); }; -function ClearSend() -{ +function ClearSend() { $("idAccount").value = ""; $("idTo").value = ""; $("idSumSend").value = ""; @@ -619,10 +531,9 @@ function ClearSend() $("idNameTo2").innerText = ""; }; -function downloadKey(fieldID) -{ +function downloadKey(fieldID) { var text = document.getElementById(fieldID).value; - var blob = new Blob([text], {type:"text/plain"}); + var blob = new Blob([text], { type: "text/plain" }); var anchor = document.createElement("a"); anchor.download = "tera-key.txt"; anchor.href = window.URL.createObjectURL(blob); @@ -633,59 +544,48 @@ function downloadKey(fieldID) document.body.removeChild(anchor); }; -function openModal(id) -{ +function openModal(id) { var modal = document.querySelector("#" + id); var overlay = document.querySelector("#overlay"); modal.style.display = "block"; overlay.style.display = "block"; }; -function closeModal() -{ - if(NotModalClose) - return ; +function closeModal() { + if (NotModalClose) + return; var modals = document.querySelectorAll(".modal"); var overlay = document.querySelector("#overlay"); - modals.forEach(function (item) - { + modals.forEach(function(item) { item.style.display = "none"; }); overlay.style.display = "none"; }; -function showMenu(Num) -{ +function showMenu(Num) { var menu = document.querySelector("#idBt" + Num); - if(menu.style.display === "none") - { + if (menu.style.display === "none") { menu.style.display = "block"; } - else - { + else { menu.style.display = "none"; } }; -function closeMenu(Num) -{ +function closeMenu(Num) { var menu = document.querySelector("#idBt" + Num); - setTimeout(function () - { + setTimeout(function() { menu.style.display = "none"; }, 115); }; -function UploadKey(id) -{ +function UploadKey(id) { var file = $(id).files[0]; var reader = new FileReader(); - reader.onload = function () - { - if(reader.result.byteLength !== 64) + reader.onload = function() { + if (reader.result.byteLength !== 64) SetError("Error file length (" + reader.result.byteLength + ")"); - else - { + else { var view = new Uint8Array(reader.result); var Key = Utf8ArrayToStr(view); SetStatus("OK"); @@ -698,33 +598,29 @@ function UploadKey(id) reader.readAsArrayBuffer(file); }; -function InitPrivKey() -{ +function InitPrivKey() { $("idPrivKeyEdit").value = GetPrivKey(); SetPubKeyHTML(); SetVisiblePrivKey(); $("idSave2").disabled = !IsPrivateMode(); }; -function SendMobileBefore() -{ - if($("idSendButton").disabled) - return ; +function SendMobileBefore() { + if ($("idSendButton").disabled) + return; var FromID = ParseNum($("idAccount").value); var Item = MapAccounts[FromID]; - if(!Item) - { + if (!Item) { SetError("Error FROM ID"); - return ; + return; } $("idConfirmFromID").innerText = Item.Num; $("idConfirmFromName").innerText = Item.Name + " (" + STRING_FROM_COIN(Item.Value) + " " + CurrencyNameItem(Item) + ")"; var ToID = ParseNum($("idTo").value); var Item2 = MapAccounts[ToID]; - if(!Item2) - { + if (!Item2) { SetError("Error TO ID"); - return ; + return; } $("idConfirmToID").innerText = Item2.Num; $("idConfirmToName").innerText = Item2.Name + " (" + STRING_FROM_COIN(Item2.Value) + " " + CurrencyNameItem(Item2) + ")"; @@ -737,27 +633,23 @@ function SendMobileBefore() SetStatus(""); }; -function OKSend() -{ +function OKSend() { SendMoney(); $("idSumSend").value = 0; CancelSend(); }; -function CancelSend() -{ +function CancelSend() { SetVisibleClass(".send-page__setting", 1); SetVisibleClass(".send-page__confirm", 0); }; -function SetNewPassword() -{ +function SetNewPassword() { var Str1 = $("Password1").value.trim(); var Str2 = $("Password2").value.trim(); - if(Str1 !== Str2) - { + if (Str1 !== Str2) { SetError("Wrong passwords"); - return ; + return; } var Key = GetPrivKey(); SetWalletPassword(Str1); @@ -766,7 +658,7 @@ function SetNewPassword() closeModal(); $("Password1").value = ""; $("Password2").value = ""; - if(Str1) + if (Str1) SetStatus("Password changed successfully"); else SetStatus("Password has been reset successfully"); @@ -774,53 +666,45 @@ function SetNewPassword() }; var MultipleMode = 0; -function MyOpenWallet(bCheck) -{ +function MyOpenWallet(bCheck) { var Str = $("Password").value.trim(); - if(!Str) - { + if (!Str) { SetError("Type password, pls"); - return ; + return; } $("Password").value = ""; - if(Str.substr(0, 11) === "--subwallet") - { + if (Str.substr(0, 11) === "--subwallet") { Str = Str.substr(11); - if(Str === " off") - { + if (Str === " off") { Storage.setItem("USESUBWALLET", 0); SetStatus("Set off subwallet mode"); } - else - { + else { Storage.setItem("USESUBWALLET", 1); SetStatus("Set subwallet mode"); } SetUsePassword(1); - return ; + return; } - if(Str === "--reset") - { + if (Str === "--reset") { SetWalletPassword(""); OpenWalletKey(); SetUsePassword(0); NotModalClose = 0; closeModal(); - return ; + return; } SetWalletPassword(Str); OpenWalletKey(); SetStatus(""); - if(bCheck) - { + if (bCheck) { var WasPubKey = Storage.getItem("WALLET_PUB_KEY_MAIN"); var PrivKey = GetArrFromHex(GetPrivKey()); var TestPubKey = GetHexFromArr(SignLib.publicKeyCreate(PrivKey, 1)); - if(WasPubKey !== TestPubKey) - { + if (WasPubKey !== TestPubKey) { SetWalletPassword(""); SetError("Wrong password"); - return ; + return; } SetStatus("Password ok"); MultipleMode = 0; @@ -828,8 +712,7 @@ function MyOpenWallet(bCheck) SetVisibleBlock("idLoad2", 1); SetVisibleBlock("idPasswordEdit", 1); } - else - { + else { MultipleMode = 1; SetVisibleBlock("idKeyEdit", 0); SetVisibleBlock("idLoad2", 0); @@ -842,15 +725,13 @@ function MyOpenWallet(bCheck) SetUsePassword(1); }; -function SetUsePassword(bUse) -{ +function SetUsePassword(bUse) { document.documentElement.style.setProperty('--fill--password', bUse ? 'blue' : 'black'); SetVisibleBlock("idWalletExit", !!bUse); SetVisibleBlock("idEntrance", Storage.getItem("USESUBWALLET") === "1"); }; -function DoExitWallet() -{ +function DoExitWallet() { ClearSend(); NotModalClose = 1; $("Password").value = ""; @@ -862,63 +743,53 @@ var StrDappCardTemplate; var StrDappRowCardTemplate; var CardMapList = {}; -function InitDappsCard() -{ - if($("DappRowCardTemplate")) - { +function InitDappsCard() { + if ($("DappRowCardTemplate")) { StrDappRowCardTemplate = $("DappRowCardTemplate").outerHTML; $("DappRowCardTemplate").outerHTML = ""; } - if($("DappCardTemplate")) - { + if ($("DappCardTemplate")) { StrDappCardTemplate = $("DappCardTemplate").outerHTML; } }; -function ViewDapps() -{ +function ViewDapps() { ViewCurrent(DefDapps); - GetData("/GetDappCategory", {}, function (Data) - { - if(Data && Data.result && Data.arr) - { + GetData("/GetDappCategory", {}, function(Data) { + if (Data && Data.result && Data.arr) { var arr = Data.arr; - for(var i = 0; i < arr.length; i++) - { + for (var i = 0; i < arr.length; i++) { var key = arr[i]; - arr[i] = {sort:MapCategory[key].toUpperCase(), text:MapCategory[key], value:key}; + arr[i] = { sort: MapCategory[key].toUpperCase(), text: MapCategory[key], value: key }; } - arr.push({sort:"-", text:"Choose the category", value:0}); + arr.push({ sort: "-", text: "Choose the category", value: 0 }); FillCategoryAndSort("idCategory", arr); } }); }; -function FillDappCard(Str,Item) -{ +function FillDappCard(Str, Item) { CardMapList[Item.Num] = Item; Str = Str.replace(/{Item.Num}/g, Item.Num); Str = Str.replace("{Item.Name}", escapeHtml(Item.Name)); Str = Str.replace("{Item.Description}", escapeHtml(Item.Description)); Str = Str.replace("{Item.Owner}", Item.Owner); - if(!Item.TokenGenerate) + if (!Item.TokenGenerate) Str = Str.replace("dapp-modal__ok-token", "myhidden"); Str = Str.replace("{Item.IconPath}", RetIconPath(Item, 0)); return Str; }; -function RetDappCard(Item) -{ +function RetDappCard(Item) { var Str = FillDappCard(StrDappRowCardTemplate, Item); Str = Str.replace("DappRowCardTemplate", "idCard" + Item.Num); return Str; }; -function OpenDappCard(Num) -{ +function OpenDappCard(Num) { var Item = CardMapList[Num]; - if(!Item) - return ; + if (!Item) + return; var Str = FillDappCard(StrDappCardTemplate, Item); Str = Str.replace("{Item.Account}", RetBaseAccount(Item)); Str = Str.replace("{Item.BlockNum}", RetOpenBlock(Item.BlockNum, 2)); @@ -929,47 +800,38 @@ function OpenDappCard(Num) openModal('DappCardTemplate'); }; -function OpenDapp(Num) -{ +function OpenDapp(Num) { OpenDapps(Num); closeModal(); }; -function FillDappCategory(Str,Item,Num) -{ +function FillDappCategory(Str, Item, Num) { var Value = Item["Category" + Num]; - if(Value && MapCategory[Value]) - { + if (Value && MapCategory[Value]) { Str = Str.replace("{Item.Category" + Num + "}", MapCategory[Value]); } - else - { + else { Str = Str.replace("dappcategory" + Num, "myhidden"); } return Str; }; -function MyToggleList(e) -{ +function MyToggleList(e) { var item = e.target; - while(true) - { - if(!item) + while (true) { + if (!item) break; - if(!item.classList) + if (!item.classList) break; - if(item.onclick && item.onclick !== MyToggleList) + if (item.onclick && item.onclick !== MyToggleList) break; - if(item.classList.contains("find--switch")) - { - if(item.classList.contains("prod-card--switch")) - { + if (item.classList.contains("find--switch")) { + if (item.classList.contains("prod-card--switch")) { item.classList.add("prod-card--active"); item.classList.add("prod-card--toggle"); item.classList.remove("prod-card--switch"); } - else - { + else { item.classList.remove("prod-card--active"); item.classList.remove("prod-card--toggle"); item.classList.add("prod-card--switch"); @@ -981,71 +843,59 @@ function MyToggleList(e) }; var LangItems = []; -function InitLangItems() -{ +function InitLangItems() { var tags = ["TITLE", "BUTTON", "DIV", "INPUT", "TH", "TD", "SPAN", "A", "H1", "H2", "H3", "H4", "H5", "P", "DT"]; var Map2 = {}; - for(var n = 0; n < tags.length; n++) - { + for (var n = 0; n < tags.length; n++) { var tagname = tags[n]; var elems = document.getElementsByTagName(tagname); - for(var elem, i = 0; elem = elems[i++]; ) - { + for (var elem, i = 0; elem = elems[i++];) { var Text = elem.innerText; - if(elem.innerHTML !== Text) + if (elem.innerHTML !== Text) continue; - if(!Text) + if (!Text) continue; - if(Text.substr(0, 1) === "{") + if (Text.substr(0, 1) === "{") continue; - if(Text.toUpperCase() == Text.toLowerCase()) + if (Text.toUpperCase() == Text.toLowerCase()) continue; - LangItems.push({key:Text, elem:elem}); + LangItems.push({ key: Text, elem: elem }); } } }; -function DoLangItems(Map) -{ +function DoLangItems(Map) { var Map2 = {}; - for(var n = 0; n < LangItems.length; n++) - { + for (var n = 0; n < LangItems.length; n++) { var key = LangItems[n].key; var elem = LangItems[n].elem; - if(Map) - { + if (Map) { var TextNew = Map[key]; - if(TextNew === undefined) - { + if (TextNew === undefined) { ToLog("Not found translate for key: " + key); Map[key] = key; TextNew = key; } - if(elem.innerText !== TextNew) - { + if (elem.innerText !== TextNew) { elem.innerText = TextNew; } } - else - { + else { Map2[key] = key; } } return Map2; }; -function DoLangScript() -{ +function DoLangScript() { InitLangItems(); LangMap["ENG"] = DoLangItems(); FillSelect("idLang", LangMap, "KEY"); }; -function ChangeLang() -{ +function ChangeLang() { var key = $("idLang").value; - if(!key) - { + if (!key) { key = "ENG"; $("idLang").value = key; } @@ -1053,47 +903,50 @@ function ChangeLang() SaveValues(); }; -function GetNewLangItem() -{ +function GetNewLangItem() { ToLog(JSON.stringify(LangMap["ENG"])); }; var LangMap = {}; LangMap["ENG"] = {}; -LangMap["RUS"] = {"TERA WALLET":"TERA КОШЕЛЕК", "Generate key":"Сгенерировать ключ", "OK":"OK", "Cancel":"Отмена", "Edit":"Редактирование", - "Save key":"Сохран.", "+ CREATE A NEW ACCOUNT":"+ СОЗДАТЬ НОВЫЙ СЧЕТ", "Create account":"Создать счет", "Send":"Отправить", - "CONFIRM":"Подтверждение", "Accounts":"Счета", "Account(s)":"Счет(а,ов)", "Blocks and Tx":"Блоки и Транзакции", "Counters":"Показатели", - "Open DApp":"Открыть Дапп", "Back":"Назад", "Delete":"Удалить", "Save to book":"Сохранить в книгу", "Choose":"Выбрать", "RECONNECT":"КОННЕКТ", - "DApps":"ДАппс", "ID":"ИД", "Amount":"Величина", "Cur":"Вал", "Name":"Имя", "PubKey":"Пуб.ключ", "Operation":"Операция", "Smart":"Смарт", - "Block Num":"Ном блока", "Num":"Ном", "Date":"Дата", "Data Hash":"Хеш данных", "PowHash":"Хеш сложности", "Block Hash":"Хеш блока", - "Bytes":"Байт", "Pow":"Сложн", "Miner":"Майнер", "(secret)":"(секрет)", "Show":"Показать", "TERA":"TERA", "Blockchain height:":"Высота блокчейна:", - "Current create:":"Текущий блок:", "Protocol ver:":"Версия протокола:", "ID: {Item.Num}":"ИД: {Item.Num}", "Token generate":"Генерация токенов", - "ACCOUNTS":"СЧЕТА", "SEND":"ПОСЛАТЬ", "DAPPS":"ДАППС", "EXPLORER":"ПРОСМ", "ATTENTION: Before using the wallet, save the private key.":"ВНИМАНИЕ: Перед использованием кошелька сохраните приватный ключ", - "Web-site":"Веб-сайт", "Bitcointalk":"Bitcointalk", "Twitter":"Твиттер", "Telegram":"Телеграм", "Discord":"Дискорд", "QQchat":"QQchat", - "Buy/sell/mine TERA":"Купить/Продать", "+ CREATE NEW":"+ СОЗДАТЬ НОВЫЙ", "Confirm Transaction":"Подтверждение транзакции", - "CREATE DAPPS":"СОЗДАТЬ", "Set pass":"Установить пароль", "Unlock":"Разблокировать", "Entrance to sub-wallet":"Войти в под-кошелек", - "Public name":"Публичное имя", "Currency":"Валюта", "Pay to:":"Получатель:", "Amount:":"Сумма:", "Description:":"Описание:", - "Welcome to TERA Wallet":"Добропожаловать в кошелек TERA", "Edit your wallet":"Редактирование вашего кошелька", "Key settings":"Задание ключей", - "KEY SETTINGS":"ЗАДАНИЕ КЛЮЧЕЙ", "Create an account":"Создание счета", "Sending coins":"Отправка монет", "Decentralized applications (dApps)":"Децентрализованные приложения (Даппс)", - "Secure your wallet":"Безопасность вашего кошелька", "Wallet is secured":"Установлен пароль", "Total":"Всего", "Item.Name":"Item.Name", - "You have no accounts yet":"У вас нет ни одного счета", "Wait 10-15 sec":"Ждите 10-15 сек", "Creating your account":"Идет создание вашего счета", - "From:":"Отправитель:", "Set a password for protect entry":"Установите пароль для безопасности", "Enter password to unlock wallet":"Введите пароль для разблокировки кошелька", - "From ID:":"Отправитель:", "Pay to ID:":"Получатель:", "Account":"Счет", "Owner":"Владелец", "Block num":"Ном блока", "Private key (secret)":"Приватный ключ (секретно)", - "Load key":"Загруз.", "Create your first account and start using TERA":"Создайте свой первый счет и начните использовать TERA", - "0 Accounts":"0 Счетов", "OWNER: {Item.Owner}":"Владелец: {Item.Owner}", "More info":"Информация", "Public key":"Публичный ключ"}; -LangMap["简体中文"] = {"TERA WALLET":"TERA 钱包", "Generate key":"生成私钥", "OK":"OK", "Cancel":"取消", "Edit":"编辑", "Save key":"保存私钥", - "+ CREATE A NEW ACCOUNT":"+ 新建账号", "Create account":"创建账号", "Send":"发送", "SEND":"转账", "CONFIRM":"确认", "Accounts":"账号", "Account(s)":"账号", - "Blocks and Tx":"区块和交易", "Counters":"状态统计", "Open DApp":"打开DApp", "Back":"返回", "Delete":"删除", "Save to book":"保存到地址本", "Choose":"选择", - "RECONNECT":"重连", "DApps":"DApps", "ID":"ID", "Amount":"余额", "Cur":"币种", "Name":"名称", "PubKey":"公钥", "Operation":"操作次数", "Smart":"DApp", - "Block Num":"区块编号", "Num":"编号", "Date":"日期", "Data Hash":"数据哈希", "PowHash":"Pow哈希", "Block Hash":"区块哈希", "Bytes":"字节", "Pow":"Pow", - "Miner":"矿工", "(secret)":"(机密)", "Show":"显示", "TERA":"TERA", "Blockchain height:":"区块高度:", "Current create:":"最近区块:", "Protocol ver:":"协议版本:", - "ID: {Item.Num}":"ID: {Item.Num}", "Token generate":"生成代币", "ACCOUNTS":"账号", "DAPPS":"DAPPS", "EXPLORER":"浏览器", "ATTENTION: Before using the wallet, save the private key.":"注意: 使用钱包前,务必保存好私钥。", - "Web-site":"官网", "Bitcointalk":"创世贴", "Twitter":"推特", "Telegram":"电报", "Discord":"Discord", "QQchat":"QQ群", "Buy/sell/mine TERA":"TERA 交易/挖矿", - "+ CREATE NEW":"+ 新建", "Confirm Transaction":"确认交易", "CREATE DAPPS":"创建DAPPS", "Set pass":"设置密码", "Unlock":"解锁", "Entrance to sub-wallet":"进入子钱包", - "Public name":"名称", "Currency":"币种", "Pay to:":"收款:", "Amount:":"金额:", "Description:":"描述:", "Welcome to TERA Wallet":"欢迎使用TERA钱包", - "Edit your wallet":"编辑钱包", "Key settings":"设置私钥", "KEY SETTINGS":"设置私钥", "Create an account":"创建账号", "Sending coins":"转账", - "Decentralized applications (dApps)":"去中心化应用 (DApps)", "Secure your wallet":"设置钱包密码", "Wallet is secured":"钱包密码已设置", "Total":"总计", - "Item.Name":"Item.Name", "You have no accounts yet":"你还没有账号", "Wait 10-15 sec":"等待10-15秒", "Creating your account":"创建你的账号", - "From:":"付款:", "Set a password for protect entry":"设置密码保护钱包", "Enter password to unlock wallet":"输入密码解锁钱包", "From ID:":"付款ID:", - "Pay to ID:":"收款ID:", "Account":"账号", "Owner":"拥有者", "Block num":"区块编号", "Private key (secret)":"私钥 (机密)", "Load key":"载入私钥", - "Create your first account and start using TERA":"创建你的第一个账号,开启TERA之旅", "0 Accounts":"0 账号", "OWNER: {Item.Owner}":"拥有者: {Item.Owner}", - "More info":"详情", "Public key":"公钥"}; +LangMap["RUS"] = { + "TERA WALLET": "TERA КОШЕЛЕК", "Generate key": "Сгенерировать ключ", "OK": "OK", "Cancel": "Отмена", "Edit": "Редактирование", + "Save key": "Сохран.", "+ CREATE A NEW ACCOUNT": "+ СОЗДАТЬ НОВЫЙ СЧЕТ", "Create account": "Создать счет", "Send": "Отправить", + "CONFIRM": "Подтверждение", "Accounts": "Счета", "Account(s)": "Счет(а,ов)", "Blocks and Tx": "Блоки и Транзакции", "Counters": "Показатели", + "Open DApp": "Открыть Дапп", "Back": "Назад", "Delete": "Удалить", "Save to book": "Сохранить в книгу", "Choose": "Выбрать", "RECONNECT": "КОННЕКТ", + "DApps": "ДАппс", "ID": "ИД", "Amount": "Величина", "Cur": "Вал", "Name": "Имя", "PubKey": "Пуб.ключ", "Operation": "Операция", "Smart": "Смарт", + "Block Num": "Ном блока", "Num": "Ном", "Date": "Дата", "Data Hash": "Хеш данных", "PowHash": "Хеш сложности", "Block Hash": "Хеш блока", + "Bytes": "Байт", "Pow": "Сложн", "Miner": "Майнер", "(secret)": "(секрет)", "Show": "Показать", "TERA": "TERA", "Blockchain height:": "Высота блокчейна:", + "Current create:": "Текущий блок:", "Protocol ver:": "Версия протокола:", "ID: {Item.Num}": "ИД: {Item.Num}", "Token generate": "Генерация токенов", + "ACCOUNTS": "СЧЕТА", "SEND": "ПОСЛАТЬ", "DAPPS": "ДАППС", "EXPLORER": "ПРОСМ", "ATTENTION: Before using the wallet, save the private key.": "ВНИМАНИЕ: Перед использованием кошелька сохраните приватный ключ", + "Web-site": "Веб-сайт", "Bitcointalk": "Bitcointalk", "Twitter": "Твиттер", "Telegram": "Телеграм", "Discord": "Дискорд", "QQchat": "QQchat", + "Buy/sell/mine TERA": "Купить/Продать", "+ CREATE NEW": "+ СОЗДАТЬ НОВЫЙ", "Confirm Transaction": "Подтверждение транзакции", + "CREATE DAPPS": "СОЗДАТЬ", "Set pass": "Установить пароль", "Unlock": "Разблокировать", "Entrance to sub-wallet": "Войти в под-кошелек", + "Public name": "Публичное имя", "Currency": "Валюта", "Pay to:": "Получатель:", "Amount:": "Сумма:", "Description:": "Описание:", + "Welcome to TERA Wallet": "Добропожаловать в кошелек TERA", "Edit your wallet": "Редактирование вашего кошелька", "Key settings": "Задание ключей", + "KEY SETTINGS": "ЗАДАНИЕ КЛЮЧЕЙ", "Create an account": "Создание счета", "Sending coins": "Отправка монет", "Decentralized applications (dApps)": "Децентрализованные приложения (Даппс)", + "Secure your wallet": "Безопасность вашего кошелька", "Wallet is secured": "Установлен пароль", "Total": "Всего", "Item.Name": "Item.Name", + "You have no accounts yet": "У вас нет ни одного счета", "Wait 10-15 sec": "Ждите 10-15 сек", "Creating your account": "Идет создание вашего счета", + "From:": "Отправитель:", "Set a password for protect entry": "Установите пароль для безопасности", "Enter password to unlock wallet": "Введите пароль для разблокировки кошелька", + "From ID:": "Отправитель:", "Pay to ID:": "Получатель:", "Account": "Счет", "Owner": "Владелец", "Block num": "Ном блока", "Private key (secret)": "Приватный ключ (секретно)", + "Load key": "Загруз.", "Create your first account and start using TERA": "Создайте свой первый счет и начните использовать TERA", + "0 Accounts": "0 Счетов", "OWNER: {Item.Owner}": "Владелец: {Item.Owner}", "More info": "Информация", "Public key": "Публичный ключ" +}; +LangMap["简体中文"] = { + "TERA WALLET": "TERA 钱包", "Generate key": "生成私钥", "OK": "OK", "Cancel": "取消", "Edit": "编辑", "Save key": "保存私钥", + "+ CREATE A NEW ACCOUNT": "+ 新建账号", "Create account": "创建账号", "Send": "发送", "SEND": "转账", "CONFIRM": "确认", "Accounts": "账号", "Account(s)": "账号", + "Blocks and Tx": "区块和交易", "Counters": "状态统计", "Open DApp": "打开DApp", "Back": "返回", "Delete": "删除", "Save to book": "保存到地址本", "Choose": "选择", + "RECONNECT": "重连", "DApps": "DApps", "ID": "ID", "Amount": "余额", "Cur": "币种", "Name": "名称", "PubKey": "公钥", "Operation": "操作次数", "Smart": "DApp", + "Block Num": "区块编号", "Num": "编号", "Date": "日期", "Data Hash": "数据哈希", "PowHash": "Pow哈希", "Block Hash": "区块哈希", "Bytes": "字节", "Pow": "Pow", + "Miner": "矿工", "(secret)": "(机密)", "Show": "显示", "TERA": "TERA", "Blockchain height:": "区块高度:", "Current create:": "最近区块:", "Protocol ver:": "协议版本:", + "ID: {Item.Num}": "ID: {Item.Num}", "Token generate": "生成代币", "ACCOUNTS": "账号", "DAPPS": "DAPPS", "EXPLORER": "浏览器", "ATTENTION: Before using the wallet, save the private key.": "注意: 使用钱包前,务必保存好私钥。", + "Web-site": "官网", "Bitcointalk": "创世贴", "Twitter": "推特", "Telegram": "电报", "Discord": "Discord", "QQchat": "QQ群", "Buy/sell/mine TERA": "TERA 交易/挖矿", + "+ CREATE NEW": "+ 新建", "Confirm Transaction": "确认交易", "CREATE DAPPS": "创建DAPPS", "Set pass": "设置密码", "Unlock": "解锁", "Entrance to sub-wallet": "进入子钱包", + "Public name": "名称", "Currency": "币种", "Pay to:": "收款:", "Amount:": "金额:", "Description:": "描述:", "Welcome to TERA Wallet": "欢迎使用TERA钱包", + "Edit your wallet": "编辑钱包", "Key settings": "设置私钥", "KEY SETTINGS": "设置私钥", "Create an account": "创建账号", "Sending coins": "转账", + "Decentralized applications (dApps)": "去中心化应用 (DApps)", "Secure your wallet": "设置钱包密码", "Wallet is secured": "钱包密码已设置", "Total": "总计", + "Item.Name": "Item.Name", "You have no accounts yet": "你还没有账号", "Wait 10-15 sec": "等待10-15秒", "Creating your account": "创建你的账号", + "From:": "付款:", "Set a password for protect entry": "设置密码保护钱包", "Enter password to unlock wallet": "输入密码解锁钱包", "From ID:": "付款ID:", + "Pay to ID:": "收款ID:", "Account": "账号", "Owner": "拥有者", "Block num": "区块编号", "Private key (secret)": "私钥 (机密)", "Load key": "载入私钥", + "Create your first account and start using TERA": "创建你的第一个账号,开启TERA之旅", "0 Accounts": "0 账号", "OWNER: {Item.Owner}": "拥有者: {Item.Owner}", + "More info": "详情", "Public key": "公钥" +}; diff --git a/src/HTML/JS/sec256k1.js b/src/HTML/JS/sec256k1.js index 4053c2d..0a05101 100644 --- a/src/HTML/JS/sec256k1.js +++ b/src/HTML/JS/sec256k1.js @@ -11,180 +11,150 @@ "use strict"; var der = require("./der"), toString = Object.prototype.toString, exports = {}, assert = exports; -exports.isArray = function (e,s) -{ - if(!Array.isArray(e)) +exports.isArray = function(e, s) { + if (!Array.isArray(e)) throw TypeError(s); -}, exports.isBoolean = function (e,s) -{ - if("[object Boolean]" !== toString.call(e)) +}, exports.isBoolean = function(e, s) { + if ("[object Boolean]" !== toString.call(e)) throw TypeError(s); -}, exports.isBuffer = function (e,s) -{ - if(!Buffer.isBuffer(e)) +}, exports.isBuffer = function(e, s) { + if (!Buffer.isBuffer(e)) throw TypeError(s); -}, exports.isFunction = function (e,s) -{ - if("[object Function]" !== toString.call(e)) +}, exports.isFunction = function(e, s) { + if ("[object Function]" !== toString.call(e)) throw TypeError(s); -}, exports.isNumber = function (e,s) -{ - if("[object Number]" !== toString.call(e)) +}, exports.isNumber = function(e, s) { + if ("[object Number]" !== toString.call(e)) throw TypeError(s); -}, exports.isObject = function (e,s) -{ - if("[object Object]" !== toString.call(e)) +}, exports.isObject = function(e, s) { + if ("[object Object]" !== toString.call(e)) throw TypeError(s); -}, exports.isBufferLength = function (e,s,r) -{ - if(e.length !== s) +}, exports.isBufferLength = function(e, s, r) { + if (e.length !== s) throw RangeError(r); -}, exports.isBufferLength2 = function (e,s,r,_) -{ - if(e.length !== s && e.length !== r) +}, exports.isBufferLength2 = function(e, s, r, _) { + if (e.length !== s && e.length !== r) throw RangeError(_); -}, exports.isLengthGTZero = function (e,s) -{ - if(0 === e.length) +}, exports.isLengthGTZero = function(e, s) { + if (0 === e.length) throw RangeError(s); -}, exports.isNumberInInterval = function (e,s,r,_) -{ - if(e <= s || r <= e) +}, exports.isNumberInInterval = function(e, s, r, _) { + if (e <= s || r <= e) throw RangeError(_); }; -var messages = {COMPRESSED_TYPE_INVALID:"compressed should be a boolean", EC_PRIVATE_KEY_TYPE_INVALID:"private key should be a Buffer", - EC_PRIVATE_KEY_LENGTH_INVALID:"private key length is invalid", EC_PRIVATE_KEY_RANGE_INVALID:"private key range is invalid", - EC_PRIVATE_KEY_TWEAK_ADD_FAIL:"tweak out of range or resulting private key is invalid", EC_PRIVATE_KEY_TWEAK_MUL_FAIL:"tweak out of range", - EC_PRIVATE_KEY_EXPORT_DER_FAIL:"couldn't export to DER format", EC_PRIVATE_KEY_IMPORT_DER_FAIL:"couldn't import from DER format", - EC_PUBLIC_KEYS_TYPE_INVALID:"public keys should be an Array", EC_PUBLIC_KEYS_LENGTH_INVALID:"public keys Array should have at least 1 element", - EC_PUBLIC_KEY_TYPE_INVALID:"public key should be a Buffer", EC_PUBLIC_KEY_LENGTH_INVALID:"public key length is invalid", EC_PUBLIC_KEY_PARSE_FAIL:"the public key could not be parsed or is invalid", - EC_PUBLIC_KEY_CREATE_FAIL:"private was invalid, try again", EC_PUBLIC_KEY_TWEAK_ADD_FAIL:"tweak out of range or resulting public key is invalid", - EC_PUBLIC_KEY_TWEAK_MUL_FAIL:"tweak out of range", EC_PUBLIC_KEY_COMBINE_FAIL:"the sum of the public keys is not valid", ECDH_FAIL:"scalar was invalid (zero or overflow)", - ECDSA_SIGNATURE_TYPE_INVALID:"signature should be a Buffer", ECDSA_SIGNATURE_LENGTH_INVALID:"signature length is invalid", - ECDSA_SIGNATURE_PARSE_FAIL:"couldn't parse signature", ECDSA_SIGNATURE_PARSE_DER_FAIL:"couldn't parse DER signature", ECDSA_SIGNATURE_SERIALIZE_DER_FAIL:"couldn't serialize signature to DER format", - ECDSA_SIGN_FAIL:"nonce generation function failed or private key is invalid", ECDSA_RECOVER_FAIL:"couldn't recover public key from signature", - MSG32_TYPE_INVALID:"message should be a Buffer", MSG32_LENGTH_INVALID:"message length is invalid", OPTIONS_TYPE_INVALID:"options should be an Object", - OPTIONS_DATA_TYPE_INVALID:"options.data should be a Buffer", OPTIONS_DATA_LENGTH_INVALID:"options.data length is invalid", - OPTIONS_NONCEFN_TYPE_INVALID:"options.noncefn should be a Function", RECOVERY_ID_TYPE_INVALID:"recovery should be a Number", - RECOVERY_ID_VALUE_INVALID:"recovery should have value between -1 and 4", TWEAK_TYPE_INVALID:"tweak should be a Buffer", TWEAK_LENGTH_INVALID:"tweak length is invalid"}; +var messages = { + COMPRESSED_TYPE_INVALID: "compressed should be a boolean", EC_PRIVATE_KEY_TYPE_INVALID: "private key should be a Buffer", + EC_PRIVATE_KEY_LENGTH_INVALID: "private key length is invalid", EC_PRIVATE_KEY_RANGE_INVALID: "private key range is invalid", + EC_PRIVATE_KEY_TWEAK_ADD_FAIL: "tweak out of range or resulting private key is invalid", EC_PRIVATE_KEY_TWEAK_MUL_FAIL: "tweak out of range", + EC_PRIVATE_KEY_EXPORT_DER_FAIL: "couldn't export to DER format", EC_PRIVATE_KEY_IMPORT_DER_FAIL: "couldn't import from DER format", + EC_PUBLIC_KEYS_TYPE_INVALID: "public keys should be an Array", EC_PUBLIC_KEYS_LENGTH_INVALID: "public keys Array should have at least 1 element", + EC_PUBLIC_KEY_TYPE_INVALID: "public key should be a Buffer", EC_PUBLIC_KEY_LENGTH_INVALID: "public key length is invalid", EC_PUBLIC_KEY_PARSE_FAIL: "the public key could not be parsed or is invalid", + EC_PUBLIC_KEY_CREATE_FAIL: "private was invalid, try again", EC_PUBLIC_KEY_TWEAK_ADD_FAIL: "tweak out of range or resulting public key is invalid", + EC_PUBLIC_KEY_TWEAK_MUL_FAIL: "tweak out of range", EC_PUBLIC_KEY_COMBINE_FAIL: "the sum of the public keys is not valid", ECDH_FAIL: "scalar was invalid (zero or overflow)", + ECDSA_SIGNATURE_TYPE_INVALID: "signature should be a Buffer", ECDSA_SIGNATURE_LENGTH_INVALID: "signature length is invalid", + ECDSA_SIGNATURE_PARSE_FAIL: "couldn't parse signature", ECDSA_SIGNATURE_PARSE_DER_FAIL: "couldn't parse DER signature", ECDSA_SIGNATURE_SERIALIZE_DER_FAIL: "couldn't serialize signature to DER format", + ECDSA_SIGN_FAIL: "nonce generation function failed or private key is invalid", ECDSA_RECOVER_FAIL: "couldn't recover public key from signature", + MSG32_TYPE_INVALID: "message should be a Buffer", MSG32_LENGTH_INVALID: "message length is invalid", OPTIONS_TYPE_INVALID: "options should be an Object", + OPTIONS_DATA_TYPE_INVALID: "options.data should be a Buffer", OPTIONS_DATA_LENGTH_INVALID: "options.data length is invalid", + OPTIONS_NONCEFN_TYPE_INVALID: "options.noncefn should be a Function", RECOVERY_ID_TYPE_INVALID: "recovery should be a Number", + RECOVERY_ID_VALUE_INVALID: "recovery should have value between -1 and 4", TWEAK_TYPE_INVALID: "tweak should be a Buffer", TWEAK_LENGTH_INVALID: "tweak length is invalid" +}; -function initCompressedValue(e,s) -{ +function initCompressedValue(e, s) { return void 0 === e ? s : (assert.isBoolean(e, messages.COMPRESSED_TYPE_INVALID), e); }; -module.exports = function (E) -{ - return {privateKeyVerify:function (e) - { +module.exports = function(E) { + return { + privateKeyVerify: function(e) { return assert.isBuffer(e, messages.EC_PRIVATE_KEY_TYPE_INVALID), 32 === e.length && E.privateKeyVerify(e); - }, privateKeyExport:function (e,s) - { + }, privateKeyExport: function(e, s) { assert.isBuffer(e, messages.EC_PRIVATE_KEY_TYPE_INVALID), assert.isBufferLength(e, 32, messages.EC_PRIVATE_KEY_LENGTH_INVALID), - s = initCompressedValue(s, !0); + s = initCompressedValue(s, !0); var r = E.privateKeyExport(e, s); return der.privateKeyExport(e, r, s); - }, privateKeyImport:function (e) - { - if(assert.isBuffer(e, messages.EC_PRIVATE_KEY_TYPE_INVALID), (e = der.privateKeyImport(e)) && 32 === e.length && E.privateKeyVerify(e)) + }, privateKeyImport: function(e) { + if (assert.isBuffer(e, messages.EC_PRIVATE_KEY_TYPE_INVALID), (e = der.privateKeyImport(e)) && 32 === e.length && E.privateKeyVerify(e)) return e; throw new Error(messages.EC_PRIVATE_KEY_IMPORT_DER_FAIL); - }, privateKeyNegate:function (e) - { + }, privateKeyNegate: function(e) { return assert.isBuffer(e, messages.EC_PRIVATE_KEY_TYPE_INVALID), assert.isBufferLength(e, 32, messages.EC_PRIVATE_KEY_LENGTH_INVALID), - E.privateKeyNegate(e); - }, privateKeyModInverse:function (e) - { + E.privateKeyNegate(e); + }, privateKeyModInverse: function(e) { return assert.isBuffer(e, messages.EC_PRIVATE_KEY_TYPE_INVALID), assert.isBufferLength(e, 32, messages.EC_PRIVATE_KEY_LENGTH_INVALID), - E.privateKeyModInverse(e); - }, privateKeyTweakAdd:function (e,s) - { + E.privateKeyModInverse(e); + }, privateKeyTweakAdd: function(e, s) { return assert.isBuffer(e, messages.EC_PRIVATE_KEY_TYPE_INVALID), assert.isBufferLength(e, 32, messages.EC_PRIVATE_KEY_LENGTH_INVALID), - assert.isBuffer(s, messages.TWEAK_TYPE_INVALID), assert.isBufferLength(s, 32, messages.TWEAK_LENGTH_INVALID), E.privateKeyTweakAdd(e, - s); - }, privateKeyTweakMul:function (e,s) - { + assert.isBuffer(s, messages.TWEAK_TYPE_INVALID), assert.isBufferLength(s, 32, messages.TWEAK_LENGTH_INVALID), E.privateKeyTweakAdd(e, + s); + }, privateKeyTweakMul: function(e, s) { return assert.isBuffer(e, messages.EC_PRIVATE_KEY_TYPE_INVALID), assert.isBufferLength(e, 32, messages.EC_PRIVATE_KEY_LENGTH_INVALID), - assert.isBuffer(s, messages.TWEAK_TYPE_INVALID), assert.isBufferLength(s, 32, messages.TWEAK_LENGTH_INVALID), E.privateKeyTweakMul(e, - s); - }, publicKeyCreate:function (e,s) - { + assert.isBuffer(s, messages.TWEAK_TYPE_INVALID), assert.isBufferLength(s, 32, messages.TWEAK_LENGTH_INVALID), E.privateKeyTweakMul(e, + s); + }, publicKeyCreate: function(e, s) { return assert.isBuffer(e, messages.EC_PRIVATE_KEY_TYPE_INVALID), assert.isBufferLength(e, 32, messages.EC_PRIVATE_KEY_LENGTH_INVALID), - s = initCompressedValue(s, !0), E.publicKeyCreate(e, s); - }, publicKeyConvert:function (e,s) - { + s = initCompressedValue(s, !0), E.publicKeyCreate(e, s); + }, publicKeyConvert: function(e, s) { return assert.isBuffer(e, messages.EC_PUBLIC_KEY_TYPE_INVALID), assert.isBufferLength2(e, 33, 65, messages.EC_PUBLIC_KEY_LENGTH_INVALID), - s = initCompressedValue(s, !0), E.publicKeyConvert(e, s); - }, publicKeyVerify:function (e) - { + s = initCompressedValue(s, !0), E.publicKeyConvert(e, s); + }, publicKeyVerify: function(e) { return assert.isBuffer(e, messages.EC_PUBLIC_KEY_TYPE_INVALID), E.publicKeyVerify(e); - }, publicKeyTweakAdd:function (e,s,r) - { + }, publicKeyTweakAdd: function(e, s, r) { return assert.isBuffer(e, messages.EC_PUBLIC_KEY_TYPE_INVALID), assert.isBufferLength2(e, 33, 65, messages.EC_PUBLIC_KEY_LENGTH_INVALID), - assert.isBuffer(s, messages.TWEAK_TYPE_INVALID), assert.isBufferLength(s, 32, messages.TWEAK_LENGTH_INVALID), r = initCompressedValue(r, - !0), E.publicKeyTweakAdd(e, s, r); - }, publicKeyTweakMul:function (e,s,r) - { + assert.isBuffer(s, messages.TWEAK_TYPE_INVALID), assert.isBufferLength(s, 32, messages.TWEAK_LENGTH_INVALID), r = initCompressedValue(r, + !0), E.publicKeyTweakAdd(e, s, r); + }, publicKeyTweakMul: function(e, s, r) { return assert.isBuffer(e, messages.EC_PUBLIC_KEY_TYPE_INVALID), assert.isBufferLength2(e, 33, 65, messages.EC_PUBLIC_KEY_LENGTH_INVALID), - assert.isBuffer(s, messages.TWEAK_TYPE_INVALID), assert.isBufferLength(s, 32, messages.TWEAK_LENGTH_INVALID), r = initCompressedValue(r, - !0), E.publicKeyTweakMul(e, s, r); - }, publicKeyCombine:function (e,s) - { + assert.isBuffer(s, messages.TWEAK_TYPE_INVALID), assert.isBufferLength(s, 32, messages.TWEAK_LENGTH_INVALID), r = initCompressedValue(r, + !0), E.publicKeyTweakMul(e, s, r); + }, publicKeyCombine: function(e, s) { assert.isArray(e, messages.EC_PUBLIC_KEYS_TYPE_INVALID), assert.isLengthGTZero(e, messages.EC_PUBLIC_KEYS_LENGTH_INVALID); - for(var r = 0; r < e.length; ++r) + for (var r = 0; r < e.length; ++r) assert.isBuffer(e[r], messages.EC_PUBLIC_KEY_TYPE_INVALID), assert.isBufferLength2(e[r], 33, 65, messages.EC_PUBLIC_KEY_LENGTH_INVALID); return s = initCompressedValue(s, !0), E.publicKeyCombine(e, s); - }, signatureNormalize:function (e) - { + }, signatureNormalize: function(e) { return assert.isBuffer(e, messages.ECDSA_SIGNATURE_TYPE_INVALID), assert.isBufferLength(e, 64, messages.ECDSA_SIGNATURE_LENGTH_INVALID), - E.signatureNormalize(e); - }, signatureExport:function (e) - { + E.signatureNormalize(e); + }, signatureExport: function(e) { assert.isBuffer(e, messages.ECDSA_SIGNATURE_TYPE_INVALID), assert.isBufferLength(e, 64, messages.ECDSA_SIGNATURE_LENGTH_INVALID); var s = E.signatureExport(e); return der.signatureExport(s); - }, signatureImport:function (e) - { + }, signatureImport: function(e) { assert.isBuffer(e, messages.ECDSA_SIGNATURE_TYPE_INVALID), assert.isLengthGTZero(e, messages.ECDSA_SIGNATURE_LENGTH_INVALID); var s = der.signatureImport(e); - if(s) + if (s) return E.signatureImport(s); throw new Error(messages.ECDSA_SIGNATURE_PARSE_DER_FAIL); - }, signatureImportLax:function (e) - { + }, signatureImportLax: function(e) { assert.isBuffer(e, messages.ECDSA_SIGNATURE_TYPE_INVALID), assert.isLengthGTZero(e, messages.ECDSA_SIGNATURE_LENGTH_INVALID); var s = der.signatureImportLax(e); - if(s) + if (s) return E.signatureImport(s); throw new Error(messages.ECDSA_SIGNATURE_PARSE_DER_FAIL); - }, sign:function (e,s,r) - { + }, sign: function(e, s, r) { assert.isBuffer(e, messages.MSG32_TYPE_INVALID), assert.isBufferLength(e, 32, messages.MSG32_LENGTH_INVALID), assert.isBuffer(s, - messages.EC_PRIVATE_KEY_TYPE_INVALID), assert.isBufferLength(s, 32, messages.EC_PRIVATE_KEY_LENGTH_INVALID); + messages.EC_PRIVATE_KEY_TYPE_INVALID), assert.isBufferLength(s, 32, messages.EC_PRIVATE_KEY_LENGTH_INVALID); var _ = null, t = null; return void 0 !== r && (assert.isObject(r, messages.OPTIONS_TYPE_INVALID), void 0 !== r.data && (assert.isBuffer(r.data, messages.OPTIONS_DATA_TYPE_INVALID), - assert.isBufferLength(r.data, 32, messages.OPTIONS_DATA_LENGTH_INVALID), _ = r.data), void 0 !== r.noncefn && (assert.isFunction(r.noncefn, - messages.OPTIONS_NONCEFN_TYPE_INVALID), t = r.noncefn)), E.sign(e, s, t, _); - }, verify:function (e,s,r) - { + assert.isBufferLength(r.data, 32, messages.OPTIONS_DATA_LENGTH_INVALID), _ = r.data), void 0 !== r.noncefn && (assert.isFunction(r.noncefn, + messages.OPTIONS_NONCEFN_TYPE_INVALID), t = r.noncefn)), E.sign(e, s, t, _); + }, verify: function(e, s, r) { return assert.isBuffer(e, messages.MSG32_TYPE_INVALID), assert.isBufferLength(e, 32, messages.MSG32_LENGTH_INVALID), assert.isBuffer(s, - messages.ECDSA_SIGNATURE_TYPE_INVALID), assert.isBufferLength(s, 64, messages.ECDSA_SIGNATURE_LENGTH_INVALID), assert.isBuffer(r, - messages.EC_PUBLIC_KEY_TYPE_INVALID), assert.isBufferLength2(r, 33, 65, messages.EC_PUBLIC_KEY_LENGTH_INVALID), E.verify(e, - s, r); - }, recover:function (e,s,r,_) - { + messages.ECDSA_SIGNATURE_TYPE_INVALID), assert.isBufferLength(s, 64, messages.ECDSA_SIGNATURE_LENGTH_INVALID), assert.isBuffer(r, + messages.EC_PUBLIC_KEY_TYPE_INVALID), assert.isBufferLength2(r, 33, 65, messages.EC_PUBLIC_KEY_LENGTH_INVALID), E.verify(e, + s, r); + }, recover: function(e, s, r, _) { return assert.isBuffer(e, messages.MSG32_TYPE_INVALID), assert.isBufferLength(e, 32, messages.MSG32_LENGTH_INVALID), assert.isBuffer(s, - messages.ECDSA_SIGNATURE_TYPE_INVALID), assert.isBufferLength(s, 64, messages.ECDSA_SIGNATURE_LENGTH_INVALID), assert.isNumber(r, - messages.RECOVERY_ID_TYPE_INVALID), assert.isNumberInInterval(r, - 1, 4, messages.RECOVERY_ID_VALUE_INVALID), _ = initCompressedValue(_, - !0), E.recover(e, s, r, _); - }, ecdh:function (e,s) - { + messages.ECDSA_SIGNATURE_TYPE_INVALID), assert.isBufferLength(s, 64, messages.ECDSA_SIGNATURE_LENGTH_INVALID), assert.isNumber(r, + messages.RECOVERY_ID_TYPE_INVALID), assert.isNumberInInterval(r, - 1, 4, messages.RECOVERY_ID_VALUE_INVALID), _ = initCompressedValue(_, + !0), E.recover(e, s, r, _); + }, ecdh: function(e, s) { return assert.isBuffer(e, messages.EC_PUBLIC_KEY_TYPE_INVALID), assert.isBufferLength2(e, 33, 65, messages.EC_PUBLIC_KEY_LENGTH_INVALID), - assert.isBuffer(s, messages.EC_PRIVATE_KEY_TYPE_INVALID), assert.isBufferLength(s, 32, messages.EC_PRIVATE_KEY_LENGTH_INVALID), - E.ecdh(e, s); - }, ecdhUnsafe:function (e,s,r) - { + assert.isBuffer(s, messages.EC_PRIVATE_KEY_TYPE_INVALID), assert.isBufferLength(s, 32, messages.EC_PRIVATE_KEY_LENGTH_INVALID), + E.ecdh(e, s); + }, ecdhUnsafe: function(e, s, r) { return assert.isBuffer(e, messages.EC_PUBLIC_KEY_TYPE_INVALID), assert.isBufferLength2(e, 33, 65, messages.EC_PUBLIC_KEY_LENGTH_INVALID), - assert.isBuffer(s, messages.EC_PRIVATE_KEY_TYPE_INVALID), assert.isBufferLength(s, 32, messages.EC_PRIVATE_KEY_LENGTH_INVALID), - r = initCompressedValue(r, !0), E.ecdhUnsafe(e, s, r); - }}; + assert.isBuffer(s, messages.EC_PRIVATE_KEY_TYPE_INVALID), assert.isBufferLength(s, 32, messages.EC_PRIVATE_KEY_LENGTH_INVALID), + r = initCompressedValue(r, !0), E.ecdhUnsafe(e, s, r); + } + }; }, global.SIGN_LIB = module.exports; diff --git a/src/HTML/JS/sha3.js b/src/HTML/JS/sha3.js index 255d5df..da42d9f 100644 --- a/src/HTML/JS/sha3.js +++ b/src/HTML/JS/sha3.js @@ -8,17 +8,14 @@ * Telegram: https://t.me/terafoundation */ -(function () -{ +(function() { 'use strict'; var root = typeof window === 'object' ? window : {}; var NODE_JS = !root.JS_SHA3_NO_NODE_JS && typeof process === 'object' && process.versions && process.versions.node; - if(NODE_JS && !root.RUN_NW_CLIENT) - { + if (NODE_JS && !root.RUN_NW_CLIENT) { root = global; } - if(root.RUN_CLIENT) - { + if (root.RUN_CLIENT) { root = window; } var COMMON_JS = !root.JS_SHA3_NO_COMMON_JS && typeof module === 'object' && module.exports; @@ -30,157 +27,132 @@ var PADDING = [6, 1536, 393216, 100663296]; var SHIFT = [0, 8, 16, 24]; var RC = [1, 0, 32898, 0, 32906, 2147483648, 2147516416, 2147483648, 32907, 0, 2147483649, 0, 2147516545, 2147483648, 32777, - 2147483648, 138, 0, 136, 0, 2147516425, 0, 2147483658, 0, 2147516555, 0, 139, 2147483648, 32905, 2147483648, 32771, 2147483648, - 32770, 2147483648, 128, 2147483648, 32778, 0, 2147483658, 2147483648, 2147516545, 2147483648, 32896, 2147483648, 2147483649, - 0, 2147516424, 2147483648]; + 2147483648, 138, 0, 136, 0, 2147516425, 0, 2147483658, 0, 2147516555, 0, 139, 2147483648, 32905, 2147483648, 32771, 2147483648, + 32770, 2147483648, 128, 2147483648, 32778, 0, 2147483658, 2147483648, 2147516545, 2147483648, 32896, 2147483648, 2147483649, + 0, 2147516424, 2147483648]; var BITS = [224, 256, 384, 512]; var SHAKE_BITS = [128, 256]; var OUTPUT_TYPES = ['hex', 'buffer', 'arrayBuffer', 'array']; - var CSHAKE_BYTEPAD = {'128':168, '256':136}; - if(root.JS_SHA3_NO_NODE_JS || !Array.isArray) - { - Array.isArray = function (obj) - { + var CSHAKE_BYTEPAD = { '128': 168, '256': 136 }; + if (root.JS_SHA3_NO_NODE_JS || !Array.isArray) { + Array.isArray = function(obj) { return Object.prototype.toString.call(obj) === '[object Array]'; }; } - var createOutputMethod = function (bits,padding,outputType) - { - return function (message) - { + var createOutputMethod = function(bits, padding, outputType) { + return function(message) { return new Keccak(bits, padding, bits).update(message)[outputType](); }; }; - var createShakeOutputMethod = function (bits,padding,outputType) - { - return function (message,outputBits) - { + var createShakeOutputMethod = function(bits, padding, outputType) { + return function(message, outputBits) { return new Keccak(bits, padding, outputBits).update(message)[outputType](); }; }; - var createCshakeOutputMethod = function (bits,padding,outputType) - { - return function (message,outputBits,n,s) - { + var createCshakeOutputMethod = function(bits, padding, outputType) { + return function(message, outputBits, n, s) { return methods['cshake' + bits].update(message, outputBits, n, s)[outputType](); }; }; - var createKmacOutputMethod = function (bits,padding,outputType) - { - return function (key,message,outputBits,s) - { + var createKmacOutputMethod = function(bits, padding, outputType) { + return function(key, message, outputBits, s) { return methods['kmac' + bits].update(key, message, outputBits, s)[outputType](); }; }; - var createOutputMethods = function (method,createMethod,bits,padding) - { - for(var i = 0; i < OUTPUT_TYPES.length; ++i) - { + var createOutputMethods = function(method, createMethod, bits, padding) { + for (var i = 0; i < OUTPUT_TYPES.length; ++i) { var type = OUTPUT_TYPES[i]; method[type] = createMethod(bits, padding, type); } return method; }; - var createMethod = function (bits,padding,outputs) - { + var createMethod = function(bits, padding, outputs) { var method = createOutputMethod(bits, padding, outputs); - method.create = function () - { + method.create = function() { return new Keccak(bits, padding, bits); }; - method.update = function (message) - { + method.update = function(message) { return method.create().update(message); }; return createOutputMethods(method, createOutputMethod, bits, padding); }; - var createMethodArray = function (bits,padding) - { + var createMethodArray = function(bits, padding) { var method = createOutputMethod(bits, padding, 'array'); - method.create = function () - { + method.create = function() { return new Keccak(bits, padding, bits); }; - method.update = function (message) - { + method.update = function(message) { return method.create().update(message); }; return createOutputMethods(method, createOutputMethod, bits, padding); }; - var createShakeMethod = function (bits,padding) - { + var createShakeMethod = function(bits, padding) { var method = createShakeOutputMethod(bits, padding, 'hex'); - method.create = function (outputBits) - { + method.create = function(outputBits) { return new Keccak(bits, padding, outputBits); }; - method.update = function (message,outputBits) - { + method.update = function(message, outputBits) { return method.create(outputBits).update(message); }; return createOutputMethods(method, createShakeOutputMethod, bits, padding); }; - var createCshakeMethod = function (bits,padding) - { + var createCshakeMethod = function(bits, padding) { var w = CSHAKE_BYTEPAD[bits]; var method = createCshakeOutputMethod(bits, padding, 'hex'); - method.create = function (outputBits,n,s) - { - if(!n && !s) - { + method.create = function(outputBits, n, s) { + if (!n && !s) { return methods['shake' + bits].create(outputBits); } - else - { + else { return new Keccak(bits, padding, outputBits).bytepad([n, s], w); } }; - method.update = function (message,outputBits,n,s) - { + method.update = function(message, outputBits, n, s) { return method.create(outputBits, n, s).update(message); }; return createOutputMethods(method, createCshakeOutputMethod, bits, padding); }; - var createKmacMethod = function (bits,padding) - { + var createKmacMethod = function(bits, padding) { var w = CSHAKE_BYTEPAD[bits]; var method = createKmacOutputMethod(bits, padding, 'hex'); - method.create = function (key,outputBits,s) - { + method.create = function(key, outputBits, s) { return new Kmac(bits, padding, outputBits).bytepad(['KMAC', s], w).bytepad([key], w); }; - method.update = function (key,message,outputBits,s) - { + method.update = function(key, message, outputBits, s) { return method.create(key, outputBits, s).update(message); }; return createOutputMethods(method, createKmacOutputMethod, bits, padding); }; - var algorithms = [{name:'keccak', padding:KECCAK_PADDING, bits:BITS, createMethod:createMethod}, {name:'sha3', padding:PADDING, - bits:BITS, createMethod:createMethod, outputs:'hex'}, {name:'sha3_array', padding:PADDING, bits:BITS, createMethod:createMethod, - outputs:'array'}, {name:'sha3_buf', padding:PADDING, bits:BITS, createMethod:createMethod, outputs:'buffer'}, {name:'shake', - padding:SHAKE_PADDING, bits:SHAKE_BITS, createMethod:createShakeMethod}, {name:'cshake', padding:CSHAKE_PADDING, bits:SHAKE_BITS, - createMethod:createCshakeMethod}, {name:'kmac', padding:CSHAKE_PADDING, bits:SHAKE_BITS, createMethod:createKmacMethod}]; + var algorithms = [{ name: 'keccak', padding: KECCAK_PADDING, bits: BITS, createMethod: createMethod }, { + name: 'sha3', padding: PADDING, + bits: BITS, createMethod: createMethod, outputs: 'hex' + }, { + name: 'sha3_array', padding: PADDING, bits: BITS, createMethod: createMethod, + outputs: 'array' + }, { name: 'sha3_buf', padding: PADDING, bits: BITS, createMethod: createMethod, outputs: 'buffer' }, { + name: 'shake', + padding: SHAKE_PADDING, bits: SHAKE_BITS, createMethod: createShakeMethod + }, { + name: 'cshake', padding: CSHAKE_PADDING, bits: SHAKE_BITS, + createMethod: createCshakeMethod + }, { name: 'kmac', padding: CSHAKE_PADDING, bits: SHAKE_BITS, createMethod: createKmacMethod }]; var methods = {}, methodNames = []; - for(var i = 0; i < algorithms.length; ++i) - { + for (var i = 0; i < algorithms.length; ++i) { var algorithm = algorithms[i]; var bits = algorithm.bits; - for(var j = 0; j < bits.length; ++j) - { + for (var j = 0; j < bits.length; ++j) { var methodName = algorithm.name + '_' + bits[j]; methodNames.push(methodName); methods[methodName] = algorithm.createMethod(bits[j], algorithm.padding, algorithm.outputs); - if(algorithm.name !== 'sha3') - { + if (algorithm.name !== 'sha3') { var newMethodName = algorithm.name + bits[j]; methodNames.push(newMethodName); methods[newMethodName] = methods[methodName]; } } } - -function Keccak(bits,padding,outputBits) - { + + function Keccak(bits, padding, outputBits) { this.blocks = []; this.s = []; this.padding = padding; @@ -192,71 +164,55 @@ function Keccak(bits,padding,outputBits) this.byteCount = this.blockCount << 2; this.outputBlocks = outputBits >> 5; this.extraBytes = (outputBits & 31) >> 3; - for(var i = 0; i < 50; ++i) - { + for (var i = 0; i < 50; ++i) { this.s[i] = 0; } }; - Keccak.prototype.update = function (message) - { + Keccak.prototype.update = function(message) { var notString = typeof message !== 'string'; - if(notString && message.constructor === root.ArrayBuffer) - { + if (notString && message.constructor === root.ArrayBuffer) { TO_ERROR_LOG("SHA3", 10, 'ERROR: Error type ArrayBuffer, use Uint8Array instead!'); return [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; } var length = message.length; - if(notString) - { - if(typeof length !== 'number' || !Array.isArray(message) && !(ARRAY_BUFFER && ArrayBuffer.isView(message))) - { + if (notString) { + if (typeof length !== 'number' || !Array.isArray(message) && !(ARRAY_BUFFER && ArrayBuffer.isView(message))) { TO_ERROR_LOG("SHA3", 20, 'ERROR: Input is invalid type, message=' + JSON.stringify(message)); return [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; } } var blocks = this.blocks, byteCount = this.byteCount, blockCount = this.blockCount, index = 0, s = this.s, i, code; - while(index < length) - { - if(this.reset) - { + while (index < length) { + if (this.reset) { this.reset = false; blocks[0] = this.block; - for(i = 1; i < blockCount + 1; ++i) - { + for (i = 1; i < blockCount + 1; ++i) { blocks[i] = 0; } } - if(notString) - { - for(i = this.start; index < length && i < byteCount; ++index) - { + if (notString) { + for (i = this.start; index < length && i < byteCount; ++index) { blocks[i >> 2] |= message[index] << SHIFT[i++ & 3]; } } - else - { - for(i = this.start; index < length && i < byteCount; ++index) - { + else { + for (i = this.start; index < length && i < byteCount; ++index) { code = message.charCodeAt(index); - if(code < 0x80) - { + if (code < 0x80) { blocks[i >> 2] |= code << SHIFT[i++ & 3]; } else - if(code < 0x800) - { + if (code < 0x800) { blocks[i >> 2] |= (0xc0 | (code >> 6)) << SHIFT[i++ & 3]; blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; } else - if(code < 0xd800 || code >= 0xe000) - { + if (code < 0xd800 || code >= 0xe000) { blocks[i >> 2] |= (0xe0 | (code >> 12)) << SHIFT[i++ & 3]; blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3]; blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; } - else - { + else { code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff)); blocks[i >> 2] |= (0xf0 | (code >> 18)) << SHIFT[i++ & 3]; blocks[i >> 2] |= (0x80 | ((code >> 12) & 0x3f)) << SHIFT[i++ & 3]; @@ -266,91 +222,73 @@ function Keccak(bits,padding,outputBits) } } this.lastByteIndex = i; - if(i >= byteCount) - { + if (i >= byteCount) { this.start = i - byteCount; this.block = blocks[blockCount]; - for(i = 0; i < blockCount; ++i) - { + for (i = 0; i < blockCount; ++i) { s[i] ^= blocks[i]; } f(s); this.reset = true; } - else - { + else { this.start = i; } } return this; }; - Keccak.prototype.encode = function (x,right) - { + Keccak.prototype.encode = function(x, right) { var o = x & 255, n = 1; var bytes = [o]; x = x >> 8; o = x & 255; - while(o > 0) - { + while (o > 0) { bytes.unshift(o); x = x >> 8; o = x & 255; ++n; } - if(right) - { + if (right) { bytes.push(n); } - else - { + else { bytes.unshift(n); } this.update(bytes); return bytes.length; }; - Keccak.prototype.encodeString = function (str) - { + Keccak.prototype.encodeString = function(str) { str = str || ''; var notString = typeof str !== 'string'; - if(notString && str.constructor === root.ArrayBuffer) - { + if (notString && str.constructor === root.ArrayBuffer) { str = new Uint8Array(str); } var length = str.length; - if(notString) - { - if(typeof length !== 'number' || !Array.isArray(str) && !(ARRAY_BUFFER && ArrayBuffer.isView(str))) - { + if (notString) { + if (typeof length !== 'number' || !Array.isArray(str) && !(ARRAY_BUFFER && ArrayBuffer.isView(str))) { TO_ERROR_LOG("SHA3", 30, 'ERROR: Input is invalid type, str=' + JSON.stringify(str)); return [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; } } var bytes = 0; - if(notString) - { + if (notString) { bytes = length; } - else - { - for(var i = 0; i < str.length; ++i) - { + else { + for (var i = 0; i < str.length; ++i) { var code = str.charCodeAt(i); - if(code < 0x80) - { + if (code < 0x80) { bytes += 1; } else - if(code < 0x800) - { + if (code < 0x800) { bytes += 2; } else - if(code < 0xd800 || code >= 0xe000) - { + if (code < 0xd800 || code >= 0xe000) { bytes += 3; } - else - { + else { code = 0x10000 + (((code & 0x3ff) << 10) | (str.charCodeAt(++i) & 0x3ff)); bytes += 4; } @@ -360,11 +298,9 @@ function Keccak(bits,padding,outputBits) this.update(str); return bytes; }; - Keccak.prototype.bytepad = function (strs,w) - { + Keccak.prototype.bytepad = function(strs, w) { var bytes = this.encode(w); - for(var i = 0; i < strs.length; ++i) - { + for (var i = 0; i < strs.length; ++i) { bytes += this.encodeString(strs[i]); } var paddingBytes = w - bytes % w; @@ -373,104 +309,82 @@ function Keccak(bits,padding,outputBits) this.update(zeros); return this; }; - Keccak.prototype.finalize = function () - { + Keccak.prototype.finalize = function() { var blocks = this.blocks, i = this.lastByteIndex, blockCount = this.blockCount, s = this.s; blocks[i >> 2] |= this.padding[i & 3]; - if(this.lastByteIndex === this.byteCount) - { + if (this.lastByteIndex === this.byteCount) { blocks[0] = blocks[blockCount]; - for(i = 1; i < blockCount + 1; ++i) - { + for (i = 1; i < blockCount + 1; ++i) { blocks[i] = 0; } } blocks[blockCount - 1] |= 0x80000000; - for(i = 0; i < blockCount; ++i) - { + for (i = 0; i < blockCount; ++i) { s[i] ^= blocks[i]; } f(s); }; - Keccak.prototype.toString = Keccak.prototype.hex = function () - { + Keccak.prototype.toString = Keccak.prototype.hex = function() { this.finalize(); var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, extraBytes = this.extraBytes, i = 0, j = 0; var hex = '', block; - while(j < outputBlocks) - { - for(i = 0; i < blockCount && j < outputBlocks; ++i, ++j) - { + while (j < outputBlocks) { + for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) { block = s[i]; hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F] + HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F] + HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F] + HEX_CHARS[(block >> 28) & 0x0F] + HEX_CHARS[(block >> 24) & 0x0F]; } - if(j % blockCount === 0) - { + if (j % blockCount === 0) { f(s); i = 0; } } - if(extraBytes) - { + if (extraBytes) { block = s[i]; - if(extraBytes > 0) - { + if (extraBytes > 0) { hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F]; } - if(extraBytes > 1) - { + if (extraBytes > 1) { hex += HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F]; } - if(extraBytes > 2) - { + if (extraBytes > 2) { hex += HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F]; } } return hex; }; - Keccak.prototype.arrayBuffer = function () - { + Keccak.prototype.arrayBuffer = function() { this.finalize(); var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, extraBytes = this.extraBytes, i = 0, j = 0; var bytes = this.outputBits >> 3; var buffer; - if(extraBytes) - { + if (extraBytes) { buffer = new ArrayBuffer((outputBlocks + 1) << 2); } - else - { + else { buffer = new ArrayBuffer(bytes); } var array = new Uint32Array(buffer); - while(j < outputBlocks) - { - for(i = 0; i < blockCount && j < outputBlocks; ++i, ++j) - { + while (j < outputBlocks) { + for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) { array[j] = s[i]; } - if(j % blockCount === 0) - { + if (j % blockCount === 0) { f(s); } } - if(extraBytes) - { + if (extraBytes) { array[i] = s[i]; buffer = buffer.slice(0, bytes); } return buffer; }; Keccak.prototype.buffer = Keccak.prototype.arrayBuffer; - Keccak.prototype.digest = Keccak.prototype.array = function () - { + Keccak.prototype.digest = Keccak.prototype.array = function() { this.finalize(); var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, extraBytes = this.extraBytes, i = 0, j = 0; var array = [], offset, block; - while(j < outputBlocks) - { - for(i = 0; i < blockCount && j < outputBlocks; ++i, ++j) - { + while (j < outputBlocks) { + for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) { offset = j << 2; block = s[i]; array[offset] = block & 0xFF; @@ -478,48 +392,39 @@ function Keccak(bits,padding,outputBits) array[offset + 2] = (block >> 16) & 0xFF; array[offset + 3] = (block >> 24) & 0xFF; } - if(j % blockCount === 0) - { + if (j % blockCount === 0) { f(s); } } - if(extraBytes) - { + if (extraBytes) { offset = j << 2; block = s[i]; - if(extraBytes > 0) - { + if (extraBytes > 0) { array[offset] = block & 0xFF; } - if(extraBytes > 1) - { + if (extraBytes > 1) { array[offset + 1] = (block >> 8) & 0xFF; } - if(extraBytes > 2) - { + if (extraBytes > 2) { array[offset + 2] = (block >> 16) & 0xFF; } } return array; }; - -function Kmac(bits,padding,outputBits) - { + + function Kmac(bits, padding, outputBits) { Keccak.call(this, bits, padding, outputBits); }; Kmac.prototype = new Keccak(); - Kmac.prototype.finalize = function () - { + Kmac.prototype.finalize = function() { this.encode(this.outputBits, true); return Keccak.prototype.finalize.call(this); }; - var f = function (s) - { + var f = function(s) { var h, l, n, c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, - b16, b17, b18, b19, b20, b21, b22, b23, b24, b25, b26, b27, b28, b29, b30, b31, b32, b33, b34, b35, b36, b37, b38, b39, b40, - b41, b42, b43, b44, b45, b46, b47, b48, b49; - for(n = 0; n < 48; n += 2) - { + b16, b17, b18, b19, b20, b21, b22, b23, b24, b25, b26, b27, b28, b29, b30, b31, b32, b33, b34, b35, b36, b37, b38, b39, b40, + b41, b42, b43, b44, b45, b46, b47, b48, b49; + for (n = 0; n < 48; n += 2) { c0 = s[0] ^ s[10] ^ s[20] ^ s[30] ^ s[40]; c1 = s[1] ^ s[11] ^ s[21] ^ s[31] ^ s[41]; c2 = s[2] ^ s[12] ^ s[22] ^ s[32] ^ s[42]; @@ -697,58 +602,47 @@ function Kmac(bits,padding,outputBits) root.sha3_str = methods.sha3_256; root.sha3_array_256 = methods.sha3_array_256; root.sha3 = methods.sha3_array_256; - root.sha = function (data) - { + root.sha = function(data) { return meshhash(methods.sha3_256(data)); }; - root.shaarr = function (data) - { + root.shaarr = function(data) { return meshhash(methods.sha3_array_256(data)); }; - root.shabuf = function (data) - { + root.shabuf = function(data) { return Buffer.from(shaarr(data)); }; - root.shabuf = function (data) - { + root.shabuf = function(data) { return Buffer.from(shaarr(data)); }; - root.SHA3BUF = function (data,num) - { + root.SHA3BUF = function(data, num) { return Buffer.from(SHA3ARR(data, num)); }; - root.SHA3ARR = function (data,num) - { - if(!NEW_SIGN_TIME || !num || num >= NEW_SIGN_TIME) + root.SHA3ARR = function(data, num) { + if (!NEW_SIGN_TIME || !num || num >= NEW_SIGN_TIME) return sha3(data); else return meshhash(methods.sha3_array_256(data)); }; - root.shaarrblock = function (data,num) - { + root.shaarrblock = function(data, num) { return meshhash(methods.sha3_array_256(data), num); }; })(); -function meshhash(hash,num) -{ +function meshhash(hash, num) { var regs = [hash[3], hash[2], hash[1], hash[0]]; var mem = []; - for(var i = 0; i < 16; i++) - { + for (var i = 0; i < 16; i++) { mem[i] = hash[i * 2] + (hash[i * 2 + 1] << 8); } var WasGoto = 0; var L = 0; - for(var i = 0; i < 64; i++) - { + for (var i = 0; i < 64; i++) { var c = hash[L & 31]; L++; var a = (c >> 4) & 0xF; var b = c & 0xF; var r = c & 0x3; - switch(a) - { + switch (a) { case 0: regs[0] = regs[0] + regs[r]; break; @@ -768,15 +662,13 @@ function meshhash(hash,num) regs[0] = regs[0] + regs[1] + regs[2] + regs[3]; break; case 8: - if((regs[0] & 0xFFFF) < 32768 && !WasGoto) - { + if ((regs[0] & 0xFFFF) < 32768 && !WasGoto) { L = 32 + L - b; WasGoto = 1; } break; case 9: - if((regs[0] & 0xFFFF) > 32768 && !WasGoto) - { + if ((regs[0] & 0xFFFF) > 32768 && !WasGoto) { L += b; WasGoto = 1; } @@ -786,16 +678,14 @@ function meshhash(hash,num) } var index1 = regs[0] & 0xF; var index2 = (regs[0] >> 8) & 0xF; - if(index1 !== index2) - { + if (index1 !== index2) { var temp = mem[index1]; mem[index1] = mem[index2]; mem[index2] = temp; } } var ret = []; - for(var i = 0; i < 16; i++) - { + for (var i = 0; i < 16; i++) { ret[i * 2] = mem[i] & 0xFF; ret[i * 2 + 1] = mem[i] >> 8; } diff --git a/src/HTML/JS/sign-lib-min.js b/src/HTML/JS/sign-lib-min.js index b2dd307..a2b75b9 100644 --- a/src/HTML/JS/sign-lib-min.js +++ b/src/HTML/JS/sign-lib-min.js @@ -9,222 +9,183 @@ */ var $jscomp = $jscomp || {}; -$jscomp.scope = {}, $jscomp.arrayIteratorImpl = function (t) -{ +$jscomp.scope = {}, $jscomp.arrayIteratorImpl = function(t) { var e = 0; - return function () - { - return e < t.length ? {done:!1, value:t[e++]} : {done:!0}; + return function() { + return e < t.length ? { done: !1, value: t[e++] } : { done: !0 }; }; -}, $jscomp.arrayIterator = function (t) -{ - return {next:$jscomp.arrayIteratorImpl(t)}; -}, $jscomp.ASSUME_ES5 = !1, $jscomp.ASSUME_NO_NATIVE_MAP = !1, $jscomp.ASSUME_NO_NATIVE_SET = !1, $jscomp.defineProperty = $jscomp.ASSUME_ES5 || "function" == typeof Object.defineProperties ? Object.defineProperty : function (t,e,r) -{ +}, $jscomp.arrayIterator = function(t) { + return { next: $jscomp.arrayIteratorImpl(t) }; +}, $jscomp.ASSUME_ES5 = !1, $jscomp.ASSUME_NO_NATIVE_MAP = !1, $jscomp.ASSUME_NO_NATIVE_SET = !1, $jscomp.defineProperty = $jscomp.ASSUME_ES5 || "function" == typeof Object.defineProperties ? Object.defineProperty : function(t, e, r) { t != Array.prototype && t != Object.prototype && (t[e] = r.value); -}, $jscomp.getGlobal = function (t) -{ +}, $jscomp.getGlobal = function(t) { return "undefined" != typeof window && window === t ? t : "undefined" != typeof global && null != global ? global : t; -}, $jscomp.global = $jscomp.getGlobal(this), $jscomp.SYMBOL_PREFIX = "jscomp_symbol_", $jscomp.initSymbol = function () -{ - $jscomp.initSymbol = function () - { +}, $jscomp.global = $jscomp.getGlobal(this), $jscomp.SYMBOL_PREFIX = "jscomp_symbol_", $jscomp.initSymbol = function() { + $jscomp.initSymbol = function() { }, $jscomp.global.Symbol || ($jscomp.global.Symbol = $jscomp.Symbol); -}, $jscomp.Symbol = function () -{ +}, $jscomp.Symbol = function() { var e = 0; - return function (t) - { + return function(t) { return $jscomp.SYMBOL_PREFIX + (t || "") + e++; }; -}(), $jscomp.initSymbolIterator = function () -{ +}(), $jscomp.initSymbolIterator = function() { $jscomp.initSymbol(); var t = $jscomp.global.Symbol.iterator; t || (t = $jscomp.global.Symbol.iterator = $jscomp.global.Symbol("iterator")), "function" != typeof Array.prototype[t] && $jscomp.defineProperty(Array.prototype, - t, {configurable:!0, writable:!0, value:function () - { - return $jscomp.iteratorPrototype($jscomp.arrayIteratorImpl(this)); - }}), $jscomp.initSymbolIterator = function () - { - }; -}, $jscomp.initSymbolAsyncIterator = function () -{ + t, { + configurable: !0, writable: !0, value: function() { + return $jscomp.iteratorPrototype($jscomp.arrayIteratorImpl(this)); + } + }), $jscomp.initSymbolIterator = function() { + }; +}, $jscomp.initSymbolAsyncIterator = function() { $jscomp.initSymbol(); var t = $jscomp.global.Symbol.asyncIterator; - t || (t = $jscomp.global.Symbol.asyncIterator = $jscomp.global.Symbol("asyncIterator")), $jscomp.initSymbolAsyncIterator = function () - { + t || (t = $jscomp.global.Symbol.asyncIterator = $jscomp.global.Symbol("asyncIterator")), $jscomp.initSymbolAsyncIterator = function() { }; -}, $jscomp.iteratorPrototype = function (t) -{ - return $jscomp.initSymbolIterator(), (t = {next:t})[$jscomp.global.Symbol.iterator] = function () - { +}, $jscomp.iteratorPrototype = function(t) { + return $jscomp.initSymbolIterator(), (t = { next: t })[$jscomp.global.Symbol.iterator] = function() { return this; }, t; -}, function i(n,s,o) -{ - -function a(e,t) - { - if(!s[e]) - { - if(!n[e]) - { +}, function i(n, s, o) { + + function a(e, t) { + if (!s[e]) { + if (!n[e]) { var r = "function" == typeof require && require; - if(!t && r) + if (!t && r) return r(e, !0); - if(h) + if (h) return h(e, !0); throw (r = Error("Cannot find module '" + e + "'")).code = "MODULE_NOT_FOUND", r; } - r = s[e] = {exports:{}}, n[e][0].call(r.exports, function (t) - { + r = s[e] = { exports: {} }, n[e][0].call(r.exports, function(t) { return a(n[e][1][t] || t); }, r, r.exports, i, n, s, o); } return s[e].exports; }; - for(var h = "function" == typeof require && require, t = 0; t < o.length; t++) + for (var h = "function" == typeof require && require, t = 0; t < o.length; t++) a(o[t]); return a; -}({1:[function (t,e,r) - { - -function a(t) - { +}({ + 1: [function(t, e, r) { + + function a(t) { var e = t.length; - if(0 < e % 4) + if (0 < e % 4) throw Error("Invalid string. Length must be a multiple of 4"); - return - 1 === (t = t.indexOf("=")) && (t = e), [t, t === e ? 0 : 4 - t % 4]; + return - 1 === (t = t.indexOf("=")) && (t = e), [t, t === e ? 0 : 4 - t % 4]; }; - -function o(t,e,r) - { - for(var i = [], n = e; n < r; n += 3) + + function o(t, e, r) { + for (var i = [], n = e; n < r; n += 3) e = (t[n] << 16 & 16711680) + (t[n + 1] << 8 & 65280) + (255 & t[n + 2]), i.push(h[e >> 18 & 63] + h[e >> 12 & 63] + h[e >> 6 & 63] + h[63 & e]); return i.join(""); }; - r.byteLength = function (t) - { + r.byteLength = function(t) { var e = (t = a(t))[1]; return 3 * (t[0] + e) / 4 - e; - }, r.toByteArray = function (t) - { + }, r.toByteArray = function(t) { var e = a(t), r = e[0]; e = e[1]; - for(var i = new l(3 * (r + e) / 4 - e), n = 0, s = 0 < e ? r - 4 : r, o = 0; o < s; o += 4) + for (var i = new l(3 * (r + e) / 4 - e), n = 0, s = 0 < e ? r - 4 : r, o = 0; o < s; o += 4) r = u[t.charCodeAt(o)] << 18 | u[t.charCodeAt(o + 1)] << 12 | u[t.charCodeAt(o + 2)] << 6 | u[t.charCodeAt(o + 3)], i[n++] = r >> 16 & 255, - i[n++] = r >> 8 & 255, i[n++] = 255 & r; + i[n++] = r >> 8 & 255, i[n++] = 255 & r; return 2 === e && (r = u[t.charCodeAt(o)] << 2 | u[t.charCodeAt(o + 1)] >> 4, i[n++] = 255 & r), 1 === e && (r = u[t.charCodeAt(o)] << 10 | u[t.charCodeAt(o + 1)] << 4 | u[t.charCodeAt(o + 2)] >> 2, - i[n++] = r >> 8 & 255, i[n++] = 255 & r), i; - }, r.fromByteArray = function (t) - { - for(var e = t.length, r = e % 3, i = [], n = 0, s = e - r; n < s; n += 16383) + i[n++] = r >> 8 & 255, i[n++] = 255 & r), i; + }, r.fromByteArray = function(t) { + for (var e = t.length, r = e % 3, i = [], n = 0, s = e - r; n < s; n += 16383) i.push(o(t, n, s < n + 16383 ? s : n + 16383)); return 1 === r ? (t = t[e - 1], i.push(h[t >> 2] + h[t << 4 & 63] + "==")) : 2 === r && (t = (t[e - 2] << 8) + t[e - 1], i.push(h[t >> 10] + h[t >> 4 & 63] + h[t << 2 & 63] + "=")), - i.join(""); + i.join(""); }; var h = [], u = [], l = "undefined" != typeof Uint8Array ? Uint8Array : Array; - for(t = 0; t < 64; ++t) + for (t = 0; t < 64; ++t) h[t] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[t], u["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charCodeAt(t)] = t; u[45] = 62, u[95] = 63; - }, {}], 2:[function (t,e,r) - { - }, {}], 3:[function (t,e,r) - { - -function n(t) - { - if(B < t) + }, {}], 2: [function(t, e, r) { + }, {}], 3: [function(t, e, r) { + + function n(t) { + if (B < t) throw new RangeError("Invalid typed array length"); return (t = new Uint8Array(t)).__proto__ = h.prototype, t; }; - -function h(t,e,r) - { - if("number" != typeof t) + + function h(t, e, r) { + if ("number" != typeof t) return i(t, e, r); - if("string" == typeof e) + if ("string" == typeof e) throw Error("If encoding is specified then the first argument must be a string"); return o(t); }; - -function i(t,e,r) - { - if("number" == typeof t) + + function i(t, e, r) { + if ("number" == typeof t) throw new TypeError('"value" argument must not be a number'); - if(S(t) || t && S(t.buffer)) - { - if(e < 0 || t.byteLength < e) + if (S(t) || t && S(t.buffer)) { + if (e < 0 || t.byteLength < e) throw new RangeError('"offset" is outside of buffer bounds'); - if(t.byteLength < e + (r || 0)) + if (t.byteLength < e + (r || 0)) throw new RangeError('"length" is outside of buffer bounds'); return (t = void 0 === e && void 0 === r ? new Uint8Array(t) : void 0 === r ? new Uint8Array(t, e) : new Uint8Array(t, e, r)).__proto__ = h.prototype, - t; + t; } - if("string" != typeof t) - return function (t) - { - if(h.isBuffer(t)) - { + if ("string" != typeof t) + return function(t) { + if (h.isBuffer(t)) { var e = 0 | u(t.length), r = n(e); return 0 === r.length || t.copy(r, 0, 0, e), r; } - if(t) - { - if(ArrayBuffer.isView(t) || "length" in t) + if (t) { + if (ArrayBuffer.isView(t) || "length" in t) return (e = "number" != typeof t.length) || (e = (e = t.length) != e), e ? n(0) : a(t); - if("Buffer" === t.type && Array.isArray(t.data)) + if ("Buffer" === t.type && Array.isArray(t.data)) return a(t.data); } throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object."); }(t); var i = e; - if("string" == typeof i && "" !== i || (i = "utf8"), !h.isEncoding(i)) + if ("string" == typeof i && "" !== i || (i = "utf8"), !h.isEncoding(i)) throw new TypeError("Unknown encoding: " + i); return (t = (r = n(e = 0 | l(t, i))).write(t, i)) !== e && (r = r.slice(0, t)), r; }; - -function s(t) - { - if("number" != typeof t) + + function s(t) { + if ("number" != typeof t) throw new TypeError('"size" argument must be of type number'); - if(t < 0) + if (t < 0) throw new RangeError('"size" argument must not be negative'); }; - -function o(t) - { + + function o(t) { return s(t), n(t < 0 ? 0 : 0 | u(t)); }; - -function a(t) - { - for(var e = t.length < 0 ? 0 : 0 | u(t.length), r = n(e), i = 0; i < e; i += 1) + + function a(t) { + for (var e = t.length < 0 ? 0 : 0 | u(t.length), r = n(e), i = 0; i < e; i += 1) r[i] = 255 & t[i]; return r; }; - -function u(t) - { - if(B <= t) + + function u(t) { + if (B <= t) throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x" + B.toString(16) + " bytes"); return 0 | t; }; - -function l(t,e) - { - if(h.isBuffer(t)) + + function l(t, e) { + if (h.isBuffer(t)) return t.length; - if(ArrayBuffer.isView(t) || S(t)) + if (ArrayBuffer.isView(t) || S(t)) return t.byteLength; "string" != typeof t && (t = "" + t); var r = t.length; - if(0 === r) + if (0 === r) return 0; - for(var i = !1; ; ) - switch(e) - { + for (var i = !1; ;) + switch (e) { case "ascii": case "latin1": case "binary": @@ -243,91 +204,78 @@ function l(t,e) case "base64": return I.toByteArray(w(t)).length; default: - if(i) + if (i) return v(t).length; e = ("" + e).toLowerCase(), i = !0; } }; - -function f(t,e,r) - { + + function f(t, e, r) { var i = t[e]; t[e] = t[r], t[r] = i; }; - -function c(t,e,r,i,n) - { - if(0 === t.length) - return - 1; - if("string" == typeof r ? (i = r, r = 0) : 2147483647 < r ? r = 2147483647 : r < - 2147483648 && (r = - 2147483648), (r = + r) != r && (r = n ? 0 : t.length - 1), - r < 0 && (r = t.length + r), r >= t.length) - { - if(n) - return - 1; + + function c(t, e, r, i, n) { + if (0 === t.length) + return - 1; + if ("string" == typeof r ? (i = r, r = 0) : 2147483647 < r ? r = 2147483647 : r < - 2147483648 && (r = - 2147483648), (r = + r) != r && (r = n ? 0 : t.length - 1), + r < 0 && (r = t.length + r), r >= t.length) { + if (n) + return - 1; r = t.length - 1; } else - if(r < 0) - { - if(!n) - return - 1; + if (r < 0) { + if (!n) + return - 1; r = 0; } - if("string" == typeof e && (e = h.from(e, i)), h.isBuffer(e)) - return 0 === e.length ? - 1 : d(t, e, r, i, n); - if("number" == typeof e) + if ("string" == typeof e && (e = h.from(e, i)), h.isBuffer(e)) + return 0 === e.length ? - 1 : d(t, e, r, i, n); + if ("number" == typeof e) return e &= 255, "function" == typeof Uint8Array.prototype.indexOf ? n ? Uint8Array.prototype.indexOf.call(t, e, r) : Uint8Array.prototype.lastIndexOf.call(t, - e, r) : d(t, [e], r, i, n); + e, r) : d(t, [e], r, i, n); throw new TypeError("val must be string, number or Buffer"); }; - -function d(t,e,r,i,n) - { - -function s(t,e) - { + + function d(t, e, r, i, n) { + + function s(t, e) { return 1 === o ? t[e] : t.readUInt16BE(e * o); }; var o = 1, a = t.length, h = e.length; - if(void 0 !== i && ("ucs2" === (i = String(i).toLowerCase()) || "ucs-2" === i || "utf16le" === i || "utf-16le" === i)) - { - if(t.length < 2 || e.length < 2) - return - 1; + if (void 0 !== i && ("ucs2" === (i = String(i).toLowerCase()) || "ucs-2" === i || "utf16le" === i || "utf-16le" === i)) { + if (t.length < 2 || e.length < 2) + return - 1; a /= o = 2, h /= 2, r /= 2; } - if(n) - for(i = - 1; r < a; r++) - if(s(t, r) === s(e, - 1 === i ? 0 : r - i)) - { - if( - 1 === i && (i = r), r - i + 1 === h) + if (n) + for (i = - 1; r < a; r++) + if (s(t, r) === s(e, - 1 === i ? 0 : r - i)) { + if (- 1 === i && (i = r), r - i + 1 === h) return i * o; } else - - 1 !== i && (r -= r - i), i = - 1; + - 1 !== i && (r -= r - i), i = - 1; else - for(a < r + h && (r = a - h); 0 <= r; r--) - { - for(a = !0, i = 0; i < h; i++) - if(s(t, r + i) !== s(e, i)) - { + for (a < r + h && (r = a - h); 0 <= r; r--) { + for (a = !0, i = 0; i < h; i++) + if (s(t, r + i) !== s(e, i)) { a = !1; break; } - if(a) + if (a) return r; } - return - 1; + return - 1; }; - -function p(t,e,r) - { + + function p(t, e, r) { r = Math.min(t.length, r); - for(var i = []; e < r; ) - { + for (var i = []; e < r;) { var n = t[e], s = null, o = 239 < n ? 4 : 223 < n ? 3 : 191 < n ? 2 : 1; - if(e + o <= r) - switch(o) - { + if (e + o <= r) + switch (o) { case 1: n < 128 && (s = n); break; @@ -346,704 +294,587 @@ function p(t,e,r) 128 == (192 & a) && 128 == (192 & h) && 128 == (192 & u) && (65535 < (n = (15 & n) << 18 | (63 & a) << 12 | (63 & h) << 6 | 63 & u) && n < 1114112 && (s = n)); } null === s ? (s = 65533, o = 1) : 65535 < s && (s -= 65536, i.push(s >>> 10 & 1023 | 55296), s = 56320 | 1023 & s), i.push(s), - e += o; + e += o; } - if((t = i.length) <= x) + if ((t = i.length) <= x) i = String.fromCharCode.apply(String, i); - else - { - for(r = "", e = 0; e < t; ) + else { + for (r = "", e = 0; e < t;) r += String.fromCharCode.apply(String, i.slice(e, e += x)); i = r; } return i; }; - -function m(t,e,r) - { - if(0 != t % 1 || t < 0) + + function m(t, e, r) { + if (0 != t % 1 || t < 0) throw new RangeError("offset is not uint"); - if(r < t + e) + if (r < t + e) throw new RangeError("Trying to access beyond buffer length"); }; - -function _(t,e,r,i,n,s) - { - if(!h.isBuffer(t)) + + function _(t, e, r, i, n, s) { + if (!h.isBuffer(t)) throw new TypeError('"buffer" argument must be a Buffer instance'); - if(n < e || e < s) + if (n < e || e < s) throw new RangeError('"value" argument is out of bounds'); - if(r + i > t.length) + if (r + i > t.length) throw new RangeError("Index out of range"); }; - -function g(t,e,r,i,n,s) - { - if(r + i > t.length) + + function g(t, e, r, i, n, s) { + if (r + i > t.length) throw new RangeError("Index out of range"); - if(r < 0) + if (r < 0) throw new RangeError("Index out of range"); }; - -function b(t,e,r,i,n) - { - return e = + e, r >>>= 0, n || g(t, 0, r, 4), A.write(t, e, r, i, 23, 4), r + 4; + + function b(t, e, r, i, n) { + return e = + e, r >>>= 0, n || g(t, 0, r, 4), A.write(t, e, r, i, 23, 4), r + 4; }; - -function y(t,e,r,i,n) - { - return e = + e, r >>>= 0, n || g(t, 0, r, 8), A.write(t, e, r, i, 52, 8), r + 8; + + function y(t, e, r, i, n) { + return e = + e, r >>>= 0, n || g(t, 0, r, 8), A.write(t, e, r, i, 52, 8), r + 8; }; - -function w(t) - { - if((t = (t = t.split("=")[0]).trim().replace(L, "")).length < 2) + + function w(t) { + if ((t = (t = t.split("=")[0]).trim().replace(L, "")).length < 2) return ""; - for(; 0 != t.length % 4; ) + for (; 0 != t.length % 4;) t += "="; return t; }; - -function v(t,e) - { + + function v(t, e) { e = e || 1 / 0; - for(var r, i = t.length, n = null, s = [], o = 0; o < i; ++o) - { - if(55295 < (r = t.charCodeAt(o)) && r < 57344) - { - if(!n) - { - if(56319 < r) - { - - 1 < (e -= 3) && s.push(239, 191, 189); + for (var r, i = t.length, n = null, s = [], o = 0; o < i; ++o) { + if (55295 < (r = t.charCodeAt(o)) && r < 57344) { + if (!n) { + if (56319 < r) { + - 1 < (e -= 3) && s.push(239, 191, 189); continue; } - if(o + 1 === i) - { - - 1 < (e -= 3) && s.push(239, 191, 189); + if (o + 1 === i) { + - 1 < (e -= 3) && s.push(239, 191, 189); continue; } n = r; continue; } - if(r < 56320) - { - - 1 < (e -= 3) && s.push(239, 191, 189), n = r; + if (r < 56320) { + - 1 < (e -= 3) && s.push(239, 191, 189), n = r; continue; } r = 65536 + (n - 55296 << 10 | r - 56320); } else - n && - 1 < (e -= 3) && s.push(239, 191, 189); - if(n = null, r < 128) - { - if(--e < 0) + n && - 1 < (e -= 3) && s.push(239, 191, 189); + if (n = null, r < 128) { + if (--e < 0) break; s.push(r); } else - if(r < 2048) - { - if((e -= 2) < 0) + if (r < 2048) { + if ((e -= 2) < 0) break; s.push(r >> 6 | 192, 63 & r | 128); } else - if(r < 65536) - { - if((e -= 3) < 0) + if (r < 65536) { + if ((e -= 3) < 0) break; s.push(r >> 12 | 224, r >> 6 & 63 | 128, 63 & r | 128); } - else - { - if(!(r < 1114112)) + else { + if (!(r < 1114112)) throw Error("Invalid code point"); - if((e -= 4) < 0) + if ((e -= 4) < 0) break; s.push(r >> 18 | 240, r >> 12 & 63 | 128, r >> 6 & 63 | 128, 63 & r | 128); } } return s; }; - -function M(t) - { - for(var e = [], r = 0; r < t.length; ++r) + + function M(t) { + for (var e = [], r = 0; r < t.length; ++r) e.push(255 & t.charCodeAt(r)); return e; }; - -function E(t,e,r,i) - { - for(var n = 0; n < i && !(n + r >= e.length || n >= t.length); ++n) + + function E(t, e, r, i) { + for (var n = 0; n < i && !(n + r >= e.length || n >= t.length); ++n) e[n + r] = t[n]; return n; }; - -function S(t) - { + + function S(t) { return t instanceof ArrayBuffer || null != t && null != t.constructor && "ArrayBuffer" === t.constructor.name && "number" == typeof t.byteLength; }; var I = t("base64-js"), A = t("ieee754"); - r.Buffer = h, r.SlowBuffer = function (t) - { - return + t != t && (t = 0), h.alloc( + t); + r.Buffer = h, r.SlowBuffer = function(t) { + return + t != t && (t = 0), h.alloc(+ t); }, r.INSPECT_MAX_BYTES = 50; var B = 2147483647; - r.kMaxLength = B, (h.TYPED_ARRAY_SUPPORT = function () - { - try - { + r.kMaxLength = B, (h.TYPED_ARRAY_SUPPORT = function() { + try { var t = new Uint8Array(1); - return t.__proto__ = {__proto__:Uint8Array.prototype, foo:function () - { + return t.__proto__ = { + __proto__: Uint8Array.prototype, foo: function() { return 42; - }}, 42 === t.foo(); + } + }, 42 === t.foo(); } - catch(t) - { + catch (t) { return !1; } }()) || "undefined" == typeof console || "function" != typeof console.error || console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."), - Object.defineProperty(h.prototype, "parent", {get:function () - { - if(this instanceof h) - return this.buffer; - }}), Object.defineProperty(h.prototype, "offset", {get:function () - { - if(this instanceof h) - return this.byteOffset; - }}), $jscomp.initSymbol(), $jscomp.initSymbol(), $jscomp.initSymbol(), "undefined" != typeof Symbol && Symbol.species && h[Symbol.species] === h && ($jscomp.initSymbol(), - Object.defineProperty(h, Symbol.species, {value:null, configurable:!0, enumerable:!1, writable:!1})), h.poolSize = 8192, h.from = function (t,e,r) - { - return i(t, e, r); - }, h.prototype.__proto__ = Uint8Array.prototype, h.__proto__ = Uint8Array, h.alloc = function (t,e,r) - { - return s(t), t = t <= 0 ? n(t) : void 0 !== e ? "string" == typeof r ? n(t).fill(e, r) : n(t).fill(e) : n(t); - }, h.allocUnsafe = function (t) - { - return o(t); - }, h.allocUnsafeSlow = function (t) - { - return o(t); - }, h.isBuffer = function (t) - { - return null != t && !0 === t._isBuffer; - }, h.compare = function (t,e) - { - if(!h.isBuffer(t) || !h.isBuffer(e)) - throw new TypeError("Arguments must be Buffers"); - if(t === e) - return 0; - for(var r = t.length, i = e.length, n = 0, s = Math.min(r, i); n < s; ++n) - if(t[n] !== e[n]) - { - r = t[n], i = e[n]; - break; + Object.defineProperty(h.prototype, "parent", { + get: function() { + if (this instanceof h) + return this.buffer; } - return r < i ? - 1 : i < r ? 1 : 0; - }, h.isEncoding = function (t) - { - switch(String(t).toLowerCase()) - { - case "hex": - case "utf8": - case "utf-8": - case "ascii": - case "latin1": - case "binary": - case "base64": - case "ucs2": - case "ucs-2": - case "utf16le": - case "utf-16le": - return !0; - default: - return !1; - } - }, h.concat = function (t,e) - { - if(!Array.isArray(t)) - throw new TypeError('"list" argument must be an Array of Buffers'); - if(0 === t.length) - return h.alloc(0); - var r; - if(void 0 === e) - for(r = e = 0; r < t.length; ++r) - e += t[r].length; - var i = h.allocUnsafe(e), n = 0; - for(r = 0; r < t.length; ++r) - { - var s = t[r]; - if(ArrayBuffer.isView(s) && (s = h.from(s)), !h.isBuffer(s)) - throw new TypeError('"list" argument must be an Array of Buffers'); - s.copy(i, n), n += s.length; - } - return i; - }, h.byteLength = l, h.prototype._isBuffer = !0, h.prototype.swap16 = function () - { - var t = this.length; - if(0 != t % 2) - throw new RangeError("Buffer size must be a multiple of 16-bits"); - for(var e = 0; e < t; e += 2) - f(this, e, e + 1); - return this; - }, h.prototype.swap32 = function () - { - var t = this.length; - if(0 != t % 4) - throw new RangeError("Buffer size must be a multiple of 32-bits"); - for(var e = 0; e < t; e += 4) - f(this, e, e + 3), f(this, e + 1, e + 2); - return this; - }, h.prototype.swap64 = function () - { - var t = this.length; - if(0 != t % 8) - throw new RangeError("Buffer size must be a multiple of 64-bits"); - for(var e = 0; e < t; e += 8) - f(this, e, e + 7), f(this, e + 1, e + 6), f(this, e + 2, e + 5), f(this, e + 3, e + 4); - return this; - }, h.prototype.toLocaleString = h.prototype.toString = function () - { - var t = this.length; - return 0 === t ? "" : 0 === arguments.length ? p(this, 0, t) : function (t,e,r) - { - var i = !1; - if((void 0 === e || e < 0) && (e = 0), e > this.length) - return ""; - if((void 0 === r || r > this.length) && (r = this.length), r <= 0) - return ""; - if((r >>>= 0) <= (e >>>= 0)) - return ""; - for(t || (t = "utf8"); ; ) - switch(t) - { + }), Object.defineProperty(h.prototype, "offset", { + get: function() { + if (this instanceof h) + return this.byteOffset; + } + }), $jscomp.initSymbol(), $jscomp.initSymbol(), $jscomp.initSymbol(), "undefined" != typeof Symbol && Symbol.species && h[Symbol.species] === h && ($jscomp.initSymbol(), + Object.defineProperty(h, Symbol.species, { value: null, configurable: !0, enumerable: !1, writable: !1 })), h.poolSize = 8192, h.from = function(t, e, r) { + return i(t, e, r); + }, h.prototype.__proto__ = Uint8Array.prototype, h.__proto__ = Uint8Array, h.alloc = function(t, e, r) { + return s(t), t = t <= 0 ? n(t) : void 0 !== e ? "string" == typeof r ? n(t).fill(e, r) : n(t).fill(e) : n(t); + }, h.allocUnsafe = function(t) { + return o(t); + }, h.allocUnsafeSlow = function(t) { + return o(t); + }, h.isBuffer = function(t) { + return null != t && !0 === t._isBuffer; + }, h.compare = function(t, e) { + if (!h.isBuffer(t) || !h.isBuffer(e)) + throw new TypeError("Arguments must be Buffers"); + if (t === e) + return 0; + for (var r = t.length, i = e.length, n = 0, s = Math.min(r, i); n < s; ++n) + if (t[n] !== e[n]) { + r = t[n], i = e[n]; + break; + } + return r < i ? - 1 : i < r ? 1 : 0; + }, h.isEncoding = function(t) { + switch (String(t).toLowerCase()) { case "hex": - for(t = e, e = r, r = this.length, (!t || t < 0) && (t = 0), (!e || e < 0 || r < e) && (e = r), i = "", r = t; r < e; ++r) - i = (t = i) + (i = (i = this[r]) < 16 ? "0" + i.toString(16) : i.toString(16)); - return i; case "utf8": case "utf-8": - return p(this, e, r); case "ascii": - for(t = "", r = Math.min(this.length, r); e < r; ++e) - t += String.fromCharCode(127 & this[e]); - return t; case "latin1": case "binary": - for(t = "", r = Math.min(this.length, r); e < r; ++e) - t += String.fromCharCode(this[e]); - return t; case "base64": - return e = 0 === e && r === this.length ? I.fromByteArray(this) : I.fromByteArray(this.slice(e, r)); case "ucs2": case "ucs-2": case "utf16le": case "utf-16le": - for(e = this.slice(e, r), r = "", t = 0; t < e.length; t += 2) - r += String.fromCharCode(e[t] + 256 * e[t + 1]); - return r; + return !0; default: - if(i) - throw new TypeError("Unknown encoding: " + t); - t = (t + "").toLowerCase(), i = !0; + return !1; } - }.apply(this, arguments); - }, h.prototype.equals = function (t) - { - if(!h.isBuffer(t)) - throw new TypeError("Argument must be a Buffer"); - return this === t || 0 === h.compare(this, t); - }, h.prototype.inspect = function () - { - var t = "", e = r.INSPECT_MAX_BYTES; - return 0 < this.length && (t = this.toString("hex", 0, e).match(/.{2}/g).join(" "), this.length > e && (t += " ... ")), ""; - }, h.prototype.compare = function (t,e,r,i,n) - { - if(!h.isBuffer(t)) - throw new TypeError("Argument must be a Buffer"); - if(void 0 === e && (e = 0), void 0 === r && (r = t ? t.length : 0), void 0 === i && (i = 0), void 0 === n && (n = this.length), - e < 0 || r > t.length || i < 0 || n > this.length) - throw new RangeError("out of range index"); - if(n <= i && r <= e) - return 0; - if(n <= i) - return - 1; - if(r <= e) - return 1; - if(this === t) - return 0; - var s = (n >>>= 0) - (i >>>= 0), o = (r >>>= 0) - (e >>>= 0), a = Math.min(s, o); - for(i = this.slice(i, n), t = t.slice(e, r), e = 0; e < a; ++e) - if(i[e] !== t[e]) - { - s = i[e], o = t[e]; - break; - } - return s < o ? - 1 : o < s ? 1 : 0; - }, h.prototype.includes = function (t,e,r) - { - return - 1 !== this.indexOf(t, e, r); - }, h.prototype.indexOf = function (t,e,r) - { - return c(this, t, e, r, !0); - }, h.prototype.lastIndexOf = function (t,e,r) - { - return c(this, t, e, r, !1); - }, h.prototype.write = function (t,e,r,i) - { - if(void 0 === e) - i = "utf8", r = this.length, e = 0; - else - if(void 0 === r && "string" == typeof e) - i = e, r = this.length, e = 0; - else - { - if(!isFinite(e)) - throw Error("Buffer.write(string, encoding, offset[, length]) is no longer supported"); - e >>>= 0, isFinite(r) ? (r >>>= 0, void 0 === i && (i = "utf8")) : (i = r, r = void 0); - } - var n = this.length - e; - if((void 0 === r || n < r) && (r = n), 0 < t.length && (r < 0 || e < 0) || e > this.length) - throw new RangeError("Attempt to write outside buffer bounds"); - for(i || (i = "utf8"), n = !1; ; ) - switch(i) - { - case "hex": - t: - { - for(e = Number(e) || 0, i = this.length - e, r ? i < (r = Number(r)) && (r = i) : r = i, (i = t.length) / 2 < r && (r = i / 2), - i = 0; i < r; ++i) - { - if((n = parseInt(t.substr(2 * i, 2), 16)) != n) - { - t = i; - break t; - } - this[e + i] = n; + }, h.concat = function(t, e) { + if (!Array.isArray(t)) + throw new TypeError('"list" argument must be an Array of Buffers'); + if (0 === t.length) + return h.alloc(0); + var r; + if (void 0 === e) + for (r = e = 0; r < t.length; ++r) + e += t[r].length; + var i = h.allocUnsafe(e), n = 0; + for (r = 0; r < t.length; ++r) { + var s = t[r]; + if (ArrayBuffer.isView(s) && (s = h.from(s)), !h.isBuffer(s)) + throw new TypeError('"list" argument must be an Array of Buffers'); + s.copy(i, n), n += s.length; + } + return i; + }, h.byteLength = l, h.prototype._isBuffer = !0, h.prototype.swap16 = function() { + var t = this.length; + if (0 != t % 2) + throw new RangeError("Buffer size must be a multiple of 16-bits"); + for (var e = 0; e < t; e += 2) + f(this, e, e + 1); + return this; + }, h.prototype.swap32 = function() { + var t = this.length; + if (0 != t % 4) + throw new RangeError("Buffer size must be a multiple of 32-bits"); + for (var e = 0; e < t; e += 4) + f(this, e, e + 3), f(this, e + 1, e + 2); + return this; + }, h.prototype.swap64 = function() { + var t = this.length; + if (0 != t % 8) + throw new RangeError("Buffer size must be a multiple of 64-bits"); + for (var e = 0; e < t; e += 8) + f(this, e, e + 7), f(this, e + 1, e + 6), f(this, e + 2, e + 5), f(this, e + 3, e + 4); + return this; + }, h.prototype.toLocaleString = h.prototype.toString = function() { + var t = this.length; + return 0 === t ? "" : 0 === arguments.length ? p(this, 0, t) : function(t, e, r) { + var i = !1; + if ((void 0 === e || e < 0) && (e = 0), e > this.length) + return ""; + if ((void 0 === r || r > this.length) && (r = this.length), r <= 0) + return ""; + if ((r >>>= 0) <= (e >>>= 0)) + return ""; + for (t || (t = "utf8"); ;) + switch (t) { + case "hex": + for (t = e, e = r, r = this.length, (!t || t < 0) && (t = 0), (!e || e < 0 || r < e) && (e = r), i = "", r = t; r < e; ++r) + i = (t = i) + (i = (i = this[r]) < 16 ? "0" + i.toString(16) : i.toString(16)); + return i; + case "utf8": + case "utf-8": + return p(this, e, r); + case "ascii": + for (t = "", r = Math.min(this.length, r); e < r; ++e) + t += String.fromCharCode(127 & this[e]); + return t; + case "latin1": + case "binary": + for (t = "", r = Math.min(this.length, r); e < r; ++e) + t += String.fromCharCode(this[e]); + return t; + case "base64": + return e = 0 === e && r === this.length ? I.fromByteArray(this) : I.fromByteArray(this.slice(e, r)); + case "ucs2": + case "ucs-2": + case "utf16le": + case "utf-16le": + for (e = this.slice(e, r), r = "", t = 0; t < e.length; t += 2) + r += String.fromCharCode(e[t] + 256 * e[t + 1]); + return r; + default: + if (i) + throw new TypeError("Unknown encoding: " + t); + t = (t + "").toLowerCase(), i = !0; } - t = i; + }.apply(this, arguments); + }, h.prototype.equals = function(t) { + if (!h.isBuffer(t)) + throw new TypeError("Argument must be a Buffer"); + return this === t || 0 === h.compare(this, t); + }, h.prototype.inspect = function() { + var t = "", e = r.INSPECT_MAX_BYTES; + return 0 < this.length && (t = this.toString("hex", 0, e).match(/.{2}/g).join(" "), this.length > e && (t += " ... ")), ""; + }, h.prototype.compare = function(t, e, r, i, n) { + if (!h.isBuffer(t)) + throw new TypeError("Argument must be a Buffer"); + if (void 0 === e && (e = 0), void 0 === r && (r = t ? t.length : 0), void 0 === i && (i = 0), void 0 === n && (n = this.length), + e < 0 || r > t.length || i < 0 || n > this.length) + throw new RangeError("out of range index"); + if (n <= i && r <= e) + return 0; + if (n <= i) + return - 1; + if (r <= e) + return 1; + if (this === t) + return 0; + var s = (n >>>= 0) - (i >>>= 0), o = (r >>>= 0) - (e >>>= 0), a = Math.min(s, o); + for (i = this.slice(i, n), t = t.slice(e, r), e = 0; e < a; ++e) + if (i[e] !== t[e]) { + s = i[e], o = t[e]; + break; } - return t; - case "utf8": - case "utf-8": - return E(v(t, this.length - e), this, e, r); - case "ascii": - return E(M(t), this, e, r); - case "latin1": - case "binary": - return E(M(t), this, e, r); - case "base64": - return E(I.toByteArray(w(t)), this, e, r); - case "ucs2": - case "ucs-2": - case "utf16le": - case "utf-16le": - i = t, n = this.length - e; - for(var s = [], o = 0; o < i.length && !((n -= 2) < 0); ++o) - { - var a = i.charCodeAt(o); - t = a >> 8, a %= 256, s.push(a), s.push(t); + return s < o ? - 1 : o < s ? 1 : 0; + }, h.prototype.includes = function(t, e, r) { + return - 1 !== this.indexOf(t, e, r); + }, h.prototype.indexOf = function(t, e, r) { + return c(this, t, e, r, !0); + }, h.prototype.lastIndexOf = function(t, e, r) { + return c(this, t, e, r, !1); + }, h.prototype.write = function(t, e, r, i) { + if (void 0 === e) + i = "utf8", r = this.length, e = 0; + else + if (void 0 === r && "string" == typeof e) + i = e, r = this.length, e = 0; + else { + if (!isFinite(e)) + throw Error("Buffer.write(string, encoding, offset[, length]) is no longer supported"); + e >>>= 0, isFinite(r) ? (r >>>= 0, void 0 === i && (i = "utf8")) : (i = r, r = void 0); } - return E(s, this, e, r); - default: - if(n) - throw new TypeError("Unknown encoding: " + i); - i = ("" + i).toLowerCase(), n = !0; - } - }, h.prototype.toJSON = function () - { - return {type:"Buffer", data:Array.prototype.slice.call(this._arr || this, 0)}; - }; + var n = this.length - e; + if ((void 0 === r || n < r) && (r = n), 0 < t.length && (r < 0 || e < 0) || e > this.length) + throw new RangeError("Attempt to write outside buffer bounds"); + for (i || (i = "utf8"), n = !1; ;) + switch (i) { + case "hex": + t: + { + for (e = Number(e) || 0, i = this.length - e, r ? i < (r = Number(r)) && (r = i) : r = i, (i = t.length) / 2 < r && (r = i / 2), + i = 0; i < r; ++i) { + if ((n = parseInt(t.substr(2 * i, 2), 16)) != n) { + t = i; + break t; + } + this[e + i] = n; + } + t = i; + } + return t; + case "utf8": + case "utf-8": + return E(v(t, this.length - e), this, e, r); + case "ascii": + return E(M(t), this, e, r); + case "latin1": + case "binary": + return E(M(t), this, e, r); + case "base64": + return E(I.toByteArray(w(t)), this, e, r); + case "ucs2": + case "ucs-2": + case "utf16le": + case "utf-16le": + i = t, n = this.length - e; + for (var s = [], o = 0; o < i.length && !((n -= 2) < 0); ++o) { + var a = i.charCodeAt(o); + t = a >> 8, a %= 256, s.push(a), s.push(t); + } + return E(s, this, e, r); + default: + if (n) + throw new TypeError("Unknown encoding: " + i); + i = ("" + i).toLowerCase(), n = !0; + } + }, h.prototype.toJSON = function() { + return { type: "Buffer", data: Array.prototype.slice.call(this._arr || this, 0) }; + }; var x = 4096; - h.prototype.slice = function (t,e) - { + h.prototype.slice = function(t, e) { var r = this.length; return (t = ~~t) < 0 ? (t += r) < 0 && (t = 0) : r < t && (t = r), (e = void 0 === e ? r : ~~e) < 0 ? (e += r) < 0 && (e = 0) : r < e && (e = r), - e < t && (e = t), (r = this.subarray(t, e)).__proto__ = h.prototype, r; - }, h.prototype.readUIntLE = function (t,e,r) - { + e < t && (e = t), (r = this.subarray(t, e)).__proto__ = h.prototype, r; + }, h.prototype.readUIntLE = function(t, e, r) { t >>>= 0, e >>>= 0, r || m(t, e, this.length), r = this[t]; - for(var i = 1, n = 0; ++n < e && (i *= 256); ) + for (var i = 1, n = 0; ++n < e && (i *= 256);) r += this[t + n] * i; return r; - }, h.prototype.readUIntBE = function (t,e,r) - { + }, h.prototype.readUIntBE = function(t, e, r) { t >>>= 0, e >>>= 0, r || m(t, e, this.length), r = this[t + --e]; - for(var i = 1; 0 < e && (i *= 256); ) + for (var i = 1; 0 < e && (i *= 256);) r += this[t + --e] * i; return r; - }, h.prototype.readUInt8 = function (t,e) - { + }, h.prototype.readUInt8 = function(t, e) { return t >>>= 0, e || m(t, 1, this.length), this[t]; - }, h.prototype.readUInt16LE = function (t,e) - { + }, h.prototype.readUInt16LE = function(t, e) { return t >>>= 0, e || m(t, 2, this.length), this[t] | this[t + 1] << 8; - }, h.prototype.readUInt16BE = function (t,e) - { + }, h.prototype.readUInt16BE = function(t, e) { return t >>>= 0, e || m(t, 2, this.length), this[t] << 8 | this[t + 1]; - }, h.prototype.readUInt32LE = function (t,e) - { + }, h.prototype.readUInt32LE = function(t, e) { return t >>>= 0, e || m(t, 4, this.length), (this[t] | this[t + 1] << 8 | this[t + 2] << 16) + 16777216 * this[t + 3]; - }, h.prototype.readUInt32BE = function (t,e) - { + }, h.prototype.readUInt32BE = function(t, e) { return t >>>= 0, e || m(t, 4, this.length), 16777216 * this[t] + (this[t + 1] << 16 | this[t + 2] << 8 | this[t + 3]); - }, h.prototype.readIntLE = function (t,e,r) - { + }, h.prototype.readIntLE = function(t, e, r) { t >>>= 0, e >>>= 0, r || m(t, e, this.length), r = this[t]; - for(var i = 1, n = 0; ++n < e && (i *= 256); ) + for (var i = 1, n = 0; ++n < e && (i *= 256);) r += this[t + n] * i; return 128 * i <= r && (r -= Math.pow(2, 8 * e)), r; - }, h.prototype.readIntBE = function (t,e,r) - { + }, h.prototype.readIntBE = function(t, e, r) { t >>>= 0, e >>>= 0, r || m(t, e, this.length), r = e; - for(var i = 1, n = this[t + --r]; 0 < r && (i *= 256); ) + for (var i = 1, n = this[t + --r]; 0 < r && (i *= 256);) n += this[t + --r] * i; return 128 * i <= n && (n -= Math.pow(2, 8 * e)), n; - }, h.prototype.readInt8 = function (t,e) - { - return t >>>= 0, e || m(t, 1, this.length), 128 & this[t] ? - 1 * (255 - this[t] + 1) : this[t]; - }, h.prototype.readInt16LE = function (t,e) - { + }, h.prototype.readInt8 = function(t, e) { + return t >>>= 0, e || m(t, 1, this.length), 128 & this[t] ? - 1 * (255 - this[t] + 1) : this[t]; + }, h.prototype.readInt16LE = function(t, e) { t >>>= 0, e || m(t, 2, this.length); var r = this[t] | this[t + 1] << 8; return 32768 & r ? 4294901760 | r : r; - }, h.prototype.readInt16BE = function (t,e) - { + }, h.prototype.readInt16BE = function(t, e) { t >>>= 0, e || m(t, 2, this.length); var r = this[t + 1] | this[t] << 8; return 32768 & r ? 4294901760 | r : r; - }, h.prototype.readInt32LE = function (t,e) - { + }, h.prototype.readInt32LE = function(t, e) { return t >>>= 0, e || m(t, 4, this.length), this[t] | this[t + 1] << 8 | this[t + 2] << 16 | this[t + 3] << 24; - }, h.prototype.readInt32BE = function (t,e) - { + }, h.prototype.readInt32BE = function(t, e) { return t >>>= 0, e || m(t, 4, this.length), this[t] << 24 | this[t + 1] << 16 | this[t + 2] << 8 | this[t + 3]; - }, h.prototype.readFloatLE = function (t,e) - { + }, h.prototype.readFloatLE = function(t, e) { return t >>>= 0, e || m(t, 4, this.length), A.read(this, t, !0, 23, 4); - }, h.prototype.readFloatBE = function (t,e) - { + }, h.prototype.readFloatBE = function(t, e) { return t >>>= 0, e || m(t, 4, this.length), A.read(this, t, !1, 23, 4); - }, h.prototype.readDoubleLE = function (t,e) - { + }, h.prototype.readDoubleLE = function(t, e) { return t >>>= 0, e || m(t, 8, this.length), A.read(this, t, !0, 52, 8); - }, h.prototype.readDoubleBE = function (t,e) - { + }, h.prototype.readDoubleBE = function(t, e) { return t >>>= 0, e || m(t, 8, this.length), A.read(this, t, !1, 52, 8); - }, h.prototype.writeUIntLE = function (t,e,r,i) - { - t = + t, e >>>= 0, r >>>= 0, i || _(this, t, e, r, Math.pow(2, 8 * r) - 1, 0), i = 1; + }, h.prototype.writeUIntLE = function(t, e, r, i) { + t = + t, e >>>= 0, r >>>= 0, i || _(this, t, e, r, Math.pow(2, 8 * r) - 1, 0), i = 1; var n = 0; - for(this[e] = 255 & t; ++n < r && (i *= 256); ) + for (this[e] = 255 & t; ++n < r && (i *= 256);) this[e + n] = t / i & 255; return e + r; - }, h.prototype.writeUIntBE = function (t,e,r,i) - { - t = + t, e >>>= 0, r >>>= 0, i || _(this, t, e, r, Math.pow(2, 8 * r) - 1, 0); + }, h.prototype.writeUIntBE = function(t, e, r, i) { + t = + t, e >>>= 0, r >>>= 0, i || _(this, t, e, r, Math.pow(2, 8 * r) - 1, 0); var n = 1; - for(this[e + (i = r - 1)] = 255 & t; 0 <= --i && (n *= 256); ) + for (this[e + (i = r - 1)] = 255 & t; 0 <= --i && (n *= 256);) this[e + i] = t / n & 255; return e + r; - }, h.prototype.writeUInt8 = function (t,e,r) - { - return t = + t, e >>>= 0, r || _(this, t, e, 1, 255, 0), this[e] = 255 & t, e + 1; - }, h.prototype.writeUInt16LE = function (t,e,r) - { - return t = + t, e >>>= 0, r || _(this, t, e, 2, 65535, 0), this[e] = 255 & t, this[e + 1] = t >>> 8, e + 2; - }, h.prototype.writeUInt16BE = function (t,e,r) - { - return t = + t, e >>>= 0, r || _(this, t, e, 2, 65535, 0), this[e] = t >>> 8, this[e + 1] = 255 & t, e + 2; - }, h.prototype.writeUInt32LE = function (t,e,r) - { - return t = + t, e >>>= 0, r || _(this, t, e, 4, 4294967295, 0), this[e + 3] = t >>> 24, this[e + 2] = t >>> 16, this[e + 1] = t >>> 8, - this[e] = 255 & t, e + 4; - }, h.prototype.writeUInt32BE = function (t,e,r) - { - return t = + t, e >>>= 0, r || _(this, t, e, 4, 4294967295, 0), this[e] = t >>> 24, this[e + 1] = t >>> 16, this[e + 2] = t >>> 8, - this[e + 3] = 255 & t, e + 4; - }, h.prototype.writeIntLE = function (t,e,r,i) - { - t = + t, e >>>= 0, i || _(this, t, e, r, (i = Math.pow(2, 8 * r - 1)) - 1, - i); + }, h.prototype.writeUInt8 = function(t, e, r) { + return t = + t, e >>>= 0, r || _(this, t, e, 1, 255, 0), this[e] = 255 & t, e + 1; + }, h.prototype.writeUInt16LE = function(t, e, r) { + return t = + t, e >>>= 0, r || _(this, t, e, 2, 65535, 0), this[e] = 255 & t, this[e + 1] = t >>> 8, e + 2; + }, h.prototype.writeUInt16BE = function(t, e, r) { + return t = + t, e >>>= 0, r || _(this, t, e, 2, 65535, 0), this[e] = t >>> 8, this[e + 1] = 255 & t, e + 2; + }, h.prototype.writeUInt32LE = function(t, e, r) { + return t = + t, e >>>= 0, r || _(this, t, e, 4, 4294967295, 0), this[e + 3] = t >>> 24, this[e + 2] = t >>> 16, this[e + 1] = t >>> 8, + this[e] = 255 & t, e + 4; + }, h.prototype.writeUInt32BE = function(t, e, r) { + return t = + t, e >>>= 0, r || _(this, t, e, 4, 4294967295, 0), this[e] = t >>> 24, this[e + 1] = t >>> 16, this[e + 2] = t >>> 8, + this[e + 3] = 255 & t, e + 4; + }, h.prototype.writeIntLE = function(t, e, r, i) { + t = + t, e >>>= 0, i || _(this, t, e, r, (i = Math.pow(2, 8 * r - 1)) - 1, - i); var n = 1, s = i = 0; - for(this[e] = 255 & t; ++i < r && (n *= 256); ) + for (this[e] = 255 & t; ++i < r && (n *= 256);) t < 0 && 0 === s && 0 !== this[e + i - 1] && (s = 1), this[e + i] = (t / n >> 0) - s & 255; return e + r; - }, h.prototype.writeIntBE = function (t,e,r,i) - { - t = + t, e >>>= 0, i || _(this, t, e, r, (i = Math.pow(2, 8 * r - 1)) - 1, - i); + }, h.prototype.writeIntBE = function(t, e, r, i) { + t = + t, e >>>= 0, i || _(this, t, e, r, (i = Math.pow(2, 8 * r - 1)) - 1, - i); var n = 1, s = 0; - for(this[e + (i = r - 1)] = 255 & t; 0 <= --i && (n *= 256); ) + for (this[e + (i = r - 1)] = 255 & t; 0 <= --i && (n *= 256);) t < 0 && 0 === s && 0 !== this[e + i + 1] && (s = 1), this[e + i] = (t / n >> 0) - s & 255; return e + r; - }, h.prototype.writeInt8 = function (t,e,r) - { - return t = + t, e >>>= 0, r || _(this, t, e, 1, 127, - 128), t < 0 && (t = 255 + t + 1), this[e] = 255 & t, e + 1; - }, h.prototype.writeInt16LE = function (t,e,r) - { - return t = + t, e >>>= 0, r || _(this, t, e, 2, 32767, - 32768), this[e] = 255 & t, this[e + 1] = t >>> 8, e + 2; - }, h.prototype.writeInt16BE = function (t,e,r) - { - return t = + t, e >>>= 0, r || _(this, t, e, 2, 32767, - 32768), this[e] = t >>> 8, this[e + 1] = 255 & t, e + 2; - }, h.prototype.writeInt32LE = function (t,e,r) - { - return t = + t, e >>>= 0, r || _(this, t, e, 4, 2147483647, - 2147483648), this[e] = 255 & t, this[e + 1] = t >>> 8, this[e + 2] = t >>> 16, - this[e + 3] = t >>> 24, e + 4; - }, h.prototype.writeInt32BE = function (t,e,r) - { - return t = + t, e >>>= 0, r || _(this, t, e, 4, 2147483647, - 2147483648), t < 0 && (t = 4294967295 + t + 1), this[e] = t >>> 24, - this[e + 1] = t >>> 16, this[e + 2] = t >>> 8, this[e + 3] = 255 & t, e + 4; - }, h.prototype.writeFloatLE = function (t,e,r) - { + }, h.prototype.writeInt8 = function(t, e, r) { + return t = + t, e >>>= 0, r || _(this, t, e, 1, 127, - 128), t < 0 && (t = 255 + t + 1), this[e] = 255 & t, e + 1; + }, h.prototype.writeInt16LE = function(t, e, r) { + return t = + t, e >>>= 0, r || _(this, t, e, 2, 32767, - 32768), this[e] = 255 & t, this[e + 1] = t >>> 8, e + 2; + }, h.prototype.writeInt16BE = function(t, e, r) { + return t = + t, e >>>= 0, r || _(this, t, e, 2, 32767, - 32768), this[e] = t >>> 8, this[e + 1] = 255 & t, e + 2; + }, h.prototype.writeInt32LE = function(t, e, r) { + return t = + t, e >>>= 0, r || _(this, t, e, 4, 2147483647, - 2147483648), this[e] = 255 & t, this[e + 1] = t >>> 8, this[e + 2] = t >>> 16, + this[e + 3] = t >>> 24, e + 4; + }, h.prototype.writeInt32BE = function(t, e, r) { + return t = + t, e >>>= 0, r || _(this, t, e, 4, 2147483647, - 2147483648), t < 0 && (t = 4294967295 + t + 1), this[e] = t >>> 24, + this[e + 1] = t >>> 16, this[e + 2] = t >>> 8, this[e + 3] = 255 & t, e + 4; + }, h.prototype.writeFloatLE = function(t, e, r) { return b(this, t, e, !0, r); - }, h.prototype.writeFloatBE = function (t,e,r) - { + }, h.prototype.writeFloatBE = function(t, e, r) { return b(this, t, e, !1, r); - }, h.prototype.writeDoubleLE = function (t,e,r) - { + }, h.prototype.writeDoubleLE = function(t, e, r) { return y(this, t, e, !0, r); - }, h.prototype.writeDoubleBE = function (t,e,r) - { + }, h.prototype.writeDoubleBE = function(t, e, r) { return y(this, t, e, !1, r); - }, h.prototype.copy = function (t,e,r,i) - { - if(!h.isBuffer(t)) + }, h.prototype.copy = function(t, e, r, i) { + if (!h.isBuffer(t)) throw new TypeError("argument should be a Buffer"); - if(r || (r = 0), i || 0 === i || (i = this.length), e >= t.length && (e = t.length), e || (e = 0), 0 < i && i < r && (i = r), - i === r || 0 === t.length || 0 === this.length) + if (r || (r = 0), i || 0 === i || (i = this.length), e >= t.length && (e = t.length), e || (e = 0), 0 < i && i < r && (i = r), + i === r || 0 === t.length || 0 === this.length) return 0; - if(e < 0) + if (e < 0) throw new RangeError("targetStart out of bounds"); - if(r < 0 || r >= this.length) + if (r < 0 || r >= this.length) throw new RangeError("Index out of range"); - if(i < 0) + if (i < 0) throw new RangeError("sourceEnd out of bounds"); i > this.length && (i = this.length), t.length - e < i - r && (i = t.length - e + r); var n = i - r; - if(this === t && "function" == typeof Uint8Array.prototype.copyWithin) + if (this === t && "function" == typeof Uint8Array.prototype.copyWithin) this.copyWithin(e, r, i); else - if(this === t && r < e && e < i) - for(i = n - 1; 0 <= i; --i) + if (this === t && r < e && e < i) + for (i = n - 1; 0 <= i; --i) t[i + e] = this[i + r]; else Uint8Array.prototype.set.call(t, this.subarray(r, i), e); return n; - }, h.prototype.fill = function (t,e,r,i) - { - if("string" == typeof t) - { - if("string" == typeof e ? (i = e, e = 0, r = this.length) : "string" == typeof r && (i = r, r = this.length), void 0 !== i && "string" != typeof i) + }, h.prototype.fill = function(t, e, r, i) { + if ("string" == typeof t) { + if ("string" == typeof e ? (i = e, e = 0, r = this.length) : "string" == typeof r && (i = r, r = this.length), void 0 !== i && "string" != typeof i) throw new TypeError("encoding must be a string"); - if("string" == typeof i && !h.isEncoding(i)) + if ("string" == typeof i && !h.isEncoding(i)) throw new TypeError("Unknown encoding: " + i); - if(1 === t.length) - { + if (1 === t.length) { var n = t.charCodeAt(0); ("utf8" === i && n < 128 || "latin1" === i) && (t = n); } } else "number" == typeof t && (t &= 255); - if(e < 0 || this.length < e || this.length < r) + if (e < 0 || this.length < e || this.length < r) throw new RangeError("Out of range index"); - if(r <= e) + if (r <= e) return this; - if(e >>>= 0, r = void 0 === r ? this.length : r >>> 0, t || (t = 0), "number" == typeof t) - for(i = e; i < r; ++i) + if (e >>>= 0, r = void 0 === r ? this.length : r >>> 0, t || (t = 0), "number" == typeof t) + for (i = e; i < r; ++i) this[i] = t; - else - { + else { var s = (n = h.isBuffer(t) ? t : new h(t, i)).length; - if(0 === s) + if (0 === s) throw new TypeError('The value "' + t + '" is invalid for argument "value"'); - for(i = 0; i < r - e; ++i) + for (i = 0; i < r - e; ++i) this[i + e] = n[i % s]; } return this; }; var L = /[^+/0-9A-Za-z-_]/g; - }, {"base64-js":1, ieee754:6}], 4:[function (t,e,r) - { - (function (t) - { - r.isArray = function (t) - { + }, { "base64-js": 1, ieee754: 6 }], 4: [function(t, e, r) { + (function(t) { + r.isArray = function(t) { return Array.isArray ? Array.isArray(t) : "[object Array]" === Object.prototype.toString.call(t); - }, r.isBoolean = function (t) - { + }, r.isBoolean = function(t) { return "boolean" == typeof t; - }, r.isNull = function (t) - { + }, r.isNull = function(t) { return null === t; - }, r.isNullOrUndefined = function (t) - { + }, r.isNullOrUndefined = function(t) { return null == t; - }, r.isNumber = function (t) - { + }, r.isNumber = function(t) { return "number" == typeof t; - }, r.isString = function (t) - { + }, r.isString = function(t) { return "string" == typeof t; - }, r.isSymbol = function (t) - { + }, r.isSymbol = function(t) { return "symbol" == typeof t; - }, r.isUndefined = function (t) - { + }, r.isUndefined = function(t) { return void 0 === t; - }, r.isRegExp = function (t) - { + }, r.isRegExp = function(t) { return "[object RegExp]" === Object.prototype.toString.call(t); - }, r.isObject = function (t) - { + }, r.isObject = function(t) { return "object" == typeof t && null !== t; - }, r.isDate = function (t) - { + }, r.isDate = function(t) { return "[object Date]" === Object.prototype.toString.call(t); - }, r.isError = function (t) - { + }, r.isError = function(t) { return "[object Error]" === Object.prototype.toString.call(t) || t instanceof Error; - }, r.isFunction = function (t) - { + }, r.isFunction = function(t) { return "function" == typeof t; - }, r.isPrimitive = function (t) - { + }, r.isPrimitive = function(t) { return null === t || "boolean" == typeof t || "number" == typeof t || "string" == typeof t || "symbol" == typeof t || void 0 === t; }, r.isBuffer = t.isBuffer; - }).call(this, {isBuffer:t("../../is-buffer/index.js")}); - }, {"../../is-buffer/index.js":8}], 5:[function (t,e,r) - { - -function o() - { + }).call(this, { isBuffer: t("../../is-buffer/index.js") }); + }, { "../../is-buffer/index.js": 8 }], 5: [function(t, e, r) { + + function o() { this._events && Object.prototype.hasOwnProperty.call(this, "_events") || (this._events = l(null), this._eventsCount = 0), this._maxListeners = this._maxListeners || void 0; }; - -function i(t,e,r,i) - { + + function i(t, e, r, i) { var n; - if("function" != typeof r) + if ("function" != typeof r) throw new TypeError('"listener" argument must be a function'); - if(n = t._events) - { + if (n = t._events) { n.newListener && (t.emit("newListener", e, r.listener ? r.listener : r), n = t._events); var s = n[e]; } else n = t._events = l(null), t._eventsCount = 0; return s ? ("function" == typeof s ? s = n[e] = i ? [r, s] : [s, r] : i ? s.unshift(r) : s.push(r), s.warned || (r = void 0 === t._maxListeners ? o.defaultMaxListeners : t._maxListeners) && 0 < r && s.length > r && (s.warned = !0, - (r = Error("Possible EventEmitter memory leak detected. " + s.length + ' "' + String(e) + '" listeners added. Use emitter.setMaxListeners() to increase limit.')).name = "MaxListenersExceededWarning", - r.emitter = t, r.type = e, r.count = s.length, "object" == typeof console && console.warn && console.warn("%s: %s", r.name, - r.message))) : (n[e] = r, ++t._eventsCount), t; + (r = Error("Possible EventEmitter memory leak detected. " + s.length + ' "' + String(e) + '" listeners added. Use emitter.setMaxListeners() to increase limit.')).name = "MaxListenersExceededWarning", + r.emitter = t, r.type = e, r.count = s.length, "object" == typeof console && console.warn && console.warn("%s: %s", r.name, + r.message))) : (n[e] = r, ++t._eventsCount), t; }; - -function n() - { - if(!this.fired) - switch(this.target.removeListener(this.type, this.wrapFn), this.fired = !0, arguments.length) - { + + function n() { + if (!this.fired) + switch (this.target.removeListener(this.type, this.wrapFn), this.fired = !0, arguments.length) { case 0: return this.listener.call(this.target); case 1: @@ -1053,678 +884,565 @@ function n() case 3: return this.listener.call(this.target, arguments[0], arguments[1], arguments[2]); default: - for(var t = Array(arguments.length), e = 0; e < t.length; ++e) + for (var t = Array(arguments.length), e = 0; e < t.length; ++e) t[e] = arguments[e]; this.listener.apply(this.target, t); } }; - -function s(t,e,r) - { - return t = {fired:!1, wrapFn:void 0, target:t, type:e, listener:r}, (e = c.call(n, t)).listener = r, t.wrapFn = e; + + function s(t, e, r) { + return t = { fired: !1, wrapFn: void 0, target: t, type: e, listener: r }, (e = c.call(n, t)).listener = r, t.wrapFn = e; }; - -function a(t,e,r) - { - if(!(t = t._events)) + + function a(t, e, r) { + if (!(t = t._events)) return []; - if(!(e = t[e])) + if (!(e = t[e])) return []; - if("function" == typeof e) + if ("function" == typeof e) return r ? [e.listener || e] : [e]; - if(r) - for(r = Array(e.length), t = 0; t < r.length; ++t) + if (r) + for (r = Array(e.length), t = 0; t < r.length; ++t) r[t] = e[t].listener || e[t]; else r = u(e, e.length); return r; }; - -function h(t) - { + + function h(t) { var e = this._events; - if(e) - { - if("function" == typeof (t = e[t])) + if (e) { + if ("function" == typeof (t = e[t])) return 1; - if(t) + if (t) return t.length; } return 0; }; - -function u(t,e) - { - for(var r = Array(e), i = 0; i < e; ++i) + + function u(t, e) { + for (var r = Array(e), i = 0; i < e; ++i) r[i] = t[i]; return r; }; - var l = Object.create || function (t) - { - var e = function () - { + var l = Object.create || function(t) { + var e = function() { }; return e.prototype = t, new e; - }, f = Object.keys || function (t) - { + }, f = Object.keys || function(t) { var e, r = []; - for(e in t) + for (e in t) Object.prototype.hasOwnProperty.call(t, e) && r.push(e); return e; - }, c = Function.prototype.bind || function (t) - { + }, c = Function.prototype.bind || function(t) { var e = this; - return function () - { + return function() { return e.apply(t, arguments); }; }; ((e.exports = o).EventEmitter = o).prototype._events = void 0, o.prototype._maxListeners = void 0; var d = 10; - try - { - t = {}, Object.defineProperty && Object.defineProperty(t, "x", {value:0}); + try { + t = {}, Object.defineProperty && Object.defineProperty(t, "x", { value: 0 }); var p = 0 === t.x; } - catch(t) - { + catch (t) { p = !1; } - p ? Object.defineProperty(o, "defaultMaxListeners", {enumerable:!0, get:function () - { + p ? Object.defineProperty(o, "defaultMaxListeners", { + enumerable: !0, get: function() { return d; - }, set:function (t) - { - if("number" != typeof t || t < 0 || t != t) + }, set: function(t) { + if ("number" != typeof t || t < 0 || t != t) throw new TypeError('"defaultMaxListeners" must be a positive number'); d = t; - }}) : o.defaultMaxListeners = d, o.prototype.setMaxListeners = function (t) - { - if("number" != typeof t || t < 0 || isNaN(t)) + } + }) : o.defaultMaxListeners = d, o.prototype.setMaxListeners = function(t) { + if ("number" != typeof t || t < 0 || isNaN(t)) throw new TypeError('"n" argument must be a positive number'); return this._maxListeners = t, this; - }, o.prototype.getMaxListeners = function () - { + }, o.prototype.getMaxListeners = function() { return void 0 === this._maxListeners ? o.defaultMaxListeners : this._maxListeners; - }, o.prototype.emit = function (t) - { + }, o.prototype.emit = function(t) { var e, r, i, n = "error" === t; - if(i = this._events) + if (i = this._events) n = n && null == i.error; else - if(!n) + if (!n) return !1; - if(n) - { - if(1 < arguments.length && (e = arguments[1]), e instanceof Error) + if (n) { + if (1 < arguments.length && (e = arguments[1]), e instanceof Error) throw e; throw (i = Error('Unhandled "error" event. (' + e + ")")).context = e, i; } - if(!(e = i[t])) + if (!(e = i[t])) return !1; i = "function" == typeof e; var s = arguments.length; - switch(s) - { + switch (s) { case 1: - if(i) + if (i) e.call(this); else - for(e = u(e, i = e.length), n = 0; n < i; ++n) + for (e = u(e, i = e.length), n = 0; n < i; ++n) e[n].call(this); break; case 2: - if(n = arguments[1], i) + if (n = arguments[1], i) e.call(this, n); else - for(e = u(e, i = e.length), s = 0; s < i; ++s) + for (e = u(e, i = e.length), s = 0; s < i; ++s) e[s].call(this, n); break; case 3: - if(n = arguments[1], s = arguments[2], i) + if (n = arguments[1], s = arguments[2], i) e.call(this, n, s); else - for(e = u(e, i = e.length), r = 0; r < i; ++r) + for (e = u(e, i = e.length), r = 0; r < i; ++r) e[r].call(this, n, s); break; case 4: - if(n = arguments[1], s = arguments[2], r = arguments[3], i) + if (n = arguments[1], s = arguments[2], r = arguments[3], i) e.call(this, n, s, r); - else - { + else { e = u(e, i = e.length); - for(var o = 0; o < i; ++o) + for (var o = 0; o < i; ++o) e[o].call(this, n, s, r); } break; default: - for(n = Array(s - 1), r = 1; r < s; r++) + for (n = Array(s - 1), r = 1; r < s; r++) n[r - 1] = arguments[r]; - if(i) + if (i) e.apply(this, n); else - for(e = u(e, i = e.length), s = 0; s < i; ++s) + for (e = u(e, i = e.length), s = 0; s < i; ++s) e[s].apply(this, n); } return !0; - }, o.prototype.on = o.prototype.addListener = function (t,e) - { + }, o.prototype.on = o.prototype.addListener = function(t, e) { return i(this, t, e, !1); - }, o.prototype.prependListener = function (t,e) - { + }, o.prototype.prependListener = function(t, e) { return i(this, t, e, !0); - }, o.prototype.once = function (t,e) - { - if("function" != typeof e) + }, o.prototype.once = function(t, e) { + if ("function" != typeof e) throw new TypeError('"listener" argument must be a function'); return this.on(t, s(this, t, e)), this; - }, o.prototype.prependOnceListener = function (t,e) - { - if("function" != typeof e) + }, o.prototype.prependOnceListener = function(t, e) { + if ("function" != typeof e) throw new TypeError('"listener" argument must be a function'); return this.prependListener(t, s(this, t, e)), this; - }, o.prototype.removeListener = function (t,e) - { + }, o.prototype.removeListener = function(t, e) { var r; - if("function" != typeof e) + if ("function" != typeof e) throw new TypeError('"listener" argument must be a function'); var i = this._events; - if(!i) + if (!i) return this; var n = i[t]; - if(!n) + if (!n) return this; - if(n === e || n.listener === e) + if (n === e || n.listener === e) 0 == --this._eventsCount ? this._events = l(null) : (delete i[t], i.removeListener && this.emit("removeListener", t, n.listener || e)); else - if("function" != typeof n) - { - var s = - 1; - for(r = n.length - 1; 0 <= r; r--) - if(n[r] === e || n[r].listener === e) - { + if ("function" != typeof n) { + var s = - 1; + for (r = n.length - 1; 0 <= r; r--) + if (n[r] === e || n[r].listener === e) { var o = n[r].listener; s = r; break; } - if(s < 0) + if (s < 0) return this; - if(0 === s) + if (0 === s) n.shift(); - else - { + else { r = s + 1; - for(var a = n.length; r < a; s += 1, r += 1) + for (var a = n.length; r < a; s += 1, r += 1) n[s] = n[r]; n.pop(); } 1 === n.length && (i[t] = n[0]), i.removeListener && this.emit("removeListener", t, o || e); } return this; - }, o.prototype.removeAllListeners = function (t) - { + }, o.prototype.removeAllListeners = function(t) { var e = this._events; - if(!e) + if (!e) return this; - if(!e.removeListener) + if (!e.removeListener) return 0 === arguments.length ? (this._events = l(null), this._eventsCount = 0) : e[t] && (0 == --this._eventsCount ? this._events = l(null) : delete e[t]), - this; - if(0 === arguments.length) - { + this; + if (0 === arguments.length) { var r = f(e); - for(e = 0; e < r.length; ++e) - { + for (e = 0; e < r.length; ++e) { var i = r[e]; "removeListener" !== i && this.removeAllListeners(i); } return this.removeAllListeners("removeListener"), this._events = l(null), this._eventsCount = 0, this; } - if("function" == typeof (r = e[t])) + if ("function" == typeof (r = e[t])) this.removeListener(t, r); else - if(r) - for(e = r.length - 1; 0 <= e; e--) + if (r) + for (e = r.length - 1; 0 <= e; e--) this.removeListener(t, r[e]); return this; - }, o.prototype.listeners = function (t) - { + }, o.prototype.listeners = function(t) { return a(this, t, !0); - }, o.prototype.rawListeners = function (t) - { + }, o.prototype.rawListeners = function(t) { return a(this, t, !1); - }, o.listenerCount = function (t,e) - { + }, o.listenerCount = function(t, e) { return "function" == typeof t.listenerCount ? t.listenerCount(e) : h.call(t, e); - }, o.prototype.listenerCount = h, o.prototype.eventNames = function () - { + }, o.prototype.listenerCount = h, o.prototype.eventNames = function() { return 0 < this._eventsCount ? Reflect.ownKeys(this._events) : []; }; - }, {}], 6:[function (t,e,r) - { - r.read = function (t,e,r,i,n) - { - var s = 8 * n - i - 1, o = (1 << s) - 1, a = o >> 1, h = - 7, u = r ? - 1 : 1, l = t[e + (n = r ? n - 1 : 0)]; - for(n += u, r = l & (1 << - h) - 1, l >>= - h, h += s; 0 < h; r = 256 * r + t[e + n], n += u, h -= 8); - for(s = r & (1 << - h) - 1, r >>= - h, h += i; 0 < h; s = 256 * s + t[e + n], n += u, h -= 8); - if(0 === r) + }, {}], 6: [function(t, e, r) { + r.read = function(t, e, r, i, n) { + var s = 8 * n - i - 1, o = (1 << s) - 1, a = o >> 1, h = - 7, u = r ? - 1 : 1, l = t[e + (n = r ? n - 1 : 0)]; + for (n += u, r = l & (1 << - h) - 1, l >>= - h, h += s; 0 < h; r = 256 * r + t[e + n], n += u, h -= 8); + for (s = r & (1 << - h) - 1, r >>= - h, h += i; 0 < h; s = 256 * s + t[e + n], n += u, h -= 8); + if (0 === r) r = 1 - a; - else - { - if(r === o) - return s ? NaN : 1 / 0 * (l ? - 1 : 1); + else { + if (r === o) + return s ? NaN : 1 / 0 * (l ? - 1 : 1); s += Math.pow(2, i), r -= a; } - return (l ? - 1 : 1) * s * Math.pow(2, r - i); - }, r.write = function (t,e,r,i,n,s) - { - var o, a = 8 * s - n - 1, h = (1 << a) - 1, u = h >> 1, l = 23 === n ? Math.pow(2, - 24) - Math.pow(2, - 77) : 0; + return (l ? - 1 : 1) * s * Math.pow(2, r - i); + }, r.write = function(t, e, r, i, n, s) { + var o, a = 8 * s - n - 1, h = (1 << a) - 1, u = h >> 1, l = 23 === n ? Math.pow(2, - 24) - Math.pow(2, - 77) : 0; s = i ? 0 : s - 1; - var f = i ? 1 : - 1, c = e < 0 || 0 === e && 1 / e < 0 ? 1 : 0; - for(e = Math.abs(e), isNaN(e) || 1 / 0 === e ? (e = isNaN(e) ? 1 : 0, i = h) : (i = Math.floor(Math.log(e) / Math.LN2), e * (o = Math.pow(2, - - i)) < 1 && (i--, o *= 2), 2 <= (e = 1 <= i + u ? e + l / o : e + l * Math.pow(2, 1 - u)) * o && (i++, o /= 2), h <= i + u ? (e = 0, - i = h) : 1 <= i + u ? (e = (e * o - 1) * Math.pow(2, n), i += u) : (e = e * Math.pow(2, u - 1) * Math.pow(2, n), i = 0)); 8 <= n; t[r + s] = 255 & e, - s += f, e /= 256, n -= 8); - for(i = i << n | e, a += n; 0 < a; t[r + s] = 255 & i, s += f, i /= 256, a -= 8); + var f = i ? 1 : - 1, c = e < 0 || 0 === e && 1 / e < 0 ? 1 : 0; + for (e = Math.abs(e), isNaN(e) || 1 / 0 === e ? (e = isNaN(e) ? 1 : 0, i = h) : (i = Math.floor(Math.log(e) / Math.LN2), e * (o = Math.pow(2, + - i)) < 1 && (i-- , o *= 2), 2 <= (e = 1 <= i + u ? e + l / o : e + l * Math.pow(2, 1 - u)) * o && (i++ , o /= 2), h <= i + u ? (e = 0, + i = h) : 1 <= i + u ? (e = (e * o - 1) * Math.pow(2, n), i += u) : (e = e * Math.pow(2, u - 1) * Math.pow(2, n), i = 0)); 8 <= n; t[r + s] = 255 & e, + s += f, e /= 256, n -= 8); + for (i = i << n | e, a += n; 0 < a; t[r + s] = 255 & i, s += f, i /= 256, a -= 8); t[r + s - f] |= 128 * c; }; - }, {}], 7:[function (t,e,r) - { - e.exports = "function" == typeof Object.create ? function (t,e) - { - t.super_ = e, t.prototype = Object.create(e.prototype, {constructor:{value:t, enumerable:!1, writable:!0, configurable:!0}}); - } : function (t,e) - { - t.super_ = e; - var r = function () - { + }, {}], 7: [function(t, e, r) { + e.exports = "function" == typeof Object.create ? function(t, e) { + t.super_ = e, t.prototype = Object.create(e.prototype, { constructor: { value: t, enumerable: !1, writable: !0, configurable: !0 } }); + } : function(t, e) { + t.super_ = e; + var r = function() { + }; + r.prototype = e.prototype, t.prototype = new r, t.prototype.constructor = t; }; - r.prototype = e.prototype, t.prototype = new r, t.prototype.constructor = t; - }; - }, {}], 8:[function (t,e,r) - { - -function i(t) - { + }, {}], 8: [function(t, e, r) { + + function i(t) { return !!t.constructor && "function" == typeof t.constructor.isBuffer && t.constructor.isBuffer(t); }; - e.exports = function (t) - { + e.exports = function(t) { return null != t && (i(t) || "function" == typeof t.readFloatLE && "function" == typeof t.slice && i(t.slice(0, 0)) || !!t._isBuffer); }; - }, {}], 9:[function (t,e,r) - { + }, {}], 9: [function(t, e, r) { var i = {}.toString; - e.exports = Array.isArray || function (t) - { + e.exports = Array.isArray || function(t) { return "[object Array]" == i.call(t); }; - }, {}], 10:[function (t,e,r) - { - (function (o) - { - !o.version || 0 === o.version.indexOf("v0.") || 0 === o.version.indexOf("v1.") && 0 !== o.version.indexOf("v1.8.") ? e.exports = {nextTick:function (t,e,r,i) - { - if("function" != typeof t) + }, {}], 10: [function(t, e, r) { + (function(o) { + !o.version || 0 === o.version.indexOf("v0.") || 0 === o.version.indexOf("v1.") && 0 !== o.version.indexOf("v1.8.") ? e.exports = { + nextTick: function(t, e, r, i) { + if ("function" != typeof t) throw new TypeError('"callback" argument must be a function'); var n = arguments.length; - switch(n) - { + switch (n) { case 0: case 1: return o.nextTick(t); case 2: - return o.nextTick(function () - { + return o.nextTick(function() { t.call(null, e); }); case 3: - return o.nextTick(function () - { + return o.nextTick(function() { t.call(null, e, r); }); case 4: - return o.nextTick(function () - { + return o.nextTick(function() { t.call(null, e, r, i); }); default: var s = Array(n - 1); - for(n = 0; n < s.length; ) + for (n = 0; n < s.length;) s[n++] = arguments[n]; - return o.nextTick(function () - { + return o.nextTick(function() { t.apply(null, s); }); } - }} : e.exports = o; + } + } : e.exports = o; }).call(this, t("_process")); - }, {_process:11}], 11:[function (t,e,r) - { - -function i() - { + }, { _process: 11 }], 11: [function(t, e, r) { + + function i() { throw Error("setTimeout has not been defined"); }; - -function n() - { + + function n() { throw Error("clearTimeout has not been defined"); }; - -function s(e) - { - if(l === setTimeout) + + function s(e) { + if (l === setTimeout) return setTimeout(e, 0); - if((l === i || !l) && setTimeout) + if ((l === i || !l) && setTimeout) return l = setTimeout, setTimeout(e, 0); - try - { + try { return l(e, 0); } - catch(t) - { - try - { + catch (t) { + try { return l.call(null, e, 0); } - catch(t) - { + catch (t) { return l.call(this, e, 0); } } }; - -function o() - { - p && c && (p = !1, c.length ? d = c.concat(d) : m = - 1, d.length && a()); + + function o() { + p && c && (p = !1, c.length ? d = c.concat(d) : m = - 1, d.length && a()); }; - -function a() - { - if(!p) - { + + function a() { + if (!p) { var t = s(o); p = !0; - for(var e = d.length; e; ) - { - for(c = d, d = []; ++m < e; ) + for (var e = d.length; e;) { + for (c = d, d = []; ++m < e;) c && c[m].run(); - m = - 1, e = d.length; + m = - 1, e = d.length; } - c = null, p = !1, function (e) - { - if(f === clearTimeout) + c = null, p = !1, function(e) { + if (f === clearTimeout) return clearTimeout(e); - if((f === n || !f) && clearTimeout) + if ((f === n || !f) && clearTimeout) return f = clearTimeout, clearTimeout(e); - try - { + try { f(e); } - catch(t) - { - try - { + catch (t) { + try { return f.call(null, e); } - catch(t) - { + catch (t) { return f.call(this, e); } } }(t); } }; - -function h(t,e) - { + + function h(t, e) { this.fun = t, this.array = e; }; - -function u() - { + + function u() { }; t = e.exports = {}; - try - { + try { var l = "function" == typeof setTimeout ? setTimeout : i; } - catch(t) - { + catch (t) { l = i; } - try - { + try { var f = "function" == typeof clearTimeout ? clearTimeout : n; } - catch(t) - { + catch (t) { f = n; } - var c, d = [], p = !1, m = - 1; - t.nextTick = function (t) - { + var c, d = [], p = !1, m = - 1; + t.nextTick = function(t) { var e = Array(arguments.length - 1); - if(1 < arguments.length) - for(var r = 1; r < arguments.length; r++) + if (1 < arguments.length) + for (var r = 1; r < arguments.length; r++) e[r - 1] = arguments[r]; d.push(new h(t, e)), 1 !== d.length || p || s(a); - }, h.prototype.run = function () - { + }, h.prototype.run = function() { this.fun.apply(null, this.array); }, t.title = "browser", t.browser = !0, t.env = {}, t.argv = [], t.version = "", t.versions = {}, t.on = u, t.addListener = u, - t.once = u, t.off = u, t.removeListener = u, t.removeAllListeners = u, t.emit = u, t.prependListener = u, t.prependOnceListener = u, - t.listeners = function (t) - { - return []; - }, t.binding = function (t) - { - throw Error("process.binding is not supported"); - }, t.cwd = function () - { - return "/"; - }, t.chdir = function (t) - { - throw Error("process.chdir is not supported"); - }, t.umask = function () - { - return 0; - }; - }, {}], 12:[function (t,e,r) - { + t.once = u, t.off = u, t.removeListener = u, t.removeAllListeners = u, t.emit = u, t.prependListener = u, t.prependOnceListener = u, + t.listeners = function(t) { + return []; + }, t.binding = function(t) { + throw Error("process.binding is not supported"); + }, t.cwd = function() { + return "/"; + }, t.chdir = function(t) { + throw Error("process.chdir is not supported"); + }, t.umask = function() { + return 0; + }; + }, {}], 12: [function(t, e, r) { e.exports = t("./lib/_stream_duplex.js"); - }, {"./lib/_stream_duplex.js":13}], 13:[function (t,e,r) - { - -function i(t) - { - if(!(this instanceof i)) + }, { "./lib/_stream_duplex.js": 13 }], 13: [function(t, e, r) { + + function i(t) { + if (!(this instanceof i)) return new i(t); a.call(this, t), h.call(this, t), t && !1 === t.readable && (this.readable = !1), t && !1 === t.writable && (this.writable = !1), - this.allowHalfOpen = !0, t && !1 === t.allowHalfOpen && (this.allowHalfOpen = !1), this.once("end", n); + this.allowHalfOpen = !0, t && !1 === t.allowHalfOpen && (this.allowHalfOpen = !1), this.once("end", n); }; - -function n() - { + + function n() { this.allowHalfOpen || this._writableState.ended || o.nextTick(s, this); }; - -function s(t) - { + + function s(t) { t.end(); }; var o = t("process-nextick-args"); - r = Object.keys || function (t) - { + r = Object.keys || function(t) { var e, r = []; - for(e in t) + for (e in t) r.push(e); return r; }, e.exports = i, (e = t("core-util-is")).inherits = t("inherits"); var a = t("./_stream_readable"), h = t("./_stream_writable"); - for(e.inherits(i, a), t = r(h.prototype), e = 0; e < t.length; e++) + for (e.inherits(i, a), t = r(h.prototype), e = 0; e < t.length; e++) r = t[e], i.prototype[r] || (i.prototype[r] = h.prototype[r]); - Object.defineProperty(i.prototype, "writableHighWaterMark", {enumerable:!1, get:function () - { + Object.defineProperty(i.prototype, "writableHighWaterMark", { + enumerable: !1, get: function() { return this._writableState.highWaterMark; - }}), Object.defineProperty(i.prototype, "destroyed", {get:function () - { + } + }), Object.defineProperty(i.prototype, "destroyed", { + get: function() { return void 0 !== this._readableState && void 0 !== this._writableState && (this._readableState.destroyed && this._writableState.destroyed); - }, set:function (t) - { + }, set: function(t) { void 0 !== this._readableState && void 0 !== this._writableState && (this._readableState.destroyed = t, this._writableState.destroyed = t); - }}), i.prototype._destroy = function (t,e) - { + } + }), i.prototype._destroy = function(t, e) { this.push(null), this.end(), o.nextTick(e, t); }; - }, {"./_stream_readable":15, "./_stream_writable":17, "core-util-is":4, inherits:7, "process-nextick-args":10}], 14:[function (t,e,r) - { - -function i(t) - { - if(!(this instanceof i)) + }, { "./_stream_readable": 15, "./_stream_writable": 17, "core-util-is": 4, inherits: 7, "process-nextick-args": 10 }], 14: [function(t, e, r) { + + function i(t) { + if (!(this instanceof i)) return new i(t); n.call(this, t); }; e.exports = i; var n = t("./_stream_transform"); - (e = t("core-util-is")).inherits = t("inherits"), e.inherits(i, n), i.prototype._transform = function (t,e,r) - { + (e = t("core-util-is")).inherits = t("inherits"), e.inherits(i, n), i.prototype._transform = function(t, e, r) { r(null, t); }; - }, {"./_stream_transform":16, "core-util-is":4, inherits:7}], 15:[function (L,k,t) - { - (function (m,t) - { - -function e(t,e) - { + }, { "./_stream_transform": 16, "core-util-is": 4, inherits: 7 }], 15: [function(L, k, t) { + (function(m, t) { + + function e(t, e) { t = t || {}; var r = e instanceof (p = p || L("./_stream_duplex")); this.objectMode = !!t.objectMode, r && (this.objectMode = this.objectMode || !!t.readableObjectMode); var i = t.highWaterMark, n = t.readableHighWaterMark, s = this.objectMode ? 16 : 16384; this.highWaterMark = i || 0 === i ? i : r && (n || 0 === n) ? n : s, this.highWaterMark = Math.floor(this.highWaterMark), this.buffer = new B, - this.length = 0, this.pipes = null, this.pipesCount = 0, this.flowing = null, this.reading = this.endEmitted = this.ended = !1, - this.sync = !0, this.destroyed = this.resumeScheduled = this.readableListening = this.emittedReadable = this.needReadable = !1, - this.defaultEncoding = t.defaultEncoding || "utf8", this.awaitDrain = 0, this.readingMore = !1, this.encoding = this.decoder = null, - t.encoding && (A || (A = L("string_decoder/").StringDecoder), this.decoder = new A(t.encoding), this.encoding = t.encoding); + this.length = 0, this.pipes = null, this.pipesCount = 0, this.flowing = null, this.reading = this.endEmitted = this.ended = !1, + this.sync = !0, this.destroyed = this.resumeScheduled = this.readableListening = this.emittedReadable = this.needReadable = !1, + this.defaultEncoding = t.defaultEncoding || "utf8", this.awaitDrain = 0, this.readingMore = !1, this.encoding = this.decoder = null, + t.encoding && (A || (A = L("string_decoder/").StringDecoder), this.decoder = new A(t.encoding), this.encoding = t.encoding); }; - -function r(t) - { - if(p = p || L("./_stream_duplex"), !(this instanceof r)) + + function r(t) { + if (p = p || L("./_stream_duplex"), !(this instanceof r)) return new r(t); this._readableState = new e(t, this), this.readable = !0, t && ("function" == typeof t.read && (this._read = t.read), "function" == typeof t.destroy && (this._destroy = t.destroy)), - w.call(this); + w.call(this); }; - -function n(t,e,r,i,n) - { + + function n(t, e, r, i, n) { var s = t._readableState; - if(null === e) + if (null === e) s.reading = !1, s.ended || (s.decoder && (e = s.decoder.end()) && e.length && (s.buffer.push(e), s.length += s.objectMode ? 1 : e.length), - s.ended = !0, u(t)); - else - { - if(!n) - { + s.ended = !0, u(t)); + else { + if (!n) { var o; n = e, v.isBuffer(n) || n instanceof M || "string" == typeof n || void 0 === n || s.objectMode || (o = new TypeError("Invalid non-string/buffer chunk")); var a = o; } a ? t.emit("error", a) : s.objectMode || e && 0 < e.length ? ("string" == typeof e || s.objectMode || Object.getPrototypeOf(e) === v.prototype || (e = v.from(e)), - i ? s.endEmitted ? t.emit("error", Error("stream.unshift() after end event")) : h(t, s, e, !0) : s.ended ? t.emit("error", - Error("stream.push() after EOF")) : (s.reading = !1, s.decoder && !r ? (e = s.decoder.write(e), s.objectMode || 0 !== e.length ? h(t, - s, e, !1) : s.readingMore || (s.readingMore = !0, b.nextTick(l, t, s))) : h(t, s, e, !1))) : i || (s.reading = !1); + i ? s.endEmitted ? t.emit("error", Error("stream.unshift() after end event")) : h(t, s, e, !0) : s.ended ? t.emit("error", + Error("stream.push() after EOF")) : (s.reading = !1, s.decoder && !r ? (e = s.decoder.write(e), s.objectMode || 0 !== e.length ? h(t, + s, e, !1) : s.readingMore || (s.readingMore = !0, b.nextTick(l, t, s))) : h(t, s, e, !1))) : i || (s.reading = !1); } return !s.ended && (s.needReadable || s.length < s.highWaterMark || 0 === s.length); }; - -function h(t,e,r,i) - { + + function h(t, e, r, i) { e.flowing && 0 === e.length && !e.sync ? (t.emit("data", r), t.read(0)) : (e.length += e.objectMode ? 1 : r.length, i ? e.buffer.unshift(r) : e.buffer.push(r), - e.needReadable && u(t)), e.readingMore || (e.readingMore = !0, b.nextTick(l, t, e)); + e.needReadable && u(t)), e.readingMore || (e.readingMore = !0, b.nextTick(l, t, e)); }; - -function s(t,e) - { - if(t <= 0 || 0 === e.length && e.ended) + + function s(t, e) { + if (t <= 0 || 0 === e.length && e.ended) return 0; - if(e.objectMode) + if (e.objectMode) return 1; - if(t != t) + if (t != t) return e.flowing && e.length ? e.buffer.head.data.length : e.length; - if(t > e.highWaterMark) - { + if (t > e.highWaterMark) { var r = t; - 8388608 <= r ? r = 8388608 : (r--, r |= r >>> 1, r |= r >>> 2, r |= r >>> 4, r |= r >>> 8, r |= r >>> 16, r++), e.highWaterMark = r; + 8388608 <= r ? r = 8388608 : (r-- , r |= r >>> 1, r |= r >>> 2, r |= r >>> 4, r |= r >>> 8, r |= r >>> 16, r++), e.highWaterMark = r; } return t <= e.length ? t : e.ended ? e.length : (e.needReadable = !0, 0); }; - -function u(t) - { + + function u(t) { var e = t._readableState; e.needReadable = !1, e.emittedReadable || (I("emitReadable", e.flowing), e.emittedReadable = !0, e.sync ? b.nextTick(i, t) : i(t)); }; - -function i(t) - { + + function i(t) { I("emit readable"), t.emit("readable"), _(t); }; - -function l(t,e) - { - for(var r = e.length; !e.reading && !e.flowing && !e.ended && e.length < e.highWaterMark && (I("maybeReadMore read 0"), t.read(0), - r !== e.length); ) + + function l(t, e) { + for (var r = e.length; !e.reading && !e.flowing && !e.ended && e.length < e.highWaterMark && (I("maybeReadMore read 0"), t.read(0), + r !== e.length);) r = e.length; e.readingMore = !1; }; - -function o(t) - { + + function o(t) { I("readable nexttick read 0"), t.read(0); }; - -function a(t,e) - { + + function a(t, e) { e.reading || (I("resume read 0"), t.read(0)), e.resumeScheduled = !1, e.awaitDrain = 0, t.emit("resume"), _(t), e.flowing && !e.reading && t.read(0); }; - -function _(t) - { + + function _(t) { var e = t._readableState; - for(I("flow", e.flowing); e.flowing && null !== t.read(); ); + for (I("flow", e.flowing); e.flowing && null !== t.read();); }; - -function f(t,e) - { - if(0 === e.length) + + function f(t, e) { + if (0 === e.length) return null; - if(e.objectMode) + if (e.objectMode) var r = e.buffer.shift(); else - if(!t || t >= e.length) + if (!t || t >= e.length) r = e.decoder ? e.buffer.join("") : 1 === e.buffer.length ? e.buffer.head.data : e.buffer.concat(e.length), e.buffer.clear(); - else - { + else { r = e.buffer; var i = e.decoder; - if(t < r.head.data.length) + if (t < r.head.data.length) i = r.head.data.slice(0, t), r.head.data = r.head.data.slice(t); - else - { - if(t === r.head.data.length) + else { + if (t === r.head.data.length) r = r.shift(); else - if(i) - { + if (i) { var n = r.head, s = 1, o = n.data; - for(i = t - o.length; n = n.next; ) - { + for (i = t - o.length; n = n.next;) { var a = n.data, h = i > a.length ? a.length : i; - if(o = h === a.length ? o + a : o + a.slice(0, i), 0 === (i -= h)) - { + if (o = h === a.length ? o + a : o + a.slice(0, i), 0 === (i -= h)) { h === a.length ? (++s, r.head = n.next ? n.next : r.tail = null) : (r.head = n).data = a.slice(h); break; } @@ -1732,12 +1450,9 @@ function f(t,e) } r.length -= s, r = o; } - else - { - for(i = t, n = v.allocUnsafe(i), o = 1, (s = r.head).data.copy(n), i -= s.data.length; s = s.next; ) - { - if(h = i > (a = s.data).length ? a.length : i, a.copy(n, n.length - i, 0, h), 0 === (i -= h)) - { + else { + for (i = t, n = v.allocUnsafe(i), o = 1, (s = r.head).data.copy(n), i -= s.data.length; s = s.next;) { + if (h = i > (a = s.data).length ? a.length : i, a.copy(n, n.length - i, 0, h), 0 === (i -= h)) { h === a.length ? (++o, r.head = s.next ? s.next : r.tail = null) : (r.head = s).data = a.slice(h); break; } @@ -1751,122 +1466,102 @@ function f(t,e) } return r; }; - -function c(t) - { + + function c(t) { var e = t._readableState; - if(0 < e.length) + if (0 < e.length) throw Error('"endReadable()" called on non-empty stream'); e.endEmitted || (e.ended = !0, b.nextTick(d, e, t)); }; - -function d(t,e) - { + + function d(t, e) { t.endEmitted || 0 !== t.length || (t.endEmitted = !0, e.readable = !1, e.emit("end")); }; - -function g(t,e) - { - for(var r = 0, i = t.length; r < i; r++) - if(t[r] === e) + + function g(t, e) { + for (var r = 0, i = t.length; r < i; r++) + if (t[r] === e) return r; - return - 1; + return - 1; }; var b = L("process-nextick-args"); k.exports = r; var p, y = L("isarray"); r.ReadableState = e, L("events"); - var w = L("./internal/streams/stream"), v = L("safe-buffer").Buffer, M = t.Uint8Array || function () - { + var w = L("./internal/streams/stream"), v = L("safe-buffer").Buffer, M = t.Uint8Array || function() { }, E = L("core-util-is"); E.inherits = L("inherits"); var S = L("util"), I = void 0; - I = S && S.debuglog ? S.debuglog("stream") : function () - { + I = S && S.debuglog ? S.debuglog("stream") : function() { }; var A, B = L("./internal/streams/BufferList"); S = L("./internal/streams/destroy"), E.inherits(r, w); var x = ["error", "close", "destroy", "pause", "resume"]; - Object.defineProperty(r.prototype, "destroyed", {get:function () - { + Object.defineProperty(r.prototype, "destroyed", { + get: function() { return void 0 !== this._readableState && this._readableState.destroyed; - }, set:function (t) - { + }, set: function(t) { this._readableState && (this._readableState.destroyed = t); - }}), r.prototype.destroy = S.destroy, r.prototype._undestroy = S.undestroy, r.prototype._destroy = function (t,e) - { + } + }), r.prototype.destroy = S.destroy, r.prototype._undestroy = S.undestroy, r.prototype._destroy = function(t, e) { this.push(null), e(t); - }, r.prototype.push = function (t,e) - { + }, r.prototype.push = function(t, e) { var r = this._readableState; - if(r.objectMode) + if (r.objectMode) var i = !0; else "string" == typeof t && ((e = e || r.defaultEncoding) !== r.encoding && (t = v.from(t, e), e = ""), i = !0); return n(this, t, e, !1, i); - }, r.prototype.unshift = function (t) - { + }, r.prototype.unshift = function(t) { return n(this, t, null, !0, !1); - }, r.prototype.isPaused = function () - { + }, r.prototype.isPaused = function() { return !1 === this._readableState.flowing; - }, r.prototype.setEncoding = function (t) - { + }, r.prototype.setEncoding = function(t) { return A || (A = L("string_decoder/").StringDecoder), this._readableState.decoder = new A(t), this._readableState.encoding = t, - this; - }, r.prototype.read = function (t) - { + this; + }, r.prototype.read = function(t) { I("read", t), t = parseInt(t, 10); var e = this._readableState, r = t; - if(0 !== t && (e.emittedReadable = !1), 0 === t && e.needReadable && (e.length >= e.highWaterMark || e.ended)) + if (0 !== t && (e.emittedReadable = !1), 0 === t && e.needReadable && (e.length >= e.highWaterMark || e.ended)) return I("read: emitReadable", e.length, e.ended), 0 === e.length && e.ended ? c(this) : u(this), null; - if(0 === (t = s(t, e)) && e.ended) + if (0 === (t = s(t, e)) && e.ended) return 0 === e.length && c(this), null; var i = e.needReadable; return I("need readable", i), (0 === e.length || e.length - t < e.highWaterMark) && I("length less than watermark", i = !0), - e.ended || e.reading ? I("reading or ended", !1) : i && (I("do read"), e.reading = !0, e.sync = !0, 0 === e.length && (e.needReadable = !0), - this._read(e.highWaterMark), e.sync = !1, e.reading || (t = s(r, e))), null === (i = 0 < t ? f(t, e) : null) ? (e.needReadable = !0, - t = 0) : e.length -= t, 0 === e.length && (e.ended || (e.needReadable = !0), r !== t && e.ended && c(this)), null !== i && this.emit("data", - i), i; - }, r.prototype._read = function (t) - { + e.ended || e.reading ? I("reading or ended", !1) : i && (I("do read"), e.reading = !0, e.sync = !0, 0 === e.length && (e.needReadable = !0), + this._read(e.highWaterMark), e.sync = !1, e.reading || (t = s(r, e))), null === (i = 0 < t ? f(t, e) : null) ? (e.needReadable = !0, + t = 0) : e.length -= t, 0 === e.length && (e.ended || (e.needReadable = !0), r !== t && e.ended && c(this)), null !== i && this.emit("data", + i), i; + }, r.prototype._read = function(t) { this.emit("error", Error("_read() is not implemented")); - }, r.prototype.pipe = function (i,t) - { - -function n() - { + }, r.prototype.pipe = function(i, t) { + + function n() { I("onend"), i.end(); }; - -function s(t) - { - I("ondata"), (p = !1) !== i.write(t) || p || ((1 === f.pipesCount && f.pipes === i || 1 < f.pipesCount && - 1 !== g(f.pipes, - i)) && !d && (I("false write response, pause", l._readableState.awaitDrain), l._readableState.awaitDrain++, p = !0), l.pause()); + + function s(t) { + I("ondata"), (p = !1) !== i.write(t) || p || ((1 === f.pipesCount && f.pipes === i || 1 < f.pipesCount && - 1 !== g(f.pipes, + i)) && !d && (I("false write response, pause", l._readableState.awaitDrain), l._readableState.awaitDrain++ , p = !0), l.pause()); }; - -function o(t) - { + + function o(t) { I("onerror", t), u(), i.removeListener("error", o), 0 === i.listeners("error").length && i.emit("error", t); }; - -function a() - { + + function a() { i.removeListener("finish", h), u(); }; - -function h() - { + + function h() { I("onfinish"), i.removeListener("close", a), u(); }; - -function u() - { + + function u() { I("unpipe"), l.unpipe(i); }; var l = this, f = this._readableState; - switch(f.pipesCount) - { + switch (f.pipesCount) { case 0: f.pipes = i; break; @@ -1878,553 +1573,466 @@ function u() } f.pipesCount += 1, I("pipe count=%d opts=%j", f.pipesCount, t); var e = t && !1 === t.end || i === m.stdout || i === m.stderr ? u : n; - f.endEmitted ? b.nextTick(e) : l.once("end", e), i.on("unpipe", function t(e,r) - { + f.endEmitted ? b.nextTick(e) : l.once("end", e), i.on("unpipe", function t(e, r) { I("onunpipe"), e === l && r && !1 === r.hasUnpiped && (r.hasUnpiped = !0, I("cleanup"), i.removeListener("close", a), i.removeListener("finish", - h), i.removeListener("drain", c), i.removeListener("error", o), i.removeListener("unpipe", t), l.removeListener("end", n), - l.removeListener("end", u), l.removeListener("data", s), d = !0, !f.awaitDrain || i._writableState && !i._writableState.needDrain || c()); + h), i.removeListener("drain", c), i.removeListener("error", o), i.removeListener("unpipe", t), l.removeListener("end", n), + l.removeListener("end", u), l.removeListener("data", s), d = !0, !f.awaitDrain || i._writableState && !i._writableState.needDrain || c()); }); - var r, c = (r = l, function () - { + var r, c = (r = l, function() { var t = r._readableState; - I("pipeOnDrain", t.awaitDrain), t.awaitDrain && t.awaitDrain--, 0 === t.awaitDrain && r.listeners("data").length && (t.flowing = !0, - _(r)); + I("pipeOnDrain", t.awaitDrain), t.awaitDrain && t.awaitDrain-- , 0 === t.awaitDrain && r.listeners("data").length && (t.flowing = !0, + _(r)); }); i.on("drain", c); var d = !1, p = !1; - return l.on("data", s), function (t,e,r) - { - if("function" == typeof t.prependListener) + return l.on("data", s), function(t, e, r) { + if ("function" == typeof t.prependListener) return t.prependListener(e, r); t._events && t._events[e] ? y(t._events[e]) ? t._events[e].unshift(r) : t._events[e] = [r, t._events[e]] : t.on(e, r); }(i, "error", o), i.once("close", a), i.once("finish", h), i.emit("pipe", l), f.flowing || (I("pipe resume"), l.resume()), - i; - }, r.prototype.unpipe = function (t) - { - var e = this._readableState, r = {hasUnpiped:!1}; - if(0 === e.pipesCount) + i; + }, r.prototype.unpipe = function(t) { + var e = this._readableState, r = { hasUnpiped: !1 }; + if (0 === e.pipesCount) return this; - if(1 === e.pipesCount) + if (1 === e.pipesCount) return t && t !== e.pipes || (t || (t = e.pipes), e.pipes = null, e.pipesCount = 0, e.flowing = !1, t && t.emit("unpipe", this, - r)), this; - if(t) - return - 1 === (i = g(e.pipes, t)) || (e.pipes.splice(i, 1), --e.pipesCount, 1 === e.pipesCount && (e.pipes = e.pipes[0]), - t.emit("unpipe", this, r)), this; + r)), this; + if (t) + return - 1 === (i = g(e.pipes, t)) || (e.pipes.splice(i, 1), --e.pipesCount, 1 === e.pipesCount && (e.pipes = e.pipes[0]), + t.emit("unpipe", this, r)), this; t = e.pipes; var i = e.pipesCount; - for(e.pipes = null, e.pipesCount = 0, e.flowing = !1, e = 0; e < i; e++) + for (e.pipes = null, e.pipesCount = 0, e.flowing = !1, e = 0; e < i; e++) t[e].emit("unpipe", this, r); return this; - }, r.prototype.addListener = r.prototype.on = function (t,e) - { + }, r.prototype.addListener = r.prototype.on = function(t, e) { var r = w.prototype.on.call(this, t, e); - if("data" === t) + if ("data" === t) !1 !== this._readableState.flowing && this.resume(); else - if("readable" === t) - { + if ("readable" === t) { var i = this._readableState; i.endEmitted || i.readableListening || (i.readableListening = i.needReadable = !0, i.emittedReadable = !1, i.reading ? i.length && u(this) : b.nextTick(o, - this)); + this)); } return r; - }, r.prototype.resume = function () - { + }, r.prototype.resume = function() { var t = this._readableState; return t.flowing || (I("resume"), t.flowing = !0, t.resumeScheduled || (t.resumeScheduled = !0, b.nextTick(a, this, t))), this; - }, r.prototype.pause = function () - { + }, r.prototype.pause = function() { return I("call pause flowing=%j", this._readableState.flowing), !1 !== this._readableState.flowing && (I("pause"), this._readableState.flowing = !1, - this.emit("pause")), this; - }, r.prototype.wrap = function (e) - { + this.emit("pause")), this; + }, r.prototype.wrap = function(e) { var r = this, i = this._readableState, n = !1; - for(var t in e.on("end", function () - { - if(I("wrapped end"), i.decoder && !i.ended) - { + for (var t in e.on("end", function() { + if (I("wrapped end"), i.decoder && !i.ended) { var t = i.decoder.end(); t && t.length && r.push(t); } r.push(null); - }), e.on("data", function (t) - { + }), e.on("data", function(t) { I("wrapped data"), i.decoder && (t = i.decoder.write(t)), i.objectMode && null == t || !(i.objectMode || t && t.length) || r.push(t) || (n = !0, - e.pause()); + e.pause()); }), e) - void 0 === this[t] && "function" == typeof e[t] && (this[t] = function (t) - { - return function () - { + void 0 === this[t] && "function" == typeof e[t] && (this[t] = function(t) { + return function() { return e[t].apply(e, arguments); }; }(t)); - for(t = 0; t < x.length; t++) + for (t = 0; t < x.length; t++) e.on(x[t], this.emit.bind(this, x[t])); - return this._read = function (t) - { + return this._read = function(t) { I("wrapped _read", t), n && (n = !1, e.resume()); }, this; - }, Object.defineProperty(r.prototype, "readableHighWaterMark", {enumerable:!1, get:function () - { + }, Object.defineProperty(r.prototype, "readableHighWaterMark", { + enumerable: !1, get: function() { return this._readableState.highWaterMark; - }}), r._fromList = f; + } + }), r._fromList = f; }).call(this, L("_process"), "undefined" != typeof global ? global : "undefined" != typeof self ? self : "undefined" != typeof window ? window : {}); - }, {"./_stream_duplex":13, "./internal/streams/BufferList":18, "./internal/streams/destroy":19, "./internal/streams/stream":20, - _process:11, "core-util-is":4, events:5, inherits:7, isarray:9, "process-nextick-args":10, "safe-buffer":25, "string_decoder/":27, - util:2}], 16:[function (t,e,r) - { - -function i(t) - { - if(!(this instanceof i)) + }, { + "./_stream_duplex": 13, "./internal/streams/BufferList": 18, "./internal/streams/destroy": 19, "./internal/streams/stream": 20, + _process: 11, "core-util-is": 4, events: 5, inherits: 7, isarray: 9, "process-nextick-args": 10, "safe-buffer": 25, "string_decoder/": 27, + util: 2 + }], 16: [function(t, e, r) { + + function i(t) { + if (!(this instanceof i)) return new i(t); - o.call(this, t), this._transformState = {afterTransform:function (t,e) - { + o.call(this, t), this._transformState = { + afterTransform: function(t, e) { var r = this._transformState; r.transforming = !1; var i = r.writecb; - if(!i) + if (!i) return this.emit("error", Error("write callback called multiple times")); r.writechunk = null, (r.writecb = null) != e && this.push(e), i(t), (r = this._readableState).reading = !1, (r.needReadable || r.length < r.highWaterMark) && this._read(r.highWaterMark); - }.bind(this), needTransform:!1, transforming:!1, writecb:null, writechunk:null, writeencoding:null}, this._readableState.needReadable = !0, - this._readableState.sync = !1, t && ("function" == typeof t.transform && (this._transform = t.transform), "function" == typeof t.flush && (this._flush = t.flush)), - this.on("prefinish", n); + }.bind(this), needTransform: !1, transforming: !1, writecb: null, writechunk: null, writeencoding: null + }, this._readableState.needReadable = !0, + this._readableState.sync = !1, t && ("function" == typeof t.transform && (this._transform = t.transform), "function" == typeof t.flush && (this._flush = t.flush)), + this.on("prefinish", n); }; - -function n() - { + + function n() { var r = this; - "function" == typeof this._flush ? this._flush(function (t,e) - { + "function" == typeof this._flush ? this._flush(function(t, e) { s(r, t, e); }) : s(this, null, null); }; - -function s(t,e,r) - { - if(e) + + function s(t, e, r) { + if (e) return t.emit("error", e); - if(null != r && t.push(r), t._writableState.length) + if (null != r && t.push(r), t._writableState.length) throw Error("Calling transform done when ws.length != 0"); - if(t._transformState.transforming) + if (t._transformState.transforming) throw Error("Calling transform done when still transforming"); return t.push(null); }; e.exports = i; var o = t("./_stream_duplex"); - (e = t("core-util-is")).inherits = t("inherits"), e.inherits(i, o), i.prototype.push = function (t,e) - { + (e = t("core-util-is")).inherits = t("inherits"), e.inherits(i, o), i.prototype.push = function(t, e) { return this._transformState.needTransform = !1, o.prototype.push.call(this, t, e); - }, i.prototype._transform = function (t,e,r) - { + }, i.prototype._transform = function(t, e, r) { throw Error("_transform() is not implemented"); - }, i.prototype._write = function (t,e,r) - { + }, i.prototype._write = function(t, e, r) { var i = this._transformState; i.writecb = r, i.writechunk = t, i.writeencoding = e, i.transforming || (t = this._readableState, (i.needTransform || t.needReadable || t.length < t.highWaterMark) && this._read(t.highWaterMark)); - }, i.prototype._read = function (t) - { + }, i.prototype._read = function(t) { null !== (t = this._transformState).writechunk && t.writecb && !t.transforming ? (t.transforming = !0, this._transform(t.writechunk, - t.writeencoding, t.afterTransform)) : t.needTransform = !0; - }, i.prototype._destroy = function (t,e) - { + t.writeencoding, t.afterTransform)) : t.needTransform = !0; + }, i.prototype._destroy = function(t, e) { var r = this; - o.prototype._destroy.call(this, t, function (t) - { + o.prototype._destroy.call(this, t, function(t) { e(t), r.emit("close"); }); }; - }, {"./_stream_duplex":13, "core-util-is":4, inherits:7}], 17:[function (v,M,t) - { - (function (t,e,r) - { - -function a(r) - { + }, { "./_stream_duplex": 13, "core-util-is": 4, inherits: 7 }], 17: [function(v, M, t) { + (function(t, e, r) { + + function a(r) { var i = this; - this.entry = this.next = null, this.finish = function () - { + this.entry = this.next = null, this.finish = function() { var t = i.entry; - for(i.entry = null; t; ) - { + for (i.entry = null; t;) { var e = t.callback; - r.pendingcb--, e(void 0), t = t.next; + r.pendingcb-- , e(void 0), t = t.next; } r.corkedRequestsFree ? r.corkedRequestsFree.next = i : r.corkedRequestsFree = i; }; }; - -function l() - { + + function l() { }; - -function i(t,n) - { + + function i(t, n) { p = p || v("./_stream_duplex"), t = t || {}; var e = n instanceof p; this.objectMode = !!t.objectMode, e && (this.objectMode = this.objectMode || !!t.writableObjectMode); var r = t.highWaterMark, i = t.writableHighWaterMark, s = this.objectMode ? 16 : 16384; this.highWaterMark = r || 0 === r ? r : e && (i || 0 === i) ? i : s, this.highWaterMark = Math.floor(this.highWaterMark), this.destroyed = this.finished = this.ended = this.ending = this.needDrain = this.finalCalled = !1, - this.decodeStrings = !1 !== t.decodeStrings, this.defaultEncoding = t.defaultEncoding || "utf8", this.length = 0, this.writing = !1, - this.corked = 0, this.sync = !0, this.bufferProcessing = !1, this.onwrite = function (t) - { - var e = n._writableState, r = e.sync, i = e.writecb; - e.writing = !1, e.writecb = null, e.length -= e.writelen, e.writelen = 0, t ? (--e.pendingcb, r ? (d.nextTick(i, t), d.nextTick(c, - n, e), n._writableState.errorEmitted = !0, n.emit("error", t)) : (i(t), n._writableState.errorEmitted = !0, n.emit("error", - t), c(n, e))) : ((t = u(e)) || e.corked || e.bufferProcessing || !e.bufferedRequest || h(n, e), r ? m(o, n, e, t, i) : o(n, - e, t, i)); - }, this.writecb = null, this.writelen = 0, this.lastBufferedRequest = this.bufferedRequest = null, this.pendingcb = 0, this.errorEmitted = this.prefinished = !1, - this.bufferedRequestCount = 0, this.corkedRequestsFree = new a(this); + this.decodeStrings = !1 !== t.decodeStrings, this.defaultEncoding = t.defaultEncoding || "utf8", this.length = 0, this.writing = !1, + this.corked = 0, this.sync = !0, this.bufferProcessing = !1, this.onwrite = function(t) { + var e = n._writableState, r = e.sync, i = e.writecb; + e.writing = !1, e.writecb = null, e.length -= e.writelen, e.writelen = 0, t ? (--e.pendingcb, r ? (d.nextTick(i, t), d.nextTick(c, + n, e), n._writableState.errorEmitted = !0, n.emit("error", t)) : (i(t), n._writableState.errorEmitted = !0, n.emit("error", + t), c(n, e))) : ((t = u(e)) || e.corked || e.bufferProcessing || !e.bufferedRequest || h(n, e), r ? m(o, n, e, t, i) : o(n, + e, t, i)); + }, this.writecb = null, this.writelen = 0, this.lastBufferedRequest = this.bufferedRequest = null, this.pendingcb = 0, this.errorEmitted = this.prefinished = !1, + this.bufferedRequestCount = 0, this.corkedRequestsFree = new a(this); }; - -function n(t) - { - if(p = p || v("./_stream_duplex"), !(w.call(n, this) || this instanceof p)) + + function n(t) { + if (p = p || v("./_stream_duplex"), !(w.call(n, this) || this instanceof p)) return new n(t); this._writableState = new i(t, this), this.writable = !0, t && ("function" == typeof t.write && (this._write = t.write), "function" == typeof t.writev && (this._writev = t.writev), - "function" == typeof t.destroy && (this._destroy = t.destroy), "function" == typeof t.final && (this._final = t.final)), g.call(this); + "function" == typeof t.destroy && (this._destroy = t.destroy), "function" == typeof t.final && (this._final = t.final)), g.call(this); }; - -function f(t,e,r,i,n,s,o) - { + + function f(t, e, r, i, n, s, o) { e.writelen = i, e.writecb = o, e.writing = !0, e.sync = !0, r ? t._writev(n, e.onwrite) : t._write(n, s, e.onwrite), e.sync = !1; }; - -function o(t,e,r,i) - { - !r && 0 === e.length && e.needDrain && (e.needDrain = !1, t.emit("drain")), e.pendingcb--, i(), c(t, e); + + function o(t, e, r, i) { + !r && 0 === e.length && e.needDrain && (e.needDrain = !1, t.emit("drain")), e.pendingcb-- , i(), c(t, e); }; - -function h(t,e) - { + + function h(t, e) { e.bufferProcessing = !0; var r = e.bufferedRequest; - if(t._writev && r && r.next) - { + if (t._writev && r && r.next) { var i = Array(e.bufferedRequestCount), n = e.corkedRequestsFree; n.entry = r; - for(var s = 0, o = !0; r; ) + for (var s = 0, o = !0; r;) (i[s] = r).isBuf || (o = !1), r = r.next, s += 1; - i.allBuffers = o, f(t, e, !0, e.length, i, "", n.finish), e.pendingcb++, e.lastBufferedRequest = null, n.next ? (e.corkedRequestsFree = n.next, - n.next = null) : e.corkedRequestsFree = new a(e), e.bufferedRequestCount = 0; + i.allBuffers = o, f(t, e, !0, e.length, i, "", n.finish), e.pendingcb++ , e.lastBufferedRequest = null, n.next ? (e.corkedRequestsFree = n.next, + n.next = null) : e.corkedRequestsFree = new a(e), e.bufferedRequestCount = 0; } - else - { - for(; r && (i = r.chunk, f(t, e, !1, e.objectMode ? 1 : i.length, i, r.encoding, r.callback), r = r.next, e.bufferedRequestCount--, - !e.writing); ); + else { + for (; r && (i = r.chunk, f(t, e, !1, e.objectMode ? 1 : i.length, i, r.encoding, r.callback), r = r.next, e.bufferedRequestCount-- , + !e.writing);); null === r && (e.lastBufferedRequest = null); } e.bufferedRequest = r, e.bufferProcessing = !1; }; - -function u(t) - { + + function u(t) { return t.ending && 0 === t.length && null === t.bufferedRequest && !t.finished && !t.writing; }; - -function s(e,r) - { - e._final(function (t) - { - r.pendingcb--, t && e.emit("error", t), r.prefinished = !0, e.emit("prefinish"), c(e, r); + + function s(e, r) { + e._final(function(t) { + r.pendingcb-- , t && e.emit("error", t), r.prefinished = !0, e.emit("prefinish"), c(e, r); }); }; - -function c(t,e) - { + + function c(t, e) { var r = u(e); - return r && (e.prefinished || e.finalCalled || ("function" == typeof t._final ? (e.pendingcb++, e.finalCalled = !0, d.nextTick(s, - t, e)) : (e.prefinished = !0, t.emit("prefinish"))), 0 === e.pendingcb && (e.finished = !0, t.emit("finish"))), r; + return r && (e.prefinished || e.finalCalled || ("function" == typeof t._final ? (e.pendingcb++ , e.finalCalled = !0, d.nextTick(s, + t, e)) : (e.prefinished = !0, t.emit("prefinish"))), 0 === e.pendingcb && (e.finished = !0, t.emit("finish"))), r; }; var d = v("process-nextick-args"); M.exports = n; - var p, m = !t.browser && - 1 < ["v0.10", "v0.9."].indexOf(t.version.slice(0, 5)) ? r : d.nextTick; + var p, m = !t.browser && - 1 < ["v0.10", "v0.9."].indexOf(t.version.slice(0, 5)) ? r : d.nextTick; n.WritableState = i, (t = v("core-util-is")).inherits = v("inherits"); - var _ = {deprecate:v("util-deprecate")}, g = v("./internal/streams/stream"), b = v("safe-buffer").Buffer, y = e.Uint8Array || function () - { + var _ = { deprecate: v("util-deprecate") }, g = v("./internal/streams/stream"), b = v("safe-buffer").Buffer, y = e.Uint8Array || function() { }; - if(e = v("./internal/streams/destroy"), t.inherits(n, g), i.prototype.getBuffer = function () - { - for(var t = this.bufferedRequest, e = []; t; ) + if (e = v("./internal/streams/destroy"), t.inherits(n, g), i.prototype.getBuffer = function() { + for (var t = this.bufferedRequest, e = []; t;) e.push(t), t = t.next; return e; - }, function () - { - try - { - Object.defineProperty(i.prototype, "buffer", {get:_.deprecate(function () - { + }, function() { + try { + Object.defineProperty(i.prototype, "buffer", { + get: _.deprecate(function() { return this.getBuffer(); - }, "_writableState.buffer is deprecated. Use _writableState.getBuffer instead.", "DEP0003")}); + }, "_writableState.buffer is deprecated. Use _writableState.getBuffer instead.", "DEP0003") + }); } - catch(t) - { + catch (t) { } - }(), $jscomp.initSymbol(), $jscomp.initSymbol(), $jscomp.initSymbol(), "function" == typeof Symbol && Symbol.hasInstance && "function" == typeof Function.prototype[Symbol.hasInstance]) - { + }(), $jscomp.initSymbol(), $jscomp.initSymbol(), $jscomp.initSymbol(), "function" == typeof Symbol && Symbol.hasInstance && "function" == typeof Function.prototype[Symbol.hasInstance]) { $jscomp.initSymbol(); var w = Function.prototype[Symbol.hasInstance]; - $jscomp.initSymbol(), Object.defineProperty(n, Symbol.hasInstance, {value:function (t) - { + $jscomp.initSymbol(), Object.defineProperty(n, Symbol.hasInstance, { + value: function(t) { return !!w.call(this, t) || this === n && (t && t._writableState instanceof i); - }}); + } + }); } else - w = function (t) - { + w = function(t) { return t instanceof this; }; - n.prototype.pipe = function () - { + n.prototype.pipe = function() { this.emit("error", Error("Cannot pipe, not readable")); - }, n.prototype.write = function (t,e,r) - { + }, n.prototype.write = function(t, e, r) { var i, n = this._writableState, s = !1; - if((i = !n.objectMode) && (i = t, i = b.isBuffer(i) || i instanceof y), i && !b.isBuffer(t) && (t = b.from(t)), "function" == typeof e && (r = e, - e = null), i ? e = "buffer" : e || (e = n.defaultEncoding), "function" != typeof r && (r = l), n.ended) + if ((i = !n.objectMode) && (i = t, i = b.isBuffer(i) || i instanceof y), i && !b.isBuffer(t) && (t = b.from(t)), "function" == typeof e && (r = e, + e = null), i ? e = "buffer" : e || (e = n.defaultEncoding), "function" != typeof r && (r = l), n.ended) n = r, r = Error("write after end"), this.emit("error", r), d.nextTick(n, r); - else - { + else { var o; - if(!(o = i)) - { + if (!(o = i)) { var a = r, h = !0, u = !1; null === (o = t) ? u = new TypeError("May not write null values to stream") : "string" == typeof o || void 0 === o || n.objectMode || (u = new TypeError("Invalid non-string/buffer chunk")), - u && (this.emit("error", u), d.nextTick(a, u), h = !1), o = h; + u && (this.emit("error", u), d.nextTick(a, u), h = !1), o = h; } - o && (n.pendingcb++, (s = i) || (i = t, n.objectMode || !1 === n.decodeStrings || "string" != typeof i || (i = b.from(i, e)), - t !== i && (s = !0, e = "buffer", t = i)), o = n.objectMode ? 1 : t.length, n.length += o, (i = n.length < n.highWaterMark) || (n.needDrain = !0), - n.writing || n.corked ? (o = n.lastBufferedRequest, n.lastBufferedRequest = {chunk:t, encoding:e, isBuf:s, callback:r, next:null}, - o ? o.next = n.lastBufferedRequest : n.bufferedRequest = n.lastBufferedRequest, n.bufferedRequestCount += 1) : f(this, n, !1, - o, t, e, r), s = i); + o && (n.pendingcb++ , (s = i) || (i = t, n.objectMode || !1 === n.decodeStrings || "string" != typeof i || (i = b.from(i, e)), + t !== i && (s = !0, e = "buffer", t = i)), o = n.objectMode ? 1 : t.length, n.length += o, (i = n.length < n.highWaterMark) || (n.needDrain = !0), + n.writing || n.corked ? (o = n.lastBufferedRequest, n.lastBufferedRequest = { chunk: t, encoding: e, isBuf: s, callback: r, next: null }, + o ? o.next = n.lastBufferedRequest : n.bufferedRequest = n.lastBufferedRequest, n.bufferedRequestCount += 1) : f(this, n, !1, + o, t, e, r), s = i); } return s; - }, n.prototype.cork = function () - { + }, n.prototype.cork = function() { this._writableState.corked++; - }, n.prototype.uncork = function () - { + }, n.prototype.uncork = function() { var t = this._writableState; - t.corked && (t.corked--, t.writing || t.corked || t.finished || t.bufferProcessing || !t.bufferedRequest || h(this, t)); - }, n.prototype.setDefaultEncoding = function (t) - { - if("string" == typeof t && (t = t.toLowerCase()), !( - 1 < "hex utf8 utf-8 ascii binary base64 ucs2 ucs-2 utf16le utf-16le raw".split(" ").indexOf((t + "").toLowerCase()))) + t.corked && (t.corked-- , t.writing || t.corked || t.finished || t.bufferProcessing || !t.bufferedRequest || h(this, t)); + }, n.prototype.setDefaultEncoding = function(t) { + if ("string" == typeof t && (t = t.toLowerCase()), !(- 1 < "hex utf8 utf-8 ascii binary base64 ucs2 ucs-2 utf16le utf-16le raw".split(" ").indexOf((t + "").toLowerCase()))) throw new TypeError("Unknown encoding: " + t); return this._writableState.defaultEncoding = t, this; - }, Object.defineProperty(n.prototype, "writableHighWaterMark", {enumerable:!1, get:function () - { + }, Object.defineProperty(n.prototype, "writableHighWaterMark", { + enumerable: !1, get: function() { return this._writableState.highWaterMark; - }}), n.prototype._write = function (t,e,r) - { + } + }), n.prototype._write = function(t, e, r) { r(Error("_write() is not implemented")); - }, n.prototype._writev = null, n.prototype.end = function (t,e,r) - { + }, n.prototype._writev = null, n.prototype.end = function(t, e, r) { var i = this._writableState; "function" == typeof t ? (r = t, e = t = null) : "function" == typeof e && (r = e, e = null), null != t && this.write(t, e), - i.corked && (i.corked = 1, this.uncork()), i.ending || i.finished || (t = r, i.ending = !0, c(this, i), t && (i.finished ? d.nextTick(t) : this.once("finish", - t)), i.ended = !0, this.writable = !1); - }, Object.defineProperty(n.prototype, "destroyed", {get:function () - { + i.corked && (i.corked = 1, this.uncork()), i.ending || i.finished || (t = r, i.ending = !0, c(this, i), t && (i.finished ? d.nextTick(t) : this.once("finish", + t)), i.ended = !0, this.writable = !1); + }, Object.defineProperty(n.prototype, "destroyed", { + get: function() { return void 0 !== this._writableState && this._writableState.destroyed; - }, set:function (t) - { + }, set: function(t) { this._writableState && (this._writableState.destroyed = t); - }}), n.prototype.destroy = e.destroy, n.prototype._undestroy = e.undestroy, n.prototype._destroy = function (t,e) - { + } + }), n.prototype.destroy = e.destroy, n.prototype._undestroy = e.undestroy, n.prototype._destroy = function(t, e) { this.end(), e(t); }; }).call(this, v("_process"), "undefined" != typeof global ? global : "undefined" != typeof self ? self : "undefined" != typeof window ? window : {}, - v("timers").setImmediate); - }, {"./_stream_duplex":13, "./internal/streams/destroy":19, "./internal/streams/stream":20, _process:11, "core-util-is":4, - inherits:7, "process-nextick-args":10, "safe-buffer":25, timers:28, "util-deprecate":29}], 18:[function (t,e,r) - { + v("timers").setImmediate); + }, { + "./_stream_duplex": 13, "./internal/streams/destroy": 19, "./internal/streams/stream": 20, _process: 11, "core-util-is": 4, + inherits: 7, "process-nextick-args": 10, "safe-buffer": 25, timers: 28, "util-deprecate": 29 + }], 18: [function(t, e, r) { var i = t("safe-buffer").Buffer, n = t("util"); - e.exports = function () - { - -function t() - { - if(!(this instanceof t)) + e.exports = function() { + + function t() { + if (!(this instanceof t)) throw new TypeError("Cannot call a class as a function"); this.tail = this.head = null, this.length = 0; }; - return t.prototype.push = function (t) - { - t = {data:t, next:null}, 0 < this.length ? this.tail.next = t : this.head = t, this.tail = t, ++this.length; - }, t.prototype.unshift = function (t) - { - t = {data:t, next:this.head}, 0 === this.length && (this.tail = t), this.head = t, ++this.length; - }, t.prototype.shift = function () - { - if(0 !== this.length) - { + return t.prototype.push = function(t) { + t = { data: t, next: null }, 0 < this.length ? this.tail.next = t : this.head = t, this.tail = t, ++this.length; + }, t.prototype.unshift = function(t) { + t = { data: t, next: this.head }, 0 === this.length && (this.tail = t), this.head = t, ++this.length; + }, t.prototype.shift = function() { + if (0 !== this.length) { var t = this.head.data; return this.head = 1 === this.length ? this.tail = null : this.head.next, --this.length, t; } - }, t.prototype.clear = function () - { + }, t.prototype.clear = function() { this.head = this.tail = null, this.length = 0; - }, t.prototype.join = function (t) - { - if(0 === this.length) + }, t.prototype.join = function(t) { + if (0 === this.length) return ""; - for(var e = this.head, r = "" + e.data; e = e.next; ) + for (var e = this.head, r = "" + e.data; e = e.next;) r += t + e.data; return r; - }, t.prototype.concat = function (t) - { - if(0 === this.length) + }, t.prototype.concat = function(t) { + if (0 === this.length) return i.alloc(0); - if(1 === this.length) + if (1 === this.length) return this.head.data; t = i.allocUnsafe(t >>> 0); - for(var e = this.head, r = 0; e; ) + for (var e = this.head, r = 0; e;) e.data.copy(t, r), r += e.data.length, e = e.next; return t; }, t; - }(), n && n.inspect && n.inspect.custom && (e.exports.prototype[n.inspect.custom] = function () - { - var t = n.inspect({length:this.length}); + }(), n && n.inspect && n.inspect.custom && (e.exports.prototype[n.inspect.custom] = function() { + var t = n.inspect({ length: this.length }); return this.constructor.name + " " + t; }); - }, {"safe-buffer":25, util:2}], 19:[function (t,e,r) - { - -function n(t,e) - { + }, { "safe-buffer": 25, util: 2 }], 19: [function(t, e, r) { + + function n(t, e) { t.emit("error", e); }; var s = t("process-nextick-args"); - e.exports = {destroy:function (t,e) - { + e.exports = { + destroy: function(t, e) { var r = this, i = this._writableState && this._writableState.destroyed; return this._readableState && this._readableState.destroyed || i ? e ? e(t) : !t || this._writableState && this._writableState.errorEmitted || s.nextTick(n, - this, t) : (this._readableState && (this._readableState.destroyed = !0), this._writableState && (this._writableState.destroyed = !0), - this._destroy(t || null, function (t) - { - !e && t ? (s.nextTick(n, r, t), r._writableState && (r._writableState.errorEmitted = !0)) : e && e(t); - })), this; - }, undestroy:function () - { + this, t) : (this._readableState && (this._readableState.destroyed = !0), this._writableState && (this._writableState.destroyed = !0), + this._destroy(t || null, function(t) { + !e && t ? (s.nextTick(n, r, t), r._writableState && (r._writableState.errorEmitted = !0)) : e && e(t); + })), this; + }, undestroy: function() { this._readableState && (this._readableState.destroyed = !1, this._readableState.reading = !1, this._readableState.ended = !1, - this._readableState.endEmitted = !1), this._writableState && (this._writableState.destroyed = !1, this._writableState.ended = !1, - this._writableState.ending = !1, this._writableState.finished = !1, this._writableState.errorEmitted = !1); - }}; - }, {"process-nextick-args":10}], 20:[function (t,e,r) - { + this._readableState.endEmitted = !1), this._writableState && (this._writableState.destroyed = !1, this._writableState.ended = !1, + this._writableState.ending = !1, this._writableState.finished = !1, this._writableState.errorEmitted = !1); + } + }; + }, { "process-nextick-args": 10 }], 20: [function(t, e, r) { e.exports = t("events").EventEmitter; - }, {events:5}], 21:[function (t,e,r) - { + }, { events: 5 }], 21: [function(t, e, r) { e.exports = t("./readable").PassThrough; - }, {"./readable":22}], 22:[function (t,e,r) - { + }, { "./readable": 22 }], 22: [function(t, e, r) { (((r = e.exports = t("./lib/_stream_readable.js")).Stream = r).Readable = r).Writable = t("./lib/_stream_writable.js"), r.Duplex = t("./lib/_stream_duplex.js"), - r.Transform = t("./lib/_stream_transform.js"), r.PassThrough = t("./lib/_stream_passthrough.js"); - }, {"./lib/_stream_duplex.js":13, "./lib/_stream_passthrough.js":14, "./lib/_stream_readable.js":15, "./lib/_stream_transform.js":16, - "./lib/_stream_writable.js":17}], 23:[function (t,e,r) - { + r.Transform = t("./lib/_stream_transform.js"), r.PassThrough = t("./lib/_stream_passthrough.js"); + }, { + "./lib/_stream_duplex.js": 13, "./lib/_stream_passthrough.js": 14, "./lib/_stream_readable.js": 15, "./lib/_stream_transform.js": 16, + "./lib/_stream_writable.js": 17 + }], 23: [function(t, e, r) { e.exports = t("./readable").Transform; - }, {"./readable":22}], 24:[function (t,e,r) - { + }, { "./readable": 22 }], 24: [function(t, e, r) { e.exports = t("./lib/_stream_writable.js"); - }, {"./lib/_stream_writable.js":17}], 25:[function (t,e,r) - { - -function i(t,e) - { - for(var r in t) + }, { "./lib/_stream_writable.js": 17 }], 25: [function(t, e, r) { + + function i(t, e) { + for (var r in t) e[r] = t[r]; }; - -function n(t,e,r) - { + + function n(t, e, r) { return o(t, e, r); }; var s = t("buffer"), o = s.Buffer; - o.from && o.alloc && o.allocUnsafe && o.allocUnsafeSlow ? e.exports = s : (i(s, r), r.Buffer = n), i(o, n), n.from = function (t,e,r) - { - if("number" == typeof t) + o.from && o.alloc && o.allocUnsafe && o.allocUnsafeSlow ? e.exports = s : (i(s, r), r.Buffer = n), i(o, n), n.from = function(t, e, r) { + if ("number" == typeof t) throw new TypeError("Argument must not be a number"); return o(t, e, r); - }, n.alloc = function (t,e,r) - { - if("number" != typeof t) + }, n.alloc = function(t, e, r) { + if ("number" != typeof t) throw new TypeError("Argument must be a number"); return t = o(t), void 0 !== e ? "string" == typeof r ? t.fill(e, r) : t.fill(e) : t.fill(0), t; - }, n.allocUnsafe = function (t) - { - if("number" != typeof t) + }, n.allocUnsafe = function(t) { + if ("number" != typeof t) throw new TypeError("Argument must be a number"); return o(t); - }, n.allocUnsafeSlow = function (t) - { - if("number" != typeof t) + }, n.allocUnsafeSlow = function(t) { + if ("number" != typeof t) throw new TypeError("Argument must be a number"); return s.SlowBuffer(t); }; - }, {buffer:3}], 26:[function (t,e,r) - { - -function i() - { + }, { buffer: 3 }], 26: [function(t, e, r) { + + function i() { l.call(this); }; e.exports = i; var l = t("events").EventEmitter; t("inherits")(i, l), i.Readable = t("readable-stream/readable.js"), i.Writable = t("readable-stream/writable.js"), i.Duplex = t("readable-stream/duplex.js"), - i.Transform = t("readable-stream/transform.js"), i.PassThrough = t("readable-stream/passthrough.js"), (i.Stream = i).prototype.pipe = function (e,t) - { - -function r(t) - { - e.writable && !1 === e.write(t) && h.pause && h.pause(); + i.Transform = t("readable-stream/transform.js"), i.PassThrough = t("readable-stream/passthrough.js"), (i.Stream = i).prototype.pipe = function(e, t) { + + function r(t) { + e.writable && !1 === e.write(t) && h.pause && h.pause(); + }; + + function i() { + h.readable && h.resume && h.resume(); + }; + + function n() { + u || (u = !0, e.end()); + }; + + function s() { + u || (u = !0, "function" == typeof e.destroy && e.destroy()); + }; + + function o(t) { + if (a(), 0 === l.listenerCount(this, "error")) + throw t; + }; + + function a() { + h.removeListener("data", r), e.removeListener("drain", i), h.removeListener("end", n), h.removeListener("close", s), h.removeListener("error", + o), e.removeListener("error", o), h.removeListener("end", a), h.removeListener("close", a), e.removeListener("close", a); + }; + var h = this; + h.on("data", r), e.on("drain", i), e._isStdio || t && !1 === t.end || (h.on("end", n), h.on("close", s)); + var u = !1; + return h.on("error", o), e.on("error", o), h.on("end", a), h.on("close", a), e.on("close", a), e.emit("pipe", h), e; }; - -function i() - { - h.readable && h.resume && h.resume(); - }; - -function n() - { - u || (u = !0, e.end()); - }; - -function s() - { - u || (u = !0, "function" == typeof e.destroy && e.destroy()); - }; - -function o(t) - { - if(a(), 0 === l.listenerCount(this, "error")) - throw t; - }; - -function a() - { - h.removeListener("data", r), e.removeListener("drain", i), h.removeListener("end", n), h.removeListener("close", s), h.removeListener("error", - o), e.removeListener("error", o), h.removeListener("end", a), h.removeListener("close", a), e.removeListener("close", a); - }; - var h = this; - h.on("data", r), e.on("drain", i), e._isStdio || t && !1 === t.end || (h.on("end", n), h.on("close", s)); - var u = !1; - return h.on("error", o), e.on("error", o), h.on("end", a), h.on("close", a), e.on("close", a), e.emit("pipe", h), e; - }; - }, {events:5, inherits:7, "readable-stream/duplex.js":12, "readable-stream/passthrough.js":21, "readable-stream/readable.js":22, - "readable-stream/transform.js":23, "readable-stream/writable.js":24}], 27:[function (t,e,r) - { - -function i(t) - { - var e = function (t) - { - if(!t) + }, { + events: 5, inherits: 7, "readable-stream/duplex.js": 12, "readable-stream/passthrough.js": 21, "readable-stream/readable.js": 22, + "readable-stream/transform.js": 23, "readable-stream/writable.js": 24 + }], 27: [function(t, e, r) { + + function i(t) { + var e = function(t) { + if (!t) return "utf8"; - for(var e; ; ) - switch(t) - { + for (var e; ;) + switch (t) { case "utf8": case "utf-8": return "utf8"; @@ -2441,15 +2049,14 @@ function i(t) case "hex": return t; default: - if(e) - return ; + if (e) + return; t = ("" + t).toLowerCase(), e = !0; } }(t); - if("string" != typeof e && (c.isEncoding === d || !d(t))) + if ("string" != typeof e && (c.isEncoding === d || !d(t))) throw Error("Unknown encoding: " + t); - switch(this.encoding = e || t, this.encoding) - { + switch (this.encoding = e || t, this.encoding) { case "utf16le": this.text = o, this.end = a, t = 4; break; @@ -2464,32 +2071,25 @@ function i(t) } this.lastTotal = this.lastNeed = 0, this.lastChar = c.allocUnsafe(t); }; - -function s(t) - { - return t <= 127 ? 0 : 6 == t >> 5 ? 2 : 14 == t >> 4 ? 3 : 30 == t >> 3 ? 4 : 2 == t >> 6 ? - 1 : - 2; + + function s(t) { + return t <= 127 ? 0 : 6 == t >> 5 ? 2 : 14 == t >> 4 ? 3 : 30 == t >> 3 ? 4 : 2 == t >> 6 ? - 1 : - 2; }; - -function n(t) - { + + function n(t) { var e = this.lastTotal - this.lastNeed; t: - if(128 != (192 & t[0])) - { + if (128 != (192 & t[0])) { this.lastNeed = 0; var r = "�"; } - else - { - if(1 < this.lastNeed && 1 < t.length) - { - if(128 != (192 & t[1])) - { + else { + if (1 < this.lastNeed && 1 < t.length) { + if (128 != (192 & t[1])) { this.lastNeed = 1, r = "�"; break t; } - if(2 < this.lastNeed && 2 < t.length && 128 != (192 & t[2])) - { + if (2 < this.lastNeed && 2 < t.length && 128 != (192 & t[2])) { this.lastNeed = 2, r = "�"; break t; } @@ -2497,54 +2097,45 @@ function n(t) r = void 0; } return void 0 !== r ? r : this.lastNeed <= t.length ? (t.copy(this.lastChar, e, 0, this.lastNeed), this.lastChar.toString(this.encoding, - 0, this.lastTotal)) : (t.copy(this.lastChar, e, 0, t.length), void (this.lastNeed -= t.length)); + 0, this.lastTotal)) : (t.copy(this.lastChar, e, 0, t.length), void (this.lastNeed -= t.length)); }; - -function o(t,e) - { - if(0 != (t.length - e) % 2) + + function o(t, e) { + if (0 != (t.length - e) % 2) return this.lastNeed = 1, this.lastTotal = 2, this.lastChar[0] = t[t.length - 1], t.toString("utf16le", e, t.length - 1); var r = t.toString("utf16le", e); - if(r) - { + if (r) { var i = r.charCodeAt(r.length - 1); - if(55296 <= i && i <= 56319) + if (55296 <= i && i <= 56319) return this.lastNeed = 2, this.lastTotal = 4, this.lastChar[0] = t[t.length - 2], this.lastChar[1] = t[t.length - 1], r.slice(0, - - 1); + - 1); } return r; }; - -function a(t) - { + + function a(t) { return t = t && t.length ? this.write(t) : "", this.lastNeed ? t + this.lastChar.toString("utf16le", 0, this.lastTotal - this.lastNeed) : t; }; - -function h(t,e) - { + + function h(t, e) { var r = (t.length - e) % 3; return 0 === r ? t.toString("base64", e) : (this.lastNeed = 3 - r, this.lastTotal = 3, 1 === r ? this.lastChar[0] = t[t.length - 1] : (this.lastChar[0] = t[t.length - 2], - this.lastChar[1] = t[t.length - 1]), t.toString("base64", e, t.length - r)); + this.lastChar[1] = t[t.length - 1]), t.toString("base64", e, t.length - r)); }; - -function u(t) - { + + function u(t) { return t = t && t.length ? this.write(t) : "", this.lastNeed ? t + this.lastChar.toString("base64", 0, 3 - this.lastNeed) : t; }; - -function l(t) - { + + function l(t) { return t.toString(this.encoding); }; - -function f(t) - { + + function f(t) { return t && t.length ? this.write(t) : ""; }; - var c = t("safe-buffer").Buffer, d = c.isEncoding || function (t) - { - switch((t = "" + t) && t.toLowerCase()) - { + var c = t("safe-buffer").Buffer, d = c.isEncoding || function(t) { + switch ((t = "" + t) && t.toLowerCase()) { case "hex": case "utf8": case "utf-8": @@ -2561,14 +2152,12 @@ function f(t) return !1; } }; - (r.StringDecoder = i).prototype.write = function (t) - { - if(0 === t.length) + (r.StringDecoder = i).prototype.write = function(t) { + if (0 === t.length) return ""; - if(this.lastNeed) - { + if (this.lastNeed) { var e = this.fillLast(t); - if(void 0 === e) + if (void 0 === e) return ""; var r = this.lastNeed; this.lastNeed = 0; @@ -2576,106 +2165,79 @@ function f(t) else r = 0; return r < t.length ? e ? e + this.text(t, r) : this.text(t, r) : e || ""; - }, i.prototype.end = function (t) - { + }, i.prototype.end = function(t) { return t = t && t.length ? this.write(t) : "", this.lastNeed ? t + "�" : t; - }, i.prototype.text = function (t,e) - { - var r = function (t,e,r) - { + }, i.prototype.text = function(t, e) { + var r = function(t, e, r) { var i = e.length - 1; - if(i < r) + if (i < r) return 0; var n = s(e[i]); - return 0 <= n ? (0 < n && (t.lastNeed = n - 1), n) : --i < r || - 2 === n ? 0 : 0 <= (n = s(e[i])) ? (0 < n && (t.lastNeed = n - 2), - n) : --i < r || - 2 === n ? 0 : 0 <= (n = s(e[i])) ? (0 < n && (2 === n ? n = 0 : t.lastNeed = n - 3), n) : 0; + return 0 <= n ? (0 < n && (t.lastNeed = n - 1), n) : --i < r || - 2 === n ? 0 : 0 <= (n = s(e[i])) ? (0 < n && (t.lastNeed = n - 2), + n) : --i < r || - 2 === n ? 0 : 0 <= (n = s(e[i])) ? (0 < n && (2 === n ? n = 0 : t.lastNeed = n - 3), n) : 0; }(this, t, e); return this.lastNeed ? (this.lastTotal = r, r = t.length - (r - this.lastNeed), t.copy(this.lastChar, 0, r), t.toString("utf8", - e, r)) : t.toString("utf8", e); - }, i.prototype.fillLast = function (t) - { - if(this.lastNeed <= t.length) + e, r)) : t.toString("utf8", e); + }, i.prototype.fillLast = function(t) { + if (this.lastNeed <= t.length) return t.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed), this.lastChar.toString(this.encoding, 0, this.lastTotal); t.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, t.length), this.lastNeed -= t.length; }; - }, {"safe-buffer":25}], 28:[function (h,t,u) - { - (function (t,e) - { - -function r(t,e) - { + }, { "safe-buffer": 25 }], 28: [function(h, t, u) { + (function(t, e) { + + function r(t, e) { this._id = t, this._clearFn = e; }; var i = h("process/browser.js").nextTick, n = Function.prototype.apply, s = Array.prototype.slice, o = {}, a = 0; - u.setTimeout = function () - { + u.setTimeout = function() { return new r(n.call(setTimeout, window, arguments), clearTimeout); - }, u.setInterval = function () - { + }, u.setInterval = function() { return new r(n.call(setInterval, window, arguments), clearInterval); - }, u.clearTimeout = u.clearInterval = function (t) - { + }, u.clearTimeout = u.clearInterval = function(t) { t.close(); - }, r.prototype.unref = r.prototype.ref = function () - { - }, r.prototype.close = function () - { + }, r.prototype.unref = r.prototype.ref = function() { + }, r.prototype.close = function() { this._clearFn.call(window, this._id); - }, u.enroll = function (t,e) - { + }, u.enroll = function(t, e) { clearTimeout(t._idleTimeoutId), t._idleTimeout = e; - }, u.unenroll = function (t) - { - clearTimeout(t._idleTimeoutId), t._idleTimeout = - 1; - }, u._unrefActive = u.active = function (t) - { + }, u.unenroll = function(t) { + clearTimeout(t._idleTimeoutId), t._idleTimeout = - 1; + }, u._unrefActive = u.active = function(t) { clearTimeout(t._idleTimeoutId); var e = t._idleTimeout; - 0 <= e && (t._idleTimeoutId = setTimeout(function () - { + 0 <= e && (t._idleTimeoutId = setTimeout(function() { t._onTimeout && t._onTimeout(); }, e)); - }, u.setImmediate = "function" == typeof t ? t : function (t) - { + }, u.setImmediate = "function" == typeof t ? t : function(t) { var e = a++, r = !(arguments.length < 2) && s.call(arguments, 1); - return o[e] = !0, i(function () - { + return o[e] = !0, i(function() { o[e] && (r ? t.apply(null, r) : t.call(null), u.clearImmediate(e)); }), e; - }, u.clearImmediate = "function" == typeof e ? e : function (t) - { + }, u.clearImmediate = "function" == typeof e ? e : function(t) { delete o[t]; }; }).call(this, h("timers").setImmediate, h("timers").clearImmediate); - }, {"process/browser.js":11, timers:28}], 29:[function (t,r,e) - { - (function (e) - { - -function i(t) - { - try - { - if(!e.localStorage) + }, { "process/browser.js": 11, timers: 28 }], 29: [function(t, r, e) { + (function(e) { + + function i(t) { + try { + if (!e.localStorage) return !1; } - catch(t) - { + catch (t) { return !1; } return null != (t = e.localStorage[t]) && "true" === String(t).toLowerCase(); }; - r.exports = function (t,e) - { - if(i("noDeprecation")) + r.exports = function(t, e) { + if (i("noDeprecation")) return t; var r = !1; - return function () - { - if(!r) - { - if(i("throwDeprecation")) + return function() { + if (!r) { + if (i("throwDeprecation")) throw Error(e); i("traceDeprecation") ? console.trace(e) : console.warn(e), r = !0; } @@ -2683,416 +2245,342 @@ function i(t) }; }; }).call(this, "undefined" != typeof global ? global : "undefined" != typeof self ? self : "undefined" != typeof window ? window : {}); - }, {}], 30:[function (t,e,r) - { + }, {}], 30: [function(t, e, r) { window.SignLib = t("secp256k1/lib/js"), window.Buffer = t("safe-buffer").Buffer; - }, {"safe-buffer":42, "secp256k1/lib/js":48}], 31:[function (t,e,r) - { - -function i(t) - { + }, { "safe-buffer": 42, "secp256k1/lib/js": 48 }], 31: [function(t, e, r) { + + function i(t) { s.call(this), (this.hashMode = "string" == typeof t) ? this[t] = this._finalOrDigest : this.final = this._finalOrDigest, this._final && (this.__final = this._final, - this._final = null), this._encoding = this._decoder = null; + this._final = null), this._encoding = this._decoder = null; }; var n = t("safe-buffer").Buffer, s = t("stream").Transform, o = t("string_decoder").StringDecoder; - t("inherits")(i, s), i.prototype.update = function (t,e,r) - { + t("inherits")(i, s), i.prototype.update = function(t, e, r) { return "string" == typeof t && (t = n.from(t, e)), t = this._update(t), this.hashMode ? this : (r && (t = this._toString(t, - r)), t); - }, i.prototype.setAutoPadding = function () - { - }, i.prototype.getAuthTag = function () - { + r)), t); + }, i.prototype.setAutoPadding = function() { + }, i.prototype.getAuthTag = function() { throw Error("trying to get auth tag in unsupported state"); - }, i.prototype.setAuthTag = function () - { + }, i.prototype.setAuthTag = function() { throw Error("trying to set auth tag in unsupported state"); - }, i.prototype.setAAD = function () - { + }, i.prototype.setAAD = function() { throw Error("trying to set aad in unsupported state"); - }, i.prototype._transform = function (t,e,r) - { - try - { + }, i.prototype._transform = function(t, e, r) { + try { this.hashMode ? this._update(t) : this.push(this._update(t)); } - catch(t) - { + catch (t) { var i = t; } - finally - { + finally { r(i); } - }, i.prototype._flush = function (t) - { - try - { + }, i.prototype._flush = function(t) { + try { this.push(this.__final()); } - catch(t) - { + catch (t) { var e = t; } t(e); - }, i.prototype._finalOrDigest = function (t) - { + }, i.prototype._finalOrDigest = function(t) { var e = this.__final() || n.alloc(0); return t && (e = this._toString(e, t, !0)), e; - }, i.prototype._toString = function (t,e,r) - { - if(this._decoder || (this._decoder = new o(e), this._encoding = e), this._encoding !== e) + }, i.prototype._toString = function(t, e, r) { + if (this._decoder || (this._decoder = new o(e), this._encoding = e), this._encoding !== e) throw Error("can't switch encodings"); return t = this._decoder.write(t), r && (t += this._decoder.end()), t; }, e.exports = i; - }, {inherits:39, "safe-buffer":42, stream:26, string_decoder:27}], 32:[function (t,e,r) - { - -function i(t) - { + }, { inherits: 39, "safe-buffer": 42, stream: 26, string_decoder: 27 }], 32: [function(t, e, r) { + + function i(t) { a.call(this, "digest"), this._hash = t; }; r = t("inherits"); var n = t("md5.js"), s = t("ripemd160"), o = t("sha.js"), a = t("cipher-base"); - r(i, a), i.prototype._update = function (t) - { + r(i, a), i.prototype._update = function(t) { this._hash.update(t); - }, i.prototype._final = function () - { + }, i.prototype._final = function() { return this._hash.digest(); - }, e.exports = function (t) - { + }, e.exports = function(t) { return "md5" === (t = t.toLowerCase()) ? new n : "rmd160" === t || "ripemd160" === t ? new s : new i(o(t)); }; - }, {"cipher-base":31, inherits:39, "md5.js":40, ripemd160:41, "sha.js":51}], 33:[function (t,e,r) - { + }, { "cipher-base": 31, inherits: 39, "md5.js": 40, ripemd160: 41, "sha.js": 51 }], 33: [function(t, e, r) { var i = t("md5.js"); - e.exports = function (t) - { + e.exports = function(t) { return (new i).update(t).digest(); }; - }, {"md5.js":40}], 34:[function (t,e,r) - { - -function i(t,e) - { + }, { "md5.js": 40 }], 34: [function(t, e, r) { + + function i(t, e) { o.call(this, "digest"), "string" == typeof e && (e = a.from(e)); var r = "sha512" === t || "sha384" === t ? 128 : 64; this._alg = t, (this._key = e).length > r ? e = ("rmd160" === t ? new h : u(t)).update(e).digest() : e.length < r && (e = a.concat([e, - l], r)); - for(var i = this._ipad = a.allocUnsafe(r), n = this._opad = a.allocUnsafe(r), s = 0; s < r; s++) + l], r)); + for (var i = this._ipad = a.allocUnsafe(r), n = this._opad = a.allocUnsafe(r), s = 0; s < r; s++) i[s] = 54 ^ e[s], n[s] = 92 ^ e[s]; this._hash = "rmd160" === t ? new h : u(t), this._hash.update(i); }; r = t("inherits"); var n = t("./legacy"), o = t("cipher-base"), a = t("safe-buffer").Buffer, s = t("create-hash/md5"), h = t("ripemd160"), u = t("sha.js"), - l = a.alloc(128); - r(i, o), i.prototype._update = function (t) - { + l = a.alloc(128); + r(i, o), i.prototype._update = function(t) { this._hash.update(t); - }, i.prototype._final = function () - { + }, i.prototype._final = function() { var t = this._hash.digest(); return ("rmd160" === this._alg ? new h : u(this._alg)).update(this._opad).update(t).digest(); - }, e.exports = function (t,e) - { + }, e.exports = function(t, e) { return "rmd160" === (t = t.toLowerCase()) || "ripemd160" === t ? new i("rmd160", e) : "md5" === t ? new n(s, e) : new i(t, - e); + e); }; - }, {"./legacy":35, "cipher-base":31, "create-hash/md5":33, inherits:39, ripemd160:41, "safe-buffer":42, "sha.js":51}], 35:[function (t,e,r) - { - -function i(t,e) - { + }, { "./legacy": 35, "cipher-base": 31, "create-hash/md5": 33, inherits: 39, ripemd160: 41, "safe-buffer": 42, "sha.js": 51 }], 35: [function(t, e, r) { + + function i(t, e) { o.call(this, "digest"), "string" == typeof e && (e = s.from(e)), this._alg = t, 64 < (this._key = e).length ? e = t(e) : e.length < 64 && (e = s.concat([e, - a], 64)); - for(var r = this._ipad = s.allocUnsafe(64), i = this._opad = s.allocUnsafe(64), n = 0; n < 64; n++) + a], 64)); + for (var r = this._ipad = s.allocUnsafe(64), i = this._opad = s.allocUnsafe(64), n = 0; n < 64; n++) r[n] = 54 ^ e[n], i[n] = 92 ^ e[n]; this._hash = [r]; }; r = t("inherits"); var s = t("safe-buffer").Buffer, o = t("cipher-base"), a = s.alloc(128); - r(i, o), i.prototype._update = function (t) - { + r(i, o), i.prototype._update = function(t) { this._hash.push(t); - }, i.prototype._final = function () - { + }, i.prototype._final = function() { var t = this._alg(s.concat(this._hash)); return this._alg(s.concat([this._opad, t])); }, e.exports = i; - }, {"cipher-base":31, inherits:39, "safe-buffer":42}], 36:[function (e,h,t) - { - (function (n) - { - -function t(t,e,r,i) - { + }, { "cipher-base": 31, inherits: 39, "safe-buffer": 42 }], 36: [function(e, h, t) { + (function(n) { + + function t(t, e, r, i) { var n = s[t]; - if(void 0 === n) + if (void 0 === n) throw Error("hash " + t + " is not supported"); this._algo = t, this._securityStrength = n.securityStrength / 8, this._outlen = n.outlen / 8, this._reseedInterval = 281474976710656, - this._init(e, r, i); + this._init(e, r, i); }; var i = e("create-hmac"), s = e("./lib/hash-info.json"), o = new n(0), r = new n([0]), a = new n([1]); - t.prototype._update = function (t) - { + t.prototype._update = function(t) { var e = i(this._algo, this._K).update(this._V).update(r); t && e.update(t), this._K = e.digest(), this._V = i(this._algo, this._K).update(this._V).digest(), t && (this._K = i(this._algo, - this._K).update(this._V).update(a).update(t).digest(), this._V = i(this._algo, this._K).update(this._V).digest()); - }, t.prototype._init = function (t,e,r) - { - if(t.length < this._securityStrength) + this._K).update(this._V).update(a).update(t).digest(), this._V = i(this._algo, this._K).update(this._V).digest()); + }, t.prototype._init = function(t, e, r) { + if (t.length < this._securityStrength) throw Error("Not enough entropy"); this._K = new n(this._outlen), this._V = new n(this._outlen); - for(var i = 0; i < this._K.length; ++i) + for (var i = 0; i < this._K.length; ++i) this._K[i] = 0, this._V[i] = 1; this._update(n.concat([t, e, r || o])), this._reseed = 1; - }, t.prototype.reseed = function (t,e) - { - if(t.length < this._securityStrength) + }, t.prototype.reseed = function(t, e) { + if (t.length < this._securityStrength) throw Error("Not enough entropy"); this._update(n.concat([t, e || o])), this._reseed = 1; - }, t.prototype.generate = function (t,e) - { - if(this._reseed > this._reseedInterval) + }, t.prototype.generate = function(t, e) { + if (this._reseed > this._reseedInterval) throw Error("Reseed is required"); e && 0 === e.length && (e = void 0), e && this._update(e); - for(var r = new n(0); r.length < t; ) + for (var r = new n(0); r.length < t;) this._V = i(this._algo, this._K).update(this._V).digest(), r = n.concat([r, this._V]); return this._update(e), this._reseed += 1, r.slice(0, t); }, h.exports = t; }).call(this, e("buffer").Buffer); - }, {"./lib/hash-info.json":37, buffer:3, "create-hmac":34}], 37:[function (t,e,r) - { - e.exports = {sha1:{securityStrength:128, outlen:160, seedlen:440}, sha224:{securityStrength:192, outlen:224, seedlen:440}, - sha256:{securityStrength:256, outlen:256, seedlen:440}, sha384:{securityStrength:256, outlen:384, seedlen:888}, sha512:{securityStrength:256, - outlen:512, seedlen:888}}; - }, {}], 38:[function (t,e,r) - { - -function i(t) - { + }, { "./lib/hash-info.json": 37, buffer: 3, "create-hmac": 34 }], 37: [function(t, e, r) { + e.exports = { + sha1: { securityStrength: 128, outlen: 160, seedlen: 440 }, sha224: { securityStrength: 192, outlen: 224, seedlen: 440 }, + sha256: { securityStrength: 256, outlen: 256, seedlen: 440 }, sha384: { securityStrength: 256, outlen: 384, seedlen: 888 }, sha512: { + securityStrength: 256, + outlen: 512, seedlen: 888 + } + }; + }, {}], 38: [function(t, e, r) { + + function i(t) { n.call(this), this._block = s.allocUnsafe(t), this._blockSize = t, this._blockOffset = 0, this._length = [0, 0, 0, 0], this._finalized = !1; }; var s = t("safe-buffer").Buffer, n = t("stream").Transform; - t("inherits")(i, n), i.prototype._transform = function (t,e,r) - { + t("inherits")(i, n), i.prototype._transform = function(t, e, r) { var i = null; - try - { + try { this.update(t, e); } - catch(t) - { + catch (t) { i = t; } r(i); - }, i.prototype._flush = function (t) - { + }, i.prototype._flush = function(t) { var e = null; - try - { + try { this.push(this.digest()); } - catch(t) - { + catch (t) { e = t; } t(e); - }, i.prototype.update = function (t,e) - { + }, i.prototype.update = function(t, e) { var r = t; - if(!s.isBuffer(r) && "string" != typeof r) + if (!s.isBuffer(r) && "string" != typeof r) throw new TypeError("Data must be a string or a buffer"); - if(this._finalized) + if (this._finalized) throw Error("Digest already called"); s.isBuffer(t) || (t = s.from(t, e)), r = this._block; - for(var i = 0; this._blockOffset + t.length - i >= this._blockSize; ) - { - for(var n = this._blockOffset; n < this._blockSize; ) + for (var i = 0; this._blockOffset + t.length - i >= this._blockSize;) { + for (var n = this._blockOffset; n < this._blockSize;) r[n++] = t[i++]; this._update(), this._blockOffset = 0; } - for(; i < t.length; ) + for (; i < t.length;) r[this._blockOffset++] = t[i++]; - for(r = 0, i = 8 * t.length; 0 < i; ++r) + for (r = 0, i = 8 * t.length; 0 < i; ++r) this._length[r] += i, 0 < (i = this._length[r] / 4294967296 | 0) && (this._length[r] -= 4294967296 * i); return this; - }, i.prototype._update = function () - { + }, i.prototype._update = function() { throw Error("_update is not implemented"); - }, i.prototype.digest = function (t) - { - if(this._finalized) + }, i.prototype.digest = function(t) { + if (this._finalized) throw Error("Digest already called"); this._finalized = !0; var e = this._digest(); - for(void 0 !== t && (e = e.toString(t)), this._block.fill(0), t = this._blockOffset = 0; t < 4; ++t) + for (void 0 !== t && (e = e.toString(t)), this._block.fill(0), t = this._blockOffset = 0; t < 4; ++t) this._length[t] = 0; return e; - }, i.prototype._digest = function () - { + }, i.prototype._digest = function() { throw Error("_digest is not implemented"); }, e.exports = i; - }, {inherits:39, "safe-buffer":42, stream:26}], 39:[function (t,e,r) - { + }, { inherits: 39, "safe-buffer": 42, stream: 26 }], 39: [function(t, e, r) { arguments[4][7][0].apply(r, arguments); - }, {dup:7}], 40:[function (l,f,t) - { - (function (e) - { - -function t() - { + }, { dup: 7 }], 40: [function(l, f, t) { + (function(e) { + + function t() { i.call(this, 64), this._a = 1732584193, this._b = 4023233417, this._c = 2562383102, this._d = 271733878; }; - -function a(t,e) - { + + function a(t, e) { return t << e | t >>> 32 - e; }; - -function n(t,e,r,i,n,s,o) - { + + function n(t, e, r, i, n, s, o) { return a(t + (e & r | ~e & i) + n + s | 0, o) + e | 0; }; - -function s(t,e,r,i,n,s,o) - { + + function s(t, e, r, i, n, s, o) { return a(t + (e & i | r & ~i) + n + s | 0, o) + e | 0; }; - -function o(t,e,r,i,n,s,o) - { + + function o(t, e, r, i, n, s, o) { return a(t + (e ^ r ^ i) + n + s | 0, o) + e | 0; }; - -function h(t,e,r,i,n,s,o) - { + + function h(t, e, r, i, n, s, o) { return a(t + (r ^ (e | ~i)) + n + s | 0, o) + e | 0; }; var r = l("inherits"), i = l("hash-base"), u = Array(16); - r(t, i), t.prototype._update = function () - { - for(var t = 0; t < 16; ++t) + r(t, i), t.prototype._update = function() { + for (var t = 0; t < 16; ++t) u[t] = this._block.readInt32LE(4 * t); t = this._a; var e = this._b, r = this._c, i = this._d; e = h(e = h(e = h(e = h(e = o(e = o(e = o(e = o(e = s(e = s(e = s(e = s(e = n(e = n(e = n(e = n(e, r = n(r, i = n(i, t = n(t, - e, r, i, u[0], 3614090360, 7), e, r, u[1], 3905402710, 12), t, e, u[2], 606105819, 17), i, t, u[3], 3250441966, 22), r = n(r, - i = n(i, t = n(t, e, r, i, u[4], 4118548399, 7), e, r, u[5], 1200080426, 12), t, e, u[6], 2821735955, 17), i, t, u[7], 4249261313, - 22), r = n(r, i = n(i, t = n(t, e, r, i, u[8], 1770035416, 7), e, r, u[9], 2336552879, 12), t, e, u[10], 4294925233, 17), i, - t, u[11], 2304563134, 22), r = n(r, i = n(i, t = n(t, e, r, i, u[12], 1804603682, 7), e, r, u[13], 4254626195, 12), t, e, u[14], - 2792965006, 17), i, t, u[15], 1236535329, 22), r = s(r, i = s(i, t = s(t, e, r, i, u[1], 4129170786, 5), e, r, u[6], 3225465664, - 9), t, e, u[11], 643717713, 14), i, t, u[0], 3921069994, 20), r = s(r, i = s(i, t = s(t, e, r, i, u[5], 3593408605, 5), e, - r, u[10], 38016083, 9), t, e, u[15], 3634488961, 14), i, t, u[4], 3889429448, 20), r = s(r, i = s(i, t = s(t, e, r, i, u[9], - 568446438, 5), e, r, u[14], 3275163606, 9), t, e, u[3], 4107603335, 14), i, t, u[8], 1163531501, 20), r = s(r, i = s(i, t = s(t, - e, r, i, u[13], 2850285829, 5), e, r, u[2], 4243563512, 9), t, e, u[7], 1735328473, 14), i, t, u[12], 2368359562, 20), r = o(r, - i = o(i, t = o(t, e, r, i, u[5], 4294588738, 4), e, r, u[8], 2272392833, 11), t, e, u[11], 1839030562, 16), i, t, u[14], 4259657740, - 23), r = o(r, i = o(i, t = o(t, e, r, i, u[1], 2763975236, 4), e, r, u[4], 1272893353, 11), t, e, u[7], 4139469664, 16), i, - t, u[10], 3200236656, 23), r = o(r, i = o(i, t = o(t, e, r, i, u[13], 681279174, 4), e, r, u[0], 3936430074, 11), t, e, u[3], - 3572445317, 16), i, t, u[6], 76029189, 23), r = o(r, i = o(i, t = o(t, e, r, i, u[9], 3654602809, 4), e, r, u[12], 3873151461, - 11), t, e, u[15], 530742520, 16), i, t, u[2], 3299628645, 23), r = h(r, i = h(i, t = h(t, e, r, i, u[0], 4096336452, 6), e, - r, u[7], 1126891415, 10), t, e, u[14], 2878612391, 15), i, t, u[5], 4237533241, 21), r = h(r, i = h(i, t = h(t, e, r, i, u[12], - 1700485571, 6), e, r, u[3], 2399980690, 10), t, e, u[10], 4293915773, 15), i, t, u[1], 2240044497, 21), r = h(r, i = h(i, t = h(t, - e, r, i, u[8], 1873313359, 6), e, r, u[15], 4264355552, 10), t, e, u[6], 2734768916, 15), i, t, u[13], 1309151649, 21), r = h(r, - i = h(i, t = h(t, e, r, i, u[4], 4149444226, 6), e, r, u[11], 3174756917, 10), t, e, u[2], 718787259, 15), i, t, u[9], 3951481745, - 21), this._a = this._a + t | 0, this._b = this._b + e | 0, this._c = this._c + r | 0, this._d = this._d + i | 0; - }, t.prototype._digest = function () - { + e, r, i, u[0], 3614090360, 7), e, r, u[1], 3905402710, 12), t, e, u[2], 606105819, 17), i, t, u[3], 3250441966, 22), r = n(r, + i = n(i, t = n(t, e, r, i, u[4], 4118548399, 7), e, r, u[5], 1200080426, 12), t, e, u[6], 2821735955, 17), i, t, u[7], 4249261313, + 22), r = n(r, i = n(i, t = n(t, e, r, i, u[8], 1770035416, 7), e, r, u[9], 2336552879, 12), t, e, u[10], 4294925233, 17), i, + t, u[11], 2304563134, 22), r = n(r, i = n(i, t = n(t, e, r, i, u[12], 1804603682, 7), e, r, u[13], 4254626195, 12), t, e, u[14], + 2792965006, 17), i, t, u[15], 1236535329, 22), r = s(r, i = s(i, t = s(t, e, r, i, u[1], 4129170786, 5), e, r, u[6], 3225465664, + 9), t, e, u[11], 643717713, 14), i, t, u[0], 3921069994, 20), r = s(r, i = s(i, t = s(t, e, r, i, u[5], 3593408605, 5), e, + r, u[10], 38016083, 9), t, e, u[15], 3634488961, 14), i, t, u[4], 3889429448, 20), r = s(r, i = s(i, t = s(t, e, r, i, u[9], + 568446438, 5), e, r, u[14], 3275163606, 9), t, e, u[3], 4107603335, 14), i, t, u[8], 1163531501, 20), r = s(r, i = s(i, t = s(t, + e, r, i, u[13], 2850285829, 5), e, r, u[2], 4243563512, 9), t, e, u[7], 1735328473, 14), i, t, u[12], 2368359562, 20), r = o(r, + i = o(i, t = o(t, e, r, i, u[5], 4294588738, 4), e, r, u[8], 2272392833, 11), t, e, u[11], 1839030562, 16), i, t, u[14], 4259657740, + 23), r = o(r, i = o(i, t = o(t, e, r, i, u[1], 2763975236, 4), e, r, u[4], 1272893353, 11), t, e, u[7], 4139469664, 16), i, + t, u[10], 3200236656, 23), r = o(r, i = o(i, t = o(t, e, r, i, u[13], 681279174, 4), e, r, u[0], 3936430074, 11), t, e, u[3], + 3572445317, 16), i, t, u[6], 76029189, 23), r = o(r, i = o(i, t = o(t, e, r, i, u[9], 3654602809, 4), e, r, u[12], 3873151461, + 11), t, e, u[15], 530742520, 16), i, t, u[2], 3299628645, 23), r = h(r, i = h(i, t = h(t, e, r, i, u[0], 4096336452, 6), e, + r, u[7], 1126891415, 10), t, e, u[14], 2878612391, 15), i, t, u[5], 4237533241, 21), r = h(r, i = h(i, t = h(t, e, r, i, u[12], + 1700485571, 6), e, r, u[3], 2399980690, 10), t, e, u[10], 4293915773, 15), i, t, u[1], 2240044497, 21), r = h(r, i = h(i, t = h(t, + e, r, i, u[8], 1873313359, 6), e, r, u[15], 4264355552, 10), t, e, u[6], 2734768916, 15), i, t, u[13], 1309151649, 21), r = h(r, + i = h(i, t = h(t, e, r, i, u[4], 4149444226, 6), e, r, u[11], 3174756917, 10), t, e, u[2], 718787259, 15), i, t, u[9], 3951481745, + 21), this._a = this._a + t | 0, this._b = this._b + e | 0, this._c = this._c + r | 0, this._d = this._d + i | 0; + }, t.prototype._digest = function() { this._block[this._blockOffset++] = 128, 56 < this._blockOffset && (this._block.fill(0, this._blockOffset, 64), this._update(), - this._blockOffset = 0), this._block.fill(0, this._blockOffset, 56), this._block.writeUInt32LE(this._length[0], 56), this._block.writeUInt32LE(this._length[1], - 60), this._update(); + this._blockOffset = 0), this._block.fill(0, this._blockOffset, 56), this._block.writeUInt32LE(this._length[0], 56), this._block.writeUInt32LE(this._length[1], + 60), this._update(); var t = new e(16); return t.writeInt32LE(this._a, 0), t.writeInt32LE(this._b, 4), t.writeInt32LE(this._c, 8), t.writeInt32LE(this._d, 12), t; }, f.exports = t; }).call(this, l("buffer").Buffer); - }, {buffer:3, "hash-base":38, inherits:39}], 41:[function (t,e,r) - { - -function i() - { + }, { buffer: 3, "hash-base": 38, inherits: 39 }], 41: [function(t, e, r) { + + function i() { s.call(this, 64), this._a = 1732584193, this._b = 4023233417, this._c = 2562383102, this._d = 271733878, this._e = 3285377520; }; - -function d(t,e) - { + + function d(t, e) { return t << e | t >>> 32 - e; }; var n = t("buffer").Buffer; r = t("inherits"); var s = t("hash-base"), p = Array(16), m = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 7, 4, 13, 1, 10, 6, 15, 3, - 12, 0, 9, 5, 2, 14, 11, 8, 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12, 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, - 5, 6, 2, 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13], _ = [5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12, - 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2, 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13, 8, 6, 4, 1, 3, - 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14, 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11], g = [11, 14, 15, 12, 5, 8, 7, - 9, 11, 13, 14, 15, 6, 7, 9, 8, 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12, 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, - 13, 6, 5, 12, 7, 5, 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12, 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, - 8, 5, 6], b = [8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6, 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, - 11, 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5, 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8, 8, 5, 12, - 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11], y = [0, 1518500249, 1859775393, 2400959708, 2840853838], w = [1352829926, 1548603684, - 1836072691, 2053994217, 0]; - r(i, s), i.prototype._update = function () - { - for(var t = 0; t < 16; ++t) + 12, 0, 9, 5, 2, 14, 11, 8, 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12, 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, + 5, 6, 2, 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13], _ = [5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12, + 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2, 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13, 8, 6, 4, 1, 3, + 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14, 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11], g = [11, 14, 15, 12, 5, 8, 7, + 9, 11, 13, 14, 15, 6, 7, 9, 8, 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12, 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, + 13, 6, 5, 12, 7, 5, 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12, 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, + 8, 5, 6], b = [8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6, 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, + 11, 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5, 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8, 8, 5, 12, + 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11], y = [0, 1518500249, 1859775393, 2400959708, 2840853838], w = [1352829926, 1548603684, + 1836072691, 2053994217, 0]; + r(i, s), i.prototype._update = function() { + for (var t = 0; t < 16; ++t) p[t] = this._block.readInt32LE(4 * t); var e = 0 | this._a; t = 0 | this._b; - for(var r = 0 | this._c, i = 0 | this._d, n = 0 | this._e, s = 0 | this._a, o = 0 | this._b, a = 0 | this._c, h = 0 | this._d, - u = 0 | this._e, l = 0; l < 80; l += 1) - { - if(l < 16) - { + for (var r = 0 | this._c, i = 0 | this._d, n = 0 | this._e, s = 0 | this._a, o = 0 | this._b, a = 0 | this._c, h = 0 | this._d, + u = 0 | this._e, l = 0; l < 80; l += 1) { + if (l < 16) { var f = n; f = d(e + (t ^ r ^ i) + p[m[l]] + y[0] | 0, g[l]) + f | 0, e = u; var c = d(s + (o ^ (a | ~h)) + p[_[l]] + w[0] | 0, b[l]) + e | 0; } else c = l < 32 ? (f = n, f = d(e + (t & r | ~t & i) + p[m[l]] + y[1] | 0, g[l]) + f | 0, e = u, d(s + (o & h | a & ~h) + p[_[l]] + w[1] | 0, - b[l]) + e | 0) : l < 48 ? (f = n, f = d(e + ((t | ~r) ^ i) + p[m[l]] + y[2] | 0, g[l]) + f | 0, e = u, d(s + ((o | ~a) ^ h) + p[_[l]] + w[2] | 0, - b[l]) + e | 0) : l < 64 ? (f = n, f = d(e + (t & i | r & ~i) + p[m[l]] + y[3] | 0, g[l]) + f | 0, e = u, d(s + (o & a | ~o & h) + p[_[l]] + w[3] | 0, - b[l]) + e | 0) : (f = n, f = d(e + (t ^ (r | ~i)) + p[m[l]] + y[4] | 0, g[l]) + f | 0, e = u, d(s + (o ^ a ^ h) + p[_[l]] + w[4] | 0, - b[l]) + e | 0); + b[l]) + e | 0) : l < 48 ? (f = n, f = d(e + ((t | ~r) ^ i) + p[m[l]] + y[2] | 0, g[l]) + f | 0, e = u, d(s + ((o | ~a) ^ h) + p[_[l]] + w[2] | 0, + b[l]) + e | 0) : l < 64 ? (f = n, f = d(e + (t & i | r & ~i) + p[m[l]] + y[3] | 0, g[l]) + f | 0, e = u, d(s + (o & a | ~o & h) + p[_[l]] + w[3] | 0, + b[l]) + e | 0) : (f = n, f = d(e + (t ^ (r | ~i)) + p[m[l]] + y[4] | 0, g[l]) + f | 0, e = u, d(s + (o ^ a ^ h) + p[_[l]] + w[4] | 0, + b[l]) + e | 0); e = n, n = i, i = d(r, 10), r = t, t = f, s = u, u = h, h = d(a, 10), a = o, o = c; } r = this._b + r + h | 0, this._b = this._c + i + u | 0, this._c = this._d + n + s | 0, this._d = this._e + e + o | 0, this._e = this._a + t + a | 0, - this._a = r; - }, i.prototype._digest = function () - { + this._a = r; + }, i.prototype._digest = function() { this._block[this._blockOffset++] = 128, 56 < this._blockOffset && (this._block.fill(0, this._blockOffset, 64), this._update(), - this._blockOffset = 0), this._block.fill(0, this._blockOffset, 56), this._block.writeUInt32LE(this._length[0], 56), this._block.writeUInt32LE(this._length[1], - 60), this._update(); + this._blockOffset = 0), this._block.fill(0, this._blockOffset, 56), this._block.writeUInt32LE(this._length[0], 56), this._block.writeUInt32LE(this._length[1], + 60), this._update(); var t = n.alloc ? n.alloc(20) : new n(20); return t.writeInt32LE(this._a, 0), t.writeInt32LE(this._b, 4), t.writeInt32LE(this._c, 8), t.writeInt32LE(this._d, 12), t.writeInt32LE(this._e, - 16), t; + 16), t; }, e.exports = i; - }, {buffer:3, "hash-base":38, inherits:39}], 42:[function (t,e,r) - { + }, { buffer: 3, "hash-base": 38, inherits: 39 }], 42: [function(t, e, r) { arguments[4][25][0].apply(r, arguments); - }, {buffer:3, dup:25}], 43:[function (t,e,r) - { - -function l() - { + }, { buffer: 3, dup: 25 }], 43: [function(t, e, r) { + + function l() { this.negative = 0, this.words = null, this.length = 0; }; var i = t("safe-buffer").Buffer; - t = t("./optimized"), l.fromNumber = function (t) - { + t = t("./optimized"), l.fromNumber = function(t) { var e = new l; return e.words = [67108863 & t], e.length = 1, e; - }, l.fromBuffer = function (t) - { + }, l.fromBuffer = function(t) { var e = new l; return e.words = Array(10), e.words[0] = (3 & t[28]) << 24 | t[29] << 16 | t[30] << 8 | t[31], e.words[1] = (15 & t[25]) << 22 | t[26] << 14 | t[27] << 6 | t[28] >>> 2, - e.words[2] = (63 & t[22]) << 20 | t[23] << 12 | t[24] << 4 | t[25] >>> 4, e.words[3] = (255 & t[19]) << 18 | t[20] << 10 | t[21] << 2 | t[22] >>> 6, - e.words[4] = (3 & t[15]) << 24 | t[16] << 16 | t[17] << 8 | t[18], e.words[5] = (15 & t[12]) << 22 | t[13] << 14 | t[14] << 6 | t[15] >>> 2, - e.words[6] = (63 & t[9]) << 20 | t[10] << 12 | t[11] << 4 | t[12] >>> 4, e.words[7] = (255 & t[6]) << 18 | t[7] << 10 | t[8] << 2 | t[9] >>> 6, - e.words[8] = (3 & t[2]) << 24 | t[3] << 16 | t[4] << 8 | t[5], e.words[9] = t[0] << 14 | t[1] << 6 | t[2] >>> 2, e.length = 10, - e.strip(); - }, l.prototype.toBuffer = function () - { - for(var t = this.words, e = this.length; e < 10; ++e) + e.words[2] = (63 & t[22]) << 20 | t[23] << 12 | t[24] << 4 | t[25] >>> 4, e.words[3] = (255 & t[19]) << 18 | t[20] << 10 | t[21] << 2 | t[22] >>> 6, + e.words[4] = (3 & t[15]) << 24 | t[16] << 16 | t[17] << 8 | t[18], e.words[5] = (15 & t[12]) << 22 | t[13] << 14 | t[14] << 6 | t[15] >>> 2, + e.words[6] = (63 & t[9]) << 20 | t[10] << 12 | t[11] << 4 | t[12] >>> 4, e.words[7] = (255 & t[6]) << 18 | t[7] << 10 | t[8] << 2 | t[9] >>> 6, + e.words[8] = (3 & t[2]) << 24 | t[3] << 16 | t[4] << 8 | t[5], e.words[9] = t[0] << 14 | t[1] << 6 | t[2] >>> 2, e.length = 10, + e.strip(); + }, l.prototype.toBuffer = function() { + for (var t = this.words, e = this.length; e < 10; ++e) t[e] = 0; return i.from([t[9] >>> 14 & 255, t[9] >>> 6 & 255, (63 & t[9]) << 2 | t[8] >>> 24 & 3, t[8] >>> 16 & 255, t[8] >>> 8 & 255, 255 & t[8], t[7] >>> 18 & 255, t[7] >>> 10 & 255, t[7] >>> 2 & 255, (3 & t[7]) << 6 | t[6] >>> 20 & 63, t[6] >>> 12 & 255, @@ -3100,272 +2588,223 @@ function l() t[4] >>> 16 & 255, t[4] >>> 8 & 255, 255 & t[4], t[3] >>> 18 & 255, t[3] >>> 10 & 255, t[3] >>> 2 & 255, (3 & t[3]) << 6 | t[2] >>> 20 & 63, t[2] >>> 12 & 255, t[2] >>> 4 & 255, (15 & t[2]) << 4 | t[1] >>> 22 & 15, t[1] >>> 14 & 255, t[1] >>> 6 & 255, (63 & t[1]) << 2 | t[0] >>> 24 & 3, t[0] >>> 16 & 255, t[0] >>> 8 & 255, 255 & t[0]]); - }, l.prototype.clone = function () - { + }, l.prototype.clone = function() { var t = new l; t.words = Array(this.length); - for(var e = 0; e < this.length; e++) + for (var e = 0; e < this.length; e++) t.words[e] = this.words[e]; return t.length = this.length, t.negative = this.negative, t; - }, l.prototype.strip = function () - { - for(; 1 < this.length && 0 == (0 | this.words[this.length - 1]); ) + }, l.prototype.strip = function() { + for (; 1 < this.length && 0 == (0 | this.words[this.length - 1]);) this.length--; return this; - }, l.prototype.normSign = function () - { + }, l.prototype.normSign = function() { return 1 === this.length && 0 === this.words[0] && (this.negative = 0), this; - }, l.prototype.isEven = function () - { + }, l.prototype.isEven = function() { return 0 == (1 & this.words[0]); - }, l.prototype.isOdd = function () - { + }, l.prototype.isOdd = function() { return 1 == (1 & this.words[0]); - }, l.prototype.isZero = function () - { + }, l.prototype.isZero = function() { return 1 === this.length && 0 === this.words[0]; - }, l.prototype.ucmp = function (t) - { - if(this.length !== t.length) - return this.length > t.length ? 1 : - 1; - for(var e = this.length - 1; 0 <= e; --e) - if(this.words[e] !== t.words[e]) - return this.words[e] > t.words[e] ? 1 : - 1; + }, l.prototype.ucmp = function(t) { + if (this.length !== t.length) + return this.length > t.length ? 1 : - 1; + for (var e = this.length - 1; 0 <= e; --e) + if (this.words[e] !== t.words[e]) + return this.words[e] > t.words[e] ? 1 : - 1; return 0; - }, l.prototype.gtOne = function () - { + }, l.prototype.gtOne = function() { return 1 < this.length || 1 < this.words[0]; - }, l.prototype.isOverflow = function () - { + }, l.prototype.isOverflow = function() { return 0 <= this.ucmp(l.n); - }, l.prototype.isHigh = function () - { + }, l.prototype.isHigh = function() { return 1 === this.ucmp(l.nh); - }, l.prototype.bitLengthGT256 = function () - { + }, l.prototype.bitLengthGT256 = function() { return 10 < this.length || 10 === this.length && 4194303 < this.words[9]; - }, l.prototype.iuaddn = function (t) - { - for(this.words[0] += t, t = 0; 67108863 < this.words[t] && t < this.length; ++t) + }, l.prototype.iuaddn = function(t) { + for (this.words[0] += t, t = 0; 67108863 < this.words[t] && t < this.length; ++t) this.words[t] -= 67108864, this.words[t + 1] += 1; return t === this.length && (this.words[t] = 1, this.length += 1), this; - }, l.prototype.iadd = function (t) - { - if(this.negative !== t.negative) + }, l.prototype.iadd = function(t) { + if (this.negative !== t.negative) return 0 !== this.negative ? (this.negative = 0, this.isub(t), this.negative ^= 1) : (t.negative = 0, this.isub(t), t.negative = 1), - this.normSign(); - if(this.length > t.length) + this.normSign(); + if (this.length > t.length) var e = this; else e = t, t = this; - for(var r = 0, i = 0; r < t.length; ++r) + for (var r = 0, i = 0; r < t.length; ++r) i = e.words[r] + t.words[r] + i, this.words[r] = 67108863 & i, i >>>= 26; - for(; 0 !== i && r < e.length; ++r) + for (; 0 !== i && r < e.length; ++r) i = e.words[r] + i, this.words[r] = 67108863 & i, i >>>= 26; - if(this.length = e.length, 0 !== i) + if (this.length = e.length, 0 !== i) this.words[this.length++] = i; else - if(e !== this) - for(; r < e.length; ++r) + if (e !== this) + for (; r < e.length; ++r) this.words[r] = e.words[r]; return this; - }, l.prototype.add = function (t) - { + }, l.prototype.add = function(t) { return this.clone().iadd(t); - }, l.prototype.isub = function (t) - { - if(this.negative !== t.negative) + }, l.prototype.isub = function(t) { + if (this.negative !== t.negative) return 0 !== this.negative ? (this.negative = 0, this.iadd(t), this.negative = 1) : (t.negative = 0, this.iadd(t), t.negative = 1), - this.normSign(); + this.normSign(); var e = this.ucmp(t); - if(0 === e) + if (0 === e) return this.negative = 0, this.words[0] = 0, this.length = 1, this; 0 < e ? e = this : (e = t, t = this); - for(var r = 0, i = 0; r < t.length; ++r) - { + for (var r = 0, i = 0; r < t.length; ++r) { var n = e.words[r] - t.words[r] + i; i = n >> 26, this.words[r] = 67108863 & n; } - for(; 0 !== i && r < e.length; ++r) + for (; 0 !== i && r < e.length; ++r) i = (n = e.words[r] + i) >> 26, this.words[r] = 67108863 & n; - if(0 === i && r < e.length && e !== this) - for(; r < e.length; ++r) + if (0 === i && r < e.length && e !== this) + for (; r < e.length; ++r) this.words[r] = e.words[r]; return this.length = Math.max(this.length, r), e !== this && (this.negative ^= 1), this.strip().normSign(); - }, l.prototype.sub = function (t) - { + }, l.prototype.sub = function(t) { return this.clone().isub(t); - }, l.umulTo = function (t,e,r) - { + }, l.umulTo = function(t, e, r) { r.length = t.length + e.length - 1; var i = t.words[0] * e.words[0], n = i / 67108864 | 0; r.words[0] = 67108863 & i, i = 1; - for(var s = r.length; i < s; i++) - { + for (var s = r.length; i < s; i++) { var o = n >>> 26, a = 67108863 & n; n = Math.max(0, i - t.length + 1); - for(var h = Math.min(i, e.length - 1); n <= h; n++) + for (var h = Math.min(i, e.length - 1); n <= h; n++) o += (a = t.words[i - n] * e.words[n] + a) / 67108864 | 0, a &= 67108863; r.words[i] = a, n = o; } return 0 !== n && (r.words[r.length++] = n), r.strip(); - }, l.umulTo10x10 = Math.imul ? t.umulTo10x10 : l.umulTo, l.umulnTo = function (t,e,r) - { - if(0 === e) + }, l.umulTo10x10 = Math.imul ? t.umulTo10x10 : l.umulTo, l.umulnTo = function(t, e, r) { + if (0 === e) return r.words = [0], r.length = 1, r; - for(var i = 0, n = 0; i < t.length; ++i) + for (var i = 0, n = 0; i < t.length; ++i) n = t.words[i] * e + n, r.words[i] = 67108863 & n, n = n / 67108864 | 0; return r.length = 0 < n ? (r.words[i] = n, t.length + 1) : t.length, r; - }, l.prototype.umul = function (t) - { + }, l.prototype.umul = function(t) { var e = new l; return e.words = Array(this.length + t.length), 10 === this.length && 10 === t.length ? l.umulTo10x10(this, t, e) : 1 === this.length ? l.umulnTo(t, - this.words[0], e) : 1 === t.length ? l.umulnTo(this, t.words[0], e) : l.umulTo(this, t, e); - }, l.prototype.isplit = function (t) - { + this.words[0], e) : 1 === t.length ? l.umulnTo(this, t.words[0], e) : l.umulTo(this, t, e); + }, l.prototype.isplit = function(t) { t.length = Math.min(this.length, 9); - for(var e = 0; e < t.length; ++e) + for (var e = 0; e < t.length; ++e) t.words[e] = this.words[e]; - if(this.length <= 9) + if (this.length <= 9) return this.words[0] = 0, this.length = 1, this; var r = this.words[9]; - for(t.words[t.length++] = 4194303 & r, e = 10; e < this.length; ++e) + for (t.words[t.length++] = 4194303 & r, e = 10; e < this.length; ++e) t = this.words[e], this.words[e - 10] = (4194303 & t) << 4 | r >>> 22, r = t; return r >>>= 22, this.words[e - 10] = r, this.length = 0 === r && 10 < this.length ? this.length - 10 : this.length - 9, this; - }, l.prototype.fireduce = function () - { + }, l.prototype.fireduce = function() { return this.isOverflow() && this.isub(l.n), this; - }, l.prototype.ureduce = function () - { + }, l.prototype.ureduce = function() { var t = this.clone().isplit(l.tmp).umul(l.nc).iadd(l.tmp); return t.bitLengthGT256() && ((t = t.isplit(l.tmp).umul(l.nc).iadd(l.tmp)).bitLengthGT256() && (t = t.isplit(l.tmp).umul(l.nc).iadd(l.tmp))), - t.fireduce(); - }, l.prototype.ishrn = function (t) - { - for(var e = (1 << t) - 1, r = 26 - t, i = this.length - 1, n = 0; 0 <= i; --i) - { + t.fireduce(); + }, l.prototype.ishrn = function(t) { + for (var e = (1 << t) - 1, r = 26 - t, i = this.length - 1, n = 0; 0 <= i; --i) { var s = this.words[i]; this.words[i] = n << r | s >>> t, n = s & e; } return 1 < this.length && 0 === this.words[this.length - 1] && --this.length, this; - }, l.prototype.uinvm = function () - { - for(var t = this.clone(), e = l.n.clone(), r = l.fromNumber(1), i = l.fromNumber(0), n = l.fromNumber(0), s = l.fromNumber(1); t.isEven() && e.isEven(); ) - { - for(var o = 1, a = 1; 0 == (t.words[0] & a) && 0 == (e.words[0] & a) && o < 26; ++o, a <<= 1); + }, l.prototype.uinvm = function() { + for (var t = this.clone(), e = l.n.clone(), r = l.fromNumber(1), i = l.fromNumber(0), n = l.fromNumber(0), s = l.fromNumber(1); t.isEven() && e.isEven();) { + for (var o = 1, a = 1; 0 == (t.words[0] & a) && 0 == (e.words[0] & a) && o < 26; ++o, a <<= 1); t.ishrn(o), e.ishrn(o); } - for(o = e.clone(), a = t.clone(); !t.isZero(); ) - { - for(var h = 0, u = 1; 0 == (t.words[0] & u) && h < 26; ++h, u <<= 1); - if(0 < h) - for(t.ishrn(h); 0 < h--; ) + for (o = e.clone(), a = t.clone(); !t.isZero();) { + for (var h = 0, u = 1; 0 == (t.words[0] & u) && h < 26; ++h, u <<= 1); + if (0 < h) + for (t.ishrn(h); 0 < h--;) (r.isOdd() || i.isOdd()) && (r.iadd(o), i.isub(a)), r.ishrn(1), i.ishrn(1); - for(h = 0, u = 1; 0 == (e.words[0] & u) && h < 26; ++h, u <<= 1); - if(0 < h) - for(e.ishrn(h); 0 < h--; ) + for (h = 0, u = 1; 0 == (e.words[0] & u) && h < 26; ++h, u <<= 1); + if (0 < h) + for (e.ishrn(h); 0 < h--;) (n.isOdd() || s.isOdd()) && (n.iadd(o), s.isub(a)), n.ishrn(1), s.ishrn(1); 0 <= t.ucmp(e) ? (t.isub(e), r.isub(n), i.isub(s)) : (e.isub(t), n.isub(r), s.isub(i)); } return 1 === n.negative ? (n.negative = 0, (t = n.ureduce()).negative ^= 1, t.normSign().iadd(l.n)) : n.ureduce(); - }, l.prototype.imulK = function () - { + }, l.prototype.imulK = function() { this.words[this.length] = 0, this.words[this.length + 1] = 0, this.length += 2; - for(var t = 0, e = 0; t < this.length; ++t) - { + for (var t = 0, e = 0; t < this.length; ++t) { var r = 0 | this.words[t]; e += 977 * r, this.words[t] = 67108863 & e, e = 64 * r + (e / 67108864 | 0); } return 0 === this.words[this.length - 1] && (--this.length, 0 === this.words[this.length - 1] && --this.length), this; - }, l.prototype.redIReduce = function () - { + }, l.prototype.redIReduce = function() { this.isplit(l.tmp).imulK().iadd(l.tmp), this.bitLengthGT256() && this.isplit(l.tmp).imulK().iadd(l.tmp); var t = this.ucmp(l.p); return 0 === t ? (this.words[0] = 0, this.length = 1) : 0 < t ? this.isub(l.p) : this.strip(), this; - }, l.prototype.redNeg = function () - { + }, l.prototype.redNeg = function() { return this.isZero() ? l.fromNumber(0) : l.p.sub(this); - }, l.prototype.redAdd = function (t) - { + }, l.prototype.redAdd = function(t) { return this.clone().redIAdd(t); - }, l.prototype.redIAdd = function (t) - { + }, l.prototype.redIAdd = function(t) { return this.iadd(t), 0 <= this.ucmp(l.p) && this.isub(l.p), this; - }, l.prototype.redIAdd7 = function () - { + }, l.prototype.redIAdd7 = function() { return this.iuaddn(7), 0 <= this.ucmp(l.p) && this.isub(l.p), this; - }, l.prototype.redSub = function (t) - { + }, l.prototype.redSub = function(t) { return this.clone().redISub(t); - }, l.prototype.redISub = function (t) - { + }, l.prototype.redISub = function(t) { return this.isub(t), 0 !== this.negative && this.iadd(l.p), this; - }, l.prototype.redMul = function (t) - { + }, l.prototype.redMul = function(t) { return this.umul(t).redIReduce(); - }, l.prototype.redSqr = function () - { + }, l.prototype.redSqr = function() { return this.umul(this).redIReduce(); - }, l.prototype.redSqrt = function () - { - if(this.isZero()) + }, l.prototype.redSqrt = function() { + if (this.isZero()) return this.clone(); - for(var t = this.redSqr(), e = t.redSqr(), r = (t = (e = e.redSqr().redMul(e)).redMul(t)).redMul(this), i = r, n = 0; n < 54; ++n) + for (var t = this.redSqr(), e = t.redSqr(), r = (t = (e = e.redSqr().redMul(e)).redMul(t)).redMul(this), i = r, n = 0; n < 54; ++n) i = i.redSqr().redSqr().redSqr().redSqr().redMul(r); - for(i = i.redSqr().redSqr().redSqr().redSqr().redMul(t), n = 0; n < 5; ++n) + for (i = i.redSqr().redSqr().redSqr().redSqr().redMul(t), n = 0; n < 5; ++n) i = i.redSqr().redSqr().redSqr().redSqr().redMul(r); return 0 === (i = (i = i.redSqr().redSqr().redSqr().redSqr().redMul(e)).redSqr().redSqr().redSqr().redSqr().redSqr().redSqr().redMul(e)).redSqr().ucmp(this) ? i : null; - }, l.prototype.redInvm = function () - { - for(var t = this.clone(), e = l.p.clone(), r = l.fromNumber(1), i = l.fromNumber(0); t.gtOne() && e.gtOne(); ) - { - for(var n = 0, s = 1; 0 == (t.words[0] & s) && n < 26; ++n, s <<= 1); - if(0 < n) - for(t.ishrn(n); 0 < n--; ) + }, l.prototype.redInvm = function() { + for (var t = this.clone(), e = l.p.clone(), r = l.fromNumber(1), i = l.fromNumber(0); t.gtOne() && e.gtOne();) { + for (var n = 0, s = 1; 0 == (t.words[0] & s) && n < 26; ++n, s <<= 1); + if (0 < n) + for (t.ishrn(n); 0 < n--;) r.isOdd() && r.iadd(l.p), r.ishrn(1); - for(n = 0, s = 1; 0 == (e.words[0] & s) && n < 26; ++n, s <<= 1); - if(0 < n) - for(e.ishrn(n); 0 < n--; ) + for (n = 0, s = 1; 0 == (e.words[0] & s) && n < 26; ++n, s <<= 1); + if (0 < n) + for (e.ishrn(n); 0 < n--;) i.isOdd() && i.iadd(l.p), i.ishrn(1); 0 <= t.ucmp(e) ? (t.isub(e), r.isub(i)) : (e.isub(t), i.isub(r)); } return 0 !== (t = 1 === t.length && 1 === t.words[0] ? r : i).negative && t.iadd(l.p), 0 !== t.negative ? (t.negative = 0, - t.redIReduce().redNeg()) : t.redIReduce(); - }, l.prototype.getNAF = function (t) - { + t.redIReduce().redNeg()) : t.redIReduce(); + }, l.prototype.getNAF = function(t) { var e = [], r = 1 << t + 1, i = r - 1; r >>= 1; - for(var n = this.clone(); !n.isZero(); ) - { - for(var s = 0, o = 1; 0 == (n.words[0] & o) && s < 26; ++s, o <<= 1) + for (var n = this.clone(); !n.isZero();) { + for (var s = 0, o = 1; 0 == (n.words[0] & o) && s < 26; ++s, o <<= 1) e.push(0); - if(0 !== s) + if (0 !== s) n.ishrn(s); else - if(r <= (s = n.words[0] & i)) + if (r <= (s = n.words[0] & i)) e.push(r - s), n.iuaddn(s - r).ishrn(1); else - if(e.push(s), n.words[0] -= s, !n.isZero()) - { - for(s = t - 1; 0 < s; --s) + if (e.push(s), n.words[0] -= s, !n.isZero()) { + for (s = t - 1; 0 < s; --s) e.push(0); n.ishrn(t); } } return e; - }, l.prototype.inspect = function () - { - if(this.isZero()) + }, l.prototype.inspect = function() { + if (this.isZero()) return "0"; - for(var t = this.toBuffer().toString("hex"), e = 0; "0" === t[e]; ++e); + for (var t = this.toBuffer().toString("hex"), e = 0; "0" === t[e]; ++e); return t.slice(e); }, l.n = l.fromBuffer(i.from("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141", "hex")), l.nh = l.n.clone().ishrn(1), - l.nc = l.fromBuffer(i.from("000000000000000000000000000000014551231950B75FC4402DA1732FC9BEBF", "hex")), l.p = l.fromBuffer(i.from("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F", - "hex")), l.psn = l.p.sub(l.n), (l.tmp = new l).words = Array(10), l.fromNumber(1).words[3] = 0, e.exports = l; - }, {"./optimized":44, "safe-buffer":42}], 44:[function (t,e,r) - { - r.umulTo10x10 = function (t,e,r) - { + l.nc = l.fromBuffer(i.from("000000000000000000000000000000014551231950B75FC4402DA1732FC9BEBF", "hex")), l.p = l.fromBuffer(i.from("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F", + "hex")), l.psn = l.p.sub(l.n), (l.tmp = new l).words = Array(10), l.fromNumber(1).words[3] = 0, e.exports = l; + }, { "./optimized": 44, "safe-buffer": 42 }], 44: [function(t, e, r) { + r.umulTo10x10 = function(t, e, r) { var i = t.words, n = e.words; e = r.words; var s = (t = 0) | i[0], o = 8191 & s, a = s >>> 13, h = 0 | i[1]; @@ -3408,133 +2847,126 @@ function l() n = Math.imul(o, A); var $ = t + z + ((8191 & (n += Math.imul(a, I))) << 13); t = (q = Math.imul(a, A)) + (n >>> 13) + ($ >>> 26), $ &= 67108863, z = Math.imul(s, I), n = Math.imul(s, A), n += Math.imul(u, - I), q = Math.imul(u, A), z += Math.imul(o, S), n += Math.imul(o, x); + I), q = Math.imul(u, A), z += Math.imul(o, S), n += Math.imul(o, x); var W = t + z + ((8191 & (n += Math.imul(a, S))) << 13); t = (q += Math.imul(a, x)) + (n >>> 13) + (W >>> 26), W &= 67108863, z = Math.imul(h, I), n = Math.imul(h, A), n += Math.imul(f, - I), q = Math.imul(f, A), z += Math.imul(s, S), n += Math.imul(s, x), n += Math.imul(u, S), q += Math.imul(u, x), z += Math.imul(o, - B), n += Math.imul(o, k); + I), q = Math.imul(f, A), z += Math.imul(s, S), n += Math.imul(s, x), n += Math.imul(u, S), q += Math.imul(u, x), z += Math.imul(o, + B), n += Math.imul(o, k); var Z = t + z + ((8191 & (n += Math.imul(a, B))) << 13); t = (q += Math.imul(a, k)) + (n >>> 13) + (Z >>> 26), Z &= 67108863, z = Math.imul(l, I), n = Math.imul(l, A), n += Math.imul(d, - I), q = Math.imul(d, A), z += Math.imul(h, S), n += Math.imul(h, x), n += Math.imul(f, S), q += Math.imul(f, x), z += Math.imul(s, - B), n += Math.imul(s, k), n += Math.imul(u, B), q += Math.imul(u, k), z += Math.imul(o, L), n += Math.imul(o, C); + I), q = Math.imul(d, A), z += Math.imul(h, S), n += Math.imul(h, x), n += Math.imul(f, S), q += Math.imul(f, x), z += Math.imul(s, + B), n += Math.imul(s, k), n += Math.imul(u, B), q += Math.imul(u, k), z += Math.imul(o, L), n += Math.imul(o, C); var G = t + z + ((8191 & (n += Math.imul(a, L))) << 13); t = (q += Math.imul(a, C)) + (n >>> 13) + (G >>> 26), G &= 67108863, z = Math.imul(c, I), n = Math.imul(c, A), n += Math.imul(m, - I), q = Math.imul(m, A), z += Math.imul(l, S), n += Math.imul(l, x), n += Math.imul(d, S), q += Math.imul(d, x), z += Math.imul(h, - B), n += Math.imul(h, k), n += Math.imul(f, B), q += Math.imul(f, k), z += Math.imul(s, L), n += Math.imul(s, C), n += Math.imul(u, - L), q += Math.imul(u, C), z += Math.imul(o, T), n += Math.imul(o, j); + I), q = Math.imul(m, A), z += Math.imul(l, S), n += Math.imul(l, x), n += Math.imul(d, S), q += Math.imul(d, x), z += Math.imul(h, + B), n += Math.imul(h, k), n += Math.imul(f, B), q += Math.imul(f, k), z += Math.imul(s, L), n += Math.imul(s, C), n += Math.imul(u, + L), q += Math.imul(u, C), z += Math.imul(o, T), n += Math.imul(o, j); var H = t + z + ((8191 & (n += Math.imul(a, T))) << 13); t = (q += Math.imul(a, j)) + (n >>> 13) + (H >>> 26), H &= 67108863, z = Math.imul(p, I), n = Math.imul(p, A), n += Math.imul(g, - I), q = Math.imul(g, A), z += Math.imul(c, S), n += Math.imul(c, x), n += Math.imul(m, S), q += Math.imul(m, x), z += Math.imul(l, - B), n += Math.imul(l, k), n += Math.imul(d, B), q += Math.imul(d, k), z += Math.imul(h, L), n += Math.imul(h, C), n += Math.imul(f, - L), q += Math.imul(f, C), z += Math.imul(s, T), n += Math.imul(s, j), n += Math.imul(u, T), q += Math.imul(u, j), z += Math.imul(o, - F), n += Math.imul(o, R); + I), q = Math.imul(g, A), z += Math.imul(c, S), n += Math.imul(c, x), n += Math.imul(m, S), q += Math.imul(m, x), z += Math.imul(l, + B), n += Math.imul(l, k), n += Math.imul(d, B), q += Math.imul(d, k), z += Math.imul(h, L), n += Math.imul(h, C), n += Math.imul(f, + L), q += Math.imul(f, C), z += Math.imul(s, T), n += Math.imul(s, j), n += Math.imul(u, T), q += Math.imul(u, j), z += Math.imul(o, + F), n += Math.imul(o, R); var J = t + z + ((8191 & (n += Math.imul(a, F))) << 13); t = (q += Math.imul(a, R)) + (n >>> 13) + (J >>> 26), J &= 67108863, z = Math.imul(_, I), n = Math.imul(_, A), n += Math.imul(y, - I), q = Math.imul(y, A), z += Math.imul(p, S), n += Math.imul(p, x), n += Math.imul(g, S), q += Math.imul(g, x), z += Math.imul(c, - B), n += Math.imul(c, k), n += Math.imul(m, B), q += Math.imul(m, k), z += Math.imul(l, L), n += Math.imul(l, C), n += Math.imul(d, - L), q += Math.imul(d, C), z += Math.imul(h, T), n += Math.imul(h, j), n += Math.imul(f, T), q += Math.imul(f, j), z += Math.imul(s, - F), n += Math.imul(s, R), n += Math.imul(u, F), q += Math.imul(u, R), z += Math.imul(o, O), n += Math.imul(o, P); + I), q = Math.imul(y, A), z += Math.imul(p, S), n += Math.imul(p, x), n += Math.imul(g, S), q += Math.imul(g, x), z += Math.imul(c, + B), n += Math.imul(c, k), n += Math.imul(m, B), q += Math.imul(m, k), z += Math.imul(l, L), n += Math.imul(l, C), n += Math.imul(d, + L), q += Math.imul(d, C), z += Math.imul(h, T), n += Math.imul(h, j), n += Math.imul(f, T), q += Math.imul(f, j), z += Math.imul(s, + F), n += Math.imul(s, R), n += Math.imul(u, F), q += Math.imul(u, R), z += Math.imul(o, O), n += Math.imul(o, P); var X = t + z + ((8191 & (n += Math.imul(a, O))) << 13); t = (q += Math.imul(a, P)) + (n >>> 13) + (X >>> 26), X &= 67108863, z = Math.imul(b, I), n = Math.imul(b, A), n += Math.imul(v, - I), q = Math.imul(v, A), z += Math.imul(_, S), n += Math.imul(_, x), n += Math.imul(y, S), q += Math.imul(y, x), z += Math.imul(p, - B), n += Math.imul(p, k), n += Math.imul(g, B), q += Math.imul(g, k), z += Math.imul(c, L), n += Math.imul(c, C), n += Math.imul(m, - L), q += Math.imul(m, C), z += Math.imul(l, T), n += Math.imul(l, j), n += Math.imul(d, T), q += Math.imul(d, j), z += Math.imul(h, - F), n += Math.imul(h, R), n += Math.imul(f, F), q += Math.imul(f, R), z += Math.imul(s, O), n += Math.imul(s, P), n += Math.imul(u, - O), q += Math.imul(u, P), z += Math.imul(o, N), n += Math.imul(o, D); + I), q = Math.imul(v, A), z += Math.imul(_, S), n += Math.imul(_, x), n += Math.imul(y, S), q += Math.imul(y, x), z += Math.imul(p, + B), n += Math.imul(p, k), n += Math.imul(g, B), q += Math.imul(g, k), z += Math.imul(c, L), n += Math.imul(c, C), n += Math.imul(m, + L), q += Math.imul(m, C), z += Math.imul(l, T), n += Math.imul(l, j), n += Math.imul(d, T), q += Math.imul(d, j), z += Math.imul(h, + F), n += Math.imul(h, R), n += Math.imul(f, F), q += Math.imul(f, R), z += Math.imul(s, O), n += Math.imul(s, P), n += Math.imul(u, + O), q += Math.imul(u, P), z += Math.imul(o, N), n += Math.imul(o, D); var Q = t + z + ((8191 & (n += Math.imul(a, N))) << 13); t = (q += Math.imul(a, D)) + (n >>> 13) + (Q >>> 26), Q &= 67108863, z = Math.imul(w, I), n = Math.imul(w, A), n += Math.imul(M, - I), q = Math.imul(M, A), z += Math.imul(b, S), n += Math.imul(b, x), n += Math.imul(v, S), q += Math.imul(v, x), z += Math.imul(_, - B), n += Math.imul(_, k), n += Math.imul(y, B), q += Math.imul(y, k), z += Math.imul(p, L), n += Math.imul(p, C), n += Math.imul(g, - L), q += Math.imul(g, C), z += Math.imul(c, T), n += Math.imul(c, j), n += Math.imul(m, T), q += Math.imul(m, j), z += Math.imul(l, - F), n += Math.imul(l, R), n += Math.imul(d, F), q += Math.imul(d, R), z += Math.imul(h, O), n += Math.imul(h, P), n += Math.imul(f, - O), q += Math.imul(f, P), z += Math.imul(s, N), n += Math.imul(s, D), n += Math.imul(u, N), q += Math.imul(u, D), z += Math.imul(o, - U), n += Math.imul(o, K); + I), q = Math.imul(M, A), z += Math.imul(b, S), n += Math.imul(b, x), n += Math.imul(v, S), q += Math.imul(v, x), z += Math.imul(_, + B), n += Math.imul(_, k), n += Math.imul(y, B), q += Math.imul(y, k), z += Math.imul(p, L), n += Math.imul(p, C), n += Math.imul(g, + L), q += Math.imul(g, C), z += Math.imul(c, T), n += Math.imul(c, j), n += Math.imul(m, T), q += Math.imul(m, j), z += Math.imul(l, + F), n += Math.imul(l, R), n += Math.imul(d, F), q += Math.imul(d, R), z += Math.imul(h, O), n += Math.imul(h, P), n += Math.imul(f, + O), q += Math.imul(f, P), z += Math.imul(s, N), n += Math.imul(s, D), n += Math.imul(u, N), q += Math.imul(u, D), z += Math.imul(o, + U), n += Math.imul(o, K); var tt = t + z + ((8191 & (n += Math.imul(a, U))) << 13); return t = (q += Math.imul(a, K)) + (n >>> 13) + (tt >>> 26), tt &= 67108863, z = Math.imul(i, I), n = Math.imul(i, A), n += Math.imul(E, - I), q = Math.imul(E, A), z += Math.imul(w, S), n += Math.imul(w, x), n += Math.imul(M, S), q += Math.imul(M, x), z += Math.imul(b, - B), n += Math.imul(b, k), n += Math.imul(v, B), q += Math.imul(v, k), z += Math.imul(_, L), n += Math.imul(_, C), n += Math.imul(y, - L), q += Math.imul(y, C), z += Math.imul(p, T), n += Math.imul(p, j), n += Math.imul(g, T), q += Math.imul(g, j), z += Math.imul(c, - F), n += Math.imul(c, R), n += Math.imul(m, F), q += Math.imul(m, R), z += Math.imul(l, O), n += Math.imul(l, P), n += Math.imul(d, - O), q += Math.imul(d, P), z += Math.imul(h, N), n += Math.imul(h, D), n += Math.imul(f, N), q += Math.imul(f, D), z += Math.imul(s, - U), n += Math.imul(s, K), n += Math.imul(u, U), q += Math.imul(u, K), z += Math.imul(o, V), n += Math.imul(o, Y), n += Math.imul(a, - V), t = (q += Math.imul(a, Y)) + (n >>> 13) + ((o = t + z + ((8191 & n) << 13)) >>> 26), o &= 67108863, z = Math.imul(i, S), - n = Math.imul(i, x), n += Math.imul(E, S), q = Math.imul(E, x), z += Math.imul(w, B), n += Math.imul(w, k), n += Math.imul(M, - B), q += Math.imul(M, k), z += Math.imul(b, L), n += Math.imul(b, C), n += Math.imul(v, L), q += Math.imul(v, C), z += Math.imul(_, - T), n += Math.imul(_, j), n += Math.imul(y, T), q += Math.imul(y, j), z += Math.imul(p, F), n += Math.imul(p, R), n += Math.imul(g, - F), q += Math.imul(g, R), z += Math.imul(c, O), n += Math.imul(c, P), n += Math.imul(m, O), q += Math.imul(m, P), z += Math.imul(l, - N), n += Math.imul(l, D), n += Math.imul(d, N), q += Math.imul(d, D), z += Math.imul(h, U), n += Math.imul(h, K), n += Math.imul(f, - U), q += Math.imul(f, K), z += Math.imul(s, V), n += Math.imul(s, Y), n += Math.imul(u, V), t = (q += Math.imul(u, Y)) + (n >>> 13) + ((s = t + z + ((8191 & n) << 13)) >>> 26), - s &= 67108863, z = Math.imul(i, B), n = Math.imul(i, k), n += Math.imul(E, B), q = Math.imul(E, k), z += Math.imul(w, L), n += Math.imul(w, - C), n += Math.imul(M, L), q += Math.imul(M, C), z += Math.imul(b, T), n += Math.imul(b, j), n += Math.imul(v, T), q += Math.imul(v, - j), z += Math.imul(_, F), n += Math.imul(_, R), n += Math.imul(y, F), q += Math.imul(y, R), z += Math.imul(p, O), n += Math.imul(p, - P), n += Math.imul(g, O), q += Math.imul(g, P), z += Math.imul(c, N), n += Math.imul(c, D), n += Math.imul(m, N), q += Math.imul(m, - D), z += Math.imul(l, U), n += Math.imul(l, K), n += Math.imul(d, U), q += Math.imul(d, K), z += Math.imul(h, V), n += Math.imul(h, - Y), n += Math.imul(f, V), t = (q += Math.imul(f, Y)) + (n >>> 13) + ((h = t + z + ((8191 & n) << 13)) >>> 26), h &= 67108863, - z = Math.imul(i, L), n = Math.imul(i, C), n += Math.imul(E, L), q = Math.imul(E, C), z += Math.imul(w, T), n += Math.imul(w, - j), n += Math.imul(M, T), q += Math.imul(M, j), z += Math.imul(b, F), n += Math.imul(b, R), n += Math.imul(v, F), q += Math.imul(v, - R), z += Math.imul(_, O), n += Math.imul(_, P), n += Math.imul(y, O), q += Math.imul(y, P), z += Math.imul(p, N), n += Math.imul(p, - D), n += Math.imul(g, N), q += Math.imul(g, D), z += Math.imul(c, U), n += Math.imul(c, K), n += Math.imul(m, U), q += Math.imul(m, - K), z += Math.imul(l, V), n += Math.imul(l, Y), n += Math.imul(d, V), t = (q += Math.imul(d, Y)) + (n >>> 13) + ((l = t + z + ((8191 & n) << 13)) >>> 26), - l &= 67108863, z = Math.imul(i, T), n = Math.imul(i, j), n += Math.imul(E, T), q = Math.imul(E, j), z += Math.imul(w, F), n += Math.imul(w, - R), n += Math.imul(M, F), q += Math.imul(M, R), z += Math.imul(b, O), n += Math.imul(b, P), n += Math.imul(v, O), q += Math.imul(v, - P), z += Math.imul(_, N), n += Math.imul(_, D), n += Math.imul(y, N), q += Math.imul(y, D), z += Math.imul(p, U), n += Math.imul(p, - K), n += Math.imul(g, U), q += Math.imul(g, K), z += Math.imul(c, V), n += Math.imul(c, Y), n += Math.imul(m, V), t = (q += Math.imul(m, - Y)) + (n >>> 13) + ((c = t + z + ((8191 & n) << 13)) >>> 26), c &= 67108863, z = Math.imul(i, F), n = Math.imul(i, R), n += Math.imul(E, - F), q = Math.imul(E, R), z += Math.imul(w, O), n += Math.imul(w, P), n += Math.imul(M, O), q += Math.imul(M, P), z += Math.imul(b, - N), n += Math.imul(b, D), n += Math.imul(v, N), q += Math.imul(v, D), z += Math.imul(_, U), n += Math.imul(_, K), n += Math.imul(y, - U), q += Math.imul(y, K), z += Math.imul(p, V), n += Math.imul(p, Y), n += Math.imul(g, V), t = (q += Math.imul(g, Y)) + (n >>> 13) + ((p = t + z + ((8191 & n) << 13)) >>> 26), - p &= 67108863, z = Math.imul(i, O), n = Math.imul(i, P), n += Math.imul(E, O), q = Math.imul(E, P), z += Math.imul(w, N), n += Math.imul(w, - D), n += Math.imul(M, N), q += Math.imul(M, D), z += Math.imul(b, U), n += Math.imul(b, K), n += Math.imul(v, U), q += Math.imul(v, - K), z += Math.imul(_, V), n += Math.imul(_, Y), n += Math.imul(y, V), t = (q += Math.imul(y, Y)) + (n >>> 13) + ((_ = t + z + ((8191 & n) << 13)) >>> 26), - _ &= 67108863, z = Math.imul(i, N), n = Math.imul(i, D), n += Math.imul(E, N), q = Math.imul(E, D), z += Math.imul(w, U), n += Math.imul(w, - K), n += Math.imul(M, U), q += Math.imul(M, K), z += Math.imul(b, V), n += Math.imul(b, Y), n += Math.imul(v, V), t = (q += Math.imul(v, - Y)) + (n >>> 13) + ((b = t + z + ((8191 & n) << 13)) >>> 26), b &= 67108863, z = Math.imul(i, U), n = Math.imul(i, K), n += Math.imul(E, - U), q = Math.imul(E, K), z += Math.imul(w, V), n += Math.imul(w, Y), n += Math.imul(M, V), t = (q += Math.imul(M, Y)) + (n >>> 13) + ((w = t + z + ((8191 & n) << 13)) >>> 26), - w &= 67108863, z = Math.imul(i, V), n = Math.imul(i, Y), n += Math.imul(E, V), t = (q = Math.imul(E, Y)) + (n >>> 13) + ((a = t + z + ((8191 & n) << 13)) >>> 26), - e[0] = $, e[1] = W, e[2] = Z, e[3] = G, e[4] = H, e[5] = J, e[6] = X, e[7] = Q, e[8] = tt, e[9] = o, e[10] = s, e[11] = h, - e[12] = l, e[13] = c, e[14] = p, e[15] = _, e[16] = b, e[17] = w, e[18] = 67108863 & a, 0 !== t && (e[19] = t, r.length++), - r; + I), q = Math.imul(E, A), z += Math.imul(w, S), n += Math.imul(w, x), n += Math.imul(M, S), q += Math.imul(M, x), z += Math.imul(b, + B), n += Math.imul(b, k), n += Math.imul(v, B), q += Math.imul(v, k), z += Math.imul(_, L), n += Math.imul(_, C), n += Math.imul(y, + L), q += Math.imul(y, C), z += Math.imul(p, T), n += Math.imul(p, j), n += Math.imul(g, T), q += Math.imul(g, j), z += Math.imul(c, + F), n += Math.imul(c, R), n += Math.imul(m, F), q += Math.imul(m, R), z += Math.imul(l, O), n += Math.imul(l, P), n += Math.imul(d, + O), q += Math.imul(d, P), z += Math.imul(h, N), n += Math.imul(h, D), n += Math.imul(f, N), q += Math.imul(f, D), z += Math.imul(s, + U), n += Math.imul(s, K), n += Math.imul(u, U), q += Math.imul(u, K), z += Math.imul(o, V), n += Math.imul(o, Y), n += Math.imul(a, + V), t = (q += Math.imul(a, Y)) + (n >>> 13) + ((o = t + z + ((8191 & n) << 13)) >>> 26), o &= 67108863, z = Math.imul(i, S), + n = Math.imul(i, x), n += Math.imul(E, S), q = Math.imul(E, x), z += Math.imul(w, B), n += Math.imul(w, k), n += Math.imul(M, + B), q += Math.imul(M, k), z += Math.imul(b, L), n += Math.imul(b, C), n += Math.imul(v, L), q += Math.imul(v, C), z += Math.imul(_, + T), n += Math.imul(_, j), n += Math.imul(y, T), q += Math.imul(y, j), z += Math.imul(p, F), n += Math.imul(p, R), n += Math.imul(g, + F), q += Math.imul(g, R), z += Math.imul(c, O), n += Math.imul(c, P), n += Math.imul(m, O), q += Math.imul(m, P), z += Math.imul(l, + N), n += Math.imul(l, D), n += Math.imul(d, N), q += Math.imul(d, D), z += Math.imul(h, U), n += Math.imul(h, K), n += Math.imul(f, + U), q += Math.imul(f, K), z += Math.imul(s, V), n += Math.imul(s, Y), n += Math.imul(u, V), t = (q += Math.imul(u, Y)) + (n >>> 13) + ((s = t + z + ((8191 & n) << 13)) >>> 26), + s &= 67108863, z = Math.imul(i, B), n = Math.imul(i, k), n += Math.imul(E, B), q = Math.imul(E, k), z += Math.imul(w, L), n += Math.imul(w, + C), n += Math.imul(M, L), q += Math.imul(M, C), z += Math.imul(b, T), n += Math.imul(b, j), n += Math.imul(v, T), q += Math.imul(v, + j), z += Math.imul(_, F), n += Math.imul(_, R), n += Math.imul(y, F), q += Math.imul(y, R), z += Math.imul(p, O), n += Math.imul(p, + P), n += Math.imul(g, O), q += Math.imul(g, P), z += Math.imul(c, N), n += Math.imul(c, D), n += Math.imul(m, N), q += Math.imul(m, + D), z += Math.imul(l, U), n += Math.imul(l, K), n += Math.imul(d, U), q += Math.imul(d, K), z += Math.imul(h, V), n += Math.imul(h, + Y), n += Math.imul(f, V), t = (q += Math.imul(f, Y)) + (n >>> 13) + ((h = t + z + ((8191 & n) << 13)) >>> 26), h &= 67108863, + z = Math.imul(i, L), n = Math.imul(i, C), n += Math.imul(E, L), q = Math.imul(E, C), z += Math.imul(w, T), n += Math.imul(w, + j), n += Math.imul(M, T), q += Math.imul(M, j), z += Math.imul(b, F), n += Math.imul(b, R), n += Math.imul(v, F), q += Math.imul(v, + R), z += Math.imul(_, O), n += Math.imul(_, P), n += Math.imul(y, O), q += Math.imul(y, P), z += Math.imul(p, N), n += Math.imul(p, + D), n += Math.imul(g, N), q += Math.imul(g, D), z += Math.imul(c, U), n += Math.imul(c, K), n += Math.imul(m, U), q += Math.imul(m, + K), z += Math.imul(l, V), n += Math.imul(l, Y), n += Math.imul(d, V), t = (q += Math.imul(d, Y)) + (n >>> 13) + ((l = t + z + ((8191 & n) << 13)) >>> 26), + l &= 67108863, z = Math.imul(i, T), n = Math.imul(i, j), n += Math.imul(E, T), q = Math.imul(E, j), z += Math.imul(w, F), n += Math.imul(w, + R), n += Math.imul(M, F), q += Math.imul(M, R), z += Math.imul(b, O), n += Math.imul(b, P), n += Math.imul(v, O), q += Math.imul(v, + P), z += Math.imul(_, N), n += Math.imul(_, D), n += Math.imul(y, N), q += Math.imul(y, D), z += Math.imul(p, U), n += Math.imul(p, + K), n += Math.imul(g, U), q += Math.imul(g, K), z += Math.imul(c, V), n += Math.imul(c, Y), n += Math.imul(m, V), t = (q += Math.imul(m, + Y)) + (n >>> 13) + ((c = t + z + ((8191 & n) << 13)) >>> 26), c &= 67108863, z = Math.imul(i, F), n = Math.imul(i, R), n += Math.imul(E, + F), q = Math.imul(E, R), z += Math.imul(w, O), n += Math.imul(w, P), n += Math.imul(M, O), q += Math.imul(M, P), z += Math.imul(b, + N), n += Math.imul(b, D), n += Math.imul(v, N), q += Math.imul(v, D), z += Math.imul(_, U), n += Math.imul(_, K), n += Math.imul(y, + U), q += Math.imul(y, K), z += Math.imul(p, V), n += Math.imul(p, Y), n += Math.imul(g, V), t = (q += Math.imul(g, Y)) + (n >>> 13) + ((p = t + z + ((8191 & n) << 13)) >>> 26), + p &= 67108863, z = Math.imul(i, O), n = Math.imul(i, P), n += Math.imul(E, O), q = Math.imul(E, P), z += Math.imul(w, N), n += Math.imul(w, + D), n += Math.imul(M, N), q += Math.imul(M, D), z += Math.imul(b, U), n += Math.imul(b, K), n += Math.imul(v, U), q += Math.imul(v, + K), z += Math.imul(_, V), n += Math.imul(_, Y), n += Math.imul(y, V), t = (q += Math.imul(y, Y)) + (n >>> 13) + ((_ = t + z + ((8191 & n) << 13)) >>> 26), + _ &= 67108863, z = Math.imul(i, N), n = Math.imul(i, D), n += Math.imul(E, N), q = Math.imul(E, D), z += Math.imul(w, U), n += Math.imul(w, + K), n += Math.imul(M, U), q += Math.imul(M, K), z += Math.imul(b, V), n += Math.imul(b, Y), n += Math.imul(v, V), t = (q += Math.imul(v, + Y)) + (n >>> 13) + ((b = t + z + ((8191 & n) << 13)) >>> 26), b &= 67108863, z = Math.imul(i, U), n = Math.imul(i, K), n += Math.imul(E, + U), q = Math.imul(E, K), z += Math.imul(w, V), n += Math.imul(w, Y), n += Math.imul(M, V), t = (q += Math.imul(M, Y)) + (n >>> 13) + ((w = t + z + ((8191 & n) << 13)) >>> 26), + w &= 67108863, z = Math.imul(i, V), n = Math.imul(i, Y), n += Math.imul(E, V), t = (q = Math.imul(E, Y)) + (n >>> 13) + ((a = t + z + ((8191 & n) << 13)) >>> 26), + e[0] = $, e[1] = W, e[2] = Z, e[3] = G, e[4] = H, e[5] = J, e[6] = X, e[7] = Q, e[8] = tt, e[9] = o, e[10] = s, e[11] = h, + e[12] = l, e[13] = c, e[14] = p, e[15] = _, e[16] = b, e[17] = w, e[18] = 67108863 & a, 0 !== t && (e[19] = t, r.length++), + r; }; - }, {}], 45:[function (t,e,r) - { - -function a(t,e,r) - { + }, {}], 45: [function(t, e, r) { + + function a(t, e, r) { this.z = null === t && null === e && null === r ? (this.y = this.x = a.one, a.zero) : (this.x = t, this.y = e, r), this.zOne = this.z === a.one; }; - t = t("./bn"), a.zero = t.fromNumber(0), a.one = t.fromNumber(1), a.prototype.neg = function () - { + t = t("./bn"), a.zero = t.fromNumber(0), a.one = t.fromNumber(1), a.prototype.neg = function() { return this.inf ? this : new a(this.x, this.y.redNeg(), this.z); - }, a.prototype.add = function (t) - { - if(this.inf) + }, a.prototype.add = function(t) { + if (this.inf) return t; - if(t.inf) + if (t.inf) return this; var e = t.z.redSqr(), r = this.z.redSqr(), i = this.x.redMul(e), n = t.x.redMul(r); - if(e = this.y.redMul(e).redMul(t.z), r = t.y.redMul(r).redMul(this.z), n = i.redSub(n), r = e.redSub(r), n.isZero()) + if (e = this.y.redMul(e).redMul(t.z), r = t.y.redMul(r).redMul(this.z), n = i.redSub(n), r = e.redSub(r), n.isZero()) return r.isZero() ? this.dbl() : new a(null, null, null); var s = n.redSqr(), o = i.redMul(s); return s = s.redMul(n), new a(i = r.redSqr().redIAdd(s).redISub(o).redISub(o), e = r.redMul(o.redISub(i)).redISub(e.redMul(s)), - t = this.z.redMul(t.z).redMul(n)); - }, a.prototype.mixedAdd = function (t) - { - if(this.inf) + t = this.z.redMul(t.z).redMul(n)); + }, a.prototype.mixedAdd = function(t) { + if (this.inf) return t.toECJPoint(); - if(t.inf) + if (t.inf) return this; var e = this.z.redSqr(), r = this.x, i = t.x.redMul(e), n = this.y; - if(t = t.y.redMul(e).redMul(this.z), i = r.redSub(i), t = n.redSub(t), i.isZero()) + if (t = t.y.redMul(e).redMul(this.z), i = r.redSub(i), t = n.redSub(t), i.isZero()) return t.isZero() ? this.dbl() : new a(null, null, null); var s = i.redSqr(); return e = r.redMul(s), s = s.redMul(i), new a(r = t.redSqr().redIAdd(s).redISub(e).redISub(e), n = t.redMul(e.redISub(r)).redISub(n.redMul(s)), - i = this.z.redMul(i)); - }, a.prototype.dbl = function () - { - if(this.inf) + i = this.z.redMul(i)); + }, a.prototype.dbl = function() { + if (this.inf) return this; - if(this.zOne) - { + if (this.zOne) { var t = this.x.redSqr(), e = this.y.redSqr(), r = e.redSqr(); e = (e = this.x.redAdd(e).redSqr().redISub(t).redISub(r)).redIAdd(e); var i = (t = t.redAdd(t).redIAdd(t)).redSqr().redISub(e).redISub(e), n = r.redIAdd(r).redIAdd(r).redIAdd(r); @@ -3542,599 +2974,510 @@ function a(t,e,r) } else t = this.x.redSqr(), r = (e = this.y.redSqr()).redSqr(), e = (e = this.x.redAdd(e).redSqr().redISub(t).redISub(r)).redIAdd(e), - i = (t = t.redAdd(t).redIAdd(t)).redSqr(), n = r.redIAdd(r).redIAdd(r).redIAdd(r), r = i.redISub(e).redISub(e), e = t.redMul(e.redISub(r)).redISub(n), - t = (t = this.y.redMul(this.z)).redIAdd(t); + i = (t = t.redAdd(t).redIAdd(t)).redSqr(), n = r.redIAdd(r).redIAdd(r).redIAdd(r), r = i.redISub(e).redISub(e), e = t.redMul(e.redISub(r)).redISub(n), + t = (t = this.y.redMul(this.z)).redIAdd(t); return new a(r, e, t); - }, a.prototype.dblp = function (t) - { - if(0 === t || this.inf) + }, a.prototype.dblp = function(t) { + if (0 === t || this.inf) return this; - for(var e = this, r = 0; r < t; r++) + for (var e = this, r = 0; r < t; r++) e = e.dbl(); return e; - }, Object.defineProperty(a.prototype, "inf", {enumerable:!0, get:function () - { + }, Object.defineProperty(a.prototype, "inf", { + enumerable: !0, get: function() { return this.z.isZero(); - }}), e.exports = a; - }, {"./bn":43}], 46:[function (t,e,r) - { - -function s(t,e) - { + } + }), e.exports = a; + }, { "./bn": 43 }], 46: [function(t, e, r) { + + function s(t, e) { this.inf = null === t && null === e ? (this.x = this.y = null, !0) : (this.x = t, this.y = e, !1); }; var i = t("safe-buffer").Buffer, n = t("./bn"), o = t("./ecjpoint"); - s.fromPublicKey = function (t) - { + s.fromPublicKey = function(t) { var e = t[0]; - if(33 !== t.length || 2 !== e && 3 !== e) + if (33 !== t.length || 2 !== e && 3 !== e) return 65 !== t.length || 4 !== e && 6 !== e && 7 !== e ? null : (r = n.fromBuffer(t.slice(1, 33)), t = n.fromBuffer(t.slice(33, - 65)), 0 <= r.ucmp(n.p) || 0 <= t.ucmp(n.p) || (6 === e || 7 === e) && t.isOdd() !== (7 === e) || 0 !== r.redSqr().redMul(r).redIAdd7().ucmp(t.redSqr()) ? null : new s(r, - t)); + 65)), 0 <= r.ucmp(n.p) || 0 <= t.ucmp(n.p) || (6 === e || 7 === e) && t.isOdd() !== (7 === e) || 0 !== r.redSqr().redMul(r).redIAdd7().ucmp(t.redSqr()) ? null : new s(r, + t)); var r = n.fromBuffer(t.slice(1, 33)); return 0 <= r.ucmp(n.p) ? null : null === (t = r.redSqr().redMul(r).redIAdd7().redSqrt()) ? null : (3 === e !== t.isOdd() && (t = t.redNeg()), - new s(r, t)); - }, s.prototype.toPublicKey = function (t) - { + new s(r, t)); + }, s.prototype.toPublicKey = function(t) { var e = this.x, r = this.y; return t ? ((t = i.alloc(33))[0] = r.isOdd() ? 3 : 2, e.toBuffer().copy(t, 1)) : ((t = i.alloc(65))[0] = 4, e.toBuffer().copy(t, - 1), r.toBuffer().copy(t, 33)), t; - }, s.fromECJPoint = function (t) - { - if(t.inf) + 1), r.toBuffer().copy(t, 33)), t; + }, s.fromECJPoint = function(t) { + if (t.inf) return new s(null, null); var e = t.z.redInvm(), r = e.redSqr(); return new s(t.x.redMul(r), t = t.y.redMul(r).redMul(e)); - }, s.prototype.toECJPoint = function () - { + }, s.prototype.toECJPoint = function() { return this.inf ? new o(null, null, null) : new o(this.x, this.y, o.one); - }, s.prototype.neg = function () - { + }, s.prototype.neg = function() { return this.inf ? this : new s(this.x, this.y.redNeg()); - }, s.prototype.add = function (t) - { - if(this.inf) + }, s.prototype.add = function(t) { + if (this.inf) return t; - if(t.inf) + if (t.inf) return this; - if(0 === this.x.ucmp(t.x)) + if (0 === this.x.ucmp(t.x)) return 0 === this.y.ucmp(t.y) ? this.dbl() : new s(null, null); var e = this.y.redSub(t.y); return e.isZero() || (e = e.redMul(this.x.redSub(t.x).redInvm())), new s(t = e.redSqr().redISub(this.x).redISub(t.x), e = e.redMul(this.x.redSub(t)).redISub(this.y)); - }, s.prototype.dbl = function () - { - if(this.inf) + }, s.prototype.dbl = function() { + if (this.inf) return this; var t = this.y.redAdd(this.y); - if(t.isZero()) + if (t.isZero()) return new s(null, null); var e = this.x.redSqr(); return new s(t = (e = e.redAdd(e).redIAdd(e).redMul(t.redInvm())).redSqr().redISub(this.x.redAdd(this.x)), e = e.redMul(this.x.redSub(t)).redISub(this.y)); - }, s.prototype.mul = function (t) - { + }, s.prototype.mul = function(t) { var e = this._getNAFPoints(4), r = e.points; t = t.getNAF(e.wnd), e = new o(null, null, null); - for(var i = t.length - 1; 0 <= i; i--) - { - for(var n = 0; 0 <= i && 0 === t[i]; i--, ++n); - if(0 <= i && (n += 1), e = e.dblp(n), i < 0) + for (var i = t.length - 1; 0 <= i; i--) { + for (var n = 0; 0 <= i && 0 === t[i]; i-- , ++n); + if (0 <= i && (n += 1), e = e.dblp(n), i < 0) break; - e = 0 < (n = t[i]) ? e.mixedAdd(r[n - 1 >> 1]) : e.mixedAdd(r[ - n - 1 >> 1].neg()); + e = 0 < (n = t[i]) ? e.mixedAdd(r[n - 1 >> 1]) : e.mixedAdd(r[- n - 1 >> 1].neg()); } return s.fromECJPoint(e); - }, s.prototype._getNAFPoints1 = function () - { - return {wnd:1, points:[this]}; - }, s.prototype._getNAFPoints = function (t) - { - for(var e = Array((1 << t) - 1), r = (e[0] = this).dbl(), i = 1; i < e.length; ++i) + }, s.prototype._getNAFPoints1 = function() { + return { wnd: 1, points: [this] }; + }, s.prototype._getNAFPoints = function(t) { + for (var e = Array((1 << t) - 1), r = (e[0] = this).dbl(), i = 1; i < e.length; ++i) e[i] = e[i - 1].add(r); - return {wnd:t, points:e}; + return { wnd: t, points: e }; }, e.exports = s; - }, {"./bn":43, "./ecjpoint":45, "safe-buffer":42}], 47:[function (t,e,r) - { - -function i() - { + }, { "./bn": 43, "./ecjpoint": 45, "safe-buffer": 42 }], 47: [function(t, e, r) { + + function i() { this.x = s.fromBuffer(n.from("79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798", "hex")), this.y = s.fromBuffer(n.from("483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8", - "hex")), this.inf = !1, this._precompute(); + "hex")), this.inf = !1, this._precompute(); }; var n = t("safe-buffer").Buffer, s = t("./bn"), u = t("./ecpoint"), l = t("./ecjpoint"); - i.prototype._precompute = function () - { - for(var t = new u(this.x, this.y), e = Array(66), r = e[0] = t, i = 1; i < e.length; ++i) - { - for(var n = 0; n < 4; n++) + i.prototype._precompute = function() { + for (var t = new u(this.x, this.y), e = Array(66), r = e[0] = t, i = 1; i < e.length; ++i) { + for (var n = 0; n < 4; n++) r = r.dbl(); e[i] = r; } - this.precomputed = {naf:t._getNAFPoints(7), doubles:{step:4, points:e, negpoints:e.map(function (t) - { + this.precomputed = { + naf: t._getNAFPoints(7), doubles: { + step: 4, points: e, negpoints: e.map(function(t) { return t.neg(); - })}}; - }, i.prototype.mul = function (t) - { + }) + } + }; + }, i.prototype.mul = function(t) { var e = this.precomputed.doubles.step, r = this.precomputed.doubles.points, i = this.precomputed.doubles.negpoints, n = t.getNAF(1), - s = ((1 << e + 1) - (0 == e % 2 ? 2 : 1)) / 3; + s = ((1 << e + 1) - (0 == e % 2 ? 2 : 1)) / 3; t = []; - for(var o = 0; o < n.length; o += e) - { - for(var a = 0, h = o + e - 1; o <= h; h--) + for (var o = 0; o < n.length; o += e) { + for (var a = 0, h = o + e - 1; o <= h; h--) a = (a << 1) + n[h]; t.push(a); } - for(e = new l(null, null, null), n = new l(null, null, null); 0 < s; s--) - { - for(o = 0; o < t.length; o++) - t[o] === s ? n = n.mixedAdd(r[o]) : t[o] === - s && (n = n.mixedAdd(i[o])); + for (e = new l(null, null, null), n = new l(null, null, null); 0 < s; s--) { + for (o = 0; o < t.length; o++) + t[o] === s ? n = n.mixedAdd(r[o]) : t[o] === - s && (n = n.mixedAdd(i[o])); e = e.add(n); } return u.fromECJPoint(e); - }, i.prototype.mulAdd = function (t,e,r) - { + }, i.prototype.mulAdd = function(t, e, r) { var i = this.precomputed.naf, n = e._getNAFPoints1(); - for(e = [i.points, n.points], t = [t.getNAF(i.wnd), r.getNAF(n.wnd)], r = new l(null, null, null), i = [null, null], n = Math.max(t[0].length, - t[1].length); 0 <= n; n--) - { - for(var s = 0; 0 <= n && (i[0] = 0 | t[0][n], i[1] = 0 | t[1][n], 0 === i[0] && 0 === i[1]); ++s, --n); - if(0 <= n && (s += 1), r = r.dblp(s), n < 0) + for (e = [i.points, n.points], t = [t.getNAF(i.wnd), r.getNAF(n.wnd)], r = new l(null, null, null), i = [null, null], n = Math.max(t[0].length, + t[1].length); 0 <= n; n--) { + for (var s = 0; 0 <= n && (i[0] = 0 | t[0][n], i[1] = 0 | t[1][n], 0 === i[0] && 0 === i[1]); ++s, --n); + if (0 <= n && (s += 1), r = r.dblp(s), n < 0) break; - for(s = 0; s < 2; s++) - { + for (s = 0; s < 2; s++) { var o, a = i[s]; - 0 !== a && (0 < a ? o = e[s][a >> 1] : a < 0 && (o = e[s][ - a >> 1].neg()), r = void 0 === o.z ? r.mixedAdd(o) : r.add(o)); + 0 !== a && (0 < a ? o = e[s][a >> 1] : a < 0 && (o = e[s][- a >> 1].neg()), r = void 0 === o.z ? r.mixedAdd(o) : r.add(o)); } } return r; }, e.exports = new i; - }, {"./bn":43, "./ecjpoint":45, "./ecpoint":46, "safe-buffer":42}], 48:[function (t,e,i) - { + }, { "./bn": 43, "./ecjpoint": 45, "./ecpoint": 46, "safe-buffer": 42 }], 48: [function(t, e, i) { var f = t("safe-buffer").Buffer, n = t("create-hash"), c = t("drbg.js/hmac"), d = t("../messages.json"), p = t("./bn"), o = t("./ecpoint"), - m = t("./ecpointg"); - i.privateKeyVerify = function (t) - { + m = t("./ecpointg"); + i.privateKeyVerify = function(t) { return !((t = p.fromBuffer(t)).isOverflow() || t.isZero()); - }, i.privateKeyExport = function (t,e) - { + }, i.privateKeyExport = function(t, e) { var r = p.fromBuffer(t); - if(r.isOverflow() || r.isZero()) + if (r.isOverflow() || r.isZero()) throw Error(d.EC_PRIVATE_KEY_EXPORT_DER_FAIL); return m.mul(r).toPublicKey(e); - }, i.privateKeyNegate = function (t) - { + }, i.privateKeyNegate = function(t) { return (t = p.fromBuffer(t)).isZero() ? f.alloc(32) : (0 < t.ucmp(p.n) && t.isub(p.n), p.n.sub(t).toBuffer()); - }, i.privateKeyModInverse = function (t) - { - if((t = p.fromBuffer(t)).isOverflow() || t.isZero()) + }, i.privateKeyModInverse = function(t) { + if ((t = p.fromBuffer(t)).isOverflow() || t.isZero()) throw Error(d.EC_PRIVATE_KEY_RANGE_INVALID); return t.uinvm().toBuffer(); - }, i.privateKeyTweakAdd = function (t,e) - { + }, i.privateKeyTweakAdd = function(t, e) { var r = p.fromBuffer(e); - if(r.isOverflow()) + if (r.isOverflow()) throw Error(d.EC_PRIVATE_KEY_TWEAK_ADD_FAIL); - if(r.iadd(p.fromBuffer(t)), r.isOverflow() && r.isub(p.n), r.isZero()) + if (r.iadd(p.fromBuffer(t)), r.isOverflow() && r.isub(p.n), r.isZero()) throw Error(d.EC_PRIVATE_KEY_TWEAK_ADD_FAIL); return r.toBuffer(); - }, i.privateKeyTweakMul = function (t,e) - { + }, i.privateKeyTweakMul = function(t, e) { var r = p.fromBuffer(e); - if(r.isOverflow() || r.isZero()) + if (r.isOverflow() || r.isZero()) throw Error(d.EC_PRIVATE_KEY_TWEAK_MUL_FAIL); var i = p.fromBuffer(t); return r.umul(i).ureduce().toBuffer(); - }, i.publicKeyCreate = function (t,e) - { + }, i.publicKeyCreate = function(t, e) { var r = p.fromBuffer(t); - if(r.isOverflow() || r.isZero()) + if (r.isOverflow() || r.isZero()) throw Error(d.EC_PUBLIC_KEY_CREATE_FAIL); return m.mul(r).toPublicKey(e); - }, i.publicKeyConvert = function (t,e) - { + }, i.publicKeyConvert = function(t, e) { var r = o.fromPublicKey(t); - if(null === r) + if (null === r) throw Error(d.EC_PUBLIC_KEY_PARSE_FAIL); return r.toPublicKey(e); - }, i.publicKeyVerify = function (t) - { + }, i.publicKeyVerify = function(t) { return null !== o.fromPublicKey(t); - }, i.publicKeyTweakAdd = function (t,e,r) - { - if(null === (t = o.fromPublicKey(t))) + }, i.publicKeyTweakAdd = function(t, e, r) { + if (null === (t = o.fromPublicKey(t))) throw Error(d.EC_PUBLIC_KEY_PARSE_FAIL); - if((e = p.fromBuffer(e)).isOverflow()) + if ((e = p.fromBuffer(e)).isOverflow()) throw Error(d.EC_PUBLIC_KEY_TWEAK_ADD_FAIL); return m.mul(e).add(t).toPublicKey(r); - }, i.publicKeyTweakMul = function (t,e,r) - { - if(null === (t = o.fromPublicKey(t))) + }, i.publicKeyTweakMul = function(t, e, r) { + if (null === (t = o.fromPublicKey(t))) throw Error(d.EC_PUBLIC_KEY_PARSE_FAIL); - if((e = p.fromBuffer(e)).isOverflow() || e.isZero()) + if ((e = p.fromBuffer(e)).isOverflow() || e.isZero()) throw Error(d.EC_PUBLIC_KEY_TWEAK_MUL_FAIL); return t.mul(e).toPublicKey(r); - }, i.publicKeyCombine = function (t,e) - { - for(var r = Array(t.length), i = 0; i < t.length; ++i) - if(r[i] = o.fromPublicKey(t[i]), null === r[i]) + }, i.publicKeyCombine = function(t, e) { + for (var r = Array(t.length), i = 0; i < t.length; ++i) + if (r[i] = o.fromPublicKey(t[i]), null === r[i]) throw Error(d.EC_PUBLIC_KEY_PARSE_FAIL); i = r[0]; - for(var n = 1; n < r.length; ++n) + for (var n = 1; n < r.length; ++n) i = i.add(r[n]); - if(i.inf) + if (i.inf) throw Error(d.EC_PUBLIC_KEY_COMBINE_FAIL); return i.toPublicKey(e); - }, i.signatureNormalize = function (t) - { + }, i.signatureNormalize = function(t) { var e = p.fromBuffer(t.slice(0, 32)), r = p.fromBuffer(t.slice(32, 64)); - if(e.isOverflow() || r.isOverflow()) + if (e.isOverflow() || r.isOverflow()) throw Error(d.ECDSA_SIGNATURE_PARSE_FAIL); return t = f.from(t), r.isHigh() && p.n.sub(r).toBuffer().copy(t, 32), t; - }, i.signatureExport = function (t) - { + }, i.signatureExport = function(t) { var e = t.slice(0, 32); - if(t = t.slice(32, 64), p.fromBuffer(e).isOverflow() || p.fromBuffer(t).isOverflow()) + if (t = t.slice(32, 64), p.fromBuffer(e).isOverflow() || p.fromBuffer(t).isOverflow()) throw Error(d.ECDSA_SIGNATURE_PARSE_FAIL); - return {r:e, s:t}; - }, i.signatureImport = function (t) - { + return { r: e, s: t }; + }, i.signatureImport = function(t) { var e = p.fromBuffer(t.r); return e.isOverflow() && (e = p.fromNumber(0)), (t = p.fromBuffer(t.s)).isOverflow() && (t = p.fromNumber(0)), f.concat([e.toBuffer(), t.toBuffer()]); - }, i.sign = function (t,e,r,i) - { + }, i.sign = function(t, e, r, i) { var n = p.fromBuffer(e); - if(n.isOverflow() || n.isZero()) + if (n.isOverflow() || n.isZero()) throw Error(d.ECDSA_SIGN_FAIL); - if(null === r) - { + if (null === r) { var s = new c("sha256", e, t, i); - r = function () - { + r = function() { return s.generate(32); }; } - for(var o = p.fromBuffer(t), a = 0; ; ++a) - { + for (var o = p.fromBuffer(t), a = 0; ; ++a) { var h = r(t, e, null, i, a); - if(!f.isBuffer(h) || 32 !== h.length) + if (!f.isBuffer(h) || 32 !== h.length) throw Error(d.ECDSA_SIGN_FAIL); var u = p.fromBuffer(h); - if(!u.isOverflow() && !u.isZero()) - { + if (!u.isOverflow() && !u.isZero()) { var l = m.mul(u); - if(!(h = l.x.fireduce()).isZero() && !(u = u.uinvm().umul(h.umul(n).ureduce().iadd(o).fireduce()).ureduce()).isZero()) - return t = (0 !== l.x.ucmp(h) ? 2 : 0) | (l.y.isOdd() ? 1 : 0), u.isHigh() && (u = p.n.sub(u), t ^= 1), {signature:f.concat([h.toBuffer(), - u.toBuffer()]), recovery:t}; + if (!(h = l.x.fireduce()).isZero() && !(u = u.uinvm().umul(h.umul(n).ureduce().iadd(o).fireduce()).ureduce()).isZero()) + return t = (0 !== l.x.ucmp(h) ? 2 : 0) | (l.y.isOdd() ? 1 : 0), u.isHigh() && (u = p.n.sub(u), t ^= 1), { + signature: f.concat([h.toBuffer(), + u.toBuffer()]), recovery: t + }; } } - }, i.verify = function (t,e,r) - { + }, i.verify = function(t, e, r) { var i = p.fromBuffer(e.slice(0, 32)); - if(e = p.fromBuffer(e.slice(32, 64)), i.isOverflow() || e.isOverflow()) + if (e = p.fromBuffer(e.slice(32, 64)), i.isOverflow() || e.isOverflow()) throw Error(d.ECDSA_SIGNATURE_PARSE_FAIL); - if(e.isHigh() || i.isZero() || e.isZero()) + if (e.isHigh() || i.isZero() || e.isZero()) return !1; - if(null === (r = o.fromPublicKey(r))) + if (null === (r = o.fromPublicKey(r))) throw Error(d.EC_PUBLIC_KEY_PARSE_FAIL); return t = (e = e.uinvm()).umul(p.fromBuffer(t)).ureduce(), e = e.umul(i).ureduce(), !(t = m.mulAdd(t, r, e)).inf && (r = t.z.redSqr(), - 0 === i.redMul(r).ucmp(t.x) || !(0 <= i.ucmp(p.psn)) && 0 === i.iadd(p.psn).redMul(r).ucmp(t.x)); - }, i.recover = function (t,e,r,i) - { + 0 === i.redMul(r).ucmp(t.x) || !(0 <= i.ucmp(p.psn)) && 0 === i.iadd(p.psn).redMul(r).ucmp(t.x)); + }, i.recover = function(t, e, r, i) { var n = p.fromBuffer(e.slice(0, 32)); - if(e = p.fromBuffer(e.slice(32, 64)), n.isOverflow() || e.isOverflow()) + if (e = p.fromBuffer(e.slice(32, 64)), n.isOverflow() || e.isOverflow()) throw Error(d.ECDSA_SIGNATURE_PARSE_FAIL); - do - { - if(!n.isZero() && !e.isZero()) - { + do { + if (!n.isZero() && !e.isZero()) { var s = n; - if(r >> 1) - { - if(0 <= s.ucmp(p.psn)) + if (r >> 1) { + if (0 <= s.ucmp(p.psn)) break; s = n.add(p.n); } - if(s = f.concat([f.from([2 + (1 & r)]), s.toBuffer()]), null !== (s = o.fromPublicKey(s))) + if (s = f.concat([f.from([2 + (1 & r)]), s.toBuffer()]), null !== (s = o.fromPublicKey(s))) return r = n.uinvm(), t = p.n.sub(p.fromBuffer(t)).umul(r).ureduce(), e = e.umul(r).ureduce(), o.fromECJPoint(m.mulAdd(t, s, - e)).toPublicKey(i); + e)).toPublicKey(i); } } - while(0); + while (0); throw Error(d.ECDSA_RECOVER_FAIL); - }, i.ecdh = function (t,e) - { + }, i.ecdh = function(t, e) { var r = i.ecdhUnsafe(t, e, !0); return n("sha256").update(r).digest(); - }, i.ecdhUnsafe = function (t,e,r) - { - if(null === (t = o.fromPublicKey(t))) + }, i.ecdhUnsafe = function(t, e, r) { + if (null === (t = o.fromPublicKey(t))) throw Error(d.EC_PUBLIC_KEY_PARSE_FAIL); - if((e = p.fromBuffer(e)).isOverflow() || e.isZero()) + if ((e = p.fromBuffer(e)).isOverflow() || e.isZero()) throw Error(d.ECDH_FAIL); return t.mul(e).toPublicKey(r); }; - }, {"../messages.json":49, "./bn":43, "./ecpoint":46, "./ecpointg":47, "create-hash":32, "drbg.js/hmac":36, "safe-buffer":42}], - 49:[function (t,e,r) - { - e.exports = {COMPRESSED_TYPE_INVALID:"compressed should be a boolean", EC_PRIVATE_KEY_TYPE_INVALID:"private key should be a Buffer", - EC_PRIVATE_KEY_LENGTH_INVALID:"private key length is invalid", EC_PRIVATE_KEY_RANGE_INVALID:"private key range is invalid", - EC_PRIVATE_KEY_TWEAK_ADD_FAIL:"tweak out of range or resulting private key is invalid", EC_PRIVATE_KEY_TWEAK_MUL_FAIL:"tweak out of range", - EC_PRIVATE_KEY_EXPORT_DER_FAIL:"couldn't export to DER format", EC_PRIVATE_KEY_IMPORT_DER_FAIL:"couldn't import from DER format", - EC_PUBLIC_KEYS_TYPE_INVALID:"public keys should be an Array", EC_PUBLIC_KEYS_LENGTH_INVALID:"public keys Array should have at least 1 element", - EC_PUBLIC_KEY_TYPE_INVALID:"public key should be a Buffer", EC_PUBLIC_KEY_LENGTH_INVALID:"public key length is invalid", EC_PUBLIC_KEY_PARSE_FAIL:"the public key could not be parsed or is invalid", - EC_PUBLIC_KEY_CREATE_FAIL:"private was invalid, try again", EC_PUBLIC_KEY_TWEAK_ADD_FAIL:"tweak out of range or resulting public key is invalid", - EC_PUBLIC_KEY_TWEAK_MUL_FAIL:"tweak out of range", EC_PUBLIC_KEY_COMBINE_FAIL:"the sum of the public keys is not valid", ECDH_FAIL:"scalar was invalid (zero or overflow)", - ECDSA_SIGNATURE_TYPE_INVALID:"signature should be a Buffer", ECDSA_SIGNATURE_LENGTH_INVALID:"signature length is invalid", - ECDSA_SIGNATURE_PARSE_FAIL:"couldn't parse signature", ECDSA_SIGNATURE_PARSE_DER_FAIL:"couldn't parse DER signature", ECDSA_SIGNATURE_SERIALIZE_DER_FAIL:"couldn't serialize signature to DER format", - ECDSA_SIGN_FAIL:"nonce generation function failed or private key is invalid", ECDSA_RECOVER_FAIL:"couldn't recover public key from signature", - MSG32_TYPE_INVALID:"message should be a Buffer", MSG32_LENGTH_INVALID:"message length is invalid", OPTIONS_TYPE_INVALID:"options should be an Object", - OPTIONS_DATA_TYPE_INVALID:"options.data should be a Buffer", OPTIONS_DATA_LENGTH_INVALID:"options.data length is invalid", - OPTIONS_NONCEFN_TYPE_INVALID:"options.noncefn should be a Function", RECOVERY_ID_TYPE_INVALID:"recovery should be a Number", - RECOVERY_ID_VALUE_INVALID:"recovery should have value between -1 and 4", TWEAK_TYPE_INVALID:"tweak should be a Buffer", TWEAK_LENGTH_INVALID:"tweak length is invalid"}; - }, {}], 50:[function (t,e,r) - { - -function i(t,e) - { + }, { "../messages.json": 49, "./bn": 43, "./ecpoint": 46, "./ecpointg": 47, "create-hash": 32, "drbg.js/hmac": 36, "safe-buffer": 42 }], + 49: [function(t, e, r) { + e.exports = { + COMPRESSED_TYPE_INVALID: "compressed should be a boolean", EC_PRIVATE_KEY_TYPE_INVALID: "private key should be a Buffer", + EC_PRIVATE_KEY_LENGTH_INVALID: "private key length is invalid", EC_PRIVATE_KEY_RANGE_INVALID: "private key range is invalid", + EC_PRIVATE_KEY_TWEAK_ADD_FAIL: "tweak out of range or resulting private key is invalid", EC_PRIVATE_KEY_TWEAK_MUL_FAIL: "tweak out of range", + EC_PRIVATE_KEY_EXPORT_DER_FAIL: "couldn't export to DER format", EC_PRIVATE_KEY_IMPORT_DER_FAIL: "couldn't import from DER format", + EC_PUBLIC_KEYS_TYPE_INVALID: "public keys should be an Array", EC_PUBLIC_KEYS_LENGTH_INVALID: "public keys Array should have at least 1 element", + EC_PUBLIC_KEY_TYPE_INVALID: "public key should be a Buffer", EC_PUBLIC_KEY_LENGTH_INVALID: "public key length is invalid", EC_PUBLIC_KEY_PARSE_FAIL: "the public key could not be parsed or is invalid", + EC_PUBLIC_KEY_CREATE_FAIL: "private was invalid, try again", EC_PUBLIC_KEY_TWEAK_ADD_FAIL: "tweak out of range or resulting public key is invalid", + EC_PUBLIC_KEY_TWEAK_MUL_FAIL: "tweak out of range", EC_PUBLIC_KEY_COMBINE_FAIL: "the sum of the public keys is not valid", ECDH_FAIL: "scalar was invalid (zero or overflow)", + ECDSA_SIGNATURE_TYPE_INVALID: "signature should be a Buffer", ECDSA_SIGNATURE_LENGTH_INVALID: "signature length is invalid", + ECDSA_SIGNATURE_PARSE_FAIL: "couldn't parse signature", ECDSA_SIGNATURE_PARSE_DER_FAIL: "couldn't parse DER signature", ECDSA_SIGNATURE_SERIALIZE_DER_FAIL: "couldn't serialize signature to DER format", + ECDSA_SIGN_FAIL: "nonce generation function failed or private key is invalid", ECDSA_RECOVER_FAIL: "couldn't recover public key from signature", + MSG32_TYPE_INVALID: "message should be a Buffer", MSG32_LENGTH_INVALID: "message length is invalid", OPTIONS_TYPE_INVALID: "options should be an Object", + OPTIONS_DATA_TYPE_INVALID: "options.data should be a Buffer", OPTIONS_DATA_LENGTH_INVALID: "options.data length is invalid", + OPTIONS_NONCEFN_TYPE_INVALID: "options.noncefn should be a Function", RECOVERY_ID_TYPE_INVALID: "recovery should be a Number", + RECOVERY_ID_VALUE_INVALID: "recovery should have value between -1 and 4", TWEAK_TYPE_INVALID: "tweak should be a Buffer", TWEAK_LENGTH_INVALID: "tweak length is invalid" + }; + }, {}], 50: [function(t, e, r) { + + function i(t, e) { this._block = l.alloc(t), this._finalSize = e, this._blockSize = t, this._len = 0; }; var l = t("safe-buffer").Buffer; - i.prototype.update = function (t,e) - { + i.prototype.update = function(t, e) { "string" == typeof t && (t = l.from(t, e || "utf8")); - for(var r = this._block, i = this._blockSize, n = t.length, s = this._len, o = 0; o < n; ) - { - for(var a = s % i, h = Math.min(n - o, i - a), u = 0; u < h; u++) + for (var r = this._block, i = this._blockSize, n = t.length, s = this._len, o = 0; o < n;) { + for (var a = s % i, h = Math.min(n - o, i - a), u = 0; u < h; u++) r[a + u] = t[o + u]; o += h, 0 == (s += h) % i && this._update(r); } return this._len += n, this; - }, i.prototype.digest = function (t) - { + }, i.prototype.digest = function(t) { var e = this._len % this._blockSize; - if(this._block[e] = 128, this._block.fill(0, e + 1), e >= this._finalSize && (this._update(this._block), this._block.fill(0)), - (e = 8 * this._len) <= 4294967295) + if (this._block[e] = 128, this._block.fill(0, e + 1), e >= this._finalSize && (this._update(this._block), this._block.fill(0)), + (e = 8 * this._len) <= 4294967295) this._block.writeUInt32BE(e, this._blockSize - 4); - else - { + else { var r = (4294967295 & e) >>> 0; this._block.writeUInt32BE((e - r) / 4294967296, this._blockSize - 8), this._block.writeUInt32BE(r, this._blockSize - 4); } return this._update(this._block), e = this._hash(), t ? e.toString(t) : e; - }, i.prototype._update = function () - { + }, i.prototype._update = function() { throw Error("_update must be implemented by subclass"); }, e.exports = i; - }, {"safe-buffer":42}], 51:[function (t,e,r) - { - (r = e.exports = function (t) - { + }, { "safe-buffer": 42 }], 51: [function(t, e, r) { + (r = e.exports = function(t) { t = t.toLowerCase(); var e = r[t]; - if(!e) + if (!e) throw Error(t + " is not supported (we accept pull requests)"); return new e; }).sha = t("./sha"), r.sha1 = t("./sha1"), r.sha224 = t("./sha224"), r.sha256 = t("./sha256"), r.sha384 = t("./sha384"), r.sha512 = t("./sha512"); - }, {"./sha":52, "./sha1":53, "./sha224":54, "./sha256":55, "./sha384":56, "./sha512":57}], 52:[function (t,e,r) - { - -function i() - { + }, { "./sha": 52, "./sha1": 53, "./sha224": 54, "./sha256": 55, "./sha384": 56, "./sha512": 57 }], 52: [function(t, e, r) { + + function i() { this.init(), this._w = o, n.call(this, 64, 56); }; r = t("inherits"); - var n = t("./hash"), s = t("safe-buffer").Buffer, h = [1518500249, 1859775393, - 1894007588, - 899497514], o = Array(80); - r(i, n), i.prototype.init = function () - { + var n = t("./hash"), s = t("safe-buffer").Buffer, h = [1518500249, 1859775393, - 1894007588, - 899497514], o = Array(80); + r(i, n), i.prototype.init = function() { return this._a = 1732584193, this._b = 4023233417, this._c = 2562383102, this._d = 271733878, this._e = 3285377520, this; - }, i.prototype._update = function (t) - { - for(var e = this._w, r = 0 | this._a, i = 0 | this._b, n = 0 | this._c, s = 0 | this._d, o = 0 | this._e, a = 0; a < 16; ++a) + }, i.prototype._update = function(t) { + for (var e = this._w, r = 0 | this._a, i = 0 | this._b, n = 0 | this._c, s = 0 | this._d, o = 0 | this._e, a = 0; a < 16; ++a) e[a] = t.readInt32BE(4 * a); - for(; a < 80; ++a) + for (; a < 80; ++a) e[a] = e[a - 3] ^ e[a - 8] ^ e[a - 14] ^ e[a - 16]; - for(t = 0; t < 80; ++t) - { + for (t = 0; t < 80; ++t) { a = (r << 5 | r >>> 27) + (0 === (a = ~~(t / 20)) ? i & n | ~i & s : 2 === a ? i & n | i & s | n & s : i ^ n ^ s) + o + e[t] + h[a] | 0, - o = s, s = n, n = i << 30 | i >>> 2, i = r, r = a; + o = s, s = n, n = i << 30 | i >>> 2, i = r, r = a; } this._a = r + this._a | 0, this._b = i + this._b | 0, this._c = n + this._c | 0, this._d = s + this._d | 0, this._e = o + this._e | 0; - }, i.prototype._hash = function () - { + }, i.prototype._hash = function() { var t = s.allocUnsafe(20); return t.writeInt32BE(0 | this._a, 0), t.writeInt32BE(0 | this._b, 4), t.writeInt32BE(0 | this._c, 8), t.writeInt32BE(0 | this._d, - 12), t.writeInt32BE(0 | this._e, 16), t; + 12), t.writeInt32BE(0 | this._e, 16), t; }, e.exports = i; - }, {"./hash":50, inherits:39, "safe-buffer":42}], 53:[function (t,e,r) - { - -function i() - { + }, { "./hash": 50, inherits: 39, "safe-buffer": 42 }], 53: [function(t, e, r) { + + function i() { this.init(), this._w = o, n.call(this, 64, 56); }; r = t("inherits"); - var n = t("./hash"), s = t("safe-buffer").Buffer, h = [1518500249, 1859775393, - 1894007588, - 899497514], o = Array(80); - r(i, n), i.prototype.init = function () - { + var n = t("./hash"), s = t("safe-buffer").Buffer, h = [1518500249, 1859775393, - 1894007588, - 899497514], o = Array(80); + r(i, n), i.prototype.init = function() { return this._a = 1732584193, this._b = 4023233417, this._c = 2562383102, this._d = 271733878, this._e = 3285377520, this; - }, i.prototype._update = function (t) - { - for(var e = this._w, r = 0 | this._a, i = 0 | this._b, n = 0 | this._c, s = 0 | this._d, o = 0 | this._e, a = 0; a < 16; ++a) + }, i.prototype._update = function(t) { + for (var e = this._w, r = 0 | this._a, i = 0 | this._b, n = 0 | this._c, s = 0 | this._d, o = 0 | this._e, a = 0; a < 16; ++a) e[a] = t.readInt32BE(4 * a); - for(; a < 80; ++a) + for (; a < 80; ++a) t = e[a - 3] ^ e[a - 8] ^ e[a - 14] ^ e[a - 16], e[a] = t << 1 | t >>> 31; - for(a = 0; a < 80; ++a) - { + for (a = 0; a < 80; ++a) { t = (r << 5 | r >>> 27) + (0 === (t = ~~(a / 20)) ? i & n | ~i & s : 2 === t ? i & n | i & s | n & s : i ^ n ^ s) + o + e[a] + h[t] | 0, - o = s, s = n, n = i << 30 | i >>> 2, i = r, r = t; + o = s, s = n, n = i << 30 | i >>> 2, i = r, r = t; } this._a = r + this._a | 0, this._b = i + this._b | 0, this._c = n + this._c | 0, this._d = s + this._d | 0, this._e = o + this._e | 0; - }, i.prototype._hash = function () - { + }, i.prototype._hash = function() { var t = s.allocUnsafe(20); return t.writeInt32BE(0 | this._a, 0), t.writeInt32BE(0 | this._b, 4), t.writeInt32BE(0 | this._c, 8), t.writeInt32BE(0 | this._d, - 12), t.writeInt32BE(0 | this._e, 16), t; + 12), t.writeInt32BE(0 | this._e, 16), t; }, e.exports = i; - }, {"./hash":50, inherits:39, "safe-buffer":42}], 54:[function (t,e,r) - { - -function i() - { + }, { "./hash": 50, inherits: 39, "safe-buffer": 42 }], 54: [function(t, e, r) { + + function i() { this.init(), this._w = a, s.call(this, 64, 56); }; r = t("inherits"); var n = t("./sha256"), s = t("./hash"), o = t("safe-buffer").Buffer, a = Array(64); - r(i, n), i.prototype.init = function () - { + r(i, n), i.prototype.init = function() { return this._a = 3238371032, this._b = 914150663, this._c = 812702999, this._d = 4144912697, this._e = 4290775857, this._f = 1750603025, - this._g = 1694076839, this._h = 3204075428, this; - }, i.prototype._hash = function () - { + this._g = 1694076839, this._h = 3204075428, this; + }, i.prototype._hash = function() { var t = o.allocUnsafe(28); return t.writeInt32BE(this._a, 0), t.writeInt32BE(this._b, 4), t.writeInt32BE(this._c, 8), t.writeInt32BE(this._d, 12), t.writeInt32BE(this._e, - 16), t.writeInt32BE(this._f, 20), t.writeInt32BE(this._g, 24), t; + 16), t.writeInt32BE(this._f, 20), t.writeInt32BE(this._g, 24), t; }, e.exports = i; - }, {"./hash":50, "./sha256":55, inherits:39, "safe-buffer":42}], 55:[function (t,e,r) - { - -function i() - { + }, { "./hash": 50, "./sha256": 55, inherits: 39, "safe-buffer": 42 }], 55: [function(t, e, r) { + + function i() { this.init(), this._w = o, n.call(this, 64, 56); }; r = t("inherits"); var n = t("./hash"), s = t("safe-buffer").Buffer, c = [1116352408, 1899447441, 3049323471, 3921009573, 961987163, 1508970993, - 2453635748, 2870763221, 3624381080, 310598401, 607225278, 1426881987, 1925078388, 2162078206, 2614888103, 3248222580, 3835390401, - 4022224774, 264347078, 604807628, 770255983, 1249150122, 1555081692, 1996064986, 2554220882, 2821834349, 2952996808, 3210313671, - 3336571891, 3584528711, 113926993, 338241895, 666307205, 773529912, 1294757372, 1396182291, 1695183700, 1986661051, 2177026350, - 2456956037, 2730485921, 2820302411, 3259730800, 3345764771, 3516065817, 3600352804, 4094571909, 275423344, 430227734, 506948616, - 659060556, 883997877, 958139571, 1322822218, 1537002063, 1747873779, 1955562222, 2024104815, 2227730452, 2361852424, 2428436474, - 2756734187, 3204031479, 3329325298], o = Array(64); - r(i, n), i.prototype.init = function () - { + 2453635748, 2870763221, 3624381080, 310598401, 607225278, 1426881987, 1925078388, 2162078206, 2614888103, 3248222580, 3835390401, + 4022224774, 264347078, 604807628, 770255983, 1249150122, 1555081692, 1996064986, 2554220882, 2821834349, 2952996808, 3210313671, + 3336571891, 3584528711, 113926993, 338241895, 666307205, 773529912, 1294757372, 1396182291, 1695183700, 1986661051, 2177026350, + 2456956037, 2730485921, 2820302411, 3259730800, 3345764771, 3516065817, 3600352804, 4094571909, 275423344, 430227734, 506948616, + 659060556, 883997877, 958139571, 1322822218, 1537002063, 1747873779, 1955562222, 2024104815, 2227730452, 2361852424, 2428436474, + 2756734187, 3204031479, 3329325298], o = Array(64); + r(i, n), i.prototype.init = function() { return this._a = 1779033703, this._b = 3144134277, this._c = 1013904242, this._d = 2773480762, this._e = 1359893119, this._f = 2600822924, - this._g = 528734635, this._h = 1541459225, this; - }, i.prototype._update = function (t) - { - for(var e = this._w, r = 0 | this._a, i = 0 | this._b, n = 0 | this._c, s = 0 | this._d, o = 0 | this._e, a = 0 | this._f, - h = 0 | this._g, u = 0 | this._h, l = 0; l < 16; ++l) + this._g = 528734635, this._h = 1541459225, this; + }, i.prototype._update = function(t) { + for (var e = this._w, r = 0 | this._a, i = 0 | this._b, n = 0 | this._c, s = 0 | this._d, o = 0 | this._e, a = 0 | this._f, + h = 0 | this._g, u = 0 | this._h, l = 0; l < 16; ++l) e[l] = t.readInt32BE(4 * l); - for(; l < 64; ++l) - { + for (; l < 64; ++l) { t = e[l - 2]; var f = e[l - 15]; e[l] = ((t >>> 17 | t << 15) ^ (t >>> 19 | t << 13) ^ t >>> 10) + e[l - 7] + ((f >>> 7 | f << 25) ^ (f >>> 18 | f << 14) ^ f >>> 3) + e[l - 16] | 0; } - for(l = 0; l < 64; ++l) + for (l = 0; l < 64; ++l) t = u + ((o >>> 6 | o << 26) ^ (o >>> 11 | o << 21) ^ (o >>> 25 | o << 7)) + (h ^ o & (a ^ h)) + c[l] + e[l] | 0, f = ((r >>> 2 | r << 30) ^ (r >>> 13 | r << 19) ^ (r >>> 22 | r << 10)) + (r & i | n & (r | i)) | 0, - u = h, h = a, a = o, o = s + t | 0, s = n, n = i, i = r, r = t + f | 0; + u = h, h = a, a = o, o = s + t | 0, s = n, n = i, i = r, r = t + f | 0; this._a = r + this._a | 0, this._b = i + this._b | 0, this._c = n + this._c | 0, this._d = s + this._d | 0, this._e = o + this._e | 0, - this._f = a + this._f | 0, this._g = h + this._g | 0, this._h = u + this._h | 0; - }, i.prototype._hash = function () - { + this._f = a + this._f | 0, this._g = h + this._g | 0, this._h = u + this._h | 0; + }, i.prototype._hash = function() { var t = s.allocUnsafe(32); return t.writeInt32BE(this._a, 0), t.writeInt32BE(this._b, 4), t.writeInt32BE(this._c, 8), t.writeInt32BE(this._d, 12), t.writeInt32BE(this._e, - 16), t.writeInt32BE(this._f, 20), t.writeInt32BE(this._g, 24), t.writeInt32BE(this._h, 28), t; + 16), t.writeInt32BE(this._f, 20), t.writeInt32BE(this._g, 24), t.writeInt32BE(this._h, 28), t; }, e.exports = i; - }, {"./hash":50, inherits:39, "safe-buffer":42}], 56:[function (t,e,r) - { - -function i() - { + }, { "./hash": 50, inherits: 39, "safe-buffer": 42 }], 56: [function(t, e, r) { + + function i() { this.init(), this._w = a, s.call(this, 128, 112); }; r = t("inherits"); var n = t("./sha512"), s = t("./hash"), o = t("safe-buffer").Buffer, a = Array(160); - r(i, n), i.prototype.init = function () - { + r(i, n), i.prototype.init = function() { return this._ah = 3418070365, this._bh = 1654270250, this._ch = 2438529370, this._dh = 355462360, this._eh = 1731405415, this._fh = 2394180231, - this._gh = 3675008525, this._hh = 1203062813, this._al = 3238371032, this._bl = 914150663, this._cl = 812702999, this._dl = 4144912697, - this._el = 4290775857, this._fl = 1750603025, this._gl = 1694076839, this._hl = 3204075428, this; - }, i.prototype._hash = function () - { - -function t(t,e,r) - { + this._gh = 3675008525, this._hh = 1203062813, this._al = 3238371032, this._bl = 914150663, this._cl = 812702999, this._dl = 4144912697, + this._el = 4290775857, this._fl = 1750603025, this._gl = 1694076839, this._hl = 3204075428, this; + }, i.prototype._hash = function() { + + function t(t, e, r) { i.writeInt32BE(t, r), i.writeInt32BE(e, r + 4); }; var i = o.allocUnsafe(48); return t(this._ah, this._al, 0), t(this._bh, this._bl, 8), t(this._ch, this._cl, 16), t(this._dh, this._dl, 24), t(this._eh, - this._el, 32), t(this._fh, this._fl, 40), i; + this._el, 32), t(this._fh, this._fl, 40), i; }, e.exports = i; - }, {"./hash":50, "./sha512":57, inherits:39, "safe-buffer":42}], 57:[function (t,e,r) - { - -function i() - { + }, { "./hash": 50, "./sha512": 57, inherits: 39, "safe-buffer": 42 }], 57: [function(t, e, r) { + + function i() { this.init(), this._w = o, n.call(this, 128, 112); }; - -function k(t,e) - { + + function k(t, e) { return t >>> 0 < e >>> 0 ? 1 : 0; }; r = t("inherits"); var n = t("./hash"), s = t("safe-buffer").Buffer, T = [1116352408, 3609767458, 1899447441, 602891725, 3049323471, 3964484399, - 3921009573, 2173295548, 961987163, 4081628472, 1508970993, 3053834265, 2453635748, 2937671579, 2870763221, 3664609560, 3624381080, - 2734883394, 310598401, 1164996542, 607225278, 1323610764, 1426881987, 3590304994, 1925078388, 4068182383, 2162078206, 991336113, - 2614888103, 633803317, 3248222580, 3479774868, 3835390401, 2666613458, 4022224774, 944711139, 264347078, 2341262773, 604807628, - 2007800933, 770255983, 1495990901, 1249150122, 1856431235, 1555081692, 3175218132, 1996064986, 2198950837, 2554220882, 3999719339, - 2821834349, 766784016, 2952996808, 2566594879, 3210313671, 3203337956, 3336571891, 1034457026, 3584528711, 2466948901, 113926993, - 3758326383, 338241895, 168717936, 666307205, 1188179964, 773529912, 1546045734, 1294757372, 1522805485, 1396182291, 2643833823, - 1695183700, 2343527390, 1986661051, 1014477480, 2177026350, 1206759142, 2456956037, 344077627, 2730485921, 1290863460, 2820302411, - 3158454273, 3259730800, 3505952657, 3345764771, 106217008, 3516065817, 3606008344, 3600352804, 1432725776, 4094571909, 1467031594, - 275423344, 851169720, 430227734, 3100823752, 506948616, 1363258195, 659060556, 3750685593, 883997877, 3785050280, 958139571, - 3318307427, 1322822218, 3812723403, 1537002063, 2003034995, 1747873779, 3602036899, 1955562222, 1575990012, 2024104815, 1125592928, - 2227730452, 2716904306, 2361852424, 442776044, 2428436474, 593698344, 2756734187, 3733110249, 3204031479, 2999351573, 3329325298, - 3815920427, 3391569614, 3928383900, 3515267271, 566280711, 3940187606, 3454069534, 4118630271, 4000239992, 116418474, 1914138554, - 174292421, 2731055270, 289380356, 3203993006, 460393269, 320620315, 685471733, 587496836, 852142971, 1086792851, 1017036298, - 365543100, 1126000580, 2618297676, 1288033470, 3409855158, 1501505948, 4234509866, 1607167915, 987167468, 1816402316, 1246189591], - o = Array(160); - r(i, n), i.prototype.init = function () - { + 3921009573, 2173295548, 961987163, 4081628472, 1508970993, 3053834265, 2453635748, 2937671579, 2870763221, 3664609560, 3624381080, + 2734883394, 310598401, 1164996542, 607225278, 1323610764, 1426881987, 3590304994, 1925078388, 4068182383, 2162078206, 991336113, + 2614888103, 633803317, 3248222580, 3479774868, 3835390401, 2666613458, 4022224774, 944711139, 264347078, 2341262773, 604807628, + 2007800933, 770255983, 1495990901, 1249150122, 1856431235, 1555081692, 3175218132, 1996064986, 2198950837, 2554220882, 3999719339, + 2821834349, 766784016, 2952996808, 2566594879, 3210313671, 3203337956, 3336571891, 1034457026, 3584528711, 2466948901, 113926993, + 3758326383, 338241895, 168717936, 666307205, 1188179964, 773529912, 1546045734, 1294757372, 1522805485, 1396182291, 2643833823, + 1695183700, 2343527390, 1986661051, 1014477480, 2177026350, 1206759142, 2456956037, 344077627, 2730485921, 1290863460, 2820302411, + 3158454273, 3259730800, 3505952657, 3345764771, 106217008, 3516065817, 3606008344, 3600352804, 1432725776, 4094571909, 1467031594, + 275423344, 851169720, 430227734, 3100823752, 506948616, 1363258195, 659060556, 3750685593, 883997877, 3785050280, 958139571, + 3318307427, 1322822218, 3812723403, 1537002063, 2003034995, 1747873779, 3602036899, 1955562222, 1575990012, 2024104815, 1125592928, + 2227730452, 2716904306, 2361852424, 442776044, 2428436474, 593698344, 2756734187, 3733110249, 3204031479, 2999351573, 3329325298, + 3815920427, 3391569614, 3928383900, 3515267271, 566280711, 3940187606, 3454069534, 4118630271, 4000239992, 116418474, 1914138554, + 174292421, 2731055270, 289380356, 3203993006, 460393269, 320620315, 685471733, 587496836, 852142971, 1086792851, 1017036298, + 365543100, 1126000580, 2618297676, 1288033470, 3409855158, 1501505948, 4234509866, 1607167915, 987167468, 1816402316, 1246189591], + o = Array(160); + r(i, n), i.prototype.init = function() { return this._ah = 1779033703, this._bh = 3144134277, this._ch = 1013904242, this._dh = 2773480762, this._eh = 1359893119, this._fh = 2600822924, - this._gh = 528734635, this._hh = 1541459225, this._al = 4089235720, this._bl = 2227873595, this._cl = 4271175723, this._dl = 1595750129, - this._el = 2917565137, this._fl = 725511199, this._gl = 4215389547, this._hl = 327033209, this; - }, i.prototype._update = function (t) - { - for(var e = this._w, r = 0 | this._ah, i = 0 | this._bh, n = 0 | this._ch, s = 0 | this._dh, o = 0 | this._eh, a = 0 | this._fh, - h = 0 | this._gh, u = 0 | this._hh, l = 0 | this._al, f = 0 | this._bl, c = 0 | this._cl, d = 0 | this._dl, p = 0 | this._el, - m = 0 | this._fl, _ = 0 | this._gl, g = 0 | this._hl, b = 0; b < 32; b += 2) + this._gh = 528734635, this._hh = 1541459225, this._al = 4089235720, this._bl = 2227873595, this._cl = 4271175723, this._dl = 1595750129, + this._el = 2917565137, this._fl = 725511199, this._gl = 4215389547, this._hl = 327033209, this; + }, i.prototype._update = function(t) { + for (var e = this._w, r = 0 | this._ah, i = 0 | this._bh, n = 0 | this._ch, s = 0 | this._dh, o = 0 | this._eh, a = 0 | this._fh, + h = 0 | this._gh, u = 0 | this._hh, l = 0 | this._al, f = 0 | this._bl, c = 0 | this._cl, d = 0 | this._dl, p = 0 | this._el, + m = 0 | this._fl, _ = 0 | this._gl, g = 0 | this._hl, b = 0; b < 32; b += 2) e[b] = t.readInt32BE(4 * b), e[b + 1] = t.readInt32BE(4 * b + 4); - for(; b < 160; b += 2) - { + for (; b < 160; b += 2) { t = e[b - 30]; var y = e[b - 30 + 1], w = (t >>> 1 | y << 31) ^ (t >>> 8 | y << 24) ^ t >>> 7, v = (y >>> 1 | t << 31) ^ (y >>> 8 | t << 24) ^ (y >>> 7 | t << 25), - M = ((t = e[b - 4]) >>> 19 | (y = e[b - 4 + 1]) << 13) ^ (y >>> 29 | t << 3) ^ t >>> 6; + M = ((t = e[b - 4]) >>> 19 | (y = e[b - 4 + 1]) << 13) ^ (y >>> 29 | t << 3) ^ t >>> 6; y = (y >>> 19 | t << 13) ^ (t >>> 29 | y << 3) ^ (y >>> 6 | t << 26); var E = e[b - 32], S = e[b - 32 + 1]; t = v + e[b - 14 + 1] | 0, w = (w = (w = w + e[b - 14] + k(t, v) | 0) + M + k(t = t + y | 0, y) | 0) + E + k(t = t + S | 0, - S) | 0, e[b] = w, e[b + 1] = t; + S) | 0, e[b] = w, e[b + 1] = t; } - for(b = 0; b < 160; b += 2) - { + for (b = 0; b < 160; b += 2) { w = e[b], t = e[b + 1], y = r & i | n & (r | i); var I = l & f | c & (l | f); E = (r >>> 28 | l << 4) ^ (l >>> 2 | r << 30) ^ (l >>> 7 | r << 25), S = (l >>> 28 | r << 4) ^ (r >>> 2 | l << 30) ^ (r >>> 7 | l << 25); var A = T[b], B = T[b + 1], x = h ^ o & (a ^ h), L = _ ^ p & (m ^ _); v = (v = (v = (v = u + ((o >>> 14 | p << 18) ^ (o >>> 18 | p << 14) ^ (p >>> 9 | o << 23)) + k(M = g + ((p >>> 14 | o << 18) ^ (p >>> 18 | o << 14) ^ (o >>> 9 | p << 23)) | 0, - g) | 0) + x + k(M = M + L | 0, L) | 0) + A + k(M = M + B | 0, B) | 0) + w + k(M = M + t | 0, t) | 0, w = E + y + k(t = S + I | 0, - S) | 0, u = h, g = _, h = a, _ = m, a = o, m = p, o = s + v + k(p = d + M | 0, d) | 0, s = n, d = c, n = i, c = f, i = r, f = l, - r = v + w + k(l = M + t | 0, M) | 0; + g) | 0) + x + k(M = M + L | 0, L) | 0) + A + k(M = M + B | 0, B) | 0) + w + k(M = M + t | 0, t) | 0, w = E + y + k(t = S + I | 0, + S) | 0, u = h, g = _, h = a, _ = m, a = o, m = p, o = s + v + k(p = d + M | 0, d) | 0, s = n, d = c, n = i, c = f, i = r, f = l, + r = v + w + k(l = M + t | 0, M) | 0; } this._al = this._al + l | 0, this._bl = this._bl + f | 0, this._cl = this._cl + c | 0, this._dl = this._dl + d | 0, this._el = this._el + p | 0, - this._fl = this._fl + m | 0, this._gl = this._gl + _ | 0, this._hl = this._hl + g | 0, this._ah = this._ah + r + k(this._al, - l) | 0, this._bh = this._bh + i + k(this._bl, f) | 0, this._ch = this._ch + n + k(this._cl, c) | 0, this._dh = this._dh + s + k(this._dl, - d) | 0, this._eh = this._eh + o + k(this._el, p) | 0, this._fh = this._fh + a + k(this._fl, m) | 0, this._gh = this._gh + h + k(this._gl, - _) | 0, this._hh = this._hh + u + k(this._hl, g) | 0; - }, i.prototype._hash = function () - { - -function t(t,e,r) - { + this._fl = this._fl + m | 0, this._gl = this._gl + _ | 0, this._hl = this._hl + g | 0, this._ah = this._ah + r + k(this._al, + l) | 0, this._bh = this._bh + i + k(this._bl, f) | 0, this._ch = this._ch + n + k(this._cl, c) | 0, this._dh = this._dh + s + k(this._dl, + d) | 0, this._eh = this._eh + o + k(this._el, p) | 0, this._fh = this._fh + a + k(this._fl, m) | 0, this._gh = this._gh + h + k(this._gl, + _) | 0, this._hh = this._hh + u + k(this._hl, g) | 0; + }, i.prototype._hash = function() { + + function t(t, e, r) { i.writeInt32BE(t, r), i.writeInt32BE(e, r + 4); }; var i = s.allocUnsafe(64); return t(this._ah, this._al, 0), t(this._bh, this._bl, 8), t(this._ch, this._cl, 16), t(this._dh, this._dl, 24), t(this._eh, - this._el, 32), t(this._fh, this._fl, 40), t(this._gh, this._gl, 48), t(this._hh, this._hl, 56), i; + this._el, 32), t(this._fh, this._fl, 40), t(this._gh, this._gl, 48), t(this._hh, this._hl, 56), i; }, e.exports = i; - }, {"./hash":50, inherits:39, "safe-buffer":42}]}, {}, [30]); + }, { "./hash": 50, inherits: 39, "safe-buffer": 42 }] +}, {}, [30]); diff --git a/src/HTML/JS/wallet-lib.js b/src/HTML/JS/wallet-lib.js index 889a7d1..d870cd5 100644 --- a/src/HTML/JS/wallet-lib.js +++ b/src/HTML/JS/wallet-lib.js @@ -19,65 +19,56 @@ var MaxBlockNum = 0; var DelList = {}; var WasAccountsDataStr; -function SetAccountsData(Data,AccountsDataStr) -{ - if(!Data || !Data.result) - return ; - if($("idBtRun")) +function SetAccountsData(Data, AccountsDataStr) { + if (!Data || !Data.result) + return; + if ($("idBtRun")) $("idBtRun").style.display = (Data.arr.length ? '' : 'none'); - if(AccountsDataStr === WasAccountsDataStr) - return ; + if (AccountsDataStr === WasAccountsDataStr) + return; WasAccountsDataStr = AccountsDataStr; var arr = Data.arr; var Select = $("idAccount"); - if(arr.length !== Select.options.length) - { + if (arr.length !== Select.options.length) { var options = Select.options; options.length = arr.length; } MaxBlockNum = GetCurrentBlockNumByTime(); SetGridData(arr, "grid_accounts", "idMyTotalSum"); - for(var i = 0; arr && i < arr.length; i++) - { + for (var i = 0; arr && i < arr.length; i++) { var Item = arr[i]; Item.MyAccount = true; var Num = ParseNum(Item.Num); - if(!MapAccounts[Num]) + if (!MapAccounts[Num]) MapAccounts[Num] = {}; CopyObjKeys(MapAccounts[Num], Item); var option = Select.options[i]; var StrText = GetAccountText(Item, Num, 1); - if(option.text !== StrText) + if (option.text !== StrText) CheckNameAccTo(); option.value = Num; option.text = StrText; } var CurentValue = LoadMapAfter["idAccount"]; - if(CurentValue) - { + if (CurentValue) { Select.value = CurentValue; delete LoadMapAfter["idAccount"]; } SetCurCurencyName(); }; -function CurTransactionToForm(bForce) -{ +function CurTransactionToForm(bForce) { var Item = $("idTransaction"); - if(Item && (Item.className === "" || bForce)) + if (Item && (Item.className === "" || bForce)) Item.value = GetJSONFromTransaction(CurrentTR); }; -function CheckNameAccTo() -{ +function CheckNameAccTo() { MaxBlockNum = GetCurrentBlockNumByTime(); var ToID = ParseNum($("idTo").value); - if(!MapAccounts[ToID] || (MapAccounts[ToID].MustUpdate && MapAccounts[ToID].MustUpdate >= MaxBlockNum)) - { - GetData("GetAccountList", {StartNum:ToID}, function (Data) - { - if(Data && Data.result === 1 && Data.arr.length) - { + if (!MapAccounts[ToID] || (MapAccounts[ToID].MustUpdate && MapAccounts[ToID].MustUpdate >= MaxBlockNum)) { + GetData("GetAccountList", { StartNum: ToID }, function(Data) { + if (Data && Data.result === 1 && Data.arr.length) { var Item = Data.arr[0]; Item.UpdateData = Date.now(); MapAccounts[Item.Num] = Item; @@ -88,199 +79,173 @@ function CheckNameAccTo() SetNameAccTo(); }; -function SetNameAccTo() -{ +function SetNameAccTo() { var Str = ""; var ToID = ParseNum($("idTo").value); var Item = MapAccounts[ToID]; var element = $("idNameTo"); var StrTo = GetAccountText(Item, ToID, 1); - if(!element) - { + if (!element) { element = $("idNameTo2"); } - else - { + else { StrTo = "To: " + StrTo; } - if(element.innerText !== StrTo) - { + if (element.innerText !== StrTo) { element.innerText = StrTo; - if(Item && Item.MyAccount) + if (Item && Item.MyAccount) element.className = "smallbold"; else element.className = ""; } }; -function GetAccountText(Item,Num,bGetSum) -{ - if(Item) - { +function GetAccountText(Item, Num, bGetSum) { + if (Item) { var text = Item.Name; - if(!text || text.length === 0) + if (!text || text.length === 0) text = Num; else text = "" + Num + ". " + text; - if(bGetSum) - { + if (bGetSum) { var StrSum = SUM_TO_STRING(Item.Value, Item.Currency); text += " (" + StrSum + ")"; } return text; } - else - { + else { return Num; } }; -function OnEditIdTo() -{ +function OnEditIdTo() { CheckNameAccTo(); OnEditTransactionFields(); }; -function OnEditTransactionFields() -{ - if(IsVisibleBlock("edit_transaction")) +function OnEditTransactionFields() { + if (IsVisibleBlock("edit_transaction")) CreateTransaction(); SetCurCurencyName(); SaveValues(); }; -function SetCurCurencyName() -{ +function SetCurCurencyName() { var idCoin = $("idCoinName"); - if(!idCoin) - return ; + if (!idCoin) + return; var Num = ParseNum($("idAccount").value); var Item = MapAccounts[Num]; - if(Item) - { + if (Item) { idCoin.innerText = CurrencyName(Item.Currency); } }; -function CreateTransaction(F,CheckErr,Run) -{ +function CreateTransaction(F, CheckErr, Run) { CheckNameAccTo(); CheckSending(); var FromID = ParseNum($("idAccount").value); - if(CheckErr && FromID === 0) - { + if (CheckErr && FromID === 0) { SetError("Select valid 'From account'"); - return ; + return; } var StrTo = $("idTo").value.trim(); var bFindAcc = 0; var ToPubKey = ""; var ToID = ParseNum(StrTo); - if(StrTo !== "" + ToID) - { - if(StrTo.length === 66 && (StrTo.substr(0, 2) === "02" || StrTo.substr(0, 2) === "03") && IsHexStr(StrTo)) - { + if (StrTo !== "" + ToID) { + if (StrTo.length === 66 && (StrTo.substr(0, 2) === "02" || StrTo.substr(0, 2) === "03") && IsHexStr(StrTo)) { ToID = 0; ToPubKey = StrTo; - if(ToPubKey === PubKeyStr) + if (ToPubKey === PubKeyStr) bFindAcc = 1; } - else - { - if(CheckErr) + else { + if (CheckErr) SetError("Valid 'Pay to' - required!"); - return ; + return; } } - if(CheckErr && ToID <= 0 && ToPubKey === "" && !AttachItem) - { + if (CheckErr && ToID <= 0 && ToPubKey === "" && !AttachItem) { SetError("Valid 'Pay to' - required!"); - return ; + return; } var Description = $("idDescription").value.substr(0, 200); var StrSum = $("idSumSend").value; var indDot = StrSum.indexOf("."); - if(indDot >= 0) - { + if (indDot >= 0) { var StrTER = StrSum.substr(0, indDot); var StrCENT = StrSum.substr(indDot + 1); } - else - { + else { var StrTER = StrSum; var StrCENT = "0"; } StrCENT = StrCENT + "000000000"; - var Coin = {SumCOIN:ParseNum(StrTER), SumCENT:ParseNum(StrCENT.substr(0, 9))}; + var Coin = { SumCOIN: ParseNum(StrTER), SumCENT: ParseNum(StrCENT.substr(0, 9)) }; var OperationID = 0; var Item = MapAccounts[FromID]; - if(Item) - { + if (Item) { OperationID = Item.Value.OperationID; } var AttachBody = []; - if(AttachItem) - { + if (AttachItem) { AttachBody = AttachItem.Data.Body; - if(!AttachBody) + if (!AttachBody) AttachBody = []; } var ToPubKeyArr = []; - if(ToPubKey) + if (ToPubKey) ToPubKeyArr = GetArrFromHex(ToPubKey); - var TR = {Type:111, Version:3, Reserve:0, FromID:FromID, OperationID:OperationID, To:[{PubKey:ToPubKeyArr, ID:ToID, SumCOIN:Coin.SumCOIN, - SumCENT:Coin.SumCENT}], Description:Description, Body:AttachBody, Sign:CurrentTR.Sign, }; - Object.defineProperties(TR, {bFindAcc:{configurable:true, writable:true, enumerable:false, value:bFindAcc}}); - Object.defineProperties(TR, {Run:{configurable:true, writable:true, enumerable:false, value:Run}}); - if(JSON.stringify(TR) === JSON.stringify(CurrentTR)) - { - if(F) + var TR = { + Type: 111, Version: 3, Reserve: 0, FromID: FromID, OperationID: OperationID, To: [{ + PubKey: ToPubKeyArr, ID: ToID, SumCOIN: Coin.SumCOIN, + SumCENT: Coin.SumCENT + }], Description: Description, Body: AttachBody, Sign: CurrentTR.Sign, + }; + Object.defineProperties(TR, { bFindAcc: { configurable: true, writable: true, enumerable: false, value: bFindAcc } }); + Object.defineProperties(TR, { Run: { configurable: true, writable: true, enumerable: false, value: Run } }); + if (JSON.stringify(TR) === JSON.stringify(CurrentTR)) { + if (F) F(CurrentTR); - return ; + return; } CurrentTR = TR; - GetSignTransaction(TR, "", function (TR) - { + GetSignTransaction(TR, "", function(TR) { CurTransactionToForm(true); - if(F) + if (F) F(TR); }); }; -function SignJSON(F) -{ - if($("idSignJSON").disabled) - return ; +function SignJSON(F) { + if ($("idSignJSON").disabled) + return; var TR = GetTransactionFromJSON(); - if(!TR) - return ; + if (!TR) + return; CurrentTR = TR; - GetSignTransaction(TR, "", function (TR) - { + GetSignTransaction(TR, "", function(TR) { CurTransactionToForm(true); - if(F) + if (F) F(); }); }; -function CheckSending(bToStatus) -{ +function CheckSending(bToStatus) { MaxBlockNum = GetCurrentBlockNumByTime(); var CanSend = IsPrivateMode(); var StrButton = "Send"; var StrButtonSign = "Sign JSON"; - if(!CanSend) - { + if (!CanSend) { StrButton = " "; StrButtonSign = " "; } - if(CanSend) - { + if (CanSend) { var FromID = ParseNum($("idAccount").value); var Item = MapAccounts[FromID]; - if(Item && Item.NextSendTime && Item.NextSendTime > MaxBlockNum) - { - if(bToStatus) + if (Item && Item.NextSendTime && Item.NextSendTime > MaxBlockNum) { + if (bToStatus) SetStatus("Transaction was sending. Wait... (" + Item.LastTransactionText + ")"); CanSend = false; StrButton = "Wait..."; @@ -293,31 +258,26 @@ function CheckSending(bToStatus) return CanSend; }; -function AddWhiteList() -{ +function AddWhiteList() { var ToID = ParseNum($("idTo").value); - if(ToID && $("idWhiteOnSend").checked) + if (ToID && $("idWhiteOnSend").checked) Storage.setItem("White:" + ToID, 1); }; -function SendMoneyBefore() -{ - if($("idSendButton").disabled) - return ; +function SendMoneyBefore() { + if ($("idSendButton").disabled) + return; var ToID = ParseNum($("idTo").value); var Item = MapAccounts[ToID]; - if(Storage.getItem("White:" + ToID) || !$("idSumSend").value || Item && Item.MyAccount) - { + if (Storage.getItem("White:" + ToID) || !$("idSumSend").value || Item && Item.MyAccount) { SendMoney(); } - else - { + else { var CoinAmount = COIN_FROM_FLOAT($("idSumSend").value); var StrTo = " to " + GetAccountText(Item, ToID); $("idWhiteOnSend").checked = 0; $("idOnSendText").innerHTML = "" + STRING_FROM_COIN(CoinAmount) + " " + $("idCoinName").innerText + StrTo; - if($("idSumSend").value >= 100000) - { + if ($("idSumSend").value >= 100000) { $("idOnSendText").innerHTML += "
WARNING: You are about to send a very large amount!
"; } SetVisibleBlock("idBlockOnSend", 1); @@ -325,31 +285,26 @@ function SendMoneyBefore() } }; -function SendMoney2() -{ +function SendMoney2() { AddWhiteList(); SendMoney(); }; -function SendMoney() -{ - if(!CanSendTransaction) - { +function SendMoney() { + if (!CanSendTransaction) { SetError("Can't Send transaction"); - return ; + return; } CheckSending(true); - if($("idSendButton").disabled) - return ; + if ($("idSendButton").disabled) + return; SetVisibleBlock("idBlockOnSend", 0); CreateTransaction(SendMoneyTR, true, ClearAttach); }; -function GetJSONFromTransaction(TR) -{ +function GetJSONFromTransaction(TR) { var TR2 = JSON.parse(JSON.stringify(TR)); - for(var i = 0; i < TR2.To.length; i++) - { + for (var i = 0; i < TR2.To.length; i++) { var Item = TR2.To[i]; Item.PubKey = GetHexFromArr(Item.PubKey); } @@ -359,24 +314,19 @@ function GetJSONFromTransaction(TR) return Str; }; -function GetTransactionFromJSON() -{ +function GetTransactionFromJSON() { var Str = $("idTransaction").value; - try - { + try { var TR = JSON.parse(Str); } - catch(e) - { + catch (e) { SetError(e); return undefined; } - for(var i = 0; i < TR.To.length; i++) - { + for (var i = 0; i < TR.To.length; i++) { var Item = TR.To[i]; Item.PubKey = GetArrFromHex(Item.PubKey); - if(Item.SumTER && Item.SumCOIN === undefined) - { + if (Item.SumTER && Item.SumCOIN === undefined) { Item.SumCOIN = Item.SumTER; delete Item.SumTER; } @@ -386,68 +336,58 @@ function GetTransactionFromJSON() return TR; }; -function SendMoneyJSON() -{ - if(!CanSendTransaction) - { +function SendMoneyJSON() { + if (!CanSendTransaction) { SetError("Can't Send transaction"); - return ; + return; } var TR = GetTransactionFromJSON(); - if(!TR) - return ; + if (!TR) + return; SendMoneyTR(TR); }; -function SignAndSendFromJSON() -{ +function SignAndSendFromJSON() { SignJSON(SendMoneyJSON); }; -function GetTransactionText(TR,key) -{ +function GetTransactionText(TR, key) { var Str; - if(TR) - { - if(TR.Type === TYPE_TRANSACTION_CREATE) - { + if (TR) { + if (TR.Type === TYPE_TRANSACTION_CREATE) { Str = "New account " + TR.Name.substr(0, 20); } else - if(TR.Type === 111) - { + if (TR.Type === 111) { var MapItem = {}; - var ValueTotal = {SumCOIN:0, SumCENT:0}; + var ValueTotal = { SumCOIN: 0, SumCENT: 0 }; Str = "" + TR.FromID + "/" + TR.OperationID + " to "; - for(var i = 0; i < TR.To.length; i++) - { + for (var i = 0; i < TR.To.length; i++) { var Item = TR.To[i]; - if(Item.ID === TR.FromID || MapItem[Item.ID]) + if (Item.ID === TR.FromID || MapItem[Item.ID]) continue; MapItem[Item.ID] = 1; ADD(ValueTotal, Item); - if(i === 0) + if (i === 0) Str += "["; - if(Str.length < 16) - { - if(i > 0) + if (Str.length < 16) { + if (i > 0) Str += ","; - if(Item.ID || (Item.PubKey && Item.PubKey.length !== 66)) + if (Item.ID || (Item.PubKey && Item.PubKey.length !== 66)) Str += Item.ID; else Str += GetHexFromArr(Item.PubKey).substr(0, 8); } else - if(Str.substr(Str.length - 1) !== ".") + if (Str.substr(Str.length - 1) !== ".") Str += "..."; } Str += "] " + SUM_TO_STRING(ValueTotal); Str += " " + (TR.Description.substr(0, 20)).replace(/\n/g, ""); } } - else - { - if(key) + else { + if (key) Str = key; else Str = ""; @@ -455,18 +395,15 @@ function GetTransactionText(TR,key) return Str; }; -function SendMoneyTR(TR) -{ +function SendMoneyTR(TR) { var Body = GetArrFromTR(TR); WriteArr(Body, TR.Sign, 64); Body.length += 12; - SendTransaction(Body, TR, undefined, function (Err,TR,Body) - { - if(Err) - return ; + SendTransaction(Body, TR, undefined, function(Err, TR, Body) { + if (Err) + return; var Item = MapAccounts[TR.FromID]; - if(Item) - { + if (Item) { var key = GetHexFromArr(sha3(Body)); var BlockNum = GetCurrentBlockNumByTime(); Item.LastTransactionText = GetTransactionText(TR); @@ -477,37 +414,31 @@ function SendMoneyTR(TR) }); }; -function ClearTransaction() -{ +function ClearTransaction() { PayList = []; ClearAttach(); CheckSendList(1); var arr = ["idAccount", "idTo", "idSumSend", "idDescription"]; - for(var i = 0; i < arr.length; i++) - { + for (var i = 0; i < arr.length; i++) { $(arr[i]).value = ""; } SaveValues(); CreateTransaction(); }; -function StartEditTransactionJSON() -{ +function StartEditTransactionJSON() { var Item = $("idTransaction"); Item.className = "smallbold"; }; -function EditJSONTransaction() -{ +function EditJSONTransaction() { var name = "edit_transaction"; var Item = $("idTransaction"); - if(IsVisibleBlock(name)) - { + if (IsVisibleBlock(name)) { SetVisibleBlock(name, false); Item.className = ""; } - else - { + else { CreateTransaction(); SetVisibleBlock(name, true); Item.className = ""; @@ -515,16 +446,14 @@ function EditJSONTransaction() }; var glNumPayCount = 0; -function GetInvoiceHTML(item,onclick,classstr) -{ - if(!item.num) - { +function GetInvoiceHTML(item, onclick, classstr) { + if (!item.num) { glNumPayCount++; item.num = glNumPayCount; } var idname = "idSendInvoice" + item.num; var value = ""; - if(item.Data.Amount) + if (item.Data.Amount) value += "" + item.Data.Amount + " Tera"; else value += "No pay"; @@ -532,55 +461,46 @@ function GetInvoiceHTML(item,onclick,classstr) return ""; }; -function AddSendList(item) -{ - PayList.push({Data:item}); +function AddSendList(item) { + PayList.push({ Data: item }); }; -function CheckSendList(bRedraw) -{ +function CheckSendList(bRedraw) { TitleWarning = PayList.length; - if(AttachItem) + if (AttachItem) TitleWarning++; var Str = Storage.getItem("InvoiceList"); - if(!Str && !bRedraw) - return ; - if(!bRedraw) - { + if (!Str && !bRedraw) + return; + if (!bRedraw) { SelectTab("TabSend"); } - if(Str) - { + if (Str) { var arr = JSON.parse(Str); - for(var i = 0; i < arr.length; i++) - { + for (var i = 0; i < arr.length; i++) { AddSendList(arr[i]); } Storage.setItem("InvoiceList", ""); } var idList = $("idSendList"); - if(PayList.length) - { + if (PayList.length) { idList.innerHTML = "
Select the item you want to sign (pay) and send to blockchain:
"; - for(var i = 0; i < PayList.length; i++) - { + for (var i = 0; i < PayList.length; i++) { var item = PayList[i]; idList.innerHTML += GetInvoiceHTML(item, "UseInvoice(" + i + ")", "btinvoice"); } - if(AttachItem === undefined) + if (AttachItem === undefined) UseInvoice(0); } - else - { + else { idList.innerHTML = ""; } }; setInterval(CheckSendList, 200); -function UseInvoice(Num) -{ +function UseInvoice(Num) { var item = PayList[Num]; - if(item.Data.From) + if (item.Data.From) $("idAccount").value = item.Data.From; $("idTo").value = item.Data.To; $("idSumSend").value = item.Data.Amount; @@ -591,19 +511,16 @@ function UseInvoice(Num) CheckSendList(1); }; -function ClearAttach() -{ +function ClearAttach() { AttachItem = undefined; - if($("idAttach")) + if ($("idAttach")) $("idAttach").innerHTML = ""; }; -function OpenAttach() -{ - if(AttachItem) - { +function OpenAttach() { + if (AttachItem) { var Data2 = JSON.parse(JSON.stringify(AttachItem.Data)); - if(Data2.Body) + if (Data2.Body) Data2.Body = GetHexFromArr(Data2.Body); delete Data2.TransferSecret; alert("DATA:\n" + JSON.stringify(Data2, "", 4)); @@ -611,79 +528,65 @@ function OpenAttach() }; var CURRENCY, PUBKEY, NAME, SMART; -function SendTrCreateAccWait(Currency,PubKey,Name,Smart) -{ +function SendTrCreateAccWait(Currency, PubKey, Name, Smart) { CURRENCY = Currency; PUBKEY = PubKey; NAME = Name; SMART = Smart; - setTimeout(function () - { + setTimeout(function() { SendTrCreateAcc(CURRENCY, PUBKEY, NAME, 0, SMART, 0, 0); }, 50); }; -function SendTrCreateAcc(Currency,PubKey,Description,Adviser,Smart,bFindAcc,bAddToPay) -{ +function SendTrCreateAcc(Currency, PubKey, Description, Adviser, Smart, bFindAcc, bAddToPay) { var TR = GetTrCreateAcc(Currency, PubKey, Description, Adviser, Smart); var Body = GetBodyCreateAcc(TR); TR.bFindAcc = 1; - if(bAddToPay) - { - var Item = {name:Description, To:0, Amount:CONFIG_DATA.PRICE_DAO.NewAccount, Description:"Create acc: " + Description, Body:Body, + if (bAddToPay) { + var Item = { + name: Description, To: 0, Amount: CONFIG_DATA.PRICE_DAO.NewAccount, Description: "Create acc: " + Description, Body: Body, }; AddToInvoiceList(Item); } - else - { + else { SendTransaction(Body, TR); } $("idAccountName").value = ""; CancelCreateAccount(); }; -function ChangeSmart(NumAccount,WasSmart) -{ - if(!IsPrivateMode()) - { +function ChangeSmart(NumAccount, WasSmart) { + if (!IsPrivateMode()) { SetError("Pls, open wallet"); return 0; } var Result = prompt("Enter smart number:", WasSmart); - if(Result !== null && Result != WasSmart) - { + if (Result !== null && Result != WasSmart) { var Smart = parseInt(Result); - if(Smart) - { - GetData("GetDappList", {StartNum:Smart, CountNum:1}, function (Data) - { - if(Data && Data.result && Data.arr.length === 1) - { + if (Smart) { + GetData("GetDappList", { StartNum: Smart, CountNum: 1 }, function(Data) { + if (Data && Data.result && Data.arr.length === 1) { SetSmartToAccount(NumAccount, Smart); } - else - { + else { SetError("Error smart number"); } }); } - else - { + else { SetSmartToAccount(NumAccount, Smart); } } }; -function SetSmartToAccount(NumAccount,Smart) -{ +function SetSmartToAccount(NumAccount, Smart) { var OperationID = 0; var Item = MapAccounts[NumAccount]; - if(Item) - { + if (Item) { OperationID = Item.Value.OperationID; } OperationID++; - var TR = {Type:140, Account:NumAccount, Smart:Smart, FromNum:NumAccount, Reserve:[], OperationID:OperationID, Sign:"", }; + var TR = { Type: 140, Account: NumAccount, Smart: Smart, FromNum: NumAccount, Reserve: [], OperationID: OperationID, Sign: "", }; var Body = []; WriteByte(Body, TR.Type); WriteUint(Body, TR.Account); @@ -694,12 +597,11 @@ function SetSmartToAccount(NumAccount,Smart) SendTrArrayWithSign(Body, TR.Account, TR); }; -function CheckLengthAccDesription(name,Length) -{ +function CheckLengthAccDesription(name, Length) { var Str = $(name).value.substr(0, Length + 1); var arr = toUTF8Array(Str); var Len = Length - arr.length; - if(Len < 0) + if (Len < 0) SetError("Bad length"); else SetStatus("Lost: " + Len + " bytes"); diff --git a/src/HTML/JS/wallet-web.js b/src/HTML/JS/wallet-web.js index c582e93..7e31c96 100644 --- a/src/HTML/JS/wallet-web.js +++ b/src/HTML/JS/wallet-web.js @@ -18,24 +18,37 @@ var StartTimeConnecting = 0; var ConnectedCount = 0; var NETWORK = "TERA-MAIN"; var ServerMap = {}; -var ServerMainMap = {"127.0.0.1":{"ip":"127.0.0.1", "port":80, "Name":"LOCAL"}, "terafoundation.org":{"ip":"terafoundation.org", - "port":443, "Name":"TERA", "System":1}, "dappsgate.com":{"ip":"dappsgate.com", "port":80, "Name":"SUPPORT2", "System":1}, "t1.teraexplorer.com":{"ip":"t1.teraexplorer.com", - "port":80, "Name":"t1.teraexplorer.com", "System":1}, "t2.teraexplorer.com":{"ip":"t2.teraexplorer.com", "port":80, "Name":"t2.teraexplorer.com", - "System":1}, "t3.teraexplorer.com":{"ip":"t3.teraexplorer.com", "port":80, "Name":"t3.teraexplorer.com", "System":1}, "t4.teraexplorer.com":{"ip":"t4.teraexplorer.com", - "port":80, "Name":"t4.teraexplorer.com", "System":1}, "t5.teraexplorer.com":{"ip":"t5.teraexplorer.com", "port":80, "Name":"t5.teraexplorer.com", - "System":1}, }; -var ServerTestMap = {"127.0.0.1":{"ip":"127.0.0.1", "port":80, "Name":"LOCAL"}, "dappsgate.com":{"ip":"dappsgate.com", "port":88, - "Name":"SUPPORT2", "System":1}, }; +var ServerMainMap = { + "127.0.0.1": { "ip": "127.0.0.1", "port": 80, "Name": "LOCAL" }, "terafoundation.org": { + "ip": "terafoundation.org", + "port": 443, "Name": "TERA", "System": 1 + }, "dappsgate.com": { "ip": "dappsgate.com", "port": 80, "Name": "SUPPORT2", "System": 1 }, "t1.teraexplorer.com": { + "ip": "t1.teraexplorer.com", + "port": 80, "Name": "t1.teraexplorer.com", "System": 1 + }, "t2.teraexplorer.com": { + "ip": "t2.teraexplorer.com", "port": 80, "Name": "t2.teraexplorer.com", + "System": 1 + }, "t3.teraexplorer.com": { "ip": "t3.teraexplorer.com", "port": 80, "Name": "t3.teraexplorer.com", "System": 1 }, "t4.teraexplorer.com": { + "ip": "t4.teraexplorer.com", + "port": 80, "Name": "t4.teraexplorer.com", "System": 1 + }, "t5.teraexplorer.com": { + "ip": "t5.teraexplorer.com", "port": 80, "Name": "t5.teraexplorer.com", + "System": 1 + }, +}; +var ServerTestMap = { + "127.0.0.1": { "ip": "127.0.0.1", "port": 80, "Name": "LOCAL" }, "dappsgate.com": { + "ip": "dappsgate.com", "port": 88, + "Name": "SUPPORT2", "System": 1 + }, +}; -function StartWebWallet() -{ - if(NETWORK === "TERA-TEST2") - { +function StartWebWallet() { + if (NETWORK === "TERA-TEST2") { MIN_SUM_POWER = 0; ServerMap = ServerTestMap; } - else - { + else { MIN_SUM_POWER = COUNT_BLOCK_PROOF * 35; ServerMap = ServerMainMap; } @@ -44,64 +57,53 @@ function StartWebWallet() ConnectWebWallet(); }; -function OnInitWebWallet() -{ +function OnInitWebWallet() { var str = Storage.getItem(NETWORK + "NodesArrayList"); - if(str) - { + if (str) { var arr = JSON.parse(str); - for(var i = 0; i < arr.length; i++) - { + for (var i = 0; i < arr.length; i++) { var Item = ServerMap[arr[i].ip]; - if(Item && Item.System) + if (Item && Item.System) continue; ServerMap[arr[i].ip] = arr[i]; } } }; -function SaveServerMap() -{ +function SaveServerMap() { var arr = []; - for(var key in ServerMap) - { + for (var key in ServerMap) { var Item = ServerMap[key]; - if(Item.SumPower >= MIN_SUM_POWER) - { - arr.push({ip:Item.ip, port:Item.port}); + if (Item.SumPower >= MIN_SUM_POWER) { + arr.push({ ip: Item.ip, port: Item.port }); } } Storage.setItem(NETWORK + "NodesArrayList", JSON.stringify(arr)); }; -function SetStatus(Str) -{ +function SetStatus(Str) { var id = $("idStatus"); id.innerHTML = Str; - if(Str) + if (Str) console.log(id.innerText); }; -function SetError(Str,bNoSound) -{ +function SetError(Str, bNoSound) { SetStatus("
" + Str + "
"); }; var CountConnect = 0; var CountWallet = 0; -function ConnectWebWallet() -{ +function ConnectWebWallet() { StartTimeConnecting = Date.now(); ConnectedCount = 0; - for(var key in ServerMap) - { + for (var key in ServerMap) { var Item = ServerMap[key]; Item.SendHandShake = 0; } - if(window.BrowserIE && !IsLocalClient()) - { + if (window.BrowserIE && !IsLocalClient()) { MainServer = undefined; - return ; + return; } CountConnect = 0; CountWallet = 0; @@ -111,68 +113,57 @@ function ConnectWebWallet() }; var Stage = 0; -function LoopHandShake() -{ +function LoopHandShake() { Stage++; SetStatus("Connecting: " + Stage + "..."); - for(var key in ServerMap) - { + for (var key in ServerMap) { var Item = ServerMap[key]; - if(Item.SendHandShake || !Item.port) + if (Item.SendHandShake || !Item.port) continue; CountConnect++; - if(window.BrowserIE && CountConnect > 4) + if (window.BrowserIE && CountConnect > 4) break; DoNodeList(Item); } }; -function DoNodeList(Item) -{ +function DoNodeList(Item) { console.log(GetProtocolServerPath(Item) + "/GetNodeList"); - if(window.location.protocol === "https:" && Item.port !== 443) - return ; - if(Item.port === 443 && IsIPAddres(Item.ip)) - return ; + if (window.location.protocol === "https:" && Item.port !== 443) + return; + if (Item.port === 443 && IsIPAddres(Item.ip)) + return; SetStatus("Try: " + Item.ip + ":" + Item.port); Item.SendHandShake = 1; - GetData(GetProtocolServerPath(Item) + "/GetNodeList", {}, function (Data) - { - if(Data && Data.result && Data.NETWORK === NETWORK && Data.VersionNum >= MIN_VERSION) - { + GetData(GetProtocolServerPath(Item) + "/GetNodeList", {}, function(Data) { + if (Data && Data.result && Data.NETWORK === NETWORK && Data.VersionNum >= MIN_VERSION) { ConnectedCount++; Item.GetHandShake = 1; Item.BlockChain = Data.BlockChain; SetStatus("Get: " + Item.ip + ":" + Item.port); var bWas = 0; - for(var i = 0; i < Data.arr.length; i++) - { + for (var i = 0; i < Data.arr.length; i++) { var Node = Data.arr[i]; - if(!ServerMap[Node.ip] && Node.port) - { + if (!ServerMap[Node.ip] && Node.port) { ServerMap[Node.ip] = Node; console.log("New: " + Node.ip + ":" + Node.port); bWas = 1; } } - if(bWas && ConnectedCount < MaxConnectedCount && new Date() - StartTimeConnecting < MaxTimeConnecting) - { + if (bWas && ConnectedCount < MaxConnectedCount && new Date() - StartTimeConnecting < MaxTimeConnecting) { setTimeout(LoopHandShake, 100); } } }); }; -function LoopWalletInfo() -{ +function LoopWalletInfo() { SetStatus("Get wallets info..."); - for(var key in ServerMap) - { + for (var key in ServerMap) { var Item = ServerMap[key]; - if(Item.port) - { + if (Item.port) { CountWallet++; - if(window.BrowserIE && CountWallet > 4) + if (window.BrowserIE && CountWallet > 4) break; DoWalletInfo(Item); } @@ -180,18 +171,15 @@ function LoopWalletInfo() setTimeout(FindLider, 500); }; -function DoWalletInfo(Item) -{ - if(window.location.protocol === "https:" && Item.port !== 443) - return ; - if(Item.port === 443 && IsIPAddres(Item.ip)) - return ; +function DoWalletInfo(Item) { + if (window.location.protocol === "https:" && Item.port !== 443) + return; + if (Item.port === 443 && IsIPAddres(Item.ip)) + return; Item.StartTime = Date.now(); Item.SendWalletInfo = 1; - GetData(GetProtocolServerPath(Item) + "/GetCurrentInfo", {BlockChain:1}, function (Data) - { - if(Data && Data.result && Data.BlockChain && Data.NETWORK === NETWORK) - { + GetData(GetProtocolServerPath(Item) + "/GetCurrentInfo", { BlockChain: 1 }, function(Data) { + if (Data && Data.result && Data.BlockChain && Data.NETWORK === NETWORK) { Item.Name = Data.NODES_NAME; Item.GetWalletInfo = 1; Item.DeltaTime = new Date() - Item.StartTime; @@ -202,49 +190,40 @@ function DoWalletInfo(Item) }); }; -function FindLider() -{ +function FindLider() { MainServer = undefined; var Arr = []; var MapSumPower = {}; - for(var key in ServerMap) - { + for (var key in ServerMap) { var Item = ServerMap[key]; - if(Item.GetWalletInfo && Item.BlockChain) - { + if (Item.GetWalletInfo && Item.BlockChain) { var arr = Item.BlockChain; - if(arr.data) + if (arr.data) arr = arr.data; Item.SumPower = CalcPowFromBlockChain(arr); - if(Item.SumPower < MIN_SUM_POWER) - { + if (Item.SumPower < MIN_SUM_POWER) { console.log("Skip: " + Item.ip + ":" + Item.port + " SumPower(" + Item.SumPower + ") < MIN_SUM_POWER(" + MIN_SUM_POWER + ")"); continue; } - if(!MapSumPower[Item.SumPower]) + if (!MapSumPower[Item.SumPower]) MapSumPower[Item.SumPower] = 0; MapSumPower[Item.SumPower]++; Arr.push(Item); } } var Max = 0, MaxKey; - for(var key in MapSumPower) - { - if(MapSumPower[key] >= Max) - { + for (var key in MapSumPower) { + if (MapSumPower[key] >= Max) { Max = MapSumPower[key]; MaxKey = parseInt(key); } } - Arr.sort(function (a,b) - { + Arr.sort(function(a, b) { return a.DeltaTime - b.DeltaTime; }); - for(var i = 0; i < Arr.length; i++) - { + for (var i = 0; i < Arr.length; i++) { var Item = Arr[i]; - if(Item.SumPower === MaxKey) - { + if (Item.SumPower === MaxKey) { SetStatus("Find " + Item.ip + ":" + Item.port + " with pow=" + Item.SumPower + "/" + MaxKey + " ping=" + Item.DeltaTime); MainServer = Item; SaveServerMap(); @@ -254,23 +233,19 @@ function FindLider() OnFindServer(); }; -function CalcPowFromBlockChain(BufRead) -{ +function CalcPowFromBlockChain(BufRead) { var Sum = 0; var Arr = GetBlockArrFromBuffer(BufRead); - if(Arr.length === COUNT_BLOCK_PROOF) - { - for(var i = 0; i < Arr.length; i++) - { + if (Arr.length === COUNT_BLOCK_PROOF) { + for (var i = 0; i < Arr.length; i++) { Sum += Arr[i].Power; } } return Sum; }; -function SetAllSum() -{ +function SetAllSum() { var Item = MapAccounts[$("idAccount").value]; - if(Item) + if (Item) $("idSumSend").value = FLOAT_FROM_COIN(Item.Value).toStringF(); }; diff --git a/src/core/api/api-exchange.ts b/src/core/api/api-exchange.ts index 1a2adf9..186efde 100644 --- a/src/core/api/api-exchange.ts +++ b/src/core/api/api-exchange.ts @@ -12,7 +12,9 @@ global.HTTPCaller.CreateAccount = function(Params, response) { if (typeof Params === "object" && Params.Name && Params.PubKey) { var TYPE_TRANSACTION_CREATE = 100; var TR = { - Type: global.TYPE_TRANSACTION_CREATE, Currency: Params.Currency, PubKey: global.GetArrFromHex(Params.PubKey), Description: Params.Name, + Type: global.TYPE_TRANSACTION_CREATE, + Currency: Params.Currency, + PubKey: global.GetArrFromHex(Params.PubKey), Description: Params.Name, Smart: Params.Smart, Adviser: 0, }; var Body = global.BufLib.GetBufferFromObject(TR, global.FORMAT_CREATE, 1000, {}); diff --git a/src/core/base.ts b/src/core/base.ts index 1e7af3f..05487d0 100644 --- a/src/core/base.ts +++ b/src/core/base.ts @@ -16,7 +16,7 @@ import * as crypto from 'crypto'; import * as os from 'os' global.glStopNode = false; -const MAX_TIME_NETWORK_TRANSPORT = 1 * 1000; +//const MAX_TIME_NETWORK_TRANSPORT = 1 * 1000; var GlSumUser; var GlSumSys; var GlSumIdle; @@ -204,7 +204,7 @@ module.exports = class CCommon { return crypto.randomBytes(32); } }; -class SMemBuffer { +export class SMemBuffer { MetaMap1 MetaMap2 CheckName @@ -249,7 +249,7 @@ class SMemBuffer { return; if (this.CheckName) { var Count = 0; - for (var key in this.MetaMap2) { + for (var _ in this.MetaMap2) { Count++ } if (Count) { @@ -366,15 +366,15 @@ global.STreeBuffer = STreeBuffer; global.TestCreateTr = TestCreateTr; function TestCreateTr() { - const FORMAT_CREATE = "{\ - Type:byte,\ - Currency:uint,\ - PubKey:arr33,\ - Description:str40,\ - Adviser:uint,\ - Reserve:arr7,\ - POWCreate:arr12,\ - }"; + // const FORMAT_CREATE = "{\ + // Type:byte,\ + // Currency:uint,\ + // PubKey:arr33,\ + // Description:str40,\ + // Adviser:uint,\ + // Reserve:arr7,\ + // POWCreate:arr12,\ + // }"; var TR = { Type: 100, Currency: 0, PubKey: [2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], Description: "Description", Adviser: 10, diff --git a/src/core/block-exchange.ts b/src/core/block-exchange.ts index 2e3a773..b6ba88f 100644 --- a/src/core/block-exchange.ts +++ b/src/core/block-exchange.ts @@ -99,7 +99,7 @@ module.exports = class CConsensus extends require("./block-loader") Context.TrDataLen = 0 Context.Info = "Create at:" + global.GetStrOnlyTimeUTC() var Transfer; - var TransferM2; + //var TransferM2; var LocalLevel = 0; var Levels = this.LevelNodes; for (let L = 0; L < Levels.length; L++) { @@ -180,13 +180,14 @@ module.exports = class CConsensus extends require("./block-loader") global.ToLog("TRANSFER BlockNum:" + Block.BlockNum + " TxArray=" + Data.TxArray.length + " from " + NodeName(Node)) this.ToMaxPOWList(Data.MaxPOW) this.ToMaxSumList(this.GetMaxSumListFromID(Node, Data.MaxSumID, Data.BlockList)) - var WasNewAdd = 0; + //var WasNewAdd = 0; if (Data.TxArray.length) { for (var i = 0; i < Data.TxArray.length; i++) { var Tr = Data.TxArray[i]; var Res = this.AddTrToBlockQuote(Block, Tr); - if (Res === 1) - WasNewAdd = 1 + if (Res === 1) { + //WasNewAdd = 1 + } if (global.USE_CHECK_SENDING && Res > 0) { var Tt = Block.PowTxTree.find(Tr); if (Tt) { @@ -511,9 +512,8 @@ module.exports = class CConsensus extends require("./block-loader") bSend = 1 CanEnd = 0 break; - } - else { - var Stop = 1; + } else { + //var Stop = 1; } } } @@ -825,7 +825,7 @@ module.exports = class CConsensus extends require("./block-loader") var SumPow = 0; if (arr.length !== global.SUM_LIST_LENGTH) return SumPow; - var CountLoad = 0; + //var CountLoad = 0; var BlockNumStart = CurBlockNum - arr.length + 1; for (var i = 0; i < arr.length; i++) { var Item = arr[i]; @@ -1105,8 +1105,8 @@ module.exports = class CConsensus extends require("./block-loader") if (this.LoadHistoryMode) return; var bWasSave = false; - var LoadBlockNum; - var LoadHash; + // var LoadBlockNum; + // var LoadHash; var start_save = CURRENTBLOCKNUM + global.TIME_START_SAVE; for (var BlockNum = CURRENTBLOCKNUM - global.BLOCK_PROCESSING_LENGTH2; BlockNum > global.BLOCK_PROCESSING_LENGTH2 && BlockNum < CURRENTBLOCKNUM; BlockNum++) { var Block = this.GetBlock(BlockNum); diff --git a/src/core/block-loader.ts b/src/core/block-loader.ts index c366137..ef989d1 100644 --- a/src/core/block-loader.ts +++ b/src/core/block-loader.ts @@ -9,8 +9,8 @@ */ "use strict"; -const fs = require("fs"); -import * as crypto from 'crypto'; +//const fs = require("fs"); +//import * as crypto from 'crypto'; require('./block-loader-const'); const STAT_BLOCK_LOAD_PERIOD = global.CONSENSUS_PERIOD_TIME / 5; module.exports = class CBlock extends require("./rest-loader") @@ -264,7 +264,7 @@ module.exports = class CBlock extends require("./rest-loader") if (global.LOAD_TO_BEGIN && this.BlockNumDBMin) { this.SendLoadToBegin() } - var CountStopSend = 0; + //var CountStopSend = 0; var min_num = this.CurrentBlockNum - global.MAX_COUNT_CHAIN_LOAD; var min_num_load = this.CurrentBlockNum; for (var i = 0; i < this.LoadedChainList.length; i++) { @@ -309,8 +309,9 @@ module.exports = class CBlock extends require("./rest-loader") chain.StopSend = true } } - if (chain && chain.StopSend) - CountStopSend++ + if (chain && chain.StopSend) { + //CountStopSend++ + } chain = this.LoadedChainList[i] if (chain && !chain.GetFindDB() && !chain.StopSend) { this.SendChainNext(chain, true) @@ -532,7 +533,7 @@ module.exports = class CBlock extends require("./rest-loader") chain.BlockHead = Block if (!chain.BlockNumMax) chain.BlockNumMax = Block.BlockNum - var PrevBlock0 = PrevBlock; + //var PrevBlock0 = PrevBlock; if (BlockFind) { if (PrevBlock) { PrevBlock.BlockDown = BlockFind @@ -671,9 +672,9 @@ module.exports = class CBlock extends require("./rest-loader") for (var num = 0; num < this.LoadedChainList.length; num++) { var chain = this.LoadedChainList[num]; if (chain && chain.arr && chain.arr.length && chain.StopSend) { - var Count = 0; + //var Count = 0; for (var i = chain.CurNumArrLoad; i < chain.arr.length; i++) { - Count++ + //Count++ var Block = chain.arr[i]; if (!global.IsZeroArr(Block.TreeHash) && !Block.TreeEq && !Block.LoadDBFinaly) { if (!Block.MapSend) { @@ -696,13 +697,13 @@ module.exports = class CBlock extends require("./rest-loader") if (CountSend >= global.MAX_BLOCK_SEND) return; } - } - else + } else { if (i === chain.CurNumArrLoad) { chain.CurNumArrLoad++ Block.LoadDBFinaly = true - Count = 0 + //Count = 0 } + } } this.CheckAndWriteLoadedChain(chain) } @@ -1029,16 +1030,14 @@ module.exports = class CBlock extends require("./rest-loader") this.SendF(Node, { "Method": "CANBLOCK", "Data": { BlockNum: Block.BlockNum } }) } } - static - CANBLOCK_F() { + static CANBLOCK_F() { return "{BlockNum:uint}"; } CANBLOCK(Info, CurTime) { - var Data = this.DataFromF(Info); + // var Data = this.DataFromF(Info); this.SendF(Info.Node, { "Method": "RETCANBLOCK", "Data": { Result: 1 } }) } - static - RETCANBLOCK_F() { + static RETCANBLOCK_F() { return "{Result:byte}"; } RETCANBLOCK(Info, CurTime) { @@ -1149,10 +1148,10 @@ module.exports = class CBlock extends require("./rest-loader") this.FREE_MEM_BLOCKS(NumMax - global.BLOCK_COUNT_IN_MEMORY) var maxArrMap = Math.floor(NumMax / global.BLOCK_COUNT_IN_MEMORY) - 1; if (maxArrMap >= 0) { - var nWasCount = 0; + // var nWasCount = 0; for (var key in this.MapMapLoaded) if (key as any < maxArrMap) { - nWasCount++ + // nWasCount++ delete this.MapMapLoaded[key] } } diff --git a/src/core/connect.ts b/src/core/connect.ts index 36dc01e..098dbd3 100644 --- a/src/core/connect.ts +++ b/src/core/connect.ts @@ -9,7 +9,7 @@ */ "use strict"; -import * as crypto from 'crypto'; +// import * as crypto from 'crypto'; const CNode = require("./node"); global.PERIOD_FOR_RECONNECT = 3600 * 1000; global.CHECK_DELTA_TIME = { Num: 0, bUse: 0, StartBlockNum: 0, EndBlockNum: 0, bAddTime: 0, DeltaTime: 0, Sign: [] }; @@ -205,8 +205,8 @@ module.exports = class CConnect extends require("./transfer-msg") if (Node.BlockProcessCount <= this.BusyLevel) StopGetBlock = 1 } - var СтатДанные = []; - var DirectMAccount = 0; + // var СтатДанные = []; + // var DirectMAccount = 0; var Ret = { VERSIONMAX: global.DEF_VERSION, FIRST_TIME_BLOCK: 0, diff --git a/src/core/crypto-library.ts b/src/core/crypto-library.ts index 80c7144..647cc2c 100644 --- a/src/core/crypto-library.ts +++ b/src/core/crypto-library.ts @@ -451,40 +451,42 @@ function CalcTreeHashFromArrBody(BlockNum, arrContent) { } }; -function TestMerklTree() { - var h1 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; - var h2 = global.sha3("2"); - var h3 = global.sha3("3"); - var h4 = global.sha3("4"); - var h5 = global.sha3("5"); - var Tree: any = { RecalcCount: 0 }; - var CalcMap = {}; - Tree.LevelsHash = [[h1, h2]]; - Tree.RecalcCount = 0; - CalcMap[0] = 1; - CalcMap[1] = 1; - UpdateMerklTree(Tree, CalcMap, 0); - CalcMap = {}; - Tree.LevelsHash[0] = [h1, h2, h3, h4]; - Tree.RecalcCount = 0; - CalcMap[2] = 1; - CalcMap[3] = 1; - UpdateMerklTree(Tree, CalcMap, 0); - CalcMap = {}; - Tree.LevelsHash[0] = [h1, h2, h3]; - Tree.RecalcCount = 0; - CalcMap[Tree.LevelsHash[0].length - 1] = 1; - UpdateMerklTree(Tree, CalcMap, 0); - global.ToLog("Root=" + global.GetHexFromArr(Tree.Root)); - global.ToLog("RecalcCount=" + Tree.RecalcCount); - return Tree; -}; -if (0) +// function TestMerklTree() { +// var h1 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; +// var h2 = global.sha3("2"); +// var h3 = global.sha3("3"); +// var h4 = global.sha3("4"); +// // var h5 = global.sha3("5"); +// var Tree: any = { RecalcCount: 0 }; +// var CalcMap = {}; +// Tree.LevelsHash = [[h1, h2]]; +// Tree.RecalcCount = 0; +// CalcMap[0] = 1; +// CalcMap[1] = 1; +// UpdateMerklTree(Tree, CalcMap, 0); +// CalcMap = {}; +// Tree.LevelsHash[0] = [h1, h2, h3, h4]; +// Tree.RecalcCount = 0; +// CalcMap[2] = 1; +// CalcMap[3] = 1; +// UpdateMerklTree(Tree, CalcMap, 0); +// CalcMap = {}; +// Tree.LevelsHash[0] = [h1, h2, h3]; +// Tree.RecalcCount = 0; +// CalcMap[Tree.LevelsHash[0].length - 1] = 1; +// UpdateMerklTree(Tree, CalcMap, 0); +// global.ToLog("Root=" + global.GetHexFromArr(Tree.Root)); +// global.ToLog("RecalcCount=" + Tree.RecalcCount); +// return Tree; +// }; + +if (0) { setTimeout(function() { TestMerkleProof(100); global.ToLog("=========END========="); process.exit(0); }); +} function TestMerkleProof(CountTest) { for (var R = 0; R < CountTest; R++) { @@ -841,22 +843,22 @@ function DoSecret(Arr, Arr2, SecretBuf, StartLen) { } }; -function TestEncryptDecrypt() { - var ArrSecret = Buffer.from([1, 1, 1, 1, 1, 1]); - var Arr = GetArrFromStr(" Secret message", 64); - var Arr2 = Buffer.from(new Uint8Array(Arr.length)); - var Arr3 = Buffer.from(new Uint8Array(Arr.length)); - console.log("Message:"); - console.log(Arr); - console.log("-------------------"); - Encrypt(Arr, Arr2, ArrSecret); - console.log("Encrypt:"); - console.log(Arr2); - console.log("-------------------"); - Decrypt(Arr2, Arr3, ArrSecret); - console.log("Decrypt:"); - console.log(Utf8ArrayToStr(Arr3.slice(9))); -}; +// function TestEncryptDecrypt() { +// var ArrSecret = Buffer.from([1, 1, 1, 1, 1, 1]); +// var Arr = GetArrFromStr(" Secret message", 64); +// var Arr2 = Buffer.from(new Uint8Array(Arr.length)); +// var Arr3 = Buffer.from(new Uint8Array(Arr.length)); +// console.log("Message:"); +// console.log(Arr); +// console.log("-------------------"); +// Encrypt(Arr, Arr2, ArrSecret); +// console.log("Encrypt:"); +// console.log(Arr2); +// console.log("-------------------"); +// Decrypt(Arr2, Arr3, ArrSecret); +// console.log("Decrypt:"); +// console.log(Utf8ArrayToStr(Arr3.slice(9))); +// }; function toUTF8Array(str) { var utf8 = []; @@ -921,9 +923,9 @@ function Utf8ArrayToStr(array) { return out; }; -function GetArr32FromStr(Str) { - return GetArrFromStr(Str, 32); -}; +// function GetArr32FromStr(Str) { +// return GetArrFromStr(Str, 32); +// }; function GetArrFromStr(Str, Len) { var arr = toUTF8Array(Str); @@ -965,8 +967,7 @@ for (var i = 0; i < DEVELOP_PUB_KEY_ARR.length; i++) DEVELOP_PUB_KEY_ARR[i] = Buffer.from(global.GetArrFromHex(DEVELOP_PUB_KEY_ARR[i])); global.DEVELOP_PUB_KEY = DEVELOP_PUB_KEY_ARR[0]; global.DEVELOP_PUB_KEY0 = Buffer.from(global.GetArrFromHex("022e80aa78bc07c72781fac12488096f0bfa7b4f48fbab0f2a92e208d1ee3654df")); -let LOCAL_RUN = global.LOCAL_RUN; -if (LOCAL_RUN) { +if (global.LOCAL_RUN) { global.DEVELOP_PUB_KEY0 = Buffer.from(global.GetArrFromHex("026A04AB98D9E4774AD806E302DDDEB63BEA16B5CB5F223EE77478E861BB583EB3")); global.DEVELOP_PUB_KEY = global.DEVELOP_PUB_KEY0; } @@ -975,8 +976,8 @@ global.ARR_PUB_KEY = ["027ae0dce92d8be1f893525b226695ddf0fe6ad756349a76777ff51f3 "0270e0c5acb8eefe7faddac45503da4885e02fb554975d12907f6c33ac6c6bdba5", "0202f2aad628f46d433faf70ba6bf12ab9ed96a46923b592a72508dc43af36cb80", "0254f373fc44ac4a3e80ec8cb8cc3693a856caa82e0493067bdead78ce8ec354b8", "027617f9511b0b0cdbda8f3e17907732731296321846f3fd6fd19460f7227d9482", ]; -let GetHexFromArr = global.GetHexFromArr; -if (global.TEST_NETWORK || LOCAL_RUN) { +// let GetHexFromArr = global.GetHexFromArr; +if (global.TEST_NETWORK || global.LOCAL_RUN) { for (var i = 0; i < 100; i++) global.ARR_PUB_KEY[i] = global.GetHexFromArr(global.DEVELOP_PUB_KEY0); global.DEVELOP_PUB_KEY_ARR = [global.DEVELOP_PUB_KEY0]; diff --git a/src/core/html-server.ts b/src/core/html-server.ts index 55ea3eb..0b27e02 100644 --- a/src/core/html-server.ts +++ b/src/core/html-server.ts @@ -13,10 +13,12 @@ import './crypto-library' import './log' import * as crypto from 'crypto'; -const os = require('os'); var BlockTree = new global.STreeBuffer(300 * 1000, global.CompareItemHashSimple, "number"); -const http = require('http'), net = require('net'), url = require('url'), fs = require('fs'), querystring = require('querystring'); +import http = require('http'); +const url = require('url') +const fs = require('fs') +const querystring = require('querystring'); var ContenTypeMap = {}; ContenTypeMap["js"] = "application/javascript"; ContenTypeMap["css"] = "text/css"; @@ -1117,27 +1119,27 @@ HTTPCaller.GetHistoryTransactions = function(Params) { return { result: 0 }; }; -function GetCopyBlock(Block) { - var Result: any = { - BlockNum: Block.BlockNum, bSave: Block.bSave, TreeHash: global.GetHexFromAddres(Block.TreeHash), AddrHash: global.GetHexFromAddres(Block.AddrHash), - PrevHash: global.GetHexFromAddres(Block.PrevHash), SumHash: global.GetHexFromAddres(Block.SumHash), SumPow: Block.SumPow, TrDataPos: Block.TrDataPos, - TrDataLen: Block.TrDataLen, SeqHash: global.GetHexFromAddres(Block.SeqHash), Hash: global.GetHexFromAddres(Block.Hash), Power: global.GetPowPower(Block.PowHash), - TrCount: Block.TrCount, arrContent: Block.arrContent, - }; - return Result; -}; +// function GetCopyBlock(Block) { +// var Result: any = { +// BlockNum: Block.BlockNum, bSave: Block.bSave, TreeHash: global.GetHexFromAddres(Block.TreeHash), AddrHash: global.GetHexFromAddres(Block.AddrHash), +// PrevHash: global.GetHexFromAddres(Block.PrevHash), SumHash: global.GetHexFromAddres(Block.SumHash), SumPow: Block.SumPow, TrDataPos: Block.TrDataPos, +// TrDataLen: Block.TrDataLen, SeqHash: global.GetHexFromAddres(Block.SeqHash), Hash: global.GetHexFromAddres(Block.Hash), Power: global.GetPowPower(Block.PowHash), +// TrCount: Block.TrCount, arrContent: Block.arrContent, +// }; +// return Result; +// }; var AddrLength = 16; function GetHexFromAddresShort(Hash) { return global.GetHexFromAddres(Hash).substr(0, AddrLength); }; -function GetHexFromStrShort(Str) { - if (Str === undefined) - return Str; - else - return Str.substr(0, AddrLength); -}; +// function GetHexFromStrShort(Str) { +// if (Str === undefined) +// return Str; +// else +// return Str.substr(0, AddrLength); +// }; var glid = 0; function GetGUID(Block) { @@ -1247,7 +1249,7 @@ function AddMapList(arrLoadedBlocks, type, MapMapLoaded, MainChains?) { } } }; -var MapFileHTML5 = {}; +// var MapFileHTML5 = {}; function SendWebFile(response, name?, StrCookie?, bParsing?) { var type = name.substr(name.length - 4, 4); @@ -1385,21 +1387,21 @@ global.GetFileHTMLFromMarkdown = GetFileHTMLFromMarkdown; global.GetFileSimple = GetFileSimple; global.SaveFileSimple = SaveFileSimple; -function GetStrTime(now) { - if (!now) - now = global.GetCurrentTime(0); - var Str = "" + now.getHours().toStringZ(2); - Str = Str + ":" + now.getMinutes().toStringZ(2); - Str = Str + ":" + now.getSeconds().toStringZ(2); - return Str; -}; +// function GetStrTime(now) { +// if (!now) +// now = global.GetCurrentTime(0); +// var Str = "" + now.getHours().toStringZ(2); +// Str = Str + ":" + now.getMinutes().toStringZ(2); +// Str = Str + ":" + now.getSeconds().toStringZ(2); +// return Str; +// }; function OnGetData(arg) { - var response = { - end: function() { - }, writeHead: function() { - }, - }; + // var response = { + // end: function() { + // }, writeHead: function() { + // }, + // }; var Path = arg.path; var obj = arg.obj; if (Path.substr(0, 1) === "/") @@ -1573,18 +1575,18 @@ if (global.ELECTRON) { } exports.SendData = OnGetData; -function RunConsole(StrRun) { - var Str = fs.readFileSync("./EXPERIMENTAL/!run-console.js", { encoding: "utf8" }); - if (StrRun) - Str += "\n" + StrRun; - try { - var ret = eval(Str); - } - catch (e) { - ret = e.message + "\n" + e.stack; - } - return ret; -}; +// function RunConsole(StrRun) { +// var Str = fs.readFileSync("./EXPERIMENTAL/!run-console.js", { encoding: "utf8" }); +// if (StrRun) +// Str += "\n" + StrRun; +// try { +// var ret = eval(Str); +// } +// catch (e) { +// ret = e.message + "\n" + e.stack; +// } +// return ret; +// }; var WebWalletUser = {}; function GetUserContext(Params) { diff --git a/src/core/library.ts b/src/core/library.ts index 98d5910..d041b79 100644 --- a/src/core/library.ts +++ b/src/core/library.ts @@ -31,7 +31,7 @@ global.RBTree = require('bintrees').RBTree; global.ntpClient = require('ntp-client'); global.Stun = require('stun'); global.ZIP = require("zip"); -var strOS = os.platform() + "_" + os.arch(); +// var strOS = os.platform() + "_" + os.arch(); if (!global.secp256k1) { global.secp256k1 = require('secp256k1'); } @@ -56,16 +56,16 @@ global.GetCurrentBlockNumByTime = function GetCurrentBlockNumByTime() { return StartBlockNum; }; global.DelDir = function(Path) { - if (Path.substr(Path.length - 1, 1) === "/") + if (Path.substr(Path.length - 1, 1) === "/") { Path = Path.substr(0, Path.length - 1); + } if (fs.existsSync(Path)) { var arr = fs.readdirSync(Path); for (var i = 0; i < arr.length; i++) { var name = Path + "/" + arr[i]; if (fs.statSync(name).isDirectory()) { global.DelDir(name); - } - else { + } else { if (name.right(9) == "const.lst") continue; if (name.right(7) == "log.log") @@ -82,7 +82,7 @@ global.SliceArr = function(arr, start, end) { } return ret; }; -var nRand = Math.floor(123 + Math.random() * 1000); +// var nRand = Math.floor(123 + Math.random() * 1000); function random(max) { return Math.floor(Math.random() * max); diff --git a/src/core/log.ts b/src/core/log.ts index 085f6a8..f46d31c 100644 --- a/src/core/log.ts +++ b/src/core/log.ts @@ -12,31 +12,30 @@ import * as fs from 'fs' import './constant' import './log-strict' -let { - START_PORT_NUMBER, - CheckSizeLogFile, -} = global - -var file_name_info = global.GetDataPath("info.log"), file_name_infoPrev = global.GetDataPath("info-prev.log"); -CheckSizeLogFile(file_name_info, file_name_infoPrev); -var file_name_log = global.GetDataPath("log.log"), file_name_logPrev = global.GetDataPath("log-prev.log"); -CheckSizeLogFile(file_name_log, file_name_logPrev); -var file_name_log_web = global.GetDataPath("web.log"), file_name_log_webPrev = global.GetDataPath("web-prev.log"); -CheckSizeLogFile(file_name_log_web, file_name_log_webPrev); -var StartStatTime, file_name_error = global.GetDataPath("err.log"), file_name_errorPrev = global.GetDataPath("err-prev.log"); +var file_name_info = global.GetDataPath("info.log") +var file_name_infoPrev = global.GetDataPath("info-prev.log"); +global.CheckSizeLogFile(file_name_info, file_name_infoPrev); +var file_name_log = global.GetDataPath("log.log") +var file_name_logPrev = global.GetDataPath("log-prev.log"); +global.CheckSizeLogFile(file_name_log, file_name_logPrev); +var file_name_log_web = global.GetDataPath("web.log") +var file_name_log_webPrev = global.GetDataPath("web-prev.log"); +global.CheckSizeLogFile(file_name_log_web, file_name_log_webPrev); +var StartStatTime, file_name_error = global.GetDataPath("err.log") +var file_name_errorPrev = global.GetDataPath("err-prev.log"); function ToLogFile(e, t, r?) { t instanceof Error && (t = t.message + "\n" + t.stack), global.START_SERVER || (t = global.PROCESS_NAME + ": " + t), "MAIN" !== global.PROCESS_NAME && process.send ? process.send({ cmd: "log", message: t - }) : (console.log(START_PORT_NUMBER + ": " + global.GetStrOnlyTime() + ": " + t), r || SaveToLogFileSync(e, t)); + }) : (console.log(global.START_PORT_NUMBER + ": " + global.GetStrOnlyTime() + ": " + t), r || SaveToLogFileSync(e, t)); }; function ToLogClient(e, t, r) { let ArrLogClient = global.ArrLogClient; e && (ToLogFile(file_name_log, e), t || (t = ""), ArrLogClient.push({ text: global.GetStrOnlyTime() + " " + e, key: t, final: r }), 13 < ArrLogClient.length && ArrLogClient.shift()); }; -CheckSizeLogFile(file_name_error, file_name_errorPrev), global.ToLog = function(e, t) { +global.CheckSizeLogFile(file_name_error, file_name_errorPrev), global.ToLog = function(e, t) { void 0 === t && (t = 1), t && t > global.LOG_LEVEL || (global.ALL_LOG_TO_CLIENT ? ToLogClient(e, void 0, void 0) : ToLogFile(file_name_log, e)); }, global.ToLogWeb = function(e) { @@ -70,11 +69,11 @@ function ResizeArrAvg(e) { return t; }; -function ResizeArr(e) { - for (var t = [], r = Math.trunc(e.length / 2), o = 0; o < r; o++) - t[o] = e[2 * o]; - return t; -}; +// function ResizeArr(e) { +// for (var t = [], r = Math.trunc(e.length / 2), o = 0; o < r; o++) +// t[o] = e[2 * o]; +// return t; +// }; function GetDiagramData(e, t) { var r, o = 2 * MAX_STAT_PERIOD + 2; @@ -115,20 +114,20 @@ function CopyStatInterval(e, t) { r[n] = o[n], "MAX:" === n.substr(0, 4) && (o[n] = 0); }; -function SaveToLogFileAsync(e, o) { - fs.open(e, "a", void 0, function(e, r) { - if (e) - console.log("Ошибка открытия лог-файла ошибок"); - else { - var t = global.GetStrTime() + " : " + o + "\r\n"; - fs.write(r, t, null, "utf8", function(e, t) { - e ? console.log("Ошибка записи в лог-файл ошибок!") : fs.close(r, function(e) { - e && console.log(e); - }); - }); - } - }); -}; +// function SaveToLogFileAsync(e, o) { +// fs.open(e, "a", void 0, function(e, r) { +// if (e) +// console.log("Ошибка открытия лог-файла ошибок"); +// else { +// var t = global.GetStrTime() + " : " + o + "\r\n"; +// fs.write(r, t, null, "utf8", function(e, t) { +// e ? console.log("Ошибка записи в лог-файл ошибок!") : fs.close(r, function(e) { +// e && console.log(e); +// }); +// }); +// } +// }); +// }; function SaveToLogFileSync(e, t) { try { @@ -143,29 +142,35 @@ global.PrepareStatEverySecond = function() { CurStatIndex++; var e = GetCurrentStatIndex(); CopyStatInterval(CONTEXT_STATS, e), CopyStatInterval(CONTEXT_ERRORS, e); -}, global.TO_ERROR_LOG = function(e, t, r, o, n, a) { +} +global.TO_ERROR_LOG = function(e, t, r, o, n, a) { r instanceof Error && (r = r.message + "\n"), "rinfo" === o ? r += " from: " + n.address + ":" + n.port : "node" === o && (r += " from: " + n.ip + ":" + n.port); var l = e + ":" + t; global.ToError(" ==ERROR== " + l + " " + r), AddToStatContext(CONTEXT_ERRORS, l), global.ADD_TO_STAT("ERRORS"); -}, global.HASH_RATE = 0, global.ADD_HASH_RATE = function(e) { +} +global.HASH_RATE = 0, global.ADD_HASH_RATE = function(e) { e /= 1e6, global.HASH_RATE += e, global.ADD_TO_STAT("HASHRATE", e); -}, global.GET_STAT = function(e) { +} +global.GET_STAT = function(e) { var t = CONTEXT_STATS.Total[e]; return t || (t = 0), t; -}, global.ADD_TO_STAT_TIME = function(e, t, r) { +} +global.ADD_TO_STAT_TIME = function(e, t, r) { if (global.STAT_MODE) { if (r && 2 !== global.STAT_MODE) return; var o = process.hrtime(t), n = 1e3 * o[0] + o[1] / 1e6; global.ADD_TO_STAT(e, n); } -}, global.ADD_TO_STAT = function(e, t, r) { +} +global.ADD_TO_STAT = function(e, t, r) { if (global.STAT_MODE) { if (r && 2 !== global.STAT_MODE) return; AddToStatContext(CONTEXT_STATS, e, t); } -}, global.GET_STATDIAGRAMS = function(e) { +} +global.GET_STATDIAGRAMS = function(e) { global.GetCurrentTime(); var t = GetCurrentStatIndex(); if (!e || !e.length) @@ -195,7 +200,8 @@ global.PrepareStatEverySecond = function() { i.AvgValue = g, i.steptime = _, i.arr = T.slice(1); } return r; -}, global.GET_STATS = function(e) { +} +global.GET_STATS = function(e) { var t = global.GetCurrentTime(), r = GetCurrentStatIndex(); return { stats: { @@ -206,23 +212,28 @@ global.PrepareStatEverySecond = function() { r, 600) }, period: (t - StartStatTime) / 1e3, Confirmation: [] }; -}, global.StartCommonStat = function() { - for (var e in CONTEXT_STATS.Total) +} +global.StartCommonStat = function() { + for (var _ in CONTEXT_STATS.Total) return; global.ClearCommonStat(); -}, global.ClearCommonStat = function() { +} +global.ClearCommonStat = function() { StartStatTime = void (CurStatIndex = 0), CONTEXT_STATS = { Total: {}, Interval: [] }, CONTEXT_ERRORS = { Total: {}, Interval: [] }, global.HASH_RATE = 0, global.SERVER.ClearStat(); -}, global.ResizeArrAvg = ResizeArrAvg, global.ResizeArrMax = ResizeArrMax, global.DEBUG_MODE ? global.TO_DEBUG_LOG = function(e, t, r, o) { +} +global.ResizeArrAvg = ResizeArrAvg, global.ResizeArrMax = ResizeArrMax, global.DEBUG_MODE ? global.TO_DEBUG_LOG = function(e, t, r, o) { global.DEBUG_MODE && ("rinfo" === t && (e += " from: " + r.address + ":" + r.port + " - " + o.length), global.ToLog(e)); } : global.TO_DEBUG_LOG = function(e, t, r, o) { -}, global.GetStrOnlyTime = function(e) { +} +global.GetStrOnlyTime = function(e) { if (!global.GetCurrentTime) return ":::"; e || (e = global.GetCurrentTime()); var t = "" + e.getHours().toStringZ(2); return t = (t = (t = t + ":" + e.getMinutes().toStringZ(2)) + ":" + e.getSeconds().toStringZ(2)) + "." + e.getMilliseconds().toStringZ(3); -}, global.GetStrTime = function(e) { +} +global.GetStrTime = function(e) { if (!global.GetCurrentTime) return ":::"; e || (e = global.GetCurrentTime()); diff --git a/src/core/server.ts b/src/core/server.ts index 2b50fa2..2af1758 100644 --- a/src/core/server.ts +++ b/src/core/server.ts @@ -10,7 +10,7 @@ "use strict"; import net = require("net"); -import dgram = require("dgram"); +// import dgram = require("dgram"); import * as crypto from 'crypto'; import "./library" import "./crypto-library" @@ -19,7 +19,7 @@ global.BUF_TYPE = 1; global.STR_TYPE = 2; global.MAX_STR_BUF_DATA = 200; global.MAX_CONNECTION_ACTIVE = 40; -var MAX_CONNECTION_ANOTHER = 40; +// var MAX_CONNECTION_ANOTHER = 40; const TRAFIC_LIMIT_NODE_1S = global.MAX_BLOCK_SIZE * 1.25; const TRAFIC_LIMIT_1S = 8 * TRAFIC_LIMIT_NODE_1S; global.STAT_PERIOD = global.CONSENSUS_PERIOD_TIME / 5; @@ -715,13 +715,13 @@ export default class CTransport extends require("./connect") } DoSendBuf() { this.RecalcSendStatictic() - var CountNodeSend = 0; + // var CountNodeSend = 0; var it = this.ActualNodes.iterator(), Node; NEXT_NODE: while ((Node = it.next()) !== null) if (Node.Socket && Node.ConnectStatus() === 100) if (Node.BufWrite.length > 0) { - CountNodeSend++ + // CountNodeSend++ var CountSend = Math.min(BUF_PACKET_SIZE, Node.BufWrite.length); var Value = CountSend / 1024; if (global.LIMIT_SEND_TRAFIC) { diff --git a/src/core/update.ts b/src/core/update.ts index 39d1b6b..888e738 100644 --- a/src/core/update.ts +++ b/src/core/update.ts @@ -30,7 +30,7 @@ function RunOnUpdate() { function CreateHeadersHash100() { global.ToLog("CreateHeadersHash100"); - const DBRow = require("./db/db-row"); + // const DBRow = require("./db/db-row"); global.UpdateMode = 1; var DB = global.SERVER.DBHeader100; var Num = 0; diff --git a/src/core/wallet.ts b/src/core/wallet.ts index 640e84d..59ed82f 100644 --- a/src/core/wallet.ts +++ b/src/core/wallet.ts @@ -9,12 +9,12 @@ */ "use strict"; -const fs = require('fs'); +// const fs = require('fs'); import * as crypto from 'crypto'; require("./library"); require("./crypto-library"); const WalletPath = "WALLET"; -const DBRow = require("./db/db-row"); +// const DBRow = require("./db/db-row"); const CONFIG_NAME = global.GetDataPath(WalletPath + "/config.lst"); class CApp { Password @@ -25,7 +25,7 @@ class CApp { PubKeyArr constructor() { global.CheckCreateDir(global.GetDataPath(WalletPath)) - var bReadOnly = (global.PROCESS_NAME !== "TX"); + // var bReadOnly = (global.PROCESS_NAME !== "TX"); this.Password = "" this.WalletOpen = undefined var Params = global.LoadParams(CONFIG_NAME, undefined); diff --git a/src/process/main-process.ts b/src/process/main-process.ts index c0b169b..88f8889 100644 --- a/src/process/main-process.ts +++ b/src/process/main-process.ts @@ -12,7 +12,7 @@ import '../core/constant' global.PROCESS_NAME = "MAIN"; import fs = require('fs'); import os = require('os'); -import path = require('path') +// import path = require('path') import * as crypto from 'crypto'; global.START_SERVER = 1; @@ -366,7 +366,7 @@ var StartCheckMining = 0; global.MiningPaused = 0; var ProcessMemorySize = 0; global.ArrMiningWrk = []; -var BlockMining; +// var BlockMining; if (global.ADDRLIST_MODE) { // @ts-ignore return; @@ -503,7 +503,7 @@ function SetCalcPOW(Block, cmd) { return; if (ArrMiningWrk.length !== global.GetCountMiningCPU()) return; - BlockMining = Block; + // BlockMining = Block; for (var i = 0; i < ArrMiningWrk.length; i++) { var CurWorker = ArrMiningWrk[i]; if (!CurWorker.bOnline) @@ -654,7 +654,7 @@ function RunOnce() { }, 10000); } }; -var glPortDebug = 49800; +// var glPortDebug = 49800; function Fork(Path, ArrArgs?) { const child_process = require('child_process'); @@ -674,7 +674,7 @@ function Fork(Path, ArrArgs?) { ArrArgs.push("NOALIVE"); if (global.DEV_MODE) ArrArgs.push("DEV_MODE"); - glPortDebug++; + // glPortDebug++; var execArgv = []; var Worker = child_process.fork(Path, ArrArgs, { execArgv: execArgv }); return Worker; diff --git a/src/process/static-process.ts b/src/process/static-process.ts index 7450d7e..7f5e3af 100644 --- a/src/process/static-process.ts +++ b/src/process/static-process.ts @@ -111,7 +111,7 @@ function GETBLOCKHEADER100(msg) { return; var EndNum100 = BlockNum / 100; var LoadHash100 = Data.Hash; - var Hash100; + // var Hash100; var Count = Data.Count; if (!Count || Count < 0 || !EndNum100) return; @@ -228,8 +228,8 @@ function GETREST(msg) { var ProofArrR = []; var ArrRest = []; if (nResult) { - var WorkStruct = {}; - var WorkFormat = global.DApps.Accounts.FORMAT_ACCOUNT_ROW; + // var WorkStruct = {}; + // var WorkFormat = global.DApps.Accounts.FORMAT_ACCOUNT_ROW; var WorkFormatLength = global.DApps.Accounts.SIZE_ACCOUNT_ROW; var Max = global.DApps.Accounts.DBState.GetMaxNum(); var LengthAccount = Data.Count; diff --git a/src/process/tx-process.ts b/src/process/tx-process.ts index 9d79d71..7cd5ca8 100644 --- a/src/process/tx-process.ts +++ b/src/process/tx-process.ts @@ -122,7 +122,7 @@ function DoTXProcess() { var StartTime = Date.now(); if (global.bShowDetail) global.ToLog("BlockMin: " + BlockMin.BlockNum + " LastBlockNum=" + LastBlockNum); - var CountTX = 0; + // var CountTX = 0; for (var Num = BlockMin.BlockNum; Num < BlockMin.BlockNum + 200; Num++) { var EndTime = Date.now(); var Delta = EndTime - StartTime; @@ -155,7 +155,7 @@ function DoTXProcess() { global.SERVER.BlockProcessTX(Block); if (Num % 100000 === 0) global.ToLog("CALC: " + Num); - CountTX++; + // CountTX++; if (global.bShowDetail) global.ToLog(" CALC: " + Num + " SumHash: " + global.GetHexFromArr(Block.SumHash).substr(0, 12)); BlockTree.SaveValue(Block.BlockNum, { BlockNum: Block.BlockNum, SumHash: Block.SumHash }); @@ -330,7 +330,8 @@ function TXWriteAccHash() { var Item = global.DApps.Smart.DBSmart.Read(num); if (!Item) break; - var Body = global.BufLib.GetBufferFromObject(Item, global.DApps.Smart.FORMAT_ROW, 20000, {}); + // var Body = + global.BufLib.GetBufferFromObject(Item, global.DApps.Smart.FORMAT_ROW, 20000, {}); global.DApps.Smart.DBSmartWrite(Item); } global.DApps.Accounts.CalcMerkleTree(1); diff --git a/src/process/web-process.ts b/src/process/web-process.ts index 361c472..b2e330d 100644 --- a/src/process/web-process.ts +++ b/src/process/web-process.ts @@ -9,7 +9,7 @@ */ import * as crypto from 'crypto' import * as http from 'http' -import * as net from 'net' +// import * as net from 'net' import * as url from 'url' import * as fs from 'fs' import * as querystring from 'querystring' @@ -106,23 +106,13 @@ process.on('message', function(msg) { var RedirectServer; var HostingServer; -let { - ToLogWeb, - CHECK_STOP_CHILD_PROCESS, - ToError, - ToLog, - TO_ERROR_LOG, - PrepareStatEverySecond, - ToLogTrace -} = global - function Exit() { - ToLogWeb("=Exit1="); + global.ToLogWeb("=Exit1="); if (RedirectServer) RedirectServer.close(); if (HostingServer) HostingServer.close(); - ToLogWeb("=Exit2="); + global.ToLogWeb("=Exit2="); process.exit(0); }; @@ -130,7 +120,7 @@ function CheckAlive() { if (global.NOALIVE) return; var Delta = Date.now() - LastAlive; - if (Delta > CHECK_STOP_CHILD_PROCESS) { + if (Delta > global.CHECK_STOP_CHILD_PROCESS) { Exit(); return; } @@ -138,7 +128,7 @@ function CheckAlive() { process.on('uncaughtException', function(err) { global.ToError(err.stack); global.ToLog(err.stack); - TO_ERROR_LOG("HOSTING", 777, err); + global.TO_ERROR_LOG("HOSTING", 777, err); global.ToLog("-----------------HOSTING EXIT------------------", 0); process.exit(); }); @@ -147,7 +137,7 @@ process.on('error' as any, function(err: TeraError) { global.ToLog(err.stack); }); if (!global.HTTP_HOSTING_PORT) { - ToLogTrace("global.HTTP_HOSTING_PORT=" + global.HTTP_HOSTING_PORT); + global.ToLogTrace("global.HTTP_HOSTING_PORT=" + global.HTTP_HOSTING_PORT); process.exit(); } var CServerDB = require("../core/db/block-db"); @@ -159,18 +149,12 @@ global.HTTP_PORT_NUMBER = 0; require("../core/html-server"); require("../core/transaction-validator"); global.STAT_MODE = 1; -setInterval(PrepareStatEverySecond, 1000); +setInterval(global.PrepareStatEverySecond, 1000); var IndexName = "index.html"; -let { - GetDataPath, - CheckCreateDir, - LoadParams, - SaveParams, - ADD_TO_STAT -} = global + if (global.HTTPS_HOSTING_DOMAIN) { var file_sert = global.GetDataPath("sertif.lst"); - CheckCreateDir(global.GetDataPath("tmp")); + global.CheckCreateDir(global.GetDataPath("tmp")); var greenlock = require('greenlock').create({ version: 'draft-12', server: 'https://acme-v02.api.letsencrypt.org/directory', configDir: global.GetDataPath('tmp'), }); @@ -182,7 +166,7 @@ if (global.HTTPS_HOSTING_DOMAIN) { RedirectServer.listen(80); var GetNewSert = 1; if (fs.existsSync(file_sert)) { - var certs = LoadParams(file_sert, {}); + var certs = global.LoadParams(file_sert, {}); var Delta = certs.expiresAt - Date.now(); if (Delta >= 10 * 24 * 3600 * 1000) { global.ToLog("USE EXIST SERT. ExpiresAt: " + new Date(certs.expiresAt)); @@ -196,7 +180,7 @@ if (global.HTTPS_HOSTING_DOMAIN) { global.ToLog("Start get new SERT", 0); var opts = { domains: [global.HTTPS_HOSTING_DOMAIN], email: 'progr76@gmail.com', agreeTos: true, communityMember: true, }; greenlock.register(opts).then(function(certs) { - SaveParams(file_sert, certs); + global.SaveParams(file_sert, certs); var tlsOptions = { key: certs.privkey, cert: certs.cert + '\r\n' + certs.chain }; HostingServer = require('https').createServer(tlsOptions, MainHTTPFunction); RunListenServer(); @@ -219,7 +203,7 @@ function MainHTTPFunction(request, response) { var DataURL = url.parse(request.url); var Params = querystring.parse(DataURL.query); var Path = querystring.unescape(DataURL.pathname); - ADD_TO_STAT("HTTP_ALL"); + global.ADD_TO_STAT("HTTP_ALL"); var Type = request.method; if (Type === "POST") { let Response = response; @@ -354,7 +338,7 @@ function DoCommandNew(response, Type, Path, Params) { } Method = ArrPath[2]; } - ADD_TO_STAT("HTTP:" + Method); + global.ADD_TO_STAT("HTTP:" + Method); var F = Caller[Method]; if (F) { response.writeHead(200, { 'Content-Type': 'text/plain', 'Access-Control-Allow-Origin': "*" }); @@ -841,7 +825,7 @@ setInterval(function() { if (!Count) Count = 1; var AvgPow = SumPow / Count; - ADD_TO_STAT("MAX:HASH_RATE_B", AvgPow); + global.ADD_TO_STAT("MAX:HASH_RATE_B", AvgPow); } var Count = global.COUNT_BLOCK_PROOF + 16 - 1; if (MaxNumBlockDB > Count) { @@ -852,8 +836,7 @@ setInterval(function() { require("./api-exchange.js"); try { require("../SITE/JS/web-addon.js"); -} -catch (e) { +} catch (e) { } global.LoadBlockFromNetwork = function(Params, F) { global.ToLog("RUN: LoadBlockFromNetwork:" + Params.BlockNum, 2); diff --git a/src/system/accounts.ts b/src/system/accounts.ts index 36d81f6..294cbc1 100644 --- a/src/system/accounts.ts +++ b/src/system/accounts.ts @@ -82,13 +82,6 @@ global.global.FORMAT_ACCOUNT_HASH3 = "{\ SmartHash:buffer32,\ SmartCount:uint,\ }"; -let { - ToLog, - shaarr, - UpdateMerklTree, - ToError, - SERVER -} = global class MerkleDBRow extends DBRow { private MerkleTree @@ -120,7 +113,7 @@ class MerkleDBRow extends DBRow { } } this.MerkleTree.RecalcCount = 0 - UpdateMerklTree(this.MerkleTree, this.MerkleCalc, 0) + global.UpdateMerklTree(this.MerkleTree, this.MerkleCalc, 0) this.MerkleCalc = {} return this.MerkleTree.Root; } @@ -590,7 +583,7 @@ class AccountApp extends require("./dapp") power = Tr.power } else { - power = global.GetPowPower(shaarr(Body)) + power = global.GetPowPower(global.shaarr(Body)) } if (global.TEST_NETWORK && BlockNum >= 3290000) { CheckMinPower = 0 @@ -1408,23 +1401,23 @@ global.DAppByType[TYPE_DEPRECATED_TRANSFER2] = App; global.DAppByType[TYPE_TRANSACTION_TRANSFER] = App; global.DAppByType[global.TYPE_TRANSACTION_ACC_HASH] = App; -function TestStateFiles(Size, Format) { - return; - if (global.PROCESS_NAME !== "MAIN") - return; - var DBState1 = new DBRow("state-ok", Size, Format, 0); - var DBState2 = new DBRow("state-no", Size, Format, 0); - for (var Num = 0; 1; Num++) { - var Item1 = DBState1.Read(Num); - var Item2 = DBState2.Read(Num); - if (!Item1 && !Item2) - break; - var Str1 = JSON.stringify(Item1); - var Str2 = JSON.stringify(Item2); - if (Str1 !== Str2) { - global.ToLog("Err item: " + Num); - global.ToLog("1: " + Str1); - global.ToLog("2: " + Str2); - } - } -}; +// function TestStateFiles(Size, Format) { +// return; +// if (global.PROCESS_NAME !== "MAIN") +// return; +// var DBState1 = new DBRow("state-ok", Size, Format, 0); +// var DBState2 = new DBRow("state-no", Size, Format, 0); +// for (var Num = 0; 1; Num++) { +// var Item1 = DBState1.Read(Num); +// var Item2 = DBState2.Read(Num); +// if (!Item1 && !Item2) +// break; +// var Str1 = JSON.stringify(Item1); +// var Str2 = JSON.stringify(Item2); +// if (Str1 !== Str2) { +// global.ToLog("Err item: " + Num); +// global.ToLog("1: " + Str1); +// global.ToLog("2: " + Str2); +// } +// } +// }; diff --git a/src/system/dapp.ts b/src/system/dapp.ts index fd37568..fc26986 100644 --- a/src/system/dapp.ts +++ b/src/system/dapp.ts @@ -9,7 +9,7 @@ */ "use strict"; -import * as fs from 'fs' +// import * as fs from 'fs' class DApp { constructor() { } @@ -46,16 +46,16 @@ class DApp { }; module.exports = DApp; -function ReqDir(Path) { - if (fs.existsSync(Path)) { - var arr = fs.readdirSync(Path); - for (var i = 0; i < arr.length; i++) { - var name = arr[i]; - global.ToLog("Reg: " + name); - var name2 = Path + "/" + arr[i]; - require(name2); - } - } -}; +// function ReqDir(Path) { +// if (fs.existsSync(Path)) { +// var arr = fs.readdirSync(Path); +// for (var i = 0; i < arr.length; i++) { +// var name = arr[i]; +// global.ToLog("Reg: " + name); +// var name2 = Path + "/" + arr[i]; +// require(name2); +// } +// } +// }; global.DApps = {}; global.DAppByType = {}; diff --git a/src/system/smart.ts b/src/system/smart.ts index 607c016..4ae8b43 100644 --- a/src/system/smart.ts +++ b/src/system/smart.ts @@ -371,7 +371,7 @@ class SmartApp extends require("./dapp") } if (Category) Category = global.global.ParseNum(Category) - var WasError = 0; + // var WasError = 0; var arr = []; var Data; for (var num = start; true; num++) { @@ -1178,10 +1178,10 @@ var mask = 0xffffffff; function MathRandom() { DO(5); - function seed(i) { - m_w = i; - m_z = 987654321; - }; + // function seed(i) { + // m_w = i; + // m_z = 987654321; + // }; function random() { m_z = (36969 * (m_z & 65535) + (m_z >> 16)) & mask; diff --git a/tsconfig.json b/tsconfig.json index 0999065..a285ddd 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,6 +3,7 @@ "outDir": "dist", "allowJs": true, "sourceMap": true, + "noUnusedLocals": true, "target": "es5" }, "include": [