@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
↳
AuthStrategy
Implemented by
AnonymousAuthStrategyAuthenticationServiceClientCredentialsAuthStrategyPKCEAuthStrategyPreAuthStrategy
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
Defined in
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
| Name | Type | Description |
|---|---|---|
options? | AuthStrategyInitializeOptions | Initialize options including postAuthentication callback |
Returns
Promise<void>
Defined in
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
isAuthenticated
▸ isAuthenticated(): boolean
Whether the strategy currently has an authenticated session
Returns
boolean
Defined in
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
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
| Name | Type | Description |
|---|---|---|
scopes | string[] | Unprefixed resource scopes |
deploymentInfo? | any | Optional refreshed deployment info |
Returns
Promise<void>
Defined in
cleanup
▸ cleanup(): Promise<void>
Cleanup resources when the strategy is no longer needed
Returns
Promise<void>
Defined in
getDomain
▸ getDomain(): string
Get the domain for authentication
Returns
string