You can install the library via npm:
npm install waltid-permissions
Here's a quick guide on how to use the library in your JavaScript environment.
First, import the library into your JavaScript file:
import lib from 'waltid-permissions';
Below is an example of how to create a PermissionChecker
, define a permission set, apply permissions, and check specific permissions:
// Create a new instance of PermissionChecker
const permissionChecker = new lib.id.walt.permissions.PermissionChecker();
// Create a permission set from a permission string
const permissionSet = lib.id.walt.permissions.FlowPermissionSet.Companion.fromPermissionStringFlow('orgA.a', 'orgA.tenant1:+issue,+config');
// Apply permissions asynchronously
await permissionChecker.applyPermissionsAsync(permissionSet);
// Check if a specific permission is granted
console.log(permissionChecker.checkPermission("orgA.tenant1.abc", "issue")); // Outputs: true/false