diff --git a/.eslintignore b/.eslintignore index 3389f1dad..b3ecd2628 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,6 +1,5 @@ build/** components/** -coverage/** dist/** mnemonic_languages/** diff --git a/.gitignore b/.gitignore index 222adda6a..595b3f859 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,6 @@ node_modules .sass-cache .eslintcache -coverage/* build/curve25519_compiled.js build/icons/* stylesheets/*.css.map @@ -12,7 +11,6 @@ config/local-*.json *.provisionprofile release/ /dev-app-update.yml -.nyc_output/ *.sublime* sql/ diff --git a/.prettierignore b/.prettierignore index 6d510d168..b580692d3 100644 --- a/.prettierignore +++ b/.prettierignore @@ -47,6 +47,4 @@ test/fixtures.js stylesheets/_intlTelInput.scss # Coverage -coverage/** -.nyc_output/** release/** diff --git a/.yarnclean b/.yarnclean index 73649a14a..9a42251c3 100644 --- a/.yarnclean +++ b/.yarnclean @@ -14,10 +14,6 @@ assets # examples example -# code coverage directories -coverage -.nyc_output - # build scripts Makefile Gulpfile.js @@ -38,5 +34,3 @@ Gruntfile.js # misc *.md -# asset directories -!nyc/node_modules/istanbul-reports/lib/html/assets diff --git a/package.json b/package.json index 2af38bea6..1de7eb8da 100644 --- a/package.json +++ b/package.json @@ -20,18 +20,17 @@ "start-swarm-test": "cross-env NODE_ENV=swarm-testing NODE_APP_INSTANCE=$MULTI electron .", "grunt": "grunt", "grunt:dev": "yarn clean-transpile; yarn grunt dev --force", - "icon-gen": "electron-icon-maker --input=images/session/session_icon_1024.png --output=./build", + "icon-gen": "cp images/session/session_icon_1024.png --output=./build/icon.png", "generate": "yarn icon-gen && yarn grunt --force", "build-release": "cross-env SIGNAL_ENV=production electron-builder --config.extraMetadata.environment=production --publish=never --config.directories.output=release", "build-module-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", - "clean-module-protobuf": "rm -f ts/protobuf/compiled.d.ts ts/protobuf/compiled.js", + "clean-module-protobuf": "rimraf ts/protobuf/compiled.d.ts ts/protobuf/compiled.js", "build-protobuf": "yarn build-module-protobuf", "clean-protobuf": "yarn clean-module-protobuf", "test": "yarn test-node && yarn test-electron", "test-view": "NODE_ENV=test yarn run start", "test-lib-view": "NODE_ENV=test-lib yarn run start", "test-electron": "yarn grunt test", - "test-integration": "ELECTRON_DISABLE_SANDBOX=1 mocha --exit --full-trace --timeout 10000 ts/test/session/integration/integration_itest.js", "test-node": "mocha --recursive --exit --timeout 10000 test/app test/modules \"./ts/test/**/*_test.js\" ", "eslint-full": "eslint .", "lint-full": "yarn format-full && yarn lint-files-full", @@ -181,7 +180,6 @@ "eslint-plugin-import": "2.8.0", "eslint-plugin-mocha": "4.12.1", "eslint-plugin-more": "0.3.1", - "extract-zip": "1.6.6", "grunt": "1.0.1", "grunt-cli": "1.2.0", "grunt-contrib-concat": "1.0.1", @@ -196,12 +194,9 @@ "mocha-testcheck": "1.0.0-rc.0", "node-gyp": "3.8.0", "node-sass-import-once": "1.2.0", - "nyc": "11.4.1", "postinstall-prepare": "^1.0.1", "prettier": "1.19.0", "qs": "6.5.1", - "react-docgen-typescript": "1.2.6", - "react-styleguidist": "7.0.1", "sinon": "9.0.2", "spectron": "^10.0.0", "ts-loader": "4.1.0", @@ -322,7 +317,7 @@ "!**/node_modules/*/build/**", "!**/*.{o,hprof,orig,pyc,pyo,rbc}", "!**/._*", - "!**/{.DS_Store,.git,.hg,.svn,CVS,RCS,SCCS,__pycache__,thumbs.db,.gitignore,.gitattributes,.editorconfig,.flowconfig,.yarn-metadata.json,.idea,appveyor.yml,.travis.yml,circle.yml,npm-debug.log,.nyc_output,yarn.lock,.yarn-integrity,.map}", + "!**/{.DS_Store,.git,.hg,.svn,CVS,RCS,SCCS,__pycache__,thumbs.db,.gitignore,.gitattributes,.editorconfig,.flowconfig,.yarn-metadata.json,.idea,appveyor.yml,.travis.yml,circle.yml,npm-debug.log,,yarn.lock,.yarn-integrity,.map}", "node_modules/spellchecker/build/Release/*.node", "node_modules/websocket/build/Release/*.node", "node_modules/socks/build/*.js", diff --git a/styleguide.config.js b/styleguide.config.js deleted file mode 100644 index 95e700262..000000000 --- a/styleguide.config.js +++ /dev/null @@ -1,78 +0,0 @@ -const path = require('path'); -// eslint-disable-next-line import/no-extraneous-dependencies -const typescriptSupport = require('react-docgen-typescript'); - -const propsParser = typescriptSupport.withCustomConfig('./tsconfig.json').parse; - -module.exports = { - sections: [ - { - name: 'Components', - description: '', - components: 'ts/components/[^_]*.tsx', - }, - { - name: 'Conversation', - description: 'Everything necessary to render a conversation', - components: 'ts/components/conversation/[^_]*.tsx', - }, - { - name: 'Media Gallery', - description: 'Display media and documents in a conversation', - components: 'ts/components/conversation/media-gallery/[^_]*.tsx', - }, - { - name: 'Utility', - description: 'Utility components used across the application', - components: 'ts/components/utility/[^_]*.tsx', - }, - { - name: 'Test', - description: 'Components only used for testing', - components: 'ts/styleguide/**/*.tsx', - }, - ], - contextDependencies: [path.join(__dirname, 'ts/styleguide')], - // We don't want one long, single page - pagePerSection: true, - // Expose entire repository to the styleguidist server, primarily for stylesheets - assetsDir: './', - // Add top-level elements to the HTML: - // docs: https://github.com/vxna/mini-html-webpack-template - // https://react-styleguidist.js.org/docs/configuration.html#template - template: { - head: { - links: [ - { - rel: 'stylesheet', - type: 'text/css', - href: '/stylesheets/manifest.css', - }, - ], - }, - }, - propsParser, - webpackConfig: { - devtool: 'source-map', - - resolve: { - // Necessary to enable the absolute path used in the context option above - modules: [__dirname, path.join(__dirname, 'node_modules')], - extensions: ['.tsx'], - }, - - module: { - rules: [ - { - test: /\.tsx?$/, - loader: 'ts-loader', - }, - { - // To test handling of attachments, we need arraybuffers in memory - test: /\.(gif|mp3|mp4|txt|jpg|jpeg|png)$/, - loader: 'arraybuffer-loader', - }, - ], - }, - }, -}; diff --git a/test/index.html b/test/index.html index da7027e38..8cd88f6f1 100644 --- a/test/index.html +++ b/test/index.html @@ -61,11 +61,6 @@ - - - - - diff --git a/ts/session/onions/onionSend.ts b/ts/session/onions/onionSend.ts index 934a18731..961cfa6a6 100644 --- a/ts/session/onions/onionSend.ts +++ b/ts/session/onions/onionSend.ts @@ -177,7 +177,7 @@ export const sendViaOnion = async ( }); }, { - retries: 9, // each path can fail 3 times before being dropped, we have 3 paths at most + retries: 4, // each path can fail 3 times before being dropped, we have 3 paths at most factor: 2, minTimeout: 100, maxTimeout: 4000, diff --git a/ts/session/snode_api/SNodeAPI.ts b/ts/session/snode_api/SNodeAPI.ts index 911d4a8d3..d536eeece 100644 --- a/ts/session/snode_api/SNodeAPI.ts +++ b/ts/session/snode_api/SNodeAPI.ts @@ -542,7 +542,7 @@ export async function retrieveNextMessages( } catch (e) { window?.log?.warn( 'Got an error while retrieving next messages. Not retrying as we trigger fetch often:', - e + e.message ); if (e.message === ERROR_CODE_NO_CONNECT) { window.inboxStore?.dispatch(updateIsOnline(false)); diff --git a/ts/session/snode_api/onions.ts b/ts/session/snode_api/onions.ts index aeb5fa3bb..331ad883a 100644 --- a/ts/session/snode_api/onions.ts +++ b/ts/session/snode_api/onions.ts @@ -402,6 +402,7 @@ export async function decodeOnionResult(symmetricKey: ArrayBuffer, ciphertext: s return { plaintext: new TextDecoder().decode(plaintextBuffer), ciphertextBuffer }; } +const STATUS_NO_STATUS = 8888; /** * Only exported for testing purpose */ @@ -413,8 +414,8 @@ export async function processOnionResponse({ associatedWith, lsrpcEd25519Key, }: { - response: { text: () => Promise; status: number }; - symmetricKey: ArrayBuffer; + response?: { text: () => Promise; status: number }; + symmetricKey?: ArrayBuffer; guardNode: Snode; lsrpcEd25519Key?: string; abortSignal?: AbortSignal; @@ -425,13 +426,13 @@ export async function processOnionResponse({ processAbortedRequest(abortSignal); try { - ciphertext = await response.text(); + ciphertext = (await response?.text()) || ''; } catch (e) { window?.log?.warn(e); } await processOnionRequestErrorOnPath( - response.status, + response?.status || STATUS_NO_STATUS, ciphertext, guardNode.pubkey_ed25519, lsrpcEd25519Key, @@ -455,10 +456,12 @@ export async function processOnionResponse({ ciphertextBuffer = decoded.ciphertextBuffer; } catch (e) { window?.log?.error('[path] lokiRpc::processingOnionResponse - decode error', e); - window?.log?.error( - '[path] lokiRpc::processingOnionResponse - symmetricKey', - toHex(symmetricKey) - ); + if (symmetricKey) { + window?.log?.error( + '[path] lokiRpc::processingOnionResponse - symmetricKey', + toHex(symmetricKey) + ); + } if (ciphertextBuffer) { window?.log?.error( '[path] lokiRpc::processingOnionResponse - ciphertextBuffer', @@ -666,13 +669,22 @@ const sendOnionRequestHandlingSnodeEject = async ({ }): Promise => { // this sendOnionRequest() call has to be the only one like this. // If you need to call it, call it through sendOnionRequestHandlingSnodeEject because this is the one handling path rebuilding and known errors - const { response, decodingSymmetricKey } = await sendOnionRequest({ - nodePath, - destX25519Any, - finalDestOptions, - finalRelayOptions, - abortSignal, - }); + let response, decodingSymmetricKey; + try { + // this might throw a timeout error + const result = await sendOnionRequest({ + nodePath, + destX25519Any, + finalDestOptions, + finalRelayOptions, + abortSignal, + }); + + response = result.response; + decodingSymmetricKey = result.decodingSymmetricKey; + } catch (e) { + window.log.warn('sendOnionRequest', e); + } // this call will handle the common onion failure logic. // if an error is not retryable a AbortError is triggered, which is handled by pRetry and retries are stopped const processed = await processOnionResponse({ @@ -877,7 +889,7 @@ export async function lokiOnionFetch( return retriedResult; } catch (e) { - window?.log?.warn('onionFetchRetryable failed ', e); + window?.log?.warn('onionFetchRetryable failed ', e.message); // console.warn('error to show to user'); if (e?.errno === 'ENETUNREACH') { // better handle the no connection state diff --git a/ts/util/lint/linter.ts b/ts/util/lint/linter.ts index fc4734ba1..03a9d7a19 100644 --- a/ts/util/lint/linter.ts +++ b/ts/util/lint/linter.ts @@ -128,7 +128,6 @@ const excludedFiles = [ '^node_modules/node-sass-import-once/*', '^node_modules/node-sass/*', '^node_modules/nsp/*', - '^node_modules/nyc/*', '^node_modules/phantomjs-prebuilt/*', '^node_modules/postcss*', '^node_modules/preserve/*', @@ -137,7 +136,6 @@ const excludedFiles = [ '^node_modules/ramda/*', '^node_modules/react-docgen/*', '^node_modules/react-error-overlay/*', - '^node_modules/react-styleguidist/*', '^node_modules/recast/*', '^node_modules/reduce-css-calc/*', '^node_modules/resolve/*', diff --git a/ts/util/lint/rules.json b/ts/util/lint/rules.json index 6125feb20..134f92638 100644 --- a/ts/util/lint/rules.json +++ b/ts/util/lint/rules.json @@ -114,51 +114,6 @@ "expression": "\\bload\\(", "reason": "Arbitrary code execution" }, - { - "name": "React-ref", - "expression": "\\bref(\\s)*=\\b", - "reason": "Potential XSS", - "excludedModules": [ - "node_modules/react-dom", - "node_modules/tslint-microsoft-contrib", - "node_modules/react-error-overlay", - "node_modules/react-styleguidist" - ] - }, - { - "name": "React-createRef", - "expression": "\\bcreateRef\\(", - "reason": "Potential XSS", - "excludedModules": [ - "node_modules/react/", - "node_modules/react-dom", - "node_modules/tslint-microsoft-contrib", - "node_modules/react-error-overlay", - "node_modules/react-styleguidist" - ] - }, - { - "name": "React-findDOMNode", - "expression": "\\bfindDOMNode\\(", - "reason": "Potential XSS", - "excludedModules": [ - "node_modules/react-dom", - "node_modules/tslint-microsoft-contrib", - "node_modules/react-error-overlay", - "node_modules/react-styleguidist" - ] - }, - { - "name": "React-dangerouslySetInnerHTML", - "expression": "\\bdangerouslySetInnerHTML\\b", - "reason": "Potential XSS", - "excludedModules": [ - "node_modules/react-dom", - "node_modules/tslint-microsoft-contrib", - "node_modules/react-error-overlay", - "node_modules/react-styleguidist" - ] - }, { "name": "fbjs-createNodesFromMarkup", "expression": "\\bcreateNodesFromMarkup\\b", diff --git a/tslint.json b/tslint.json index 79c9acaf1..e74f971d7 100644 --- a/tslint.json +++ b/tslint.json @@ -73,7 +73,7 @@ } ], // Adding select dev dependencies here for now, may turn on all in the future - "no-implicit-dependencies": [true, ["dashdash", "electron"]], + "no-implicit-dependencies": [true, ["electron"]], // Maybe will turn on: // We're not trying to be comprehensive with JSDoc right now. We have the style guide. "completed-docs": false,