Skip to content

Commit c8bdb4a

Browse files
jumoelljharbhfauldssandeepmeduru
authored andcommitted
feat: Support pure web authentication for commands
* feat: Add support for web auth, utilizing code from npm-profile Co-authored-by: Jordan Harband <ljharb@gmail.com> Co-authored-by: Hayden Faulds <fauldsh@gmail.com> Co-authored-by: Sandeep Meduru <sandeepmeduru@github.com>
1 parent 68ade72 commit c8bdb4a

File tree

16 files changed

+148
-26
lines changed

16 files changed

+148
-26
lines changed

lib/auth/sso.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const login = async (npm, { creds, registry, scope }) => {
5252
authType: ssoType,
5353
}
5454

55-
const { token, sso } = await otplease(opts,
55+
const { token, sso } = await otplease(npm, opts,
5656
opts => profile.loginCouch(auth.username, auth.password, opts)
5757
)
5858

lib/commands/access.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ class Access extends BaseCommand {
180180

181181
modifyPackage (pkg, opts, fn, requireScope = true) {
182182
return this.getPackage(pkg, requireScope)
183-
.then(pkgName => otplease(opts, opts => fn(pkgName, opts)))
183+
.then(pkgName => otplease(this.npm, opts, opts => fn(pkgName, opts)))
184184
}
185185

186186
async getPackage (name, requireScope) {

lib/commands/deprecate.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class Deprecate extends BaseCommand {
6060
packument.versions[v].deprecated = msg
6161
})
6262

63-
return otplease(this.npm.flatOptions, opts => fetch(uri, {
63+
return otplease(this.npm, this.npm.flatOptions, opts => fetch(uri, {
6464
...opts,
6565
spec: p,
6666
method: 'PUT',

lib/commands/dist-tag.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ class DistTag extends BaseCommand {
116116
},
117117
spec,
118118
}
119-
await otplease(reqOpts, reqOpts => regFetch(url, reqOpts))
119+
await otplease(this.npm, reqOpts, reqOpts => regFetch(url, reqOpts))
120120
this.npm.output(`+${t}: ${spec.name}@${version}`)
121121
}
122122

@@ -142,7 +142,7 @@ class DistTag extends BaseCommand {
142142
method: 'DELETE',
143143
spec,
144144
}
145-
await otplease(reqOpts, reqOpts => regFetch(url, reqOpts))
145+
await otplease(this.npm, reqOpts, reqOpts => regFetch(url, reqOpts))
146146
this.npm.output(`-${tag}: ${spec.name}@${version}`)
147147
}
148148

lib/commands/hook.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Hook extends BaseCommand {
2222
static ignoreImplicitWorkspace = true
2323

2424
async exec (args) {
25-
return otplease({
25+
return otplease(this.npm, {
2626
...this.npm.flatOptions,
2727
}, (opts) => {
2828
switch (args[0]) {

lib/commands/org.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class Org extends BaseCommand {
3333
}
3434

3535
async exec ([cmd, orgname, username, role], cb) {
36-
return otplease({
36+
return otplease(this.npm, {
3737
...this.npm.flatOptions,
3838
}, opts => {
3939
switch (cmd) {

lib/commands/owner.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ class Owner extends BaseCommand {
202202

203203
const dataPath = `/${spec.escapedName}/-rev/${encodeURIComponent(data._rev)}`
204204
try {
205-
const res = await otplease(this.npm.flatOptions, opts => {
205+
const res = await otplease(this.npm, this.npm.flatOptions, opts => {
206206
return npmFetch.json(dataPath, {
207207
...opts,
208208
method: 'PUT',

lib/commands/profile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ class Profile extends BaseCommand {
221221

222222
newUser[prop] = value
223223

224-
const result = await otplease(conf, conf => npmProfile.set(newUser, conf))
224+
const result = await otplease(this.npm, conf, conf => npmProfile.set(newUser, conf))
225225

226226
if (this.npm.config.get('json')) {
227227
this.npm.output(JSON.stringify({ [prop]: result[prop] }, null, 2))

lib/commands/publish.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ class Publish extends BaseCommand {
6262
}
6363

6464
const opts = { ...this.npm.flatOptions, progress: false }
65+
log.disableProgress()
6566

6667
// you can publish name@version, ./foo.tgz, etc.
6768
// even though the default is the 'file:.' cwd.
@@ -116,7 +117,7 @@ class Publish extends BaseCommand {
116117
log.notice('', `Publishing to ${outputRegistry}${dryRun ? ' (dry-run)' : ''}`)
117118

118119
if (!dryRun) {
119-
await otplease(opts, opts => libpub(manifest, tarballData, opts))
120+
await otplease(this.npm, opts, opts => libpub(manifest, tarballData, opts))
120121
}
121122

122123
if (spec.type === 'directory' && !ignoreScripts) {

lib/commands/team.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class Team extends BaseCommand {
4444
// XXX: "description" option to libnpmteam is used as a description of the
4545
// team, but in npm's options, this is a boolean meaning "show the
4646
// description in npm search output". Hence its being set to null here.
47-
await otplease({ ...this.npm.flatOptions }, opts => {
47+
await otplease(this.npm, { ...this.npm.flatOptions }, opts => {
4848
entity = entity.replace(/^@/, '')
4949
switch (cmd) {
5050
case 'create': return this.create(entity, opts)

0 commit comments

Comments
 (0)