-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
Use web standard Permissions API #3200
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice
export class PermissionStatus { | ||
state: PermissionState; | ||
constructor(state: PermissionState); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you duplicate the jsdoc comments here?
(We need to fix this situation soon...)
assertEquals(perms[perm], perm === grant); | ||
} | ||
testPerm({ [grant]: true }, async function envGranted(): Promise<void> { | ||
const status0 = await Deno.permissions.query({ name: grant }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we not just start using the global Permissions object?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. Let's move permissions
under navigator
and other classes to global.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe leave it for separate PR since it is apparently controversial
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I misread the thread. OK. Let's keep it for now.
cli/js/permissions.ts
Outdated
url?: string; | ||
path?: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use sub types for these?
interface PermissionDescriptor {
name: PermissionName;
}
namespace Deno {
export interface NetPermissionDescriptor extends PermissionDescriptor {
name: "net";
url?: string;
}
// ...
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! That looks nicer. I'll update.
Like I said here #2767 (comment), putting this in What about this is supposed to work outside of deno anyway? 🙄 Happened with |
cli/js/permissions.ts
Outdated
type PermissionDescriptor = | ||
| SimplePermissionDescriptor | ||
| PathPermissionDescriptor | ||
| NetPermissionDescriptor; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Opinion: I think it would be better to give each permission its own interface so they are arbitrarily extensible e.g. #3137.
Maybe read/write have a meaningful commonality but the rest aren't related to each other.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense 👍 I separated descriptor types for each permission.
|
||
export class Permissions { | ||
query(d: PermissionDescriptor): Promise<PermissionStatus>; | ||
revoke(d: PermissionDescriptor): Promise<PermissionStatus>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to have jsdoc with examples for these, since the previous API did have nice docs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good. There's one more documentation change needed https://deno.land/std/manual.md#inspecting-and-revoking-permissions
Thank you for catching. Updated //std/manual.md. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - thanks! Looking forward to having this in the next release
This PR changes the current permissions API to the web standard Permissions API.
ref:
Partially addresses #2767.