Compare commits
16 Commits
Author | SHA1 | Date | |
---|---|---|---|
8d358dd93d | |||
e576d6058a | |||
6546da2394 | |||
29597daba1 | |||
c8b647d2fd | |||
1fa4aca049 | |||
2d4695de22 | |||
a3f4dcbc2a | |||
d6e81288b4 | |||
c441d89596 | |||
85b69e487a | |||
0d94ed9345 | |||
e188b18016 | |||
33c0fa3746 | |||
52be1415ee | |||
e75d5eabdb |
216
package-lock.json
generated
216
package-lock.json
generated
@ -1,18 +1,13 @@
|
||||
{
|
||||
"name": "@pushrocks/smartsocket",
|
||||
"version": "1.1.41",
|
||||
"version": "1.1.49",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"@airbnb/node-memwatch": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://verdaccio.lossless.one/@airbnb%2fnode-memwatch/-/node-memwatch-1.0.2.tgz",
|
||||
"integrity": "sha512-2R+MEEMSTUdKwQ6NFWkyA/UNoSjL1tMldZqJbZpgXSwNMBzlNlkUWEXKu9RqTTMkDqJRfGJ2VDs8gPlPK2APDQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"bindings": "^1.3.0",
|
||||
"nan": "^2.9.2"
|
||||
}
|
||||
"@apiglobal/typedrequest-interfaces": {
|
||||
"version": "1.0.7",
|
||||
"resolved": "https://verdaccio.lossless.one/@apiglobal%2ftypedrequest-interfaces/-/typedrequest-interfaces-1.0.7.tgz",
|
||||
"integrity": "sha512-yPl0UcLFMwSQL7bK52wVjkgvadC+x2YS3+7T15V1A1dXNxa96yd4WX1fqcKqwnBrvYexq/8FaxWGi98tZ0oNwg=="
|
||||
},
|
||||
"@babel/code-frame": {
|
||||
"version": "7.5.5",
|
||||
@ -35,9 +30,9 @@
|
||||
}
|
||||
},
|
||||
"@gitzone/tsbuild": {
|
||||
"version": "2.1.11",
|
||||
"resolved": "https://verdaccio.lossless.one/@gitzone%2ftsbuild/-/tsbuild-2.1.11.tgz",
|
||||
"integrity": "sha512-Sa90/S7rkfFaTa2yeASHVAWIl3hNh9DBqVcQbOCaNhqKUGdD+NzPw1MESuMOXqKG7oM5i4Cu6qfcJB0fmAjS8g==",
|
||||
"version": "2.1.17",
|
||||
"resolved": "https://registry.npmjs.org/@gitzone/tsbuild/-/tsbuild-2.1.17.tgz",
|
||||
"integrity": "sha512-Mg2cu7cW3cC6L2tzatB8t6OMVgTGatobb8UkN+y3n7KAWRld4gXcVWmaehch/wSFrbmk6Oe8rPjdWPjhTSIF1Q==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@pushrocks/smartcli": "^3.0.7",
|
||||
@ -45,7 +40,7 @@
|
||||
"@pushrocks/smartlog": "^2.0.19",
|
||||
"@pushrocks/smartpath": "^4.0.1",
|
||||
"@pushrocks/smartpromise": "^3.0.2",
|
||||
"typescript": "^3.4.5"
|
||||
"typescript": "^3.5.2"
|
||||
}
|
||||
},
|
||||
"@gitzone/tsrun": {
|
||||
@ -128,9 +123,9 @@
|
||||
}
|
||||
},
|
||||
"@pushrocks/lik": {
|
||||
"version": "3.0.10",
|
||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2flik/-/lik-3.0.10.tgz",
|
||||
"integrity": "sha512-iWG06QsrL6AAnjPRWMVz4bRaRE0jJt/HgEK0YeLqaSBLY8ju4ps1j4lEN8VrUlXGZyPB6UGQfcreesO24buYhQ==",
|
||||
"version": "3.0.11",
|
||||
"resolved": "https://registry.npmjs.org/@pushrocks/lik/-/lik-3.0.11.tgz",
|
||||
"integrity": "sha512-SDKRPj9+xBTqozlDPcA7O6BcccM1Tw/sXPVP+OnhNxCubDZ/L2kGNpPpqm43NJUoNxSSo5wdBw4N7MAFYCGdVg==",
|
||||
"requires": {
|
||||
"@pushrocks/smartdelay": "^2.0.3",
|
||||
"@pushrocks/smartpromise": "^3.0.2",
|
||||
@ -199,9 +194,9 @@
|
||||
}
|
||||
},
|
||||
"@pushrocks/smartexpress": {
|
||||
"version": "3.0.38",
|
||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartexpress/-/smartexpress-3.0.38.tgz",
|
||||
"integrity": "sha512-di26orVJwgBRGKVpYcPrauc14CVo0piAzXTBWFZZNUCuIsndnXepd9oDzMO+KHVZpNz3W4DxbtRkppZjrh9ejw==",
|
||||
"version": "3.0.40",
|
||||
"resolved": "https://registry.npmjs.org/@pushrocks/smartexpress/-/smartexpress-3.0.40.tgz",
|
||||
"integrity": "sha512-biAquO44yvrZ/elC3psUbYYoeZn647HjZXyQ14WL5IcXMgnKBo5+qvkqNgDmcHSKJ9KuVnycuRWa8vg6z77GSg==",
|
||||
"requires": {
|
||||
"@pushrocks/lik": "^3.0.10",
|
||||
"@pushrocks/smartfile": "^7.0.4",
|
||||
@ -238,9 +233,9 @@
|
||||
}
|
||||
},
|
||||
"@pushrocks/smartrequest": {
|
||||
"version": "1.1.16",
|
||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartrequest/-/smartrequest-1.1.16.tgz",
|
||||
"integrity": "sha512-3LbtqoqnjfzWSQ10NryhJmgwPpvMlVoYyTzE676+yC4hM2rnGSzxozLZxMr6enV4VeZcloQ0CqHBivKoT/kdvA==",
|
||||
"version": "1.1.23",
|
||||
"resolved": "https://registry.npmjs.org/@pushrocks/smartrequest/-/smartrequest-1.1.23.tgz",
|
||||
"integrity": "sha512-Hws3YfzIE0b/E3aTkSugLskKWBq7e8HDXEN+RlRyTFONxW/XONKJFTw4mp3jk+puWpYGDoOTcP+Ua4jd19z9pA==",
|
||||
"requires": {
|
||||
"@pushrocks/smartpromise": "^3.0.2",
|
||||
"@types/form-data": "^2.2.1",
|
||||
@ -399,22 +394,21 @@
|
||||
}
|
||||
},
|
||||
"@pushrocks/tapbundle": {
|
||||
"version": "3.0.11",
|
||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2ftapbundle/-/tapbundle-3.0.11.tgz",
|
||||
"integrity": "sha512-s7epZfJZX+LsBVmIYvoaY4WtgPvRLnHZMVTpQAPJGMBqxJAQxhQ2wvGJjmqMAGhhznAHI6t4g+m0KTp3vFIRVg==",
|
||||
"version": "3.0.13",
|
||||
"resolved": "https://registry.npmjs.org/@pushrocks/tapbundle/-/tapbundle-3.0.13.tgz",
|
||||
"integrity": "sha512-23O4UMBafCuD+RnUlXNvtT9DGbL1HMD+xZE1Zcr7Ll7WvgxUgRQQfk9kq6qbLLbjaRe1J2Ijsgh1HuZbBaucLQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@pushrocks/early": "^3.0.3",
|
||||
"@pushrocks/smartdelay": "^2.0.3",
|
||||
"@pushrocks/smartpromise": "^3.0.2",
|
||||
"leakage": "^0.4.0",
|
||||
"smartchai": "^2.0.1"
|
||||
}
|
||||
},
|
||||
"@types/body-parser": {
|
||||
"version": "1.17.0",
|
||||
"resolved": "https://verdaccio.lossless.one/@types%2fbody-parser/-/body-parser-1.17.0.tgz",
|
||||
"integrity": "sha512-a2+YeUjPkztKJu5aIF2yArYFQQp8d51wZ7DavSHjFuY1mqVgidGyzEQ41JIVNy82fXj8yPgy2vJmfIywgESW6w==",
|
||||
"version": "1.17.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.17.1.tgz",
|
||||
"integrity": "sha512-RoX2EZjMiFMjZh9lmYrwgoP9RTpAjSHiJxdp4oidAQVO02T7HER3xj9UKue5534ULWeqVEkujhWcyvUce+d68w==",
|
||||
"requires": {
|
||||
"@types/connect": "*",
|
||||
"@types/node": "*"
|
||||
@ -462,9 +456,9 @@
|
||||
}
|
||||
},
|
||||
"@types/express": {
|
||||
"version": "4.17.0",
|
||||
"resolved": "https://verdaccio.lossless.one/@types%2fexpress/-/express-4.17.0.tgz",
|
||||
"integrity": "sha512-CjaMu57cjgjuZbh9DpkloeGxV45CnMGlVd+XpG7Gm9QgVrd7KFq+X4HY0vM+2v0bczS48Wg7bvnMY5TN+Xmcfw==",
|
||||
"version": "4.17.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.1.tgz",
|
||||
"integrity": "sha512-VfH/XCP0QbQk5B5puLqTLEeFgR8lfCJHZJKkInZ9mkYd+u8byX0kztXEQxEk4wZXJs8HI+7km2ALXjn4YKcX9w==",
|
||||
"requires": {
|
||||
"@types/body-parser": "*",
|
||||
"@types/express-serve-static-core": "*",
|
||||
@ -472,9 +466,9 @@
|
||||
}
|
||||
},
|
||||
"@types/express-serve-static-core": {
|
||||
"version": "4.16.7",
|
||||
"resolved": "https://verdaccio.lossless.one/@types%2fexpress-serve-static-core/-/express-serve-static-core-4.16.7.tgz",
|
||||
"integrity": "sha512-847KvL8Q1y3TtFLRTXcVakErLJQgdpFSaq+k043xefz9raEf0C7HalpSY7OW5PyjCnY8P7bPW5t/Co9qqp+USg==",
|
||||
"version": "4.16.9",
|
||||
"resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.16.9.tgz",
|
||||
"integrity": "sha512-GqpaVWR0DM8FnRUJYKlWgyARoBUAVfRIeVDZQKOttLFp5SmhhF9YFIYeTPwMd/AXfxlP7xVO2dj1fGu0Q+krKQ==",
|
||||
"requires": {
|
||||
"@types/node": "*",
|
||||
"@types/range-parser": "*"
|
||||
@ -542,9 +536,9 @@
|
||||
"integrity": "sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA=="
|
||||
},
|
||||
"@types/node": {
|
||||
"version": "12.7.1",
|
||||
"resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-12.7.1.tgz",
|
||||
"integrity": "sha512-aK9jxMypeSrhiYofWWBf/T7O+KwaiAHzM4sveCdWPn71lzUSMimRnKzhXDKfKwV1kWoBo2P1aGgaIYGLf9/ljw=="
|
||||
"version": "12.7.4",
|
||||
"resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-12.7.4.tgz",
|
||||
"integrity": "sha512-W0+n1Y+gK/8G2P/piTkBBN38Qc5Q1ZSO6B5H3QmPCUewaiXOo2GCAWZ4ElZCcNhjJuBSUSLGFUJnmlCn5+nxOQ=="
|
||||
},
|
||||
"@types/range-parser": {
|
||||
"version": "1.2.3",
|
||||
@ -552,9 +546,9 @@
|
||||
"integrity": "sha512-ewFXqrQHlFsgc09MK5jP5iR7vumV/BYayNC6PgJO2LPe8vrnNFyjQjSppfEngITi0qvfKtzFvgKymGheFM9UOA=="
|
||||
},
|
||||
"@types/serve-static": {
|
||||
"version": "1.13.2",
|
||||
"resolved": "https://verdaccio.lossless.one/@types%2fserve-static/-/serve-static-1.13.2.tgz",
|
||||
"integrity": "sha512-/BZ4QRLpH/bNYgZgwhKEh+5AsboDBcUdlBYgzoLX0fpj3Y2gp6EApyOlM3bK53wQS/OE1SrdSYBAbux2D1528Q==",
|
||||
"version": "1.13.3",
|
||||
"resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.13.3.tgz",
|
||||
"integrity": "sha512-oprSwp094zOglVrXdlo/4bAHtKTAxX6VT8FOZlBKrmyLbNvE1zxZyJ6yikMVtHIvwP45+ZQGJn+FdXGKTozq0g==",
|
||||
"requires": {
|
||||
"@types/express-serve-static-core": "*",
|
||||
"@types/mime": "*"
|
||||
@ -758,15 +752,6 @@
|
||||
"callsite": "1.0.0"
|
||||
}
|
||||
},
|
||||
"bindings": {
|
||||
"version": "1.5.0",
|
||||
"resolved": "https://verdaccio.lossless.one/bindings/-/bindings-1.5.0.tgz",
|
||||
"integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"file-uri-to-path": "1.0.0"
|
||||
}
|
||||
},
|
||||
"blob": {
|
||||
"version": "0.0.5",
|
||||
"resolved": "https://verdaccio.lossless.one/blob/-/blob-0.0.5.tgz",
|
||||
@ -804,6 +789,11 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"bowser": {
|
||||
"version": "2.5.3",
|
||||
"resolved": "https://registry.npmjs.org/bowser/-/bowser-2.5.3.tgz",
|
||||
"integrity": "sha512-aWCA+CKfKNL/WGzNgjmK+Whp57JMzboZMwJ5gy2jDj2bEIjbMCb3ImGX+V++5wsJftyFiDIbOjRXl60ycniVqg=="
|
||||
},
|
||||
"brace-expansion": {
|
||||
"version": "1.1.11",
|
||||
"resolved": "https://verdaccio.lossless.one/brace-expansion/-/brace-expansion-1.1.11.tgz",
|
||||
@ -1280,12 +1270,6 @@
|
||||
"has-binary2": "~1.0.2"
|
||||
}
|
||||
},
|
||||
"es6-error": {
|
||||
"version": "4.1.1",
|
||||
"resolved": "https://verdaccio.lossless.one/es6-error/-/es6-error-4.1.1.tgz",
|
||||
"integrity": "sha512-Um/+FxMr9CISWh0bi5Zv0iOD+4cFh5qLeks1qhAopKVAJw3drgKbKySikp7wGhDL0HPeaja0P5ULZrxLkniUVg==",
|
||||
"dev": true
|
||||
},
|
||||
"escape-html": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://verdaccio.lossless.one/escape-html/-/escape-html-1.0.3.tgz",
|
||||
@ -1459,12 +1443,6 @@
|
||||
"escape-string-regexp": "^1.0.5"
|
||||
}
|
||||
},
|
||||
"file-uri-to-path": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://verdaccio.lossless.one/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz",
|
||||
"integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==",
|
||||
"dev": true
|
||||
},
|
||||
"finalhandler": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://verdaccio.lossless.one/finalhandler/-/finalhandler-1.1.2.tgz",
|
||||
@ -1666,9 +1644,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"helmet": {
|
||||
"version": "3.20.0",
|
||||
"resolved": "https://verdaccio.lossless.one/helmet/-/helmet-3.20.0.tgz",
|
||||
"integrity": "sha512-Ob+TqmQFZ5f7WgP8kBbAzNPsbf6p1lOj5r+327/ymw/IILWih3wcx9u/u/S8Mwv5wbBkO7Li6x5s23t3COhUKw==",
|
||||
"version": "3.20.1",
|
||||
"resolved": "https://registry.npmjs.org/helmet/-/helmet-3.20.1.tgz",
|
||||
"integrity": "sha512-em+X5Wz/f0yqoRsBnpnVy3wJHSiIeskX3FQn30szBh1tILaOeSRRLkShuUVFlk/o4qTYjWxdHg4FrRe45iBWHg==",
|
||||
"requires": {
|
||||
"depd": "2.0.0",
|
||||
"dns-prefetch-control": "0.2.0",
|
||||
@ -1677,7 +1655,7 @@
|
||||
"feature-policy": "0.3.0",
|
||||
"frameguard": "3.1.0",
|
||||
"helmet-crossdomain": "0.4.0",
|
||||
"helmet-csp": "2.8.0",
|
||||
"helmet-csp": "2.9.0",
|
||||
"hide-powered-by": "1.1.0",
|
||||
"hpkp": "2.0.0",
|
||||
"hsts": "2.2.0",
|
||||
@ -1700,14 +1678,14 @@
|
||||
"integrity": "sha512-AB4DTykRw3HCOxovD1nPR16hllrVImeFp5VBV9/twj66lJ2nU75DP8FPL0/Jp4jj79JhTfG+pFI2MD02kWJ+fA=="
|
||||
},
|
||||
"helmet-csp": {
|
||||
"version": "2.8.0",
|
||||
"resolved": "https://verdaccio.lossless.one/helmet-csp/-/helmet-csp-2.8.0.tgz",
|
||||
"integrity": "sha512-MlCPeM0Sm3pS9RACRihx70VeTHmkQwa7sum9EK1tfw1VZyvFU0dBWym9nHh3CRkTRNlyNm/WFCMvuh9zXkOjNw==",
|
||||
"version": "2.9.0",
|
||||
"resolved": "https://registry.npmjs.org/helmet-csp/-/helmet-csp-2.9.0.tgz",
|
||||
"integrity": "sha512-DGGOQtOLM7ZQpjbf/uvUonq1yG/rFgsBuK10ZJt2AtxUJxqfkPvfmP9aLUmgH9IactiRiYoiFY72YYSPl1TLTQ==",
|
||||
"requires": {
|
||||
"bowser": "2.5.3",
|
||||
"camelize": "1.0.0",
|
||||
"content-security-policy-builder": "2.1.0",
|
||||
"dasherize": "2.0.0",
|
||||
"platform": "1.3.5"
|
||||
"dasherize": "2.0.0"
|
||||
}
|
||||
},
|
||||
"hide-powered-by": {
|
||||
@ -1907,25 +1885,6 @@
|
||||
"invert-kv": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"leakage": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://verdaccio.lossless.one/leakage/-/leakage-0.4.0.tgz",
|
||||
"integrity": "sha512-x7gYK5n5dPkHDZWJ2Kh8Ag1hZNzUh+HtXn8Bv1aDdN6o6ONPCJ8sOfFq+kxcULJFp3lXaCjXb3iXOLmQRbBLwA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@airbnb/node-memwatch": "^1.0.2",
|
||||
"es6-error": "^4.0.2",
|
||||
"left-pad": "^1.1.3",
|
||||
"minimist": "^1.2.0",
|
||||
"pretty-bytes": "^4.0.2"
|
||||
}
|
||||
},
|
||||
"left-pad": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://verdaccio.lossless.one/left-pad/-/left-pad-1.3.0.tgz",
|
||||
"integrity": "sha512-XI5MPzVNApjAyhQzphX8BkmKsKUxD4LdyK24iZeQGinBN9yTQT3bFlCBy/aVx2HrNcqQGsdot8ghrjyrvMCoEA==",
|
||||
"dev": true
|
||||
},
|
||||
"locate-path": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://verdaccio.lossless.one/locate-path/-/locate-path-3.0.0.tgz",
|
||||
@ -2118,9 +2077,9 @@
|
||||
}
|
||||
},
|
||||
"minimist": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://verdaccio.lossless.one/minimist/-/minimist-1.2.0.tgz",
|
||||
"integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=",
|
||||
"version": "0.0.8",
|
||||
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
|
||||
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=",
|
||||
"dev": true
|
||||
},
|
||||
"mkdirp": {
|
||||
@ -2130,14 +2089,6 @@
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"minimist": "0.0.8"
|
||||
},
|
||||
"dependencies": {
|
||||
"minimist": {
|
||||
"version": "0.0.8",
|
||||
"resolved": "https://verdaccio.lossless.one/minimist/-/minimist-0.0.8.tgz",
|
||||
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"moment": {
|
||||
@ -2158,16 +2109,10 @@
|
||||
"resolved": "https://verdaccio.lossless.one/ms/-/ms-2.1.1.tgz",
|
||||
"integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg=="
|
||||
},
|
||||
"nan": {
|
||||
"version": "2.14.0",
|
||||
"resolved": "https://verdaccio.lossless.one/nan/-/nan-2.14.0.tgz",
|
||||
"integrity": "sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg==",
|
||||
"dev": true
|
||||
},
|
||||
"nanoid": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://verdaccio.lossless.one/nanoid/-/nanoid-2.0.1.tgz",
|
||||
"integrity": "sha512-k1u2uemjIGsn25zmujKnotgniC/gxQ9sdegdezeDiKdkDW56THUMqlz3urndKCXJxA6yPzSZbXx/QCMe/pxqsA=="
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://verdaccio.lossless.one/nanoid/-/nanoid-2.1.0.tgz",
|
||||
"integrity": "sha512-g5WwS+p6Cm+zQhO2YOpRbQThZVnNb7DDq74h8YDCLfAGynrEOrbx2E16dc8ciENiP1va5sqaAruqn2sN+xpkWg=="
|
||||
},
|
||||
"negotiator": {
|
||||
"version": "0.6.1",
|
||||
@ -2309,9 +2254,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"p-limit": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://verdaccio.lossless.one/p-limit/-/p-limit-2.2.0.tgz",
|
||||
"integrity": "sha512-pZbTJpoUsCzV48Mc9Nh51VbwO0X9cuPFE8gYwx9BTCt9SF8/b7Zljd2fVgOxhIF/HDTKgpVzs+GPhyKfjLLFRQ==",
|
||||
"version": "2.2.1",
|
||||
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.2.1.tgz",
|
||||
"integrity": "sha512-85Tk+90UCVWvbDavCLKPOLC9vvY8OwEX/RtKF+/1OADJMVlFfEHOiMTPVyxg7mk/dKa+ipdHm0OUkTvCpMTuwg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"p-try": "^2.0.0"
|
||||
@ -2397,17 +2342,6 @@
|
||||
"resolved": "https://verdaccio.lossless.one/pify/-/pify-2.3.0.tgz",
|
||||
"integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw="
|
||||
},
|
||||
"platform": {
|
||||
"version": "1.3.5",
|
||||
"resolved": "https://verdaccio.lossless.one/platform/-/platform-1.3.5.tgz",
|
||||
"integrity": "sha512-TuvHS8AOIZNAlE77WUDiR4rySV/VMptyMfcfeoMgs4P8apaZM3JrnbzBiixKUv+XR6i+BXrQh8WAnjaSPFO65Q=="
|
||||
},
|
||||
"pretty-bytes": {
|
||||
"version": "4.0.2",
|
||||
"resolved": "https://verdaccio.lossless.one/pretty-bytes/-/pretty-bytes-4.0.2.tgz",
|
||||
"integrity": "sha1-sr+C5zUNZcbDOqlaqlpPYyf2HNk=",
|
||||
"dev": true
|
||||
},
|
||||
"process-nextick-args": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://verdaccio.lossless.one/process-nextick-args/-/process-nextick-args-2.0.0.tgz",
|
||||
@ -2581,9 +2515,9 @@
|
||||
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
|
||||
},
|
||||
"semver": {
|
||||
"version": "5.7.0",
|
||||
"resolved": "https://verdaccio.lossless.one/semver/-/semver-5.7.0.tgz",
|
||||
"integrity": "sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==",
|
||||
"version": "5.7.1",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz",
|
||||
"integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==",
|
||||
"dev": true
|
||||
},
|
||||
"send": {
|
||||
@ -2661,11 +2595,11 @@
|
||||
"dev": true
|
||||
},
|
||||
"shortid": {
|
||||
"version": "2.2.14",
|
||||
"resolved": "https://verdaccio.lossless.one/shortid/-/shortid-2.2.14.tgz",
|
||||
"integrity": "sha512-4UnZgr9gDdA1kaKj/38IiudfC3KHKhDc1zi/HSxd9FQDR0VLwH3/y79tZJLsVYPsJgIjeHjqIWaWVRJUj9qZOQ==",
|
||||
"version": "2.2.15",
|
||||
"resolved": "https://verdaccio.lossless.one/shortid/-/shortid-2.2.15.tgz",
|
||||
"integrity": "sha512-5EaCy2mx2Jgc/Fdn9uuDuNIIfWBpzY4XIlhoqtXF6qsf+/+SGZ+FxDdX/ZsMZiWupIWNqAEmiNY4RC+LSmCeOw==",
|
||||
"requires": {
|
||||
"nanoid": "^2.0.0"
|
||||
"nanoid": "^2.1.0"
|
||||
}
|
||||
},
|
||||
"signal-exit": {
|
||||
@ -2960,9 +2894,9 @@
|
||||
"integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ=="
|
||||
},
|
||||
"tslint": {
|
||||
"version": "5.18.0",
|
||||
"resolved": "https://verdaccio.lossless.one/tslint/-/tslint-5.18.0.tgz",
|
||||
"integrity": "sha512-Q3kXkuDEijQ37nXZZLKErssQVnwCV/+23gFEMROi8IlbaBG6tXqLPQJ5Wjcyt/yHPKBC+hD5SzuGaMora+ZS6w==",
|
||||
"version": "5.19.0",
|
||||
"resolved": "https://registry.npmjs.org/tslint/-/tslint-5.19.0.tgz",
|
||||
"integrity": "sha512-1LwwtBxfRJZnUvoS9c0uj8XQtAnyhWr9KlNvDIdB+oXyT+VpsOAaEhEgKi1HrZ8rq0ki/AAnbGSv4KM6/AfVZw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@babel/code-frame": "^7.0.0",
|
||||
@ -3047,9 +2981,9 @@
|
||||
}
|
||||
},
|
||||
"typescript": {
|
||||
"version": "3.5.1",
|
||||
"resolved": "https://verdaccio.lossless.one/typescript/-/typescript-3.5.1.tgz",
|
||||
"integrity": "sha512-64HkdiRv1yYZsSe4xC1WVgamNigVYjlssIoaH2HcZF0+ijsk5YK2g0G34w9wJkze8+5ow4STd22AynfO6ZYYLw==",
|
||||
"version": "3.6.2",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.6.2.tgz",
|
||||
"integrity": "sha512-lmQ4L+J6mnu3xweP8+rOrUwzmN+MRAj7TgtJtDaXE5PMyX2kCrklhg3rvOsOIfNeAWMQWO2F1GPc1kMD2vLAfw==",
|
||||
"dev": true
|
||||
},
|
||||
"universalify": {
|
||||
@ -3081,9 +3015,9 @@
|
||||
"integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM="
|
||||
},
|
||||
"uuid": {
|
||||
"version": "3.3.2",
|
||||
"resolved": "https://verdaccio.lossless.one/uuid/-/uuid-3.3.2.tgz",
|
||||
"integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA=="
|
||||
"version": "3.3.3",
|
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.3.tgz",
|
||||
"integrity": "sha512-pW0No1RGHgzlpHJO1nsVrHKpOEIxkGg1xB+v0ZmdNH5OAeAwzAVrCnI2/6Mtx+Uys6iaylxa+D3g4j63IKKjSQ=="
|
||||
},
|
||||
"vary": {
|
||||
"version": "1.1.2",
|
||||
|
17
package.json
17
package.json
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@pushrocks/smartsocket",
|
||||
"version": "1.1.41",
|
||||
"version": "1.1.49",
|
||||
"description": "easy and secure websocket communication",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
@ -19,26 +19,27 @@
|
||||
},
|
||||
"homepage": "https://gitlab.com/pushrocks/smartsocket#README",
|
||||
"dependencies": {
|
||||
"@pushrocks/lik": "^3.0.10",
|
||||
"@apiglobal/typedrequest-interfaces": "^1.0.7",
|
||||
"@pushrocks/lik": "^3.0.11",
|
||||
"@pushrocks/smartdelay": "^2.0.3",
|
||||
"@pushrocks/smartexpress": "^3.0.38",
|
||||
"@pushrocks/smartexpress": "^3.0.40",
|
||||
"@pushrocks/smarthash": "^2.0.6",
|
||||
"@pushrocks/smartlog": "^2.0.19",
|
||||
"@pushrocks/smartpromise": "^3.0.2",
|
||||
"@types/shortid": "0.0.29",
|
||||
"@types/socket.io": "^2.1.2",
|
||||
"@types/socket.io-client": "^1.4.32",
|
||||
"shortid": "^2.2.14",
|
||||
"shortid": "^2.2.15",
|
||||
"socket.io": "^2.2.0",
|
||||
"socket.io-client": "^2.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.1.11",
|
||||
"@gitzone/tsbuild": "^2.1.17",
|
||||
"@gitzone/tsrun": "^1.2.8",
|
||||
"@gitzone/tstest": "^1.0.24",
|
||||
"@pushrocks/tapbundle": "^3.0.11",
|
||||
"@types/node": "^12.7.1",
|
||||
"tslint": "^5.18.0",
|
||||
"@pushrocks/tapbundle": "^3.0.13",
|
||||
"@types/node": "^12.7.4",
|
||||
"tslint": "^5.19.0",
|
||||
"tslint-config-prettier": "^1.18.0"
|
||||
},
|
||||
"private": false,
|
||||
|
@ -1 +1 @@
|
||||
console.log('TODO');
|
||||
console.log('TODO');
|
||||
|
@ -11,7 +11,7 @@ import smartsocket = require('../ts/index');
|
||||
let testSmartsocket: smartsocket.Smartsocket;
|
||||
let testSmartsocketClient: smartsocket.SmartsocketClient;
|
||||
let testSocketRole1: smartsocket.SocketRole;
|
||||
let testSocketFunction1: smartsocket.SocketFunction;
|
||||
let testSocketFunction1: smartsocket.SocketFunction<any>;
|
||||
let myseServer: smartexpress.Server;
|
||||
|
||||
const testConfig = {
|
||||
@ -93,9 +93,7 @@ tap.test('should be able to make a functionCall from client to server', async ()
|
||||
console.log(response);
|
||||
});
|
||||
|
||||
tap.test('should be able to make a functionCall from server to client', async () => {
|
||||
|
||||
});
|
||||
tap.test('should be able to make a functionCall from server to client', async () => {});
|
||||
|
||||
// terminate
|
||||
tap.test('should close the server', async () => {
|
||||
|
67
test/test.ts
67
test/test.ts
@ -9,8 +9,30 @@ import smartsocket = require('../ts/index');
|
||||
|
||||
let testSmartsocket: smartsocket.Smartsocket;
|
||||
let testSmartsocketClient: smartsocket.SmartsocketClient;
|
||||
let testSocketConnection: smartsocket.SocketConnection;
|
||||
let testSocketRole1: smartsocket.SocketRole;
|
||||
let testSocketFunction1: smartsocket.SocketFunction;
|
||||
let testSocketFunctionForServer: smartsocket.SocketFunction<any>;
|
||||
let testSocketFunctionClient: smartsocket.SocketFunction<any>;
|
||||
|
||||
export interface IReqResClient {
|
||||
method: 'testFunction1';
|
||||
request: {
|
||||
value1: string;
|
||||
};
|
||||
response: {
|
||||
value1: string;
|
||||
}
|
||||
}
|
||||
|
||||
export interface IReqResServer {
|
||||
method: 'testFunction2';
|
||||
request: {
|
||||
hi: string;
|
||||
};
|
||||
response: {
|
||||
hi: string
|
||||
}
|
||||
}
|
||||
|
||||
const testConfig = {
|
||||
port: 3000
|
||||
@ -33,14 +55,23 @@ tap.test('should add a socketrole', async () => {
|
||||
|
||||
// class SocketFunction
|
||||
tap.test('should register a new Function', async () => {
|
||||
testSocketFunction1 = new smartsocket.SocketFunction({
|
||||
testSocketFunctionForServer = new smartsocket.SocketFunction({
|
||||
allowedRoles: [testSocketRole1],
|
||||
funcDef: async (dataArg, socketConnectionArg) => {
|
||||
return dataArg;
|
||||
},
|
||||
funcName: 'testFunction1'
|
||||
});
|
||||
testSmartsocket.addSocketFunction(testSocketFunction1);
|
||||
testSmartsocket.addSocketFunction(testSocketFunctionForServer);
|
||||
|
||||
testSocketFunctionClient = new smartsocket.SocketFunction({
|
||||
allowedRoles: [],
|
||||
funcDef: async (dataArg, socketConnectionArg) => {
|
||||
return dataArg;
|
||||
},
|
||||
funcName: 'testFunction2'
|
||||
});
|
||||
testSmartsocket.addSocketFunction(testSocketFunctionForServer);
|
||||
console.log(testSmartsocket.socketFunctions);
|
||||
});
|
||||
|
||||
@ -57,33 +88,41 @@ tap.test('should react to a new websocket connection from client', async () => {
|
||||
alias: 'testClient1',
|
||||
role: 'testRole1'
|
||||
});
|
||||
testSmartsocketClient.addSocketFunction(testSocketFunction1);
|
||||
testSmartsocketClient.addSocketFunction(testSocketFunctionClient);
|
||||
console.log(testSmartsocketClient.socketFunctions);
|
||||
await testSmartsocketClient.connect();
|
||||
});
|
||||
|
||||
tap.test('client should disconnect and reconnect', async tools => {
|
||||
await testSmartsocketClient.disconnect();
|
||||
await tools.delayFor(100);
|
||||
await testSmartsocketClient.connect();
|
||||
});
|
||||
|
||||
tap.test('2 clients should connect in parallel', async () => {
|
||||
// TODO: implement parallel test
|
||||
});
|
||||
|
||||
tap.test('should be able to make a functionCall from client to server', async () => {
|
||||
const response = await testSmartsocketClient.serverCall('testFunction1', {
|
||||
const response = await testSmartsocketClient.serverCall<IReqResClient>('testFunction1', {
|
||||
value1: 'hello'
|
||||
});
|
||||
console.log(response);
|
||||
expect(response.value1).to.equal('hello');
|
||||
});
|
||||
|
||||
tap.test('should be able to make a functionCall from server to client', async () => {
|
||||
const response = await testSmartsocketClient.serverCall('testFunction1', {
|
||||
hi: 'hi there from client'
|
||||
});
|
||||
const response = await testSmartsocket.clientCall<IReqResServer>(
|
||||
'testFunction2',
|
||||
{
|
||||
hi: 'hi there from server'
|
||||
},
|
||||
testSmartsocket.socketConnections.find(socketConnection => {
|
||||
return true;
|
||||
})
|
||||
);
|
||||
console.log(response);
|
||||
expect(response.hi).to.equal('hi there from server');
|
||||
});
|
||||
|
||||
tap.test('client should disconnect and reconnect', async tools => {
|
||||
await testSmartsocketClient.disconnect();
|
||||
await tools.delayFor(100);
|
||||
await testSmartsocketClient.connect();
|
||||
});
|
||||
|
||||
// terminate
|
||||
|
@ -1,5 +1,3 @@
|
||||
import * as plugins from './smartsocket.plugins';
|
||||
|
||||
// export main classes
|
||||
export * from './smartsocket.classes.smartsocket';
|
||||
export * from './smartsocket.classes.smartsocketclient';
|
||||
|
@ -3,7 +3,7 @@ import * as plugins from './smartsocket.plugins';
|
||||
// classes
|
||||
import { Objectmap } from '@pushrocks/lik';
|
||||
import { SocketConnection } from './smartsocket.classes.socketconnection';
|
||||
import { ISocketFunctionCall, SocketFunction } from './smartsocket.classes.socketfunction';
|
||||
import { ISocketFunctionCallDataRequest, SocketFunction, ISocketFunctionCallDataResponse } from './smartsocket.classes.socketfunction';
|
||||
import { SocketRequest } from './smartsocket.classes.socketrequest';
|
||||
import { SocketRole } from './smartsocket.classes.socketrole';
|
||||
import { SocketServer } from './smartsocket.classes.socketserver';
|
||||
@ -18,10 +18,10 @@ export interface ISmartsocketConstructorOptions {
|
||||
export class Smartsocket {
|
||||
public options: ISmartsocketConstructorOptions;
|
||||
public io: SocketIO.Server;
|
||||
public openSockets = new Objectmap<SocketConnection>();
|
||||
public socketConnections = new Objectmap<SocketConnection>();
|
||||
public socketRoles = new Objectmap<SocketRole>();
|
||||
public socketFunctions = new Objectmap<SocketFunction>();
|
||||
public socketRequests = new Objectmap<SocketRequest>();
|
||||
public socketFunctions = new Objectmap<SocketFunction<any>>();
|
||||
public socketRequests = new Objectmap<SocketRequest<any>>();
|
||||
|
||||
private socketServer = new SocketServer(this);
|
||||
|
||||
@ -50,14 +50,14 @@ export class Smartsocket {
|
||||
*/
|
||||
public async stop() {
|
||||
await plugins.smartdelay.delayFor(1000);
|
||||
this.openSockets.forEach((socketObjectArg: SocketConnection) => {
|
||||
this.socketConnections.forEach((socketObjectArg: SocketConnection) => {
|
||||
plugins.smartlog.defaultLogger.log(
|
||||
'info',
|
||||
`disconnect socket with >>alias ${socketObjectArg.alias}`
|
||||
);
|
||||
socketObjectArg.socket.disconnect();
|
||||
});
|
||||
this.openSockets.wipe();
|
||||
this.socketConnections.wipe();
|
||||
this.io.close();
|
||||
|
||||
// stop the corresponging server
|
||||
@ -69,13 +69,12 @@ export class Smartsocket {
|
||||
/**
|
||||
* allows call to specific client.
|
||||
*/
|
||||
public async clientCall(
|
||||
functionNameArg: string,
|
||||
dataArg: any,
|
||||
public async clientCall<T extends plugins.typedrequestInterfaces.ITypedRequest>(
|
||||
functionNameArg: T['method'],
|
||||
dataArg: T['request'],
|
||||
targetSocketConnectionArg: SocketConnection
|
||||
) {
|
||||
const done = plugins.smartpromise.defer();
|
||||
const socketRequest = new SocketRequest(this, {
|
||||
): Promise<T['response']> {
|
||||
const socketRequest = new SocketRequest<T>(this, {
|
||||
funcCallData: {
|
||||
funcDataArg: dataArg,
|
||||
funcName: functionNameArg
|
||||
@ -84,10 +83,8 @@ export class Smartsocket {
|
||||
shortId: plugins.shortid.generate(),
|
||||
side: 'requesting'
|
||||
});
|
||||
socketRequest.dispatch().then((dataArg2: ISocketFunctionCall) => {
|
||||
done.resolve(dataArg2.funcDataArg);
|
||||
});
|
||||
const result = await done.promise;
|
||||
const response: ISocketFunctionCallDataResponse<T> = await socketRequest.dispatch();
|
||||
const result = response.funcDataArg;
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -101,14 +98,14 @@ export class Smartsocket {
|
||||
return;
|
||||
}
|
||||
|
||||
public addSocketFunction(socketFunction: SocketFunction) {
|
||||
public addSocketFunction(socketFunction: SocketFunction<any>) {
|
||||
this.socketFunctions.add(socketFunction);
|
||||
}
|
||||
|
||||
/**
|
||||
* the standard handler for new socket connections
|
||||
*/
|
||||
private _handleSocketConnection(socketArg) {
|
||||
private async _handleSocketConnection(socketArg: plugins.socketIo.Socket) {
|
||||
const socketConnection: SocketConnection = new SocketConnection({
|
||||
alias: undefined,
|
||||
authenticated: false,
|
||||
@ -118,14 +115,8 @@ export class Smartsocket {
|
||||
socket: socketArg
|
||||
});
|
||||
plugins.smartlog.defaultLogger.log('info', 'Socket connected. Trying to authenticate...');
|
||||
this.openSockets.add(socketConnection);
|
||||
socketConnection
|
||||
.authenticate()
|
||||
.then(() => {
|
||||
return socketConnection.listenToFunctionRequests();
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
});
|
||||
this.socketConnections.add(socketConnection);
|
||||
await socketConnection.authenticate();
|
||||
await socketConnection.listenToFunctionRequests();
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
import * as plugins from './smartsocket.plugins';
|
||||
|
||||
import { SocketConnection } from './smartsocket.classes.socketconnection';
|
||||
import { ISocketFunctionCall, SocketFunction } from './smartsocket.classes.socketfunction';
|
||||
import { ISocketFunctionCallDataRequest, SocketFunction } from './smartsocket.classes.socketfunction';
|
||||
import { ISocketRequestDataObject, SocketRequest } from './smartsocket.classes.socketrequest';
|
||||
import { SocketRole } from './smartsocket.classes.socketrole';
|
||||
|
||||
@ -18,26 +18,28 @@ export interface ISmartsocketClientOptions {
|
||||
|
||||
export class SmartsocketClient {
|
||||
public alias: string;
|
||||
public role: string;
|
||||
public socketRole: SocketRole;
|
||||
public socketConnection: SocketConnection;
|
||||
public serverUrl: string;
|
||||
public serverPort: number;
|
||||
public serverPassword: string;
|
||||
|
||||
public socketFunctions = new plugins.lik.Objectmap<SocketFunction>();
|
||||
public socketRequests = new plugins.lik.Objectmap<SocketRequest>();
|
||||
public socketFunctions = new plugins.lik.Objectmap<SocketFunction<any>>();
|
||||
public socketRequests = new plugins.lik.Objectmap<SocketRequest<any>>();
|
||||
public socketRoles = new plugins.lik.Objectmap<SocketRole>();
|
||||
|
||||
constructor(optionsArg: ISmartsocketClientOptions) {
|
||||
this.alias = optionsArg.alias;
|
||||
this.role = optionsArg.role;
|
||||
this.serverUrl = optionsArg.url;
|
||||
this.serverPort = optionsArg.port;
|
||||
this.serverPassword = optionsArg.password;
|
||||
this.socketRole = new SocketRole({
|
||||
name: optionsArg.role,
|
||||
passwordHash: optionsArg.password
|
||||
});
|
||||
}
|
||||
|
||||
public addSocketFunction(socketFunction: SocketFunction) {
|
||||
public addSocketFunction(socketFunction: SocketFunction<any>) {
|
||||
this.socketFunctions.add(socketFunction);
|
||||
this.socketRole.allowedFunctions.add(socketFunction);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -50,20 +52,20 @@ export class SmartsocketClient {
|
||||
this.socketConnection = new SocketConnection({
|
||||
alias: this.alias,
|
||||
authenticated: false,
|
||||
role: undefined,
|
||||
role: this.socketRole,
|
||||
side: 'client',
|
||||
smartsocketHost: this,
|
||||
socket: plugins.socketIoClient(socketUrl, { multiplex: false })
|
||||
});
|
||||
this.socketConnection.socket.on('requestAuth', () => {
|
||||
console.log('server requested authentication');
|
||||
plugins.smartlog.defaultLogger.log('info', 'server requested authentication');
|
||||
this.socketConnection.socket.emit('dataAuth', {
|
||||
role: this.role,
|
||||
password: this.serverPassword,
|
||||
role: this.socketRole.name,
|
||||
password: this.socketRole.passwordHash,
|
||||
alias: this.alias
|
||||
});
|
||||
this.socketConnection.socket.on('authenticated', () => {
|
||||
console.log('client is authenticated');
|
||||
plugins.smartlog.defaultLogger.log('info', 'client is authenticated');
|
||||
this.socketConnection.authenticated = true;
|
||||
this.socketConnection.listenToFunctionRequests();
|
||||
done.resolve();
|
||||
@ -72,18 +74,23 @@ export class SmartsocketClient {
|
||||
return done.promise;
|
||||
}
|
||||
|
||||
public disconnect() {
|
||||
const done = plugins.smartpromise.defer();
|
||||
this.socketConnection.socket.disconnect();
|
||||
/**
|
||||
* disconnect from the server
|
||||
*/
|
||||
public async disconnect() {
|
||||
this.socketConnection.socket.disconnect(true);
|
||||
this.socketConnection = undefined;
|
||||
plugins.smartlog.defaultLogger.log('ok', 'disconnected!');
|
||||
done.resolve();
|
||||
return done.promise;
|
||||
}
|
||||
|
||||
public serverCall(functionNameArg: string, dataArg: any) {
|
||||
/**
|
||||
* dispatches a server call
|
||||
* @param functionNameArg
|
||||
* @param dataArg
|
||||
*/
|
||||
public async serverCall<T extends plugins.typedrequestInterfaces.ITypedRequest>(functionNameArg: T['method'], dataArg: T['request']): Promise<T['response']> {
|
||||
const done = plugins.smartpromise.defer();
|
||||
const socketRequest = new SocketRequest(this, {
|
||||
const socketRequest = new SocketRequest<T>(this, {
|
||||
side: 'requesting',
|
||||
originSocketConnection: this.socketConnection,
|
||||
shortId: plugins.shortid.generate(),
|
||||
@ -92,9 +99,8 @@ export class SmartsocketClient {
|
||||
funcDataArg: dataArg
|
||||
}
|
||||
});
|
||||
socketRequest.dispatch().then((dataArg2: ISocketFunctionCall) => {
|
||||
done.resolve(dataArg2.funcDataArg);
|
||||
});
|
||||
return done.promise;
|
||||
const response = await socketRequest.dispatch();
|
||||
const result = response.funcDataArg;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -5,10 +5,7 @@ import { Objectmap } from '@pushrocks/lik';
|
||||
// import classes
|
||||
import { Smartsocket } from './smartsocket.classes.smartsocket';
|
||||
import { SocketFunction } from './smartsocket.classes.socketfunction';
|
||||
import {
|
||||
SocketRequest,
|
||||
ISocketRequestDataObject,
|
||||
} from './smartsocket.classes.socketrequest';
|
||||
import { SocketRequest, ISocketRequestDataObject } from './smartsocket.classes.socketrequest';
|
||||
import { SocketRole } from './smartsocket.classes.socketrole';
|
||||
|
||||
// socket.io
|
||||
@ -118,15 +115,15 @@ export class SocketConnection {
|
||||
public listenToFunctionRequests() {
|
||||
const done = plugins.smartpromise.defer();
|
||||
if (this.authenticated) {
|
||||
this.socket.on('function', (dataArg: ISocketRequestDataObject) => {
|
||||
this.socket.on('function', (dataArg: ISocketRequestDataObject<any>) => {
|
||||
// check if requested function is available to the socket's scope
|
||||
plugins.smartlog.defaultLogger.log('info', 'function request received');
|
||||
const referencedFunction: SocketFunction = this.role.allowedFunctions.find(
|
||||
const referencedFunction: SocketFunction<any> = this.role.allowedFunctions.find(
|
||||
socketFunctionArg => {
|
||||
return socketFunctionArg.name === dataArg.funcCallData.funcName;
|
||||
}
|
||||
);
|
||||
if (referencedFunction !== undefined) {
|
||||
if (referencedFunction) {
|
||||
plugins.smartlog.defaultLogger.log('ok', 'function in access scope');
|
||||
const localSocketRequest = new SocketRequest(this.smartsocketRef, {
|
||||
side: 'responding',
|
||||
@ -142,12 +139,15 @@ export class SocketConnection {
|
||||
);
|
||||
}
|
||||
});
|
||||
this.socket.on('functionResponse', (dataArg: ISocketRequestDataObject) => {
|
||||
this.socket.on('functionResponse', (dataArg: ISocketRequestDataObject<any>) => {
|
||||
plugins.smartlog.defaultLogger.log(
|
||||
'info',
|
||||
`received response for request with id ${dataArg.shortId}`
|
||||
);
|
||||
const targetSocketRequest = SocketRequest.getSocketRequestById(this.smartsocketRef, dataArg.shortId);
|
||||
const targetSocketRequest = SocketRequest.getSocketRequestById(
|
||||
this.smartsocketRef,
|
||||
dataArg.shortId
|
||||
);
|
||||
targetSocketRequest.handleResponse(dataArg);
|
||||
});
|
||||
plugins.smartlog.defaultLogger.log(
|
||||
|
@ -12,34 +12,44 @@ import { SmartsocketClient } from './smartsocket.classes.smartsocketclient';
|
||||
/**
|
||||
* interface of the contructor options of class SocketFunction
|
||||
*/
|
||||
export interface ISocketFunctionConstructorOptions {
|
||||
funcName: string;
|
||||
funcDef: TFuncDef;
|
||||
export interface ISocketFunctionConstructorOptions<T extends plugins.typedrequestInterfaces.ITypedRequest> {
|
||||
funcName: T['method'];
|
||||
funcDef: TFuncDef<T>;
|
||||
allowedRoles: SocketRole[]; // all roles that are allowed to execute a SocketFunction
|
||||
}
|
||||
|
||||
/**
|
||||
* interface of the Socket Function call, in other words the object that routes a call to a function
|
||||
*/
|
||||
export interface ISocketFunctionCall {
|
||||
funcName: string;
|
||||
funcDataArg: any;
|
||||
export interface ISocketFunctionCallDataRequest<T extends plugins.typedrequestInterfaces.ITypedRequest> {
|
||||
funcName: T['method'];
|
||||
funcDataArg: T['request'];
|
||||
}
|
||||
|
||||
/**
|
||||
* interface of the Socket Function call, in other words the object that routes a call to a function
|
||||
*/
|
||||
export interface ISocketFunctionCallDataResponse<T extends plugins.typedrequestInterfaces.ITypedRequest> {
|
||||
funcName: T['method'];
|
||||
funcDataArg: T['response'];
|
||||
}
|
||||
|
||||
/**
|
||||
* interface for function definition of SocketFunction
|
||||
*/
|
||||
export type TFuncDef = (dataArg: any, connectionArg: SocketConnection) => PromiseLike<any>;
|
||||
export type TFuncDef<T extends plugins.typedrequestInterfaces.ITypedRequest> = (dataArg: T['request'], connectionArg: SocketConnection) => PromiseLike<T['response']>;
|
||||
|
||||
// export classes
|
||||
|
||||
/**
|
||||
* class that respresents a function that can be transparently called using a SocketConnection
|
||||
*/
|
||||
export class SocketFunction {
|
||||
export class SocketFunction<T extends plugins.typedrequestInterfaces.ITypedRequest> {
|
||||
// STATIC
|
||||
public static getSocketFunctionByName (smartsocketRefArg: Smartsocket | SmartsocketClient, functionNameArg: string): SocketFunction {
|
||||
console.log(smartsocketRefArg.socketFunctions);
|
||||
public static getSocketFunctionByName<Q extends plugins.typedrequestInterfaces.ITypedRequest>(
|
||||
smartsocketRefArg: Smartsocket | SmartsocketClient,
|
||||
functionNameArg: string
|
||||
): SocketFunction<Q> {
|
||||
return smartsocketRefArg.socketFunctions.find(socketFunctionArg => {
|
||||
return socketFunctionArg.name === functionNameArg;
|
||||
});
|
||||
@ -47,13 +57,13 @@ export class SocketFunction {
|
||||
|
||||
// INSTANCE
|
||||
public name: string;
|
||||
public funcDef: TFuncDef;
|
||||
public funcDef: TFuncDef<T>;
|
||||
public roles: SocketRole[];
|
||||
|
||||
/**
|
||||
* the constructor for SocketFunction
|
||||
*/
|
||||
constructor(optionsArg: ISocketFunctionConstructorOptions) {
|
||||
constructor(optionsArg: ISocketFunctionConstructorOptions<T>) {
|
||||
this.name = optionsArg.funcName;
|
||||
this.funcDef = optionsArg.funcDef;
|
||||
this.roles = optionsArg.allowedRoles;
|
||||
@ -65,20 +75,16 @@ export class SocketFunction {
|
||||
/**
|
||||
* invokes the function of this SocketFunction
|
||||
*/
|
||||
public invoke(dataArg: ISocketFunctionCall, socketConnectionArg: SocketConnection): Promise<any> {
|
||||
const done = plugins.smartpromise.defer();
|
||||
public async invoke(dataArg: ISocketFunctionCallDataRequest<T>, socketConnectionArg: SocketConnection): Promise<ISocketFunctionCallDataResponse<T>> {
|
||||
if (dataArg.funcName === this.name) {
|
||||
this.funcDef(dataArg.funcDataArg, socketConnectionArg).then((resultData: any) => {
|
||||
const funcResponseData: ISocketFunctionCall = {
|
||||
funcName: this.name,
|
||||
funcDataArg: resultData
|
||||
};
|
||||
done.resolve(funcResponseData);
|
||||
});
|
||||
const funcResponseData: ISocketFunctionCallDataResponse<T> = {
|
||||
funcName: this.name,
|
||||
funcDataArg: await this.funcDef(dataArg.funcDataArg, socketConnectionArg)
|
||||
};
|
||||
return funcResponseData;
|
||||
} else {
|
||||
throw new Error("SocketFunction.name does not match the data argument's .name!");
|
||||
}
|
||||
return done.promise;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,7 +1,7 @@
|
||||
import * as plugins from './smartsocket.plugins';
|
||||
|
||||
// import interfaces
|
||||
import { SocketFunction, ISocketFunctionCall } from './smartsocket.classes.socketfunction';
|
||||
import { SocketFunction, ISocketFunctionCallDataRequest, ISocketFunctionCallDataResponse } from './smartsocket.classes.socketfunction';
|
||||
|
||||
// import classes
|
||||
import { Objectmap } from '@pushrocks/lik';
|
||||
@ -17,29 +17,29 @@ export type TSocketRequestSide = 'requesting' | 'responding';
|
||||
/**
|
||||
* interface of constructor of class SocketRequest
|
||||
*/
|
||||
export interface SocketRequestConstructorOptions {
|
||||
export interface ISocketRequestConstructorOptions<T extends plugins.typedrequestInterfaces.ITypedRequest> {
|
||||
side: TSocketRequestSide;
|
||||
originSocketConnection: SocketConnection;
|
||||
shortId: string;
|
||||
funcCallData?: ISocketFunctionCall;
|
||||
funcCallData?: ISocketFunctionCallDataRequest<T>;
|
||||
}
|
||||
|
||||
/**
|
||||
* request object that is sent initially and may or may not receive a response
|
||||
*/
|
||||
export interface ISocketRequestDataObject {
|
||||
funcCallData: ISocketFunctionCall;
|
||||
export interface ISocketRequestDataObject<T extends plugins.typedrequestInterfaces.ITypedRequest> {
|
||||
funcCallData: ISocketFunctionCallDataRequest<T> | ISocketFunctionCallDataResponse<T>;
|
||||
shortId: string;
|
||||
responseTimeout?: number;
|
||||
}
|
||||
|
||||
// export classes
|
||||
export class SocketRequest {
|
||||
export class SocketRequest<T extends plugins.typedrequestInterfaces.ITypedRequest> {
|
||||
// STATIC
|
||||
public static getSocketRequestById(
|
||||
smartsocketRef: Smartsocket | SmartsocketClient,
|
||||
shortIdArg: string
|
||||
): SocketRequest {
|
||||
): SocketRequest<any> {
|
||||
return smartsocketRef.socketRequests.find(socketRequestArg => {
|
||||
return socketRequestArg.shortid === shortIdArg;
|
||||
});
|
||||
@ -50,13 +50,15 @@ export class SocketRequest {
|
||||
public side: TSocketRequestSide;
|
||||
public shortid: string;
|
||||
public originSocketConnection: SocketConnection;
|
||||
public funcCallData: ISocketFunctionCall;
|
||||
public done = plugins.smartpromise.defer();
|
||||
public funcCallData: ISocketFunctionCallDataRequest<T>;
|
||||
public done = plugins.smartpromise.defer<ISocketFunctionCallDataResponse<T>>();
|
||||
|
||||
public smartsocketRef: Smartsocket | SmartsocketClient;
|
||||
|
||||
|
||||
constructor(smartsocketRefArg: Smartsocket | SmartsocketClient, optionsArg: SocketRequestConstructorOptions) {
|
||||
constructor(
|
||||
smartsocketRefArg: Smartsocket | SmartsocketClient,
|
||||
optionsArg: ISocketRequestConstructorOptions<T>
|
||||
) {
|
||||
this.smartsocketRef = smartsocketRefArg;
|
||||
this.side = optionsArg.side;
|
||||
this.shortid = optionsArg.shortId;
|
||||
@ -70,8 +72,8 @@ export class SocketRequest {
|
||||
/**
|
||||
* dispatches a socketrequest from the requesting to the receiving side
|
||||
*/
|
||||
public dispatch() {
|
||||
const requestData: ISocketRequestDataObject = {
|
||||
public dispatch(): Promise<ISocketFunctionCallDataResponse<T>> {
|
||||
const requestData: ISocketRequestDataObject<T> = {
|
||||
funcCallData: this.funcCallData,
|
||||
shortId: this.shortid
|
||||
};
|
||||
@ -82,7 +84,7 @@ export class SocketRequest {
|
||||
/**
|
||||
* handles the response that is received by the requesting side
|
||||
*/
|
||||
public handleResponse(responseDataArg: ISocketRequestDataObject) {
|
||||
public async handleResponse(responseDataArg: ISocketRequestDataObject<T>) {
|
||||
plugins.smartlog.defaultLogger.log('info', 'handling response!');
|
||||
this.done.resolve(responseDataArg.funcCallData);
|
||||
this.smartsocketRef.socketRequests.remove(this);
|
||||
@ -94,7 +96,7 @@ export class SocketRequest {
|
||||
* creates the response on the responding side
|
||||
*/
|
||||
public async createResponse(): Promise<void> {
|
||||
const targetSocketFunction: SocketFunction = SocketFunction.getSocketFunctionByName(
|
||||
const targetSocketFunction: SocketFunction<T> = SocketFunction.getSocketFunctionByName(
|
||||
this.smartsocketRef,
|
||||
this.funcCallData.funcName
|
||||
);
|
||||
@ -110,11 +112,11 @@ export class SocketRequest {
|
||||
plugins.smartlog.defaultLogger.log('info', `invoking ${targetSocketFunction.name}`);
|
||||
targetSocketFunction.invoke(this.funcCallData, this.originSocketConnection).then(resultData => {
|
||||
plugins.smartlog.defaultLogger.log('info', 'got resultData. Sending it to requesting party.');
|
||||
const requestData: ISocketRequestDataObject = {
|
||||
const responseData: ISocketRequestDataObject<T> = {
|
||||
funcCallData: resultData,
|
||||
shortId: this.shortid
|
||||
};
|
||||
this.originSocketConnection.socket.emit('functionResponse', requestData);
|
||||
this.originSocketConnection.socket.emit('functionResponse', responseData);
|
||||
this.smartsocketRef.socketRequests.remove(this);
|
||||
});
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
import * as plugins from './smartsocket.plugins';
|
||||
|
||||
|
||||
// import classes
|
||||
import { Objectmap } from '@pushrocks/lik';
|
||||
import { SocketFunction } from './smartsocket.classes.socketfunction';
|
||||
@ -11,7 +10,7 @@ import { ISocketConnectionAuthenticationObject } from './smartsocket.classes.soc
|
||||
/**
|
||||
* interface for class SocketRole
|
||||
*/
|
||||
export interface SocketRoleOptions {
|
||||
export interface ISocketRoleOptions {
|
||||
name: string;
|
||||
passwordHash: string;
|
||||
}
|
||||
@ -23,18 +22,19 @@ export class SocketRole {
|
||||
// STATIC
|
||||
public static getSocketRoleByName(
|
||||
referenceSmartsocket: Smartsocket | SmartsocketClient,
|
||||
socketRoleNameArg: string,
|
||||
): SocketRole{
|
||||
socketRoleNameArg: string
|
||||
): SocketRole {
|
||||
return referenceSmartsocket.socketRoles.find(socketRoleArg => {
|
||||
return socketRoleArg.name === socketRoleNameArg;
|
||||
});
|
||||
}
|
||||
|
||||
public static checkPasswordForRole (
|
||||
public static checkPasswordForRole(
|
||||
dataArg: ISocketConnectionAuthenticationObject,
|
||||
referenceSmartsocket: Smartsocket | SmartsocketClient
|
||||
): boolean {
|
||||
const targetPasswordHash = SocketRole.getSocketRoleByName(referenceSmartsocket, dataArg.role).passwordHash;
|
||||
const targetPasswordHash = SocketRole.getSocketRoleByName(referenceSmartsocket, dataArg.role)
|
||||
.passwordHash;
|
||||
const computedCompareHash = plugins.smarthash.sha256FromStringSync(dataArg.password);
|
||||
return targetPasswordHash === computedCompareHash;
|
||||
}
|
||||
@ -42,12 +42,17 @@ export class SocketRole {
|
||||
// INSTANCE
|
||||
public name: string;
|
||||
public passwordHash: string;
|
||||
public allowedFunctions = new Objectmap<SocketFunction>();
|
||||
constructor(optionsArg: SocketRoleOptions) {
|
||||
public allowedFunctions = new Objectmap<SocketFunction<any>>();
|
||||
constructor(optionsArg: ISocketRoleOptions) {
|
||||
this.name = optionsArg.name;
|
||||
this.passwordHash = optionsArg.passwordHash;
|
||||
}
|
||||
public addSocketFunction(socketFunctionArg: SocketFunction) {
|
||||
|
||||
/**
|
||||
* adds the socketfunction to the socketrole
|
||||
* @param socketFunctionArg
|
||||
*/
|
||||
public addSocketFunction(socketFunctionArg: SocketFunction<any>) {
|
||||
this.allowedFunctions.add(socketFunctionArg);
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ import * as plugins from './smartsocket.plugins';
|
||||
|
||||
// used in case no other server is supplied
|
||||
import * as http from 'http';
|
||||
import * as https from 'https';
|
||||
import { Smartsocket } from './smartsocket.classes.smartsocket';
|
||||
|
||||
/**
|
||||
@ -10,7 +11,7 @@ import { Smartsocket } from './smartsocket.classes.smartsocket';
|
||||
*/
|
||||
export class SocketServer {
|
||||
private smartsocket: Smartsocket;
|
||||
private httpServer: http.Server;
|
||||
private httpServer: http.Server | https.Server;
|
||||
// wether httpServer is standalone
|
||||
private standaloneServer = false;
|
||||
private expressServer: any;
|
||||
@ -54,11 +55,11 @@ export class SocketServer {
|
||||
// in case an external server has been set "this.standaloneServer" should be false
|
||||
if (this.httpServer && this.standaloneServer) {
|
||||
if (!this.smartsocket.options.port) {
|
||||
console.log('there should be a port specifed for smartsocket!');
|
||||
plugins.smartlog.defaultLogger.log('error', 'there should be a port specifed for smartsocket!');
|
||||
throw new Error('there should be a port specified for smartsocket');
|
||||
}
|
||||
this.httpServer.listen(this.smartsocket.options.port, () => {
|
||||
console.log(`Server started in standalone mode on ${this.smartsocket.options.port}`);
|
||||
plugins.smartlog.defaultLogger.log('success', `Server started in standalone mode on ${this.smartsocket.options.port}`);
|
||||
done.resolve();
|
||||
});
|
||||
} else {
|
||||
|
@ -1,12 +1,16 @@
|
||||
// apiglobal scope
|
||||
import * as typedrequestInterfaces from '@apiglobal/typedrequest-interfaces';
|
||||
|
||||
export {typedrequestInterfaces};
|
||||
|
||||
// pushrocks scope
|
||||
import * as lik from '@pushrocks/lik';
|
||||
import * as smartlog from '@pushrocks/smartlog';
|
||||
import * as smarthash from '@pushrocks/smarthash';
|
||||
import * as smartdelay from '@pushrocks/smartdelay';
|
||||
import * as smartexpress from '@pushrocks/smartexpress';
|
||||
import * as smartpromise from '@pushrocks/smartpromise';
|
||||
import * as shortid from 'shortid';
|
||||
import socketIo from 'socket.io';
|
||||
import socketIoClient from 'socket.io-client';
|
||||
|
||||
|
||||
export {
|
||||
lik,
|
||||
@ -14,7 +18,15 @@ export {
|
||||
smarthash,
|
||||
smartdelay,
|
||||
smartexpress,
|
||||
smartpromise,
|
||||
smartpromise
|
||||
};
|
||||
|
||||
// third party scope
|
||||
import * as shortid from 'shortid';
|
||||
import socketIo from 'socket.io';
|
||||
import socketIoClient from 'socket.io-client';
|
||||
|
||||
export {
|
||||
shortid,
|
||||
socketIo,
|
||||
socketIoClient
|
||||
|
Reference in New Issue
Block a user