Skip to content

muze-nl/jsfs-solid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitHub License GitHub package.json version NPM Version npm bundle size Project stage: Experimental

JSFS-Solid: a jsfs solid client

import '@muze-nl/jsfs-solid'

async function main() {
	const client = await solidClient(
		"https://auke.solidcommunity.net/profile/card#me",
	    {
	        client_info: {
	  		     client_name: 'My Client'
	  	    }
	    }
	)
    const dir = await client.storage[0].list()
    console.log(dir)
}

main()

Table of Contents

  1. Introduction
  2. Usage
  3. Dependencies
  4. Contributing
  5. License

Introduction

JSFS-Solid is both a client to access Solid PODs (storage) and an Adapter for the JSFS API.

Usage

npm install @muze-nl/jsfs-solid

In the browser, using a cdn:

<script src="https://cdn.jsdelivr.net/npm/@muze-nl/jsfs-solid/dist/browser.js"></script>

Using ES6 modules, in the browser (using a bundler) or Node (or Deno, or...):

import '@muze-nl/jsfs-solid'

Create a new client like this:

const client = await solidClient(
	'https://auke.solidcommunity.net/profile/card#me', // a solid webid
	{
		client_info: {
			client_name: "My Client"
		}
	}
)

This will read the webid profile and return an API that includes:

  • profile: an object containing the profile information, parsed with OLDM
  • storage: an array with all the storage entries from the webid profile, as a filesystem API (using JSFS)
  • id(): returns the id token, but only if the client has been forced to authenticate/authorize to access a resource.
  • issuer: the first issuer defined in the webid profile, or null
  • inbox: the first inbox defined in the webid profile, or null

In addition, the client is an HTTP client (Using Metro with the following methods:

  • get
  • post
  • put
  • delete
  • patch Each of these will automatically trigger an OIDC (OpenID Connect) Solid authorization step, if the requested resource requires it.

Each storage entry implements a simple filesystem API with the following methods:

  • cd
  • read
  • write
  • delete
  • exists
  • list

The list method returns an array of objects with these properties:

{
	filename,
	path,
	name
}

The read method returns these properties, where data is a dataset using OLDM.

{
	type,
	name,
	contents,
	data,
	http: {
		headers,
		status,
		url
	}
}

Similarly, you can write files like this:

await client.write(data, 'movies.ttl', 'text/turtle')

Just make sure that the data is OLDM data.

Dependencies

License

This software is licensed under MIT open source license. See the License file.

About

No description, website, or topics provided.

Resources

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors