Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-xmpp-jid

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-xmpp-jid

XMPP identifiers (JID) for JavaScript

  • 2.3.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
150
increased by51.52%
Maintainers
1
Weekly downloads
 
Created
Source

JID

XMPP identifiers (JID) for JavaScript

Travis js-standard-style

JID typelocal@domain/resourceusage
domainwonderland.netservers and components
barealice@wonderland.netusers
fullalice@wonderland.net/rabbitholeuser resource (device)

https://en.wikipedia.org/wiki/XMPP#Decentralization_and_addressing

Usage

var JID = require('jid')

/*
 * All return an instance of JID.JID, the new operator is optional.
 */
var addr = new JID('alice@wonderland.net/rabbithole')          // OK
var addr = JID`${'alice'}@${'wonderland.net'}/${'rabbithole'}` // OK, es6 tagged template string
var addr = new JID('alice', 'wonderland.net', 'rabbithole')    // BEST; see section on escaping below

addr instanceof JID.JID // true

// domain JIDs are created passing the domain as the first argument
var addr = JID('wonderland.net')

/*
 * local
 */
addr.local = 'alice'
addr.local      // alice
// same as
addr.setLocal('alice')
addr.getLocal() // alice

/*
 * domain
 */
addr.domain = 'wonderland.net'
addr.domain      // wonderland.net
// same as
addr.setDomain('wonderland.net')
addr.getDomain() // wonderland.net

/*
 * resource
 */
addr.resource = 'rabbithole'
addr.resource      // rabbithole
// same as
addr.setResource('rabbithole')
addr.getResource() // rabbithole

addr.toString() // alice@wonderland.net/rabbithole
addr.bare()     // returns a JID without resource

addr.equals(some_jid) // returns true if the two JIDs are equal, false otherwise
// same as
JID.equal(addr, some_jid)

JID.is(addr) // returns true if the passed argument is an instance of JID.JID, false otherwise

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

// GOOD
new JID(local, domain, resource)

over

// BAD
new JID(local@domain/resource)

for user input.

References

Deprecated

Keywords

FAQs

Package last updated on 20 Jan 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc