@iobroker/db-objects-redis 7.2.3 → 8.0.0-alpha.1-20260921-e5941ca8a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/index.d.ts +1 -1
- package/build/cjs/index.js +5 -3
- package/build/cjs/index.js.map +2 -2
- package/build/cjs/lib/objects/constants.js.map +2 -2
- package/build/cjs/lib/objects/interview.js +2 -0
- package/build/cjs/lib/objects/interview.js.map +1 -1
- package/build/cjs/lib/objects/lua-v3/custom.lua +23 -1
- package/build/cjs/lib/objects/lua-v3/filter.lua +23 -1
- package/build/cjs/lib/objects/lua-v3/programs.lua +23 -1
- package/build/cjs/lib/objects/lua-v3/script.lua +23 -1
- package/build/cjs/lib/objects/lua-v3/variables.lua +23 -1
- package/build/cjs/lib/objects/lua-v4/custom.lua +23 -1
- package/build/cjs/lib/objects/lua-v4/filter.lua +23 -1
- package/build/cjs/lib/objects/lua-v4/programs.lua +23 -1
- package/build/cjs/lib/objects/lua-v4/script.lua +23 -1
- package/build/cjs/lib/objects/lua-v4/variables.lua +23 -1
- package/build/cjs/lib/objects/lua-v4-no-sets/custom.lua +23 -1
- package/build/cjs/lib/objects/lua-v4-no-sets/filter.lua +23 -1
- package/build/cjs/lib/objects/lua-v4-no-sets/programs.lua +23 -1
- package/build/cjs/lib/objects/lua-v4-no-sets/script.lua +23 -1
- package/build/cjs/lib/objects/lua-v4-no-sets/variables.lua +23 -1
- package/build/cjs/lib/objects/objectsInRedisClient.d.ts +961 -125
- package/build/cjs/lib/objects/objectsInRedisClient.js +1092 -776
- package/build/cjs/lib/objects/objectsInRedisClient.js.map +3 -3
- package/build/cjs/lib/objects/objectsUtils.d.ts +139 -17
- package/build/cjs/lib/objects/objectsUtils.js +212 -192
- package/build/cjs/lib/objects/objectsUtils.js.map +3 -3
- package/build/esm/index.d.ts +1 -1
- package/build/esm/index.d.ts.map +1 -1
- package/build/esm/index.js.map +1 -1
- package/build/esm/lib/objects/constants.d.ts.map +1 -1
- package/build/esm/lib/objects/constants.js.map +1 -1
- package/build/esm/lib/objects/lua-v3/custom.lua +23 -1
- package/build/esm/lib/objects/lua-v3/filter.lua +23 -1
- package/build/esm/lib/objects/lua-v3/programs.lua +23 -1
- package/build/esm/lib/objects/lua-v3/script.lua +23 -1
- package/build/esm/lib/objects/lua-v3/variables.lua +23 -1
- package/build/esm/lib/objects/lua-v4/custom.lua +23 -1
- package/build/esm/lib/objects/lua-v4/filter.lua +23 -1
- package/build/esm/lib/objects/lua-v4/programs.lua +23 -1
- package/build/esm/lib/objects/lua-v4/script.lua +23 -1
- package/build/esm/lib/objects/lua-v4/variables.lua +23 -1
- package/build/esm/lib/objects/lua-v4-no-sets/custom.lua +23 -1
- package/build/esm/lib/objects/lua-v4-no-sets/filter.lua +23 -1
- package/build/esm/lib/objects/lua-v4-no-sets/programs.lua +23 -1
- package/build/esm/lib/objects/lua-v4-no-sets/script.lua +23 -1
- package/build/esm/lib/objects/lua-v4-no-sets/variables.lua +23 -1
- package/build/esm/lib/objects/objectsInRedisClient.d.ts +961 -125
- package/build/esm/lib/objects/objectsInRedisClient.d.ts.map +1 -1
- package/build/esm/lib/objects/objectsInRedisClient.js +880 -571
- package/build/esm/lib/objects/objectsInRedisClient.js.map +1 -1
- package/build/esm/lib/objects/objectsUtils.d.ts +139 -17
- package/build/esm/lib/objects/objectsUtils.d.ts.map +1 -1
- package/build/esm/lib/objects/objectsUtils.js +273 -221
- package/build/esm/lib/objects/objectsUtils.js.map +1 -1
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +9 -9
|
@@ -1,52 +1,174 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Common functions between client and server
|
|
3
3
|
*
|
|
4
|
-
* Copyright 2013-
|
|
4
|
+
* Copyright 2013-2026 bluefox <dogafox@gmail.com>
|
|
5
5
|
*
|
|
6
6
|
* MIT License
|
|
7
7
|
*
|
|
8
8
|
*/
|
|
9
9
|
import * as CONSTS from '../../lib/objects/constants.js';
|
|
10
|
+
import type { Client as ObjectClient } from '@iobroker/db-objects-redis';
|
|
10
11
|
export * as CONSTS from '../../lib/objects/constants.js';
|
|
11
12
|
export declare const ERRORS: typeof CONSTS.ERRORS;
|
|
12
13
|
export declare const REG_CHECK_ID: RegExp;
|
|
14
|
+
/** Resolved permission context of the user performing a request */
|
|
15
|
+
export interface UserContext {
|
|
16
|
+
/** The user on whose behalf the request is performed */
|
|
17
|
+
user: ioBroker.ObjectIDs.User;
|
|
18
|
+
/** The primary group of the user */
|
|
19
|
+
group: ioBroker.ObjectIDs.Group;
|
|
20
|
+
/** All groups the user is a member of */
|
|
21
|
+
groups: ioBroker.ObjectIDs.Group[];
|
|
22
|
+
/** The effective permissions resolved from the user and its groups */
|
|
23
|
+
acl: ioBroker.ObjectPermissions;
|
|
24
|
+
/** Whether the permissions have already been resolved/checked */
|
|
25
|
+
checked?: boolean;
|
|
26
|
+
}
|
|
27
|
+
/** Information about a file's mime type */
|
|
13
28
|
export interface FileMimeInformation {
|
|
14
29
|
/** the mime type, of the file */
|
|
15
30
|
mimeType: string;
|
|
16
|
-
/** if content is binary or textual */
|
|
31
|
+
/** if the content is binary or textual */
|
|
17
32
|
isBinary: boolean;
|
|
18
33
|
}
|
|
34
|
+
/** The access control list of an object, state or file */
|
|
19
35
|
export interface ACLObject {
|
|
20
|
-
|
|
21
|
-
|
|
36
|
+
/** The user that owns the object */
|
|
37
|
+
owner: ioBroker.ObjectIDs.User;
|
|
38
|
+
/** The group that owns the object */
|
|
39
|
+
ownerGroup: ioBroker.ObjectIDs.Group;
|
|
40
|
+
/** Permission bitmask for object access */
|
|
22
41
|
object: number;
|
|
42
|
+
/** Permission bitmask for state access */
|
|
23
43
|
state: number;
|
|
44
|
+
/** Permission bitmask for file access */
|
|
24
45
|
file: number;
|
|
25
46
|
}
|
|
47
|
+
/** Metadata of a stored file */
|
|
26
48
|
export interface FileObject {
|
|
49
|
+
/** Whether this is a virtual file (a directory placeholder) */
|
|
27
50
|
virtualFile?: boolean;
|
|
28
|
-
stats
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
51
|
+
/** File system stats of the file */
|
|
52
|
+
stats?: {
|
|
53
|
+
size?: number;
|
|
54
|
+
};
|
|
55
|
+
/** Timestamp (ms) when the file was last modified */
|
|
56
|
+
modifiedAt?: number;
|
|
57
|
+
/** Timestamp (ms) when the file was created */
|
|
58
|
+
createdAt?: number;
|
|
59
|
+
/** Evaluated access control list of the file */
|
|
60
|
+
acl?: ioBroker.EvaluatedFileACL;
|
|
61
|
+
/** Whether the entry is a directory */
|
|
62
|
+
isDir?: boolean;
|
|
63
|
+
/** Whether the file does not exist (yet) */
|
|
64
|
+
notExists?: boolean;
|
|
65
|
+
/** The mime type of the file */
|
|
66
|
+
mimeType?: string;
|
|
67
|
+
/** Whether the file content is binary */
|
|
68
|
+
binary?: boolean;
|
|
32
69
|
}
|
|
33
|
-
export type CheckFileRightsCallback = (err: Error | null | undefined, options: Record<string, any>, opt?: any) => void;
|
|
34
70
|
/**
|
|
35
71
|
* Determines the mime type, of an extension and if it is binary content
|
|
36
72
|
*
|
|
37
73
|
* @param ext file extension e.g. `.txt`
|
|
38
74
|
* @param isTextData if content is of type string
|
|
39
75
|
*/
|
|
40
|
-
export declare function getMimeType(ext: string, isTextData
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
76
|
+
export declare function getMimeType(ext: string, isTextData?: boolean): FileMimeInformation;
|
|
77
|
+
/**
|
|
78
|
+
* Check if the given options have the required rights on a file according to its ACL
|
|
79
|
+
*
|
|
80
|
+
* @param fileOptions The stored file options including its ACL
|
|
81
|
+
* @param fileOptions.mimeType The mime type of the file
|
|
82
|
+
* @param fileOptions.notExists Whether the file does not exist yet
|
|
83
|
+
* @param fileOptions.acl The access control list stored for the file
|
|
84
|
+
* @param userContext The current request options including the user and group
|
|
85
|
+
* @param flag The access flag(s) to check for
|
|
86
|
+
* @param defaultNewAcl The default ACL to use if the file has none yet
|
|
87
|
+
*/
|
|
88
|
+
export declare function checkFile(fileOptions: {
|
|
89
|
+
mimeType?: string;
|
|
90
|
+
notExists?: boolean;
|
|
91
|
+
acl?: ioBroker.FileACL;
|
|
92
|
+
}, userContext: UserContext, flag: number, defaultNewAcl?: ACLObject | null): boolean;
|
|
93
|
+
/**
|
|
94
|
+
* Check whether the given user is allowed to access a file and call back with the effective options
|
|
95
|
+
*
|
|
96
|
+
* @param objects The objects database client
|
|
97
|
+
* @param id The id of the object owning the file
|
|
98
|
+
* @param name The file name, or null for the whole namespace
|
|
99
|
+
* @param options The current request options including the user
|
|
100
|
+
* @param flag The access flag(s) to check for
|
|
101
|
+
*/
|
|
102
|
+
export declare function checkFileRightsAsync(objects: ObjectClient, id: string, name: string | null, options: {
|
|
103
|
+
user?: ioBroker.ObjectIDs.User;
|
|
104
|
+
} | null | undefined, flag: CONSTS.GenericAccessFlags): Promise<{
|
|
105
|
+
fileOptions: FileObject;
|
|
106
|
+
userContext: UserContext;
|
|
107
|
+
}>;
|
|
108
|
+
export type GetUserGroupPromiseReturn = [
|
|
109
|
+
user: ioBroker.ObjectIDs.User,
|
|
110
|
+
groups: ioBroker.ObjectIDs.Group[],
|
|
111
|
+
acl: ioBroker.ObjectPermissions
|
|
112
|
+
];
|
|
113
|
+
type GetUserGroupCallback = (err: Error | null | undefined, user: ioBroker.ObjectIDs.User, groups: ioBroker.ObjectIDs.Group[], acl: ioBroker.ObjectPermissions) => void;
|
|
114
|
+
/**
|
|
115
|
+
* Determine the groups and effective ACL of the given user
|
|
116
|
+
*
|
|
117
|
+
* @param objects The objects database client
|
|
118
|
+
* @param user The id of the user to look up
|
|
119
|
+
* @param callback Called with the user, its groups and the effective ACL
|
|
120
|
+
*/
|
|
121
|
+
export declare function getUserGroup(objects: ObjectClient, user: ioBroker.ObjectIDs.User, callback: GetUserGroupCallback): void;
|
|
122
|
+
/**
|
|
123
|
+
* Determine the groups and effective ACL of the given user
|
|
124
|
+
*
|
|
125
|
+
* @param objects The objects database client
|
|
126
|
+
* @param user The id of the user to look up
|
|
127
|
+
*/
|
|
128
|
+
export declare function getUserGroupAsync(objects: ObjectClient, user: ioBroker.ObjectIDs.User): Promise<GetUserGroupPromiseReturn>;
|
|
129
|
+
/**
|
|
130
|
+
* Sanitize an object id and file name so they cannot escape the intended directory
|
|
131
|
+
*
|
|
132
|
+
* @param id The object id owning the file
|
|
133
|
+
* @param name The file name to sanitize
|
|
134
|
+
*/
|
|
46
135
|
export declare function sanitizePath(id: string, name: string): {
|
|
136
|
+
/** The sanitized object id */
|
|
47
137
|
id: string;
|
|
138
|
+
/** The sanitized file name */
|
|
48
139
|
name: string;
|
|
49
140
|
};
|
|
50
|
-
|
|
51
|
-
|
|
141
|
+
/**
|
|
142
|
+
* Check if the given options have the required rights on an object according to its ACL
|
|
143
|
+
*
|
|
144
|
+
* @param obj The object (or file object) to check, or null
|
|
145
|
+
* @param options The current request options including the user and group
|
|
146
|
+
* @param flag The access flag(s) to check for
|
|
147
|
+
*/
|
|
148
|
+
export declare function checkObject(obj: ioBroker.AnyObject | FileObject | null, options: UserContext, flag: CONSTS.GenericAccessFlags): boolean;
|
|
149
|
+
/**
|
|
150
|
+
* Check whether the given user is allowed to access an object and call back with the effective options
|
|
151
|
+
*
|
|
152
|
+
* @param objects The objects database client
|
|
153
|
+
* @param id The id of the object, or null
|
|
154
|
+
* @param object The object to check, or null
|
|
155
|
+
* @param options The current request options including the user
|
|
156
|
+
* @param flag The access flag(s) to check for
|
|
157
|
+
* @param callback Called with the effective options once the rights have been checked
|
|
158
|
+
*/
|
|
159
|
+
export declare function checkObjectRights(objects: ObjectClient, id: string | null, object: ioBroker.Object | null, options: {
|
|
160
|
+
user?: ioBroker.ObjectIDs.User;
|
|
161
|
+
} | null | undefined, flag: CONSTS.GenericAccessFlags, callback: (err: Error | null | undefined, userContext?: UserContext) => void): void;
|
|
162
|
+
/**
|
|
163
|
+
* Check whether the given user is allowed to access an object and call back with the effective options
|
|
164
|
+
*
|
|
165
|
+
* @param objects The objects database client
|
|
166
|
+
* @param id The id of the object, or null
|
|
167
|
+
* @param object The object to check, or null
|
|
168
|
+
* @param options The current request options including the user
|
|
169
|
+
* @param flag The access flag(s) to check for
|
|
170
|
+
*/
|
|
171
|
+
export declare function checkObjectRightsAsync(objects: ObjectClient, id: string | null, object: ioBroker.Object | null, options: {
|
|
172
|
+
user?: ioBroker.ObjectIDs.User;
|
|
173
|
+
} | null | undefined, flag: CONSTS.GenericAccessFlags): Promise<UserContext>;
|
|
52
174
|
//# sourceMappingURL=objectsUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"objectsUtils.d.ts","sourceRoot":"","sources":["../../../../src/lib/objects/objectsUtils.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"objectsUtils.d.ts","sourceRoot":"","sources":["../../../../src/lib/objects/objectsUtils.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAOH,OAAO,KAAK,MAAM,MAAM,4BAA4B,CAAC;AACrD,OAAO,KAAK,EAAE,MAAM,IAAI,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAGzE,OAAO,KAAK,MAAM,MAAM,4BAA4B,CAAC;AACrD,eAAO,MAAM,MAAM,sBAAgB,CAAC;AACpC,eAAO,MAAM,YAAY,QAAsB,CAAC;AAKhD,mEAAmE;AACnE,MAAM,WAAW,WAAW;IACxB,wDAAwD;IACxD,IAAI,EAAE,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC;IAC9B,oCAAoC;IACpC,KAAK,EAAE,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC;IAChC,yCAAyC;IACzC,MAAM,EAAE,QAAQ,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;IACnC,sEAAsE;IACtE,GAAG,EAAE,QAAQ,CAAC,iBAAiB,CAAC;IAChC,iEAAiE;IACjE,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB;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