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

capability-uri

v0.4.1

Published

Capability URI scheme specification and reference implementation

Downloads

1

Readme

capability-uri

Stability: 1 - Experimental

NPM version

Contributors

@tristanls

Contents

Overview

This module documents the capability URI scheme and provides a reference implementation for generating and parsing capability URIs.

Capability URI Scheme

The "cpblty" scheme is used to identify capabilities.

There are two types of "cpblty" URIs. They are distinguished by the mechanism used to identify the authority responsible for resolving the capability.

The first type of capability URI uses IP address or DNS resolution to identify authority.

The second type of capability URI uses first path part of the URI to identify the authority responsible for resolving the capability, allowing for non-IP and non-DNS resolution mechanisms.

The scheme-specific syntax and semantics of capability URIs are as follows:

capability_URI = "cpblty:" "//" authority "/#" capability_token
               / "cpblty:" capability_authority [ "@" authority_scheme ] ":" capability_token
authority_scheme =  ALPHA *( ALPHA / DIGIT / "-" / "_" )
capability_authority = base64url
capability_token = "CPBLTY" version "-" base64url

The semantics are such that the identified authority is the domain containing the capability specified by the capability_token. For full specification of authority, see RFC 3986, Section 3.2 - Authority. Alternatively, the capability_authority, in combination with optional authority_scheme, is the authority containing the capability specified by the capability_token. The string CPBLTY is a well-known string to facilitate searches for leaked capabilities. version is the numeric version of capability_token used. base64url is URL-safe base64 encoded bytes of the specified capability.

Examples

Capability URI using example.com registered DNS name to designate authority:

cpblty://example.com/#CPBLTY1-IbwNerN4Dw4BYlpYc4Az-pNBWen_WsdrTrpb-HmMiJOEHvCv1xHKBn2Q

Capability URI using DkDvHuU78RZGUeNs3Q-Wsw authority to be interpreted using a custom my_dht resolution scheme:

cpblty:DkDvHuU78RZGUeNs3Q-Wsw@my_dht:CPBLTY1-IbwNerN4Dw4BYlpYc4Az-pNBWen_WsdrTrpb-HmMiJOEHvCv1xHKBn2Q

Capability URI using DkDvHuU78RZGUeNs3Q-Wsw authority with an implied resolution scheme:

cpblty:DkDvHuU78RZGUeNs3Q-Wsw:CPBLTY1-IbwNerN4Dw4BYlpYc4Az-pNBWen_WsdrTrpb-HmMiJOEHvCv1xHKBn2Q

Installation

npm install capability-uri

Tests

npm test

Usage

const CapabilityToken = require("capability-token");
const CapabilityURI = require("capability-uri");
const crypto = require("crypto");
const UrlSafeBase64 = require("urlsafe-base64");

const uri1 = CapabilityURI.parse(`cpblty://example.com/#${new CapabilityToken().serialize()}`);
console.log(uri1);
console.log(uri1.serialize());

const uri2 = new CapabilityURI(
    {
        authority: "example.com",
        capabilityToken: new CapabilityToken()
    }
);
console.log(uri2);
console.log(uri2.serialize());

const uri3 = new CapabilityURI(
    {
        capabilityAuthority: UrlSafeBase64.encode(crypto.randomBytes(64)),
        capabilityToken: new CapabilityToken()
    }
);
console.log(uri3);
console.log(uri3.serialize());

const uri4 = new CapabilityURI(
    {
        authorityScheme: "dht",
        capabilityAuthority: UrlSafeBase64.encode(crypto.randomBytes(64)),
        capabilityToken: new CapabilityToken()
    }
);
console.log(uri4);
console.log(uri4.serialize());

Documentation

CapabilityURI

IP/DNS Capability URI

  • authority: String Domain containing the capability specified by the capabilityToken. For full specification of authority, see RFC 3986, Section 3.2 - Authority.
  • capabilityToken: CapabilityToken CapabilityToken instance.

Other Capability URI

  • authorityScheme: String (Default: undefined) Optional authority scheme.
  • capabilityAuthority: String Base64url encoded authority containing the capability specified by the capabilityToken.
  • capabilityToken: CapabilityToken CapabilityToken instance.

Public API

CapabilityURI.parse(uri)

  • uri: String String capability URI to parse.
  • Return: CapabilityURI Parsed capability URI, either IP/DNS type or Other type.

new CapabilityURI(config)

  • config: Object configuration.
    • authority: String Domain containing the capability specified by the capabilityToken. For full specification of authority, see RFC 3986, Section 3.2 - Authority. Mutually exclusive with capabilityAuthority.
    • authorityScheme: String (Default: undefined) Optional authority scheme.
    • capabilityAuthority: String Base64url encoded authority containing the capability specified by the capabilityToken. Mutually exclusive with authority.
    • capabilityToken: CapabilityToken CapabilityToken instance.
  • Return: CapabilityURI Capability URI instance as configured.

Creates a new CapabilityURI instance as configured.

capabilityUri.serialize()

  • Return: String Capability URI.

Serializes capabilityUri into a string in URI format.

Releases

Current releases.

Policy

We follow the semantic versioning policy (semver.org) with a caveat:

Given a version number MAJOR.MINOR.PATCH, increment the:

MAJOR version when you make incompatible API changes, MINOR version when you add functionality in a backwards-compatible manner, and PATCH version when you make backwards-compatible bug fixes.

caveat: Major version zero is a special case indicating development version that may make incompatible API changes without incrementing MAJOR version.