configuration.rst 18 KB

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