Skip to content

feat(sdk): add User-Agent header to HTTP and OAuth requests#66

Merged
clavery merged 2 commits intomainfrom
feature/user-agent
Jan 22, 2026
Merged

feat(sdk): add User-Agent header to HTTP and OAuth requests#66
clavery merged 2 commits intomainfrom
feature/user-agent

Conversation

@clavery
Copy link
Collaborator

@clavery clavery commented Jan 22, 2026

Summary

  • Adds User-Agent and sfdc_user_agent headers to all HTTP requests and OAuth token requests
  • SDK standalone uses b2c-tooling-sdk/x.x.x format
  • CLI uses b2c-cli/x.x.x format
  • User-Agent middleware auto-registers via the global middleware registry for HTTP clients
  • Auth middleware registry extends User-Agent support to OAuth token requests (which bypass the HTTP client middleware chain)

Implementation

HTTP Requests:

  • createUserAgentMiddleware() in clients/middleware.ts
  • userAgentProvider auto-registers with globalMiddlewareRegistry

OAuth Token Requests:

  • New AuthMiddlewareRegistry in auth/middleware.ts
  • userAgentAuthProvider auto-registers with globalAuthMiddlewareRegistry
  • Applied in OAuthStrategy.clientCredentialsGrant()

CLI Plugin Hooks:

  • b2c:http-middleware - for HTTP client middleware
  • b2c:auth-middleware - for OAuth request middleware

Sets User-Agent and sfdc_user_agent headers on all API requests.
SDK uses 'b2c-tooling-sdk/x.x.x', CLI uses 'b2c-cli/x.x.x'.
Extends the User-Agent header support to OAuth token requests by creating
a separate auth middleware registry. OAuth requests previously bypassed
the HTTP middleware chain since they use direct fetch() calls.

- Add AuthMiddlewareRegistry for auth-specific middleware
- Add b2c:auth-middleware CLI plugin hook
- Apply middleware in OAuthStrategy.clientCredentialsGrant()
- Register userAgentAuthProvider with the auth middleware registry
@clavery clavery changed the title feat(sdk): add User-Agent header to HTTP requests feat(sdk): add User-Agent header to HTTP and OAuth requests Jan 22, 2026
@clavery clavery requested a review from yhsieh1 January 22, 2026 17:16
@clavery clavery merged commit a14c741 into main Jan 22, 2026
3 checks passed
@clavery clavery mentioned this pull request Jan 25, 2026
@clavery clavery deleted the feature/user-agent branch January 27, 2026 01:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant