diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..20080bb --- /dev/null +++ b/.dockerignore @@ -0,0 +1,9 @@ +* +!package.json +!yarn.lock +!build.sh +!default.conf +!start.sh +!server/* +!client/* +**/node_modules/* \ No newline at end of file diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 1eeb4ca..0000000 --- a/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -.DS_Store -node_modules -*.log -*sublime* -*.rdb \ No newline at end of file diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 0000000..b009dfb --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +lts/* diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..3836da9 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,7 @@ +{ + "trailingComma": "all", + "tabWidth": 2, + "singleQuote": true, + "arrowParens": "avoid", + "printWidth": 120 +} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..871c997 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +#FROM nginx:alpine3.18 +FROM node:20.9.0-alpine3.18 + +WORKDIR /home/node +COPY --chown=node:node . . + +RUN apk update && apk add --no-cache bash nginx openssl && \ + rm /etc/nginx/http.d/default.conf && \ + mv /home/node/default.conf /etc/nginx/http.d/ && \ + chmod +x /home/node/start.sh && \ + npm install -g yarn@latest --force && \ + yarn upgrade --no-cache && \ + yarn build + + +STOPSIGNAL SIGINT +# Start the startup script +CMD ["/home/node/start.sh"] \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..7c05ada --- /dev/null +++ b/LICENSE @@ -0,0 +1,23 @@ + +(The MIT License) + +Copyright (c) 2016-present darkwire.io + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/app.json b/app.json new file mode 100644 index 0000000..042fb5b --- /dev/null +++ b/app.json @@ -0,0 +1,54 @@ +{ + "name": "Darkwire", + "description": "End-to-end encrypted web chat", + "keywords": [ + "cryptography", + "chat", + "privacy" + ], + "website": "https://darkwire.io", + "repository": "https://github.com/darkwire/darkwire.io", + "env": { + "HEROKU_APP_NAME": { + "required": false + }, + "HEROKU_PARENT_APP_NAME": { + "required": false + }, + "MAILGUN_API_KEY": { + "description": "Mailgun API Key (only required for abuse reporting)", + "required": false + }, + "ABUSE_TO_EMAIL_ADDRESS": { + "description": "Where to send abuse reports (only required for abuse reporting)", + "required": false + }, + "MAILGUN_DOMAIN": { + "description": "Mailgun domain (only required for abuse reporting)", + "required": false + }, + "ABUSE_FROM_EMAIL_ADDRESS": { + "description": "From address on abuse emails (only required for abuse reporting)", + "required": false + }, + "API_HOST": { + "description": "Example: 'api.your-darkwire-api.com'", + "required": false + }, + "API_PROTOCOL": { + "description": "Example: 'https'", + "required": false, + "value": "https" + }, + "API_PORT": { + "description": "Example: 443", + "required": false, + "value": "443" + }, + "SITE_URL": { + "description": "Full URL of site. Example: https://darkwire.io", + "required": false + } + }, + "image": "heroku/nodejs" +} \ No newline at end of file diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..f3fb8a8 --- /dev/null +++ b/build.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +api_host=$API_HOST + +echo "building client..." +cd client +yarn upgrade +yarn build +cd ../ + +echo "building server..." +cd server +yarn upgrade +yarn build \ No newline at end of file diff --git a/client/.env.dist b/client/.env.dist new file mode 100644 index 0000000..311bb67 --- /dev/null +++ b/client/.env.dist @@ -0,0 +1,14 @@ +# Api settings +TZ=UTC +VITE_API_HOST=localhost +VITE_API_PROTOCOL=http +VITE_API_PORT=3001 +VITE_COMMIT_SHA=some_sha + +# To display darkwire version +VITE_COMMIT_SHA=some_sha + +# Set max transferable file size in MB +VITE_MAX_FILE_SIZE=4 + + diff --git a/client/.eslintrc.cjs b/client/.eslintrc.cjs new file mode 100644 index 0000000..6815699 --- /dev/null +++ b/client/.eslintrc.cjs @@ -0,0 +1,10 @@ +module.exports = { + extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'], + parser: '@typescript-eslint/parser', + plugins: ['@typescript-eslint'], + root: true, + env: { + browser: true, + node: true, + }, +}; diff --git a/client/.gitignore b/client/.gitignore new file mode 100644 index 0000000..c7f41f7 --- /dev/null +++ b/client/.gitignore @@ -0,0 +1,25 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +dist/ +dist-ssr +*.local +coverage + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/client/LICENSE b/client/LICENSE new file mode 100644 index 0000000..94da581 --- /dev/null +++ b/client/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2016-present darkwire.io + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/client/README.md b/client/README.md new file mode 100644 index 0000000..b8f0546 --- /dev/null +++ b/client/README.md @@ -0,0 +1,11 @@ +# Darkwire Client + +This is the client for [Darkwire](https://github.com/darkwire/darkwire.io). It requires [darkwire-server](../server) in order to run. + +## Translations + +Translation strings are pulled from JSON files in [this directory](https://github.com/darkwire/darkwire.io/tree/master/client/src/i18n). We welcome pull requests to add support for more lanuages. For native speakers, it should take only a few minutes to translate the site. + +Please see [this PR](https://github.com/darkwire/darkwire.io/pull/95) for an example of what your translation PR should look like. + +Thank you for your contributions! diff --git a/client/index.html b/client/index.html new file mode 100644 index 0000000..712990b --- /dev/null +++ b/client/index.html @@ -0,0 +1,17 @@ + + + + + + + + + + + Darkwire.io - instant encrypted web chat + + +
+ + + diff --git a/client/jsconfig.json b/client/jsconfig.json new file mode 100644 index 0000000..0ecf7b3 --- /dev/null +++ b/client/jsconfig.json @@ -0,0 +1,9 @@ +{ + "compilerOptions": { + "baseUrl": "src", + "paths": { + "@/*": ["src/*"] + } + } +} + diff --git a/client/package.json b/client/package.json new file mode 100644 index 0000000..d535d5e --- /dev/null +++ b/client/package.json @@ -0,0 +1,77 @@ +{ + "name": "darkwire-client", + "version": "2.0.0-beta.12", + "main": "index.js", + "type": "module", + "contributors": [ + { + "name": "Daniel Seripap" + }, + { + "name": "Alan Friedman" + } + ], + "license": "MIT", + "dependencies": { + "bootstrap": "^5.3.2", + "classnames": "^2.3.2", + "clipboard": "^2.0.11", + "jquery": "3", + "moment": "^2.29.4", + "nanoid": "^5.0.4", + "randomcolor": "^0.6.2", + "react": "^18.2.0", + "react-dom": "^18.2.0", + "react-feather": "^2.0.10", + "react-linkify": "^1.0.0-alpha", + "react-modal": "^3.16.1", + "react-redux": "^8.0.5", + "react-router": "^6.4.4", + "react-router-dom": "^6.4.4", + "react-simple-dropdown": "^3.2.3", + "redux": "^4.2.0", + "redux-thunk": "^2.4.2", + "sanitize-html": "^2.7.3", + "socket.io-client": "^4.5.4", + "tinycon": "^0.6.8" + }, + "scripts": { + "dev": "vite", + "build": "tsc && vite build", + "preview": "vite preview", + "test": "TZ=UTC vitest", + "lint": "eslint src", + "coverage": "TZ=UTC vitest --coverage --watch=false" + }, + "devDependencies": { + "@testing-library/jest-dom": "^6.1.6", + "@testing-library/react": "^14.1.2", + "@testing-library/user-event": "^14.4.3", + "@typescript-eslint/eslint-plugin": "^6.16.0", + "@typescript-eslint/parser": "^6.16.0", + "@vitejs/plugin-react": "^4.2.1", + "@vitest/coverage-istanbul": "^1.1.0", + "eslint": "^8.29.0", + "eslint-config-prettier": "^9.1.0", + "eslint-plugin-prettier": "^5.1.2", + "jest-environment-jsdom-sixteen": "^2.0.0", + "jest-fetch-mock": "^3.0.3", + "prettier": "^3.1.1", + "sass": "^1.69.6", + "typescript": "^5.3.3", + "vitest": "^1.1.0", + "vitest-fetch-mock": "^0.2.1" + }, + "browserslist": { + "production": [ + ">0.2%", + "not dead", + "not op_mini all" + ], + "development": [ + "last 1 chrome version", + "last 1 firefox version", + "last 1 safari version" + ] + } +} diff --git a/client/public/favicon.ico b/client/public/favicon.ico new file mode 100644 index 0000000..359faae Binary files /dev/null and b/client/public/favicon.ico differ diff --git a/client/public/manifest.json b/client/public/manifest.json new file mode 100644 index 0000000..2553b79 --- /dev/null +++ b/client/public/manifest.json @@ -0,0 +1,15 @@ +{ + "short_name": "Darkwire", + "name": "Darkwire.io - encrypted web chat", + "icons": [ + { + "src": "favicon.ico", + "sizes": "64x64 32x32 24x24 16x16", + "type": "image/x-icon" + } + ], + "start_url": ".", + "display": "standalone", + "theme_color": "#000000", + "background_color": "#ffffff" +} diff --git a/client/public/robots.txt b/client/public/robots.txt new file mode 100644 index 0000000..14267e9 --- /dev/null +++ b/client/public/robots.txt @@ -0,0 +1,2 @@ +User-agent: * +Allow: / \ No newline at end of file diff --git a/client/src/actions/app.js b/client/src/actions/app.js new file mode 100644 index 0000000..3aac089 --- /dev/null +++ b/client/src/actions/app.js @@ -0,0 +1,44 @@ +export const openModal = payload => ({ type: 'OPEN_MODAL', payload }); +export const closeModal = () => ({ type: 'CLOSE_MODAL' }); + +export const setScrolledToBottom = payload => ({ type: 'SET_SCROLLED_TO_BOTTOM', payload }); + +export const showNotice = payload => async dispatch => { + dispatch({ type: 'SHOW_NOTICE', payload }); +}; + +export const toggleWindowFocus = payload => async dispatch => { + dispatch({ type: 'TOGGLE_WINDOW_FOCUS', payload }); +}; + +export const toggleSoundEnabled = payload => async dispatch => { + dispatch({ type: 'TOGGLE_SOUND_ENABLED', payload }); +}; + +export const togglePersistenceEnabled = payload => async dispatch => { + dispatch({ type: 'TOGGLE_PERSISTENCE_ENABLED', payload }); +}; + +export const toggleNotificationEnabled = payload => async dispatch => { + dispatch({ type: 'TOGGLE_NOTIFICATION_ENABLED', payload }); +}; + +export const toggleNotificationAllowed = payload => async dispatch => { + dispatch({ type: 'TOGGLE_NOTIFICATION_ALLOWED', payload }); +}; + +export const toggleSocketConnected = payload => async dispatch => { + dispatch({ type: 'TOGGLE_SOCKET_CONNECTED', payload }); +}; + +export const createUser = payload => async dispatch => { + dispatch({ type: 'CREATE_USER', payload }); +}; + +export const clearActivities = () => async dispatch => { + dispatch({ type: 'CLEAR_ACTIVITIES' }); +}; + +export const setLanguage = payload => async dispatch => { + dispatch({ type: 'CHANGE_LANGUAGE', payload }); +}; diff --git a/client/src/actions/app.test.js b/client/src/actions/app.test.js new file mode 100644 index 0000000..9ba2a35 --- /dev/null +++ b/client/src/actions/app.test.js @@ -0,0 +1,55 @@ +import * as actions from './app'; + +import { describe, it, expect, vi } from 'vitest'; + +describe('App actions', () => { + it('should create an action to scroll to bottom', () => { + expect(actions.setScrolledToBottom('test')).toEqual({ + type: 'SET_SCROLLED_TO_BOTTOM', + payload: 'test', + }); + }); + + it('should create an action to close modal', () => { + expect(actions.closeModal()).toEqual({ + type: 'CLOSE_MODAL', + }); + }); + + it('should create an action to open modal', () => { + expect(actions.openModal('test')).toEqual({ + type: 'OPEN_MODAL', + payload: 'test', + }); + }); + + it('should create an action to clear activities', () => { + const mockDispatch = vi.fn(); + + actions.clearActivities()(mockDispatch); + + expect(mockDispatch).toHaveBeenLastCalledWith({ + type: 'CLEAR_ACTIVITIES', + }); + }); + it('should create all actions', () => { + const mockDispatch = vi.fn(); + + const actionsResults = [ + [actions.toggleWindowFocus('test'), 'TOGGLE_WINDOW_FOCUS'], + [actions.showNotice('test'), 'SHOW_NOTICE'], + [actions.toggleSoundEnabled('test'), 'TOGGLE_SOUND_ENABLED'], + [actions.toggleSocketConnected('test'), 'TOGGLE_SOCKET_CONNECTED'], + [actions.createUser('test'), 'CREATE_USER'], + [actions.setLanguage('test'), 'CHANGE_LANGUAGE'], + ]; + + actionsResults.forEach(([action, type]) => { + action(mockDispatch); + expect(mockDispatch).toHaveBeenLastCalledWith({ + type, + payload: 'test', + }); + }); + }); +}); diff --git a/client/src/actions/encrypted_messages.js b/client/src/actions/encrypted_messages.js new file mode 100644 index 0000000..9500042 --- /dev/null +++ b/client/src/actions/encrypted_messages.js @@ -0,0 +1,16 @@ +import { getSocket } from '@/utils/socket'; +import { prepare as prepareMessage, process as processMessage } from '@/utils/message'; + +export const sendEncryptedMessage = payload => async (dispatch, getState) => { + const state = getState(); + const msg = await prepareMessage(payload, state); + dispatch({ type: `SEND_ENCRYPTED_MESSAGE_${msg.original.type}`, payload: msg.original.payload }); + getSocket().emit('ENCRYPTED_MESSAGE', msg.toSend); +}; + +export const receiveEncryptedMessage = payload => async (dispatch, getState) => { + const state = getState(); + const message = await processMessage(payload, state); + // Pass current state to all RECEIVE_ENCRYPTED_MESSAGE reducers for convenience, since each may have different needs + dispatch({ type: `RECEIVE_ENCRYPTED_MESSAGE_${message.type}`, payload: { payload: message.payload, state } }); +}; diff --git a/client/src/actions/encrypted_messages.test.js b/client/src/actions/encrypted_messages.test.js new file mode 100644 index 0000000..10fc3fe --- /dev/null +++ b/client/src/actions/encrypted_messages.test.js @@ -0,0 +1,51 @@ +import * as actions from './encrypted_messages'; +import { getSocket } from '@/utils/socket'; +import { prepare as prepareMessage, process as processMessage } from '@/utils/message'; + +import { describe, it, expect, vi } from 'vitest'; + +vi.mock('@/utils/message', () => { + return { + prepare: vi + .fn() + .mockResolvedValue({ original: { type: 'messageType', payload: 'test' }, toSend: 'encryptedpayload' }), + process: vi.fn().mockResolvedValue({ type: 'messageType', payload: 'test' }), + }; +}); + +const mockEmit = vi.fn(); + +vi.mock('@/utils/socket', () => { + return { + getSocket: vi.fn().mockImplementation(() => ({ + emit: mockEmit, + })), + }; +}); + +describe('Encrypted messages actions', () => { + it('should create an action to send message', async () => { + const mockDispatch = vi.fn(); + + await actions.sendEncryptedMessage({ payload: 'payload' })(mockDispatch, vi.fn().mockReturnValue({ state: {} })); + + expect(prepareMessage).toHaveBeenLastCalledWith({ payload: 'payload' }, { state: {} }); + expect(mockDispatch).toHaveBeenLastCalledWith({ payload: 'test', type: 'SEND_ENCRYPTED_MESSAGE_messageType' }); + expect(getSocket().emit).toHaveBeenLastCalledWith('ENCRYPTED_MESSAGE', 'encryptedpayload'); + }); + + it('should create an action to receive message', async () => { + const mockDispatch = vi.fn(); + + await actions.receiveEncryptedMessage({ payload: 'encrypted' })( + mockDispatch, + vi.fn().mockReturnValue({ state: {} }), + ); + + expect(processMessage).toHaveBeenLastCalledWith({ payload: 'encrypted' }, { state: {} }); + expect(mockDispatch).toHaveBeenLastCalledWith({ + payload: { payload: 'test', state: { state: {} } }, + type: 'RECEIVE_ENCRYPTED_MESSAGE_messageType', + }); + }); +}); diff --git a/client/src/actions/index.js b/client/src/actions/index.js new file mode 100644 index 0000000..0a6acfa --- /dev/null +++ b/client/src/actions/index.js @@ -0,0 +1,5 @@ +/* istanbul ignore file */ + +export * from './app'; +export * from './unencrypted_messages'; +export * from './encrypted_messages'; diff --git a/client/src/actions/unencrypted_messages.js b/client/src/actions/unencrypted_messages.js new file mode 100644 index 0000000..d87cc02 --- /dev/null +++ b/client/src/actions/unencrypted_messages.js @@ -0,0 +1,80 @@ +import { getSocket } from '@/utils/socket'; + +const receiveUserEnter = (payload, dispatch) => { + dispatch({ type: 'USER_ENTER', payload }); +}; + +const receiveToggleLockRoom = (payload, dispatch, getState) => { + const state = getState(); + + const lockedByUser = state.room.members.find(m => m.publicKey.n === payload.publicKey.n); + const lockedByUsername = lockedByUser.username; + const lockedByUserId = lockedByUser.id; + + dispatch({ + type: 'RECEIVE_TOGGLE_LOCK_ROOM', + payload: { + username: lockedByUsername, + locked: payload.locked, + id: lockedByUserId, + }, + }); +}; + +const receiveUserExit = (payload, dispatch, getState) => { + const state = getState(); + const payloadPublicKeys = payload.map(member => member.publicKey.n); + const exitingUser = state.room.members.find(m => !payloadPublicKeys.includes(m.publicKey.n)); + + if (!exitingUser) { + return; + } + + const exitingUserId = exitingUser.id; + const exitingUsername = exitingUser.username; + + dispatch({ + type: 'USER_EXIT', + payload: { + members: payload, + id: exitingUserId, + username: exitingUsername, + }, + }); +}; + +export const receiveUnencryptedMessage = (type, payload) => async (dispatch, getState) => { + switch (type) { + case 'USER_ENTER': + return receiveUserEnter(payload, dispatch); + case 'USER_EXIT': + return receiveUserExit(payload, dispatch, getState); + case 'TOGGLE_LOCK_ROOM': + return receiveToggleLockRoom(payload, dispatch, getState); + default: + return; + } +}; + +const sendToggleLockRoom = (dispatch, getState) => { + const state = getState(); + getSocket().emit('TOGGLE_LOCK_ROOM', null, res => { + dispatch({ + type: 'TOGGLE_LOCK_ROOM', + payload: { + locked: res.isLocked, + username: state.user.username, + sender: state.user.id, + }, + }); + }); +}; + +export const sendUnencryptedMessage = type => async (dispatch, getState) => { + switch (type) { + case 'TOGGLE_LOCK_ROOM': + return sendToggleLockRoom(dispatch, getState); + default: + return; + } +}; diff --git a/client/src/actions/unencrypted_messages.test.js b/client/src/actions/unencrypted_messages.test.js new file mode 100644 index 0000000..f28c150 --- /dev/null +++ b/client/src/actions/unencrypted_messages.test.js @@ -0,0 +1,126 @@ +import * as actions from './unencrypted_messages'; + +import { describe, it, expect, vi } from 'vitest'; + +const mockEmit = vi.fn((_type, _null, callback) => { + callback({ isLocked: true }); +}); + +vi.mock('@/utils/socket', () => { + return { + getSocket: vi.fn().mockImplementation(() => ({ + emit: mockEmit, + })), + }; +}); + +describe('Receive unencrypted message actions', () => { + it('should create no action', () => { + const mockDispatch = vi.fn(); + actions.receiveUnencryptedMessage('FAKE')(mockDispatch, vi.fn().mockReturnValue({})); + expect(mockDispatch).not.toHaveBeenCalled(); + }); + + it('should create user enter action', () => { + const mockDispatch = vi.fn(); + actions.receiveUnencryptedMessage('USER_ENTER', 'test')(mockDispatch, vi.fn().mockReturnValue({ state: {} })); + expect(mockDispatch).toHaveBeenLastCalledWith({ type: 'USER_ENTER', payload: 'test' }); + }); + + it('should create user exit action', () => { + const mockDispatch = vi.fn(); + const state = { + room: { + members: [ + { publicKey: { n: 'alankey' }, id: 'alankey', username: 'alan' }, + { publicKey: { n: 'dankey' }, id: 'dankey', username: 'dan' }, + { publicKey: { n: 'alicekey' }, id: 'alicekey', username: 'dan' }, + ], + }, + }; + const mockGetState = vi.fn().mockReturnValue(state); + const payload1 = [ + { publicKey: { n: 'alankey' } }, + { publicKey: { n: 'dankey' } }, + { publicKey: { n: 'alicekey' } }, + ]; + const payload2 = [{ publicKey: { n: 'dankey' } }, { publicKey: { n: 'alicekey' } }]; + + // Nobody left + actions.receiveUnencryptedMessage('USER_EXIT', payload1)(mockDispatch, mockGetState); + + expect(mockDispatch).not.toHaveBeenCalled(); + + actions.receiveUnencryptedMessage('USER_EXIT', payload2)(mockDispatch, mockGetState); + expect(mockDispatch).toHaveBeenLastCalledWith({ + payload: { + id: 'alankey', + members: [{ publicKey: { n: 'dankey' } }, { publicKey: { n: 'alicekey' } }], + username: 'alan', + }, + type: 'USER_EXIT', + }); + }); + + it('should create receive toggle lock room action', () => { + const mockDispatch = vi.fn(); + const state = { + room: { + members: [ + { publicKey: { n: 'alankey' }, id: 'idalan', username: 'alan' }, + { publicKey: { n: 'dankey' }, id: 'iddan', username: 'dan' }, + ], + }, + }; + const mockGetState = vi.fn().mockReturnValue(state); + const payload = { publicKey: { n: 'alankey' } }; + + actions.receiveUnencryptedMessage('TOGGLE_LOCK_ROOM', payload)(mockDispatch, mockGetState); + expect(mockDispatch).toHaveBeenLastCalledWith({ + payload: { id: 'idalan', locked: undefined, username: 'alan' }, + type: 'RECEIVE_TOGGLE_LOCK_ROOM', + }); + }); + + it('should create receive toggle lock room action', () => { + const mockDispatch = vi.fn(); + const state = { + user: { + username: 'alan', + id: 'idalan', + }, + }; + const mockGetState = vi.fn().mockReturnValue(state); + + actions.sendUnencryptedMessage('TOGGLE_LOCK_ROOM')(mockDispatch, mockGetState); + expect(mockDispatch).toHaveBeenLastCalledWith({ + payload: { locked: true, sender: 'idalan', username: 'alan' }, + type: 'TOGGLE_LOCK_ROOM', + }); + }); +}); + +describe('Send unencrypted message actions', () => { + it('should create no action', () => { + const mockDispatch = vi.fn(); + actions.sendUnencryptedMessage('FAKE')(mockDispatch, vi.fn().mockReturnValue({})); + expect(mockDispatch).not.toHaveBeenCalled(); + }); + + it('should create toggle lock room action', () => { + const mockDispatch = vi.fn(); + const state = { + user: { + username: 'alan', + id: 'idalan', + }, + }; + const mockGetState = vi.fn().mockReturnValue(state); + + actions.sendUnencryptedMessage('TOGGLE_LOCK_ROOM')(mockDispatch, mockGetState); + expect(mockDispatch).toHaveBeenLastCalledWith({ + payload: { locked: true, sender: 'idalan', username: 'alan' }, + type: 'TOGGLE_LOCK_ROOM', + }); + }); +}); diff --git a/client/src/api/config.js b/client/src/api/config.js new file mode 100644 index 0000000..dbb5bb6 --- /dev/null +++ b/client/src/api/config.js @@ -0,0 +1,27 @@ +/* istanbul ignore file */ +let host; +let protocol; +let port; + +switch (import.meta.env.MODE) { + case 'staging': + host = import.meta.env.VITE_API_HOST; + protocol = import.meta.env.VITE_API_PROTOCOL || 'https'; + port = import.meta.env.VITE_API_PORT || 443; + break; + case 'production': + host = import.meta.env.VITE_API_HOST; + protocol = import.meta.env.VITE_API_PROTOCOL || 'https'; + port = import.meta.env.VITE_API_PORT || 443; + break; + default: + host = import.meta.env.VITE_API_HOST || 'localhost'; + protocol = import.meta.env.VITE_API_PROTOCOL || 'http'; + port = import.meta.env.VITE_API_PORT || 3001; +} + +export default { + host, + port, + protocol, +}; diff --git a/client/src/api/generator.js b/client/src/api/generator.js new file mode 100644 index 0000000..4033902 --- /dev/null +++ b/client/src/api/generator.js @@ -0,0 +1,14 @@ +/* istanbul ignore file */ +import config from './config'; + +export default (resourceName = '') => { + const { port, protocol, host } = config; + + const resourcePath = resourceName; + + if (!host) { + return `/${resourcePath}`; + } + + return `${protocol}://${host}:${port}/${resourcePath}`; +}; diff --git a/client/src/audio/beep.mp3 b/client/src/audio/beep.mp3 new file mode 100644 index 0000000..738c24f Binary files /dev/null and b/client/src/audio/beep.mp3 differ diff --git a/client/src/components/About/About.test.jsx b/client/src/components/About/About.test.jsx new file mode 100644 index 0000000..21ad331 --- /dev/null +++ b/client/src/components/About/About.test.jsx @@ -0,0 +1,54 @@ +import React from 'react'; +import { render, fireEvent } from '@testing-library/react'; +import About from '.'; +import { describe, it, expect, vi, afterEach } from 'vitest'; + +vi.useFakeTimers(); + +// Mock Api generator + +vi.mock('@/api/generator', () => { + return { + default: path => { + return `http://fakedomain/${path}`; + }, + }; +}); + +describe('About component', () => { + afterEach(() => { + fetchMock.resetMocks(); + }); + + it('should display', async () => { + const { asFragment } = render(); + + expect(asFragment()).toMatchSnapshot(); + }); + + it('should report abuse', async () => { + const { getByText, queryByText } = render(); + + expect(queryByText('Thank you!')).not.toBeInTheDocument(); + + fireEvent.click(getByText('Submit')); + + expect(fetchMock).toHaveBeenCalledWith('http://fakedomain/abuse/test', { method: 'POST' }); + + expect(getByText('Thank you!')).toBeInTheDocument(); + }); + + it('should change room id', async () => { + const { getByPlaceholderText, getByText, queryByText } = render(); + + expect(queryByText('Thank you!')).not.toBeInTheDocument(); + + fireEvent.change(getByPlaceholderText('Room ID'), { target: { value: 'newRoomName' } }); + + vi.runAllTimers(); + + fireEvent.click(getByText('Submit')); + + expect(fetchMock).toHaveBeenLastCalledWith('http://fakedomain/abuse/newRoomName', { method: 'POST' }); + }); +}); diff --git a/client/src/components/About/__snapshots__/About.test.jsx.snap b/client/src/components/About/__snapshots__/About.test.jsx.snap new file mode 100644 index 0000000..eae0680 --- /dev/null +++ b/client/src/components/About/__snapshots__/About.test.jsx.snap @@ -0,0 +1,513 @@ +// Vitest Snapshot v1 + +exports[`About component > should display 1`] = ` + +
+ +
+

+ Version +

+

+ Commit SHA: + + some_sha + +

+
+
+

+ Software +

+

+ This software uses the + + Web Cryptography API + + to encrypt data which is transferred using + + secure WebSockets + + . Messages are never stored on a server or sent over the wire in plain-text. +

+

+ We believe in privacy and transparency.   + + View the source code and documentation on GitHub. + +

+
+
+

+ Report Abuse +

+

+ We encourage you to report problematic content to us. Please keep in mind that to help ensure the safety, confidentiality and security of your messages, we do not have the contents of messages available to us, which limits our ability to verify the report and take action. +

+

+ When needed, you can take a screenshot of the content and share it, along with any available contact info, with appropriate law enforcement authorities. +

+

+ To report any content, email us at abuse[at]darkwire.io or submit the room ID below to report anonymously. +

+
+
+
+ +
+ +
+
+
+
+
+

+ If you feel you or anyone else is in immediate danger, please contact your local emergency services. +

+

+ If you receive content from someone who wishes to hurt themselves, and you're concerned for their safety, please contact your local emergency services or a + + suicide prevention hotline + + . +

+

+ If you receive or encounter content indicating abuse or exploitation of a child, please contact the + + National Center for Missing and Exploited Children (NCMEC) + + . +

+
+
+

+ Acceptable Use Policy +

+

+ This Acceptable Use Policy (this “Policy”) describes prohibited uses of the web services offered by Darkwire and its affiliates (the “Services”) and the website located at https://darkwire.io (the “Darkwire Site”). The examples described in this Policy are not exhaustive. We may modify this Policy at any time by posting a revised version on the Darkwire Site. By using the Services or accessing the Darkwire Site, you agree to the latest version of this Policy. If you violate the Policy or authorize or help others to do so, we may suspend or terminate your use of the Services. +

+ + No Illegal, Harmful, or Offensive Use or Content + +

+ You may not use, or encourage, promote, facilitate or instruct others to use, the Services or Darkwire Site for any illegal, harmful, fraudulent, infringing or offensive use, or to transmit, store, display, distribute or otherwise make available content that is illegal, harmful, fraudulent, infringing or offensive. Prohibited activities or content include: +

+
    +
  • + + Illegal, Harmful or Fraudulent Activities. + + Any activities that are illegal, that violate the rights of others, or that may be harmful to others, our operations or reputation, including disseminating, promoting or facilitating child pornography, offering or disseminating fraudulent goods, services, schemes, or promotions, make-money-fast schemes, ponzi and pyramid schemes, phishing, or pharming. +
  • +
  • + + Infringing Content. + + Content that infringes or misappropriates the intellectual property or proprietary rights of others. +
  • +
  • + + Offensive Content. + + Content that is defamatory, obscene, abusive, invasive of privacy, or otherwise objectionable, including content that constitutes child pornography, relates to bestiality, or depicts non-consensual sex acts. +
  • +
  • + + Harmful Content. + + Content or other computer technology that may damage, interfere with, surreptitiously intercept, or expropriate any system, program, or data, including viruses, Trojan horses, worms, time bombs, or cancelbots. +
  • +
+ + No Security Violations + +
+ You may not use the Services to violate the security or integrity of any network, computer or communications system, software application, or network or computing device (each, a “System”). Prohibited activities include: +
    +
  • + + Unauthorized Access. + + Accessing or using any System without permission, including attempting to probe, scan, or test the vulnerability of a System or to breach any security or authentication measures used by a System. +
  • +
  • + + Interception. + + Monitoring of data or traffic on a System without permission. +
  • +
  • + + Falsification of Origin. + + Forging TCP-IP packet headers, e-mail headers, or any part of a message describing its origin or route. The legitimate use of aliases and anonymous remailers is not prohibited by this provision. +
  • +
+ + No Network Abuse + +
+ You may not make network connections to any users, hosts, or networks unless you have permission to communicate with them. Prohibited activities include: +
    +
  • + + Monitoring or Crawling. + + Monitoring or crawling of a System that impairs or disrupts the System being monitored or crawled. +
  • +
  • + + Denial of Service (DoS). + + Inundating a target with communications requests so the target either cannot respond to legitimate traffic or responds so slowly that it becomes ineffective. +
  • +
  • + + Intentional Interference. + + Interfering with the proper functioning of any System, including any deliberate attempt to overload a system by mail bombing, news bombing, broadcast attacks, or flooding techniques. +
  • +
  • + + Operation of Certain Network Services. + + Operating network services like open proxies, open mail relays, or open recursive domain name servers. +
  • +
  • + + Avoiding System Restrictions. + + Using manual or electronic means to avoid any use limitations placed on a System, such as access and storage restrictions. +
  • +
+ + No E-Mail or Other Message Abuse + +
+ You will not distribute, publish, send, or facilitate the sending of unsolicited mass e-mail or other messages, promotions, advertising, or solicitations (like “spam”), including commercial advertising and informational announcements. You will not alter or obscure mail headers or assume a sender’s identity without the sender’s explicit permission. You will not collect replies to messages sent from another internet service provider if those messages violate this Policy or the acceptable use policy of that provider. + + Our Monitoring and Enforcement + +
+ We reserve the right, but do not assume the obligation, to investigate any violation of this Policy or misuse of the Services or Darkwire Site. We may: +
    +
  • + investigate violations of this Policy or misuse of the Services or Darkwire Site; or +
  • +
  • + remove, disable access to, or modify any content or resource that violates this Policy or any other agreement we have with you for use of the Services or the Darkwire Site. +
  • +
  • + We may report any activity that we suspect violates any law or regulation to appropriate law enforcement officials, regulators, or other appropriate third parties. Our reporting may include disclosing appropriate customer information. We also may cooperate with appropriate law enforcement agencies, regulators, or other appropriate third parties to help with the investigation and prosecution of illegal conduct by providing network and systems information related to alleged violations of this Policy. +
  • +
+ Reporting of Violations of this Policy +
+ If you become aware of any violation of this Policy, you will immediately notify us and provide us with assistance, as requested, to stop or remedy the violation. To report any violation of this Policy, please follow our abuse reporting process. +
+
+

+ Terms of Service ("Terms") +

+

+ Last updated: December 11, 2017 +

+

+ Please read these Terms of Service ("Terms", "Terms of Service") carefully before using the https://darkwire.io website (the "Service") operated by Darkwire ("us", "we", or "our"). +

+

+ Your access to and use of the Service is conditioned on your acceptance of and compliance with these Terms. These Terms apply to all visitors, users and others who access or use the Service. +

+

+ By accessing or using the Service you agree to be bound by these Terms. If you disagree with any part of the terms then you may not access the Service. +

+ + Links To Other Web Sites + +

+ Our Service may contain links to third-party web sites or services that are not owned or controlled by Darkwire. +

+

+ Darkwire has no control over, and assumes no responsibility for, the content, privacy policies, or practices of any third party web sites or services. You further acknowledge and agree that Darkwire shall not be responsible or liable, directly or indirectly, for any damage or loss caused or alleged to be caused by or in connection with use of or reliance on any such content, goods or services available on or through any such web sites or services. +

+

+ We strongly advise you to read the terms and conditions and privacy policies of any third-party web sites or services that you visit. +

+ + Termination + +

+ We may terminate or suspend access to our Service immediately, without prior notice or liability, for any reason whatsoever, including without limitation if you breach the Terms. +

+

+ All provisions of the Terms which by their nature should survive termination shall survive termination, including, without limitation, ownership provisions, warranty disclaimers, indemnity and limitations of liability. +

+ + Governing Law + +

+ These Terms shall be governed and construed in accordance with the laws of New York, United States, without regard to its conflict of law provisions. +

+

+ Our failure to enforce any right or provision of these Terms will not be considered a waiver of those rights. If any provision of these Terms is held to be invalid or unenforceable by a court, the remaining provisions of these Terms will remain in effect. These Terms constitute the entire agreement between us regarding our Service, and supersede and replace any prior agreements we might have between us regarding the Service. +

+
+
+

+ Disclaimer +

+

+ WARNING: Darkwire does not mask IP addresses nor can verify the integrity of parties recieving messages.  Proceed with caution and always confirm recipients beforre starting a chat session. +

+

+ Please also note that + + ALL CHATROOMS + + are public.  Anyone can guess your room URL. If you need a more-private room, use the lock feature or set the URL manually by entering a room ID after "darkwire.io/". +

+
+ + No Warranties; Exclusion of Liability; Indemnification + +

+ + OUR WEBSITE IS OPERATED BY Darkwire ON AN "AS IS," "AS AVAILABLE" BASIS, WITHOUT REPRESENTATIONS OR WARRANTIES OF ANY KIND. TO THE FULLEST EXTENT PERMITTED BY LAW, Darkwire SPECIFICALLY DISCLAIMS ALL WARRANTIES AND CONDITIONS OF ANY KIND, INCLUDING ALL IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NONINFRINGEMENT FOR OUR WEBSITE AND ANY CONTRACTS AND SERVICES YOU PURCHASE THROUGH IT. Darkwire SHALL NOT HAVE ANY LIABILITY OR RESPONSIBILITY FOR ANY ERRORS OR OMISSIONS IN THE CONTENT OF OUR WEBSITE, FOR CONTRACTS OR SERVICES SOLD THROUGH OUR WEBSITE, FOR YOUR ACTION OR INACTION IN CONNECTION WITH OUR WEBSITE OR FOR ANY DAMAGE TO YOUR COMPUTER OR DATA OR ANY OTHER DAMAGE YOU MAY INCUR IN CONNECTION WITH OUR WEBSITE. YOUR USE OF OUR WEBSITE AND ANY CONTRACTS OR SERVICES ARE AT YOUR OWN RISK. IN NO EVENT SHALL EITHER Darkwire OR THEIR AGENTS BE LIABLE FOR ANY DIRECT, INDIRECT, PUNITIVE, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR IN ANY WAY CONNECTED WITH THE USE OF OUR WEBSITE, CONTRACTS AND SERVICES PURCHASED THROUGH OUR WEBSITE, THE DELAY OR INABILITY TO USE OUR WEBSITE OR OTHERWISE ARISING IN CONNECTION WITH OUR WEBSITE, CONTRACTS OR RELATED SERVICES, WHETHER BASED ON CONTRACT, TORT, STRICT LIABILITY OR OTHERWISE, EVEN IF ADVISED OF THE POSSIBILITY OF ANY SUCH DAMAGES. IN NO EVENT SHALL Darkwire’s LIABILITY FOR ANY DAMAGE CLAIM EXCEED THE AMOUNT PAID BY YOU TO Darkwire FOR THE TRANSACTION GIVING RISE TO SUCH DAMAGE CLAIM. + +

+

+ + SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THE ABOVE EXCLUSION MAY NOT APPLY TO YOU. + +

+

+ + WITHOUT LIMITING THE FOREGOING, Darkwire DO NOT REPRESENT OR WARRANT THAT THE INFORMATION ON THE WEBITE IS ACCURATE, COMPLETE, RELIABLE, USEFUL, TIMELY OR CURRENT OR THAT OUR WEBSITE WILL OPERATE WITHOUT INTERRUPTION OR ERROR. + +

+

+ + YOU AGREE THAT ALL TIMES, YOU WILL LOOK TO ATTORNEYS FROM WHOM YOU PURCHASE SERVICES FOR ANY CLAIMS OF ANY NATURE, INCLUDING LOSS, DAMAGE, OR WARRANTY. Darkwire AND THEIR RESPECTIVE AFFILIATES MAKE NO REPRESENTATION OR GUARANTEES ABOUT ANY CONTRACTS AND SERVICES OFFERED THROUGH OUR WEBSITE. + +

+

+ + Darkwire MAKES NO REPRESENTATION THAT CONTENT PROVIDED ON OUR WEBSITE, CONTRACTS, OR RELATED SERVICES ARE APPLICABLE OR APPROPRIATE FOR USE IN ALL JURISDICTIONS. + +

+ + Indemnification + +

+ You agree to defend, indemnify and hold Darkwire harmless from and against any and all claims, damages, costs and expenses, including attorneys' fees, arising from or related to your use of our Website or any Contracts or Services you purchase through it. +

+ + Changes + +

+ We reserve the right, at our sole discretion, to modify or replace these Terms at any time. If a revision is material we will try to provide at least 30 days notice prior to any new terms taking effect. What constitutes a material change will be determined at our sole discretion. +

+

+ By continuing to access or use our Service after those revisions become effective, you agree to be bound by the revised terms. If you do not agree to the new terms, please stop using the Service. +

+ + Contact Us + +

+ If you have any questions about these Terms, please contact us at hello[at]darkwire.io. +

+
+
+

+ Contact +

+

+ Questions/comments? Email us at hello[at]darkwire.io +

+

+ Found a bug or want a new feature? + + Open a ticket on Github + + . +

+
+ +
+
+`; diff --git a/client/src/components/About/index.jsx b/client/src/components/About/index.jsx new file mode 100644 index 0000000..823ed74 --- /dev/null +++ b/client/src/components/About/index.jsx @@ -0,0 +1,451 @@ +/* eslint-disable */ +import React, { Component } from 'react'; +import PropTypes from 'prop-types'; + +import { COMMIT_SHA } from '@/config/env'; +import apiUrlGenerator from '@/api/generator'; +import styles from './styles.module.scss'; + +class About extends Component { + constructor(props) { + super(props); + this.state = { + roomId: props.roomId, + abuseReported: false, + }; + } + + handleUpdateRoomId(evt) { + this.setState({ + roomId: evt.target.value, + }); + } + + handleReportAbuse(evt) { + evt.preventDefault(); + fetch(`${apiUrlGenerator('abuse')}/${this.state.roomId}`, { + method: 'POST', + }); + this.setState({ + abuseReported: true, + }); + } + + render() { + return ( +
+
+
+ Version +
+
+ Software +
+ + + + +
+ Contact +
+
+ Donate +
+
+ +
+

Version

+

+ Commit SHA:{' '} + + {COMMIT_SHA} + +

+
+ +
+

Software

+

+ This software uses the{' '} + + Web Cryptography API + {' '} + to encrypt data which is transferred using{' '} + + secure WebSockets + + . Messages are never stored on a server or sent over the wire in plain-text. +

+

+ We believe in privacy and transparency.   + + View the source code and documentation on GitHub. + +

+
+ +
+

Report Abuse

+

+ We encourage you to report problematic content to us. Please keep in mind that to help ensure the safety, + confidentiality and security of your messages, we do not have the contents of messages available to us, + which limits our ability to verify the report and take action. +

+

+ When needed, you can take a screenshot of the content and share it, along with any available contact info, + with appropriate law enforcement authorities. +

+

+ To report any content, email us at abuse[at]darkwire.io or submit the room ID below to report anonymously. +

+
+ {this.state.abuseReported &&
Thank you!
} +
+
+ +
+ +
+
+
+
+
+

If you feel you or anyone else is in immediate danger, please contact your local emergency services.

+

+ If you receive content from someone who wishes to hurt themselves, and you're concerned for their safety, + please contact your local emergency services or a{' '} + suicide prevention hotline. +

+

+ If you receive or encounter content indicating abuse or exploitation of a child, please contact the{' '} + National Center for Missing and Exploited Children (NCMEC). +

+
+ +
+

Acceptable Use Policy

+

+ This Acceptable Use Policy (this “Policy”) describes prohibited uses of the web services offered by Darkwire + and its affiliates (the “Services”) and the website located at https://darkwire.io (the “Darkwire Site”). + The examples described in this Policy are not exhaustive. We may modify this Policy at any time by posting a + revised version on the Darkwire Site. By using the Services or accessing the Darkwire Site, you agree to the + latest version of this Policy. If you violate the Policy or authorize or help others to do so, we may + suspend or terminate your use of the Services. +

+ No Illegal, Harmful, or Offensive Use or Content +

+ You may not use, or encourage, promote, facilitate or instruct others to use, the Services or Darkwire Site + for any illegal, harmful, fraudulent, infringing or offensive use, or to transmit, store, display, + distribute or otherwise make available content that is illegal, harmful, fraudulent, infringing or + offensive. Prohibited activities or content include: +

+
    +
  • + Illegal, Harmful or Fraudulent Activities. Any activities that are illegal, that violate + the rights of others, or that may be harmful to others, our operations or reputation, including + disseminating, promoting or facilitating child pornography, offering or disseminating fraudulent goods, + services, schemes, or promotions, make-money-fast schemes, ponzi and pyramid schemes, phishing, or + pharming. +
  • + +
  • + Infringing Content. Content that infringes or misappropriates the intellectual property + or proprietary rights of others. +
  • + +
  • + Offensive Content. Content that is defamatory, obscene, abusive, invasive of privacy, or + otherwise objectionable, including content that constitutes child pornography, relates to bestiality, or + depicts non-consensual sex acts. +
  • + +
  • + Harmful Content. Content or other computer technology that may damage, interfere with, + surreptitiously intercept, or expropriate any system, program, or data, including viruses, Trojan horses, + worms, time bombs, or cancelbots. +
  • +
+ No Security Violations +
+ You may not use the Services to violate the security or integrity of any network, computer or communications + system, software application, or network or computing device (each, a “System”). Prohibited activities + include: +
    +
  • + Unauthorized Access. Accessing or using any System without permission, including + attempting to probe, scan, or test the vulnerability of a System or to breach any security or + authentication measures used by a System. +
  • + +
  • + Interception. Monitoring of data or traffic on a System without permission. +
  • + +
  • + Falsification of Origin. Forging TCP-IP packet headers, e-mail headers, or any part of a + message describing its origin or route. The legitimate use of aliases and anonymous remailers is not + prohibited by this provision. +
  • +
+ No Network Abuse +
+ You may not make network connections to any users, hosts, or networks unless you have permission to + communicate with them. Prohibited activities include: +
    +
  • + Monitoring or Crawling. Monitoring or crawling of a System that impairs or disrupts the + System being monitored or crawled. +
  • + +
  • + Denial of Service (DoS). Inundating a target with communications requests so the target + either cannot respond to legitimate traffic or responds so slowly that it becomes ineffective. +
  • + +
  • + Intentional Interference. Interfering with the proper functioning of any System, + including any deliberate attempt to overload a system by mail bombing, news bombing, broadcast attacks, or + flooding techniques. +
  • + +
  • + Operation of Certain Network Services. Operating network services like open proxies, open + mail relays, or open recursive domain name servers. +
  • + +
  • + Avoiding System Restrictions. Using manual or electronic means to avoid any use + limitations placed on a System, such as access and storage restrictions. +
  • +
+ No E-Mail or Other Message Abuse +
+ You will not distribute, publish, send, or facilitate the sending of unsolicited mass e-mail or other + messages, promotions, advertising, or solicitations (like “spam”), including commercial advertising and + informational announcements. You will not alter or obscure mail headers or assume a sender’s identity without + the sender’s explicit permission. You will not collect replies to messages sent from another internet service + provider if those messages violate this Policy or the acceptable use policy of that provider. + Our Monitoring and Enforcement +
+ We reserve the right, but do not assume the obligation, to investigate any violation of this Policy or misuse + of the Services or Darkwire Site. We may: +
    +
  • investigate violations of this Policy or misuse of the Services or Darkwire Site; or
  • +
  • + remove, disable access to, or modify any content or resource that violates this Policy or any other + agreement we have with you for use of the Services or the Darkwire Site. +
  • +
  • + We may report any activity that we suspect violates any law or regulation to appropriate law enforcement + officials, regulators, or other appropriate third parties. Our reporting may include disclosing + appropriate customer information. We also may cooperate with appropriate law enforcement agencies, + regulators, or other appropriate third parties to help with the investigation and prosecution of illegal + conduct by providing network and systems information related to alleged violations of this Policy. +
  • +
+ Reporting of Violations of this Policy +
+ If you become aware of any violation of this Policy, you will immediately notify us and provide us with + assistance, as requested, to stop or remedy the violation. To report any violation of this Policy, please + follow our abuse reporting process. +
+ +
+

Terms of Service ("Terms")

+

Last updated: December 11, 2017

+

+ Please read these Terms of Service ("Terms", "Terms of Service") carefully before using the + https://darkwire.io website (the "Service") operated by Darkwire ("us", "we", or "our"). +

+

+ Your access to and use of the Service is conditioned on your acceptance of and compliance with these Terms. + These Terms apply to all visitors, users and others who access or use the Service. +

+

+ By accessing or using the Service you agree to be bound by these Terms. If you disagree with any part of the + terms then you may not access the Service. +

+ Links To Other Web Sites +

+ Our Service may contain links to third-party web sites or services that are not owned or controlled by + Darkwire. +

+

+ Darkwire has no control over, and assumes no responsibility for, the content, privacy policies, or practices + of any third party web sites or services. You further acknowledge and agree that Darkwire shall not be + responsible or liable, directly or indirectly, for any damage or loss caused or alleged to be caused by or + in connection with use of or reliance on any such content, goods or services available on or through any + such web sites or services. +

+

+ We strongly advise you to read the terms and conditions and privacy policies of any third-party web sites or + services that you visit. +

+ Termination +

+ We may terminate or suspend access to our Service immediately, without prior notice or liability, for any + reason whatsoever, including without limitation if you breach the Terms. +

+

+ All provisions of the Terms which by their nature should survive termination shall survive termination, + including, without limitation, ownership provisions, warranty disclaimers, indemnity and limitations of + liability. +

+ Governing Law +

+ These Terms shall be governed and construed in accordance with the laws of New York, United States, without + regard to its conflict of law provisions. +

+

+ Our failure to enforce any right or provision of these Terms will not be considered a waiver of those + rights. If any provision of these Terms is held to be invalid or unenforceable by a court, the remaining + provisions of these Terms will remain in effect. These Terms constitute the entire agreement between us + regarding our Service, and supersede and replace any prior agreements we might have between us regarding the + Service. +

+
+ +
+

Disclaimer

+

+ WARNING: Darkwire does not mask IP addresses nor can verify the integrity of parties recieving messages. +  Proceed with caution and always confirm recipients beforre starting a chat session. +

+

+ Please also note that ALL CHATROOMS are public.  Anyone can guess your room URL. If + you need a more-private room, use the lock feature or set the URL manually by entering a room ID after + "darkwire.io/". +

+
+ No Warranties; Exclusion of Liability; Indemnification +

+ + OUR WEBSITE IS OPERATED BY Darkwire ON AN "AS IS," "AS AVAILABLE" BASIS, WITHOUT REPRESENTATIONS OR + WARRANTIES OF ANY KIND. TO THE FULLEST EXTENT PERMITTED BY LAW, Darkwire SPECIFICALLY DISCLAIMS ALL + WARRANTIES AND CONDITIONS OF ANY KIND, INCLUDING ALL IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NONINFRINGEMENT FOR OUR WEBSITE AND ANY CONTRACTS AND SERVICES + YOU PURCHASE THROUGH IT. Darkwire SHALL NOT HAVE ANY LIABILITY OR RESPONSIBILITY FOR ANY ERRORS OR + OMISSIONS IN THE CONTENT OF OUR WEBSITE, FOR CONTRACTS OR SERVICES SOLD THROUGH OUR WEBSITE, FOR YOUR + ACTION OR INACTION IN CONNECTION WITH OUR WEBSITE OR FOR ANY DAMAGE TO YOUR COMPUTER OR DATA OR ANY OTHER + DAMAGE YOU MAY INCUR IN CONNECTION WITH OUR WEBSITE. YOUR USE OF OUR WEBSITE AND ANY CONTRACTS OR SERVICES + ARE AT YOUR OWN RISK. IN NO EVENT SHALL EITHER Darkwire OR THEIR AGENTS BE LIABLE FOR ANY DIRECT, + INDIRECT, PUNITIVE, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR IN ANY WAY CONNECTED + WITH THE USE OF OUR WEBSITE, CONTRACTS AND SERVICES PURCHASED THROUGH OUR WEBSITE, THE DELAY OR INABILITY + TO USE OUR WEBSITE OR OTHERWISE ARISING IN CONNECTION WITH OUR WEBSITE, CONTRACTS OR RELATED SERVICES, + WHETHER BASED ON CONTRACT, TORT, STRICT LIABILITY OR OTHERWISE, EVEN IF ADVISED OF THE POSSIBILITY OF ANY + SUCH DAMAGES. IN NO EVENT SHALL Darkwire’s LIABILITY FOR ANY DAMAGE CLAIM EXCEED THE AMOUNT PAID BY YOU TO + Darkwire FOR THE TRANSACTION GIVING RISE TO SUCH DAMAGE CLAIM. + +

+

+ + SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THE + ABOVE EXCLUSION MAY NOT APPLY TO YOU. + +

+

+ + WITHOUT LIMITING THE FOREGOING, Darkwire DO NOT REPRESENT OR WARRANT THAT THE INFORMATION ON THE WEBITE IS + ACCURATE, COMPLETE, RELIABLE, USEFUL, TIMELY OR CURRENT OR THAT OUR WEBSITE WILL OPERATE WITHOUT + INTERRUPTION OR ERROR. + +

+

+ + YOU AGREE THAT ALL TIMES, YOU WILL LOOK TO ATTORNEYS FROM WHOM YOU PURCHASE SERVICES FOR ANY CLAIMS OF ANY + NATURE, INCLUDING LOSS, DAMAGE, OR WARRANTY. Darkwire AND THEIR RESPECTIVE AFFILIATES MAKE NO + REPRESENTATION OR GUARANTEES ABOUT ANY CONTRACTS AND SERVICES OFFERED THROUGH OUR WEBSITE. + +

+

+ + Darkwire MAKES NO REPRESENTATION THAT CONTENT PROVIDED ON OUR WEBSITE, CONTRACTS, OR RELATED SERVICES ARE + APPLICABLE OR APPROPRIATE FOR USE IN ALL JURISDICTIONS. + +

+ Indemnification +

+ You agree to defend, indemnify and hold Darkwire harmless from and against any and all claims, damages, + costs and expenses, including attorneys' fees, arising from or related to your use of our Website or any + Contracts or Services you purchase through it. +

+ Changes +

+ We reserve the right, at our sole discretion, to modify or replace these Terms at any time. If a revision is + material we will try to provide at least 30 days notice prior to any new terms taking effect. What + constitutes a material change will be determined at our sole discretion. +

+

+ By continuing to access or use our Service after those revisions become effective, you agree to be bound by + the revised terms. If you do not agree to the new terms, please stop using the Service. +

+ Contact Us +

If you have any questions about these Terms, please contact us at hello[at]darkwire.io.

+
+ +
+

Contact

+

Questions/comments? Email us at hello[at]darkwire.io

+

+ Found a bug or want a new feature?{' '} + + Open a ticket on Github + + . +

+
+ + +
+ ); + } +} + +About.propTypes = { + roomId: PropTypes.string.isRequired, +}; + +export default About; diff --git a/client/src/components/About/styles.module.scss b/client/src/components/About/styles.module.scss new file mode 100644 index 0000000..c998dc6 --- /dev/null +++ b/client/src/components/About/styles.module.scss @@ -0,0 +1,9 @@ +.links { + margin-bottom: 20px; +} + +.base { + section { + margin-bottom: 50px; + } +} diff --git a/client/src/components/Chat/Chat.jsx b/client/src/components/Chat/Chat.jsx new file mode 100644 index 0000000..92e0b27 --- /dev/null +++ b/client/src/components/Chat/Chat.jsx @@ -0,0 +1,296 @@ +import React, { Component } from 'react'; +import PropTypes from 'prop-types'; +import sanitizeHtml from 'sanitize-html'; +import { CornerDownRight } from 'react-feather'; + +import { getSelectedText, hasTouchSupport } from '@/utils/dom'; + +import FileTransfer from '@/components/FileTransfer'; + +export class Chat extends Component { + constructor(props) { + super(props); + this.state = { + message: '', + touchSupport: hasTouchSupport, + shiftKeyDown: false, + }; + + this.commands = [ + { + command: 'nick', + description: 'Changes nickname.', + parameters: ['{username}'], + usage: '/nick {username}', + scope: 'global', + action: params => { + // eslint-disable-line + let newUsername = params.join(' ') || ''; // eslint-disable-line + + // Remove things that aren't digits or chars + newUsername = newUsername.replace(/[^A-Za-z0-9]/g, '-'); + + const errors = []; + + if (!newUsername.trim().length) { + errors.push('Username cannot be blank'); + } + + if (newUsername.toString().length > 16) { + errors.push('Username cannot be greater than 16 characters'); + } + + if (!newUsername.match(/^[A-Z]/i)) { + errors.push('Username must start with a letter'); + } + + if (errors.length) { + return this.props.showNotice({ + message: `${errors.join(', ')}`, + level: 'error', + }); + } + + this.props.sendEncryptedMessage({ + type: 'CHANGE_USERNAME', + payload: { + id: this.props.userId, + newUsername, + currentUsername: this.props.username, + }, + }); + }, + }, + { + command: 'help', + description: 'Shows a list of commands.', + paramaters: [], + usage: '/help', + scope: 'local', + action: params => { + // eslint-disable-line + const validCommands = this.commands.map(command => `/${command.command}`); + this.props.showNotice({ + message: `Valid commands: ${validCommands.sort().join(', ')}`, + level: 'info', + }); + }, + }, + { + command: 'me', + description: 'Invoke virtual action', + paramaters: ['{action}'], + usage: '/me {action}', + scope: 'global', + action: params => { + // eslint-disable-line + const actionMessage = params.join(' '); + if (!actionMessage.trim().length) { + return false; + } + + this.props.sendEncryptedMessage({ + type: 'USER_ACTION', + payload: { + action: actionMessage, + }, + }); + }, + }, + { + command: 'clear', + description: 'Clears the chat screen', + paramaters: [], + usage: '/clear', + scope: 'local', + action: (params = null) => { + // eslint-disable-line + this.props.clearActivities(); + }, + }, + ]; + } + + componentDidMount() { + if (!hasTouchSupport) { + // Disable for now due to vary issues: + // Paste not working, shift+enter line breaks + // autosize(this.textInput); + this.textInput.addEventListener('autosize:resized', () => { + this.props.scrollToBottom(); + }); + } + } + + componentWillReceiveProps(nextProps) { + if (nextProps.focusChat) { + if (!getSelectedText()) { + // Don't focus for now, evaluate UX benfits + // this.textInput.focus() + } + } + } + + componentDidUpdate(nextProps, nextState) { + if (!nextState.message.trim().length) { + // autosize.update(this.textInput) + } + } + + handleKeyUp(e) { + if (e.key === 'Shift') { + this.setState({ + shiftKeyDown: false, + }); + } + } + + handleKeyPress(e) { + if (e.key === 'Shift') { + this.setState({ + shiftKeyDown: true, + }); + } + // Fix when autosize is enabled - line breaks require shift+enter twice + if (e.key === 'Enter' && !hasTouchSupport && !this.state.shiftKeyDown) { + e.preventDefault(); + if (this.canSend()) { + this.sendMessage(); + } else { + this.setState({ + message: '', + }); + } + } + } + + executeCommand(command) { + const commandToExecute = this.commands.find(cmnd => cmnd.command === command.command); + + if (commandToExecute) { + const { params } = command; + const commandResult = commandToExecute.action(params); + + return commandResult; + } + + return null; + } + + handleSendClick() { + this.sendMessage.bind(this); + this.textInput.focus(); + } + + handleFormSubmit(evt) { + evt.preventDefault(); + this.sendMessage(); + } + + parseCommand(message) { + const commandTrigger = { + command: null, + params: [], + }; + + if (message.charAt(0) === '/') { + const parsedCommand = message.replace('/', '').split(' '); + commandTrigger.command = sanitizeHtml(parsedCommand[0]) || null; + // Get params + if (parsedCommand.length >= 2) { + for (let i = 1; i < parsedCommand.length; i++) { + commandTrigger.params.push(parsedCommand[i]); + } + } + + return commandTrigger; + } + + return false; + } + + sendMessage() { + if (!this.canSend()) { + return; + } + + const { message } = this.state; + const isCommand = this.parseCommand(message); + + if (isCommand) { + const res = this.executeCommand(isCommand); + if (res === false) { + return; + } + } else { + this.props.sendEncryptedMessage({ + type: 'TEXT_MESSAGE', + payload: { + text: message, + timestamp: Date.now(), + }, + }); + } + + this.setState({ + message: '', + }); + } + + handleInputChange(evt) { + this.setState({ + message: evt.target.value, + }); + } + + canSend() { + return this.state.message.trim().length; + } + + render() { + const touchSupport = this.state.touchSupport; + + return ( +
+