Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 17 additions & 1 deletion src/background/service-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,13 @@ chrome.action.onClicked.addListener(async (tab) => {
/**
* Handle messages from popup
*/
chrome.runtime.onMessage.addListener((message: ExtensionMessage, _sender, sendResponse) => {
chrome.runtime.onMessage.addListener((message: ExtensionMessage, sender, sendResponse) => {
// Reject messages from other extensions or web pages
if (sender.id !== chrome.runtime.id) {
sendResponse({ success: false, error: 'Unauthorized sender' });
return false;
}

console.log('Message received:', message.type, message.payload);

switch (message.type) {
Expand All @@ -108,12 +114,22 @@ chrome.runtime.onMessage.addListener((message: ExtensionMessage, _sender, sendRe
return true; // Keep channel open for async response

case 'UPLOAD_ASSET':
// Only allow from extension pages, not content scripts
if (sender.tab) {
sendResponse({ success: false, error: 'Unauthorized sender' });
return false;
}
handleAssetUpload(message.payload)
.then(() => sendResponse({ success: true }))
.catch((error) => sendResponse({ success: false, error: error.message }));
return true;

case 'START_GOOGLE_AUTH':
// Only allow from extension pages, not content scripts
if (sender.tab) {
sendResponse({ success: false, error: 'Unauthorized sender' });
return false;
}
console.log('Starting Google Auth in background...');
(async () => {
try {
Expand Down
8 changes: 7 additions & 1 deletion src/offscreen/offscreen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@ interface WatermarkPayload {
}

// Listen for messages from service worker
chrome.runtime.onMessage.addListener((message, _sender, sendResponse) => {
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
// Reject messages from other extensions or web pages
if (sender.id !== chrome.runtime.id) {
sendResponse({ success: false, error: 'Unauthorized sender' });
return false;
}

if (message.type === 'ADD_WATERMARK') {
addWatermark(message.payload)
.then((result) => sendResponse({ success: true, data: result }))
Expand Down