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

@sentinel-official/sentinel-js-sdk

v2.1.0

Published

sentinel javascript sdk

Readme

sentinel-js-sdk

The Sentinel JS SDK relays on CosmJS and it was developed following the official tutorial, it take also inspiration from other open source Cosmos SDK.

NPM Version NPM Downloads GitHub Repo stars GitHub forks

The SDK exstends the followings:

Full documentation: https://sentinel-official.github.io/sentinel-js-sdk/

VPN protocols

The SDK supports every service type advertised by sentinel-dvpnx v9:

| Protocol | SDK class | Client mode | Runtime executable | | --- | --- | --- | --- | | WireGuard | Wireguard | Full tunnel | wg-quick | | V2Ray | V2Ray | Local SOCKS5 proxy | v2ray | | OpenVPN | OpenVPN | Full tunnel | openvpn | | Xray | Xray | Local SOCKS5 proxy | xray | | AmneziaWG | AmneziaWG | Full tunnel | awg-quick | | Hysteria2 | Hysteria2 | Full tunnel | hysteria2 |

The SDK creates protocol credentials, parses the authenticated node handshake, writes private configuration files (0600 on Unix), and starts/stops the corresponding client. Native executables are not bundled in the npm package. Full-tunnel clients require root/administrator network privileges.

The connection flow is the same for all protocols:

  1. Query an active node and inspect nodeInfo(remoteAddr).service_type.
  2. Start an on-chain session and obtain its session ID from NodeEventCreateSession.
  3. Create the matching client class and send its peer request through handshake.
  4. Base64-decode and parse result.data, then call parseConfig.
  5. Call connect; later call disconnect and cleanup.
import {
    AmneziaWG,
    Hysteria2,
    NodeVPNType,
    OpenVPN,
    V2Ray,
    Wireguard,
    Xray,
    handshake,
} from "@sentinel-official/sentinel-js-sdk";

const clients = {
    [NodeVPNType.WIREGUARD]: () => new Wireguard(),
    [NodeVPNType.V2RAY]: () => new V2Ray(),
    [NodeVPNType.OPENVPN]: () => new OpenVPN(),
    [NodeVPNType.XRAY]: () => new Xray(),
    [NodeVPNType.AMNEZIAWG]: () => new AmneziaWG(),
    [NodeVPNType.HYSTERIA2]: () => new Hysteria2(),
};

const serviceType = nodeStatus.service_type;
const vpn = clients[serviceType]();

const result = await handshake(
    sessionId,
    vpn.getPeerRequest(),
    cosmosPrivateKey,
    node.remoteAddrs[0],
);
const data = JSON.parse(Buffer.from(result.data, "base64").toString("utf8"));
await vpn.parseConfig(data, result.addrs);
await vpn.connect();

V2Ray and Xray expose the selected local proxy port as vpn.socksPort. Their traffic must be routed through socks5://127.0.0.1:<socksPort>; they do not alter the system default route.

clients

import { SentinelClient } from "@sentinel-official/sentinel-js-sdk";

const rpc = "https://rpc.sentinel.co:443"
const client = await SentinelClient.connect(rpc)

If you need to sign and broadcast a tx you need to instantiate a SigningClient.

import { SigningSentinelClient } from "@sentinel-official/sentinel-js-sdk";
import { DirectSecp256k1HdWallet } from "@cosmjs/proto-signing"
import { GasPrice } from "@cosmjs/stargate"

const wallet = await DirectSecp256k1HdWallet.fromMnemonic(mnemonic, { prefix: "sent" });
const [account] = await wallet.getAccounts();

const rpc = "https://rpc.sentinel.co:443"

// With a default GasPrice:
const customDenom = "udvpn"
const gasPrice = GasPrice.fromString(`0.2${customDenom}`);
const client = await SigningSentinelClient.connectWithSigner(rpc, wallet, {
    gasPrice: gasPrice
})

// Without a default GasPrice:
const client = await SigningSentinelClient.connectWithSigner(rpc, wallet)

You can also set other default parameters: https://cosmos.github.io/cosmjs/latest/stargate/interfaces/SigningStargateClientOptions.html.

In order to subscribe to chain events you need a websocket client

import { SentinelWsClient } from "@sentinel-official/sentinel-js-sdk";
const client = new SentinelWsClient("wss://rpc.sentinel.quokkastake.io");
const stream = client.subscribe("tm.event='NewBlock'")
stream.addListener({
    next: data => console.log(data),
    error: err => console.error(err),
    complete: () => console.log('completed'),
});

query

import { Status, PageRequest } from "@sentinel-official/sentinel-js-sdk";
const nodes = await client.sentinelQuery?.node.nodes(
    Status.STATUS_ACTIVE,
    PageRequest.fromPartial({
        limit: 5,
        countTotal: true
    })
)

For pagination please follow:

  • https://docs.cosmos.network/v0.45/core/proto-docs.html#cosmos-base-query-v1beta1-pagination-proto
  • https://github.com/cosmos/cosmos-sdk/blob/main/types/query/pagination.pb.go#L32-L53
  • https://github.com/confio/cosmjs-types/blob/main/src/cosmos/base/query/v1beta1/pagination.ts

transaction

After you have initialize a SigningClient you can prepare and broadcast a tx in multiple ways.

  1. Create a MsgEcodeObject and call signAndBroadcast from your client.
import { TxNodeStartSession, nodeStartSession } from "@sentinel-official/sentinel-js-sdk";
import Long from "long";

const udvpn = p2pNode.node.gigabytePrices.filter(x => x.denom === "udvpn")[0] as Price
const args: TxNodeStartSession = {
    from: account.address,
    nodeAddress: p2pNode.node.address,
    gigabytes: Long.fromString(gygabytes, true),
    maxPrice: udvpn
}
const msg = nodeStartSession(args)
const tx = client.signAndBroadcast(account.address, [msg], "auto", "memo")
  1. Call directly nodeStartSession from your client or from submodule (this will automatically signAndBroadcast the tx)
import { TxNodeStartSession } from "@sentinel-official/sentinel-js-sdk";
import Long from "long";

const args: TxNodeStartSession = {
    from: account.address,
    nodeAddress: sentnode,
    gigabytes: Long.fromNumber(gygabyte, true),
    fee: "auto",
    memo: "hello from js-sdk"
    maxPrice: ....
}
// call directly
const tx1 = client.nodeStartSession(args)
// use submodule
const tx2 = client.node.startSession(args)

It is up to you if you want to await the tx or use a callback

const tx1 = await client.nodeStartSession(args)
client.nodeStartSession(args).then(tx => { do stuff... })

events parsing

client.signAndBroadcast or implicit call trought, for example, client.nodeStartSession or client.node.subscribe return a DeliverTxResponse. You can search for a determinate event using the method searchEvent. For example if you are looking for sentinel.node.v3.EventCreateSession, you can do the following:

import { searchEvent } from "@sentinel-official/sentinel-js-sdk";
const eventCreateSubscription = searchEvent(sentinel.node.v3.EventCreateSession, tx.events);

or better

import { searchEvent } from "@sentinel-official/sentinel-js-sdk";
import { NodeEventCreateSession } from "@sentinel-official/sentinel-js-sdk";
const eventCreateSubscription = searchEvent(NodeEventCreateSession.type, tx.events);

The single event can also be parsed via the appropriate interface, following the example:

import { searchEvent } from "@sentinel-official/sentinel-js-sdk";
import { NodeEventCreateSession, isNodeEventCreateSession } from "@sentinel-official/sentinel-js-sdk";

const eventCreateSubscription = searchEvent(NodeEventCreateSession.type, tx.events);
if(eventCreateSubscription && isNodeEventCreateSession(eventCreateSubscription)) {
    const eventParsed = NodeEventCreateSession.parse(eventCreateSubscription)
    console.log(`Your subscription id is: ${eventParsed.value.sessionId}`)
} else console.log("eventCreateSubscription, not found")

protobuf

All the .proto files are compiled using protoc and ts-proto as plugin. The compiled .ts proto files are under src/protobuf. If you want to compile again you can use scripts/generate-proto.sh. The script requires git and protoc, it will automatically download all the .proto definitions from sentinel-hub and relative third parties.

examples

The official cosmjs examples can be used as well. Just remember to replace StargateClient with SentinelClient and SigningStargateClient with SigningSentinelClient.

The repository provide currently a nodejs script example and a keplr one (based on: https://tutorials.cosmos.network/tutorials/7-cosmjs/4-with-keplr.html).

The opt-in mainnet VPN smoke test discovers nodes dynamically and verifies session creation, handshake, configuration, connectivity, cleanup, and cancellation. It is not run in CI: it spends wallet funds and some protocols require root network privileges.

If you want to use a local version of sdk (for testing purpose) you have to compile the src folder into dist and then link the package with npm.

npm run build
npm link
cd examples/<choose-an-example>
npm link @sentinel-official/sentinel-js-sdk

run keplr example

cd examples/keplr
npm i
npm run dev

Navigate to: http://127.0.0.1:3000/.

run nodejs example

cd examples/node
npm i
ts-node main.ts