Repository navigation
Add SignalR TypeScript auth refresh - #67964
Merged
Merged
Conversation
Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds an opt-in authentication refresh feature to the SignalR TypeScript client, enabling both manual and scheduled token refresh based on server-reported lifetimes, while preserving redirect/Azure SignalR token semantics.
Changes:
- Introduces
withAuthenticationRefresh(...)onHubConnectionBuilder, new exported option/context types, and aHubConnection.refreshAuthentication()API with optional auto-refresh scheduling. - Extends
HttpConnection+AccessTokenHttpClientto capture token lifetimes from negotiate/refresh responses and to refresh viaPOST /refresh?id=...while keeping transport vs app tokens separated correctly. - Adds/updates Jest unit tests and a browser functional test validating refreshed claims without changing the user identifier.
Show a summary per file
| File | Description |
|---|---|
| src/SignalR/clients/ts/signalr/tests/OutputSize.test.ts | Updates size threshold for the minified bundle to account for added client functionality. |
| src/SignalR/clients/ts/signalr/tests/HubConnection.test.ts | Adds unit coverage for manual refresh, auto-refresh scheduling, cleanup, and failure logging. |
| src/SignalR/clients/ts/signalr/tests/HttpConnection.test.ts | Adds unit coverage for negotiate/refresh token lifetime parsing and refresh token behavior (redirect + token handling). |
| src/SignalR/clients/ts/signalr/src/index.ts | Exports new authentication refresh option/context types as part of the public TS surface. |
| src/SignalR/clients/ts/signalr/src/IAuthenticationRefreshOptions.ts | Adds the new public option + callback context type definitions. |
| src/SignalR/clients/ts/signalr/src/HubConnectionBuilder.ts | Adds withAuthenticationRefresh(...) to opt into refresh behavior. |
| src/SignalR/clients/ts/signalr/src/HubConnection.ts | Implements manual refresh API + auto-refresh timer scheduling and callback invocation. |
| src/SignalR/clients/ts/signalr/src/HttpConnection.ts | Implements /refresh request flow, token lifetime parsing, and feature wiring to HubConnection. |
| src/SignalR/clients/ts/signalr/src/AccessTokenHttpClient.ts | Adds refresh-specific token factory behavior and tracks refresh request tokens. |
| src/SignalR/clients/ts/FunctionalTests/ts/HubConnectionTests.ts | Adds browser functional test validating refreshed claims with stable user identifier. |
| src/SignalR/clients/ts/FunctionalTests/Startup.cs | Enables authentication refresh on the authorized hub and issues scoped JWTs for test validation. |
| src/SignalR/clients/ts/FunctionalTests/AuthorizedHub.cs | Adds hub methods to read name identifier + claim values for refresh validation. |
Copilot's findings
Comments suppressed due to low confidence (1)
src/SignalR/clients/ts/signalr/src/HubConnection.ts:1135
- This log message interpolates the raw caught value, which can produce unhelpful output like '[object Object]'. Use
getErrorString(e)for consistent, readable error logging (as done elsewhere in this file).
this._logger.log(LogLevel.Error, `An onAuthenticationRefreshFailed callback threw error '${e}'.`);
- Files reviewed: 12/12 changed files
- Comments generated: 3
Co-authored-by: Copilot App <[email protected]>
halter73
reviewed
Jul 29, 2026
halter73
reviewed
Jul 29, 2026
Co-authored-by: Copilot App <[email protected]>
halter73
approved these changes
Jul 30, 2026
|
Pay Github Sponsors program |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
POST /refresh?id={connectionToken}, schedule automatic refresh, and expose manual refresh fromHubConnection.Validation
npm run buildinsrc\SignalR\clients\ts\signalrHttpConnection.test.tsandHubConnection.test.tstsconfig.json --noEmitTOTAL: 266 SUCCESSgit diff --check