-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat(elicitation): Add URL elicitation support. SEP-1036 #994
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
8c135fb
108631c
1cfd1eb
f88e21a
766a4f9
1f1d9e1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,165 @@ | ||||||||||||
| import { | ||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like CI is failing due to formatting issues, please run |
||||||||||||
| ElicitationResponse, | ||||||||||||
| PendingElicitationRequest, | ||||||||||||
| UrlElicitationRequestData, | ||||||||||||
| } from "@/components/ElicitationTab.tsx"; | ||||||||||||
| import JsonView from "@/components/JsonView.tsx"; | ||||||||||||
| import { Button } from "@/components/ui/button.tsx"; | ||||||||||||
| import { CheckCheck, Copy } from "lucide-react"; | ||||||||||||
| import useCopy from "@/lib/hooks/useCopy.ts"; | ||||||||||||
| import { toast } from "@/lib/hooks/useToast.ts"; | ||||||||||||
|
|
||||||||||||
| export type ElicitationUrlRequestProps = { | ||||||||||||
| request: PendingElicitationRequest & { | ||||||||||||
| request: UrlElicitationRequestData; | ||||||||||||
| }; | ||||||||||||
| onResolve: (id: number, response: ElicitationResponse) => void; | ||||||||||||
| }; | ||||||||||||
|
|
||||||||||||
| const ElicitationUrlRequest = ({ | ||||||||||||
| request, | ||||||||||||
| onResolve, | ||||||||||||
| }: ElicitationUrlRequestProps) => { | ||||||||||||
| const { copied, setCopied } = useCopy(); | ||||||||||||
|
|
||||||||||||
| const parsedUrl = (() => { | ||||||||||||
| try { | ||||||||||||
| return new URL(request.request.url); | ||||||||||||
| } catch { | ||||||||||||
| return null; | ||||||||||||
| } | ||||||||||||
| })(); | ||||||||||||
|
|
||||||||||||
| const handleAcceptAndOpen = () => { | ||||||||||||
| if (!parsedUrl) { | ||||||||||||
| return; | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
|
||||||||||||
| if (parsedUrl.protocol !== "http:" && parsedUrl.protocol !== "https:") { | |
| return; | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @pbezglasny , looks like you resolved this but the handleAcceptAndOpen function still doesn't validate URL schemes before opening. Should we add the suggested filter for only allowing http or https?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the warning message text doesn't match between code and tests:
- Code (
ElicitationUrlRequest.tsx:73):"This URL contains internationalized (non-ASCII) characters" - Tests:
"This URL contains internationalized characters"
Please update one to match the other.
Uh oh!
There was an error while loading. Please reload this page.