Skip to content

Commit aa83cca

Browse files
committed
Auto-fill HTTP Proxies
1 parent b7eb9bd commit aa83cca

File tree

3 files changed

+88
-2
lines changed

3 files changed

+88
-2
lines changed

background/NetworkAuth.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,21 @@ export class NetworkAuth {
4444
return { cancel: false };
4545
}
4646

47-
const url = new URL(requestDetails.url);
47+
let originalUrl;
48+
49+
if (requestDetails.isProxy) {
50+
if (requestDetails.proxyInfo) {
51+
// Firefox
52+
originalUrl = requestDetails.proxyInfo.host;
53+
} else {
54+
// Chrome
55+
originalUrl = requestDetails.challenger.host;
56+
}
57+
} else {
58+
originalUrl = requestDetails.url;
59+
}
60+
61+
const url = new URL(originalUrl);
4862
url.hostname = punycode.toUnicode(url.hostname);
4963

5064
const result = await window.kee.findLogins(

manifest.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@
100100
"<all_urls>",
101101
"notifications",
102102
"unlimitedStorage",
103-
"idle"
103+
"idle",
104+
"proxy"
104105
],
105106
"web_accessible_resources" : [
106107
"panels/*"

typedefs/browser.d.ts

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4665,6 +4665,77 @@ declare namespace browser.webRequest {
46654665

46664666
type OnCompletedOptions = "responseHeaders";
46674667

4668+
interface ResourceRequest {
4669+
url: string;
4670+
/** The ID of the request. Request IDs are unique within a browser session. As a result, they could be used to relate different events of the same request. */
4671+
requestId: string;
4672+
/** The value 0 indicates that the request happens in the main frame; a positive value indicates the ID of a subframe in which the request happens. If the document of a (sub-)frame is loaded (type is main_frame or sub_frame), frameId indicates the ID of this frame, not the ID of the outer frame. Frame IDs are unique within a tab. */
4673+
frameId: number;
4674+
/** ID of frame that wraps the frame which sent the request. Set to -1 if no parent frame exists. */
4675+
parentFrameId: number;
4676+
/** The ID of the tab in which the request takes place. Set to -1 if the request isn't related to a tab. */
4677+
tabId: number;
4678+
/**
4679+
* How the requested resource will be used.
4680+
* One of: "main_frame", "sub_frame", "stylesheet", "script", "image", "object", "xmlhttprequest", or "other"
4681+
*/
4682+
type: string;
4683+
/** The time when this signal is triggered, in milliseconds since the epoch. */
4684+
timeStamp: number;
4685+
}
4686+
4687+
interface WebResponseDetails extends ResourceRequest {
4688+
/** HTTP status line of the response or the 'HTTP/0.9 200 OK' string for HTTP/0.9 responses (i.e., responses that lack a status line). */
4689+
statusLine: string;
4690+
/**
4691+
* Standard HTTP status code returned by the server.
4692+
* @since Chrome 43.
4693+
*/
4694+
statusCode: number;
4695+
}
4696+
4697+
interface WebResponseHeadersDetails extends WebResponseDetails {
4698+
/** Optional. The HTTP response headers that have been received with this response. */
4699+
responseHeaders?: HttpHeaders;
4700+
method: string; /** standard HTTP method i.e. GET, POST, PUT, etc. */
4701+
}
4702+
4703+
interface WebAuthChallenger {
4704+
host: string;
4705+
port: number;
4706+
}
4707+
4708+
interface ProxyInfo {
4709+
host: string;
4710+
port: number;
4711+
type: string;
4712+
/* One of:
4713+
4714+
"http": HTTP proxy (or SSL CONNECT for HTTPS)
4715+
"https": HTTP proxying over TLS connection to proxy
4716+
"socks": SOCKS v5 proxy
4717+
"socks4": SOCKS v4 proxy
4718+
"direct": no proxy
4719+
"unknown": unknown proxy
4720+
*/
4721+
username: string;
4722+
proxyDNS: boolean;
4723+
failoverTimeout: number;
4724+
}
4725+
4726+
interface WebAuthenticationChallengeDetails extends WebResponseHeadersDetails {
4727+
/** The authentication scheme, e.g. Basic or Digest. */
4728+
scheme: string;
4729+
/** The authentication realm provided by the server, if there is one. */
4730+
realm?: string;
4731+
/** The server requesting authentication. In Chrome, host is the proxy host if isProxy is true */
4732+
challenger: WebAuthChallenger;
4733+
/** True for Proxy-Authenticate, false for WWW-Authenticate. */
4734+
isProxy: boolean;
4735+
/** Firefox only. This property is present only if the request is being proxied. */
4736+
proxyInfo?: ProxyInfo;
4737+
}
4738+
46684739
/** An object describing filters to apply to webRequest events. */
46694740
interface RequestFilter {
46704741
/** A list of URLs or URL patterns. Requests that cannot match any of the URLs will be filtered out. */

0 commit comments

Comments
 (0)