@fyno/node 1.1.11 → 1.2.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.
@@ -1 +1,26 @@
1
- /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
1
+ /*!
2
+ * The buffer module from node.js, for the browser.
3
+ *
4
+ * @author Feross Aboukhadijeh <https://feross.org>
5
+ * @license MIT
6
+ */
7
+
8
+ /*!
9
+ * mime-db
10
+ * Copyright(c) 2014 Jonathan Ong
11
+ * Copyright(c) 2015-2022 Douglas Christopher Wilson
12
+ * MIT Licensed
13
+ */
14
+
15
+ /*!
16
+ * mime-types
17
+ * Copyright(c) 2014 Jonathan Ong
18
+ * Copyright(c) 2015 Douglas Christopher Wilson
19
+ * MIT Licensed
20
+ */
21
+
22
+ /*! Axios v1.13.5 Copyright (c) 2026 Matt Zabriskie and contributors */
23
+
24
+ /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
25
+
26
+ /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fyno/node",
3
- "version": "1.1.11",
3
+ "version": "1.2.0",
4
4
  "description": "This is the official Node.js module for sending notifications through Fyno.io.",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -24,13 +24,15 @@
24
24
  "devDependencies": {
25
25
  "@types/jest": "^29.2.4",
26
26
  "jest": "^29.3.1",
27
+ "node-polyfill-webpack-plugin": "^4.1.0",
27
28
  "prettier": "^2.8.0",
28
29
  "webpack-cli": "^5.0.1"
29
30
  },
30
31
  "dependencies": {
31
32
  "@types/node": "^18.11.11",
32
- "axios": "^1.2.0",
33
- "axios-retry": "^3.3.1"
33
+ "axios": "1.13.5",
34
+ "axios-retry": "^3.3.1",
35
+ "https-proxy-agent": "^7.0.6"
34
36
  },
35
37
  "repository": {
36
38
  "type": "git",
@@ -1,5 +1,6 @@
1
1
  const axios = require("axios");
2
2
  const axiosRetry = require("axios-retry");
3
+ const { axiosInstance } = require("../httplib");
3
4
 
4
5
  class Event {
5
6
  constructor(endpoint, headers, event, payload) {
@@ -29,7 +30,7 @@ class Event {
29
30
 
30
31
  trigger = async () => {
31
32
  return new Promise((resolve, reject) => {
32
- axios
33
+ axiosInstance
33
34
  .post(this.endpoint, this.payload, { headers: this.headers })
34
35
  .then((resp) => {
35
36
  resolve(resp.data);
@@ -1,4 +1,4 @@
1
- const axios = require("axios");
1
+ const { axiosInstance } = require("../httplib");
2
2
 
3
3
  class Profile {
4
4
  constructor(endpoint, headers, distinct_id, payload) {
@@ -148,7 +148,7 @@ class Profile {
148
148
  headers: this.headers,
149
149
  };
150
150
  if (method !== "GET" && payload) axiosPayload.data = payload;
151
- const response = await axios(axiosPayload);
151
+ const response = await axiosInstance(axiosPayload);
152
152
  return response;
153
153
  };
154
154
  }
package/src/httplib.js ADDED
@@ -0,0 +1,38 @@
1
+ const axios = require("axios");
2
+ const httpsKeepAlive = require("node:https");
3
+ const httpKeepAlive = require("node:http");
4
+
5
+ const { HttpsProxyAgent } = require("https-proxy-agent");
6
+
7
+ const proxyUrl = process.env.HTTPS_PROXY || process.env.HTTP_PROXY;
8
+
9
+ let httpsAgent;
10
+ let httpAgent;
11
+ let axiosInstance;
12
+
13
+ if (proxyUrl) {
14
+ const proxyKeepAlive =
15
+ process.env.PROXY_KEEP_ALIVE === undefined
16
+ ? true
17
+ : String(process.env.PROXY_KEEP_ALIVE).toLowerCase() !== "false";
18
+
19
+ const proxyAgent = new HttpsProxyAgent(proxyUrl);
20
+
21
+ proxyAgent.keepAlive = proxyKeepAlive;
22
+ axiosInstance = axios.create({
23
+ httpAgent: proxyAgent,
24
+ httpsAgent: proxyAgent,
25
+ });
26
+ } else {
27
+ httpsAgent = new httpsKeepAlive.Agent({ keepAlive: true });
28
+ httpAgent = new httpKeepAlive.Agent({ keepAlive: true });
29
+
30
+ axiosInstance = axios.create({
31
+ httpsAgent,
32
+ httpAgent,
33
+ });
34
+ }
35
+
36
+ module.exports = {
37
+ axiosInstance,
38
+ };
@@ -0,0 +1,6 @@
1
+ const NodePolyfillPlugin = require("node-polyfill-webpack-plugin");
2
+
3
+ module.exports = {
4
+ target: "node",
5
+ plugins: [new NodePolyfillPlugin()],
6
+ };