JID
XMPP identifiers (JID) for JavaScript
JID type | local | @ | domain | / | resource | usage |
---|
domain | | | wonderland.net | | | servers and components |
bare | alice | @ | wonderland.net | | | users |
full | alice | @ | wonderland.net | / | rabbithole | user resource (device) |
https://en.wikipedia.org/wiki/XMPP#Decentralization_and_addressing
Usage
var JID = require('jid')
var addr = new JID('alice@wonderland.net/rabbithole')
var addr = JID`${'alice'}@${'wonderland.net'}/${'rabbithole'}`
var addr = new JID('alice', 'wonderland.net', 'rabbithole')
addr instanceof JID.JID
var addr = JID('wonderland.net')
addr.local = 'alice'
addr.local
addr.setLocal('alice')
addr.getLocal()
addr.domain = 'wonderland.net'
addr.domain
addr.setDomain('wonderland.net')
addr.getDomain()
addr.resource = 'rabbithole'
addr.resource
addr.setResource('rabbithole')
addr.getResource()
addr.toString()
addr.bare()
addr.equals(some_jid)
JID.equal(addr, some_jid)
JID.is(addr)
Escaping
The XEP-0106 defines a method to escape and unescape characters that aren't allowed in the local part of the JID. This library fully implement it but because @
and /
are ones of them and used as JID separators, you should always prefer the following syntax
new JID(local, domain, resource)
over
new JID(local@domain/resource)
for user input.
References
Deprecated