Compare commits

..

8 Commits

Author SHA1 Message Date
7552dc1e9f 1.0.22 2018-05-28 12:07:26 +02:00
fe91459510 fix(core): update to transparent universe 2018-05-28 12:07:25 +02:00
0e0ffb7634 1.0.21 2018-05-26 13:44:32 +02:00
37bb052774 fix(UniverseMessage / UniverseChannel): better authentication for of messages for channels 2018-05-26 13:44:32 +02:00
3c7683d40e 1.0.20 2018-05-24 17:08:29 +02:00
c19f27e873 fix(dependencies): update 2018-05-24 17:08:28 +02:00
c1a03fec0f 1.0.19 2018-05-24 16:55:25 +02:00
8b650c5ea7 fix(UniverseChannel): improve channel handling 2018-05-24 16:55:24 +02:00
15 changed files with 241 additions and 494 deletions

View File

@ -3,7 +3,7 @@ image: hosttoday/ht-docker-node:npmci
cache: cache:
paths: paths:
- .yarn/ - .npmci_cache/
key: "$CI_BUILD_STAGE" key: "$CI_BUILD_STAGE"
stages: stages:
@ -26,8 +26,8 @@ mirror:
snyk: snyk:
stage: security stage: security
script: script:
- npmci command yarn global add snyk - npmci command npm install -g snyk
- npmci command yarn install --ignore-scripts - npmci command npm install --ignore-scripts
- npmci command snyk test - npmci command snyk test
tags: tags:
- docker - docker
@ -117,7 +117,7 @@ pages:
image: hosttoday/ht-docker-node:npmci image: hosttoday/ht-docker-node:npmci
stage: metadata stage: metadata
script: script:
- npmci command yarn global add npmpage - npmci command npm install -g npmpage
- npmci command npmpage - npmci command npmpage
tags: tags:
- docker - docker

377
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "@pushrocks/smartuniverse", "name": "@pushrocks/smartuniverse",
"version": "1.0.18", "version": "1.0.22",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
@ -203,11 +203,6 @@
} }
} }
}, },
"@types/yargs": {
"version": "10.0.2",
"resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-10.0.2.tgz",
"integrity": "sha512-VbsIazac1gy20qTjEZVgDUhs8uuVmGbFkSGcdHpcMoXSC4+0vn/PRHz9YBqpgxKwUi8qoxf3eHff07w7aKNBOg=="
},
"accepts": { "accepts": {
"version": "1.3.5", "version": "1.3.5",
"resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.5.tgz", "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.5.tgz",
@ -227,11 +222,6 @@
"resolved": "https://registry.npmjs.org/ansi-256-colors/-/ansi-256-colors-1.1.0.tgz", "resolved": "https://registry.npmjs.org/ansi-256-colors/-/ansi-256-colors-1.1.0.tgz",
"integrity": "sha1-kQ3lDvzHwJ49gvL4er1rcAwYgYo=" "integrity": "sha1-kQ3lDvzHwJ49gvL4er1rcAwYgYo="
}, },
"ansi-regex": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz",
"integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg="
},
"ansi-styles": { "ansi-styles": {
"version": "3.2.1", "version": "3.2.1",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz",
@ -380,11 +370,6 @@
"resolved": "https://registry.npmjs.org/callsite/-/callsite-1.0.0.tgz", "resolved": "https://registry.npmjs.org/callsite/-/callsite-1.0.0.tgz",
"integrity": "sha1-KAOY5dZkvXQDi28JBRU+borxvCA=" "integrity": "sha1-KAOY5dZkvXQDi28JBRU+borxvCA="
}, },
"camelcase": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-4.1.0.tgz",
"integrity": "sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0="
},
"camelize": { "camelize": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/camelize/-/camelize-1.0.0.tgz", "resolved": "https://registry.npmjs.org/camelize/-/camelize-1.0.0.tgz",
@ -448,16 +433,6 @@
"resolved": "https://registry.npmjs.org/cli-spinners/-/cli-spinners-1.3.1.tgz", "resolved": "https://registry.npmjs.org/cli-spinners/-/cli-spinners-1.3.1.tgz",
"integrity": "sha512-1QL4544moEsDVH9T/l6Cemov/37iv1RtoKf7NJ04A60+4MREXNfx/QvavbH6QoGdsD4N4Mwy49cmaINR/o2mdg==" "integrity": "sha512-1QL4544moEsDVH9T/l6Cemov/37iv1RtoKf7NJ04A60+4MREXNfx/QvavbH6QoGdsD4N4Mwy49cmaINR/o2mdg=="
}, },
"cliui": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/cliui/-/cliui-4.1.0.tgz",
"integrity": "sha512-4FG+RSG9DL7uEwRUZXZn3SS34DiDPfzP0VOiEwtUWlE+AR2EIg+hSyvrIgUUfhdgR/UkAeW2QHgeP+hWrXs7jQ==",
"requires": {
"string-width": "^2.1.1",
"strip-ansi": "^4.0.0",
"wrap-ansi": "^2.0.0"
}
},
"clone": { "clone": {
"version": "2.1.1", "version": "2.1.1",
"resolved": "https://registry.npmjs.org/clone/-/clone-2.1.1.tgz", "resolved": "https://registry.npmjs.org/clone/-/clone-2.1.1.tgz",
@ -483,11 +458,6 @@
"readable-stream": "^2.3.5" "readable-stream": "^2.3.5"
} }
}, },
"code-point-at": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz",
"integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c="
},
"color-convert": { "color-convert": {
"version": "1.9.1", "version": "1.9.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz",
@ -560,16 +530,6 @@
"vary": "^1" "vary": "^1"
} }
}, },
"cross-spawn": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz",
"integrity": "sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk=",
"requires": {
"lru-cache": "^4.0.1",
"shebang-command": "^1.2.0",
"which": "^1.2.9"
}
},
"dasherize": { "dasherize": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/dasherize/-/dasherize-2.0.0.tgz", "resolved": "https://registry.npmjs.org/dasherize/-/dasherize-2.0.0.tgz",
@ -583,11 +543,6 @@
"ms": "2.0.0" "ms": "2.0.0"
} }
}, },
"decamelize": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz",
"integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA="
},
"deep-eql": { "deep-eql": {
"version": "3.0.1", "version": "3.0.1",
"resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz", "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz",
@ -764,20 +719,6 @@
"resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
"integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=" "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc="
}, },
"execa": {
"version": "0.7.0",
"resolved": "https://registry.npmjs.org/execa/-/execa-0.7.0.tgz",
"integrity": "sha1-lEvs00zEHuMqY6n68nrVpl/Fl3c=",
"requires": {
"cross-spawn": "^5.0.1",
"get-stream": "^3.0.0",
"is-stream": "^1.1.0",
"npm-run-path": "^2.0.0",
"p-finally": "^1.0.0",
"signal-exit": "^3.0.0",
"strip-eof": "^1.0.0"
}
},
"expect-ct": { "expect-ct": {
"version": "0.1.1", "version": "0.1.1",
"resolved": "https://registry.npmjs.org/expect-ct/-/expect-ct-0.1.1.tgz", "resolved": "https://registry.npmjs.org/expect-ct/-/expect-ct-0.1.1.tgz",
@ -927,14 +868,6 @@
} }
} }
}, },
"find-up": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz",
"integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=",
"requires": {
"locate-path": "^2.0.0"
}
},
"first-chunk-stream": { "first-chunk-stream": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/first-chunk-stream/-/first-chunk-stream-2.0.0.tgz", "resolved": "https://registry.npmjs.org/first-chunk-stream/-/first-chunk-stream-2.0.0.tgz",
@ -983,22 +916,12 @@
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
"integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A=="
}, },
"get-caller-file": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-1.0.2.tgz",
"integrity": "sha1-9wLmMSfn4jHBYKgMFVSstw1QR+U="
},
"get-func-name": { "get-func-name": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz",
"integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=", "integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=",
"dev": true "dev": true
}, },
"get-stream": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz",
"integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ="
},
"glob": { "glob": {
"version": "7.1.2", "version": "7.1.2",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz",
@ -1147,11 +1070,6 @@
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
"integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4="
}, },
"invert-kv": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-1.0.0.tgz",
"integrity": "sha1-EEqOSqym09jNFXqO+L+rLXo//bY="
},
"ipaddr.js": { "ipaddr.js": {
"version": "1.6.0", "version": "1.6.0",
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.6.0.tgz", "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.6.0.tgz",
@ -1167,16 +1085,6 @@
"resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.1.tgz", "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.1.tgz",
"integrity": "sha1-mqIOtq7rv/d/vTPnTKAbM1gdOhY=" "integrity": "sha1-mqIOtq7rv/d/vTPnTKAbM1gdOhY="
}, },
"is-fullwidth-code-point": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz",
"integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8="
},
"is-promise": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz",
"integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o="
},
"is-regex": { "is-regex": {
"version": "1.0.4", "version": "1.0.4",
"resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.4.tgz", "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.4.tgz",
@ -1185,11 +1093,6 @@
"has": "^1.0.1" "has": "^1.0.1"
} }
}, },
"is-stream": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz",
"integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ="
},
"is-symbol": { "is-symbol": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.1.tgz", "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.1.tgz",
@ -1205,11 +1108,6 @@
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
"integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE="
}, },
"isexe": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
"integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA="
},
"js-yaml": { "js-yaml": {
"version": "3.11.0", "version": "3.11.0",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.11.0.tgz", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.11.0.tgz",
@ -1227,14 +1125,6 @@
"graceful-fs": "^4.1.6" "graceful-fs": "^4.1.6"
} }
}, },
"lcid": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/lcid/-/lcid-1.0.0.tgz",
"integrity": "sha1-MIrMr6C8SDo4Z7S28rlQYlHRuDU=",
"requires": {
"invert-kv": "^1.0.0"
}
},
"leakage": { "leakage": {
"version": "0.3.0", "version": "0.3.0",
"resolved": "https://registry.npmjs.org/leakage/-/leakage-0.3.0.tgz", "resolved": "https://registry.npmjs.org/leakage/-/leakage-0.3.0.tgz",
@ -1267,15 +1157,6 @@
"symbol-tree": "^3.2.2" "symbol-tree": "^3.2.2"
} }
}, },
"locate-path": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz",
"integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=",
"requires": {
"p-locate": "^2.0.0",
"path-exists": "^3.0.0"
}
},
"lodash": { "lodash": {
"version": "4.17.10", "version": "4.17.10",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz",
@ -1368,15 +1249,6 @@
"chalk": "^2.0.1" "chalk": "^2.0.1"
} }
}, },
"lru-cache": {
"version": "4.1.3",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.3.tgz",
"integrity": "sha512-fFEhvcgzuIoJVUF8fYr5KR0YqxD238zgObTps31YdADwPPAp82a4M8TrckkWyx7ekNlf9aBcVn81cFwwXngrJA==",
"requires": {
"pseudomap": "^1.0.2",
"yallist": "^2.1.2"
}
},
"make-error": { "make-error": {
"version": "1.3.4", "version": "1.3.4",
"resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.4.tgz", "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.4.tgz",
@ -1388,14 +1260,6 @@
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
"integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=" "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g="
}, },
"mem": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/mem/-/mem-1.1.0.tgz",
"integrity": "sha1-Xt1StIXKHZAP5kiVUFOZoN+kX3Y=",
"requires": {
"mimic-fn": "^1.0.0"
}
},
"memwatch-next": { "memwatch-next": {
"version": "0.3.0", "version": "0.3.0",
"resolved": "https://registry.npmjs.org/memwatch-next/-/memwatch-next-0.3.0.tgz", "resolved": "https://registry.npmjs.org/memwatch-next/-/memwatch-next-0.3.0.tgz",
@ -1508,19 +1372,6 @@
"typings-global": "^1.0.6" "typings-global": "^1.0.6"
} }
}, },
"npm-run-path": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz",
"integrity": "sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8=",
"requires": {
"path-key": "^2.0.0"
}
},
"number-is-nan": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz",
"integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0="
},
"object-assign": { "object-assign": {
"version": "4.1.1", "version": "4.1.1",
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
@ -1585,42 +1436,6 @@
"resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz",
"integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=" "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M="
}, },
"os-locale": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/os-locale/-/os-locale-2.1.0.tgz",
"integrity": "sha512-3sslG3zJbEYcaC4YVAvDorjGxc7tv6KVATnLPZONiljsUncvihe9BQoVCEs0RZ1kmf4Hk9OBqlZfJZWI4GanKA==",
"requires": {
"execa": "^0.7.0",
"lcid": "^1.0.0",
"mem": "^1.1.0"
}
},
"p-finally": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz",
"integrity": "sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4="
},
"p-limit": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.2.0.tgz",
"integrity": "sha512-Y/OtIaXtUPr4/YpMv1pCL5L5ed0rumAaAeBSj12F+bSlMdys7i8oQF/GUJmfpTS/QoaRrS/k6pma29haJpsMng==",
"requires": {
"p-try": "^1.0.0"
}
},
"p-locate": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz",
"integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=",
"requires": {
"p-limit": "^1.1.0"
}
},
"p-try": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz",
"integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M="
},
"parseqs": { "parseqs": {
"version": "0.0.5", "version": "0.0.5",
"resolved": "https://registry.npmjs.org/parseqs/-/parseqs-0.0.5.tgz", "resolved": "https://registry.npmjs.org/parseqs/-/parseqs-0.0.5.tgz",
@ -1642,21 +1457,11 @@
"resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.2.tgz", "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.2.tgz",
"integrity": "sha1-/CidTtiZMRlGDBViUyYs3I3mW/M=" "integrity": "sha1-/CidTtiZMRlGDBViUyYs3I3mW/M="
}, },
"path-exists": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz",
"integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU="
},
"path-is-absolute": { "path-is-absolute": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18="
}, },
"path-key": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz",
"integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A="
},
"path-to-regexp": { "path-to-regexp": {
"version": "0.1.7", "version": "0.1.7",
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz",
@ -1698,11 +1503,6 @@
"ipaddr.js": "1.6.0" "ipaddr.js": "1.6.0"
} }
}, },
"pseudomap": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz",
"integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM="
},
"q": { "q": {
"version": "1.5.1", "version": "1.5.1",
"resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz", "resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz",
@ -1758,16 +1558,6 @@
"resolved": "https://registry.npmjs.org/replace-ext/-/replace-ext-1.0.0.tgz", "resolved": "https://registry.npmjs.org/replace-ext/-/replace-ext-1.0.0.tgz",
"integrity": "sha1-3mMSg3P8v3w8z6TeWkgMRaZ5WOs=" "integrity": "sha1-3mMSg3P8v3w8z6TeWkgMRaZ5WOs="
}, },
"require-directory": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz",
"integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I="
},
"require-main-filename": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-1.0.1.tgz",
"integrity": "sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE="
},
"require-reload": { "require-reload": {
"version": "0.2.2", "version": "0.2.2",
"resolved": "https://registry.npmjs.org/require-reload/-/require-reload-0.2.2.tgz", "resolved": "https://registry.npmjs.org/require-reload/-/require-reload-0.2.2.tgz",
@ -1838,29 +1628,11 @@
"send": "0.16.2" "send": "0.16.2"
} }
}, },
"set-blocking": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz",
"integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc="
},
"setprototypeof": { "setprototypeof": {
"version": "1.1.0", "version": "1.1.0",
"resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.0.tgz", "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.0.tgz",
"integrity": "sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ==" "integrity": "sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ=="
}, },
"shebang-command": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz",
"integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=",
"requires": {
"shebang-regex": "^1.0.0"
}
},
"shebang-regex": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz",
"integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM="
},
"shortid": { "shortid": {
"version": "2.2.8", "version": "2.2.8",
"resolved": "https://registry.npmjs.org/shortid/-/shortid-2.2.8.tgz", "resolved": "https://registry.npmjs.org/shortid/-/shortid-2.2.8.tgz",
@ -1885,21 +1657,6 @@
"chai-string": "^1.4.0" "chai-string": "^1.4.0"
} }
}, },
"smartcli": {
"version": "2.0.12",
"resolved": "https://registry.npmjs.org/smartcli/-/smartcli-2.0.12.tgz",
"integrity": "sha512-oeHfzFJ6RRz7yNQbwNIXfnXMq71XIzuD8pc0aURxA883ocsPLtyLSfYkhZk7DjzIFb8LpZRge0cFO3Dk7frGDw==",
"requires": {
"@types/yargs": "^10.0.1",
"beautylog": "^6.1.10",
"lik": "^2.0.2",
"rxjs": "^5.4.3",
"smartparam": "1.0.2",
"smartq": "^1.1.6",
"typings-global": "^1.0.20",
"yargs": "^11.0.0"
}
},
"smartdelay": { "smartdelay": {
"version": "1.0.4", "version": "1.0.4",
"resolved": "https://registry.npmjs.org/smartdelay/-/smartdelay-1.0.4.tgz", "resolved": "https://registry.npmjs.org/smartdelay/-/smartdelay-1.0.4.tgz",
@ -1961,18 +1718,6 @@
"vinyl-file": "^3.0.0" "vinyl-file": "^3.0.0"
} }
}, },
"smartparam": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/smartparam/-/smartparam-1.0.2.tgz",
"integrity": "sha512-Q09m98X6+WG9q0Wpj6LXXSqGdYUItLAsj5ypJ8pRkGtry2V4zZzhimv4xviViLIfrgIBn5uTfbjNU0is7+WRTA==",
"requires": {
"beautylog": "6.1.10",
"is-promise": "^2.1.0",
"minimatch": "^3.0.4",
"smartq": "^1.1.6",
"typings-global": "^1.0.20"
}
},
"smartpath": { "smartpath": {
"version": "3.2.8", "version": "3.2.8",
"resolved": "https://registry.npmjs.org/smartpath/-/smartpath-3.2.8.tgz", "resolved": "https://registry.npmjs.org/smartpath/-/smartpath-3.2.8.tgz",
@ -2148,15 +1893,6 @@
"resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz",
"integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=" "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow="
}, },
"string-width": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz",
"integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==",
"requires": {
"is-fullwidth-code-point": "^2.0.0",
"strip-ansi": "^4.0.0"
}
},
"string_decoder": { "string_decoder": {
"version": "1.1.1", "version": "1.1.1",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
@ -2165,14 +1901,6 @@
"safe-buffer": "~5.1.0" "safe-buffer": "~5.1.0"
} }
}, },
"strip-ansi": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz",
"integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=",
"requires": {
"ansi-regex": "^3.0.0"
}
},
"strip-bom": { "strip-bom": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-2.0.0.tgz", "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-2.0.0.tgz",
@ -2198,11 +1926,6 @@
"strip-bom": "^2.0.0" "strip-bom": "^2.0.0"
} }
}, },
"strip-eof": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz",
"integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8="
},
"supports-color": { "supports-color": {
"version": "5.4.0", "version": "5.4.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz",
@ -2249,9 +1972,9 @@
"integrity": "sha1-F+bBH3PdTz10zaek/zI46a2b+JA=" "integrity": "sha1-F+bBH3PdTz10zaek/zI46a2b+JA="
}, },
"ts-node": { "ts-node": {
"version": "6.0.3", "version": "6.0.5",
"resolved": "https://registry.npmjs.org/ts-node/-/ts-node-6.0.3.tgz", "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-6.0.5.tgz",
"integrity": "sha512-ARaOMNFEPKg2ZuC1qJddFvHxHNFVckR0g9xLxMIoMqSSIkDc8iS4/LoV53EdDWWNq2FGwqcEf0bVVGJIWpsznw==", "integrity": "sha512-iNhWu2hli9/1p9PGLJ/4OZS+NR0IVEVk63KCrH3qa7jJZxXa+oPheBj5JyM8tuQM9RkBpw1PrNUEUPJR9wTGDw==",
"dev": true, "dev": true,
"requires": { "requires": {
"arrify": "^1.0.0", "arrify": "^1.0.0",
@ -2354,61 +2077,6 @@
"vinyl": "^2.0.1" "vinyl": "^2.0.1"
} }
}, },
"which": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz",
"integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==",
"requires": {
"isexe": "^2.0.0"
}
},
"which-module": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz",
"integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho="
},
"wrap-ansi": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz",
"integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=",
"requires": {
"string-width": "^1.0.1",
"strip-ansi": "^3.0.1"
},
"dependencies": {
"ansi-regex": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz",
"integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8="
},
"is-fullwidth-code-point": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz",
"integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=",
"requires": {
"number-is-nan": "^1.0.0"
}
},
"string-width": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz",
"integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=",
"requires": {
"code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0",
"strip-ansi": "^3.0.0"
}
},
"strip-ansi": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz",
"integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=",
"requires": {
"ansi-regex": "^2.0.0"
}
}
}
},
"wrappy": { "wrappy": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
@ -2439,43 +2107,6 @@
"resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz",
"integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=" "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68="
}, },
"y18n": {
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/y18n/-/y18n-3.2.1.tgz",
"integrity": "sha1-bRX7qITAhnnA136I53WegR4H+kE="
},
"yallist": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz",
"integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI="
},
"yargs": {
"version": "11.0.0",
"resolved": "https://registry.npmjs.org/yargs/-/yargs-11.0.0.tgz",
"integrity": "sha512-Rjp+lMYQOWtgqojx1dEWorjCofi1YN7AoFvYV7b1gx/7dAAeuI4kN5SZiEvr0ZmsZTOpDRcCqrpI10L31tFkBw==",
"requires": {
"cliui": "^4.0.0",
"decamelize": "^1.1.1",
"find-up": "^2.1.0",
"get-caller-file": "^1.0.1",
"os-locale": "^2.0.0",
"require-directory": "^2.1.1",
"require-main-filename": "^1.0.1",
"set-blocking": "^2.0.0",
"string-width": "^2.0.0",
"which-module": "^2.0.0",
"y18n": "^3.2.1",
"yargs-parser": "^9.0.2"
}
},
"yargs-parser": {
"version": "9.0.2",
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-9.0.2.tgz",
"integrity": "sha1-nM9qQ0YP5O1Aqbto9I1DuKaMwHc=",
"requires": {
"camelcase": "^4.1.0"
}
},
"yeast": { "yeast": {
"version": "0.1.2", "version": "0.1.2",
"resolved": "https://registry.npmjs.org/yeast/-/yeast-0.1.2.tgz", "resolved": "https://registry.npmjs.org/yeast/-/yeast-0.1.2.tgz",

View File

@ -1,6 +1,6 @@
{ {
"name": "@pushrocks/smartuniverse", "name": "@pushrocks/smartuniverse",
"version": "1.0.18", "version": "1.0.22",
"private": true, "private": true,
"description": "messaging service for your micro services", "description": "messaging service for your micro services",
"main": "dist/index.js", "main": "dist/index.js",
@ -13,16 +13,17 @@
"format": "(gitzone format)" "format": "(gitzone format)"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^9.6.0", "@types/node": "^9.6.18",
"tapbundle": "^2.0.0", "tapbundle": "^2.0.0",
"ts-node": "^6.0.3", "ts-node": "^6.0.5",
"typescript": "^2.8.3" "typescript": "^2.8.3"
}, },
"peerDependencies": {
"rxjs": "*"
},
"dependencies": { "dependencies": {
"lik": "^2.0.5", "lik": "^2.0.5",
"nodehash": "^1.0.4", "nodehash": "^1.0.4",
"rxjs": "^5.5.8",
"smartcli": "^2.0.12",
"smartdelay": "^1.0.4", "smartdelay": "^1.0.4",
"smartexpress": "^1.0.21", "smartexpress": "^1.0.21",
"smartfile": "^4.2.28", "smartfile": "^4.2.28",

View File

@ -5,8 +5,8 @@ import * as smartuniverse from '../ts/index';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
let testUniverse: smartuniverse.Universe; let testUniverse: smartuniverse.Universe;
let testUniverseClient: smartuniverse.UniverseClient; let testUniverseClient: smartuniverse.ClientUniverse;
let testMessageObservable: Observable<smartuniverse.UniverseMessage>; let testClientChannel: smartuniverse.ClientUniverseChannel;
tap.test('first test', async () => { tap.test('first test', async () => {
testUniverse = new smartuniverse.Universe({ testUniverse = new smartuniverse.Universe({
@ -20,10 +20,19 @@ tap.test('add a message to the SmartUniverse', async () => {
// testing message handling // testing message handling
tap.test('create smartuniverse client', async () => { tap.test('create smartuniverse client', async () => {
testUniverseClient = new smartuniverse.UniverseClient({ testUniverseClient = new smartuniverse.ClientUniverse({
serverAddress: 'http://localhost:8765' serverAddress: 'http://localhost:8765'
}); });
expect(testUniverseClient).to.be.instanceof(smartuniverse.UniverseClient); expect(testUniverseClient).to.be.instanceof(smartuniverse.ClientUniverse);
});
tap.test('should add a channel to the universe', async () => {
await testUniverse.addChannel('testChannel', 'testPassword');
});
tap.test('should get a observable correctly', async () => {
testClientChannel = await testUniverseClient.getChannel('testChannel');
expect(testClientChannel).to.be.instanceof(smartuniverse.ClientUniverseChannel);
}); });
tap.test('should send a message correctly', async () => { tap.test('should send a message correctly', async () => {
@ -32,10 +41,6 @@ tap.test('should send a message correctly', async () => {
}); });
}); });
tap.test('should get a observable correctly', async () => {
testMessageObservable = testUniverseClient.getMessageObservable();
});
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 () => {

View File

@ -1,3 +1,10 @@
// Client classes
export * from './smartuniverse.classes.clientuniverse';
export * from './smartuniverse.classes.clientuniversechannel';
// Server classes
export * from './smartuniverse.classes.universe'; export * from './smartuniverse.classes.universe';
export * from './smartuniverse.classes.universeclient'; export * from './smartuniverse.classes.universecache';
export * from './smartuniverse.classes.universechannel';
export * from './smartuniverse.classes.universemessage'; export * from './smartuniverse.classes.universemessage';
export * from './smartuniverse.interfaces';

View File

@ -1,14 +1,16 @@
import * as plugins from './smartuniverse.plugins'; import * as plugins from './smartuniverse.plugins';
import { Objectmap } from 'lik';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { Smartsocket, SmartsocketClient } from 'smartsocket'; import { Smartsocket, SmartsocketClient } from 'smartsocket';
import * as url from 'url'; import * as url from 'url';
import { import {
ClientUniverseChannel,
IServerGetMessagesRequestBody, IServerGetMessagesRequestBody,
IServerPutMessageRequestBody IServerPutMessageRequestBody,
} from './smartuniverse.classes.universe'; UniverseMessage
import { UniverseMessage } from './smartuniverse.classes.universemessage'; } from './';
export interface IClientOptions { export interface IClientOptions {
serverAddress: string; serverAddress: string;
@ -18,10 +20,12 @@ export interface IClientOptions {
* this class is for client side only!!! * this class is for client side only!!!
* allows connecting to a universe server * allows connecting to a universe server
*/ */
export class UniverseClient { export class ClientUniverse {
public options; public options;
private socketClient: plugins.smartsocket.SmartsocketClient; public socketClient: plugins.smartsocket.SmartsocketClient;
private observableIntake: plugins.smartrx.ObservableIntake<UniverseMessage>; public observableIntake: plugins.smartrx.ObservableIntake<UniverseMessage>;
public channelCache = new Objectmap<ClientUniverseChannel>();
constructor(optionsArg: IClientOptions) { constructor(optionsArg: IClientOptions) {
this.options = optionsArg; this.options = optionsArg;
@ -38,7 +42,21 @@ export class UniverseClient {
}); });
} }
public getMessageObservable() { public async getChannel(channelName: string): Promise<ClientUniverseChannel> {
await this.checkConnection();
const clientUniverseChannel = await ClientUniverseChannel.createClientUniverseChannel(
this,
channelName
);
this.channelCache.add(clientUniverseChannel);
return clientUniverseChannel;
}
public close() {
this.socketClient.disconnect();
}
private async checkConnection() {
if (!this.socketClient && !this.observableIntake) { if (!this.socketClient && !this.observableIntake) {
const parsedURL = url.parse(this.options.serverAddress); const parsedURL = url.parse(this.options.serverAddress);
this.socketClient = new SmartsocketClient({ this.socketClient = new SmartsocketClient({
@ -51,10 +69,5 @@ export class UniverseClient {
this.observableIntake = new plugins.smartrx.ObservableIntake(); this.observableIntake = new plugins.smartrx.ObservableIntake();
this.socketClient.connect(); this.socketClient.connect();
} }
return this.observableIntake.observable;
}
public close() {
this.socketClient.disconnect();
} }
} }

View File

@ -0,0 +1,34 @@
import * as plugins from './smartuniverse.plugins';
import { ClientUniverse, IUniverseChannel } from './';
export class ClientUniverseChannel implements IUniverseChannel {
// ======
// STATIC
// ======
public static async createClientUniverseChannel(
clientUniverseArg: ClientUniverse,
channelName: string
): Promise<ClientUniverseChannel> {
const clientChannel = new ClientUniverseChannel(clientUniverseArg);
await clientChannel.transmitSubscription();
return clientChannel;
}
// ========
// INSTANCE
// ========
public clientUniverse: ClientUniverse;
constructor(clientUniverseArg: ClientUniverse) {
this.clientUniverse = clientUniverseArg;
}
/**
* tells the universe about this instances interest into a channel
*/
public async transmitSubscription() {
this.clientUniverse.socketClient;
}
}

View File

@ -0,0 +1,15 @@
import * as plugins from './smartuniverse.plugins';
import { IUniverseMessage } from './';
export class ClientUniverseMessage implements IUniverseMessage {
// ======
// STATIC
// ======
createMessage(messageArg: string, payloadArg: any) {}
// ========
// INSTANCE
// ========
constructor(messageArg, payloadArg) {}
}

View File

@ -1,9 +1,7 @@
import * as plugins from './smartuniverse.plugins'; import * as plugins from './smartuniverse.plugins';
import { Handler, Route, Server } from 'smartexpress'; import { Handler, Route, Server } from 'smartexpress';
import { UniverseChannel } from './smartuniverse.classes.universechannel'; import { UniverseCache, UniverseChannel, UniverseMessage } from './';
import { UniverseMessage } from './smartuniverse.classes.universemessage';
import { UniverseStore } from './smartuniverse.classes.universestore';
import * as paths from './smartuniverse.paths'; import * as paths from './smartuniverse.paths';
@ -32,7 +30,7 @@ export interface IServerPutMessageRequestBody {
*/ */
export class Universe { export class Universe {
// subinstances // subinstances
public universeStore: UniverseStore; public universeCache: UniverseCache;
// options // options
private options: ISmartUniverseConstructorOptions; private options: ISmartUniverseConstructorOptions;
@ -54,7 +52,15 @@ export class Universe {
constructor(optionsArg: ISmartUniverseConstructorOptions) { constructor(optionsArg: ISmartUniverseConstructorOptions) {
this.options = optionsArg; this.options = optionsArg;
this.universeStore = new UniverseStore(this.options.messageExpiryInMilliseconds); this.universeCache = new UniverseCache(this.options.messageExpiryInMilliseconds);
}
/**
* adds a channel to the Universe
*/
public async addChannel(nameArg: string, passphraseArg: string) {
const newChannel = new UniverseChannel(this.universeCache, nameArg, passphraseArg);
this.universeCache.channelMap.add(newChannel);
} }
/** /**
@ -68,41 +74,13 @@ export class Universe {
port: portArg port: portArg
}); });
// message handling
// adds messages
const addMessageHandler = new Handler('PUT', request => {
const requestBody: IServerPutMessageRequestBody = request.body;
const message = new UniverseMessage(requestBody.message, requestBody.channel, requestBody.passphrase, requestBody.payload);
this.universeStore.addMessage(message);
console.log(requestBody);
return true;
});
// gets messages
const readMessageHandler = new Handler('GET', request => {
const done = plugins.smartq.defer<UniverseMessage[]>();
const requestBody = request.body;
const messageObservable = this.universeStore.readMessagesYoungerThan(requestBody.since);
messageObservable.toArray().subscribe(universeMessageArrayArg => {
done.resolve(universeMessageArrayArg);
});
return done.promise;
});
// create new Route for messages
const messageRoute = new Route(this.smartexpressServer, 'message');
messageRoute.addHandler(addMessageHandler);
messageRoute.addHandler(readMessageHandler);
const leaderElectionRoute = new Route(this.smartexpressServer, 'leadelection');
// TODO: implement Handlers for leader election
// add websocket upgrade // add websocket upgrade
this.smartsocket = new plugins.smartsocket.Smartsocket({ this.smartsocket = new plugins.smartsocket.Smartsocket({
port: 12345 // fix this within smartsocket port: 12345 // fix this within smartsocket
}); });
this.smartsocket.setExternalServer('express', this.smartexpressServer as any); // should work with express as well this.smartsocket.setExternalServer('express', this.smartexpressServer as any);
// should work with express as well
this.smartsocket.start(); this.smartsocket.start();
await this.smartexpressServer.start(); await this.smartexpressServer.start();

View File

@ -1,5 +1,6 @@
import * as plugins from './smartuniverse.plugins'; import * as plugins from './smartuniverse.plugins';
import { UniverseChannel } from './smartuniverse.classes.universechannel';
import { UniverseMessage } from './smartuniverse.classes.universemessage'; import { UniverseMessage } from './smartuniverse.classes.universemessage';
import { Objectmap } from 'lik'; import { Objectmap } from 'lik';
@ -10,11 +11,27 @@ import { rxjs } from 'smartrx';
/** /**
* universe store handles the creation, storage and retrieval of messages. * universe store handles the creation, storage and retrieval of messages.
*/ */
export class UniverseStore { export class UniverseCache {
// ========
// INSTANCE
// ========
public standardMessageExpiry: number; public standardMessageExpiry: number;
public destructionTime: number = 60000; public destructionTime: number = 60000;
public messageStore = new Objectmap<UniverseMessage>();
private lastId: number = 0; // stores the last id /**
* stores messages for this instance
*/
public messageMap = new Objectmap<UniverseMessage>();
/**
* stores the channels that are available within the universe
*/
public channelMap = new Objectmap<UniverseChannel>();
/**
* allows messages to be processed in a blacklist mode for further analysis
*/
public blackListChannel = new UniverseChannel(this, 'blacklist', 'nada');
constructor(standardMessageExpiryArg: number) { constructor(standardMessageExpiryArg: number) {
this.standardMessageExpiry = standardMessageExpiryArg; this.standardMessageExpiry = standardMessageExpiryArg;
@ -25,15 +42,17 @@ export class UniverseStore {
* @param messageArg * @param messageArg
* @param attachedPayloadArg * @param attachedPayloadArg
*/ */
public addMessage(messageArg: UniverseMessage) { public async addMessage(messageArg: UniverseMessage) {
this.messageStore.add(messageArg); messageArg.setUniverseCache(this);
UniverseChannel.authorizeAMessageForAChannel(this, messageArg);
this.messageMap.add(messageArg);
} }
/** /**
* Read a message from the UniverseStore * Read a message from the UniverseStore
*/ */
public readMessagesYoungerThan(unixTimeArg?: number): Observable<UniverseMessage> { public readMessagesYoungerThan(unixTimeArg?: number): Observable<UniverseMessage> {
const messageObservable = rxjs.Observable.from(this.messageStore.getArray()).filter( const messageObservable = rxjs.Observable.from(this.messageMap.getArray()).filter(
messageArg => { messageArg => {
return messageArg.timestamp.isYoungerThanMilliSeconds(this.destructionTime); return messageArg.timestamp.isYoungerThanMilliSeconds(this.destructionTime);
} }

View File

@ -1,63 +1,91 @@
import * as plugins from './smartuniverse.plugins'; import * as plugins from './smartuniverse.plugins';
import { Objectmap } from 'lik'; import { Objectmap } from 'lik';
import { UniverseCache } from './smartuniverse.classes.universecache';
import { UniverseMessage } from './smartuniverse.classes.universemessage';
/** /**
* enables messages to stay within a certain scope. * enables messages to stay within a certain scope.
*/ */
export class UniverseChannel { export class UniverseChannel {
/** // ======
* stores the channels that are available within the universe // STATIC
*/ // ======
public static channelStore = new Objectmap<UniverseChannel>();
/**
* allows messages to be processed in a blacklist mode for further analysis
*/
public static blackListChannel = new UniverseChannel('blacklist', 'nada');
/** /**
* creates new channels * creates new channels
* @param channelArg the name of the topic * @param channelArg the name of the topic
* @param passphraseArg the secret thats used for a certain topic. * @param passphraseArg the secret thats used for a certain topic.
*/ */
public static createChannel (channelNameArg: string, passphraseArg: string) { public static createChannel(
const newChannel = new UniverseChannel(channelNameArg, passphraseArg); universeCacheArg: UniverseCache,
channelNameArg: string,
passphraseArg: string
) {
const newChannel = new UniverseChannel(universeCacheArg, channelNameArg, passphraseArg);
return newChannel; return newChannel;
}; }
public static authorizeForChannel (channelNameArg: string, passphraseArg: string) { /**
const foundChannel = this.channelStore.find(universeChannel => { * returns boolean wether certain channel exists
const result = universeChannel.authenticate(channelNameArg, passphraseArg); */
return result; public static async doesChannelExists(universeCacheArg: UniverseCache, channelNameArg: string) {
const channel = universeCacheArg.channelMap.find(channelArg => {
return channelArg.name === channelNameArg;
}); });
if(foundChannel) { if (channel) {
return true;
} else {
return false;
}
}
public static authorizeAMessageForAChannel(
universeCacheArg: UniverseCache,
universeMessageArg: UniverseMessage
) {
const foundChannel = universeCacheArg.channelMap.find(universeChannel => {
const result = universeChannel.authenticate(universeMessageArg);
return result;
});
if (foundChannel) {
universeMessageArg.authenticated = true;
universeMessageArg.universeChannelList.add(foundChannel);
return foundChannel; return foundChannel;
} else { } else {
return this.blackListChannel; universeMessageArg.authenticated = false;
universeMessageArg.universeChannelList.add(universeCacheArg.blackListChannel);
} }
}; }
// ========
// INSTANCE
// ========
/** /**
* the name of the channel * the name of the channel
*/ */
public name: string; public name: string;
public universeCacheInstance: UniverseCache;
/** /**
* the passphrase for the channel * the passphrase for the channel
*/ */
public passphrase: string; public passphrase: string;
constructor(channelNameArg: string, passphraseArg: string) { constructor(universeCacheArg: UniverseCache, channelNameArg: string, passphraseArg: string) {
this.name = channelNameArg; this.name = channelNameArg;
this.passphrase = passphraseArg; this.passphrase = passphraseArg;
UniverseChannel.channelStore.add(this);
} }
/** /**
* authenticates a client on the server side * authenticates a client on the server side
*/ */
public authenticate(channelNameArg: string, passphraseArg: string): boolean { public authenticate(universeMessageArg: UniverseMessage): boolean {
return (this.name === channelNameArg && this.passphrase === passphraseArg); return (
this.name === universeMessageArg.requestedChannelName &&
this.passphrase === universeMessageArg.requestedChannelPassphrase
);
} }
public pushToClients(messageArg: UniverseMessage) {}
} }

View File

@ -1,12 +1,15 @@
import * as plugins from './smartuniverse.plugins'; import * as plugins from './smartuniverse.plugins';
import { Objectmap } from 'lik';
import { Timer, TimeStamp } from 'smarttime'; import { Timer, TimeStamp } from 'smarttime';
import { UniverseChannel } from './smartuniverse.classes.universechannel';
import { UniverseStore } from './smartuniverse.classes.universestore';
import { Universe } from './smartuniverse.classes.universe'; import { Universe } from './smartuniverse.classes.universe';
import { UniverseChannel } from './smartuniverse.classes.universechannel';
import { UniverseCache } from './smartuniverse.classes.universecache';
/** /**
* represents a message within a universe * represents a message within a universe
* acts as a container to save message states like authentication status
*/ */
export class UniverseMessage { export class UniverseMessage {
/** /**
@ -18,13 +21,25 @@ export class UniverseMessage {
public id: number; public id: number;
/** /**
* the universe store the message is attached to * the UniverseCache the message is attached to
*/ */
public universeStore: UniverseStore; public universeCache: UniverseCache;
/**
* requestedChannelName
*/
public requestedChannelName: string;
public requestedChannelPassphrase: string;
/** /**
* enables unprotected grouping of messages for efficiency purposes. * enables unprotected grouping of messages for efficiency purposes.
*/ */
public universeChannel: UniverseChannel; public universeChannelList = new Objectmap<UniverseChannel>();
/**
* wether the message is authenticated
*/
public authenticated: boolean = null;
/** /**
* time of creation * time of creation
@ -47,16 +62,23 @@ export class UniverseMessage {
* @param messageArg * @param messageArg
* @param attachedPayloadArg * @param attachedPayloadArg
*/ */
constructor(messageArg: string, channelNameArg: string, passphraseArg: string, attachedPayloadArg: any) { constructor(
messageArg: string,
requestedChannelNameArg: string,
passphraseArg: string,
attachedPayloadArg: any
) {
this.timestamp = new TimeStamp(); this.timestamp = new TimeStamp();
this.message = messageArg; this.message = messageArg;
this.universeChannel = UniverseChannel.authorizeForChannel(channelNameArg, passphraseArg); this.requestedChannelName = requestedChannelNameArg;
this.requestedChannelPassphrase = passphraseArg;
this.attachedPayload = attachedPayloadArg; this.attachedPayload = attachedPayloadArg;
// prevent memory issues
this.fallBackDestruction(); this.fallBackDestruction();
} }
public setUniverseStore(universeStoreArg: UniverseStore) { public setUniverseCache(universeCacheArg: UniverseCache) {
this.universeStore = universeStoreArg; this.universeCache = universeCacheArg;
} }
public setDestructionTimer(selfdestructAfterArg: number) { public setDestructionTimer(selfdestructAfterArg: number) {
@ -64,15 +86,22 @@ export class UniverseMessage {
this.destructionTimer = new Timer(selfdestructAfterArg); this.destructionTimer = new Timer(selfdestructAfterArg);
this.destructionTimer.start(); this.destructionTimer.start();
// set up self destruction by removing this from the parent messageStore // set up self destruction by removing this from the parent messageCache
this.destructionTimer.completed.then(async () => { this.destructionTimer.completed.then(async () => {
this.universeStore.messageStore.remove(this); this.universeCache.messageMap.remove(this);
}); });
} else { } else {
this.fallBackDestruction(); this.fallBackDestruction();
} }
} }
/**
* handles bad messages for further analysis
*/
handleAsBadMessage() {
console.log('received a bad message');
}
/** /**
* prevents memory leaks if channels have no default * prevents memory leaks if channels have no default
*/ */

View File

@ -1,14 +0,0 @@
import * as plugins from './smartuniverse.plugins';
import { Universe } from './index';
process.env.CLI = 'true';
const universeCli = new plugins.smartcli.Smartcli();
universeCli.standardTask().then(async argvArg => {
const standardUniverse = new Universe({
messageExpiryInMilliseconds: 60000
});
await standardUniverse.initServer(8765);
});

View File

@ -0,0 +1,3 @@
export interface IUniverseChannel {}
export interface IUniverseMessage {}

View File

@ -1,7 +1,6 @@
import * as lik from 'lik'; import * as lik from 'lik';
import * as nodehash from 'nodehash'; import * as nodehash from 'nodehash';
import * as path from 'path'; import * as path from 'path';
import * as smartcli from 'smartcli';
import * as smartdelay from 'smartdelay'; import * as smartdelay from 'smartdelay';
import * as smartexpress from 'smartexpress'; import * as smartexpress from 'smartexpress';
import * as smartfile from 'smartfile'; import * as smartfile from 'smartfile';
@ -15,7 +14,6 @@ export {
lik, lik,
nodehash, nodehash,
path, path,
smartcli,
smartdelay, smartdelay,
smartexpress, smartexpress,
smartfile, smartfile,