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

@svene/juanfi-hotspot

v0.1.1

Published

[![npm version](https://img.shields.io/npm/v/@svene/juanfi-hotspot.svg)](https://www.npmjs.com/package/@svene/juanfi-hotspot) [![npm downloads](https://img.shields.io/npm/dm/@svene/juanfi-hotspot.svg)](https://www.npmjs.com/package/@svene/juanfi-hotspot)

Readme

@svene/juanfi-hotspot

npm version npm downloads

Browser-side helpers for custom JuanFI hotspot pages.

Use this inside hotspot pages when handling voucher login, coin insertion, e-load, selected vendo logic, timers, labels, or local storage.

install

npm install @svene/juanfi-hotspot

voucher login

import { loginWithVoucher } from '@svene/juanfi-hotspot';

const form = document.querySelector<HTMLFormElement>('#sendin');

if (!form) {
  throw new Error('Missing login form');
}

loginWithVoucher({
  form,
  voucher: 'ABC123',
  loginOption: 1,
  chapId: window.chapId,
  chapChallenge: window.chapChallenge,
});

MAC-as-voucher fallback:

loginWithVoucher({
  form,
  voucher: '',
  mac: 'AA:BB:CC:DD:EE:FF',
  macAsVoucherCode: true,
  loginOption: 1,
});

member login

import { loginWithMember } from '@svene/juanfi-hotspot';

const sendinForm = document.querySelector<HTMLFormElement>('#sendin');
const loginForm = document.querySelector<HTMLFormElement>('#login');

if (!sendinForm || !loginForm) {
  throw new Error('Missing login forms');
}

loginWithMember({
  sendinForm,
  loginForm,
  chapId: window.chapId,
  chapChallenge: window.chapChallenge,
});

coin flow

createCoinFlow starts top-up, polls coin status, saves voucher state, and calls UI hooks.

import { createCoinFlow } from '@svene/juanfi-hotspot';
import { createJuanFiApi } from '@svene/juanfi-api';

const api = createJuanFiApi({
  vendoIp: '10.1.0.41',
});

const flow = createCoinFlow({
  api,
  mac: 'AA:BB:CC:DD:EE:FF',
  ipAddress: '10.0.0.23',
  pollMs: 1000,

  onStarted(update) {
    console.log('voucher', update.voucher);
  },

  onWaitingForCoin(update) {
    console.log('remaining', update.remainTime);
  },

  onCoinAdded(update) {
    console.log('coins', update.totalCoin);
  },

  onVoucherReady(update) {
    console.log('ready', update.voucher);
  },

  onFailed(error) {
    console.log(error.code, error.error);
  },

  onDone(update) {
    console.log('done', update.voucher);
  },
});

await flow.start();

Stop polling:

flow.stop();

Cancel if no coins were inserted:

await flow.cancel();

Save voucher:

await flow.save();

e-load flow

createLoadFlow manages product loading, mobile number entry, product selection, coin polling, and load completion.

import { createLoadFlow } from '@svene/juanfi-hotspot';
import { createJuanFiApi } from '@svene/juanfi-api';

const api = createJuanFiApi({
  vendoIp: '10.1.0.41',
});

const flow = createLoadFlow({
  api,
  mac: 'AA:BB:CC:DD:EE:FF',
  pollMs: 1000,

  onStep(state) {
    console.log('step', state.step);
  },

  onProducts(products) {
    console.log(products);
  },

  onCoinAdded(update) {
    console.log(update.totalCoin);
  },

  onVoucherReady(update) {
    console.log('leftover voucher', update.voucher);
  },

  onFailed(error) {
    console.log(error.code, error.error);
  },

  onDone(update) {
    console.log('load done', update.voucher);
  },
});

await flow.start();

flow.setMobile('09171234567');
await flow.next();

flow.selectGroup('GLOBE');
flow.selectProduct('GLOBE50');
await flow.next();

await flow.next();

Read state:

const state = flow.getState();

console.log(state.step);
console.log(state.mobile);
console.log(state.selectedProduct);

selected vendo

import { selectVendo } from '@svene/juanfi-hotspot';

const selected = selectVendo({
  isMultiVendo: true,
  multiVendoOption: 0,
  selectedVendoIp: '10.1.0.41',
  defaultVendoIp: '10.1.0.41',
  multiVendoAddresses: [
    {
      vendoName: 'Main',
      vendoIp: '10.1.0.41',
      chargingEnable: true,
      eloadEnable: true,
    },
  ],
});

console.log(selected.vendoIp);
console.log(selected.showSelector);

multiVendoOption:

  • 0: use selected IP and show selector
  • 1: match hotspot address
  • 2: match interface name

storage

Storage shape:

type StoragePort = {
  readonly saveValue: (key: string, value: string) => void;
  readonly readValue: (key: string) => string | null;
  readonly removeValue: (key: string) => void;
};

Custom storage:

const memoryStorage = new Map<string, string>();

const storage = {
  saveValue(key: string, value: string) {
    memoryStorage.set(key, value);
  },
  readValue(key: string) {
    return memoryStorage.get(key) ?? null;
  },
  removeValue(key: string) {
    memoryStorage.delete(key);
  },
};

Use it:

const flow = createCoinFlow({
  api,
  mac: 'AA:BB:CC:DD:EE:FF',
  storage,
});

CDN

<script src="https://cdn.jsdelivr.net/npm/@svene/[email protected]/dist/juanfi-hotspot.min.js"></script>

Browser global:

JuanFiHotspot.loginWithVoucher({
  form: document.querySelector('#sendin'),
  voucher: 'ABC123',
  loginOption: 1,
});

Download:

curl -L -o juanfi-hotspot.js https://cdn.jsdelivr.net/npm/@svene/[email protected]/dist/juanfi-hotspot.min.js

Do not use latest in production. Always pin the version.

scripts

npm run test -w @svene/juanfi-hotspot
npm run build -w @svene/juanfi-hotspot