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 🙏

© 2025 – Pkg Stats / Ryan Hefner

ckb-light-client-js

v1.0.3

Published

Web version of CKB LightClient, provide full APIs of CKB LightClient in browser.

Readme

ckb-light-client-js

Web version of CKB LightClient, provide full APIs of CKB LightClient in browser.

Usage

Install this package

npm install ckb-light-client-js

A piece of code

import { LightClient, randomSecretKey } from "light-client-js";

const client = new LightClient();

const config = `
chain = "dev"

[store]
path = "data/store"

[network]
path = "data/network"

listen_addresses = ["/ip4/0.0.0.0/tcp/8110"]
### Specify the public and routable network addresses
# public_addresses = []

# Node connects to nodes listed here to discovery other peers when there's no local stored peers.
# When chain.spec is changed, this usually should also be changed to the bootnodes in the new chain.
bootnodes = [
    "/ip4/18.167.71.41/tcp/8115/ws/p2p/QmZ3g4ikFdUijFyQdDsuxnvMwgC4uMU4Ux8siwPGPxLnRC",
    # "/ip4/18.167.71.41/tcp/8115/wss/p2p/QmZ3g4ikFdUijFyQdDsuxnvMwgC4uMU4Ux8siwPGPxLnRC"
]


max_peers = 125
max_outbound_peers = 2
# 2 minutes
ping_interval_secs = 120
# 20 minutes
ping_timeout_secs = 1200
connect_outbound_interval_secs = 15
# If set to true, try to register upnp
upnp = false
# If set to true, network service will add discovered local address to peer store, it's helpful for private net development
discovery_local_address = false
# If set to true, random cleanup when there are too many inbound nodes
# Ensure that itself can continue to serve as a bootnode node
bootnode_mode = false

`

await client.start({ type: "TestNet", config }, randomSecretKey(), "info");
console.log(await client.getTipHeader())

A more complex example

https://github.com/Officeyutong/ckb-light-client-wasm-demo

Restrictions

  • ckb-light-client-js only supports WebSocket over TLS peers on HTTPS sites. On HTTP sites, insecure WebSocket may be used.

  • Due to the restrictions of browsers, you must set some headers properly. See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer#security_requirements for details. There are some configuration examples:

nginx

    server {
        listen 5600;
        server_name localhost;
        root /root/ckb-light-client;
        location / {
            index index.html;
            add_header Cross-Origin-Embedder-Policy "require-corp" always;
            add_header Cross-Origin-Opener-Policy "same-origin" always;
        }
    }

Webpack dev server

const path = require('path');

module.exports = {
  //...
  devServer: {
    headers: {
      "Cross-Origin-Embedder-Policy": "require-corp",
      "Cross-Origin-Opener-Policy": "same-origin"
    }
  },
};

Vercel

{
    "headers": [
        {
            "source": "/(.*)",
            "headers": [
                {
                    "key": "Cross-Origin-Embedder-Policy",
                    "value": "require-corp"
                },
                {
                    "key": "Cross-Origin-Opener-Policy",
                    "value": "same-origin"
                }
            ]
        }
    ]
}