BkperAuthConfig
Configuration options for the BkperAuth class.
Properties
baseUrl?
optional baseUrl: string;Override the authentication service base URL.
Most users don’t need this. The default production URL works out of the box.
Use cases:
- Testing: Point to a mock authentication service for integration tests
- Development: Use a local mock server
Example
// Testing with mock serverconst auth = new BkperAuth({ baseUrl: 'http://localhost:3000/mock-auth'});getAdditionalAuthParams()?
optional getAdditionalAuthParams: () => Record<string, string>;Provide additional parameters to send to the authentication service.
Useful for custom authentication flows or passing additional context to your authentication implementation.
Returns
Record<string, string>
Record of key-value pairs to append to auth requests
Example
// Custom authentication contextconst auth = new BkperAuth({ getAdditionalAuthParams: () => { const token = new URLSearchParams(location.search).get('custom-token'); return token ? { customToken: token } : {}; }});onError()?
optional onError: (error) => void;Called when an error occurs during authentication.
Parameters
| Parameter | Type | Description |
|---|---|---|
error | unknown | The error that occurred |
Returns
void
onLoginRequired()?
optional onLoginRequired: () => void;Called when login is required (user needs to sign in).
Returns
void
onLoginSuccess()?
optional onLoginSuccess: () => void;Called when login succeeds (user is authenticated).
Returns
void
onLogout()?
optional onLogout: () => void;Called when the user logs out.
Returns
void
onTokenRefresh()?
optional onTokenRefresh: (token) => void;Called when the access token is refreshed.
Parameters
| Parameter | Type | Description |
|---|---|---|
token | string | The new access token |
Returns
void