Sign in
Log inSign up
Ákos Kőműves

2 likes

·

1.2K reads

8 comments

Emmanuel Uzoezie
Emmanuel Uzoezie
Dec 6, 2022

Supabase is what I want to get soon, the article will help a lot, thanks for sharing this. Looking forward to learn from it.

1
·
·1 reply
Ákos Kőműves
Ákos Kőműves
Author
·Dec 6, 2022

Happy to hear this Emmanuel, Supabase is great!

·
Richard Bankole
Richard Bankole
Jan 10, 2023

Hi Ákos, thanks for posting this guide!

I wanted to check out the repo directly, but I'm getting a 404 error - can you please share an updated link?

1
·
·1 reply
Ákos Kőműves
Ákos Kőműves
Author
·Jan 11, 2023

The repo was set to private 🙈 Thanks Richard Bankole

·
Emre Demirel
Emre Demirel
Jan 3, 2023

I don't understand how did you handle the session management here. You are using getSession() method from supabase js on your background script but it can't turn anything because supabase can't initialize session on your extension on the background script.

I am using oauth client to login with my background script. I can login but I can't use any other method because supabase can't set session data to chrome.storage.local

Even tho, I explicitly refreshSession on my background script, it returns the new session but doesn't add anywhere. So it disappears in the first browser refresh. How do you keep the extension session live inside your background script? I ask this because there is no info for cross-tab session management inside extensions anywhere in the internet :)

Just because I don't have valid session stored anywhere in my background script, I can't use RLS with supabase-js. Also just because I can't use RLS I can't share my anon_key. Any ideas/opinions on this?

·
·3 replies
Ákos Kőműves
Ákos Kőműves
Author
·Jan 4, 2023

I don't understand how did you handle the session management here. You are using getSession() method from supabase js on your background script but it can't turn anything because supabase can't initialize session on your extension on the background script.

getSession() returns the existing session that's persisted in localStorage after a successful await supabase.auth.signInWithPassword(value); call.

·
Emre Demirel
Emre Demirel
Jan 4, 2023

Ákos Kőműves I know that but here's the problem. localStorage is domain based. So when you switch to different tab for different website, your extension won't persist the session. There has to be an extension wide solution which is only (as far as i imagine) possible with chrome.storage.local

Also, since you can't utilize localStorage, your background script can't use it for JS sdk. Service workers have their own runtime outside of window. If we want to have RLS active and use the database features, it's not possible extension-wide with the current session mechanism.

I wonder how you would solve those problems? I ask because mainly those are the problems that I am trying to solve but there is no proper information anywhere in the internet :)

·
Ákos Kőműves
Ákos Kőműves
Author
·Jan 4, 2023

Emre Demirel this extension is designed to work on blank.org or whatever page you specify in the manifest file.

My other extension tweton.com works only on twitter.com.

I haven't built any extensions that retain data between websites, although it would be possible with chrome.storage.local, it wouldn't work with Firefox.

Luckily supabase's createClient function accepts a 3rd argument where you can specify a custom storage mechanism.

It accepts an object with getItem, setItem, and removeItem.

supabase.com/docs/reference/javascript/ini…

Hope this helps.

·