# solid-acl-parser

> A js library for parsing and modifying acl files

Latest version **0.2.1** (published 2019-12-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install solid-acl-parser
pnpm add solid-acl-parser
yarn add solid-acl-parser
bun add solid-acl-parser
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.1 |
| Published | 2019-12-07 |
| First published | 2019-07-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 2.3 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | otto-aa |
| Maintainers | otto-aa |
| Keywords | solid, acl, wac |

## Links

- npm: https://www.npmjs.com/package/solid-acl-parser
- Homepage: https://otto-aa.github.io/solid-acl-parser/
- Issues: https://github.com/otto-aa/solid-acl-parser/issues
- npm.io page: https://npm.io/package/solid-acl-parser

## Dependencies (6)

- [n3](https://npm.io/package/n3.md) ^1.3.4
- [core-js](https://npm.io/package/core-js.md) ^3.4.7
- [@types/n3](https://npm.io/package/@types/n3.md) ^1.1.1
- [url-parse](https://npm.io/package/url-parse.md) ^1.4.7
- [@types/url-parse](https://npm.io/package/@types/url-parse.md) ^1.4.3
- [@babel/runtime-corejs3](https://npm.io/package/@babel/runtime-corejs3.md) ^7.7.5

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 0.2.1 (latest) — 2019-12-07
- 0.2.0 — 2019-11-30
- 0.1.0 — 2019-09-24
- 0.0.3 — 2019-07-10
- 0.0.2 — 2019-07-09
- 0.0.1 — 2019-07-08

## README

# Solid ACL Parser
[![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:  <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 } = 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)
  console.log(newTurtle)
}
main()
```

Output turtle
```text/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.
```

---
_Source: https://npm.io/package/solid-acl-parser · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
