npm

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 19, 2026 License: Apache-2.0 Imports: 16 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package npm downloads a published npm package's tarball and unpacks it with internal/supplychain/archive. It never runs npm install, a lifecycle script (preinstall/install/postinstall), or any other package code - the tarball is treated purely as data to extract and hand to other analyzers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Fetcher

type Fetcher struct {
	Registry string
	Client   *http.Client
	Limits   archive.Limits
	// Policy is what CheckURL runs the tarball URL through. Tests point it
	// at an httptest.Server and so need AllowPrivateNetworks; production
	// use leaves it at its default.
	Policy httpx.Policy
}

Fetcher downloads packages from an npm registry. Both the registry metadata request and the tarball download - whose URL the registry response names, not the caller - go through httpx.DefaultPolicy: no private-network destination, guarded at dial time, no cross-origin redirect followed.

func New

func New() *Fetcher

New builds a Fetcher pointed at the public npm registry with the package's default archive safety limits

func (*Fetcher) Download

func (f *Fetcher) Download(ctx context.Context, name, version, destDir string) (archive.Result, string, error)

Download fetches name@version's tarball, verifies it against the registry's declared integrity (preferred) or shasum, and extracts it under destDir. destDir must already exist. Nothing in the package is ever executed: this is a download and an archive.Extract call, nothing else.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL