1 | import { JwtPayload } from 'jsonwebtoken';
|
2 | import { DestinationServiceCredentials, Service, ServiceCredentials, XsuaaServiceCredentials } from './environment-accessor-types';
|
3 | import { ClientCredentials } from './xsuaa-service-types';
|
4 | /**
|
5 | * Basic Credentials Getter from Destination service credentials needed for JWT generator.
|
6 | *
|
7 | * @returns Basic credentials.
|
8 | */
|
9 | export declare function getDestinationBasicCredentials(): BasicCredentials;
|
10 | /**
|
11 | * First 'destination' credentials getter.
|
12 | *
|
13 | * @returns The 'destination' credentials object or `null`, if it does not exist.
|
14 | */
|
15 | export declare function getDestinationServiceCredentials(): any;
|
16 | /**
|
17 | * Destination credentials getter.
|
18 | *
|
19 | * @returns A list of 'credentials' objects in 'destination' service.
|
20 | */
|
21 | export declare function getDestinationServiceCredentialsList(): DestinationServiceCredentials[];
|
22 | /**
|
23 | * Credentials list getter for a given service.
|
24 | * @param service - Service name
|
25 | * @returns Fetched credentials objects of existing service in 'VCAP_SERVICES'.
|
26 | */
|
27 | export declare function getServiceCredentialsList(service: string): any[];
|
28 | /**
|
29 | * Services getter for a given service.
|
30 | * @param service - Service name.
|
31 | * @returns List of service bindings of the given type. Returns an empty array if no service binding exists for the given type.
|
32 | */
|
33 | export declare function getServiceList(service: string): Service[];
|
34 | /**
|
35 | * Returns the first found instance for the given service type.
|
36 | * @param service - The service type.
|
37 | * @returns The first found service.
|
38 | */
|
39 | export declare function getService(service: string): Service | undefined;
|
40 | /**
|
41 | * Get destination service if one is present.
|
42 | *
|
43 | * @returns Destination service
|
44 | * @throws Error in case no destination service is found in the VCAP variables
|
45 | */
|
46 | export declare function getDestinationService(): Service;
|
47 | /**
|
48 | * 'VCAP_SERVICES' Getter from environment variables.
|
49 | * This function returns the VCAP_SERVICES as object or `null`, if it is not defined (i.e. no services are bound to the application).
|
50 | *
|
51 | * @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.
|
52 | */
|
53 | export declare function getVcapService(): Record<string, any> | null;
|
54 | /**
|
55 | * Environment variables accessor.
|
56 | * @param name - Environment variable name.
|
57 | * @returns Env variable value if defined.
|
58 | * null: If not defined.
|
59 | */
|
60 | export declare function getEnvironmentVariable(name: string): string | undefined | null;
|
61 | /**
|
62 | * Destination URI getter
|
63 | * NOTICE: If there exist more than one destination/uri, the function
|
64 | * returns the first entry.
|
65 | *
|
66 | * @returns The first existing uri in destination or `null`, if not found.
|
67 | */
|
68 | export declare function getDestinationServiceUri(): string | null;
|
69 | /**
|
70 | * Takes a decoded JWT and uses the client_id and audience claims to determine the XSUAA service instance
|
71 | * that issued the JWT. Returns the credentials if a match is found, otherwise throws an error.
|
72 | * If no decoded JWT is specified, then returns the first existing XSUAA credential service plan "application".
|
73 | * @param token - Either an encoded or decoded JWT.
|
74 | * @returns The credentials for a match, otherwise `null`.
|
75 | */
|
76 | export declare function getXsuaaServiceCredentials(token?: JwtPayload | string): XsuaaServiceCredentials;
|
77 | /**
|
78 | * Takes a string that represents the service type and resolves it by calling [[getService]].
|
79 | * If the parameter is already an instance of [[Service]], it is returned directly.
|
80 | *
|
81 | * Throws an error when no service can be found for the given type.
|
82 | * @param service - A string representing the service type or a [[Service]] instance.
|
83 | * @returns A [[Service]] instance.
|
84 | */
|
85 | export declare function resolveService(service: string | Service): Service;
|
86 | /**
|
87 | * Extracts the credentials of a service into an instance of [[ClientCredentials]].
|
88 | * @param serviceCreds - The credentials of a service as read from VCAP_SERVICES.
|
89 | * @returns A [[ClientCredentials]] instance.
|
90 | */
|
91 | export declare function extractClientCredentials(serviceCreds: ServiceCredentials): ClientCredentials;
|
92 | interface BasicCredentials {
|
93 | clientid: string;
|
94 | clientsecret: string;
|
95 | }
|
96 | /**
|
97 | * @deprecated Since v1.5.0. Use directly exported functions instead
|
98 | */
|
99 | export declare const EnvironmentAccessor: {
|
100 | getDestinationBasicCredentials: typeof getDestinationBasicCredentials;
|
101 | getDestinationServiceCredentials: typeof getDestinationServiceCredentials;
|
102 | getDestinationServiceCredentialsList: typeof getDestinationServiceCredentialsList;
|
103 | getServiceCredentialsList: typeof getServiceCredentialsList;
|
104 | getServiceList: typeof getServiceList;
|
105 | getVcapService: typeof getVcapService;
|
106 | getEnvironmentVariable: typeof getEnvironmentVariable;
|
107 | getDestinationServiceUri: typeof getDestinationServiceUri;
|
108 | getXsuaaServiceCredentials: typeof getXsuaaServiceCredentials;
|
109 | };
|
110 | export {};
|
111 | //# sourceMappingURL=environment-accessor.d.ts.map |
\ | No newline at end of file |