cleanup auth-utils and remove example files

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Olivier Chafik 2025-06-16 20:05:02 +01:00
commit 1f4e42c09e
No known key found for this signature in database
2 changed files with 29 additions and 389 deletions

View file

@ -14,6 +14,7 @@ import {
OAuthError
} from "../errors.js";
import { OAuthServerConfig } from "../types.js";
import { resourceUrlFromServerUrl } from "../../../shared/auth-utils.js";
export type AuthorizationHandlerOptions = {
provider: OAuthServerProvider;
@ -137,7 +138,7 @@ export function authorizationHandler({ provider, rateLimit: rateLimitConfig, con
}
// Remove fragment from server URL if present (though it shouldn't have one)
const canonicalServerUrl = config.serverUrl!.split('#')[0];
const canonicalServerUrl = resourceUrlFromServerUrl(config.serverUrl!);
if (resource !== canonicalServerUrl) {
throw new InvalidTargetError(

View file

@ -16,6 +16,7 @@ import {
InvalidTargetError
} from "../errors.js";
import { OAuthServerConfig } from "../types.js";
import { resourceUrlFromServerUrl } from "../../../shared/auth-utils.js";
export type TokenHandlerOptions = {
provider: OAuthServerProvider;
@ -110,7 +111,7 @@ export function tokenHandler({ provider, rateLimit: rateLimitConfig, config }: T
throw new InvalidRequestError("Resource parameter is required when server URL validation is enabled");
}
const canonicalServerUrl = config.serverUrl!.split('#')[0];
const canonicalServerUrl = resourceUrlFromServerUrl(config.serverUrl!);
if (resource !== canonicalServerUrl) {
throw new InvalidTargetError(
@ -161,7 +162,7 @@ export function tokenHandler({ provider, rateLimit: rateLimitConfig, config }: T
throw new InvalidRequestError("Resource parameter is required when server URL validation is enabled");
}
const canonicalServerUrl = config.serverUrl!.split('#')[0];
const canonicalServerUrl = resourceUrlFromServerUrl(config.serverUrl!);
if (resource !== canonicalServerUrl) {
throw new InvalidTargetError(