-
Notifications
You must be signed in to change notification settings - Fork 48
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
Conversation
Feature/prevent fetch
return JSON.stringify([sortEntries(fields), sortEntries(properties)]); | ||
}; | ||
|
||
const sha256 = async (input: string): Promise<string> => { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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)
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