lib/client: always request sasl cap when available

This will allow us to issue post-registration SASL commands.
This commit is contained in:
Simon Ser 2021-11-21 13:35:32 +01:00
parent 86b08296a0
commit 4f927b5536

View file

@ -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"] });