wpa-editor

Scan and edit wpa supplicant config file from NodeJS

Usage no npm install needed!

<script type="module">
  import wpaEditor from 'https://cdn.skypack.dev/wpa-editor';
</script>

README

wpa-editor

  • Install

  • Description

  • How to use

  • Options

Install

npm install wpa-editor -save 

Description

Scan and edit wpa supplicant config file from NodeJS.

How to use

const wpa = require("wpa-editor");
var wifi = new wpa();
//scan and return all ssid visible in array
wifi.scan(function(err, res){
    console.log(res);
})
//edit wpa-supplicant config file (/etc/wpa_supplicant/wpa_supplicant.conf)
//param: SSID[string], password[string]
wifi.editWPA("test","test1234", function(err){
    console.log(err);
});

Options

var wifi = new wpa({
    {
        interfaces : "wlan0", //Default wifi interface
        configFilePathname : "/etc/wpa_supplicant/wpa_supplicant.conf", //wpa-supplicant config file location
        regex : /^\nnetwork=(.|\n|\r){1,}\}$/gm //parse network in file location
    }
});