Transcript from the "Determining Permissions and Q&A" Lesson
>> Let's talk about determining permissions that we might already have. Because we don't wanna ask users for permissions that we already have. So you can query to get a specific permission. So in this case, let's just log out, I'm gonna just copy this in here. So we have this descriptor, let me collapse this terminal.
[00:00:22] So what we're gonna do here is just query and see, do we have this permission, right? And then we're just logging it out here. And then let's go ahead and query it afterwards to see what the state of it is, and just do this. All right, so now let's do deno run app.ts.
[00:00:44] All right, so you can see that by default the state is prompt. So if we haven't, we now have permissions the state is prompt. And if we say grant, then it becomes granted. And if we were to do that again and say deny, then the state is denied.
[00:00:57] Now, note that if you do this. Like this, if you pass this in, what do you think is gonna happen? Well, let's find out. Nothing, it never asks us, because it already sees that it's granted, so it just goes ahead and does that. However, if we were to give it an insufficient amount of access, like allow read equals the current directory, what will happen then?
[00:01:29] Then it asks us, because we didn't give it enough permissions. So you can see that the permissions API is pretty smart in so much as it's not gonna prompt you multiple times for permissions if those permissions are already there. So the question was, if Deno is asking you for permission, what what if node implements the same functionality, wouldn't that defeat the purpose of Deno?
[00:01:52] I don't know if that would, I don't think so. But I think that there's a better point there, what you just made, which is that, will node begin to adopt some of the things that Deno is doing, that we generally consider to be good ideas or improvements on the current state of affairs?
[00:02:11] And I think, yes, absolutely, it will. And in fact, I think that might be a more likely outcome here, is that we begin to see node adopt Deno's way of doing things. And then perhaps there's a merger at some point down the road back into a single project.
[00:02:28] So the question was, we were executing in the context of the current user, but what if we wanted to execute in the context of another user? Is there a way to request elevated permissions? I don't know, there isn't a way that I know of Deno to do that, but I'm not exactly sure if that's something that Deno should do, or if that's something that you should do.
[00:02:54] I guess I'm a little fuzzy on the use case of Deno saying, hey, I know you're running as this user, but I wanna run as a different user, can I do that? It seems like the answer to that would be, no, you just run Deno as that other user, but perhaps I'm missing something.
>> Good question though. I bet there is a use case for wanting to do that.