-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement global auth state in the api playground (#1162)
- Loading branch information
1 parent
bfb3ee5
commit 7ee919b
Showing
12 changed files
with
399 additions
and
427 deletions.
There are no files selected for viewing
217 changes: 87 additions & 130 deletions
217
packages/ui/app/src/api-playground/PlaygroundAuthorizationForm.tsx
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,27 @@ | ||
export declare namespace PlaygroundRequestFormAuth { | ||
interface BearerAuth { | ||
type: "bearerAuth"; | ||
token: string; | ||
} | ||
import { z } from "zod"; | ||
|
||
interface Header { | ||
type: "header"; | ||
headers: Record<string, string>; | ||
} | ||
export const PlaygroundAuthStateBearerTokenSchema = z.strictObject({ | ||
token: z.string(), | ||
}); | ||
export type PlaygroundAuthStateBearerToken = z.infer<typeof PlaygroundAuthStateBearerTokenSchema>; | ||
export const PLAYGROUND_AUTH_STATE_BEARER_TOKEN_INITIAL: PlaygroundAuthStateBearerToken = { token: "" }; | ||
|
||
interface BasicAuth { | ||
type: "basicAuth"; | ||
username: string; | ||
password: string; | ||
} | ||
} | ||
export const PlaygroundAuthStateHeaderSchema = z.strictObject({ | ||
headers: z.record(z.string()), | ||
}); | ||
export type PlaygroundAuthStateHeader = z.infer<typeof PlaygroundAuthStateHeaderSchema>; | ||
export const PLAYGROUND_AUTH_STATE_HEADER_INITIAL: PlaygroundAuthStateHeader = { headers: {} }; | ||
|
||
export type PlaygroundRequestFormAuth = | ||
| PlaygroundRequestFormAuth.BearerAuth | ||
| PlaygroundRequestFormAuth.Header | ||
| PlaygroundRequestFormAuth.BasicAuth; | ||
export const PlaygroundAuthStateBasicAuthSchema = z.strictObject({ | ||
username: z.string(), | ||
password: z.string(), | ||
}); | ||
export type PlaygroundAuthStateBasicAuth = z.infer<typeof PlaygroundAuthStateBasicAuthSchema>; | ||
export const PLAYGROUND_AUTH_STATE_BASIC_AUTH_INITIAL: PlaygroundAuthStateBasicAuth = { username: "", password: "" }; | ||
|
||
export const PlaygroundAuthStateSchema = z.strictObject({ | ||
bearerAuth: PlaygroundAuthStateBearerTokenSchema.optional(), | ||
header: PlaygroundAuthStateHeaderSchema.optional(), | ||
basicAuth: PlaygroundAuthStateBasicAuthSchema.optional(), | ||
}); | ||
export type PlaygroundAuthState = z.infer<typeof PlaygroundAuthStateSchema>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.