diff --git a/package-lock.json b/package-lock.json index f35fc38..2630c54 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,6 +10,8 @@ "license": "MIT", "dependencies": { "@koa/router": "^12.0.0", + "@rocket.chat/core-typings": "^6.3.0-rc.2", + "@rocket.chat/ddp-client": "^0.0.2-rc.2", "@rocket.chat/emitter": "^0.31", "@rocket.chat/sdk": "next", "@supercharge/promise-pool": "^2.4.0", @@ -1542,6 +1544,68 @@ "node": ">=14" } }, + "node_modules/@rocket.chat/api-client": { + "version": "0.1.0-rc.2", + "resolved": "https://registry.npmjs.org/@rocket.chat/api-client/-/api-client-0.1.0-rc.2.tgz", + "integrity": "sha512-5Ybxy9TejPIV85cuHdHsE+i+tklNtly5yzhGRnqdDa9744UUbHuAbbeTITPDC7luXSoMOr6jzxjxySTDDT4uVQ==", + "dependencies": { + "@rocket.chat/core-typings": "^6.3.0-rc.2", + "@rocket.chat/rest-typings": "^6.3.0-rc.2", + "filter-obj": "^3.0.0", + "query-string": "^7.1.3", + "split-on-first": "^3.0.0", + "strict-uri-encode": "^2.0.0" + } + }, + "node_modules/@rocket.chat/apps-engine": { + "version": "1.39.1", + "resolved": "https://registry.npmjs.org/@rocket.chat/apps-engine/-/apps-engine-1.39.1.tgz", + "integrity": "sha512-AxsDzrjnp9Cp22Ba3XTFgbZBi+nVdsuCf4OVRUPsPJspi0jf3X7HyrKkgaxMmr9H96HB+LzVEm9lXq6VFyqYog==", + "dependencies": { + "adm-zip": "^0.5.9", + "cryptiles": "^4.1.3", + "jose": "^4.11.1", + "lodash.clonedeep": "^4.5.0", + "semver": "^5.7.1", + "stack-trace": "0.0.10", + "uuid": "^3.4.0", + "vm2": "^3.9.19" + }, + "peerDependencies": { + "@rocket.chat/ui-kit": "next" + } + }, + "node_modules/@rocket.chat/apps-engine/node_modules/semver": { + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", + "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", + "bin": { + "semver": "bin/semver" + } + }, + "node_modules/@rocket.chat/core-typings": { + "version": "6.3.0-rc.2", + "resolved": "https://registry.npmjs.org/@rocket.chat/core-typings/-/core-typings-6.3.0-rc.2.tgz", + "integrity": "sha512-03ox4QGMFIo7+oiM8YU8VXIEuw9ygpJLa1Imh9NKFfurenfC6eM7iE4abiXO7cS1y1Kj7FDE+qEvOQmsn/8wjg==", + "dependencies": { + "@rocket.chat/apps-engine": "1.39.1", + "@rocket.chat/icons": "next", + "@rocket.chat/message-parser": "next", + "@rocket.chat/ui-kit": "next" + } + }, + "node_modules/@rocket.chat/ddp-client": { + "version": "0.0.2-rc.2", + "resolved": "https://registry.npmjs.org/@rocket.chat/ddp-client/-/ddp-client-0.0.2-rc.2.tgz", + "integrity": "sha512-kqC+zz+dSrwITu1OyOMZqzZ3qMkZmWx8QAsJH2NFeGdBBORnXyq5NpJaNhkQFPhb+Fz+lS0pNhz2UloSOJfDkw==", + "dependencies": { + "@rocket.chat/api-client": "^0.1.0-rc.2", + "@rocket.chat/rest-typings": "^6.3.0-rc.2" + }, + "peerDependencies": { + "@rocket.chat/emitter": "*" + } + }, "node_modules/@rocket.chat/emitter": { "version": "0.31.23", "resolved": "https://registry.npmjs.org/@rocket.chat/emitter/-/emitter-0.31.23.tgz", @@ -1582,6 +1646,52 @@ "url": "https://github.com/prettier/prettier?sponsor=1" } }, + "node_modules/@rocket.chat/icons": { + "version": "0.32.0-dev.371", + "resolved": "https://registry.npmjs.org/@rocket.chat/icons/-/icons-0.32.0-dev.371.tgz", + "integrity": "sha512-OwWOcNApL2a6BWzd/svZnGnzUptlvi7mMpzxQtY1NrZIHRN3ROSPMnf9mtNwQ6ppUbl6POgHZ3aeVKxEgmYflw==" + }, + "node_modules/@rocket.chat/message-parser": { + "version": "0.32.0-dev.337", + "resolved": "https://registry.npmjs.org/@rocket.chat/message-parser/-/message-parser-0.32.0-dev.337.tgz", + "integrity": "sha512-jBOuGyFZDlVql2zu1+9QAp/DPbBkI5nY0MooRdBShj5joOQIFfheJmZS2FoWHJ3EduMvXFMFfzhx3S+iXbEjGQ==", + "dependencies": { + "tldts": "~5.7.112" + } + }, + "node_modules/@rocket.chat/rest-typings": { + "version": "6.3.0-rc.2", + "resolved": "https://registry.npmjs.org/@rocket.chat/rest-typings/-/rest-typings-6.3.0-rc.2.tgz", + "integrity": "sha512-LCk+EyhFbcz3a/1baeZjeYNSbmcRnG+QtZp6bwbviNGyUpf2X5jn43aWPYjVavQ0+sTr8OFNb8qrpOrlmXGNVQ==", + "dependencies": { + "@rocket.chat/apps-engine": "1.39.1", + "@rocket.chat/core-typings": "^6.3.0-rc.2", + "@rocket.chat/message-parser": "next", + "@rocket.chat/ui-kit": "next", + "ajv": "^8.11.0", + "ajv-formats": "^2.1.1" + } + }, + "node_modules/@rocket.chat/rest-typings/node_modules/ajv": { + "version": "8.12.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.12.0.tgz", + "integrity": "sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==", + "dependencies": { + "fast-deep-equal": "^3.1.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/@rocket.chat/rest-typings/node_modules/json-schema-traverse": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==" + }, "node_modules/@rocket.chat/sdk": { "version": "1.0.0-alpha.42", "resolved": "https://registry.npmjs.org/@rocket.chat/sdk/-/sdk-1.0.0-alpha.42.tgz", @@ -1598,6 +1708,14 @@ "npm": "> 5.0.0" } }, + "node_modules/@rocket.chat/ui-kit": { + "version": "0.32.0-dev.324", + "resolved": "https://registry.npmjs.org/@rocket.chat/ui-kit/-/ui-kit-0.32.0-dev.324.tgz", + "integrity": "sha512-59xJySgj8FjNfIhTAA+mPvnACvSRufGEpmpgDW/nUGdi4GWsHtWIo/rA0nlRHMR8Har8dg1yotQiHmhIKMUsvg==", + "peerDependencies": { + "@rocket.chat/icons": "*" + } + }, "node_modules/@selderee/plugin-htmlparser2": { "version": "0.11.0", "resolved": "https://registry.npmjs.org/@selderee/plugin-htmlparser2/-/plugin-htmlparser2-0.11.0.tgz", @@ -2258,7 +2376,6 @@ "version": "8.9.0", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.9.0.tgz", "integrity": "sha512-jaVNAFBHNLXspO543WnNNPZFRtavh3skAkITqD0/2aeMkKZTN+254PyhwxFYrk3vQ1xfY+2wbesJMs/JC8/PwQ==", - "dev": true, "bin": { "acorn": "bin/acorn" }, @@ -2275,6 +2392,22 @@ "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" } }, + "node_modules/acorn-walk": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz", + "integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/adm-zip": { + "version": "0.5.10", + "resolved": "https://registry.npmjs.org/adm-zip/-/adm-zip-0.5.10.tgz", + "integrity": "sha512-x0HvcHqVJNTPk/Bw8JbLWlWoo6Wwnsug0fnYYro1HBrjxZ3G7/AZk7Ahv8JwDe1uIcz8eBqvu86FuF1POiG7vQ==", + "engines": { + "node": ">=6.0" + } + }, "node_modules/aggregate-error": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/aggregate-error/-/aggregate-error-3.1.0.tgz", @@ -2304,6 +2437,42 @@ "url": "https://github.com/sponsors/epoberezkin" } }, + "node_modules/ajv-formats": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ajv-formats/-/ajv-formats-2.1.1.tgz", + "integrity": "sha512-Wx0Kx52hxE7C18hkMEggYlEifqWZtYaRgouJor+WMdPnQyEK13vgEWyVNup7SoeeoLMsr4kf5h6dOW11I15MUA==", + "dependencies": { + "ajv": "^8.0.0" + }, + "peerDependencies": { + "ajv": "^8.0.0" + }, + "peerDependenciesMeta": { + "ajv": { + "optional": true + } + } + }, + "node_modules/ajv-formats/node_modules/ajv": { + "version": "8.12.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.12.0.tgz", + "integrity": "sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==", + "dependencies": { + "fast-deep-equal": "^3.1.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/ajv-formats/node_modules/json-schema-traverse": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==" + }, "node_modules/ansi-escapes": { "version": "4.3.2", "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.2.tgz", @@ -3373,6 +3542,15 @@ "resolved": "https://registry.npmjs.org/bintrees/-/bintrees-1.0.2.tgz", "integrity": "sha512-VOMgTMwjAaUG580SXn3LacVgjurrbMme7ZZNYGSSV7mmtY6QQRh0Eg3pwIcntQ77DErK1L0NxkbetjcoXzVwKw==" }, + "node_modules/boom": { + "version": "7.3.0", + "resolved": "https://registry.npmjs.org/boom/-/boom-7.3.0.tgz", + "integrity": "sha512-Swpoyi2t5+GhOEGw8rEsKvTxFLIDiiKoUc2gsoV6Lyr43LHBIzch3k2MvYUs8RTROrIkVJ3Al0TkaOGjnb+B6A==", + "deprecated": "This module has moved and is now available at @hapi/boom. Please update your dependencies as this version is no longer maintained an may contain bugs and security issues.", + "dependencies": { + "hoek": "6.x.x" + } + }, "node_modules/brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -3923,6 +4101,15 @@ "node": ">= 8" } }, + "node_modules/cryptiles": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-4.1.3.tgz", + "integrity": "sha512-gT9nyTMSUC1JnziQpPbxKGBbUg8VL7Zn2NB4E1cJYvuXdElHrwxrV9bmltZGDzet45zSDGyYceueke1TjynGzw==", + "deprecated": "This module has moved and is now available at @hapi/cryptiles. Please update your dependencies as this version is no longer maintained an may contain bugs and security issues.", + "dependencies": { + "boom": "7.x.x" + } + }, "node_modules/debug": { "version": "4.3.4", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", @@ -3984,6 +4171,14 @@ "node": ">=0.10.0" } }, + "node_modules/decode-uri-component": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.2.tgz", + "integrity": "sha512-FqUYQ+8o158GyGTrMFJms9qh3CqTKvAqgqsTnkLI8sKu0028orqBhxNMFkFen0zGyg6epACD32pjVk58ngIErQ==", + "engines": { + "node": ">=0.10" + } + }, "node_modules/dedent": { "version": "0.7.0", "resolved": "https://registry.npmjs.org/dedent/-/dedent-0.7.0.tgz", @@ -4945,8 +5140,7 @@ "node_modules/fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", - "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", - "dev": true + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==" }, "node_modules/fast-diff": { "version": "1.3.0", @@ -5029,6 +5223,17 @@ "node": ">=8" } }, + "node_modules/filter-obj": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/filter-obj/-/filter-obj-3.0.0.tgz", + "integrity": "sha512-oQZM+QmVni8MsYzcq9lgTHD/qeLqaG8XaOPOW7dzuSafVxSUlH1+1ZDefj2OD9f2XsmG5lFl2Euc9NI4jgwFWg==", + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/find-up": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", @@ -5480,6 +5685,12 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/hoek": { + "version": "6.1.3", + "resolved": "https://registry.npmjs.org/hoek/-/hoek-6.1.3.tgz", + "integrity": "sha512-YXXAAhmF9zpQbC7LEcREFtXfGq5K1fmd+4PHkBq8NUqmzW3G+Dq10bI/i0KucLRwss3YYFQ0fSfoxBZYiGUqtQ==", + "deprecated": "This module has moved and is now available at @hapi/hoek. Please update your dependencies as this version is no longer maintained an may contain bugs and security issues." + }, "node_modules/hosted-git-info": { "version": "2.8.9", "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz", @@ -6839,6 +7050,14 @@ } } }, + "node_modules/jose": { + "version": "4.14.4", + "resolved": "https://registry.npmjs.org/jose/-/jose-4.14.4.tgz", + "integrity": "sha512-j8GhLiKmUAh+dsFXlX1aJCbt5KMibuKb+d7j1JaOJG6s2UjX1PQlW+OKB/sD4a/5ZYF4RcmYmLSndOoU3Lt/3g==", + "funding": { + "url": "https://github.com/sponsors/panva" + } + }, "node_modules/js-sha256": { "version": "0.9.0", "resolved": "https://registry.npmjs.org/js-sha256/-/js-sha256-0.9.0.tgz", @@ -7329,6 +7548,11 @@ "node": ">=8" } }, + "node_modules/lodash.clonedeep": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz", + "integrity": "sha512-H5ZhCF25riFd9uB5UCkVKo61m3S/xZk1x4wA6yp/L3RFP6Z/eHH1ymQcGLo7J3GMPfm0V/7m1tryHuGVxpqEBQ==" + }, "node_modules/lodash.iserror": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/lodash.iserror/-/lodash.iserror-3.1.1.tgz", @@ -8941,6 +9165,39 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/query-string": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/query-string/-/query-string-7.1.3.tgz", + "integrity": "sha512-hh2WYhq4fi8+b+/2Kg9CEge4fDPvHS534aOOvOZeQ3+Vf2mCFsaFBYj0i+iXcAq6I9Vzp5fjMFBlONvayDC1qg==", + "dependencies": { + "decode-uri-component": "^0.2.2", + "filter-obj": "^1.1.0", + "split-on-first": "^1.0.0", + "strict-uri-encode": "^2.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/query-string/node_modules/filter-obj": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/filter-obj/-/filter-obj-1.1.0.tgz", + "integrity": "sha512-8rXg1ZnX7xzy2NGDVkBVaAy+lSlPNwad13BtgSlLuxfIslyt5Vg64U7tFcCt4WS1R0hvtnQybT/IyCkGZ3DpXQ==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/query-string/node_modules/split-on-first": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/split-on-first/-/split-on-first-1.1.0.tgz", + "integrity": "sha512-43ZssAJaMusuKWL8sKUBQXHWOpq8d6CfN/u1p4gUzfJkM05C8rxTmYrkIPTXapZpORA6LkkzcUulJ8FqA7Uudw==", + "engines": { + "node": ">=6" + } + }, "node_modules/queue-microtask": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", @@ -9316,6 +9573,14 @@ "node": ">=0.10.0" } }, + "node_modules/require-from-string": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", + "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/resolve": { "version": "1.22.2", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.2.tgz", @@ -9828,12 +10093,31 @@ "integrity": "sha512-uBIcIl3Ih6Phe3XHK1NqboJLdGfwr1UN3k6wSD1dZpmPsIkb8AGNbZYJ1fOBk834+Gxy8rpfDxrS6XLEMZMY2g==", "dev": true }, + "node_modules/split-on-first": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/split-on-first/-/split-on-first-3.0.0.tgz", + "integrity": "sha512-qxQJTx2ryR0Dw0ITYyekNQWpz6f8dGd7vffGNflQQ3Iqj9NJ6qiZ7ELpZsJ/QBhIVAiDfXdag3+Gp8RvWa62AA==", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/sprintf-js": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==", "dev": true }, + "node_modules/stack-trace": { + "version": "0.0.10", + "resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz", + "integrity": "sha512-KGzahc7puUKkzyMt+IqAep+TVNbKP+k2Lmwhub39m1AsTSkaDutx56aDCo+HLDzf/D26BIHTJWNiTG1KAJiQCg==", + "engines": { + "node": "*" + } + }, "node_modules/stack-utils": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/stack-utils/-/stack-utils-2.0.6.tgz", @@ -9880,6 +10164,14 @@ "readable-stream": "2" } }, + "node_modules/strict-uri-encode": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/strict-uri-encode/-/strict-uri-encode-2.0.0.tgz", + "integrity": "sha512-QwiXZgpRcKkhTj2Scnn++4PKtWsH0kpzZ62L2R6c/LUVYv7hVnZqcg2+sMuT6R7Jusu1vviK/MFsu6kNJfWlEQ==", + "engines": { + "node": ">=4" + } + }, "node_modules/string_decoder": { "version": "1.1.1", "resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", @@ -10624,6 +10916,22 @@ "resolved": "https://registry.npmjs.org/tiny-events/-/tiny-events-1.0.1.tgz", "integrity": "sha512-QuhRLBsUWwrj+7mVvffHWmtHmMjt4GihlCN8/WucyHBqDINW9n9K5xsdfK3MdIeJIHRlmI4zI6izU1jbD3kn6Q==" }, + "node_modules/tldts": { + "version": "5.7.112", + "resolved": "https://registry.npmjs.org/tldts/-/tldts-5.7.112.tgz", + "integrity": "sha512-6VSJ/C0uBtc2PQlLsp4IT8MIk2UUh6qVeXB1HZtK+0HiXlAPzNcfF3p2WM9RqCO/2X1PIa4danlBLPoC2/Tc7A==", + "dependencies": { + "tldts-core": "^5.7.112" + }, + "bin": { + "tldts": "bin/cli.js" + } + }, + "node_modules/tldts-core": { + "version": "5.7.112", + "resolved": "https://registry.npmjs.org/tldts-core/-/tldts-core-5.7.112.tgz", + "integrity": "sha512-mutrEUgG2sp0e/MIAnv9TbSLR0IPbvmAImpzqul5O/HJ2XM1/I1sajchQ/fbj0fPdA31IiuWde8EUhfwyldY1Q==" + }, "node_modules/tmpl": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/tmpl/-/tmpl-1.0.5.tgz", @@ -11004,7 +11312,6 @@ "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", - "dev": true, "dependencies": { "punycode": "^2.1.0" } @@ -11014,6 +11321,15 @@ "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" }, + "node_modules/uuid": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", + "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", + "deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.", + "bin": { + "uuid": "bin/uuid" + } + }, "node_modules/v8-compile-cache-lib": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", @@ -11083,6 +11399,22 @@ "node": ">= 0.8" } }, + "node_modules/vm2": { + "version": "3.9.19", + "resolved": "https://registry.npmjs.org/vm2/-/vm2-3.9.19.tgz", + "integrity": "sha512-J637XF0DHDMV57R6JyVsTak7nIL8gy5KH4r1HiwWLf/4GBbb5MKL5y7LpmF4A8E2nR6XmzpmMFQ7V7ppPTmUQg==", + "deprecated": "The library contains critical security issues and should not be used for production! The maintenance of the project has been discontinued. Consider migrating your code to isolated-vm.", + "dependencies": { + "acorn": "^8.7.0", + "acorn-walk": "^8.2.0" + }, + "bin": { + "vm2": "bin/vm2" + }, + "engines": { + "node": ">=6.0" + } + }, "node_modules/walker": { "version": "1.0.8", "resolved": "https://registry.npmjs.org/walker/-/walker-1.0.8.tgz", diff --git a/package.json b/package.json index 7a586fa..df23429 100644 --- a/package.json +++ b/package.json @@ -60,6 +60,8 @@ }, "dependencies": { "@koa/router": "^12.0.0", + "@rocket.chat/core-typings": "^6.3.0-rc.2", + "@rocket.chat/ddp-client": "^0.0.2-rc.2", "@rocket.chat/emitter": "^0.31", "@rocket.chat/sdk": "next", "@supercharge/promise-pool": "^2.4.0", diff --git a/src/client/Client.ts b/src/client/Client.ts index 905d2f2..56832a5 100644 --- a/src/client/Client.ts +++ b/src/client/Client.ts @@ -1,10 +1,9 @@ import { URLSearchParams } from 'url'; -import RocketChatClient from '@rocket.chat/sdk/lib/clients/Rocketchat'; +import { DDPSDK } from '@rocket.chat/ddp-client'; import EJSON from 'ejson'; import fetch from 'node-fetch'; -import type Api from '@rocket.chat/sdk/lib/api/api'; -import type { IAPIRequest, ISubscription } from '@rocket.chat/sdk/interfaces'; +import type { UserStatus } from '@rocket.chat/core-typings'; import { config } from '../config'; import type { Subscription } from '../definifitons'; @@ -14,22 +13,19 @@ import * as prom from '../lib/prom'; import { rand } from '../lib/rand'; import { action, errorLogger, suppressError } from './decorators'; -const logger = { - debug: (...args: any) => true || console.log(args), - info: (...args: any) => true || console.log(args), - warning: (...args: any) => true || console.log(args), - warn: (...args: any) => true || console.log(args), - error: (...args: any) => { - console.error(args); - }, -}; - -const { SSL_ENABLED = 'no', LOG_IN = 'yes' } = process.env; - -const useSsl = typeof SSL_ENABLED !== 'undefined' ? ['yes', 'true'].includes(SSL_ENABLED) : true; +const { LOG_IN = 'yes' } = process.env; export type ClientType = 'web' | 'android' | 'ios'; +declare module '@rocket.chat/rest-typings' { + // eslint-disable-next-line @typescript-eslint/naming-convention + interface Endpoints { + '/v1/permissions': { + get: () => unknown; + }; + } +} + // eslint-disable-next-line @typescript-eslint/naming-convention export interface ClientLoadTest { status: 'logged' | 'not-logged' | 'logging'; @@ -46,7 +42,7 @@ export interface ClientLoadTest { typing(rid: string, typing: boolean): Promise; - openRoom(rid: string, roomType: string): Promise; + openRoom(rid: string, roomType: 'groups' | 'channels'): Promise; subscribeRoom(rid: string): Promise; @@ -54,11 +50,11 @@ export interface ClientLoadTest { getRandomSubscription(): Subscription | undefined; - get: Api['get']; + get: DDPSDK['rest']['get']; - post: Api['post']; + post: DDPSDK['rest']['post']; - subscribe: RocketChatClient['subscribe']; + subscribe: DDPSDK['client']['subscribe']; } export class Client implements ClientLoadTest { @@ -82,7 +78,7 @@ export class Client implements ClientLoadTest { } | undefined = undefined; - client: RocketChatClient; + client: DDPSDK; subscribedToLivechat = false; @@ -102,39 +98,33 @@ export class Client implements ClientLoadTest { this.defaultCredentials = credentials; } - const client = new RocketChatClient({ - logger, - host: this.host, - useSsl, - }); - - this.client = client; + this.client = DDPSDK.create(this.host); - this.get = prom.promWrapperRest('GET', (...args) => this.client.get(...args)); - this.post = prom.promWrapperRest('POST', (...args) => this.client.post(...args)); + this.get = prom.promWrapperRest('GET', this.client.rest.get); + this.post = prom.promWrapperRest('POST', this.client.rest.post); - this.subscribe = prom.promWrapperSubscribe((...args) => this.client.subscribe(...args)); + this.subscribe = prom.promWrapperSubscribe(this.client.client.subscribe); } status: 'logged' | 'not-logged' | 'logging' = 'not-logged'; - get: IAPIRequest; + get: DDPSDK['rest']['get']; - post: IAPIRequest; + post: DDPSDK['rest']['post']; - subscribe: (topic: string, ...args: any[]) => Promise; + subscribe: DDPSDK['client']['subscribe']; @suppressError @action async beforeLogin(): Promise { - await this.client.connect({}); + await this.client.client.connect(); prom.connected.inc(); switch (this.type) { case 'android': case 'ios': - await Promise.all([this.get('settings.public'), this.get('settings.oauth')]); + await Promise.all([this.get('/v1/settings.public'), this.get('/v1/settings.oauth')]); break; } } @@ -172,21 +162,21 @@ export class Client implements ClientLoadTest { @suppressError @action async joinRoom(rid = 'GENERAL') { - await this.client.joinRoom({ rid }); + await this.client.rest.post('/v1/channels.join', { roomId: rid }); } @suppressError @action async setStatus() { - const status = rand(['online', 'away', 'offline', 'busy']); + const status = rand(['online', 'away', 'offline', 'busy']) as UserStatus; - await this.post('users.setStatus', { status }); + await this.post('/v1/users.setStatus', { status }); } @suppressError @action async read(rid: string): Promise { - await this.post('subscriptions.read', { rid }); + await this.post('/v1/subscriptions.read', { rid }); } @suppressError @@ -196,31 +186,33 @@ export class Client implements ClientLoadTest { const { credentials } = this; - const user = await this.client.login(credentials); + await this.client.account.loginWithPassword(credentials.username, credentials.password); // do one by one as doing three at same time was hanging switch (this.type) { case 'android': case 'ios': await Promise.all( - ['rooms-changed', 'subscriptions-changed'].map((stream) => this.subscribe('stream-notify-user', `${user.id}/${stream}`)), + ['rooms-changed', 'subscriptions-changed'].map((stream) => + this.subscribe('stream-notify-user', `${this.client.account.uid!}/${stream}`), + ), ); await Promise.all(['userData', 'activeUsers'].map((stream) => this.subscribe(stream, ''))); await Promise.all([ - this.get('me'), - this.get('permissions'), - this.get('settings.public'), - this.get('subscriptions.get'), - this.get('rooms.get'), + this.get('/v1/me'), + this.get('/v1/permissions' as any), + this.get('/v1/settings.public'), + this.get('/v1/subscriptions.get', {}), + this.get('/v1/rooms.get', {} as any), ]); break; } await Promise.all(this.getLoginSubs().map(([stream, ...params]) => this.subscribe(stream, ...params))); - await Promise.all(this.getLoginMethods().map((params) => this.client.methodCall(...params))); + await Promise.all(this.getLoginMethods().map((params) => this.client.call(...params))); this.status = 'logged'; } @@ -247,11 +239,7 @@ export class Client implements ClientLoadTest { await this.typing(rid, true); await delay(1000); - try { - await this.client.sendMessage(msg, rid); - } catch (e) { - throw e; - } + await this.client.rest.post('/v1/chat.sendMessage', { message: { msg, rid } }); await this.typing(rid, false); } @@ -259,31 +247,27 @@ export class Client implements ClientLoadTest { @suppressError @action async typing(rid: string, typing: boolean): Promise { - await this.client.methodCall('stream-notify-room', `${rid}/typing`, this.client.username, typing); + await this.client.call('stream-notify-room', `${rid}/typing`, this.client.account.user!.username!, typing); } @suppressError @action - async openRoom(rid = 'GENERAL', roomType = 'groups'): Promise { - try { - const calls: Promise[] = [this.subscribeRoom(rid)]; - - switch (this.type) { - case 'android': - case 'ios': - calls.push(this.get('commands.list')); - calls.push(this.get(`${roomType}.members`, { roomId: rid })); - calls.push(this.get(`${roomType}.roles`, { roomId: rid })); - calls.push(this.get(`${roomType}.history`, { roomId: rid })); - break; - } + async openRoom(rid = 'GENERAL', roomType: 'groups' | 'channels' = 'groups'): Promise { + const calls: Promise[] = [this.subscribeRoom(rid)]; - await Promise.all(calls); - - await this.post('subscriptions.read', { rid }); - } catch (e) { - console.error('error open room', { uid: this.client.userId, rid }, e); + switch (this.type) { + case 'android': + case 'ios': + calls.push(this.get('/v1/commands.list')); + calls.push(this.get(`/v1/${roomType}.members`, { roomId: rid })); + calls.push(this.get(`/v1/${roomType}.roles`, { roomId: rid })); + calls.push(this.get(`/v1/${roomType}.history`, { roomId: rid })); + break; } + + await Promise.all(calls); + + await this.post('/v1/subscriptions.read', { rid }); } getRandomSubscription(): Subscription { @@ -312,15 +296,11 @@ export class Client implements ClientLoadTest { params, }); - const result = await this.post(`${anon ? 'method.callAnon' : 'method.call'}/${encodeURIComponent(method)}`, { + const result = await this.post(`${anon ? '/v1/method.callAnon' : '/v1/method.call'}/${encodeURIComponent(method)}`, { message, }); - if (!result.success) { - throw new Error(result.error); - } - - const msgResult = EJSON.parse(result.message); + const msgResult = EJSON.parse(result.message as unknown as string); return msgResult.result; } diff --git a/src/client/Omnichannel.ts b/src/client/Omnichannel.ts index c6840b9..6d31562 100644 --- a/src/client/Omnichannel.ts +++ b/src/client/Omnichannel.ts @@ -1,4 +1,6 @@ -import type { Department, Inquiry, Subscription, Visitor } from '../definifitons'; +import type { IInquiry, ILivechatDepartmentAgents, Serialized } from '@rocket.chat/core-typings'; + +import type { Inquiry, Subscription } from '../definifitons'; import * as prom from '../lib/prom'; import { rand } from '../lib/rand'; import { Client } from './Client'; @@ -19,7 +21,7 @@ export class OmnichannelClient extends Client { const end = prom.actions.startTimer({ action: 'getRoutingConfig' }); try { - const routingConfig = await this.client.methodCall('livechat:getRoutingConfig'); + const routingConfig = await this.client.call('livechat:getRoutingConfig'); end({ status: 'success' }); return routingConfig; @@ -28,14 +30,14 @@ export class OmnichannelClient extends Client { } } - async getAgentDepartments(): Promise<{ departments: Department[] } | undefined> { + async getAgentDepartments(): Promise<{ departments: ILivechatDepartmentAgents[] } | undefined> { if (this.status === 'logging') { await this.login(); } const end = prom.actions.startTimer({ action: 'getAgentDepartments' }); try { - const departments = await this.get(`livechat/agents/${this.client.userId}/departments?enabledDepartmentsOnly=true`); + const departments = await this.get(`/v1/livechat/agents/${this.client.account.uid!}/departments`, { enabledDepartmentsOnly: 'true' }); end({ status: 'success' }); return departments; @@ -51,7 +53,7 @@ export class OmnichannelClient extends Client { const end = prom.actions.startTimer({ action: 'getQueuedInquiries' }); try { - const inquiries = await this.get(`livechat/inquiries.queuedForUser`, { userId: this.client.userId }); + const inquiries = await this.get(`/v1/livechat/inquiries.queuedForUser`, {}); end({ status: 'success' }); return inquiries; @@ -93,7 +95,7 @@ export class OmnichannelClient extends Client { const end = prom.actions.startTimer({ action: 'takeInquiry' }); const endInq = prom.inquiryTaken.startTimer(); try { - await this.client.methodCall('livechat:takeInquiry', id, { + await this.client.call('livechat:takeInquiry', id, { clientAction: true, }); end({ status: 'success' }); @@ -104,36 +106,36 @@ export class OmnichannelClient extends Client { } } - async getInquiry(id: string): Promise { + async getInquiry(id: string): Promise | undefined> { if (this.status === 'logging') { await this.login(); } const end = prom.actions.startTimer({ action: 'getOneInquiry' }); try { - const inq = await this.get(`livechat/inquiries.getOne`, { + const { inquiry } = await this.get(`/v1/livechat/inquiries.getOne`, { roomId: id, }); end({ status: 'success' }); - return inq; + return inquiry || undefined; } catch (e) { end({ status: 'error' }); } } - async getVisitorInfo(vid: string): Promise { + async getVisitorInfo(vid: string) { if (this.status === 'logging') { await this.login(); } const end = prom.actions.startTimer({ action: 'getVisitorInfo' }); try { - const v = await this.get(`livechat/visitors.info`, { + const { visitor } = await this.get(`/v1/livechat/visitors.info`, { visitorId: vid, }); end({ status: 'success' }); - return v; + return visitor; } catch (e) { end({ status: 'error' }); } @@ -157,7 +159,7 @@ export class OmnichannelClient extends Client { end({ status: 'success' }); endAction({ status: 'success' }); } catch (e) { - console.error('error open room', { uid: this.client.userId, rid }, e); + console.error('error open room', { uid: this.client.account.uid, rid }, e); end({ status: 'error' }); endAction({ status: 'error' }); } diff --git a/src/client/WebClient.ts b/src/client/WebClient.ts index 2acd131..775283b 100644 --- a/src/client/WebClient.ts +++ b/src/client/WebClient.ts @@ -7,7 +7,7 @@ export class WebClient extends Client { loginPromise: Promise | undefined; async beforeLogin(): Promise { - await this.client.connect({}); + await this.client.connection.connect(); prom.connected.inc(); @@ -41,7 +41,7 @@ export class WebClient extends Client { await this.beforeLogin(); - const user = await this.client.login(credentials); + await this.client.account.loginWithPassword(credentials.username, credentials.password); // await this.subscribeLoggedNotify(); await Promise.all( @@ -75,7 +75,7 @@ export class WebClient extends Client { 'rooms-changed', 'webrtc', 'userData', - ].map((event) => this.subscribe('stream-notify-user', `${user.id}/${event}`, false)), + ].map((event) => this.subscribe('stream-notify-user', `${this.client.account.uid}/${event}`, false)), ); await Promise.all( @@ -107,9 +107,9 @@ export class WebClient extends Client { const newIds = userIds.filter((id) => !this.usersPresence.includes(id)); const removeIds = this.usersPresence.filter((id) => !userIds.includes(id)); - await this.get(`users.presence?ids[]=${newIds.join('&ids[]=')}&_empty=`); + await this.get(`/v1/users.presence`, { ids: newIds }); - ((await this.client.socket) as any).ddp.subscribe('stream-user-presence', [ + await this.client.client.subscribe('stream-user-presence', [ '', { ...(newIds && { added: newIds }), @@ -144,7 +144,7 @@ export class WebClient extends Client { @suppressError @action async typing(rid: string, typing: boolean): Promise { - await this.client.methodCall('stream-notify-room', `${rid}/user-activity`, this.client.username, typing); + await this.client.call('stream-notify-room', `${rid}/user-activity`, this.client.account.user!.username, typing); } @suppressError diff --git a/src/lib/prom.ts b/src/lib/prom.ts index 730323e..8c5ba1c 100644 --- a/src/lib/prom.ts +++ b/src/lib/prom.ts @@ -109,7 +109,7 @@ export const promWrapperRest = }) as unknown as F; }; -export const promWrapperSubscribe = Promise>(fn: F): F => { +export const promWrapperSubscribe = any>(fn: F): F => { return (async (...args: any[]) => { const endTimer = subscriptions.startTimer({ name: args[0] }); try {