Skip to content

Commit 6bd906d

Browse files
authored
Merge pull request #432 from Authenticator-Extension/new-edge-fixes
New edge fixes
2 parents 229aa24 + cdc4259 commit 6bd906d

File tree

4 files changed

+32
-8
lines changed

4 files changed

+32
-8
lines changed

src/background.ts

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,11 @@ async function getTotp(text: string) {
219219
}
220220

221221
function getBackupToken(service: string) {
222-
if (navigator.userAgent.indexOf("Chrome") !== -1 && service === "drive") {
222+
if (
223+
navigator.userAgent.indexOf("Chrome") !== -1 &&
224+
navigator.userAgent.indexOf("Edg") === -1 &&
225+
service === "drive"
226+
) {
223227
chrome.identity.getAuthToken(
224228
{
225229
interactive: true,
@@ -233,18 +237,26 @@ function getBackupToken(service: string) {
233237
);
234238
} else {
235239
let authUrl = "";
240+
let redirUrl = "";
236241
if (service === "dropbox") {
242+
redirUrl = encodeURIComponent(chrome.identity.getRedirectURL());
237243
authUrl =
238244
"https://www.dropbox.com/oauth2/authorize?response_type=token&client_id=" +
239245
getCredentials().dropbox.client_id +
240246
"&redirect_uri=" +
241-
encodeURIComponent(chrome.identity.getRedirectURL());
247+
redirUrl;
242248
} else if (service === "drive") {
249+
if (navigator.userAgent.indexOf("Edg") !== -1) {
250+
redirUrl = encodeURIComponent("https://authenticator.cc/oauth-edge");
251+
} else {
252+
redirUrl = encodeURIComponent("https://authenticator.cc/oauth");
253+
}
254+
243255
authUrl =
244256
"https://accounts.google.com/o/oauth2/v2/auth?response_type=code&access_type=offline&client_id=" +
245257
getCredentials().drive.client_id +
246258
"&scope=https%3A//www.googleapis.com/auth/drive.file&prompt=consent&redirect_uri=" +
247-
encodeURIComponent("https://authenticator.cc/oauth");
259+
redirUrl;
248260
}
249261
chrome.identity.launchWebAuthFlow(
250262
{ url: authUrl, interactive: true },
@@ -296,7 +308,9 @@ function getBackupToken(service: string) {
296308
getCredentials().drive.client_secret +
297309
"&code=" +
298310
value +
299-
"&redirect_uri=https://authenticator.cc/oauth&grant_type=authorization_code"
311+
"&redirect_uri=" +
312+
redirUrl +
313+
"&grant_type=authorization_code"
300314
);
301315
xhr.setRequestHeader("Accept", "application/json");
302316
xhr.setRequestHeader(
@@ -365,7 +379,10 @@ chrome.runtime.onInstalled.addListener(async details => {
365379

366380
let url: string | null = null;
367381

368-
if (navigator.userAgent.indexOf("Chrome") !== -1) {
382+
if (
383+
navigator.userAgent.indexOf("Chrome") !== -1 &&
384+
navigator.userAgent.indexOf("Edg") === -1
385+
) {
369386
url = "https://authenticator.cc/docs/en/chrome-issues";
370387
}
371388

src/components/Popup/DrivePage.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,10 @@ export default Vue.extend({
7979
);
8080
xhr.onreadystatechange = () => {
8181
if (xhr.readyState === 4) {
82-
if (navigator.userAgent.indexOf("Chrome") !== -1) {
82+
if (
83+
navigator.userAgent.indexOf("Chrome") !== -1 &&
84+
navigator.userAgent.indexOf("Edg") === -1
85+
) {
8386
chrome.identity.removeCachedAuthToken(
8487
{ token: localStorage.driveToken },
8588
() => {

src/components/Popup/MenuPage.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ export default Vue.extend({
106106
107107
if (navigator.userAgent.indexOf("Firefox") !== -1) {
108108
url = "https://authenticator.cc/docs/en/firefox-issues";
109+
} else if (navigator.userAgent.indexOf("Edg") !== -1) {
110+
url = "https://authenticator.cc/docs/en/edge-issues";
109111
}
110112
111113
const feedbackURL = this.$store.state.menu.feedbackURL;

src/models/backup.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ export class Drive implements BackupProvider {
129129
if (res.error.code === 401) {
130130
if (
131131
navigator.userAgent.indexOf("Chrome") !== -1 &&
132-
navigator.userAgent.indexOf("OPR") === -1
132+
navigator.userAgent.indexOf("OPR") === -1 &&
133+
navigator.userAgent.indexOf("Edg") === -1
133134
) {
134135
// Clear invalid token from
135136
// chrome://identity-internals/
@@ -162,7 +163,8 @@ export class Drive implements BackupProvider {
162163
private async refreshToken() {
163164
if (
164165
navigator.userAgent.indexOf("Chrome") !== -1 &&
165-
navigator.userAgent.indexOf("OPR") === -1
166+
navigator.userAgent.indexOf("OPR") === -1 &&
167+
navigator.userAgent.indexOf("Edg") === -1
166168
) {
167169
return new Promise((resolve: (value: boolean) => void) => {
168170
return chrome.identity.getAuthToken(

0 commit comments

Comments
 (0)