Skip to content

Commit

Permalink
Merge pull request #801 from walt-id/chore/permissions-readme
Browse files Browse the repository at this point in the history
chore: Added README for waltid-permissions
  • Loading branch information
taminobaumann authored Oct 15, 2024
2 parents 663dbe0 + 5aef9a1 commit 43df5b7
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
49 changes: 49 additions & 0 deletions waltid-libraries/auth/waltid-permissions/README-JS.md
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
```
18 changes: 18 additions & 0 deletions waltid-libraries/auth/waltid-permissions/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,21 @@ extensions.getByType<SuspendTransformGradleExtension>().apply {
)
)
}

npmPublish {
registries {
val envToken = System.getenv("NPM_TOKEN")
val npmTokenFile = File("secret_npm_token.txt")
val secretNpmToken =
envToken ?: npmTokenFile.let { if (it.isFile) it.readLines().first() else "" }
val hasNPMToken = secretNpmToken.isNotEmpty()
val isReleaseBuild = Regex("\\d+.\\d+.\\d+").matches(version.get())
if (isReleaseBuild && hasNPMToken) {
readme.set(File("README-JS.md"))
register("npmjs") {
uri.set(uri("https://registry.npmjs.org"))
authToken.set(secretNpmToken)
}
}
}
}

0 comments on commit 43df5b7

Please sign in to comment.