diff --git a/waltid-libraries/auth/waltid-permissions/README-JS.md b/waltid-libraries/auth/waltid-permissions/README-JS.md new file mode 100644 index 000000000..f8c4f1da6 --- /dev/null +++ b/waltid-libraries/auth/waltid-permissions/README-JS.md @@ -0,0 +1,49 @@ +
+

Kotlin Multiplatform Permissions library

+ by walt.id +

Define, apply, and check permissions seamlessly across different platforms.

+ + Join community! + + + Follow @walt_id + +

+ +## 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 +``` \ No newline at end of file diff --git a/waltid-libraries/auth/waltid-permissions/build.gradle.kts b/waltid-libraries/auth/waltid-permissions/build.gradle.kts index 6a276dc30..741693b72 100644 --- a/waltid-libraries/auth/waltid-permissions/build.gradle.kts +++ b/waltid-libraries/auth/waltid-permissions/build.gradle.kts @@ -130,3 +130,21 @@ extensions.getByType().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) + } + } + } +} \ No newline at end of file