@xmpp/sasl
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/xmpp__sasl package

0.13.1 • Public • Published

SASL

SASL Negotiation for @xmpp/client.

Included and enabled in @xmpp/client.

Usage

object

const {xmpp} = require('@xmpp/client')
const client = xmpp({credentials: {
  username: 'foo',
  password: 'bar'
})

function

Instead, you can provide a function that will be called every time authentication occurs (every (re)connect).

Uses cases:

  • Have the user enter the password every time
  • Do not ask for password before connection is made
  • Debug authentication
  • Using a SASL mechanism with specific requirements
  • Perform an asynchronous operation to get credentials
const { xmpp } = require("@xmpp/client");
const client = xmpp({ credentials: authenticate });

async function authenticate(auth, mechanism) {
  console.debug("authenticate", mechanism);
  const credentials = {
    username: await prompt("enter username"),
    password: await prompt("enter password"),
  };
  console.debug("authenticating");
  try {
    await auth(credentials);
    console.debug("authenticated");
  } catch (err) {
    console.error(err);
    throw err;
  }
}

References

RFC 6120 SASL Negotiation

Readme

Keywords

Package Sidebar

Install

npm i @xmpp/sasl

Weekly Downloads

3,395

Version

0.13.1

License

ISC

Unpacked Size

8.7 kB

Total Files

5

Last publish

Collaborators

  • sonny