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 🙏

© 2026 – Pkg Stats / Ryan Hefner

capability-stem

v0.0.4

Published

Capability stem enabling capabilities in GET HTTPS requests.

Readme

capability-stem

Stability: 1 - Experimental

NPM version License Issues Downloads

Capability stem enabling capabilities in GET HTTPS requests.

The capability is initially encoded as the fragment in the URI (see: https://tools.ietf.org/html/rfc3986#section-3.5). When the server receives the GET request, it returns JavaScript to the client that reads the fragment from the URI and encodes it as a Bearer token in a POST request (see: https://tools.ietf.org/html/rfc6750).

Contents

Installation

npm install capability-stem

Usage

To run the below example run:

npm run readme
"use strict";

var crypto = require('crypto');
var fs = require('fs');
var path = require('path');
var StemServer = require('../server.js');

var EXAMPLE_CAPABILITY = crypto.randomBytes(42).toString('base64');

var stemServer = StemServer.listen({
    host: 'localhost',
    port: 4443,
    key: fs.readFileSync(path.normalize(path.join(__dirname, 'readme/server-key.pem'))),
    cert: fs.readFileSync(path.normalize(path.join(__dirname, 'readme/server-cert.pem'))),
    secureProtocol: "TLSv1_method"
});

stemServer.on('listening', function () {
    console.log('server listening on https://localhost:4443');
    console.log('   ...try visiting https://localhost:4443/#' + EXAMPLE_CAPABILITY);
    console.log('   ...then visit just https://localhost:4443 in another tab');
    console.log('');
    console.log('Ctrl+C to exit');
});

stemServer.on('request', function (capability, req, res) {
    // we have a capability string, a request, and a response object

    // for example, we only allow EXAMPLE_CAPABILITY
    if (capability !== EXAMPLE_CAPABILITY) {
        console.log('received invalid request...');
        res.writeHead(401, {'Content-Type': 'text/html'});
        res.write('<h2>401 Unauthorized</h2>');
        res.end();
        return;
    }

    console.log('received valid request...');
    console.log(req.url);
    console.dir(req.headers);
    res.writeHead(200, {'Content-Type': 'text/html'});
    fs.createReadStream(
        path.normalize(path.join(__dirname, 'readme', 'content.html')))
        .pipe(res);
});

Tests

None at this time.

Documentation

CapabilityStem

Public API

CapabilityStem.listen(config, [callback])

Creates a new CapabilityStem instance and starts listening for connections.

new CapabilityStem(config)

Creates a new CapabilityStem instance.

capabilityStem.close([callback])

  • callback: Function (Default: undefined) function () {} Optional callback to call once the server is stopped.

Stops the CapabilityStem server from accepting new connections.

capabilityStem.listen([callback])

  • callback: Function (Default: undefined) function () {} Optional callback to call once the server is listening for connections.

After listen() is called, the server will begin accepting new connections.

Event 'request'

  • function (capability, request, response) {}

Emitted when the server receives a request with correctly encoded capability.

WARNING You still need to check that the capability is valid.