@iobroker/db-objects-redis
Advanced tools
Comparing version 5.0.20-alpha.0-20240409-d68ed299 to 5.0.20-alpha.0-20240418-165fc4c8
@@ -7,4 +7,4 @@ /** | ||
export declare const Server: null; | ||
export { ObjectsInRedisClient as Client } from './lib/objects/objectsInRedisClient'; | ||
export * as objectsUtils from './lib/objects/objectsUtils'; | ||
export { ObjectsInRedisClient as Client } from './lib/objects/objectsInRedisClient.js'; | ||
export * as objectsUtils from './lib/objects/objectsUtils.js'; | ||
//# sourceMappingURL=index.d.ts.map |
"use strict"; | ||
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) { | ||
if (k2 === void 0) | ||
k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { | ||
return m[k]; | ||
} }; | ||
var __create = Object.create; | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __getProtoOf = Object.getPrototypeOf; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __export = (target, all) => { | ||
for (var name in all) | ||
__defProp(target, name, { get: all[name], enumerable: true }); | ||
}; | ||
var __copyProps = (to, from, except, desc) => { | ||
if (from && typeof from === "object" || typeof from === "function") { | ||
for (let key of __getOwnPropNames(from)) | ||
if (!__hasOwnProp.call(to, key) && key !== except) | ||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
} : function(o, m, k, k2) { | ||
if (k2 === void 0) | ||
k2 = k; | ||
o[k2] = m[k]; | ||
return to; | ||
}; | ||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( | ||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, | ||
mod | ||
)); | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
var esm_exports = {}; | ||
__export(esm_exports, { | ||
Client: () => import_objectsInRedisClient.ObjectsInRedisClient, | ||
Server: () => Server, | ||
getDefaultPort: () => getDefaultPort, | ||
objectsUtils: () => objectsUtils | ||
}); | ||
var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
} : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = exports && exports.__importStar || function(mod) { | ||
if (mod && mod.__esModule) | ||
return mod; | ||
var result = {}; | ||
if (mod != null) { | ||
for (var k in mod) | ||
if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) | ||
__createBinding(result, mod, k); | ||
} | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.objectsUtils = exports.Client = exports.Server = exports.getDefaultPort = void 0; | ||
module.exports = __toCommonJS(esm_exports); | ||
var import_objectsInRedisClient = require("./lib/objects/objectsInRedisClient.js"); | ||
var objectsUtils = __toESM(require("./lib/objects/objectsUtils.js"), 1); | ||
function getDefaultPort(host) { | ||
return host.includes(",") ? 26379 : 6379; | ||
} | ||
exports.getDefaultPort = getDefaultPort; | ||
exports.Server = null; | ||
var objectsInRedisClient_1 = require("./lib/objects/objectsInRedisClient"); | ||
Object.defineProperty(exports, "Client", { enumerable: true, get: function() { | ||
return objectsInRedisClient_1.ObjectsInRedisClient; | ||
} }); | ||
exports.objectsUtils = __importStar(require("./lib/objects/objectsUtils")); | ||
const Server = null; | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = { | ||
Client, | ||
Server, | ||
getDefaultPort, | ||
objectsUtils | ||
}); | ||
//# sourceMappingURL=index.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.GROUP_STARTS_WITH = exports.USER_STARTS_WITH = exports.REG_CHECK_ID = exports.ACCESS_CREATE = exports.ACCESS_DELETE = exports.ACCESS_LIST = exports.ACCESS_READ = exports.ACCESS_WRITE = exports.ACCESS_USER_ALL = exports.ACCESS_USER_RW = exports.ACCESS_USER_READ = exports.ACCESS_USER_WRITE = exports.ACCESS_USER_EXEC = exports.ACCESS_GROUP_ALL = exports.ACCESS_GROUP_RW = exports.ACCESS_GROUP_READ = exports.ACCESS_GROUP_WRITE = exports.ACCESS_GROUP_EXEC = exports.ACCESS_EVERY_ALL = exports.ACCESS_EVERY_RW = exports.ACCESS_EVERY_READ = exports.ACCESS_EVERY_WRITE = exports.ACCESS_EVERY_EXEC = exports.SYSTEM_ADMIN_GROUP = exports.SYSTEM_ADMIN_USER = exports.ERRORS = void 0; | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __export = (target, all) => { | ||
for (var name in all) | ||
__defProp(target, name, { get: all[name], enumerable: true }); | ||
}; | ||
var __copyProps = (to, from, except, desc) => { | ||
if (from && typeof from === "object" || typeof from === "function") { | ||
for (let key of __getOwnPropNames(from)) | ||
if (!__hasOwnProp.call(to, key) && key !== except) | ||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
} | ||
return to; | ||
}; | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
var constants_exports = {}; | ||
__export(constants_exports, { | ||
ACCESS_CREATE: () => ACCESS_CREATE, | ||
ACCESS_DELETE: () => ACCESS_DELETE, | ||
ACCESS_EVERY_ALL: () => ACCESS_EVERY_ALL, | ||
ACCESS_EVERY_EXEC: () => ACCESS_EVERY_EXEC, | ||
ACCESS_EVERY_READ: () => ACCESS_EVERY_READ, | ||
ACCESS_EVERY_RW: () => ACCESS_EVERY_RW, | ||
ACCESS_EVERY_WRITE: () => ACCESS_EVERY_WRITE, | ||
ACCESS_GROUP_ALL: () => ACCESS_GROUP_ALL, | ||
ACCESS_GROUP_EXEC: () => ACCESS_GROUP_EXEC, | ||
ACCESS_GROUP_READ: () => ACCESS_GROUP_READ, | ||
ACCESS_GROUP_RW: () => ACCESS_GROUP_RW, | ||
ACCESS_GROUP_WRITE: () => ACCESS_GROUP_WRITE, | ||
ACCESS_LIST: () => ACCESS_LIST, | ||
ACCESS_READ: () => ACCESS_READ, | ||
ACCESS_USER_ALL: () => ACCESS_USER_ALL, | ||
ACCESS_USER_EXEC: () => ACCESS_USER_EXEC, | ||
ACCESS_USER_READ: () => ACCESS_USER_READ, | ||
ACCESS_USER_RW: () => ACCESS_USER_RW, | ||
ACCESS_USER_WRITE: () => ACCESS_USER_WRITE, | ||
ACCESS_WRITE: () => ACCESS_WRITE, | ||
ERRORS: () => ERRORS, | ||
GROUP_STARTS_WITH: () => GROUP_STARTS_WITH, | ||
REG_CHECK_ID: () => REG_CHECK_ID, | ||
SYSTEM_ADMIN_GROUP: () => SYSTEM_ADMIN_GROUP, | ||
SYSTEM_ADMIN_USER: () => SYSTEM_ADMIN_USER, | ||
USER_STARTS_WITH: () => USER_STARTS_WITH | ||
}); | ||
module.exports = __toCommonJS(constants_exports); | ||
var ERRORS; | ||
@@ -9,28 +54,57 @@ (function(ERRORS2) { | ||
ERRORS2["ERROR_DB_CLOSED"] = "DB closed"; | ||
})(ERRORS || (exports.ERRORS = ERRORS = {})); | ||
exports.SYSTEM_ADMIN_USER = "system.user.admin"; | ||
exports.SYSTEM_ADMIN_GROUP = "system.group.administrator"; | ||
exports.ACCESS_EVERY_EXEC = 1; | ||
exports.ACCESS_EVERY_WRITE = 2; | ||
exports.ACCESS_EVERY_READ = 4; | ||
exports.ACCESS_EVERY_RW = exports.ACCESS_EVERY_WRITE | exports.ACCESS_EVERY_READ; | ||
exports.ACCESS_EVERY_ALL = exports.ACCESS_EVERY_WRITE | exports.ACCESS_EVERY_READ | exports.ACCESS_EVERY_EXEC; | ||
exports.ACCESS_GROUP_EXEC = 16; | ||
exports.ACCESS_GROUP_WRITE = 32; | ||
exports.ACCESS_GROUP_READ = 64; | ||
exports.ACCESS_GROUP_RW = exports.ACCESS_GROUP_WRITE | exports.ACCESS_GROUP_READ; | ||
exports.ACCESS_GROUP_ALL = exports.ACCESS_GROUP_WRITE | exports.ACCESS_GROUP_READ | exports.ACCESS_GROUP_EXEC; | ||
exports.ACCESS_USER_EXEC = 256; | ||
exports.ACCESS_USER_WRITE = 512; | ||
exports.ACCESS_USER_READ = 1024; | ||
exports.ACCESS_USER_RW = exports.ACCESS_USER_WRITE | exports.ACCESS_USER_READ; | ||
exports.ACCESS_USER_ALL = exports.ACCESS_USER_WRITE | exports.ACCESS_USER_READ | exports.ACCESS_USER_EXEC; | ||
exports.ACCESS_WRITE = 2; | ||
exports.ACCESS_READ = 4; | ||
exports.ACCESS_LIST = "list"; | ||
exports.ACCESS_DELETE = "delete"; | ||
exports.ACCESS_CREATE = "create"; | ||
exports.REG_CHECK_ID = /[*?[\]]|\$%\$/; | ||
exports.USER_STARTS_WITH = "system.user."; | ||
exports.GROUP_STARTS_WITH = "system.group."; | ||
})(ERRORS || (ERRORS = {})); | ||
const SYSTEM_ADMIN_USER = "system.user.admin"; | ||
const SYSTEM_ADMIN_GROUP = "system.group.administrator"; | ||
const ACCESS_EVERY_EXEC = 1; | ||
const ACCESS_EVERY_WRITE = 2; | ||
const ACCESS_EVERY_READ = 4; | ||
const ACCESS_EVERY_RW = ACCESS_EVERY_WRITE | ACCESS_EVERY_READ; | ||
const ACCESS_EVERY_ALL = ACCESS_EVERY_WRITE | ACCESS_EVERY_READ | ACCESS_EVERY_EXEC; | ||
const ACCESS_GROUP_EXEC = 16; | ||
const ACCESS_GROUP_WRITE = 32; | ||
const ACCESS_GROUP_READ = 64; | ||
const ACCESS_GROUP_RW = ACCESS_GROUP_WRITE | ACCESS_GROUP_READ; | ||
const ACCESS_GROUP_ALL = ACCESS_GROUP_WRITE | ACCESS_GROUP_READ | ACCESS_GROUP_EXEC; | ||
const ACCESS_USER_EXEC = 256; | ||
const ACCESS_USER_WRITE = 512; | ||
const ACCESS_USER_READ = 1024; | ||
const ACCESS_USER_RW = ACCESS_USER_WRITE | ACCESS_USER_READ; | ||
const ACCESS_USER_ALL = ACCESS_USER_WRITE | ACCESS_USER_READ | ACCESS_USER_EXEC; | ||
const ACCESS_WRITE = 2; | ||
const ACCESS_READ = 4; | ||
const ACCESS_LIST = "list"; | ||
const ACCESS_DELETE = "delete"; | ||
const ACCESS_CREATE = "create"; | ||
const REG_CHECK_ID = /[*?[\]]|\$%\$/; | ||
const USER_STARTS_WITH = "system.user."; | ||
const GROUP_STARTS_WITH = "system.group."; | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = { | ||
ACCESS_CREATE, | ||
ACCESS_DELETE, | ||
ACCESS_EVERY_ALL, | ||
ACCESS_EVERY_EXEC, | ||
ACCESS_EVERY_READ, | ||
ACCESS_EVERY_RW, | ||
ACCESS_EVERY_WRITE, | ||
ACCESS_GROUP_ALL, | ||
ACCESS_GROUP_EXEC, | ||
ACCESS_GROUP_READ, | ||
ACCESS_GROUP_RW, | ||
ACCESS_GROUP_WRITE, | ||
ACCESS_LIST, | ||
ACCESS_READ, | ||
ACCESS_USER_ALL, | ||
ACCESS_USER_EXEC, | ||
ACCESS_USER_READ, | ||
ACCESS_USER_RW, | ||
ACCESS_USER_WRITE, | ||
ACCESS_WRITE, | ||
ERRORS, | ||
GROUP_STARTS_WITH, | ||
REG_CHECK_ID, | ||
SYSTEM_ADMIN_GROUP, | ||
SYSTEM_ADMIN_USER, | ||
USER_STARTS_WITH | ||
}); | ||
//# sourceMappingURL=constants.js.map |
/// <reference types="@iobroker/types-dev" /> | ||
import type { ACLObject, CheckFileRightsCallback, GetUserGroupPromiseReturn } from './objectsUtils.js'; | ||
import type { ACLObject, CheckFileRightsCallback, GetUserGroupPromiseReturn } from '../../lib/objects/objectsUtils.js'; | ||
import type { InternalLogger } from '@iobroker/js-controller-common/tools'; | ||
@@ -4,0 +4,0 @@ import type { ConnectionOptions, DbStatus } from '@iobroker/db-base/inMemFileDB'; |
@@ -10,4 +10,4 @@ /** | ||
/// <reference types="@iobroker/types-dev" /> | ||
import * as CONSTS from './constants'; | ||
export * as CONSTS from './constants'; | ||
import * as CONSTS from '../../lib/objects/constants.js'; | ||
export * as CONSTS from '../../lib/objects/constants.js'; | ||
export declare const ERRORS: typeof CONSTS.ERRORS; | ||
@@ -14,0 +14,0 @@ export declare const REG_CHECK_ID: RegExp; |
"use strict"; | ||
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) { | ||
if (k2 === void 0) | ||
k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { | ||
return m[k]; | ||
} }; | ||
var __create = Object.create; | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __getProtoOf = Object.getPrototypeOf; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __export = (target, all) => { | ||
for (var name in all) | ||
__defProp(target, name, { get: all[name], enumerable: true }); | ||
}; | ||
var __copyProps = (to, from, except, desc) => { | ||
if (from && typeof from === "object" || typeof from === "function") { | ||
for (let key of __getOwnPropNames(from)) | ||
if (!__hasOwnProp.call(to, key) && key !== except) | ||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
} : function(o, m, k, k2) { | ||
if (k2 === void 0) | ||
k2 = k; | ||
o[k2] = m[k]; | ||
return to; | ||
}; | ||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( | ||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, | ||
mod | ||
)); | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
var objectsUtils_exports = {}; | ||
__export(objectsUtils_exports, { | ||
CONSTS: () => CONSTS2, | ||
ERRORS: () => ERRORS, | ||
REG_CHECK_ID: () => REG_CHECK_ID, | ||
checkFile: () => checkFile, | ||
checkFileRights: () => checkFileRights, | ||
checkObject: () => checkObject, | ||
checkObjectRights: () => checkObjectRights, | ||
getMimeType: () => getMimeType, | ||
getUserGroup: () => getUserGroup, | ||
sanitizePath: () => sanitizePath | ||
}); | ||
var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
} : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = exports && exports.__importStar || function(mod) { | ||
if (mod && mod.__esModule) | ||
return mod; | ||
var result = {}; | ||
if (mod != null) { | ||
for (var k in mod) | ||
if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) | ||
__createBinding(result, mod, k); | ||
} | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __importDefault = exports && exports.__importDefault || function(mod) { | ||
return mod && mod.__esModule ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.checkObjectRights = exports.checkObject = exports.sanitizePath = exports.getUserGroup = exports.checkFileRights = exports.checkFile = exports.getMimeType = exports.REG_CHECK_ID = exports.ERRORS = exports.CONSTS = void 0; | ||
const node_path_1 = __importDefault(require("node:path")); | ||
const deep_clone_1 = __importDefault(require("deep-clone")); | ||
const db_base_1 = require("@iobroker/db-base"); | ||
const CONSTS = __importStar(require("./constants")); | ||
const mime_types_1 = __importDefault(require("mime-types")); | ||
exports.CONSTS = __importStar(require("./constants")); | ||
exports.ERRORS = CONSTS.ERRORS; | ||
exports.REG_CHECK_ID = CONSTS.REG_CHECK_ID; | ||
module.exports = __toCommonJS(objectsUtils_exports); | ||
var import_node_path = __toESM(require("node:path"), 1); | ||
var import_deep_clone = __toESM(require("deep-clone"), 1); | ||
var import_db_base = require("@iobroker/db-base"); | ||
var CONSTS = __toESM(require("../../lib/objects/constants.js"), 1); | ||
var import_mime_types = __toESM(require("mime-types"), 1); | ||
var CONSTS2 = __toESM(require("../../lib/objects/constants.js"), 1); | ||
const ERRORS = CONSTS.ERRORS; | ||
const REG_CHECK_ID = CONSTS.REG_CHECK_ID; | ||
const USER_STARTS_WITH = CONSTS.USER_STARTS_WITH; | ||
@@ -52,3 +52,3 @@ const GROUP_STARTS_WITH = CONSTS.GROUP_STARTS_WITH; | ||
try { | ||
const mimeType = mime_types_1.default.lookup(ext); | ||
const mimeType = import_mime_types.default.lookup(ext); | ||
if (mimeType) { | ||
@@ -108,7 +108,6 @@ return { mimeType, isBinary: !mimeType.startsWith("text/") && !textTypes.includes(ext) }; | ||
} | ||
exports.getMimeType = getMimeType; | ||
function checkFile(fileOptions, options, flag, defaultNewAcl) { | ||
if (typeof fileOptions.acl !== "object") { | ||
fileOptions = {}; | ||
fileOptions.mimeType = (0, deep_clone_1.default)(fileOptions); | ||
fileOptions.mimeType = (0, import_deep_clone.default)(fileOptions); | ||
fileOptions.acl = { | ||
@@ -142,3 +141,2 @@ owner: defaultNewAcl && defaultNewAcl.owner || CONSTS.SYSTEM_ADMIN_USER, | ||
} | ||
exports.checkFile = checkFile; | ||
function checkFileRights(objects, id, name, options, flag, callback) { | ||
@@ -161,6 +159,6 @@ const _options = options || {}; | ||
if (flag === CONSTS.ACCESS_WRITE && !_options.acl.file.write) { | ||
return db_base_1.tools.maybeCallbackWithError(callback, exports.ERRORS.ERROR_PERMISSION, _options); | ||
return import_db_base.tools.maybeCallbackWithError(callback, ERRORS.ERROR_PERMISSION, _options); | ||
} | ||
if (flag === CONSTS.ACCESS_READ && !_options.acl.file.read) { | ||
return db_base_1.tools.maybeCallbackWithError(callback, exports.ERRORS.ERROR_PERMISSION, _options); | ||
return import_db_base.tools.maybeCallbackWithError(callback, ERRORS.ERROR_PERMISSION, _options); | ||
} | ||
@@ -170,9 +168,8 @@ _options.checked = true; | ||
if (err) { | ||
return db_base_1.tools.maybeCallbackWithError(callback, exports.ERRORS.ERROR_PERMISSION, options2); | ||
return import_db_base.tools.maybeCallbackWithError(callback, ERRORS.ERROR_PERMISSION, options2); | ||
} else { | ||
return db_base_1.tools.maybeCallbackWithError(callback, null, options2, opt); | ||
return import_db_base.tools.maybeCallbackWithError(callback, null, options2, opt); | ||
} | ||
}); | ||
} | ||
exports.checkFileRights = checkFileRights; | ||
function getDefaultAdminRights(acl, _isState) { | ||
@@ -219,6 +216,6 @@ return { | ||
console.log(`invalid user name: ${user}`); | ||
return db_base_1.tools.maybeCallbackWithError(callback, `invalid user name: ${user}`, (0, deep_clone_1.default)(user), [], (0, deep_clone_1.default)(defaultAcl.acl)); | ||
return import_db_base.tools.maybeCallbackWithError(callback, `invalid user name: ${user}`, (0, import_deep_clone.default)(user), [], (0, import_deep_clone.default)(defaultAcl.acl)); | ||
} | ||
if (users[user]) { | ||
return db_base_1.tools.maybeCallbackWithError(callback, null, user, users[user].groups, users[user].acl); | ||
return import_db_base.tools.maybeCallbackWithError(callback, null, user, users[user].groups, users[user].acl); | ||
} | ||
@@ -244,3 +241,2 @@ let error; | ||
objects.getObjectList({ startkey: "system.user.", endkey: "system.user.\u9999" }, { checked: true }, (err2, arr2) => { | ||
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j; | ||
if (err2) { | ||
@@ -252,6 +248,6 @@ error = err2; | ||
for (const row of arr2.rows) { | ||
users[row.value._id] = (0, deep_clone_1.default)(defaultAcl); | ||
users[row.value._id] = (0, import_deep_clone.default)(defaultAcl); | ||
} | ||
} | ||
users[CONSTS.SYSTEM_ADMIN_USER] = users[CONSTS.SYSTEM_ADMIN_USER] || (0, deep_clone_1.default)(defaultAcl); | ||
users[CONSTS.SYSTEM_ADMIN_USER] = users[CONSTS.SYSTEM_ADMIN_USER] || (0, import_deep_clone.default)(defaultAcl); | ||
users[CONSTS.SYSTEM_ADMIN_USER].acl = getDefaultAdminRights(users[CONSTS.SYSTEM_ADMIN_USER].acl); | ||
@@ -324,13 +320,13 @@ for (let g = 0; g < groups.length; g++) { | ||
users[u].acl.state = users[u].acl.state || {}; | ||
users[u].acl.state.create = (_a = groups[g].common.acl.state) == null ? void 0 : _a.create; | ||
users[u].acl.state.read = (_b = groups[g].common.acl.state) == null ? void 0 : _b.read; | ||
users[u].acl.state.write = (_c = groups[g].common.acl.state) == null ? void 0 : _c.write; | ||
users[u].acl.state.delete = (_d = groups[g].common.acl.state) == null ? void 0 : _d.delete; | ||
users[u].acl.state.list = (_e = groups[g].common.acl.state) == null ? void 0 : _e.list; | ||
users[u].acl.state.create = groups[g].common.acl.state?.create; | ||
users[u].acl.state.read = groups[g].common.acl.state?.read; | ||
users[u].acl.state.write = groups[g].common.acl.state?.write; | ||
users[u].acl.state.delete = groups[g].common.acl.state?.delete; | ||
users[u].acl.state.list = groups[g].common.acl.state?.list; | ||
} else { | ||
users[u].acl.state.create = users[u].acl.state.create || ((_f = groups[g].common.acl.state) == null ? void 0 : _f.create); | ||
users[u].acl.state.read = users[u].acl.state.read || ((_g = groups[g].common.acl.state) == null ? void 0 : _g.read); | ||
users[u].acl.state.write = users[u].acl.state.write || ((_h = groups[g].common.acl.state) == null ? void 0 : _h.write); | ||
users[u].acl.state.delete = users[u].acl.state.delete || ((_i = groups[g].common.acl.state) == null ? void 0 : _i.delete); | ||
users[u].acl.state.list = users[u].acl.state.list || ((_j = groups[g].common.acl.state) == null ? void 0 : _j.list); | ||
users[u].acl.state.create = users[u].acl.state.create || groups[g].common.acl.state?.create; | ||
users[u].acl.state.read = users[u].acl.state.read || groups[g].common.acl.state?.read; | ||
users[u].acl.state.write = users[u].acl.state.write || groups[g].common.acl.state?.write; | ||
users[u].acl.state.delete = users[u].acl.state.delete || groups[g].common.acl.state?.delete; | ||
users[u].acl.state.list = users[u].acl.state.list || groups[g].common.acl.state?.list; | ||
} | ||
@@ -340,7 +336,6 @@ } | ||
} | ||
return db_base_1.tools.maybeCallbackWithError(callback, error, user, users[user] ? users[user].groups : [], users[user] ? users[user].acl : (0, deep_clone_1.default)(defaultAcl.acl)); | ||
return import_db_base.tools.maybeCallbackWithError(callback, error, user, users[user] ? users[user].groups : [], users[user] ? users[user].acl : (0, import_deep_clone.default)(defaultAcl.acl)); | ||
}); | ||
}); | ||
} | ||
exports.getUserGroup = getUserGroup; | ||
function sanitizePath(id, name) { | ||
@@ -359,7 +354,7 @@ if (!name) { | ||
if (name.includes("..")) { | ||
name = node_path_1.default.normalize("/" + name); | ||
name = import_node_path.default.normalize("/" + name); | ||
} | ||
if (name.includes("..")) { | ||
name = name.replace(/\.\./g, ""); | ||
name = node_path_1.default.normalize("/" + name); | ||
name = import_node_path.default.normalize("/" + name); | ||
} | ||
@@ -372,3 +367,2 @@ name = name.replace(/\\/g, "/"); | ||
} | ||
exports.sanitizePath = sanitizePath; | ||
function checkObject(obj, options, flag) { | ||
@@ -404,3 +398,2 @@ if (!obj || !("common" in obj) || !obj.acl || flag === CONSTS.ACCESS_LIST) { | ||
} | ||
exports.checkObject = checkObject; | ||
function checkObjectRights(objects, id, object, options, flag, callback) { | ||
@@ -427,19 +420,19 @@ options = options || {}; | ||
if (options.user === CONSTS.SYSTEM_ADMIN_USER || options.group === CONSTS.SYSTEM_ADMIN_GROUP || options.groups && options.groups.includes(CONSTS.SYSTEM_ADMIN_GROUP)) { | ||
return db_base_1.tools.maybeCallbackWithError(callback, null, options); | ||
return import_db_base.tools.maybeCallbackWithError(callback, null, options); | ||
} | ||
if (typeof id === "string" && (id.startsWith(USER_STARTS_WITH) || id.startsWith(GROUP_STARTS_WITH))) { | ||
if (flag === CONSTS.ACCESS_WRITE && !options.acl.users.write) { | ||
return db_base_1.tools.maybeCallbackWithError(callback, exports.ERRORS.ERROR_PERMISSION, options); | ||
return import_db_base.tools.maybeCallbackWithError(callback, ERRORS.ERROR_PERMISSION, options); | ||
} | ||
if (flag === CONSTS.ACCESS_READ && !options.acl.users.read) { | ||
return db_base_1.tools.maybeCallbackWithError(callback, exports.ERRORS.ERROR_PERMISSION, options); | ||
return import_db_base.tools.maybeCallbackWithError(callback, ERRORS.ERROR_PERMISSION, options); | ||
} | ||
if (flag === CONSTS.ACCESS_DELETE && !options.acl.users.delete) { | ||
return db_base_1.tools.maybeCallbackWithError(callback, exports.ERRORS.ERROR_PERMISSION, options); | ||
return import_db_base.tools.maybeCallbackWithError(callback, ERRORS.ERROR_PERMISSION, options); | ||
} | ||
if (flag === CONSTS.ACCESS_LIST && !options.acl.users.list) { | ||
return db_base_1.tools.maybeCallbackWithError(callback, exports.ERRORS.ERROR_PERMISSION, options); | ||
return import_db_base.tools.maybeCallbackWithError(callback, ERRORS.ERROR_PERMISSION, options); | ||
} | ||
if (flag === CONSTS.ACCESS_CREATE && !options.acl.users.create) { | ||
return db_base_1.tools.maybeCallbackWithError(callback, exports.ERRORS.ERROR_PERMISSION, options); | ||
return import_db_base.tools.maybeCallbackWithError(callback, ERRORS.ERROR_PERMISSION, options); | ||
} | ||
@@ -451,12 +444,12 @@ if (flag === CONSTS.ACCESS_DELETE) { | ||
if (flag === CONSTS.ACCESS_WRITE && !options.acl.object.write) { | ||
db_base_1.tools.maybeCallbackWithError(callback, exports.ERRORS.ERROR_PERMISSION, options); | ||
import_db_base.tools.maybeCallbackWithError(callback, ERRORS.ERROR_PERMISSION, options); | ||
} | ||
if (flag === CONSTS.ACCESS_READ && !options.acl.object.read) { | ||
return db_base_1.tools.maybeCallbackWithError(callback, exports.ERRORS.ERROR_PERMISSION, options); | ||
return import_db_base.tools.maybeCallbackWithError(callback, ERRORS.ERROR_PERMISSION, options); | ||
} | ||
if (flag === CONSTS.ACCESS_DELETE && !options.acl.object.delete) { | ||
return db_base_1.tools.maybeCallbackWithError(callback, exports.ERRORS.ERROR_PERMISSION, options); | ||
return import_db_base.tools.maybeCallbackWithError(callback, ERRORS.ERROR_PERMISSION, options); | ||
} | ||
if (flag === CONSTS.ACCESS_LIST && !options.acl.object.list) { | ||
return db_base_1.tools.maybeCallbackWithError(callback, exports.ERRORS.ERROR_PERMISSION, options); | ||
return import_db_base.tools.maybeCallbackWithError(callback, ERRORS.ERROR_PERMISSION, options); | ||
} | ||
@@ -467,8 +460,20 @@ if (flag === CONSTS.ACCESS_DELETE) { | ||
if (id && !checkObject(object, options, flag)) { | ||
return db_base_1.tools.maybeCallbackWithError(callback, exports.ERRORS.ERROR_PERMISSION, options); | ||
return import_db_base.tools.maybeCallbackWithError(callback, ERRORS.ERROR_PERMISSION, options); | ||
} else { | ||
return db_base_1.tools.maybeCallbackWithError(callback, null, options); | ||
return import_db_base.tools.maybeCallbackWithError(callback, null, options); | ||
} | ||
} | ||
exports.checkObjectRights = checkObjectRights; | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = { | ||
CONSTS, | ||
ERRORS, | ||
REG_CHECK_ID, | ||
checkFile, | ||
checkFileRights, | ||
checkObject, | ||
checkObjectRights, | ||
getMimeType, | ||
getUserGroup, | ||
sanitizePath | ||
}); | ||
//# sourceMappingURL=objectsUtils.js.map |
@@ -7,4 +7,4 @@ /** | ||
export declare const Server: null; | ||
export { ObjectsInRedisClient as Client } from './lib/objects/objectsInRedisClient'; | ||
export * as objectsUtils from './lib/objects/objectsUtils'; | ||
export { ObjectsInRedisClient as Client } from './lib/objects/objectsInRedisClient.js'; | ||
export * as objectsUtils from './lib/objects/objectsUtils.js'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,27 +0,1 @@ | ||
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.objectsUtils = exports.Client = exports.Server = exports.getDefaultPort = void 0; | ||
/** | ||
@@ -31,10 +5,8 @@ * | ||
*/ | ||
function getDefaultPort(host) { | ||
export function getDefaultPort(host) { | ||
return host.includes(',') ? 26379 : 6379; | ||
} | ||
exports.getDefaultPort = getDefaultPort; | ||
exports.Server = null; | ||
var objectsInRedisClient_1 = require("./lib/objects/objectsInRedisClient"); | ||
Object.defineProperty(exports, "Client", { enumerable: true, get: function () { return objectsInRedisClient_1.ObjectsInRedisClient; } }); | ||
exports.objectsUtils = __importStar(require("./lib/objects/objectsUtils")); | ||
export const Server = null; | ||
export { ObjectsInRedisClient as Client } from './lib/objects/objectsInRedisClient.js'; | ||
export * as objectsUtils from './lib/objects/objectsUtils.js'; | ||
//# sourceMappingURL=index.js.map |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.GROUP_STARTS_WITH = exports.USER_STARTS_WITH = exports.REG_CHECK_ID = exports.ACCESS_CREATE = exports.ACCESS_DELETE = exports.ACCESS_LIST = exports.ACCESS_READ = exports.ACCESS_WRITE = exports.ACCESS_USER_ALL = exports.ACCESS_USER_RW = exports.ACCESS_USER_READ = exports.ACCESS_USER_WRITE = exports.ACCESS_USER_EXEC = exports.ACCESS_GROUP_ALL = exports.ACCESS_GROUP_RW = exports.ACCESS_GROUP_READ = exports.ACCESS_GROUP_WRITE = exports.ACCESS_GROUP_EXEC = exports.ACCESS_EVERY_ALL = exports.ACCESS_EVERY_RW = exports.ACCESS_EVERY_READ = exports.ACCESS_EVERY_WRITE = exports.ACCESS_EVERY_EXEC = exports.SYSTEM_ADMIN_GROUP = exports.SYSTEM_ADMIN_USER = exports.ERRORS = void 0; | ||
var ERRORS; | ||
export var ERRORS; | ||
(function (ERRORS) { | ||
@@ -9,28 +6,28 @@ ERRORS["ERROR_PERMISSION"] = "permissionError"; | ||
ERRORS["ERROR_DB_CLOSED"] = "DB closed"; | ||
})(ERRORS || (exports.ERRORS = ERRORS = {})); | ||
exports.SYSTEM_ADMIN_USER = 'system.user.admin'; | ||
exports.SYSTEM_ADMIN_GROUP = 'system.group.administrator'; | ||
exports.ACCESS_EVERY_EXEC = 0x1; | ||
exports.ACCESS_EVERY_WRITE = 0x2; | ||
exports.ACCESS_EVERY_READ = 0x4; | ||
exports.ACCESS_EVERY_RW = exports.ACCESS_EVERY_WRITE | exports.ACCESS_EVERY_READ; | ||
exports.ACCESS_EVERY_ALL = exports.ACCESS_EVERY_WRITE | exports.ACCESS_EVERY_READ | exports.ACCESS_EVERY_EXEC; | ||
exports.ACCESS_GROUP_EXEC = 0x10; | ||
exports.ACCESS_GROUP_WRITE = 0x20; | ||
exports.ACCESS_GROUP_READ = 0x40; | ||
exports.ACCESS_GROUP_RW = exports.ACCESS_GROUP_WRITE | exports.ACCESS_GROUP_READ; | ||
exports.ACCESS_GROUP_ALL = exports.ACCESS_GROUP_WRITE | exports.ACCESS_GROUP_READ | exports.ACCESS_GROUP_EXEC; | ||
exports.ACCESS_USER_EXEC = 0x100; | ||
exports.ACCESS_USER_WRITE = 0x200; | ||
exports.ACCESS_USER_READ = 0x400; | ||
exports.ACCESS_USER_RW = exports.ACCESS_USER_WRITE | exports.ACCESS_USER_READ; | ||
exports.ACCESS_USER_ALL = exports.ACCESS_USER_WRITE | exports.ACCESS_USER_READ | exports.ACCESS_USER_EXEC; | ||
exports.ACCESS_WRITE = 0x2; | ||
exports.ACCESS_READ = 0x4; | ||
exports.ACCESS_LIST = 'list'; | ||
exports.ACCESS_DELETE = 'delete'; | ||
exports.ACCESS_CREATE = 'create'; | ||
exports.REG_CHECK_ID = /[*?[\]]|\$%\$/; | ||
exports.USER_STARTS_WITH = 'system.user.'; | ||
exports.GROUP_STARTS_WITH = 'system.group.'; | ||
})(ERRORS || (ERRORS = {})); | ||
export const SYSTEM_ADMIN_USER = 'system.user.admin'; | ||
export const SYSTEM_ADMIN_GROUP = 'system.group.administrator'; | ||
export const ACCESS_EVERY_EXEC = 0x1; | ||
export const ACCESS_EVERY_WRITE = 0x2; | ||
export const ACCESS_EVERY_READ = 0x4; | ||
export const ACCESS_EVERY_RW = ACCESS_EVERY_WRITE | ACCESS_EVERY_READ; | ||
export const ACCESS_EVERY_ALL = ACCESS_EVERY_WRITE | ACCESS_EVERY_READ | ACCESS_EVERY_EXEC; | ||
export const ACCESS_GROUP_EXEC = 0x10; | ||
export const ACCESS_GROUP_WRITE = 0x20; | ||
export const ACCESS_GROUP_READ = 0x40; | ||
export const ACCESS_GROUP_RW = ACCESS_GROUP_WRITE | ACCESS_GROUP_READ; | ||
export const ACCESS_GROUP_ALL = ACCESS_GROUP_WRITE | ACCESS_GROUP_READ | ACCESS_GROUP_EXEC; | ||
export const ACCESS_USER_EXEC = 0x100; | ||
export const ACCESS_USER_WRITE = 0x200; | ||
export const ACCESS_USER_READ = 0x400; | ||
export const ACCESS_USER_RW = ACCESS_USER_WRITE | ACCESS_USER_READ; | ||
export const ACCESS_USER_ALL = ACCESS_USER_WRITE | ACCESS_USER_READ | ACCESS_USER_EXEC; | ||
export const ACCESS_WRITE = 0x2; | ||
export const ACCESS_READ = 0x4; | ||
export const ACCESS_LIST = 'list'; | ||
export const ACCESS_DELETE = 'delete'; | ||
export const ACCESS_CREATE = 'create'; | ||
export const REG_CHECK_ID = /[*?[\]]|\$%\$/; | ||
export const USER_STARTS_WITH = 'system.user.'; | ||
export const GROUP_STARTS_WITH = 'system.group.'; | ||
//# sourceMappingURL=constants.js.map |
/// <reference types="@iobroker/types-dev" /> | ||
import type { ACLObject, CheckFileRightsCallback, GetUserGroupPromiseReturn } from './objectsUtils.js'; | ||
import type { ACLObject, CheckFileRightsCallback, GetUserGroupPromiseReturn } from '../../lib/objects/objectsUtils.js'; | ||
import type { InternalLogger } from '@iobroker/js-controller-common/tools'; | ||
@@ -4,0 +4,0 @@ import type { ConnectionOptions, DbStatus } from '@iobroker/db-base/inMemFileDB'; |
@@ -10,4 +10,4 @@ /** | ||
/// <reference types="@iobroker/types-dev" /> | ||
import * as CONSTS from './constants'; | ||
export * as CONSTS from './constants'; | ||
import * as CONSTS from '../../lib/objects/constants.js'; | ||
export * as CONSTS from '../../lib/objects/constants.js'; | ||
export declare const ERRORS: typeof CONSTS.ERRORS; | ||
@@ -14,0 +14,0 @@ export declare const REG_CHECK_ID: RegExp; |
@@ -1,2 +0,1 @@ | ||
"use strict"; | ||
/** | ||
@@ -10,38 +9,10 @@ * Common functions between client and server | ||
*/ | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.checkObjectRights = exports.checkObject = exports.sanitizePath = exports.getUserGroup = exports.checkFileRights = exports.checkFile = exports.getMimeType = exports.REG_CHECK_ID = exports.ERRORS = exports.CONSTS = void 0; | ||
const node_path_1 = __importDefault(require("node:path")); | ||
const deep_clone_1 = __importDefault(require("deep-clone")); | ||
const db_base_1 = require("@iobroker/db-base"); | ||
const CONSTS = __importStar(require("./constants")); | ||
const mime_types_1 = __importDefault(require("mime-types")); | ||
exports.CONSTS = __importStar(require("./constants")); | ||
exports.ERRORS = CONSTS.ERRORS; | ||
exports.REG_CHECK_ID = CONSTS.REG_CHECK_ID; | ||
import path from 'node:path'; | ||
import deepClone from 'deep-clone'; | ||
import { tools } from '@iobroker/db-base'; | ||
import * as CONSTS from '../../lib/objects/constants.js'; | ||
import mime from 'mime-types'; | ||
export * as CONSTS from '../../lib/objects/constants.js'; | ||
export const ERRORS = CONSTS.ERRORS; | ||
export const REG_CHECK_ID = CONSTS.REG_CHECK_ID; | ||
const USER_STARTS_WITH = CONSTS.USER_STARTS_WITH; | ||
@@ -57,3 +28,3 @@ const GROUP_STARTS_WITH = CONSTS.GROUP_STARTS_WITH; | ||
try { | ||
const mimeType = mime_types_1.default.lookup(ext); | ||
const mimeType = mime.lookup(ext); | ||
if (mimeType) { | ||
@@ -111,3 +82,3 @@ return { mimeType, isBinary: !mimeType.startsWith('text/') && !textTypes.includes(ext) }; | ||
*/ | ||
function getMimeType(ext, isTextData) { | ||
export function getMimeType(ext, isTextData) { | ||
if (!ext) { | ||
@@ -125,7 +96,6 @@ return { mimeType: isTextData ? 'text/plain' : 'application/octet-stream', isBinary: !isTextData }; | ||
} | ||
exports.getMimeType = getMimeType; | ||
function checkFile(fileOptions, options, flag, defaultNewAcl) { | ||
export function checkFile(fileOptions, options, flag, defaultNewAcl) { | ||
if (typeof fileOptions.acl !== 'object') { | ||
fileOptions = {}; | ||
fileOptions.mimeType = (0, deep_clone_1.default)(fileOptions); | ||
fileOptions.mimeType = deepClone(fileOptions); | ||
fileOptions.acl = { | ||
@@ -173,4 +143,3 @@ owner: (defaultNewAcl && defaultNewAcl.owner) || CONSTS.SYSTEM_ADMIN_USER, | ||
} | ||
exports.checkFile = checkFile; | ||
function checkFileRights(objects, id, name, options, flag, callback) { | ||
export function checkFileRights(objects, id, name, options, flag, callback) { | ||
const _options = options || {}; | ||
@@ -195,3 +164,3 @@ if (!_options.user) { | ||
// write | ||
return db_base_1.tools.maybeCallbackWithError(callback, exports.ERRORS.ERROR_PERMISSION, _options); | ||
return tools.maybeCallbackWithError(callback, ERRORS.ERROR_PERMISSION, _options); | ||
} | ||
@@ -201,3 +170,3 @@ // If user may read | ||
// read | ||
return db_base_1.tools.maybeCallbackWithError(callback, exports.ERRORS.ERROR_PERMISSION, _options); | ||
return tools.maybeCallbackWithError(callback, ERRORS.ERROR_PERMISSION, _options); | ||
} | ||
@@ -207,10 +176,9 @@ _options.checked = true; | ||
if (err) { | ||
return db_base_1.tools.maybeCallbackWithError(callback, exports.ERRORS.ERROR_PERMISSION, options); | ||
return tools.maybeCallbackWithError(callback, ERRORS.ERROR_PERMISSION, options); | ||
} | ||
else { | ||
return db_base_1.tools.maybeCallbackWithError(callback, null, options, opt); | ||
return tools.maybeCallbackWithError(callback, null, options, opt); | ||
} | ||
}); | ||
} | ||
exports.checkFileRights = checkFileRights; | ||
// For users and groups | ||
@@ -255,9 +223,9 @@ function getDefaultAdminRights(acl, _isState) { | ||
} | ||
function getUserGroup(objects, user, callback) { | ||
export function getUserGroup(objects, user, callback) { | ||
if (!user || typeof user !== 'string' || !user.startsWith(USER_STARTS_WITH)) { | ||
console.log(`invalid user name: ${user}`); | ||
return db_base_1.tools.maybeCallbackWithError(callback, `invalid user name: ${user}`, (0, deep_clone_1.default)(user), [], (0, deep_clone_1.default)(defaultAcl.acl)); | ||
return tools.maybeCallbackWithError(callback, `invalid user name: ${user}`, deepClone(user), [], deepClone(defaultAcl.acl)); | ||
} | ||
if (users[user]) { | ||
return db_base_1.tools.maybeCallbackWithError(callback, null, user, users[user].groups, users[user].acl); | ||
return tools.maybeCallbackWithError(callback, null, user, users[user].groups, users[user].acl); | ||
} | ||
@@ -292,6 +260,6 @@ let error; | ||
// cannot use here Object.assign, because required deep copy | ||
users[row.value._id] = (0, deep_clone_1.default)(defaultAcl); | ||
users[row.value._id] = deepClone(defaultAcl); | ||
} | ||
} | ||
users[CONSTS.SYSTEM_ADMIN_USER] = users[CONSTS.SYSTEM_ADMIN_USER] || (0, deep_clone_1.default)(defaultAcl); | ||
users[CONSTS.SYSTEM_ADMIN_USER] = users[CONSTS.SYSTEM_ADMIN_USER] || deepClone(defaultAcl); | ||
users[CONSTS.SYSTEM_ADMIN_USER].acl = getDefaultAdminRights(users[CONSTS.SYSTEM_ADMIN_USER].acl); | ||
@@ -403,8 +371,7 @@ for (let g = 0; g < groups.length; g++) { | ||
} | ||
return db_base_1.tools.maybeCallbackWithError(callback, error, user, users[user] ? users[user].groups : [], users[user] ? users[user].acl : (0, deep_clone_1.default)(defaultAcl.acl)); | ||
return tools.maybeCallbackWithError(callback, error, user, users[user] ? users[user].groups : [], users[user] ? users[user].acl : deepClone(defaultAcl.acl)); | ||
}); | ||
}); | ||
} | ||
exports.getUserGroup = getUserGroup; | ||
function sanitizePath(id, name) { | ||
export function sanitizePath(id, name) { | ||
if (!name) { | ||
@@ -422,3 +389,3 @@ name = ''; | ||
if (name.includes('..')) { | ||
name = node_path_1.default.normalize('/' + name); | ||
name = path.normalize('/' + name); | ||
} | ||
@@ -428,3 +395,3 @@ if (name.includes('..')) { | ||
name = name.replace(/\.\./g, ''); | ||
name = node_path_1.default.normalize('/' + name); | ||
name = path.normalize('/' + name); | ||
} | ||
@@ -437,4 +404,3 @@ name = name.replace(/\\/g, '/'); // replace win path backslashes | ||
} | ||
exports.sanitizePath = sanitizePath; | ||
function checkObject(obj, options, flag) { | ||
export function checkObject(obj, options, flag) { | ||
// read rights of object | ||
@@ -480,4 +446,3 @@ if (!obj || !('common' in obj) || !obj.acl || flag === CONSTS.ACCESS_LIST) { | ||
} | ||
exports.checkObject = checkObject; | ||
function checkObjectRights(objects, id, object, options, flag, callback) { | ||
export function checkObjectRights(objects, id, object, options, flag, callback) { | ||
options = options || {}; | ||
@@ -508,3 +473,3 @@ if (!options.user) { | ||
(options.groups && options.groups.includes(CONSTS.SYSTEM_ADMIN_GROUP))) { | ||
return db_base_1.tools.maybeCallbackWithError(callback, null, options); | ||
return tools.maybeCallbackWithError(callback, null, options); | ||
} | ||
@@ -516,3 +481,3 @@ // if user or group objects | ||
// write | ||
return db_base_1.tools.maybeCallbackWithError(callback, exports.ERRORS.ERROR_PERMISSION, options); | ||
return tools.maybeCallbackWithError(callback, ERRORS.ERROR_PERMISSION, options); | ||
} | ||
@@ -522,3 +487,3 @@ // If user may read | ||
// read | ||
return db_base_1.tools.maybeCallbackWithError(callback, exports.ERRORS.ERROR_PERMISSION, options); | ||
return tools.maybeCallbackWithError(callback, ERRORS.ERROR_PERMISSION, options); | ||
} | ||
@@ -528,3 +493,3 @@ // If user may delete | ||
// delete | ||
return db_base_1.tools.maybeCallbackWithError(callback, exports.ERRORS.ERROR_PERMISSION, options); | ||
return tools.maybeCallbackWithError(callback, ERRORS.ERROR_PERMISSION, options); | ||
} | ||
@@ -534,3 +499,3 @@ // If user may list | ||
// list | ||
return db_base_1.tools.maybeCallbackWithError(callback, exports.ERRORS.ERROR_PERMISSION, options); | ||
return tools.maybeCallbackWithError(callback, ERRORS.ERROR_PERMISSION, options); | ||
} | ||
@@ -540,3 +505,3 @@ // If user may create | ||
// create | ||
return db_base_1.tools.maybeCallbackWithError(callback, exports.ERRORS.ERROR_PERMISSION, options); | ||
return tools.maybeCallbackWithError(callback, ERRORS.ERROR_PERMISSION, options); | ||
} | ||
@@ -552,3 +517,3 @@ // If user may write | ||
// write | ||
db_base_1.tools.maybeCallbackWithError(callback, exports.ERRORS.ERROR_PERMISSION, options); | ||
tools.maybeCallbackWithError(callback, ERRORS.ERROR_PERMISSION, options); | ||
} | ||
@@ -558,3 +523,3 @@ // If user may read | ||
// read | ||
return db_base_1.tools.maybeCallbackWithError(callback, exports.ERRORS.ERROR_PERMISSION, options); | ||
return tools.maybeCallbackWithError(callback, ERRORS.ERROR_PERMISSION, options); | ||
} | ||
@@ -564,3 +529,3 @@ // If user may delete | ||
// delete | ||
return db_base_1.tools.maybeCallbackWithError(callback, exports.ERRORS.ERROR_PERMISSION, options); | ||
return tools.maybeCallbackWithError(callback, ERRORS.ERROR_PERMISSION, options); | ||
} | ||
@@ -570,3 +535,3 @@ // If user may list | ||
// list | ||
return db_base_1.tools.maybeCallbackWithError(callback, exports.ERRORS.ERROR_PERMISSION, options); | ||
return tools.maybeCallbackWithError(callback, ERRORS.ERROR_PERMISSION, options); | ||
} | ||
@@ -578,9 +543,8 @@ if (flag === CONSTS.ACCESS_DELETE) { | ||
if (id && !checkObject(object, options, flag)) { | ||
return db_base_1.tools.maybeCallbackWithError(callback, exports.ERRORS.ERROR_PERMISSION, options); | ||
return tools.maybeCallbackWithError(callback, ERRORS.ERROR_PERMISSION, options); | ||
} | ||
else { | ||
return db_base_1.tools.maybeCallbackWithError(callback, null, options); | ||
return tools.maybeCallbackWithError(callback, null, options); | ||
} | ||
} | ||
exports.checkObjectRights = checkObjectRights; | ||
//# sourceMappingURL=objectsUtils.js.map |
{ | ||
"name": "@iobroker/db-objects-redis", | ||
"version": "5.0.20-alpha.0-20240409-d68ed299", | ||
"type": "module", | ||
"version": "5.0.20-alpha.0-20240418-165fc4c8", | ||
"engines": { | ||
@@ -8,3 +9,3 @@ "node": ">=16.4.0" | ||
"dependencies": { | ||
"@iobroker/db-base": "5.0.20-alpha.0-20240409-d68ed299", | ||
"@iobroker/db-base": "5.0.20-alpha.0-20240418-165fc4c8", | ||
"deep-clone": "^3.0.3", | ||
@@ -32,4 +33,4 @@ "ioredis": "^4.28.2", | ||
"scripts": { | ||
"build": "tsc -b tsconfig.build.json", | ||
"postbuild": "esm2cjs --in build/esm --out build/cjs -l error && cpy ./lib/objects/**/*.lua ./build/esm/lib/objects/ --cwd=src && cpy ./lib/objects/**/*.lua ./build/cjs/lib/objects/ --cwd=src && cpy ./**/*.d.ts ./build/cjs/ --cwd=build/esm/" | ||
"build": "tsc -b tsconfig.build.json && tsc-alias", | ||
"postbuild": "esm2cjs --in build/esm --out build/cjs -l error -t node18 && cpy ./lib/objects/**/*.lua ./build/esm/lib/objects/ --cwd=src && cpy ./lib/objects/**/*.lua ./build/cjs/lib/objects/ --cwd=src && cpy ./**/*.d.ts ./build/cjs/ --cwd=build/esm/" | ||
}, | ||
@@ -53,3 +54,3 @@ "main": "build/cjs/index.js", | ||
], | ||
"gitHead": "177223a8779da419012abbbff883d3cc649045d0" | ||
"gitHead": "ba7b732f23ddf0da772e23ed6175185ec204ee6b" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
0
Yes
1038558
9958
+ Added@iobroker/db-base@5.0.20-alpha.0-20240418-165fc4c8(transitive)
+ Added@iobroker/js-controller-common@5.0.20-alpha.0-20240418-165fc4c8(transitive)
- Removed@iobroker/db-base@5.0.20-alpha.0-20240409-d68ed299(transitive)
- Removed@iobroker/js-controller-common@5.0.20-alpha.0-20240409-d68ed299(transitive)