Verified Commit ae4f5530 authored by Richard Pospesel's avatar Richard Pospesel Committed by Pier Angelo Vendrame
Browse files

Bug 40597: Implement TorSettings module

- migrated in-page settings read/write implementation from about:preferences#tor
  to the TorSettings module
- TorSettings initially loads settings from the tor daemon, and saves them to
  firefox prefs
- TorSettings notifies observers when a setting has changed; currently only
  QuickStart notification is implemented for parity with previous preference
  notify logic in about:torconnect and about:preferences#tor
- about:preferences#tor, and about:torconnect now read and write settings
  thorugh the TorSettings module
- all tor settings live in the torbrowser.settings.* preference branch
- removed unused pref modify permission for about:torconnect content page from
  AsyncPrefs.jsm

Bug 40645: Migrate Moat APIs to Moat.jsm module
parent 44b7a4ed
Loading
Loading
Loading
Loading
+61 −0
Original line number Diff line number Diff line
"use strict";

var EXPORTED_SYMBOLS = ["BridgeDB"];

const { MoatRPC } = ChromeUtils.import("resource:///modules/Moat.jsm");

var BridgeDB = {
  _moatRPC: null,
  _challenge: null,
  _image: null,
  _bridges: null,

  get currentCaptchaImage() {
    return this._image;
  },

  get currentBridges() {
    return this._bridges;
  },

  async submitCaptchaGuess(solution) {
    if (!this._moatRPC) {
      this._moatRPC = new MoatRPC();
      await this._moatRPC.init();
    }

    const response = await this._moatRPC.check(
      "obfs4",
      this._challenge,
      solution,
      false
    );
    this._bridges = response?.bridges;
    return this._bridges;
  },

  async requestNewCaptchaImage() {
    try {
      if (!this._moatRPC) {
        this._moatRPC = new MoatRPC();
        await this._moatRPC.init();
      }

      const response = await this._moatRPC.fetch(["obfs4"]);
      this._challenge = response.challenge;
      this._image =
        "data:image/jpeg;base64," + encodeURIComponent(response.image);
    } catch (err) {
      console.error("Could not request a captcha image", err);
    }
    return this._image;
  },

  close() {
    this._moatRPC?.uninit();
    this._moatRPC = null;
    this._challenge = null;
    this._image = null;
    this._bridges = null;
  },
};
+804 −0

File added.

Preview size limit exceeded, changes collapsed.

+1164 −0

File added.

Preview size limit exceeded, changes collapsed.

+782 −0

File added.

Preview size limit exceeded, changes collapsed.

+4 −0
Original line number Diff line number Diff line
@@ -121,6 +121,7 @@ EXTRA_JS_MODULES += [
    "AboutNewTab.jsm",
    "AppUpdater.jsm",
    "AsyncTabSwitcher.jsm",
    "BridgeDB.jsm",
    "BrowserUIUtils.jsm",
    "BrowserUsageTelemetry.jsm",
    "BrowserWindowTracker.jsm",
@@ -131,6 +132,7 @@ EXTRA_JS_MODULES += [
    "FaviconLoader.jsm",
    "HomePage.jsm",
    "LaterRun.jsm",
    'Moat.jsm',
    "NewTabPagePreloading.jsm",
    "OpenInTabsUtils.jsm",
    "PageActions.jsm",
@@ -144,6 +146,8 @@ EXTRA_JS_MODULES += [
    "SitePermissions.jsm",
    "TabsList.jsm",
    "TabUnloader.jsm",
    "TorConnect.jsm",
    "TorSettings.jsm",
    "TransientPrefs.jsm",
    "webrtcUI.jsm",
    "ZoomUI.jsm",
Loading