smartsocket/dist/smartsocket.helpers.js

36 lines
3.0 KiB
JavaScript
Raw Permalink Normal View History

2016-08-07 12:58:20 +00:00
"use strict";
2017-07-07 20:02:19 +00:00
Object.defineProperty(exports, "__esModule", { value: true });
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
2016-09-04 22:34:09 +00:00
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) => {
2018-03-15 01:29:40 +00:00
return smartsocket_classes_socketfunction_1.allSocketFunctions.find(socketFunctionArg => {
return socketFunctionArg.name === functionNameArg;
});
};
// SocketRequest helpers
/**
* get corresponding Socketrequest instance by shortId
*/
exports.getSocketRequestById = (shortIdArg, requestSide) => {
2018-03-15 01:29:40 +00:00
return smartsocket_classes_socketrequest_1.allSocketRequests.find(socketRequestArg => {
return socketRequestArg.shortid === shortIdArg;
});
};
2016-08-09 09:42:21 +00:00
// SocketRole helpers
/**
* get corresponding SocketRole instance by name
*/
2016-09-04 22:34:09 +00:00
exports.getSocketRoleByName = (socketRoleNameArg, referenceSmartsocket) => {
2018-03-15 01:29:40 +00:00
return referenceSmartsocket.socketRoles.find(socketRoleArg => {
return socketRoleArg.name === socketRoleNameArg;
});
2016-08-07 16:59:39 +00:00
};
2018-03-15 01:29:40 +00:00
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzb2NrZXQuaGVscGVycy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0c29ja2V0LmhlbHBlcnMudHMiXSwibmFtZXMiOltdLCJ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