Skip to content

Commit

Permalink
Auto-fill HTTP Proxies
Browse files Browse the repository at this point in the history
  • Loading branch information
luckyrat committed Feb 2, 2018
1 parent 8cb20a9 commit 6d40a09
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 4 deletions.
16 changes: 15 additions & 1 deletion background/NetworkAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,21 @@ class NetworkAuth {
return;
}

const url = new URL(requestDetails.url);
let originalUrl;

if (requestDetails.isProxy) {
if (requestDetails.proxyInfo) {
// Firefox
originalUrl = requestDetails.proxyInfo.host;
} else {
// Chrome
originalUrl = requestDetails.challenger.host;
}
} else {
originalUrl = requestDetails.url;
}

const url = new URL(originalUrl);
url.hostname = punycode.toUnicode(url.hostname);

kee.findLogins(url.href, null, requestDetails.realm, null, null, null, null, result => {
Expand Down
3 changes: 2 additions & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@
"webRequest",
"<all_urls>",
"notifications",
"unlimitedStorage"
"unlimitedStorage",
"proxy"
],
"web_accessible_resources" : [
"panels/*"
Expand Down
24 changes: 22 additions & 2 deletions typedefs/browser.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3367,16 +3367,36 @@ declare namespace browser.webRequest {
port: number;
}

interface ProxyInfo {
host: string;
port: number;
type: string;
/* One of:
"http": HTTP proxy (or SSL CONNECT for HTTPS)
"https": HTTP proxying over TLS connection to proxy
"socks": SOCKS v5 proxy
"socks4": SOCKS v4 proxy
"direct": no proxy
"unknown": unknown proxy
*/
username: string;
proxyDNS: boolean;
failoverTimeout: number;
}

interface WebAuthenticationChallengeDetails extends WebResponseHeadersDetails {
/** The authentication scheme, e.g. Basic or Digest. */
scheme: string;
/** The authentication realm provided by the server, if there is one. */
realm?: string;
/** The server requesting authentication. */
/** The server requesting authentication. In Chrome, host is the proxy host if isProxy is true */
challenger: WebAuthChallenger;
/** True for Proxy-Authenticate, false for WWW-Authenticate. */
isProxy: boolean;
}
/** Firefox only. This property is present only if the request is being proxied. */
proxyInfo?: ProxyInfo;
}

/** An object describing filters to apply to webRequest events. */
interface RequestFilter {
Expand Down

0 comments on commit 6d40a09

Please sign in to comment.