From 636352e0ca1e611c7673f2ab68538e1ddb2dc5b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Tue, 10 Jan 2023 14:35:44 +0100 Subject: 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. --- cli/tsc/mod.rs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'cli/tsc') diff --git a/cli/tsc/mod.rs b/cli/tsc/mod.rs index c08b4e1ae..6ea037522 100644 --- a/cli/tsc/mod.rs +++ b/cli/tsc/mod.rs @@ -33,6 +33,7 @@ use deno_core::RuntimeOptions; use deno_core::Snapshot; use deno_graph::Resolved; use deno_runtime::deno_node::NodeResolutionMode; +use deno_runtime::permissions::PermissionsContainer; use once_cell::sync::Lazy; use std::borrow::Cow; use std::collections::HashMap; @@ -647,6 +648,7 @@ fn op_resolve( &referrer, NodeResolutionMode::Types, npm_resolver, + &mut PermissionsContainer::allow_all(), ) .ok() .flatten(), @@ -703,6 +705,7 @@ pub fn resolve_npm_package_reference_types( npm_ref, NodeResolutionMode::Types, npm_resolver, + &mut PermissionsContainer::allow_all(), )?; Ok(NodeResolution::into_specifier_and_media_type( maybe_resolution, -- cgit v1.2.3