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

fix: Validate username at get-identity #5884

Merged
merged 4 commits into from Nov 30, 2022
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/utils/get-identity.js
Expand Up @@ -12,7 +12,9 @@ module.exports = async (npm, opts) => {
// No username, but we have other credentials; fetch the username from registry
if (creds.token || creds.certfile && creds.keyfile) {
const registryData = await npmFetch.json('/-/whoami', { ...opts })
return registryData.username
if (typeof registryData?.username === 'string')
return registryData.username
)
sosoba marked this conversation as resolved.
Show resolved Hide resolved
}

// At this point, even if they have a credentials object, it doesn't have a
Expand Down