Skip to content

Commit 8646f48

Browse files
typottergreghuels
andauthored
chore: update to latest common. (#179)
* chore: bump @eppo/js-client-sdk-common to 4.12.0 * chore: set format metadata where needed, lint * tests * yarn lock * docs --------- Co-authored-by: Greg Huels <[email protected]>
1 parent 5b317da commit 8646f48

File tree

7 files changed

+41
-26
lines changed

7 files changed

+41
-26
lines changed

docs/js-client-sdk.eppojsclient.instance.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44

55
## EppoJSClient.instance property
66

7-
@<!-- -->deprecated. use `getInstance()` instead.
7+
> Warning: This API is now obsolete.
8+
>
9+
> use `getInstance()` instead.
10+
>
811
912
**Signature:**
1013

docs/js-client-sdk.eppojsclient.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,6 @@ boolean
7272
7373
</td><td>
7474
75-
@<!-- -->deprecated. use `getInstance()` instead.
76-
7775
7876
</td></tr>
7977
</tbody></table>

js-client-sdk.api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ export class EppoJSClient extends EppoClient {
8888
init(config: Omit<IClientConfig, 'forceReinitialize'>): Promise<EppoJSClient>;
8989
// (undocumented)
9090
static initialized: boolean;
91+
// @deprecated (undocumented)
9192
static instance: EppoJSClient;
9293
// @internal (undocumented)
9394
offlineInit(config: IClientConfigSync): void;

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@eppo/js-client-sdk",
3-
"version": "3.11.0",
3+
"version": "3.12.0",
44
"description": "Eppo SDK for client-side JavaScript applications",
55
"main": "dist/index.js",
66
"files": [
@@ -60,7 +60,7 @@
6060
"webpack-cli": "^6.0.1"
6161
},
6262
"dependencies": {
63-
"@eppo/js-client-sdk-common": "4.10.0"
63+
"@eppo/js-client-sdk-common": "4.12.0"
6464
},
6565
"packageManager": "[email protected]+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
6666
}

src/index.spec.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
constants,
1111
EppoClient,
1212
Flag,
13+
FormatEnum,
1314
HybridConfigurationStore,
1415
IAsyncStore,
1516
IPrecomputedConfigurationResponse,
@@ -184,7 +185,7 @@ describe('EppoJSClient E2E test', () => {
184185

185186
beforeAll(async () => {
186187
global.fetch = jest.fn(() => {
187-
const ufc = readMockUfcResponse(MOCK_UFC_RESPONSE_FILE);
188+
const ufc = readMockUfcResponse(OBFUSCATED_MOCK_UFC_RESPONSE_FILE);
188189

189190
return Promise.resolve({
190191
ok: true,
@@ -416,6 +417,7 @@ describe('initialization options', () => {
416417

417418
const maxRetryDelay = DEFAULT_POLL_INTERVAL_MS * POLL_JITTER_PCT;
418419
const mockConfigResponse = {
420+
format: FormatEnum.CLIENT,
419421
flags: {
420422
[obfuscatedFlagKey]: mockObfuscatedUfcFlagConfig,
421423
},
@@ -1015,6 +1017,7 @@ describe('initialization options', () => {
10151017
status: 200,
10161018
json: () =>
10171019
Promise.resolve({
1020+
format: 'CLIENT',
10181021
flags: {
10191022
[md5Hash(flagKey)]: mockObfuscatedUfcFlagConfig,
10201023
},

src/index.ts

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,25 @@ import {
44
AttributeType,
55
BanditActions,
66
BanditSubjectAttributes,
7+
BoundedEventQueue,
78
EppoClient,
9+
EppoPrecomputedClient,
10+
Event,
811
EventDispatcher,
912
Flag,
1013
FlagConfigurationRequestParameters,
14+
FormatEnum,
1115
IAssignmentDetails,
1216
IAssignmentLogger,
17+
IBanditLogger,
18+
IConfigurationWire,
1319
IContainerExperiment,
14-
EppoPrecomputedClient,
15-
PrecomputedFlagsRequestParameters,
20+
IObfuscatedPrecomputedConfigurationResponse,
1621
newDefaultEventDispatcher,
1722
ObfuscatedFlag,
18-
BoundedEventQueue,
19-
validation,
20-
Event,
21-
IConfigurationWire,
23+
PrecomputedFlagsRequestParameters,
2224
Subject,
23-
IBanditLogger,
24-
IObfuscatedPrecomputedConfigurationResponse,
25+
validation,
2526
} from '@eppo/js-client-sdk-common';
2627

2728
import { assignmentCacheFactory } from './cache/assignment-cache-factory';
@@ -35,12 +36,12 @@ import {
3536
import {
3637
chromeStorageIfAvailable,
3738
configurationStorageFactory,
38-
precomputedFlagsStorageFactory,
3939
hasChromeStorage,
4040
hasWindowLocalStorage,
4141
localStorageIfAvailable,
42-
precomputedBanditStoreFactory,
4342
overrideStorageFactory,
43+
precomputedBanditStoreFactory,
44+
precomputedFlagsStorageFactory,
4445
} from './configuration-factory';
4546
import BrowserNetworkStatusListener from './events/browser-network-status-listener';
4647
import LocalStorageBackedNamedEventQueue from './events/local-storage-backed-named-event-queue';
@@ -107,7 +108,7 @@ export class EppoJSClient extends EppoClient {
107108
// Use an empty memory-only configuration store until the `init` method is called,
108109
// to avoid serving stale data to the user.
109110
/**
110-
* @deprecated. use `getInstance()` instead.
111+
* @deprecated Use `getInstance()` instead.
111112
*/
112113
public static instance = new EppoJSClient({
113114
flagConfigurationStore,
@@ -325,6 +326,14 @@ export class EppoJSClient extends EppoClient {
325326
storageKeySuffix,
326327
},
327328
);
329+
330+
// Client-side config should be obfuscated by default.
331+
// This has the effect of casting any entries stored in the persistent store as obfuscated.
332+
// We do this because we don't store any metadata in the persistent store and can make the assumption that entries
333+
// in the persistent store are obfuscated since the reason behind obfuscation is to obfuscate any data stored on a
334+
// user device.
335+
this.setIsObfuscated(true); // Use deprecated method to silence warning logs.
336+
configurationStore.setFormat(FormatEnum.CLIENT);
328337
this.setFlagConfigurationStore(configurationStore);
329338

330339
if (enableOverrides) {
@@ -478,8 +487,8 @@ export class EppoJSClient extends EppoClient {
478487
initializationError = initFromFetchError
479488
? initFromFetchError
480489
: initFromConfigStoreError
481-
? initFromConfigStoreError
482-
: new Error('Eppo SDK: No configuration source produced a valid configuration');
490+
? initFromConfigStoreError
491+
: new Error('Eppo SDK: No configuration source produced a valid configuration');
483492
}
484493
applicationLogger.debug('Initialization source', initializationSource);
485494
} catch (error: unknown) {
@@ -514,6 +523,7 @@ export class EppoJSClient extends EppoClient {
514523
const memoryOnlyConfigurationStore = configurationStorageFactory({
515524
forceMemoryOnly: true,
516525
});
526+
memoryOnlyConfigurationStore.setFormat(isObfuscated ? FormatEnum.CLIENT : FormatEnum.SERVER);
517527
memoryOnlyConfigurationStore
518528
.setEntries(config.flagsConfiguration)
519529
.catch((err) =>

yarn.lock

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -380,10 +380,10 @@
380380
resolved "https://registry.yarnpkg.com/@discoveryjs/json-ext/-/json-ext-0.6.3.tgz#f13c7c205915eb91ae54c557f5e92bddd8be0e83"
381381
integrity sha512-4B4OijXeVNOPZlYA2oEwWOTkzyltLao+xbotHQeqN++Rv27Y6s818+n2Qkp8q+Fxhn0t/5lA5X1Mxktud8eayQ==
382382

383-
"@eppo/js-client-sdk-common@4.10.0":
384-
version "4.10.0"
385-
resolved "https://registry.yarnpkg.com/@eppo/js-client-sdk-common/-/js-client-sdk-common-4.10.0.tgz#56250e42059a45545f1023ad4d47340aa892742f"
386-
integrity sha512-VLChPiZl4GEoyx+7b5TqFdnMRXM/s/nvlPsOiPoSNBFH5VbNFQsc543qDYnRM/cVPVAGfmHNEKTmec2ohXwD0Q==
383+
"@eppo/js-client-sdk-common@4.12.0":
384+
version "4.12.0"
385+
resolved "https://registry.yarnpkg.com/@eppo/js-client-sdk-common/-/js-client-sdk-common-4.12.0.tgz#87836c5cbfbf49beecc832edb12a4da329e4b9ea"
386+
integrity sha512-d16xB5prgH1H+OHaFZWXjVgOjyNu90JEH4SWoCxYLjypUQC0mkAw7riLFBDJ0jqQ1L9/EG0SJooXOOQ7tSjBqw==
387387
dependencies:
388388
buffer "npm:@eppo/[email protected]"
389389
js-base64 "^3.7.7"
@@ -5330,9 +5330,9 @@ url-parse@^1.5.3:
53305330
requires-port "^1.0.0"
53315331

53325332
uuid@^11.0.5:
5333-
version "11.0.5"
5334-
resolved "https://registry.yarnpkg.com/uuid/-/uuid-11.0.5.tgz#07b46bdfa6310c92c3fb3953a8720f170427fc62"
5335-
integrity sha512-508e6IcKLrhxKdBbcA2b4KQZlLVp2+J5UwQ6F7Drckkc5N9ZJwFa4TgWtsww9UG8fGHbm6gbV19TdM5pQ4GaIA==
5333+
version "11.1.0"
5334+
resolved "https://registry.yarnpkg.com/uuid/-/uuid-11.1.0.tgz#9549028be1753bb934fc96e2bca09bb4105ae912"
5335+
integrity sha512-0/A9rDy9P7cJ+8w1c9WD9V//9Wj15Ce2MPz8Ri6032usz+NfePxx5AcN3bN+r6ZL6jEo066/yNYB3tn4pQEx+A==
53365336

53375337
v8-compile-cache-lib@^3.0.1:
53385338
version "3.0.1"

0 commit comments

Comments
 (0)