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-16 02:48:42 +00:00
|
|
|
// SocketConnection helpers
|
2016-09-04 22:34:09 +00:00
|
|
|
exports.checkPasswordForRole = (dataArg, referenceSmartsocket) => {
|
|
|
|
let targetPasswordHash = exports.getSocketRoleByName(dataArg.role, referenceSmartsocket).passwordHash;
|
2016-08-16 02:48:42 +00:00
|
|
|
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
|
|
|
|
*/
|
2016-09-04 22:34:09 +00:00
|
|
|
exports.getSocketRoleByName = (socketRoleNameArg, referenceSmartsocket) => {
|
|
|
|
return referenceSmartsocket.socketRoles.find((socketRoleArg) => { return socketRoleArg.name === socketRoleNameArg; });
|
2016-08-07 16:59:39 +00:00
|
|
|
};
|
2016-09-04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