Skip to content

@egain/ai-agent-sdk API Reference - v0.3.2 / 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 ​

NameType
configPreAuthConfig

Returns ​

PreAuthStrategy

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 ​

NameTypeDescription
callbackTokenExpiringCallbackFunction 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 ​

NameType
options?AuthStrategyInitializeOptions

Returns ​

Promise<void>

Implementation of ​

AuthStrategy.initialize

Defined in ​

core/auth/PreAuthStrategy.ts:174


authenticate ​

▸ authenticate(): Promise<void>

Authenticate using pre-auth token

Returns ​

Promise<void>

Implementation of ​

AuthStrategy.authenticate

Defined in ​

core/auth/PreAuthStrategy.ts:213


isAuthenticated ​

▸ isAuthenticated(): boolean

Check if the user is currently authenticated

Returns ​

boolean

Implementation of ​

AuthStrategy.isAuthenticated

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 ​

AuthStrategy.getToken

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 ​

NameTypeDescription
tokenstringThe 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>

Implementation of ​

AuthStrategy.cleanup

Defined in ​

core/auth/PreAuthStrategy.ts:277

Released under the MIT License.