From ac3cd6ab6ab65ece93ca2fb52c3818531b13e682 Mon Sep 17 00:00:00 2001
From: Andreas Coroiu <andreas.coroiu@gmail.com>
Date: Fri, 18 Nov 2022 09:47:49 +0100
Subject: [PATCH] [EC-598] feat: scaffold content scripting

---
 apps/browser/src/content/webauthn/content-script.ts | 2 ++
 apps/browser/src/content/webauthn/page-script.ts    | 2 ++
 apps/browser/src/manifest.json                      | 4 +++-
 apps/browser/src/manifest.v3.json                   | 7 ++++++-
 apps/browser/webpack.config.js                      | 2 ++
 5 files changed, 15 insertions(+), 2 deletions(-)
 create mode 100644 apps/browser/src/content/webauthn/content-script.ts
 create mode 100644 apps/browser/src/content/webauthn/page-script.ts

diff --git a/apps/browser/src/content/webauthn/content-script.ts b/apps/browser/src/content/webauthn/content-script.ts
new file mode 100644
index 0000000000..bc3ccbdafe
--- /dev/null
+++ b/apps/browser/src/content/webauthn/content-script.ts
@@ -0,0 +1,2 @@
+// eslint-disable-next-line no-console
+console.log("content-script loaded");
diff --git a/apps/browser/src/content/webauthn/page-script.ts b/apps/browser/src/content/webauthn/page-script.ts
new file mode 100644
index 0000000000..b7281608a7
--- /dev/null
+++ b/apps/browser/src/content/webauthn/page-script.ts
@@ -0,0 +1,2 @@
+// eslint-disable-next-line no-console
+console.log("page-script loaded");
diff --git a/apps/browser/src/manifest.json b/apps/browser/src/manifest.json
index 3730ac6c56..f993c82fb6 100644
--- a/apps/browser/src/manifest.json
+++ b/apps/browser/src/manifest.json
@@ -21,7 +21,8 @@
         "content/autofill.js",
         "content/autofiller.js",
         "content/notificationBar.js",
-        "content/contextMenuHandler.js"
+        "content/contextMenuHandler.js",
+        "content/webauthn/content-script.js"
       ],
       "matches": ["http://*/*", "https://*/*", "file:///*"],
       "run_at": "document_start"
@@ -98,6 +99,7 @@
     }
   },
   "web_accessible_resources": [
+    "content/webauthn/page-script.js",
     "notification/bar.html",
     "images/icon38.png",
     "images/icon38_locked.png"
diff --git a/apps/browser/src/manifest.v3.json b/apps/browser/src/manifest.v3.json
index bbba272c19..8558b7f32f 100644
--- a/apps/browser/src/manifest.v3.json
+++ b/apps/browser/src/manifest.v3.json
@@ -106,7 +106,12 @@
   },
   "web_accessible_resources": [
     {
-      "resources": ["notification/bar.html", "images/icon38.png", "images/icon38_locked.png"],
+      "resources": [
+        "content/webauthn/page-script.js",
+        "notification/bar.html",
+        "images/icon38.png",
+        "images/icon38_locked.png"
+      ],
       "matches": ["<all_urls>"]
     }
   ],
diff --git a/apps/browser/webpack.config.js b/apps/browser/webpack.config.js
index e9224a8919..e089c7a252 100644
--- a/apps/browser/webpack.config.js
+++ b/apps/browser/webpack.config.js
@@ -141,6 +141,8 @@ const mainConfig = {
     "content/notificationBar": "./src/content/notificationBar.ts",
     "content/contextMenuHandler": "./src/content/contextMenuHandler.ts",
     "content/message_handler": "./src/content/message_handler.ts",
+    "content/webauthn/content-script": "./src/content/webauthn/content-script.ts",
+    "content/webauthn/page-script": "./src/content/webauthn/page-script.ts",
     "notification/bar": "./src/notification/bar.js",
     "encrypt-worker": "../../libs/common/src/services/cryptography/encrypt.worker.ts",
   },