feat: Added generic client hooks for HTTP based authentication, and improved agent.json resolution #33
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.
This PR adds a generic client hook for HTTP based authentication. This allows protocols, like the Agentic Profile, to implement Decentralized ID (DID)/JWT based authentication which then enables user, business, and gov scoped identity for A2A agents. When an authHandler is provided and an HTTP 401 is received, the client will try a second time (see the A2AClient._fetch() function) with revised auth headers if new ones are made available by the authHandler.
This PR also improves the client agent card resolution. Previously the card was always found at /.well-known/agent.json which is only correct for agents at the URL path root. For agents with paths, such as https://example.com/agents/coder the URL for the agent card should be https://example.com/agents/coder/agent.json. This PR fixes the error.
I've moved the previous Eliza sample agent to a separate PR into a2a-samples. The Eliza sample provides A2A server side authentication, and a modified A2A CLI with authentication.
The Eliza sample code relies on this PR to function.