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: prevent fetch on load #224

Merged
merged 52 commits into from
Aug 6, 2024
Merged

feat: prevent fetch on load #224

merged 52 commits into from
Aug 6, 2024

Conversation

Tymek
Copy link
Member

@Tymek Tymek commented Aug 5, 2024

About the changes

Copy of PR #202, with changes making it ready to be merged into main.

Solves part of #201 (Service worker compatibility)

Diff: wanteeed/unleash-proxy-client-js@feature/prevent-fetch-on-load...Unleash:unleash-proxy-client-js:feature/prevent-fetch-on-load

@Tymek Tymek changed the title Feature/prevent fetch on load feat: prevent fetch on load Aug 5, 2024
@Tymek Tymek requested a review from kwasniew August 5, 2024 17:21
@Tymek Tymek marked this pull request as ready for review August 5, 2024 17:46
return JSON.stringify([sortEntries(fields), sortEntries(properties)]);
};

const sha256 = async (input: string): Promise<string> => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd use a non-cryptographic hash function suitable for general hash-based lookup e.g. murmurhash that we already use in the node client. It should be faster than cryptography hashing, there's a tiny library we already use elsewhere and it's tested.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also I've just found that we're hashing only the context which is usually quite small so maybe we can start with no hashing in the first version?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we can skip it in this version, but I'd like to have it to prevent storing PII in Unleash storage.

Speed difference is negligible (~5.5ms for murmur vs ~6.2ms for SHA-256, for medium size context). I don't think it's worth additional weight (https://bundlephobia.com/package/murmurhash3js@3.0.1)

@kwasniew kwasniew self-requested a review August 6, 2024 08:36
@Tymek Tymek merged commit c2b4145 into main Aug 6, 2024
3 checks passed
@Tymek Tymek deleted the feature/prevent-fetch-on-load branch August 6, 2024 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants