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

@vpnht/sdk

v1.1.2

Published

Node wrapper for [VPN.ht Desktop](https://github.com/vpnht/desktop).

Downloads

12

Readme

@vpnht/sdk

Node wrapper for VPN.ht Desktop.

Table Of Contents

Installation

With Yarn:

$ yarn add @vpnht/sdk

With NPM:

$ npm install @vpnht/sdk

Usage

const VPNht = require("@vpnht/sdk");

Quick Example

Run commands

const VPNht = require("@vpnht/sdk");

const isConnected = await VPNht.isConnected();

if (!VPNht.isInstalled()) {
  const installer = await VPNht.install();

  installer.on("download", ({ percent, time }) => {
    console.log({ percent, time });
  });

  installer.on("error", data => {
    console.log(data);
  });
}

if (!isConnected) {
  VPNht.open();
}

API

isConnected()

Return a Promise with true when the VPN is connected.

isInstalled()

Return a Boolean with true when the VPN Client is installed and ready.

open()

Open the VPN.ht Desktop client and detach it from the opening process.

signup({ email, password })

Create a new customer and return a Promise.

signin({ email, password })

Check the credentials and return a Promise with an auth token to be used on the API.

pickPlan({ plan, processor, authToken })

Pick a plan and create an invoice and return a Promise with a direct payment link.

plan = "MONTHLY" || "ANNUALLY"
processor = "PAYMENTWALL" || "PAYPAL" || "CRYPTO"
authToken = token collected from signup or signin

isActiveService({ authToken })

Return a Promise with true if the customer have an active service (paid)

install()

Return a Promise with an EventEmitter who expose the following events name.

ATTENTION: When you call the install() function, the download is initialized right away.

const installer = await VPNht.install();

.on('download', function (data) {})

Return the download progress with the following elements:

{
  "percent": 0.5,
  "speed": 554732,
  "size": {
    "total": 90044871,
    "transferred": 27610959
  },
  "time": {
    "elapsed": 36.235,
    "remaining": 81.403
  }
}

.on('downloaded', function (data) {})

Triggered when the download is complete.

ATTENTION: The sdk will automatically open the installer when ready. You shouldn't have to handle anything here, but the event is exposed in case you may need it.

{
  "path": "/var/tmp",
  "file": "/var/tmp/install.pkg"
}

.on('installed', function () {})

Triggered when the install is completed and the client ready.

We suggest to call open().

.on('error', function (error) {})

Triggered when something went wrong with the install procedure.

status()

Return a EventEmitter who expose the following events name.

ATTENTION: When you call the status() function, the service need to be ready. You can validate it with isInstalled function.

const status = VPNht.status();

.on('connected', function () {})

Triggered when the VPN status changed to connected.

.on('disconnected', function () {})

Triggered when the VPN status changed to connected.

.on('error', function (error) {})

Triggered when something went wrong with the service connection.