node-red-contrib-hikvision-ultimate
Advanced tools
Comparing version 1.2.1 to 1.2.3
@@ -6,3 +6,3 @@ | ||
const DigestFetch = require('digest-fetch') | ||
const AbortController = require('abort-controller'); | ||
// const AbortController = require('abort-controller'); | ||
const https = require('https'); | ||
@@ -139,3 +139,3 @@ const fs = require('fs'); | ||
controller = new AbortController(); // For aborting the stream request | ||
controller = new globalThis.AbortController(); // For aborting the stream request | ||
var options = { | ||
@@ -142,0 +142,0 @@ // These properties are part of the Fetch Standard |
@@ -6,3 +6,3 @@ | ||
const DigestFetch = require('digest-fetch') | ||
const AbortController = require('abort-controller'); | ||
// const AbortController = require('abort-controller'); | ||
const { XMLParser } = require("fast-xml-parser"); | ||
@@ -121,3 +121,3 @@ const https = require('https'); | ||
controller = new AbortController(); // For aborting the stream request | ||
controller = new globalThis.AbortController(); // For aborting the stream request | ||
var options = { | ||
@@ -124,0 +124,0 @@ // These properties are part of the Fetch Standard |
@@ -9,3 +9,3 @@ const { default: fetch } = require('node-fetch') | ||
const DigestFetch = require('digest-fetch'); // 04/6/2022 DO NOT UPGRADE TO NODE-FETCH V3, BECAUSE DIGEST-FETCH DOESN'T SUPPORT IT | ||
const AbortController = require('abort-controller'); | ||
// const AbortController = require('abort-controller'); | ||
const https = require('https'); | ||
@@ -139,3 +139,3 @@ | ||
controller = new AbortController(); // For aborting the stream request | ||
controller = new globalThis.AbortController(); // For aborting the stream request | ||
node.optionsAlarmStream = { | ||
@@ -142,0 +142,0 @@ // These properties are part of the Fetch Standard |
@@ -5,3 +5,3 @@ | ||
const DigestFetch = require('digest-fetch') | ||
const AbortController = require('abort-controller'); | ||
// const AbortController = require('abort-controller'); | ||
const { XMLParser } = require("fast-xml-parser"); | ||
@@ -123,3 +123,3 @@ const readableStr = require('stream').Readable; | ||
controller = new AbortController(); // For aborting the stream request | ||
controller = new globalThis.AbortController(); // For aborting the stream request | ||
var optionsAlarmStream = { | ||
@@ -245,43 +245,43 @@ // These properties are part of the Fetch Standard | ||
node.request = async function (_callerNode, _method, _URL, _body) { | ||
var clientGenericRequest; | ||
if (node.authentication === "digest") clientGenericRequest = new DigestFetch(node.credentials.user, node.credentials.password); // Instantiate the fetch client. | ||
if (node.authentication === "basic") clientGenericRequest = new DigestFetch(node.credentials.user, node.credentials.password, { basic: true }); // Instantiate the fetch client. | ||
var clientGenericRequest; | ||
if (node.authentication === "digest") clientGenericRequest = new DigestFetch(node.credentials.user, node.credentials.password); // Instantiate the fetch client. | ||
if (node.authentication === "basic") clientGenericRequest = new DigestFetch(node.credentials.user, node.credentials.password, { basic: true }); // Instantiate the fetch client. | ||
var reqController = new AbortController(); // For aborting the stream request | ||
var options = { | ||
// These properties are part of the Fetch Standard | ||
method: _method.toString().toUpperCase(), | ||
headers: {}, // request headers. format is the identical to that accepted by the Headers constructor (see below) | ||
body: _body, // request body. can be null, a string, a Buffer, a Blob, or a Node.js Readable stream | ||
redirect: 'follow', // set to `manual` to extract redirect headers, `error` to reject redirect | ||
signal: reqController.signal, // pass an instance of AbortSignal to optionally abort requests | ||
var reqcontroller = new globalThis.AbortController(); // For aborting the stream request | ||
var options = { | ||
// These properties are part of the Fetch Standard | ||
method: _method.toString().toUpperCase(), | ||
headers: {}, // request headers. format is the identical to that accepted by the Headers constructor (see below) | ||
body: _body, // request body. can be null, a string, a Buffer, a Blob, or a Node.js Readable stream | ||
redirect: 'follow', // set to `manual` to extract redirect headers, `error` to reject redirect | ||
signal: reqController.signal, // pass an instance of AbortSignal to optionally abort requests | ||
// The following properties are node-fetch extensions | ||
follow: 20, // maximum redirect count. 0 to not follow redirect | ||
timeout: 8000, // req/res timeout in ms, it resets on redirect. 0 to disable (OS limit applies). Signal is recommended instead. | ||
compress: false, // support gzip/deflate content encoding. false to disable | ||
size: 0, // maximum response body size in bytes. 0 to disable | ||
agent: node.protocol === "https" ? customHttpsAgent : null // http(s).Agent instance or function that returns an instance (see below) | ||
}; | ||
try { | ||
if (!_URL.startsWith("/")) _URL = "/" + _URL; | ||
const response = await clientGenericRequest.fetch(node.protocol + "://" + node.host + _URL, options); | ||
if (response.ok) { | ||
try { | ||
const oReadable = readableStr.from(response.body, { encoding: 'utf8' }); | ||
oReadable.on('data', (chunk) => { | ||
if (node.debug) RED.log.error(chunk); | ||
}); | ||
} catch (error) { | ||
throw new Error("Error readableStream: " + error.message || ""); | ||
} | ||
} else { | ||
throw new Error("Error response: " + response.statusText || " unknown response code"); | ||
// The following properties are node-fetch extensions | ||
follow: 20, // maximum redirect count. 0 to not follow redirect | ||
timeout: 8000, // req/res timeout in ms, it resets on redirect. 0 to disable (OS limit applies). Signal is recommended instead. | ||
compress: false, // support gzip/deflate content encoding. false to disable | ||
size: 0, // maximum response body size in bytes. 0 to disable | ||
agent: node.protocol === "https" ? customHttpsAgent : null // http(s).Agent instance or function that returns an instance (see below) | ||
}; | ||
try { | ||
if (!_URL.startsWith("/")) _URL = "/" + _URL; | ||
const response = await clientGenericRequest.fetch(node.protocol + "://" + node.host + _URL, options); | ||
if (response.ok) { | ||
try { | ||
const oReadable = readableStr.from(response.body, { encoding: 'utf8' }); | ||
oReadable.on('data', (chunk) => { | ||
if (node.debug) RED.log.error(chunk); | ||
}); | ||
} catch (error) { | ||
throw new Error("Error readableStream: " + error.message || ""); | ||
} | ||
} else { | ||
throw new Error("Error response: " + response.statusText || " unknown response code"); | ||
} | ||
} catch (error) { | ||
// Main Error | ||
if (node.debug) RED.log.error("Doorbell-config: clientGenericRequest.fetch error " + error.message); | ||
throw (new Error("clientGenericRequest.fetch error:" + error.message)); | ||
} | ||
} catch (error) { | ||
// Main Error | ||
if (node.debug) RED.log.error("Doorbell-config: clientGenericRequest.fetch error " + error.message); | ||
throw (new Error("clientGenericRequest.fetch error:" + error.message)); | ||
} | ||
}; | ||
@@ -288,0 +288,0 @@ //#endregion |
@@ -5,3 +5,2 @@ | ||
const DigestFetch = require('digest-fetch'); // 04/6/2022 DO NOT UPGRADE TO NODE-FETCH V3, BECAUSE DIGEST-FETCH DOESN'T SUPPORT IT | ||
const AbortController = require('abort-controller'); | ||
const { XMLParser } = require("fast-xml-parser"); | ||
@@ -11,2 +10,3 @@ | ||
const https = require('https'); | ||
const http = require('http'); | ||
const Dicer = require('dicer'); | ||
@@ -43,4 +43,11 @@ | ||
const customHttpsAgent = new https.Agent({ | ||
rejectUnauthorized: false | ||
rejectUnauthorized: false, | ||
keepAlive: true, // Mantiene vive le connessioni | ||
maxSockets: 10, // Numero massimo di connessioni simultanee | ||
}); | ||
const customHttpAgent = new http.Agent({ | ||
rejectUnauthorized: false, | ||
keepAlive: true, // Mantiene vive le connessioni | ||
maxSockets: 10, // Numero massimo di connessioni simultanee | ||
}); | ||
@@ -78,3 +85,3 @@ // 14/12/2020 Get the infos from the camera | ||
size: 0, // maximum response body size in bytes. 0 to disable | ||
agent: jParams.protocol === "https" ? customHttpsAgent : null // http(s).Agent instance or function that returns an instance (see below) | ||
agent: jParams.protocol === "https" ? customHttpsAgent : customHttpAgent // http(s).Agent instance or function that returns an instance (see below) | ||
}; | ||
@@ -108,36 +115,3 @@ try { | ||
// 14/12/2020 Get the infos from the camera | ||
// RED.httpAdmin.get("/hikvisionUltimateDiscoverOnlineDevices", RED.auth.needsPermission('Hikvisionconfig.read'), function (req, res) { | ||
// if (node.onLineHikvisionDevicesDiscoverList === null) { | ||
// try { | ||
// (async () => { | ||
// try { | ||
// let discoveredDevices = await discoHikvisionDevices.Discover(); | ||
// try { | ||
// res.json(discoveredDevices); | ||
// return; | ||
// } catch (error) { | ||
// res.json(error); | ||
// return; | ||
// } | ||
// } catch (error) { | ||
// RED.log.error("Errore hikvisionUltimateDiscoverOnlineDevices " + error.message); | ||
// res.json(error); | ||
// } | ||
// })(); | ||
// } catch (err) { | ||
// res.json(err); | ||
// } | ||
// } else { | ||
// res.json(node.onLineHikvisionDevicesDiscoverList) | ||
// } | ||
// }); | ||
// This function starts the heartbeat timer, to detect the disconnection from the server | ||
node.resetHeartBeatTimer = () => { | ||
@@ -193,3 +167,3 @@ // Reset node.timerCheckHeartBeat | ||
controller = new AbortController(); // For aborting the stream request | ||
controller = new globalThis.AbortController(); // For aborting the stream request | ||
var optionsAlarmStream = { | ||
@@ -208,3 +182,3 @@ // These properties are part of the Fetch Standard | ||
size: 0, // maximum response body size in bytes. 0 to disable | ||
agent: node.protocol === "https" ? customHttpsAgent : null | ||
agent: node.protocol === "https" ? customHttpsAgent : customHttpAgent | ||
@@ -247,4 +221,2 @@ }; | ||
//console.log(`Receiving multipart stream with boundary: ${boundary}`); | ||
// Inizializza Dicer per il parsing del multipart | ||
@@ -305,3 +277,2 @@ const dicer = new Dicer({ boundary }); | ||
}); | ||
part.on('error', (err) => { | ||
@@ -394,3 +365,3 @@ //console.error('Error in part:', err); | ||
var reqController = new AbortController(); // For aborting the stream request | ||
var reqController = new globalThis.AbortController(); // For aborting the stream request | ||
var options = { | ||
@@ -409,3 +380,3 @@ // These properties are part of the Fetch Standard | ||
size: 0, // maximum response body size in bytes. 0 to disable | ||
agent: node.protocol === "https" ? customHttpsAgent : null // http(s).Agent instance or function that returns an instance (see below) | ||
agent: node.protocol === "https" ? customHttpsAgent : customHttpAgent // http(s).Agent instance or function that returns an instance (see below) | ||
}; | ||
@@ -496,3 +467,6 @@ | ||
if (node.timerCheckHeartBeat !== null) clearTimeout(node.timerCheckHeartBeat); | ||
done(); | ||
setTimeout(() => { | ||
done(); | ||
}, 2000); | ||
}); | ||
@@ -499,0 +473,0 @@ |
@@ -5,3 +5,3 @@ | ||
const DigestFetch = require('digest-fetch') | ||
const AbortController = require('abort-controller'); | ||
// const AbortController = require('abort-controller'); | ||
const { XMLParser } = require("fast-xml-parser"); | ||
@@ -306,3 +306,3 @@ const readableStr = require('stream').Readable; | ||
controller = new AbortController(); // For aborting the stream request | ||
controller = new globalThis.AbortController(); // For aborting the stream request | ||
var optionsAlarmStream = { | ||
@@ -309,0 +309,0 @@ // These properties are part of the Fetch Standard |
{ | ||
"name": "node-red-contrib-hikvision-ultimate", | ||
"version": "1.2.1", | ||
"version": "1.2.3", | ||
"description": "A native set of nodes for Hikvision (and compatible) Cameras, Alarms, Radars, NVR, Doorbells, etc.", | ||
@@ -9,3 +9,2 @@ "author": "Supergiovane (https://github.com/Supergiovane)", | ||
"digest-fetch": "2.0.1", | ||
"abort-controller": "3.0.0", | ||
"jimp": "0.22.10", | ||
@@ -30,3 +29,3 @@ "lodash": "4.17.21", | ||
"engines": { | ||
"node": ">=12.3.0" | ||
"node": ">=16.0.0" | ||
}, | ||
@@ -33,0 +32,0 @@ "license": "MIT", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6
3401547
5412
8
- Removedabort-controller@3.0.0
- Removedabort-controller@3.0.0(transitive)
- Removedevent-target-shim@5.0.1(transitive)