UNPKG

appstore-cli

Version:

A command-line interface (CLI) to interact with the Apple App Store Connect API.

58 lines (49 loc) 1.7 kB
/** * Represents the authentication settings for Apple services during the build process. */ export interface AuthenticationConfiguration { /** * App Store Connect API Key ID */ apiKeyId?: string; /** * App Store Connect API Issuer ID */ apiIssuerId?: string; /** * Fastlane spaceauth session token */ fastlaneToken?: string; /** * Apple ID username for authentication */ username?: string; } /** * Validates an AuthenticationConfiguration object * @param config The AuthenticationConfiguration to validate * @returns Array of validation errors, empty if valid */ export function validateAuthenticationConfiguration(config: AuthenticationConfiguration): string[] { const errors: string[] = []; // Validate that either API credentials or Fastlane token is provided const hasApiCredentials = !!config.apiKeyId && config.apiKeyId.trim() !== '' && !!config.apiIssuerId && config.apiIssuerId.trim() !== ''; const hasFastlaneToken = !!config.fastlaneToken && config.fastlaneToken.trim() !== ''; if (!hasApiCredentials && !hasFastlaneToken) { errors.push('Either API credentials (key ID and issuer ID) or Fastlane token must be provided'); } // Validate API credentials if provided if (config.apiKeyId && config.apiKeyId.trim() !== '') { if (!config.apiIssuerId || config.apiIssuerId.trim() === '') { errors.push('API Issuer ID is required when API Key ID is provided'); } } if (config.apiIssuerId && config.apiIssuerId.trim() !== '') { if (!config.apiKeyId || config.apiKeyId.trim() === '') { errors.push('API Key ID is required when API Issuer ID is provided'); } } return errors; }