Compare commits

..

3 Commits

Author SHA1 Message Date
Dave Umrysh
8e6f80326b committing build files 2021-08-25 15:38:01 -06:00
Dave Umrysh
f95aef64d0 update readme about encryption.Fix bookmarlet syntax 2021-08-25 15:37:00 -06:00
Dave Umrysh
a91ca1a092 add a flag to disable encryption by default 2021-08-25 15:29:44 -06:00
8 changed files with 52 additions and 41 deletions

View File

@ -23,6 +23,7 @@ Built on:
exitMessage: 'The chat is closed. You may close this window.', exitMessage: 'The chat is closed. You may close this window.',
chatUnavailableMessage: 'The chat service is not available right now. Please try again later.', chatUnavailableMessage: 'The chat service is not available right now. Please try again later.',
anonymousDisplayName: 'Anonymous', anonymousDisplayName: 'Anonymous',
enableEncryption: 'yes',
} }
EmbeddableChatbox.mount(config); EmbeddableChatbox.mount(config);
@ -41,6 +42,7 @@ Options:
| `exitMessage` (optional) | Text to show if the user rejects the Terms of Use. | `The chat is closed. You may close this window.` | | `exitMessage` (optional) | Text to show if the user rejects the Terms of Use. | `The chat is closed. You may close this window.` |
| `anonymousDisplayName` (optional) | The display name for the chat user. | `Anonymous` | | `anonymousDisplayName` (optional) | The display name for the chat user. | `Anonymous` |
| `chatUnavailableMessage` (optional) | Text to show if no-one is available to respond | `The chat service is not available right now. Please try again later.` | | `chatUnavailableMessage` (optional) | Text to show if no-one is available to respond | `The chat service is not available right now. Please try again later.` |
| `enableEncryption` (optional) | if set to "yes" then the chat will be encrypted by default | `yes` |
## Feature list ## Feature list
@ -80,7 +82,7 @@ You can try this out on the [live demo](https://nomadic-labs.github.io/safesuppo
Clone the project: Clone the project:
``` ```
git clone https://github.com/nomadic-labs/safesupport-chatbox.git git clone https://git.umycode.com/dave/safesupport-chatbox.git
``` ```
Install the dependencies: Install the dependencies:
``` ```

12
dist/bookmarklet.js vendored

File diff suppressed because one or more lines are too long

12
dist/chatbox.js vendored

File diff suppressed because one or more lines are too long

1
dist/index.html vendored
View File

@ -23,6 +23,7 @@
exitMessage: 'The chat is closed. You may close this window.', exitMessage: 'The chat is closed. You may close this window.',
chatUnavailableMessage: 'The chat service is not available right now. Please try again later.', chatUnavailableMessage: 'The chat service is not available right now. Please try again later.',
anonymousDisplayName: 'Anonymous', anonymousDisplayName: 'Anonymous',
enableEncryption: 'no',
} }
EmbeddableChatbox.mount(config); EmbeddableChatbox.mount(config);

View File

@ -23,6 +23,7 @@
exitMessage: 'The chat is closed. You may close this window.', exitMessage: 'The chat is closed. You may close this window.',
chatUnavailableMessage: 'The chat service is not available right now. Please try again later.', chatUnavailableMessage: 'The chat service is not available right now. Please try again later.',
anonymousDisplayName: 'Anonymous', anonymousDisplayName: 'Anonymous',
enableEncryption: 'no',
} }
EmbeddableChatbox.mount(config); EmbeddableChatbox.mount(config);

View File

@ -38,6 +38,7 @@ const DEFAULT_EXIT_MESSAGE = "The chat is closed. You may close this window."
const DEFAULT_ANONYMOUS_DISPLAY_NAME="Anonymous" const DEFAULT_ANONYMOUS_DISPLAY_NAME="Anonymous"
const DEFAULT_CHAT_UNAVAILABLE_MESSAGE = "The chat service is not available right now. Please try again later." const DEFAULT_CHAT_UNAVAILABLE_MESSAGE = "The chat service is not available right now. Please try again later."
const DEFAULT_WAIT_MESSAGE = "Please be patient, our online facilitators are currently responding to other support requests." const DEFAULT_WAIT_MESSAGE = "Please be patient, our online facilitators are currently responding to other support requests."
const DEFAULT_ENCRYPTION = "yes"
class ChatBox extends React.Component { class ChatBox extends React.Component {
@ -229,9 +230,13 @@ class ChatBox extends React.Component {
client.setDisplayName(this.props.anonymousDisplayName) client.setDisplayName(this.props.anonymousDisplayName)
this.setMatrixListeners(client) this.setMatrixListeners(client)
try { if(this.props.enableEncryption == "yes"){
await client.initCrypto() try {
} catch(err) { await client.initCrypto()
} catch(err) {
return this.initializeUnencryptedChat()
}
}else{
return this.initializeUnencryptedChat() return this.initializeUnencryptedChat()
} }
@ -257,7 +262,9 @@ class ChatBox extends React.Component {
isCryptoEnabled: false, isCryptoEnabled: false,
}) })
this.displayBotMessage({ body: RESTARTING_UNENCRYPTED_CHAT_MESSAGE }) if(this.props.enableEncryption == "yes"){
this.displayBotMessage({ body: RESTARTING_UNENCRYPTED_CHAT_MESSAGE })
}
let opts = { let opts = {
baseUrl: this.props.matrixServerUrl, baseUrl: this.props.matrixServerUrl,
@ -277,7 +284,9 @@ class ChatBox extends React.Component {
client.setDisplayName(this.props.anonymousDisplayName) client.setDisplayName(this.props.anonymousDisplayName)
await this.createRoom(client) await this.createRoom(client)
await client.startClient() await client.startClient()
this.displayBotMessage({ body: UNENCRYPTION_NOTICE }) if(this.props.enableEncryption == "yes"){
this.displayBotMessage({ body: UNENCRYPTION_NOTICE })
}
} catch(err) { } catch(err) {
console.log("error", err) console.log("error", err)
this.handleInitError(err) this.handleInitError(err)
@ -715,6 +724,7 @@ ChatBox.propTypes = {
chatUnavailableMessage: PropTypes.string, chatUnavailableMessage: PropTypes.string,
anonymousDisplayName: PropTypes.string, anonymousDisplayName: PropTypes.string,
waitMessage: PropTypes.string, waitMessage: PropTypes.string,
enableEncryption: PropTypes.string,
} }
ChatBox.defaultProps = { ChatBox.defaultProps = {
@ -729,6 +739,7 @@ ChatBox.defaultProps = {
anonymousDisplayName: DEFAULT_ANONYMOUS_DISPLAY_NAME, anonymousDisplayName: DEFAULT_ANONYMOUS_DISPLAY_NAME,
chatUnavailableMessage: DEFAULT_CHAT_UNAVAILABLE_MESSAGE, chatUnavailableMessage: DEFAULT_CHAT_UNAVAILABLE_MESSAGE,
waitMessage: DEFAULT_WAIT_MESSAGE, waitMessage: DEFAULT_WAIT_MESSAGE,
enableEncryption: DEFAULT_ENCRYPTION,
} }
export default ChatBox; export default ChatBox;

View File

@ -1,17 +1,18 @@
import EmbeddableChatbox from './embeddable-chatbox'; import EmbeddableChatbox from './embeddable-chatbox';
const config = { const config = {
matrixServerUrl: 'https://matrix.safesupport.chat', matrixServerUrl: 'https://matrix.safesupport.chat',
botId: '@help-bot:safesupport.chat', botId: '@help-bot:safesupport.chat',
roomName: 'Support Chat', roomName: 'Support Chat',
termsUrl: 'https://tosdr.org/', termsUrl: 'https://tosdr.org/',
introMessage: "This chat application does not collect any of your personal data or any data from your use of this service.", introMessage: 'This chat application does not collect any of your personal data or any data from your use of this service.',
agreementMessage: 'Do you want to continue?', agreementMessage: 'Do you want to continue?',
confirmationMessage: 'Waiting for a facilitator to join the chat...', confirmationMessage: 'Waiting for a facilitator to join the chat...',
exitMessage: 'The chat is closed. You may close this window.', exitMessage: 'The chat is closed. You may close this window.',
chatUnavailableMessage: 'The chat service is not available right now. Please try again later.', chatUnavailableMessage: 'The chat service is not available right now. Please try again later.',
anonymousDisplayName: 'Anonymous', anonymousDisplayName: 'Anonymous',
} enableEncryption: 'no',
};
export default function bookmarklet() { export default function bookmarklet() {
if (window.EmbeddableChatbox) { if (window.EmbeddableChatbox) {

View File

@ -2763,15 +2763,10 @@ camelcase@^5.0.0, camelcase@^5.3.1:
resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320" resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320"
integrity sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg== integrity sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==
caniuse-lite@^1.0.30001023: caniuse-lite@^1.0.30001023, caniuse-lite@^1.0.30001036, caniuse-lite@^1.0.30001038:
version "1.0.30001023" version "1.0.30001251"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001023.tgz#b82155827f3f5009077bdd2df3d8968bcbcc6fc4" resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001251.tgz"
integrity sha512-C5TDMiYG11EOhVOA62W1p3UsJ2z4DsHtMBQtjzp3ZsUglcQn62WOUgW0y795c7A5uZ+GCEIvzkMatLIlAsbNTA== integrity sha512-HOe1r+9VkU4TFmnU70z+r7OLmtR+/chB1rdcJUeQlAinjEeb0cKL20tlAtOagNZhbrtLnCvV19B4FmF1rgzl6A==
caniuse-lite@^1.0.30001036, caniuse-lite@^1.0.30001038:
version "1.0.30001038"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001038.tgz#44da3cbca2ab6cb6aa83d1be5d324e17f141caff"
integrity sha512-zii9quPo96XfOiRD4TrfYGs+QsGZpb2cGiMAzPjtf/hpFgB6zCPZgJb7I1+EATeMw/o+lG8FyRAnI+CWStHcaQ==
capture-exit@^2.0.0: capture-exit@^2.0.0:
version "2.0.0" version "2.0.0"
@ -10250,9 +10245,9 @@ websocket-driver@>=0.5.1:
websocket-extensions ">=0.1.1" websocket-extensions ">=0.1.1"
websocket-extensions@>=0.1.1: websocket-extensions@>=0.1.1:
version "0.1.4" version "0.1.3"
resolved "https://registry.yarnpkg.com/websocket-extensions/-/websocket-extensions-0.1.4.tgz#7f8473bc839dfd87608adb95d7eb075211578a42" resolved "https://registry.yarnpkg.com/websocket-extensions/-/websocket-extensions-0.1.3.tgz#5d2ff22977003ec687a4b87073dfbbac146ccf29"
integrity sha512-OqedPIGOfsDlo31UNwYbCFMSaO9m9G/0faIHj5/dZFDMFqPTcx6UwqyOy3COEaEOg/9VsGIpdqn62W5KhoKSpg== integrity sha512-nqHUnMXmBzT0w570r2JpJxfiSD1IzoI+HGVdd3aZ0yNi3ngvQ4jv1dtHt5VGxfI2yj5yqImPhOK4vmIh2xMbGg==
whatwg-encoding@^1.0.1, whatwg-encoding@^1.0.3: whatwg-encoding@^1.0.1, whatwg-encoding@^1.0.3:
version "1.0.5" version "1.0.5"