Skip to content

Commit 3bc728e

Browse files
fix(twitch): register chat intent for refreshing auth (#83750)
Summary: - The PR registers Twitch refreshing-token users with Twurple's chat intent and adds regression coverage for that contract. - Reproducibility: yes. by source and dependency contract. Current main does not register the chat intent, and ... RefreshingAuthProvider only resolves getAccessTokenForIntent('chat') when that intent is mapped to a user. Automerge notes: - PR branch already contained follow-up commit before automerge: fix(twitch): register chat intent for refreshing auth Validation: - ClawSweeper review passed for head 1fdadcf. - Required merge gates passed before the squash merge. Prepared head SHA: 1fdadcf Review: #83750 (comment) Co-authored-by: Andy Ye <35905412+TurboTheTurtle@users.noreply.github.com> Co-authored-by: clawsweeper <274271284+clawsweeper[bot]@users.noreply.github.com> Co-authored-by: clawsweeper[bot] <274271284+clawsweeper[bot]@users.noreply.github.com>
1 parent c81271e commit 3bc728e

3 files changed

Lines changed: 39 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ Docs: https://docs.openclaw.ai
9494
- Telegram: keep queued forum-topic follow-up messages from inheriting superseded source abort signals, so later same-topic user turns can still run and reply after an active turn is replaced. (#83827) Thanks @VACInc.
9595
- CLI/update: bypass npm freshness filters consistently during managed package and plugin installs so freshly published release plugins remain installable. Thanks @jalehman.
9696
- CLI/update: guide root-owned npm install EACCES recovery by stopping the managed Gateway before manual package replacement, then reinstalling and restarting the service. Fixes #83747. (#83757) Thanks @brokemac79.
97+
- Twitch: register refreshing chat tokens with Twurple's chat intent so automatic token refresh keeps chat access available. (#83750) Thanks @TurboTheTurtle.
9798
- Agents/subagents: keep collect-mode announce queues batching unresolved-origin items with compatible same-route messages and resume collection after a true cross-channel drain when a later compatible batch remains. Fixes #83577.
9899
- Skills: refresh existing session skill snapshots when watched skill roots change, so changed extra skill directories take effect without starting a new session. Fixes #83782. (#83800) Thanks @hclsys.
99100
- Providers/Anthropic: preserve native image input for current Claude model rows when stale local catalog data marks them text-only. (#83756) Thanks @TurboTheTurtle.

extensions/twitch/src/twitch-client.test.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,33 @@ describe("TwitchClientManager", () => {
201201
);
202202
});
203203

204+
it("should register refreshing tokens for Twurple chat intent", async () => {
205+
const refreshingAccount: TwitchAccountConfig = {
206+
...testAccount,
207+
clientSecret: "test-client-secret",
208+
refreshToken: "test-refresh-token",
209+
expiresIn: 3600,
210+
obtainmentTimestamp: 1_700_000_000_000,
211+
};
212+
213+
await manager.getClient(refreshingAccount);
214+
215+
expect(mockAddUserForToken).toHaveBeenCalledTimes(1);
216+
expect(mockAddUserForToken).toHaveBeenCalledWith(
217+
{
218+
accessToken: "mock-token-from-tests",
219+
refreshToken: "test-refresh-token",
220+
expiresIn: 3600,
221+
obtainmentTimestamp: 1_700_000_000_000,
222+
},
223+
["chat"],
224+
);
225+
expect(mockAuthProvider.constructor).not.toHaveBeenCalled();
226+
expect(mockLogger.info).toHaveBeenCalledWith(
227+
"Using RefreshingAuthProvider for testbot (automatic token refresh enabled)",
228+
);
229+
});
230+
204231
it("should throw error when clientId is missing", async () => {
205232
const accountWithoutClientId: TwitchAccountConfig = {
206233
...testAccount,

extensions/twitch/src/twitch-client.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import { resolveTwitchToken } from "./token.js";
66
import type { ChannelLogSink, TwitchAccountConfig, TwitchChatMessage } from "./types.js";
77
import { normalizeToken } from "./utils/twitch.js";
88

9+
const TWITCH_CHAT_AUTH_INTENTS = ["chat"];
10+
911
/**
1012
* Manages Twitch chat client connections
1113
*/
@@ -33,12 +35,15 @@ export class TwitchClientManager {
3335
});
3436

3537
await authProvider
36-
.addUserForToken({
37-
accessToken: normalizedToken,
38-
refreshToken: account.refreshToken ?? null,
39-
expiresIn: account.expiresIn ?? null,
40-
obtainmentTimestamp: account.obtainmentTimestamp ?? Date.now(),
41-
})
38+
.addUserForToken(
39+
{
40+
accessToken: normalizedToken,
41+
refreshToken: account.refreshToken ?? null,
42+
expiresIn: account.expiresIn ?? null,
43+
obtainmentTimestamp: account.obtainmentTimestamp ?? Date.now(),
44+
},
45+
TWITCH_CHAT_AUTH_INTENTS,
46+
)
4247
.then((userId) => {
4348
this.logger.info(
4449
`Added user ${userId} to RefreshingAuthProvider for ${account.username}`,

0 commit comments

Comments
 (0)