# @xmpp/sasl

> XMPP SASL for JavaScript

Latest version **0.14.0** (published 2025-10-29) · ISC license · 0 weekly downloads

## Install

```sh
npm install @xmpp/sasl
pnpm add @xmpp/sasl
yarn add @xmpp/sasl
bun add @xmpp/sasl
```

## Health

**Score 58/100 (C)** — status: stable.

Positive: has types package; esm support; no vulnerabilities; high maintenance score.

Warnings: low downloads; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.14.0 |
| Published | 2025-10-29 |
| First published | 2018-10-07 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | separate (@types/xmpp__sasl) |
| Module format | ESM + CommonJS |
| Node | >= 20.10 |
| Dependencies | 4 |
| Unpacked size | 12.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2275 |
| Maintainers | sonny |
| Keywords | XMPP, sasl |

## Links

- npm: https://www.npmjs.com/package/@xmpp/sasl
- Repository: https://github.com/xmppjs/xmpp.js
- Homepage: https://github.com/xmppjs/xmpp.js/tree/main/packages/sasl
- Issues: http://github.com/xmppjs/xmpp.js/issues
- npm.io page: https://npm.io/package/@xmpp/sasl

## Dependencies (4)

- [@xmpp/xml](https://npm.io/package/@xmpp/xml.md) ^0.14.0
- [@xmpp/error](https://npm.io/package/@xmpp/error.md) ^0.14.0
- [@xmpp/base64](https://npm.io/package/@xmpp/base64.md) ^0.14.0
- [@xmpp/events](https://npm.io/package/@xmpp/events.md) ^0.14.0

## Recent versions

- 0.14.0 (latest) — 2025-10-29
- 0.13.6 — 2025-07-06
- 0.13.5 — 2025-06-11
- 0.13.4 — 2025-01-21
- 0.13.3 — 2024-12-23
- 0.13.1 — 2022-02-16
- 0.13.0 — 2021-08-28
- 0.12.1 — 2021-08-22
- 0.12.0 — 2020-12-21
- 0.11.0 — 2020-02-14
- 0.10.0 — 2020-02-07
- 0.9.2 — 2020-01-02
- 0.9.1 — 2019-11-23
- 0.9.0 — 2019-11-19
- 0.8.0 — 2019-10-06
- … 6 more at https://npm.io/package/@xmpp/sasl/versions

## README

# SASL

SASL Negotiation for `@xmpp/client`.

Included and enabled in `@xmpp/client`.

## Usage

### object

```js
import { xmpp } from "@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
- Fetch credentials from a secure database

```js
import { xmpp } from "@xmpp/client";

const client = xmpp({ credentials: onAuthenticate });

async function onAuthenticate(authenticate, mechanisms) {
  console.debug("authenticate", mechanisms);
  const credentials = {
    username: await prompt("enter username"),
    password: await prompt("enter password"),
  };
  console.debug("authenticating");
  await authenticate(credentials, mechanisms[0]);
  console.debug("authenticated");
}
```

## References

[RFC 6120 SASL Negotiation](https://xmpp.org/rfcs/rfc6120.html#sasl)

---
_Source: https://npm.io/package/@xmpp/sasl · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
