-
Notifications
You must be signed in to change notification settings - Fork 98
chore: replace @node-rs/crc32 with Node.js stdlib zlib.crc32 #938
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
Conversation
|
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the Comment |
Co-authored-by: fengmk2 <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #938 +/- ##
==========================================
- Coverage 95.38% 95.26% -0.12%
==========================================
Files 197 197
Lines 22276 22261 -15
Branches 2464 2465 +1
==========================================
- Hits 21248 21208 -40
- Misses 1028 1053 +25 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this 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 modernizes the codebase by replacing the external @node-rs/crc32 dependency with Node.js's built-in zlib.crc32() function, which has been available since v20.18.0. The change reduces dependencies while maintaining identical CRC32 calculation behavior.
Key Changes:
- Migrated from external
@node-rs/crc32to nativenode:zlibcrc32 implementation - Removed unused
checkToken()function and its associated tests - Dependency cleanup in package.json
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| app/common/UserUtil.ts | Updated import to use node:zlib crc32; removed unused checkToken() validation function |
| package.json | Removed @node-rs/crc32 external dependency |
| test/common/UserUtil.test.ts | Removed tests for deleted checkToken() function |
| for (let i = 0; i < 2000; i++) { | ||
| const token = randomToken('cnpm'); | ||
| assert.match(token, /cnpm_\w{31,33}_\w{4,6}/); | ||
| assert.ok(checkToken(token, 'cnpm')); | ||
| assert.ok(!checkToken(token, 'npm')); | ||
| assert.ok(!checkToken(`${token}a`, 'cnpm')); | ||
| } | ||
| }); |
Copilot
AI
Dec 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The removal of all checkToken() tests significantly reduces test coverage for the token validation logic. While checkToken() is no longer exported, the token format and CRC32 validation remain critical for randomToken() functionality.
Consider keeping at least basic validation tests to ensure:
- Tokens generated with the new
zlib.crc32()can still be validated correctly - Invalid tokens are properly rejected
- The CRC32 checksum format remains compatible
You could add inline validation within the existing randomToken() test to verify the token structure and checksum integrity without exposing the checkToken() function.
[skip ci] ## <small>4.18.1 (2025-12-22)</small> * chore: replace @node-rs/crc32 with Node.js stdlib zlib.crc32 (#938) ([8a1b79f](8a1b79f)), closes [#938](#938) [#937](#937) * chore(deps): update dependency oxfmt to ^0.20.0 (#944) ([e6f9208](e6f9208)), closes [#944](#944) * chore(deps): update dependency oxlint-tsgolint to ^0.10.0 (#939) ([6f07c76](6f07c76)), closes [#939](#939) * chore(deps): update oxfmt and remove prettier (#923) ([9ab9d2a](9ab9d2a)), closes [#923](#923) * fix: should refresh package manifests to dists to avoid missing versions (#946) ([7d345b8](7d345b8)), closes [#946](#946) [hi#level](https://github.com/hi/issues/level)
|
🎉 This PR is included in version 4.18.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Node.js now provides
zlib.crc32()as a built-in function (available since v20.18.0+), eliminating the need for the@node-rs/crc32external dependency.Changes
crc32fromnode:zlibinstead of@node-rs/crc32@node-rs/crc32dependencyAPI Compatibility
Both implementations return identical results - unsigned 32-bit integers calculated using the same CRC32 algorithm:
The change is transparent to
randomToken()andcheckToken()- no behavioral changes.Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.