Establishes a connection to the backend using the supplied credentials.
Performs a health‑check ping first; if successful, it requests an authentication
token from the /token endpoint. When the token is obtained, the method
updates internal state (authorization header, connection flags) and, unless
a dry run is requested, sets up a reconnection routine. Any errors are
logged and the method resolves to false.
The user's email address for authentication.
The password (or token) for the specified user.
Optionalrefresh: booleanOptionaldry: boolean
If true, the method performs a dry run
without persisting credentials or configuring reconnection logic.
Promisetrue if the connection was successfully
established, otherwise false.
Attempts to establish a connection to the backend without authentication.
This method sends a ping request. If the ping succeeds, it clears any
existing authorization data, marks the instance as connected,
enables the no‑authentication mode, and returns true. If the ping
fails, it logs a warning, clears authorization, marks the instance
as disconnected, and returns false.
true when a connection is successfully
established without authentication, otherwise false.
Forces a connection using the provided bearer token.
The token to be used for authentication.
Optionalrefresh: string | nullRetrieves the API endpoint.
The API endpoint string.
Returns the current authorization token.
The authorization token or an empty string if none is set.
Performs an HTTP request using the client’s internal connection.
The method verifies that the client is connected before attempting a request.
It automatically injects the authorization token, permanent headers, and any
headers supplied in config. If the request body is a FormData instance
(or provides a getHeaders method), the appropriate form headers are added.
Response handling:
200 or 201: returns success: true with the received data.498: attempts to reconnect and retries the request once.401: logs an authentication error, marks the client as disconnected.403 and other status codes: return success: false with the status code.The HTTP method to use.
The endpoint path relative to the base URL.
Optionalbody: J
Optional request payload. May be FormData or a plain object.
Optionalconfig: ConHandleConfig
Optional Axios-like configuration for the request.
A promise that resolves to a HandleRes object
containing the response data, status code, any error information, and headers.
Indicates whether the instance is considered connected.
The instance is regarded as connected when it either does not require authentication
(noAuth is true) or it has an authorization token set (authorization is not null),
and it is not currently marked as disconnected.
true if the instance is connected, false otherwise.
Optionalconfig: ConHandleConfigSends a ping request to the API to verify connectivity and version availability.
true if the API responded with a 200 status code and a valid version object; false otherwise.
Sets the API endpoint URL used by the client.
The full URL of the API endpoint.
Validates the current authentication token by performing a ping and a test request
to the backend. The method first ensures connectivity via ping. If the ping
succeeds, it attempts to retrieve a token from the /test/auth endpoint using the
current token in the Authorization header. The operation is considered successful
if the response status code is 200 or 201.
If any step fails, an error is logged and the method returns {@code false}. On success, it returns {@code true}.
A promise that resolves to {@code true} if the token test succeeds, otherwise {@code false}.
Returns the current authorization token.
The authorization token or an empty string if none is set.
BaseCon provides a minimal client for interacting with an HTTP backend. It manages connection state, authentication tokens, and reconnection logic while delegating actual HTTP requests to a supplied ConHandle.