From 1d72be9dec97ac0d11f8be020be4e49d5cb6478e Mon Sep 17 00:00:00 2001 From: Antoni Spaanderman <56turtle56@gmail.com> Date: Wed, 25 May 2022 16:51:50 +0200 Subject: [PATCH] warnings count to 470 --- package-lock.json | 187 +++++++++++++++++++++++- package.json | 32 +++- src/controllers/auth.ts | 2 +- src/controllers/chatTribes.ts | 2 +- src/controllers/invoices.ts | 3 +- src/controllers/media.ts | 5 +- src/controllers/messages.ts | 3 +- src/controllers/payment.ts | 7 +- src/crypto/rsa.ts | 82 +++++------ src/grpc/interfaces.ts | 10 +- src/grpc/lightning.ts | 70 ++++----- src/helpers.ts | 36 ++--- src/models/index.ts | 14 +- src/tests/utils/msg/sendTribeMessage.ts | 2 +- src/utils/msg.ts | 6 +- src/utils/tribes.ts | 8 +- 16 files changed, 325 insertions(+), 144 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8a3ed2456..8351293db 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,16 @@ "@grpc/proto-loader": "^0.5.3", "@octokit/webhooks-types": "^5.2.0", "@scout_apm/scout-apm": "^0.1.10", - "@types/node": "^13.5.1", + "@types/cron": "^2.0.0", + "@types/crypto-js": "^4.1.1", + "@types/ip": "^1.1.0", + "@types/md5": "^2.3.2", + "@types/minimist": "^1.2.2", + "@types/multer": "^1.4.7", + "@types/pg": "^8.6.5", + "@types/qrcode": "^1.4.2", + "@types/secure-random": "^1.1.0", + "@types/underscore": "^1.11.4", "async": "^2.6.2", "async-lock": "^1.2.2", "axios": "^0.21.1", @@ -87,6 +96,7 @@ "nodeapp": "dist/app.js" }, "devDependencies": { + "@types/node": "^17.0.35", "@typescript-eslint/eslint-plugin": "^4.28.2", "@typescript-eslint/parser": "^4.33.0", "ava": "^3.15.0", @@ -851,6 +861,20 @@ "integrity": "sha512-vt+kDhq/M2ayberEtJcIN/hxXy1Pk+59g2FV/ZQceeaTyCtCucjL2Q7FXlFjtWn4n15KCr1NE2lNNFhp0lEThw==", "license": "MIT" }, + "node_modules/@types/cron": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@types/cron/-/cron-2.0.0.tgz", + "integrity": "sha512-xZM08fqvwIXgghtPVkSPKNgC+JoMQ2OHazEvyTKnNf7aWu1aB6/4lBbQFrb03Td2cUGG7ITzMv3mFYnMu6xRaQ==", + "dependencies": { + "@types/luxon": "*", + "@types/node": "*" + } + }, + "node_modules/@types/crypto-js": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/@types/crypto-js/-/crypto-js-4.1.1.tgz", + "integrity": "sha512-BG7fQKZ689HIoc5h+6D2Dgq1fABRa0RbBWKBd9SP/MVRVXROflpm5fhwyATX5duFmbStzyzyycPB8qUYKDH3NA==" + }, "node_modules/@types/decompress": { "version": "4.2.4", "resolved": "https://registry.npmjs.org/@types/decompress/-/decompress-4.2.4.tgz", @@ -945,6 +969,14 @@ "@types/node": "*" } }, + "node_modules/@types/ip": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@types/ip/-/ip-1.1.0.tgz", + "integrity": "sha512-dwNe8gOoF70VdL6WJBwVHtQmAX4RMd62M+mAB9HQFjG1/qiCLM/meRy95Pd14FYBbEDwCq7jgJs89cHpLBu4HQ==", + "dependencies": { + "@types/node": "*" + } + }, "node_modules/@types/json-schema": { "version": "7.0.9", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.9.tgz", @@ -977,6 +1009,16 @@ "resolved": "https://registry.npmjs.org/@types/lru-cache/-/lru-cache-5.1.1.tgz", "integrity": "sha512-ssE3Vlrys7sdIzs5LOxCzTVMsU7i9oa/IaW92wF32JFb3CVczqOkru2xspuKczHEbG3nvmPY7IFqVmGGHdNbYw==" }, + "node_modules/@types/luxon": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/@types/luxon/-/luxon-2.3.2.tgz", + "integrity": "sha512-WOehptuhKIXukSUUkRgGbj2c997Uv/iUgYgII8U7XLJqq9W2oF0kQ6frEznRQbdurioz+L/cdaIm4GutTQfgmA==" + }, + "node_modules/@types/md5": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/@types/md5/-/md5-2.3.2.tgz", + "integrity": "sha512-v+JFDu96+UYJ3/UWzB0mEglIS//MZXgRaJ4ubUPwOM0gvLc/kcQ3TWNYwENEK7/EcXGQVrW8h/XqednSjBd/Og==" + }, "node_modules/@types/mime": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/@types/mime/-/mime-1.3.2.tgz", @@ -990,6 +1032,19 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/minimist": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/@types/minimist/-/minimist-1.2.2.tgz", + "integrity": "sha512-jhuKLIRrhvCPLqwPcx6INqmKeiA5EWrsCOPhrlFSrbrmU4ZMPjj5Ul/oLCMDO98XRUIwVm78xICz4EPCektzeQ==" + }, + "node_modules/@types/multer": { + "version": "1.4.7", + "resolved": "https://registry.npmjs.org/@types/multer/-/multer-1.4.7.tgz", + "integrity": "sha512-/SNsDidUFCvqqcWDwxv2feww/yqhNeTRL5CVoL3jU4Goc4kKEL10T7Eye65ZqPNi4HRx8sAEX59pV1aEH7drNA==", + "dependencies": { + "@types/express": "*" + } + }, "node_modules/@types/mustache": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/@types/mustache/-/mustache-4.1.2.tgz", @@ -997,10 +1052,9 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "13.13.52", - "resolved": "https://registry.npmjs.org/@types/node/-/node-13.13.52.tgz", - "integrity": "sha512-s3nugnZumCC//n4moGGe6tkNMyYEdaDBitVjwPxXmR5lnMG5dHePinH2EdxkG3Rh1ghFHHixAG4NJhpJW1rthQ==", - "license": "MIT" + "version": "17.0.35", + "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.35.tgz", + "integrity": "sha512-vu1SrqBjbbZ3J6vwY17jBs8Sr/BKA+/a/WtjRG+whKg1iuLFOosq872EXS0eXWILdO36DHQQeku/ZcL6hz2fpg==" }, "node_modules/@types/node-fetch": { "version": "2.5.12", @@ -1028,12 +1082,30 @@ "@types/node": "*" } }, + "node_modules/@types/pg": { + "version": "8.6.5", + "resolved": "https://registry.npmjs.org/@types/pg/-/pg-8.6.5.tgz", + "integrity": "sha512-tOkGtAqRVkHa/PVZicq67zuujI4Oorfglsr2IbKofDwBSysnaqSx7W1mDqFqdkGE6Fbgh+PZAl0r/BWON/mozw==", + "dependencies": { + "@types/node": "*", + "pg-protocol": "*", + "pg-types": "^2.2.0" + } + }, "node_modules/@types/pug": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/@types/pug/-/pug-2.0.5.tgz", "integrity": "sha512-LOnASQoeNZMkzexRuyqcBBDZ6rS+rQxUMkmj5A0PkhhiSZivLIuz6Hxyr1mkGoEZEkk66faROmpMi4fFkrKsBA==", "license": "MIT" }, + "node_modules/@types/qrcode": { + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/@types/qrcode/-/qrcode-1.4.2.tgz", + "integrity": "sha512-7uNT9L4WQTNJejHTSTdaJhfBSCN73xtXaHFyBJ8TSwiLhe4PRuTue7Iph0s2nG9R/ifUaSnGhLUOZavlBEqDWQ==", + "dependencies": { + "@types/node": "*" + } + }, "node_modules/@types/qs": { "version": "6.9.7", "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.7.tgz", @@ -1046,6 +1118,14 @@ "integrity": "sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw==", "license": "MIT" }, + "node_modules/@types/secure-random": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@types/secure-random/-/secure-random-1.1.0.tgz", + "integrity": "sha512-FVkD9qNAeuc1m53VQfWhuUdn9IWjv6griflGfLcSoF3ZexyNv1ciPlZLyrucWYcdhNjKERgDb45IJwb8a/ZKDQ==", + "dependencies": { + "@types/node": "*" + } + }, "node_modules/@types/semver": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/@types/semver/-/semver-5.5.0.tgz", @@ -1089,6 +1169,11 @@ "integrity": "sha512-F5DIZ36YVLE+PN+Zwws4kJogq47hNgX3Nx6WyDJ3kcplxyke3XIzB8uK5n/Lpm1HBsbGzd6nmGehL8cPekP+Tg==", "license": "MIT" }, + "node_modules/@types/underscore": { + "version": "1.11.4", + "resolved": "https://registry.npmjs.org/@types/underscore/-/underscore-1.11.4.tgz", + "integrity": "sha512-uO4CD2ELOjw8tasUrAhvnn2W4A0ZECOvMjCivJr4gA9pGgjv+qxKWY9GLTMVEK8ej85BxQOocUyE7hImmSQYcg==" + }, "node_modules/@types/uuid": { "version": "3.4.4", "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-3.4.4.tgz", @@ -8120,6 +8205,11 @@ "uuid": "^3.3.3" } }, + "node_modules/lsat-js/node_modules/@types/node": { + "version": "13.13.52", + "resolved": "https://registry.npmjs.org/@types/node/-/node-13.13.52.tgz", + "integrity": "sha512-s3nugnZumCC//n4moGGe6tkNMyYEdaDBitVjwPxXmR5lnMG5dHePinH2EdxkG3Rh1ghFHHixAG4NJhpJW1rthQ==" + }, "node_modules/lsat-js/node_modules/@types/uuid": { "version": "3.4.10", "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-3.4.10.tgz", @@ -14568,6 +14658,20 @@ "resolved": "https://registry.npmjs.org/@types/cors/-/cors-2.8.12.tgz", "integrity": "sha512-vt+kDhq/M2ayberEtJcIN/hxXy1Pk+59g2FV/ZQceeaTyCtCucjL2Q7FXlFjtWn4n15KCr1NE2lNNFhp0lEThw==" }, + "@types/cron": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@types/cron/-/cron-2.0.0.tgz", + "integrity": "sha512-xZM08fqvwIXgghtPVkSPKNgC+JoMQ2OHazEvyTKnNf7aWu1aB6/4lBbQFrb03Td2cUGG7ITzMv3mFYnMu6xRaQ==", + "requires": { + "@types/luxon": "*", + "@types/node": "*" + } + }, + "@types/crypto-js": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/@types/crypto-js/-/crypto-js-4.1.1.tgz", + "integrity": "sha512-BG7fQKZ689HIoc5h+6D2Dgq1fABRa0RbBWKBd9SP/MVRVXROflpm5fhwyATX5duFmbStzyzyycPB8qUYKDH3NA==" + }, "@types/decompress": { "version": "4.2.4", "resolved": "https://registry.npmjs.org/@types/decompress/-/decompress-4.2.4.tgz", @@ -14652,6 +14756,14 @@ "@types/node": "*" } }, + "@types/ip": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@types/ip/-/ip-1.1.0.tgz", + "integrity": "sha512-dwNe8gOoF70VdL6WJBwVHtQmAX4RMd62M+mAB9HQFjG1/qiCLM/meRy95Pd14FYBbEDwCq7jgJs89cHpLBu4HQ==", + "requires": { + "@types/node": "*" + } + }, "@types/json-schema": { "version": "7.0.9", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.9.tgz", @@ -14681,6 +14793,16 @@ "resolved": "https://registry.npmjs.org/@types/lru-cache/-/lru-cache-5.1.1.tgz", "integrity": "sha512-ssE3Vlrys7sdIzs5LOxCzTVMsU7i9oa/IaW92wF32JFb3CVczqOkru2xspuKczHEbG3nvmPY7IFqVmGGHdNbYw==" }, + "@types/luxon": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/@types/luxon/-/luxon-2.3.2.tgz", + "integrity": "sha512-WOehptuhKIXukSUUkRgGbj2c997Uv/iUgYgII8U7XLJqq9W2oF0kQ6frEznRQbdurioz+L/cdaIm4GutTQfgmA==" + }, + "@types/md5": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/@types/md5/-/md5-2.3.2.tgz", + "integrity": "sha512-v+JFDu96+UYJ3/UWzB0mEglIS//MZXgRaJ4ubUPwOM0gvLc/kcQ3TWNYwENEK7/EcXGQVrW8h/XqednSjBd/Og==" + }, "@types/mime": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/@types/mime/-/mime-1.3.2.tgz", @@ -14692,15 +14814,28 @@ "integrity": "sha512-Klz949h02Gz2uZCMGwDUSDS1YBlTdDDgbWHi+81l29tQALUtvz4rAYi5uoVhE5Lagoq6DeqAUlbrHvW/mXDgdQ==", "dev": true }, + "@types/minimist": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/@types/minimist/-/minimist-1.2.2.tgz", + "integrity": "sha512-jhuKLIRrhvCPLqwPcx6INqmKeiA5EWrsCOPhrlFSrbrmU4ZMPjj5Ul/oLCMDO98XRUIwVm78xICz4EPCektzeQ==" + }, + "@types/multer": { + "version": "1.4.7", + "resolved": "https://registry.npmjs.org/@types/multer/-/multer-1.4.7.tgz", + "integrity": "sha512-/SNsDidUFCvqqcWDwxv2feww/yqhNeTRL5CVoL3jU4Goc4kKEL10T7Eye65ZqPNi4HRx8sAEX59pV1aEH7drNA==", + "requires": { + "@types/express": "*" + } + }, "@types/mustache": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/@types/mustache/-/mustache-4.1.2.tgz", "integrity": "sha512-c4OVMMcyodKQ9dpwBwh3ofK9P6U9ZktKU9S+p33UqwMNN1vlv2P0zJZUScTshnx7OEoIIRcCFNQ904sYxZz8kg==" }, "@types/node": { - "version": "13.13.52", - "resolved": "https://registry.npmjs.org/@types/node/-/node-13.13.52.tgz", - "integrity": "sha512-s3nugnZumCC//n4moGGe6tkNMyYEdaDBitVjwPxXmR5lnMG5dHePinH2EdxkG3Rh1ghFHHixAG4NJhpJW1rthQ==" + "version": "17.0.35", + "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.35.tgz", + "integrity": "sha512-vu1SrqBjbbZ3J6vwY17jBs8Sr/BKA+/a/WtjRG+whKg1iuLFOosq872EXS0eXWILdO36DHQQeku/ZcL6hz2fpg==" }, "@types/node-fetch": { "version": "2.5.12", @@ -14725,11 +14860,29 @@ "@types/node": "*" } }, + "@types/pg": { + "version": "8.6.5", + "resolved": "https://registry.npmjs.org/@types/pg/-/pg-8.6.5.tgz", + "integrity": "sha512-tOkGtAqRVkHa/PVZicq67zuujI4Oorfglsr2IbKofDwBSysnaqSx7W1mDqFqdkGE6Fbgh+PZAl0r/BWON/mozw==", + "requires": { + "@types/node": "*", + "pg-protocol": "*", + "pg-types": "^2.2.0" + } + }, "@types/pug": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/@types/pug/-/pug-2.0.5.tgz", "integrity": "sha512-LOnASQoeNZMkzexRuyqcBBDZ6rS+rQxUMkmj5A0PkhhiSZivLIuz6Hxyr1mkGoEZEkk66faROmpMi4fFkrKsBA==" }, + "@types/qrcode": { + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/@types/qrcode/-/qrcode-1.4.2.tgz", + "integrity": "sha512-7uNT9L4WQTNJejHTSTdaJhfBSCN73xtXaHFyBJ8TSwiLhe4PRuTue7Iph0s2nG9R/ifUaSnGhLUOZavlBEqDWQ==", + "requires": { + "@types/node": "*" + } + }, "@types/qs": { "version": "6.9.7", "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.7.tgz", @@ -14740,6 +14893,14 @@ "resolved": "https://registry.npmjs.org/@types/range-parser/-/range-parser-1.2.4.tgz", "integrity": "sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw==" }, + "@types/secure-random": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@types/secure-random/-/secure-random-1.1.0.tgz", + "integrity": "sha512-FVkD9qNAeuc1m53VQfWhuUdn9IWjv6griflGfLcSoF3ZexyNv1ciPlZLyrucWYcdhNjKERgDb45IJwb8a/ZKDQ==", + "requires": { + "@types/node": "*" + } + }, "@types/semver": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/@types/semver/-/semver-5.5.0.tgz", @@ -14777,6 +14938,11 @@ "resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.2.tgz", "integrity": "sha512-F5DIZ36YVLE+PN+Zwws4kJogq47hNgX3Nx6WyDJ3kcplxyke3XIzB8uK5n/Lpm1HBsbGzd6nmGehL8cPekP+Tg==" }, + "@types/underscore": { + "version": "1.11.4", + "resolved": "https://registry.npmjs.org/@types/underscore/-/underscore-1.11.4.tgz", + "integrity": "sha512-uO4CD2ELOjw8tasUrAhvnn2W4A0ZECOvMjCivJr4gA9pGgjv+qxKWY9GLTMVEK8ej85BxQOocUyE7hImmSQYcg==" + }, "@types/uuid": { "version": "3.4.4", "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-3.4.4.tgz", @@ -19917,6 +20083,11 @@ "uuid": "^3.3.3" }, "dependencies": { + "@types/node": { + "version": "13.13.52", + "resolved": "https://registry.npmjs.org/@types/node/-/node-13.13.52.tgz", + "integrity": "sha512-s3nugnZumCC//n4moGGe6tkNMyYEdaDBitVjwPxXmR5lnMG5dHePinH2EdxkG3Rh1ghFHHixAG4NJhpJW1rthQ==" + }, "@types/uuid": { "version": "3.4.10", "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-3.4.10.tgz", diff --git a/package.json b/package.json index 289657d10..670d6fc48 100644 --- a/package.json +++ b/package.json @@ -16,22 +16,38 @@ "dev": "rm -rf dist/ && tsc && cp -r public dist/public && node --inspect ./dist/app.js", "build-binaries": "rm -rf dist/ && tsc && cp config/app.json dist/config/app.json && cp config/config.json dist/config/config.json && pkg . --target node12-alpine-x64,node12-macos-x64 --out-path binaries", "start-ecs": "cp config/app.json dist/config/app.json && cp config/config.json dist/config/config.json && export NODE_ENV=production && node --max-old-space-size=128 dist/app.js", - "lint": "eslint ./src/*.ts ./src/**/*.ts --fix --max-warnings 517" + "lint": "eslint ./src/*.ts ./src/**/*.ts --fix --max-warnings 470" }, "keywords": [], "author": "", "license": "ISC", "ava": { - "files": ["!src/tests/utils/**", "!src/tests/types"], - "extensions": ["ts"], - "require": ["ts-node/register"] + "files": [ + "!src/tests/utils/**", + "!src/tests/types" + ], + "extensions": [ + "ts" + ], + "require": [ + "ts-node/register" + ] }, "dependencies": { "@boltz/bolt11": "^1.2.7", "@grpc/proto-loader": "^0.5.3", "@octokit/webhooks-types": "^5.2.0", "@scout_apm/scout-apm": "^0.1.10", - "@types/node": "^13.5.1", + "@types/cron": "^2.0.0", + "@types/crypto-js": "^4.1.1", + "@types/ip": "^1.1.0", + "@types/md5": "^2.3.2", + "@types/minimist": "^1.2.2", + "@types/multer": "^1.4.7", + "@types/pg": "^8.6.5", + "@types/qrcode": "^1.4.2", + "@types/secure-random": "^1.1.0", + "@types/underscore": "^1.11.4", "async": "^2.6.2", "async-lock": "^1.2.2", "axios": "^0.21.1", @@ -102,6 +118,7 @@ "zbase32": "^1.0.2" }, "devDependencies": { + "@types/node": "^17.0.35", "@typescript-eslint/eslint-plugin": "^4.28.2", "@typescript-eslint/parser": "^4.33.0", "ava": "^3.15.0", @@ -115,7 +132,10 @@ "socket.io-client-legacy": "npm:socket.io-client@^2.4.0" }, "pkg": { - "assets": ["config/*", "dist/config/*"] + "assets": [ + "config/*", + "dist/config/*" + ] }, "husky": { "hooks": { diff --git a/src/controllers/auth.ts b/src/controllers/auth.ts index 4007ae8e7..81947ea46 100644 --- a/src/controllers/auth.ts +++ b/src/controllers/auth.ts @@ -84,7 +84,7 @@ export async function requestTransportKey(req: Req, res) { return } - const transportTokenKeys: { [k: string]: string } = await rsa.genKeys() + const transportTokenKeys = await rsa.genKeys() fs.writeFileSync(config.transportPublicKeyLocation, transportTokenKeys.public) fs.writeFileSync( config.transportPrivateKeyLocation, diff --git a/src/controllers/chatTribes.ts b/src/controllers/chatTribes.ts index 684ec79c9..23b6f2206 100644 --- a/src/controllers/chatTribes.ts +++ b/src/controllers/chatTribes.ts @@ -761,7 +761,7 @@ export async function createTribeChatParams( } // make ts sig here w LNd pubkey - that is UUID - const keys: { [k: string]: string } = await rsa.genKeys() + const keys = await rsa.genKeys() const groupUUID = await tribes.genSignedTimestamp(owner.publicKey) const theContactIds = contactIds.includes(owner.id) ? contactIds diff --git a/src/controllers/invoices.ts b/src/controllers/invoices.ts index 19878b1ac..7ba7ae301 100644 --- a/src/controllers/invoices.ts +++ b/src/controllers/invoices.ts @@ -16,6 +16,7 @@ import * as bolt11 from '@boltz/bolt11' import { sphinxLogger } from '../utils/logger' import { Req } from '../types' import { Response } from 'express' +import { ChatPlusMembers } from '../network/send' function stripLightningPrefix(s: string): string { if (s.toLowerCase().startsWith('lightning:')) return s.substring(10) @@ -202,7 +203,7 @@ export const createInvoice = async (req: Req, res: Response): Promise => { success(res, jsonUtils.messageToJson(message, chat)) network.sendMessage({ - chat: chat, + chat: chat as Partial, sender: owner, type: constants.message_types.invoice, message: { diff --git a/src/controllers/media.ts b/src/controllers/media.ts index ddc5a7266..ee798262d 100644 --- a/src/controllers/media.ts +++ b/src/controllers/media.ts @@ -18,6 +18,7 @@ import { loadConfig } from '../utils/config' import { failure } from '../utils/res' import { logging, sphinxLogger } from '../utils/logger' import { Req } from '../types' +import { ChatPlusMembers } from '../network/send' const config = loadConfig() @@ -143,7 +144,7 @@ export const sendAttachmentMessage = async (req: Req, res) => { if (reply_uuid) msg.replyUuid = reply_uuid if (parent_id) msg.parentId = parent_id network.sendMessage({ - chat: chat, + chat: chat as Partial, sender: owner, type: constants.message_types.attachment, amount: amount || 0, @@ -230,7 +231,7 @@ export const purchase = async (req: Req, res) => { purchaser: owner.id, // for tribe, knows who sent } network.sendMessage({ - chat: { ...chat.dataValues, contactIds: [contact_id] }, + chat: { ...chat.dataValues, contactIds: JSON.stringify([ contact_id ]) }, sender: owner, type: constants.message_types.purchase, realSatsContactId: contact_id, // ALWAYS will be keysend, so doesnt matter if tribe owner or not diff --git a/src/controllers/messages.ts b/src/controllers/messages.ts index 7c2af8d13..72987b589 100644 --- a/src/controllers/messages.ts +++ b/src/controllers/messages.ts @@ -15,6 +15,7 @@ import * as short from 'short-uuid' import constants from '../constants' import { logging, sphinxLogger } from '../utils/logger' import { Req, Res } from '../types' +import { ChatPlusMembers } from '../network/send' // deprecated export const getMessages = async (req: Req, res: Res): Promise => { @@ -383,7 +384,7 @@ export const sendMessage = async (req: Req, res: Res): Promise => { if (recipientPic) msgToSend.recipientPic = recipientPic const sendMessageParams: SendMessageParams = { - chat: chat, + chat: chat as Partial, sender: owner, amount: amount || 0, type: msgtype, diff --git a/src/controllers/payment.ts b/src/controllers/payment.ts index d888c672f..c88c31ea9 100644 --- a/src/controllers/payment.ts +++ b/src/controllers/payment.ts @@ -1,4 +1,4 @@ -import { Message, Chat, models } from '../models' +import { Message, ChatRecord, models } from '../models' import { sendNotification } from '../hub' import * as socket from '../utils/socket' import * as jsonUtils from '../utils/json' @@ -14,6 +14,7 @@ import { anonymousKeysend } from './feed' import { sphinxLogger } from '../utils/logger' import { Req, Res } from '../types' import { sendConfirmation } from './confirmations' +import { ChatPlusMembers } from '../network/send' export const sendPayment = async (req: Req, res: Res): Promise => { if (!req.owner) return failure(res, 'no owner') @@ -120,11 +121,11 @@ export const sendPayment = async (req: Req, res: Res): Promise => { // if remote text map, put that in let theChat = chat if (contact_ids) { - theChat = { ...chat.dataValues, contactIds: contact_ids } as Chat + theChat = { ...chat.dataValues, contactIds: contact_ids } if (remote_text_map) msgToSend.content = remote_text_map } network.sendMessage({ - chat: theChat, + chat: theChat as Partial, sender: owner, type: constants.message_types.direct_payment, message: msgToSend as Message, diff --git a/src/crypto/rsa.ts b/src/crypto/rsa.ts index ac7bbb4e0..1e16b5ac2 100644 --- a/src/crypto/rsa.ts +++ b/src/crypto/rsa.ts @@ -3,14 +3,18 @@ import * as crypto from 'crypto' const BLOCK_SIZE = 256 const MAX_CHUNK_SIZE = BLOCK_SIZE - 11 // 11 is the PCKS1 padding -export function encrypt(key, txt) { +export interface KeyPair { + public: string, + private: string +} + +export function encrypt(key: string, txt: string): string { try { const buf = Buffer.from(txt) - let finalBuf = Buffer.from([]) + let finalBuf = Buffer.alloc(0) const n = Math.ceil(buf.length / MAX_CHUNK_SIZE) - const arr = Array(n).fill(0) const pubc = cert.pub(key) - arr.forEach((_, i) => { + for (let i = 0; i < n; i++) { const f = crypto.publicEncrypt( { key: pubc, @@ -18,22 +22,21 @@ export function encrypt(key, txt) { }, buf.subarray(i * MAX_CHUNK_SIZE, i * MAX_CHUNK_SIZE + MAX_CHUNK_SIZE) ) - finalBuf = Buffer.concat([finalBuf, f]) - }) + finalBuf = Buffer.concat([ finalBuf, f ]) + } return finalBuf.toString('base64') } catch (e) { return '' } } -export function decrypt(privateKey, enc) { +export function decrypt(privateKey: string | Buffer, enc: string): string { try { const buf = Buffer.from(enc, 'base64') let finalDec = '' const n = Math.ceil(buf.length / BLOCK_SIZE) - const arr = Array(n).fill(0) const privc = cert.priv(privateKey) - arr.forEach((_, i) => { + for (let i = 0; i < n; i++) { const b = crypto.privateDecrypt( { key: privc, @@ -42,32 +45,35 @@ export function decrypt(privateKey, enc) { buf.subarray(i * BLOCK_SIZE, i * BLOCK_SIZE + BLOCK_SIZE) ) finalDec += b.toString('utf-8') - }) + } return finalDec } catch (e) { return '' } } -export function genKeys(): Promise<{ [k: string]: string }> { - return new Promise((resolve, reject) => { +export function genKeys(): Promise { + return new Promise(resolve => { crypto.generateKeyPair( 'rsa', { modulusLength: 2048, }, (err, publicKey, privKey) => { + if (err) { + // TODO handle error + } const pubPEM = publicKey.export({ type: 'pkcs1', format: 'pem', }) - const pubBase64 = cert.unpub(pubPEM) + const pubBase64 = cert.unpub(pubPEM.toString()) const privPEM = privKey.export({ type: 'pkcs1', format: 'pem', }) - const privBase64 = cert.unpriv(privPEM) - resolve({ + const privBase64 = cert.unpriv(privPEM.toString()) + resolve({ public: pubBase64, private: privBase64, }) @@ -76,18 +82,19 @@ export function genKeys(): Promise<{ [k: string]: string }> { }) } -export function testRSA() { +export function testRSA(): void { crypto.generateKeyPair( 'rsa', { modulusLength: 2048, }, (err, publicKey, privateKey) => { + if (err) console.log('error', err) const pubPEM = publicKey.export({ type: 'pkcs1', format: 'pem', }) - const pub = cert.unpub(pubPEM) + const pub = cert.unpub(pubPEM.toString()) const msg = 'hi' const enc = encrypt(pub, msg) @@ -96,41 +103,22 @@ export function testRSA() { type: 'pkcs1', format: 'pem', }) - const priv = cert.unpriv(privPEM) + const priv = cert.unpriv(privPEM.toString()) const dec = decrypt(priv, enc) - console.log(`SUCESS: ${msg === dec}`) + console.log(`SUCCESS: ${msg === dec}`) } ) } +const beginPub = '-----BEGIN RSA PUBLIC KEY-----' +const endPub = '-----END RSA PUBLIC KEY-----' +const beginPriv = '-----BEGIN RSA PRIVATE KEY-----' +const endPriv = '-----END RSA PRIVATE KEY-----' + const cert = { - unpub: function (key) { - let s = key - s = s.replace('-----BEGIN RSA PUBLIC KEY-----', '') - s = s.replace('-----END RSA PUBLIC KEY-----', '') - return s.replace(/[\r\n]+/gm, '') - }, - unpriv: function (key) { - let s = key - s = s.replace('-----BEGIN RSA PRIVATE KEY-----', '') - s = s.replace('-----END RSA PRIVATE KEY-----', '') - return s.replace(/[\r\n]+/gm, '') - }, - pub: function (key) { - return ( - '-----BEGIN RSA PUBLIC KEY-----\n' + - key + - '\n' + - '-----END RSA PUBLIC KEY-----' - ) - }, - priv: function (key) { - return ( - '-----BEGIN RSA PRIVATE KEY-----\n' + - key + - '\n' + - '-----END RSA PRIVATE KEY-----' - ) - }, + unpub: (key: string): string => key.replace(beginPub, '').replace(endPub, '').trim(), + unpriv: (key: string): string => key.replace(beginPriv, '').replace(endPriv, '').trim(), + pub: (key: string | Buffer): string => beginPub + '\n' + key + '\n' + endPub, + priv: (key: string | Buffer): string => beginPriv + '\n' + key + '\n' + endPriv } diff --git a/src/grpc/interfaces.ts b/src/grpc/interfaces.ts index dc4d78083..6368dc94b 100644 --- a/src/grpc/interfaces.ts +++ b/src/grpc/interfaces.ts @@ -351,7 +351,7 @@ export function listPeersResponse( } export type Buf = Buffer | ByteBuffer | ArrayBuffer -type DestCustomRecords = { [key: string]: Buf } +type DestCustomRecords = { [k: string]: Buf } export interface KeysendRequest { amt: number final_cltv_delta: number @@ -531,6 +531,10 @@ export interface Invoice { features: { [k: string]: any } is_keysend: boolean } +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface Payment { + // if any fields are needed add them +} interface GreenlightOffchainPayment { label: string preimage: Buf @@ -614,13 +618,14 @@ export function connectPeerResponse( if (IS_GREENLIGHT) { return {} } - return {} + return {} } interface AmountsRes { satoshi: string millisatoshi: string } + function greenlightAmoutToAmounts(a: GreenlightAmount): AmountsRes { let satoshi = '' let millisatoshi = '' @@ -683,7 +688,6 @@ enum GreenlightChannelState { } function shortChanIDfromInt64(int: string): string { - if (typeof int !== 'string') return '' const l = long.fromString(int, true) const blockHeight = l.shiftRight(40) const txIndex = l.shiftRight(16).and(0xffffff) diff --git a/src/grpc/lightning.ts b/src/grpc/lightning.ts index a0e9b0dc4..ee3ab4ab4 100644 --- a/src/grpc/lightning.ts +++ b/src/grpc/lightning.ts @@ -171,8 +171,8 @@ export async function queryRoute( routes: [], } } - return new Promise(async function (resolve, reject) { - const lightning = await loadLightning(true, ownerPubkey) // try proxy + const lightning = await loadLightning(true, ownerPubkey) // try proxy + return new Promise((resolve, reject) => { const options: { [k: string]: any } = { pub_key, amt } if (route_hint && route_hint.includes(':')) { const arr = route_hint.split(':') @@ -202,8 +202,8 @@ export type NewAddressType = 0 | 1 | 2 | 3 export async function newAddress( type: NewAddressType = NESTED_PUBKEY_HASH ): Promise { - return new Promise(async function (resolve, reject) { - const lightning = await loadLightning() + const lightning = await loadLightning() + return new Promise((resolve, reject) => { lightning.newAddress({ type }, (err, response) => { if (err) { reject(err) @@ -218,14 +218,14 @@ export async function newAddress( }) } -// for payingn invoice and invite invoice +// for paying invoice and invite invoice export async function sendPayment( payment_request: string, ownerPubkey?: string ): Promise { sphinxLogger.info('sendPayment', logging.Lightning) - return new Promise(async (resolve, reject) => { - const lightning = await loadLightning(true, ownerPubkey) // try proxy + const lightning = await loadLightning(true, ownerPubkey) // try proxy + return new Promise((resolve, reject) => { if (isProxy()) { const opts = { payment_request, @@ -289,8 +289,7 @@ export function keysend( sphinxLogger.info('keysend', logging.Lightning) return new Promise(async function (resolve, reject) { try { - const randoStr = crypto.randomBytes(32).toString('hex') - const preimage = ByteBuffer.fromHex(randoStr) + const preimage = ByteBuffer.wrap(crypto.randomBytes(32)) const dest_custom_records = { [`${LND_KEYSEND_KEY}`]: preimage, } @@ -427,7 +426,7 @@ export async function keysendMessage( let res: any = null const ts = new Date().valueOf() // WEAVE MESSAGE If TOO LARGE - await asyncForEach(Array.from(Array(n)), async (u, i) => { + for (let i = 0; i < n; i++) { const spliti = Math.ceil((opts.data || '').length / n) const m = (opts.data || '').substring(i * spliti, i * spliti + spliti) const isLastThread = i === n - 1 @@ -447,7 +446,7 @@ export async function keysendMessage( sphinxLogger.error(e) fail = true } - }) + } if (success && !fail) { resolve(res) } else { @@ -456,12 +455,6 @@ export async function keysendMessage( }) } -async function asyncForEach(array, callback) { - for (let index = 0; index < array.length; index++) { - await callback(array[index], index, array) - } -} - export async function signAscii( ascii: string, ownerPubkey?: string @@ -490,14 +483,14 @@ export function listInvoices(): Promise { }) } -export async function listAllInvoices(): Promise { +export async function listAllInvoices(): Promise { sphinxLogger.info(`=> list all invoices`) - const invs = await paginateInvoices(40) - return invs + return paginateInvoices(40) } -async function paginateInvoices(limit, i = 0) { + +async function paginateInvoices(limit: number, i = 0): Promise { try { - const r: any = await listInvoicesPaginated(limit, i) + const r = await listInvoicesPaginated(limit, i) const lastOffset = parseInt(r.first_index_offset) if (lastOffset > 0) { return r.invoices.concat(await paginateInvoices(limit, lastOffset)) @@ -507,7 +500,8 @@ async function paginateInvoices(limit, i = 0) { return [] } } -function listInvoicesPaginated(limit, offset) { + +function listInvoicesPaginated(limit: number, offset: number): Promise<{ first_index_offset: string, invoices: interfaces.Invoice[] }> { return new Promise(async (resolve, reject) => { const lightning = await loadLightning() lightning.listInvoices( @@ -525,15 +519,16 @@ function listInvoicesPaginated(limit, offset) { } // need to upgrade to .10 for this -export async function listAllPayments(): Promise { +export async function listAllPayments(): Promise { sphinxLogger.info('=> list all payments') const pays = await paginatePayments(40) // max num sphinxLogger.info(`pays ${pays && pays.length}`) return pays } -async function paginatePayments(limit, i = 0) { + +async function paginatePayments(limit: number, i = 0): Promise { try { - const r: any = await listPaymentsPaginated(limit, i) + const r = await listPaymentsPaginated(limit, i) const lastOffset = parseInt(r.first_index_offset) // this is "first" cuz its in reverse (lowest index) if (lastOffset > 0) { return r.payments.concat(await paginatePayments(limit, lastOffset)) @@ -543,10 +538,8 @@ async function paginatePayments(limit, i = 0) { return [] } } -export function listPaymentsPaginated( - limit: number, - offset: number -): Promise { + +export function listPaymentsPaginated(limit: number, offset: number): Promise<{ first_index_offset: string, payments: interfaces.Payment[] }> { return new Promise(async (resolve, reject) => { const lightning = await loadLightning() lightning.listPayments( @@ -563,7 +556,7 @@ export function listPaymentsPaginated( }) } -export function listAllPaymentsFull(): Promise { +export function listAllPaymentsFull(): Promise<{ payments: interfaces.Payment[] }> { sphinxLogger.info('=> list all payments') return new Promise(async (resolve, reject) => { const lightning = await loadLightning() @@ -578,13 +571,8 @@ export function listAllPaymentsFull(): Promise { } // msg is hex -export async function signMessage( - msg: string, - ownerPubkey?: string -): Promise { - // log('signMessage') - const r = await signBuffer(Buffer.from(msg, 'hex'), ownerPubkey) - return r +export async function signMessage(msg: string, ownerPubkey?: string): Promise { + return signBuffer(Buffer.from(msg, 'hex'), ownerPubkey) } export function signBuffer(msg: Buffer, ownerPubkey?: string): Promise { @@ -599,7 +587,7 @@ export function signBuffer(msg: Buffer, ownerPubkey?: string): Promise { const recidBytes = sigBuf.subarray(66, 67) // 31 is the magic EC recid (27+4) for compressed pubkeys const ecRecid = Buffer.from(recidBytes).readUIntBE(0, 1) + 31 - const finalRecid = Buffer.from('00', 'hex') + const finalRecid = Buffer.allocUnsafe(1) finalRecid.writeUInt8(ecRecid, 0) const finalSig = Buffer.concat([finalRecid, sigBytes], 65) resolve(zbase32.encode(finalSig)) @@ -628,7 +616,7 @@ export async function verifyBytes( return r } -interface VerifyResponse { +export interface VerifyResponse { valid: boolean pubkey: string } @@ -662,7 +650,7 @@ export function verifyMessage( ) ) ) - const recoveredPubkey = secp256k1.recover( + const recoveredPubkey: Buffer = secp256k1.recover( Buffer.from(hash), // 32 byte hash of message sigBytes, // 64 byte signature of message (not DER, 32 byte R and 32 byte S with 0x00 padding) recid, // number 1 or 0. This will usually be encoded in the base64 message signature diff --git a/src/helpers.ts b/src/helpers.ts index 4d600927e..9744d6265 100644 --- a/src/helpers.ts +++ b/src/helpers.ts @@ -5,10 +5,10 @@ import type { Msg, Payload, ChatMember } from './network/interfaces' import constants from './constants' import { logging, sphinxLogger } from './utils/logger' -export const findOrCreateChat = async (params) => { +export const findOrCreateChat = async (params: { chat_id: number, owner_id: number, recipient_id: number }): Promise => { const { chat_id, owner_id, recipient_id } = params // console.log("chat_id, owner_id, recipient_id", chat_id, owner_id, recipient_id) - let chat + let chat: ChatRecord const date = new Date() date.setMilliseconds(0) // console.log("findOrCreateChat", chat_id, typeof chat_id, owner_id, typeof owner_id) @@ -18,7 +18,7 @@ export const findOrCreateChat = async (params) => { }) // console.log('findOrCreateChat: chat_id exists') } else { - if (!owner_id || !recipient_id) return null + if (!owner_id || !recipient_id) return sphinxLogger.info(`chat does not exists, create new`) const owner: ContactRecord = await models.Contact.findOne({ where: { id: owner_id }, @@ -39,8 +39,8 @@ export const findOrCreateChat = async (params) => { chat = await models.Chat.create({ uuid: uuid, contactIds: JSON.stringify([ - parseInt(owner_id), - parseInt(recipient_id), + owner_id, + recipient_id, ]), createdAt: date, updatedAt: date, @@ -65,12 +65,12 @@ export const sendContactKeys = async ({ type: number contactIds: number[] sender: any - success?: Function - failure?: Function + success?: ({ destination_key: string, amount: number }) => void + failure?: (error: Error) => void dontActuallySendContactKey?: boolean contactPubKey?: string routeHint?: string -}) => { +}): Promise => { const msg = newkeyexchangemsg( type, sender, @@ -101,7 +101,7 @@ export const sendContactKeys = async ({ } const contact = await models.Contact.findOne({ where: { id: contactId } }) if (!(contact && contact.publicKey)) return - const destination_key = contact.publicKey + const destination_key: string = contact.publicKey const route_hint = contact.routeHint // console.log("=> KEY EXCHANGE", msg) @@ -143,11 +143,11 @@ export const performKeysendMessage = async ({ route_hint?: string amount: number msg: Partial - success?: Function - failure?: Function + success?: (arg: {destination_key: string, amount: number} | boolean) => void + failure?: (error: Error) => void sender: any extra_tlv?: { [k: string]: any } -}) => { +}): Promise => { const opts = { dest: destination_key, data: msg || {}, @@ -174,7 +174,7 @@ export async function findOrCreateContactByPubkeyAndRouteHint( senderAlias: string, owner: Contact, realAmount: number -) { +): Promise { let sender = await models.Contact.findOne({ where: { publicKey: senderPubKey, tenant: owner.id }, }) @@ -207,11 +207,7 @@ export async function findOrCreateContactByPubkeyAndRouteHint( return sender } -export async function findOrCreateChatByUUID( - chat_uuid, - contactIds, - tenant -): Promise { +export async function findOrCreateChatByUUID(chat_uuid: string, contactIds: number[], tenant: number): Promise { let chat = await models.Chat.findOne({ where: { uuid: chat_uuid, tenant, deleted: false }, }) @@ -230,7 +226,7 @@ export async function findOrCreateChatByUUID( return chat } -export async function sleep(ms) { +export async function sleep(ms: number): Promise { return new Promise((resolve) => setTimeout(resolve, ms)) } @@ -356,7 +352,7 @@ export async function parseReceiveParams(payload: Payload): Promise<{ } } -export async function asyncForEach(array, callback) { +export async function asyncForEach(array: T[], callback: (value: T, index: number, array: T[]) => Promise): Promise { for (let index = 0; index < array.length; index++) { await callback(array[index], index, array) } diff --git a/src/models/index.ts b/src/models/index.ts index 296de6b59..b343d3eb0 100644 --- a/src/models/index.ts +++ b/src/models/index.ts @@ -1,5 +1,6 @@ // parse BIGINTs to number -require('pg').defaults.parseInt8 = true +import * as pg from 'pg' +pg.defaults.parseInt8 = true import { Sequelize } from 'sequelize-typescript' import * as path from 'path' import Chat, { ChatRecord } from './sql/chat' @@ -19,6 +20,7 @@ import RequestsTransportTokens from './sql/requestsTransportTokens' import * as minimist from 'minimist' import { loadConfig } from '../utils/config' import { isProxy } from '../utils/proxy' +import { readFileSync } from 'fs' const argv = minimist(process.argv.slice(2)) @@ -27,7 +29,7 @@ const configFile = argv.db : path.join(__dirname, '../../config/config.json') const env = process.env.NODE_ENV || 'development' -const config = require(configFile)[env] +const config = JSON.parse(readFileSync(configFile).toString())[env] const appConfig = loadConfig() @@ -81,4 +83,12 @@ export { BotMemberRecord, Invite, Subscription, + ChatBot, + Timer, + Bot, + Accounting, + MediaKey, + Lsat, + BotMember, + RequestsTransportTokens, } diff --git a/src/tests/utils/msg/sendTribeMessage.ts b/src/tests/utils/msg/sendTribeMessage.ts index cb5d7c348..7794e035e 100644 --- a/src/tests/utils/msg/sendTribeMessage.ts +++ b/src/tests/utils/msg/sendTribeMessage.ts @@ -18,7 +18,7 @@ export async function sendTribeMessage( t: Assertions, node1: NodeConfig, tribe: Chat, - text: String, + text: string, options?: SendMessageOptions ): Promise { //NODE1 SENDS TEXT MESSAGE TO NODE2 diff --git a/src/utils/msg.ts b/src/utils/msg.ts index ae231c510..cf8beaf5b 100644 --- a/src/utils/msg.ts +++ b/src/utils/msg.ts @@ -60,11 +60,11 @@ async function encryptTribeBroadcast( if (isTribeOwner) { // has been previously decrypted if (message.content) { - const encContent = await rsa.encrypt(contact.contactKey, message.content) + const encContent = rsa.encrypt(contact.contactKey, message.content.toString()) obj.content = encContent } if (message.mediaKey) { - const encMediaKey = await rsa.encrypt( + const encMediaKey = rsa.encrypt( contact.contactKey, message.mediaKey ) @@ -139,7 +139,7 @@ async function decryptMessage( content = m.content['chat'] } } - const decContent = rsa.decrypt(chat.groupPrivateKey, content) + const decContent = rsa.decrypt(chat.groupPrivateKey, content.toString()) obj.content = decContent } if (m.mediaKey) { diff --git a/src/utils/tribes.ts b/src/utils/tribes.ts index 21d694b44..ceabf4db8 100644 --- a/src/utils/tribes.ts +++ b/src/utils/tribes.ts @@ -41,7 +41,7 @@ export async function getTribeOwnersChatByUUID(uuid: string): Promise { model: models.Chat, mapToModel: true, // pass true here if you have any mapped fields } - ) as unknown as Chat + ) // console.log('=> getTribeOwnersChatByUUID r:', r) return r && r[0] && r[0].dataValues } catch (e) { @@ -138,7 +138,7 @@ async function initAndSubscribeTopics(onMessage: (topic: string, message: Buffer if (isProxy()) { const allOwners: Contact[] = await models.Contact.findAll({ where: { isOwner: true }, - }) as unknown as Contact[] + }) if (!(allOwners && allOwners.length)) return asyncForEach(allOwners, async c => { if (c.id === 1) return // the proxy non user @@ -170,7 +170,7 @@ async function subExtraHostsForTenant( tenant, host: { [Op.ne]: host }, // not the host from config }, - }) as unknown as Chat[] + }) if (!(externalTribes && externalTribes.length)) return const usedHosts: string[] = [] externalTribes.forEach(async (et) => { @@ -233,7 +233,7 @@ async function updateTribeStats(myPubkey) { ownerPubkey: myPubkey, deleted: false, }, - }) as unknown as Chat[] + }) await asyncForEach(myTribes, async (tribe) => { try { const contactIds = JSON.parse(tribe.contactIds)