@splitsoftware/splitio 10.18.0 → 10.18.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 +8 -0
- package/es/settings/browser.js +3 -3
- package/es/settings/defaults/version.js +1 -1
- package/es/settings/node.js +3 -3
- package/es/settings/runtime/ip.js +381 -0
- package/es/settings/runtime/node.js +1 -1
- package/lib/settings/browser.js +3 -3
- package/lib/settings/defaults/version.js +1 -1
- package/lib/settings/node.js +5 -5
- package/lib/settings/runtime/ip.js +381 -0
- package/lib/settings/runtime/node.js +1 -1
- package/package.json +3 -4
- package/src/settings/browser.js +4 -3
- package/src/settings/defaults/version.js +1 -1
- package/src/settings/node.js +4 -3
- package/src/settings/runtime/ip.js +433 -0
- package/src/settings/runtime/node.js +1 -1
- package/types/splitio.d.ts +4 -4
package/CHANGES.txt
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
10.18.2 (May 6, 2022)
|
|
2
|
+
- Bugfixing - Removed "ip" dependency to use an inline copy of it that fixes an error when using it in Node v18 (https://github.com/indutny/node-ip/issues/113).
|
|
3
|
+
|
|
4
|
+
10.18.1 (April 20, 2022)
|
|
5
|
+
- Updated some dependencies for vulnerability fixes.
|
|
6
|
+
- Bugfixing - Updated @splitsoftware/splitio-commons package to avoid an error when requiring some third-party dependencies used by the package (Related to issue https://github.com/splitio/javascript-client/issues/662).
|
|
7
|
+
- Bugfixing - Updated `ready` method to rejects the promise with an Error object instead of a string value (Related to issue https://github.com/splitio/javascript-client/issues/654).
|
|
8
|
+
|
|
1
9
|
10.18.0 (April 7, 2022)
|
|
2
10
|
- Added user consent feature to allow delaying or disabling the data tracking from SDK until user consent is explicitly granted or declined. Read more in our docs.
|
|
3
11
|
- Added `scheduler.impressionsQueueSize` property to SDK configuration to limit the amount of impressions tracked in memory. Read more in our docs.
|
package/es/settings/browser.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { settingsValidation } from '@splitsoftware/splitio-commons/esm/utils/settingsValidation';
|
|
2
|
-
import { defaults } from './defaults/browser';
|
|
3
2
|
import { validateRuntime } from '@splitsoftware/splitio-commons/esm/utils/settingsValidation/runtime';
|
|
4
|
-
import { validateStorage } from './storage/browser';
|
|
5
|
-
import { validateIntegrations } from './integrations/browser';
|
|
6
3
|
import { validateLogger } from '@splitsoftware/splitio-commons/esm/utils/settingsValidation/logger/builtinLogger';
|
|
7
4
|
import { LocalhostFromObject } from '@splitsoftware/splitio-commons/esm/sync/offline/LocalhostFromObject';
|
|
8
5
|
import { validateConsent } from '@splitsoftware/splitio-commons/esm/utils/settingsValidation/consent';
|
|
6
|
+
import { defaults } from './defaults/browser';
|
|
7
|
+
import { validateStorage } from './storage/browser';
|
|
8
|
+
import { validateIntegrations } from './integrations/browser';
|
|
9
9
|
var params = {
|
|
10
10
|
defaults: defaults,
|
|
11
11
|
acceptKey: true, acceptTT: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export var packageVersion = '10.18.0';
|
|
1
|
+
export var packageVersion = '10.18.2-rc.0';
|
package/es/settings/node.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { settingsValidation } from '@splitsoftware/splitio-commons/esm/utils/settingsValidation';
|
|
2
|
-
import { defaults } from './defaults/node';
|
|
3
|
-
import { validateRuntime } from './runtime/node';
|
|
4
|
-
import { validateStorage } from './storage/node';
|
|
5
2
|
import { validateLogger } from '@splitsoftware/splitio-commons/esm/utils/settingsValidation/logger/builtinLogger';
|
|
6
3
|
import { LocalhostFromFile } from '@splitsoftware/splitio-commons/esm/sync/offline/LocalhostFromFile';
|
|
4
|
+
import { defaults } from './defaults/node';
|
|
5
|
+
import { validateStorage } from './storage/node';
|
|
6
|
+
import { validateRuntime } from './runtime/node';
|
|
7
7
|
var params = {
|
|
8
8
|
defaults: defaults,
|
|
9
9
|
runtime: validateRuntime,
|
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
/* eslint-disable no-redeclare */
|
|
2
|
+
/*
|
|
3
|
+
Adaptation of "ip" package (https://www.npmjs.com/package/ip) that fixes an error when running in Node v18.
|
|
4
|
+
|
|
5
|
+
This software is licensed under the MIT License.
|
|
6
|
+
|
|
7
|
+
Copyright Fedor Indutny, 2012.
|
|
8
|
+
|
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
14
|
+
*/
|
|
15
|
+
'use strict';
|
|
16
|
+
var ip = exports;
|
|
17
|
+
var Buffer = require('buffer').Buffer;
|
|
18
|
+
var os = require('os');
|
|
19
|
+
ip.toBuffer = function (ip, buff, offset) {
|
|
20
|
+
offset = ~~offset;
|
|
21
|
+
var result;
|
|
22
|
+
if (this.isV4Format(ip)) {
|
|
23
|
+
result = buff || new Buffer(offset + 4);
|
|
24
|
+
ip.split(/\./g).map(function (byte) {
|
|
25
|
+
result[offset++] = parseInt(byte, 10) & 0xff;
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
else if (this.isV6Format(ip)) {
|
|
29
|
+
var sections = ip.split(':', 8);
|
|
30
|
+
var i;
|
|
31
|
+
for (i = 0; i < sections.length; i++) {
|
|
32
|
+
var isv4 = this.isV4Format(sections[i]);
|
|
33
|
+
var v4Buffer;
|
|
34
|
+
if (isv4) {
|
|
35
|
+
v4Buffer = this.toBuffer(sections[i]);
|
|
36
|
+
sections[i] = v4Buffer.slice(0, 2).toString('hex');
|
|
37
|
+
}
|
|
38
|
+
if (v4Buffer && ++i < 8) {
|
|
39
|
+
sections.splice(i, 0, v4Buffer.slice(2, 4).toString('hex'));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (sections[0] === '') {
|
|
43
|
+
while (sections.length < 8)
|
|
44
|
+
sections.unshift('0');
|
|
45
|
+
}
|
|
46
|
+
else if (sections[sections.length - 1] === '') {
|
|
47
|
+
while (sections.length < 8)
|
|
48
|
+
sections.push('0');
|
|
49
|
+
}
|
|
50
|
+
else if (sections.length < 8) {
|
|
51
|
+
for (i = 0; i < sections.length && sections[i] !== ''; i++)
|
|
52
|
+
;
|
|
53
|
+
var argv = [i, 1];
|
|
54
|
+
for (i = 9 - sections.length; i > 0; i--) {
|
|
55
|
+
argv.push('0');
|
|
56
|
+
}
|
|
57
|
+
sections.splice.apply(sections, argv);
|
|
58
|
+
}
|
|
59
|
+
result = buff || new Buffer(offset + 16);
|
|
60
|
+
for (i = 0; i < sections.length; i++) {
|
|
61
|
+
var word = parseInt(sections[i], 16);
|
|
62
|
+
result[offset++] = (word >> 8) & 0xff;
|
|
63
|
+
result[offset++] = word & 0xff;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (!result) {
|
|
67
|
+
throw Error('Invalid ip address: ' + ip);
|
|
68
|
+
}
|
|
69
|
+
return result;
|
|
70
|
+
};
|
|
71
|
+
ip.toString = function (buff, offset, length) {
|
|
72
|
+
offset = ~~offset;
|
|
73
|
+
length = length || (buff.length - offset);
|
|
74
|
+
var result = [];
|
|
75
|
+
if (length === 4) {
|
|
76
|
+
// IPv4
|
|
77
|
+
for (var i = 0; i < length; i++) {
|
|
78
|
+
result.push(buff[offset + i]);
|
|
79
|
+
}
|
|
80
|
+
result = result.join('.');
|
|
81
|
+
}
|
|
82
|
+
else if (length === 16) {
|
|
83
|
+
// IPv6
|
|
84
|
+
for (var i = 0; i < length; i += 2) {
|
|
85
|
+
result.push(buff.readUInt16BE(offset + i).toString(16));
|
|
86
|
+
}
|
|
87
|
+
result = result.join(':');
|
|
88
|
+
result = result.replace(/(^|:)0(:0)*:0(:|$)/, '$1::$3');
|
|
89
|
+
result = result.replace(/:{3,4}/, '::');
|
|
90
|
+
}
|
|
91
|
+
return result;
|
|
92
|
+
};
|
|
93
|
+
var ipv4Regex = /^(\d{1,3}\.){3,3}\d{1,3}$/;
|
|
94
|
+
var ipv6Regex = /^(::)?(((\d{1,3}\.){3}(\d{1,3}){1})?([0-9a-f]){0,4}:{0,2}){1,8}(::)?$/i;
|
|
95
|
+
ip.isV4Format = function (ip) {
|
|
96
|
+
return ipv4Regex.test(ip);
|
|
97
|
+
};
|
|
98
|
+
ip.isV6Format = function (ip) {
|
|
99
|
+
return ipv6Regex.test(ip);
|
|
100
|
+
};
|
|
101
|
+
function _resolveFamily(family) {
|
|
102
|
+
return typeof family === 'number' ? 'ipv' + family : family.toLowerCase();
|
|
103
|
+
}
|
|
104
|
+
function _normalizeFamily(family) {
|
|
105
|
+
return family ? _resolveFamily(family) : 'ipv4';
|
|
106
|
+
}
|
|
107
|
+
ip.fromPrefixLen = function (prefixlen, family) {
|
|
108
|
+
if (prefixlen > 32) {
|
|
109
|
+
family = 'ipv6';
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
family = _normalizeFamily(family);
|
|
113
|
+
}
|
|
114
|
+
var len = 4;
|
|
115
|
+
if (family === 'ipv6') {
|
|
116
|
+
len = 16;
|
|
117
|
+
}
|
|
118
|
+
var buff = new Buffer(len);
|
|
119
|
+
for (var i = 0, n = buff.length; i < n; ++i) {
|
|
120
|
+
var bits = 8;
|
|
121
|
+
if (prefixlen < 8) {
|
|
122
|
+
bits = prefixlen;
|
|
123
|
+
}
|
|
124
|
+
prefixlen -= bits;
|
|
125
|
+
buff[i] = ~(0xff >> bits) & 0xff;
|
|
126
|
+
}
|
|
127
|
+
return ip.toString(buff);
|
|
128
|
+
};
|
|
129
|
+
ip.mask = function (addr, mask) {
|
|
130
|
+
addr = ip.toBuffer(addr);
|
|
131
|
+
mask = ip.toBuffer(mask);
|
|
132
|
+
var result = new Buffer(Math.max(addr.length, mask.length));
|
|
133
|
+
var i = 0;
|
|
134
|
+
// Same protocol - do bitwise and
|
|
135
|
+
if (addr.length === mask.length) {
|
|
136
|
+
for (i = 0; i < addr.length; i++) {
|
|
137
|
+
result[i] = addr[i] & mask[i];
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
else if (mask.length === 4) {
|
|
141
|
+
// IPv6 address and IPv4 mask
|
|
142
|
+
// (Mask low bits)
|
|
143
|
+
for (i = 0; i < mask.length; i++) {
|
|
144
|
+
result[i] = addr[addr.length - 4 + i] & mask[i];
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
// IPv6 mask and IPv4 addr
|
|
149
|
+
for (var i = 0; i < result.length - 6; i++) {
|
|
150
|
+
result[i] = 0;
|
|
151
|
+
}
|
|
152
|
+
// ::ffff:ipv4
|
|
153
|
+
result[10] = 0xff;
|
|
154
|
+
result[11] = 0xff;
|
|
155
|
+
for (i = 0; i < addr.length; i++) {
|
|
156
|
+
result[i + 12] = addr[i] & mask[i + 12];
|
|
157
|
+
}
|
|
158
|
+
i = i + 12;
|
|
159
|
+
}
|
|
160
|
+
for (; i < result.length; i++)
|
|
161
|
+
result[i] = 0;
|
|
162
|
+
return ip.toString(result);
|
|
163
|
+
};
|
|
164
|
+
ip.cidr = function (cidrString) {
|
|
165
|
+
var cidrParts = cidrString.split('/');
|
|
166
|
+
var addr = cidrParts[0];
|
|
167
|
+
if (cidrParts.length !== 2)
|
|
168
|
+
throw new Error('invalid CIDR subnet: ' + addr);
|
|
169
|
+
var mask = ip.fromPrefixLen(parseInt(cidrParts[1], 10));
|
|
170
|
+
return ip.mask(addr, mask);
|
|
171
|
+
};
|
|
172
|
+
ip.subnet = function (addr, mask) {
|
|
173
|
+
var networkAddress = ip.toLong(ip.mask(addr, mask));
|
|
174
|
+
// Calculate the mask's length.
|
|
175
|
+
var maskBuffer = ip.toBuffer(mask);
|
|
176
|
+
var maskLength = 0;
|
|
177
|
+
for (var i = 0; i < maskBuffer.length; i++) {
|
|
178
|
+
if (maskBuffer[i] === 0xff) {
|
|
179
|
+
maskLength += 8;
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
var octet = maskBuffer[i] & 0xff;
|
|
183
|
+
while (octet) {
|
|
184
|
+
octet = (octet << 1) & 0xff;
|
|
185
|
+
maskLength++;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
var numberOfAddresses = Math.pow(2, 32 - maskLength);
|
|
190
|
+
return {
|
|
191
|
+
networkAddress: ip.fromLong(networkAddress),
|
|
192
|
+
firstAddress: numberOfAddresses <= 2 ?
|
|
193
|
+
ip.fromLong(networkAddress) :
|
|
194
|
+
ip.fromLong(networkAddress + 1),
|
|
195
|
+
lastAddress: numberOfAddresses <= 2 ?
|
|
196
|
+
ip.fromLong(networkAddress + numberOfAddresses - 1) :
|
|
197
|
+
ip.fromLong(networkAddress + numberOfAddresses - 2),
|
|
198
|
+
broadcastAddress: ip.fromLong(networkAddress + numberOfAddresses - 1),
|
|
199
|
+
subnetMask: mask,
|
|
200
|
+
subnetMaskLength: maskLength,
|
|
201
|
+
numHosts: numberOfAddresses <= 2 ?
|
|
202
|
+
numberOfAddresses : numberOfAddresses - 2,
|
|
203
|
+
length: numberOfAddresses,
|
|
204
|
+
contains: function (other) {
|
|
205
|
+
return networkAddress === ip.toLong(ip.mask(other, mask));
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
};
|
|
209
|
+
ip.cidrSubnet = function (cidrString) {
|
|
210
|
+
var cidrParts = cidrString.split('/');
|
|
211
|
+
var addr = cidrParts[0];
|
|
212
|
+
if (cidrParts.length !== 2)
|
|
213
|
+
throw new Error('invalid CIDR subnet: ' + addr);
|
|
214
|
+
var mask = ip.fromPrefixLen(parseInt(cidrParts[1], 10));
|
|
215
|
+
return ip.subnet(addr, mask);
|
|
216
|
+
};
|
|
217
|
+
ip.not = function (addr) {
|
|
218
|
+
var buff = ip.toBuffer(addr);
|
|
219
|
+
for (var i = 0; i < buff.length; i++) {
|
|
220
|
+
buff[i] = 0xff ^ buff[i];
|
|
221
|
+
}
|
|
222
|
+
return ip.toString(buff);
|
|
223
|
+
};
|
|
224
|
+
ip.or = function (a, b) {
|
|
225
|
+
a = ip.toBuffer(a);
|
|
226
|
+
b = ip.toBuffer(b);
|
|
227
|
+
// same protocol
|
|
228
|
+
if (a.length === b.length) {
|
|
229
|
+
for (var i = 0; i < a.length; ++i) {
|
|
230
|
+
a[i] |= b[i];
|
|
231
|
+
}
|
|
232
|
+
return ip.toString(a);
|
|
233
|
+
// mixed protocols
|
|
234
|
+
}
|
|
235
|
+
else {
|
|
236
|
+
var buff = a;
|
|
237
|
+
var other = b;
|
|
238
|
+
if (b.length > a.length) {
|
|
239
|
+
buff = b;
|
|
240
|
+
other = a;
|
|
241
|
+
}
|
|
242
|
+
var offset = buff.length - other.length;
|
|
243
|
+
for (var i = offset; i < buff.length; ++i) {
|
|
244
|
+
buff[i] |= other[i - offset];
|
|
245
|
+
}
|
|
246
|
+
return ip.toString(buff);
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
ip.isEqual = function (a, b) {
|
|
250
|
+
a = ip.toBuffer(a);
|
|
251
|
+
b = ip.toBuffer(b);
|
|
252
|
+
// Same protocol
|
|
253
|
+
if (a.length === b.length) {
|
|
254
|
+
for (var i = 0; i < a.length; i++) {
|
|
255
|
+
if (a[i] !== b[i])
|
|
256
|
+
return false;
|
|
257
|
+
}
|
|
258
|
+
return true;
|
|
259
|
+
}
|
|
260
|
+
// Swap
|
|
261
|
+
if (b.length === 4) {
|
|
262
|
+
var t = b;
|
|
263
|
+
b = a;
|
|
264
|
+
a = t;
|
|
265
|
+
}
|
|
266
|
+
// a - IPv4, b - IPv6
|
|
267
|
+
for (var i = 0; i < 10; i++) {
|
|
268
|
+
if (b[i] !== 0)
|
|
269
|
+
return false;
|
|
270
|
+
}
|
|
271
|
+
var word = b.readUInt16BE(10);
|
|
272
|
+
if (word !== 0 && word !== 0xffff)
|
|
273
|
+
return false;
|
|
274
|
+
for (var i = 0; i < 4; i++) {
|
|
275
|
+
if (a[i] !== b[i + 12])
|
|
276
|
+
return false;
|
|
277
|
+
}
|
|
278
|
+
return true;
|
|
279
|
+
};
|
|
280
|
+
ip.isPrivate = function (addr) {
|
|
281
|
+
return /^(::f{4}:)?10\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/i
|
|
282
|
+
.test(addr) ||
|
|
283
|
+
/^(::f{4}:)?192\.168\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(addr) ||
|
|
284
|
+
/^(::f{4}:)?172\.(1[6-9]|2\d|30|31)\.([0-9]{1,3})\.([0-9]{1,3})$/i
|
|
285
|
+
.test(addr) ||
|
|
286
|
+
/^(::f{4}:)?127\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(addr) ||
|
|
287
|
+
/^(::f{4}:)?169\.254\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(addr) ||
|
|
288
|
+
/^f[cd][0-9a-f]{2}:/i.test(addr) ||
|
|
289
|
+
/^fe80:/i.test(addr) ||
|
|
290
|
+
/^::1$/.test(addr) ||
|
|
291
|
+
/^::$/.test(addr);
|
|
292
|
+
};
|
|
293
|
+
ip.isPublic = function (addr) {
|
|
294
|
+
return !ip.isPrivate(addr);
|
|
295
|
+
};
|
|
296
|
+
ip.isLoopback = function (addr) {
|
|
297
|
+
return /^(::f{4}:)?127\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})/
|
|
298
|
+
.test(addr) ||
|
|
299
|
+
/^fe80::1$/.test(addr) ||
|
|
300
|
+
/^::1$/.test(addr) ||
|
|
301
|
+
/^::$/.test(addr);
|
|
302
|
+
};
|
|
303
|
+
ip.loopback = function (family) {
|
|
304
|
+
//
|
|
305
|
+
// Default to `ipv4`
|
|
306
|
+
//
|
|
307
|
+
family = _normalizeFamily(family);
|
|
308
|
+
if (family !== 'ipv4' && family !== 'ipv6') {
|
|
309
|
+
throw new Error('family must be ipv4 or ipv6');
|
|
310
|
+
}
|
|
311
|
+
return family === 'ipv4' ? '127.0.0.1' : 'fe80::1';
|
|
312
|
+
};
|
|
313
|
+
//
|
|
314
|
+
// ### function address (name, family)
|
|
315
|
+
// #### @name {string|'public'|'private'} **Optional** Name or security
|
|
316
|
+
// of the network interface.
|
|
317
|
+
// #### @family {ipv4|ipv6} **Optional** IP family of the address (defaults
|
|
318
|
+
// to ipv4).
|
|
319
|
+
//
|
|
320
|
+
// Returns the address for the network interface on the current system with
|
|
321
|
+
// the specified `name`:
|
|
322
|
+
// * String: First `family` address of the interface.
|
|
323
|
+
// If not found see `undefined`.
|
|
324
|
+
// * 'public': the first public ip address of family.
|
|
325
|
+
// * 'private': the first private ip address of family.
|
|
326
|
+
// * undefined: First address with `ipv4` or loopback address `127.0.0.1`.
|
|
327
|
+
//
|
|
328
|
+
ip.address = function (name, family) {
|
|
329
|
+
var interfaces = os.networkInterfaces();
|
|
330
|
+
var all;
|
|
331
|
+
//
|
|
332
|
+
// Default to `ipv4`
|
|
333
|
+
//
|
|
334
|
+
family = _normalizeFamily(family);
|
|
335
|
+
//
|
|
336
|
+
// If a specific network interface has been named,
|
|
337
|
+
// return the address.
|
|
338
|
+
//
|
|
339
|
+
if (name && name !== 'private' && name !== 'public') {
|
|
340
|
+
var res = interfaces[name].filter(function (details) {
|
|
341
|
+
var itemFamily = _resolveFamily(details.family);
|
|
342
|
+
return itemFamily === family;
|
|
343
|
+
});
|
|
344
|
+
if (res.length === 0)
|
|
345
|
+
return undefined;
|
|
346
|
+
return res[0].address;
|
|
347
|
+
}
|
|
348
|
+
var all = Object.keys(interfaces).map(function (nic) {
|
|
349
|
+
//
|
|
350
|
+
// Note: name will only be `public` or `private`
|
|
351
|
+
// when this is called.
|
|
352
|
+
//
|
|
353
|
+
var addresses = interfaces[nic].filter(function (details) {
|
|
354
|
+
details.family = _resolveFamily(details.family);
|
|
355
|
+
if (details.family !== family || ip.isLoopback(details.address)) {
|
|
356
|
+
return false;
|
|
357
|
+
}
|
|
358
|
+
else if (!name) {
|
|
359
|
+
return true;
|
|
360
|
+
}
|
|
361
|
+
return name === 'public' ? ip.isPrivate(details.address) :
|
|
362
|
+
ip.isPublic(details.address);
|
|
363
|
+
});
|
|
364
|
+
return addresses.length ? addresses[0].address : undefined;
|
|
365
|
+
}).filter(Boolean);
|
|
366
|
+
return !all.length ? ip.loopback(family) : all[0];
|
|
367
|
+
};
|
|
368
|
+
ip.toLong = function (ip) {
|
|
369
|
+
var ipl = 0;
|
|
370
|
+
ip.split('.').forEach(function (octet) {
|
|
371
|
+
ipl <<= 8;
|
|
372
|
+
ipl += parseInt(octet);
|
|
373
|
+
});
|
|
374
|
+
return (ipl >>> 0);
|
|
375
|
+
};
|
|
376
|
+
ip.fromLong = function (ipl) {
|
|
377
|
+
return ((ipl >>> 24) + '.' +
|
|
378
|
+
(ipl >> 16 & 255) + '.' +
|
|
379
|
+
(ipl >> 8 & 255) + '.' +
|
|
380
|
+
(ipl & 255));
|
|
381
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import osFunction from 'os';
|
|
2
|
-
import ipFunction from 'ip';
|
|
2
|
+
import ipFunction from './ip';
|
|
3
3
|
import { UNKNOWN, NA, CONSUMER_MODE } from '@splitsoftware/splitio-commons/esm/utils/constants';
|
|
4
4
|
export function validateRuntime(settings) {
|
|
5
5
|
var isIPAddressesEnabled = settings.core.IPAddressesEnabled === true;
|
package/lib/settings/browser.js
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.settingsFactory = void 0;
|
|
4
4
|
var settingsValidation_1 = require("@splitsoftware/splitio-commons/cjs/utils/settingsValidation");
|
|
5
|
-
var browser_1 = require("./defaults/browser");
|
|
6
5
|
var runtime_1 = require("@splitsoftware/splitio-commons/cjs/utils/settingsValidation/runtime");
|
|
7
|
-
var browser_2 = require("./storage/browser");
|
|
8
|
-
var browser_3 = require("./integrations/browser");
|
|
9
6
|
var builtinLogger_1 = require("@splitsoftware/splitio-commons/cjs/utils/settingsValidation/logger/builtinLogger");
|
|
10
7
|
var LocalhostFromObject_1 = require("@splitsoftware/splitio-commons/cjs/sync/offline/LocalhostFromObject");
|
|
11
8
|
var consent_1 = require("@splitsoftware/splitio-commons/cjs/utils/settingsValidation/consent");
|
|
9
|
+
var browser_1 = require("./defaults/browser");
|
|
10
|
+
var browser_2 = require("./storage/browser");
|
|
11
|
+
var browser_3 = require("./integrations/browser");
|
|
12
12
|
var params = {
|
|
13
13
|
defaults: browser_1.defaults,
|
|
14
14
|
acceptKey: true, acceptTT: true,
|
package/lib/settings/node.js
CHANGED
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.settingsFactory = void 0;
|
|
4
4
|
var settingsValidation_1 = require("@splitsoftware/splitio-commons/cjs/utils/settingsValidation");
|
|
5
|
-
var node_1 = require("./defaults/node");
|
|
6
|
-
var node_2 = require("./runtime/node");
|
|
7
|
-
var node_3 = require("./storage/node");
|
|
8
5
|
var builtinLogger_1 = require("@splitsoftware/splitio-commons/cjs/utils/settingsValidation/logger/builtinLogger");
|
|
9
6
|
var LocalhostFromFile_1 = require("@splitsoftware/splitio-commons/cjs/sync/offline/LocalhostFromFile");
|
|
7
|
+
var node_1 = require("./defaults/node");
|
|
8
|
+
var node_2 = require("./storage/node");
|
|
9
|
+
var node_3 = require("./runtime/node");
|
|
10
10
|
var params = {
|
|
11
11
|
defaults: node_1.defaults,
|
|
12
|
-
runtime:
|
|
13
|
-
storage:
|
|
12
|
+
runtime: node_3.validateRuntime,
|
|
13
|
+
storage: node_2.validateStorage,
|
|
14
14
|
logger: builtinLogger_1.validateLogger,
|
|
15
15
|
localhost: function () { return (0, LocalhostFromFile_1.LocalhostFromFile)(); },
|
|
16
16
|
consent: function () { return undefined; }, // resets settings.userConsent to the default
|