import { DialogTurnResult } from 'botbuilder-dialogs'; import { TurnState } from '../TurnState'; import { Application } from '../Application'; import { TurnContext, Storage, TokenResponse } from 'botbuilder'; import { AuthError } from './Authentication'; /** * @internal * Base class to handle Teams conversational bot authentication. * @template TState - The type of the turn state. */ export declare abstract class BotAuthenticationBase { protected _storage: Storage; protected _settingName: string; private _userSignInSuccessHandler?; private _userSignInFailureHandler?; /** * Creates a new instance of BotAuthenticationBase. * @param {Application} app - The application instance. * @param {string} settingName - The name of the setting. * @param {Storage} [storage] - The storage to save states. */ constructor(app: Application, settingName: string, storage?: Storage); /** * Authenticates the user. * @param {TurnContext} context - The turn context. * @param {TState} state - The turn state. * @returns {Promise} - The authentication token, or undefined if authentication failed. */ authenticate(context: TurnContext, state: TState): Promise; /** * Checks if the activity is a valid message activity * @param {TurnContext} context - The turn context. * @returns {boolean} - True if the activity is a valid message activity. */ isValidActivity(context: TurnContext): boolean; /** * The handler function is called when the user has successfully signed in * @template TState * @param {(context: TurnContext, state: TState) => Promise} handler The handler function to call when the user has successfully signed in */ onUserSignInSuccess(handler: (context: TurnContext, state: TState) => Promise): void; /** * The handler function is called when the user sign in flow fails * @template TState * @param {(context: TurnContext, state: TState) => Promise} handler The handler function to call when the user failed to signed in */ onUserSignInFailure(handler: (context: TurnContext, state: TState, error: AuthError) => Promise): void; /** * Handles the signin/verifyState activity. The onUserSignInSuccess and onUserSignInFailure handlers will be called based on the result. * @param {TurnContext} context - The turn context. * @param {TState} state - The turn state. */ handleSignInActivity(context: TurnContext, state: TState): Promise; /** * Deletes the user auth state and user dialog state from the turn state. So that the next message can start a new authentication flow. * @param {TurnContext} context - The turn context. * @param {TState} state - The turn state. */ deleteAuthFlowState(context: TurnContext, state: TState): void; /** * Gets the property name for storing user authentication state. * @param {TurnContext} context - The turn context. * @returns {string} - The property name. */ getUserAuthStatePropertyName(context: TurnContext): string; /** * Gets the property name for storing user dialog state. * @param {TurnContext} context - The turn context. * @returns {string} - The property name. */ getUserDialogStatePropertyName(context: TurnContext): string; private getUserAuthState; private getUserDialogState; verifyStateRouteSelector(context: TurnContext): Promise; tokenExchangeRouteSelector(context: TurnContext): Promise; /** * Run or continue the authentication dialog. * @param {TurnContext} context - The turn context. * @param {TState} state - The turn state. * @param {string} dialogStateProperty - The property name for storing dialog state. * @returns {Promise>} - A promise that resolves to the dialog turn result containing the token response. */ abstract runDialog(context: TurnContext, state: TState, dialogStateProperty: string): Promise>; /** * Continues the authentication dialog. * @param {TurnContext} context - The turn context. * @param {TState} state - The turn state. * @param {string} dialogStateProperty - The property name for storing dialog state. * @returns {Promise>} - A promise that resolves to the dialog turn result containing the token response. */ abstract continueDialog(context: TurnContext, state: TState, dialogStateProperty: string): Promise>; } /** * Sets the setting name in the context.activity.value object. * The setting name is needed in signIn/verifyState` and `signIn/tokenExchange` route selector to accurately route to the correct authentication setting. * @param {TurnContext} context The turn context object * @param {string} settingName The auth setting name */ export declare function setSettingNameInContextActivityValue(context: TurnContext, settingName: string): void; /** * Sets the token in the turn state * @param {TurnState} state The turn state * @param {string} settingName The name of the setting * @param {string} token The token to set * @internal */ export declare function setTokenInState(state: TState, settingName: string, token: string): void; /** * Deletes the token from the turn state * @param {TurnState} state The turn state * @param {string} settingName The name of the setting */ export declare function deleteTokenFromState(state: TState, settingName: string): void; /** * Determines if the user is in the sign in flow. * @template TState * @param {TState} state - the turn state * @returns {string | undefined} The setting name if the user is in sign in flow. Otherwise, undefined. */ export declare function userInSignInFlow(state: TState): string | undefined; /** * Update the turn state to indicate the user is in the sign in flow by providing the authentication setting name used. * @template TState * @param {TState} state - the turn state * @param {string} settingName - the authentication setting name. */ export declare function setUserInSignInFlow(state: TState, settingName: string): void; /** * Deletes the user sign in flow state from the turn state. * @template TState * Determines if the user is in the sign in flow. * @param {TState} state - the turn state */ export declare function deleteUserInSignInFlow(state: TState): void; //# sourceMappingURL=BotAuthenticationBase.d.ts.map