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

feat: obfuscated precomputed assignments #164

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
a1cf3bf
make getMD5HashWithSalt
sameerank Dec 9, 2024
22538e1
add tests
sameerank Dec 9, 2024
7cd544c
Merge branch 'main' into sameeran/ff-3682-use-salt-in-flag-key-hash-t…
sameerank Dec 9, 2024
1ff6d8b
Merge branch 'main' into sameeran/ff-3682-use-salt-in-flag-key-hash-t…
sameerank Dec 12, 2024
b8a2d9d
Export saltedHasher
sameerank Dec 12, 2024
567e66d
Fix tests
sameerank Dec 12, 2024
c8f5171
Alter test to use obfuscated file
sameerank Dec 12, 2024
c0288fe
Merge branch 'main' into sameeran/ff-3682-use-salt-in-flag-key-hash-t…
sameerank Dec 14, 2024
ed3f0b3
Change branch name for test data
sameerank Dec 14, 2024
47333ec
Get all the tests to pass
sameerank Dec 15, 2024
a3ed52a
Make more obvious that the salt was decoded
sameerank Dec 15, 2024
25c6f8c
Switch to using appendBinary for the salt
sameerank Dec 16, 2024
a169e29
Clean up
sameerank Dec 16, 2024
d366925
Include salt in convenience method for setting precomputed flag store
sameerank Dec 16, 2024
8fe80dc
Add a helper to convert context attributes to subject attributes
sameerank Dec 16, 2024
b1048a3
Change default to isObfuscated since we expect the precomputed api to…
sameerank Dec 16, 2024
b81175f
v4.7.1-alpha.0
sameerank Dec 16, 2024
9f36640
Revert "v4.7.1-alpha.0"
sameerank Dec 16, 2024
aee17ce
v4.7.0-alpha.0
sameerank Dec 16, 2024
67e9446
Switch to initializing the client with an options object
sameerank Dec 16, 2024
ed8027d
Make response data not optional
sameerank Dec 16, 2024
4e8aa63
precomputedFlag variable casing
sameerank Dec 16, 2024
6040e96
update hashing
typotter Dec 17, 2024
dd6b1e9
fix lint
leoromanovsky Dec 17, 2024
b178a6c
handoff and address comments
typotter Dec 18, 2024
749e8c1
Merge branch 'main' into sameeran/ff-3682-use-salt-in-flag-key-hash-t…
typotter Dec 18, 2024
e99306d
bump version
typotter Dec 18, 2024
f036edc
Merge branch 'main' into sameeran/ff-3682-use-salt-in-flag-key-hash-t…
sameerank Jan 6, 2025
173b3a3
Inf is a numeric attribute too
sameerank Jan 7, 2025
d43e9be
Remove unnecessary public methods
sameerank Jan 8, 2025
bba9863
Remove more unnecessary functions
sameerank Jan 8, 2025
0d1f341
Add to exported interfaces
sameerank Jan 8, 2025
bb03341
Update src/interfaces.ts
sameerank Jan 8, 2025
ad86727
Update src/attributes.ts attributes is ContextAttributes
sameerank Jan 8, 2025
b15f488
Remove redundant 'subjectAttributes as ContextAttributes'
sameerank Jan 8, 2025
3a322a7
Also print error if store is missing salt
sameerank Jan 8, 2025
928f58d
Remove buildContextAttributes
sameerank Jan 8, 2025
5241bf7
v4.8.0-alpha.0
sameerank Jan 8, 2025
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
Make more obvious that the salt was decoded
  • Loading branch information
sameerank committed Dec 15, 2024
commit a3ed52a37ded97c3298ad0621e545ed43c5562f8
2 changes: 1 addition & 1 deletion src/client/eppo-precomputed-client.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ describe('EppoPrecomputedClient E2E test', () => {
});

const client = new EppoPrecomputedClient(storage, true);
client.setFlagKeySalt(salt);
client.setDecodedFlagKeySalt(salt);

expect(client.getStringAssignment(precomputedFlagKey, 'default')).toBe(
mockPrecomputedFlag.variationValue,
Expand Down
10 changes: 5 additions & 5 deletions src/client/eppo-precomputed-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default class EppoPrecomputedClient {
private precomputedFlagsRequestParameters?: PrecomputedFlagsRequestParameters;
private subjectKey?: string;
private subjectAttributes?: Attributes;
private flagKeySalt = '';
private decodedFlagKeySalt = '';

constructor(
private precomputedFlagStore: IConfigurationStore<PrecomputedFlag>,
Expand All @@ -64,8 +64,8 @@ export default class EppoPrecomputedClient {
this.isObfuscated = isObfuscated;
}

public setFlagKeySalt(salt: string) {
this.flagKeySalt = salt;
public setDecodedFlagKeySalt(salt: string) {
this.decodedFlagKeySalt = salt;
}
// Individual methods for single responsibility
public setPrecomputedFlagsRequestParameters(parameters: PrecomputedFlagsRequestParameters) {
Expand Down Expand Up @@ -129,7 +129,7 @@ export default class EppoPrecomputedClient {
// A callback to capture the salt and subject information
precomputedRequestor.onPrecomputedResponse = (responseData) => {
if (responseData.decodedSalt) {
this.setFlagKeySalt(responseData.decodedSalt);
this.setDecodedFlagKeySalt(responseData.decodedSalt);
}
if (responseData.subjectKey && responseData.subjectAttributes) {
this.setSubjectData(responseData.subjectKey, responseData.subjectAttributes);
Expand Down Expand Up @@ -298,7 +298,7 @@ export default class EppoPrecomputedClient {
}

private getObfuscatedFlag(flagKey: string): DecodedPrecomputedFlag | null {
const saltedAndHashedFlagKey = getMD5Hash(flagKey, this.flagKeySalt);
const saltedAndHashedFlagKey = getMD5Hash(flagKey, this.decodedFlagKeySalt);
const precomputedFlag: PrecomputedFlag | null = this.precomputedFlagStore.get(
saltedAndHashedFlagKey,
) as PrecomputedFlag;
Expand Down
Loading