Deno First Look

Determining Permissions and Q&A

Burke Holland

Burke Holland

Deno First Look

Check out a free preview of the full Deno First Look course

The "Determining Permissions and Q&A" Lesson is part of the full, Deno First Look course featured in this preview video. Here's what you'd learn in this lesson:

Burke explains how to query specific permissions by making an API status request. Student questions regarding if Node were to implement Deno's permissions functionality and requesting elevated permissions with Deno are also covered in this segment.


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.

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.

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.

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?

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?

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?

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.

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.

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.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now