import { Logger } from '@sudoplatform/sudo-common'; import { AuthenticationStore } from '../core/auth-store'; import { DefaultKeyManager } from '../core/key-manager'; import { FederatedSignInConfig } from '../core/sdk-config'; import { Subscriber } from '../core/subscriber'; import { AuthenticationTokens } from './user-client-interface'; export interface AuthenticationDetails { authenticationTokens: AuthenticationTokens; userId: string; } export interface AuthUI { /** * Presents the sign in UI for federated sign in using an external identity provider. */ presentFederatedSignInUI(): void; /** * Processes tokens from federated sign in that are returned in exchange * for the authorization code that is returned to the specified URL. * * @param url callback URL containing the authorization code. * @return Successful authentication result AuthenticationTokens. */ processFederatedSignInTokens(url: string): Promise; /** * Resets any internal state. */ reset(): void; /** * Presents the Cognito hosted UI signout endpoint. * When the endpoint is invoked, the hosted web app's cookies * will be invalidated, but the user is not logged out of Cognito. */ presentSignOutUI(): void; } export declare const DefaultRefreshTokenLifetime = 60; export declare class CognitoAuthUI implements AuthUI, Subscriber { private authenticationStore; private federatedSignInConfig; private keyManager; private launchUriFn?; private auth; private tokensRefreshedPromise?; private refreshTokenLifetime; private logger; constructor(authenticationStore: AuthenticationStore, federatedSignInConfig: FederatedSignInConfig, keyManager: DefaultKeyManager, logger: Logger, launchUriFn?: ((url: string) => void) | undefined); private initCognitoAuthSDK; presentFederatedSignInUI(): void; processFederatedSignInTokens(url: string): Promise; /** * This function is called when the authentication store notifies subscribers of an item update. * * @param itemName the name of the item being updated */ update(itemName: string): void; reset(): void; presentSignOutUI(): void; private storeRefreshTokenLifetime; private getAuthTokens; private getTokenExpiry; /** * Store the authentication tokens and user id of the signed in user in the key manager. */ private storeTokensInKeyManager; }