mirror of
https://github.com/denoland/deno.git
synced 2025-08-03 02:22:40 +00:00
feat(runtime): allow URL for permissions (#11578)
This commit is contained in:
parent
b6b71c3d59
commit
15b0e61de5
5 changed files with 75 additions and 13 deletions
|
@ -93,7 +93,16 @@
|
|||
} else if (ArrayIsArray(value)) {
|
||||
value = ArrayPrototypeMap(value, (route) => {
|
||||
if (route instanceof URL) {
|
||||
route = pathFromURL(route);
|
||||
if (permission === "net") {
|
||||
route = route.host;
|
||||
}
|
||||
if (permission === "env") {
|
||||
throw new Error(
|
||||
`Expected 'string' for env permission, received 'URL'`,
|
||||
);
|
||||
} else {
|
||||
route = pathFromURL(route);
|
||||
}
|
||||
}
|
||||
return route;
|
||||
});
|
||||
|
@ -115,12 +124,12 @@
|
|||
write = "inherit",
|
||||
}) {
|
||||
return {
|
||||
env: parseUnitPermission(env, "env"),
|
||||
env: parseArrayPermission(env, "env"),
|
||||
hrtime: parseUnitPermission(hrtime, "hrtime"),
|
||||
net: parseArrayPermission(net, "net"),
|
||||
plugin: parseUnitPermission(plugin, "plugin"),
|
||||
read: parseArrayPermission(read, "read"),
|
||||
run: parseUnitPermission(run, "run"),
|
||||
run: parseArrayPermission(run, "run"),
|
||||
write: parseArrayPermission(write, "write"),
|
||||
};
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
Deno: { core },
|
||||
__bootstrap: { webUtil: { illegalConstructorKey } },
|
||||
} = window;
|
||||
const { pathFromURL } = window.__bootstrap.util;
|
||||
const {
|
||||
ArrayPrototypeIncludes,
|
||||
Map,
|
||||
|
@ -161,6 +162,17 @@
|
|||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (desc.name === "read" || desc.name === "write") {
|
||||
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);
|
||||
return PromiseResolve(cache(desc, state));
|
||||
}
|
||||
|
@ -173,6 +185,17 @@
|
|||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (desc.name === "read" || desc.name === "write") {
|
||||
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);
|
||||
return PromiseResolve(cache(desc, state));
|
||||
}
|
||||
|
@ -185,6 +208,17 @@
|
|||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (desc.name === "read" || desc.name === "write") {
|
||||
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);
|
||||
return PromiseResolve(cache(desc, state));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue