smartsocket/dist/smartsocket.helpers.js

30 lines
2.8 KiB
JavaScript

"use strict";
const plugins = require("./smartsocket.plugins");
const smartsocket_classes_socketfunction_1 = require("./smartsocket.classes.socketfunction");
const smartsocket_classes_socketrequest_1 = require("./smartsocket.classes.socketrequest");
const smartsocket_classes_socketrole_1 = require("./smartsocket.classes.socketrole");
// SocketConnection helpers
exports.checkPasswordForRole = (dataArg) => {
let targetPasswordHash = exports.getSocketRoleByName(dataArg.role).passwordHash;
let computedCompareHash = plugins.nodehash.sha256FromStringSync(dataArg.password);
return targetPasswordHash === computedCompareHash;
};
// SocketFunction helpers
exports.getSocketFunctionByName = (functionNameArg) => {
return smartsocket_classes_socketfunction_1.allSocketFunctions.find((socketFunctionArg) => { return socketFunctionArg.name === functionNameArg; });
};
// SocketRequest helpers
/**
* get corresponding Socketrequest instance by shortId
*/
exports.getSocketRequestById = (shortIdArg, requestSide) => {
return smartsocket_classes_socketrequest_1.allSocketRequests.find((socketRequestArg) => { return socketRequestArg.shortid === shortIdArg; });
};
// SocketRole helpers
/**
* get corresponding SocketRole instance by name
*/
exports.getSocketRoleByName = (socketRoleNameArg) => {
return smartsocket_classes_socketrole_1.allSocketRoles.find((socketRoleArg) => { return socketRoleArg.name === socketRoleNameArg; });
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzb2NrZXQuaGVscGVycy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0c29ja2V0LmhlbHBlcnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLE1BQVksT0FBTyxXQUFNLHVCQUF1QixDQUFDLENBQUE7QUFJakQscURBQW1ELHNDQUFzQyxDQUFDLENBQUE7QUFFMUYsb0RBQXFFLHFDQUFxQyxDQUFDLENBQUE7QUFDM0csaURBQTJDLGtDQUFrQyxDQUFDLENBQUE7QUFFOUUsMkJBQTJCO0FBQ2hCLDRCQUF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