Skip to content

@egain/ai-agent-sdk API Reference - v0.1.1 / PKCEAuthStrategy

Class: PKCEAuthStrategy

PKCE (Proof Key for Code Exchange) authentication strategy for browsers Implements OAuth 2.0 PKCE flow for secure browser-based authentication using MSAL

Implements

Table of contents

Constructors

Methods

Constructors

constructor

new PKCEAuthStrategy(config): PKCEAuthStrategy

Parameters

NameType
configPKCEAuthConfig

Returns

PKCEAuthStrategy

Defined in

core/auth/PKCEAuthStrategy.ts:236

Methods

buildConfigFromDeploymentInfo

buildConfigFromDeploymentInfo(deploymentInfo, agentDetails, endpoint, scopes, logger?, authScheme?, egClientId?, localLogin?): Promise<PKCEAuthConfig>

Build PKCE configuration from deployment info and agent details This method fetches authentication metadata and constructs the PKCE config

Parameters

NameTypeDescription
deploymentInfoanyDeployment information containing API domain, client IDs, tenant ID
agentDetailsanyAgent details containing userType and other agent-specific information
endpointstringThe endpoint URL used to fetch deployment info (used for nextRoute)
scopesstring[]Scopes to request (passed from AuthenticationService)
logger?LoggerOptional logger instance for logging
authScheme?"popup" | "redirect"Authentication scheme: 'popup' or 'redirect' (defaults to 'popup')
egClientId?stringOptional client ID override from initParams (takes priority over deployment client IDs)
localLogin?booleanWhen true, forces local account login instead of federated SSO

Returns

Promise<PKCEAuthConfig>

Promise resolving to PKCEAuthConfig

Defined in

core/auth/PKCEAuthStrategy.ts:100


initialize

initialize(options?): Promise<void>

Initialize the PKCE authentication strategy

Parameters

NameType
options?AuthStrategyInitializeOptions

Returns

Promise<void>

Implementation of

AuthStrategy.initialize

Defined in

core/auth/PKCEAuthStrategy.ts:249


authenticate

authenticate(): Promise<void>

Authenticate using PKCE flow

Returns

Promise<void>

Implementation of

AuthStrategy.authenticate

Defined in

core/auth/PKCEAuthStrategy.ts:364


isAuthenticated

isAuthenticated(): boolean

Check if the user is currently authenticated

Returns

boolean

Defined in

core/auth/PKCEAuthStrategy.ts:447


getToken

getToken(): Promise<string>

Get authentication token using PKCE flow

Returns

Promise<string>

Implementation of

AuthStrategy.getToken

Defined in

core/auth/PKCEAuthStrategy.ts:454


startAuthorizationFlow

startAuthorizationFlow(): Promise<void>

Start the PKCE authorization flow Redirects user to authorization server

Returns

Promise<void>

Defined in

core/auth/PKCEAuthStrategy.ts:493


handleCallback

handleCallback(code, state): Promise<void>

Handle the OAuth callback with authorization code This is handled automatically by MSAL's handleRedirectPromise

Parameters

NameType
codestring
statestring

Returns

Promise<void>

Defined in

core/auth/PKCEAuthStrategy.ts:501


refreshToken

refreshToken(): Promise<string>

Refresh the access token using refresh token

Returns

Promise<string>

Defined in

core/auth/PKCEAuthStrategy.ts:510


cleanup

cleanup(): Promise<void>

Cleanup resources

Returns

Promise<void>

Implementation of

AuthStrategy.cleanup

Defined in

core/auth/PKCEAuthStrategy.ts:534

Released under the MIT License.