"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const types_1 = require("@deepstream/types");
/**
 * Used for users that don't provide a username
 */
const OPEN = 'open';
/**
 * The open authentication handler allows every client to connect.
 * If the client specifies a username as part of its authentication
 * data, it will be used to identify the user internally
 */
class OpenAuthentication extends types_1.DeepstreamPlugin {
    constructor() {
        super(...arguments);
        this.description = 'Open Authentication';
    }
    /**
    * Grants access to any user. Registers them with username or open
    */
    async isValidUser(connectionData, authData) {
        return {
            isValid: true,
            id: (authData.username && authData.username.toString()) || OPEN
        };
    }
}
exports.OpenAuthentication = OpenAuthentication;
//# sourceMappingURL=open-authentication.js.map