configuration.rst 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562
  1. =============
  2. Configuration
  3. =============
  4. .. contents:: Table of Contents
  5. :depth: 2
  6. :local:
  7. The included minified JS and CSS files can be used for demoing or testing, but
  8. you'll want to configure *Converse.js* to suit your needs before you deploy it
  9. on your website.
  10. *Converse.js* is passed its configuration settings when you call its *initialize* method.
  11. You'll most likely want to call the *initialize* method in your HTML page. For
  12. an example of how this is done, please see the bottom of the *./index.html* page.
  13. Please refer to the `Configuration variables`_ section below for info on
  14. all the available configuration settings.
  15. After you have configured *Converse.js*, you'll have to regenerate the minified
  16. JS file so that it will include the new settings. Please refer to the
  17. :ref:`minification` section for more info on how to do this.
  18. .. _`configuration-variables`:
  19. Configuration variables
  20. =======================
  21. allow_contact_requests
  22. ----------------------
  23. Default: ``true``
  24. Allow users to add one another as contacts. If this is set to false, the
  25. **Add a contact** widget, **Contact Requests** and **Pending Contacts** roster
  26. sections will all not appear. Additionally, all incoming contact requests will be
  27. ignored.
  28. allow_muc
  29. ---------
  30. Default: ``true``
  31. Allow multi-user chat (muc) in chatrooms. Setting this to ``false`` will remove
  32. the ``Chatrooms`` tab from the control box.
  33. allow_otr
  34. ---------
  35. Default: ``true``
  36. Allow Off-the-record encryption of single-user chat messages.
  37. allow_registration
  38. ------------------
  39. Default: ``true``
  40. Support for `XEP-0077: In band registration <http://xmpp.org/extensions/xep-0077.html>`_
  41. Allow XMPP account registration showing the corresponding UI register form interface.
  42. animate
  43. -------
  44. Default: ``true``
  45. Show animations, for example when opening and closing chat boxes.
  46. auto_list_rooms
  47. ---------------
  48. Default: ``false``
  49. If true, and the XMPP server on which the current user is logged in supports
  50. multi-user chat, then a list of rooms on that server will be fetched.
  51. Not recommended for servers with lots of chat rooms.
  52. For each room on the server a query is made to fetch further details (e.g.
  53. features, number of occupants etc.), so on servers with many rooms this
  54. option will create lots of extra connection traffic.
  55. auto_reconnect
  56. --------------
  57. Default: ``true``
  58. Automatically reconnect to the XMPP server if the connection drops
  59. unexpectedly.
  60. auto_subscribe
  61. --------------
  62. Default: ``false``
  63. If true, the user will automatically subscribe back to any contact requests.
  64. .. _`bosh-service-url`:
  65. bosh_service_url
  66. ----------------
  67. Default: ``undefined``
  68. To connect to an XMPP server over HTTP you need a `BOSH <https://en.wikipedia.org/wiki/BOSH>`_
  69. connection manager which acts as a middle man between the HTTP and XMPP
  70. protocols.
  71. The bosh_service_url setting takes the URL of a BOSH connection manager.
  72. Please refer to your XMPP server's documentation on how to enable BOSH.
  73. For more information, read this blog post: `Which BOSH server do you need? <http://metajack.im/2008/09/08/which-bosh-server-do-you-need>`_
  74. A more modern alternative to BOSH is to use `websockets <https://developer.mozilla.org/en/docs/WebSockets>`_.
  75. Please see the :ref:`websocket-url` configuration setting.
  76. cache_otr_key
  77. -------------
  78. Default: ``false``
  79. Let the `OTR (Off-the-record encryption) <https://otr.cypherpunks.ca>`_ private
  80. key be cached in your browser's session storage.
  81. The browser's session storage persists across page loads but is deleted once
  82. the tab or window is closed.
  83. If this option is set to ``false``, a new OTR private key will be generated
  84. for each page load. While more inconvenient, this is a much more secure option.
  85. This setting can only be used together with ``allow_otr = true``.
  86. .. note::
  87. A browser window's session storage is accessible by all javascript that
  88. is served from the same domain. So if there is malicious javascript served by
  89. the same server (or somehow injected via an attacker), then they will be able
  90. to retrieve your private key and read your all the chat messages in your
  91. current session. Previous sessions however cannot be decrypted.
  92. debug
  93. -----
  94. Default: ``false``
  95. If set to true, debugging output will be logged to the browser console.
  96. domain_placeholder
  97. ------------------
  98. Default: ``e.g. conversejs.org``
  99. The placeholder text shown in the domain input on the registration form.
  100. .. _`keepalive`:
  101. keepalive
  102. ---------
  103. Default: ``true``
  104. Determines whether Converse.js will maintain the chat session across page
  105. loads.
  106. See also:
  107. * :ref:`session-support`
  108. * `Using prebind in connection with keepalive`_
  109. .. note::
  110. Currently the "keepalive" setting only works with BOSH and not with
  111. websockets. This is because XMPP over websocket does not use the same
  112. session token as with BOSH. A possible solution for this is to implement
  113. `XEP-0198 <http://xmpp.org/extensions/xep-0198.html>`_, specifically
  114. with regards to "stream resumption".
  115. message_carbons
  116. ---------------
  117. Default: ``false``
  118. Support for `XEP-0280: Message Carbons <https://xmpp.org/extensions/xep-0280.html>`_
  119. In order to keep all IM clients for a user engaged in a conversation,
  120. outbound messages are carbon-copied to all interested resources.
  121. This is especially important in webchat, like converse.js, where each browser
  122. tab serves as a separate IM client.
  123. Both message_carbons and `forward_messages`_ try to solve the same problem
  124. (showing sent messages in all connected chat clients aka resources), but go about it
  125. in two different ways.
  126. Message carbons is the XEP (Jabber protocol extension) specifically drafted to
  127. solve this problem, while `forward_messages`_ uses
  128. `stanza forwarding <http://www.xmpp.org/extensions/xep-0297.html>`_
  129. expose_rid_and_sid
  130. ------------------
  131. Default: ``false``
  132. Allow the prebind tokens, RID (request ID) and SID (session ID), to be exposed
  133. globally via the API. This allows other scripts served on the same page to use
  134. these values.
  135. *Beware*: a malicious script could use these tokens to assume your identity
  136. and inject fake chat messages.
  137. forward_messages
  138. ----------------
  139. Default: ``false``
  140. If set to ``true``, sent messages will also be forwarded to the sending user's
  141. bare JID (their Jabber ID independent of any chat clients aka resources).
  142. This means that sent messages are visible from all the user's chat clients,
  143. and not just the one from which it was actually sent.
  144. This is especially important for web chat, such as converse.js, where each
  145. browser tab functions as a separate chat client, with its own resource.
  146. This feature uses Stanza forwarding, see also `XEP 0297: Stanza Forwarding <http://www.xmpp.org/extensions/xep-0297.html>`_
  147. For an alternative approach, see also `message_carbons`_.
  148. fullname
  149. --------
  150. If you are using prebinding, can specify the fullname of the currently
  151. logged in user, otherwise the user's vCard will be fetched.
  152. hide_muc_server
  153. ---------------
  154. Default: ``false``
  155. Hide the ``server`` input field of the form inside the ``Room`` panel of the
  156. controlbox. Useful if you want to restrict users to a specific XMPP server of
  157. your choosing.
  158. hide_offline_users
  159. ------------------
  160. Default: ``false``
  161. If set to ``true``, then don't show offline users.
  162. i18n
  163. ----
  164. Specify the locale/language. The language must be in the ``locales`` object. Refer to
  165. ``./locale/locales.js`` to see which locales are supported.
  166. .. _`play-sounds`:
  167. play_sounds
  168. -----------
  169. Default: ``false``
  170. Plays a notification sound when you receive a personal message or when your
  171. nickname is mentioned in a chat room.
  172. Inside the ``./sounds`` directory of the Converse.js repo, you'll see MP3 and Ogg
  173. formatted sound files. We need both, because neither format is supported by all browsers.
  174. For now, sound files are looked up by convention, not configuration. So to have
  175. a sound play when a message is received, make sure that your webserver serves
  176. it in both formats as ``http://yoursite.com/sounds/msg_received.mp3`` and
  177. ``http://yoursite.com/sounds/msg_received.ogg``.
  178. ``http://yoursite.com`` should of course be your site's URL.
  179. .. _`prebind`:
  180. prebind
  181. --------
  182. Default: ``false``
  183. See also: :ref:`session-support`
  184. Use this option when you want to attach to an existing XMPP connection that was
  185. already authenticated (usually on the backend before page load).
  186. This is useful when you don't want to render the login form on the chat control
  187. box with each page load.
  188. For prebinding to work, you must set up a pre-authenticated BOSH session,
  189. for which you will receive a JID (jabber ID), SID (session ID) and RID
  190. (Request ID).
  191. These values (``rid``, ``sid`` and ``jid``) need to be passed into
  192. ``converse.initialize`` (with the exception of ``keepalive``, see below).
  193. Additionally, you also have to specify a ``bosh_service_url``.
  194. Using prebind in connection with keepalive
  195. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  196. The ``prebind`` and `keepalive`_ options can be used together.
  197. The ``keepalive`` option caches the ``rid``, ``sid`` and ``jid`` values
  198. (henceforth referred to as *session tokens*) one receives from a prebinded
  199. BOSH session, in order to re-use them when the page reloads.
  200. However, if besides setting ``keepalive`` to ``true``, you also set ``prebind``
  201. to ``true``, and you pass in valid session tokens to ``converse.initialize``,
  202. then those passed in session tokens will be used instead of any tokens cached by
  203. ``keepalive``.
  204. If you set ``prebind`` to ``true`` and don't pass in the session tokens to
  205. ``converse.initialize``, then converse.js will look for tokens cached by
  206. ``keepalive``.
  207. If you've set ``keepalive`` and ``prebind`` to ``true``, don't pass in session
  208. tokens and converse.js doesn't find any cached session tokens, then
  209. converse.js will emit an event ``noResumeableSession`` and exit.
  210. This allows you to start a prebinded session with valid tokens, and then fall
  211. back to ``keepalive`` for maintaining that session across page reloads. When
  212. for some reason ``keepalive`` doesn't have cached session tokens anymore, you
  213. can listen for the ``noResumeableSession`` event and take that as a cue that
  214. you should again prebind in order to get valid session tokens.
  215. Here is a code example:
  216. .. code-block:: javascript
  217. converse.on('noResumeableSession', function () {
  218. $.getJSON('/prebind', function (data) {
  219. converse.initialize({
  220. prebind: true,
  221. keepalive: true,
  222. bosh_service_url: 'https://bind.example.com',
  223. jid: data.jid,
  224. sid: data.sid,
  225. rid: data.rid
  226. });
  227. });
  228. });
  229. converse.initialize({
  230. prebind: true,
  231. keepalive: true,
  232. bosh_service_url: 'https://bind.example.com'
  233. }));
  234. providers_link
  235. --------------
  236. Default: ``https://xmpp.net/directory.php``
  237. The hyperlink on the registration form which points to a directory of public
  238. XMPP servers.
  239. roster_groups
  240. -------------
  241. Default: ``false``
  242. If set to ``true``, converse.js will show any roster groups you might have
  243. configured.
  244. .. note::
  245. It's currently not possible to use converse.js to assign contacts to groups.
  246. Converse.js can only show users and groups that were previously configured
  247. elsewhere.
  248. show_controlbox_by_default
  249. --------------------------
  250. Default: ``false``
  251. The "controlbox" refers to the special chatbox containing your contacts roster,
  252. status widget, chatrooms and other controls.
  253. By default this box is hidden and can be toggled by clicking on any element in
  254. the page with class *toggle-controlbox*.
  255. If this options is set to true, the controlbox will by default be shown upon
  256. page load.
  257. show_only_online_users
  258. ----------------------
  259. Default: ``false``
  260. If set to ``true``, only online users will be shown in the contacts roster.
  261. Users with any other status (e.g. away, busy etc.) will not be shown.
  262. storage
  263. -------
  264. Default: ``session``
  265. Valid options: ``session``, ``local``.
  266. This option determines the type of `storage <https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Storage>`_
  267. (``localStorage`` or ``sessionStorage``) used by converse.js to cache user data.
  268. Originally converse.js used only localStorage, however sessionStorage is from a
  269. privacy perspective a better choice.
  270. The main difference between the two is that sessionStorage only persists while
  271. the current tab or window containing a converse.js instance is open. As soon as
  272. it's closed, the data is cleared.
  273. Data in localStorage on the other hand is kept indefinitely.
  274. .. note::
  275. Since version 0.8.0, the use of local storage is not recommended. The
  276. statuses (online, away, busy etc.) of your roster contacts are cached in
  277. the browser storage. If you use local storage, these values are stored for
  278. multiple sessions, and they will likely become out of sync with your contacts'
  279. actual statuses. The session storage doesn't have this problem, because
  280. roster contact statuses will not become out of sync in a single session,
  281. only across more than one session.
  282. use_otr_by_default
  283. ------------------
  284. Default: ``false``
  285. If set to ``true``, Converse.js will automatically try to initiate an OTR (off-the-record)
  286. encrypted chat session every time you open a chat box.
  287. use_vcards
  288. ----------
  289. Default: ``true``
  290. Determines whether the XMPP server will be queried for roster contacts' VCards
  291. or not. VCards contain extra personal information such as your fullname and
  292. avatar image.
  293. visible_toolbar_buttons
  294. -----------------------
  295. Default:
  296. .. code-block:: javascript
  297. {
  298. call: false,
  299. clear: true,
  300. emoticons: true,
  301. toggle_participants: true
  302. }
  303. Allows you to show or hide buttons on the chat boxes' toolbars.
  304. * *call*:
  305. Provides a button with a picture of a telephone on it.
  306. When the call button is pressed, it will emit an event that can be used by a third-party library to initiate a call.::
  307. converse.on('callButtonClicked', function(event, data) {
  308. console.log('Strophe connection is', data.connection);
  309. console.log('Bare buddy JID is', data.model.get('jid'));
  310. // ... Third-party library code ...
  311. });
  312. * *clear*:
  313. Provides a button for clearing messages from a chat box.
  314. * *emoticons*:
  315. Enables rendering of emoticons and provides a toolbar button for choosing them.
  316. * toggle_participants:
  317. Shows a button for toggling (i.e. showing/hiding) the list of participants in a chat room.
  318. .. _`websocket-url`:
  319. websocket_url
  320. -------------
  321. Default: ``undefined``
  322. This option is used to specify a
  323. `websocket <https://developer.mozilla.org/en/docs/WebSockets>`_ URI to which
  324. converse.js can connect to.
  325. Websockets provide a more modern and effective two-way communication protocol
  326. between the browser and a server, effectively emulating TCP at the application
  327. layer and therefore overcoming many of the problems with existing long-polling
  328. techniques for bidirectional HTTP (such as `BOSH <https://en.wikipedia.org/wiki/BOSH>`_).
  329. Please refer to your XMPP server's documentation on how to enable websocket
  330. support.
  331. .. note::
  332. Please note that not older browsers do not support websockets. For older
  333. browsers you'll want to specify a BOSH URL. See the :ref:`bosh-service-url`
  334. configuration setting).
  335. .. note::
  336. Converse.js does not yet support "keepalive" with websockets.
  337. xhr_custom_status
  338. -----------------
  339. Default: ``false``
  340. .. note::
  341. XHR stands for XMLHTTPRequest, and is meant here in the AJAX sense (Asynchronous Javascript and XML).
  342. This option will let converse.js make an AJAX POST with your changed custom chat status to a
  343. remote server.
  344. xhr_custom_status_url
  345. ---------------------
  346. .. note::
  347. XHR stands for XMLHTTPRequest, and is meant here in the AJAX sense (Asynchronous Javascript and XML).
  348. Default: Empty string
  349. Used only in conjunction with ``xhr_custom_status``.
  350. This is the URL to which the AJAX POST request to set the user's custom status
  351. message will be made.
  352. The message itself is sent in the request under the key ``msg``.
  353. xhr_user_search
  354. ---------------
  355. Default: ``false``
  356. .. note::
  357. XHR stands for XMLHTTPRequest, and is meant here in the AJAX sense (Asynchronous Javascript and XML).
  358. There are two ways to add users.
  359. * The user inputs a valid JID (Jabber ID), and the user is added as a pending contact.
  360. * The user inputs some text (for example part of a firstname or lastname), an XHR (Ajax Request) will be made to a remote server, and a list of matches are returned. The user can then choose one of the matches to add as a contact.
  361. This setting enables the second mechanism, otherwise by default the first will be used.
  362. *What is expected from the remote server?*
  363. A default JSON encoded list of objects must be returned. Each object
  364. corresponds to a matched user and needs the keys ``id`` and ``fullname``.
  365. xhr_user_search_url
  366. -------------------
  367. .. note::
  368. XHR stands for XMLHTTPRequest, and is meant here in the AJAX sense (Asynchronous Javascript and XML).
  369. Default: Empty string
  370. Used only in conjunction with ``xhr_user_search``.
  371. This is the URL to which an AJAX GET request will be made to fetch user data from your remote server.
  372. The query string will be included in the request with ``q`` as its key.
  373. The calendar can be configured through a `data-pat-calendar` attribute.
  374. The available options are: