-
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: Added worker script * feat: auto-pat-authentication * chore: Added empty export from the worker file to build as module * fix: Added * in the manifest to resolve prod build error
- Loading branch information
Showing
8 changed files
with
71 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { checkTokenValidity } from "../utils/fetchOpenSaucedApiData"; | ||
import getAccessToken from "../utils/getAccessToken"; | ||
import setAccessTokenInChromeStorage from "../utils/setAccessToken"; | ||
|
||
const processHotOSHomePage = async () => { | ||
const data = await chrome.storage.sync.get(["os-access-token"]); | ||
if (data["os-access-token"]) return; | ||
try { | ||
const accessToken = getAccessToken(); | ||
if (!accessToken) return; | ||
|
||
const isValid = await checkTokenValidity(accessToken); | ||
if (!isValid) return; | ||
|
||
await setAccessTokenInChromeStorage(accessToken); | ||
} catch (error) { | ||
console.error("Error processing Hot home page:", error); | ||
} | ||
}; | ||
|
||
//The local storage takes time to set after the document is idle | ||
setTimeout(processHotOSHomePage, 1000); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const getAccessToken = (): string | null => { | ||
const localStore = window.localStorage.getItem("supabase.auth.token"); | ||
if (localStore === null) return null; | ||
return JSON.parse(localStore)?.currentSession?.access_token; | ||
}; | ||
|
||
export default getAccessToken; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
const setAccessTokenInChromeStorage = (accessToken: string): Promise<void> => { | ||
return new Promise((resolve, reject) => { | ||
chrome.storage.sync.set({ "os-access-token": accessToken }, () => { | ||
if (chrome.runtime.lastError) { | ||
reject(chrome.runtime.lastError); | ||
} else { | ||
resolve(); | ||
} | ||
}); | ||
}); | ||
}; | ||
|
||
export default setAccessTokenInChromeStorage; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
chrome.webRequest.onCompleted.addListener( | ||
(details) => { | ||
chrome.storage.sync.remove("os-access-token"); | ||
}, | ||
{ urls: ["https://ibcwmlhcimymasokhgvn.supabase.co/auth/v1/logout"] } | ||
); | ||
|
||
export {}; |