diff --git a/lib/client.js b/lib/client.js index 7687e08..5b81ff1 100644 --- a/lib/client.js +++ b/lib/client.js @@ -13,6 +13,7 @@ const permanentCaps = [ "labeled-response", "message-tags", "multi-prefix", + "sasl", "server-time", "setname", @@ -542,10 +543,14 @@ export default class Client extends EventTarget { return saslCap.split(",").includes(mech); } - requestCaps(extra) { - let reqCaps = extra || []; + requestCaps() { + let wantCaps = [].concat(permanentCaps); + if (!this.params.bouncerNetwork) { + wantCaps.push("soju.im/bouncer-networks-notify"); + } - permanentCaps.forEach((cap) => { + let reqCaps = []; + wantCaps.forEach((cap) => { if (this.availableCaps[cap] !== undefined && !this.enabledCaps[cap]) { reqCaps.push(cap); } @@ -566,19 +571,13 @@ export default class Client extends EventTarget { if (args[0] != "*") { console.log("Available server caps:", this.availableCaps); - let reqCaps = []; let capEnd = true; if ((this.params.saslPlain && this.supportsSASL("PLAIN")) || (this.params.saslExternal && this.supportsSASL("EXTERNAL"))) { // CAP END is deferred after authentication finishes - reqCaps.push("sasl"); capEnd = false; } - if (!this.params.bouncerNetwork && this.availableCaps["soju.im/bouncer-networks-notify"] !== undefined) { - reqCaps.push("soju.im/bouncer-networks-notify"); - } - - this.requestCaps(reqCaps); + this.requestCaps(); if (this.status != Client.Status.REGISTERED && capEnd) { this.send({ command: "CAP", params: ["END"] });