2
0

configuration.rst 22 KB

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