17 Commits

Author SHA1 Message Date
Sharon Kennedy
3107cf6904 1.2.0 2020-06-25 23:04:00 -04:00
Sharon Kennedy
0fcb7e6e07 build and add profiler 2020-06-25 23:03:22 -04:00
Sharon Kennedy
c80e3269c3 configurable max wait time 2020-06-25 22:20:54 -04:00
Sharon Kennedy
5ed83271d9 configurable size and position of chatbox 2020-06-25 21:56:55 -04:00
Sharon Kennedy
706791cc38 1.1.1 2020-06-11 23:09:23 -04:00
Sharon Kennedy
181a4da221 generic chat unavailable message 2020-06-11 23:08:38 -04:00
Sharon Kennedy
46868b141a 1.1.0 2020-06-11 23:03:05 -04:00
Sharon Kennedy
247bc3e2ba 1.1.1 2020-06-11 23:02:14 -04:00
Sharon Kennedy
29b86e4190 1.1.0 2020-06-11 23:02:03 -04:00
Sharon Kennedy
716f61b183 1.1.1 2020-06-11 23:01:43 -04:00
Sharon Kennedy
516a1e0fbd encrypt by default 2020-06-11 22:59:42 -04:00
Sharon Kennedy
80ecf98be1 1.1.0 2020-06-11 11:01:52 -04:00
Sharon Kennedy
f0b43743f7 add flag to disable encryption 2020-06-11 08:31:46 -04:00
Sharon Kennedy
5252321f56 store messages in object instead of array 2020-06-11 01:54:05 -04:00
Sharon Kennedy
93135daaa8 close chat connection if chat is offline 2020-06-10 17:49:19 -04:00
Sharon Kennedy
f27ebb3c71 move offline messaging to chatbox instead of bot 2020-06-10 16:59:50 -04:00
Sharon Kennedy
7d5ad29b60 use rhok server for demo 2020-05-27 22:22:16 -04:00
11 changed files with 16152 additions and 114 deletions

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

7
dist/index.html vendored
View File

@@ -13,8 +13,8 @@
<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:safesupport.chat', 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.",
@@ -23,6 +23,9 @@
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',
position: 'bottom right',
size: 'large',
maxWaitTime: 6000*3,
} }
EmbeddableChatbox.mount(config); EmbeddableChatbox.mount(config);

15900
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,10 +1,11 @@
{ {
"name": "private-safesupport-chatbox", "name": "private-safesupport-chatbox",
"version": "1.0.2", "version": "1.2.0",
"description": "A secure and private embeddable chatbox that connects to Riot", "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",
"build:profile": "webpack --mode production --config webpack.config.profile.js",
"start": "webpack-dev-server", "start": "webpack-dev-server",
"test": "jest", "test": "jest",
"test-update-snapshots": "jest --updateSnapshot", "test-update-snapshots": "jest --updateSnapshot",
@@ -121,7 +122,7 @@
"style-loader": "1.1.2", "style-loader": "1.1.2",
"wait-for-expect": "^3.0.2", "wait-for-expect": "^3.0.2",
"webpack": "4.41.5", "webpack": "4.41.5",
"webpack-bundle-analyzer": "^3.7.0", "webpack-bundle-analyzer": "^3.8.0",
"webpack-cli": "3.3.10", "webpack-cli": "3.3.10",
"webpack-dev-server": "3.10.1", "webpack-dev-server": "3.10.1",
"webpack-obfuscator": "0.22.0", "webpack-obfuscator": "0.22.0",

View File

@@ -13,8 +13,8 @@
<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:safesupport.chat', 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.",
@@ -23,6 +23,9 @@
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',
position: 'bottom right',
size: 'large',
maxWaitTime: 6000*3,
} }
EmbeddableChatbox.mount(config); EmbeddableChatbox.mount(config);

View File

@@ -26,14 +26,56 @@
} }
} }
@keyframes slideInDown {
from {
transform: translate3d(0, -100%, 0);
display: inherit;
visibility: visible;
}
to {
transform: translate3d(0, 0, 0);
}
}
@keyframes slideOutUp {
from {
transform: translate3d(0, 0, 0);
}
to {
display: none;
visibility: hidden;
transform: translate3d(0, -100%, 0);
}
}
.docked-widget { .docked-widget {
position: fixed; position: fixed;
bottom: 10px;
right: 10px;
z-index: 9999; z-index: 9999;
width: 400px;
max-width: 100vw; max-width: 100vw;
font-size: $base-font-size; font-size: $base-font-size;
&.size-large {
width: 400px;
.dock {
width: 400px;
}
}
&.size-small {
#open-chatbox-label {
display: flex;
align-items: center;
.icon {
margin-left: 0.5em;
font-size: 1.2em;
}
}
}
} }
.dock { .dock {
@@ -41,7 +83,6 @@
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
width: 400px;
max-width: calc(100vw - 10px); max-width: calc(100vw - 10px);
color: $white; color: $white;
font-family: $theme-font; font-family: $theme-font;
@@ -53,6 +94,7 @@
background-color: transparent; background-color: transparent;
padding: 5px; padding: 5px;
#open-chatbox-label { #open-chatbox-label {
background: $theme-color; background: $theme-color;
padding: 0.75em; padding: 0.75em;
@@ -105,6 +147,10 @@
&-entering { &-entering {
animation-name: slideInUp; animation-name: slideInUp;
&.position-top {
animation-name: slideInDown;
}
} }
&-entered { &-entered {
display: inherit; display: inherit;
@@ -112,6 +158,10 @@
} }
&-exiting { &-exiting {
animation-name: slideOutDown; animation-name: slideOutDown;
&.position-top {
animation-name: slideOutUp;
}
} }
&-exited { &-exited {
display: none; display: none;

View File

@@ -24,8 +24,7 @@ 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 WAIT_TIME_MS = 120000 // 2 minutes const CHAT_IS_OFFLINE_NOTICE = "CHAT_OFFLINE"
const CHAT_IS_OFFLINE_NOTICE = "Chat is offline"
const DEFAULT_MATRIX_SERVER = "https://matrix.rhok.space/" const DEFAULT_MATRIX_SERVER = "https://matrix.rhok.space/"
const DEFAULT_BOT_ID = "@help-bot:rhok.space" const DEFAULT_BOT_ID = "@help-bot:rhok.space"
@@ -37,7 +36,13 @@ 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_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_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_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 {
@@ -52,7 +57,7 @@ class ChatBox extends React.Component {
userId: null, userId: null,
password: null, password: null,
localStorage: null, localStorage: null,
messages: [], messages: {},
inputValue: "", inputValue: "",
errors: [], errors: [],
roomId: null, roomId: null,
@@ -144,9 +149,8 @@ class ChatBox extends React.Component {
} }
} }
exitChat = async () => { exitChat = async (resetState=true) => {
if (!this.state.client) return null; if (this.state.client) {
await this.state.client.leave(this.state.roomId) await this.state.client.leave(this.state.roomId)
const auth = { const auth = {
@@ -162,10 +166,15 @@ class ChatBox extends React.Component {
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()
this.setState({ client: null })
}
this.state.localStorage.clear() this.state.localStorage.clear()
if (resetState) {
this.setState(this.initialState) this.setState(this.initialState)
} }
}
createLocalStorage = async (deviceId, sessionId) => { createLocalStorage = async (deviceId, sessionId) => {
let localStorage = global.localStorage; let localStorage = global.localStorage;
@@ -232,14 +241,14 @@ class ChatBox extends React.Component {
try { try {
await client.initCrypto() await client.initCrypto()
} catch(err) { } catch(err) {
return this.initializeUnencryptedChat() return this.restartWithoutCrypto()
} }
await client.startClient() await client.startClient()
await this.createRoom(client) await this.createRoom(client)
} }
initializeUnencryptedChat = async () => { restartWithoutCrypto = async () => {
if (this.state.client) { if (this.state.client) {
this.state.client.leave(this.state.roomId) this.state.client.leave(this.state.roomId)
this.state.client.stopClient() this.state.client.stopClient()
@@ -282,7 +291,21 @@ class ChatBox extends React.Component {
console.log("error", err) console.log("error", err)
this.handleInitError(err) this.handleInitError(err)
} }
}
initializeUnencryptedChat = async () => {
this.setState({ ready: false })
const client = await this.createClientWithAccount()
this.setState({
client: client
})
client.setDisplayName(this.props.anonymousDisplayName)
this.setMatrixListeners(client)
await client.startClient()
await this.createRoom(client)
} }
handleInitError = (err) => { handleInitError = (err) => {
@@ -292,17 +315,8 @@ class ChatBox extends React.Component {
} }
handleDecryptionError = async (event, err) => { handleDecryptionError = async (event, err) => {
if (this.state.client) {
const isCryptoEnabled = await this.state.client.isCryptoEnabled()
const isRoomEncrypted = this.state.client.isRoomEncrypted(this.state.roomId)
if (!isCryptoEnabled || !isRoomEncrypted) {
return this.initializeUnencryptedChat()
}
}
const eventId = event.getId() const eventId = event.getId()
this.displayFakeMessage({ body: '** Unable to decrypt message **' }, event.getSender(), eventId) this.handleMessageEvent(event)
this.setState({ decryptionErrors: { [eventId]: true }}) this.setState({ decryptionErrors: { [eventId]: true }})
} }
@@ -376,31 +390,39 @@ class ChatBox extends React.Component {
} }
displayFakeMessage = (content, sender, messageId=uuid()) => { displayFakeMessage = (content, sender, messageId=uuid()) => {
const msgList = [...this.state.messages]
const msg = { const msg = {
id: messageId, id: messageId,
type: 'm.room.message', type: 'm.room.message',
sender: sender, sender: sender,
roomId: this.state.roomId, roomId: this.state.roomId,
content: content, content: content,
} timestamp: Date.now(),
msgList.push(msg)
this.setState({ messages: msgList })
} }
displayBotMessage = (content, roomId) => { this.setState({
const msgList = [...this.state.messages] messages: {
...this.state.messages,
[messageId]: msg
}
})
}
displayBotMessage = (content, roomId, messageId=uuid()) => {
const msg = { const msg = {
id: uuid(), id: messageId,
type: 'm.room.message', type: 'm.room.message',
sender: this.props.botId, sender: this.props.botId,
roomId: roomId || this.state.roomId, roomId: roomId || this.state.roomId,
content: content, content: content,
timestamp: Date.now(),
} }
msgList.push(msg)
this.setState({ messages: msgList }) this.setState({
messages: {
...this.state.messages,
[messageId]: msg
}
})
} }
handleMessageEvent = event => { handleMessageEvent = event => {
@@ -410,8 +432,12 @@ class ChatBox extends React.Component {
sender: event.getSender(), sender: event.getSender(),
roomId: event.getRoomId(), roomId: event.getRoomId(),
content: event.getContent(), content: event.getContent(),
timestamp: event.getTs(),
} }
// there's also event.getClearContent() which only works on encrypted messages
// but not really sure when it should be used vs event.getContent()
if (message.content.showToUser && message.content.showToUser !== this.state.userId) { if (message.content.showToUser && message.content.showToUser !== this.state.userId) {
return; return;
} }
@@ -427,22 +453,42 @@ class ChatBox extends React.Component {
this.setState({ messagesInFlight }) this.setState({ messagesInFlight })
} }
// check for decryption error message and replace with decrypted message
// or push message to messages array
const messages = [...this.state.messages]
const decryptionErrors = {...this.state.decryptionErrors} const decryptionErrors = {...this.state.decryptionErrors}
delete decryptionErrors[message.id] delete decryptionErrors[message.id]
const existingMessageIndex = messages.findIndex(({ id }) => id === message.id)
if (existingMessageIndex > -1) { const isOfflineNotice = message.content.msgtype === "m.notice" && message.content.body === CHAT_IS_OFFLINE_NOTICE
messages.splice(existingMessageIndex, 1, message)
} else { let newMessage = message
messages.push(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({ messages, decryptionErrors }) this.setState({
messages: {
...this.state.messages,
[message.id]: newMessage,
},
decryptionErrors
})
} }
handleChatOffline = () => {
this.exitChat(false) // close the chat connection but keep chatbox state
window.clearInterval(this.state.waitIntervalId) // no more waiting messages
window.clearInterval(this.state.waitTimeoutId) // no more waiting messages
this.setState({ ready: true }) // no more loading animation
}
handleKeyDown = (e) => { handleKeyDown = (e) => {
switch (e.keyCode) { switch (e.keyCode) {
@@ -482,7 +528,8 @@ class ChatBox extends React.Component {
if (eventType === "m.room.member" && content.membership === "join" && sender !== this.props.botId && sender !== this.state.userId) { if (eventType === "m.room.member" && content.membership === "join" && sender !== this.props.botId && sender !== this.state.userId) {
this.verifyAllRoomDevices(client, room) this.verifyAllRoomDevices(client, room)
this.setState({ facilitatorId: sender, ready: true }) this.setState({ facilitatorId: sender, ready: true })
window.clearInterval(this.state.timeoutId) window.clearInterval(this.state.waitIntervalId)
window.clearInterval(this.state.waitTimeoutId)
} }
}); });
@@ -492,12 +539,6 @@ class ChatBox extends React.Component {
return this.handleDecryptionError(event, err) return this.handleDecryptionError(event, err)
} }
if (event.getType() === "m.room.message") { if (event.getType() === "m.room.message") {
const content = event.getContent()
if (content.msgtype === "m.notice" && content.body === CHAT_IS_OFFLINE_NOTICE) {
this.setState({ ready: true })
return window.clearInterval(this.state.timeoutId)
}
this.handleMessageEvent(event) this.handleMessageEvent(event)
} }
}); });
@@ -513,7 +554,7 @@ class ChatBox extends React.Component {
} }
componentDidUpdate(prevProps, prevState) { componentDidUpdate(prevProps, prevState) {
if (prevState.messages.length !== this.state.messages.length) { if ((prevState.messages !== this.state.messages) || (prevState.messagesInFlight !== this.state.messagesInFlight) || (prevState.typingStatus !== this.state.typingStatus)) {
if (this.messageWindow.current.scrollTo) { if (this.messageWindow.current.scrollTo) {
this.messageWindow.current.scrollTo(0, this.messageWindow.current.scrollHeight) this.messageWindow.current.scrollTo(0, this.messageWindow.current.scrollHeight)
} }
@@ -549,20 +590,31 @@ class ChatBox extends React.Component {
this.setState({ awaitingAgreement: false }) this.setState({ awaitingAgreement: false })
this.startWaitTimeForFacilitator() this.startWaitTimeForFacilitator()
try { try {
if (this.props.isEncryptionDisabled) {
this.initializeUnencryptedChat()
} else {
this.initializeChat() this.initializeChat()
}
} catch(err) { } catch(err) {
this.handleInitError(err) this.handleInitError(err)
} }
} }
startWaitTimeForFacilitator = () => { startWaitTimeForFacilitator = () => {
const timeoutId = window.setInterval(() => { const waitIntervalId = window.setInterval(() => {
if (!this.state.facilitatorId) { if (!this.state.facilitatorId && !this.state.ready) {
this.displayBotMessage({ body: this.props.waitMessage }) this.displayBotMessage({ body: this.props.waitMessage })
} }
}, WAIT_TIME_MS) }, this.props.waitInterval)
this.setState({ timeoutId }) const waitTimeoutId = window.setTimeout(() => {
if (!this.state.facilitatorId && !this.state.ready) {
this.displayBotMessage({ body: this.props.chatUnavailableMessage })
this.handleChatOffline()
}
}, this.props.maxWaitTime)
this.setState({ waitIntervalId, waitTimeoutId })
} }
handleRejectTerms = () => { handleRejectTerms = () => {
@@ -575,7 +627,7 @@ class ChatBox extends React.Component {
const message = this.state.inputValue const message = this.state.inputValue
if (!Boolean(message)) return null; if (!Boolean(message)) return null;
if (this.state.isCryptoEnabled && !(this.state.client.isRoomEncrypted(this.state.roomId) && this.state.client.isCryptoEnabled())) return null; if (this.state.isCryptoEnabled && this.state.client && !(this.state.client.isRoomEncrypted(this.state.roomId) && this.state.client.isCryptoEnabled())) return null;
if (this.state.client && this.state.roomId) { if (this.state.client && this.state.roomId) {
const messagesInFlight = [...this.state.messagesInFlight] const messagesInFlight = [...this.state.messagesInFlight]
@@ -596,15 +648,17 @@ class ChatBox extends React.Component {
render() { render() {
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 inputLabel = 'Send a message...' const inputLabel = 'Send a message...'
const [positionY, positionX] = this.props.position.split(' ')
return ( return (
<div id="safesupport"> <div id="safesupport">
<div className="docked-widget" role="complementary"> <div className={`docked-widget size-${this.props.size}`} role="complementary" style={{ [positionY]: '10px', [positionX]: '10px' }}>
<Transition in={opened} timeout={250} onExited={this.handleWidgetExit} onEntered={this.handleWidgetEnter}> <Transition in={opened} timeout={250} onExited={this.handleWidgetExit} onEntered={this.handleWidgetEnter}>
{(status) => { {(status) => {
return ( return (
<div className={`widget widget-${status}`} aria-hidden={!opened}> <div className={`widget widget-${status} position-${positionY}`} aria-hidden={!opened}>
<div id="safesupport-chatbox" aria-haspopup="dialog"> <div id="safesupport-chatbox" aria-haspopup="dialog">
<Header handleToggleOpen={this.handleToggleOpen} opened={opened} handleExitChat={this.handleExitChat} /> <Header handleToggleOpen={this.handleToggleOpen} opened={opened} handleExitChat={this.handleExitChat} />
@@ -631,7 +685,7 @@ class ChatBox extends React.Component {
</div> </div>
{ {
messages.map((message, index) => { orderedMessages.map((message, index) => {
return( return(
<Message key={message.id} message={message} userId={userId} botId={this.props.botId} client={this.state.client} /> <Message key={message.id} message={message} userId={userId} botId={this.props.botId} client={this.state.client} />
) )
@@ -656,7 +710,7 @@ class ChatBox extends React.Component {
<div className={`message from-bot`}> <div className={`message from-bot`}>
<div className="text buttons"> <div className="text buttons">
{`Restart chat without encryption?`} {`Restart chat without encryption?`}
<button className="btn" id="accept" onClick={this.initializeUnencryptedChat}>RESTART</button> <button className="btn" id="accept" onClick={this.restartWithoutCrypto}>RESTART</button>
</div> </div>
</div> </div>
} }
@@ -695,7 +749,7 @@ class ChatBox extends React.Component {
)} )}
} }
</Transition> </Transition>
{showDock && !roomId && <Dock handleToggleOpen={this.handleToggleOpen} />} {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>
@@ -715,6 +769,12 @@ ChatBox.propTypes = {
chatUnavailableMessage: PropTypes.string, chatUnavailableMessage: PropTypes.string,
anonymousDisplayName: PropTypes.string, anonymousDisplayName: PropTypes.string,
waitMessage: PropTypes.string, waitMessage: PropTypes.string,
chatOfflineMessage: PropTypes.string,
isEncryptionDisabled: PropTypes.bool,
position: PropTypes.oneOf(['top left', 'top right', 'bottom left', 'bottom right']),
size: PropTypes.oneOf(['small', 'large']),
maxWaitTime: PropTypes.number,
waitInterval: PropTypes.number,
} }
ChatBox.defaultProps = { ChatBox.defaultProps = {
@@ -729,6 +789,12 @@ 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,
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

@@ -1,8 +1,7 @@
import React from "react" import React, { Fragment } from "react"
import PropTypes from "prop-types" import PropTypes from "prop-types"
const Dock = ({ handleToggleOpen }) => { const Dock = ({ handleToggleOpen, size }) => {
return( return(
<button <button
type="button" type="button"
@@ -11,10 +10,19 @@ const Dock = ({ handleToggleOpen }) => {
onKeyPress={handleToggleOpen} onKeyPress={handleToggleOpen}
aria-labelledby="open-chatbox-label" aria-labelledby="open-chatbox-label"
> >
{
size === 'small' ?
<div id="open-chatbox-label">
<span>Chat</span><span className="icon">+</span>
</div>
:
<Fragment>
<div id="open-chatbox-label">Start a new chat</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>
</Fragment>
}
</button> </button>
) )
} }

View File

@@ -1,17 +1,17 @@
import EmbeddableChatbox from './embeddable-chatbox'; import EmbeddableChatbox from './embeddable-chatbox';
const config = { const config = {
matrixServerUrl: 'https://matrix.safesupport.chat', matrixServerUrl: 'https://matrix.rhok.space',
botId: '@help-bot:safesupport.chat', 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.',
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',
} };
export default function bookmarklet() { export default function bookmarklet() {
if (window.EmbeddableChatbox) { if (window.EmbeddableChatbox) {

View File

@@ -0,0 +1,7 @@
const config = require('./webpack.config');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
config[0].plugins = config[0].plugins.concat([new BundleAnalyzerPlugin({ analyzerPort: 5555 })]);
module.exports = config;