fix: auth in extension

This commit is contained in:
Dhravya 2024-03-31 23:22:35 -07:00
parent deab0568df
commit a919affca3
5 changed files with 12 additions and 8 deletions

View file

@ -1,4 +1,6 @@
# Logs
*.zip
logs
*.log
npm-debug.log*

View file

@ -7,7 +7,8 @@
"dev": "vite",
"build": "tsc && vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview"
"preview": "vite preview",
"package": "zip -r extension.zip dist/"
},
"dependencies": {
"@radix-ui/react-tooltip": "^1.0.7",

View file

@ -14,7 +14,7 @@ function App() {
if (loginButton) {
if (jwt) {
fetch('https://anycontext.dhr.wtf/api/me', {
fetch('https://supermemory.dhr.wtf/api/me', {
headers: {
Authorization: `Bearer ${jwt}`,
},
@ -43,7 +43,7 @@ function App() {
<button
onClick={() =>
chrome.tabs.create({
url: 'https://anycontext.dhr.wtf/api/auth/signin',
url: 'https://supermemory.dhr.wtf/api/auth/signin',
})
}
id="login"

View file

@ -17,7 +17,7 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
console.error("No JWT found");
return;
}
fetch("https://anycontext.dhr.wtf/api/store", {
fetch("https://supermemory.dhr.wtf/api/store", {
method: "POST",
headers: {
"Authorization": `Bearer ${jwt}`,
@ -33,7 +33,7 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
const jwt = request.jwt;
(async () => {
await fetch("https://anycontext.dhr.wtf/api/ask", {
await fetch("https://supermemory.dhr.wtf/api/ask", {
method: "POST",
headers: {
"Authorization": `Bearer ${jwt}`,

View file

@ -8,7 +8,8 @@ window.addEventListener('message', (event) => {
if (
!(
window.location.hostname === 'localhost' ||
window.location.hostname.endsWith('dhr.wtf')
window.location.hostname === 'anycontext.dhr.wtf' ||
window.location.hostname === 'supermemory.dhr.wtf'
)
) {
console.log(
@ -35,10 +36,10 @@ import SideBar from './SideBar';
// get JWT from local storage
const jwt = chrome.storage.local.get('jwt').then((data) => {
return data.jwt;
}) as Promise<string>
}) as Promise<string>;
jwt.then((jwt) => {
ReactDOM.createRoot(
document.getElementById('anycontext-app-container')!,
).render(<SideBar jwt={jwt} />);
});
});