Skip to content

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

Class: AnonymousAuthStrategy ​

Anonymous authentication strategy No authentication required - user remains anonymous

Implements ​

Table of contents ​

Constructors ​

Properties ​

Methods ​

Constructors ​

constructor ​

• new AnonymousAuthStrategy(config?): AnonymousAuthStrategy

Parameters ​

NameType
config?AnonymousAuthConfig

Returns ​

AnonymousAuthStrategy

Defined in ​

core/auth/AnonymousAuthStrategy.ts:95

Properties ​

TOKEN_EXPIRY_BUFFER_MS ​

▪ Static Readonly TOKEN_EXPIRY_BUFFER_MS: number = ACCESS_TOKEN_REFRESH_BUFFER_MS

Defined in ​

core/auth/AnonymousAuthStrategy.ts:93

Methods ​

initialize ​

▸ initialize(options?): Promise<void>

Initialize the anonymous authentication strategy

Parameters ​

NameType
options?AuthStrategyInitializeOptions

Returns ​

Promise<void>

Implementation of ​

AuthStrategy.initialize

Defined in ​

core/auth/AnonymousAuthStrategy.ts:115


updateScopes ​

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

Replace the scopes used for the next token request, e.g. once agent details reveal per-agent extraScopes. The token cache key carries a fingerprint of the scope list, so a token cached for a different scope set is not reused and a token cached for the same set (in any order) is.

Parameters ​

NameTypeDescription
scopesstring[]Unprefixed resource scopes; the permission prefix is applied at request time
deploymentInfo?anyOptional refreshed deployment info

Returns ​

Promise<void>

Implementation of ​

AuthStrategy.updateScopes

Defined in ​

core/auth/AnonymousAuthStrategy.ts:130


clearMetadataCache ​

▸ clearMetadataCache(): void

Clears all cached metadata entries

Returns ​

void

Defined in ​

core/auth/AnonymousAuthStrategy.ts:207


authenticate ​

▸ authenticate(): Promise<void>

Authenticate the anonymous user

Returns ​

Promise<void>

Implementation of ​

AuthStrategy.authenticate

Defined in ​

core/auth/AnonymousAuthStrategy.ts:244


isAuthenticated ​

▸ isAuthenticated(): boolean

Check if the user is currently authenticated

Returns ​

boolean

Implementation of ​

AuthStrategy.isAuthenticated

Defined in ​

core/auth/AnonymousAuthStrategy.ts:257


getToken ​

▸ getToken(): Promise<null | string>

Get authentication token for anonymous user Returns cached token if valid, otherwise fetches a new one Token is cached with TTL based on expires_in from the token response

Returns ​

Promise<null | string>

Implementation of ​

AuthStrategy.getToken

Defined in ​

core/auth/AnonymousAuthStrategy.ts:309


clearTokenCache ​

▸ clearTokenCache(): void

Clear the cached token for the current scope set Forces a new token to be fetched on next getToken() call. Tokens cached for other scope sets are left alone (they expire on their own); clearMetadataCache clears the whole prefix, token entries included.

Returns ​

void

Defined in ​

core/auth/AnonymousAuthStrategy.ts:387


cleanup ​

▸ cleanup(): Promise<void>

Cleanup resources.

Intentionally a no-op: token and metadata live in sessionStorage so a later widget remount (or a new AnonymousAuthStrategy after anonymous→PKCE switch) can reuse them instead of calling the anonymous token API again. Call clearTokenCache / clearMetadataCache to force a refresh.

Returns ​

Promise<void>

Implementation of ​

AuthStrategy.cleanup

Defined in ​

core/auth/AnonymousAuthStrategy.ts:401


getDeploymentInfo ​

▸ getDeploymentInfo(domain): Promise<any>

Get deployment information a given domain

Parameters ​

NameType
domainstring

Returns ​

Promise<any>

Defined in ​

core/auth/AnonymousAuthStrategy.ts:409

Released under the MIT License.