Index: lib/whitelisting.js |
=================================================================== |
--- a/lib/whitelisting.js |
+++ b/lib/whitelisting.js |
@@ -21,6 +21,12 @@ |
let pagesWithKey = new ext.PageMap(); |
+/** |
+ * Checks whether a page is whitelisted. |
+ * |
+ * @param {Page} page |
+ * @return {WhitelistFilter} The active filter whitelisting this page or null |
+ */ |
function isPageWhitelisted(page) |
{ |
let url = page.url; |
@@ -33,6 +39,15 @@ |
} |
exports.isPageWhitelisted = isPageWhitelisted; |
+/** |
+ * Checks whether a frame is whitelisted. |
+ * |
+ * @param {Page} page |
+ * @param {Frame} frame |
+ * @param {string} [type=DOCUMENT] The request type to check whether |
+ * the frame is whitelisted for. |
+ * @return {Boolean} |
+ */ |
function isFrameWhitelisted(page, frame, type) |
{ |
while (frame) |
@@ -57,6 +72,14 @@ |
} |
exports.isFrameWhitelisted = isFrameWhitelisted; |
+/** |
+ * Gets the public key, previously recorded for the given page |
+ * and frame, to be considered for the $sitekey filter option. |
+ * |
+ * @param {Page} page |
+ * @param {Frame} frame |
+ * @return {string} |
+ */ |
function getKey(page, frame) |
{ |
let urlsWithKey = pagesWithKey.get(page); |
@@ -98,6 +121,17 @@ |
urlsWithKey[stringifyURL(url)] = key; |
} |
+/** |
+ * Validates signatures given by the "X-Adblock-Key" request |
+ * header or the "data-adblockkey" attribute of the document |
+ * element. If the signature is valid, the public key will be |
+ * recorded and considered for the $sitekey filter option. |
+ * |
+ * @param {string} token The base64-encoded public key and |
+ * signature separated by an underscrore. |
+ * @param {Page} page |
+ * @param {Frame} frame |
+ */ |
function processKey(token, page, frame) |
{ |
if (token.indexOf("_") < 0) |