npm: parse contentPolicy field into Version.Metadata - #50
Merged
Conversation
npm now lets maintainers declare dual-use content via a contentPolicy object in package.json, propagated into the packument version object. Parse it as a typed *ContentPolicy and expose it under Metadata["npm:contentPolicy"] alongside attestations and signatures. https://docs.npmjs.com/policies/dual-use
Contributor
There was a problem hiding this comment.
Pull request overview
Adds support in the npm registry implementation for npm’s new contentPolicy metadata by decoding it into a typed Go struct and exposing it via core.Version.Metadata under a namespaced key.
Changes:
- Parse the npm packument
contentPolicyfield into a typed*ContentPolicyonversionInfo. - Expose the parsed value as
Metadata["npm:contentPolicy"]alongside existingnpm:attestationsandnpm:signatures. - Add a unit test covering the round-trip behavior for
contentPolicy.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| internal/npm/npm.go | Adds ContentPolicy parsing to versionInfo and publishes it as npm:contentPolicy in version metadata. |
| internal/npm/npm_test.go | Adds tests for npm:contentPolicy being nil when absent and correctly populated when present. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
npm now lets maintainers declare dual-use content via a
contentPolicyobject inpackage.json, which propagates into the packument version object. Parse it as a typed*ContentPolicyand expose it underMetadata["npm:contentPolicy"]alongsidenpm:attestationsandnpm:signatures.Announcement: https://github.blog/changelog/2026-07-28-npm-publish-time-malware-scanning-and-dual-use-metadata/
Policy: https://docs.npmjs.com/policies/dual-use
The
packageResponsestruct hunk is gofmt re-aligning columns; the file had drifted.