<commit_before>/*jslint node: true*/
"use strict";

var utils = require('../utils');
var Buffer = require('buffer');

module.exports = function () {
    return function (irc) {
        irc.sasl = {
            method: '',
            mechanism: function saslMechanism(mechanism, network, fn) {
                if (typeof network ===  'function') { // (fn)
                    fn = network;
                    network = '';
                }

                irc.sasl.method = mechanism;

                irc.once('cap_ack', function (event) {
                    if(event.capabilities === 'sasl') {
                        // Send method/mechanism
                        irc.write("AUTHENTICATE " + mechanism);
                    }
                });
            },
            login: function saslLogin(account, password, network, fn) {
                if (typeof network ===  'function') { // (fn)
                    fn = network;
                    network = '';
                }

                irc.on('data', function(msg, network) {
                    if(msg.command === 'AUTHENTICATE' && msg.params === '+' && irc.sasl.method === "PLAIN") {
                        // Send our PLAIN password now!
                        if (account === undefined && password === undefined) {
                            // User didnt use SASL but we need to still "auth"
                            irc.write("AUTHENTICATE +");
                        } else {
                            var data = new Buffer(account+'\u0000'+account+'\u0000'+password).toString('base64');

                            irc.write("AUTHENTICATE "+data);
                        }
                    }
                });
            }
        };
    };
};<commit_msg>cap-sasl: forgot network in irc.write<commit_after>/*jslint node: true*/
"use strict";

var utils = require('../utils');
var Buffer = require('buffer');

module.exports = function () {
    return function (irc) {
        irc.sasl = {
            method: '',
            mechanism: function saslMechanism(mechanism, network, fn) {
                if (typeof network ===  'function') { // (fn)
                    fn = network;
                    network = '';
                }

                irc.sasl.method = mechanism;

                irc.once('cap_ack', function (event) {
                    if(event.capabilities === 'sasl') {
                        // Send method/mechanism
                        irc.write("AUTHENTICATE " + mechanism, network, fn);
                    }
                });
            },
            login: function saslLogin(account, password, network, fn) {
                if (typeof network ===  'function') { // (fn)
                    fn = network;
                    network = '';
                }

                irc.on('data', function(msg, network) {
                    if(msg.command === 'AUTHENTICATE' && msg.params === '+' && irc.sasl.method === "PLAIN") {
                        // Send our PLAIN password now!
                        if (account === undefined && password === undefined) {
                            // User didnt use SASL but we need to still "auth"
                            irc.write("AUTHENTICATE +", network, fn);
                        } else {
                            var data = new Buffer(account+'\u0000'+account+'\u0000'+password).toString('base64');

                            irc.write("AUTHENTICATE "+data, network, fn);
                        }
                    }
                });
            }
        };
    };
};
{'fraction_non_alphanumeric': 0.13155680224403926, 'fraction_numerical': 0.005610098176718092, 'mean_word_length': 1.116320474777448, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7185268', 'n_tokens_mistral': 945, 'n_tokens_neox': 860, 'n_words': 194}