Skip to content
This repository has been archived by the owner on Jul 15, 2019. It is now read-only.

Commit

Permalink
make Facebook import permission optional
Browse files Browse the repository at this point in the history
  • Loading branch information
adon committed Feb 23, 2016
1 parent a348ec5 commit 63e4a92
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/javascript/crypto/e2e/extension/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ goog.provide('e2e.ext.config');
*/
e2e.ext.config = {
/* The name of the cookie used to authenticate users to the keyserver. */
AUTH_COOKIE: 'YOUR_COOKIE_HERE',
AUTH_COOKIE: 'YBY',
/* Some location that has access to the auth cookie. */
AUTH_DEFAULT_ORIGIN: 'https://us-mg5.mail.yahoo.com',
AUTH_DEFAULT_ORIGIN: 'https://mail.yahoo.com',

/* The CONAME CONFIG */
CONAME: {
Expand Down
9 changes: 5 additions & 4 deletions src/javascript/crypto/e2e/extension/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
"webRequest",
"webRequestBlocking",
"https://localhost:25519/*",
"https://*.mail.yahoo.com/*",
"https://www.facebook.com/*/publickey/download?_rdr=p"
"https://*.mail.yahoo.com/*"
],
"optional_permissions": [
"https://www.facebook.com/*/publickey/download"
],
"optional_permissions": [],
"background": {"scripts": ["launcher_binary.js"]},
"options_page": "settings.html",
"browser_action": {
Expand All @@ -28,7 +29,7 @@
"run_at": "document_end"
},
{
"matches": ["https://alpha.coname.corp.yahoo.com:25519/auth/cookies"],
"matches": ["https://localhost:25519/auth/cookies"],
"js": ["yAuth/cookies.js"]
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ panels.KeyringMgmtMini.prototype.enterDocument = function() {
listen(
goog.dom.getElementByClass(constants.CssClass.ACTION, fbImportDiv),
goog.events.EventType.CLICK,
this.fbImportKey_).
this.fbImportGetPermission_).
listen(
goog.dom.getElementByClass(
constants.CssClass.CANCEL, passphraseChangeDiv),
Expand Down Expand Up @@ -308,7 +308,7 @@ panels.KeyringMgmtMini.prototype.enterDocument = function() {
listen(
keyboardHandler,
goog.ui.KeyboardShortcutHandler.EventType.SHORTCUT_TRIGGERED,
this.fbImportKey_);
this.fbImportGetPermission_);
};


Expand Down Expand Up @@ -377,6 +377,24 @@ panels.KeyringMgmtMini.prototype.importKeyring_ = function() {
};


/**
* Request for permission to access Facebook PGP key address
* @param {Event} event
* @private
*/
panels.KeyringMgmtMini.prototype.fbImportGetPermission_ = function(event) {
// Permissions must be requested from inside a user gesture, like a button's
// click handler.
chrome.permissions.request({
origins: ['https://www.facebook.com/']
}, goog.bind(function(granted) {
if (granted) {
this.fbImportKey_(event);
}
}, this));
};


/**
* Handles requests from the user to import a key from Facebook.
* @param {Event} event
Expand Down Expand Up @@ -413,7 +431,7 @@ panels.KeyringMgmtMini.prototype.fbImportKey_ = function(event) {
panels.KeyringMgmtMini.prototype.sendFbRequest_ = function(username, cb,
errback) {
var url = ['https://www.facebook.com', username, 'publickey',
'download?_rdr=p'].join('/');
'download'].join('/');
var xhr = new XMLHttpRequest();
xhr.timeout = 2000;
xhr.open('GET', url, true);
Expand Down
3 changes: 1 addition & 2 deletions src/javascript/crypto/e2e/extension/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,7 @@ utils.openAuthWindow = function(email) {

// TODO: url now hardcoded. support openid type
var authUrl = 'https://by.bouncer.login.yahoo.com/login?url=' +
encodeURIComponent(
'https://alpha.coname.corp.yahoo.com:25519/auth/cookies');
encodeURIComponent(e2e.ext.config.CONAME.realms[0].addr + '/auth/cookies');

chrome.windows.create({
url: authUrl,
Expand Down

0 comments on commit 63e4a92

Please sign in to comment.