Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update npm audit 401 error message #112

Closed
wants to merge 6 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/audit.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,10 @@ function auditCmd (args, cb) {
}).then((auditReport) => {
return audit.submitForFullReport(auditReport)
}).catch((err) => {
if (err.statusCode === 404 || err.statusCode >= 500) {
// Some 3rd Party registries such as Microsoft Azure DevOps do not presently support `npm audit`. As no token is passed for `audit` and the registry may not
// have an exception in place for audit, a 401 is returned, which informs the user of an authentication-related issue that really masks a lack of implementation.
// Therefore, the custom error message now also triggers for 401s.
if (err.statusCode === 401 || err.statusCode === 404 || err.statusCode >= 500) {
const ne = new Error(`Your configured registry (${opts.registry}) does not support audit requests.`)
ne.code = 'ENOAUDIT'
ne.wrapped = err
Expand Down