AdguardTeam / AdGuardVPNExtension

AdGuard VPN Chrome and Firefox extension
https://adguard-vpn.com/
GNU General Public License v3.0
86 stars 19 forks source link

onAuthRequired event doesn't fire for requests sent from extension on MV3. #110

Closed maximtop closed 1 year ago

maximtop commented 1 year ago

Please answer the following questions for yourself before submitting an issue.

AdGuard VPN Browser Extension version

2.0.16

Environment

- OS: MacOS
- Browser: Chrome

Issue Details

In the extension, we have implemented a mechanism that triggers the onAuthRequired event whenever the proxy settings are changed.

https://github.com/AdguardTeam/AdGuardVPNExtension/blob/f2a4fad5291a5e7269531418aa0049acc2444988/src/background/proxy/chrome/proxyApi.ts#L139-L146

We created this mechanism to prevent situations where the onAuthRequired event doesn't fire for certain requests, such as those involving websockets. This works as expected in Manifest V2 (mv2), with the onAuthRequired event firing every time. However, in the extension built on Manifest V3 (mv3), it doesn't fire.

Expected Behavior

The onAuthRequired event is designed to fire every time a request is sent via a proxy.

Screenshots

No response

Additional Information

chromium bug tracker https://bugs.chromium.org/p/chromium/issues/detail?id=1464898

alexx7311 commented 1 year ago

Here's the link on how to reproduce the problem https://github.com/AdguardTeam/AdGuardVPNExtension/issues/109

ameshkov commented 1 year ago

Since the old workaround works no more in MV3, we should try a different one now, even uglier than the old one:

try {
    const ret = await chrome.windows.create({
        url: `http://${nanoid()}.${PAC_SCRIPT_CHECK_URL}`,
        focused: false,
        state: 'minimized',
    });
    await new Promise(resolve => setTimeout(resolve, 2000));
    await chrome.windows.remove(ret.id);
} catch (ex) {
    console.log(`Error while using the workaround to force onAuthRequired: ${ex}`);
}

The idea is to open a new hidden window which will "trigger" onAuthRequired and make the browser forget about cached credentials.

We should also carefully assess how annoying this hidden window is on both macOS and Windows.

ihurin commented 1 year ago

+1 CRM 779919.

db-EV commented 1 year ago

Same problem here, extension from the Chrome Web Store unusable right now. I had even problems that an individual DNS server wasn't used anymore. Installed now manually version 1.4.22 which is working as aspected.

AleksandrKalininAdGuard commented 1 year ago

+3 CRM 781400 780089 781089

AleksandrKalininAdGuard commented 1 year ago

+1 CRM 781693

ihurin commented 1 year ago

+1 CRM 785031

ihurin commented 1 year ago

@maximtop hi, is there anything new regarding this?

db-EV commented 1 year ago

Was fixed in release 2.0.22 (https://github.com/AdguardTeam/AdGuardVPNExtension/releases/tag/v2.0.22).

ihurin commented 1 year ago

@db-EV hey, what if issue is still repro in the new version in Opera in Incognito mode? CRM 791374