import { AxiosRequestConfig } from 'axios'; import * as AWS from 'aws-sdk/global.js'; declare const sigV4Client: { [key: string]: any; }; interface LemonKMS { arn: string; } interface LemonOAuthTokenResult { accountId: string; authId: string; credential: LemonCredentials; identityId: string; identityToken: string; identityPoolId?: string; error?: any; accessToken?: string; } interface LemonCredentials { AccessKeyId: string; SecretKey: string; Expiration?: string; SessionToken?: string; hostKey?: string; } interface LemonRefreshTokenResult { authId: string; accountId: string; identityId: string; credential: LemonCredentials; } interface SignaturePayload { authId?: string; accountId?: string; identityId?: string; identityToken?: string; } type Cloud = 'aws' | 'azure'; /** * default options for initializing service */ interface LemonOptions { /** * project name */ project: string; /** * target cloud */ cloud: Cloud; /** * endpoint url for authentication */ oAuthEndpoint: string; /** * extra header for axios request */ extraHeader?: any; /** * extra options for axios request */ extraOptions?: Omit; /** * whether to add the x-lemon-identity to request header */ shouldUseXLemonIdentity?: boolean; } declare class AxiosService { private requestOptions; private options; private axiosInstance; constructor(requestOptions?: AxiosRequestConfig); get(url: string, queryParams?: object): Promise; post(url: string, body: object, queryParams?: object): Promise; put(url: string, body: object, queryParams?: object): Promise; patch(url: string, body: object, queryParams?: object): Promise; delete(url: string, queryParams?: object): Promise; private makeRequest; } interface RequiredHttpParameters { method: string; path?: string; queryParams?: any; bodyReq?: any; } interface SignedHttpOptions { customHeader?: any; customOptions?: any; } declare class SignedHttpService { private providerCredential; private customHeader; private customOptions; private logger; constructor(options?: SignedHttpOptions, credentials?: AWS.Credentials); request(endpoint: string, allParams: RequiredHttpParameters): Promise; private getSignedClient; private getSignedHeader; private executeRequest; private extractHostname; } declare class LocalStorageService { private storage; constructor(); setItem(key: string, value: string): void; getItem(key: string): any; removeItem(key: string): void; } declare enum LogType { DEBUG = "DEBUG", WARN = "WARN", INFO = "INFO", ERROR = "ERROR" } interface LogInterface { debug(message: string, ...extraParams: any[]): void; warn(message: string, ...extraParams: any[]): void; info(message: string, ...extraParams: any[]): void; error(message: string, ...extraParams: any[]): void; } interface FormatInterface { timestampFormat: string; typeFormat: string; textFormat: string; namespaceFormat: string; } declare class LoggerService implements LogInterface { private utils; private isNode; private isBrowser; private namespace; private options; constructor(namespace?: string, options?: any); log(message: string, ...extraParams: any[]): void; debug(message: string, ...extraParams: any[]): void; warn(message: string, ...extraParams: any[]): void; info(message: string, ...extraParams: any[]): void; error(message: string, ...extraParams: any[]): void; private writeLog; private createLogMessage; private logOnBrowser; private getFormat; private getNodeFormat; private getBrowserFormat; private createTimestamp; } declare const NODE_COLORS: { Black: number; Red: number; Green: number; Yellow: number; Blue: number; Magenta: number; Cyan: number; Grey: number; White: number; }; declare const BROWSER_COLORS: { Black: string; Red: string; Green: string; Yellow: string; Blue: string; Magenta: string; Cyan: string; Grey: string; White: string; }; declare class LoggerHelperService { private colorSet; private logColors; constructor(); formatMessage(message: string, params: any[]): string; getColorAsType(type: LogType): string; getColorByName(name?: string): any; isBrowser(): boolean; isNode(): boolean; private checkErrorInstance; private getColorSet; } declare const createAsyncDelay: (duration: number) => Promise; declare const withRetries: (attempt: any, nthTry: number, delay: number) => (...args: any[]) => Promise; declare const hmac: (message: string, key: string) => string; declare const calcSignature: (payload: SignaturePayload, current?: string, userAgent?: string) => string; interface Storage { getItem(key: string, ...params: any): any; setItem(key: string, value: string, ...params: any): any; removeItem(key: string, ...params: any): any; } declare class LemonStorageService { private project; private storage; private credentialItemList; private prefix; private storageService; constructor(project?: string, storage?: Storage); updatePrefix(prefix: string): void; setItem(key: string, value: string): Promise; getItem(key: string): Promise; getAllItems(): Promise<{}>; hasCachedToken(): Promise; shouldRefreshToken(): Promise; getCachedCredentialItems(): Promise; getCachedLemonOAuthToken(cloud: Cloud): Promise; /** * Required Azure keys: accountId, identityToken * @param token * @returns */ saveLemonOAuthToken(token: LemonOAuthTokenResult, cloud: Cloud): Promise; clearLemonOAuthToken(): Promise; saveKMS(kms: LemonKMS): Promise; } /** * core service for authentication processing */ declare class AuthService { private readonly identityService; constructor(options: LemonOptions, storage?: Storage); /** * return token information stored in local storage */ getSavedToken(): Promise<{ [key: string]: string; }>; /** * set a request header or set the Axios Request Config. If you no longer use extra options, you need to reset it after the request. * @param options */ setLemonOptions(options: LemonOptions): void; /** * check login status with AWS Credentials */ isAuthenticated(): Promise; /** * generate AWS Credentials with token issued through LEMON-OAUTH-API * @param token */ buildCredentialsByToken(token: LemonOAuthTokenResult): Promise; /** * generate AWS Credentials from data stored on Local Storage */ buildCredentialsByStorage(): Promise; /** * @param kms Save kms to LocalStorage */ saveKMS(kms: LemonKMS): Promise; /** * get the current AWS Credentials and automatically renews the token when it expires. If has not, it returns null. */ getCredentials(): Promise; /** * HTTP request using Axios. If there are AWS Credentials on browser, request HTTP with AWS V4 Signing * @param method * @param endpoint * @param path * @param params * @param body */ request(method: string, endpoint: string, path: string, params?: any, body?: any): Promise; /** * execute the request() function above after executing getCredentials() function * @param method * @param endpoint * @param path * @param params * @param body */ requestWithCredentials(method: string, endpoint: string, path: string, params?: any, body?: any): Promise; /** * clear AWS Credentials and delete Local Storage data */ logout(): Promise; } declare class IdentityService { private oauthURL; private extraHeader; private extraOptions; private shouldUseXLemonIdentity; private options; private readonly lemonStorage; private readonly logger; constructor(options: LemonOptions, storage?: Storage); setOptions(options: LemonOptions): void; updateStoragePrefix(projectName: string): void; getSavedCredentials(): Promise<{ [key: string]: string; }>; saveKMS(kms: LemonKMS): Promise; buildCredentialsByToken(token: LemonOAuthTokenResult): Promise; buildCredentialsByStorage(): Promise; request(method: string, endpoint: string, path: string, params?: any, bodyReq?: any): Promise; requestWithCredentials(method: string, endpoint: string, path: string, params?: any, body?: any): Promise; getCredentials(): Promise; isAuthenticated(): Promise; logout(): Promise; private setExtraData; private checkCachedToken; refreshCachedToken(): Promise; private static createAWSCredentials; private getCurrentCredentials; private requestRefreshWithRetries; private executeRequest; private buildAWSCredentialsByToken; } export { AuthService, AxiosService, BROWSER_COLORS, Cloud, FormatInterface, IdentityService, LemonCredentials, LemonKMS, LemonOAuthTokenResult, LemonOptions, LemonRefreshTokenResult, LemonStorageService, LocalStorageService, LogInterface, LogType, LoggerHelperService, LoggerService, NODE_COLORS, RequiredHttpParameters, SignaturePayload, SignedHttpOptions, SignedHttpService, Storage, calcSignature, createAsyncDelay, hmac, sigV4Client, withRetries };