You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(claim): send canonical token wire field + surface session_token (#15)
Two user-impacting bugs in Client.Claim:
1. Wire-name drift. The SDK was posting body["jwt"] = opts.JWT — the
deprecated alias. The api ClaimRequest doc explicitly names sdk-go as
one of three drift sources for the legacy `jwt` field (with dashboard
+ MCP). Server accepts both with `token` winning on collision, so this
is wire-compatible.
2. ClaimResult.SessionToken missing. The api /claim handler returns a
freshly minted 24h session JWT in the response body, but the SDK's
result struct contained no field for it — every caller that wanted
to provision resources right after Claim() had to run a separate
magic-link login round-trip.
Changes:
- ClaimResult gains SessionToken `json:"session_token,omitempty"`.
- ClaimOpts gains canonical Token field (json:"token"); existing JWT
field retained as deprecated alias (json:"-") with claimToken() helper
that mirrors api.ClaimRequest.claimToken precedence (Token wins).
- claim.go sends body["token"] = opts.claimToken(); validation message
updated from "JWT is required" → "Token is required".
- Tests: TestClaim asserts wire body contains no `jwt` and has `token`,
plus SessionToken round-trip. Two regression tests added —
TestClaim_JWTFieldBackwardCompat (deprecated field still compiles and
the SDK still translates to canonical wire) and TestClaim_TokenWinsOverJWT
(precedence rule mirrors api).
Existing callers compile unchanged (JWT field retained). Project
coverage 97.8% (>95% floor), patch coverage 100%.
0 commit comments