diff --git a/packages/transport-bridge/package.json b/packages/transport-bridge/package.json index 68fbd3a84a..46e7882925 100644 --- a/packages/transport-bridge/package.json +++ b/packages/transport-bridge/package.json @@ -18,7 +18,6 @@ "build:lib": "yarn build:js" }, "devDependencies": { - "@types/json-stable-stringify": "^1", "esbuild": "^0.25.2", "html-inline-script-webpack-plugin": "^3.2.1", "html-webpack-plugin": "5.6.5", @@ -32,7 +31,6 @@ "@trezor/theme": "workspace:*", "@trezor/transport": "workspace:*", "@trezor/utils": "workspace:*", - "json-stable-stringify": "^1.2.1", "react": "19.1.0", "react-dom": "19.1.0", "react-intl": "^8.0.6", diff --git a/packages/transport-bridge/src/http.ts b/packages/transport-bridge/src/http.ts index cc85510fdc..ecea48eaa7 100644 --- a/packages/transport-bridge/src/http.ts +++ b/packages/transport-bridge/src/http.ts @@ -1,5 +1,4 @@ import fs from 'fs/promises'; -import stringify from 'json-stable-stringify'; import path from 'path'; import { URL } from 'url'; @@ -143,12 +142,28 @@ export class TrezordNode { `http: resolving listen subscriptions. n of aborted subscriptions: ${aborted.length}`, ); } + const [affected, unaffected] = arrayPartition(notAborted, subscription => { + const currentState = new Map(this.descriptors.map(d => [d.path, d])); + const changed = subscription.descriptors.some(d => { + const current = currentState.get(d.path); + if (!current) return true; - const [affected, unaffected] = arrayPartition( - notAborted, - // TODO this may be tricky comparison, e.g. when client send something extra in the descriptors - subscription => stringify(subscription.descriptors) !== stringify(this.descriptors), - ); + currentState.delete(d.path); + const fields = [ + 'id', + 'type', + 'session', + 'sessionOwner', + 'debugSession', + 'vendor', + 'product', + ] as (keyof Descriptor)[]; + + return fields.some(f => current[f] !== d[f]); + }); + + return changed || currentState.size > 0; + }); this.logger?.debug( `http: affected subscriptions ${affected.length}. unaffected subscriptions ${unaffected.length}`, diff --git a/scripts/list-outdated-dependencies/connect-dependencies.txt b/scripts/list-outdated-dependencies/connect-dependencies.txt index d0c783d87f..e68ff03e2f 100644 --- a/scripts/list-outdated-dependencies/connect-dependencies.txt +++ b/scripts/list-outdated-dependencies/connect-dependencies.txt @@ -11,7 +11,6 @@ @types/chrome @types/flexsearch @types/git-url-parse -@types/json-stable-stringify @types/jws @types/karma @types/lodash @@ -47,7 +46,6 @@ git-url-parse groestl-hash-js html-inline-script-webpack-plugin intersection-observer -json-stable-stringify json5 jssha karma diff --git a/yarn.lock b/yarn.lock index 30c37bd6fa..cb790ad854 100644 --- a/yarn.lock +++ b/yarn.lock @@ -15440,11 +15440,9 @@ __metadata: "@trezor/theme": "workspace:*" "@trezor/transport": "workspace:*" "@trezor/utils": "workspace:*" - "@types/json-stable-stringify": "npm:^1" esbuild: "npm:^0.25.2" html-inline-script-webpack-plugin: "npm:^3.2.1" html-webpack-plugin: "npm:5.6.5" - json-stable-stringify: "npm:^1.2.1" react: "npm:19.1.0" react-dom: "npm:19.1.0" react-intl: "npm:^8.0.6" @@ -16480,13 +16478,6 @@ __metadata: languageName: node linkType: hard -"@types/json-stable-stringify@npm:^1": - version: 1.0.36 - resolution: "@types/json-stable-stringify@npm:1.0.36" - checksum: 10/765b07589e11a3896c3d06bb9e3a9be681e7edd95adf27370df0647a91bd2bfcfaf0e091fd4a13729343b388973f73f7e789d6cc62ab988240518a2d27c4a4e2 - languageName: node - linkType: hard - "@types/json5@npm:^0.0.29": version: 0.0.29 resolution: "@types/json5@npm:0.0.29" @@ -31285,7 +31276,7 @@ __metadata: languageName: node linkType: hard -"json-stable-stringify@npm:^1.0.2, json-stable-stringify@npm:^1.2.1": +"json-stable-stringify@npm:^1.0.2": version: 1.2.1 resolution: "json-stable-stringify@npm:1.2.1" dependencies: