interface AppRef { readonly region: string; readonly org: string; readonly space: string; readonly app: string; } interface XsuaaCredentials { readonly clientId: string; readonly clientSecret: string; readonly url: string; readonly xsappname?: string; } interface CachedToken { readonly accessToken: string; readonly expiresAt: string; } interface XsuaaEntry extends AppRef { readonly credentials: XsuaaCredentials; readonly token?: CachedToken; readonly fetchedAt: string; } interface XsuaaStore { readonly version: 1; readonly entries: readonly XsuaaEntry[]; } interface RawVcapUaaCredentials { readonly clientid: string; readonly clientsecret: string; readonly url: string; readonly xsappname?: string; } interface RawVcapBinding { readonly name?: string; readonly label?: string; readonly credentials: RawVcapUaaCredentials; } interface RawVcapServices { readonly xsuaa?: readonly RawVcapBinding[]; } type FetchSecretFn = (ref: AppRef) => Promise; type FetchTokenFn = (creds: XsuaaCredentials) => Promise; declare const SAPTOOLS_DIR_NAME = ".saptools"; declare const XSUAA_FILENAME = "xsuaa-data.json"; declare function saptoolsDir(): string; declare function xsuaaDataPath(): string; declare function readStore(): Promise; declare function writeStore(store: XsuaaStore): Promise; declare function matchesRef(entry: XsuaaEntry, ref: AppRef): boolean; declare function findEntry(store: XsuaaStore, ref: AppRef): XsuaaEntry | undefined; declare function upsertSecret(store: XsuaaStore, ref: AppRef, credentials: XsuaaCredentials, now?: Date): XsuaaStore; declare function upsertToken(store: XsuaaStore, ref: AppRef, token: CachedToken): XsuaaStore; interface JwtPayload { readonly exp?: number; readonly iat?: number; readonly iss?: string; readonly aud?: string | readonly string[]; } declare function decodeJwtPayload(jwt: string): JwtPayload; declare const TOKEN_EXPIRY_BUFFER_SECONDS = 45; declare function computeExpiryIso(jwt: string, now?: Date): string; declare function isExpired(expiresAt: string, now?: Date): boolean; declare function extractVcapServicesJson(stdout: string): string; declare function parseXsuaaFromVcap(stdout: string): XsuaaCredentials; interface OAuthTokenResponse { readonly access_token: string; readonly token_type: string; readonly expires_in: number; } interface FetchTokenOptions { readonly fetchImpl?: typeof fetch; readonly grantType?: "client_credentials"; } declare function fetchClientCredentialsToken(creds: XsuaaCredentials, opts?: FetchTokenOptions): Promise; interface FetchSecretOptions { readonly fetchCredentials?: FetchSecretFn; readonly now?: Date; } declare function fetchSecret(ref: AppRef, opts?: FetchSecretOptions): Promise; interface GetTokenOptions { readonly fetchCredentials?: FetchSecretFn; readonly fetchToken?: FetchTokenFn; readonly now?: Date; } declare function getToken(ref: AppRef, opts?: GetTokenOptions): Promise; type GetTokenCachedOptions = GetTokenOptions; declare function getTokenCached(ref: AppRef, opts?: GetTokenCachedOptions): Promise; export { type AppRef, type CachedToken, type FetchSecretFn, type FetchSecretOptions, type FetchTokenFn, type FetchTokenOptions, type GetTokenCachedOptions, type GetTokenOptions, type JwtPayload, type OAuthTokenResponse, type RawVcapBinding, type RawVcapServices, type RawVcapUaaCredentials, SAPTOOLS_DIR_NAME, TOKEN_EXPIRY_BUFFER_SECONDS, XSUAA_FILENAME, type XsuaaCredentials, type XsuaaEntry, type XsuaaStore, computeExpiryIso, decodeJwtPayload, extractVcapServicesJson, fetchClientCredentialsToken, fetchSecret, findEntry, getToken, getTokenCached, isExpired, matchesRef, parseXsuaaFromVcap, readStore, saptoolsDir, upsertSecret, upsertToken, writeStore, xsuaaDataPath };