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

zerotier.js

v1.5.0

Published

A TypeScript wrapper for the ZeroTier One API, providing an easy-to-use interface for managing ZeroTier networks and clients.

Downloads

68

Readme

ZeroTier.js

A TypeScript wrapper for the ZeroTier One API, providing an easy-to-use interface for managing ZeroTier networks and clients.

Features

  • Supports ZeroTier Client and Controller functionality
  • Written in TypeScript for better type safety and autocompletion
  • Compatible with Node.js and browser environments
  • Automatically detects the platform and sets appropriate defaults
  • Supports reading credentials from a file or environment variable

Installation

npm install zerotier.js

Usage

ZeroTier Client

import { ZeroTierClient } from "zerotier.js";

const client = new ZeroTierClient();

client.getStatus().then((status) => {
  console.log("ZeroTier Status:", status);
});

client.getNetworks().then((networks) => {
  console.log("Networks:", networks);
});

ZeroTier Controller

import { ZeroTierController } from "zerotier.js";

const controller = new ZeroTierController();

controller.getNetworks().then((networks) => {
  console.log("Controller Networks:", networks);
});

controller.getMembers("your_network_id").then((members) => {
  console.log("Network Members:", members);
});

API Reference

ZeroTierAPI

The ZeroTierAPI class handles the underlying HTTP communication with the ZeroTier One API.

ZeroTierAPIOptions

The ZeroTierAPIOptions interface contains optional settings for the ZeroTierAPI class.

  • baseUrl: The base URL for the ZeroTier One API. Defaults to http://localhost:9993.
  • credentialsPath: The file path to the ZeroTier One API credentials. Defaults to the appropriate path based on the platform.
  • httpClient: An optional custom HTTPClient instance to use for making requests. Defaults to either BrowserHTTPClient or NodeHTTPClient depending on the environment.

Methods

  • invoke<T>(method: string, path: string, body?: any): Promise<T>: Makes an HTTP request to the API and returns the deserialized response body.

ZeroTierClient

The ZeroTierClient class provides methods for managing ZeroTier clients.

Methods

  • getConfig(): Promise<ZeroTier.Config>: Retrieves the client's configuration.
  • getStatus(): Promise<ZeroTier.Status>: Retrieves the client's status information.
  • getNetworks(): Promise<ZeroTier.Network[]>: Retrieves a list of networks the client is a member of.
  • getNetwork(id: string): Promise<ZeroTier.Network>: Retrieves information about a specific network.
  • joinNetwork(id: string): Promise<ZeroTier.Network>: Joins the client to a network.
  • leaveNetwork(id: string): Promise<{ result: boolean }>: Removes the client from a network.
  • getPeers(): Promise<ZeroTier.Peer[]>: Retrieves a list of peers connected to the client.
  • getPeer(id: string): Promise<ZeroTier.Peer>: Retrieves information about a specific peer.

ZeroTierController

The ZeroTierController class provides methods for managing ZeroTier networks and members.

Methods

  • getNetworks(): Promise<string[]>: Retrieves a list of network IDs managed by the controller.
  • getNetwork(id: string): Promise<ZeroTier.Controller.Network>: Retrieves information about a specific network.
  • createNetwork(id: string, data: Partial<ZeroTier.Controller.Network>): Promise<ZeroTier.Controller.Network>: Creates a new network with the provided data.
  • updateNetwork(id: string, data: Partial<ZeroTier.Controller.Network>): Promise<ZeroTier.Controller.Network>: Updates an existing network with the provided data.
  • deleteNetwork(id: string): Promise<ZeroTier.Controller.Network>: Deletes a network.
  • getMembers(id: string): Promise<{ [address: string]: number }>: Retrieves a list of members for a specific network.
  • getMember(id: string, memberId: string): Promise<ZeroTier.Controller.Member>: Retrieves information about a specific member.
  • authorizeMember(id: string, memberId: string): Promise<ZeroTier.Controller.Member>: Authorizes a member to access a network.
  • deauthorizeMember(id: string, memberId: string): Promise<ZeroTier.Controller.Member>: Deauthorizes a member from accessing a network.
  • deleteMember(id: string, memberId: string): Promise<ZeroTier.Controller.Member>: Removes a member from a network.

Please refer to the ZeroTier API documentation for more information on the available methods and data structures.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request or open an issue to report bugs, suggest improvements, or request new features.

License

This project is licensed under the MIT License.