Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
feat(core): add shared api-client module for auth headers
yushenf76312511df3
diff --git a/packages/core/src/hub/api-client.ts b/packages/core/src/hub/api-client.tsnew file mode 100644index 0000000000..a622c67a43--- /dev/null+++ b/packages/core/src/hub/api-client.ts@@ -0,0 +1,21 @@+import { getLocalAuth } from "./auth-store.js";++export const API_BASE_URL = "https://api-dev.copilothub.ai";++/**+ * Return auth headers for the proxy API.+ * Throws if the user is not logged in.+ */+export function getAuthHeaders(): Record<string, string> {+ const auth = getLocalAuth();+ if (!auth) {+ throw new Error(+ "Not logged in. Please sign in via the Desktop app.",+ );+ }+ return {+ sid: auth.sid,+ "device-id": auth.deviceId,+ "os-type": "3",+ };+}diff --git a/packages/core/src/hub/index.ts b/packages/core/src/hub/index.tsindex 671f72bdca..93c15b7a71 100644--- a/packages/core/src/hub/index.ts+++ b/packages/core/src/hub/index.ts@@ -2,4 +2,5 @@ export { Hub } from "./hub.js";export type { MessageSource, InboundMessageEvent } from "./hub.js";export { getHubId } from "./hub-identity.js";export { getLocalAuth, type LocalAuthData } from "./auth-store.js";+export { API_BASE_URL, getAuthHeaders } from "./api-client.js";export type { HubOptions } from "./types.js";