diff --git a/README.md b/README.md index b2b2f18..a41f0cf 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ Built on: exitMessage: 'The chat is closed. You may close this window.', chatUnavailableMessage: 'The chat service is not available right now. Please try again later.', anonymousDisplayName: 'Anonymous', + enableEncryption: 'yes', } EmbeddableChatbox.mount(config); @@ -46,6 +47,7 @@ Options: | `size` (optional) | The size of the start button. Can be 'small' or 'large' | `large` | | `position` (optional) | The position of the start button. Can be 'top left', 'top right', 'bottom left', 'bottom right'. | `bottom right` | | `waitInterval` (optional) | The interval (in ms) at which the bot sends the wait message | 120000 | +| `enableEncryption` (optional) | if set to "yes" then the chat will be encrypted by default | `yes` | ## Feature list @@ -86,7 +88,7 @@ You can try this out on the [live demo](https://nomadic-labs.github.io/safesuppo Clone the project: ``` -git clone https://github.com/Safe-Support-Chat/ocrcc-chatbox.git +git clone https://git.umycode.com/dave/ocrcc-chatbox.git ``` Install the dependencies: ``` diff --git a/src/components/chatbox.jsx b/src/components/chatbox.jsx index 47d3030..896f385 100644 --- a/src/components/chatbox.jsx +++ b/src/components/chatbox.jsx @@ -221,9 +221,14 @@ class ChatBox extends React.Component { this.setState({ ready: false }) const client = await this.createClientWithAccount() - try { - await client.initCrypto() - } catch(err) { + + if(this.props.enableEncryption == "yes"){ + try { + await client.initCrypto() + } catch(err) { + return this.restartWithoutCrypto() + } + }else{ return this.restartWithoutCrypto() } @@ -257,7 +262,9 @@ class ChatBox extends React.Component { isCryptoEnabled: false, }) - this.displayBotMessage({ body: RESTARTING_UNENCRYPTED_CHAT_MESSAGE }) + if(this.props.enableEncryption == "yes"){ + this.displayBotMessage({ body: RESTARTING_UNENCRYPTED_CHAT_MESSAGE }) + } let opts = { baseUrl: this.props.matrixServerUrl, @@ -277,7 +284,9 @@ class ChatBox extends React.Component { client.setDisplayName(this.props.displayName) this.setMatrixListeners(client) await this.createRoom(client) - this.displayBotMessage({ body: UNENCRYPTION_NOTICE }) + if(this.props.enableEncryption == "yes"){ + this.displayBotMessage({ body: UNENCRYPTION_NOTICE }) + } } catch(err) { console.log("error", err) this.handleInitError(err) @@ -767,6 +776,7 @@ ChatBox.propTypes = { chatUnavailableMessage: PropTypes.string, displayName: PropTypes.string, waitMessage: PropTypes.string, + enableEncryption: PropTypes.string, chatOfflineMessage: PropTypes.string, isEncryptionDisabled: PropTypes.bool, position: PropTypes.oneOf(['top left', 'top right', 'bottom left', 'bottom right']), diff --git a/src/defaultConfig.js b/src/defaultConfig.js index 709b43b..833c4a9 100644 --- a/src/defaultConfig.js +++ b/src/defaultConfig.js @@ -15,6 +15,7 @@ const DEFAULT_WAIT_INTERVAL_MS = 120000; // 2 minutes const DEFAULT_DOCK_LABEL = 'Start a new chat'; const DEFAULT_ENABLED = true; const DEFAULT_AVAILABLE = true; +const DEFAULT_ENCRYPTION = "yes" const defaultConfig = { termsUrl: DEFAULT_TERMS_URL, @@ -26,6 +27,7 @@ const defaultConfig = { displayName: DEFAULT_DISPLAY_NAME, chatUnavailableMessage: DEFAULT_CHAT_UNAVAILABLE_MESSAGE, waitMessage: DEFAULT_WAIT_MESSAGE, + enableEncryption: DEFAULT_ENCRYPTION, chatOfflineMessage: DEFAULT_CHAT_OFFLINE_MESSAGE, isEncryptionDisabled: DEFAULT_ENCRYPTION_DISABLED, position: DEFAULT_POSITION,