npm: support GitHub Packages SHA tarball URLs - #238
Open
ksivamuthu-cei wants to merge 2 commits into
Open
Conversation
Rebuild GitHub's content-addressed tarball URLs from verified metadata while preserving regular npm downloads. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
ksivamuthu-cei
force-pushed
the
fix/npm-github-packages-tarballs
branch
from
August 8, 2026 02:30
6b0110f to
f4a64d3
Compare
There was a problem hiding this comment.
Pull request overview
Adds support in the npm proxy handler for registries that publish content-addressed tarball URLs (e.g., GitHub Packages), by rewriting metadata tarball URLs to a conventional *.tgz proxy path and resolving downloads via a shasum-backed lookup against upstream metadata.
Changes:
- Rewrites content-addressed tarball URLs to
{name}-{version}.tgzplus agit-pkgs-shasumquery parameter. - Resolves shasum-based download requests by re-fetching upstream metadata, verifying
dist.shasum, and usingdist.tarball(with upstream-origin validation). - Adds tests covering GitHub Packages-style rewriting, successful fetch, checksum mismatch rejection, and cross-host tarball rejection.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| internal/handler/npm.go | Adds shasum-aware tarball rewrite + download resolution/validation for content-addressed tarball URLs. |
| internal/handler/npm_test.go | Adds test coverage for GitHub Packages tarball rewriting and shasum-based download validation paths. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Support npm registries that publish content-addressed tarball URLs, including GitHub Packages URLs shaped like:
Previously, the proxy used the final URL segment as the filename. Because GitHub's final segment is a SHA-1 rather than
{package}-{version}.tgz, downloads failed before cache lookup withcould not determine version from filename.This change:
.tgzpath with a privategit-pkgs-shasumquery parameter;dist.shasum;dist.tarballURL rather than reconstructing GitHub's content-addressed path; andRegular npm tarball paths retain their existing rewrite and download behavior.
Tests
go test ./internal/handler -run 'TestNPM'go test ./...go vet ./...go build ./cmd/proxyAdded coverage for GitHub Packages metadata rewriting, fetching the original content-addressed tarball, checksum mismatch rejection, and cross-host tarball rejection.