Skip to content

chore(1-3230): use homebrew version of uuid generation #240

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

Merged
merged 1 commit into from
Jan 16, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { TinyEmitter } from 'tiny-emitter';
import { v4 as uuidv4 } from 'uuid';
Copy link
Contributor

Choose a reason for hiding this comment

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

do we use it for something else? can we remove this from package dependencies?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. I haven't checked, but I'm pretty sure I wasn't the one to add it. Let's see.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We use it in src/events-handler.ts too. We could switch that one for the same impl potentially, but I don't really wanna touch that now if we don't have to?

import Metrics from './metrics';
import type IStorageProvider from './storage-provider';
import InMemoryStorageProvider from './storage-provider-inmemory';
@@ -11,6 +10,7 @@ import {
urlWithContextAsQuery,
} from './util';
import { sdkVersion } from './version';
import { uuidv4 } from './uuidv4';

const DEFINED_FIELDS = [
'userId',
14 changes: 14 additions & 0 deletions src/uuidv4.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* This function generates a UUID using Math.random().
* The distribution of unique values is not guaranteed to be as robust
* as with a crypto module but works across all platforms (Node, React Native, browser JS).
*
* We use it for connection id generation which is not critical for security.
*/
export const uuidv4 = (): string => {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
const r = (Math.random() * 16) | 0;
const v = c === 'x' ? r : (r & 0x3) | 0x8;
return v.toString(16);
});
};
PHP-Proxy

PHP-Proxy

Error accessing resource: 429 - Too Many Requests