<!-- Copyright (c) 2026 defconxt. All rights reserved. -->
<!-- Licensed under AGPL-3.0 — see LICENSE file for details. -->
<!-- NERF is a trademark of defconxt. -->
# Detecting Dependency Confusion — API Reference

## npm Registry API

```bash
# Check if package exists
npm view <package-name> version

# Get full package metadata
npm view <package-name> --json

# List all versions
npm view <package-name> versions --json

# Check scoped package
npm view @scope/package-name version
```

## PyPI JSON API

```bash
# Check if package exists
curl -s https://pypi.org/pypi/<package-name>/json | jq '.info.version'

# Get all versions
curl -s https://pypi.org/pypi/<package-name>/json | jq '.releases | keys'

# Check package metadata
pip index versions <package-name>
```

## Maven Central Search API

```bash
# Search for artifact
curl -s "https://search.maven.org/solrsearch/select?q=a:<artifact-id>&rows=5" | jq '.response.docs'

# Search by group and artifact
curl -s "https://search.maven.org/solrsearch/select?q=g:<group-id>+AND+a:<artifact-id>" | jq '.response.numFound'
```

## .npmrc Configuration

```ini
# Set default registry to internal
registry=https://npm.internal.company.com/

# Scope-specific registry
@company:registry=https://npm.internal.company.com/

# Auth token via environment variable
//npm.internal.company.com/:_authToken=${NPM_TOKEN}
```

## pip.conf Configuration

```ini
[global]
index-url = https://pypi.internal.company.com/simple/
extra-index-url = https://pypi.org/simple/
trusted-host = pypi.internal.company.com
```

## Prevention Checklist

| Strategy | npm | PyPI | Maven |
|----------|-----|------|-------|
| Scoped/namespaced packages | `@company/pkg` | N/A | `com.company:pkg` |
| Registry pinning | `.npmrc` | `pip.conf` | `settings.xml` |
| Lock file enforcement | `npm ci` | `--require-hashes` | `mvn dependency:resolve` |
| Claim names on public registry | Publish placeholder | Publish placeholder | Publish placeholder |
| Version pinning | `package-lock.json` | `requirements.txt` | `dependencyManagement` |
