{"id":16746,"library":"solid-auth-cli","title":"Solid Command-Line Authentication Client","description":"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.","status":"active","version":"1.0.15","language":"javascript","source_language":"en","source_url":null,"tags":["javascript"],"install":[{"cmd":"npm install solid-auth-cli","lang":"bash","label":"npm"},{"cmd":"yarn add solid-auth-cli","lang":"bash","label":"yarn"},{"cmd":"pnpm add solid-auth-cli","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required for integration with rdflib.js for RDF graph manipulation, specifically version 0.19.1 or newer.","package":"rdflib","optional":true}],"imports":[{"note":"solid-auth-cli is primarily a CommonJS module. Direct ES Module 'import' syntax is not supported without transpilation or a wrapper.","wrong":"import auth from 'solid-auth-cli'","symbol":"auth","correct":"const auth = require('solid-auth-cli')"},{"note":"The login method is accessed as a property of the main module export, not as a named export.","wrong":"import { login } from 'solid-auth-cli'","symbol":"login","correct":"auth.login()"},{"note":"The fetch method is accessed as a property of the main module export, not as a named export. This custom fetch function provides authenticated Solid requests.","wrong":"import { fetch } from 'solid-auth-cli'","symbol":"fetch","correct":"auth.fetch(resource)"}],"quickstart":{"code":"const solid = { auth:require('solid-auth-cli') }\nconst resource = \"https://example.com/private/hidden.ttl\" // Replace with your Solid Pod resource\nconst expected = \"only the owner\"\n\nconsole.log(\"logging in ...\")\nlogin().then( session => {\n    console.log(`logged in as <${session.webId}>`)\n    solid.auth.fetch(resource).then( response => {\n        if (!response.ok) console.log(response.status+\" \"+response.statusText)\n        response.text().then( content => {\n            if( content.match(new RegExp(expected)) ) console.log(\"ok: content matches expected pattern.\")\n            else console.log(\"Got something, but not the right thing.\")\n        },e => console.log(\"Error parsing : \"+e))\n    },e => console.log(\"Error fetching : \"+e))\n},e => console.log(\"Error logging in : \"+e))\n\nasync function login() {\n    // This example attempts a silent login from a previous session, then prompts if needed.\n    // For a non-interactive script, ensure credentials are set via env vars or config file.\n    var session = await solid.auth.currentSession()\n    if (!session) {\n        // You would typically configure IDP, username, password via env vars or a config file for CLI usage\n        session = await solid.auth.login() // Will attempt to read ~/.solid-auth-cli-config.json or env vars\n    }\n    return session;\n}","lang":"javascript","description":"This quickstart demonstrates how to log in persistently, fetch an authenticated resource from a Solid Pod, and check its content."},"warnings":[{"fix":"Ensure rdflib.js is installed at version 0.19.1 or higher. Run `npm install rdflib@^0.19.1` or update your `package.json`.","message":"When integrating with rdflib.js, solid-auth-cli requires rdflib.js version 0.19.1 or later due to API changes in rdflib's fetcher initialization.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use `const solid = require('solid-auth-cli')` or ensure your Node.js environment is configured for CommonJS. If you must use ESM, consider dynamic `import()` or a wrapper.","message":"solid-auth-cli is a CommonJS module. Attempting to use `import` statements directly in an ES Module context will fail unless Node.js is configured for interoperability or a build step transpiles it.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-22T00:00:00.000Z","next_check":"2026-07-21T00:00:00.000Z","problems":[{"fix":"Upgrade `rdflib.js` to version 0.19.1 or newer: `npm install rdflib@^0.19.1`.","cause":"Attempting to use `rdflib.js` with `solid-auth-cli` when `rdflib.js` is an older, incompatible version (prior to 0.19.1).","error":"TypeError: rdflib_1.default.fetcher is not a function"},{"fix":"Ensure your project's `package.json` specifies `\"type\": \"commonjs\"`, or rename your file to `.cjs`. Alternatively, wrap `solid-auth-cli` in a CJS file or use dynamic `import()` if truly in an ESM context.","cause":"You are attempting to use the `require()` function in an ES Module (ESM) context in Node.js, where `import` is expected.","error":"ReferenceError: require is not defined"},{"fix":"Provide credentials directly to `login({ idp: '...', username: '...', password: '...' })`, or create a `~/.solid-auth-cli-config.json` file, or set the necessary environment variables before running your script.","cause":"The `login()` method was called without sufficient credentials or configuration. It expects either an object with `idp`, `username`, `password`, a path to a credentials JSON file, or environment variables `SOLID_IDP`, `SOLID_USERNAME`, `SOLID_PASSWORD` to be set.","error":"Error logging in: No Identity Provider, username, or password found."}],"ecosystem":"npm"}