add custom headers on initial _startOrAuth call (#318)
* add custom headers on initial _startOrAuth call * update client/sse.ts: align commonHeaders w/ streamableHttp version --------- Co-authored-by: Olivier Chafik <ochafik@anthropic.com>
This commit is contained in:
parent
7d7896fc72
commit
6ae4a5727c
1 changed files with 33 additions and 13 deletions
|
|
@ -382,6 +382,29 @@ describe("SSEClientTransport", () => {
|
|||
expect(mockAuthProvider.tokens).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("attaches custom header from provider on initial SSE connection", async () => {
|
||||
mockAuthProvider.tokens.mockResolvedValue({
|
||||
access_token: "test-token",
|
||||
token_type: "Bearer"
|
||||
});
|
||||
const customHeaders = {
|
||||
"X-Custom-Header": "custom-value",
|
||||
};
|
||||
|
||||
transport = new SSEClientTransport(resourceBaseUrl, {
|
||||
authProvider: mockAuthProvider,
|
||||
requestInit: {
|
||||
headers: customHeaders,
|
||||
},
|
||||
});
|
||||
|
||||
await transport.start();
|
||||
|
||||
expect(lastServerRequest.headers.authorization).toBe("Bearer test-token");
|
||||
expect(lastServerRequest.headers["x-custom-header"]).toBe("custom-value");
|
||||
expect(mockAuthProvider.tokens).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("attaches auth header from provider on POST requests", async () => {
|
||||
mockAuthProvider.tokens.mockResolvedValue({
|
||||
access_token: "test-token",
|
||||
|
|
|
|||
Loading…
Reference in a new issue