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

FF-1749: JS SDK Common UFC update #45

Merged
merged 42 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
f69cdc6
wip
schmit Mar 25, 2024
07b9cde
making progress
schmit Mar 27, 2024
fd04b4b
make more tests pass
schmit Mar 27, 2024
ca7ea07
wip
schmit Mar 28, 2024
2a7b3ec
fix more tests
schmit Mar 28, 2024
d676f4c
update event cache test
schmit Mar 28, 2024
12eb7d1
.bind(this)
schmit Mar 28, 2024
e9bb4b3
pass all the tests
schmit Mar 28, 2024
684da8a
Update script to create obfuscated UFC
schmit Mar 28, 2024
aa64366
add obfuscation and make all tests pass
schmit Mar 29, 2024
4d6264e
cleanup
schmit Mar 29, 2024
1e9e10e
Address PR comments
schmit Apr 3, 2024
cab5b1f
Address PR comments
schmit Apr 3, 2024
e5d4be1
Hardcoded obfuscation tests and other fixes
schmit Apr 3, 2024
7400ed0
test for overwriting id for matching rules
schmit Apr 3, 2024
4d9a3a0
remove unused import
schmit Apr 3, 2024
67f7cbc
remove unneeded lint comment
schmit Apr 3, 2024
c6b0960
Add comment on getAssignmentDetail
schmit Apr 3, 2024
d71727e
addressing PR comments
schmit Apr 4, 2024
c650af5
update e2e test for more clarity
schmit Apr 4, 2024
bfd47f6
move obfuscated to client attribute, valueOf eppoValue
schmit Apr 4, 2024
bfc201e
add version metadata, add isInitialized
schmit Apr 4, 2024
8e5dbeb
Add uninitialized test back in
schmit Apr 4, 2024
7a3f392
add version update to pre-commit
schmit Apr 4, 2024
25d8ebf
add version in pre-commit
schmit Apr 4, 2024
834606e
test
schmit Apr 4, 2024
370d80a
update version
schmit Apr 4, 2024
d058c46
bump version
schmit Apr 4, 2024
9ce18fb
Merge branch 'main' into ufc-revamp
schmit Apr 4, 2024
cf991bc
dont be fancy
schmit Apr 4, 2024
6d063c4
remove evaluator as arg to eppo client constructor
schmit Apr 10, 2024
a5cfe95
Replace lru-cache package with simple local implementation (FF-1876) …
leoromanovsky Apr 5, 2024
bafd881
Merge branch 'main' into ufc-revamp
schmit Apr 10, 2024
5958d19
update endpoint to match backend
schmit Apr 12, 2024
ee3d43a
[ufc] add null operator and more fixes (#50)
schmit Apr 15, 2024
9915183
export test helpers
schmit Apr 15, 2024
fd6e357
export flag and variationtype
schmit Apr 15, 2024
a28e473
export attribute type
schmit Apr 15, 2024
08e36c8
export more types
schmit Apr 15, 2024
7735cc6
Update function signatures
schmit Apr 18, 2024
7b25f18
[UFC] Update obfuscation decoding (#52)
schmit Apr 19, 2024
555dece
Merge branch 'main' into ufc-revamp
schmit Apr 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update script to create obfuscated UFC
  • Loading branch information
schmit committed Mar 28, 2024
commit 684da8ad92ebef095a12fb330b582311e868a029
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"typecheck": "tsc",
"test": "yarn test:unit",
"test:unit": "NODE_ENV=test jest '.*\\.spec\\.ts'",
"obfuscate-mock-rac": "ts-node test/writeObfuscatedMockRac"
"obfuscate-mock-ufc": "ts-node test/writeObfuscatedMockUFC"
},
"jsdelivr": "dist/eppo-sdk.js",
"repository": {
Expand Down
36 changes: 0 additions & 36 deletions test/writeObfuscatedMockRac.ts

This file was deleted.

52 changes: 52 additions & 0 deletions test/writeObfuscatedMockUFC.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import * as fs from 'fs';

import { Flag, Rule } from '../src/interfaces';
import { encodeBase64, getMD5Hash } from '../src/obfuscation';

import {
MOCK_UFC_RESPONSE_FILE,
OBFUSCATED_MOCK_UFC_RESPONSE_FILE,
readMockUFCResponse,
TEST_DATA_DIR,
} from './testHelpers';

function obfuscateRule(rule: Rule) {
return {
...rule,
conditions: rule.conditions.map((condition) => ({
...condition,
attribute: getMD5Hash(condition.attribute),
operator: getMD5Hash(condition.operator),
value:
['ONE_OF', 'NOT_ONE_OF'].includes(condition.operator) && typeof condition.value === 'object'
? condition.value.map((value) => getMD5Hash(value.toLowerCase()))
: encodeBase64(`${condition.value}`),
})),
};
}

function obfuscateFlag(flag: Flag) {
return {
...flag,
key: getMD5Hash(flag.key),
allocations: flag.allocations.map((allocation) => ({
...allocation,
rules: allocation.rules.map(obfuscateRule),
})),
};
}

export function generateObfuscatedMockRac() {
const ufc = readMockUFCResponse(MOCK_UFC_RESPONSE_FILE);
const keys = Object.keys(ufc.flags);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const flagsCopy: Record<string, any> = {};
keys.forEach((key) => {
flagsCopy[getMD5Hash(key)] = obfuscateFlag(ufc.flags[key]);
});
return { flags: flagsCopy };
}

const obfuscatedRacFilePath = TEST_DATA_DIR + OBFUSCATED_MOCK_UFC_RESPONSE_FILE;
const obfuscatedRac = generateObfuscatedMockRac();
fs.writeFileSync(obfuscatedRacFilePath, JSON.stringify(obfuscatedRac, null, 2));