Skip to content

Conversation

minggangw
Copy link
Member

@minggangw minggangw commented Mar 12, 2025

This PR replaces the use of the "uuid" library with Node’s built-in crypto module for generating UUIDs (nodejs >= v14.17.0).

  • Removed dependency on the "uuid" package in test and library files.
  • Replaced uuidv4() calls with crypto.randomUUID() calls for generating UUIDs.

Reference:

Fix: #1081

@minggangw minggangw requested a review from Copilot March 12, 2025 03:15
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR replaces the use of the "uuid" library with Node’s built-in crypto module for generating UUIDs, addressing issue #1081.

  • Removed dependency on the "uuid" package in test and library files
  • Replaced uuidv4() calls with crypto.randomUUID() calls for generating UUIDs

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
test/test-action-server.js Updated UUID generation in tests
lib/action/uuid.js Updated UUID generation in production code
test/test-action-client.js Removed unused "uuid" import
Comments suppressed due to low confidence (1)

lib/action/uuid.js:39

  • Ensure that the 'crypto' module is imported or available in this file, as it is required for using crypto.randomUUID().
let uuid = crypto.randomUUID().replace(/-/g, '');


function createUuid() {
let uuid = uuidv4().replace(/-/g, '');
let uuid = crypto.randomUUID().replace(/-/g, '');
Copy link

Copilot AI Mar 12, 2025

Choose a reason for hiding this comment

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

Ensure that the 'crypto' module is imported or available in this file, since the new UUID generation relies on crypto.randomUUID.

Copilot uses AI. Check for mistakes.

@coveralls
Copy link

coveralls commented Mar 12, 2025

Coverage Status

coverage: 85.32%. remained the same
when pulling 0293482 on minggangw:fix-1081
into 59d758c on RobotWebTools:develop.

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR replaces the use of the external "uuid" library with Node’s built-in crypto module for generating UUIDs to remove the extra dependency and use a native API (supported in Node.js v14.17.0+).

  • Removed imports for the "uuid" package in library and test files.
  • Replaced all uuidv4() calls with crypto.randomUUID() calls (with subsequent removal of dashes).

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
lib/action/uuid.js Updates UUID generation in production code with crypto.randomUUID() replacing uuidv4().
test/test-action-server.js Updates UUID generation in tests to use crypto.randomUUID() instead of uuidv4().
test/test-action-client.js Removes uuid dependency from client tests.

@minggangw minggangw merged commit 619f176 into RobotWebTools:develop Mar 12, 2025
10 of 11 checks passed
minggangw added a commit that referenced this pull request Mar 13, 2025
This PR replaces the use of the "uuid" library with Node’s built-in crypto module for generating UUIDs (nodejs >=  v14.17.0).

- Removed dependency on the "uuid" package in test and library files.
- Replaced uuidv4() calls with crypto.randomUUID() calls for generating UUIDs.

Reference:
- https://nodejs.org/docs/latest-v22.x/api/crypto.html#cryptorandomuuidoptions

Fix: #1081
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.

Generate UUID through crypto

2 participants