How make api calls in a chrome extension with MV3 - google-chrome

I am trying to migrate my chrome extension from MV2 - MV3, The app makes several API calls. When I build and install the extension locally it works fine but when I test the published version of the app... It doesn't make any internet connection. The extension is built using reactJS + parcel v1
Has anyone also faced these issues before, I cannot tell what I am doing wrong?
Here's is my the log of the error I am getting
In the manifest.json I set the host_permission like so
}
...
"host_permissions": [
"https://api.openweathermap.org/data/2.5/onecall",
"https://disease.sh/v3/covid-19/countries/",
"https://type.fit/api/quotes",
"http://ip-api.com/json"
]
...
}

Related

How do I set CryptoTokenExtension to work under HTTP for development work

I am trying to get U2F to work under Chrome. I'm developing so I'd like it if I could connect to my local web server with not HTTPS certificate.
I am running Chrome in OSX
Currently my workflow is
Quit all instances of Google Chrome.
Restart Google Chrome with the --show-component-extension-options command-line flag.
Navigate to chrome://extensions and enable Developer Mode by clicking a checkbox in the top right corner.
Find the CryptoTokenExtension extension.
Click on "background page". This will open a Developer Tools window, including a Console.
In the console, type:
HTTP_ORIGINS_ALLOWED = true;
and it still doesn't work. What step am I missing
Just changing the value won't reregister the extension's manifest.json which has to be patched too:
"externally_connectable": {
"matches": [
"https://*/*"
],
You can manually edit resourse.pak file in any binary/hex editor (not a text editor).
In Windows it's usually in %LocalAppData%\Google\Chrome\Application\xxxxx\resources.pak
Backup the file
Find "fjajfjhkeibgmiggdfehjplbhmfkialk"
Replace the nearby "https://*/*" with     "*://*/*"
Optionally edit HTTP_ORIGINS_ALLOWED
Save and restart Chrome
You can automate this by writing a simple patcher in node.js or any other scripting language.
P.S. Not tested.

I can't uninstall the existing service worker

I have created basic sample application and integrated angular/pwa. In ngsw-config .json file i added datagroups for api call. Now i can able to download the application and api call is working fine in offline too.
After that i moved to my application and did the same for pwa. Now api call is not working in offline. I checked with api call which i used in sample application still i'm getting the data for that url but i didn't specified in ngsw-config.json file.
I can't unregistered my old service worker and create new service worker. In chrome developer tool i unregistered that service worker and again reload my application but still i'm getting the old data.
Angular version: 6.0.2
Browser:
- [ ] Chrome (desktop) version
For Tooling issues:
- Node version: 8.9.1
- Platform: Windows

Google Cloud Function Deployment with firebase deploy: does nothing

While trying to deploy the sample Google Actions Transactions API to Google Cloud Functions using firebase as per the instructions here, I encountered a problem where the firebase deploy --only functions just hanged doing nothing (did not print any error on firebase CLI). the firebase debug logs also did not give a clue of the issue.
Please help.
Thanks!
-Kunal
I found a workaroud for this problem as mentioned here. I am trying to deploy the Google Cloud Function using Firebase from behind a corporate proxy. It appears that Firebase does not read proxy settings from the environment variables. This is an open issue.
Workaround:
Go to (on Windows)
C:\Users\YOUR_USER_NAME\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\firebase\node_modules\faye-websocket\lib\faye\websocket\client.js
And update code to use your proxy server:port-
`var Client = function(_url, protocols, options) {
options = options || {};
options.proxy = {
origin: '**YOUR_PROXY_SERVER:PORT**',
headers: {'User-Agent': 'node'},
}`
This work around can be used in DEV mode until Firebase provides permanent fix.
Enjoy!

Chrome Native Messaging Api not working on Linux

I've been trying to get the official Native Messaging example running on my Debian linux, but when I click the connect button, the connection to the host is not made and the error "Specified native messaging host not found." is returned.
From other people who have the same problem I learnt that it's probably an error in my native app manifest, but I can't find it for hours now. It is located at ~/.config/google-chrome/NativeMessagingHosts/com.google.chrome.example.echo.json and reads:
{
"name": "com.google.chrome.example.echo",
"description": "Chrome Native Messaging API Example Host",
"path": "/path/to/my/home/Desktop/native.py",
"type": "stdio",
"allowed_origins": [
"chrome-extension://mcmmilohkmnlhdododggiegdjholjfan/"
]
}
The only thing's I've changed is the chrome extension id and the path, which I checked (when running it from my shell the app launches and behaves correctly). Its code is taken from the aforementioned example.
Any idea what might be wrong? I'm stumped.
I've found the same to be true on OSX with Chrome 33.0.1750.117.
You have to put it in
/Library/Google/Chrome/NativeMessagingHosts/ and not in user's Library/Google/Chrome/NativeMessagingHosts/ folder.
(I'd comment but my reputation didn't allow it)
Ok, so I dug into the Chrome sources for my version (33.0.1750.117) and figured out that the json file is never read (and confirmed my finding using inotifywatch). I think (judging from this file line 143ff and this file) that the home directory is never actually looked into when the manifest file is searched.
However I came across a command line switch which can be used to locate the manifest files: --native-messaging-hosts="com.google.chrome.example.echo=~/.config/google-chrome/NativeMessagingHosts/com.google.chrome.example.echo.json". Even though this is no permanent solution it works for me, because I don't have root on the machine I'm developing on and can't write to /etc/opt/
https://code.google.com/p/chromium/issues/detail?id=237873
According to this bug the user-level installation will be supported in Chrome-34

Invalid manifest.json but not locally

I made some changes to a Chrome Extension of mine, I updated the manifest.json by changing the extension's version number and, finally, I uploaded it to the Chrome Web Store.
Here is the url.
Now if you try to install it, you'll get an "invalid manifest" error.
The problem here is that I don't either get this error with the locally unpacked version or when I upload the extesion to the Chrome Web Store.
This is the manifest.json