Skip to content

@egain/ai-agent-sdk API Reference - v0.3.2 / AuthStrategy

Interface: AuthStrategy ​

Base interface for authentication strategies All authentication strategies must implement this interface

Hierarchy ​

Implemented by ​

Table of contents ​

Methods ​

Methods ​

getToken ​

▸ getToken(): Promise<null | string>

Get an authentication token This method may be called multiple times, so implementations should handle token refresh if needed

Returns ​

Promise<null | string>

Inherited from ​

AuthProvider.getToken

Defined in ​

core/auth/AuthProvider.ts:11


initialize ​

▸ initialize(options?): Promise<void>

Initialize the authentication strategy This method sets up the strategy but does not perform authentication Called when the strategy is set on the agent

Parameters ​

NameTypeDescription
options?AuthStrategyInitializeOptionsInitialize options including postAuthentication callback

Returns ​

Promise<void>

Defined in ​

core/auth/AuthStrategy.ts:65


authenticate ​

▸ authenticate(): Promise<void>

Authenticate the user This method performs the actual authentication flow The postAuthentication callback registered during initialize() will be called after authentication completes

Returns ​

Promise<void>

Defined in ​

core/auth/AuthStrategy.ts:72


isAuthenticated ​

▸ isAuthenticated(): boolean

Whether the strategy currently has an authenticated session

Returns ​

boolean

Defined in ​

core/auth/AuthStrategy.ts:77


logout ​

▸ logout(): Promise<void>

Log out of the identity provider. Optional; PKCE implements this via MSAL using the same popup/redirect scheme as login. Takes no options.

Returns ​

Promise<void>

Defined in ​

core/auth/AuthStrategy.ts:83


updateScopes ​

▸ updateScopes(scopes, deploymentInfo?): Promise<void>

Replace the scopes used for subsequent token requests without re-running initialization. Optional; the anonymous strategy implements it so per-agent extraScopes learned after the first token can apply to the next one.

Parameters ​

NameTypeDescription
scopesstring[]Unprefixed resource scopes
deploymentInfo?anyOptional refreshed deployment info

Returns ​

Promise<void>

Defined in ​

core/auth/AuthStrategy.ts:92


cleanup ​

▸ cleanup(): Promise<void>

Cleanup resources when the strategy is no longer needed

Returns ​

Promise<void>

Defined in ​

core/auth/AuthStrategy.ts:97


getDomain ​

▸ getDomain(): string

Get the domain for authentication

Returns ​

string

Defined in ​

core/auth/AuthStrategy.ts:102

Released under the MIT License.