LoginSignup
1
0

Chrome拡張機能でFirebase Authenticationを使うとストア公開できない件を解消(暫定対応)

Last updated at Posted at 2023-10-08

ある時からストア公開申請が否認されるようになった

すでにストア上で公開されているChrome拡張機能に軽微なアップデートを施して公開申請したところ、急に否認されるようになった。

Hi there,

We regret to inform you that the most recent submission of your item was rejected. Please find the details below.

Item name: XXXXXXXXXXXXXXXX

Item ID: XXXXXXXXXXXXXXXX

Violation(s):

Violation reference ID: Blue Argon

Technical Requirements - Additional Requirements for Manifest V3:

Violation: Including remotely hosted code in a Manifest V3 item.
How to rectify: Ensure that all logic related to the extensions operation is included in the extension package.
Relevant section of the program policy:
Extensions using Manifest V3 must meet additional requirements related to the extension's code. Specifically, the full functionality of an extension must be easily discernible from its submitted code. (learn more)

問い合わせてみた

この否認理由に抵触ようなアップデート内容ではなかったので、何かの間違いではと思い何度かリトライしたが変わらず。まず問い合わせてみた。

Hello Developer,

Thanks for reaching out to us. We understand your concern and will help you with the same.

We have reviewed your extension and observed that it is not in compliance with our Remote Hosted Code policy.

Please find details of the violation in your item below.

Item name : XXXXXXXXXXXXXXXX

Item ID : XXXXXXXXXXXXXXXX

Remote Hosted Code :

Violation : Including remotely hosted code resources in a manifest v3 item.
The usage of remote hosted code was found in the background.bundle.js, contentScript.bundle.js and popup.bundle.js files of your code package fetching code from GoogleAPIs.
Corrective action : Ensure that all scripts referenced or injected are contained within the extension package. Please refer to the link.

要するに(原因)

  • Remotely hosted code (外部サーバーなどにホスティングされたコード)をダウンロードして挿入して実行してはいけない。
    • これを容認すると、審査を回避して任意のコードを実行できてしまい、審査の意味が無くなってしまう。
    • つい最近まではこれを利用して審査を掻い潜ることができていたらしいが、ついに厳しくなったよう。
  • GoogleAPIs を利用している部分に原因があるらしい。
    • 検索したところ、 firebase/auth 内部に外部スクリプトを実行する処理が含まれているらしい。 cf. 同じく困っている人のGitHub Issue
    • これを解消すれば良さそう!
  • 急に否認されるようになったのは、恐らく審査基準が変わったから(?)

よくある解決策(スマートではないのでNG)

HTMLの <script> でCDNなどから読み込めばOK。
色々な記事でこの方法が紹介されていましたが、以下の理由からどうしても避けたかった。

スマートではない理由

  1. まず、この記事にもある通り、外部サーバーとのコミュニケーションやサービスロジックはbackgroundへまとめ、DOM操作などをpopupやcontent_scriptへまとめて分離すべきとされています。
  2. なので firebase/auth の処理はbackground内で実装すべき。しかし、backgroundはMV3からservice_workerなのでHTMLを利用できない。
  3. やるとしたら、popup.htmlやcontent_script.htmlで実装するしかない。1に反する。
  4. 全く同じJavaScriptをpopup.htmlとcontent_script.htmlの両方で重複読み込みすることにもなる。

以前(MV2)まではbackgroundもHTMLで読み込む仕様だったため、悪くない手段だったらしい。

採用した解決策(暫定対応)

このIssueコメントにある通り、 firebase/auth 自体を修正する。
もちろんライブラリ自体を修正するのが悪手ということは理解した上で、暫定対応としてこの方法を採用することにしました。
(少ない修正で済むし、Chrome Web StoreもFirebaseもGoogleサービスということで、その内解消されるのではないか、という淡い期待もありつつ)

注意点

firebase をアップデートする際にパッチの修正も要確認。

手順

  1. https://github.com/XchHarutyunyan/firebase-patch-fix-blue_argon
    これの通りにpatch-packageを設定。
  2. npm run postinstall
  3. webpackなどのバンドラでコンパイルしている場合、生成されたbackground.jsなどのファイル内に https://www.google.com/recaptcha/enterprise.js が含まれていなければ修正できている。

結果🎉

Hi there,

Congratulations! The following item that you submitted for review has been successfully published to the Chrome Web Store:

Item ID: XXXXXXXXXXXXXXXX
Item Name: XXXXXXXXXXXXXXXX
Item Type: extension
Version: 1.2.3
Visibility: Public
Link to Published Item: Link

あとは firebase/auth の恒久対応を待つばかり🙏

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0