"use strict"; const plugins = require("./smartsocket.plugins"); /** * authenticate a socket */ exports.authenticateSocket = (socketConnectionArg) => { let done = plugins.q.defer(); socketConnectionArg.socket.on("dataAuth", dataArg => { plugins.beautylog.log("received authentication data. now hashing and comparing..."); socketConnectionArg.socket.removeListener("dataAuth", () => { }); if ((true)) { socketConnectionArg.alias = dataArg.alias; socketConnectionArg.authenticated = true; socketConnectionArg.role = dataArg.role; socketConnectionArg.socket.emit("authenticated"); plugins.beautylog.ok(`socket with >>alias ${socketConnectionArg.alias} >>role ${socketConnectionArg.role} is authenticated!`); done.resolve(socketConnectionArg); } else { socketConnectionArg.socket.disconnect(); done.reject("not authenticated"); } ; }); socketConnectionArg.socket.emit("requestAuth"); return done.promise; }; exports.listenToReadySocket = (socketConnectionArg) => { let done = plugins.q.defer(); // socketConnectionArg.socket.listen("function", ) return done.promise; }; //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzb2NrZXQuaGVscGVycy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0c29ja2V0LmhlbHBlcnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLE1BQVksT0FBTyxXQUFNLHVCQUF1QixDQUFDLENBQUE7QUFRakQ7O0dBRUc7QUFDUSwwQkFBa0IsR0FBRyxDQUFDLG1CQUFxQztJQUNsRSxJQUFJLElBQUksR0FBRyxPQUFPLENBQUMsQ0FBQyxDQUFDLEtBQUssRUFBRSxDQUFDO0lBQzdCLG1CQUFtQixDQUFDLE1BQU0sQ0FBQyxFQUFFLENBQUMsVUFBVSxFQUFFLE9BQU87UUFDN0MsT0FBTyxDQUFDLFNBQVMsQ0FBQyxHQUFHLENBQUMsNERBQTRELENBQUMsQ0FBQztRQUNwRixtQkFBbUIsQ0FBQyxNQUFNLENBQUMsY0FBYyxDQUFDLFVBQVUsRUFBRSxRQUFRLENBQUMsQ0FBQyxDQUFDO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