2016-08-07 12:58:20 +00:00
|
|
|
"use strict";
|
2016-08-16 02:48:42 +00:00
|
|
|
const plugins = require("./smartsocket.plugins");
|
2016-08-12 03:56:40 +00:00
|
|
|
const smartsocket_classes_socketfunction_1 = require("./smartsocket.classes.socketfunction");
|
|
|
|
const smartsocket_classes_socketrequest_1 = require("./smartsocket.classes.socketrequest");
|
2016-08-09 09:42:21 +00:00
|
|
|
const smartsocket_classes_socketrole_1 = require("./smartsocket.classes.socketrole");
|
2016-08-16 02:48:42 +00:00
|
|
|
// SocketConnection helpers
|
|
|
|
exports.checkPasswordForRole = (dataArg) => {
|
|
|
|
let targetPasswordHash = exports.getSocketRoleByName(dataArg.role).passwordHash;
|
|
|
|
let computedCompareHash = plugins.nodehash.sha256FromStringSync(dataArg.password);
|
|
|
|
return targetPasswordHash === computedCompareHash;
|
|
|
|
};
|
2016-08-12 03:56:40 +00:00
|
|
|
// 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; });
|
|
|
|
};
|
2016-08-09 09:42:21 +00:00
|
|
|
// SocketRole helpers
|
2016-08-12 03:56:40 +00:00
|
|
|
/**
|
|
|
|
* get corresponding SocketRole instance by name
|
|
|
|
*/
|
|
|
|
exports.getSocketRoleByName = (socketRoleNameArg) => {
|
2016-08-09 09:42:21 +00:00
|
|
|
return smartsocket_classes_socketrole_1.allSocketRoles.find((socketRoleArg) => { return socketRoleArg.name === socketRoleNameArg; });
|
2016-08-07 16:59:39 +00:00
|
|
|
};
|
2016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