@@ -58,14 +58,18 @@ export const getNpmRegistryUrl = (() => {
5858export async function npmResolveConcreteVersion (
5959 packageName : string ,
6060 tagOrVersion : string ,
61+ authToken ?: string ,
6162) : Promise < string > {
6263 const url = new URL ( getNpmRegistryUrl ( ) ) ;
63- url . pathname = `${ packageName } /${ tagOrVersion } ` ;
64- const resp = await fetch ( url ) ;
64+ url . pathname = `${ url . pathname } ${ packageName } /${ tagOrVersion } ` ;
65+ const headers = authToken
66+ ? { Authorization : `Bearer ${ authToken } ` }
67+ : undefined ;
68+ const resp = await fetch ( url , { headers} ) ;
6569 if (
6670 [
6771 200 , // OK
68- 301 , // Moved Permanemently
72+ 301 , // Moved Permanently
6973 302 , // Found
7074 304 , // Not Modified
7175 307 , // Temporary Redirect
@@ -126,10 +130,16 @@ const minorVersion = (version: string) => {
126130
127131export async function getTemplateVersion (
128132 reactNativeVersion : string ,
133+ authToken ?: string ,
129134) : Promise < TemplateVersion | undefined > {
130- const json = await fetch (
131- new URL ( '@react-native-community/template' , getNpmRegistryUrl ( ) ) ,
132- ) . then ( ( resp ) => resp . json ( ) as Promise < NpmTemplateResponse > ) ;
135+ const url = new URL ( getNpmRegistryUrl ( ) ) ;
136+ url . pathname = `${ url . pathname } @react-native-community/template` ;
137+ const headers = authToken
138+ ? { Authorization : `Bearer ${ authToken } ` }
139+ : undefined ;
140+ const json = await fetch ( url , { headers} ) . then (
141+ ( resp ) => resp . json ( ) as Promise < NpmTemplateResponse > ,
142+ ) ;
133143
134144 // We are abusing which npm metadata is publicly available through the registry. Scripts
135145 // is always captured, and we use this in the Github Action that manages our releases to
0 commit comments