@@ -118,15 +118,33 @@ export function isJFrogConfig(
118118 return json . validateSchema ( jfrogConfigSchema , config ) ;
119119}
120120
121+ /** A schema for Cloudsmith OIDC configurations. */
122+ export const cloudsmithConfigSchema = {
123+ namespace : json . string ,
124+ "service-slug" : json . string ,
125+ "api-host" : json . string ,
126+ } as const satisfies json . Schema ;
127+
128+ /** Configuration for Cloudsmith OIDC. */
129+ export type CloudsmithConfig = json . FromSchema < typeof cloudsmithConfigSchema > ;
130+
131+ /** Decides whether `config` is a Cloudsmith OIDC configuration. */
132+ export function isCloudsmithConfig (
133+ config : UnvalidatedObject < AuthConfig > ,
134+ ) : config is CloudsmithConfig {
135+ return json . validateSchema ( cloudsmithConfigSchema , config ) ;
136+ }
137+
121138/** An array of all OIDC configuration schemas along with output-friendly names. */
122139export const oidcSchemas = [
123140 { schema : azureConfigSchema , name : "Azure" } ,
124141 { schema : awsConfigSchema , name : "AWS" } ,
125142 { schema : jfrogConfigSchema , name : "JFrog" } ,
143+ { schema : cloudsmithConfigSchema , name : "Cloudsmith" } ,
126144] ;
127145
128146/** Represents all supported OIDC configurations. */
129- export type OIDC = AzureConfig | AWSConfig | JFrogConfig ;
147+ export type OIDC = AzureConfig | AWSConfig | JFrogConfig | CloudsmithConfig ;
130148
131149/** All authentication-related fields. */
132150export type AuthConfig = UsernamePassword | Token | OIDC ;
@@ -185,6 +203,10 @@ export function credentialToStr(credential: Credential): string {
185203 credential [ "identity-mapping-name" ] ,
186204 ) ;
187205 appendIfDefined ( "JFrog Audience" , credential . audience ) ;
206+ } else if ( isCloudsmithConfig ( credential ) ) {
207+ appendIfDefined ( "Cloudsmith Namespace" , credential . namespace ) ;
208+ appendIfDefined ( "Cloudsmith Service Slug" , credential [ "service-slug" ] ) ;
209+ appendIfDefined ( "Cloudsmith API Host" , credential [ "api-host" ] ) ;
188210 }
189211
190212 return result ;
0 commit comments