@healthcloudai/hc-login-connector
v0.0.4
Published
Healthcheck Login authentication SDK with TypeScrip and token refresh
Maintainers
Readme
Healthcheck Login Connector
This library provides a client for authenticating users. It handles login, password reset, token refresh, and authenticated user context retrieval.
The connector is built on top of the shared Healthcheck HTTP layer.
Features
- Patient login to Healthcheck tenant
- Password reset flow
- Access token and refresh token handling
- Token refresh support
- Retrieval of authenticated user information
- Built on shared Healthcheck HttpClient
Installation
npm install @healthcloudai/hc-login-connector \
@healthcloudai/hc-httpImport
import { HCLoginClient } from "@healthcloudai/hc-login-connector";
import { FetchClient } from "@healthcloudai/hc-http";Usage
Configuration
Before calling any authentication methods, the client must be configured with a tenant ID and environment.
const httpClient = new FetchClient();
const loginClient = new HCLoginClient(httpClient);
loginClient.configure("tenant-id", "dev");
// Optional region:
// loginClient.configure("tenant-id", "dev", "mx");Methods
Login
await loginClient.login("[email protected]", "password");Reset Password
await loginClient.resetPassword("[email protected]");Refresh Token
await loginClient.refreshToken();Get Auth Header
Returns the authorization headers required for authenticated API requests. This method is used internally by other Healthcheck connectors.
const headers = loginClient.getAuthHeader();Get User Info
const userInfo = await loginClient.getUserInfo();Get Header
await loginClient.getHeader();How It Works
HCLoginClient
- Manages authentication and token lifecycle
- Stores access, refresh, and ID tokens internally
- Provides authorization headers for other connectors
HttpClient
- Handles all HTTP communication
- Used by the login client and all other Healthcheck SDK modules
Other connectors (Appointments, EHR, Healthservice, Settings, etc.)
consume authentication headers via getAuthHeader() and do not manage tokens directly.
Notes
- Authentication logic is centralized in
HCLoginClient - This connector is required by most other Healthcheck SDK connectors
