import * as tl from "azure-pipelines-task-lib" ; export interface IPackageSource { accountUrl : string ; isInternal : boolean ; } export class InternalAuthInfo { constructor ( public uriPrefixes , public accessToken ) { } } export class ExternalAuthInfo { constructor ( public packageSource , public authType ) { } } export class TokenExternalAuthInfo extends ExternalAuthInfo { constructor ( public packageSource , public token ) { super ( packageSource , ExternalAuthType . Token ) ; } } export enum ExternalAuthType { Token , UsernamePassword } export function GetExternalAuthInfo ( inputKey ) { let externalAuthInfo ; let endpointName = tl . getInput ( inputKey ) ; const accountUri = tl . getEndpointUrl ( endpointName , false ) ; let externalAuth = tl . getEndpointAuthorization ( endpointName , false ) ; switch ( externalAuth . scheme . toLocaleLowerCase ( ) ) { case "token" : let token = externalAuth . parameters [ "apitoken" ] ; externalAuthInfo = new TokenExternalAuthInfo ( < IPackageSource > { accountUrl : accountUri } , token ) ; break ; case "usernamepassword" : tl . error ( tl . loc ( "Error_AuthNotSupported" ) ) ; break ; default : break ; } return externalAuthInfo ; }