@theholocron/http-client 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -20,9 +20,10 @@ interface RestClientConfig {
20
20
  /**
21
21
  * How the token is sent.
22
22
  * - `"bearer"` (default): `Authorization: Bearer <token>`
23
+ * - `"basic"`: `Authorization: Basic <token>`
23
24
  * - `"apikey"`: uses `apiKeyHeader` (e.g. `x-api-key`)
24
25
  */
25
- tokenScheme?: "bearer" | "apikey";
26
+ tokenScheme?: "bearer" | "basic" | "apikey";
26
27
  /** Header name when `tokenScheme` is `"apikey"`. Defaults to `"x-api-key"`. */
27
28
  apiKeyHeader?: string;
28
29
  /**
package/dist/index.mjs CHANGED
@@ -23,6 +23,7 @@ function createRestClient(config) {
23
23
  while (baseUrl.endsWith("/")) baseUrl = baseUrl.slice(0, -1);
24
24
  const staticHeaders = { accept: "application/json" };
25
25
  if (config.tokenScheme === "apikey") staticHeaders[config.apiKeyHeader ?? "x-api-key"] = config.token;
26
+ else if (config.tokenScheme === "basic") staticHeaders["authorization"] = `Basic ${config.token}`;
26
27
  else staticHeaders["authorization"] = `Bearer ${config.token}`;
27
28
  Object.assign(staticHeaders, config.extraHeaders);
28
29
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theholocron/http-client",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Shared HTTP primitives for theholocron — REST client factory, auth resolver, and error types",
5
5
  "homepage": "https://github.com/theholocron/clients/tree/main/packages/http-client#readme",
6
6
  "bugs": "https://github.com/theholocron/clients/issues",