Skip to content

Commit 1197733

Browse files
committed
feat: add OAuth proxy support to eliminate CORS issues
- Add OAuth proxy endpoints to server for token exchange and refresh - Implement OAuth proxy utility functions in client - Integrate OAuth proxy support into OAuth flow - Add comprehensive OAuth proxy tests - Extract common proxyFetch helper for code reuse - Enhance error handling in proxy client - Fix Prettier version mismatch to unblock CI - Remove duplicate express.json() middleware - Fix request body handling in proxy endpoints
1 parent 5a7f996 commit 1197733

File tree

10 files changed

+905
-38
lines changed

10 files changed

+905
-38
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- uses: actions/checkout@v4
1616

1717
- name: Check formatting
18-
run: npx prettier --check .
18+
run: npx prettier@3.7.4 --check .
1919

2020
- uses: actions/setup-node@v4
2121
with:

client/src/App.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -499,9 +499,14 @@ const App = () => {
499499
};
500500

501501
try {
502-
const stateMachine = new OAuthStateMachine(sseUrl, (updates) => {
503-
currentState = { ...currentState, ...updates };
504-
});
502+
const stateMachine = new OAuthStateMachine(
503+
sseUrl,
504+
(updates) => {
505+
currentState = { ...currentState, ...updates };
506+
},
507+
connectionType,
508+
config,
509+
);
505510

506511
while (
507512
currentState.oauthStep !== "complete" &&
@@ -917,6 +922,8 @@ const App = () => {
917922
onBack={() => setIsAuthDebuggerVisible(false)}
918923
authState={authState}
919924
updateAuthState={updateAuthState}
925+
connectionType={connectionType}
926+
config={config}
920927
/>
921928
</TabsContent>
922929
);

client/src/components/AuthDebugger.tsx

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,15 @@ import { OAuthFlowProgress } from "./OAuthFlowProgress";
77
import { OAuthStateMachine } from "../lib/oauth-state-machine";
88
import { SESSION_KEYS } from "../lib/constants";
99
import { validateRedirectUrl } from "@/utils/urlValidation";
10+
import { InspectorConfig } from "../lib/configurationTypes";
1011

1112
export interface AuthDebuggerProps {
1213
serverUrl: string;
1314
onBack: () => void;
1415
authState: AuthDebuggerState;
1516
updateAuthState: (updates: Partial<AuthDebuggerState>) => void;
17+
connectionType: "direct" | "proxy";
18+
config: InspectorConfig;
1619
}
1720

1821
interface StatusMessageProps {
@@ -60,6 +63,8 @@ const AuthDebugger = ({
6063
onBack,
6164
authState,
6265
updateAuthState,
66+
connectionType,
67+
config,
6368
}: AuthDebuggerProps) => {
6469
// Check for existing tokens on mount
6570
useEffect(() => {
@@ -103,8 +108,9 @@ const AuthDebugger = ({
103108
}, [serverUrl, updateAuthState]);
104109

105110
const stateMachine = useMemo(
106-
() => new OAuthStateMachine(serverUrl, updateAuthState),
107-
[serverUrl, updateAuthState],
111+
() =>
112+
new OAuthStateMachine(serverUrl, updateAuthState, connectionType, config),
113+
[serverUrl, updateAuthState, connectionType, config],
108114
);
109115

110116
const proceedToNextStep = useCallback(async () => {
@@ -150,11 +156,16 @@ const AuthDebugger = ({
150156
latestError: null,
151157
};
152158

153-
const oauthMachine = new OAuthStateMachine(serverUrl, (updates) => {
154-
// Update our temporary state during the process
155-
currentState = { ...currentState, ...updates };
156-
// But don't call updateAuthState yet
157-
});
159+
const oauthMachine = new OAuthStateMachine(
160+
serverUrl,
161+
(updates) => {
162+
// Update our temporary state during the process
163+
currentState = { ...currentState, ...updates };
164+
// But don't call updateAuthState yet
165+
},
166+
connectionType,
167+
config,
168+
);
158169

159170
// Manually step through each stage of the OAuth flow
160171
while (currentState.oauthStep !== "complete") {

0 commit comments

Comments
 (0)