lib/client: don't error out if SASL isn't available on RPL_WELCOME

Some servers (soju) might remove the sasl cap on connection
registration.
This commit is contained in:
Simon Ser 2021-11-19 19:32:13 +01:00
parent 723951a07b
commit 51bf8da3d6

View File

@ -58,6 +58,7 @@ export default class Client extends EventTarget {
status = Client.Status.DISCONNECTED;
serverPrefix = { name: "*" };
nick = null;
supportsCap = false;
availableCaps = {};
enabledCaps = {};
isupport = new Map();
@ -234,7 +235,7 @@ export default class Client extends EventTarget {
let k;
switch (msg.command) {
case irc.RPL_WELCOME:
if (this.params.saslPlain && this.availableCaps["sasl"] === undefined) {
if (this.params.saslPlain && !this.supportsCap) {
this.dispatchEvent(new CustomEvent("error", { detail: "Server doesn't support SASL PLAIN" }));
this.disconnect();
return;
@ -536,6 +537,7 @@ export default class Client extends EventTarget {
let args = msg.params.slice(2);
switch (subCmd) {
case "LS":
this.supportsCap = true;
this.addAvailableCaps(args[args.length - 1]);
if (args[0] != "*") {
console.log("Available server caps:", this.availableCaps);