From 01b52624a02913830de70af5b47c551bfdcbf13b Mon Sep 17 00:00:00 2001 From: "Michael B. Gale" Date: Mon, 9 Mar 2026 19:27:49 +0000 Subject: [PATCH] Move out auth config from `Credential` type --- src/start-proxy/types.ts | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/src/start-proxy/types.ts b/src/start-proxy/types.ts index 3d28b98d4..a118b7e87 100644 --- a/src/start-proxy/types.ts +++ b/src/start-proxy/types.ts @@ -5,18 +5,38 @@ */ export type RawCredential = Partial; +/** Usernames may be present for both authentication with tokens or passwords. */ +export type Username = { + /** The username needed to authenticate to the package registry, if any. */ + username?: string; +}; + +/** + * Fields expected for authentication based on a username and password. + * Both username and password are optional. + */ +export type UsernamePassword = { + /** The password needed to authenticate to the package registry, if any. */ + password?: string; +} & Username; + +/** + * Fields expected for token-based authentication. + * Both username and token are optional. + */ +export type Token = { + /** The token needed to authenticate to the package registry, if any. */ + token?: string; +} & Username; + +/** All authentication-related fields. */ +export type AuthConfig = UsernamePassword & Token; + /** * A package registry configuration includes identifying information as well as * authentication credentials. */ -export type Credential = { - /** The username needed to authenticate to the package registry, if any. */ - username?: string; - /** The password needed to authenticate to the package registry, if any. */ - password?: string; - /** The token needed to authenticate to the package registry, if any. */ - token?: string; -} & Registry; +export type Credential = AuthConfig & Registry; /** A package registry is identified by its type and address. */ export type Registry = {