Solid Command-Line Authentication Client

1.0.15 · active · verified Wed Apr 22

solid-auth-cli is a Node.js and command-line client library designed to facilitate persistent authentication with Solid Pods. It provides an API that mirrors solid-auth-client, enabling scripts to function in both browser (via solid-auth-client) and server-side/CLI environments (via solid-auth-cli) with minimal code changes. The current stable version is 1.0.15. While a specific release cadence isn't detailed, its versioning suggests a mature and stable 1.x branch. A key differentiator is its support for persistent logins using configuration files or environment variables, making it ideal for automated scripts or server-side applications that interact with Solid resources. It also offers a custom fetch implementation that can be integrated with rdflib.js (version 0.19.1 or newer) for graph data manipulation, or used directly for fetching resources via standard REST APIs, allowing programmatic interaction with the Solid ecosystem.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to log in persistently, fetch an authenticated resource from a Solid Pod, and check its content.

const solid = { auth:require('solid-auth-cli') }
const resource = "https://example.com/private/hidden.ttl" // Replace with your Solid Pod resource
const expected = "only the owner"

console.log("logging in ...")
login().then( session => {
    console.log(`logged in as <${session.webId}>`)
    solid.auth.fetch(resource).then( response => {
        if (!response.ok) console.log(response.status+" "+response.statusText)
        response.text().then( content => {
            if( content.match(new RegExp(expected)) ) console.log("ok: content matches expected pattern.")
            else console.log("Got something, but not the right thing.")
        },e => console.log("Error parsing : "+e))
    },e => console.log("Error fetching : "+e))
},e => console.log("Error logging in : "+e))

async function login() {
    // This example attempts a silent login from a previous session, then prompts if needed.
    // For a non-interactive script, ensure credentials are set via env vars or config file.
    var session = await solid.auth.currentSession()
    if (!session) {
        // You would typically configure IDP, username, password via env vars or a config file for CLI usage
        session = await solid.auth.login() // Will attempt to read ~/.solid-auth-cli-config.json or env vars
    }
    return session;
}

view raw JSON →