Skip to content

Commit

Permalink
Merge pull request #267 from splitio/fix_sdk_key_validation
Browse files Browse the repository at this point in the history
Update SDK key validation in NodeJS
  • Loading branch information
EmilianoSanchez authored Nov 3, 2023
2 parents f3b4de8 + 0247602 commit ab50d43
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- Added a new optional Split Filter configuration option. This allows the SDK and Split services to only synchronize the flags in the specified flag sets, avoiding unused or unwanted flags from being synced on the SDK instance, bringing all the benefits from a reduced payload.
- Note: Only applicable when the SDK is in charge of the rollout data synchronization. When not applicable, the SDK will log a warning on init.
- Added `sets` property to the `SplitView` object returned by the `split` and `splits` methods of the SDK manager to expose flag sets on flag views.
- Bugfixing - Fixed SDK key validation in NodeJS to ensure the SDK_READY_TIMED_OUT event is emitted when a client-side type SDK key is provided instead of a server-side one (Related to issue https://github.com/splitio/javascript-client/issues/768).

1.10.0 (October 20, 2023)
- Added `defaultTreatment` property to the `SplitView` object returned by the `split` and `splits` methods of the SDK manager (Related to issue https://github.com/splitio/javascript-commons/issues/225).
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@splitsoftware/splitio-commons",
"version": "1.10.1-rc.3",
"version": "1.10.1-rc.4",
"description": "Split Javascript SDK common components",
"main": "cjs/index.js",
"module": "esm/index.js",
Expand Down
5 changes: 5 additions & 0 deletions src/readiness/readinessManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,12 @@ export function readinessManagerFactory(
return readinessManagerFactory(EventEmitter, readyTimeout, splits);
},

// @TODO review/remove next methods when non-recoverable errors are reworked
// Called on consumer mode, when storage fails to connect
timeout,
// Called on 403 error (client-side SDK key on server-side), to set the SDK as destroyed for
// tracking and evaluations, while keeping event listeners to emit SDK_READY_TIMED_OUT event
setDestroyed() { isDestroyed = true; },

destroy() {
isDestroyed = true;
Expand Down
1 change: 1 addition & 0 deletions src/readiness/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export interface IReadinessManager {
isOperational(): boolean,

timeout(): void,
setDestroyed(): void,
destroy(): void,

/** for client-side */
Expand Down
2 changes: 1 addition & 1 deletion src/sync/polling/updaters/segmentChangesUpdater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export function segmentChangesUpdaterFactory(
if (error && error.statusCode === 403) {
// If the operation is forbidden, it may be due to permissions. Destroy the SDK instance.
// @TODO although factory status is destroyed, synchronization is not stopped
if (readiness) readiness.destroy();
if (readiness) readiness.setDestroyed();
log.error(`${LOG_PREFIX_INSTANTIATION}: you passed a client-side type authorizationKey, please grab an SDK Key from the Split user interface that is of type server-side.`);
} else {
log.warn(`${LOG_PREFIX_SYNC_SEGMENTS}Error while doing fetch of segments. ${error}`);
Expand Down

0 comments on commit ab50d43

Please sign in to comment.