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.