Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Added README for waltid-permissions #801

Merged
merged 1 commit into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
}
}
}
}
Loading