mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-09 09:18:42 +09:00
Remove Firefox Accounts service and tie-ins.
See previous commit for removal of browser identity module.
This commit is contained in:
parent
ccf32a6b79
commit
c64dc935f9
420 changed files with 9 additions and 51958 deletions
|
|
@ -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);
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ EXTRA_COMPONENTS += [
|
|||
'ContentPermissionPrompt.js',
|
||||
'DirectoryProvider.js',
|
||||
'FilePicker.js',
|
||||
'FxAccountsPush.js',
|
||||
'HelperAppDialog.js',
|
||||
'ImageBlockingPolicy.js',
|
||||
'LoginManagerPrompter.js',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue