Skip to content

Repository files navigation

Solid ACL Parser [Not actively maintained]

No Maintenance IntendedBuild Status

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.

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.

constSolidAclParser=require('SolicAclParser')constwebId='https://pod.example.org/profile/card#me'constaclUrl='https://pod.example.org/private/file.ext.acl'constfileUrl='https://pod.example.org/private/file.ext'constturtle=`@prefix acl: <http://www.w3.org/ns/auth/acl#>.@prefix foaf: <http://xmlns.com/foaf/0.1/>.<#Read-0> a acl:Authorization; acl:agentClass foaf:Agent; # everyone acl:mode acl:Read; # has Read-only access acl:accessTo <https://pod.example.org/private/file.ext>.`const{ AclParser, Permissions }=SolidAclParserconst{WRITE,CONTROL}=Permissionsasyncfunctionmain(){// Parse the turtle to an AclDoc object which we can modifyconstparser=newAclParser({ aclUrl, fileUrl })constdoc=awaitparser.turtleToAclDoc(turtle)// Give the webId WRITE and CONTROL permissionsdoc.addRule([WRITE,CONTROL],webId)// Parse it back to turtle so we can store it in the podconstnewTurtle=awaitparser.aclDocToTurtle(doc)console.log(newTurtle)}main()

Output turtle

@prefix acl: <http://www.w3.org/ns/auth/acl#>.
@prefix foaf: <http://xmlns.com/foaf/0.1/>.
<#Read-0> a acl:Authorization;
acl:agentClass foaf:Agent;
acl:accessTo <./file.ext>;
acl:mode acl:Read.
<#WriteControl-0> a acl:Authorization;
acl:agent </profile/card#me>;
acl:accessTo <./file.ext>;
acl:mode acl:Write, acl:Control.

About

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.

Topics

Resources

Stars

3 stars

Watchers

3 watching

Forks

Releases

Packages

Used by

Contributors

Languages