import { JwtPayload } from 'jsonwebtoken'; import { DestinationServiceCredentials, Service, ServiceCredentials, XsuaaServiceCredentials } from './environment-accessor-types'; import { ClientCredentials } from './xsuaa-service-types'; /** * Basic Credentials Getter from Destination service credentials needed for JWT generator. * * @returns Basic credentials. */ export declare function getDestinationBasicCredentials(): BasicCredentials; /** * First 'destination' credentials getter. * * @returns The 'destination' credentials object or `null`, if it does not exist. */ export declare function getDestinationServiceCredentials(): any; /** * Destination credentials getter. * * @returns A list of 'credentials' objects in 'destination' service. */ export declare function getDestinationServiceCredentialsList(): DestinationServiceCredentials[]; /** * Credentials list getter for a given service. * @param service - Service name * @returns Fetched credentials objects of existing service in 'VCAP_SERVICES'. */ export declare function getServiceCredentialsList(service: string): any[]; /** * Services getter for a given service. * @param service - Service name. * @returns List of service bindings of the given type. Returns an empty array if no service binding exists for the given type. */ export declare function getServiceList(service: string): Service[]; /** * Returns the first found instance for the given service type. * @param service - The service type. * @returns The first found service. */ export declare function getService(service: string): Service | undefined; /** * Get destination service if one is present. * * @returns Destination service * @throws Error in case no destination service is found in the VCAP variables */ export declare function getDestinationService(): Service; /** * 'VCAP_SERVICES' Getter from environment variables. * This function returns the VCAP_SERVICES as object or `null`, if it is not defined (i.e. no services are bound to the application). * * @returns 'VCAP_SERVICES' found in environment variables or `null`, if not defined. The key denotes the name ov the service and the value is the definition. */ export declare function getVcapService(): Record | null; /** * Environment variables accessor. * @param name - Environment variable name. * @returns Env variable value if defined. * null: If not defined. */ export declare function getEnvironmentVariable(name: string): string | undefined | null; /** * Destination URI getter * NOTICE: If there exist more than one destination/uri, the function * returns the first entry. * * @returns The first existing uri in destination or `null`, if not found. */ export declare function getDestinationServiceUri(): string | null; /** * Takes a decoded JWT and uses the client_id and audience claims to determine the XSUAA service instance * that issued the JWT. Returns the credentials if a match is found, otherwise throws an error. * If no decoded JWT is specified, then returns the first existing XSUAA credential service plan "application". * @param token - Either an encoded or decoded JWT. * @returns The credentials for a match, otherwise `null`. */ export declare function getXsuaaServiceCredentials(token?: JwtPayload | string): XsuaaServiceCredentials; /** * Takes a string that represents the service type and resolves it by calling [[getService]]. * If the parameter is already an instance of [[Service]], it is returned directly. * * Throws an error when no service can be found for the given type. * @param service - A string representing the service type or a [[Service]] instance. * @returns A [[Service]] instance. */ export declare function resolveService(service: string | Service): Service; /** * Extracts the credentials of a service into an instance of [[ClientCredentials]]. * @param serviceCreds - The credentials of a service as read from VCAP_SERVICES. * @returns A [[ClientCredentials]] instance. */ export declare function extractClientCredentials(serviceCreds: ServiceCredentials): ClientCredentials; interface BasicCredentials { clientid: string; clientsecret: string; } /** * @deprecated Since v1.5.0. Use directly exported functions instead */ export declare const EnvironmentAccessor: { getDestinationBasicCredentials: typeof getDestinationBasicCredentials; getDestinationServiceCredentials: typeof getDestinationServiceCredentials; getDestinationServiceCredentialsList: typeof getDestinationServiceCredentialsList; getServiceCredentialsList: typeof getServiceCredentialsList; getServiceList: typeof getServiceList; getVcapService: typeof getVcapService; getEnvironmentVariable: typeof getEnvironmentVariable; getDestinationServiceUri: typeof getDestinationServiceUri; getXsuaaServiceCredentials: typeof getXsuaaServiceCredentials; }; export {}; //# sourceMappingURL=environment-accessor.d.ts.map