tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

WellKnownOpportunisticUtils.sys.mjs (755B)


      1 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
      2 /* This Source Code Form is subject to the terms of the Mozilla Public
      3 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
      4 * You can obtain one at http://mozilla.org/MPL/2.0/. */
      5 
      6 export function WellKnownOpportunisticUtils() {
      7  this.valid = false;
      8  this.mixed = false;
      9  this.lifetime = 0;
     10 }
     11 
     12 WellKnownOpportunisticUtils.prototype = {
     13  QueryInterface: ChromeUtils.generateQI(["nsIWellKnownOpportunisticUtils"]),
     14 
     15  verify(aJSON, aOrigin) {
     16    try {
     17      let arr = JSON.parse(aJSON.toLowerCase());
     18      if (!arr.includes(aOrigin.toLowerCase())) {
     19        throw new Error("invalid origin");
     20      }
     21    } catch (e) {
     22      return;
     23    }
     24    this.valid = true;
     25  },
     26 };