Commit Graph
2 Commits
Author SHA1 Message Date
yetone abefa04ff9 orcaterm: refresh-token test holds one expiry for its tokens (#675)
refresh-token.test.mjs (db307844) built each fixture token with an exp
read from the clock on every call, so two tokens for the same jti
differed when the calls fell either side of a second boundary. The QR
sign-in test compared them and went red on CI run 41774409142 (it
skipped that publish run's dist job, so reasonix-desktop 0.1.0 from #700
waits for the next one). The file now reads the clock once.

Run (mote): refresh-token.test.mjs 8 times, 6 pass / 0 fail each.
Broken by hand: a 1.1s sleep inside the QR test: green with the fixed
expiry, 1 fail with the old per-call one.
Not tried: the whole orcaterm package again (only this test file
changed).
2026-11-04 12:47:15 +08:00
yetone db307844e7 orcaterm 0.1.6: keep the WeChat sign-in's refresh token and renew from it (#675)
orinsid's desktop-client logs (#675, 11-04) show OrcaTerm 1.6.8 renewing
from a long-lived oauth_refresh_token_v2 on a 110-minute schedule, while
the plugin dropped the exchange's refresh token (`refresh: r.accessToken`)
and renewed from the two-hour access token, which OrcaTerm answers
SESSION_EXPIRED for 30 minutes into an idle sign-in.

OrcaTerm's own bundle (orcaterm.cloud.tencent.com/terminal,
orcaterm_components/orcaterm_app, fetched 11-04) settles the protocol:
- the WeChat exchange sends {code, state, client: "desktop"} from the
  desktop client, and reads data.refreshToken from the reply;
- the client keeps a refresh token only when it matches
  /^<uuid>\.\d{1,6}\.[A-Za-z0-9_-]{43}$/ and its uuid is the access
  token's jti (persistLoginRefreshToken);
- OAuthRefreshToken sends {refreshToken} when it has one, else
  {accessToken}.

The plugin now does the same: the exchange sends client "desktop", a
matching refresh token is the sign-in's `refresh`, renewal sends it (an
access token past its expiry no longer stops a renewal that has one),
and a reply's RefreshToken replaces it, else it is kept. A sign-in from
before 0.1.6 has the access token in `refresh` and renews as before
until the next scan.

Run (mote): packages/orcaterm `bun test`, 121 pass / 0 fail, including
the new refresh-token.test.mjs (6 tests).
Broken by hand: dropped client "desktop", sent {accessToken} always and
saved `refresh: r.accessToken` again: 4 of the 6 new tests went red (the
two that stay green check a mismatched token isn't kept and the
pre-0.1.6 path).
Not tried: a real WeChat sign-in. No OrcaTerm account here, so whether
the reply to client "desktop" carries refreshToken for this flow, and
whether renewal rotates it, is from the vendor's bundle, not a capture.
If the reply has none, the sign-in falls back to the 0.1.5 behaviour.
2026-11-04 12:37:29 +08:00