Skip to content

Commit 71583ca

Browse files
committed
fix: correct authState.authorizationUrl type to URL
1 parent 7792125 commit 71583ca

File tree

6 files changed

+11
-7
lines changed

6 files changed

+11
-7
lines changed

client/src/components/AuthDebugger.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ const AuthDebugger = ({
187187
JSON.stringify(currentState),
188188
);
189189
// Open the authorization URL automatically
190-
window.location.href = currentState.authorizationUrl;
190+
window.location.href = currentState.authorizationUrl.toString();
191191
break;
192192
}
193193
}

client/src/components/OAuthFlowProgress.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ export const OAuthFlowProgress = ({
240240
<p className="font-medium mb-2 text-sm">Authorization URL:</p>
241241
<div className="flex items-center gap-2">
242242
<p className="text-xs break-all">
243-
{authState.authorizationUrl}
243+
{String(authState.authorizationUrl)}
244244
</p>
245245
<button
246246
onClick={() => {

client/src/components/__tests__/AuthDebugger.test.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,9 @@ describe("AuthDebugger", () => {
482482
await waitFor(() => {
483483
expect(updateAuthState).toHaveBeenCalledWith(
484484
expect.objectContaining({
485-
authorizationUrl: expect.stringContaining("scope="),
485+
authorizationUrl: expect.objectContaining({
486+
href: "https://oauth.example.com/authorize?scope=read+write",
487+
}),
486488
}),
487489
);
488490
});
@@ -496,7 +498,9 @@ describe("AuthDebugger", () => {
496498
await waitFor(() => {
497499
expect(updateAuthState).toHaveBeenCalledWith(
498500
expect.objectContaining({
499-
authorizationUrl: expect.stringContaining("scope="),
501+
authorizationUrl: expect.objectContaining({
502+
href: "https://oauth.example.com/authorize?scope=read+write",
503+
}),
500504
}),
501505
);
502506
});

client/src/lib/auth-types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export interface AuthDebuggerState {
3434
authServerUrl: URL | null;
3535
oauthMetadata: OAuthMetadata | null;
3636
oauthClientInfo: OAuthClientInformationFull | OAuthClientInformation | null;
37-
authorizationUrl: string | null;
37+
authorizationUrl: URL | null;
3838
authorizationCode: string;
3939
latestError: Error | null;
4040
statusMessage: StatusMessage | null;

client/src/lib/oauth-state-machine.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ export const oauthTransitions: Record<OAuthStep, StateTransition> = {
132132

133133
context.provider.saveCodeVerifier(codeVerifier);
134134
context.updateState({
135-
authorizationUrl: authorizationUrl.toString(),
135+
authorizationUrl: authorizationUrl,
136136
oauthStep: "authorization_code",
137137
});
138138
},

client/src/utils/urlValidation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* @param url - The URL string to validate
66
* @throws Error if the URL has an unsafe protocol
77
*/
8-
export function validateRedirectUrl(url: string): void {
8+
export function validateRedirectUrl(url: string | URL): void {
99
try {
1010
const parsedUrl = new URL(url);
1111
if (parsedUrl.protocol !== "http:" && parsedUrl.protocol !== "https:") {

0 commit comments

Comments
 (0)