@splitsoftware/splitio 10.27.1-rc.2 → 10.28.0-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,3 +1,7 @@
1
+ 10.28.0 (August XXX, 2024)
2
+ - Updated @splitsoftware/splitio-commons package to version 1.17.0 that includes minor updates:
3
+ - Added `sync.requestOptions.getHeaderOverrides` configuration option to enhance SDK HTTP request Headers for Authorization Frameworks.
4
+
1
5
  10.27.0 (June 25, 2024)
2
6
  - Added `sync.requestOptions.agent` option to SDK configuration for NodeJS. This allows passing a custom NodeJS HTTP(S) Agent with specific configurations for the SDK requests, like custom TLS settings or a network proxy (See https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK#proxy).
3
7
  - Updated some transitive dependencies for vulnerability fixes.
@@ -3,7 +3,6 @@ import { validateRuntime } from '@splitsoftware/splitio-commons/esm/utils/settin
3
3
  import { validateLogger } from '@splitsoftware/splitio-commons/esm/utils/settingsValidation/logger/builtinLogger';
4
4
  import { LocalhostFromObject } from '@splitsoftware/splitio-commons/esm/sync/offline/LocalhostFromObject';
5
5
  import { validateConsent } from '@splitsoftware/splitio-commons/esm/utils/settingsValidation/consent';
6
- import { STANDALONE_MODE } from '@splitsoftware/splitio-commons/esm/utils/constants';
7
6
  import { defaults } from './defaults/browser';
8
7
  import { validateStorage } from './storage/browser';
9
8
  import { validateIntegrations } from './integrations/browser';
@@ -18,9 +17,5 @@ var params = {
18
17
  consent: validateConsent,
19
18
  };
20
19
  export function settingsFactory(config) {
21
- var settings = settingsValidation(config, params);
22
- // Override in localhost mode to emit SDK_READY event
23
- if (settings.mode !== STANDALONE_MODE)
24
- settings.sync.largeSegmentsEnabled = false;
25
- return settings;
20
+ return settingsValidation(config, params);
26
21
  }
@@ -9,9 +9,7 @@ export var defaults = {
9
9
  // Maximum amount of time used before notifies me a timeout.
10
10
  readyTimeout: 10,
11
11
  // Amount of time we will wait before the first push of events.
12
- eventsFirstPushWindow: 10,
13
- // Wait for large segments to emit SDK_READY event.
14
- waitForLargeSegments: true,
12
+ eventsFirstPushWindow: 10
15
13
  },
16
14
  // Consent is considered granted by default
17
15
  userConsent: CONSENT_GRANTED,
@@ -12,9 +12,7 @@ export var defaults = {
12
12
  // Maximum amount of time used before notifies me a timeout.
13
13
  readyTimeout: 15,
14
14
  // Don't wait a specific time for first flush on Node, no page load here.
15
- eventsFirstPushWindow: 0,
16
- // Don't wait for large segments to emit SDK_READY event.
17
- waitForLargeSegments: false,
15
+ eventsFirstPushWindow: 0
18
16
  },
19
17
  features: '.split',
20
18
  // Instance version.
@@ -1 +1 @@
1
- export var packageVersion = '10.27.1-rc.2';
1
+ export var packageVersion = '10.28.0-rc.0';
@@ -10,6 +10,7 @@ var params = {
10
10
  storage: validateStorage,
11
11
  logger: validateLogger,
12
12
  localhost: function () { return LocalhostFromFile(); },
13
+ consent: function () { return undefined; }, // resets settings.userConsent to the default
13
14
  // In Node.js the SDK ignores `config.integrations`, so a validator for integrations is not required
14
15
  };
15
16
  export function settingsFactory(config) {
@@ -17,9 +18,5 @@ export function settingsFactory(config) {
17
18
  // if provided, keeps reference to the `requestOptions` object
18
19
  if (settings.sync.requestOptions)
19
20
  settings.sync.requestOptions = config.sync.requestOptions;
20
- // Reset config options not supported in Node.js
21
- if (settings.sync.largeSegmentsEnabled)
22
- settings.log.warn('Client instantiation: config.sync.largeSegmentsEnabled option is not supported in NodeJS. Ignoring it.');
23
- settings.sync.largeSegmentsEnabled = false;
24
21
  return settings;
25
22
  }
@@ -18,7 +18,7 @@ export function validateStorage(settings) {
18
18
  if (type !== STORAGE_MEMORY && type !== STORAGE_LOCALSTORAGE ||
19
19
  type === STORAGE_LOCALSTORAGE && !isLocalStorageAvailable()) {
20
20
  fallbackToMemory();
21
- log.error('Invalid or unavailable storage. Fallback into MEMORY storage');
21
+ log.error('Invalid or unavailable storage. Fallbacking into MEMORY storage');
22
22
  }
23
23
  return {
24
24
  type: type,
@@ -6,7 +6,7 @@ export function validateStorage(settings) {
6
6
  case STORAGE_REDIS: {
7
7
  // If passing REDIS storage in localhost or standalone mode, we log an error and fallback to MEMORY storage
8
8
  if (mode === STANDALONE_MODE || mode === LOCALHOST_MODE) {
9
- log.error('The provided REDIS storage is invalid for this mode. It requires consumer mode. Fallback into default MEMORY storage.');
9
+ log.error('The provided REDIS storage is invalid for this mode. It requires consumer mode. Fallbacking into default MEMORY storage.');
10
10
  return {
11
11
  type: STORAGE_MEMORY,
12
12
  prefix: prefix
@@ -53,7 +53,7 @@ export function validateStorage(settings) {
53
53
  throw new Error('A REDIS storage is required on consumer mode');
54
54
  // If passing an invalid storage type, log an error
55
55
  if (type !== STORAGE_MEMORY)
56
- log.error("The provided '" + type + "' storage type is invalid. Fallback into default MEMORY storage.");
56
+ log.error("The provided '" + type + "' storage type is invalid. Fallbacking into default MEMORY storage.");
57
57
  return {
58
58
  type: STORAGE_MEMORY,
59
59
  prefix: prefix
@@ -6,7 +6,6 @@ var runtime_1 = require("@splitsoftware/splitio-commons/cjs/utils/settingsValida
6
6
  var builtinLogger_1 = require("@splitsoftware/splitio-commons/cjs/utils/settingsValidation/logger/builtinLogger");
7
7
  var LocalhostFromObject_1 = require("@splitsoftware/splitio-commons/cjs/sync/offline/LocalhostFromObject");
8
8
  var consent_1 = require("@splitsoftware/splitio-commons/cjs/utils/settingsValidation/consent");
9
- var constants_1 = require("@splitsoftware/splitio-commons/cjs/utils/constants");
10
9
  var browser_1 = require("./defaults/browser");
11
10
  var browser_2 = require("./storage/browser");
12
11
  var browser_3 = require("./integrations/browser");
@@ -21,10 +20,6 @@ var params = {
21
20
  consent: consent_1.validateConsent,
22
21
  };
23
22
  function settingsFactory(config) {
24
- var settings = (0, settingsValidation_1.settingsValidation)(config, params);
25
- // Override in localhost mode to emit SDK_READY event
26
- if (settings.mode !== constants_1.STANDALONE_MODE)
27
- settings.sync.largeSegmentsEnabled = false;
28
- return settings;
23
+ return (0, settingsValidation_1.settingsValidation)(config, params);
29
24
  }
30
25
  exports.settingsFactory = settingsFactory;
@@ -12,9 +12,7 @@ exports.defaults = {
12
12
  // Maximum amount of time used before notifies me a timeout.
13
13
  readyTimeout: 10,
14
14
  // Amount of time we will wait before the first push of events.
15
- eventsFirstPushWindow: 10,
16
- // Wait for large segments to emit SDK_READY event.
17
- waitForLargeSegments: true,
15
+ eventsFirstPushWindow: 10
18
16
  },
19
17
  // Consent is considered granted by default
20
18
  userConsent: constants_1.CONSENT_GRANTED,
@@ -15,9 +15,7 @@ exports.defaults = {
15
15
  // Maximum amount of time used before notifies me a timeout.
16
16
  readyTimeout: 15,
17
17
  // Don't wait a specific time for first flush on Node, no page load here.
18
- eventsFirstPushWindow: 0,
19
- // Don't wait for large segments to emit SDK_READY event.
20
- waitForLargeSegments: false,
18
+ eventsFirstPushWindow: 0
21
19
  },
22
20
  features: '.split',
23
21
  // Instance version.
@@ -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.27.1-rc.2';
4
+ exports.packageVersion = '10.28.0-rc.0';
@@ -13,6 +13,7 @@ var params = {
13
13
  storage: node_2.validateStorage,
14
14
  logger: builtinLogger_1.validateLogger,
15
15
  localhost: function () { return (0, LocalhostFromFile_1.LocalhostFromFile)(); },
16
+ consent: function () { return undefined; }, // resets settings.userConsent to the default
16
17
  // In Node.js the SDK ignores `config.integrations`, so a validator for integrations is not required
17
18
  };
18
19
  function settingsFactory(config) {
@@ -20,10 +21,6 @@ function settingsFactory(config) {
20
21
  // if provided, keeps reference to the `requestOptions` object
21
22
  if (settings.sync.requestOptions)
22
23
  settings.sync.requestOptions = config.sync.requestOptions;
23
- // Reset config options not supported in Node.js
24
- if (settings.sync.largeSegmentsEnabled)
25
- settings.log.warn('Client instantiation: config.sync.largeSegmentsEnabled option is not supported in NodeJS. Ignoring it.');
26
- settings.sync.largeSegmentsEnabled = false;
27
24
  return settings;
28
25
  }
29
26
  exports.settingsFactory = settingsFactory;
@@ -21,7 +21,7 @@ function validateStorage(settings) {
21
21
  if (type !== constants_1.STORAGE_MEMORY && type !== STORAGE_LOCALSTORAGE ||
22
22
  type === STORAGE_LOCALSTORAGE && !(0, isLocalStorageAvailable_1.isLocalStorageAvailable)()) {
23
23
  fallbackToMemory();
24
- log.error('Invalid or unavailable storage. Fallback into MEMORY storage');
24
+ log.error('Invalid or unavailable storage. Fallbacking into MEMORY storage');
25
25
  }
26
26
  return {
27
27
  type: type,
@@ -9,7 +9,7 @@ function validateStorage(settings) {
9
9
  case constants_1.STORAGE_REDIS: {
10
10
  // If passing REDIS storage in localhost or standalone mode, we log an error and fallback to MEMORY storage
11
11
  if (mode === constants_1.STANDALONE_MODE || mode === constants_1.LOCALHOST_MODE) {
12
- log.error('The provided REDIS storage is invalid for this mode. It requires consumer mode. Fallback into default MEMORY storage.');
12
+ log.error('The provided REDIS storage is invalid for this mode. It requires consumer mode. Fallbacking into default MEMORY storage.');
13
13
  return {
14
14
  type: constants_1.STORAGE_MEMORY,
15
15
  prefix: prefix
@@ -56,7 +56,7 @@ function validateStorage(settings) {
56
56
  throw new Error('A REDIS storage is required on consumer mode');
57
57
  // If passing an invalid storage type, log an error
58
58
  if (type !== constants_1.STORAGE_MEMORY)
59
- log.error("The provided '" + type + "' storage type is invalid. Fallback into default MEMORY storage.");
59
+ log.error("The provided '" + type + "' storage type is invalid. Fallbacking into default MEMORY storage.");
60
60
  return {
61
61
  type: constants_1.STORAGE_MEMORY,
62
62
  prefix: prefix
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@splitsoftware/splitio",
3
- "version": "10.27.1-rc.2",
3
+ "version": "10.28.0-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.16.1-rc.8",
43
+ "@splitsoftware/splitio-commons": "1.17.0-rc.0",
44
44
  "@types/google.analytics": "0.0.40",
45
45
  "@types/ioredis": "^4.28.0",
46
46
  "bloom-filters": "^3.0.0",
@@ -3,7 +3,6 @@ import { validateRuntime } from '@splitsoftware/splitio-commons/src/utils/settin
3
3
  import { validateLogger } from '@splitsoftware/splitio-commons/src/utils/settingsValidation/logger/builtinLogger';
4
4
  import { LocalhostFromObject } from '@splitsoftware/splitio-commons/src/sync/offline/LocalhostFromObject';
5
5
  import { validateConsent } from '@splitsoftware/splitio-commons/src/utils/settingsValidation/consent';
6
- import { STANDALONE_MODE } from '@splitsoftware/splitio-commons/src/utils/constants';
7
6
 
8
7
  import { defaults } from './defaults/browser';
9
8
  import { validateStorage } from './storage/browser';
@@ -21,10 +20,5 @@ const params = {
21
20
  };
22
21
 
23
22
  export function settingsFactory(config) {
24
- const settings = settingsValidation(config, params);
25
-
26
- // Override in localhost mode to emit SDK_READY event
27
- if (settings.mode !== STANDALONE_MODE) settings.sync.largeSegmentsEnabled = false;
28
-
29
- return settings;
23
+ return settingsValidation(config, params);
30
24
  }
@@ -10,9 +10,7 @@ export const defaults = {
10
10
  // Maximum amount of time used before notifies me a timeout.
11
11
  readyTimeout: 10,
12
12
  // Amount of time we will wait before the first push of events.
13
- eventsFirstPushWindow: 10,
14
- // Wait for large segments to emit SDK_READY event.
15
- waitForLargeSegments: true,
13
+ eventsFirstPushWindow: 10
16
14
  },
17
15
 
18
16
  // Consent is considered granted by default
@@ -13,9 +13,7 @@ export const defaults = {
13
13
  // Maximum amount of time used before notifies me a timeout.
14
14
  readyTimeout: 15,
15
15
  // Don't wait a specific time for first flush on Node, no page load here.
16
- eventsFirstPushWindow: 0,
17
- // Don't wait for large segments to emit SDK_READY event.
18
- waitForLargeSegments: false,
16
+ eventsFirstPushWindow: 0
19
17
  },
20
18
 
21
19
  features: '.split',
@@ -1 +1 @@
1
- export const packageVersion = '10.27.1-rc.2';
1
+ export const packageVersion = '10.28.0-rc.0';
@@ -12,6 +12,7 @@ const params = {
12
12
  storage: validateStorage,
13
13
  logger: validateLogger,
14
14
  localhost: () => LocalhostFromFile(),
15
+ consent: () => undefined, // resets settings.userConsent to the default
15
16
  // In Node.js the SDK ignores `config.integrations`, so a validator for integrations is not required
16
17
  };
17
18
 
@@ -20,10 +21,5 @@ export function settingsFactory(config) {
20
21
 
21
22
  // if provided, keeps reference to the `requestOptions` object
22
23
  if (settings.sync.requestOptions) settings.sync.requestOptions = config.sync.requestOptions;
23
-
24
- // Reset config options not supported in Node.js
25
- if (settings.sync.largeSegmentsEnabled) settings.log.warn('Client instantiation: config.sync.largeSegmentsEnabled option is not supported in NodeJS. Ignoring it.');
26
- settings.sync.largeSegmentsEnabled = false;
27
-
28
24
  return settings;
29
25
  }
@@ -31,7 +31,7 @@ export function validateStorage(settings) {
31
31
  if (type !== STORAGE_MEMORY && type !== STORAGE_LOCALSTORAGE ||
32
32
  type === STORAGE_LOCALSTORAGE && !isLocalStorageAvailable()) {
33
33
  fallbackToMemory();
34
- log.error('Invalid or unavailable storage. Fallback into MEMORY storage');
34
+ log.error('Invalid or unavailable storage. Fallbacking into MEMORY storage');
35
35
  }
36
36
 
37
37
  return {
@@ -16,7 +16,7 @@ export function validateStorage(settings) {
16
16
  case STORAGE_REDIS: {
17
17
  // If passing REDIS storage in localhost or standalone mode, we log an error and fallback to MEMORY storage
18
18
  if (mode === STANDALONE_MODE || mode === LOCALHOST_MODE) {
19
- log.error('The provided REDIS storage is invalid for this mode. It requires consumer mode. Fallback into default MEMORY storage.');
19
+ log.error('The provided REDIS storage is invalid for this mode. It requires consumer mode. Fallbacking into default MEMORY storage.');
20
20
  return {
21
21
  type: STORAGE_MEMORY,
22
22
  prefix
@@ -74,7 +74,7 @@ export function validateStorage(settings) {
74
74
  // If passing MEMORY storage in consumer mode, throw an error (no way to fallback to REDIS storage)
75
75
  if (mode === CONSUMER_MODE) throw new Error('A REDIS storage is required on consumer mode');
76
76
  // If passing an invalid storage type, log an error
77
- if (type !== STORAGE_MEMORY) log.error(`The provided '${type}' storage type is invalid. Fallback into default MEMORY storage.`);
77
+ if (type !== STORAGE_MEMORY) log.error(`The provided '${type}' storage type is invalid. Fallbacking into default MEMORY storage.`);
78
78
  return {
79
79
  type: STORAGE_MEMORY,
80
80
  prefix
@@ -78,7 +78,6 @@ interface ISettings {
78
78
  metricsRefreshRate?: number,
79
79
  telemetryRefreshRate: number,
80
80
  segmentsRefreshRate: number,
81
- largeSegmentsRefreshRate: number,
82
81
  offlineRefreshRate: number,
83
82
  eventsPushRate: number,
84
83
  eventsQueueSize: number,
@@ -88,8 +87,7 @@ interface ISettings {
88
87
  readyTimeout: number,
89
88
  requestTimeoutBeforeReady: number,
90
89
  retriesOnFailureBeforeReady: number,
91
- eventsFirstPushWindow: number,
92
- waitForLargeSegments: boolean
90
+ eventsFirstPushWindow: number
93
91
  },
94
92
  readonly storage: {
95
93
  prefix: string,
@@ -114,8 +112,10 @@ interface ISettings {
114
112
  splitFilters: SplitIO.SplitFilter[],
115
113
  impressionsMode: SplitIO.ImpressionsMode,
116
114
  enabled: boolean,
117
- largeSegmentsEnabled: boolean,
118
- flagSpecVersion: string
115
+ flagSpecVersion: string,
116
+ requestOptions?: {
117
+ getHeaderOverrides?: (context: { headers: Record<string, string> }) => Record<string, string>
118
+ }
119
119
  }
120
120
  /**
121
121
  * User consent status if using in browser. Undefined if using in NodeJS.
@@ -985,13 +985,6 @@ declare namespace SplitIO {
985
985
  * @default 10
986
986
  */
987
987
  eventsFirstPushWindow?: number,
988
- /**
989
- * Whether the SDK should wait for large segments to be ready before emitting SDK_READY event.
990
- * It only applies if largeSegmentsEnabled is true.
991
- * @property {boolean} waitForLargeSegments
992
- * @default true
993
- */
994
- waitForLargeSegments?: boolean
995
988
  },
996
989
  /**
997
990
  * SDK scheduler settings.
@@ -1036,13 +1029,6 @@ declare namespace SplitIO {
1036
1029
  * @default 60
1037
1030
  */
1038
1031
  segmentsRefreshRate?: number,
1039
- /**
1040
- * The SDK polls Split servers for changes to large segment definitions. This parameter controls this polling period in seconds.
1041
- * It only applies if largeSegmentsEnabled is true.
1042
- * @property {number} largeSegmentsRefreshRate
1043
- * @default 60
1044
- */
1045
- largeSegmentsRefreshRate?: number,
1046
1032
  /**
1047
1033
  * The SDK posts the queued events data in bulks. This parameter controls the posting rate in seconds.
1048
1034
  * @property {number} eventsPushRate
@@ -1147,11 +1133,22 @@ declare namespace SplitIO {
1147
1133
  userConsent?: ConsentStatus,
1148
1134
  sync?: ISharedSettings['sync'] & {
1149
1135
  /**
1150
- * Enables synchronization of large segments.
1151
- * @property {boolean} largeSegmentsEnabled
1152
- * @default false
1136
+ * Custom options object for HTTP(S) requests in the Browser.
1137
+ * If provided, this object is merged with the options object passed by the SDK for EventSource and Fetch calls.
1138
+ * @see {@link https://www.npmjs.com/package/node-fetch#options}
1153
1139
  */
1154
- largeSegmentsEnabled?: boolean
1140
+ requestOptions?: {
1141
+ /**
1142
+ * Custom function called before each request, allowing you to add or update custom headers on the SDK HTTP requests.
1143
+ * Some headers are required by the SDK, like 'SplitSDKVersion', and cannot be overridden.
1144
+ * To pass multiple headers with the same name, you can combine them into a single line separated by commas.
1145
+ * Example: `{ 'Authorization': 'value1, value2' }`.
1146
+ *
1147
+ * @property getHeaderOverrides
1148
+ * @default undefined
1149
+ */
1150
+ getHeaderOverrides?: (context: { headers: Record<string, string> }) => Record<string, string>
1151
+ },
1155
1152
  }
1156
1153
  }
1157
1154
  /**
@@ -1202,6 +1199,16 @@ declare namespace SplitIO {
1202
1199
  * @see {@link https://www.npmjs.com/package/node-fetch#options}
1203
1200
  */
1204
1201
  requestOptions?: {
1202
+ /**
1203
+ * Custom function called before each request, allowing you to add or update custom headers on the SDK HTTP requests.
1204
+ * Some headers are required by the SDK, like 'SplitSDKVersion', and cannot be overridden.
1205
+ * To pass multiple headers with the same name, you can combine them into a single line separated by commas.
1206
+ * Example: `{ 'Authorization': 'value1, value2' }`.
1207
+ *
1208
+ * @property getHeaderOverrides
1209
+ * @default undefined
1210
+ */
1211
+ getHeaderOverrides?: (context: { headers: Record<string, string> }) => Record<string, string>
1205
1212
  /**
1206
1213
  * Custom NodeJS HTTP(S) Agent used by the SDK for HTTP(S) requests.
1207
1214
  *