summaryrefslogtreecommitdiffstats
path: root/toolkit/components/satchel/integrations/FirefoxRelayUtils.sys.mjs
blob: 0dfb2a969d7b0977bb83455837d833e5d54aa0da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

import { LoginHelper } from "resource://gre/modules/LoginHelper.sys.mjs";

export const FirefoxRelayUtils = {
  isRelayInterestedField(input) {
    return (
      FirefoxRelayUtils.relayIsAvailableOrEnabled &&
      (LoginHelper.isInferredEmailField(input) ||
        LoginHelper.isInferredUsernameField(input))
    );
  },

  relayIsAvailableOrEnabled() {
    const value = Services.prefs.getStringPref(
      "signon.firefoxRelay.feature",
      undefined
    );
    return ["available", "offered", "enabled"].includes(value);
  },
};