2
0

configuration.rst 17 KB

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