Compare commits

..

No commits in common. "master" and "bot_signal" have entirely different histories.

18 changed files with 16073 additions and 332 deletions

View File

@ -10,7 +10,7 @@ Built on:
## Usage ## Usage
``` ```
<script src="https://safesupport.chat/chatbox.js" type="text/javascript"></script> <script src="https://unpkg.com/private-safesupport-chatbox" type="text/javascript"></script>
<script> <script>
var config = { var config = {
matrixServerUrl: 'https://matrix-client.matrix.org', matrixServerUrl: 'https://matrix-client.matrix.org',
@ -45,6 +45,7 @@ Options:
| `chatOfflineMessage` (optional) | Text to show if there is no-one online respond | `All of the chat facilitators are currently offline.` | | `chatOfflineMessage` (optional) | Text to show if there is no-one online respond | `All of the chat facilitators are currently offline.` |
| `size` (optional) | The size of the start button. Can be 'small' or 'large' | `large` | | `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` | | `position` (optional) | The position of the start button. Can be 'top left', 'top right', 'bottom left', 'bottom right'. | `bottom right` |
| `maxWaitTime` (optional) | The maximum time (in ms) the chatbox will wait for someone to join before closing the chat and displaying the chat unavailable message | 600000 |
| `waitInterval` (optional) | The interval (in ms) at which the bot sends the wait message | 120000 | | `waitInterval` (optional) | The interval (in ms) at which the bot sends the wait message | 120000 |
@ -74,7 +75,7 @@ This chatbox is meant to be used with a bot account that handles a number of fun
The bot account is invited to the chatroom when a support request is initiated. The bot account is invited to the chatroom when a support request is initiated.
You can find the code for the bot at [ocrcc-bot](https://github.com/Safe-Support-Chat/ocrcc-bot). You can find the code for the bot at [safesupport-bot](https://github.com/nomadic-labs/safesupport-bot).
## Bookmarklet ## Bookmarklet
@ -86,11 +87,11 @@ 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/Safe-Support-Chat/ocrcc-chatbox.git git clone https://github.com/nomadic-labs/safesupport-chatbox.git
``` ```
Install the dependencies: Install the dependencies:
``` ```
cd ocrcc-chatbox cd safesupport-chatbox
yarn yarn
``` ```

18
dist/bookmarklet.js vendored

File diff suppressed because one or more lines are too long

18
dist/chatbox.js vendored

File diff suppressed because one or more lines are too long

36
dist/component.js vendored

File diff suppressed because one or more lines are too long

17
dist/index.html vendored
View File

@ -13,8 +13,21 @@
<script src="./chatbox.js"></script> <script src="./chatbox.js"></script>
<script> <script>
var config = { var config = {
matrixServerUrl: 'https://matrix.safesupport.chat' matrixServerUrl: 'https://matrix.rhok.space',
}; botId: '@help-bot:rhok.space',
roomName: 'Support Chat',
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.",
agreementMessage: 'Do you want to continue?',
confirmationMessage: 'Waiting for a facilitator to join the chat...',
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',
position: 'bottom right',
size: 'large',
maxWaitTime: 6000*3,
}
EmbeddableChatbox.mount(config); EmbeddableChatbox.mount(config);
</script> </script>

15900
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
{ {
"name": "ocrcc-chatbox", "name": "private-safesupport-chatbox",
"version": "2.3.2", "version": "1.2.2",
"description": "A secure and private embeddable chatbox that connects to Matrix", "description": "A secure and private embeddable chatbox that connects to Riot",
"main": "dist/chatbox.js", "main": "dist/chatbox.js",
"scripts": { "scripts": {
"build": "NODE_ENV=production webpack-cli --mode production", "build": "NODE_ENV=production webpack-cli --mode production",
@ -118,8 +118,6 @@
"node-sass": "^4.13.1", "node-sass": "^4.13.1",
"postcss-increase-specificity": "0.6.0", "postcss-increase-specificity": "0.6.0",
"postcss-loader": "3.0.0", "postcss-loader": "3.0.0",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"sass-loader": "8.0.0", "sass-loader": "8.0.0",
"style-loader": "1.1.2", "style-loader": "1.1.2",
"wait-for-expect": "^3.0.2", "wait-for-expect": "^3.0.2",
@ -131,7 +129,6 @@
"webpack-serve": "3.2.0" "webpack-serve": "3.2.0"
}, },
"dependencies": { "dependencies": {
"airtable": "^0.10.0",
"browser-encrypt-attachment": "^0.3.0", "browser-encrypt-attachment": "^0.3.0",
"emoji-picker-react": "^3.1.3", "emoji-picker-react": "^3.1.3",
"isomorphic-fetch": "^2.2.1", "isomorphic-fetch": "^2.2.1",
@ -140,13 +137,11 @@
"node-localstorage": "^2.1.5", "node-localstorage": "^2.1.5",
"olm": "https://packages.matrix.org/npm/olm/olm-3.1.4.tgz", "olm": "https://packages.matrix.org/npm/olm/olm-3.1.4.tgz",
"prop-types": "^15.6.2", "prop-types": "^15.6.2",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-onclickoutside": "^6.9.0", "react-onclickoutside": "^6.9.0",
"react-test-renderer": "^16.13.0", "react-test-renderer": "^16.13.0",
"react-transition-group": "^4.0.0", "react-transition-group": "^4.0.0",
"uuidv4": "^6.0.2" "uuidv4": "^6.0.2"
},
"peerDependencies": {
"react": "^16.8.6",
"react-dom": "^16.8.6"
} }
} }

View File

@ -13,8 +13,21 @@
<script src="./chatbox.js"></script> <script src="./chatbox.js"></script>
<script> <script>
var config = { var config = {
matrixServerUrl: 'https://matrix.safesupport.chat' matrixServerUrl: 'https://matrix.rhok.space',
}; botId: '@help-bot:rhok.space',
roomName: 'Support Chat',
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.",
agreementMessage: 'Do you want to continue?',
confirmationMessage: 'Waiting for a facilitator to join the chat...',
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',
position: 'bottom right',
size: 'large',
maxWaitTime: 1000*60*3, // 3 minutes
}
EmbeddableChatbox.mount(config); EmbeddableChatbox.mount(config);
</script> </script>

View File

@ -1,94 +0,0 @@
import React, { useState, useEffect } from 'react';
import PropTypes from 'prop-types';
import Chatbox from './chatbox';
const ChatboxWithSettings = ({ settingsEndpoint = null, matrixServerUrl, ...rest }) => {
const [settings, setSettings] = useState({});
const [shifts, setShifts] = useState();
const [isAvailable, setAvailability] = useState(true);
const getSettings = async () => {
const url = `${settingsEndpoint}?homeserver=${encodeURIComponent(matrixServerUrl)}`;
const res = await fetch(url);
const data = await res.json();
const { fields, schedule = [] } = data;
if (!fields) {
const props = {
...rest,
enabled: true,
isAvailable: true,
};
return setSettings(props);
}
const settingsObj = {};
setShifts(schedule);
Object.entries(fields).forEach(([k, v]) => {
const [scope, key] = k.split('_');
if (scope === 'web') {
settingsObj[key] = v;
}
});
if (!settingsObj.enabled) {
settingsObj.enabled = false;
}
return setSettings(settingsObj);
};
const checkSchedule = () => {
const weekdays = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
const now = new Date();
const weekday = weekdays[now.getDay()];
const hours = now.getHours();
const minutes = now.getMinutes();
shifts.map(async (shift) => {
const [startHours, startMinutes] = shift.start.split(':').map((t) => Number(t));
const [endHours, endMinutes] = shift.end.split(':').map((t) => Number(t));
if (
shift.service === 'web'
&& shift.weekday === weekday
&& ((startHours < hours) || (startHours === hours && startMinutes <= minutes))
&& ((endHours > hours) || (endHours === hours && endMinutes > minutes))
) {
setAvailability(true);
}
});
};
useEffect(() => {
if (settingsEndpoint) {
getSettings();
}
}, [settingsEndpoint]);
useEffect(() => {
if (shifts && shifts.length > 0) {
checkSchedule();
}
}, [shifts]);
return (
/* eslint-disable react/jsx-props-no-spreading */
<Chatbox matrixServerUrl={matrixServerUrl} isAvailable={isAvailable} {...settings} {...rest} />
);
};
ChatboxWithSettings.propTypes = {
matrixServerUrl: PropTypes.string.isRequired,
settingsEndpoint: PropTypes.string,
};
ChatboxWithSettings.defaultProps = {
settingsEndpoint: null,
};
export default ChatboxWithSettings;

View File

@ -18,13 +18,32 @@ import Header from "./header";
import EmojiSelector from './emoji-selector'; import EmojiSelector from './emoji-selector';
import './styles.scss'; import './styles.scss';
import defaultConfig from '../defaultConfig.js';
const ENCRYPTION_CONFIG = { "algorithm": "m.megolm.v1.aes-sha2" }; const ENCRYPTION_CONFIG = { "algorithm": "m.megolm.v1.aes-sha2" };
const ENCRYPTION_NOTICE = "Messages in this chat are secured with end-to-end encryption." const ENCRYPTION_NOTICE = "Messages in this chat are secured with end-to-end encryption."
const UNENCRYPTION_NOTICE = "Messages in this chat are not encrypted." const UNENCRYPTION_NOTICE = "Messages in this chat are not encrypted."
const RESTARTING_UNENCRYPTED_CHAT_MESSAGE = "Restarting chat without encryption." const RESTARTING_UNENCRYPTED_CHAT_MESSAGE = "Restarting chat without encryption."
const CHAT_IS_OFFLINE_NOTICE = "CHAT_OFFLINE"
const DEFAULT_MATRIX_SERVER = "https://matrix.rhok.space/"
const DEFAULT_BOT_ID = "@help-bot:rhok.space"
const DEFAULT_TERMS_URL = "https://tosdr.org/"
const DEFAULT_ROOM_NAME = "Support Chat"
const DEFAULT_INTRO_MESSAGE = "This chat application does not collect any of your personal data or any data from your use of this service."
const DEFAULT_AGREEMENT_MESSAGE = "Do you want to continue?"
const DEFAULT_CONFIRMATION_MESSAGE = "Waiting for a facilitator to join the chat..."
const DEFAULT_EXIT_MESSAGE = "The chat is closed. You may close this window."
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_OFFLINE_MESSAGE = "All of the chat facilitators are currently offline."
const DEFAULT_WAIT_MESSAGE = "Please be patient, our online facilitators are currently responding to other support requests."
const DEFAULT_ENCRYPTION_DISABLED = false
const DEFAULT_POSITION = 'bottom right'
const DEFAULT_SIZE = 'large'
const DEFAULT_MAX_WAIT_MS = 600000 // 10 minutes
const DEFAULT_WAIT_INTERVAL_MS = 120000 // 2 minutes
class ChatBox extends React.Component { class ChatBox extends React.Component {
constructor(props) { constructor(props) {
@ -132,28 +151,23 @@ class ChatBox extends React.Component {
exitChat = async (resetState=true) => { exitChat = async (resetState=true) => {
if (this.state.client) { if (this.state.client) {
try { await this.state.client.leave(this.state.roomId)
await this.state.client.leave(this.state.roomId)
const auth = { const auth = {
type: 'm.login.password', type: 'm.login.password',
user: this.state.userId, user: this.state.userId,
identifier: { identifier: {
type: "m.id.user", type: "m.id.user",
user: this.state.userId, user: this.state.userId,
}, },
password: this.state.password, password: this.state.password,
}; };
await this.state.client.deactivateAccount(auth, true) await this.state.client.deactivateAccount(auth, true)
await this.state.client.stopClient() await this.state.client.stopClient()
await this.state.client.clearStores() await this.state.client.clearStores()
} catch (err) { this.setState({ client: null })
console.log("Error exiting chat", err) window.clearInterval(this.state.waitIntervalId) // no more waiting messages
} finally {
this.setState({ client: null, ready: true }) // no more loading animation
window.clearInterval(this.state.waitIntervalId) // no more waiting messages
}
} }
if (this.state.localStorage) { if (this.state.localStorage) {
@ -232,7 +246,7 @@ class ChatBox extends React.Component {
client.once('sync', async (state, prevState, data) => { client.once('sync', async (state, prevState, data) => {
if (state === "PREPARED") { if (state === "PREPARED") {
this.setState({ client }) this.setState({ client })
client.setDisplayName(this.props.displayName) client.setDisplayName(this.props.anonymousDisplayName)
this.setMatrixListeners(client) this.setMatrixListeners(client)
await this.createRoom(client) await this.createRoom(client)
} }
@ -274,7 +288,7 @@ class ChatBox extends React.Component {
if (state === "PREPARED") { if (state === "PREPARED") {
try { try {
this.setState({ client }) this.setState({ client })
client.setDisplayName(this.props.displayName) client.setDisplayName(this.props.anonymousDisplayName)
this.setMatrixListeners(client) this.setMatrixListeners(client)
await this.createRoom(client) await this.createRoom(client)
this.displayBotMessage({ body: UNENCRYPTION_NOTICE }) this.displayBotMessage({ body: UNENCRYPTION_NOTICE })
@ -293,7 +307,7 @@ class ChatBox extends React.Component {
await client.startClient() await client.startClient()
client.once('sync', async (state, prevState, data) => { client.once('sync', async (state, prevState, data) => {
client.setDisplayName(this.props.displayName) client.setDisplayName(this.props.anonymousDisplayName)
this.setMatrixListeners(client) this.setMatrixListeners(client)
await this.createRoom(client) await this.createRoom(client)
}) })
@ -447,15 +461,38 @@ class ChatBox extends React.Component {
const decryptionErrors = {...this.state.decryptionErrors} const decryptionErrors = {...this.state.decryptionErrors}
delete decryptionErrors[message.id] delete decryptionErrors[message.id]
const isOfflineNotice = message.content.msgtype === "m.notice" && message.content.body === CHAT_IS_OFFLINE_NOTICE
let newMessage = message
// when the bot sends a notice that the chat is offline
// replace the message with the client-configured message
// for now we're treating m.notice and m.text messages the same
if (isOfflineNotice) {
newMessage = {
...message,
content: {
...message.content,
body: this.props.chatOfflineMessage
}
}
this.handleChatOffline()
}
this.setState({ this.setState({
messages: { messages: {
...this.state.messages, ...this.state.messages,
[message.id]: message, [message.id]: newMessage,
}, },
decryptionErrors decryptionErrors
}) })
} }
handleChatOffline = () => {
this.exitChat(false) // close the chat connection but keep chatbox state
this.setState({ ready: true }) // no more loading animation
}
handleKeyDown = (e) => { handleKeyDown = (e) => {
switch (e.keyCode) { switch (e.keyCode) {
case 27: case 27:
@ -546,9 +583,6 @@ class ChatBox extends React.Component {
switch (signal) { switch (signal) {
case 'END_CHAT': case 'END_CHAT':
this.displayBotMessage({ body: this.props.exitMessage }) this.displayBotMessage({ body: this.props.exitMessage })
return this.exitChat(false); // keepg chat state
case 'CHAT_OFFLINE':
this.displayBotMessage({ body: this.props.chatOfflineMessage })
return this.exitChat(false); // keep chat state return this.exitChat(false); // keep chat state
} }
} }
@ -572,14 +606,14 @@ class ChatBox extends React.Component {
} }
componentDidMount() { componentDidMount() {
document.addEventListener("keydown", this.handleKeyDown, false) document.addEventListener("keydown", this.handleKeyDown, false);
window.addEventListener('beforeunload', this.exitChat) window.addEventListener('beforeunload', this.exitChat)
} }
componentWillUnmount() { componentWillUnmount() {
document.removeEventListener("keydown", this.handleKeyDown, false) document.removeEventListener("keydown", this.handleKeyDown, false);
window.removeEventListener('beforeunload', this.exitChat) window.removeEventListener('beforeunload', this.exitChat)
this.exitChat() this.exitChat();
} }
handleInputChange = e => { handleInputChange = e => {
@ -640,11 +674,6 @@ class ChatBox extends React.Component {
} }
render() { render() {
console.log(this.props)
if (!this.props.enabled || !this.props.isAvailable) {
return null
}
const { ready, messages, messagesInFlight, inputValue, userId, roomId, typingStatus, opened, showDock, emojiSelectorOpen, isMobile, decryptionErrors } = this.state; const { ready, messages, messagesInFlight, inputValue, userId, roomId, typingStatus, opened, showDock, emojiSelectorOpen, isMobile, decryptionErrors } = this.state;
const orderedMessages = Object.values(messages).sort((a,b) => a.timestamp - b.timestamp) const orderedMessages = Object.values(messages).sort((a,b) => a.timestamp - b.timestamp)
const inputLabel = 'Send a message...' const inputLabel = 'Send a message...'
@ -747,7 +776,7 @@ class ChatBox extends React.Component {
)} )}
} }
</Transition> </Transition>
{showDock && !roomId && <Dock handleToggleOpen={this.handleToggleOpen} size={this.props.size} label={this.props.dockLabel} />} {showDock && !roomId && <Dock handleToggleOpen={this.handleToggleOpen} size={this.props.size} />}
{showDock && roomId && <Header handleToggleOpen={this.handleToggleOpen} opened={opened} handleExitChat={this.handleExitChat} />} {showDock && roomId && <Header handleToggleOpen={this.handleToggleOpen} opened={opened} handleExitChat={this.handleExitChat} />}
</div> </div>
</div> </div>
@ -765,19 +794,35 @@ ChatBox.propTypes = {
confirmationMessage: PropTypes.string, confirmationMessage: PropTypes.string,
exitMessage: PropTypes.string, exitMessage: PropTypes.string,
chatUnavailableMessage: PropTypes.string, chatUnavailableMessage: PropTypes.string,
displayName: PropTypes.string, anonymousDisplayName: PropTypes.string,
waitMessage: PropTypes.string, waitMessage: PropTypes.string,
chatOfflineMessage: PropTypes.string, chatOfflineMessage: PropTypes.string,
isEncryptionDisabled: PropTypes.bool, isEncryptionDisabled: PropTypes.bool,
position: PropTypes.oneOf(['top left', 'top right', 'bottom left', 'bottom right']), position: PropTypes.oneOf(['top left', 'top right', 'bottom left', 'bottom right']),
size: PropTypes.oneOf(['small', 'large']), size: PropTypes.oneOf(['small', 'large']),
maxWaitTime: PropTypes.number,
waitInterval: PropTypes.number, waitInterval: PropTypes.number,
dockLabel: PropTypes.string,
enabled: PropTypes.bool,
isAvailable: PropTypes.bool
} }
ChatBox.defaultProps = defaultConfig ChatBox.defaultProps = {
matrixServerUrl: DEFAULT_MATRIX_SERVER,
botId: DEFAULT_BOT_ID,
termsUrl: DEFAULT_TERMS_URL,
roomName: DEFAULT_ROOM_NAME,
introMessage: DEFAULT_INTRO_MESSAGE,
agreementMessage: DEFAULT_AGREEMENT_MESSAGE,
confirmationMessage: DEFAULT_CONFIRMATION_MESSAGE,
exitMessage: DEFAULT_EXIT_MESSAGE,
anonymousDisplayName: DEFAULT_ANONYMOUS_DISPLAY_NAME,
chatUnavailableMessage: DEFAULT_CHAT_UNAVAILABLE_MESSAGE,
waitMessage: DEFAULT_WAIT_MESSAGE,
chatOfflineMessage: DEFAULT_CHAT_OFFLINE_MESSAGE,
isEncryptionDisabled: DEFAULT_ENCRYPTION_DISABLED,
position: DEFAULT_POSITION,
size: DEFAULT_SIZE,
maxWaitTime: DEFAULT_MAX_WAIT_MS,
waitInterval: DEFAULT_WAIT_INTERVAL_MS,
}
export default ChatBox; export default ChatBox;

View File

@ -27,8 +27,8 @@ import waitForExpect from 'wait-for-expect'
config.disabled = true config.disabled = true
var testConfig = { var testConfig = {
matrixServerUrl: 'https://test.matrix.tld', matrixServerUrl: 'https://matrix.rhok.space',
botId: '@help-bot:matrix.tld', botId: '@help-bot:rhok.space',
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.',

View File

@ -1,7 +1,7 @@
import React, { Fragment } from "react" import React, { Fragment } from "react"
import PropTypes from "prop-types" import PropTypes from "prop-types"
const Dock = ({ handleToggleOpen, size, label }) => { const Dock = ({ handleToggleOpen, size }) => {
return( return(
<button <button
type="button" type="button"
@ -13,11 +13,11 @@ const Dock = ({ handleToggleOpen, size, label }) => {
{ {
size === 'small' ? size === 'small' ?
<div id="open-chatbox-label"> <div id="open-chatbox-label">
<span>{label}</span><span className="icon">+</span> <span>Chat</span><span className="icon">+</span>
</div> </div>
: :
<Fragment> <Fragment>
<div id="open-chatbox-label">{label}</div> <div id="open-chatbox-label">Start a new chat</div>
<div className="label-icon"> <div className="label-icon">
<div className={`btn-icon`} aria-label={`Open support chat window`}>+</div> <div className={`btn-icon`} aria-label={`Open support chat window`}>+</div>
</div> </div>

View File

@ -1,39 +0,0 @@
const DEFAULT_TERMS_URL = 'https://tosdr.org/';
const DEFAULT_ROOM_NAME = 'Support Chat';
const DEFAULT_INTRO_MESSAGE = 'This chat application does not collect any of your personal data or any data from your use of this service.';
const DEFAULT_AGREEMENT_MESSAGE = 'Do you want to continue?';
const DEFAULT_CONFIRMATION_MESSAGE = 'Waiting for a facilitator to join the chat...';
const DEFAULT_EXIT_MESSAGE = 'The chat is closed. You may close this window.';
const DEFAULT_DISPLAY_NAME = 'Anonymous';
const DEFAULT_CHAT_UNAVAILABLE_MESSAGE = 'The chat service is not available right now. Please try again later.';
const DEFAULT_CHAT_OFFLINE_MESSAGE = 'All of the chat facilitators are currently offline.';
const DEFAULT_WAIT_MESSAGE = 'Please be patient, our online facilitators are currently responding to other support requests.';
const DEFAULT_ENCRYPTION_DISABLED = false;
const DEFAULT_POSITION = 'bottom right';
const DEFAULT_SIZE = 'large';
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 defaultConfig = {
termsUrl: DEFAULT_TERMS_URL,
roomName: DEFAULT_ROOM_NAME,
introMessage: DEFAULT_INTRO_MESSAGE,
agreementMessage: DEFAULT_AGREEMENT_MESSAGE,
confirmationMessage: DEFAULT_CONFIRMATION_MESSAGE,
exitMessage: DEFAULT_EXIT_MESSAGE,
displayName: DEFAULT_DISPLAY_NAME,
chatUnavailableMessage: DEFAULT_CHAT_UNAVAILABLE_MESSAGE,
waitMessage: DEFAULT_WAIT_MESSAGE,
chatOfflineMessage: DEFAULT_CHAT_OFFLINE_MESSAGE,
isEncryptionDisabled: DEFAULT_ENCRYPTION_DISABLED,
position: DEFAULT_POSITION,
size: DEFAULT_SIZE,
waitInterval: DEFAULT_WAIT_INTERVAL_MS,
dockLabel: DEFAULT_DOCK_LABEL,
enabled: DEFAULT_ENABLED,
isAvailable: DEFAULT_AVAILABLE,
};
export default defaultConfig;

View File

@ -1,7 +1,17 @@
import EmbeddableChatbox from './embeddable-chatbox'; import EmbeddableChatbox from './embeddable-chatbox';
import defaultConfig from '../defaultConfig';
const config = defaultConfig; const config = {
matrixServerUrl: 'https://matrix.rhok.space',
botId: '@help-bot:rhok.space',
roomName: 'Support Chat',
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.',
agreementMessage: 'Do you want to continue?',
confirmationMessage: 'Waiting for a facilitator to join the chat...',
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',
};
export default function bookmarklet() { export default function bookmarklet() {
if (window.EmbeddableChatbox) { if (window.EmbeddableChatbox) {

View File

@ -1,3 +0,0 @@
import Chatbox from '../components/chatbox';
export default Chatbox;

View File

@ -1,14 +1,13 @@
import React from 'react'; import React from 'react';
import ReactDOM from 'react-dom'; import ReactDOM from 'react-dom';
import ChatboxWithSettings from '../components/ChatboxWithSettings'; import Chatbox from '../components/chatbox';
import '../../vendor/cleanslate.css'; import '../../vendor/cleanslate.css';
export default class EmbeddableChatbox { export default class EmbeddableChatbox {
static el; static el;
static mount({ parentElement = null, ...props } = {}) { static mount({ parentElement = null, ...props } = {}) {
const component = <ChatboxWithSettings {...props} />; // eslint-disable-line const component = <Chatbox {...props} />; // eslint-disable-line
function doRender() { function doRender() {
if (EmbeddableChatbox.el) { if (EmbeddableChatbox.el) {

View File

@ -94,29 +94,4 @@ module.exports = [{
publicPath: '/', publicPath: '/',
filename: 'bookmarklet.js', filename: 'bookmarklet.js',
}, },
}, {
...defaultConfig,
entry: './src/outputs/component.js',
output: {
path: distDir,
publicPath: '/',
filename: 'component.js',
library: 'Chatbox',
libraryExport: 'default',
libraryTarget: 'commonjs2',
},
externals: {
react: {
commonjs: "react",
commonjs2: "react",
amd: "React",
root: "React"
},
"react-dom": {
commonjs: "react-dom",
commonjs2: "react-dom",
amd: "ReactDOM",
root: "ReactDOM"
}
}
}]; }];

View File

@ -1786,11 +1786,6 @@
resolved "https://registry.yarnpkg.com/@types/node/-/node-13.7.0.tgz#b417deda18cf8400f278733499ad5547ed1abec4" resolved "https://registry.yarnpkg.com/@types/node/-/node-13.7.0.tgz#b417deda18cf8400f278733499ad5547ed1abec4"
integrity sha512-GnZbirvmqZUzMgkFn70c74OQpTTUcCzlhQliTzYjQMqg+hVKcDnxdL19Ne3UdYzdMA/+W3eb646FWn/ZaT1NfQ== integrity sha512-GnZbirvmqZUzMgkFn70c74OQpTTUcCzlhQliTzYjQMqg+hVKcDnxdL19Ne3UdYzdMA/+W3eb646FWn/ZaT1NfQ==
"@types/node@^14.0.14":
version "14.14.0"
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.0.tgz#f1091b6ad5de18e8e91bdbd43ec63f13de372538"
integrity sha512-BfbIHP9IapdupGhq/hc+jT5dyiBVZ2DdeC5WwJWQWDb0GijQlzUFAeIQn/2GtvZcd2HVUU7An8felIICFTC2qg==
"@types/normalize-package-data@^2.4.0": "@types/normalize-package-data@^2.4.0":
version "2.4.0" version "2.4.0"
resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.0.tgz#e486d0d97396d79beedd0a6e33f4534ff6b4973e" resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.0.tgz#e486d0d97396d79beedd0a6e33f4534ff6b4973e"
@ -2022,18 +2017,6 @@ abbrev@1:
resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.1.tgz#f8f2c887ad10bf67f634f005b6987fed3179aac8" resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.1.tgz#f8f2c887ad10bf67f634f005b6987fed3179aac8"
integrity sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q== integrity sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==
abort-controller@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/abort-controller/-/abort-controller-3.0.0.tgz#eaf54d53b62bae4138e809ca225c8439a6efb392"
integrity sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==
dependencies:
event-target-shim "^5.0.0"
abortcontroller-polyfill@^1.4.0:
version "1.5.0"
resolved "https://registry.yarnpkg.com/abortcontroller-polyfill/-/abortcontroller-polyfill-1.5.0.tgz#2c562f530869abbcf88d949a2b60d1d402e87a7c"
integrity sha512-O6Xk757Jb4o0LMzMOMdWvxpHWrQzruYBaUruFaIOfAQRnWFxfdXYobw12jrVHGtoXk6WiiyYzc0QWN9aL62HQA==
accepts@^1.3.5, accepts@~1.3.4, accepts@~1.3.5, accepts@~1.3.7: accepts@^1.3.5, accepts@~1.3.4, accepts@~1.3.5, accepts@~1.3.7:
version "1.3.7" version "1.3.7"
resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.7.tgz#531bc726517a3b2b41f850021c6cc15eaab507cd" resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.7.tgz#531bc726517a3b2b41f850021c6cc15eaab507cd"
@ -2101,17 +2084,6 @@ airbnb-prop-types@^2.15.0:
prop-types-exact "^1.2.0" prop-types-exact "^1.2.0"
react-is "^16.9.0" react-is "^16.9.0"
airtable@^0.10.0:
version "0.10.0"
resolved "https://registry.yarnpkg.com/airtable/-/airtable-0.10.0.tgz#29f7f5fb209b898b72238fe847142cf2a41210b2"
integrity sha512-6gBUG+z1kqvwyHYWlc+y74TfYpc18mvmNuVcefjlvd6MSgLP9Hk47ByyBS6Ke8zdSk6kBTDpdiwCjoJQUpu6yg==
dependencies:
"@types/node" "^14.0.14"
abort-controller "^3.0.0"
abortcontroller-polyfill "^1.4.0"
lodash "4.17.19"
node-fetch "^2.6.0"
ajv-errors@^1.0.0: ajv-errors@^1.0.0:
version "1.0.1" version "1.0.1"
resolved "https://registry.yarnpkg.com/ajv-errors/-/ajv-errors-1.0.1.tgz#f35986aceb91afadec4102fbd85014950cefa64d" resolved "https://registry.yarnpkg.com/ajv-errors/-/ajv-errors-1.0.1.tgz#f35986aceb91afadec4102fbd85014950cefa64d"
@ -2966,10 +2938,15 @@ 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.30001036, caniuse-lite@^1.0.30001038: caniuse-lite@^1.0.30001023:
version "1.0.30001300" version "1.0.30001023"
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001300.tgz" resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001023.tgz#b82155827f3f5009077bdd2df3d8968bcbcc6fc4"
integrity sha512-cVjiJHWGcNlJi8TZVKNMnvMid3Z3TTdDHmLDzlOdIiZq138Exvo0G+G0wTdVYolxKb4AYwC+38pxodiInVtJSA== integrity sha512-C5TDMiYG11EOhVOA62W1p3UsJ2z4DsHtMBQtjzp3ZsUglcQn62WOUgW0y795c7A5uZ+GCEIvzkMatLIlAsbNTA==
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"
@ -4428,11 +4405,6 @@ etag@~1.8.1:
resolved "https://registry.yarnpkg.com/etag/-/etag-1.8.1.tgz#41ae2eeb65efa62268aebfea83ac7d79299b0887" resolved "https://registry.yarnpkg.com/etag/-/etag-1.8.1.tgz#41ae2eeb65efa62268aebfea83ac7d79299b0887"
integrity sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc= integrity sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=
event-target-shim@^5.0.0:
version "5.0.1"
resolved "https://registry.yarnpkg.com/event-target-shim/-/event-target-shim-5.0.1.tgz#5d4d3ebdf9583d63a5333ce2deb7480ab2b05789"
integrity sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==
eventemitter3@4.0.0, eventemitter3@^4.0.0: eventemitter3@4.0.0, eventemitter3@^4.0.0:
version "4.0.0" version "4.0.0"
resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-4.0.0.tgz#d65176163887ee59f386d64c82610b696a4a74eb" resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-4.0.0.tgz#d65176163887ee59f386d64c82610b696a4a74eb"
@ -6845,11 +6817,6 @@ lodash.sortby@^4.7.0:
resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438" resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438"
integrity sha1-7dFMgk4sycHgsKG0K7UhBRakJDg= integrity sha1-7dFMgk4sycHgsKG0K7UhBRakJDg=
lodash@4.17.19:
version "4.17.19"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.19.tgz#e48ddedbe30b3321783c5b4301fbd353bc1e4a4b"
integrity sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==
lodash@^4.0.0, lodash@^4.15.0, lodash@^4.17.11, lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15, lodash@~4.17.10: lodash@^4.0.0, lodash@^4.15.0, lodash@^4.17.11, lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15, lodash@~4.17.10:
version "4.17.15" version "4.17.15"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548"
@ -7336,11 +7303,6 @@ node-fetch@^2.3.0:
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.0.tgz#e633456386d4aa55863f676a7ab0daa8fdecb0fd" resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.0.tgz#e633456386d4aa55863f676a7ab0daa8fdecb0fd"
integrity sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA== integrity sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA==
node-fetch@^2.6.0:
version "2.6.1"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.1.tgz#045bd323631f76ed2e2b55573394416b639a0052"
integrity sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==
node-forge@0.9.0: node-forge@0.9.0:
version "0.9.0" version "0.9.0"
resolved "https://registry.yarnpkg.com/node-forge/-/node-forge-0.9.0.tgz#d624050edbb44874adca12bb9a52ec63cb782579" resolved "https://registry.yarnpkg.com/node-forge/-/node-forge-0.9.0.tgz#d624050edbb44874adca12bb9a52ec63cb782579"