denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
97.41k stars 5.37k forks source link

Is there any API to get allowed value of permission? #22985

Open Hajime-san opened 7 months ago

Hajime-san commented 7 months ago

I'm using the nice library dax heavily to write shell-like script. BTW, it requires all environment variable inside while it needs only $PATH environment variable to run ls.

as follows

import $ from 'dax';

await $`ls`;
% deno run --allow-env=PATH --allow-read --allow-run=ls ls.ts
┌ ⚠️  Deno requests env access.
├ Run again with --allow-env to bypass this prompt.
└ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all env permissions) > 

So, I wish if an API to get allowed value of permission.

I'm not clear whether it passes security requirements model of Deno.

Thanks!

dsherret commented 4 months ago

@Hajime-san can you rephrase your question? There is a Deno.permissions.query API, but I'm not sure that's what you're looking for: https://docs.deno.com/runtime/manual/runtime/permission_apis/

Hajime-san commented 3 months ago

Thank you for replying!

You suggest the Deno.permissions.query API is a way of to get value that allowed by user. However, it requires that library or application author to write codes with predicting what permission value will be allowed in detail. For instance, the Deno.Env.toObject API returns all environment value with giving --allow-env permission. So, I'm trying to say that like Deno.env.onAllowed API extends Event interface (or WICG Proposal Observable) it will return permission allowed environment value at that point.