Skip to content

Commit 567f15b

Browse files
authored
feat: npm view oidc considerations (#8432)
1 parent cb60ef4 commit 567f15b

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

lib/commands/view.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,10 +448,12 @@ function cleanup (data) {
448448
}
449449

450450
const keys = Object.keys(data)
451+
451452
if (keys.length <= 3 && data.name && (
452453
(keys.length === 1) ||
453454
(keys.length === 3 && data.email && data.url) ||
454-
(keys.length === 2 && (data.email || data.url))
455+
(keys.length === 2 && (data.email || data.url)) ||
456+
data.trustedPublisher
455457
)) {
456458
data = unparsePerson(data)
457459
}

test/lib/commands/view.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,34 @@ const packument = (nv, opts) => {
126126
'1.0.1': {},
127127
},
128128
},
129+
'cyan-oidc': {
130+
_npmUser: {
131+
name: 'claudia',
132+
email: 'claudia@cyan.com',
133+
trustedPublisher: {
134+
id: 'github',
135+
oidcConfigId: 'oidc:a0e127d0-8d66-45d0-8264-e4f8372c7249',
136+
},
137+
},
138+
name: 'cyan',
139+
'dist-tags': {
140+
latest: '1.0.0',
141+
},
142+
versions: {
143+
'1.0.0': {
144+
version: '1.0.0',
145+
name: 'cyan',
146+
dist: {
147+
shasum: '123',
148+
tarball: 'http://hm.cyan.com/1.0.0.tgz',
149+
integrity: '---',
150+
fileCount: 1,
151+
unpackedSize: 1000000,
152+
},
153+
},
154+
'1.0.1': {},
155+
},
156+
},
129157
brown: {
130158
name: 'brown',
131159
},
@@ -438,6 +466,12 @@ t.test('package with --json and semver range', async t => {
438466
t.matchSnapshot(joinedOutput())
439467
})
440468

469+
t.test('package with _npmUser.trustedPublisher shows cleaned up property with --json', async t => {
470+
const { view, joinedOutput } = await loadMockNpm(t, { config: { json: true } })
471+
await view.exec(['cyan-oidc@^1.0.0'])
472+
t.match(joinedOutput(), /claudia <claudia@cyan.com>/, 'uses oidc trustedPublisher info for _npmUser')
473+
})
474+
441475
t.test('package with --json and no versions', async t => {
442476
const { view, joinedOutput } = await loadMockNpm(t, { config: { json: true } })
443477
await view.exec(['brown'])

0 commit comments

Comments
 (0)