At a site collection level, I can look at the permission levels for the collection at
/sites/siteCollectionname/_layouts/15/role.aspx, and then I can navigate to a particular permission level and see the specific permissions that are granted to that level at
I want retrieve this information programmatically using CSOM. I can retrieve a site's RoleDefinitionCollection and enumerate the permission levels themselves, including their name, description and 'role type kind'. I now want to, for each RoleDefinition, enumerate the base permissions (PermissionKind?) that are set on it. For example, for a permission level represented in the below screenshot, I want to output "Add Items, Edit Items, Delete Items, View Items".
I am aware that permissions are implemented using masks and that this involves a high and low integer, but unsure how to fetch these and then transform them into human-readable permissions.