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

@ndn/nfdmgmt

v0.0.20240630

Published

NDNts: NFD Management

Downloads

15

Readme

@ndn/nfdmgmt

This package is part of NDNts, Named Data Networking libraries for the modern web.

This package implements basic support for NFD Management protocol. It includes both a generic variant and a NFD-specific variant with additional typing.

  • [X] ControlCommand
    • [X] generic: invokeGeneric, ControlResponse
    • [X] NFD: invoke, invokeCsErase, ControlParameters
  • [X] StatusDataset
    • [X] generic: list, StatusDataset
    • [X] NFD: FaceDataset, FaceQuery, CsInfo, StrategyChoice, RibEntry
  • [ ] NotificationStream

This implementation is validated against NFD using nfdmgmt-interop.

import { enableNfdPrefixReg } from "@ndn/nfdmgmt";

// other imports for examples
import { consume, produce } from "@ndn/endpoint";
import { Forwarder, type FwFace } from "@ndn/fw";
import { generateSigningKey } from "@ndn/keychain";
import { UnixTransport } from "@ndn/node-transport";
import { Data, Interest, Name } from "@ndn/packet";
import { delay, fromUtf8, toUtf8 } from "@ndn/util";
import assert from "node:assert/strict";

NFD Prefix Registration

enableNfdPrefixReg function enables NFD prefix registration. The snippet here shows API usage. If you are using @ndn/cli-common package, this is called automatically if the uplink connects to NFD.

// Create two forwarders, one as consumer and one as producer.
const fwC = Forwarder.create();
const fwP = Forwarder.create();

// Connect to NFD using Unix socket transport.
const unixSocket = process.env.DEMO_NFD_UNIX ?? "/run/nfd/nfd.sock";
let uplinkC: FwFace;
try {
  uplinkC = await UnixTransport.createFace({ fw: fwC }, unixSocket);
} catch {
  // Skip the example if NFD is not running.
  console.warn("NFD not running");
  process.exit(0);
}
const uplinkP = await UnixTransport.createFace({ fw: fwP, addRoutes: [] }, unixSocket);

// Generate a signing key and enable NFD prefix registration.
const [privateKey] = await generateSigningKey("/K");
enableNfdPrefixReg(uplinkP, { signer: privateKey });

// Start a producer.
const producer = produce("/P", async () => {
  console.log("producing");
  return new Data("/P", Data.FreshnessPeriod(1000), toUtf8("NDNts + NFD"));
}, { fw: fwP });
await delay(500);

// Start a consumer, fetch Data from the producer via NFD.
const data = await consume(new Interest("/P", Interest.MustBeFresh), { fw: fwC });
const payloadText = fromUtf8(data.content);
console.log("received", `${data.name} ${payloadText}`);
assert.equal(payloadText, "NDNts + NFD");

// Close faces.
uplinkC.close();
uplinkP.close();
producer.close();

Signed Interest 0.2

Previously, NFD Management protocol uses the deprecated Signed Interest 0.2 format. signInterest02 function provides basic support for this older format.

NFD is now accepting the Signed Interest format in NDN packet spec and this package has switched to it. However, signInterest02 function is temporarily kept for interoperability with other programs that follows the structure of NFD Management protocol but still requires the old format.