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

agntcy-dir

v1.0.0

Published

Directory SDK

Downloads

274

Readme

Directory JavaScript SDK

Overview

Dir JavaScript SDK provides a simple way to interact with the Directory API. It allows developers to integrate and use Directory functionality from their applications with ease. The SDK supports both JavaScript and TypeScript applications.

Note for users: The SDK is intended for use in Node.js applications and will not work in Web applications.

Features

The Directory SDK provides comprehensive access to all Directory APIs with a simple, intuitive interface:

Store API

  • Record Management: Push records to the store and pull them by reference
  • Metadata Operations: Look up record metadata without downloading full content
  • Data Lifecycle: Delete records permanently from the store
  • Referrer Support: Push and pull artifacts for existing records
  • Sync Management: Manage storage synchronization policies between Directory servers

Search API

  • Flexible Search: Search stored records using text, semantic, and structured queries
  • Advanced Filtering: Filter results by metadata, content type, and other criteria

Routing API

  • Network Publishing: Publish records to make them discoverable across the network
  • Content Discovery: List and query published records across the network
  • Network Management: Unpublish records to remove them from network discovery

Signing and Verification

  • Local Signing: Sign records locally using private keys or OIDC-based authentication. Requires dirctl binary to perform signing.
  • Remote Verification: Verify record signatures using the Directory gRPC API

Developer Experience

  • Type Safety: Full type hints for better IDE support and fewer runtime errors
  • Async Support: Non-blocking operations with streaming responses for large datasets
  • Error Handling: Comprehensive gRPC error handling with detailed error messages
  • Configuration: Flexible configuration via environment variables or direct instantiation

Installation

Install the SDK using one of available JS package managers like npm

  1. Initialize the project:
npm init -y
  1. Add the SDK to your project:
npm install agntcy-dir

Configuration

The SDK can be configured via environment variables or direct instantiation:

// Environment variables (insecure mode)
process.env.DIRECTORY_CLIENT_SERVER_ADDRESS = "localhost:8888";
process.env.DIRCTL_PATH = "/path/to/dirctl";

// Environment variables (X.509 authentication)
process.env.DIRECTORY_CLIENT_SERVER_ADDRESS = "localhost:8888";
process.env.DIRECTORY_CLIENT_AUTH_MODE = "x509";
process.env.DIRECTORY_CLIENT_SPIFFE_SOCKET_PATH = "/tmp/agent.sock";

// Environment variables (JWT authentication)
process.env.DIRECTORY_CLIENT_SERVER_ADDRESS = "localhost:8888";
process.env.DIRECTORY_CLIENT_AUTH_MODE = "jwt";
process.env.DIRECTORY_CLIENT_SPIFFE_SOCKET_PATH = "/tmp/agent.sock";
process.env.DIRECTORY_CLIENT_JWT_AUDIENCE = "spiffe://example.org/dir-server";

// Or configure directly
import {Config, Client} from 'agntcy-dir';

// Insecure mode (default, for development only)
const config = new Config(
    serverAddress="localhost:8888",
    dirctlPath="/usr/local/bin/dirctl"
);
const client = new Client(config);

// X.509 authentication with SPIRE
const x509Config = new Config(
    "localhost:8888", 
    "/usr/local/bin/dirctl",
    "/tmp/agent.sock",  // SPIFFE socket path
    "x509"  // auth mode
);
const x509Transport = await Client.createGRPCTransport(x509Config);
const x509Client = new Client(x509Config, x509Transport);

// JWT authentication with SPIRE
const jwtConfig = new Config(
    "localhost:8888",
    "/usr/local/bin/dirctl",
    "/tmp/agent.sock",  // SPIFFE socket path
    "jwt",  // auth mode
    "spiffe://example.org/dir-server"  // JWT audience
);
const jwtTransport = await Client.createGRPCTransport(jwtConfig);
const jwtClient = new Client(jwtConfig, jwtTransport);

Getting Started

Prerequisites

  • NodeJS - JavaScript runtime
  • npm - Package manager
  • dirctl - Directory CLI binary
  • Directory server instance (see setup below)

1. Server Setup

Option A: Local Development Server

# Clone the repository and start the server using Taskfile
task server:start

Option B: Custom Server

# Set your Directory server address
export DIRECTORY_CLIENT_SERVER_ADDRESS="your-server:8888"

2. SDK Installation

# Add the Directory SDK
npm install agntcy-dir

Usage Examples

See the Example JavaScript Project for a complete working example that demonstrates all SDK features.

npm install
npm run example