@@ -56,7 +56,7 @@ export async function get(path: string, {configuration, headers, ident, authType
5656 if ( typeof registry !== `string` )
5757 throw new Error ( `Assertion failed: The registry should be a string` ) ;
5858
59- const auth = getAuthenticationHeader ( registry , { authType, configuration, ident} ) ;
59+ const auth = await getAuthenticationHeader ( registry , { authType, configuration, ident} ) ;
6060 if ( auth )
6161 headers = { ...headers , authorization : auth } ;
6262
@@ -83,7 +83,7 @@ export async function post(path: string, body: httpUtils.Body, {attemptedAs, con
8383 if ( typeof registry !== `string` )
8484 throw new Error ( `Assertion failed: The registry should be a string` ) ;
8585
86- const auth = getAuthenticationHeader ( registry , { authType, configuration, ident} ) ;
86+ const auth = await getAuthenticationHeader ( registry , { authType, configuration, ident} ) ;
8787 if ( auth )
8888 headers = { ...headers , authorization : auth } ;
8989
@@ -117,7 +117,7 @@ export async function put(path: string, body: httpUtils.Body, {attemptedAs, conf
117117 if ( typeof registry !== `string` )
118118 throw new Error ( `Assertion failed: The registry should be a string` ) ;
119119
120- const auth = getAuthenticationHeader ( registry , { authType, configuration, ident} ) ;
120+ const auth = await getAuthenticationHeader ( registry , { authType, configuration, ident} ) ;
121121 if ( auth )
122122 headers = { ...headers , authorization : auth } ;
123123
@@ -151,7 +151,7 @@ export async function del(path: string, {attemptedAs, configuration, headers, id
151151 if ( typeof registry !== `string` )
152152 throw new Error ( `Assertion failed: The registry should be a string` ) ;
153153
154- const auth = getAuthenticationHeader ( registry , { authType, configuration, ident} ) ;
154+ const auth = await getAuthenticationHeader ( registry , { authType, configuration, ident} ) ;
155155 if ( auth )
156156 headers = { ...headers , authorization : auth } ;
157157
@@ -178,13 +178,21 @@ export async function del(path: string, {attemptedAs, configuration, headers, id
178178 }
179179}
180180
181- function getAuthenticationHeader ( registry : string , { authType = AuthType . CONFIGURATION , configuration, ident} : { authType ?: AuthType , configuration : Configuration , ident : RegistryOptions [ 'ident' ] } ) {
181+ async function getAuthenticationHeader ( registry : string , { authType = AuthType . CONFIGURATION , configuration, ident} : { authType ?: AuthType , configuration : Configuration , ident : RegistryOptions [ 'ident' ] } ) {
182182 const effectiveConfiguration = npmConfigUtils . getAuthConfiguration ( registry , { configuration, ident} ) ;
183183 const mustAuthenticate = shouldAuthenticate ( effectiveConfiguration , authType ) ;
184184
185185 if ( ! mustAuthenticate )
186186 return null ;
187187
188+ const header = await configuration . reduceHook ( hooks => {
189+ return hooks . getNpmAuthenticationHeader ;
190+ } , undefined , registry , { configuration, ident} ) ;
191+
192+ if ( header )
193+ return header ;
194+
195+
188196 if ( effectiveConfiguration . get ( `npmAuthToken` ) )
189197 return `Bearer ${ effectiveConfiguration . get ( `npmAuthToken` ) } ` ;
190198 if ( effectiveConfiguration . get ( `npmAuthIdent` ) )
0 commit comments