Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release v0.7.0 #79

Merged
merged 11 commits into from
Aug 5, 2024
4 changes: 4 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
0.7.0 (August 5, 2024)
- Added `sync.requestOptions.agent` option to allow passing a custom NodeJS HTTP(S) Agent with specific configurations for the Synchronizer requests, like custom TLS settings or a network proxy (See https://help.split.io/hc/en-us/articles/4421513571469-Split-JavaScript-synchronizer-tools#proxy).
- Updated some transitive dependencies for vulnerability fixes.

0.6.0 (May 13, 2024)
- Added a new configuration option `sync.flagSpecVersion` to specify the flags spec version of feature flag definitions to be fetched and stored.
- Updated @splitsoftware/splitio-commons package to version 1.15.0 that includes minor updates:
Expand Down
58 changes: 29 additions & 29 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@splitsoftware/splitio-sync-tools",
"version": "0.6.0",
"version": "0.7.0",
"description": "Split JavaScript Sync Tools",
"main": "lib/cjs/index.js",
"module": "lib/esm/index.js",
Expand Down Expand Up @@ -51,7 +51,7 @@
"prepublishOnly": "npm run check && npm run test && npm run build"
},
"dependencies": {
"@splitsoftware/splitio-commons": "1.15.0",
"@splitsoftware/splitio-commons": "1.16.0",
"dotenv": "^9.0.1",
"node-fetch": "^2.6.7",
"yargs": "^17.0.1"
Expand Down
10 changes: 8 additions & 2 deletions src/Synchronizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,14 @@ export class Synchronizer {
* The Split's HTTPclient, required to make the requests to the API.
*/
this._splitApi = splitApiFactory(
this.settings,
{ getFetch: Synchronizer._getFetch },
this.settings, // @ts-expect-error
{
getFetch: Synchronizer._getFetch,
getOptions(settings: ISettings) {
// @ts-expect-error
if (settings.sync.requestOptions) return settings.sync.requestOptions;
},
},
telemetryTrackerFactory() // no-op telemetry tracker
);
}
Expand Down
2 changes: 2 additions & 0 deletions src/settings/__tests__/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ describe('synchronizerSettingsValidator', () => {
sync: {
// @ts-expect-error
flagSpecVersion: 'invalid',
requestOptions: { agent: false },
},
storage: { wrapper: {} },
};
Expand All @@ -26,6 +27,7 @@ describe('synchronizerSettingsValidator', () => {
expect(settings.scheduler.impressionsPerPost).toBe(defaults.scheduler.impressionsPerPost);
expect(settings.scheduler.maxRetries).toBe(config.scheduler!.maxRetries);
expect(settings.sync.flagSpecVersion).toBe('1.1');
expect(settings.sync.requestOptions).toBe(config.sync!.requestOptions);
});

});
3 changes: 3 additions & 0 deletions src/settings/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ export function synchronizerSettingsValidator(
// @ts-ignore, override readonly prop
settings.mode = undefined; // "producer" mode

// if provided, keeps reference to the `requestOptions` object
if (settings.sync.requestOptions) settings.sync.requestOptions = config!.sync!.requestOptions;

const { scheduler, log } = settings;

// @TODO validate synchronizerMode eventually
Expand Down
34 changes: 34 additions & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Type definitions for Split JavaScript Sync Tools
// Project: http://www.split.io/
// Definitions by: Emiliano Sanchez <https://github.com/EmilianoSanchez/>
import { RequestOptions } from 'http';

export = JsSyncTools;

Expand Down Expand Up @@ -186,6 +187,39 @@ declare module JsSyncTools {
* @default 'OPTIMIZED'
*/
impressionsMode?: ImpressionsMode
/**
* Custom options object for HTTP(S) requests in NodeJS.
* If provided, this object is merged with the options object passed for Node-Fetch calls.
* @see {@link https://www.npmjs.com/package/node-fetch#options}
*/
requestOptions?: {
/**
* Custom NodeJS HTTP(S) Agent used for HTTP(S) requests.
*
* You can use it, for example, for certificate pinning or setting a network proxy:
*
* ```javascript
* const { HttpsProxyAgent } = require('https-proxy-agent');
*
* const proxyAgent = new HttpsProxyAgent(process.env.HTTPS_PROXY || 'http://10.10.1.10:1080');
*
* const synchronizer = Synchronizer({
* ...
* sync: {
* requestOptions: {
* agent: proxyAgent
* }
* }
* })
* ```
*
* @see {@link https://nodejs.org/api/https.html#class-httpsagent}
*
* @property {http.Agent | https.Agent} agent
* @default undefined
*/
agent?: RequestOptions['agent']
},
}
/**
* Scheduler settings.
Expand Down
Loading