@splitsoftware/splitio 10.26.1-rc.3 → 10.26.2-rc.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.
package/CHANGES.txt CHANGED
@@ -1,5 +1,10 @@
1
- 10.26.1 (June 13, 2024)
1
+ 10.27.0 (June 25, 2024)
2
+ - Added `sync.requestOptions.agent` property to SDK configuration, to pass a custom HTTP(S) Agent to the SDK requests in NodeJS. This allows the SDK to use a custom agent with specific configurations, like a network proxy or custom TLS settings (See https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK#proxy).
3
+ - Updated some transitive dependencies for vulnerability fixes.
4
+
5
+ 10.26.1 (June 14, 2024)
2
6
  - Updated the internal imports of 'os' and 'ioredis' modules for NodeJS, to use EcmaScript 'import' rather than CommonJS 'require' for the ES modules build. This avoids runtime errors on some scenarios when bundling the SDK into a .mjs file or importing it from a .mjs file.
7
+ - Updated eventsource dependency for NodeJS. The eventsource v1.1.2 dependency was removed, and the SDK now uses an embedded adaptation that can accept an HTTP(S) agent option, like other HTTP(S) requests.
3
8
  - Updated @splitsoftware/splitio-commons package to version 1.16.0 that includes some vulnerability and bug fixes.
4
9
  - Bugfixing - Restored some input validation error logs that were removed in version 10.24.0. The logs inform the user when the `getTreatment(s)` methods are called with an invalid value as feature flag name or flag set name.
5
10
  - Bugfixing - Fixed localhost mode to emit SDK_UPDATE when mocked feature flags are updated in the `features` object map of the config object (Related to issue https://github.com/splitio/javascript-browser-client/issues/119).
@@ -8,6 +8,9 @@ var agent = new https.Agent({
8
8
  keepAliveMsecs: 1500
9
9
  });
10
10
  export function getOptions(settings) {
11
+ // User provided options take precedence
12
+ if (settings.sync.requestOptions)
13
+ return settings.sync.requestOptions;
11
14
  // If some URL is not HTTPS, we don't use the agent, to let the SDK connect to HTTP endpoints
12
15
  if (find(settings.urls, function (url) { return !url.startsWith('https:'); }))
13
16
  return;
@@ -1 +1 @@
1
- export var packageVersion = '10.26.1-rc.3';
1
+ export var packageVersion = '10.26.2-rc.0';
@@ -14,5 +14,9 @@ var params = {
14
14
  // In Node.js the SDK ignores `config.integrations`, so a validator for integrations is not required
15
15
  };
16
16
  export function settingsFactory(config) {
17
- return settingsValidation(config, params);
17
+ var settings = settingsValidation(config, params);
18
+ // if provided, keeps reference to the `requestOptions` object
19
+ if (settings.sync.requestOptions)
20
+ settings.sync.requestOptions = config.sync.requestOptions;
21
+ return settings;
18
22
  }
@@ -12,6 +12,9 @@ var agent = new https_1.default.Agent({
12
12
  keepAliveMsecs: 1500
13
13
  });
14
14
  function getOptions(settings) {
15
+ // User provided options take precedence
16
+ if (settings.sync.requestOptions)
17
+ return settings.sync.requestOptions;
15
18
  // If some URL is not HTTPS, we don't use the agent, to let the SDK connect to HTTP endpoints
16
19
  if ((0, lang_1.find)(settings.urls, function (url) { return !url.startsWith('https:'); }))
17
20
  return;
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.packageVersion = void 0;
4
- exports.packageVersion = '10.26.1-rc.3';
4
+ exports.packageVersion = '10.26.2-rc.0';
@@ -17,6 +17,10 @@ var params = {
17
17
  // In Node.js the SDK ignores `config.integrations`, so a validator for integrations is not required
18
18
  };
19
19
  function settingsFactory(config) {
20
- return (0, settingsValidation_1.settingsValidation)(config, params);
20
+ var settings = (0, settingsValidation_1.settingsValidation)(config, params);
21
+ // if provided, keeps reference to the `requestOptions` object
22
+ if (settings.sync.requestOptions)
23
+ settings.sync.requestOptions = config.sync.requestOptions;
24
+ return settings;
21
25
  }
22
26
  exports.settingsFactory = settingsFactory;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@splitsoftware/splitio",
3
- "version": "10.26.1-rc.3",
3
+ "version": "10.26.2-rc.0",
4
4
  "description": "Split SDK",
5
5
  "files": [
6
6
  "README.md",
@@ -40,7 +40,7 @@
40
40
  "node": ">=6"
41
41
  },
42
42
  "dependencies": {
43
- "@splitsoftware/splitio-commons": "1.15.1-rc.3",
43
+ "@splitsoftware/splitio-commons": "1.16.0",
44
44
  "@types/google.analytics": "0.0.40",
45
45
  "@types/ioredis": "^4.28.0",
46
46
  "bloom-filters": "^3.0.0",
@@ -82,7 +82,7 @@ function EventSource(url, eventSourceInitDict) {
82
82
  function onConnectionClosed(message) {
83
83
  if (readyState === EventSource.CLOSED) return;
84
84
  readyState = EventSource.CONNECTING;
85
- _emit('error', new Event('error', {message: message}));
85
+ _emit('error', new Event('error', { message: message }));
86
86
 
87
87
  // The url may have been changed by a temporary redirect. If that's the case,
88
88
  // revert it now, and flag that we are no longer pointing to a new origin
@@ -177,7 +177,7 @@ function EventSource(url, eventSourceInitDict) {
177
177
  self.connectionInProgress = false;
178
178
  // Handle HTTP errors
179
179
  if (res.statusCode === 500 || res.statusCode === 502 || res.statusCode === 503 || res.statusCode === 504) {
180
- _emit('error', new Event('error', {status: res.statusCode, message: res.statusMessage}));
180
+ _emit('error', new Event('error', { status: res.statusCode, message: res.statusMessage }));
181
181
  onConnectionClosed();
182
182
  return;
183
183
  }
@@ -187,7 +187,7 @@ function EventSource(url, eventSourceInitDict) {
187
187
  var location = res.headers.location;
188
188
  if (!location) {
189
189
  // Server sent redirect response without Location header.
190
- _emit('error', new Event('error', {status: res.statusCode, message: res.statusMessage}));
190
+ _emit('error', new Event('error', { status: res.statusCode, message: res.statusMessage }));
191
191
  return;
192
192
  }
193
193
  var prevOrigin = getOrigin(url);
@@ -200,7 +200,7 @@ function EventSource(url, eventSourceInitDict) {
200
200
  }
201
201
 
202
202
  if (res.statusCode !== 200) {
203
- _emit('error', new Event('error', {status: res.statusCode, message: res.statusMessage}));
203
+ _emit('error', new Event('error', { status: res.statusCode, message: res.statusMessage }));
204
204
  return self.close();
205
205
  }
206
206
 
@@ -386,9 +386,9 @@ EventSource.prototype.constructor = EventSource; // make stacktraces readable
386
386
  /**
387
387
  * Ready states
388
388
  */
389
- Object.defineProperty(EventSource, 'CONNECTING', {enumerable: true, value: 0});
390
- Object.defineProperty(EventSource, 'OPEN', {enumerable: true, value: 1});
391
- Object.defineProperty(EventSource, 'CLOSED', {enumerable: true, value: 2});
389
+ Object.defineProperty(EventSource, 'CONNECTING', { enumerable: true, value: 0 });
390
+ Object.defineProperty(EventSource, 'OPEN', { enumerable: true, value: 1 });
391
+ Object.defineProperty(EventSource, 'CLOSED', { enumerable: true, value: 2 });
392
392
 
393
393
  EventSource.prototype.CONNECTING = 0;
394
394
  EventSource.prototype.OPEN = 1;
@@ -11,6 +11,9 @@ const agent = new https.Agent({
11
11
  });
12
12
 
13
13
  export function getOptions(settings) {
14
+ // User provided options take precedence
15
+ if (settings.sync.requestOptions) return settings.sync.requestOptions;
16
+
14
17
  // If some URL is not HTTPS, we don't use the agent, to let the SDK connect to HTTP endpoints
15
18
  if (find(settings.urls, url => !url.startsWith('https:'))) return;
16
19
 
@@ -1 +1 @@
1
- export const packageVersion = '10.26.1-rc.3';
1
+ export const packageVersion = '10.26.2-rc.0';
@@ -17,5 +17,9 @@ const params = {
17
17
  };
18
18
 
19
19
  export function settingsFactory(config) {
20
- return settingsValidation(config, params);
20
+ const settings = settingsValidation(config, params);
21
+
22
+ // if provided, keeps reference to the `requestOptions` object
23
+ if (settings.sync.requestOptions) settings.sync.requestOptions = config.sync.requestOptions;
24
+ return settings;
21
25
  }
@@ -4,6 +4,7 @@
4
4
 
5
5
  /// <reference types="google.analytics" />
6
6
  import { RedisOptions } from "ioredis";
7
+ import { RequestOptions } from "http";
7
8
 
8
9
  export as namespace SplitIO;
9
10
  export = SplitIO;
@@ -1168,6 +1169,41 @@ declare namespace SplitIO {
1168
1169
  * @default 'standalone'
1169
1170
  */
1170
1171
  mode?: 'standalone'
1172
+ sync?: INodeBasicSettings['sync'] & {
1173
+ /**
1174
+ * Custom options object for HTTP(S) requests in NodeJS.
1175
+ * If provided, this object is merged with the options object passed by the SDK for EventSource and Node-Fetch calls.
1176
+ * @see {@link https://www.npmjs.com/package/node-fetch#options}
1177
+ */
1178
+ requestOptions?: {
1179
+ /**
1180
+ * Custom NodeJS HTTP(S) Agent used by the SDK for HTTP(S) requests.
1181
+ *
1182
+ * You can use it, for example, for certificate pinning or setting a network proxy:
1183
+ *
1184
+ * ```javascript
1185
+ * const { HttpsProxyAgent } = require('https-proxy-agent');
1186
+ *
1187
+ * const proxyAgent = new HttpsProxyAgent(process.env.HTTPS_PROXY || 'http://10.10.1.10:1080');
1188
+ *
1189
+ * const factory = SplitFactory({
1190
+ * ...
1191
+ * sync: {
1192
+ * requestOptions: {
1193
+ * agent: proxyAgent
1194
+ * }
1195
+ * }
1196
+ * })
1197
+ * ```
1198
+ *
1199
+ * @see {@link https://nodejs.org/api/https.html#class-httpsagent}
1200
+ *
1201
+ * @property {http.Agent | https.Agent} agent
1202
+ * @default undefined
1203
+ */
1204
+ agent?: RequestOptions["agent"]
1205
+ },
1206
+ }
1171
1207
  }
1172
1208
  /**
1173
1209
  * Settings interface with async storage for SDK instances created on NodeJS.