From 383f2de7d17726521f716c893759f8558fc264f2 Mon Sep 17 00:00:00 2001 From: Kirill Date: Thu, 13 Sep 2018 22:31:02 +0300 Subject: [PATCH 01/12] add package.json --- candy.js | 10 +++++++++- package.json | 27 +++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 package.json diff --git a/candy.js b/candy.js index 8b42aab..6de2be2 100644 --- a/candy.js +++ b/candy.js @@ -10,6 +10,7 @@ 'use strict'; + const MessageType = { QUERY_LATEST: 0, QUERY_ALL: 1, @@ -27,6 +28,10 @@ const BlockchainRequestors = { } }; +if (this.window === undefined) { + +}; + function Candy(nodeList) { 'use strict'; let that = this; @@ -53,7 +58,6 @@ function Candy(nodeList) { } else { console.log("Error: Can't find starwaveProtocol module"); } - ; /** * Current reciever address. Override allowed @@ -459,4 +463,8 @@ function Candy(nodeList) { return this; +} + +if (this.window === undefined){ + module.exports = Candy; } \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..4113f94 --- /dev/null +++ b/package.json @@ -0,0 +1,27 @@ +{ + "name": "candy", + "version": "1.0.0", + "description": "iZ³ blockchain connection provider for browsers", + "main": "main.js", + "dependencies": { + "cryptojs": "^2.5.3", + "elliptic": "^6.4.1", + "forge": "^2.3.0", + "moment": "^2.22.2", + "ws": "^6.0.0" + }, + "devDependencies": {}, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Izzzio/Candy.git" + }, + "author": "", + "license": "ISC", + "bugs": { + "url": "https://github.com/Izzzio/Candy/issues" + }, + "homepage": "https://github.com/Izzzio/Candy#readme" +} From 3240307f026d3dfdaad6ff7587b2d5abf0c3090e Mon Sep 17 00:00:00 2001 From: Kirill Date: Thu, 13 Sep 2018 22:38:55 +0300 Subject: [PATCH 02/12] added export for node --- NodeMetaInfo.js | 6 ++++++ digitalSignature.js | 20 +++++++++++++------- starwaveCrypto.js | 5 +++++ starwaveProtocol.js | 4 ++++ 4 files changed, 28 insertions(+), 7 deletions(-) diff --git a/NodeMetaInfo.js b/NodeMetaInfo.js index 2fbc5fa..7fc7a24 100644 --- a/NodeMetaInfo.js +++ b/NodeMetaInfo.js @@ -63,3 +63,9 @@ class NodeMetaInfo { } } + + +//unify browser and node +if (this.window === undefined){ + module.exports = NodeMetaInfo; +} \ No newline at end of file diff --git a/digitalSignature.js b/digitalSignature.js index 1336688..b60c957 100644 --- a/digitalSignature.js +++ b/digitalSignature.js @@ -66,7 +66,7 @@ function DigitalSignature(dataToSign) { //data in string format /** * Signs data * @param {data} data for signing - * @param {privateKey} private key + * @param {key} key */ @@ -74,7 +74,7 @@ function DigitalSignature(dataToSign) { //data in string format if (!data) { console.log('No data to sign'); return ''; - }; + } let md= forge.md.sha256.create(); md.update(data,'utf8'); let privateKey = forge.pki.privateKeyFromPem(key); @@ -87,13 +87,14 @@ function DigitalSignature(dataToSign) { //data in string format /** * Signs data * @param {data} data for signing - * @param {puBkey} private key + * @param {sign} sign + * @param {key} key */ this.verifyData = (data = this.signedData, sign = this.signedData.sign, key = this.signedData.pubkey) => { if (typeof data === 'object'){ sign = data.sign; data = data.data; - }; + } try { let publicKey = forge.pki.publicKeyFromPem(repairKey(fix(key))); let md = forge.md.sha256.create(); @@ -102,7 +103,7 @@ function DigitalSignature(dataToSign) { //data in string format } catch (e){ console.log(e); return false; - }; + } }; if (dataToSign !== undefined){ @@ -112,7 +113,12 @@ function DigitalSignature(dataToSign) { //data in string format if(this.verifyData() === false) { console.log('Sign self-validation error! Invalid key or sign checking'); } - }; + } return this; -}; \ No newline at end of file +} + +//unify browser and node +if (this.window === undefined){ + module.exports = DigitalSignature; +} \ No newline at end of file diff --git a/starwaveCrypto.js b/starwaveCrypto.js index 51b86ba..693b784 100644 --- a/starwaveCrypto.js +++ b/starwaveCrypto.js @@ -222,3 +222,8 @@ class StarwaveCrypto { } } + +//unify browser and node +if (this.window === undefined){ + module.exports = StarwaveCrypto; +} \ No newline at end of file diff --git a/starwaveProtocol.js b/starwaveProtocol.js index 97062ad..46003d2 100644 --- a/starwaveProtocol.js +++ b/starwaveProtocol.js @@ -383,3 +383,7 @@ class starwaveProtocol { } +//unify browser and node +if (this.window === undefined){ + module.exports = starwaveProtocol; +} \ No newline at end of file From 844de0ce02da926724a8a6f916bb189af49943cc Mon Sep 17 00:00:00 2001 From: Kirill Date: Thu, 13 Sep 2018 22:48:03 +0300 Subject: [PATCH 03/12] replace wrong package --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4113f94..307c5ef 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,8 @@ "dependencies": { "cryptojs": "^2.5.3", "elliptic": "^6.4.1", - "forge": "^2.3.0", "moment": "^2.22.2", + "node-forge": "^0.7.6", "ws": "^6.0.0" }, "devDependencies": {}, From 4287e843b872e1d23ccb5dd0ab2dc6fff9c77b8f Mon Sep 17 00:00:00 2001 From: Kirill Date: Thu, 13 Sep 2018 22:49:59 +0300 Subject: [PATCH 04/12] lock too --- package-lock.json | 94 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 package-lock.json diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..ed33266 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,94 @@ +{ + "name": "candy", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "async-limiter": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.0.tgz", + "integrity": "sha512-jp/uFnooOiO+L211eZOoSyzpOITMXx1rBITauYykG3BRYPu8h0UcxsPNB04RR5vo4Tyz3+ay17tR6JVf9qzYWg==" + }, + "bn.js": { + "version": "4.11.8", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz", + "integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA==" + }, + "brorand": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", + "integrity": "sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8=" + }, + "cryptojs": { + "version": "2.5.3", + "resolved": "https://registry.npmjs.org/cryptojs/-/cryptojs-2.5.3.tgz", + "integrity": "sha1-kJVH7PFbrEVuJ1RZs58u9F1/y7k=" + }, + "elliptic": { + "version": "6.4.1", + "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.4.1.tgz", + "integrity": "sha512-BsXLz5sqX8OHcsh7CqBMztyXARmGQ3LWPtGjJi6DiJHq5C/qvi9P3OqgswKSDftbu8+IoI/QDTAm2fFnQ9SZSQ==", + "requires": { + "bn.js": "4.11.8", + "brorand": "1.1.0", + "hash.js": "1.1.5", + "hmac-drbg": "1.0.1", + "inherits": "2.0.3", + "minimalistic-assert": "1.0.1", + "minimalistic-crypto-utils": "1.0.1" + } + }, + "hash.js": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.5.tgz", + "integrity": "sha512-eWI5HG9Np+eHV1KQhisXWwM+4EPPYe5dFX1UZZH7k/E3JzDEazVH+VGlZi6R94ZqImq+A3D1mCEtrFIfg/E7sA==", + "requires": { + "inherits": "2.0.3", + "minimalistic-assert": "1.0.1" + } + }, + "hmac-drbg": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", + "integrity": "sha1-0nRXAQJabHdabFRXk+1QL8DGSaE=", + "requires": { + "hash.js": "1.1.5", + "minimalistic-assert": "1.0.1", + "minimalistic-crypto-utils": "1.0.1" + } + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + }, + "minimalistic-assert": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", + "integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==" + }, + "minimalistic-crypto-utils": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz", + "integrity": "sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo=" + }, + "moment": { + "version": "2.22.2", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.22.2.tgz", + "integrity": "sha1-PCV/mDn8DpP/UxSWMiOeuQeD/2Y=" + }, + "node-forge": { + "version": "0.7.6", + "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-0.7.6.tgz", + "integrity": "sha512-sol30LUpz1jQFBjOKwbjxijiE3b6pjd74YwfD0fJOKPjF+fONKb2Yg8rYgS6+bK6VDl+/wfr4IYpC7jDzLUIfw==" + }, + "ws": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-6.0.0.tgz", + "integrity": "sha512-c2UlYcAZp1VS8AORtpq6y4RJIkJ9dQz18W32SpR/qXGfLDZ2jU4y4wKvvZwqbi7U6gxFQTeE+urMbXU/tsDy4w==", + "requires": { + "async-limiter": "1.0.0" + } + } + } +} From ffd1eb9f3642cf7f2f2a4eb983b81c6aa8749a85 Mon Sep 17 00:00:00 2001 From: Kirill Date: Thu, 13 Sep 2018 22:58:36 +0300 Subject: [PATCH 05/12] added some modules --- candy.js | 5 +++++ digitalSignature.js | 5 +++++ package-lock.json | 6 ++---- package.json | 2 +- starwaveCrypto.js | 6 ++++++ starwaveProtocol.js | 8 +++++--- 6 files changed, 24 insertions(+), 8 deletions(-) diff --git a/candy.js b/candy.js index 6de2be2..b25a036 100644 --- a/candy.js +++ b/candy.js @@ -10,6 +10,11 @@ 'use strict'; +//unify browser and node +if (this.window === undefined){ + const WebSocket = require('ws'); +} + const MessageType = { QUERY_LATEST: 0, diff --git a/digitalSignature.js b/digitalSignature.js index b60c957..18d3b15 100644 --- a/digitalSignature.js +++ b/digitalSignature.js @@ -7,6 +7,11 @@ 'use strict'; +//unify browser and node +if (this.window === undefined){ + const forge = require('node-forge'); +} + function DigitalSignature(dataToSign) { //data in string format diff --git a/package-lock.json b/package-lock.json index ed33266..1c1f199 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,10 +19,8 @@ "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", "integrity": "sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8=" }, - "cryptojs": { - "version": "2.5.3", - "resolved": "https://registry.npmjs.org/cryptojs/-/cryptojs-2.5.3.tgz", - "integrity": "sha1-kJVH7PFbrEVuJ1RZs58u9F1/y7k=" + "crypto-js": { + "version": "file:crypto-js" }, "elliptic": { "version": "6.4.1", diff --git a/package.json b/package.json index 307c5ef..eacd20f 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "iZ³ blockchain connection provider for browsers", "main": "main.js", "dependencies": { - "cryptojs": "^2.5.3", + "crypto-js": "file:crypto-js", "elliptic": "^6.4.1", "moment": "^2.22.2", "node-forge": "^0.7.6", diff --git a/starwaveCrypto.js b/starwaveCrypto.js index 693b784..8c686ae 100644 --- a/starwaveCrypto.js +++ b/starwaveCrypto.js @@ -12,6 +12,12 @@ 'use strict'; +//unify browser and node +if (this.window === undefined){ + const elliptic = require('elliptic'); + const CryptoJS = require('crypto-js'); +} + const SWCRYPTO_CONNECTION_MESSAGE_TYPE = 'DH-CONNECTION'; class StarwaveCrypto { diff --git a/starwaveProtocol.js b/starwaveProtocol.js index 46003d2..5af6ad0 100644 --- a/starwaveProtocol.js +++ b/starwaveProtocol.js @@ -11,7 +11,11 @@ const MESSAGE_MUTEX_TIMEOUT = 1000; const LATENCY_TIME = 100 * 1000; //time on obsolescence of message -//const moment = require('moment'); + +//unify browser and node +if (this.window === undefined){ + const moment = require('moment'); +} class starwaveProtocol { @@ -25,8 +29,6 @@ class starwaveProtocol { * @private */ this._messageMutex = {}; - - //this.starwaveCrypto = new StarwaveCrypto(this, this.candy.secretKeys); } /** From 05d44311db018c39a2fdbf87309988c725601513 Mon Sep 17 00:00:00 2001 From: Kirill Date: Sat, 15 Sep 2018 00:47:35 +0300 Subject: [PATCH 06/12] try to unify --- candy.js | 107 +++++++++++++++++++++++--------------------- digitalSignature.js | 27 ++++++----- starwaveCrypto.js | 25 ++++++----- starwaveProtocol.js | 13 +++--- 4 files changed, 93 insertions(+), 79 deletions(-) diff --git a/candy.js b/candy.js index b25a036..a695990 100644 --- a/candy.js +++ b/candy.js @@ -9,12 +9,18 @@ */ 'use strict'; - //unify browser and node -if (this.window === undefined){ - const WebSocket = require('ws'); +if (typeof _this ==='undefined') { + var _this = this; } +if (_this.window === undefined) { + _this.WebSocket = require('ws'); + _this.starwaveProtocol = require('./starwaveProtocol.js'); + _this.NodeMetaInfo = require('./NodeMetaInfo.js'); + _this.DigitalSignature = require('./digitalSignature.js'); + _this.StarwaveCrypto = require('./starwaveCrypto.js'); +} const MessageType = { QUERY_LATEST: 0, @@ -33,12 +39,9 @@ const BlockchainRequestors = { } }; -if (this.window === undefined) { - -}; function Candy(nodeList) { - 'use strict'; + let that = this; this.maxConnections = 30; this.nodeList = nodeList; @@ -57,9 +60,11 @@ function Candy(nodeList) { this.secretKeys = {}; //consist of secret keys of different busAddresses of peers + //modules list(for compability with node) + - if(typeof starwaveProtocol === 'function') { - this.starwave = new starwaveProtocol(this, MessageType); + if (typeof _this.starwaveProtocol === 'function') { + this.starwave = new _this.starwaveProtocol(this, MessageType); } else { console.log("Error: Can't find starwaveProtocol module"); } @@ -100,23 +105,23 @@ function Candy(nodeList) { * @param {Object} data */ this._dataRecieved = function (source, data) { - + console.log(data); //prevent multiple sockets on one busaddress - if(!this.allowMultiplySocketsOnBus && (this.starwave)) { - if(this.starwave.preventMultipleSockets(source) === 0) { + if (!this.allowMultiplySocketsOnBus && (this.starwave)) { + if (this.starwave.preventMultipleSockets(source) === 0) { data = null; return; } } - if(typeof that.ondata === 'function') { - if(that.ondata(data)) { + if (typeof that.ondata === 'function') { + if (that.ondata(data)) { return; } } //Data block recived - if(data.type === MessageType.RESPONSE_BLOCKCHAIN) { + if (data.type === MessageType.RESPONSE_BLOCKCHAIN) { try { /** * @var {Block} block @@ -124,11 +129,11 @@ function Candy(nodeList) { let blocks = JSON.parse(data.data); for (let a in blocks) { let block = blocks[a]; - if(that.blockHeight < block.index) { + if (that.blockHeight < block.index) { that.blockHeight = block.index } //Loading requested resource - if(typeof that._resourceQueue[block.index] !== 'undefined') { + if (typeof that._resourceQueue[block.index] !== 'undefined') { that._resourceQueue[block.index](block.data, block); that._resourceQueue[block.index] = undefined; } @@ -139,12 +144,12 @@ function Candy(nodeList) { } //New peers recived - if(data.type === MessageType.MY_PEERS) { + if (data.type === MessageType.MY_PEERS) { for (let a in data.data) { - if(data.data.hasOwnProperty(a)) { - if(that.nodeList.indexOf(data.data[a]) == -1) { + if (data.data.hasOwnProperty(a)) { + if (that.nodeList.indexOf(data.data[a]) == -1) { that.nodeList.push(data.data[a]); - if(that.getActiveConnections().length < that.maxConnections - 1) { + if (that.getActiveConnections().length < that.maxConnections - 1) { that.connectPeer(data.data[a]); } } @@ -153,21 +158,21 @@ function Candy(nodeList) { that.nodeList = Array.from(new Set(that.nodeList)); } - if(data.type === MessageType.BROADCAST) { + if (data.type === MessageType.BROADCAST) { /*if(that._lastMsgIndex < data.index) {*/ - if(data.reciver === that.recieverAddress) { + if (data.reciver === that.recieverAddress) { - if(data.id === 'CANDY_APP_RESPONSE') { - if(typeof that._candyAppResponse === 'function') { + if (data.id === 'CANDY_APP_RESPONSE') { + if (typeof that._candyAppResponse === 'function') { that._candyAppResponse(data); } } else { - if(typeof that.onmessage === 'function') { + if (typeof that.onmessage === 'function') { that.onmessage(data); } } } else { - if(data.recepient !== that.recieverAddress) { + if (data.recepient !== that.recieverAddress) { data.TTL++; that.broadcast(data); } @@ -178,10 +183,10 @@ function Candy(nodeList) { } //add meta info handling //required NodeMetaInfo.js included - if(data.type === MessageType.META) { - if(typeof NodeMetaInfo === 'function') { + if (data.type === MessageType.META) { + if (typeof NodeMetaInfo === 'function') { let ind = that.sockets.indexOf(source); - if(ind > -1) { + if (ind > -1) { that.sockets[ind].nodeMetaInfo = (new NodeMetaInfo()).parse(data.data); } else { console.log('Error: Unexpected error occurred when trying to add validators'); @@ -191,8 +196,8 @@ function Candy(nodeList) { } } - if(data.type === MessageType.SW_BROADCAST) { - if(this.starwave) { + if (data.type === MessageType.SW_BROADCAST) { + if (this.starwave) { this._lastMsgIndex = this.starwave.handleMessage(data, this.messagesHandlers, source); } } @@ -207,8 +212,8 @@ function Candy(nodeList) { that.getActiveConnections = function () { let activeSockets = []; for (let a in that.sockets) { - if(that.sockets[a]) { - if(that.sockets[a].readyState === WebSocket.OPEN) { + if (that.sockets[a]) { + if (that.sockets[a].readyState === _this.WebSocket.OPEN) { activeSockets.push(that.sockets[a]); } } @@ -224,14 +229,14 @@ function Candy(nodeList) { this.connectPeer = function (peer) { let socket = null; try { - socket = new WebSocket(peer); + socket = new _this.WebSocket(peer); } catch (e) { return; } socket.onopen = function () { setTimeout(function () { - if(typeof that.onready !== 'undefined') { - if(typeof that._autoloader !== 'undefined') { + if (typeof that.onready !== 'undefined') { + if (typeof that._autoloader !== 'undefined') { that._autoloader.onready(); } that.onready(); @@ -267,11 +272,11 @@ function Candy(nodeList) { */ this.broadcast = function (message) { let sended = false; - if(typeof message !== 'string') { + if (typeof message !== 'string') { message = JSON.stringify(message); } for (let a in that.sockets) { - if(that.sockets.hasOwnProperty(a) && that.sockets[a] !== null) { + if (that.sockets.hasOwnProperty(a) && that.sockets[a] !== null) { try { that.sockets[a].send(message); sended = true; @@ -304,7 +309,7 @@ function Candy(nodeList) { index: that._lastMsgIndex, mutex: this.getid() + this.getid() + this.getid() }; - if(!that.broadcast(message)) { + if (!that.broadcast(message)) { that.autoconnect(true); return false; } @@ -317,10 +322,10 @@ function Candy(nodeList) { * @param {boolean} force reconnection */ this.autoconnect = function (force) { - if(that.getActiveConnections().length < 1 || force) { + if (that.getActiveConnections().length < 1 || force) { for (let a in that.nodeList) { - if(that.nodeList.hasOwnProperty(a)) { - if(that.getActiveConnections().length < that.maxConnections - 1) { + if (that.nodeList.hasOwnProperty(a)) { + if (that.getActiveConnections().length < that.maxConnections - 1) { that.connectPeer(that.nodeList[a]); } } @@ -336,8 +341,8 @@ function Candy(nodeList) { */ this.start = function () { for (let a in that.nodeList) { - if(that.nodeList.hasOwnProperty(a)) { - if(that.getActiveConnections().length < that.maxConnections - 1) { + if (that.nodeList.hasOwnProperty(a)) { + if (that.getActiveConnections().length < that.maxConnections - 1) { that.connectPeer(that.nodeList[a]); } } @@ -374,7 +379,7 @@ function Candy(nodeList) { * @param message */ this._candyAppResponse = function (message) { - if(typeof that._requestQueue[message.data.backId] !== 'undefined') { + if (typeof that._requestQueue[message.data.backId] !== 'undefined') { let request = that._requestQueue[message.data.backId]; clearTimeout(request.timer); request.callback(message.err, typeof message.data.data.body !== 'undefined' ? message.data.data.body : message.data.data, message); @@ -392,7 +397,7 @@ function Candy(nodeList) { * @param {int} timeout */ this.requestApp = function (uri, data, callback, timeout) { - if(typeof timeout === 'undefined') { + if (typeof timeout === 'undefined') { timeout = 10000; } let requestId = that.getid(); @@ -429,7 +434,7 @@ function Candy(nodeList) { this.request = function (uri, data, callback, timeout) { let url = document.createElement('a'); url.href = uri.replace('candy:', 'http:'); - if(url.hostname === 'block') { + if (url.hostname === 'block') { that.loadResource(url.pathname.replace('/', ''), function (err, data) { callback(err, data.candyData, data); }); @@ -445,7 +450,7 @@ function Candy(nodeList) { * @param {Function} callback */ this.loadResource = function (blockId, callback) { - if(blockId > that.blockHeigth && blockId < 1) { + if (blockId > that.blockHeigth && blockId < 1) { callback(404); } that._resourceQueue[blockId] = function (data, rawBlock) { @@ -470,6 +475,6 @@ function Candy(nodeList) { return this; } -if (this.window === undefined){ +if (this.window === undefined) { module.exports = Candy; -} \ No newline at end of file +} diff --git a/digitalSignature.js b/digitalSignature.js index 18d3b15..8872188 100644 --- a/digitalSignature.js +++ b/digitalSignature.js @@ -8,8 +8,11 @@ 'use strict'; //unify browser and node -if (this.window === undefined){ - const forge = require('node-forge'); +if (typeof _this ==='undefined') { + var _this = this; +} +if (_this.window === undefined){ + _this.forge = require('node-forge'); } @@ -40,11 +43,11 @@ function DigitalSignature(dataToSign) { //data in string format */ this.generate = (len = 2048) => { - let rsa = forge.pki.rsa; - let keypair = forge.rsa.generateKeyPair({len}); + let rsa = _this.forge.pki.rsa; + let keypair = _this.forge.rsa.generateKeyPair({len}); keypair = { - public: repairKey(fix(forge.pki.publicKeyToRSAPublicKeyPem(keypair.publicKey, 72))), - private: repairKey(fix(forge.pki.privateKeyToPem(keypair.privateKey, 72))) + public: repairKey(fix(_this.forge.pki.publicKeyToRSAPublicKeyPem(keypair.publicKey, 72))), + private: repairKey(fix(_this.forge.pki.privateKeyToPem(keypair.privateKey, 72))) }; this.keysPair = keypair; console.log('Info: Keypair generated'); @@ -80,12 +83,12 @@ function DigitalSignature(dataToSign) { //data in string format console.log('No data to sign'); return ''; } - let md= forge.md.sha256.create(); + let md= _this.forge.md.sha256.create(); md.update(data,'utf8'); - let privateKey = forge.pki.privateKeyFromPem(key); + let privateKey = _this.forge.pki.privateKeyFromPem(key); this.sign = privateKey.sign(md); console.log('Info: Data signed'); - return {data: data, sign: forge.util.bytesToHex(this.sign)}; + return {data: data, sign: _this.forge.util.bytesToHex(this.sign)}; }; @@ -101,10 +104,10 @@ function DigitalSignature(dataToSign) { //data in string format data = data.data; } try { - let publicKey = forge.pki.publicKeyFromPem(repairKey(fix(key))); - let md = forge.md.sha256.create(); + let publicKey = _this.forge.pki.publicKeyFromPem(repairKey(fix(key))); + let md = _this.forge.md.sha256.create(); md.update(data,'utf8'); - return publicKey.verify(md.digest().bytes(), forge.util.hexToBytes(sign)); //verifying only in bytes format + return publicKey.verify(md.digest().bytes(), _this.forge.util.hexToBytes(sign)); //verifying only in bytes format } catch (e){ console.log(e); return false; diff --git a/starwaveCrypto.js b/starwaveCrypto.js index 8c686ae..ff5c295 100644 --- a/starwaveCrypto.js +++ b/starwaveCrypto.js @@ -13,9 +13,12 @@ 'use strict'; //unify browser and node -if (this.window === undefined){ - const elliptic = require('elliptic'); - const CryptoJS = require('crypto-js'); +if (typeof _this ==='undefined') { + var _this = this; +} +if (_this.window === undefined){ + _this.elliptic = require('elliptic'); + _this.CryptoJS = require('crypto-js'); } const SWCRYPTO_CONNECTION_MESSAGE_TYPE = 'DH-CONNECTION'; @@ -25,7 +28,7 @@ class StarwaveCrypto { constructor(starwaveProtocolObject, secretKeysKeyring, curve = 'secp256k1') { let that = this; // EСDH object - this.ec = new elliptic.ec(curve); + this.ec = new _this.elliptic.ec(curve); this.keyObject = this.ec.genKeyPair(); this.public = this.generateKeys(); this.starwave = starwaveProtocolObject; @@ -79,9 +82,9 @@ class StarwaveCrypto { * @returns {*} */ cipherData(data, secret) { - let encrypted = CryptoJS.AES.encrypt(data, secret).toString(); //base64 - let b64 = CryptoJS.enc.Base64.parse(encrypted);//object - encrypted = b64.toString(CryptoJS.enc.Hex);//hex + let encrypted = _this.CryptoJS.AES.encrypt(data, secret).toString(); //base64 + let b64 = _this.CryptoJS.enc.Base64.parse(encrypted);//object + encrypted = b64.toString(_this.CryptoJS.enc.Hex);//hex return encrypted; } @@ -95,10 +98,10 @@ class StarwaveCrypto { let data; try { //unpack from hex to native base64 and to object - let b64 = CryptoJS.enc.Hex.parse(encryptedData); - let bytes = b64.toString(CryptoJS.enc.Base64); - data = CryptoJS.AES.decrypt(bytes, secret); - data = data.toString(CryptoJS.enc.Utf8); + let b64 = _this.CryptoJS.enc.Hex.parse(encryptedData); + let bytes = b64.toString(_this.CryptoJS.enc.Base64); + data = _this.CryptoJS.AES.decrypt(bytes, secret); + data = data.toString(_this.CryptoJS.enc.Utf8); } catch (e) { console.log('Error decrypting data: ' + e) } diff --git a/starwaveProtocol.js b/starwaveProtocol.js index 5af6ad0..4af0947 100644 --- a/starwaveProtocol.js +++ b/starwaveProtocol.js @@ -13,8 +13,11 @@ const LATENCY_TIME = 100 * 1000; //time on obsolescence of message //unify browser and node -if (this.window === undefined){ - const moment = require('moment'); +if (typeof _this ==='undefined') { + var _this = this; +} +if (_this.window === undefined){ + _this.moment = require('moment'); } class starwaveProtocol { @@ -51,13 +54,13 @@ class starwaveProtocol { reciver: reciver, sender: sender !== undefined ? sender : this.candy.recieverAddress, id: id, - timestamp: timestamp !== undefined ? timestamp : moment().utc().valueOf(), + timestamp: timestamp !== undefined ? timestamp : _this.moment().utc().valueOf(), TTL: typeof TTL !== 'undefined' ? TTL : 0, mutex: this.candy.getid() + this.candy.getid() + this.candy.getid(), relevancyTime: relevancyTime !== undefined ? relevancyTime : LATENCY_TIME, //time of message's relevancy route: route !== undefined ? route : [], type: type !== undefined ? type : this.candy.MessageType.SW_BROADCAST, - timestampOfStart: timestampOfStart !== undefined ? timestampOfStart : moment().utc().valueOf() + timestampOfStart: timestampOfStart !== undefined ? timestampOfStart : _this.moment().utc().valueOf() }; }; @@ -173,7 +176,7 @@ class starwaveProtocol { } //check if the message is't too old - let m = moment().utc().valueOf(); + let m = _this.moment().utc().valueOf(); if(m > (message.timestamp + message.relevancyTime + LATENCY_TIME)) { return 0; //do nothing } From 67ccd8daccb0f615efe959d9036a9a0393a20e58 Mon Sep 17 00:00:00 2001 From: Kirill Date: Sun, 16 Sep 2018 22:19:13 +0300 Subject: [PATCH 07/12] include modules inside the objects --- candy.js | 45 +++++++++++++++++++++++++-------------------- digitalSignature.js | 33 +++++++++++++++++---------------- starwaveCrypto.js | 23 +++++++++++++++-------- starwaveProtocol.js | 15 +++++++++------ 4 files changed, 66 insertions(+), 50 deletions(-) diff --git a/candy.js b/candy.js index a695990..a18e4e7 100644 --- a/candy.js +++ b/candy.js @@ -14,14 +14,6 @@ if (typeof _this ==='undefined') { var _this = this; } -if (_this.window === undefined) { - _this.WebSocket = require('ws'); - _this.starwaveProtocol = require('./starwaveProtocol.js'); - _this.NodeMetaInfo = require('./NodeMetaInfo.js'); - _this.DigitalSignature = require('./digitalSignature.js'); - _this.StarwaveCrypto = require('./starwaveCrypto.js'); -} - const MessageType = { QUERY_LATEST: 0, QUERY_ALL: 1, @@ -42,6 +34,25 @@ const BlockchainRequestors = { function Candy(nodeList) { + //modules list(for compability with node) + try { + if (_this.window === undefined) { + this.WebSocket = require('ws'); + this.starwaveProtocol = require('./starwaveProtocol.js'); + this.NodeMetaInfo = require('./NodeMetaInfo.js'); + this.DigitalSignature = require('./digitalSignature.js'); + this.StarwaveCrypto = require('./starwaveCrypto.js'); + } else { //if browser + this.WebSocket = typeof WebSocket !== 'undefined' ? WebSocket : undefined; + this.starwaveProtocol = typeof starwaveProtocol !== 'undefined' ? starwaveProtocol : undefined; + this.NodeMetaInfo = typeof NodeMetaInfo !== 'undefined' ? NodeMetaInfo : undefined; + this.DigitalSignature = typeof DigitalSignature !== 'undefined' ? DigitalSignature : undefined; + this.StarwaveCrypto = typeof StarwaveCrypto !== 'undefined' ? StarwaveCrypto : undefined; + } + } catch (e) { + console.log('Error trying to include libraries: ' + e); + } + let that = this; this.maxConnections = 30; this.nodeList = nodeList; @@ -60,11 +71,8 @@ function Candy(nodeList) { this.secretKeys = {}; //consist of secret keys of different busAddresses of peers - //modules list(for compability with node) - - - if (typeof _this.starwaveProtocol === 'function') { - this.starwave = new _this.starwaveProtocol(this, MessageType); + if (typeof this.starwaveProtocol === 'function') { + this.starwave = new this.starwaveProtocol(this, MessageType); } else { console.log("Error: Can't find starwaveProtocol module"); } @@ -105,7 +113,6 @@ function Candy(nodeList) { * @param {Object} data */ this._dataRecieved = function (source, data) { - console.log(data); //prevent multiple sockets on one busaddress if (!this.allowMultiplySocketsOnBus && (this.starwave)) { if (this.starwave.preventMultipleSockets(source) === 0) { @@ -213,7 +220,7 @@ function Candy(nodeList) { let activeSockets = []; for (let a in that.sockets) { if (that.sockets[a]) { - if (that.sockets[a].readyState === _this.WebSocket.OPEN) { + if (that.sockets[a].readyState === this.WebSocket.OPEN) { activeSockets.push(that.sockets[a]); } } @@ -229,7 +236,7 @@ function Candy(nodeList) { this.connectPeer = function (peer) { let socket = null; try { - socket = new _this.WebSocket(peer); + socket = new this.WebSocket(peer); } catch (e) { return; } @@ -363,8 +370,7 @@ function Candy(nodeList) { * @param {int} timeout */ this._candyAppRequest = function (uri, requestData, backId, timeout) { - let url = document.createElement('a'); - url.href = uri.replace('candy:', 'http:'); + let url = new URL(uri.replace('candy:', 'http:')); let data = { uri: uri, data: requestData, @@ -432,8 +438,7 @@ function Candy(nodeList) { * @param {int} timeout */ this.request = function (uri, data, callback, timeout) { - let url = document.createElement('a'); - url.href = uri.replace('candy:', 'http:'); + let url = new URL(uri.replace('candy:', 'http:')); if (url.hostname === 'block') { that.loadResource(url.pathname.replace('/', ''), function (err, data) { callback(err, data.candyData, data); diff --git a/digitalSignature.js b/digitalSignature.js index 8872188..90855a0 100644 --- a/digitalSignature.js +++ b/digitalSignature.js @@ -11,13 +11,14 @@ if (typeof _this ==='undefined') { var _this = this; } -if (_this.window === undefined){ - _this.forge = require('node-forge'); -} - function DigitalSignature(dataToSign) { //data in string format - + if (_this.window === undefined){ + this.forge = require('node-forge'); + } else { + this.forge = forge; + } + /** * RSA keys for sign */ @@ -27,7 +28,7 @@ function DigitalSignature(dataToSign) { //data in string format * Sign */ this.sign = ''; - + /** * data format as presented in 'block data' */ @@ -43,11 +44,11 @@ function DigitalSignature(dataToSign) { //data in string format */ this.generate = (len = 2048) => { - let rsa = _this.forge.pki.rsa; - let keypair = _this.forge.rsa.generateKeyPair({len}); + let rsa = this.forge.pki.rsa; + let keypair = this.forge.rsa.generateKeyPair({len}); keypair = { - public: repairKey(fix(_this.forge.pki.publicKeyToRSAPublicKeyPem(keypair.publicKey, 72))), - private: repairKey(fix(_this.forge.pki.privateKeyToPem(keypair.privateKey, 72))) + public: repairKey(fix(this.forge.pki.publicKeyToRSAPublicKeyPem(keypair.publicKey, 72))), + private: repairKey(fix(this.forge.pki.privateKeyToPem(keypair.privateKey, 72))) }; this.keysPair = keypair; console.log('Info: Keypair generated'); @@ -83,12 +84,12 @@ function DigitalSignature(dataToSign) { //data in string format console.log('No data to sign'); return ''; } - let md= _this.forge.md.sha256.create(); + let md= this.forge.md.sha256.create(); md.update(data,'utf8'); - let privateKey = _this.forge.pki.privateKeyFromPem(key); + let privateKey = this.forge.pki.privateKeyFromPem(key); this.sign = privateKey.sign(md); console.log('Info: Data signed'); - return {data: data, sign: _this.forge.util.bytesToHex(this.sign)}; + return {data: data, sign: this.forge.util.bytesToHex(this.sign)}; }; @@ -104,10 +105,10 @@ function DigitalSignature(dataToSign) { //data in string format data = data.data; } try { - let publicKey = _this.forge.pki.publicKeyFromPem(repairKey(fix(key))); - let md = _this.forge.md.sha256.create(); + let publicKey = this.forge.pki.publicKeyFromPem(repairKey(fix(key))); + let md = this.forge.md.sha256.create(); md.update(data,'utf8'); - return publicKey.verify(md.digest().bytes(), _this.forge.util.hexToBytes(sign)); //verifying only in bytes format + return publicKey.verify(md.digest().bytes(), this.forge.util.hexToBytes(sign)); //verifying only in bytes format } catch (e){ console.log(e); return false; diff --git a/starwaveCrypto.js b/starwaveCrypto.js index ff5c295..abc6e66 100644 --- a/starwaveCrypto.js +++ b/starwaveCrypto.js @@ -26,9 +26,16 @@ const SWCRYPTO_CONNECTION_MESSAGE_TYPE = 'DH-CONNECTION'; class StarwaveCrypto { constructor(starwaveProtocolObject, secretKeysKeyring, curve = 'secp256k1') { + if (_this.window === undefined){ + this.elliptic = require('elliptic'); + this.CryptoJS = require('crypto-js'); + } else { + this.elliptic = elliptic; + this.CryptoJS = CryptoJS; + } let that = this; // EСDH object - this.ec = new _this.elliptic.ec(curve); + this.ec = new elliptic.ec(curve); this.keyObject = this.ec.genKeyPair(); this.public = this.generateKeys(); this.starwave = starwaveProtocolObject; @@ -82,9 +89,9 @@ class StarwaveCrypto { * @returns {*} */ cipherData(data, secret) { - let encrypted = _this.CryptoJS.AES.encrypt(data, secret).toString(); //base64 - let b64 = _this.CryptoJS.enc.Base64.parse(encrypted);//object - encrypted = b64.toString(_this.CryptoJS.enc.Hex);//hex + let encrypted = CryptoJS.AES.encrypt(data, secret).toString(); //base64 + let b64 = CryptoJS.enc.Base64.parse(encrypted);//object + encrypted = b64.toString(CryptoJS.enc.Hex);//hex return encrypted; } @@ -98,10 +105,10 @@ class StarwaveCrypto { let data; try { //unpack from hex to native base64 and to object - let b64 = _this.CryptoJS.enc.Hex.parse(encryptedData); - let bytes = b64.toString(_this.CryptoJS.enc.Base64); - data = _this.CryptoJS.AES.decrypt(bytes, secret); - data = data.toString(_this.CryptoJS.enc.Utf8); + let b64 = CryptoJS.enc.Hex.parse(encryptedData); + let bytes = b64.toString(CryptoJS.enc.Base64); + data = CryptoJS.AES.decrypt(bytes, secret); + data = data.toString(CryptoJS.enc.Utf8); } catch (e) { console.log('Error decrypting data: ' + e) } diff --git a/starwaveProtocol.js b/starwaveProtocol.js index 4af0947..04438c6 100644 --- a/starwaveProtocol.js +++ b/starwaveProtocol.js @@ -16,9 +16,7 @@ const LATENCY_TIME = 100 * 1000; //time on obsolescence of message if (typeof _this ==='undefined') { var _this = this; } -if (_this.window === undefined){ - _this.moment = require('moment'); -} + class starwaveProtocol { @@ -32,6 +30,11 @@ class starwaveProtocol { * @private */ this._messageMutex = {}; + if (_this.window === undefined){ + this.moment = require('moment'); + } else{ + this.moment = moment; + } } /** @@ -54,13 +57,13 @@ class starwaveProtocol { reciver: reciver, sender: sender !== undefined ? sender : this.candy.recieverAddress, id: id, - timestamp: timestamp !== undefined ? timestamp : _this.moment().utc().valueOf(), + timestamp: timestamp !== undefined ? timestamp : this.moment().utc().valueOf(), TTL: typeof TTL !== 'undefined' ? TTL : 0, mutex: this.candy.getid() + this.candy.getid() + this.candy.getid(), relevancyTime: relevancyTime !== undefined ? relevancyTime : LATENCY_TIME, //time of message's relevancy route: route !== undefined ? route : [], type: type !== undefined ? type : this.candy.MessageType.SW_BROADCAST, - timestampOfStart: timestampOfStart !== undefined ? timestampOfStart : _this.moment().utc().valueOf() + timestampOfStart: timestampOfStart !== undefined ? timestampOfStart : this.moment().utc().valueOf() }; }; @@ -176,7 +179,7 @@ class starwaveProtocol { } //check if the message is't too old - let m = _this.moment().utc().valueOf(); + let m = this.moment().utc().valueOf(); if(m > (message.timestamp + message.relevancyTime + LATENCY_TIME)) { return 0; //do nothing } From 1e57561a1bccb7f205792dd2f7bb97ea2577dff6 Mon Sep 17 00:00:00 2001 From: Kirill Date: Mon, 17 Sep 2018 14:11:35 +0300 Subject: [PATCH 08/12] make changing to ws from websocket --- candy.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/candy.js b/candy.js index a18e4e7..455eed9 100644 --- a/candy.js +++ b/candy.js @@ -42,12 +42,14 @@ function Candy(nodeList) { this.NodeMetaInfo = require('./NodeMetaInfo.js'); this.DigitalSignature = require('./digitalSignature.js'); this.StarwaveCrypto = require('./starwaveCrypto.js'); + this.URL = require('url').Url; } else { //if browser this.WebSocket = typeof WebSocket !== 'undefined' ? WebSocket : undefined; this.starwaveProtocol = typeof starwaveProtocol !== 'undefined' ? starwaveProtocol : undefined; this.NodeMetaInfo = typeof NodeMetaInfo !== 'undefined' ? NodeMetaInfo : undefined; this.DigitalSignature = typeof DigitalSignature !== 'undefined' ? DigitalSignature : undefined; this.StarwaveCrypto = typeof StarwaveCrypto !== 'undefined' ? StarwaveCrypto : undefined; + this.URL = URL; } } catch (e) { console.log('Error trying to include libraries: ' + e); @@ -191,10 +193,10 @@ function Candy(nodeList) { //add meta info handling //required NodeMetaInfo.js included if (data.type === MessageType.META) { - if (typeof NodeMetaInfo === 'function') { + if (typeof this.NodeMetaInfo === 'function') { let ind = that.sockets.indexOf(source); if (ind > -1) { - that.sockets[ind].nodeMetaInfo = (new NodeMetaInfo()).parse(data.data); + that.sockets[ind].nodeMetaInfo = (new this.NodeMetaInfo()).parse(data.data); } else { console.log('Error: Unexpected error occurred when trying to add validators'); } @@ -240,6 +242,7 @@ function Candy(nodeList) { } catch (e) { return; } + socket.onopen = function () { setTimeout(function () { if (typeof that.onready !== 'undefined') { @@ -269,6 +272,12 @@ function Candy(nodeList) { socket.onerror = function (error) { //console.log("Ошибка " + error.message); }; + if (_this.window === undefined){ + socket.on('open', ()=> socket.onopen()); + socket.on('close', ()=> socket.onclose()); + socket.on('message', ()=> socket.onmessage()); + socket.on('error', ()=> socket.onerror()); + } that.sockets.push(socket); }; @@ -370,7 +379,7 @@ function Candy(nodeList) { * @param {int} timeout */ this._candyAppRequest = function (uri, requestData, backId, timeout) { - let url = new URL(uri.replace('candy:', 'http:')); + let url = new this.URL(uri.replace('candy:', 'http:')); let data = { uri: uri, data: requestData, @@ -438,7 +447,7 @@ function Candy(nodeList) { * @param {int} timeout */ this.request = function (uri, data, callback, timeout) { - let url = new URL(uri.replace('candy:', 'http:')); + let url = new this.URL(uri.replace('candy:', 'http:')); if (url.hostname === 'block') { that.loadResource(url.pathname.replace('/', ''), function (err, data) { callback(err, data.candyData, data); @@ -476,7 +485,6 @@ function Candy(nodeList) { this.messagesHandlers.sort((a, b) => a.id > b.id); }; - return this; } From 70e311e891c3f5b0b0b6b00562a2ced803263d07 Mon Sep 17 00:00:00 2001 From: Kirill Revenkov Date: Tue, 25 Sep 2018 23:17:50 +0300 Subject: [PATCH 09/12] first commit --- transactionCollector.js | 51 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 transactionCollector.js diff --git a/transactionCollector.js b/transactionCollector.js new file mode 100644 index 0000000..a1626da --- /dev/null +++ b/transactionCollector.js @@ -0,0 +1,51 @@ +/** + Module which made transactions collections + */ + +'use strict'; +//unify browser and node +if (typeof _this ==='undefined') { + var _this = this; +} +if (_this.window === undefined){ + +} + +class TransactionCollector { + + constructor (candy) { + this.candy = candy; + this.lastAddedTransaction = {}; + } + + + /** + * create alert about new transaction + * @param data + * @param index + * @returns {{type: number, data: *, index: string}} + */ + createMessage(data, index = ''){ + let JSONdata = JSON.stringify(data); + return { + type: this.blockchain.messageType.TRANS_COLL, + data: JSONdata, + index:index + } + } + + /** + * broadcasting message to all peers about new element of collection, excluding excludeSocket + * @param data + * @param broadcastFunction + * @param excludeSocket + */ + sendTransactionToAllPeers(data, broadcastFunction, excludeSocket){ + broadcastFunction (this.createMessage(data), excludeSocket); + } +} + +//unify browser and node +if (this.window === undefined){ + module.exports = TransactionCollector; +} \ No newline at end of file From 4cf2ef2e0a4fb87719ff315102a37c04dfc1cd26 Mon Sep 17 00:00:00 2001 From: Kirill Date: Wed, 26 Sep 2018 10:02:02 +0300 Subject: [PATCH 10/12] added return --- transactionCollector.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/transactionCollector.js b/transactionCollector.js index a1626da..2a4ee1d 100644 --- a/transactionCollector.js +++ b/transactionCollector.js @@ -41,7 +41,9 @@ class TransactionCollector { * @param excludeSocket */ sendTransactionToAllPeers(data, broadcastFunction, excludeSocket){ - broadcastFunction (this.createMessage(data), excludeSocket); + let message = this.createMessage(data); + broadcastFunction (message, excludeSocket); + return message; } } From ff5ec8e8c5464b6b072bef73e195da53124f7c7b Mon Sep 17 00:00:00 2001 From: Kirill Date: Wed, 26 Sep 2018 10:09:18 +0300 Subject: [PATCH 11/12] add type --- candy.js | 3 ++- transactionCollector.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/candy.js b/candy.js index 455eed9..c55e0c0 100644 --- a/candy.js +++ b/candy.js @@ -21,7 +21,8 @@ const MessageType = { MY_PEERS: 3, BROADCAST: 4, META: 5, - SW_BROADCAST: 6 + SW_BROADCAST: 6, + TRANS_COLL:7, }; const BlockchainRequestors = { diff --git a/transactionCollector.js b/transactionCollector.js index 2a4ee1d..f7dfcb7 100644 --- a/transactionCollector.js +++ b/transactionCollector.js @@ -28,7 +28,7 @@ class TransactionCollector { createMessage(data, index = ''){ let JSONdata = JSON.stringify(data); return { - type: this.blockchain.messageType.TRANS_COLL, + type: this.candy.MessageType.TRANS_COLL, data: JSONdata, index:index } From dcbedf4a2d61316a93c95caa6c3ac24a7d83eeb7 Mon Sep 17 00:00:00 2001 From: Kirill Date: Thu, 27 Sep 2018 08:03:14 +0300 Subject: [PATCH 12/12] gitigmore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 03a8da3..e83f5bd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ demo — копия.html demo — копия — копия.html +node_modules