-
Notifications
You must be signed in to change notification settings - Fork 121
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
Usage in react-native #54
Comments
I'd welcome a pull request with a good source of (fairly unique per client) entropy for React Native. |
Hey Eric, According to facebook/react-native#1331 it looks like there is no idiomatic way of detecting the react native environment yet, though once there is it should be pretty easy to get some form of unique device id. |
That sounds like a great solution. Can you stay on top of it and submit a PR when it becomes available? |
In the mean time, this issue has been tackled on the RN side. React Native can be detected using I'll submit a PR soon. Does anyone have any suggestions on a proper source of entropy? I'm not experienced with this last bit. |
I don't know about the best source of entropy in ReactNative. I'm open to ideas. By the way, the current source of I'm open to a PR that either reverts to the current production code, or fixes the new modular code. I'd prefer the latter, but my top priority with cuid is "don't break stuff". There are a couple DB engines that use cuid, and I don't want to break their builds. |
What about using the devices UUID? |
@justinobney Some manufacturers have released thousands or hundreds of thousands of devices with the same device IDs, which is one of the reasons v1 UUIDs fell out of favor in the later half of the '90's and early 2000's when Windows rose to dominance, initially using MAC addresses in system UUIDs, which led to conflicts when many Windows computers were networked together. The same problem exists with cell phones in IoT devices today, making hardware-based UUIDs notoriously collision prone. |
Should be fixed now. Reopen if you have trouble. |
@ericelliott any chance this was published with an pre-existing version (2.1.4) number? Because I can see the fix on NPM, but my local NPM repository has a cached version without it. Just thinking you might get some bugs from people who think they have the latest, but don't. Maybe not. I dunno. |
npm does not allow you to publish over a version you've already published, so probably not, no. Is it possible you're importing from a different place than you think you are? |
Hah! Sorry for the distraction then and thanks for replying. |
Did you ever get it working for you? |
Yep, I kinda worked around it. 👍Thanks for following up. |
So while it seems this works, I'm confused what the idea behind using |
and similarly relying on https://www.npmjs.com/package/react-native-get-random-values similar to uuid would probably be better than just doing |
The idea is to generate host-unique entropy for a host fingerprint. It should create a different value on different devices and in different apps making different uses of the React Native global variable space. I'm not a big fan of the trivial encoding we currently use. If I were creating this specification from scratch today, I'd introduce a simple, fast hashing algorithm. |
I can potentially look into making a PR. |
This should not be the case. Different JS runtime versions will contain different global variables. How many different devices did you test across? It's completely normal for the same device to generate the same value repeatedly, but even on the same device, different app UXs will generate different values. For large apps with multiple different front-end implementations, having different ids generated across the iOS, Android, and web versions of the app will help improve cross-device entropy. In Web3 apps with many different views, you'll get an even larger variety. |
More of a comment here for other react-native users that might run into the same issue, than a bug specifically, but because react-native doesn't provide a userAgent or mimeTypes by default, using cuid will throw an error.
This can be worked around by defining dummy values before requiring cuid;
I did try using the node version but rn also doesn't set a process.pid so runs into the same issue.
The text was updated successfully, but these errors were encountered: