@@ -33,18 +33,16 @@ import {
3333 RegistryCatalogPageError ,
3434} from "./registry.adapter" ;
3535
36- type GuardedRegistryAccess = { accessToken : string ; leaseDurationMs : number } ;
37-
3836interface RegistryAddArtifactInput {
3937 normalizedName : string ;
4038 versionSpec ?: string ;
4139}
4240
43- async function getRegistryAccess ( ) : Promise < GuardedRegistryAccess | null > {
41+ async function getRegistryAccess ( ) : Promise < string | null > {
4442 const accessToken = ( await auth ( ) ) ?. accessToken ;
4543 const access = await evaluateRegistryAccess ( accessToken ) ;
4644 return access . status === REGISTRY_ACCESS . ELIGIBLE && accessToken ?. trim ( )
47- ? { accessToken, leaseDurationMs : access . leaseDurationMs }
45+ ? accessToken
4846 : null ;
4947}
5048
@@ -228,54 +226,42 @@ async function confirmRegistryMutation(
228226}
229227
230228function bootstrapReady (
231- access : GuardedRegistryAccess ,
232229 state : RegistryBootstrapState ,
233230) : RegistryBootstrapResult {
234- return {
235- status : REGISTRY_BOOTSTRAP_STATE . READY ,
236- leaseDurationMs : access . leaseDurationMs ,
237- state,
238- } ;
231+ return { status : REGISTRY_BOOTSTRAP_STATE . READY , state } ;
239232}
240233
241234function bootstrapFailure (
242- access : GuardedRegistryAccess ,
243235 failure : RegistryFailureResult ,
244236) : RegistryBootstrapResult {
245237 if ( failure . status === REGISTRY_FAILURE . ACCESS_DENIED ) {
246238 return { status : REGISTRY_FAILURE . ACCESS_DENIED } ;
247239 }
248- return bootstrapReady ( access , {
240+ return bootstrapReady ( {
249241 status :
250242 failure . status === REGISTRY_FAILURE . ONBOARDING
251243 ? REGISTRY_BOOTSTRAP_STATE . ERROR
252244 : failure . status ,
253245 } ) ;
254246}
255247
256- export async function refreshRegistryEligibility ( ) {
257- return evaluateRegistryAccess ( ( await auth ( ) ) ?. accessToken ) ;
258- }
259-
260248export async function getRegistryBootstrap ( ) : Promise < RegistryBootstrapResult > {
261- const access = await getRegistryAccess ( ) ;
262- if ( ! access ) return { status : REGISTRY_FAILURE . ACCESS_DENIED } ;
249+ const accessToken = await getRegistryAccess ( ) ;
250+ if ( ! accessToken ) return { status : REGISTRY_FAILURE . ACCESS_DENIED } ;
263251
264- const credentialRead = await readRegistryCredential ( access . accessToken ) ;
252+ const credentialRead = await readRegistryCredential ( accessToken ) ;
265253 if ( credentialRead . status !== REGISTRY_CREDENTIAL_READ . STATUS ) {
266- return bootstrapFailure ( access , credentialRead ) ;
254+ return bootstrapFailure ( credentialRead ) ;
267255 }
268- const tenantArtifactsRead = await readRegistryTenantArtifacts (
269- access . accessToken ,
270- ) ;
256+ const tenantArtifactsRead = await readRegistryTenantArtifacts ( accessToken ) ;
271257 if ( tenantArtifactsRead . status !== "ready" ) {
272- return bootstrapFailure ( access , tenantArtifactsRead ) ;
258+ return bootstrapFailure ( tenantArtifactsRead ) ;
273259 }
274260
275261 const { credential } = credentialRead ;
276262 const { tenantArtifacts } = tenantArtifactsRead ;
277263 if ( ! hasActiveRegistryCredential ( credential ) ) {
278- return bootstrapReady ( access , {
264+ return bootstrapReady ( {
279265 status : credential . validationPending
280266 ? REGISTRY_BOOTSTRAP_STATE . VALIDATION_PENDING
281267 : REGISTRY_BOOTSTRAP_STATE . ONBOARDING ,
@@ -284,26 +270,23 @@ export async function getRegistryBootstrap(): Promise<RegistryBootstrapResult> {
284270 } ) ;
285271 }
286272
287- const providers = await readRegistryProviders ( access . accessToken , credential ) ;
288- if ( providers . status !== "ready" ) return bootstrapFailure ( access , providers ) ;
289- const catalog = await readCompleteRegistryCatalog (
290- access . accessToken ,
291- credential ,
292- ) ;
273+ const providers = await readRegistryProviders ( accessToken , credential ) ;
274+ if ( providers . status !== "ready" ) return bootstrapFailure ( providers ) ;
275+ const catalog = await readCompleteRegistryCatalog ( accessToken , credential ) ;
293276 if ( catalog . status === REGISTRY_FAILURE . ACCESS_DENIED ) {
294277 return { status : REGISTRY_FAILURE . ACCESS_DENIED } ;
295278 }
296279 if ( catalog . status === REGISTRY_CATALOG . INCOMPLETE ) {
297- return bootstrapReady ( access , {
280+ return bootstrapReady ( {
298281 status : REGISTRY_BOOTSTRAP_STATE . INCOMPLETE ,
299282 catalog,
300283 } ) ;
301284 }
302285 if ( catalog . status !== REGISTRY_CATALOG . COMPLETE ) {
303- return bootstrapFailure ( access , catalog ) ;
286+ return bootstrapFailure ( catalog ) ;
304287 }
305288
306- return bootstrapReady ( access , {
289+ return bootstrapReady ( {
307290 status : REGISTRY_BOOTSTRAP_STATE . READY ,
308291 credential,
309292 catalog,
@@ -314,20 +297,18 @@ export async function getRegistryBootstrap(): Promise<RegistryBootstrapResult> {
314297export async function refreshRegistryCredential ( ) : Promise < RegistryCredentialReadResult > {
315298 const access = await getRegistryAccess ( ) ;
316299 if ( ! access ) return { status : REGISTRY_FAILURE . ACCESS_DENIED } ;
317- return readRegistryCredential ( access . accessToken ) ;
300+ return readRegistryCredential ( access ) ;
318301}
319302
320303export async function refreshRegistryCollections ( ) : Promise < RegistryCollectionsResult > {
321304 const access = await getRegistryAccess ( ) ;
322305 if ( ! access ) return { status : REGISTRY_FAILURE . ACCESS_DENIED } ;
323306
324- const providers = await readRegistryProviders ( access . accessToken , null ) ;
307+ const providers = await readRegistryProviders ( access , null ) ;
325308 if ( providers . status !== "ready" ) return providers ;
326- const catalog = await readCompleteRegistryCatalog ( access . accessToken , null ) ;
309+ const catalog = await readCompleteRegistryCatalog ( access , null ) ;
327310 if ( catalog . status !== REGISTRY_CATALOG . COMPLETE ) return catalog ;
328- const tenantArtifactsRead = await readRegistryTenantArtifacts (
329- access . accessToken ,
330- ) ;
311+ const tenantArtifactsRead = await readRegistryTenantArtifacts ( access ) ;
331312 return tenantArtifactsRead . status === "ready"
332313 ? {
333314 status : REGISTRY_CATALOG . COMPLETE ,
@@ -353,7 +334,7 @@ export async function addRegistryArtifact({
353334 headers : {
354335 Accept : "application/vnd.api+json" ,
355336 "Content-Type" : "application/vnd.api+json" ,
356- Authorization : `Bearer ${ access . accessToken } ` ,
337+ Authorization : `Bearer ${ access } ` ,
357338 } ,
358339 body : JSON . stringify ( {
359340 data : {
@@ -379,7 +360,7 @@ export async function addRegistryArtifact({
379360 ) ;
380361 }
381362
382- return confirmRegistryMutation ( access . accessToken , normalizedName , true ) ;
363+ return confirmRegistryMutation ( access , normalizedName , true ) ;
383364}
384365
385366export async function removeRegistryArtifact (
@@ -397,7 +378,7 @@ export async function removeRegistryArtifact(
397378 cache : "no-store" ,
398379 headers : {
399380 Accept : "application/vnd.api+json" ,
400- Authorization : `Bearer ${ access . accessToken } ` ,
381+ Authorization : `Bearer ${ access } ` ,
401382 } ,
402383 } ,
403384 ) ;
@@ -409,7 +390,7 @@ export async function removeRegistryArtifact(
409390 }
410391 if ( ! response . ok ) return { status : REGISTRY_FAILURE . ERROR } ;
411392
412- return confirmRegistryMutation ( access . accessToken , normalizedName , false ) ;
393+ return confirmRegistryMutation ( access , normalizedName , false ) ;
413394}
414395
415396export async function submitRegistryCredential (
@@ -418,7 +399,7 @@ export async function submitRegistryCredential(
418399 const access = await getRegistryAccess ( ) ;
419400 if ( ! access ) return { status : REGISTRY_FAILURE . ACCESS_DENIED } ;
420401
421- const priorCredential = await readRegistryCredential ( access . accessToken ) ;
402+ const priorCredential = await readRegistryCredential ( access ) ;
422403 if ( priorCredential . status !== REGISTRY_CREDENTIAL_READ . STATUS ) {
423404 return priorCredential ;
424405 }
@@ -431,7 +412,7 @@ export async function submitRegistryCredential(
431412 headers : {
432413 Accept : "application/vnd.api+json" ,
433414 "Content-Type" : "application/vnd.api+json" ,
434- Authorization : `Bearer ${ access . accessToken } ` ,
415+ Authorization : `Bearer ${ access } ` ,
435416 } ,
436417 body : JSON . stringify ( {
437418 data : { type : "registry-credentials" , attributes : { api_key : key } } ,
@@ -448,7 +429,7 @@ export async function submitRegistryCredential(
448429 const taskCompleted =
449430 submission . status === "pending" &&
450431 ( await credentialTaskCompleted ( submission . taskId ) ) ;
451- const credential = await readRegistryCredential ( access . accessToken ) ;
432+ const credential = await readRegistryCredential ( access ) ;
452433 if ( credential . status !== REGISTRY_CREDENTIAL_READ . STATUS ) return credential ;
453434
454435 return credentialActionResult (
@@ -470,7 +451,7 @@ export async function disconnectRegistryCredential(): Promise<RegistryCredential
470451 cache : "no-store" ,
471452 headers : {
472453 Accept : "application/vnd.api+json" ,
473- Authorization : `Bearer ${ access . accessToken } ` ,
454+ Authorization : `Bearer ${ access } ` ,
474455 } ,
475456 } ) ;
476457 } catch {
@@ -480,8 +461,8 @@ export async function disconnectRegistryCredential(): Promise<RegistryCredential
480461 return { status : REGISTRY_FAILURE . ACCESS_DENIED } ;
481462 }
482463
483- const credential = await readRegistryCredential ( access . accessToken ) ;
484- const tenantArtifacts = await readRegistryTenantArtifacts ( access . accessToken ) ;
464+ const credential = await readRegistryCredential ( access ) ;
465+ const tenantArtifacts = await readRegistryTenantArtifacts ( access ) ;
485466 if ( credential . status !== REGISTRY_CREDENTIAL_READ . STATUS ) return credential ;
486467 if ( tenantArtifacts . status !== "ready" ) return tenantArtifacts ;
487468 if ( ! response . ok ) return { status : REGISTRY_FAILURE . ERROR } ;
0 commit comments