UNPKG

@sap-ux/system-access

Version:

Reusable module allowing to access systems using the store or prompts.

65 lines 2.47 kB
import type { Logger } from '@sap-ux/logger'; import { BackendSystem, type SystemType, type ConnectionType } from '@sap-ux/store'; import type { UrlAbapTarget } from '../types.js'; export type BasicAuth = Required<Pick<BackendSystem, 'username' | 'password'>>; export type ServiceAuth = Required<Pick<BackendSystem, 'serviceKeys' | 'name' | 'refreshToken'>>; /** * Checks if credentials are of basic auth type. * * @param authOpts credential options * @returns boolean */ export declare function isBasicAuth(authOpts: BackendSystem | BasicAuth | undefined): authOpts is BasicAuth; /** * Checks if credentials are of service auth type. * * @param authOpts credential options * @returns boolean */ export declare function isServiceAuth(authOpts: BackendSystem | ServiceAuth | undefined): authOpts is ServiceAuth; /** * Check the secure storage if it has credentials for the given target. * * @param target ABAP target * @param logger - reference to the logger instance * @returns credentials from the store or undefined. */ export declare function getCredentialsFromStore(target: UrlAbapTarget, logger: Logger): Promise<BackendSystem | undefined>; /** * Store the credentials in the secure storage. * * @param name system name * @param target target * @param target.url system url * @param target.client optional system client * @param target.systemType system type * @param target.connectionType connection type * @param credentials basic auth credentials * @param credentials.username username * @param credentials.password password * @param logger reference to the logger instance * @returns true if the credentials are successfully stored */ export declare function storeCredentials(name: string, target: { url: string; client?: string; systemType: SystemType; connectionType: ConnectionType; }, credentials: { username: string; password: string; }, logger: Logger): Promise<boolean>; /** * Checks the environment variables for Fiori tools settings. * * @returns basic auth credentials from the environment or undefined. */ export declare function getCredentialsFromEnvVariables(): BasicAuth | undefined; /** * Prompt for username and password. * * @param username - optional username that is to be offered as default * @returns credentials object with username/password */ export declare function getCredentialsWithPrompts(username?: string): Promise<BasicAuth>; //# sourceMappingURL=credentials.d.ts.map