trust-npm
v0.1.4
Published
A safe npm wrapper that blocks untrusted dependencies by default.
Downloads
621
Maintainers
Readme
trust-npm
trust-npm is a production-oriented npm wrapper that blocks unknown dependencies by default and requires explicit approvals.
It uses your existing package-lock.json as a trust baseline and intercepts npm install before allowing package installation.
Features
- Default-deny installs for unknown packages
- Trust baseline bootstrapped from
package-lock.json - Risk scoring for unknown packages (age, downloads, repo, naming pattern)
- Human-gated approvals (
request-approve+ humanapprove) - Cross-platform npm passthrough using
child_process.spawn
Install
npm install
npm run build
npm linkThen use:
trust-npm --helpOne-command project setup
If you want npm commands to go through trust-npm automatically:
trust-npm initThis will:
- create/update
.trust-npm.jsonfrompackage-lock.json - persist alias
npm -> trust-npmin your shell profile - install npm takeover shim so plain
npmroutes throughtrust-npm - print current-session refresh commands and resolution check
- add/update
AGENTS.mdwith trust-npm usage policy
You can force shell target:
trust-npm init --shell powershell
trust-npm init --shell bash
trust-npm init --shell zshCommands
trust-npm init
Initializes .trust-npm.json, sets shell alias, enables npm takeover, prints shell refresh guidance, and writes agent guidance.
trust-npm initSkip automatic alias setup:
trust-npm init --skip-aliasEnable npm takeover shim:
trust-npm init --takeoverShow immediate shell refresh instructions/check:
trust-npm init --takeover --refresh-shellDisable takeover if needed:
trust-npm init --no-takeoverDisable session refresh guidance/check output:
trust-npm init --no-refresh-shellOptional alias instructions:
trust-npm init --print-shell-aliastrust-npm install <package...>
Intercepts install requests and blocks unknown packages until explicitly approved.
trust-npm install lodash
trust-npm install react -DIf blocked:
❌ BLOCKED (high risk): fast-ultra-db-kit
Reason:
- Published 2 day(s) ago
- 12 weekly downloads
- Missing repository field
- Risk score: 90/50
Run:
trust-npm request-approve fast-ultra-db-kit --reason "needed for feature X"
Then a human runs:
trust-npm approve fast-ultra-db-kittrust-npm approve <package...>
Human-only command. Adds packages to trusted store after explicit confirmation:
trust-npm approve lodash
trust-npm approve react react-domtrust-npm request-approve <package...>
Agent-safe command to request approval for human review:
trust-npm request-approve react-pivot-pro --reason "needed for dashboard POC"trust-npm status
Shows high-level trust status for the current project:
trust-npm statusTrust Store Format
.trust-npm.json:
{
"version": 1,
"createdAt": "2026-04-04T10:00:00.000Z",
"updatedAt": "2026-04-04T10:05:00.000Z",
"trustedPackages": {
"lodash": {
"source": "lockfile",
"approvedAt": "2026-04-04T10:00:00.000Z"
},
"fast-ultra-db-kit": {
"source": "manual",
"approvedAt": "2026-04-04T10:05:00.000Z"
}
},
"riskThreshold": 50
}Security Model
- Unknown package install attempts are blocked.
- High-risk unknown packages are called out with detailed risk factors.
- Even low-risk unknown packages are still blocked until approved.
- No silent approvals.
Notes
trust-npm installforwards to realnpm installonly when checks pass.- If you run plain
npm install, trust checks are bypassed. Use shell aliasing if desired. - Network access to npm registry is required for risk analysis on unknown packages.
Future Extensions
The structure is prepared for:
- additional package manager adapters (for example,
pip) - runtime import/require protection
- CI/CD enforcement mode
