Library for parsing and modifying ACL files


I’ve finished the first version of an acl library: (see quickstart on how to use it)
It makes it rather easy to parse an acl turtle, then modify the permissions and finally parse it back to a turtle string. I will write a wrapper which also does fetching and saving to a pod in the next days.

There are some limitations, but it should be sufficient for the majority of use cases. It currently doesn’t support trustedApps, multiple accessTo-values in the same acl file and multiple default values for the same rule. Maybe this will change in future versions, but I’m not yet sure how I would do this without making it less simple to use.

Here is a short example, demonstrating how to add write permissions for a specific webId. More examples can be found in the documenation.

const { AclParser, Permissions } = SolidAclParser
const { WRITE, CONTROL } = Permissions

async 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)

I’ve also recreated nearly all examples from the WAC-Spec for testing purposes, so if something is missing in the documentation you could check if it is used there.

If you find a bug, think that a feature is missing or the interface lacks something, I’d be glad to hear your feedback on it