AuthClient

Class Exchanges an API key for short-lived (60-minute) bearer access tokens at POST /auth/token, and caches the current token until shortly before it expires. Concurrent callers share one in-flight request.

Properties​

NameTypeDescription
baseUrlstring-
cached?{ access_token: string; expires_at: number; expires_in: number; role: string; scope: string; token_type: string; workspace_id: string }-
httpAxiosInstance-
optionsAuthClientOptions-
pending?Promise-

Members​

constructor​

(options: AuthClientOptions) => AuthClient

Parameters​

NameTypeDescription
optionsAuthClientOptions-

createAccessToken​

() => Promise

Requests a new access token, bypassing the cache.

getAccessToken​

(forceRefresh: boolean) => Promise

Returns a valid access token, requesting a new one when there is no cached token or it is about to expire.

Parameters​

NameTypeDescription
forceRefreshbooleanIgnore the cached token.

getJwks​

() => Promise

Fetches the public keys that verify the issued tokens (RS256 JWTs).

isExpiring​

(token: { access_token: string; expires_at: number; expires_in: number; role: string; scope: string; token_type: string; workspace_id: string }) => boolean

Parameters​

NameTypeDescription
token{ access_token: string; expires_at: number; expires_in: number; role: string; scope: string; token_type: string; workspace_id: string }-

Source: auth/index.ts:27