<commit_before>var events = require('events'),
    couchr = require('couchr');


exports.start = function (manager, callback) {
    var am = {};

    var ev = new events.EventEmitter();
    am.emit = function () {
        ev.emit.apply(ev, arguments);
    };
    am.on = function () {
        ev.on.apply(ev, arguments);
    };

    var user_db = manager._resolve('_users');
    var feed = couchr.changes(user_db, {include_docs: true});

    feed.on('change', function (change) {
        am.emit('change', change);
    });

    am.stop = function (callback) {
        feed.once('error', function (err) {
            // ignore connection errors during stopping of feed
            if (err.code !== 'ECONNREFUSED' &&
                err.code !== 'ECONNRESET') {
                throw err;
            }
        });
        feed.once('stop', callback);
        feed.stop();
    };


    // CouchDB 1.4.0 has a introduced the requirement that user fields be explicitly declared public for them to be
    // returned. In the case of admins, this filtering should not be applied, but there's a bug.
    // BUG: https://issues.apache.org/jira/browse/COUCHDB-1888
    var couchRoot = manager._resolve('');

    couchr.get(couchRoot, function(err, result) {
        if (err) {
            return callback(err, null);
        }

        if (result.version === '1.4.0') {
            var config_db = manager._resolve('_config');

            var publicFields = [
                '_id', '_rev,name', 'password_sha', 'password_scheme', 'iterations',
                'name', 'roles', 'derived_key', 'salt', 'database', 'hoodieId',
                'updatedAt', 'signedUpAt', 'type'
            ];

            couchr.put(config_db + '/couch_httpd_auth/public_fields', JSON.stringify(publicFields.join(',')), function() {
                callback(null, am);<commit_msg>[fix] ] remove typo in public field names<commit_after>var events = require('events'),
    couchr = require('couchr');


exports.start = function (manager, callback) {
    var am = {};

    var ev = new events.EventEmitter();
    am.emit = function () {
        ev.emit.apply(ev, arguments);
    };
    am.on = function () {
        ev.on.apply(ev, arguments);
    };

    var user_db = manager._resolve('_users');
    var feed = couchr.changes(user_db, {include_docs: true});

    feed.on('change', function (change) {
        am.emit('change', change);
    });

    am.stop = function (callback) {
        feed.once('error', function (err) {
            // ignore connection errors during stopping of feed
            if (err.code !== 'ECONNREFUSED' &&
                err.code !== 'ECONNRESET') {
                throw err;
            }
        });
        feed.once('stop', callback);
        feed.stop();
    };


    // CouchDB 1.4.0 has a introduced the requirement that user fields be explicitly declared public for them to be
    // returned. In the case of admins, this filtering should not be applied, but there's a bug.
    // BUG: https://issues.apache.org/jira/browse/COUCHDB-1888
    var couchRoot = manager._resolve('');

    couchr.get(couchRoot, function(err, result) {
        if (err) {
            return callback(err, null);
        }

        if (result.version === '1.4.0') {
            var config_db = manager._resolve('_config');

            var publicFields = [
                '_id', '_rev', 'name', 'password_sha', 'password_scheme', 'iterations',
                'name', 'roles', 'derived_key', 'salt', 'database', 'hoodieId',
                'updatedAt', 'signedUpAt', 'type'
            ];

            couchr.put(config_db + '/couch_httpd_auth/public_fields', JSON.stringify(publicFields.join(',')), function() {
                callback(null, am);
{'fraction_non_alphanumeric': 0.14797966283114797, 'fraction_numerical': 0.005351886540005352, 'mean_word_length': 2.1812765957446807, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '6053844', 'n_tokens_mistral': 1132, 'n_tokens_neox': 1090, 'n_words': 274}