import { storageSet } from "../lib/storage" import { processAuthCallback } from "../services/auth" import { client } from "../services/client" const processExternalMessage = ({type, args}: {type: string, args: any}):any => { switch (type) { case 'auth-callback': return processAuthCallback(args) default: throw new Error(`undefined message type: ${type}`) } } chrome.runtime.onMessageExternal.addListener( (request, sender, sendResponse) => { const result = processExternalMessage(request) if (typeof result?.then === 'function') { result.then(sendResponse) return true } else { sendResponse(result) } } );