@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.
Files changed (57) hide show
  1. package/build/cjs/index.d.ts +1 -1
  2. package/build/cjs/index.js +5 -3
  3. package/build/cjs/index.js.map +2 -2
  4. package/build/cjs/lib/objects/constants.js.map +2 -2
  5. package/build/cjs/lib/objects/interview.js +2 -0
  6. package/build/cjs/lib/objects/interview.js.map +1 -1
  7. package/build/cjs/lib/objects/lua-v3/custom.lua +23 -1
  8. package/build/cjs/lib/objects/lua-v3/filter.lua +23 -1
  9. package/build/cjs/lib/objects/lua-v3/programs.lua +23 -1
  10. package/build/cjs/lib/objects/lua-v3/script.lua +23 -1
  11. package/build/cjs/lib/objects/lua-v3/variables.lua +23 -1
  12. package/build/cjs/lib/objects/lua-v4/custom.lua +23 -1
  13. package/build/cjs/lib/objects/lua-v4/filter.lua +23 -1
  14. package/build/cjs/lib/objects/lua-v4/programs.lua +23 -1
  15. package/build/cjs/lib/objects/lua-v4/script.lua +23 -1
  16. package/build/cjs/lib/objects/lua-v4/variables.lua +23 -1
  17. package/build/cjs/lib/objects/lua-v4-no-sets/custom.lua +23 -1
  18. package/build/cjs/lib/objects/lua-v4-no-sets/filter.lua +23 -1
  19. package/build/cjs/lib/objects/lua-v4-no-sets/programs.lua +23 -1
  20. package/build/cjs/lib/objects/lua-v4-no-sets/script.lua +23 -1
  21. package/build/cjs/lib/objects/lua-v4-no-sets/variables.lua +23 -1
  22. package/build/cjs/lib/objects/objectsInRedisClient.d.ts +961 -125
  23. package/build/cjs/lib/objects/objectsInRedisClient.js +1092 -776
  24. package/build/cjs/lib/objects/objectsInRedisClient.js.map +3 -3
  25. package/build/cjs/lib/objects/objectsUtils.d.ts +139 -17
  26. package/build/cjs/lib/objects/objectsUtils.js +212 -192
  27. package/build/cjs/lib/objects/objectsUtils.js.map +3 -3
  28. package/build/esm/index.d.ts +1 -1
  29. package/build/esm/index.d.ts.map +1 -1
  30. package/build/esm/index.js.map +1 -1
  31. package/build/esm/lib/objects/constants.d.ts.map +1 -1
  32. package/build/esm/lib/objects/constants.js.map +1 -1
  33. package/build/esm/lib/objects/lua-v3/custom.lua +23 -1
  34. package/build/esm/lib/objects/lua-v3/filter.lua +23 -1
  35. package/build/esm/lib/objects/lua-v3/programs.lua +23 -1
  36. package/build/esm/lib/objects/lua-v3/script.lua +23 -1
  37. package/build/esm/lib/objects/lua-v3/variables.lua +23 -1
  38. package/build/esm/lib/objects/lua-v4/custom.lua +23 -1
  39. package/build/esm/lib/objects/lua-v4/filter.lua +23 -1
  40. package/build/esm/lib/objects/lua-v4/programs.lua +23 -1
  41. package/build/esm/lib/objects/lua-v4/script.lua +23 -1
  42. package/build/esm/lib/objects/lua-v4/variables.lua +23 -1
  43. package/build/esm/lib/objects/lua-v4-no-sets/custom.lua +23 -1
  44. package/build/esm/lib/objects/lua-v4-no-sets/filter.lua +23 -1
  45. package/build/esm/lib/objects/lua-v4-no-sets/programs.lua +23 -1
  46. package/build/esm/lib/objects/lua-v4-no-sets/script.lua +23 -1
  47. package/build/esm/lib/objects/lua-v4-no-sets/variables.lua +23 -1
  48. package/build/esm/lib/objects/objectsInRedisClient.d.ts +961 -125
  49. package/build/esm/lib/objects/objectsInRedisClient.d.ts.map +1 -1
  50. package/build/esm/lib/objects/objectsInRedisClient.js +880 -571
  51. package/build/esm/lib/objects/objectsInRedisClient.js.map +1 -1
  52. package/build/esm/lib/objects/objectsUtils.d.ts +139 -17
  53. package/build/esm/lib/objects/objectsUtils.d.ts.map +1 -1
  54. package/build/esm/lib/objects/objectsUtils.js +273 -221
  55. package/build/esm/lib/objects/objectsUtils.js.map +1 -1
  56. package/build/tsconfig.build.tsbuildinfo +1 -1
  57. package/package.json +9 -9
@@ -1,52 +1,174 @@
1
1
  /**
2
2
  * Common functions between client and server
3
3
  *
4
- * Copyright 2013-2024 bluefox <dogafox@gmail.com>
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
- owner: string;
21
- ownerGroup: string;
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: any;
29
- modifiedAt: number;
30
- createdAt: number;
31
- acl: ioBroker.EvaluatedFileACL;
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: boolean): FileMimeInformation;
41
- export declare function checkFile(fileOptions: Record<string, any>, options: Record<string, any>, flag: any, defaultNewAcl?: ACLObject | null): boolean;
42
- export declare function checkFileRights(objects: any, id: string, name: string | null, options: Record<string, any> | null | undefined, flag: CONSTS.GenericAccessFlags, callback?: CheckFileRightsCallback): any;
43
- export type GetUserGroupPromiseReturn = [user: string, groups: string[], acl: ioBroker.ObjectPermissions];
44
- type GetUserGroupCallback = (err: Error | null | undefined, user: string, groups: string[], acl: ioBroker.ObjectPermissions) => void;
45
- export declare function getUserGroup(objects: any, user: ioBroker.ObjectIDs.User, callback?: GetUserGroupCallback): Promise<GetUserGroupPromiseReturn> | void;
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
- export declare function checkObject(obj: ioBroker.AnyObject | FileObject | null, options: Record<string, any>, flag: CONSTS.GenericAccessFlags): boolean;
51
- export declare function checkObjectRights(objects: any, id: string | null, object: ioBroker.Object | null, options: Record<string, any> | null | undefined, flag: CONSTS.GenericAccessFlags, callback: (err: Error | null | undefined, options: Record<string, any>) => void): void | Promise<Record<string, any>>;
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