summaryrefslogtreecommitdiffstats
path: root/mobile/android/components
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@wolfbeast.com>2019-04-19 02:02:56 +0200
committerwolfbeast <mcwerewolf@wolfbeast.com>2019-04-19 02:02:56 +0200
commitde75f133a7ec654d2a7c5bf628b3aee9fc109730 (patch)
tree4771e6d114249bf48d1e843167bcf393de2b98a2 /mobile/android/components
parentcdc962dca59f2d68b82bec99beb5d67ae163f24a (diff)
downloadUXP-de75f133a7ec654d2a7c5bf628b3aee9fc109730.tar
UXP-de75f133a7ec654d2a7c5bf628b3aee9fc109730.tar.gz
UXP-de75f133a7ec654d2a7c5bf628b3aee9fc109730.tar.lz
UXP-de75f133a7ec654d2a7c5bf628b3aee9fc109730.tar.xz
UXP-de75f133a7ec654d2a7c5bf628b3aee9fc109730.zip
Remove Firefox Accounts service and tie-ins.
See previous commit for removal of browser identity module.
Diffstat (limited to 'mobile/android/components')
-rw-r--r--mobile/android/components/FxAccountsPush.js164
-rw-r--r--mobile/android/components/MobileComponents.manifest5
-rw-r--r--mobile/android/components/moz.build1
3 files changed, 0 insertions, 170 deletions
diff --git a/mobile/android/components/FxAccountsPush.js b/mobile/android/components/FxAccountsPush.js
deleted file mode 100644
index e6054a2de..000000000
--- a/mobile/android/components/FxAccountsPush.js
+++ /dev/null
@@ -1,164 +0,0 @@
-/* jshint moz: true, esnext: true */
-/* 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/. */
-
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-const Cu = Components.utils;
-
-Cu.import("resource://gre/modules/XPCOMUtils.jsm");
-Cu.import("resource://gre/modules/Services.jsm");
-Cu.import("resource://gre/modules/Messaging.jsm");
-const {
- PushCrypto,
- getCryptoParams,
-} = Cu.import("resource://gre/modules/PushCrypto.jsm");
-
-XPCOMUtils.defineLazyServiceGetter(this, "PushService",
- "@mozilla.org/push/Service;1", "nsIPushService");
-XPCOMUtils.defineLazyGetter(this, "_decoder", () => new TextDecoder());
-
-const FXA_PUSH_SCOPE = "chrome://fxa-push";
-const Log = Cu.import("resource://gre/modules/AndroidLog.jsm", {}).AndroidLog.bind("FxAccountsPush");
-
-function FxAccountsPush() {
- Services.obs.addObserver(this, "FxAccountsPush:ReceivedPushMessageToDecode", false);
-
- Messaging.sendRequestForResult({
- type: "FxAccountsPush:Initialized"
- });
-}
-
-FxAccountsPush.prototype = {
- observe: function (subject, topic, data) {
- switch (topic) {
- case "android-push-service":
- if (data === "android-fxa-subscribe") {
- this._subscribe();
- } else if (data === "android-fxa-unsubscribe") {
- this._unsubscribe();
- }
- break;
- case "FxAccountsPush:ReceivedPushMessageToDecode":
- this._decodePushMessage(data);
- break;
- }
- },
-
- _subscribe() {
- Log.i("FxAccountsPush _subscribe");
- return new Promise((resolve, reject) => {
- PushService.subscribe(FXA_PUSH_SCOPE,
- Services.scriptSecurityManager.getSystemPrincipal(),
- (result, subscription) => {
- if (Components.isSuccessCode(result)) {
- Log.d("FxAccountsPush got subscription");
- resolve(subscription);
- } else {
- Log.w("FxAccountsPush failed to subscribe", result);
- reject(new Error("FxAccountsPush failed to subscribe"));
- }
- });
- })
- .then(subscription => {
- Messaging.sendRequest({
- type: "FxAccountsPush:Subscribe:Response",
- subscription: {
- pushCallback: subscription.endpoint,
- pushPublicKey: urlsafeBase64Encode(subscription.getKey('p256dh')),
- pushAuthKey: urlsafeBase64Encode(subscription.getKey('auth'))
- }
- });
- })
- .catch(err => {
- Log.i("Error when registering FxA push endpoint " + err);
- });
- },
-
- _unsubscribe() {
- Log.i("FxAccountsPush _unsubscribe");
- return new Promise((resolve) => {
- PushService.unsubscribe(FXA_PUSH_SCOPE,
- Services.scriptSecurityManager.getSystemPrincipal(),
- (result, ok) => {
- if (Components.isSuccessCode(result)) {
- if (ok === true) {
- Log.d("FxAccountsPush unsubscribed");
- } else {
- Log.d("FxAccountsPush had no subscription to unsubscribe");
- }
- } else {
- Log.w("FxAccountsPush failed to unsubscribe", result);
- }
- return resolve(ok);
- });
- }).catch(err => {
- Log.e("Error during unsubscribe", err);
- });
- },
-
- _decodePushMessage(data) {
- Log.i("FxAccountsPush _decodePushMessage");
- data = JSON.parse(data);
- let { headers, message } = this._messageAndHeaders(data);
- return new Promise((resolve, reject) => {
- PushService.getSubscription(FXA_PUSH_SCOPE,
- Services.scriptSecurityManager.getSystemPrincipal(),
- (result, subscription) => {
- if (!subscription) {
- return reject(new Error("No subscription found"));
- }
- return resolve(subscription);
- });
- }).then(subscription => {
- return PushCrypto.decrypt(subscription.p256dhPrivateKey,
- new Uint8Array(subscription.getKey("p256dh")),
- new Uint8Array(subscription.getKey("auth")),
- headers, message);
- })
- .then(plaintext => {
- let decryptedMessage = plaintext ? _decoder.decode(plaintext) : "";
- Messaging.sendRequestForResult({
- type: "FxAccountsPush:ReceivedPushMessageToDecode:Response",
- message: decryptedMessage
- });
- })
- .catch(err => {
- Log.d("Error while decoding incoming message : " + err);
- });
- },
-
- // Copied from PushServiceAndroidGCM
- _messageAndHeaders(data) {
- // Default is no data (and no encryption).
- let message = null;
- let headers = null;
-
- if (data.message && data.enc && (data.enckey || data.cryptokey)) {
- headers = {
- encryption_key: data.enckey,
- crypto_key: data.cryptokey,
- encryption: data.enc,
- encoding: data.con,
- };
- // Ciphertext is (urlsafe) Base 64 encoded.
- message = ChromeUtils.base64URLDecode(data.message, {
- // The Push server may append padding.
- padding: "ignore",
- });
- }
- return { headers, message };
- },
-
- QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver]),
-
- classID: Components.ID("{d1bbb0fd-1d47-4134-9c12-d7b1be20b721}")
-};
-
-function urlsafeBase64Encode(key) {
- return ChromeUtils.base64URLEncode(new Uint8Array(key), { pad: false });
-}
-
-var components = [ FxAccountsPush ];
-this.NSGetFactory = XPCOMUtils.generateNSGetFactory(components);
diff --git a/mobile/android/components/MobileComponents.manifest b/mobile/android/components/MobileComponents.manifest
index 5194de48f..fe5deb95f 100644
--- a/mobile/android/components/MobileComponents.manifest
+++ b/mobile/android/components/MobileComponents.manifest
@@ -100,11 +100,6 @@ contract @mozilla.org/dom/site-specific-user-agent;1 {d5234c9d-0ee2-4b3c-9da3-18
component {18a4e042-7c7c-424b-a583-354e68553a7f} FilePicker.js
contract @mozilla.org/filepicker;1 {18a4e042-7c7c-424b-a583-354e68553a7f}
-# FxAccountsPush.js
-component {d1bbb0fd-1d47-4134-9c12-d7b1be20b721} FxAccountsPush.js
-contract @mozilla.org/fxa-push;1 {d1bbb0fd-1d47-4134-9c12-d7b1be20b721}
-category android-push-service FxAccountsPush @mozilla.org/fxa-push;1
-
#ifndef RELEASE_OR_BETA
# TabSource.js
component {5850c76e-b916-4218-b99a-31f004e0a7e7} TabSource.js
diff --git a/mobile/android/components/moz.build b/mobile/android/components/moz.build
index cac34b603..9e6683662 100644
--- a/mobile/android/components/moz.build
+++ b/mobile/android/components/moz.build
@@ -20,7 +20,6 @@ EXTRA_COMPONENTS += [
'ContentPermissionPrompt.js',
'DirectoryProvider.js',
'FilePicker.js',
- 'FxAccountsPush.js',
'HelperAppDialog.js',
'ImageBlockingPolicy.js',
'LoginManagerPrompter.js',