gencow 0.1.10 → 0.1.11

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/bin/gencow.mjs CHANGED
@@ -1764,8 +1764,22 @@ ${BOLD}Examples:${RESET}
1764
1764
  error(`Login failed: ${errData.message || errData.error || res.statusText}`);
1765
1765
  process.exit(1);
1766
1766
  }
1767
- const data = await res.json();
1768
- const apiKey = data.token;
1767
+ // Extract signed session token from Set-Cookie header
1768
+ // better-auth returns unsigned token in JSON body, but signed token in cookie
1769
+ const cookies = res.headers.getSetCookie?.() || [];
1770
+ let apiKey = null;
1771
+ for (const cookie of cookies) {
1772
+ const match = cookie.match(/better-auth\.session_token=([^;]+)/);
1773
+ if (match) {
1774
+ apiKey = decodeURIComponent(match[1]);
1775
+ break;
1776
+ }
1777
+ }
1778
+ if (!apiKey) {
1779
+ // Fallback to JSON body token
1780
+ const data = await res.json().catch(() => ({}));
1781
+ apiKey = data.token;
1782
+ }
1769
1783
  if (!apiKey) {
1770
1784
  error("Login failed: No token in response");
1771
1785
  process.exit(1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gencow",
3
- "version": "0.1.10",
3
+ "version": "0.1.11",
4
4
  "description": "Gencow — Backend OS for AI Agents",
5
5
  "type": "module",
6
6
  "bin": {
package/server/index.js CHANGED
@@ -7214,7 +7214,24 @@ function betterAuthMiddleware() {
7214
7214
  };
7215
7215
  }
7216
7216
  } catch (e) {
7217
- authError = e instanceof Error ? e : new Error(String(e));
7217
+ try {
7218
+ const session2 = await authInstance.api.getSession({
7219
+ headers: new Headers({
7220
+ cookie: `better-auth.session_token=${token}`
7221
+ })
7222
+ });
7223
+ if (session2?.user) {
7224
+ currentUser = {
7225
+ id: session2.user.id,
7226
+ email: session2.user.email,
7227
+ name: session2.user.name ?? void 0
7228
+ };
7229
+ } else {
7230
+ authError = e instanceof Error ? e : new Error(String(e));
7231
+ }
7232
+ } catch {
7233
+ authError = e instanceof Error ? e : new Error(String(e));
7234
+ }
7218
7235
  }
7219
7236
  }
7220
7237
  if (!currentUser && !authError) {