Skip to content

Commit 6d40a09

Browse files
committed
Auto-fill HTTP Proxies
1 parent 8cb20a9 commit 6d40a09

File tree

3 files changed

+39
-4
lines changed

3 files changed

+39
-4
lines changed

background/NetworkAuth.ts

+15-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,21 @@ class NetworkAuth {
5858
return;
5959
}
6060

61-
const url = new URL(requestDetails.url);
61+
let originalUrl;
62+
63+
if (requestDetails.isProxy) {
64+
if (requestDetails.proxyInfo) {
65+
// Firefox
66+
originalUrl = requestDetails.proxyInfo.host;
67+
} else {
68+
// Chrome
69+
originalUrl = requestDetails.challenger.host;
70+
}
71+
} else {
72+
originalUrl = requestDetails.url;
73+
}
74+
75+
const url = new URL(originalUrl);
6276
url.hostname = punycode.toUnicode(url.hostname);
6377

6478
kee.findLogins(url.href, null, requestDetails.realm, null, null, null, null, result => {

manifest.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@
6767
"webRequest",
6868
"<all_urls>",
6969
"notifications",
70-
"unlimitedStorage"
70+
"unlimitedStorage",
71+
"proxy"
7172
],
7273
"web_accessible_resources" : [
7374
"panels/*"

typedefs/browser.d.ts

+22-2
Original file line numberDiff line numberDiff line change
@@ -3367,16 +3367,36 @@ declare namespace browser.webRequest {
33673367
port: number;
33683368
}
33693369

3370+
interface ProxyInfo {
3371+
host: string;
3372+
port: number;
3373+
type: string;
3374+
/* One of:
3375+
3376+
"http": HTTP proxy (or SSL CONNECT for HTTPS)
3377+
"https": HTTP proxying over TLS connection to proxy
3378+
"socks": SOCKS v5 proxy
3379+
"socks4": SOCKS v4 proxy
3380+
"direct": no proxy
3381+
"unknown": unknown proxy
3382+
*/
3383+
username: string;
3384+
proxyDNS: boolean;
3385+
failoverTimeout: number;
3386+
}
3387+
33703388
interface WebAuthenticationChallengeDetails extends WebResponseHeadersDetails {
33713389
/** The authentication scheme, e.g. Basic or Digest. */
33723390
scheme: string;
33733391
/** The authentication realm provided by the server, if there is one. */
33743392
realm?: string;
3375-
/** The server requesting authentication. */
3393+
/** The server requesting authentication. In Chrome, host is the proxy host if isProxy is true */
33763394
challenger: WebAuthChallenger;
33773395
/** True for Proxy-Authenticate, false for WWW-Authenticate. */
33783396
isProxy: boolean;
3379-
}
3397+
/** Firefox only. This property is present only if the request is being proxied. */
3398+
proxyInfo?: ProxyInfo;
3399+
}
33803400

33813401
/** An object describing filters to apply to webRequest events. */
33823402
interface RequestFilter {

0 commit comments

Comments
 (0)