mirror of
https://github.com/denoland/deno.git
synced 2025-01-08 23:28:18 -05:00
refactor(cli/js/permissions): Split read and write permission descriptors (#4774)
This commit is contained in:
parent
927a771fa4
commit
76ee6fb335
2 changed files with 44 additions and 23 deletions
37
cli/js/lib.deno.ns.d.ts
vendored
37
cli/js/lib.deno.ns.d.ts
vendored
|
@ -1667,11 +1667,12 @@ declare namespace Deno {
|
||||||
Busy: ErrorConstructor;
|
Busy: ErrorConstructor;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** **UNSTABLE**: potentially want names to overlap more with browser.
|
/** The name of a "powerful feature" which needs permission.
|
||||||
*
|
*
|
||||||
* The permissions as granted by the caller.
|
* See: https://w3c.github.io/permissions/#permission-registry
|
||||||
*
|
*
|
||||||
* See: https://w3c.github.io/permissions/#permission-registry */
|
* Note that the definition of `PermissionName` in the above spec is swapped
|
||||||
|
* out for a set of Deno permissions which are not web-compatible. */
|
||||||
export type PermissionName =
|
export type PermissionName =
|
||||||
| "run"
|
| "run"
|
||||||
| "read"
|
| "read"
|
||||||
|
@ -1686,39 +1687,45 @@ declare namespace Deno {
|
||||||
* See: https://w3c.github.io/permissions/#status-of-a-permission */
|
* See: https://w3c.github.io/permissions/#status-of-a-permission */
|
||||||
export type PermissionState = "granted" | "denied" | "prompt";
|
export type PermissionState = "granted" | "denied" | "prompt";
|
||||||
|
|
||||||
interface RunPermissionDescriptor {
|
export interface RunPermissionDescriptor {
|
||||||
name: "run";
|
name: "run";
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ReadWritePermissionDescriptor {
|
export interface ReadPermissionDescriptor {
|
||||||
name: "read" | "write";
|
name: "read";
|
||||||
path?: string;
|
path?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface NetPermissionDescriptor {
|
export interface WritePermissionDescriptor {
|
||||||
|
name: "write";
|
||||||
|
path?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface NetPermissionDescriptor {
|
||||||
name: "net";
|
name: "net";
|
||||||
url?: string;
|
url?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface EnvPermissionDescriptor {
|
export interface EnvPermissionDescriptor {
|
||||||
name: "env";
|
name: "env";
|
||||||
}
|
}
|
||||||
|
|
||||||
interface PluginPermissionDescriptor {
|
export interface PluginPermissionDescriptor {
|
||||||
name: "plugin";
|
name: "plugin";
|
||||||
}
|
}
|
||||||
|
|
||||||
interface HrtimePermissionDescriptor {
|
export interface HrtimePermissionDescriptor {
|
||||||
name: "hrtime";
|
name: "hrtime";
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Permission descriptors which define a permission which can be queried,
|
/** Permission descriptors which define a permission and can be queried,
|
||||||
* requested, or revoked.
|
* requested, or revoked.
|
||||||
*
|
*
|
||||||
* See: https://w3c.github.io/permissions/#permission-descriptor */
|
* See: https://w3c.github.io/permissions/#permission-descriptor */
|
||||||
type PermissionDescriptor =
|
export type PermissionDescriptor =
|
||||||
| RunPermissionDescriptor
|
| RunPermissionDescriptor
|
||||||
| ReadWritePermissionDescriptor
|
| ReadPermissionDescriptor
|
||||||
|
| WritePermissionDescriptor
|
||||||
| NetPermissionDescriptor
|
| NetPermissionDescriptor
|
||||||
| EnvPermissionDescriptor
|
| EnvPermissionDescriptor
|
||||||
| PluginPermissionDescriptor
|
| PluginPermissionDescriptor
|
||||||
|
@ -1753,7 +1760,9 @@ declare namespace Deno {
|
||||||
request(desc: PermissionDescriptor): Promise<PermissionStatus>;
|
request(desc: PermissionDescriptor): Promise<PermissionStatus>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** **UNSTABLE**: maybe move to `navigator.permissions` to match web API. */
|
/** **UNSTABLE**: maybe move to `navigator.permissions` to match web API. It
|
||||||
|
* could look like `navigator.permissions.query({ name: Deno.symbols.read })`.
|
||||||
|
*/
|
||||||
export const permissions: Permissions;
|
export const permissions: Permissions;
|
||||||
|
|
||||||
/** see: https://w3c.github.io/permissions/#permissionstatus */
|
/** see: https://w3c.github.io/permissions/#permissionstatus */
|
||||||
|
|
|
@ -13,29 +13,41 @@ export type PermissionName =
|
||||||
|
|
||||||
export type PermissionState = "granted" | "denied" | "prompt";
|
export type PermissionState = "granted" | "denied" | "prompt";
|
||||||
|
|
||||||
interface RunPermissionDescriptor {
|
export interface RunPermissionDescriptor {
|
||||||
name: "run";
|
name: "run";
|
||||||
}
|
}
|
||||||
interface ReadWritePermissionDescriptor {
|
|
||||||
name: "read" | "write";
|
export interface ReadPermissionDescriptor {
|
||||||
|
name: "read";
|
||||||
path?: string;
|
path?: string;
|
||||||
}
|
}
|
||||||
interface NetPermissionDescriptor {
|
|
||||||
|
export interface WritePermissionDescriptor {
|
||||||
|
name: "write";
|
||||||
|
path?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface NetPermissionDescriptor {
|
||||||
name: "net";
|
name: "net";
|
||||||
url?: string;
|
url?: string;
|
||||||
}
|
}
|
||||||
interface EnvPermissionDescriptor {
|
|
||||||
|
export interface EnvPermissionDescriptor {
|
||||||
name: "env";
|
name: "env";
|
||||||
}
|
}
|
||||||
interface PluginPermissionDescriptor {
|
|
||||||
|
export interface PluginPermissionDescriptor {
|
||||||
name: "plugin";
|
name: "plugin";
|
||||||
}
|
}
|
||||||
interface HrtimePermissionDescriptor {
|
|
||||||
|
export interface HrtimePermissionDescriptor {
|
||||||
name: "hrtime";
|
name: "hrtime";
|
||||||
}
|
}
|
||||||
type PermissionDescriptor =
|
|
||||||
|
export type PermissionDescriptor =
|
||||||
| RunPermissionDescriptor
|
| RunPermissionDescriptor
|
||||||
| ReadWritePermissionDescriptor
|
| ReadPermissionDescriptor
|
||||||
|
| WritePermissionDescriptor
|
||||||
| NetPermissionDescriptor
|
| NetPermissionDescriptor
|
||||||
| EnvPermissionDescriptor
|
| EnvPermissionDescriptor
|
||||||
| PluginPermissionDescriptor
|
| PluginPermissionDescriptor
|
||||||
|
|
Loading…
Reference in a new issue