@hallparty/xmpp-jid
@hallparty/xmpp-jid
npm i @hallparty/xmpp-jid
@hallparty/xmpp-jid

@hallparty/xmpp-jid

XMPP for JavaScript

by xmppjs

0.12.0 (see all)License:ISCTypeScript:Not Found
npm i @hallparty/xmpp-jid
Readme

JID

XMPP identifiers (JID) for JavaScript

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

Install

npm install @hallparty/xmpp-jid or yarn add @hallparty/xmpp-jid

Usage

var jid = require("@hallparty/xmpp-jid");

/*
 * All return an instance of jid.JID
 */
var addr = jid("alice@wonderland.net/rabbithole");
var addr = jid("alice", "wonderland.net", "rabbithole");

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);

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.

const addr = jid("contact@example.net", "xmpp.net");
addr.toString(); // contact\40example.net@xmpp.net
// for display purpose only
addr.toString(true); // contact@example.net@xmpp.net

For user input, use

jid("contact@example.net", "xmpp.net");
// over
jid("contact@example.net@xmpp.net");

References

Deprecated

Downloads/wk

1

GitHub Stars

2.1K

LAST COMMIT

10mos ago

MAINTAINERS

1

CONTRIBUTORS

104

OPEN ISSUES

26

OPEN PRs

2
VersionTagPublished
0.12.0
latest
1yr ago
No alternatives found
No tutorials found
Add a tutorial
No dependencies found

Rate & Review

100
No reviews found
Be the first to rate