add test + prettier
This commit is contained in:
parent
35eab580ef
commit
cc49358f5a
2 changed files with 139 additions and 23 deletions
|
|
@ -30,7 +30,10 @@ export interface AuthDebuggerState {
|
|||
loading: boolean;
|
||||
oauthStep: OAuthStep;
|
||||
resourceMetadata: OAuthProtectedResourceMetadata | null;
|
||||
resourceMetadataError: Error | { status: number; statusText: string; message: string } | null;
|
||||
resourceMetadataError:
|
||||
| Error
|
||||
| { status: number; statusText: string; message: string }
|
||||
| null;
|
||||
authServerUrl: URL | null;
|
||||
oauthMetadata: OAuthMetadata | null;
|
||||
oauthClientInfo: OAuthClientInformationFull | OAuthClientInformation | null;
|
||||
|
|
@ -56,4 +59,4 @@ export const EMPTY_DEBUGGER_STATE: AuthDebuggerState = {
|
|||
latestError: null,
|
||||
statusMessage: null,
|
||||
validationError: null,
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -7,7 +7,10 @@ import {
|
|||
exchangeAuthorization,
|
||||
discoverOAuthProtectedResourceMetadata,
|
||||
} from "@modelcontextprotocol/sdk/client/auth.js";
|
||||
import { OAuthMetadataSchema, OAuthProtectedResourceMetadata } from "@modelcontextprotocol/sdk/shared/auth.js";
|
||||
import {
|
||||
OAuthMetadataSchema,
|
||||
OAuthProtectedResourceMetadata,
|
||||
} from "@modelcontextprotocol/sdk/shared/auth.js";
|
||||
|
||||
export interface StateMachineContext {
|
||||
state: AuthDebuggerState;
|
||||
|
|
@ -30,8 +33,13 @@ export const oauthTransitions: Record<OAuthStep, StateTransition> = {
|
|||
let resourceMetadata: OAuthProtectedResourceMetadata | null = null;
|
||||
let resourceMetadataError: Error | null = null;
|
||||
try {
|
||||
resourceMetadata = await discoverOAuthProtectedResourceMetadata(context.serverUrl);
|
||||
if (resourceMetadata && resourceMetadata.authorization_servers?.length) {
|
||||
resourceMetadata = await discoverOAuthProtectedResourceMetadata(
|
||||
context.serverUrl,
|
||||
);
|
||||
if (
|
||||
resourceMetadata &&
|
||||
resourceMetadata.authorization_servers?.length
|
||||
) {
|
||||
authServerUrl = new URL(resourceMetadata.authorization_servers[0]);
|
||||
}
|
||||
} catch (e) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue