Skip to content

Use node:crypto instead of third-party md5#5404

Merged
tdonohue merged 1 commit intoDSpace:mainfrom
alanorth:use-node-md5
Apr 7, 2026
Merged

Use node:crypto instead of third-party md5#5404
tdonohue merged 1 commit intoDSpace:mainfrom
alanorth:use-node-md5

Conversation

@alanorth
Copy link
Copy Markdown
Contributor

@alanorth alanorth commented Apr 7, 2026

Description

Use Node.js native crypto API to calculate md5 hashes instead of third-party md5 library. This is used during production builds to calculate hashes of i18n language files.

Note: this could be backported to DSpace 9, 8, and 7 because it is very simple and I think the Node.js APIs have been around long enough to be in all versions we use. See crypto.createHash docs: https://nodejs.org/api/crypto.html#cryptocreatehashalgorithm-options

Instructions for Reviewers

Please add a more detailed description of the changes made by your PR. At a minimum, providing a bulleted list of changes in your PR is helpful to reviewers.

List of changes in this PR:

  • First, remove md5 library
  • Second, use Node.js native crypto API

Include guidance for how to test or review your PR. This may include: steps to reproduce a bug, screenshots or description of a new feature, or reasons behind specific changes.

Run the build in production mode with npm run build:prod and then npm run serve:ssr and make sure that language switching in the UI works.

Checklist

This checklist provides a reminder of what we are going to look for when reviewing your PR. You do not need to complete this checklist prior creating your PR (draft PRs are always welcome).
However, reviewers may request that you complete any actions in this list if you have not done so. If you are unsure about an item in the checklist, don't hesitate to ask. We're here to help!

  • My PR is created against the main branch of code (unless it is a backport or is fixing an issue specific to an older branch).
  • My PR is small in size (e.g. less than 1,000 lines of code, not including comments & specs/tests), or I have provided reasons as to why that's not possible.
  • My PR passes ESLint validation using npm run lint
  • My PR doesn't introduce circular dependencies (verified via npm run check-circ-deps)
  • My PR includes TypeDoc comments for all new (or modified) public methods and classes. It also includes TypeDoc for large or complex private methods.
  • My PR passes all specs/tests and includes new/updated specs or tests based on the Code Testing Guide.
  • My PR aligns with Accessibility guidelines if it makes changes to the user interface.
  • My PR uses i18n (internationalization) keys instead of hardcoded English text, to allow for translations.
  • My PR includes details on how to test it. I've provided clear instructions to reviewers on how to successfully test this fix or feature.
  • If my PR includes new libraries/dependencies (in package.json), I've made sure their licenses align with the DSpace BSD License based on the Licensing of Contributions documentation.
  • If my PR includes new features or configurations, I've provided basic technical documentation in the PR itself.
  • If my PR fixes an issue ticket, I've linked them together.

@alanorth alanorth added dependencies Pull requests that update a dependency file 1 APPROVAL pull request only requires a single approval to merge port to dspace-7_x This PR needs to be ported to `dspace-7_x` branch for next bug-fix release port to dspace-8_x This PR needs to be ported to `dspace-8_x` branch for next bug-fix release port to dspace-9_x This PR needs to be ported to `dspace-9_x` branch for next bug-fix release labels Apr 7, 2026
Copy link
Copy Markdown
Member

@alexandrevryghem alexandrevryghem left a comment

Choose a reason for hiding this comment

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

Thnx @alanorth! I've verified that this replacement works like expected and compared the old translation file hashes with the ones created in this PR and they were identical, so I'm a +1

@alanorth
Copy link
Copy Markdown
Contributor Author

alanorth commented Apr 7, 2026

Thanks @alexandrevryghem. I wanted to pull this out as a separate change from #4739, as that one was getting a bit more complicated as I started working on it.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 7, 2026

Hi @alanorth,
Conflicts have been detected against the base branch.
Please resolve these conflicts as soon as you can. Thanks!

Use Node.js native Crypto to calculate md5 hashes instead of third-
party md5 library.
@tdonohue
Copy link
Copy Markdown
Member

tdonohue commented Apr 7, 2026

Thanks @alanorth ! Looks good to me too. Merging immediately. However, this will likely need manual backporting to 8.x and 7.x, as those both used yarn instead of npm.

@tdonohue tdonohue added this to the 10.0 milestone Apr 7, 2026
@github-project-automation github-project-automation Bot moved this to 👍 Reviewer Approved in DSpace 10.0 Release Apr 7, 2026
@tdonohue tdonohue merged commit e8a31a0 into DSpace:main Apr 7, 2026
16 checks passed
@github-project-automation github-project-automation Bot moved this from 👍 Reviewer Approved to ✅ Done in DSpace 10.0 Release Apr 7, 2026
@dspace-bot
Copy link
Copy Markdown
Contributor

Backport failed for dspace-7_x, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin dspace-7_x
git worktree add -d .worktree/backport-5404-to-dspace-7_x origin/dspace-7_x
cd .worktree/backport-5404-to-dspace-7_x
git switch --create backport-5404-to-dspace-7_x
git cherry-pick -x 0835031f83b138517c1ef59307a9879a4272f48c

@dspace-bot
Copy link
Copy Markdown
Contributor

Backport failed for dspace-8_x, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin dspace-8_x
git worktree add -d .worktree/backport-5404-to-dspace-8_x origin/dspace-8_x
cd .worktree/backport-5404-to-dspace-8_x
git switch --create backport-5404-to-dspace-8_x
git cherry-pick -x 0835031f83b138517c1ef59307a9879a4272f48c

@dspace-bot
Copy link
Copy Markdown
Contributor

Successfully created backport PR for dspace-9_x:

@tdonohue
Copy link
Copy Markdown
Member

tdonohue commented Apr 7, 2026

As I suspected, this was only able to be auto-backported to 9.x. If anyone wants to backport this further, I'd gladly review/merge the manual backports. But, per our support policies, we're only guaranteeing bug/dependency backports to 9.x at this point (unless they are security related, and this isn't).

@tdonohue tdonohue removed the port to dspace-9_x This PR needs to be ported to `dspace-9_x` branch for next bug-fix release label Apr 7, 2026
@alanorth alanorth deleted the use-node-md5 branch April 7, 2026 16:29
@alanorth
Copy link
Copy Markdown
Contributor Author

alanorth commented Apr 7, 2026

Thanks @tdonohue. Ported to dspace-8_x here: #5413

@alanorth alanorth removed the port to dspace-7_x This PR needs to be ported to `dspace-7_x` branch for next bug-fix release label Apr 7, 2026
@alanorth alanorth removed the port to dspace-8_x This PR needs to be ported to `dspace-8_x` branch for next bug-fix release label Apr 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1 APPROVAL pull request only requires a single approval to merge dependencies Pull requests that update a dependency file

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

4 participants