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 Nov 26, 2022
1 parent b7eb9bd commit aa83cca
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 2 deletions.
16 changes: 15 additions & 1 deletion background/NetworkAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,21 @@ export class NetworkAuth {
return { cancel: false };
}

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);

const result = await window.kee.findLogins(
Expand Down
3 changes: 2 additions & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@
"<all_urls>",
"notifications",
"unlimitedStorage",
"idle"
"idle",
"proxy"
],
"web_accessible_resources" : [
"panels/*"
Expand Down
71 changes: 71 additions & 0 deletions typedefs/browser.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4665,6 +4665,77 @@ declare namespace browser.webRequest {

type OnCompletedOptions = "responseHeaders";

interface ResourceRequest {
url: string;
/** 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. */
requestId: string;
/** 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. */
frameId: number;
/** ID of frame that wraps the frame which sent the request. Set to -1 if no parent frame exists. */
parentFrameId: number;
/** The ID of the tab in which the request takes place. Set to -1 if the request isn't related to a tab. */
tabId: number;
/**
* How the requested resource will be used.
* One of: "main_frame", "sub_frame", "stylesheet", "script", "image", "object", "xmlhttprequest", or "other"
*/
type: string;
/** The time when this signal is triggered, in milliseconds since the epoch. */
timeStamp: number;
}

interface WebResponseDetails extends ResourceRequest {
/** 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). */
statusLine: string;
/**
* Standard HTTP status code returned by the server.
* @since Chrome 43.
*/
statusCode: number;
}

interface WebResponseHeadersDetails extends WebResponseDetails {
/** Optional. The HTTP response headers that have been received with this response. */
responseHeaders?: HttpHeaders;
method: string; /** standard HTTP method i.e. GET, POST, PUT, etc. */
}

interface WebAuthChallenger {
host: string;
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. 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 {
/** A list of URLs or URL patterns. Requests that cannot match any of the URLs will be filtered out. */
Expand Down

0 comments on commit aa83cca

Please sign in to comment.