-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[fix]: authenticate user pass proxies when using a local browser #1484
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?
[fix]: authenticate user pass proxies when using a local browser #1484
Conversation
|
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.
No issues found across 1 file
Greptile SummaryEnables proxy authentication for local browser mode by implementing CDP Fetch domain event handlers that intercept authentication challenges and automatically provide credentials.
Issues found:
Confidence Score: 3/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant V3
participant Browser
participant Page
participant Session
participant ProxyServer
V3->>V3: init()
V3->>V3: _applyPostConnectLocalOptions(lbo)
alt proxy with username and password
V3->>Browser: awaitActivePage()
Browser-->>V3: page
V3->>Page: getSessionForFrame(mainFrameId())
Page-->>V3: session
V3->>Session: send("Fetch.enable", {handleAuthRequests: true})
Note over Session: Pauses all requests<br/>until auth is complete
V3->>Session: on("Fetch.authRequired", authHandler)
V3->>Session: on("Fetch.requestPaused", requestPausedHandler)
V3->>V3: Store cleanup function in proxyAuthHandlers Map
Note over Session,ProxyServer: When proxy requires authentication
ProxyServer->>Session: Auth challenge
Session->>V3: Fetch.authRequired event
V3->>Session: send("Fetch.continueWithAuth", credentials)
Session->>ProxyServer: Provide credentials
Note over Session: When requests are paused
Session->>V3: Fetch.requestPaused event
V3->>Session: send("Fetch.continueRequest")
Session->>ProxyServer: Continue request
end
Note over V3: On cleanup
V3->>V3: close()
loop for each cleanup handler
V3->>Session: off("Fetch.authRequired")
V3->>Session: off("Fetch.requestPaused")
end
V3->>V3: proxyAuthHandlers.clear()
|
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.
Additional Comments (3)
-
packages/core/lib/v3/v3.ts, line 988-1001 (link)logic: error handling missing on CDP send calls - both
session.send()calls should have.catch(() => {})chained to prevent unhandled promise rejections if the session is closed or the request fails -
packages/core/lib/v3/v3.ts, line 1008-1011 (link)logic: if
_applyPostConnectLocalOptionsis called multiple times for the same page, duplicate listeners will accumulate (the Map only stores the latest cleanup function). Check if handlers already exist and clean them up first: -
packages/core/lib/v3/v3.ts, line 198 (link)syntax: type should be
Map<string, () => void> | nullsince it's set tonullon line 1449
1 file reviewed, 3 comments
why
Using proxies that need a username and password doesn't work on local mode
what changed
If a username and password is included in the local options then we authenticate the proxy using fetch domain events
test plan
Summary by cubic
Fixes proxy authentication in local browser mode by supplying username/password credentials via the CDP Fetch domain. Authenticated proxies now work without manual setup.
Written for commit 434eca9. Summary will update automatically on new commits.