Comments (18)
Should be fixed now. Reopen if you have trouble.
from cuid.
So while it seems this works, I'm confused what the idea behind using Object.keys(global).toString(36) for the fingerprint on react native is
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.
from cuid.
I'd welcome a pull request with a good source of (fairly unique per client) entropy for React Native.
from cuid.
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.
from cuid.
That sounds like a great solution. Can you stay on top of it and submit a PR when it becomes available?
from cuid.
In the mean time, this issue has been tackled on the RN side.
React Native can be detected using global.navigator.product === 'ReactNative'
.
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.
from cuid.
I don't know about the best source of entropy in ReactNative. I'm open to ideas. By the way, the current source of cuid()
is a mess, and the current production version is pushed from and old branch. The old version used file concatenation to build. The new version is supposed to use proper modules, but doesn't currently work.
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.
from cuid.
What about using the devices UUID?
from cuid.
@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.
from cuid.
@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.
from cuid.
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?
from cuid.
Hah! Sorry for the distraction then and thanks for replying.
from cuid.
Did you ever get it working for you?
from cuid.
Yep, I kinda worked around it. 👍Thanks for following up.
from cuid.
So while it seems this works, I'm confused what the idea behind using Object.keys(global).toString(36)
for the fingerprint on react native is
from cuid.
and similarly relying on https://www.npmjs.com/package/react-native-get-random-values similar to uuid would probably be better than just doing Math.random
from cuid.
I can potentially look into making a PR. Object.keys(global).toString(36)
generates the same output for a specific app on all iOS or Android devices respectively as far as I can tell which doesn't seem to be the desired behavior.
from cuid.
Object.keys(global).toString(36) generates the same output for a specific app on all iOS or Android devices respectively
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.
from cuid.
Related Issues (20)
- It seems scientific notation random values are still possible HOT 6
- Question: cuid compare to /dev/urandom HOT 1
- Port to Deno HOT 2
- Simple generator for testing/development
- Where do I find the standalone version? HOT 1
- Can we make it shorter? HOT 4
- How to compare cuids HOT 1
- Dependency Dashboard
- Fails to work with cloudflare workers js runtime. HOT 4
- Question: could we register a cuid: URI scheme, or URN scheme? HOT 2
- Question: Is there an active Java implementation? HOT 5
- Use of os.hostname() causes runtime crash on Wndows 7 HOT 3
- Is CUID good for a post App? HOT 1
- Usage of new Date().getTime() vs Date.now HOT 1
- Why does a cuid have so many zeros in almost every generated id? HOT 1
- Is there any easy way to mock this lib with jest? HOT 1
- Check character HOT 1
- cuid npm package does not mention the deprecated state HOT 1
- Document post-deprecation support timeframe HOT 2
- [deps] Check for breaking changes in Dependabot's PRs
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cuid.