diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index bf623dbb1..d28295fdb 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -81,7 +81,7 @@ jobs: steps: - name: Download assets - uses: actions/download-artifact@v4.1.7 + uses: actions/download-artifact@v3 with: name: assets path: umd @@ -120,7 +120,7 @@ jobs: steps: - name: Download assets - uses: actions/download-artifact@v4.1.7 + uses: actions/download-artifact@v3 with: name: assets path: umd diff --git a/CHANGES.txt b/CHANGES.txt index 2463f5987..d609813a6 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,8 @@ +10.28.0 (September 6, 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. + - Updated some transitive dependencies for vulnerability fixes. + 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. diff --git a/package-lock.json b/package-lock.json index 8405cfce8..c31c65505 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,15 +1,15 @@ { "name": "@splitsoftware/splitio", - "version": "10.27.0", + "version": "10.28.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@splitsoftware/splitio", - "version": "10.27.0", + "version": "10.28.0", "license": "Apache-2.0", "dependencies": { - "@splitsoftware/splitio-commons": "1.16.0", + "@splitsoftware/splitio-commons": "1.17.0", "@types/google.analytics": "0.0.40", "@types/ioredis": "^4.28.0", "bloom-filters": "^3.0.0", @@ -872,9 +872,9 @@ "dev": true }, "node_modules/@splitsoftware/splitio-commons": { - "version": "1.16.0", - "resolved": "https://registry.npmjs.org/@splitsoftware/splitio-commons/-/splitio-commons-1.16.0.tgz", - "integrity": "sha512-k16cCWJOWut/NB5W1d9hQEYPxFrZXO66manp+8d6RjZYH4r+Q6lu82NYjDcfh5E93H9v+TVKcQLAmpVofbjcvg==", + "version": "1.17.0", + "resolved": "https://registry.npmjs.org/@splitsoftware/splitio-commons/-/splitio-commons-1.17.0.tgz", + "integrity": "sha512-rvP+0LGUN92bcTytiqyVxq9UzBG5kTkIYjU7b7AU2awBUYgM0bqT3xhQ9/MJ/2fsBbqC6QIsxoKDOz9pMgbAQw==", "dependencies": { "tslib": "^2.3.1" }, @@ -4671,12 +4671,12 @@ "dev": true }, "node_modules/micromatch": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", - "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", + "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", "dev": true, "dependencies": { - "braces": "^3.0.2", + "braces": "^3.0.3", "picomatch": "^2.3.1" }, "engines": { @@ -8416,9 +8416,9 @@ "dev": true }, "@splitsoftware/splitio-commons": { - "version": "1.16.0", - "resolved": "https://registry.npmjs.org/@splitsoftware/splitio-commons/-/splitio-commons-1.16.0.tgz", - "integrity": "sha512-k16cCWJOWut/NB5W1d9hQEYPxFrZXO66manp+8d6RjZYH4r+Q6lu82NYjDcfh5E93H9v+TVKcQLAmpVofbjcvg==", + "version": "1.17.0", + "resolved": "https://registry.npmjs.org/@splitsoftware/splitio-commons/-/splitio-commons-1.17.0.tgz", + "integrity": "sha512-rvP+0LGUN92bcTytiqyVxq9UzBG5kTkIYjU7b7AU2awBUYgM0bqT3xhQ9/MJ/2fsBbqC6QIsxoKDOz9pMgbAQw==", "requires": { "tslib": "^2.3.1" } @@ -11385,12 +11385,12 @@ "dev": true }, "micromatch": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", - "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", + "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", "dev": true, "requires": { - "braces": "^3.0.2", + "braces": "^3.0.3", "picomatch": "^2.3.1" } }, diff --git a/package.json b/package.json index 4091f4882..ed966a4f2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@splitsoftware/splitio", - "version": "10.27.0", + "version": "10.28.0", "description": "Split SDK", "files": [ "README.md", @@ -40,7 +40,7 @@ "node": ">=6" }, "dependencies": { - "@splitsoftware/splitio-commons": "1.16.0", + "@splitsoftware/splitio-commons": "1.17.0", "@types/google.analytics": "0.0.40", "@types/ioredis": "^4.28.0", "bloom-filters": "^3.0.0", diff --git a/src/settings/defaults/version.js b/src/settings/defaults/version.js index 9974d45bc..271ef6cd7 100644 --- a/src/settings/defaults/version.js +++ b/src/settings/defaults/version.js @@ -1 +1 @@ -export const packageVersion = '10.27.0'; +export const packageVersion = '10.28.0'; diff --git a/ts-tests/index.ts b/ts-tests/index.ts index 9ec3d6d78..a37c52808 100644 --- a/ts-tests/index.ts +++ b/ts-tests/index.ts @@ -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]; @@ -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' }; @@ -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(), } } @@ -666,7 +670,7 @@ let fullAsyncSettings: SplitIO.INodeAsyncSettings = { mode: 'consumer', debug: true, sync: { - splitFilters: splitFilters + splitFilters: splitFilters, } }; diff --git a/types/splitio.d.ts b/types/splitio.d.ts index 949b757cd..bb88476bc 100644 --- a/types/splitio.d.ts +++ b/types/splitio.d.ts @@ -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 }) => Record + } } /** * User consent status if using in browser. Undefined if using in NodeJS. @@ -1126,7 +1130,40 @@ 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 headers in SDK HTTP requests. + * Some headers, such as `SplitSDKVersion`, are required by the SDK and cannot be overridden. + * To pass multiple headers with the same name, combine their values into a single line, separated by commas. Example: `{ 'Authorization': 'value1, value2' }` + * Or provide keys with different case since headers are case-insensitive. Example: `{ 'authorization': 'value1', 'Authorization': 'value2' }` + * + * NOTE: to pass custom headers to the streaming connection in Browser, you should polyfill the `window.EventSource` object with a library that supports headers, + * like https://www.npmjs.com/package/event-source-polyfill, since native EventSource does not support them and will be ignored. + * + * @property getHeaderOverrides + * @default undefined + * + * @param context - The context for the request. + * @param context.headers - The current headers in the request. + * @returns A set of headers to be merged with the current headers. + * + * @example + * const getHeaderOverrides = (context) => { + * return { + * 'Authorization': context.headers['Authorization'] + ', other-value', + * 'custom-header': 'custom-value' + * }; + * }; + */ + getHeaderOverrides?: (context: { headers: Record }) => Record + }, + } } /** * Settings interface for SDK instances created on NodeJS. @@ -1176,6 +1213,28 @@ 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 headers in SDK HTTP requests. + * Some headers, such as `SplitSDKVersion`, are required by the SDK and cannot be overridden. + * To pass multiple headers with the same name, combine their values into a single line, separated by commas. Example: `{ 'Authorization': 'value1, value2' }` + * Or provide keys with different case since headers are case-insensitive. Example: `{ 'authorization': 'value1', 'Authorization': 'value2' }` + * + * @property getHeaderOverrides + * @default undefined + * + * @param context - The context for the request. + * @param context.headers - The current headers in the request. + * @returns A set of headers to be merged with the current headers. + * + * @example + * const getHeaderOverrides = (context) => { + * return { + * 'Authorization': context.headers['Authorization'] + ', other-value', + * 'custom-header': 'custom-value' + * }; + * }; + */ + getHeaderOverrides?: (context: { headers: Record }) => Record /** * Custom NodeJS HTTP(S) Agent used by the SDK for HTTP(S) requests. *