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

@dexagod/ldn-agent

v1.0.2

Published

The solution for notifications in a LDP environment.

Downloads

1

Readme

Solid notifications

The solution for notifications in a LDP environment.

Installation

This library can be installed using the following command: npm install @dexagod/ldn-agent

If the command line interface is required, it must be installed globally: npm install -g @dexagod/ldn-agent

Usage

CLI

In case the library is installed globally:

solid-notifications [options] <command>

The CLI interface can also be used through node:

node bin/solid-notifications.js [options] <command>

Javascript

const NotificationAgent = require('@dexagod/ldn-agent')

Configuration

A configuration object can be passed to the agent on creation. The options in this configuration object can be overwritten by overwriting the options in the parameters for specific commands.

CLI

On the CLI, the configuration file can be passed with a -c flag

solid-notifications -c config.json <command>

Javascript

const NotificationAgent = require('@dexagod/ldn-agent')
const config = {...}
const agent = new NotificationAgent(config)

Configuration options

{
  auth?: any,         // Only for javascript! A custom auth object can be passed.
  username?: string,  // Solid username. Used for authentication in node.
  password?: string,  // Solid password. Used for authentication in node.
  idp?: string,       // Solid Identity Provider. Used for authentication in node and browser.
  popup?: string,     // The URL of the login popup. Used for authentication in browser.
  sender?: string,    // The default sender added to notifications.
  format?: string,    // The format of all output data. Must be an RDF format.
  verbose?: boolean,  // Write logs to command line.
}

Authentication

Commands requiring the client to retrieve data from the inbox, may require the client to authenticate. Authentication is done using solid-auth-cli in Node, and using solid-auth-client in the browser.

CLI

The login information can be passed using the configuration file, or using the relevant option flags. Authentication will automatically be attempted for commands requiring authentication.

Javascript

The login information can be passed using the configuration file, or in the options of the login function.

const NotificationAgent = require('@dexagod/ldn-agent')
const agent = new NotificationAgent(config)

// Node && Browser
const options = { username, password, idp } 
await agent.login(options)

// Browser
// uri is the URI of the popup.
loginPopup(uri)


// Now the user is authenticated, and we can call functions requiring authentication.
// In browser environments, authentication can be easily handled by passing a custom auth object that is already authenticated.
// Else, The authentication control flow should not be awaited, but be handled using a better async approach (e.g. useEffect in React).

The used functions in the background are:

login() - node - browser

loginPopup(uri) - browser

Features

Sending notifications

CLI

solid-notifications [options] send [send-options] <receiver> <notification>

Javascript

const agent = require('@dexagod/ldn-agent')
const options = {...}
agent.sendNotification(options)

Options

{
  notification?: any,             // A Notification string
  notification_file?: any,        // A Notification file
  from: string[],                 // Senders of the notification
  to: string[],                   // Receivers of the notification
  cc?: string[],                  // CC contacts
  bcc?: string[],                 // BCC contacts
  contentType: string,            // Content Type of the notification. In the case of text/plain, the notification is as the content string of a notification (This does not work in the case of a notification file).
  contentTypeOutput: string,      // Content Type of the posted notification
}

The CLI interface handles the passed notification as a file if the -f flag is passed. All the option flags can be found here:

  solid-notifications send --help

Fetching inbox

If no url is given, it will default to the inbox of the currently authenticated user. An iterator is returned containing the notifications present in the inbox. In the case watch mode is set on the CLI, or the watch function is called in javascript, the inbox will be continuously monitored by the agent using a polling or websocket approach for new notifications. In javascript, this will return an asynciterator.

CLI

solid-notifications [options] list [list-options] [url]

Javascript

const agent = require('@dexagod/ldn-agent')
const options = {...}
// One time fetching of all notifications
const iterator = agent.listNotifications(options)
// watching the inbox continuously
const asynciterator = agent.watchNotifications(options)

Options

{
  webId?: string,                 // The resource of which the inbox is used.
  format?: string,                // The format in which notifications are emitted
  delete?:boolean,                // Notifications are deleted after listing
  watch?: boolean,                // Watch mode (currently only for CLI)
  filters?: any[],                // SAHCL shape files on which the notifications are evaluated
                                  // Only matching notifications are returned
}

All the CLI option flags can be found here:

solid-notifications list --help

Clearing inbox

If no url is given, it will default to the inbox of the currently authenticated user.

CLI

  solid-notifications [options] clear [clear-options] [url]

Javascript

const agent = require('@dexagod/ldn-agent')
const options = { ...}
agent.clearNotifications(options)

Options

{
  webId?: string,                 // The resource of which the inbox is used.
}

All the CLI option flags can be found here:

solid-notifications clear --help