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

fix: improve deno compatibility #25

Merged
merged 1 commit into from
Oct 13, 2024
Merged

fix: improve deno compatibility #25

merged 1 commit into from
Oct 13, 2024

Conversation

fvsch
Copy link
Owner

@fvsch fvsch commented Oct 12, 2024

Deno requires permissions for a bunch of APIs.

One that feels a bit scary is --allow-env, while this package only looks at the env for color support metadata and other minor stuff.

This skips this kind of access in Deno, so that servitsy can run with:

deno run --allow-net --allow-read --allow-sys='uid,networkInterfaces' npm:servitsy

I need to investigate:

  1. can the --allow-sys part can be reduced further?
  2. can --allow-net be more precise?
  3. would it be possible to do --allow-read=./some-folder and use that as the root folder?

@fvsch fvsch marked this pull request as draft October 12, 2024 16:36
@fvsch fvsch force-pushed the fvsch/deno-compat branch 2 times, most recently from 1ef161a to 762901c Compare October 13, 2024 15:57
@fvsch fvsch force-pushed the fvsch/deno-compat branch from 762901c to 26f96fb Compare October 13, 2024 22:45
@fvsch
Copy link
Owner Author

fvsch commented Oct 13, 2024

  1. can the --allow-sys part can be reduced further?

Doesn't seem like it. The uid part is when checking user access to the root directory (or to any file we try to serve). The networkInterfaces part is when trying to determine the local network address.

  1. can --allow-net be more precise?

Yes, but you’d need to combine with a specific --host and --port args, which is a bit hard.

  1. would it be possible to do --allow-read=./some-folder and use that as the root folder?

First part is possible, but you can't use Deno.permissions to list allowed paths, you can only check if a specific path is allowed.

@fvsch fvsch marked this pull request as ready for review October 13, 2024 22:52
@fvsch fvsch changed the title fix: Deno 2.0 compatibility fix: improve deno compatibility Oct 13, 2024
@fvsch fvsch merged commit c19a00d into main Oct 13, 2024
1 check passed
@fvsch fvsch deleted the fvsch/deno-compat branch October 13, 2024 22:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant