Skip to content

@egain/ai-agent-sdk API Reference - v0.1.1 / AuthenticationService

Class: AuthenticationService

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

Implements

Table of contents

Constructors

Methods

Constructors

constructor

new AuthenticationService(input?, logger?, cacheConfig?): AuthenticationService

Parameters

NameType
input?AuthenticationInput
logger?Logger
cacheConfig?AuthServiceCacheConfig

Returns

AuthenticationService

Defined in

core/auth/AuthenticationService.ts:159

Methods

initialize

initialize(options?): Promise<void>

Initialize the authentication service Delegates to the selected strategy

Parameters

NameType
options?AuthServiceInitializeOptions

Returns

Promise<void>

Implementation of

AuthStrategy.initialize

Defined in

core/auth/AuthenticationService.ts:309


getDomain

getDomain(): string

Get the domain for authentication

Returns

string

Implementation of

AuthStrategy.getDomain

Defined in

core/auth/AuthenticationService.ts:365


authenticate

authenticate(): Promise<void>

Authenticate using the selected strategy

Returns

Promise<void>

Implementation of

AuthStrategy.authenticate

Defined in

core/auth/AuthenticationService.ts:372


getToken

getToken(): Promise<null | string>

Get the authentication token from the selected strategy

Returns

Promise<null | string>

Implementation of

AuthStrategy.getToken

Defined in

core/auth/AuthenticationService.ts:387


cleanup

cleanup(): Promise<void>

Cleanup resources from the selected strategy

Returns

Promise<void>

Implementation of

AuthStrategy.cleanup

Defined in

core/auth/AuthenticationService.ts:401


getAuthenticationType

getAuthenticationType(): AuthenticationType

Get the current authentication type

Returns

AuthenticationType

Defined in

core/auth/AuthenticationService.ts:413


getIsInitialized

getIsInitialized(): boolean

Check if the service is initialized

Returns

boolean

Defined in

core/auth/AuthenticationService.ts:420


getStrategy

getStrategy(): AuthStrategy

Get the underlying strategy (for advanced use cases)

Returns

AuthStrategy

The underlying AuthStrategy instance

Defined in

core/auth/AuthenticationService.ts:428


isAnonymousStrategy

isAnonymousStrategy(): boolean

Check if the current strategy is anonymous

Returns

boolean

True if the current strategy is anonymous, false otherwise

Defined in

core/auth/AuthenticationService.ts:436


isPKCEStrategy

isPKCEStrategy(): boolean

Check if the current strategy is PKCE

Returns

boolean

True if the current strategy is PKCE, false otherwise

Defined in

core/auth/AuthenticationService.ts:444


updateToken

updateToken(token): Promise<void>

Update the access token at runtime Only supported for PreAuthStrategy

Parameters

NameTypeDescription
tokenstringThe new access token

Returns

Promise<void>

Throws

AuthError if the underlying strategy doesn't support token updates

Defined in

core/auth/AuthenticationService.ts:454


setTokenExpiringCallback

setTokenExpiringCallback(callback): void

Set the callback to be called when token is about to expire Only supported for PreAuthStrategy

Parameters

NameTypeDescription
callbackTokenExpiringCallbackFunction to call when token is expiring, receives expiresAt timestamp

Returns

void

Defined in

core/auth/AuthenticationService.ts:475


switchStrategyTo

switchStrategyTo(pkceConfig, postAuthentication?): Promise<boolean>

Switch from anonymous strategy to PKCE strategy Only switches if the current strategy is anonymous, otherwise keeps the same strategy

Parameters

NameTypeDescription
pkceConfigPKCEAuthConfigPKCE configuration options
postAuthentication?PostAuthenticationCallback-

Returns

Promise<boolean>

True if strategy was switched, false if it was already PKCE or not anonymous

Defined in

core/auth/AuthenticationService.ts:496

Released under the MIT License.