Skip to content

Commit

Permalink
done
Browse files Browse the repository at this point in the history
  • Loading branch information
sonnyp committed Dec 28, 2024
1 parent 023cb19 commit 04ebdeb
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ xmpp.on("offline", () => {
console.log("offline");
});

xmpp.on("stanza", async (stanza) => {
xmpp.once("stanza", async (stanza) => {
if (stanza.is("message")) {
await xmpp.send(xml("presence", { type: "unavailable" }));
await xmpp.stop();
Expand Down
2 changes: 1 addition & 1 deletion packages/client/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ xmpp.on("offline", () => {
console.log("offline");
});

xmpp.on("stanza", async (stanza) => {
xmpp.once("stanza", async (stanza) => {
if (stanza.is("message")) {
await xmpp.send(xml("presence", { type: "unavailable" }));
await xmpp.stop();
Expand Down
2 changes: 1 addition & 1 deletion packages/component/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ xmpp.on("offline", () => {
console.log("offline");
});

xmpp.on("stanza", async (stanza) => {
xmpp.once("stanza", async (stanza) => {
if (stanza.is("message")) {
await xmpp.stop();
}
Expand Down
2 changes: 1 addition & 1 deletion packages/component/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ xmpp.on("offline", () => {
console.log("offline");
});

xmpp.on("stanza", async (stanza) => {
xmpp.once("stanza", async (stanza) => {
if (stanza.is("message")) {
await xmpp.stop();
}
Expand Down
6 changes: 4 additions & 2 deletions packages/sasl2/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ async function authenticate({
mech.final(decode(additionalData));
}

// https://xmpp.org/extensions/xep-0388.html#success
// this is a bare JID, unless resource binding has occurred, in which case it is a full JID.
const aid = element.getChildText("authorization-identifier");
if (aid) entity._jid(aid);

Expand Down Expand Up @@ -131,8 +133,8 @@ export default function sasl2({ streamFeatures, saslFactory }, onAuthenticate) {
}

await onAuthenticate(done, intersection);

return true; // Not online yet, wait for next features
// Not online yet, wait for next features
return true;
},
);

Expand Down
3 changes: 3 additions & 0 deletions packages/stream-features/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ export default function route() {
if (!stanza.is("features", "http://etherx.jabber.org/streams"))
return next();

// FIXME: instead of this prevent mechanism
// emit online once all stream features have negotiated
// and if entity.jid is set
const prevent = await next();
if (!prevent && entity.jid) entity._status("online", entity.jid);
};
Expand Down

0 comments on commit 04ebdeb

Please sign in to comment.