New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cordova-plugin-wifiwizard2

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cordova-plugin-wifiwizard2 - npm Package Compare versions

Comparing version 3.1.0 to 3.1.1

2

package.json
{
"name": "cordova-plugin-wifiwizard2",
"version": "3.1.0",
"version": "3.1.1",
"cordova": {

@@ -5,0 +5,0 @@ "id": "wifiwizard2",

@@ -1,3 +0,30 @@

# WifiWizard2 - 3.1.0
# WiFiWizard2 - 3.1.1<!-- omit in toc -->
Table of Contents<!-- omit in toc -->
---
- [About](#about)
- [Basics](#basics)
- [Async Handling](#async-handling)
- [Demo Meteor Project](#demo-meteor-project)
- [Android and IOS Permissions and Notes](#android-and-ios-permissions-and-notes)
- [IOS Notes](#ios-notes)
- [Ionic/Angular Notes](#ionicangular-notes)
- [Global Functions](#global-functions)
- [iOS Functions](#ios-functions)
- [Android Functions](#android-functions)
- [Connect vs Enable](#connect-vs-enable)
- [Disconnect vs Disable](#disconnect-vs-disable)
- [New to 3.1.1+](#new-to-311)
- [New to 3.0.0+](#new-to-300)
- [Installation](#installation)
- [Master](#master)
- [Releases](#releases)
- [Meteor](#meteor)
- [Errors/Rejections](#errorsrejections)
- [Generic **Thrown Errors**](#generic-thrown-errors)
- [Examples](#examples)
- [Ionic/Angular Example (User Provided)](#ionicangular-example-user-provided)
- [Changelog:](#changelog)
# About
WifiWizard2 enables Wifi management for both Android and iOS applications within Cordova/Phonegap projects.

@@ -19,3 +46,3 @@

## Basics
# Basics

@@ -46,3 +73,3 @@ This plugin creates the object `WifiWizard2` and is accessible after `deviceready` has been fired, see [Cordova deviceready Event Docs](https://cordova.apache.org/docs/en/latest/cordova/events/events.html#deviceready)

## Android Permissions and Notes
## Android and IOS Permissions and Notes
In order to obtain scan results (to call `scan` or `startScan` then `getScanResults`) your application must have the `ACCESS_FINE_LOCATION` Android Permission. You can do this by calling the `requestPermission` method detailed below, or

@@ -53,2 +80,9 @@ this plugin will automagically do this for you when you call `scan` or `startScan` functions.

## IOS Notes
iOS 12 and later, enable the Access WiFi Information capability for your app in Xcode. When you enable this capability, Xcode automatically adds the Access WiFi Information entitlement to your entitlements file and App ID.
## Ionic/Angular Notes
This plugin does not have @ionic/native typings (yet), in order to use it add this to just below your import list on your service:
`declare var WifiWizard2: any;`
# Global Functions

@@ -66,4 +100,28 @@ These are functions that can be used by both Android and iOS applications

##### Thrown Errors
```javascript
WifiWizard2.timeout(delay)
```
- `delay` should be time in milliseconds to delay
- Helper async timeout delay, `delay` is optional, default is 2000ms = 2 seconds
- This method always returns a resolved promise after the delay, it will never reject or throw an error
**Example inside async function**
```javascript
async function example(){
await WifiWizard2.timeout(4000);
// do something after 4 seconds
}
```
**Example inside standard non-async function**
```javascript
function example(){
WifiWizard2.timeout(4000).then( function(){
// do something after waiting 4 seconds
}):
}
```
**Thrown Errors**
- `TIMEOUT_WAITING_FOR_SCAN` on timeout waiting for scan 10 seconds +

@@ -89,3 +147,3 @@ - `SCAN_FAILED` if unable to start scan

### Connect vs Enable
## Connect vs Enable
When writing Android Java code, there is no `connect` methods, you basically either `enable` or `disable` a network. In the original versions of WifiWizard the `connect` method would basically just call `enable` in Android.

@@ -110,3 +168,5 @@ I have changed the way this works in WifiWizard2 version 3.0.0+, converting it to a helper method to eliminate having to call `formatWifiConfig` then `add` and then `enable` ... the `connect` method will now automatically call `formatWifiConfig`, then call `add` to either add or update the network configuration, and then call `enable`.

##### Thrown Errors
**Thrown Errors**
- `CONNECT_FAILED_TIMEOUT` unable to verify connection, timed out after 60 seconds

@@ -118,3 +178,3 @@ - `INVALID_NETWORK_ID_TO_CONNECT` Unable to connect based on generated wifi config

### Disconnect vs Disable
## Disconnect vs Disable
Same as above for Connect vs Enable, except in this situation, `disconnect` will first disable the network, and then attempt to remove it (if SSID is passed)

@@ -130,3 +190,4 @@

##### Thrown Errors
**Thrown Errors**
- `DISCONNECT_NET_REMOVE_ERROR` Android returned error when removing wifi configuration

@@ -154,3 +215,4 @@ - `DISCONNECT_NET_DISABLE_ERROR` Unable to connect based on generated wifi config

##### Thrown Errors
**Thrown Errors**
- `AUTH_TYPE_NOT_SUPPORTED` - Invalid auth type specified

@@ -166,3 +228,4 @@ - `ERROR_ADDING_NETWORK` - Android returned `-1` specifying error adding network

##### Thrown Errors
**Thrown Errors**
- `UNABLE_TO_REMOVE` Android returned failure in removing network

@@ -186,3 +249,4 @@ - `REMOVE_NETWORK_NOT_FOUND` Unable to determine network ID from passed SSID

##### Thrown Errors
**Thrown Errors**
- `STARTSCAN_FAILED` Android returned failure in starting scan

@@ -229,3 +293,4 @@

##### Thrown Errors
**Thrown Errors**
- `ERROR_SETWIFIENABLED` wifi state does not match call (enable or disable)

@@ -238,5 +303,36 @@

##### Thrown Errors
**Thrown Errors**
- `GET_CONNECTED_NET_ID_ERROR` Unable to determine currently connected network ID (may not be connected)
## New to 3.1.1+
```javascript
WifiWizard2.resetBindAll()
```
- Disable bindAll to WiFi network without disconnecting from WiFi
```javascript
WifiWizard2.setBindAll()
```
- Enable bindAll to WiFi network without disconnecting from WiFi
```javascript
WifiWizard2.canConnectToInternet()
```
- Returns boolean, true or false, if device is able to connect to https://www.google.com via HTTP connection (since ping is unreliable)
- Unknown errors will still be thrown like all other async functions
- If you called `connect` or `enable` and passed `true` for `bindAll`, your application will force the ping through wifi connection.
- If you did not pass `true` (or passed `false`) for `bindAll`, and the wifi does not have internet connection, Android Lollipop+ (API 21+) will use cell connection to ping (due to Android using cell connection when wifi does not have internet) [More Details](https://android-developers.googleblog.com/2016/07/connecting-your-app-to-wi-fi-device.html)
```javascript
WifiWizard2.canConnectToRouter()
```
- As `canPingWifiRouter` is notoriously unreliable, this method uses HTTP connection to test if able to connect to router (as most routers should have web server running on port 80)
- Unknown errors will still be thrown like all other async functions
- This is useful for testing to make sure that your Android app is able to connect to the private network after connecting to WiFi
- This was added for testing the `bindAll` feature to support issues with Android Lollipop+ (API 21+) not routing calls through WiFi if WiFi does not have internet connection [See Android Blog](https://android-developers.googleblog.com/2016/07/connecting-your-app-to-wi-fi-device.html)
- Attempts to connect router IP HTTP server on port 80 (example: `http://192.168.0.1/` where `192.168.0.1` is the automatically detected IP address)
## New to 3.0.0+

@@ -247,3 +343,3 @@ ```javascript

- Returns boolean, true or false, if device is able to ping `8.8.8.8`
- Returns boolean, true or false, if device is able to ping 8.8.8.8
- Unknown errors will still be thrown like all other async functions

@@ -258,2 +354,3 @@ - If you called `connect` or `enable` and passed `true` for `bindAll`, your application will force the ping through wifi connection.

- Returns boolean, true or false, if device is able to ping the connected WiFi router IP (obtained from DHCP info)
- Version 3.1.1+ uses HTTP connection to test if able to connect to router (as ping previous did not work)
- Unknown errors will still be thrown like all other async functions

@@ -281,3 +378,4 @@ - This is useful for testing to make sure that your Android app is able to connect to the private network after connecting to WiFi

##### Thrown Errors
**Thrown Errors**
- `NO_VALID_IP_IDENTIFIED` if unable to determine a valid IP (ip returned from device is `0.0.0.0`)

@@ -289,3 +387,4 @@

- Returns a JSON object with IPv4 address and subnet `{"ip": "192.168.1.2", "subnet": "255.255.255.0" }` or rejected promise if not found or not connected
##### Thrown Errors
**Thrown Errors**
- `NO_VALID_IP_IDENTIFIED` if unable to determine a valid IP (ip returned from device is `0.0.0.0`)

@@ -298,3 +397,4 @@

##### Thrown Errors
**Thrown Errors**
- `ERROR_RECONNECT` Android returned error when reconnecting

@@ -307,3 +407,4 @@

##### Thrown Errors
**Thrown Errors**
- `ERROR_REASSOCIATE` Android returned error when reassociating

@@ -324,3 +425,4 @@

##### Thrown Errors
**Thrown Errors**
- `UNABLE_TO_DISABLE` Android returned failure in disabling network

@@ -337,3 +439,4 @@ - `DISABLE_NETWORK_NOT_FOUND` Unable to determine network ID from passed SSID to disable

##### Thrown Errors
**Thrown Errors**
- `PERMISSION_DENIED` user denied permission on device

@@ -358,59 +461,51 @@

###### Thrown Errors
**Thrown Errors**
`UNABLE_TO_ENABLE` - Android returned `-1` signifying failure enabling
```javascript
WifiWizard2.timeout(delay)
```
- `delay` should be time in milliseconds to delay
- Helper async timeout delay, `delay` is optional, default is 2000ms = 2 seconds
- This method always returns a resolved promise after the delay, it will never reject or throw an error
# Installation
###### Example inside async function:
```javascript
await WifiWizard2.timeout(4000);
// do something after 4 seconds
```
## Master
###### Example inside standard non-async function:
```javascript
WifiWizard2.timeout(4000).then( function(){
// do something after waiting 4 seconds
}):
```
Run ```cordova plugin add https://github.com/tripflex/wifiwizard2```
### Installation
To install from the master branch (latest on GitHub)
##### Master
To install a specific branch (add `#tag` replacing `tag` with tag from this repo, example:
```cordova plugin add https://github.com/tripflex/wifiwizard2#v3.1.1```
Run ```cordova plugin add https://github.com/tripflex/wifiwizard2```
Find available tags here:
https://github.com/tripflex/WifiWizard2/tags
To install from the master branch (latest on GitHub):
If you are wanting to have the latest and greatest stable version, then run the 'Releases' command below.
##### Releases
Run ```cordova plugin add wifiwizard2```
## Releases
Run ```cordova plugin add cordova-plugin-wifiwizard2```
##### Meteor
## Meteor
To install and use this plugin in a Meteor project, you have to specify the exact version from NPM repository:
[https://www.npmjs.com/package/wifiwizard2](https://www.npmjs.com/package/wifiwizard2)
[https://www.npmjs.com/package/cordova-plugin-wifiwizard2](https://www.npmjs.com/package/cordova-plugin-wifiwizard2)
As of 8/28/2018, the latest version is 3.1.0:
As of April 4th 2019, the latest version is 3.1.1:
```meteor add cordova:wifiwizard2@3.1.0```
```meteor add cordova:cordova-plugin-wifiwizard2@3.1.1```
### Errors/Rejections
# Errors/Rejections
Methods now return formatted string errors as detailed below, instead of returning generic error messages. This allows you to check yourself what specific error was returned, and customize the error message.
In an upcoming release I may add easy ways to override generic messages, or set your own, but for now, errors returned can be found below each method/function.
#### Generic Thrown Errors
## Generic **Thrown Errors**
`WIFI_NOT_ENABLED`
### Examples
# Examples
Please see demo Meteor project for code examples:
[https://github.com/tripflex/WifiWizard2Demo](https://github.com/tripflex/WifiWizard2Demo)
## Ionic/Angular Example (User Provided)
Props @13546777510 (Angelo Fan) has provided a basic Ionic/Angluar demo app:
[https://github.com/13546777510/WifiWizard2-Demo](https://github.com/13546777510/WifiWizard2-Demo)
See issue [#69](https://github.com/tripflex/WifiWizard2/issues/69) regarding this
I recommend using [ES6 arrow functions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions) to maintain `this` reference. This is especially useful if you're using Blaze and Meteor.

@@ -428,9 +523,15 @@

License
----
#License
Apache 2.0
## Changelog:
# Changelog:
**3.1.1** - April 4, 2019
- Fixed/Added location services check for Android 9+ for any method that utilises the getConnectionInfo method. Issue #71 (@arsenal942)
- Move verifyWifiEnabled() to after methods that do not require wifi to be enabled. Issue #54 (@props seanyang1984)
- Added `canConnectToRouter()` and `canConnectToInternet()` to use HTTP to test connection (since ping is notoriously unreliable)
- Added `canConnectToRouter()`, `canConnectToInternet()`, `canPingWifiRouter()`, `isConnectedToInternet()` to iOS fn return not supported
- Added `resetBindAll()` and `setBindAll()` for Android (props @saoron PR #74)
- Use `JSONObject.NULL` instead of just `null` when scan results Android older than Marshmallow (props @seanyang1984) Issue #51
#### 3.1.0 - August 28, 2018
**3.1.0** - August 28, 2018
- Fixed/Added compatibility with iOS to connect to open network

@@ -448,3 +549,3 @@ - Fixed Uncaught SyntaxError in JavaScript from using let (changed to var)

#### 3.0.0 - April 12, 2018
**3.0.0** - April 12, 2018
- Completely refactored JS methods, all now return Promises

@@ -466,3 +567,3 @@ - Added `getWifiIP` and `getWifiIPInfo` functions

#### 2.1.1 - *1/9/2018*
**2.1.1** - *1/9/2018*
- **Added Async Promise based methods**

@@ -472,3 +573,3 @@ - Fix issue with thread running before wifi is fully enabled

#### 2.1.0 - *1/8/2018*
**2.1.0** - *1/8/2018*
- **Added Async Promise based methods**

@@ -484,3 +585,3 @@ - Fixed incorrect Android Cordova exec methods incorrectly being called and returned (fixes INVALID ACTION errors/warnings)

#### 2.0.0 - *1/5/2018*
**2.0.0** - *1/5/2018*
- Added automatic disable of currently connected network on connect call (to prevent reconnect to previous wifi ssid)

@@ -505,60 +606,60 @@ - Added initial `disconnect()` before and `reconnect()` after disable/enable network on connect call

#### v0.2.9
**v0.2.9**
`isWifiEnabled` bug fixed. `level` in `getScanResults` object now refers to raw RSSI value. The function now accepts an options object, and by specifiying `{ numLevels: value }` you can get the old behavior.
#### v0.2.8
**v0.2.8**
`getScanResults` now returns the BSSID along with the SSID and strength of the network.
#### v0.2.7
**v0.2.7**
- Clobber WifiWizard.js automatically via Cordova plugin architecture
#### v0.2.6
**v0.2.6**
- Added `isWifiEnabled`, `setWifiEnabled`
#### v0.2.5
**v0.2.5**
- Fixes `getConnectedSSID` error handlers
#### v0.2.4
**v0.2.4**
- Added `getConnectedSSID` method
#### v0.2.3
**v0.2.3**
- Added `disconnect` that does disconnection on current WiFi
#### v0.2.2
**v0.2.2**
- Added `startScan` and `getScanResults`
#### v0.2.1
**v0.2.1**
- Fixed reference problem in `formatWPAConfig`
#### v0.2.0
**v0.2.0**
- Changed format of wifiConfiguration object to allow more extensibility.
#### v0.1.1
**v0.1.1**
- `addNetwork` will now update the network if the SSID already exists.
#### v0.1.0
**v0.1.0**
- All functions now work!
#### v0.0.3
**v0.0.3**
- Fixed errors in native implementation. Currently, Add and Remove networks aren't working, but others are working as expected.
#### v0.0.2
**v0.0.2**
- Changed plugin.xml and WifiWizard.js to attach WifiWizard directly to the HTML.
#### v0.0.1
**v0.0.1**
- Initial commit

@@ -346,2 +346,22 @@ /*

/**
* Unbind Network
* @returns {Promise<any>}
*/
resetBindAll: function () {
return new Promise( function( resolve, reject ){
cordova.exec(resolve, reject, "WifiWizard2", "resetBindAll", []);
});
},
/**
* Bind Network
* @returns {Promise<any>}
*/
setBindAll: function () {
return new Promise( function( resolve, reject ){
cordova.exec(resolve, reject, "WifiWizard2", "setBindAll", []);
});
},
/**
* Get Wifi Router IP from DHCP

@@ -467,2 +487,50 @@ * @returns {Promise<any>}

/**
* Check if we can connect via HTTP current WiFi router IP address
* @returns {Promise<any>}
*/
canConnectToRouter: function () {
return new Promise(function (resolve, reject) {
cordova.exec(
// Cordova can only return strings to JS, and the underlying plugin
// sends a "1" for true and "0" for false.
function (result) {
if (result == "1") {
resolve("CAN_CONNECT_TO_ROUTER");
} else {
reject("UNABLE_TO_CONNECT_TO_ROUTER");
}
},
reject, "WifiWizard2", "canConnectToRouter", []
);
});
},
/**
* Check if current WiFi connection can connect to internet (checks connection to google.com)
* @returns {Promise<any>}
*/
canConnectToInternet: function () {
return new Promise(function (resolve, reject) {
cordova.exec(
// Cordova can only return strings to JS, and the underlying plugin
// sends a "1" for true and "0" for false.
function (result) {
if (result == "1") {
resolve("IS_CONNECTED_TO_INTERNET");
} else {
reject("NOT_CONNECTED_TO_INTERNET");
}
},
reject, "WifiWizard2", "canConnectToInternet", []
);
});
},
/**
* Request ACCESS_FINE_LOCATION permission

@@ -469,0 +537,0 @@ *

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc