UNPKG

3.29 kBTypeScriptView Raw
1import { JwtPayload } from 'jsonwebtoken';
2import { CachingOptions } from './cache';
3import { Service, XsuaaServiceCredentials } from './environment-accessor-types';
4import { ResilienceOptions } from './resilience-options';
5/**
6 * Returns an access token that can be used to call the given service. The token is fetched via a client credentials grant with the credentials of the given service.
7 * If multiple instances of the provided service exist, the first instance will be selected.
8 * When a JWT is passed, the tenant of the JWT will be used when performing the grant.
9 * When no JWT is passed, the grant will be performed using the provider tenant.
10 *
11 * Throws an error if there is no instance of the given service type or the XSUAA service, or if the request to the XSUAA service fails.
12 * @param service - The type of the service or an instance of [[Service]].
13 * @param options - Options to influence caching and resilience behavior (see [[CachingOptions]] and [[ResilienceOptions]], respectively) and a JWT. By default, caching and usage of a circuit breaker are enabled.
14 * @returns Access token.
15 */
16export declare function serviceToken(service: string | Service, options?: CachingOptions & ResilienceOptions & {
17 userJwt?: string | JwtPayload;
18 xsuaaCredentials?: XsuaaServiceCredentials;
19}): Promise<string>;
20/**
21 * @deprecated Since v1.41.0 Use [[jwtBearerToken]] instead.
22 * Returns a user approved access token that can be used to call the given service on behalf of the given user. The token is fetched via user token + refresh token grant.
23 * This can be necessary for scenarios in which a token for a service is required, but the service needs
24 * to know about the user on whose behalf the request is performed (for example to let the destination
25 * service perform principal propagation with SAP S/4HANA Cloud).
26 *
27 * Throws an error if there is no instance of the given service type or the XSUAA service, or if the request to the XSUAA service fails.
28 * @param userJwt - The JWT of the user for whom the access token should be fetched.
29 * @param service - The type of the service or an instance of [[Service]].
30 * @param options - Options to influence resilience behavior (see [[ResilienceOptions]]). By default, usage of a circuit breaker is enabled.
31 * @returns A user approved access token.
32 */
33export declare function userApprovedServiceToken(userJwt: string, service: string | Service, options?: ResilienceOptions): Promise<string>;
34/**
35 * Returns a jwt bearer token that can be used to call the given service.
36 * The token is fetched via a JWT bearer token grant using the user token + client credentials.
37 *
38 * Throws an error if there is no instance of the given service type or the XSUAA service, or if the request to the XSUAA service fails.
39 * @param userJwt - The JWT of the user for whom the access token should be fetched
40 * @param service - The type of the service or an instance of [[Service]].
41 * @param options - Options to influence resilience behavior (see [[ResilienceOptions]]). By default, usage of a circuit breaker is enabled.
42 * @returns A jwt bearer token.
43 */
44export declare function jwtBearerToken(userJwt: string, service: string | Service, options?: ResilienceOptions): Promise<string>;
45//# sourceMappingURL=token-accessor.d.ts.map
\No newline at end of file