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

esp-idf-provisioning-web

v0.0.7

Published

ESP-IDF WiFi Provisioning SDK for web browsers

Readme

ESP-IDF Provisioning Web SDK

A TypeScript SDK for provisioning ESP32 devices from web browsers using the ESP-IDF provisioning protocol. Supports both BLE (Web Bluetooth) and SoftAP (HTTP) transport modes.

Features

  • [x] Security 0 and Security 1
    • [x] Security1: X25519 + PoP + AES-256-CTR
    • [ ] Security2 (not implemented)
  • [x] BLE Transport: Uses Web Bluetooth API for wireless provisioning
  • [x] SoftAP Transport: HTTP-based provisioning for devices in AP mode
  • [x] Provisioning Protocol: Supports ESP-IDF provisioning protocol for WiFi credentials
    • [x] Scan APs
    • [x] Provision device status monitoring
    • [ ] Reset and re-provisioning
    • [x] Custom endpoints

Browser Compatibility

  • BLE Mode: Requires browsers with Web Bluetooth API support (Chrome, Edge, Opera)
  • SoftAP Mode: Works in all modern browsers (user must manually connect to WiFi)

Installation

npm install esp-idf-provisioning-web

Usage

BLE with Security 0

Security 0 sends provisioning data without application-layer encryption. Use it only when the device is configured for Security 0.

import { ESPProvisionManager } from 'esp-idf-provisioning-web';

const device = await ESPProvisionManager.searchBLEDevice();
await device.connect();
const networks = await device.scanWifiList();
await device.provision('MyWiFiSSID', 'MyWiFiPassword');
// Poll fetchWifiStatus() until connected or failed, then disconnect.

Runnable example: BLE Security 0.

BLE with Security 1

Security 1 uses X25519, proof of possession (PoP), and AES-256-CTR. Supply the PoP expected by the device:

import { ESPProvisionManager } from 'esp-idf-provisioning-web';

const device = await ESPProvisionManager.searchBLEDevice();
await device.connect({
  type: 'Security1',
  proofOfPossession: 'device-proof-of-possession',
});
const networks = await device.scanWifiList();
await device.provision('MyWiFiSSID', 'MyWiFiPassword');
// Poll fetchWifiStatus() until connected or failed, then disconnect.

Runnable example: BLE Security 1.

Resolve Security 1 credentials asynchronously

connect() reads the public proto-ver endpoint before starting the handshake. Pass a resolver to obtain credentials using the returned protocol and application metadata. requestProofOfPossession below is supplied by the consuming application:

await device.connect(async (info) => {
  if (info.prov.sec_ver !== 1) throw new Error('Expected Security 1');
  const proofOfPossession = await requestProofOfPossession(info);
  return { type: 'Security1', proofOfPossession };
});

The SDK passes through custom metadata without interpreting it. Credential retrieval and authorization belong to the consuming application.

A new connect() call reads fresh metadata and runs the resolver again. Failed authentication, resolver failure, or transport failure clears the session; retry with connect(). There is no automatic downgrade to Security 0. Security 2 is unsupported.

Custom endpoints and connection status

After connecting with either security mode, use the same APIs for application endpoints and Wi-Fi status. Custom endpoints use the established security mode:

const response = await device.sendData(
  'custom-data', new TextEncoder().encode('{"command":"get"}')
);

Requests are serialized because Security 1 shares one continuous AES-CTR stream across both directions. sendData('proto-ver', ...) remains plaintext; prov-session is managed internally. Other endpoints require a completed handshake.

import { ESPWifiStaState } from 'esp-idf-provisioning-web';

let status;
do {
  status = await device.fetchWifiStatus();
  if (status.staState === ESPWifiStaState.connecting) {
    await new Promise((resolve) => setTimeout(resolve, 2000));
  }
} while (status.staState === ESPWifiStaState.connecting);

device.disconnect();

Security 1 requires a secure browser context and native Web Crypto X25519 support. Unsupported browsers fail the handshake instead of falling back to plaintext. See the Web Crypto specification and ESP-IDF protocol documentation.

SoftAP Provisioning

Important: The browser cannot automatically connect to WiFi networks. Users must manually connect to the ESP device's access point before running this code.

import { ESPProvisionManager } from 'esp-idf-provisioning-web';

// Create device instance for SoftAP
// User should already be connected to the device's WiFi network
const device = ESPProvisionManager.createSoftAPDevice(new URL('http://192.168.4.1'));

// Connect and provision
await device.connect();
await device.provision('MyWiFiSSID', 'MyWiFiPassword');

Check Bluetooth Support

// Check if Web Bluetooth is available
if (ESPProvisionManager.isBluetoothSupported()) {
  const isAvailable = await ESPProvisionManager.getBluetoothAvailability();
  console.log('Bluetooth available:', isAvailable);
}

Browser Limitations

BLE Mode

  • Requires user interaction (button click) to initiate device scanning
  • User must manually select device from browser's device picker
  • HTTPS or localhost required for Web Bluetooth API
  • The provisioning service UUID must be included in filters[].services or optionalServices

SoftAP Mode

  • Browser cannot connect to WiFi networks programmatically
  • User must manually connect to ESP device's access point
  • CORS may need to be configured on the ESP device
  • May not work on all networks due to browser security restrictions

FAQ

Which BLE service UUID should I use?

FALLBACK_SERVICE_UUID comes from ESP-IDF's default provisioning service, not a Bluetooth SIG standard. If your firmware calls wifi_prov_scheme_ble_set_service_uuid(), pass the same UUID in filters[].services or optionalServices to searchBLEDevice().

The SDK tries the default service first. If it is absent or unauthorized, it searches authorized services for prov-session and proto-ver. Endpoint names are read from the 0x2901 descriptors; no fixed endpoint UUID mapping is used.

Development

Use Node.js 24 LTS to build and lint the SDK. npm pack and npm publish rebuild the generated protocol code, bundles and type declarations before packaging.

# Install dependencies
npm install

# Build
npm run build

# Lint
npm run lint

# Build and run provisioning transport tests with simulated GATT services
npm test

# Format
npm run format

License

MIT

References