npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@gatos-jd/solid-server

v5.0.1-4

Published

Just like solid-server, but implicitly using @gatos-jd/oidc-rp for long lived tokens

Downloads

1

Readme

solid-server in Node

Build Status NPM Version Gitter chat

Solid server in NodeJS

solid-server lets you run a Solid server on top of the file-system. You can use it as a command-line tool (easy) or as a library (advanced).

Solid Features supported

Command Line Usage

Install

You can install and run the server either using Node.js directly or using Docker. This and the following sections describe the first approach, for the second approach see the section use Docker Section below.

To install, first install Node and then run the following

$ npm install -g solid-server

Run a single-user server (beginner)

The easiest way to setup solid-server is by running the wizard. This will create a config.json in your current folder

$ solid init

Note: If prompted for an SSL key and certificate, follow the instructions below.

To run your server, simply run solid start:

$ solid start
# Solid server (solid v0.2.24) running on https://localhost:8443/

If you prefer to use flags instead, the following would be the equivalent

$ solid start --port 8443 --ssl-key path/to/ssl-key.pem --ssl-cert path/to/ssl-cert.pem
# Solid server (solid v0.2.24) running on https://localhost:8443/

If you want to run solid on a particular folder (different from the one you are in, e.g. path/to/folder):

$ solid start --root path/to/folder --port 8443 --ssl-key path/to/ssl-key.pem --ssl-cert path/to/ssl-cert.pem
# Solid server (solid v0.2.24) running on https://localhost:8443/

Running in development environments

Solid requires SSL certificates to be valid, so you cannot use self-signed certificates. To switch off this security feature in development environments, you can use the bin/solid-test executable, which unsets the NODE_TLS_REJECT_UNAUTHORIZED flag and sets the rejectUnauthorized option.

How do I get an SSL key and certificate?

You need an SSL certificate from a certificate authority, such as your domain provider or Let's Encrypt!.

For testing purposes, you can use bin/solid-test with a self-signed certificate, generated as follows:

$ openssl req -outform PEM -keyform PEM -new -x509 -sha256 -newkey rsa:2048 -nodes -keyout ../privkey.pem -days 365 -out ../fullchain.pem

Note that this example creates the fullchain.pem and privkey.pem files in a directory one level higher from the current, so that you don't accidentally commit your certificates to solid while you're developing.

If you would like to get rid of the browser warnings, import your fullchain.pem certificate into your 'Trusted Root Certificate' store.

Run multi-user server (intermediate)

You can run solid so that new users can sign up, in other words, get their WebIDs username.yourdomain.com.

Pre-requisites:

  • Get a Wildcard Certificate
  • Add a Wildcard DNS record in your DNS zone (e.g.*.yourdomain.com)
  • (If you are running locally) Add the line 127.0.0.1 *.localhost to /etc/hosts
$ solid init
..
? Allow users to register their WebID (y/N) # write `y` here
..
$ solid start

Otherwise, if you want to use flags, this would be the equivalent

$ solid start --multiuser --port 8443 --ssl-cert /path/to/cert --ssl-key /path/to/key --root ./data

Your users will have a dedicated folder under ./data at ./data/<username>.<yourdomain.tld>. Also, your root domain's website will be in ./data/<yourdomain.tld>. New users can create accounts on /api/accounts/new and create new certificates on /api/accounts/cert. An easy-to-use sign-up tool is found on /api/accounts.

Running Solid behind a reverse proxy (such as NGINX)

See Running Solid behind a reverse proxy.

How can I send emails to my users with my Gmail?

To use Gmail you may need to configure "Allow Less Secure Apps" in your Gmail account unless you are using 2FA in which case you would have to create an Application Specific password. You also may need to unlock your account with "Allow access to your Google account" to use SMTP.

Extra flags (expert)

The command line tool has the following options

$ solid

  Usage: solid [options] [command]

  Commands:
    init [options]    create solid server configurations
    start [options]   run the Solid server

  Options:
    -h, --help     output usage information
    -V, --version  output the version number


$ solid init --help

  Usage: init [options]
  Create solid server configurations

  Options:
    -h, --help  output usage information
    --advanced  Ask for all the settings


$ solid start --help

  Usage: start [options]

  run the Solid server


  Options:

    --root [value]                Root folder to serve (default: './data')
    --port [value]                SSL port to use
    --server-uri [value]          Solid server uri (default: 'https://localhost:8443')
    --webid                       Enable WebID authentication and access control (uses HTTPS)
    --mount [value]               Serve on a specific URL path (default: '/')
    --config-path [value]
    --config-file [value]
    --db-path [value]
    --auth [value]                Pick an authentication strategy for WebID: `tls` or `oidc`
    --owner [value]               Set the owner of the storage (overwrites the root ACL file)
    --ssl-key [value]             Path to the SSL private key in PEM format
    --ssl-cert [value]            Path to the SSL certificate key in PEM format
    --no-reject-unauthorized      Accept self-signed certificates
    --multiuser                   Enable multi-user mode
    --idp [value]                 Obsolete; use --multiuser
    --no-live                     Disable live support through WebSockets
    --proxy [value]               Obsolete; use --corsProxy
    --cors-proxy [value]          Serve the CORS proxy on this path
    --suppress-data-browser       Suppress provision of a data browser
    --data-browser-path [value]   An HTML file which is sent to allow users to browse the data (eg using mashlib.js)
    --suffix-acl [value]          Suffix for acl files (default: '.acl')
    --suffix-meta [value]         Suffix for metadata files (default: '.meta')
    --secret [value]              Secret used to sign the session ID cookie (e.g. "your secret phrase")
    --error-pages [value]         Folder from which to look for custom error pages files (files must be named <error-code>.html -- eg. 500.html)
    --force-user [value]          Force a WebID to always be logged in (useful when offline)
    --strict-origin               Enforce same origin policy in the ACL
    --use-email                   Do you want to set up an email service?
    --email-host [value]          Host of your email service
    --email-port [value]          Port of your email service
    --email-auth-user [value]     User of your email service
    --email-auth-pass [value]     Password of your email service
    --use-api-apps                Do you want to load your default apps on /api/apps?
    --api-apps [value]            Path to the folder to mount on /api/apps
    --redirect-http-from [value]  HTTP port or ','-separated ports to redirect to the solid server port (e.g. "80,8080").
    --server-name [value]         A name for your server (not required, but will be presented on your server's frontpage)
    --server-description [value]  A description of your server (not required)
    --server-logo [value]         A logo that represents you, your brand, or your server (not required)
    --enforce-toc                 Do you want to enforce Terms & Conditions for your service?
    --toc-uri [value]             URI to your Terms & Conditions
    --support-email [value]       The support email you provide for your users (not required)
    -q, --quiet                   Do not print the logs to console
    -h, --help                    output usage information

Instead of using flags, these same options can also be configured via environment variables taking the form of SOLID_ followed by the SNAKE_CASE of the flag. For example --api-apps can be set via the SOLID_API_APPSenvironment variable, and --serverUri can be set with SOLID_SERVER_URI.

CLI flags take precedence over Environment variables, which take precedence over entries in the config file.

Configuring Solid via the config file can be a concise and convenient method and is the generally recommended approach. CLI flags can be useful when you would like to override a single configuration parameter, and using environment variables can be helpful in situations where you wish to deploy a single generic Docker image to multiple environments.

Use Docker

Build with:

docker build -t node-solid-server .

Run with:

docker run -p 8443:8443 --name solid node-solid-server

This will enable you to login to solid on https://localhost:8443 and then create a new account but not yet use that account. After a new account is made you will need to create an entry for it in your local (/etc/)hosts file in line with the account and subdomain i.e.

127.0.0.1 newsoliduser.localhost

Then you'll be able to use solid as intended.

You can modify the config within the docker container as follows:

  • Copy the config to the current directory with: docker cp solid:/usr/src/app/config.json .
  • Edit the config.json file
  • Copy the file back with docker cp config.json solid:/usr/src/app/
  • Restart the server with docker restart solid

Library Usage

Install Dependencies

npm install

Library Usage

The library provides two APIs:

  • solid.createServer(settings): starts a ready to use Express app.
  • lnode(settings): creates an Express that you can mount in your existing express app.

In case the settings is not passed, then it will start with the following default settings.

{
  cache: 0, // Set cache time (in seconds), 0 for no cache
  live: true, // Enable live support through WebSockets
  root: './', // Root location on the filesystem to serve resources
  secret: 'node-ldp', // Express Session secret key
  cert: false, // Path to the ssl cert
  key: false, // Path to the ssl key
  mount: '/', // Where to mount Linked Data Platform
  webid: false, // Enable WebID+TLS authentication
  suffixAcl: '.acl', // Suffix for acl files
  corsProxy: false, // Where to mount the CORS proxy
  errorHandler: false, // function(err, req, res, next) to have a custom error handler
  errorPages: false // specify a path where the error pages are
}

Have a look at the following examples or in the examples/ folder for more complex ones

Simple Example

You can create a solid server ready to use using solid.createServer(opts)

var solid = require('solid-server')
var ldp = solid.createServer({
    key: '/path/to/sslKey.pem',
    cert: '/path/to/sslCert.pem',
    webid: true
})
ldp.listen(3000, function() {
  // Started Linked Data Platform
})
Advanced Example

You can integrate solid in your existing Express app, by mounting the solid app on a specific path using lnode(opts).

var solid = require('solid-server')
var app = require('express')()
app.use('/test', solid(yourSettings))
app.listen(3000, function() {
  // Started Express app with ldp on '/test'
})
...
Logging

Run your app with the DEBUG variable set:

$ DEBUG="solid:*" node app.js

Testing solid Locally

Pre-Requisites

In order to really get a feel for the Solid platform, and to test out solid, you will need the following:

  1. A WebID profile and browser certificate from one of the Solid-compliant identity providers, such as solid.community.

  2. A server-side SSL certificate for solid to use (see the section below on creating a self-signed certificate for testing).

While these steps are technically optional (since you could launch it in HTTP/LDP-only mode), you will not be able to use any actual Solid features without them.

Creating a certificate for local testing

When deploying solid in production, we recommend that you go the usual Certificate Authority route to generate your SSL certificate (as you would with any website that supports HTTPS). However, for testing it locally, you can easily generate a self-signed certificate for whatever domain you're Working with.

Accessing your server

If you started your solid server locally on port 8443 as in the example above, you would then be able to visit https://localhost:8443 in the browser (ignoring the Untrusted Connection browser warnings as usual), where your solid server would redirect you to the default data viewer app.

Editing your local /etc/hosts

To test certificates and account creation on subdomains, solid's test suite uses the following localhost domains: nic.localhost, tim.localhost, and nicola.localhost. You will need to create host file entries for these, in order for the tests to pass.

Edit your /etc/hosts file, and append:

# Used for unit testing solid
127.0.0.1 nic.localhost
127.0.0.1 tim.localhost
127.0.0.1 nicola.localhost

Running the Unit Tests

$ npm test
# running the tests with logs
$ DEBUG="solid:*" npm test

In order to test a single component, you can run

npm run test-(acl|formats|params|patch)

Blacklisted usernames

By default Solid will not allow certain usernames as they might cause confusion or allow vulnerabilies for social engineering. This list is configurable via config/usernames-blacklist.json. Solid does not blacklist profanities by default.

Quota

By default, a file serverSide.ttl.inactive will be installed to new PODs. If you rename it to serverSide.ttl, it will currently set a quota for disk usage. This file is not writeable to users, only server administrators who are authorized on the backend can modify it. It is currently adviceable to remove it or set it inactive rather than set a large quota, because the current implementation will impair write performance if there is a lot of data.

Contribute to Solid

Solid is only possible because of a large community of contributors. A heartfelt thank you to everyone for all of your efforts!

You can help us too:

Have a look at CONTRIBUTING.md.

License

The MIT License