Registry↗Dashboard↗

Authentication

Authentication strategies for API key and JWT session-based auth. Factory function and strategy classes.

6 methods

auth.createAuthStrategy()

Create an auth strategy from config. Priority: apiKey > sessionToken > email/password.

apiKeyoptionalstring

API key (must start with 'ulr_' prefix).

emailoptionalstringemail

Email for session auth.

passwordoptionalstring

Password for session auth.

sessionTokenoptionalstring

Pre-existing session token.

httpClientoptionalFetchClient

HTTP client for auth requests.

onTokenRefreshoptional(token: string) => void

Callback when token is refreshed.

clearCredentialsAfterLoginoptionalboolean

Clear plaintext password from memory after first successful login (default: true). Set false for long-lived unattended sessions.

Default: true
Throws if no valid credentials are provided.
createAuthStrategy(config: AuthConfig): AuthStrategy
typescript
import { HttpClient } from '@uluops/sdk-core';

const client = new HttpClient({
  apiKey: 'ulr_your-api-key',
});

const result = await auth.createAuthStrategy();
Response Type
AuthStrategy

auth.getAuthorizationHeader()

Get the Authorization header value for the current strategy (e.g., 'Bearer token...').

Method on AuthStrategy interface.
getAuthorizationHeader(): string
typescript
import { HttpClient } from '@uluops/sdk-core';

const client = new HttpClient({
  apiKey: 'ulr_your-api-key',
});

const result = await auth.getAuthorizationHeader();
Response Type
string

auth.canRefresh()

Check if the strategy supports automatic token refresh. True for session auth with email/password credentials.

Method on AuthStrategy interface.
canRefresh(): boolean
typescript
import { HttpClient } from '@uluops/sdk-core';

const client = new HttpClient({
  apiKey: 'ulr_your-api-key',
});

const result = await auth.canRefresh();
Response Type
boolean

auth.refresh()

Refresh the credential by re-authenticating. Only callable when canRefresh() returns true.

Method on AuthStrategy interface. Throws if not refreshable.
refresh(): Promise<void>
typescript
import { HttpClient } from '@uluops/sdk-core';

const client = new HttpClient({
  apiKey: 'ulr_your-api-key',
});

const result = await auth.refresh();
Response Type
Promise<void>

auth.isAuthenticated()

Check whether the strategy currently holds a valid credential.

Method on AuthStrategy interface.
isAuthenticated(): boolean
typescript
import { HttpClient } from '@uluops/sdk-core';

const client = new HttpClient({
  apiKey: 'ulr_your-api-key',
});

const result = await auth.isAuthenticated();
Response Type
boolean

auth.getType()

Get the credential type discriminator.

Method on AuthStrategy interface.
getType(): 'api_key' | 'session'
typescript
import { HttpClient } from '@uluops/sdk-core';

const client = new HttpClient({
  apiKey: 'ulr_your-api-key',
});

const result = await auth.getType();
Response Type
'api_key' | 'session'