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 /core/bindings.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 'core/bindings.rs')
-rw-r--r-- | core/bindings.rs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/core/bindings.rs b/core/bindings.rs index b9285a402..6707f115c 100644 --- a/core/bindings.rs +++ b/core/bindings.rs @@ -13,6 +13,7 @@ use crate::modules::parse_import_assertions; use crate::modules::validate_import_assertions; use crate::modules::ImportAssertionsKind; use crate::modules::ModuleMap; +use crate::modules::ResolutionKind; use crate::ops::OpCtx; use crate::runtime::SnapshotOptions; use crate::JsRuntime; @@ -378,7 +379,8 @@ fn import_meta_resolve( return; } - match loader.resolve(&specifier_str, &referrer, false) { + match loader.resolve(&specifier_str, &referrer, ResolutionKind::DynamicImport) + { Ok(resolved) => { let resolved_val = serde_v8::to_v8(scope, resolved.as_str()).unwrap(); rv.set(resolved_val); |