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

[Enhanced SDK headers] Update type definitions #817

Merged
merged 17 commits into from
Sep 6, 2024
Merged
4 changes: 4 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
10.28.0 (August XXX, 2024)
- Updated @splitsoftware/splitio-commons package to version 1.17.0 that includes minor updates:
- Added `sync.requestOptions.getHeaderOverrides` configuration option to enhance SDK HTTP request Headers for Authorization Frameworks.

10.27.0 (June 25, 2024)
- 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).
- Updated some transitive dependencies for vulnerability fixes.
Expand Down
18 changes: 9 additions & 9 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",
"version": "10.27.0",
"version": "10.28.0-rc.1",
"description": "Split SDK",
"files": [
"README.md",
Expand Down Expand Up @@ -40,7 +40,7 @@
"node": ">=6"
},
"dependencies": {
"@splitsoftware/splitio-commons": "1.16.0",
"@splitsoftware/splitio-commons": "1.17.0-rc.1",
"@types/google.analytics": "0.0.40",
"@types/ioredis": "^4.28.0",
"bloom-filters": "^3.0.0",
Expand Down
2 changes: 1 addition & 1 deletion src/settings/defaults/version.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const packageVersion = '10.27.0';
export const packageVersion = '10.28.0-rc.1';
10 changes: 7 additions & 3 deletions ts-tests/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ splitView = {
configs: {
off: '{"dimensions":"{\"height\":20,\"width\":40}"}'
},
sets: ['set_a','set_b'],
sets: ['set_a', 'set_b'],
defaultTreatment: 'off'
};
splitViews = [splitView];
Expand Down Expand Up @@ -565,7 +565,10 @@ let fullBrowserSettings: SplitIO.IBrowserSettings = {
sync: {
splitFilters: splitFilters,
impressionsMode: 'DEBUG',
enabled: true
enabled: true,
requestOptions: {
getHeaderOverrides(context) { return { ...context.headers, 'header': 'value' } },
}
},
userConsent: 'GRANTED'
};
Expand Down Expand Up @@ -618,6 +621,7 @@ let fullNodeSettings: SplitIO.INodeSettings = {
impressionsMode: 'OPTIMIZED',
enabled: true,
requestOptions: {
getHeaderOverrides(context) { return { ...context.headers, 'header': 'value' } },
agent: new (require('https')).Agent(),
}
}
Expand Down Expand Up @@ -666,7 +670,7 @@ let fullAsyncSettings: SplitIO.INodeAsyncSettings = {
mode: 'consumer',
debug: true,
sync: {
splitFilters: splitFilters
splitFilters: splitFilters,
}
};

Expand Down
36 changes: 34 additions & 2 deletions types/splitio.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,11 @@ interface ISettings {
readonly sync: {
splitFilters: SplitIO.SplitFilter[],
impressionsMode: SplitIO.ImpressionsMode,
enabled: boolean
enabled: boolean,
flagSpecVersion: string,
requestOptions?: {
getHeaderOverrides?: (context: { headers: Record<string, string> }) => Record<string, string>
}
}
/**
* User consent status if using in browser. Undefined if using in NodeJS.
Expand Down Expand Up @@ -1126,7 +1130,25 @@ declare namespace SplitIO {
* @typedef {string} userConsent
* @default 'GRANTED'
*/
userConsent?: ConsentStatus
userConsent?: ConsentStatus,
sync?: ISharedSettings['sync'] & {
/**
* Custom options object for HTTP(S) requests in the Browser.
* If provided, this object is merged with the options object passed by the SDK for EventSource and Fetch calls.
*/
requestOptions?: {
/**
* Custom function called before each request, allowing you to add or update custom headers on the SDK HTTP requests.
* Some headers are required by the SDK, like 'SplitSDKVersion', and cannot be overridden.
* To pass multiple headers with the same name, you can combine them into a single line separated by commas.
* Example: `{ 'Authorization': 'value1, value2' }`.
*
* @property getHeaderOverrides
* @default undefined
*/
getHeaderOverrides?: (context: { headers: Record<string, string> }) => Record<string, string>
},
}
}
/**
* Settings interface for SDK instances created on NodeJS.
Expand Down Expand Up @@ -1176,6 +1198,16 @@ declare namespace SplitIO {
* @see {@link https://www.npmjs.com/package/node-fetch#options}
*/
requestOptions?: {
/**
* Custom function called before each request, allowing you to add or update custom headers on the SDK HTTP requests.
* Some headers are required by the SDK, like 'SplitSDKVersion', and cannot be overridden.
* To pass multiple headers with the same name, you can combine them into a single line separated by commas.
* Example: `{ 'Authorization': 'value1, value2' }`.
*
* @property getHeaderOverrides
* @default undefined
*/
getHeaderOverrides?: (context: { headers: Record<string, string> }) => Record<string, string>
/**
* Custom NodeJS HTTP(S) Agent used by the SDK for HTTP(S) requests.
*
Expand Down
Loading