Skip to content

Commit 9793ccc

Browse files
authored
Merge branch 'main' into normalize-headers
2 parents 9f336c5 + 6b90e1a commit 9793ccc

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

src/client/streamableHttp.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ describe('StreamableHTTPClientTransport', () => {
209209
const errorSpy = vi.fn();
210210
transport.onerror = errorSpy;
211211

212-
await expect(transport.send(message)).rejects.toThrow('Error POSTing to endpoint (HTTP 404)');
212+
await expect(transport.send(message)).rejects.toThrow('Streamable HTTP error: Error POSTing to endpoint: Session not found');
213213
expect(errorSpy).toHaveBeenCalled();
214214
});
215215

src/client/streamableHttp.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ export class StreamableHTTPClientTransport implements Transport {
534534
}
535535
}
536536

537-
throw new Error(`Error POSTing to endpoint (HTTP ${response.status}): ${text}`);
537+
throw new StreamableHTTPError(response.status, `Error POSTing to endpoint: ${text}`);
538538
}
539539

540540
// Reset auth loop flag on successful response

src/server/auth/errors.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,14 @@ export class InsufficientScopeError extends OAuthError {
163163
static errorCode = 'insufficient_scope';
164164
}
165165

166+
/**
167+
* Invalid target error - The requested resource is invalid, missing, unknown, or malformed.
168+
* (Custom error for resource indicators - RFC 8707)
169+
*/
170+
export class InvalidTargetError extends OAuthError {
171+
static errorCode = 'invalid_target';
172+
}
173+
166174
/**
167175
* A utility class for defining one-off error codes
168176
*/
@@ -199,5 +207,6 @@ export const OAUTH_ERRORS = {
199207
[MethodNotAllowedError.errorCode]: MethodNotAllowedError,
200208
[TooManyRequestsError.errorCode]: TooManyRequestsError,
201209
[InvalidClientMetadataError.errorCode]: InvalidClientMetadataError,
202-
[InsufficientScopeError.errorCode]: InsufficientScopeError
210+
[InsufficientScopeError.errorCode]: InsufficientScopeError,
211+
[InvalidTargetError.errorCode]: InvalidTargetError
203212
} as const;

0 commit comments

Comments
 (0)