/** * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ import { TurnContext } from '../../../turnContext'; import { AuthorizationHandler, AuthorizationHandlerSettings, AuthorizationHandlerStatus, AuthorizationHandlerTokenOptions } from '../types'; import { TokenResponse } from '../../../oauth'; /** * Options for configuring the Agentic authorization handler. * @remarks * Properties can be configured via environment variables (case-insensitive). * Use the format: `AgentApplication__UserAuthorization__handlers__{handlerId}__settings__{propertyName}` * where `{handlerId}` is the handler's unique identifier and `{propertyName}` matches the property name. * * @example * ```env * # For a handler with id "myAuth": * AgentApplication__UserAuthorization__handlers__myAuth__settings__type=AgenticUserAuthorization * AgentApplication__UserAuthorization__handlers__myAuth__settings__scopes=api://scope1 api://scope2 * ``` */ export interface AgenticAuthorizationOptions { /** * The type of authorization handler. */ type: 'AgenticUserAuthorization' | 'agentic'; /** * The scopes required for the authorization. * @remarks When set via environment variable, use comma or space-separated values (e.g. `scope1,scope2` or `scope1 scope2`). */ scopes?: string[]; /** * An alternative connection name to use for the authorization process. */ altBlueprintConnectionName?: string; } /** * Settings for configuring the Agentic authorization handler. */ export interface AgenticAuthorizationSettings extends AuthorizationHandlerSettings { } /** * Authorization handler for Agentic authentication. */ export declare class AgenticAuthorization implements AuthorizationHandler { readonly id: string; private options; private settings; private _onSuccess?; private _onFailure?; /** * Creates an instance of the AgenticAuthorization class. * @param id The unique identifier for the authorization handler. * @param options The options for configuring the authorization handler (must be fully resolved). * @param settings The settings for the authorization handler. */ constructor(id: string, options: AgenticAuthorizationOptions, settings: AgenticAuthorizationSettings); readonly type = "agentic"; /** * The scopes configured for this handler. */ get scopes(): string[] | undefined; /** * @inheritdoc */ signin(): Promise; /** * @inheritdoc */ signout(): Promise; /** * @inheritdoc */ token(context: TurnContext, options?: AuthorizationHandlerTokenOptions): Promise; /** * @inheritdoc */ onSuccess(callback: (context: TurnContext) => void): void; /** * @inheritdoc */ onFailure(callback: (context: TurnContext, reason?: string) => void): void; /** * Prefixes a message with the handler ID. */ private prefix; private _key; /** * Sets the authorization context in the turn state. * @param context The turn context in which to set the authorization data. * @param scopes The OAuth scopes associated with the authorization context. * @param data The token response to store in the turn state. */ private setContext; /** * Gets the authorization context from the turn state. * @param scopes The OAuth scopes for which the context is being retrieved. */ private getContext; }