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()JSFS-Solid is both a client to access Solid PODs (storage) and an Adapter for the JSFS API.
npm install @muze-nl/jsfs-solidIn 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:
getpostputdeletepatchEach 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:
cdreadwritedeleteexistslist
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.
This software is licensed under MIT open source license. See the License file.