puter.perms.request()Request a specific permission string to be granted. Note that some permission strings are not supported and will be denied silently.
puter.perms.request(permission)
permission (string) (required)
The permission string to request. Permission strings follow specific formats depending on the resource type:
user:{uuid}:email:readfs:{path}:{read|write}apps-of-user:{uuid}:{read|write}subdomains-of-user:{uuid}:{read|write}A Promise that resolves to true if the permission was granted, or false otherwise.
<html>
<body>
<script src="https://js.puter.com/v2/"></script>
<button id="request-permission">Request Permission</button>
<script>
document.getElementById('request-permission').addEventListener('click', async () => {
// Get the current user's UUID
const user = await puter.auth.getUser();
const permission = `user:${user.uuid}:email:read`;
const granted = await puter.perms.request(permission);
if (granted) {
puter.print('Permission granted');
} else {
puter.print('Permission denied');
}
});
</script>
</body>
</html>