Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
script: "gts check"
- stage: test
name: "lintspaces"
script: "npm i -g lintspaces-cli && lintspaces -nt -d 'spaces' -i 'js-comments' src/* view/* manifest-*.json css/popup.css css/import.css"
script: "npm i -g lintspaces-cli && lintspaces -nt -d 'spaces' -i 'js-comments' src/*/* src/*.ts view/* manifest-*.json css/popup.css css/import.css"
env: CACHE_NAME=LINTSPACES
- stage: test
name: "Build Firefox and run addons-linter"
Expand Down
12 changes: 9 additions & 3 deletions _locales/cs/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,13 @@
"description": "Sign out of 3rd party storage services"
},
"token_revoked": {
"message": "There was an issue connecting to your ${service} account, please sign in again.",
"description": "Error authenticating to backup service. ${service} will be replaced with a proper noun (E.g.: 'Google Drive' or 'Dropbox')"
"message": "There was an issue connecting to your $SERVICE$ account, please sign in again.",
"description": "Error authenticating to backup service. $SERVICE$ will be replaced with a proper noun (E.g.: 'Google Drive' or 'Dropbox')",
"placeholders": {
"service": {
"content": "$1",
"example": "Google Drive"
}
}
}
}
}
10 changes: 8 additions & 2 deletions _locales/de/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,13 @@
"description": "Sign out of 3rd party storage services"
},
"token_revoked": {
"message": "There was an issue connecting to your ${service} account, please sign in again.",
"description": "Error authenticating to backup service. ${service} will be replaced with a proper noun (E.g.: 'Google Drive' or 'Dropbox')"
"message": "There was an issue connecting to your $SERVICE$ account, please sign in again.",
"description": "Error authenticating to backup service. $SERVICE$ will be replaced with a proper noun (E.g.: 'Google Drive' or 'Dropbox')",
"placeholders": {
"service": {
"content": "$1",
"example": "Google Drive"
}
}
}
}
10 changes: 8 additions & 2 deletions _locales/el/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,13 @@
"description": "Sign out of 3rd party storage services"
},
"token_revoked": {
"message": "There was an issue connecting to your ${service} account, please sign in again.",
"description": "Error authenticating to backup service. ${service} will be replaced with a proper noun (E.g.: 'Google Drive' or 'Dropbox')"
"message": "There was an issue connecting to your $SERVICE$ account, please sign in again.",
"description": "Error authenticating to backup service. $SERVICE$ will be replaced with a proper noun (E.g.: 'Google Drive' or 'Dropbox')",
"placeholders": {
"service": {
"content": "$1",
"example": "Google Drive"
}
}
}
}
10 changes: 8 additions & 2 deletions _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,13 @@
"description": "Sign out of 3rd party storage services"
},
"token_revoked": {
"message": "There was an issue connecting to your ${service} account, please sign in again.",
"description": "Error authenticating to backup service. ${service} will be replaced with a proper noun (E.g.: 'Google Drive' or 'Dropbox')"
"message": "There was an issue connecting to your $SERVICE$ account, please sign in again.",
"description": "Error authenticating to backup service. $SERVICE$ will be replaced with a proper noun (E.g.: 'Google Drive' or 'Dropbox')",
"placeholders": {
"service": {
"content": "$1",
"example": "Google Drive"
}
}
}
}
12 changes: 9 additions & 3 deletions _locales/es/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,13 @@
"description": "Sign out of 3rd party storage services"
},
"token_revoked": {
"message": "Ha habido un problema al conectarse a su cuenta de ${service}, vuelva a iniciar sesión.",
"description": "Error authenticating to backup service. ${service} will be replaced with a proper noun (E.g.: 'Google Drive' or 'Dropbox')"
"message": "Ha habido un problema al conectarse a su cuenta de $SERVICE$, vuelva a iniciar sesión.",
"description": "Error authenticating to backup service. $SERVICE$ will be replaced with a proper noun (E.g.: 'Google Drive' or 'Dropbox')",
"placeholders": {
"service": {
"content": "$1",
"example": "Google Drive"
}
}
}
}
}
12 changes: 9 additions & 3 deletions _locales/fr/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,13 @@
"description": "Sign out of 3rd party storage services"
},
"token_revoked": {
"message": "There was an issue connecting to your ${service} account, please sign in again.",
"description": "Error authenticating to backup service. ${service} will be replaced with a proper noun (E.g.: 'Google Drive' or 'Dropbox')"
"message": "There was an issue connecting to your $SERVICE$ account, please sign in again.",
"description": "Error authenticating to backup service. $SERVICE$ will be replaced with a proper noun (E.g.: 'Google Drive' or 'Dropbox')",
"placeholders": {
"service": {
"content": "$1",
"example": "Google Drive"
}
}
}
}
}
12 changes: 9 additions & 3 deletions _locales/id/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,13 @@
"description": "Sign out of 3rd party storage services"
},
"token_revoked": {
"message": "There was an issue connecting to your ${service} account, please sign in again.",
"description": "Error authenticating to backup service. ${service} will be replaced with a proper noun (E.g.: 'Google Drive' or 'Dropbox')"
"message": "There was an issue connecting to your $SERVICE$ account, please sign in again.",
"description": "Error authenticating to backup service. $SERVICE$ will be replaced with a proper noun (E.g.: 'Google Drive' or 'Dropbox')",
"placeholders": {
"service": {
"content": "$1",
"example": "Google Drive"
}
}
}
}
}
12 changes: 9 additions & 3 deletions _locales/it/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,13 @@
"description": "Sign out of 3rd party storage services"
},
"token_revoked": {
"message": "There was an issue connecting to your ${service} account, please sign in again.",
"description": "Error authenticating to backup service. ${service} will be replaced with a proper noun (E.g.: 'Google Drive' or 'Dropbox')"
"message": "There was an issue connecting to your $SERVICE$ account, please sign in again.",
"description": "Error authenticating to backup service. $SERVICE$ will be replaced with a proper noun (E.g.: 'Google Drive' or 'Dropbox')",
"placeholders": {
"service": {
"content": "$1",
"example": "Google Drive"
}
}
}
}
}
10 changes: 8 additions & 2 deletions _locales/ja/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,13 @@
"description": "Sign out of 3rd party storage services"
},
"token_revoked": {
"message": "There was an issue connecting to your ${service} account, please sign in again.",
"description": "Error authenticating to backup service. ${service} will be replaced with a proper noun (E.g.: 'Google Drive' or 'Dropbox')"
"message": "There was an issue connecting to your $SERVICE$ account, please sign in again.",
"description": "Error authenticating to backup service. $SERVICE$ will be replaced with a proper noun (E.g.: 'Google Drive' or 'Dropbox')",
"placeholders": {
"service": {
"content": "$1",
"example": "Google Drive"
}
}
}
}
12 changes: 9 additions & 3 deletions _locales/nl/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,13 @@
"description": "Sign out of 3rd party storage services"
},
"token_revoked": {
"message": "Er was een probleem verbinding met uw account ${service}, log opnieuw in.",
"description": "Error authenticating to backup service. ${service} will be replaced with a proper noun (E.g.: 'Google Drive' or 'Dropbox')"
"message": "Er was een probleem verbinding met uw account $SERVICE$, log opnieuw in.",
"description": "Error authenticating to backup service. $SERVICE$ will be replaced with a proper noun (E.g.: 'Google Drive' or 'Dropbox')",
"placeholders": {
"service": {
"content": "$1",
"example": "Google Drive"
}
}
}
}
}
12 changes: 9 additions & 3 deletions _locales/pl/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,13 @@
"description": "Sign out of 3rd party storage services"
},
"token_revoked": {
"message": "Wystąpił problem z połączeniem z twoim kontem ${service}, zaloguj się ponownie.",
"description": "Error authenticating to backup service. ${service} will be replaced with a proper noun (E.g.: 'Google Drive' or 'Dropbox')"
"message": "Wystąpił problem z połączeniem z twoim kontem $SERVICE$, zaloguj się ponownie.",
"description": "Error authenticating to backup service. $SERVICE$ will be replaced with a proper noun (E.g.: 'Google Drive' or 'Dropbox')",
"placeholders": {
"service": {
"content": "$1",
"example": "Google Drive"
}
}
}
}
}
12 changes: 9 additions & 3 deletions _locales/pt_BR/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,13 @@
"description": "Sign out of 3rd party storage services"
},
"token_revoked": {
"message": "Houve um problema na conexão com sua conta do ${service}, por favor tente novamente.",
"description": "Error authenticating to backup service. ${service} will be replaced with a proper noun (E.g.: 'Google Drive' or 'Dropbox')"
"message": "Houve um problema na conexão com sua conta do $SERVICE$, por favor tente novamente.",
"description": "Error authenticating to backup service. $SERVICE$ will be replaced with a proper noun (E.g.: 'Google Drive' or 'Dropbox')",
"placeholders": {
"service": {
"content": "$1",
"example": "Google Drive"
}
}
}
}
}
12 changes: 9 additions & 3 deletions _locales/ru/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,13 @@
"description": "Sign out of 3rd party storage services"
},
"token_revoked": {
"message": "Существует проблема подключения к вашей учетной записи ${service} , пожалуйста войдите в систему снова.",
"description": "Error authenticating to backup service. ${service} will be replaced with a proper noun (E.g.: 'Google Drive' or 'Dropbox')"
"message": "Существует проблема подключения к вашей учетной записи $SERVICE$ , пожалуйста войдите в систему снова.",
"description": "Error authenticating to backup service. $SERVICE$ will be replaced with a proper noun (E.g.: 'Google Drive' or 'Dropbox')",
"placeholders": {
"service": {
"content": "$1",
"example": "Google Drive"
}
}
}
}
}
12 changes: 9 additions & 3 deletions _locales/sv/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,13 @@
"description": "Sign out of 3rd party storage services"
},
"token_revoked": {
"message": "There was an issue connecting to your ${service} account, please sign in again.",
"description": "Error authenticating to backup service. ${service} will be replaced with a proper noun (E.g.: 'Google Drive' or 'Dropbox')"
"message": "There was an issue connecting to your $SERVICE$ account, please sign in again.",
"description": "Error authenticating to backup service. $SERVICE$ will be replaced with a proper noun (E.g.: 'Google Drive' or 'Dropbox')",
"placeholders": {
"service": {
"content": "$1",
"example": "Google Drive"
}
}
}
}
}
12 changes: 9 additions & 3 deletions _locales/tr/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,13 @@
"description": "Sign out of 3rd party storage services"
},
"token_revoked": {
"message": "There was an issue connecting to your ${service} account, please sign in again.",
"description": "Error authenticating to backup service. ${service} will be replaced with a proper noun (E.g.: 'Google Drive' or 'Dropbox')"
"message": "There was an issue connecting to your $SERVICE$ account, please sign in again.",
"description": "Error authenticating to backup service. $SERVICE$ will be replaced with a proper noun (E.g.: 'Google Drive' or 'Dropbox')",
"placeholders": {
"service": {
"content": "$1",
"example": "Google Drive"
}
}
}
}
}
12 changes: 9 additions & 3 deletions _locales/vi/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,13 @@
"description": "Sign out of 3rd party storage services"
},
"token_revoked": {
"message": "Có một vấn đề kết nối với tài khoản ${service}, xin vui lòng đăng nhập lại.",
"description": "Error authenticating to backup service. ${service} will be replaced with a proper noun (E.g.: 'Google Drive' or 'Dropbox')"
"message": "Có một vấn đề kết nối với tài khoản $SERVICE$, xin vui lòng đăng nhập lại.",
"description": "Error authenticating to backup service. $SERVICE$ will be replaced with a proper noun (E.g.: 'Google Drive' or 'Dropbox')",
"placeholders": {
"service": {
"content": "$1",
"example": "Google Drive"
}
}
}
}
}
10 changes: 8 additions & 2 deletions _locales/zh_CN/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,13 @@
"description": "Sign out of 3rd party storage services"
},
"token_revoked": {
"message": "连接到您的 ${service} 账号时出错,请登录后重试。",
"description": "Error authenticating to backup service. ${service} will be replaced with a proper noun (E.g.: 'Google Drive' or 'Dropbox')"
"message": "连接到您的 $SERVICE$ 账号时出错,请登录后重试。",
"description": "Error authenticating to backup service. $SERVICE$ will be replaced with a proper noun (E.g.: 'Google Drive' or 'Dropbox')",
"placeholders": {
"service": {
"content": "$1",
"example": "Google Drive"
}
}
}
}
12 changes: 9 additions & 3 deletions _locales/zh_TW/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,13 @@
"description": "Sign out of 3rd party storage services"
},
"token_revoked": {
"message": "連接到您的 ${service} 帳戶時出現問題,請重試。",
"description": "Error authenticating to backup service. ${service} will be replaced with a proper noun (E.g.: 'Google Drive' or 'Dropbox')"
"message": "連接到您的 $SERVICE$ 帳戶時出現問題,請重試。",
"description": "Error authenticating to backup service. $SERVICE$ will be replaced with a proper noun (E.g.: 'Google Drive' or 'Dropbox')",
"placeholders": {
"service": {
"content": "$1",
"example": "Google Drive"
}
}
}
}
}
8 changes: 7 additions & 1 deletion src/models/backup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,18 @@ class Drive {
xhr.open('GET', 'https://www.googleapis.com/drive/v3/files');
xhr.setRequestHeader(
'Authorization', 'Bearer ' + localStorage.driveToken);
xhr.onreadystatechange = () => {
xhr.onreadystatechange = async () => {
if (xhr.readyState === 4) {
try {
const res = JSON.parse(xhr.responseText);
if (res.error) {
if (res.error.code === 401) {
if (navigator.userAgent.indexOf('Chrome') !== -1) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this line be removed?

Copy link
Member Author

@mymindstorm mymindstorm Jan 18, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. We have to handle Chrome Google account login differently (via chrome.identity) from Firefox because of Google API restrictions. chrome.identity isn't part of Firefox, hence the check here.

When a user revokes a token from Google's side the token is still cached in Chrome. So, if a user tries to sign in again directly after revoking a token chrome.identity.getAuthToken would notice a cached token is still available and pull it even though it was revoked. This causes the extension to show a 'Failure' message since the 'new' token is revoked already.

To reproduce with 5.2.2:

  1. login to google drive
  2. sync
  3. revoke access from https://myaccount.google.com/permissions
  4. keep syncing until the extension gets a 401
  5. close and open the extension popup (not chrome)
  6. try to login again
  7. get error
  8. goto 6

To prove it's the cache after reproducing:

  1. see error after trying to login
  2. open chrome://identity-internals/ and revoke token
  3. try to login to drive sync
  4. success

// Clear invalid token from
// chrome://identity-internals/
await chrome.identity.removeCachedAuthToken(
{'token': localStorage.driveToken});
}
localStorage.driveToken = '';
resolve(true);
}
Expand Down
2 changes: 1 addition & 1 deletion src/models/credentials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ function getCredentials() {
client_id: 'mmx38seexw3tvps' // Dropbox client ID
}
};
}
}
18 changes: 9 additions & 9 deletions src/ui/backup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ async function backup(_ui: UI) {
if (response === true) {
_ui.instance.alert(_ui.instance.i18n.updateSuccess);
} else if (localStorage.dropboxRevoked === 'true') {
_ui.instance.alert(String(_ui.instance.i18n.token_revoked)
.replace(/\${service}/, 'Dropbox'));
_ui.instance.alert(
chrome.i18n.getMessage('token_revoked', ['Dropbox']));
localStorage.removeItem('dropboxRevoked');
_ui.instance.dropboxToken = '';
} else {
_ui.instance.alert(_ui.instance.i18n.updateFailure);
}
Expand All @@ -30,9 +31,10 @@ async function backup(_ui: UI) {
if (response === true) {
_ui.instance.alert(_ui.instance.i18n.updateSuccess);
} else if (localStorage.driveRevoked === 'true') {
_ui.instance.alert(String(_ui.instance.i18n.token_revoked)
.replace(/\${service}/, 'Google Drive'));
_ui.instance.alert(
chrome.i18n.getMessage('token_revoked', ['Google Drive']));
localStorage.removeItem('driveRevoked');
_ui.instance.driveToken = '';
} else {
_ui.instance.alert(_ui.instance.i18n.updateFailure);
}
Expand Down Expand Up @@ -107,8 +109,7 @@ async function backup(_ui: UI) {
return;
} else if (localStorage.dropboxRevoked === 'true') {
_ui.instance.alert(
String(_ui.instance.i18n.token_revoked)
.replace(/\${service}/, 'Dropbox'));
chrome.i18n.getMessage('token_revoked', ['Dropbox']));
localStorage.removeItem('dropboxRevoked');
}
} catch (error) {
Expand Down Expand Up @@ -136,9 +137,8 @@ async function backup(_ui: UI) {
localStorage.lastRemindingBackupTime = clientTime;
return;
} else if (localStorage.driveRevoked === 'true') {
_ui.instance.alert(
String(_ui.instance.i18n.token_revoked)
.replace(/\${service}/, 'Google Drive'));
_ui.instance.alert(chrome.i18n.getMessage(
'token_revoked', ['Google Drive']));
localStorage.removeItem('driveRevoked');
}
} catch (error) {
Expand Down