wa-chat-server
Version:
Watson Assistant powered chat server
29 lines (28 loc) • 1.58 kB
TypeScript
import AssistantV1 from 'ibm-watson/assistant/v1';
import { IPreprocessingService } from '../../interface/IPreprocessingService';
import { ISession } from '../../interface/ISession';
import { IWAChatServerConfig } from '../../interface/IWAChatServerConfig';
import { ILogger } from '../../interface/ILogger';
/**
* This class implements adding of the logged user info to the WA request.
* Information is set to context variable internal.authentication.
* Authentication flow is the following:
* - The client calls the API /auth/getLoginUrl and redirects the user to the URL returned
* by this API (the Azure login page). The API call starts a session if not started yet.
* - Azure redirects the user back with GET parameters 'code' and 'state'.
* - The client calls the API /auth/loginWithAuthorizationCode which uses the parameters
* provided by Azure in the redirect, fetches information about the user and stores it in the
* session.
* - The service checks the information about the logged user in the session. If it is found
* then the service adds it to the internal.authentication section of the WA context.
*/
export declare class AuthenticationPreProcessingService implements IPreprocessingService {
private logger;
private config;
private context;
constructor(logger: ILogger, config: IWAChatServerConfig);
processRequest(request: AssistantV1.MessageRequest, session: ISession): Promise<void>;
private resolveAuthenticationContext;
private addAuthenticationDataToContext;
private removeAuthenticationDataFromContext;
}