11cb0ef41Sopenharmony_ci#ifndef SRC_PERMISSION_PERMISSION_BASE_H_ 21cb0ef41Sopenharmony_ci#define SRC_PERMISSION_PERMISSION_BASE_H_ 31cb0ef41Sopenharmony_ci 41cb0ef41Sopenharmony_ci#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS 51cb0ef41Sopenharmony_ci 61cb0ef41Sopenharmony_ci#include <map> 71cb0ef41Sopenharmony_ci#include <string> 81cb0ef41Sopenharmony_ci#include <string_view> 91cb0ef41Sopenharmony_ci#include "v8.h" 101cb0ef41Sopenharmony_ci 111cb0ef41Sopenharmony_cinamespace node { 121cb0ef41Sopenharmony_ci 131cb0ef41Sopenharmony_cinamespace permission { 141cb0ef41Sopenharmony_ci 151cb0ef41Sopenharmony_ci#define FILESYSTEM_PERMISSIONS(V) \ 161cb0ef41Sopenharmony_ci V(FileSystem, "fs", PermissionsRoot) \ 171cb0ef41Sopenharmony_ci V(FileSystemRead, "fs.read", FileSystem) \ 181cb0ef41Sopenharmony_ci V(FileSystemWrite, "fs.write", FileSystem) 191cb0ef41Sopenharmony_ci 201cb0ef41Sopenharmony_ci#define CHILD_PROCESS_PERMISSIONS(V) V(ChildProcess, "child", PermissionsRoot) 211cb0ef41Sopenharmony_ci 221cb0ef41Sopenharmony_ci#define WORKER_THREADS_PERMISSIONS(V) \ 231cb0ef41Sopenharmony_ci V(WorkerThreads, "worker", PermissionsRoot) 241cb0ef41Sopenharmony_ci 251cb0ef41Sopenharmony_ci#define PERMISSIONS(V) \ 261cb0ef41Sopenharmony_ci FILESYSTEM_PERMISSIONS(V) \ 271cb0ef41Sopenharmony_ci CHILD_PROCESS_PERMISSIONS(V) \ 281cb0ef41Sopenharmony_ci WORKER_THREADS_PERMISSIONS(V) 291cb0ef41Sopenharmony_ci 301cb0ef41Sopenharmony_ci#define V(name, _, __) k##name, 311cb0ef41Sopenharmony_cienum class PermissionScope { 321cb0ef41Sopenharmony_ci kPermissionsRoot = -1, 331cb0ef41Sopenharmony_ci PERMISSIONS(V) kPermissionsCount 341cb0ef41Sopenharmony_ci}; 351cb0ef41Sopenharmony_ci#undef V 361cb0ef41Sopenharmony_ci 371cb0ef41Sopenharmony_ciclass PermissionBase { 381cb0ef41Sopenharmony_ci public: 391cb0ef41Sopenharmony_ci virtual void Apply(const std::string& allow, PermissionScope scope) = 0; 401cb0ef41Sopenharmony_ci virtual bool is_granted(PermissionScope perm, 411cb0ef41Sopenharmony_ci const std::string_view& param = "") = 0; 421cb0ef41Sopenharmony_ci}; 431cb0ef41Sopenharmony_ci 441cb0ef41Sopenharmony_ci} // namespace permission 451cb0ef41Sopenharmony_ci 461cb0ef41Sopenharmony_ci} // namespace node 471cb0ef41Sopenharmony_ci 481cb0ef41Sopenharmony_ci#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS 491cb0ef41Sopenharmony_ci#endif // SRC_PERMISSION_PERMISSION_BASE_H_ 50