1#ifndef SRC_PERMISSION_PERMISSION_BASE_H_
2#define SRC_PERMISSION_PERMISSION_BASE_H_
3
4#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
5
6#include <map>
7#include <string>
8#include <string_view>
9#include "v8.h"
10
11namespace node {
12
13namespace permission {
14
15#define FILESYSTEM_PERMISSIONS(V)                                              \
16  V(FileSystem, "fs", PermissionsRoot)                                         \
17  V(FileSystemRead, "fs.read", FileSystem)                                     \
18  V(FileSystemWrite, "fs.write", FileSystem)
19
20#define CHILD_PROCESS_PERMISSIONS(V) V(ChildProcess, "child", PermissionsRoot)
21
22#define WORKER_THREADS_PERMISSIONS(V)                                          \
23  V(WorkerThreads, "worker", PermissionsRoot)
24
25#define PERMISSIONS(V)                                                         \
26  FILESYSTEM_PERMISSIONS(V)                                                    \
27  CHILD_PROCESS_PERMISSIONS(V)                                                 \
28  WORKER_THREADS_PERMISSIONS(V)
29
30#define V(name, _, __) k##name,
31enum class PermissionScope {
32  kPermissionsRoot = -1,
33  PERMISSIONS(V) kPermissionsCount
34};
35#undef V
36
37class PermissionBase {
38 public:
39  virtual void Apply(const std::string& allow, PermissionScope scope) = 0;
40  virtual bool is_granted(PermissionScope perm,
41                          const std::string_view& param = "") = 0;
42};
43
44}  // namespace permission
45
46}  // namespace node
47
48#endif  // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
49#endif  // SRC_PERMISSION_PERMISSION_BASE_H_
50