Skip to content

Commit

Permalink
Address some review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sonnyp committed Dec 22, 2024
1 parent ca6b6f5 commit e37dfbf
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
echo deb http://packages.prosody.im/debian $(lsb_release -sc) main | sudo tee /etc/apt/sources.list.d/prosody.list
sudo wget https://prosody.im/files/prosody-debian-packages.key -O/etc/apt/trusted.gpg.d/prosody.gpg
sudo apt update
sudo apt install lua5.4 prosody-trunk lua-bitop lua-sec luarocks
sudo apt install lua5.3 prosody-trunk lua-bitop lua-sec luarocks
sudo service prosody stop
prosodyctl --config server/prosody.cfg.lua install mod_sasl2
prosodyctl --config server/prosody.cfg.lua install mod_sasl2_bind2
Expand Down
3 changes: 1 addition & 2 deletions packages/connection/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,7 @@ class Connection extends EventEmitter {
(this.streamFrom || this.jid)
) {
// When the stream is secure there is no leak to setting the stream from
// This is suggested in general and in required for FAST implementations
// in particular
// This is recommended in general and required for FAST implementations
headerElement.attrs.from = (this.streamFrom || this.jid).toString();
}
headerElement.attrs["xml:lang"] = lang;
Expand Down
4 changes: 2 additions & 2 deletions packages/sasl-ht-sha-256-none/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ Mechanism.prototype.final = function final(data) {
const hmac = createHmac("sha256", this.password);
hmac.update("Responder");
if (hmac.digest("latin1") !== data) {
throw "Responder message from server was wrong";
throw new Error("Responder message from server was wrong");
}
};

export default function sasl2(sasl) {
export default function saslHashedToken(sasl) {
sasl.use(Mechanism);
}
28 changes: 15 additions & 13 deletions packages/sasl2/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SASL
# SASL2

SASL2 Negotiation for `@xmpp/client` (including optional BIND2 and FAST).

Expand All @@ -11,14 +11,16 @@ Included and enabled in `@xmpp/client`.
### object

```js
const {xmpp} = require('@xmpp/client')
const client = xmpp({credentials: {
username: 'foo',
password: 'bar',
clientId: "Some UUID for this client/server pair (optional)",
software: "Name of this software (optional)",
device: "Description of this device (optional)",
})
import { xmpp } from "@xmpp/client";
const client = xmpp({
credentials: {
username: "foo",
password: "bar",
clientId: "Some UUID for this client/server pair (optional)",
software: "Name of this software (optional)",
device: "Description of this device (optional)",
},
});
```

### function
Expand All @@ -34,7 +36,7 @@ Uses cases:
- Perform an asynchronous operation to get credentials

```js
const { xmpp } = require("@xmpp/client");
import { xmpp } from "@xmpp/client";
const client = xmpp({
credentials: authenticate,
clientId: "Some UUID for this client/server pair (optional)",
Expand Down Expand Up @@ -74,6 +76,6 @@ async function authenticate(callback, mechanisms) {
## References
[SASL2](https://xmpp.org/extensions/xep-0388.html)
[BIND2](https://xmpp.org/extensions/xep-0386.html)
[FAST](https://xmpp.org/extensions/inbox/xep-fast.html)
- [SASL2](https://xmpp.org/extensions/xep-0388.html)
- [BIND2](https://xmpp.org/extensions/xep-0386.html)
- [FAST](https://xmpp.org/extensions/xep-0484.html)
12 changes: 7 additions & 5 deletions packages/stream-management/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,17 @@ export default function streamManagement({
// https://xmpp.org/extensions/xep-0198.html#enable
// For client-to-server connections, the client MUST NOT attempt to enable stream management until after it has completed Resource Binding unless it is resuming a previous session

const resumeSuccess = () => {
function resumeSuccess() {
sm.enabled = true;
if (address) entity.jid = address;
entity.status = "online";
};
}

const resumeFailed = () => {
function resumeFailed() {
sm.id = "";
sm.enabled = false;
sm.outbound = 0;
};
}

streamFeatures.use("sm", NS, async (context, next) => {
// Resuming
Expand Down Expand Up @@ -161,7 +161,9 @@ export default function streamManagement({
const enabled = bound?.getChild("enabled", NS);
if (enabled) {
if (sm.outbound_q.length > 0) {
throw "Stream Management assertion failure, queue should be empty after enable";
throw new Error(
"Stream Management assertion failure, queue should be empty after enable",
);
}
sm.outbound = 0;
sm.enabled = true;
Expand Down

0 comments on commit e37dfbf

Please sign in to comment.