diff --git a/.travis.yml b/.travis.yml index 6d1b87f27..a36f9af6f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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" diff --git a/_locales/cs/messages.json b/_locales/cs/messages.json index 0b421634f..e1b20cc96 100644 --- a/_locales/cs/messages.json +++ b/_locales/cs/messages.json @@ -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" + } + } } -} \ No newline at end of file +} diff --git a/_locales/de/messages.json b/_locales/de/messages.json index b7358bac8..8ed4cc8db 100644 --- a/_locales/de/messages.json +++ b/_locales/de/messages.json @@ -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" + } + } } } diff --git a/_locales/el/messages.json b/_locales/el/messages.json index bcfca4461..b706f819f 100644 --- a/_locales/el/messages.json +++ b/_locales/el/messages.json @@ -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" + } + } } } diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 3366e73fd..527ff1c48 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -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" + } + } } } diff --git a/_locales/es/messages.json b/_locales/es/messages.json index b64cfbb99..786b964a1 100644 --- a/_locales/es/messages.json +++ b/_locales/es/messages.json @@ -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" + } + } } -} \ No newline at end of file +} diff --git a/_locales/fr/messages.json b/_locales/fr/messages.json index 4d3d7958a..37f0982b0 100644 --- a/_locales/fr/messages.json +++ b/_locales/fr/messages.json @@ -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" + } + } } -} \ No newline at end of file +} diff --git a/_locales/id/messages.json b/_locales/id/messages.json index 4c694bf7b..456a3907f 100644 --- a/_locales/id/messages.json +++ b/_locales/id/messages.json @@ -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" + } + } } -} \ No newline at end of file +} diff --git a/_locales/it/messages.json b/_locales/it/messages.json index a14cc8ffe..37501ef8c 100644 --- a/_locales/it/messages.json +++ b/_locales/it/messages.json @@ -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" + } + } } -} \ No newline at end of file +} diff --git a/_locales/ja/messages.json b/_locales/ja/messages.json index 9c8a12e76..d014643ed 100644 --- a/_locales/ja/messages.json +++ b/_locales/ja/messages.json @@ -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" + } + } } } diff --git a/_locales/nl/messages.json b/_locales/nl/messages.json index 40c0636eb..30482b953 100644 --- a/_locales/nl/messages.json +++ b/_locales/nl/messages.json @@ -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" + } + } } -} \ No newline at end of file +} diff --git a/_locales/pl/messages.json b/_locales/pl/messages.json index 2d72654ec..c79d79889 100644 --- a/_locales/pl/messages.json +++ b/_locales/pl/messages.json @@ -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" + } + } } -} \ No newline at end of file +} diff --git a/_locales/pt_BR/messages.json b/_locales/pt_BR/messages.json index e37b3c0d2..35da7050a 100644 --- a/_locales/pt_BR/messages.json +++ b/_locales/pt_BR/messages.json @@ -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" + } + } } -} \ No newline at end of file +} diff --git a/_locales/ru/messages.json b/_locales/ru/messages.json index 59dadabd6..6b84095fe 100644 --- a/_locales/ru/messages.json +++ b/_locales/ru/messages.json @@ -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" + } + } } -} \ No newline at end of file +} diff --git a/_locales/sv/messages.json b/_locales/sv/messages.json index dbc28c051..7c59c68f0 100644 --- a/_locales/sv/messages.json +++ b/_locales/sv/messages.json @@ -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" + } + } } -} \ No newline at end of file +} diff --git a/_locales/tr/messages.json b/_locales/tr/messages.json index 647b77985..aacc481ad 100644 --- a/_locales/tr/messages.json +++ b/_locales/tr/messages.json @@ -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" + } + } } -} \ No newline at end of file +} diff --git a/_locales/vi/messages.json b/_locales/vi/messages.json index 84534caeb..2efb671ca 100644 --- a/_locales/vi/messages.json +++ b/_locales/vi/messages.json @@ -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" + } + } } -} \ No newline at end of file +} diff --git a/_locales/zh_CN/messages.json b/_locales/zh_CN/messages.json index 726dd5828..bf0bbf0f4 100644 --- a/_locales/zh_CN/messages.json +++ b/_locales/zh_CN/messages.json @@ -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" + } + } } } diff --git a/_locales/zh_TW/messages.json b/_locales/zh_TW/messages.json index 9249d597b..14cc260f7 100644 --- a/_locales/zh_TW/messages.json +++ b/_locales/zh_TW/messages.json @@ -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" + } + } } -} \ No newline at end of file +} diff --git a/src/models/backup.ts b/src/models/backup.ts index 17e459792..f3ab14fb9 100644 --- a/src/models/backup.ts +++ b/src/models/backup.ts @@ -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) { + // Clear invalid token from + // chrome://identity-internals/ + await chrome.identity.removeCachedAuthToken( + {'token': localStorage.driveToken}); + } localStorage.driveToken = ''; resolve(true); } diff --git a/src/models/credentials.ts b/src/models/credentials.ts index b5a1134f4..440d335a9 100644 --- a/src/models/credentials.ts +++ b/src/models/credentials.ts @@ -9,4 +9,4 @@ function getCredentials() { client_id: 'mmx38seexw3tvps' // Dropbox client ID } }; -} \ No newline at end of file +} diff --git a/src/ui/backup.ts b/src/ui/backup.ts index 9b59ed814..f0b922f81 100644 --- a/src/ui/backup.ts +++ b/src/ui/backup.ts @@ -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); } @@ -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); } @@ -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) { @@ -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) {