Compare commits

..

16 Commits

Author SHA1 Message Date
e12aa7e961 1.0.63 2019-08-13 18:41:28 +02:00
857b7cd010 fix(core): update 2019-08-13 18:41:27 +02:00
e100dea160 1.0.62 2019-08-13 18:16:17 +02:00
e8e87fcdba fix(core): update 2019-08-13 18:16:16 +02:00
0d18b11721 1.0.61 2019-08-13 18:06:14 +02:00
eaaefddbe3 fix(core): update 2019-08-13 18:06:13 +02:00
8c6946ddb6 1.0.60 2019-08-13 15:55:01 +02:00
3a7ebcdd80 fix(core): update 2019-08-13 15:55:01 +02:00
ec2afbfd55 1.0.59 2019-08-13 15:48:21 +02:00
89feeca735 fix(core): update 2019-08-13 15:48:20 +02:00
c4261765ec 1.0.58 2019-08-13 13:04:49 +02:00
33fe6bcd41 fix(core): update 2019-08-13 13:04:49 +02:00
1baf1c318c 1.0.57 2019-08-12 17:23:11 +02:00
051aba3299 fix(core): update 2019-08-12 17:23:10 +02:00
7998d79b13 1.0.56 2019-08-12 15:12:32 +02:00
6838a8729a fix(core): update 2019-08-12 15:12:31 +02:00
16 changed files with 267 additions and 178 deletions

155
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "@pushrocks/smartuniverse", "name": "@pushrocks/smartuniverse",
"version": "1.0.55", "version": "1.0.63",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
@ -104,24 +104,17 @@
} }
}, },
"@pushrocks/lik": { "@pushrocks/lik": {
"version": "3.0.5", "version": "3.0.10",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2flik/-/lik-3.0.5.tgz", "resolved": "https://verdaccio.lossless.one/@pushrocks%2flik/-/lik-3.0.10.tgz",
"integrity": "sha512-pc5Nq0WUysS34qPpyiZXiX254kL3vyRVbt3D36Q5QU+eHhxAThHofSzgOdyVHUZU2WFoaMlKowIVsyUFzIkfdw==", "integrity": "sha512-iWG06QsrL6AAnjPRWMVz4bRaRE0jJt/HgEK0YeLqaSBLY8ju4ps1j4lEN8VrUlXGZyPB6UGQfcreesO24buYhQ==",
"requires": { "requires": {
"@pushrocks/smartdelay": "^2.0.2", "@pushrocks/smartdelay": "^2.0.3",
"@pushrocks/smartpromise": "^2.0.5", "@pushrocks/smartpromise": "^3.0.2",
"@pushrocks/smartrx": "^2.0.3", "@pushrocks/smartrx": "^2.0.3",
"@pushrocks/smarttime": "^3.0.5", "@pushrocks/smarttime": "^3.0.12",
"@types/minimatch": "^3.0.3", "@types/minimatch": "^3.0.3",
"minimatch": "^3.0.4", "minimatch": "^3.0.4",
"symbol-tree": "^3.2.2" "symbol-tree": "^3.2.4"
},
"dependencies": {
"@pushrocks/smartpromise": {
"version": "2.0.5",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartpromise/-/smartpromise-2.0.5.tgz",
"integrity": "sha512-9j/chLtIiNkR0MDw7Mpxg9slxAVvAQwUZuiaPYX5KpHdKxQaHLI1VZ8IN0vPhwlfgNO4i4vGXV0wB8BvSDj03g=="
}
} }
}, },
"@pushrocks/smartcli": { "@pushrocks/smartcli": {
@ -182,12 +175,12 @@
} }
}, },
"@pushrocks/smartexpress": { "@pushrocks/smartexpress": {
"version": "3.0.35", "version": "3.0.38",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartexpress/-/smartexpress-3.0.35.tgz", "resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartexpress/-/smartexpress-3.0.38.tgz",
"integrity": "sha512-8DYFURxE+CXuh59O7SMRTLKaiWda/I1srcLE5Hka6YCLCahCKsT1HDVHcEVnY4E7kd9OaHEzuPa7ZddaISi5xQ==", "integrity": "sha512-di26orVJwgBRGKVpYcPrauc14CVo0piAzXTBWFZZNUCuIsndnXepd9oDzMO+KHVZpNz3W4DxbtRkppZjrh9ejw==",
"requires": { "requires": {
"@pushrocks/lik": "^3.0.5", "@pushrocks/lik": "^3.0.10",
"@pushrocks/smartfile": "^7.0.2", "@pushrocks/smartfile": "^7.0.4",
"@pushrocks/smartmanifest": "^1.0.6", "@pushrocks/smartmanifest": "^1.0.6",
"@pushrocks/smartpromise": "^3.0.2", "@pushrocks/smartpromise": "^3.0.2",
"@pushrocks/smartrequest": "^1.1.16", "@pushrocks/smartrequest": "^1.1.16",
@ -199,9 +192,9 @@
"cors": "^2.8.5", "cors": "^2.8.5",
"express": "^4.17.1", "express": "^4.17.1",
"express-force-ssl": "^0.3.2", "express-force-ssl": "^0.3.2",
"helmet": "^3.18.0", "helmet": "^3.20.0",
"rendertron-middleware": "^0.1.5", "rendertron-middleware": "^0.1.5",
"sitemap": "^2.2.0" "sitemap": "^3.2.2"
} }
}, },
"@pushrocks/smartfile": { "@pushrocks/smartfile": {
@ -340,14 +333,14 @@
} }
}, },
"@pushrocks/smartsocket": { "@pushrocks/smartsocket": {
"version": "1.1.38", "version": "1.1.44",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartsocket/-/smartsocket-1.1.38.tgz", "resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartsocket/-/smartsocket-1.1.44.tgz",
"integrity": "sha512-mGWEuA53GqTFOCebwo4Ayu2l7xjui7I0tdUNgZShGhIr4yv+q3sP/66q6cT388xVawIN+swviJPlPoogaoZXdA==", "integrity": "sha512-AxDEDQw96szewxiA7Vk+ak6l7tsf2MLIThAuoV53ycDkDNXMyJizqE8fnzks9+/OEukwwas9kYNT9MyqPIS1mw==",
"requires": { "requires": {
"@pushrocks/lik": "^3.0.5", "@pushrocks/lik": "^3.0.10",
"@pushrocks/smartdelay": "^2.0.3", "@pushrocks/smartdelay": "^2.0.3",
"@pushrocks/smartexpress": "^3.0.21", "@pushrocks/smartexpress": "^3.0.38",
"@pushrocks/smarthash": "^2.0.4", "@pushrocks/smarthash": "^2.0.6",
"@pushrocks/smartlog": "^2.0.19", "@pushrocks/smartlog": "^2.0.19",
"@pushrocks/smartpromise": "^3.0.2", "@pushrocks/smartpromise": "^3.0.2",
"@types/shortid": "0.0.29", "@types/shortid": "0.0.29",
@ -525,9 +518,9 @@
"integrity": "sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA==" "integrity": "sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA=="
}, },
"@types/node": { "@types/node": {
"version": "12.6.8", "version": "12.7.1",
"resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-12.6.8.tgz", "resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-12.7.1.tgz",
"integrity": "sha512-aX+gFgA5GHcDi89KG5keey2zf0WfZk/HAQotEamsK2kbey+8yGKcson0hbK8E+v0NArlCJQCqMP161YhV6ZXLg==" "integrity": "sha512-aK9jxMypeSrhiYofWWBf/T7O+KwaiAHzM4sveCdWPn71lzUSMimRnKzhXDKfKwV1kWoBo2P1aGgaIYGLf9/ljw=="
}, },
"@types/range-parser": { "@types/range-parser": {
"version": "1.2.3", "version": "1.2.3",
@ -604,21 +597,6 @@
"requires": { "requires": {
"mime-types": "~2.1.24", "mime-types": "~2.1.24",
"negotiator": "0.6.2" "negotiator": "0.6.2"
},
"dependencies": {
"mime-db": {
"version": "1.40.0",
"resolved": "https://verdaccio.lossless.one/mime-db/-/mime-db-1.40.0.tgz",
"integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA=="
},
"mime-types": {
"version": "2.1.24",
"resolved": "https://verdaccio.lossless.one/mime-types/-/mime-types-2.1.24.tgz",
"integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==",
"requires": {
"mime-db": "1.40.0"
}
}
} }
}, },
"after": { "after": {
@ -702,9 +680,9 @@
"dev": true "dev": true
}, },
"async-limiter": { "async-limiter": {
"version": "1.0.0", "version": "1.0.1",
"resolved": "https://verdaccio.lossless.one/async-limiter/-/async-limiter-1.0.0.tgz", "resolved": "https://verdaccio.lossless.one/async-limiter/-/async-limiter-1.0.1.tgz",
"integrity": "sha512-jp/uFnooOiO+L211eZOoSyzpOITMXx1rBITauYykG3BRYPu8h0UcxsPNB04RR5vo4Tyz3+ay17tR6JVf9qzYWg==" "integrity": "sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ=="
}, },
"asynckit": { "asynckit": {
"version": "0.4.0", "version": "0.4.0",
@ -1802,11 +1780,6 @@
"path-exists": "^3.0.0" "path-exists": "^3.0.0"
} }
}, },
"lodash": {
"version": "4.17.15",
"resolved": "https://verdaccio.lossless.one/lodash/-/lodash-4.17.15.tgz",
"integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A=="
},
"lodash._baseassign": { "lodash._baseassign": {
"version": "3.2.0", "version": "3.2.0",
"resolved": "https://verdaccio.lossless.one/lodash._baseassign/-/lodash._baseassign-3.2.0.tgz", "resolved": "https://verdaccio.lossless.one/lodash._baseassign/-/lodash._baseassign-3.2.0.tgz",
@ -1856,6 +1829,11 @@
"lodash.keys": "^3.0.0" "lodash.keys": "^3.0.0"
} }
}, },
"lodash.chunk": {
"version": "4.2.0",
"resolved": "https://verdaccio.lossless.one/lodash.chunk/-/lodash.chunk-4.2.0.tgz",
"integrity": "sha1-ZuXOH3btJ7QwPYxlEujRIW6BBrw="
},
"lodash.clonedeep": { "lodash.clonedeep": {
"version": "4.5.0", "version": "4.5.0",
"resolved": "https://verdaccio.lossless.one/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz", "resolved": "https://verdaccio.lossless.one/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz",
@ -1881,11 +1859,21 @@
"lodash.isarray": "^3.0.0" "lodash.isarray": "^3.0.0"
} }
}, },
"lodash.padstart": {
"version": "4.6.1",
"resolved": "https://verdaccio.lossless.one/lodash.padstart/-/lodash.padstart-4.6.1.tgz",
"integrity": "sha1-0uPuv/DZ05rVD1y9G1KnvOa7YRs="
},
"lodash.restparam": { "lodash.restparam": {
"version": "3.6.1", "version": "3.6.1",
"resolved": "https://verdaccio.lossless.one/lodash.restparam/-/lodash.restparam-3.6.1.tgz", "resolved": "https://verdaccio.lossless.one/lodash.restparam/-/lodash.restparam-3.6.1.tgz",
"integrity": "sha1-k2pOMJ7zMKdkXtQUWYbIWuWyCAU=" "integrity": "sha1-k2pOMJ7zMKdkXtQUWYbIWuWyCAU="
}, },
"lodash.sortby": {
"version": "4.7.0",
"resolved": "https://verdaccio.lossless.one/lodash.sortby/-/lodash.sortby-4.7.0.tgz",
"integrity": "sha1-7dFMgk4sycHgsKG0K7UhBRakJDg="
},
"log-symbols": { "log-symbols": {
"version": "2.2.0", "version": "2.2.0",
"resolved": "https://verdaccio.lossless.one/log-symbols/-/log-symbols-2.2.0.tgz", "resolved": "https://verdaccio.lossless.one/log-symbols/-/log-symbols-2.2.0.tgz",
@ -2279,9 +2267,9 @@
} }
}, },
"psl": { "psl": {
"version": "1.2.0", "version": "1.3.0",
"resolved": "https://verdaccio.lossless.one/psl/-/psl-1.2.0.tgz", "resolved": "https://verdaccio.lossless.one/psl/-/psl-1.3.0.tgz",
"integrity": "sha512-GEn74ZffufCmkDDLNcl3uuyF/aSD6exEyh1v/ZSdAomB82t6G9hzJVRx0jBmLDW+VfZqks3aScmMw9DszwUalA==" "integrity": "sha512-avHdspHO+9rQTLbv1RO+MPYeP/SzsCoxofjVnHanETfQhTJrmB0HlDoW+EiN/R+C0BZ+gERab9NY0lPN2TxNag=="
}, },
"pump": { "pump": {
"version": "3.0.0", "version": "3.0.0",
@ -2535,13 +2523,14 @@
"dev": true "dev": true
}, },
"sitemap": { "sitemap": {
"version": "2.2.0", "version": "3.2.2",
"resolved": "https://verdaccio.lossless.one/sitemap/-/sitemap-2.2.0.tgz", "resolved": "https://verdaccio.lossless.one/sitemap/-/sitemap-3.2.2.tgz",
"integrity": "sha512-9Zoi3UBhSIt5jWENDRUbzsqLMJ+Fha3P2aQ2PRghmh0FOivtHsC4FAJdkAEKHvATajd74BWp/57Yh7kz/UA53Q==", "integrity": "sha512-TModL/WU4m2q/mQcrDgNANn0P4LwprM9MMvG4hu5zP4c6IIKs2YLTu6nXXnNr8ODW/WFtxKggiJ1EGn2W0GNmg==",
"requires": { "requires": {
"lodash": "^4.17.10", "lodash.chunk": "^4.2.0",
"url-join": "^4.0.0", "lodash.padstart": "^4.6.1",
"xmlbuilder": "^10.0.0" "whatwg-url": "^7.0.0",
"xmlbuilder": "^13.0.0"
} }
}, },
"smartchai": { "smartchai": {
@ -2757,9 +2746,9 @@
} }
}, },
"symbol-tree": { "symbol-tree": {
"version": "3.2.2", "version": "3.2.4",
"resolved": "https://verdaccio.lossless.one/symbol-tree/-/symbol-tree-3.2.2.tgz", "resolved": "https://verdaccio.lossless.one/symbol-tree/-/symbol-tree-3.2.4.tgz",
"integrity": "sha1-rifbOPZgp64uHDt9G8KQgZuFGeY=" "integrity": "sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw=="
}, },
"through2": { "through2": {
"version": "3.0.1", "version": "3.0.1",
@ -2795,6 +2784,14 @@
} }
} }
}, },
"tr46": {
"version": "1.0.1",
"resolved": "https://verdaccio.lossless.one/tr46/-/tr46-1.0.1.tgz",
"integrity": "sha1-qLE/1r/SSJUZZ0zN5VujaTtwbQk=",
"requires": {
"punycode": "^2.1.0"
}
},
"ts-node": { "ts-node": {
"version": "8.2.0", "version": "8.2.0",
"resolved": "https://verdaccio.lossless.one/ts-node/-/ts-node-8.2.0.tgz", "resolved": "https://verdaccio.lossless.one/ts-node/-/ts-node-8.2.0.tgz",
@ -2909,11 +2906,6 @@
"punycode": "^2.1.0" "punycode": "^2.1.0"
} }
}, },
"url-join": {
"version": "4.0.1",
"resolved": "https://verdaccio.lossless.one/url-join/-/url-join-4.0.1.tgz",
"integrity": "sha512-jk1+QP6ZJqyOiuEI9AEWQfju/nB2Pw466kbA0LEZljHwKeMgd9WrAEgEGxjPDD2+TNbbb37rTyhEfrCXfuKXnA=="
},
"util-deprecate": { "util-deprecate": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://verdaccio.lossless.one/util-deprecate/-/util-deprecate-1.0.2.tgz", "resolved": "https://verdaccio.lossless.one/util-deprecate/-/util-deprecate-1.0.2.tgz",
@ -2978,6 +2970,21 @@
"defaults": "^1.0.3" "defaults": "^1.0.3"
} }
}, },
"webidl-conversions": {
"version": "4.0.2",
"resolved": "https://verdaccio.lossless.one/webidl-conversions/-/webidl-conversions-4.0.2.tgz",
"integrity": "sha512-YQ+BmxuTgd6UXZW3+ICGfyqRyHXVlD5GtQr5+qjiNW7bF0cqrzX500HVXPBOvgXb5YnzDd+h0zqyv61KUD7+Sg=="
},
"whatwg-url": {
"version": "7.0.0",
"resolved": "https://verdaccio.lossless.one/whatwg-url/-/whatwg-url-7.0.0.tgz",
"integrity": "sha512-37GeVSIJ3kn1JgKyjiYNmSLP1yzbpb29jdmwBSgkD9h40/hyrR/OifpVUndji3tmwGgD8qpw7iQu3RSbCrBpsQ==",
"requires": {
"lodash.sortby": "^4.7.0",
"tr46": "^1.0.1",
"webidl-conversions": "^4.0.2"
}
},
"which": { "which": {
"version": "1.3.1", "version": "1.3.1",
"resolved": "https://verdaccio.lossless.one/which/-/which-1.3.1.tgz", "resolved": "https://verdaccio.lossless.one/which/-/which-1.3.1.tgz",
@ -3059,9 +3066,9 @@
"integrity": "sha512-xN0kV+8XfOQM2OPPBdEbGtbvJNNP1pvZR7sE6d44cjJFQG4OiGDdienPg5iOUGswBTiGbBvtYDURd30BMJwwqg==" "integrity": "sha512-xN0kV+8XfOQM2OPPBdEbGtbvJNNP1pvZR7sE6d44cjJFQG4OiGDdienPg5iOUGswBTiGbBvtYDURd30BMJwwqg=="
}, },
"xmlbuilder": { "xmlbuilder": {
"version": "10.1.1", "version": "13.0.2",
"resolved": "https://verdaccio.lossless.one/xmlbuilder/-/xmlbuilder-10.1.1.tgz", "resolved": "https://verdaccio.lossless.one/xmlbuilder/-/xmlbuilder-13.0.2.tgz",
"integrity": "sha512-OyzrcFLL/nb6fMGHbiRDuPup9ljBycsdCypwuyg5AAHvyWzGfChJpCXMG88AGTIMFhGZ9RccFN1e6lhg3hkwKg==" "integrity": "sha512-Eux0i2QdDYKbdbA6AM6xE4m6ZTZr4G4xF9kahI2ukSEMCzwce2eX9WlTI5J3s+NU7hpasFsr8hWIONae7LluAQ=="
}, },
"xmlhttprequest-ssl": { "xmlhttprequest-ssl": {
"version": "1.5.5", "version": "1.5.5",

View File

@ -1,6 +1,6 @@
{ {
"name": "@pushrocks/smartuniverse", "name": "@pushrocks/smartuniverse",
"version": "1.0.55", "version": "1.0.63",
"private": false, "private": false,
"description": "messaging service for your micro services", "description": "messaging service for your micro services",
"main": "dist/index.js", "main": "dist/index.js",
@ -17,7 +17,7 @@
"@gitzone/tsbuild": "^2.1.11", "@gitzone/tsbuild": "^2.1.11",
"@gitzone/tstest": "^1.0.24", "@gitzone/tstest": "^1.0.24",
"@pushrocks/tapbundle": "^3.0.11", "@pushrocks/tapbundle": "^3.0.11",
"@types/node": "^12.6.8", "@types/node": "^12.7.1",
"tslint": "^5.18.0", "tslint": "^5.18.0",
"tslint-config-prettier": "^1.18.0" "tslint-config-prettier": "^1.18.0"
}, },
@ -25,15 +25,16 @@
"rxjs": "*" "rxjs": "*"
}, },
"dependencies": { "dependencies": {
"@pushrocks/lik": "^3.0.5", "@pushrocks/lik": "^3.0.10",
"@pushrocks/smartdelay": "^2.0.3", "@pushrocks/smartdelay": "^2.0.3",
"@pushrocks/smartexpress": "^3.0.35", "@pushrocks/smartexpress": "^3.0.38",
"@pushrocks/smartfile": "^7.0.4", "@pushrocks/smartfile": "^7.0.4",
"@pushrocks/smarthash": "^2.0.6", "@pushrocks/smarthash": "^2.0.6",
"@pushrocks/smartlog": "^2.0.19",
"@pushrocks/smartpromise": "^3.0.2", "@pushrocks/smartpromise": "^3.0.2",
"@pushrocks/smartrequest": "^1.1.16", "@pushrocks/smartrequest": "^1.1.16",
"@pushrocks/smartrx": "^2.0.3", "@pushrocks/smartrx": "^2.0.3",
"@pushrocks/smartsocket": "^1.1.38", "@pushrocks/smartsocket": "^1.1.44",
"@pushrocks/smarttime": "^3.0.12", "@pushrocks/smarttime": "^3.0.12",
"@pushrocks/smartunique": "^3.0.1" "@pushrocks/smartunique": "^3.0.1"
}, },

View File

@ -15,7 +15,7 @@ const testServerData = {
const testChannelData = { const testChannelData = {
channelName: 'awesomeTestChannel', channelName: 'awesomeTestChannel',
channelPass: 'awesomeChannelPAss' channelPass: 'awesomeChannelPass'
}; };
tap.test('first test', async () => { tap.test('first test', async () => {
@ -44,15 +44,18 @@ tap.test('should add the same channel to the client universe in the same way', a
await testClientUniverse.addChannel(testChannelData.channelName, testChannelData.channelPass); await testClientUniverse.addChannel(testChannelData.channelName, testChannelData.channelPass);
}); });
tap.test('should start the ClientUniverse', async () => {
await testClientUniverse.start();
})
tap.test('should get a observable correctly', async () => { tap.test('should get a observable correctly', async () => {
testClientChannel = await testClientUniverse.getChannel(testChannelData.channelName); testClientChannel = testClientUniverse.getChannel(testChannelData.channelName);
expect(testClientChannel).to.be.instanceof(smartuniverse.ClientUniverseChannel); expect(testClientChannel).to.be.instanceof(smartuniverse.ClientUniverseChannel);
}); });
tap.test('should send a message correctly', async () => { tap.test('should send a message correctly', async () => {
await testClientUniverse.sendMessage({ await (testClientUniverse.getChannel(testChannelData.channelName)).sendMessage({
messageText: 'hello', messageText: 'hello'
targetChannelName: testChannelData.channelName
}); });
}); });
@ -71,7 +74,7 @@ tap.test('a second client should be able to subscibe', async () => {
tap.test('should receive a message correctly', async () => {}); tap.test('should receive a message correctly', async () => {});
tap.test('should disconnect the client correctly', async () => { tap.test('should disconnect the client correctly', async () => {
testClientUniverse.close(); testClientUniverse.stop();
}); });
tap.test('should end the server correctly', async tools => { tap.test('should end the server correctly', async tools => {

View File

@ -1,6 +1,7 @@
// Client classes // Client classes
export * from './smartuniverse.classes.clientuniverse'; export * from './smartuniverse.classes.clientuniverse';
export * from './smartuniverse.classes.clientuniversechannel'; export * from './smartuniverse.classes.clientuniversechannel';
export * from './smartuniverse.classes.clientuniversemessage';
// Server classes // Server classes
export * from './smartuniverse.classes.universe'; export * from './smartuniverse.classes.universe';

View File

@ -1,4 +0,0 @@
export interface IAuthenticationRequest {
channelName: string;
password: string;
}

View File

@ -2,9 +2,11 @@ export interface IMessageCreator {
messageText: string; messageText: string;
payload?: string | number | any; payload?: string | number | any;
payloadStringType?: 'Buffer' | 'string' | 'object'; payloadStringType?: 'Buffer' | 'string' | 'object';
targetChannelName: string;
} }
/**
*
*/
export interface IUniverseMessage extends IMessageCreator { export interface IUniverseMessage extends IMessageCreator {
id: string; id: string;
/** /**
@ -12,4 +14,5 @@ export interface IUniverseMessage extends IMessageCreator {
*/ */
timestamp: number; timestamp: number;
passphrase: string; passphrase: string;
targetChannelName: string;
} }

View File

@ -7,7 +7,7 @@ import * as url from 'url';
import * as interfaces from './interfaces'; import * as interfaces from './interfaces';
import { ClientUniverseChannel, UniverseMessage } from './'; import { ClientUniverseChannel, ClientUniverseMessage } from './';
import { ClientUniverseCache } from './smartuniverse.classes.clientuniversecache'; import { ClientUniverseCache } from './smartuniverse.classes.clientuniversecache';
export interface IClientOptions { export interface IClientOptions {
@ -21,9 +21,7 @@ export interface IClientOptions {
export class ClientUniverse { export class ClientUniverse {
public options; public options;
public smartsocketClient: plugins.smartsocket.SmartsocketClient; public smartsocketClient: plugins.smartsocket.SmartsocketClient;
public observableIntake: plugins.smartrx.ObservableIntake<UniverseMessage>; public observableIntake: plugins.smartrx.ObservableIntake<ClientUniverseMessage>;
public channelStore = new Objectmap<ClientUniverseChannel>();
public clientUniverseCache = new ClientUniverseCache(); public clientUniverseCache = new ClientUniverseCache();
constructor(optionsArg: IClientOptions) { constructor(optionsArg: IClientOptions) {
@ -34,15 +32,16 @@ export class ClientUniverse {
* adds a channel to the channelcache * adds a channel to the channelcache
* TODO: verify channel before adding it to the channel cache * TODO: verify channel before adding it to the channel cache
*/ */
public async addChannel(channelNameArg: string, passphraseArg: string) { public addChannel(channelNameArg: string, passphraseArg: string) {
const existingChannel = await this.getChannel(channelNameArg); const existingChannel = this.getChannel(channelNameArg);
if (existingChannel) { if (existingChannel) {
throw new Error('channel exists'); throw new Error('channel exists');
} }
// lets create the channel // lets create the channel
ClientUniverseChannel.createClientUniverseChannel(this, channelNameArg, passphraseArg); const clientUniverseChannel = ClientUniverseChannel.createClientUniverseChannel(this, channelNameArg, passphraseArg);
return clientUniverseChannel;
} }
/** /**
@ -50,9 +49,8 @@ export class ClientUniverse {
* @param channelName * @param channelName
* @param passphraseArg * @param passphraseArg
*/ */
public async getChannel(channelName: string): Promise<ClientUniverseChannel> { public getChannel(channelName: string): ClientUniverseChannel {
await this.checkConnection(); const clientUniverseChannel = this.clientUniverseCache.channelMap.find(channel => {
const clientUniverseChannel = this.channelStore.find(channel => {
return channel.name === channelName; return channel.name === channelName;
}); });
return clientUniverseChannel; return clientUniverseChannel;
@ -63,27 +61,16 @@ export class ClientUniverse {
* @param messageArg * @param messageArg
*/ */
public removeChannel(channelNameArg, notifyServer = true) { public removeChannel(channelNameArg, notifyServer = true) {
const clientUniverseChannel = this.channelStore.findOneAndRemove(channelItemArg => { const clientUniverseChannel = this.clientUniverseCache.channelMap.findOneAndRemove(channelItemArg => {
return channelItemArg.name === channelNameArg; return channelItemArg.name === channelNameArg;
}); });
} }
/** public async start() {
* sends a message towards the server
* @param messageArg
*/
public async sendMessage(messageArg: interfaces.IMessageCreator) {
await this.checkConnection(); await this.checkConnection();
const universeMessageToSend: interfaces.IUniverseMessage = {
id: plugins.smartunique.shortId(),
timestamp: Date.now(),
passphrase: (await this.getChannel(messageArg.targetChannelName)).passphrase,
...messageArg
};
await this.smartsocketClient.serverCall('processMessage', universeMessageToSend);
} }
public close() { public stop() {
this.smartsocketClient.disconnect(); this.smartsocketClient.disconnect();
} }
@ -91,7 +78,7 @@ export class ClientUniverse {
* checks the connection towards a universe server * checks the connection towards a universe server
* since password validation is done through other means, a connection should always be possible * since password validation is done through other means, a connection should always be possible
*/ */
private async checkConnection(): Promise<void> { public async checkConnection(): Promise<void> {
if (!this.smartsocketClient && !this.observableIntake) { if (!this.smartsocketClient && !this.observableIntake) {
const parsedURL = url.parse(this.options.serverAddress); const parsedURL = url.parse(this.options.serverAddress);
const socketConfig: plugins.smartsocket.ISmartsocketClientOptions = { const socketConfig: plugins.smartsocket.ISmartsocketClientOptions = {
@ -101,7 +88,6 @@ export class ClientUniverse {
role: 'UniverseClient', role: 'UniverseClient',
url: parsedURL.protocol + '//' + parsedURL.hostname url: parsedURL.protocol + '//' + parsedURL.hostname
}; };
console.log(socketConfig);
this.smartsocketClient = new SmartsocketClient(socketConfig); this.smartsocketClient = new SmartsocketClient(socketConfig);
this.observableIntake = new plugins.smartrx.ObservableIntake(); this.observableIntake = new plugins.smartrx.ObservableIntake();
@ -110,7 +96,7 @@ export class ClientUniverse {
/** /**
* should handle a forced unsubscription by the server * should handle a forced unsubscription by the server
*/ */
const unsubscribe = new plugins.smartsocket.SocketFunction({ const socketFunctionUnsubscribe = new plugins.smartsocket.SocketFunction({
funcName: 'unsubscribe', funcName: 'unsubscribe',
allowedRoles: [], allowedRoles: [],
funcDef: async (data: interfaces.IServerUnsubscribeActionPayload) => { funcDef: async (data: interfaces.IServerUnsubscribeActionPayload) => {
@ -119,17 +105,26 @@ export class ClientUniverse {
}); });
/** /**
* should handle a message reception * handles message reception
*/ */
const processMessageSocketFunction = new plugins.smartsocket.SocketFunction({ const socketFunctionProcessMessage = new plugins.smartsocket.SocketFunction({
funcName: 'processMessage', funcName: 'processMessage',
allowedRoles: [], allowedRoles: [],
funcDef: async (data: interfaces.IServerUnsubscribeActionPayload) => { funcDef: async (messageDescriptorArg: interfaces.IUniverseMessage) => {
throw new Error('TODO'); plugins.smartlog.defaultLogger.log('info', 'Got message from server');
this.observableIntake.push(ClientUniverseMessage.createMessageFromMessageDescriptor(messageDescriptorArg));
} }
}); });
// add functions
this.smartsocketClient.addSocketFunction(socketFunctionUnsubscribe);
this.smartsocketClient.addSocketFunction(socketFunctionProcessMessage);
await this.smartsocketClient.connect(); await this.smartsocketClient.connect();
plugins.smartlog.defaultLogger.log('info', 'universe client connected successfully');
await this.clientUniverseCache.channelMap.forEach(async clientUniverseChannelArg => {
await clientUniverseChannelArg.subscribe();
});
} }
} }
} }

View File

@ -1,8 +1,11 @@
import * as plugins from './smartuniverse.plugins'; import * as plugins from './smartuniverse.plugins';
import { ClientUniverseChannel } from './smartuniverse.classes.clientuniversechannel';
/** /**
* a cache for clients * a cache for clients
* keeps track of which messages have already been received * keeps track of which messages have already been received
* good for deduplication in mesh environments * good for deduplication in mesh environments
*/ */
export class ClientUniverseCache {} export class ClientUniverseCache {
public channelMap = new plugins.lik.Objectmap<ClientUniverseChannel>();
}

View File

@ -13,18 +13,17 @@ export class ClientUniverseChannel implements interfaces.IUniverseChannel {
* @param channelNameArg * @param channelNameArg
* @param passphraseArg * @param passphraseArg
*/ */
public static async createClientUniverseChannel( public static createClientUniverseChannel(
clientUniverseArg: ClientUniverse, clientUniverseArg: ClientUniverse,
channelNameArg: string, channelNameArg: string,
passphraseArg: string passphraseArg: string
): Promise<ClientUniverseChannel> { ): ClientUniverseChannel {
const clientChannel = new ClientUniverseChannel( const clientChannel = new ClientUniverseChannel(
clientUniverseArg, clientUniverseArg,
channelNameArg, channelNameArg,
passphraseArg passphraseArg
); );
clientUniverseArg.channelStore.add(clientChannel); clientUniverseArg.clientUniverseCache.channelMap.add(clientChannel);
await clientChannel.subscribe();
return clientChannel; return clientChannel;
} }
@ -37,10 +36,10 @@ export class ClientUniverseChannel implements interfaces.IUniverseChannel {
public passphrase: string; public passphrase: string;
// refs // refs
public clientUniverse: ClientUniverse; public clientUniverseRef: ClientUniverse;
constructor(clientUniverseArg: ClientUniverse, nameArg: string, passphraseArg: string) { constructor(clientUniverseArg: ClientUniverse, nameArg: string, passphraseArg: string) {
this.clientUniverse = clientUniverseArg; this.clientUniverseRef = clientUniverseArg;
this.name = nameArg; this.name = nameArg;
this.passphrase = passphraseArg; this.passphrase = passphraseArg;
} }
@ -55,6 +54,24 @@ export class ClientUniverseChannel implements interfaces.IUniverseChannel {
name: this.name, name: this.name,
passphrase: this.passphrase passphrase: this.passphrase
}; };
this.clientUniverse.smartsocketClient.serverCall(serverCallActionName, serverCallActionPayload); await this.clientUniverseRef.smartsocketClient.serverCall(serverCallActionName, serverCallActionPayload);
}
/**
* sends a message towards the server
* @param messageArg
*/
public async sendMessage(messageArg: interfaces.IMessageCreator) {
await this.clientUniverseRef.checkConnection();
const universeMessageToSend: interfaces.IUniverseMessage = {
id: plugins.smartunique.shortId(),
timestamp: Date.now(),
passphrase: this.passphrase,
targetChannelName: this.name,
messageText: messageArg.messageText,
payload: messageArg.payload,
payloadStringType: messageArg.payloadStringType
};
await this.clientUniverseRef.smartsocketClient.serverCall('processMessage', universeMessageToSend);
} }
} }

View File

@ -6,7 +6,10 @@ export class ClientUniverseMessage implements interfaces.IUniverseMessage {
// ====== // ======
// STATIC // STATIC
// ====== // ======
public static createMessageFromPayload(messageDescriptor: interfaces.IUniverseMessage) {} public static createMessageFromMessageDescriptor(messageDescriptor: interfaces.IUniverseMessage) {
const clientuniverseMessage = new ClientUniverseMessage(messageDescriptor);
return clientuniverseMessage;
}
// ======== // ========
// INSTANCE // INSTANCE
@ -23,11 +26,14 @@ export class ClientUniverseMessage implements interfaces.IUniverseMessage {
public payloadStringType; public payloadStringType;
public targetChannelName: string; public targetChannelName: string;
constructor(messageArg: interfaces.IUniverseMessage, payloadArg) { constructor(messageArg: interfaces.IUniverseMessage) {
for (const key of Object.keys(messageArg)) { for (const key of Object.keys(messageArg)) {
this[key] = messageArg[key]; this[key] = messageArg[key];
} }
} }
/**
* gets json for payload
*/
getAsJsonForPayload() {} getAsJsonForPayload() {}
} }

View File

@ -34,7 +34,7 @@ export class Universe {
constructor(optionsArg: ISmartUniverseConstructorOptions) { constructor(optionsArg: ISmartUniverseConstructorOptions) {
this.options = optionsArg; this.options = optionsArg;
this.universeCache = new UniverseCache(this.options.messageExpiryInMilliseconds); this.universeCache = new UniverseCache(this, this.options.messageExpiryInMilliseconds);
} }
/** /**
@ -60,7 +60,7 @@ export class Universe {
* adds a channel to the Universe * adds a channel to the Universe
*/ */
public async addChannel(nameArg: string, passphraseArg: string) { public async addChannel(nameArg: string, passphraseArg: string) {
const newChannel = UniverseChannel.createChannel(this.universeCache, nameArg, passphraseArg); const newChannel = UniverseChannel.createChannel(this, nameArg, passphraseArg);
} }
/** /**
@ -89,7 +89,7 @@ export class Universe {
// add the role to smartsocket // add the role to smartsocket
this.smartsocket.addSocketRoles([ClientRole]); this.smartsocket.addSocketRoles([ClientRole]);
const SubscriptionSocketFunction = new plugins.smartsocket.SocketFunction({ const socketFunctionSubscription = new plugins.smartsocket.SocketFunction({
allowedRoles: [ClientRole], // there is only one client role, Authentication happens on another level allowedRoles: [ClientRole], // there is only one client role, Authentication happens on another level
funcName: 'channelSubscription', funcName: 'channelSubscription',
funcDef: async ( funcDef: async (
@ -98,12 +98,11 @@ export class Universe {
) => { ) => {
// run in "this context" of this class // run in "this context" of this class
await (async () => { await (async () => {
// TODO: properly add the connection
const universeConnection = new UniverseConnection({ const universeConnection = new UniverseConnection({
socketConnection: socketConnectionArg, socketConnection: socketConnectionArg,
authenticationRequests: [] authenticationRequests: [dataArg]
}); });
await UniverseConnection.addConnectionToCache(this.universeCache, universeConnection); await UniverseConnection.addConnectionToCache(this, universeConnection);
return { return {
'subscription status': 'success' 'subscription status': 'success'
}; };
@ -111,7 +110,7 @@ export class Universe {
} }
}); });
const ProcessMessageSocketFunction = new plugins.smartsocket.SocketFunction({ const socketFunctionProcessMessage = new plugins.smartsocket.SocketFunction({
allowedRoles: [ClientRole], // there is only one client role, Authentication happens on another level allowedRoles: [ClientRole], // there is only one client role, Authentication happens on another level
funcName: 'processMessage', funcName: 'processMessage',
funcDef: async (dataArg: interfaces.IUniverseMessage, socketConnectionArg) => { funcDef: async (dataArg: interfaces.IUniverseMessage, socketConnectionArg) => {
@ -122,25 +121,19 @@ export class Universe {
socketConnectionArg socketConnectionArg
); );
if (universeConnection) { if (universeConnection) {
console.log('found UniverseConnection for socket'); plugins.smartlog.defaultLogger.log('ok', 'found UniverseConnection for socket for incoming message');
} else { } else {
console.log('universe client not yet present'); plugins.smartlog.defaultLogger.log('warn', 'found no Authorized channel for incoming message');
console.log('creating one now as send only'); return {
const universeConnectionInstance = new UniverseConnection({ error: 'You need to authenticate for a channel'
socketConnection: socketConnectionArg, };
authenticationRequests: []
});
await UniverseConnection.addConnectionToCache(
this.universeCache,
universeConnectionInstance
);
} }
const unauthenticatedMessage = UniverseMessage.createMessageFromPayload(dataArg); const unauthenticatedMessage = UniverseMessage.createMessageFromPayload(socketConnectionArg, dataArg);
const foundChannel = await UniverseChannel.authorizeAMessageForAChannel( const foundChannel = await UniverseChannel.authorizeAMessageForAChannel(
this.universeCache, this.universeCache,
unauthenticatedMessage unauthenticatedMessage
); );
if (foundChannel) { if (foundChannel && unauthenticatedMessage.authenticated) {
const authenticatedMessage = unauthenticatedMessage; const authenticatedMessage = unauthenticatedMessage;
await this.universeCache.addMessage(authenticatedMessage); await this.universeCache.addMessage(authenticatedMessage);
} }
@ -148,12 +141,16 @@ export class Universe {
} }
}); });
// add socket functions
this.smartsocket.addSocketFunction(socketFunctionSubscription);
this.smartsocket.addSocketFunction(socketFunctionProcessMessage);
// add smartsocket to the running smartexpress app // add smartsocket to the running smartexpress app
this.smartsocket.setExternalServer('smartexpress', this.smartexpressServer as any); this.smartsocket.setExternalServer('smartexpress', this.smartexpressServer as any);
// start everything // start everything
await this.smartexpressServer.start(); await this.smartexpressServer.start();
await this.smartsocket.start(); await this.smartsocket.start();
console.log('started universe'); plugins.smartlog.defaultLogger.log('success', 'started universe');
} }
/** /**

View File

@ -9,6 +9,7 @@ import { Observable, from } from 'rxjs';
import { filter } from 'rxjs/operators'; import { filter } from 'rxjs/operators';
import { rxjs } from '@pushrocks/smartrx'; import { rxjs } from '@pushrocks/smartrx';
import { UniverseConnection } from './smartuniverse.classes.universeconnection'; import { UniverseConnection } from './smartuniverse.classes.universeconnection';
import { Universe } from './smartuniverse.classes.universe';
/** /**
* universe store handles the creation, storage and retrieval of messages. * universe store handles the creation, storage and retrieval of messages.
@ -30,15 +31,22 @@ export class UniverseCache {
*/ */
public channelMap = new Objectmap<UniverseChannel>(); public channelMap = new Objectmap<UniverseChannel>();
/**
* stores all connections
*/
public connectionMap = new plugins.lik.Objectmap<UniverseConnection>(); public connectionMap = new plugins.lik.Objectmap<UniverseConnection>();
/** /**
* allows messages to be processed in a blacklist mode for further analysis * allows messages to be processed in a blacklist mode for further analysis
*/ */
public blackListChannel = new UniverseChannel(this, 'blacklist', 'nada'); public blackListChannel: UniverseChannel;
constructor(standardMessageExpiryArg: number) { public universeRef: Universe;
constructor(universeArg: Universe, standardMessageExpiryArg: number) {
this.universeRef = universeArg;
this.standardMessageExpiry = standardMessageExpiryArg; this.standardMessageExpiry = standardMessageExpiryArg;
this.blackListChannel = new UniverseChannel(this.universeRef, 'blacklist', 'nada');
} }
/** /**
@ -50,6 +58,9 @@ export class UniverseCache {
messageArg.setUniverseCache(this); messageArg.setUniverseCache(this);
UniverseChannel.authorizeAMessageForAChannel(this, messageArg); UniverseChannel.authorizeAMessageForAChannel(this, messageArg);
this.messageMap.add(messageArg); this.messageMap.add(messageArg);
messageArg.universeChannelList.forEach(universeChannel => {
universeChannel.pushToClients(messageArg);
});
} }
/** /**

View File

@ -1,7 +1,10 @@
import * as plugins from './smartuniverse.plugins'; import * as plugins from './smartuniverse.plugins';
import * as interfaces from './interfaces';
import { UniverseCache } from './smartuniverse.classes.universecache'; import { UniverseCache } from './smartuniverse.classes.universecache';
import { UniverseMessage } from './smartuniverse.classes.universemessage'; import { UniverseMessage } from './smartuniverse.classes.universemessage';
import { UniverseConnection } from './smartuniverse.classes.universeconnection';
import { Universe } from './smartuniverse.classes.universe';
/** /**
* enables messages to stay within a certain scope. * enables messages to stay within a certain scope.
@ -17,12 +20,12 @@ export class UniverseChannel {
* @param passphraseArg the secret thats used for a certain topic. * @param passphraseArg the secret thats used for a certain topic.
*/ */
public static createChannel( public static createChannel(
universeCacheArg: UniverseCache, universeArg: Universe,
channelNameArg: string, channelNameArg: string,
passphraseArg: string passphraseArg: string
) { ) {
const newChannel = new UniverseChannel(universeCacheArg, channelNameArg, passphraseArg); const newChannel = new UniverseChannel(universeArg, channelNameArg, passphraseArg);
universeCacheArg.channelMap.add(newChannel); universeArg.universeCache.channelMap.add(newChannel);
return newChannel; return newChannel;
} }
@ -58,16 +61,22 @@ export class UniverseChannel {
if (foundChannel) { if (foundChannel) {
universeMessageArg.authenticated = true; universeMessageArg.authenticated = true;
universeMessageArg.universeChannelList.add(foundChannel); universeMessageArg.universeChannelList.add(foundChannel);
console.log('message authorized'); plugins.smartlog.defaultLogger.log('ok', 'message authorized');
return foundChannel; return foundChannel;
} else { } else {
universeMessageArg.authenticated = false; universeMessageArg.authenticated = false;
universeMessageArg.universeChannelList.add(universeCacheArg.blackListChannel); universeMessageArg.universeChannelList.add(universeCacheArg.blackListChannel);
console.log('message not valid'); plugins.smartlog.defaultLogger.log('warn', 'message not valid');
return null; return null;
} }
} }
public static getUniverseChannelByName(universeRef: Universe, universeChannelName: string) {
return universeRef.universeCache.channelMap.find(channelArg => {
return channelArg.name === universeChannelName;
});
}
// ======== // ========
// INSTANCE // INSTANCE
// ======== // ========
@ -75,14 +84,15 @@ export class UniverseChannel {
* the name of the channel * the name of the channel
*/ */
public name: string; public name: string;
public universeCacheInstance: UniverseCache; public universeRef: Universe;
/** /**
* the passphrase for the channel * the passphrase for the channel
*/ */
public passphrase: string; public passphrase: string;
constructor(universeCacheArg: UniverseCache, channelNameArg: string, passphraseArg: string) { constructor(universeArg: Universe, channelNameArg: string, passphraseArg: string) {
this.universeRef = universeArg;
this.name = channelNameArg; this.name = channelNameArg;
this.passphrase = passphraseArg; this.passphrase = passphraseArg;
} }
@ -99,5 +109,29 @@ export class UniverseChannel {
); );
} }
public pushToClients(messageArg: UniverseMessage) {} /**
* pushes a message to clients
* @param messageArg
*/
public async pushToClients(messageArg: UniverseMessage) {
const universeConnectionsWithChannelAccess: UniverseConnection[] = [];
this.universeRef.universeCache.connectionMap.forEach(async socketConnection => {
if (socketConnection.authenticatedChannels.includes(this)) {
universeConnectionsWithChannelAccess.push(socketConnection);
}
});
for (const universeConnection of universeConnectionsWithChannelAccess) {
const smartsocket = universeConnection.socketConnection.smartsocketRef as plugins.smartsocket.Smartsocket;
const universeMessageToSend: interfaces.IUniverseMessage = {
id: messageArg.id,
timestamp: messageArg.timestamp,
passphrase: messageArg.passphrase,
targetChannelName: this.name,
messageText: messageArg.messageText,
payload: messageArg.payload,
payloadStringType: messageArg.payloadStringType
};
smartsocket.clientCall('processMessage', universeMessageToSend, universeConnection.socketConnection);
}
}
} }

View File

@ -2,6 +2,7 @@ import * as plugins from './smartuniverse.plugins';
import * as interfaces from './interfaces'; import * as interfaces from './interfaces';
import { UniverseChannel } from './smartuniverse.classes.universechannel'; import { UniverseChannel } from './smartuniverse.classes.universechannel';
import { UniverseCache } from './smartuniverse.classes.universecache'; import { UniverseCache } from './smartuniverse.classes.universecache';
import { Universe } from './smartuniverse.classes.universe';
/** /**
* represents a connection to the universe * represents a connection to the universe
@ -12,17 +13,19 @@ export class UniverseConnection {
* @param universeConnectionArg * @param universeConnectionArg
*/ */
public static async addConnectionToCache( public static async addConnectionToCache(
universeCache: UniverseCache, universeRef: Universe,
universeConnectionArg: UniverseConnection universeConnectionArg: UniverseConnection
) { ) {
let universeConnection = universeConnectionArg; let universeConnection = universeConnectionArg;
universeConnection = await UniverseConnection.deduplicateUniverseConnection( universeConnection = await UniverseConnection.deduplicateUniverseConnection(
universeCache, universeRef.universeCache,
universeConnection universeConnection
); );
universeConnection = await UniverseConnection.authenticateAuthenticationRequests( universeConnection = await UniverseConnection.authenticateAuthenticationRequests(
universeRef,
universeConnection universeConnection
); );
universeRef.universeCache.connectionMap.add(universeConnection);
} }
/** /**
@ -50,10 +53,16 @@ export class UniverseConnection {
/** /**
* authenticate AuthenticationRequests * authenticate AuthenticationRequests
*/ */
public static authenticateAuthenticationRequests( public static async authenticateAuthenticationRequests(
universeConnectionArg universeRef: Universe,
universeConnectionArg: UniverseConnection
): Promise<UniverseConnection> { ): Promise<UniverseConnection> {
// TODO: authenticate connections for (const authenticationRequest of universeConnectionArg.authenticationRequests) {
const universeChannelToAuthenticateAgainst = UniverseChannel.getUniverseChannelByName(universeRef, authenticationRequest.name);
if (universeChannelToAuthenticateAgainst.passphrase === authenticationRequest.passphrase) {
universeConnectionArg.authenticatedChannels.push(universeChannelToAuthenticateAgainst);
}
}
return universeConnectionArg; return universeConnectionArg;
} }
@ -64,7 +73,6 @@ export class UniverseConnection {
connectionArg1: UniverseConnection, connectionArg1: UniverseConnection,
connectionArg2: UniverseConnection connectionArg2: UniverseConnection
) { ) {
// TODO: merge connections
return connectionArg1; return connectionArg1;
} }
@ -87,7 +95,7 @@ export class UniverseConnection {
* the socketClient to ping * the socketClient to ping
*/ */
public socketConnection: plugins.smartsocket.SocketConnection; public socketConnection: plugins.smartsocket.SocketConnection;
public authenticationRequests = []; public authenticationRequests: interfaces.IServerCallSubscribeActionPayload[] = [];
public subscribedChannels: UniverseChannel[] = []; public subscribedChannels: UniverseChannel[] = [];
public authenticatedChannels: UniverseChannel[] = []; public authenticatedChannels: UniverseChannel[] = [];
public failedToJoinChannels: UniverseChannel[] = []; public failedToJoinChannels: UniverseChannel[] = [];
@ -104,7 +112,7 @@ export class UniverseConnection {
socketConnection: plugins.smartsocket.SocketConnection; socketConnection: plugins.smartsocket.SocketConnection;
authenticationRequests: interfaces.IServerCallSubscribeActionPayload[]; authenticationRequests: interfaces.IServerCallSubscribeActionPayload[];
}) { }) {
// TODO: check if this is correct this.authenticationRequests = optionsArg.authenticationRequests;
this.socketConnection = optionsArg.socketConnection; this.socketConnection = optionsArg.socketConnection;
} }
} }

View File

@ -7,27 +7,28 @@ import { Timer, TimeStamp } from '@pushrocks/smarttime';
import { Universe } from './smartuniverse.classes.universe'; import { Universe } from './smartuniverse.classes.universe';
import { UniverseChannel } from './smartuniverse.classes.universechannel'; import { UniverseChannel } from './smartuniverse.classes.universechannel';
import { UniverseCache } from './smartuniverse.classes.universecache'; import { UniverseCache } from './smartuniverse.classes.universecache';
import { IUniverseMessage } from './interfaces'; import { SocketConnection } from '@pushrocks/smartsocket';
/** /**
* represents a message within a universe * represents a message within a universe
* acts as a container to save message states like authentication status * acts as a container to save message states like authentication status
*/ */
export class UniverseMessage implements interfaces.IUniverseMessage { export class UniverseMessage implements interfaces.IUniverseMessage {
public static createMessageFromPayload(dataArg: interfaces.IUniverseMessage) { public static createMessageFromPayload(socketConnectionArg: SocketConnection, dataArg: interfaces.IUniverseMessage) {
return new UniverseMessage(dataArg); const universeMessageInstance = new UniverseMessage(dataArg);
universeMessageInstance.socketConnection = socketConnectionArg;
return universeMessageInstance;
} }
public id: string; public id: string;
public timestamp: number; public timestamp: number;
public smartTimestamp: TimeStamp; public smartTimestamp: TimeStamp;
public messageText: string; public messageText: string;
public passphrase: string; public passphrase: string;
public payload: any; public payload: any;
public payloadStringType; public payloadStringType;
public targetChannelName: string; public targetChannelName: string;
public socketConnection: SocketConnection;
/** /**
* the UniverseCache the message is attached to * the UniverseCache the message is attached to
@ -42,7 +43,7 @@ export class UniverseMessage implements interfaces.IUniverseMessage {
/** /**
* wether the message is authenticated * wether the message is authenticated
*/ */
public authenticated: boolean = null; public authenticated: boolean = false;
/** /**
* a destruction timer for this message * a destruction timer for this message
@ -54,7 +55,7 @@ export class UniverseMessage implements interfaces.IUniverseMessage {
* @param messageArg * @param messageArg
* @param attachedPayloadArg * @param attachedPayloadArg
*/ */
constructor(messageDescriptor: IUniverseMessage) { constructor(messageDescriptor: interfaces.IUniverseMessage) {
this.smartTimestamp = new TimeStamp(this.timestamp); this.smartTimestamp = new TimeStamp(this.timestamp);
this.messageText = messageDescriptor.messageText; this.messageText = messageDescriptor.messageText;
this.targetChannelName = messageDescriptor.targetChannelName; this.targetChannelName = messageDescriptor.targetChannelName;
@ -68,6 +69,10 @@ export class UniverseMessage implements interfaces.IUniverseMessage {
this.universeCache = universeCacheArg; this.universeCache = universeCacheArg;
} }
public setTargetChannel() {
}
public setDestructionTimer(selfdestructAfterArg: number) { public setDestructionTimer(selfdestructAfterArg: number) {
if (selfdestructAfterArg) { if (selfdestructAfterArg) {
this.destructionTimer = new Timer(selfdestructAfterArg); this.destructionTimer = new Timer(selfdestructAfterArg);
@ -86,7 +91,7 @@ export class UniverseMessage implements interfaces.IUniverseMessage {
* handles bad messages for further analysis * handles bad messages for further analysis
*/ */
public handleAsBadMessage() { public handleAsBadMessage() {
console.log('received a bad message'); plugins.smartlog.defaultLogger.log('warn', 'received a bad message');
} }
/** /**

View File

@ -9,6 +9,7 @@ import * as smarthash from '@pushrocks/smarthash';
import * as smartdelay from '@pushrocks/smartdelay'; import * as smartdelay from '@pushrocks/smartdelay';
import * as smartexpress from '@pushrocks/smartexpress'; import * as smartexpress from '@pushrocks/smartexpress';
import * as smartfile from '@pushrocks/smartfile'; import * as smartfile from '@pushrocks/smartfile';
import * as smartlog from '@pushrocks/smartlog';
import * as smartpromise from '@pushrocks/smartpromise'; import * as smartpromise from '@pushrocks/smartpromise';
import * as smartrequest from '@pushrocks/smartrequest'; import * as smartrequest from '@pushrocks/smartrequest';
import * as smartrx from '@pushrocks/smartrx'; import * as smartrx from '@pushrocks/smartrx';
@ -22,6 +23,7 @@ export {
smartdelay, smartdelay,
smartexpress, smartexpress,
smartfile, smartfile,
smartlog,
smartpromise, smartpromise,
smartrx, smartrx,
smartrequest, smartrequest,