-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #801 from walt-id/chore/permissions-readme
chore: Added README for waltid-permissions
- Loading branch information
Showing
2 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<div align="center"> | ||
<h1>Kotlin Multiplatform Permissions library</h1> | ||
<span>by </span><a href="https://walt.id">walt.id</a> | ||
<p>Define, apply, and check permissions seamlessly across different platforms.<p> | ||
<a href="https://walt.id/community"> | ||
<img src="https://img.shields.io/badge/Join-The Community-blue.svg?style=flat" alt="Join community!" /> | ||
</a> | ||
<a href="https://twitter.com/intent/follow?screen_name=walt_id"> | ||
<img src="https://img.shields.io/twitter/follow/walt_id.svg?label=Follow%20@walt_id" alt="Follow @walt_id" /> | ||
</a> | ||
</div> | ||
|
||
## Installation | ||
|
||
You can install the library via npm: | ||
|
||
```bash | ||
npm install waltid-permissions | ||
``` | ||
|
||
## Usage | ||
|
||
Here's a quick guide on how to use the library in your JavaScript environment. | ||
|
||
### Importing the Library | ||
|
||
First, import the library into your JavaScript file: | ||
|
||
```javascript | ||
import lib from 'waltid-permissions'; | ||
``` | ||
|
||
### Example Code | ||
|
||
Below is an example of how to create a `PermissionChecker`, define a permission set, apply permissions, and check specific permissions: | ||
|
||
```javascript | ||
// 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 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters