From 9f3ed291aca76bd81f2c0b0f34351ec5a94b7536 Mon Sep 17 00:00:00 2001 From: Konstantinos Kopanidis Date: Wed, 4 Oct 2023 15:20:30 +0300 Subject: [PATCH] fix(hermes): object-hash issues --- libraries/hermes/package.json | 3 ++- libraries/hermes/src/Router.ts | 2 +- libraries/hermes/src/Socket/Socket.ts | 2 +- yarn.lock | 5 +++++ 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/libraries/hermes/package.json b/libraries/hermes/package.json index 0f0e74b82..d79b420ed 100644 --- a/libraries/hermes/package.json +++ b/libraries/hermes/package.json @@ -12,7 +12,6 @@ "build": "node_modules/.bin/rimraf dist && tsc", "publish": "npm publish", "postbuild": "copyfiles -u 1 src/*.proto src/**/*.json ./dist/" - }, "license": "ISC", "dependencies": { @@ -21,6 +20,7 @@ "@grpc/grpc-js": "^1.8.13", "@grpc/proto-loader": "^0.7.6", "@socket.io/redis-adapter": "^8.1.0", + "@types/object-hash": "^3.0.4", "body-parser": "^1.20.2", "cookie-parser": "~1.4.6", "cors": "^2.8.5", @@ -56,6 +56,7 @@ "@types/ioredis": "^4.28.10", "@types/lodash": "^4.14.192", "@types/node": "18.15.11", + "@types/object-hash": "^3.0.4", "rimraf": "^5.0.0", "typescript": "~5.0.4" } diff --git a/libraries/hermes/src/Router.ts b/libraries/hermes/src/Router.ts index 6e3d79813..c74abb816 100644 --- a/libraries/hermes/src/Router.ts +++ b/libraries/hermes/src/Router.ts @@ -127,7 +127,7 @@ export abstract class ConduitRouter { const routeKey = `${route.input.action}-${route.input.path}`; if (this._registeredRoutes.has(routeKey)) { return ( - ObjectHash.sha1(route) !== ObjectHash.sha1(this._registeredRoutes.get(routeKey)) + ObjectHash.sha1(route) !== ObjectHash.sha1(this._registeredRoutes.get(routeKey)!) ); } else { return true; diff --git a/libraries/hermes/src/Socket/Socket.ts b/libraries/hermes/src/Socket/Socket.ts index fc699af46..a4d45d71a 100644 --- a/libraries/hermes/src/Socket/Socket.ts +++ b/libraries/hermes/src/Socket/Socket.ts @@ -67,7 +67,7 @@ export class SocketController extends ConduitRouter { if (this._registeredNamespaces.has(namespace)) { if ( ObjectHash.sha1(conduitSocket) !== - ObjectHash.sha1(this._registeredNamespaces.get(namespace)) + ObjectHash.sha1(this._registeredNamespaces.get(namespace)!) ) { this.removeNamespace(namespace); if (this.metrics?.registeredRoutes) { diff --git a/yarn.lock b/yarn.lock index 29b2863cf..4fed94781 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4649,6 +4649,11 @@ dependencies: "@types/node" "*" +"@types/object-hash@^3.0.4": + version "3.0.4" + resolved "https://registry.yarnpkg.com/@types/object-hash/-/object-hash-3.0.4.tgz#31865a3d69de1042fec2ede56fd8cf0bb4e01641" + integrity sha512-w4fEy2suq1bepUxHoJRCBHJz0vS5DPAYpSbcgNwOahljxwyJsiKmi8qyes2/TJc+4Avd7fsgP+ZgUuXZjPvdug== + "@types/otp-generator@^4.0.0": version "4.0.0" resolved "https://registry.yarnpkg.com/@types/otp-generator/-/otp-generator-4.0.0.tgz#da28b1e254f46262e176ba96541bcfa32660da98"