Commit Graph

5 Commits

Author SHA1 Message Date
wbtiger 95fdee5cd8 fix: use cookie-based auth for login — resolves Windows 401
Root cause: GitLink login API returns session cookies (autologin_trustie),
not API access_tokens. The old code tried to use the cookie value as an
access_token query parameter, which GitLink rejects.

Fix: store auth cookies with "cookie:" prefix. Transport detects the
prefix and sends credentials as Cookie header instead of access_token
param. Private tokens (from --token mode) continue to use access_token
param — fully backward compatible.

Verified: login → store cookie → GetCurrentUser → repo list all pass.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-08 13:01:55 +08:00
wbtiger a27122ab76 fix: GetCurrentUser must check HTTP status and JSON status for token verification
GetCurrentUser() was not checking the HTTP status code or the JSON
"status" field. GitLink returns {"status":401,"message":"无效token"}
as valid JSON, so json.Unmarshal succeeds and the function returns nil
error — making any token appear valid.

Now properly checks HTTP status code, JSON status field, and requires
"login" field in response. If login API tokens fail verification,
shows clear guidance to use private token (--token mode).

Root cause of Windows 401: login API returns session/CSRF token, not
a valid API access_token. The broken verification masked this entirely.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-08 12:38:25 +08:00
wbtiger 993896ad6f fix: robust login token handling — verify token before storing
- Prefer autologin cookie over response body token (body token may be CSRF/session token)
- Use cookiejar to capture cookies across redirects
- Try all candidate tokens and verify each with /users/me API call
- Detect keyring store/load mismatch and auto-fallback to file storage
- Login now fails fast if no candidate token works, instead of silently storing a bad token

Fixes Windows 401 "无效token" after successful login. Also improves
reliability on headless Linux (no Secret Service) and edge cases on macOS.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-07 17:19:06 +08:00
wbtiger 342badbdd2 feat: add Windows (x64/arm64) support
- Add windows/amd64 and windows/arm64 to build targets with .zip packaging
- Update npm install.js: win32 platform detection, .exe binary, PowerShell zip extraction
- Update npm cli.js wrapper to append .exe on Windows
- Fix credential path to use filepath.Join for cross-platform compatibility
- Update README with Windows support docs and FAQ

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-07 10:52:56 +08:00
Your GitHub Username bd2d8b52d6 initial commit: gitlink-cli project 2026-04-02 16:50:00 +08:00