@flowfuse/nr-file-nodes 0.0.6-4ce617c-202404091251.0 → 0.0.6-66b148e-202406101509.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/package.json +8 -5
  2. package/utils.js +21 -0
  3. package/vfs.js +4 -2
package/package.json CHANGED
@@ -1,14 +1,15 @@
1
1
  {
2
2
  "name": "@flowfuse/nr-file-nodes",
3
- "version": "0.0.6-4ce617c-202404091251.0",
3
+ "version": "0.0.6-66b148e-202406101509.0",
4
4
  "description": "Node-RED file nodes packaged for FlowFuse",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
- "test": "npm run test:files && npm run test:memory",
7
+ "test": "npm run test:files && npm run test:memory && npm run test:utils",
8
8
  "test:memory": "mocha 'test/memory_spec.js' --timeout 5000",
9
9
  "test:files": "mocha 'test/file_spec.js' --timeout 5000",
10
- "lint": "eslint -c .eslintrc *.js",
11
- "lint:fix": "eslint -c .eslintrc *.js --fix"
10
+ "test:utils": "mocha 'test/utils_spec.js' --timeout 5000",
11
+ "lint": "eslint -c .eslintrc *.js test/*.js",
12
+ "lint:fix": "eslint -c .eslintrc *.js test/*.js --fix"
12
13
  },
13
14
  "keywords": [
14
15
  "FlowFuse",
@@ -34,7 +35,9 @@
34
35
  "homepage": "https://github.com/FlowFuse/nr-file-nodes#readme",
35
36
  "dependencies": {
36
37
  "got": "11.8.5",
37
- "iconv-lite": "0.6.3"
38
+ "iconv-lite": "0.6.3",
39
+ "http-proxy-agent": "^7.0.2",
40
+ "https-proxy-agent": "^7.0.4"
38
41
  },
39
42
  "engines": {
40
43
  "node": ">=16.x"
package/utils.js ADDED
@@ -0,0 +1,21 @@
1
+ module.exports = {
2
+ getHTTPProxyAgent
3
+ }
4
+
5
+ /**
6
+ * Get proxy agents for HTTP and/or HTTPS connections
7
+ * @param {import('http').AgentOptions} proxyOptions - proxy options
8
+ * @returns {{http: import('http-proxy-agent').HttpProxyAgent | undefined, https: import('https-proxy-agent').HttpsProxyAgent | undefined}}
9
+ */
10
+ function getHTTPProxyAgent (proxyOptions) {
11
+ const agent = {}
12
+ if (process.env.http_proxy) {
13
+ const HttpAgent = require('http-proxy-agent').HttpProxyAgent
14
+ agent.http = new HttpAgent(process.env.http_proxy, proxyOptions)
15
+ }
16
+ if (process.env.https_proxy) {
17
+ const HttpsAgent = require('https-proxy-agent').HttpsProxyAgent
18
+ agent.https = new HttpsAgent(process.env.https_proxy, proxyOptions)
19
+ }
20
+ return agent
21
+ }
package/vfs.js CHANGED
@@ -15,7 +15,8 @@
15
15
  **/
16
16
 
17
17
  const Stream = require('stream')
18
- const got = require('got')
18
+ const utils = require('./utils')
19
+ const got = require('got').default
19
20
 
20
21
  module.exports = function (RED, _teamID, _projectID, _token) {
21
22
  'use strict'
@@ -36,7 +37,8 @@ module.exports = function (RED, _teamID, _projectID, _token) {
36
37
  },
37
38
  retry: {
38
39
  limit: 0
39
- }
40
+ },
41
+ agent: utils.getHTTPProxyAgent({ timeout: 3000 })
40
42
  })
41
43
 
42
44
  const normaliseError = (err, filename) => {