Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only authorize import modules listed in the import map #26659

Open
udfordria opened this issue Oct 31, 2024 · 5 comments
Open

Only authorize import modules listed in the import map #26659

udfordria opened this issue Oct 31, 2024 · 5 comments
Labels
install suggestion suggestions for new features (yet to be agreed)

Comments

@udfordria
Copy link

Proposition

Having a way to only authorize dependencies listed in the imports block of the deno.json file.

Examples

This example should NOT work when I run deno run -A main.ts because the dependency is not listed in the imports block.

deno.json

{
  "imports": {}
}

main.ts

import { fib } from "jsr:@phocks/fib"; // Error not listed in deno.json

console.log(fib(3)); 

However, that example must work when I run deno run -A main.ts because the dependency is listed in the imports block.

deno.json

{
  "imports": {
    "fibonacci": "jsr:@phocks/fib"
  }
}

main.ts

import { fib } from "fibonacci"; // import from deno.json

console.log(fib(3)); 
@bartlomieju
Copy link
Member

I'm a bit lost here, could you explain a bit more? Do you mean Deno should not send authorization headers for private registries?

@bartlomieju bartlomieju added needs info needs further information to be properly triaged install labels Oct 31, 2024
@udfordria
Copy link
Author

What I mean is to have an option to consider "imports" as a bill of materials. If one external dependency is not listed inside the "imports" and is used as import in my typescript code, the program must not work.

@dsherret dsherret added suggestion suggestions for new features (yet to be agreed) and removed needs info needs further information to be properly triaged labels Nov 23, 2024
@dsherret
Copy link
Member

I agree on adding this. It would be nice if this mode also didn't store anything in the lockfile that's not found in the deno.json/package.json

@bartlomieju
Copy link
Member

@dsherret do you have an idea how it would be enabled? I think that banning npm:/jsr:/etc... specifier just by presence of deno.json is too restrictive and something we can't do in v2.x. Starting with an option in deno.json seems easy.

@bartlomieju
Copy link
Member

I think this would be (at least partially) fixed by denoland/deno_lint#1361.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
install suggestion suggestions for new features (yet to be agreed)
Projects
None yet
Development

No branches or pull requests

3 participants