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

WIP: Remove nanoID dependency for WASM compatibility #57

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ryanbethel
Copy link
Contributor

Currently, this is a temporary hack to remove NanoId as a dependency. It is not required for a secure token or anything that requires a cryptographically solid random number. A better solution should be implemented.

Another temporary option to match the UUID format is:

export default function uuid() {
  return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
    var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
    return v.toString(16);
  });
}
console.log(uuid())

This is a temporary hack to remove NanoId as a dependency. It is not required for a secure token or anything that requires a cryptographically solid random number.
@kristoferjoseph
Copy link
Contributor

@ryanbethel what would you recommend we do with this?
I am open to removing nanoid but I am unclear if this solution is a good enough change.

@ryanbethel
Copy link
Contributor Author

Yeah, that is probably not good enough. It was just a temporary work around. I will look into what options we have inside quickJS compiled to WASM. I know we don't have full crypto randomness, but for the purpose of element unique id's I don't think we need that.

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.

None yet

2 participants