Socket
Socket
Sign inDemoInstall

is-online

Package Overview
Dependencies
38
Maintainers
2
Versions
34
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 8.2.1 to 8.2.2

47

index.js

@@ -7,4 +7,5 @@ 'use strict';

const appleCheck = async options => {
const {body} = await got('http://captive.apple.com/hotspot-detect.html', {
const appleCheck = options => {
const gotPromise = got('http://captive.apple.com/hotspot-detect.html', {
timeout: options.timeout,
family: options.version === 'v4' ? 4 : 6,

@@ -16,3 +17,18 @@ headers: {

return /Success/.test(body || '') || Promise.reject();
const promise = (async () => {
try {
const {body} = await gotPromise;
if (body && body.includes('Success')) {
throw new Error('Apple check failed');
}
} catch (error) {
if (!(error instanceof got.CancelError)) {
throw error;
}
}
})();
promise.cancel = gotPromise.cancel;
return promise;
};

@@ -27,15 +43,32 @@

const queries = [];
const promise = pAny([
(async () => {
await publicIp[options.version]();
const query = publicIp[options.version](options);
queries.push(query);
await query;
return true;
})(),
(async () => {
await publicIp[options.version]({https: true});
const query = publicIp[options.version]({...options, onlyHttps: true});
queries.push(query);
await query;
return true;
})(),
appleCheck(options)
(async () => {
const query = appleCheck(options);
queries.push(query);
await query;
return true;
})()
]);
return pTimeout(promise, options.timeout).catch(() => false);
return pTimeout(promise, options.timeout).catch(() => {
for (const query of queries) {
query.cancel();
}
return false;
});
};

@@ -42,0 +75,0 @@

4

package.json
{
"name": "is-online",
"version": "8.2.1",
"version": "8.2.2",
"description": "Check if the internet connection is up",

@@ -53,3 +53,3 @@ "license": "MIT",

"p-timeout": "^3.0.0",
"public-ip": "^3.0.0"
"public-ip": "^4.0.1"
},

@@ -56,0 +56,0 @@ "devDependencies": {

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc