Search code examples
javascriptfirebasegoogle-chrome-extensionsdkextension-methods

Extension getting rejected fore Firebase SDK code


So basically I am developing a chrome extension in manifest v3, it has some various versions (( Some versions are about to be developed )), now in the first version that was for one site, the extension was accepted and published to Chrome Extension but as soon as I pushed updated for the second Version while adding some functionality code, the Chrome Store Team rejected it for using "remotely hosted code", upon inquiring, they gave the following reply.

We would like to let you know that the usage of remote hosted code was found in the service-worker.js file of your code package as it is fetching Google APIs in retrieveRecaptchaToken() function. Hence we request you to include all the remote hosted resources in the code package and re-submit it for review. Your submission will be approved if we find it to be compliant with all our policies.

I'm really confused as I am using rollup extension in order to use Firebase SDK V9 modular code into my codebase and it automatically places that function when I run "npm run dev", is there any help of what to do in this case?

I'm retrieving custom token from my own website whose permission is given in manifest.json and then the user is authenticated through that and we use firestore multiple calls in background as well in order to store data, search data and retrieve data.


Solution

  • Solution: After thoroughly investigating this, I found the solution, there is code in the background that actually uses the remotely hosted code.

    1- After you have compiled your code in webpack or rollup, go to your distribution folder and and open service-worker file, this file would contain alot of code, now you have to search for this.

    return _loadJS(https://apis.google.com/js/api.js?onload=${cbName}) .catch(e => reject(e));

    PS: If you dont find the above code, simply search for return _loadJS and you will most probably find the instance, it only occurs once or twice depending on your function usage in service-worker file. Once found,

    Convert that code into,

    return true;

    The above solution varies from case to case, in my case, I wasn't using this part of code so that's why converted it into return true as it was never called but due to the .js presence, chrome store would not approve it.

    Let me know if you face any issue, would be happy to respond in comments.