diff --git a/.github/workflows/build-binaries.yml b/.github/workflows/build-binaries.yml index 0d81fe895..bb10fc39d 100644 --- a/.github/workflows/build-binaries.yml +++ b/.github/workflows/build-binaries.yml @@ -32,7 +32,11 @@ jobs: - name: Checkout git repo uses: actions/checkout@v3 - - uses: ./actions/setup_and_build + - name: Setup & Build + uses: ./actions/setup_and_build + + - name: Enforce yarn.lock has no duplicates + uses: ./actions/deduplicate_fail - name: Build windows production binaries if: runner.os == 'Windows' diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 895d9897d..68974bb15 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -28,12 +28,16 @@ jobs: - name: Checkout git repo uses: actions/checkout@v3 - - uses: ./actions/setup_and_build + - name: Setup & Build + uses: ./actions/setup_and_build - name: Lint Files # no need to lint files on all platforms. Just do it once on the quicker one if: runner.os == 'Linux' run: yarn lint-full + - name: Enforce yarn.lock has no duplicates + uses: ./actions/deduplicate_fail + - name: Unit Test run: yarn test diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index acb114a50..905a21fe2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,7 +22,8 @@ jobs: - name: Checkout git repo uses: actions/checkout@v3 - - uses: ./actions/setup_and_build + - name: Setup & Build + uses: ./actions/setup_and_build - name: Build windows production binaries if: runner.os == 'Windows' diff --git a/actions/deduplicate_fail/action.yml b/actions/deduplicate_fail/action.yml new file mode 100644 index 000000000..339d2b382 --- /dev/null +++ b/actions/deduplicate_fail/action.yml @@ -0,0 +1,9 @@ +name: 'Deduplicate check' +description: 'Deduplicate check' +runs: + using: 'composite' + steps: + - name: Enforce yarn.lock has no duplicates + shell: bash + if: runner.os == 'Linux' + run: yarn dedup-yarn-lock --fail diff --git a/package.json b/package.json index 724ecee4a..55592bbc5 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "session-desktop", "productName": "Session", "description": "Private messaging from your desktop", - "version": "1.13.0", + "version": "1.13.1", "license": "GPL-3.0", "author": { "name": "Oxen Labs", @@ -43,7 +43,7 @@ "protobuf": "pbjs --target static-module --wrap commonjs --out ts/protobuf/compiled.js protos/*.proto && pbts --out ts/protobuf/compiled.d.ts ts/protobuf/compiled.js --force-long", "sass": "rimraf 'stylesheets/dist/' && webpack --config=./sass.config.js", "clean": "rimraf 'ts/**/*.js' 'ts/*.js' 'ts/*.js.map' 'ts/**/*.js.map' && rimraf tsconfig.tsbuildinfo;", - "lint-full": "yarn format-full && eslint .", + "lint-full": "yarn dedup-yarn-lock && yarn format-full && eslint .", "format-full": "prettier --list-different --write \"*.{css,js,json,scss,ts,tsx}\" \"./**/*.{css,js,json,scss,ts,tsx}\"", "start-prod-test": "cross-env NODE_ENV=production NODE_APP_INSTANCE=$MULTI electron .", "test": "mocha", @@ -60,11 +60,12 @@ "appImage": "yarn sedtoAppImage; yarn build-release-non-linux; yarn sedtoDeb", "sedtoAppImage": "sed -i 's/\"target\": \\[\"deb\", \"rpm\", \"freebsd\"\\]/\"target\": \"AppImage\"/g' package.json", "sedtoDeb": "sed -i 's/\"target\": \"AppImage\"/\"target\": \\[\"deb\", \"rpm\", \"freebsd\"\\]/g' package.json", - "ready": "yarn build-everything && yarn lint-full && yarn test", + "ready": "yarn dedup-yarn-lock --fail && yarn build-everything && yarn lint-full && yarn test", "postinstall": "yarn patch-package && yarn electron-builder install-app-deps", "update-git-info": "node ./build/updateLocalConfig.js", "worker:utils": "webpack --config=./utils.worker.config.js", "worker:libsession": "rimraf 'ts/webworker/workers/node/libsession/*.node' && webpack --config=./libsession.worker.config.js", + "dedup-yarn-lock": "yarn-deduplicate yarn.lock", "prepare": "husky install" }, "dependencies": { @@ -97,7 +98,7 @@ "fs-extra": "9.0.0", "glob": "7.1.2", "image-type": "^4.1.0", - "libsession_util_nodejs": "https://github.com/oxen-io/libsession-util-nodejs/releases/download/v0.3.21/libsession_util_nodejs-v0.3.21.tar.gz", + "libsession_util_nodejs": "https://github.com/oxen-io/libsession-util-nodejs/releases/download/v0.3.22/libsession_util_nodejs-v0.3.22.tar.gz", "libsodium-wrappers-sumo": "^0.7.9", "linkify-it": "^4.0.1", "lodash": "^4.17.21", @@ -214,7 +215,8 @@ "ts-loader": "^9.4.2", "typescript": "^5.1.6", "webpack": "^5.76.3", - "webpack-cli": "^5.1.4" + "webpack-cli": "^5.1.4", + "yarn-deduplicate": "^6.0.2" }, "engines": { "node": "18.15.0" diff --git a/ts/session/apis/file_server_api/FileServerApi.ts b/ts/session/apis/file_server_api/FileServerApi.ts index 67b5e079a..f9dee5bf9 100644 --- a/ts/session/apis/file_server_api/FileServerApi.ts +++ b/ts/session/apis/file_server_api/FileServerApi.ts @@ -137,7 +137,8 @@ export const getLatestReleaseFromFileServer = async ( ed25519SecretKey: userEd25519SecretKey, sigTimestampSeconds, }); - const body = { + + const headers = { 'X-FS-Pubkey': blindedPkHex, 'X-FS-Timestamp': `${sigTimestampSeconds}`, 'X-FS-Signature': fromUInt8ArrayToBase64(signature), @@ -146,7 +147,8 @@ export const getLatestReleaseFromFileServer = async ( abortSignal: new AbortController().signal, endpoint: RELEASE_VERSION_ENDPOINT, method: 'GET', - stringifiedBody: JSON.stringify(body), + stringifiedBody: null, + headers, }); if (!batchGlobalIsSuccess(result) || parseStatusCodeFromOnionRequestV4(result) !== 200) { diff --git a/ts/session/onions/onionSend.ts b/ts/session/onions/onionSend.ts index 127f37428..eb14f21c8 100644 --- a/ts/session/onions/onionSend.ts +++ b/ts/session/onions/onionSend.ts @@ -502,8 +502,9 @@ async function sendJsonViaOnionV4ToFileServer(sendOptions: { method: string; stringifiedBody: string | null; abortSignal: AbortSignal; + headers: Record; }): Promise { - const { endpoint, method, stringifiedBody, abortSignal } = sendOptions; + const { endpoint, method, stringifiedBody, abortSignal, headers } = sendOptions; if (!endpoint.startsWith('/')) { throw new Error('endpoint needs a leading /'); } @@ -514,7 +515,7 @@ async function sendJsonViaOnionV4ToFileServer(sendOptions: { builtUrl, { method, - headers: {}, + headers, body: stringifiedBody, useV4: true, }, diff --git a/ts/test/session/unit/onion/OnionPaths_test.ts b/ts/test/session/unit/onion/OnionPaths_test.ts index 37981f736..8bbec24d1 100644 --- a/ts/test/session/unit/onion/OnionPaths_test.ts +++ b/ts/test/session/unit/onion/OnionPaths_test.ts @@ -115,9 +115,8 @@ describe('OnionPaths', () => { describe('getRandomEdgeSnode', () => { it('random if multiple matches', () => { const originalSnodePool = generateFakeSnodes(5); - const filtered = originalSnodePool.filter((_m, i) => i % 5 !== 0); const winner = OnionPaths.getRandomEdgeSnode(originalSnodePool); - expect(filtered).to.deep.include(winner); + expect(originalSnodePool).to.deep.include(winner); }); }); diff --git a/yarn.lock b/yarn.lock index 27e9e96d1..28c77acd2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1786,9 +1786,9 @@ available-typed-arrays@^1.0.7: possible-typed-array-names "^1.0.0" axios@^1.6.5: - version "1.7.2" - resolved "https://registry.yarnpkg.com/axios/-/axios-1.7.2.tgz#b625db8a7051fbea61c35a3cbb3a1daa7b9c7621" - integrity sha512-2A8QhOMrbomlDuiLeK9XibIBzuHeRcqqNOHp0Cyp5EoJ1IFDh+XZH3A6BkXtv0K4gFGCI0Y4BM7B1wOEi0Rmgw== + version "1.7.4" + resolved "https://registry.yarnpkg.com/axios/-/axios-1.7.4.tgz#4c8ded1b43683c8dd362973c393f3ede24052aa2" + integrity sha512-DukmaFRnY6AzAALSH4J2M3k6PkaC+MfaAGdEERRWcC9q3/TWQwLpHR8ZRLKTdQ3aBDL64EdluRDjJqKw+BPZEw== dependencies: follow-redirects "^1.15.6" form-data "^4.0.0" @@ -2642,9 +2642,9 @@ date-fns@^3.3.1: integrity sha512-fRHTG8g/Gif+kSh50gaGEdToemgfj74aRX3swtiouboip5JDLAyDE9F11nHMIcvOaXeOC6D7SpNhi7uFyB7Uww== debug@4, debug@^4, debug@^4.0.1, debug@^4.1.0, debug@^4.1.1, debug@^4.3.1, debug@^4.3.2, debug@^4.3.4: - version "4.3.5" - resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.5.tgz#e83444eceb9fedd4a1da56d671ae2446a01a6e1e" - integrity sha512-pt0bNEmneDIvdL1Xsd9oDQ/wrQRkXDT4AUWlNZNPKvW5x/jyO9VFXkJUP07vQ2upmw5PlaITaPKc31jK13V+jg== + version "4.3.6" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.6.tgz#2ab2c38fbaffebf8aa95fdfe6d88438c7a13c52b" + integrity sha512-O/09Bd4Z1fBrU4VzkhFqVgpPzaGbw6Sm9FEkBT1A/YBXQFGuuSxa1dN2nxgxS34JmKXqYx8CZAwEVoJFImUXIg== dependencies: ms "2.1.2" @@ -4928,9 +4928,9 @@ levn@~0.3.0: prelude-ls "~1.1.2" type-check "~0.3.2" -"libsession_util_nodejs@https://github.com/oxen-io/libsession-util-nodejs/releases/download/v0.3.21/libsession_util_nodejs-v0.3.21.tar.gz": - version "0.3.21" - resolved "https://github.com/oxen-io/libsession-util-nodejs/releases/download/v0.3.21/libsession_util_nodejs-v0.3.21.tar.gz#64705b1f7c934ca32f929ea8127370cc82bab97a" +"libsession_util_nodejs@https://github.com/oxen-io/libsession-util-nodejs/releases/download/v0.3.22/libsession_util_nodejs-v0.3.22.tar.gz": + version "0.3.22" + resolved "https://github.com/oxen-io/libsession-util-nodejs/releases/download/v0.3.22/libsession_util_nodejs-v0.3.22.tar.gz#6d9246a7469edb6b90edd9b637726419e4a65571" dependencies: cmake-js "^7.2.1" node-addon-api "^6.1.0" @@ -6839,10 +6839,10 @@ semver@^6.0.0, semver@^6.2.0, semver@^6.3.0, semver@^6.3.1: resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.1.tgz#556d2ef8689146e46dcea4bfdd095f3434dffcb4" integrity sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA== -semver@^7.1.2, semver@^7.3.2, semver@^7.3.4, semver@^7.3.5, semver@^7.3.7, semver@^7.5.4: - version "7.6.2" - resolved "https://registry.yarnpkg.com/semver/-/semver-7.6.2.tgz#1e3b34759f896e8f14d6134732ce798aeb0c6e13" - integrity sha512-FNAIBWCx9qcRhoHcgcJ0gvU7SN1lYU2ZXuSfl04bSC5OpvDHFyJCjdNHomPXxjQlCBU67YW64PzY7/VIEH7F2w== +semver@^7.1.2, semver@^7.3.2, semver@^7.3.4, semver@^7.3.5, semver@^7.3.7, semver@^7.5.0, semver@^7.5.4: + version "7.6.3" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.6.3.tgz#980f7b5550bc175fb4dc09403085627f9eb33143" + integrity sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A== serialize-error@^7.0.1: version "7.0.1" @@ -7484,7 +7484,7 @@ tslib@2.6.2: resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.2.tgz#703ac29425e7b37cd6fd456e92404d46d1f3e4ae" integrity sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q== -tslib@^2.1.0, tslib@^2.4.0: +tslib@^2.1.0, tslib@^2.4.0, tslib@^2.5.0: version "2.6.3" resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.3.tgz#0438f810ad7a9edcde7a241c3d80db693c8cbfe0" integrity sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ== @@ -8101,6 +8101,16 @@ yargs@^17.0.0, yargs@^17.0.1, yargs@^17.7.2: y18n "^5.0.5" yargs-parser "^21.1.1" +yarn-deduplicate@^6.0.2: + version "6.0.2" + resolved "https://registry.yarnpkg.com/yarn-deduplicate/-/yarn-deduplicate-6.0.2.tgz#63498d2d4c3a8567e992a994ce0ab51aa5681f2e" + integrity sha512-Efx4XEj82BgbRJe5gvQbZmEO7pU5DgHgxohYZp98/+GwPqdU90RXtzvHirb7hGlde0sQqk5G3J3Woyjai8hVqA== + dependencies: + "@yarnpkg/lockfile" "^1.1.0" + commander "^10.0.1" + semver "^7.5.0" + tslib "^2.5.0" + yauzl@^2.10.0: version "2.10.0" resolved "https://registry.yarnpkg.com/yauzl/-/yauzl-2.10.0.tgz#c7eb17c93e112cb1086fa6d8e51fb0667b79a5f9"