@sap-cloud-sdk/connectivity
Version:
SAP Cloud SDK for JavaScript connectivity
176 lines (175 loc) • 7.89 kB
TypeScript
import type { Xor } from '@sap-cloud-sdk/util';
import type { DestinationFetchOptions } from './destination-accessor-types';
import type { DestinationFromServiceBindingOptions } from './destination-from-vcap';
import type { AuthenticationType, Destination, DestinationCertificate, HttpDestination } from './destination-service-types';
/**
* Takes an existing or a parsed destination and returns an SDK compatible destination object.
* @param destination - An object that adheres to the {@link Destination} interface.
* @returns An SDK compatible destination object.
*/
export declare function sanitizeDestination(destination: Record<string, any>): Destination;
/**
* Takes a JSON object returned by any of the calls to the destination service and returns an SDK compatible destination object.
* This function only accepts destination configurations of type 'HTTP' and will error if no 'URL' is given.
* @param destinationJson - A JSON object returned by the destination service.
* @returns An SDK compatible destination object.
* @internal
*/
export declare function parseDestination(destinationJson: DestinationJson | DestinationConfiguration): Destination;
/**
* @internal
* Get additional headers and/or query parameters from a destination.
* Destinations can specify additional headers and/or query parameters, that should be added to every request against the given destination.
* They are specified in the following format:
* `URL.headers.<header-name>` or `URL.queries.<query-parameter-name>`
* @param destinationConfig - Original destination config that could include additional headers or query parameters.
* @returns An object with either the headers or query parameters and their values, depending on the `originalKeyPrefix`.
*/
export declare function getAdditionalHeadersAndQueryParameters(destinationConfig: DestinationConfiguration): Pick<Destination, 'headers' | 'queryParameters'>;
/**
* @internal
* Get additional headers from a destination.
* Destinations can specify additional headers, that should be added to every request against the given destination.
* They are specified in the following format:
* `URL.headers.<header-name>`
* @param destinationConfig - Original destination config that could include additional headers.
* @returns An object with either the headers or query parameters and their values, depending on the `originalKeyPrefix`.
*/
export declare function getAdditionalHeaders(destinationConfig: DestinationConfiguration): Pick<Destination, 'headers'>;
/**
* @internal
* Get additional query parameters from a destination.
* Destinations can specify additional query parameters, that should be added to every request against the given destination.
* They are specified in the following format:
* `URL.queries.<query-parameter-name>`
* @param destinationConfig - Original destination config that could include additional headers or query parameters.
* @returns An object with either the headers or query parameters and their values, depending on the `originalKeyPrefix`.
*/
export declare function getAdditionalQueryParameters(destinationConfig: DestinationConfiguration): Pick<Destination, 'queryParameters'>;
/**
* @internal
*/
export declare function getDestinationConfig(destinationJson: DestinationJson | DestinationConfiguration): DestinationConfiguration;
/**
* Transform destination to string containing destination information.
* @param destination - Either destination object or destinationName and Jwt.
* @returns String containing information on the destination.
*/
export declare function toDestinationNameUrl(destination: DestinationOrFetchOptions): string;
/**
* Transforms the upper case properties of the destination service response to lower case.
* @internal
* @param certificate - Response from the certificate endpoint of the destination service.
* @returns The parsed Destination Certificate with lower case properties.
*/
export declare function parseCertificate(certificate: Record<string, any>): DestinationCertificate;
/**
* Destination configuration alongside auth tokens and certificates.
*/
export interface DestinationJson {
[key: string]: any;
/**
* Configuration of a destination as it is available through the destination service.
*/
destinationConfiguration: DestinationConfiguration;
/**
* Authentication tokens as they are available through the destination service.
*/
authTokens?: Record<string, string>[];
/**
* Certificates for authentication as they are available through the destination service.
*/
certificates?: Record<string, string>[];
}
/**
* Configuration of a destination as it is available through the destination service.
*/
export interface DestinationConfiguration {
[key: string]: any;
/**
* `URL` of the destination.
*/
URL?: string;
/**
* `Name` of the destination.
*/
Name?: string;
/**
* `ProxyType` of the destination, e.g., `Internet` or `OnPremise`.
*/
ProxyType?: string;
/**
* `sap-client` defined in the destination.
*/
'sap-client'?: string;
/**
* Username in case of basic authentication destinations.
*/
User?: string;
/**
* Password in case of basic authentication destinations.
*/
Password?: string;
/**
* Represents the authentication type of a destination.
*/
Authentication?: AuthenticationType;
/**
* Value of the TrustAll property of the destination.
*/
TrustAll?: string;
/**
* URL of the token service endpoint to retrieve access token.
* This may contain placeholders in multi-tenant scenarios. @see {@link https://help.sap.com/docs/CP_CONNECTIVITY/cca91383641e40ffbe03bdc78f00f681/c69ea6aacd714ad2ae8ceb5fc3ceea56.html?locale=en-US|OAuth SAML Bearer Assertion Authentication}.
* In most cases the XSUAA will be used here.
*/
tokenServiceURL?: string;
/**
* Decides if the token service subdomain is fixed or adjusted in multi-tenant scenarios. @see {@link https://help.sap.com/docs/CP_CONNECTIVITY/cca91383641e40ffbe03bdc78f00f681/c69ea6aacd714ad2ae8ceb5fc3ceea56.html?locale=en-US|OAuth SAML Bearer Assertion Authentication}.
*/
tokenServiceURLType?: 'Common' | 'Dedicated;';
/**
* Fixed username to retrieve an auth token from the endpoint.
*/
tokenServiceUsername?: string;
/**
* Password to retrieve an auth token from the endpoint.
*/
tokenServicePass?: string;
/**
* ClientId to retrieve an auth token from the token service endpoint.
*/
clientId?: string;
/**
* ClientSecret to retrieve an auth token from the token service endpoint.
*/
clientSecret?: string;
/**
* Deprecated option of the destination service to fix a user in OnPremise principal propagation.
*/
SystemUser?: string;
/**
* Type of the destination.
*/
Type?: 'HTTP' | 'LDAP' | 'MAIL' | 'RFC';
}
/**
* @internal
*/
export declare function isDestinationConfiguration(destination: any): destination is DestinationConfiguration;
/**
* @internal
*/
export declare function isDestinationJson(destination: any): destination is DestinationJson;
/**
* @internal
*/
export declare function noDestinationErrorMessage(destination: DestinationOrFetchOptions): string;
/**
* Type that is either a {@link HttpDestination} or (XOR) {@link DestinationFetchOptions & DestinationFromServiceBindingOptions}.
*/
export type DestinationOrFetchOptions = Xor<Destination, DestinationFetchOptions & DestinationFromServiceBindingOptions>;
/**
* Type that is either a {@link HttpDestination} or (XOR) {@link DestinationFetchOptions & DestinationFromServiceBindingOptions}.
*/
export type HttpDestinationOrFetchOptions = Xor<HttpDestination, DestinationFetchOptions & DestinationFromServiceBindingOptions>;