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
| Name | Type | Description |
|---|---|---|
baseUrl | string | - |
cached? | { access_token: string; expires_at: number; expires_in: number; role: string; scope: string; token_type: string; workspace_id: string } | - |
http | AxiosInstance | - |
options | AuthClientOptions | - |
pending? | Promise | - |
Members
constructor
(options: AuthClientOptions) => AuthClient
Parameters
| Name | Type | Description |
|---|---|---|
options | AuthClientOptions | - |
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
| Name | Type | Description |
|---|---|---|
forceRefresh | boolean | Ignore 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
| Name | Type | Description |
|---|---|---|
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