Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/otto-aa/solid-acl-parser
A js library for working with acl files. It allows you to parse the turtle representation, update permissions and agents, and finally convert it back to turtle. It does not cover fetching acl files.
https://github.com/otto-aa/solid-acl-parser
acl acl-library solid wac
Last synced: 7 days ago
JSON representation
A js library for working with acl files. It allows you to parse the turtle representation, update permissions and agents, and finally convert it back to turtle. It does not cover fetching acl files.
- Host: GitHub
- URL: https://github.com/otto-aa/solid-acl-parser
- Owner: Otto-AA
- License: mit
- Created: 2019-06-30T19:06:41.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-04T21:53:23.000Z (almost 2 years ago)
- Last Synced: 2024-10-05T09:42:26.072Z (about 1 month ago)
- Topics: acl, acl-library, solid, wac
- Language: JavaScript
- Homepage: https://otto-aa.github.io/solid-acl-parser/
- Size: 3.12 MB
- Stars: 3
- Watchers: 4
- Forks: 3
- Open Issues: 22
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Solid ACL Parser [Not actively maintained]
[![No Maintenance Intended](http://unmaintained.tech/badge.svg)](http://unmaintained.tech/)
[![Build Status](https://travis-ci.org/Otto-AA/solid-acl-parser.svg?branch=master)](https://travis-ci.org/Otto-AA/solid-acl-parser)A js library for working with acl files. It allows you to parse the turtle representation, update permissions and agents, and finally convert it back to turtle. *It does not cover fetching acl files.*
If you don't want to manually fetch and update the acl file, you can take a look at [solid-acl-utils](https://github.com/Otto-AA/solid-acl-utils).
# Documentation
Please refer to this website for documentation: https://otto-aa.github.io/solid-acl-parser/## Basic example
This example demonstrates how to parse a turtle string into an AclDoc object, then modify the permissions for a specific user and finally parse it back to turtle.```javascript
const SolidAclParser = require('SolicAclParser')const webId = 'https://pod.example.org/profile/card#me'
const aclUrl = 'https://pod.example.org/private/file.ext.acl'
const fileUrl = 'https://pod.example.org/private/file.ext'
const turtle = `
@prefix acl: .
@prefix foaf: .<#Read-0>
a acl:Authorization;
acl:agentClass foaf:Agent; # everyone
acl:mode acl:Read; # has Read-only access
acl:accessTo .`const { AclParser, Permissions } = SolidAclParser
const { WRITE, CONTROL } = Permissionsasync function main() {
// Parse the turtle to an AclDoc object which we can modify
const parser = new AclParser({ aclUrl, fileUrl })
const doc = await parser.turtleToAclDoc(turtle)// Give the webId WRITE and CONTROL permissions
doc.addRule([WRITE, CONTROL], webId)// Parse it back to turtle so we can store it in the pod
const newTurtle = await parser.aclDocToTurtle(doc)
console.log(newTurtle)
}
main()
```Output turtle
```text/turtle
@prefix acl: .
@prefix foaf: .<#Read-0> a acl:Authorization;
acl:agentClass foaf:Agent;
acl:accessTo <./file.ext>;
acl:mode acl:Read.
<#WriteControl-0> a acl:Authorization;
acl:agent ;
acl:accessTo <./file.ext>;
acl:mode acl:Write, acl:Control.
```