smartsocket/dist/smartsocket.helpers.js

29 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");
// SocketConnection helpers
exports.checkPasswordForRole = (dataArg, referenceSmartsocket) => {
let targetPasswordHash = exports.getSocketRoleByName(dataArg.role, referenceSmartsocket).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, referenceSmartsocket) => {
return referenceSmartsocket.socketRoles.find((socketRoleArg) => { return socketRoleArg.name === socketRoleNameArg; });
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzb2NrZXQuaGVscGVycy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0c29ja2V0LmhlbHBlcnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLE1BQVksT0FBTyxXQUFNLHVCQUF1QixDQUFDLENBQUE7QUFJakQscURBQW1ELHNDQUFzQyxDQUFDLENBQUE7QUFFMUYsb0RBQXFFLHFDQUFxQyxDQUFDLENBQUE7QUFHM0csMkJBQTJCO0FBQ2hCLDRCQUFvQixHQUFHLENBQUMsT0FBOEMsRUFBRSxvQkFBZ0M7SUFDL0csSUFBS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