Members
(constant) ElementType
DOM element types.
- ElementType.NORMAL - Normal element.
- ElementType.TEXT - Text data element.
- ElementType.FRAGMENT - XHTML fragment element.
- Source:
(constant) XHTML
Contains allowed tags, tag attributes, and css properties. Used in the Strophe.createHtml function to filter incoming html into the allowed XHTML-IM subset. See XEP-0071 for the list of recommended allowed tags and their attributes.
- Source:
_requestId
Private variable that keeps track of the request ids for connections.
- Source:
_xmlGenerator :Document
Type:
- Document
(constant) connectionPlugins :Object.<string, Object>
Private variable Used to store plugin names that need initialization during Connection construction.
Type:
- Object.<string, Object>
- Source:
manager :ConnectionManager
Type:
- Source:
Methods
$build(name, attrsopt) → {Builder}
Create a Strophe.Builder
This is an alias for new Strophe.Builder(name, attrs)
.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
name |
string | The root element name. |
|
attrs |
Object.<string, (string|number)> |
<optional> |
The attributes for the root element in object notation. |
- Source:
Returns:
A new Strophe.Builder object.
- Type
- Builder
$iq(attrsopt) → {Builder}
Create a Strophe.Builder with an <iq/>
element as the root.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
attrs |
Object.<string, string> |
<optional> |
The |
- Source:
Returns:
A new Strophe.Builder object.
- Type
- Builder
$msg(attrsopt) → {Builder}
Create a Strophe.Builder with a <message/>
element as the root.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
attrs |
Object.<string, string> |
<optional> |
The |
- Source:
Returns:
A new Strophe.Builder object.
- Type
- Builder
$pres(attrsopt) → {Builder}
Create a Strophe.Builder with a <presence/>
element as the root.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
attrs |
Object.<string, string> |
<optional> |
The |
- Source:
Returns:
A new Strophe.Builder object.
- Type
- Builder
addCookies(cookies)
Parameters:
Name | Type | Description |
---|---|---|
cookies |
Cookies |
arrayBufToBase64(buffer) → {string}
Parameters:
Name | Type | Description |
---|---|---|
buffer |
ArrayBufferLike |
Returns:
- Type
- string
base64ToArrayBuf(str) → {ArrayBufferLike}
Parameters:
Name | Type | Description |
---|---|---|
str |
string |
Returns:
- Type
- ArrayBufferLike
generate_cnonce() → {string}
Generate an ASCII nonce (not containing the ',' character)
Returns:
- Type
- string
getDOMParserImplementation()
DOMParser https://w3c.github.io/DOM-Parsing/#the-domparser-interface
Interface to parse XML strings into Document objects
Used implementations:
- supported browsers: built-in in DOMParser global https://developer.mozilla.org/en-US/docs/Web/API/DOMParser#Browser_compatibility
- nodejs: use '@xmldom/xmldom' module https://www.npmjs.com/package/@xmldom/xmldom
getDummyXMLDOMDocument()
Creates a dummy XML DOM document to serve as an element and text node generator.
Used implementations:
- IE < 10: avoid using createDocument() due to a memory leak, use ie-specific workaround
- other supported browsers: use document's createDocument
- nodejs: use '@xmldom/xmldom'
getWebSocketImplementation()
WHATWG WebSockets API https://www.w3.org/TR/websockets/
Interface to use the web socket protocol
Used implementations:
- supported browsers: built-in in WebSocket global https://developer.mozilla.org/en-US/docs/Web/API/WebSocket#Browser_compatibility
- nodejs: use standard-compliant 'ws' module https://www.npmjs.com/package/ws
handleError(e)
Properly logs an error to the console
Parameters:
Name | Type | Description |
---|---|---|
e |
Error |
(async) scramClientProof(authMessage, clientKey, hashName)
Parameters:
Name | Type | Description |
---|---|---|
authMessage |
string | |
clientKey |
ArrayBufferLike | |
hashName |
string |
(async) scramDeriveKeys(password, salt, iter, hashName, hashBits)
Derive the client and server keys given a string password, a hash name, and a bit length. Returns an object of the following form: { ck: ArrayBuffer, the client key sk: ArrayBuffer, the server key }
Parameters:
Name | Type | Description |
---|---|---|
password |
string | |
salt |
BufferSource | |
iter |
number | |
hashName |
string | |
hashBits |
number |
scramParseChallenge(challenge)
This function parses the information in a SASL SCRAM challenge response, into an object of the form { nonce: String, salt: ArrayBuffer, iter: Int } Returns undefined on failure.
Parameters:
Name | Type | Description |
---|---|---|
challenge |
string |
(async) scramServerSign(authMessage, sk, hashName)
Parameters:
Name | Type | Description |
---|---|---|
authMessage |
string | |
sk |
BufferSource | |
hashName |
string |
stringToArrayBuf(str) → {ArrayBufferLike}
Parameters:
Name | Type | Description |
---|---|---|
str |
string |
Returns:
- Type
- ArrayBufferLike
stx(strings, …values)
Tagged template literal function which generates Stanza objects
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
strings |
Array.<string> | ||
values |
any |
<repeatable> |
Example
stx`<presence type="${type}" xmlns="jabber:client"><show>${show}</show></presence>`
toStanza(string, throwErrorIfInvalidNSopt) → {Element}
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
string |
string | ||
throwErrorIfInvalidNS |
boolean |
<optional> |
Returns:
- Type
- Element
utf16to8(str) → {string}
Parameters:
Name | Type | Description |
---|---|---|
str |
string |
Returns:
- Type
- string
xmlElement(name, attrsopt, textopt) → {Element}
Create an XML DOM element.
This function creates an XML DOM element correctly across all implementations. Note that these are not HTML DOM elements, which aren't appropriate for XMPP stanzas.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
name |
string | The name for the element. |
|
attrs |
Array.<Array.<string>> | Object.<string, (string|number)> | string | number |
<optional> |
An optional array or object containing
key/value pairs to use as element attributes.
The object should be in the format |
text |
string | number |
<optional> |
The text child data for the element. |
Returns:
A new XML DOM element.
- Type
- Element
xmlGenerator() → {Document}
Get the DOM document to generate elements.
Returns:
- The currently used DOM document.
- Type
- Document
xmlHtmlNode(html) → {XMLDocument}
Creates an XML DOM node.
Parameters:
Name | Type | Description |
---|---|---|
html |
string | The content of the html node. |
Returns:
- Type
- XMLDocument
xmlTextNode(text) → {Text}
Creates an XML DOM text node. Provides a cross implementation version of document.createTextNode.
Parameters:
Name | Type | Description |
---|---|---|
text |
string | The content of the text node. |
Returns:
- A new XML DOM text node.
- Type
- Text
xorArrayBuffers(x, y)
Parameters:
Name | Type | Description |
---|---|---|
x |
ArrayBufferLike | |
y |
ArrayBufferLike |
Type Definitions
ConnectionOptions
Type:
- Object
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
cookies |
Cookies |
<optional> |
Allows you to pass in cookies that will be included in HTTP requests. Relevant to both the BOSH and Websocket transports. The passed in value must be a map of cookie names and string values.
Note that cookies can't be set in this way for domains other than the one that's hosting Strophe (i.e. cross-domain). Those cookies need to be set under those domains, for example they can be set server-side by making a XHR call to that domain to ask it to set any necessary cookies. |
mechanisms |
Array.<SASLMechanism> |
<optional> |
Allows you to specify the SASL authentication mechanisms that this instance of Connection (and therefore your XMPP client) will support. The value must be an array of objects with SASLMechanism prototypes. If nothing is specified, then the following mechanisms (and their priorities) are registered:
|
explicitResourceBinding |
boolean |
<optional> |
If Making this step explicit allows client authors to first finish other stream related tasks, such as setting up an XEP-0198 Stream Management session, before binding the JID resource for this session. |
protocol |
'ws' | 'wss' |
<optional> |
Note: This option is only relevant to Websocket connections, and not BOSH If you want to connect to the current host with a WebSocket connection you
can tell Strophe to use WebSockets through the "protocol" option.
Valid values are
Note that relative URLs NOT starting with a "/" will also include the path of the current site. Also because downgrading security is not permitted by browsers, when using relative URLs both BOSH and WebSocket connections will use their secure variants if the current connection to the site is also secure (https). |
worker |
string |
<optional> |
Note: This option is only relevant to Websocket connections, and not BOSH Set this option to URL from where the shared worker script should be loaded. To run the websocket connection inside a shared worker. This allows you to share a single websocket-based connection between multiple Connection instances, for example one per browser tab. The script to use is the one in |
sync |
boolean |
<optional> |
Used to control whether BOSH HTTP requests will be made synchronously or not. The default behaviour is asynchronous. If you want to make requests synchronous, make "sync" evaluate to true.
You can also toggle this on an already established connection.
|
customHeaders |
Array.<string> |
<optional> |
Used to provide custom HTTP headers to be included in the BOSH HTTP requests. |
keepalive |
boolean |
<optional> |
Used to instruct Strophe to maintain the current BOSH session across interruptions such as webpage reloads. It will do this by caching the sessions tokens in sessionStorage, and when "restore" is called it will check whether there are cached tokens with which it can resume an existing session. |
withCredentials |
boolean |
<optional> |
Used to indicate wether cookies should be included in HTTP requests (by default
they're not).
Set this value to |
contentType |
string |
<optional> |
Used to change the default Content-Type, which is "text/xml; charset=utf-8". Can be useful to reduce the amount of CORS preflight requests that are sent to the server. |
- Source:
Cookies
Type:
- Object.<string, string>
- Source:
Cookies
A map of cookie names to string values or to maps of cookie values.
Type:
- Object.<string, string>
HandlerOptions
Type:
- Object
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
HandlerOptions.matchBareFromJid |
boolean |
<optional> |
|
HandlerOptions.ignoreNamespaceFragment |
boolean |
<optional> |
- Source:
HandlerOptions
Type:
- Object
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
HandlerOptions.matchBareFromJid |
boolean |
<optional> |
|
HandlerOptions.ignoreNamespaceFragment |
boolean |
<optional> |
- Source:
LogLevels
Logging level indicators.
Type:
- 0 | 1 | 2 | 3 | 4
- Source:
NS
Common namespace constants from the XMPP RFCs and XEPs.
Type:
- Object
Properties:
Name | Type | Description |
---|---|---|
NS.HTTPBIND |
string | HTTP BIND namespace from XEP 124. |
NS.BOSH |
string | BOSH namespace from XEP 206. |
NS.CLIENT |
string | Main XMPP client namespace. |
NS.AUTH |
string | Legacy authentication namespace. |
NS.ROSTER |
string | Roster operations namespace. |
NS.PROFILE |
string | Profile namespace. |
NS.DISCO_INFO |
string | Service discovery info namespace from XEP 30. |
NS.DISCO_ITEMS |
string | Service discovery items namespace from XEP 30. |
NS.MUC |
string | Multi-User Chat namespace from XEP 45. |
NS.SASL |
string | XMPP SASL namespace from RFC 3920. |
NS.STREAM |
string | XMPP Streams namespace from RFC 3920. |
NS.BIND |
string | XMPP Binding namespace from RFC 3920 and RFC 6120. |
NS.SESSION |
string | XMPP Session namespace from RFC 3920. |
NS.XHTML_IM |
string | XHTML-IM namespace from XEP 71. |
NS.XHTML |
string | XHTML body namespace from XEP 71. |
NS.STANZAS |
string | |
NS.FRAMING |
string |
- Source:
Password
Type:
- Object
Properties:
Name | Type | Description |
---|---|---|
Password.name |
string | |
Password.ck |
string | |
Password.sk |
string | |
Password.iter |
number | |
Password.salt |
string |
- Source:
Password
Type:
- Object
Properties:
Name | Type | Description |
---|---|---|
Password.name |
string | |
Password.ck |
string | |
Password.sk |
string | |
Password.iter |
number | |
salt |
string |
SASLData
Type:
- Object.<string, any>
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
SASLData.keys |
Object |
<optional> |
- Source:
SASLXOAuth2
SASL X-OAuth2 authentication.
- Source:
StanzaAttrs
Type:
- Object.<string, (string|number)>
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
StanzaAttrs.xmlns |
string |
<optional> |
- Source:
Status
Connection status constants for use by the connection handler callback.
Type:
- Object
Properties:
Name | Type | Description |
---|---|---|
Status.ERROR |
connstatus | An error has occurred |
Status.CONNECTING |
connstatus | The connection is currently being made |
Status.CONNFAIL |
connstatus | The connection attempt failed |
Status.AUTHENTICATING |
connstatus | The connection is authenticating |
Status.AUTHFAIL |
connstatus | The authentication attempt failed |
Status.CONNECTED |
connstatus | The connection has succeeded |
Status.DISCONNECTED |
connstatus | The connection has been terminated |
Status.DISCONNECTING |
connstatus | The connection is currently being terminated |
Status.ATTACHED |
connstatus | The connection has been attached |
Status.REDIRECT |
connstatus | The connection has been redirected |
Status.CONNTIMEOUT |
connstatus | The connection has timed out |
Status.BINDREQUIRED |
connstatus | The JID resource needs to be bound for this session |
Status.ATTACHFAIL |
connstatus | Failed to attach to a pre-existing session |
Status.RECONNECTING |
connstatus | Not used by Strophe, but added for integrators |
- Source:
WebsocketLike
Type:
- Object
Properties:
Name | Type | Description |
---|---|---|
|
||
WebsocketLike.close |
function | |
WebsocketLike.onopen |
function | |
|
||
|
||
|
||
WebsocketLike.readyState |
string |
- Source:
XHTMLAttrs
Type:
- 'a' | 'blockquote' | 'br' | 'cite' | 'em' | 'img' | 'li' | 'ol' | 'p' | 'span' | 'strong' | 'ul' | 'body'
connectionCallback(connection)
Parameters:
Name | Type | Description |
---|---|---|
connection |
Connection |
connectionCallback(connection)
Parameters:
Name | Type | Description |
---|---|---|
connection |
Connection |
- Source:
connectionCallback(connection)
Parameters:
Name | Type | Description |
---|---|---|
connection |
Connection |
- Source:
connstatus
Type:
- number
- Source: