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

@srchetwynd/indie-discover

v1.1.0

Published

Endpoint Discoverer for the Indie-web

Downloads

2

Readme

indie-discover

indie-discover is an indie web endpoint discovery module

indie-discover, is part of the indie-pen-dent project, a set of javascript/nodejs applications which implement the indie web standards.

pipeline status coverage report Latest Release semantic-release: angular

Installation

pnpm i @srchetwynd/indie-discover

Or:

npm i @srchetwynd/indie-discover

Usage

The module exports a single class EndpointDiscoverer, which requires 2 parameters:

  1. A url of the site to discover endpoints from
  2. A HTML parser

HTML parser

The html parser is function which will take a HTML page as a string, and return an object with a getHref function which will retrieve the href from the document.

Here is an example using Cheerio:

import { load as cheerioLoad } from 'cheerio';

function HTMLParserFactory(page: string) {
    const loadedPage = cheerioLoad(page);
    const getHref = (query: string) => {
        const endpointElement = loadedPage(query);
        return endpointElement?.attr('href');
    };

    return {
        getHref,
    };
}

And an example using the browsers HTML parser:

function HTMLParserFactory(page: string) {
    const loadedPage = document.createElement('template');
    const getHref = (query: string) => {
        const endpointElement = loadedPage.content.querySelector(query);
        return endpointElement?.attributes.getNamedItem('href')?.value;
    };
}

Interface

The Endpoint Discoverer has 8 public methods:

discoverAuthorizationEndpoint(): Promise<string | undefined>
discoverTokenEndpoint(): Promise<string | undefined>
discoverRevocationEndpoint(): Promise<string | undefined> 
discoverIntrospectionEndpoint(): Promise<string | undefined> 
discoverUserinfoEndpoint(): Promise<string | undefined> 
discoverMicropubEndpoint(): Promise<string | undefined> 
discoverMicrosubEndpoint(): Promise<string | undefined> 
discoverMetadataEndpoint(): Promise<string | undefined> 

Each method will return the url of the endpoint as provided on the website at the provided URL.

If the site does not have the requested endpoint undefined is returned.

Support

The best place for support will be on the gitlab repository

Roadmap

Currently this supports:

  • Endpoints:
    • Authorization
    • Token
    • Revocation
    • Introspection
    • Userinfo
    • Micropub
    • Microsub
    • Metadata
  • Discovery through HTML elements

Still to support

  • Discovery through link headers
  • Support relative urls
  • Living standard:
    • Support indieauth-metadata endpoint

Contributing

I'm open to contributions, please submit issues in to the respository for ideas to improve the project. All ideas are welcome and appreciated.

Any merge will be welcome and considered, but they must pass the current linting rules, as well as the current tests, and ideally add more.

Setting up for development

These steps will get a development setup running.

  1. clone this repo,
  2. run pnpm i (If installed, or checkout why its awesome here https://pnpm.io/)
  3. run pnpm run dev

Authors and acknowledgment

It is currently a solo effort by me, but any help is welcome.

It would be unfair not to mention indieauth-client-php projects, whilst this project is not a fork of it, it was heavily influenced by it.

License

This project is licensed under the MIT License. A copy of which should be included in this repository.

Project status

This is currently under active development, but only in spare time around work, and other commitments.