36 lines
3.0 KiB
JavaScript
36 lines
3.0 KiB
JavaScript
"use strict";
|
|
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
|
|
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzb2NrZXQuaGVscGVycy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0c29ja2V0LmhlbHBlcnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSxpREFBaUQ7QUFJakQsNkZBQTBGO0FBSz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