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

@bs-solutions/bastion-network-plugin

v1.0.2

Published

Raw TCP/UDP socket plugin for Capacitor 6 and higher (LAN device discovery and connection)

Readme

bastion-network-plugin

Raw TCP/UDP socket plugin for Capacitor 6 and higher. Даёт прямой доступ к сырым сокетам из JS: UDP-broadcast для обнаружения устройств в локальной сети и TCP для подключения к ним и обмена произвольными данными. Порты и формат данных полностью на стороне приложения — плагин ничего не знает о конкретном протоколе.

Веб-платформа не поддерживается (сырые сокеты в браузере недоступны).

Install

npm i @bs-solutions/bastion-network-plugin
npx cap sync

Android

Плагин объявляет INTERNET, ACCESS_WIFI_STATE, CHANGE_WIFI_MULTICAST_STATE в собственном манифесте — дополнительно ничего добавлять не нужно.

iOS

Начиная с iOS 14 приложению нужно самому объявить local network permission в своём Info.plist — плагин это сделать не может:

<key>NSLocalNetworkUsageDescription</key>
<string>Нужен доступ к локальной сети для поиска устройств</string>

Конфигурация

TCP (connectTCP/sendTCP/disconnectTCP) работает всегда без какой-либо настройки. Для UDP (sendBroadcastUDP/receiveUDP) порты обязательно нужно задать конфигом плагина в capacitor.config.json — дефолтов нет намеренно, без конфига UDP-методы отклоняются с понятной ошибкой:

{
  "plugins": {
    "BastionNetworkPlugin": {
      "portListTransmit": [23629, 47701],
      "portListReceive": [23569, 21913]
    }
  }
}
  • portListTransmit — порты, на которые уходит sendBroadcastUDP (на все локальные подсети). Без этого ключа sendBroadcastUDP вернёт reject.
  • portListReceive — порты, которые слушаются на входящие UDP-пакеты (receiveUDP). Без этого ключа слушатели просто не поднимаются (без ошибки — приложению, которому не нужен UDP, ничего делать не надо).

API

Все бинарные данные (UDP-датаграммы, TCP-пакеты) передаются как base64-строки.

import { BastionNetworkPlugin } from '@bs-solutions/bastion-network-plugin';

await BastionNetworkPlugin.addListener('receiveUDP', ({ ip, port, data }) => {
  // data — base64
});
await BastionNetworkPlugin.addListener('receiveTCP', ({ linkId, data }) => {});
await BastionNetworkPlugin.addListener('disconnectTCP', ({ linkId }) => {});

await BastionNetworkPlugin.sendBroadcastUDP({ data: base64Data });

const { linkId } = await BastionNetworkPlugin.connectTCP({
  ip: '192.168.1.50',
  port: 1234,
  data: base64AuthToken,
});

await BastionNetworkPlugin.sendTCP({ linkId, data: base64Data });
await BastionNetworkPlugin.disconnectTCP({ linkId });

Методы

| Метод | Описание | | ------------------ | --------------------------------------------------------------------- | | sendBroadcastUDP | Разослать UDP broadcast на все локальные подсети (порты из portListTransmit) | | connectTCP | Открыть TCP-соединение, первым пакетом отправить данные авторизации | | sendTCP | Отправить данные в открытое TCP-соединение | | disconnectTCP | Закрыть TCP-соединение |

События

| Событие | Когда срабатывает | | ---------------- | ------------------------------------------------------ | | receiveUDP | Пришёл UDP-пакет на один из портов portListReceive | | receiveTCP | Пришли данные по открытому TCP-соединению | | disconnectTCP | TCP-соединение закрыто (в т.ч. по инициативе устройства) |

Maintainer

sudondie

Contributing

Please contribute! Look at the issues.

License

MIT © 2026