Skip to content

Commit c8563c6

Browse files
committed
make trusted publisher setting as optional
1 parent 8d89c74 commit c8563c6

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

packages/plugin-npm/sources/npmHttpUtils.ts

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -616,17 +616,22 @@ async function getOidcToken(registry: string, {configuration, ident}: {configura
616616
if (!idToken)
617617
return null;
618618

619-
const response = await httpUtils.post(
620-
`${registry}/-/npm/v1/oidc/token/exchange/package/${ident.name.replace(/^@/, `%40`)}`,
621-
null,
622-
{
623-
configuration,
624-
jsonResponse: true,
625-
headers: {
626-
Authorization: `Bearer ${idToken}`,
619+
try {
620+
const response = await httpUtils.post(
621+
`${registry}/-/npm/v1/oidc/token/exchange/package/${ident.name.replace(/^@/, `%40`)}`,
622+
null,
623+
{
624+
configuration,
625+
jsonResponse: true,
626+
headers: {
627+
Authorization: `Bearer ${idToken}`,
628+
},
627629
},
628-
},
629-
);
630+
);
631+
return response.token || null;
632+
} catch {
633+
// Best effort
634+
}
630635

631-
return response.token || null;
636+
return null;
632637
}

0 commit comments

Comments
 (0)