Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cordova-plugin-networkinterface

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cordova-plugin-networkinterface - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

2

package.json
{
"name": "cordova-plugin-networkinterface",
"version": "2.0.0",
"version": "2.1.0",
"description": "This plugin allows your application to retrieve the local wifi address and http proxy information.",

@@ -5,0 +5,0 @@ "cordova": {

@@ -1,3 +0,2 @@

Network Interface
=================
# Network Interface

@@ -8,3 +7,5 @@ Network interface information plugin for Cordova/PhoneGap that supports Android, Browser, iOS, and Windows 10.

cordova plugin add cordova-plugin-networkinterface
```sh
cordova plugin add cordova-plugin-networkinterface
```

@@ -15,3 +16,5 @@ ## PhoneGap Build

<plugin name="cordova-plugin-networkinterface" source="npm" />
```xml
<plugin name="cordova-plugin-networkinterface" source="npm" />
```

@@ -39,10 +42,21 @@ ## Ionic 2+ (w/ Typescript) Usage

Then use it as follows:
The Ionic wrapper functions return promises, so use them as follows:
```ts
```typescript
import { NetworkInterface } from '@ionic-native/network-interface';
constructor( private networkInterface: NetworkInterface ) {
this.networkInterface.getWiFiIPAddress( ip => alert( ip ) );
this.networkInterface.getCarrierIPAddress( ip => alert( ip ) );
this.networkInterface.getWiFiIPAddress()
.then(address => console.info(`IP: ${address.ip}, Subnet: ${address.subnet}`))
.catch(error => console.error(`Unable to get IP: ${error}`));
this.networkInterface.getCarrierIPAddress() {
.then(address => console.info(`IP: ${address.ip}, Subnet: ${address.subnet}`))
.catch(error => console.error(`Unable to get IP: ${error}`));
const url = 'www.github.com';
this.networkInterface.getHttpProxyInformation(url)
.then(proxy => console.info(`Type: ${proxy.type}, Host: ${proxy.host}, Port: ${proxy.port}`))
.catch(error => console.error(`Unable to get proxy info: ${error}`));
}

@@ -60,2 +74,3 @@ ```

### Using getWiFiIPAddress and getCarrierIPAddress
The onSuccess() callback has one argument object with the properties `ip` and `subnet` (changed in 2.x). The onError() callback is provided with a single value describing the error.

@@ -65,9 +80,9 @@

function onSuccess( ipInformation ) {
alert( "IP: " + ipInformation.ip + " subnet:" + ipInformation.subnet );
alert( "IP: " + ipInformation.ip + " subnet:" + ipInformation.subnet );
}
function onError( error ) {
// Note: onError() will be called when an IP address can't be found. eg WiFi is disabled, no SIM card, Airplane mode etc.
alert( error );
// Note: onError() will be called when an IP address can't be
// found, e.g. WiFi is disabled, no SIM card, Airplane mode
alert( error );
}

@@ -80,11 +95,13 @@

### Using getHttpProxyInformation
This function gets the relevant proxies for the passed URL in order of application. `onSuccess` we will get an array of objects, each having a `type`, `host` and `port` property. Where the url is not passed via a proxy, the `type` is "DIRECT" and both the host and port properties are set to "none"
```javascript
var url = "www.github.com"; //The url you want to find out the proxies for.
// The url you want to find out the proxies for.
const url = 'www.github.com';
function onSuccess( proxyInformation ) {
proxyInformation.forEach( function( proxy ) {
alert( "Type:" + proxy.type + " Host:" + proxy.host + " Port:" + proxt.port );
} );
proxyInformation.forEach( function( proxy ) {
alert( "Type:" + proxy.type + " Host:" + proxy.host + " Port:" + proxt.port );
});
}

@@ -98,3 +115,3 @@

networkinterface.getHttpProxyInformation( url, resolve, reject );
networkinterface.getHttpProxyInformation( url, onSuccess, onError );
```

@@ -101,0 +118,0 @@

@@ -12,3 +12,7 @@ var networkinterface = function() {

networkinterface.getHttpProxyInformation = function(url, success, fail ) {
networkinterface.getIPAddress = function( success, fail ) {
cordova.exec( success, networkinterface.getCarrierIPAddress.bind( null, success, fail ), "networkinterface", "getWiFiIPAddress", [] );
};
networkinterface.getHttpProxyInformation = function( url, success, fail ) {
cordova.exec( success, fail, "networkinterface", "getHttpProxyInformation", [url] );

@@ -15,0 +19,0 @@ };

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