mirror of
https://github.com/denoland/deno.git
synced 2025-01-03 04:48:52 -05:00
revert: allow URL for permissions (#11600)
Revert changes to "net" permissions in regards to handling URLs
introduced in 15b0e61de
.
This commit is contained in:
parent
2b53602d3c
commit
0d1a522a03
5 changed files with 9 additions and 24 deletions
2
cli/dts/lib.deno.ns.d.ts
vendored
2
cli/dts/lib.deno.ns.d.ts
vendored
|
@ -2159,7 +2159,7 @@ declare namespace Deno {
|
|||
* "github.com"
|
||||
* "deno.land:8080"
|
||||
*/
|
||||
host?: string | URL;
|
||||
host?: string;
|
||||
}
|
||||
|
||||
export interface EnvPermissionDescriptor {
|
||||
|
|
4
cli/dts/lib.deno.unstable.d.ts
vendored
4
cli/dts/lib.deno.unstable.d.ts
vendored
|
@ -1041,7 +1041,7 @@ declare namespace Deno {
|
|||
* });
|
||||
* ```
|
||||
*/
|
||||
net?: "inherit" | boolean | Array<string | URL>;
|
||||
net?: "inherit" | boolean | string[];
|
||||
|
||||
/** Specifies if the `plugin` permission should be requested or revoked.
|
||||
* If set to `"inherit"`, the current `plugin` permission will be inherited.
|
||||
|
@ -1136,7 +1136,7 @@ declare interface WorkerOptions {
|
|||
*
|
||||
* For example: `["https://deno.land", "localhost:8080"]`.
|
||||
*/
|
||||
net?: "inherit" | boolean | Array<string | URL>;
|
||||
net?: "inherit" | boolean | string[];
|
||||
plugin?: "inherit" | boolean;
|
||||
read?: "inherit" | boolean | Array<string | URL>;
|
||||
run?: "inherit" | boolean | Array<string | URL>;
|
||||
|
|
|
@ -71,8 +71,4 @@ unitTest(async function permissionURL() {
|
|||
name: "run",
|
||||
command: new URL(".", import.meta.url),
|
||||
});
|
||||
await Deno.permissions.query({
|
||||
name: "net",
|
||||
host: new URL("https://deno.land/foo"),
|
||||
});
|
||||
});
|
||||
|
|
|
@ -94,9 +94,10 @@
|
|||
value = ArrayPrototypeMap(value, (route) => {
|
||||
if (route instanceof URL) {
|
||||
if (permission === "net") {
|
||||
route = route.host;
|
||||
}
|
||||
if (permission === "env") {
|
||||
throw new Error(
|
||||
`Expected 'string' for net permission, received 'URL'`,
|
||||
);
|
||||
} else if (permission === "env") {
|
||||
throw new Error(
|
||||
`Expected 'string' for env permission, received 'URL'`,
|
||||
);
|
||||
|
@ -124,12 +125,12 @@
|
|||
write = "inherit",
|
||||
}) {
|
||||
return {
|
||||
env: parseArrayPermission(env, "env"),
|
||||
env: parseUnitPermission(env, "env"),
|
||||
hrtime: parseUnitPermission(hrtime, "hrtime"),
|
||||
net: parseArrayPermission(net, "net"),
|
||||
plugin: parseUnitPermission(plugin, "plugin"),
|
||||
read: parseArrayPermission(read, "read"),
|
||||
run: parseArrayPermission(run, "run"),
|
||||
run: parseUnitPermission(run, "run"),
|
||||
write: parseArrayPermission(write, "write"),
|
||||
};
|
||||
}
|
||||
|
|
|
@ -167,10 +167,6 @@
|
|||
desc.path = pathFromURL(desc.path);
|
||||
} else if (desc.name === "run") {
|
||||
desc.command = pathFromURL(desc.command);
|
||||
} else if (desc.name === "net") {
|
||||
if (desc.host instanceof URL) {
|
||||
desc.host = desc.host.host;
|
||||
}
|
||||
}
|
||||
|
||||
const state = opQuery(desc);
|
||||
|
@ -190,10 +186,6 @@
|
|||
desc.path = pathFromURL(desc.path);
|
||||
} else if (desc.name === "run") {
|
||||
desc.command = pathFromURL(desc.command);
|
||||
} else if (desc.name === "net") {
|
||||
if (desc.host instanceof URL) {
|
||||
desc.host = desc.host.host;
|
||||
}
|
||||
}
|
||||
|
||||
const state = opRevoke(desc);
|
||||
|
@ -213,10 +205,6 @@
|
|||
desc.path = pathFromURL(desc.path);
|
||||
} else if (desc.name === "run") {
|
||||
desc.command = pathFromURL(desc.command);
|
||||
} else if (desc.name === "net") {
|
||||
if (desc.host instanceof URL) {
|
||||
desc.host = desc.host.host;
|
||||
}
|
||||
}
|
||||
|
||||
const state = opRequest(desc);
|
||||
|
|
Loading…
Reference in a new issue