@statsig/statsig-node-core 0.2.2-beta.250428 → 0.2.2-beta.3

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/index.js CHANGED
@@ -28,32 +28,52 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.Statsig = void 0;
30
30
  const node_fetch_1 = __importDefault(require("node-fetch"));
31
+ const https_proxy_agent_1 = require("https-proxy-agent");
31
32
  const error_boundary_1 = require("./error_boundary");
32
33
  const statsig_generated_1 = require("./statsig-generated");
33
34
  __exportStar(require("./statsig-generated"), exports);
34
- const FETCH_FUNC = (method, url, headers, body) => __awaiter(void 0, void 0, void 0, function* () {
35
- try {
36
- const res = yield (0, node_fetch_1.default)(url, {
37
- method,
38
- headers,
39
- body: body ? Buffer.from(body) : undefined,
40
- });
41
- const data = yield res.arrayBuffer();
42
- return {
43
- status: res.status,
44
- data: Array.from(new Uint8Array(data)),
45
- };
35
+ function createProxyAgent(options) {
36
+ const proxy = options === null || options === void 0 ? void 0 : options.proxyConfig;
37
+ if ((proxy === null || proxy === void 0 ? void 0 : proxy.proxyHost) && (proxy === null || proxy === void 0 ? void 0 : proxy.proxyProtocol)) {
38
+ const protocol = proxy.proxyProtocol;
39
+ const host = proxy.proxyHost;
40
+ const port = proxy.proxyPort ? `:${proxy.proxyPort}` : '';
41
+ const auth = proxy.proxyAuth ? `${proxy.proxyAuth}@` : '';
42
+ const proxyUrl = `${protocol}://${auth}${host}${port}`;
43
+ if (protocol === 'http' || protocol === 'https') {
44
+ return new https_proxy_agent_1.HttpsProxyAgent(proxyUrl);
45
+ }
46
46
  }
47
- catch (err) {
48
- return {
49
- status: 0,
50
- error: 'message' in err ? err.message : 'Unknown Node Fetch Error',
51
- };
52
- }
53
- });
47
+ return undefined; // node-fetch agent parameter takes in undefined type instead of null
48
+ }
49
+ function createFetchFunc(options) {
50
+ const proxyAgent = createProxyAgent(options);
51
+ return (method, url, headers, body) => __awaiter(this, void 0, void 0, function* () {
52
+ try {
53
+ const res = yield (0, node_fetch_1.default)(url, {
54
+ method,
55
+ headers,
56
+ body: body ? Buffer.from(body) : undefined,
57
+ agent: proxyAgent,
58
+ });
59
+ const data = yield res.arrayBuffer();
60
+ return {
61
+ status: res.status,
62
+ data: Array.from(new Uint8Array(data)),
63
+ };
64
+ }
65
+ catch (err) {
66
+ return {
67
+ status: 0,
68
+ error: 'message' in err ? err.message : 'Unknown Node Fetch Error',
69
+ };
70
+ }
71
+ });
72
+ }
54
73
  class Statsig extends statsig_generated_1.StatsigNapiInternal {
55
74
  constructor(sdkKey, options) {
56
- super(FETCH_FUNC, sdkKey, options);
75
+ const fetchFunc = createFetchFunc(options);
76
+ super(fetchFunc, sdkKey, options);
57
77
  error_boundary_1.ErrorBoundary.wrap(this);
58
78
  }
59
79
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@statsig/statsig-node-core",
3
- "version": "0.2.2-beta.250428",
3
+ "version": "0.2.2-beta.3",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "jest --colors",
@@ -11,6 +11,7 @@
11
11
  "license": "ISC",
12
12
  "description": "",
13
13
  "dependencies": {
14
+ "https-proxy-agent": "^7.0.6",
14
15
  "node-fetch": "2.7.0"
15
16
  },
16
17
  "devDependencies": {
@@ -44,13 +45,13 @@
44
45
  ]
45
46
  },
46
47
  "optionalDependencies": {
47
- "@statsig/statsig-node-core-linux-x64-musl": "0.2.2-beta.250428",
48
- "@statsig/statsig-node-core-linux-x64-gnu": "0.2.2-beta.250428",
49
- "@statsig/statsig-node-core-win32-x64-msvc": "0.2.2-beta.250428",
50
- "@statsig/statsig-node-core-darwin-x64": "0.2.2-beta.250428",
51
- "@statsig/statsig-node-core-win32-ia32-msvc": "0.2.2-beta.250428",
52
- "@statsig/statsig-node-core-linux-arm64-musl": "0.2.2-beta.250428",
53
- "@statsig/statsig-node-core-linux-arm64-gnu": "0.2.2-beta.250428",
54
- "@statsig/statsig-node-core-darwin-arm64": "0.2.2-beta.250428"
48
+ "@statsig/statsig-node-core-linux-x64-musl": "0.2.2-beta.3",
49
+ "@statsig/statsig-node-core-linux-x64-gnu": "0.2.2-beta.3",
50
+ "@statsig/statsig-node-core-win32-x64-msvc": "0.2.2-beta.3",
51
+ "@statsig/statsig-node-core-darwin-x64": "0.2.2-beta.3",
52
+ "@statsig/statsig-node-core-win32-ia32-msvc": "0.2.2-beta.3",
53
+ "@statsig/statsig-node-core-linux-arm64-musl": "0.2.2-beta.3",
54
+ "@statsig/statsig-node-core-linux-arm64-gnu": "0.2.2-beta.3",
55
+ "@statsig/statsig-node-core-darwin-arm64": "0.2.2-beta.3"
55
56
  }
56
57
  }
@@ -186,6 +186,13 @@ export interface ParameterStoreEvaluationOptions {
186
186
  disableExposureLogging?: boolean
187
187
  }
188
188
 
189
+ export interface ProxyConfig {
190
+ proxyHost?: string
191
+ proxyPort?: number
192
+ proxyAuth?: string
193
+ proxyProtocol?: string
194
+ }
195
+
189
196
  export interface SecondaryExposure {
190
197
  gate: string
191
198
  gateValue: string
@@ -223,6 +230,7 @@ export interface StatsigOptions {
223
230
  specsUrl?: string
224
231
  waitForCountryLookupInit?: boolean
225
232
  waitForUserAgentInit?: boolean
233
+ proxyConfig?: ProxyConfig
226
234
  }
227
235
 
228
236
  export interface StatsigResult {