lib/client: add support for AUTHENTICATE chunking
SASL responses need to be split into 400 byte chunks before being sent to the server.
This commit is contained in:
18
lib/irc.js
18
lib/irc.js
@@ -1,3 +1,5 @@
|
||||
import * as base64 from "./base64.js";
|
||||
|
||||
// RFC 1459
|
||||
export const RPL_WELCOME = "001";
|
||||
export const RPL_YOURHOST = "002";
|
||||
@@ -942,3 +944,19 @@ export class CapRegistry {
|
||||
return { command: "CAP", params: ["REQ", l.join(" ")] };
|
||||
}
|
||||
}
|
||||
|
||||
const maxSASLLength = 400;
|
||||
|
||||
export function generateAuthenticateMessages(payload) {
|
||||
let encoded = base64.encode(payload);
|
||||
|
||||
// <= instead of < because we need to send a final empty response if the
|
||||
// last chunk is exactly 400 bytes long
|
||||
let msgs = [];
|
||||
for (let i = 0; i <= encoded.length; i += maxSASLLength) {
|
||||
let chunk = encoded.substring(i, i + 400);
|
||||
msgs.push({ command: "AUTHENTICATE", params: [chunk || "+"] });
|
||||
}
|
||||
|
||||
return msgs;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user