mirror of
https://github.com/denoland/deno.git
synced 2025-08-04 19:08:15 +00:00
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.
This commit is contained in:
parent
45768f0e83
commit
636352e0ca
26 changed files with 306 additions and 93 deletions
|
@ -1,6 +1,7 @@
|
|||
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
use crate::NodeModuleKind;
|
||||
use crate::NodePermissions;
|
||||
|
||||
use super::RequireNpmResolver;
|
||||
use deno_core::anyhow;
|
||||
|
@ -47,9 +48,10 @@ impl PackageJson {
|
|||
|
||||
pub fn load(
|
||||
resolver: &dyn RequireNpmResolver,
|
||||
permissions: &mut dyn NodePermissions,
|
||||
path: PathBuf,
|
||||
) -> Result<PackageJson, AnyError> {
|
||||
resolver.ensure_read_permission(&path)?;
|
||||
resolver.ensure_read_permission(permissions, &path)?;
|
||||
Self::load_skip_read_permission(path)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue