diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2023-01-10 14:35:44 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-10 14:35:44 +0100 |
commit | 636352e0ca1e611c7673f2ab68538e1ddb2dc5b7 (patch) | |
tree | c250c7a74917cef683999e06283ea9f7182f372c /cli/proc_state.rs | |
parent | 45768f0e832e54d61ddb5a62d62239aef0e597b5 (diff) |
fix(npm): allow to read package.json if permissions are granted (#17209)
This commit changes signature of "deno_core::ModuleLoader::resolve" to pass
an enum indicating whether or not we're resolving a specifier for dynamic import.
Additionally "CliModuleLoader" was changes to store both "parent permissions" (or
"root permissions") as well as "dynamic permissions" that allow to check for permissions
in top-level module load an dynamic imports.
Then all code paths that have anything to do with Node/npm compat are now checking
for permissions which are passed from module loader instance associated with given
worker.
Diffstat (limited to 'cli/proc_state.rs')
-rw-r--r-- | cli/proc_state.rs | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/cli/proc_state.rs b/cli/proc_state.rs index 0dd97b5e3..bbfc3cbad 100644 --- a/cli/proc_state.rs +++ b/cli/proc_state.rs @@ -532,6 +532,7 @@ impl ProcState { &self, specifier: &str, referrer: &str, + permissions: &mut PermissionsContainer, ) -> Result<ModuleSpecifier, AnyError> { if let Ok(referrer) = deno_core::resolve_url_or_path(referrer) { if self.npm_resolver.in_npm_package(&referrer) { @@ -542,6 +543,7 @@ impl ProcState { &referrer, NodeResolutionMode::Execution, &self.npm_resolver, + permissions, )) .with_context(|| { format!("Could not resolve '{}' from '{}'.", specifier, referrer) @@ -575,6 +577,7 @@ impl ProcState { &reference, NodeResolutionMode::Execution, &self.npm_resolver, + permissions, )) .with_context(|| format!("Could not resolve '{}'.", reference)); } else { @@ -618,6 +621,7 @@ impl ProcState { &reference, deno_runtime::deno_node::NodeResolutionMode::Execution, &self.npm_resolver, + permissions, )) .with_context(|| format!("Could not resolve '{}'.", reference)); } |