aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-02-17 11:02:21 -0500
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-02-17 11:02:21 -0500
commit0f46e3a093e7f0c07ad310d8c17e2582bdfd2741 (patch)
tree63318e3ce1ac19a32bc96e29f3b9b9477853993b /ext/bg/js
parentaee16c443195ff8ab2b0f5f5e8551e44895d48a1 (diff)
Use a token to ensure that messages are coming from Yomichan
Diffstat (limited to 'ext/bg/js')
-rw-r--r--ext/bg/js/backend.js9
1 files changed, 8 insertions, 1 deletions
diff --git a/ext/bg/js/backend.js b/ext/bg/js/backend.js
index 458ea483..a4d085e0 100644
--- a/ext/bg/js/backend.js
+++ b/ext/bg/js/backend.js
@@ -46,6 +46,8 @@ class Backend {
this.popupWindow = null;
this.apiForwarder = new BackendApiForwarder();
+
+ this.messageToken = yomichan.generateId(16);
}
async prepare() {
@@ -614,6 +616,10 @@ class Backend {
});
}
+ async _onApiGetMessageToken() {
+ return this.messageToken;
+ }
+
// Command handlers
async _onCommandSearch(params) {
@@ -875,7 +881,8 @@ Backend._messageHandlers = new Map([
['clipboardGet', (self, ...args) => self._onApiClipboardGet(...args)],
['getDisplayTemplatesHtml', (self, ...args) => self._onApiGetDisplayTemplatesHtml(...args)],
['getQueryParserTemplatesHtml', (self, ...args) => self._onApiGetQueryParserTemplatesHtml(...args)],
- ['getZoom', (self, ...args) => self._onApiGetZoom(...args)]
+ ['getZoom', (self, ...args) => self._onApiGetZoom(...args)],
+ ['getMessageToken', (self, ...args) => self._onApiGetMessageToken(...args)]
]);
Backend._commandHandlers = new Map([