@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
- buildConfigFromDeploymentInfo
- initialize
- authenticate
- isAuthenticated
- getToken
- startAuthorizationFlow
- handleCallback
- refreshToken
- cleanup
Constructors
constructor
• new PKCEAuthStrategy(config): PKCEAuthStrategy
Parameters
| Name | Type |
|---|---|
config | PKCEAuthConfig |
Returns
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
| Name | Type | Description |
|---|---|---|
deploymentInfo | any | Deployment information containing API domain, client IDs, tenant ID |
agentDetails | any | Agent details containing userType and other agent-specific information |
endpoint | string | The endpoint URL used to fetch deployment info (used for nextRoute) |
scopes | string[] | Scopes to request (passed from AuthenticationService) |
logger? | Logger | Optional logger instance for logging |
authScheme? | "popup" | "redirect" | Authentication scheme: 'popup' or 'redirect' (defaults to 'popup') |
egClientId? | string | Optional client ID override from initParams (takes priority over deployment client IDs) |
localLogin? | boolean | When 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
| Name | Type |
|---|---|
options? | AuthStrategyInitializeOptions |
Returns
Promise<void>
Implementation of
Defined in
core/auth/PKCEAuthStrategy.ts:249
authenticate
▸ authenticate(): Promise<void>
Authenticate using PKCE flow
Returns
Promise<void>
Implementation of
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
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
| Name | Type |
|---|---|
code | string |
state | string |
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>