@egain/ai-agent-sdk API Reference - v0.1.1 / PreAuthStrategy
Class: PreAuthStrategy
Pre-auth authentication strategy Uses a pre-obtained access token without completing authentication flow
Implements
Table of contents
Constructors
Methods
Constructors
constructor
• new PreAuthStrategy(config): PreAuthStrategy
Parameters
| Name | Type |
|---|---|
config | PreAuthConfig |
Returns
Defined in
core/auth/PreAuthStrategy.ts:57
Methods
setTokenExpiringCallback
▸ setTokenExpiringCallback(callback): void
Set the callback to be called when token is about to expire
Parameters
| Name | Type | Description |
|---|---|---|
callback | TokenExpiringCallback | Function to call when token is expiring |
Returns
void
Defined in
core/auth/PreAuthStrategy.ts:162
initialize
▸ initialize(options?): Promise<void>
Initialize the pre-auth authentication strategy Ensures the token is available and ready to use
Parameters
| Name | Type |
|---|---|
options? | AuthStrategyInitializeOptions |
Returns
Promise<void>
Implementation of
Defined in
core/auth/PreAuthStrategy.ts:174
authenticate
▸ authenticate(): Promise<void>
Authenticate using pre-auth token
Returns
Promise<void>
Implementation of
Defined in
core/auth/PreAuthStrategy.ts:213
isAuthenticated
▸ isAuthenticated(): boolean
Check if the user is currently authenticated
Returns
boolean
Defined in
core/auth/PreAuthStrategy.ts:234
getToken
▸ getToken(): Promise<string>
Get the access token If refresh function is provided and token is expired, attempts to refresh
Returns
Promise<string>
Implementation of
Defined in
core/auth/PreAuthStrategy.ts:242
updateToken
▸ updateToken(token): Promise<void>
Update the access token Cancels existing expiry timer and schedules new one based on new token If authenticated, calls postAuthentication callback with the new token
Parameters
| Name | Type | Description |
|---|---|---|
token | string | The new access token |
Returns
Promise<void>
Defined in
core/auth/PreAuthStrategy.ts:252
refreshToken
▸ refreshToken(): Promise<string>
Refresh the token using the provided refresh function
Returns
Promise<string>
Defined in
core/auth/PreAuthStrategy.ts:266
cleanup
▸ cleanup(): Promise<void>
Cleanup resources
Returns
Promise<void>